Index: /tags/3.1/index.php
===================================================================
--- /tags/3.1/index.php	(revision 17487)
+++ /tags/3.1/index.php	(revision 17487)
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Front to the WordPress application. This file doesn't do anything, but loads
+ * wp-blog-header.php which does and tells WordPress to load the theme.
+ *
+ * @package WordPress
+ */
+
+/**
+ * Tells WordPress to load the WordPress theme and output it.
+ *
+ * @var bool
+ */
+define('WP_USE_THEMES', true);
+
+/** Loads the WordPress Environment and Template */
+require('./wp-blog-header.php');
+?>
Index: /tags/3.1/license.txt
===================================================================
--- /tags/3.1/license.txt	(revision 17487)
+++ /tags/3.1/license.txt	(revision 17487)
@@ -0,0 +1,288 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc. 
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+
+WRITTEN OFFER
+
+The source code for any program binaries or compressed scripts that are
+included with WordPress can be freely obtained at the following URL:
+
+	http://wordpress.org/download/source/
Index: /tags/3.1/readme.html
===================================================================
--- /tags/3.1/readme.html	(revision 17487)
+++ /tags/3.1/readme.html	(revision 17487)
@@ -0,0 +1,109 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<title>WordPress &#8250; ReadMe</title>
+	<link rel="stylesheet" href="wp-admin/css/install.css?ver=20100228" type="text/css" />
+</head>
+<body>
+<h1 id="logo">
+	<a href="http://wordpress.org/"><img alt="WordPress" src="wp-admin/images/wordpress-logo.png" width="250" height="68" /></a>
+	<br /> Version 3.1
+</h1>
+<p style="text-align: center">Semantic Personal Publishing Platform</p>
+
+<h1>First Things First</h1>
+<p>Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I'm proud to be a part of. Thousands of hours have gone into WordPress, and we're dedicated to making it better every day. Thank you for making it part of your world.</p>
+<p style="text-align: right">&#8212; Matt Mullenweg</p>
+
+<h1>Installation: Famous 5-minute install</h1>
+<ol>
+	<li>Unzip the package in an empty directory and upload everything.</li>
+	<li>Open <span class="file"><a href="wp-admin/install.php">wp-admin/install.php</a></span> in your browser. It will take you through the process to set up a <code>wp-config.php</code> file with your database connection details.
+		<ol>
+			<li>If for some reason this doesn't work, don't worry. It doesn't work on all web hosts. Open up <code>wp-config-sample.php</code> with a text editor like WordPad or similar and fill in your database connection details.</li>
+			<li>Save the file as <code>wp-config.php</code> and upload it.</li>
+			<li>Open <span class="file"><a href="wp-admin/install.php">wp-admin/install.php</a></span> in your browser.</li>
+		</ol>
+	</li>
+	<li>Once the configuration file is set up, the installer will set up the tables needed for your blog. If there is an error, double check your <code>wp-config.php</code> file, and try again. If it fails again, please go to the <a href="http://wordpress.org/support/" title="WordPress support">support forums</a> with as much data as you can gather.</li>
+	<li><strong>If you did not enter a password, note the password given to you.</strong> If you did not provide a username, it will be <code>admin</code>.</li>
+	<li>The installer should then send you to the <a href="wp-login.php">login page</a>. Sign in with the username and password you chose during the installation. If a password was generated for you, you can then click on 'Profile' to change the password.</li>
+</ol>
+
+<h1>Updating</h1>
+<h2>Using the Automatic Updater</h2>
+<p>If you are updating from version 2.7 or higher, you can use the automatic updater:</p>
+<ol>
+	<li>Open the <span class="file"><a href="wp-admin/update-core.php">wp-admin/update-core.php</a></span> in your browser and follow the instructions.</li>
+	<li>You wanted more, perhaps? That's it!</li>
+</ol>
+
+<h2>Updating Manually</h2>
+<ol>
+	<li>Before you update anything, make sure you have backup copies of any files you may have modified such as <code>index.php</code>.</li>
+	<li>Delete your old WordPress files, saving ones you've modified.</li>
+	<li>Upload the new files.</li>
+	<li>Point your browser to <span class="file"><a href="wp-admin/upgrade.php">/wp-admin/upgrade.php</a>.</span></li>
+</ol>
+
+<h2>Theme Template Changes</h2>
+<p>If you have customized your theme templates, you may have to make some changes across major versions.</p>
+
+<h1>Migrating from other systems</h1>
+<p>WordPress can <a href="http://codex.wordpress.org/Importing_Content">import from a number of systems</a>. First you need to get WordPress installed and working as described above, before using <a href="wp-admin/import.php" title="Import to WordPress">our import tools</a>.</p>
+
+<h1>System Requirements</h1>
+<ul>
+	<li><a href="http://php.net/">PHP</a> version <strong>4.3</strong> or higher.</li>
+	<li><a href="http://www.mysql.com/">MySQL</a> version <strong>4.1.2</strong> or higher.</li>
+</ul>
+
+<h2>System Recommendations</h2>
+<ul>
+	<li>The <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">mod_rewrite</a> Apache module.</li>
+	<li>A link to <a href="http://wordpress.org/">http://wordpress.org</a> on your site.</li>
+</ul>
+
+<h1>Online Resources</h1>
+<p>If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:</p>
+<dl>
+	<dt><a href="http://codex.wordpress.org/">The WordPress Codex</a></dt>
+		<dd>The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available.</dd>
+	<dt><a href="http://wordpress.org/news/">The WordPress Blog</a></dt>
+		<dd>This is where you'll find the latest updates and news related to WordPress. Recent WordPress news appears in your administrative dashboard by default.</dd>
+	<dt><a href="http://planet.wordpress.org/">WordPress Planet</a></dt>
+		<dd>The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web.</dd>
+	<dt><a href="http://wordpress.org/support/">WordPress Support Forums</a></dt>
+		<dd>If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.</dd>
+	<dt><a href="http://codex.wordpress.org/IRC">WordPress <abbr title="Internet Relay Chat">IRC</abbr> Channel</a></dt>
+		<dd>There is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (<a href="irc://irc.freenode.net/wordpress">irc.freenode.net #wordpress</a>)</dd>
+</dl>
+
+<h1><abbr title="eXtensible Markup Language">XML</abbr>-<abbr title="Remote Procedure Call">RPC</abbr> and Atom Interface</h1>
+<p>You can post to your WordPress blog with tools like <a href="http://download.live.com/writer">Windows Live Writer</a>, <a href="http://illuminex.com/ecto/">Ecto</a>, <a href="http://bloggar.com/">w.bloggar</a>, <a href="http://radio.userland.com/">Radio Userland</a> (which means you can use Radio's email-to-blog feature), <a href="http://www.newzcrawler.com/">NewzCrawler</a>, and other tools that support the blogging <abbr title="application programming interface">API</abbr>s! :) You can read more about <a href="http://codex.wordpress.org/XML-RPC_Support"><abbr>XML</abbr>-<abbr>RPC</abbr> support on the Codex</a>.</p>
+
+<h1>Post via Email</h1>
+<p>You can post from an email client! To set this up go to your &quot;Writing&quot; options screen and fill in the connection details for your secret <abbr title="Post Office Protocol version 3">POP3</abbr> account. Then you need to set up <code>wp-mail.php</code> to execute periodically to check the mailbox for new posts. You can do it with <a href="http://en.wikipedia.org/wiki/Cron">cron</a>-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your <code>wp-mail.php</code> <abbr title="Uniform Resource Locator">URL</abbr>.</p>
+<p>Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address discrete. The script will <em>delete</em> emails that are successfully posted.</p>
+
+<h1>User Roles</h1>
+<p>We introduced a very flexible roles system in version 2.0. You can <a href="http://codex.wordpress.org/Roles_and_Capabilities" title="WordPress roles and capabilities">read more about Roles and Capabilities on the Codex</a>.</p>
+
+<h1>Final Notes</h1>
+<ul>
+	<li>If you have any suggestions, ideas, or comments, or if you (gasp!) found a bug, join us in the <a href="http://wordpress.org/support/">Support Forums</a>.</li>
+	<li>WordPress has a robust plugin <abbr title="application programming interface">API</abbr> that makes extending the code easy. If you are a developer interested in utilizing this, see the <a href="http://codex.wordpress.org/Plugin_API" title="WordPress plugin API">plugin documentation in the Codex</a>. You shouldn't modify any of the core code.</li>
+</ul>
+
+<h1>Share the Love</h1>
+<p>WordPress has no multi-million dollar marketing campaign or celebrity sponsors, but we do have something even better&#8212;you. If you enjoy WordPress please consider telling a friend, setting it up for someone less knowledgable than yourself, or writing the author of a media article that overlooks us.</p>
+
+<p>WordPress is the official continuation of <a href="http://cafelog.com/">b2/caf&#233;log</a>, which came from Michel V. The work has been continued by the <a href="http://wordpress.org/about/">WordPress developers</a>. If you would like to support WordPress, please consider <a href="http://wordpress.org/donate/" title="Donate to WordPress">donating</a>.</p>
+
+<h1>License</h1>
+<p>WordPress is free software, and is released under the terms of the <abbr title="GNU General Public License">GPL</abbr> version 2 or (at your option) any later version. See <a href="license.txt">license.txt</a>.</p>
+
+
+</body>
+</html>
Index: /tags/3.1/wp-activate.php
===================================================================
--- /tags/3.1/wp-activate.php	(revision 17487)
+++ /tags/3.1/wp-activate.php	(revision 17487)
@@ -0,0 +1,102 @@
+<?php
+define( "WP_INSTALLING", true );
+
+/** Sets up the WordPress Environment. */
+require( dirname(__FILE__) . '/wp-load.php' );
+
+require( './wp-blog-header.php' );
+
+if ( !is_multisite() ) {
+	wp_redirect( site_url( '/wp-login.php?action=register' ) );
+	die();
+}
+
+if ( is_object( $wp_object_cache ) )
+	$wp_object_cache->cache_enabled = false;
+
+do_action("activate_header");
+
+function do_activate_header() {
+	do_action("activate_wp_head");
+}
+add_action( 'wp_head', 'do_activate_header' );
+
+function wpmu_activate_stylesheet() {
+	?>
+	<style type="text/css">
+		form { margin-top: 2em; }
+		#submit, #key { width: 90%; font-size: 24px; }
+		#language { margin-top: .5em; }
+		.error { background: #f66; }
+		span.h3 { padding: 0 8px; font-size: 1.3em; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-weight: bold; color: #333; }
+	</style>
+	<?php
+}
+add_action( 'wp_head', 'wpmu_activate_stylesheet' );
+
+get_header();
+?>
+
+<div id="content" class="widecolumn">
+	<?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>
+
+		<h2><?php _e('Activation Key Required') ?></h2>
+		<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">
+			<p>
+			    <label for="key"><?php _e('Activation Key:') ?></label>
+			    <br /><input type="text" name="key" id="key" value="" size="50" />
+			</p>
+			<p class="submit">
+			    <input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e('Activate') ?>" />
+			</p>
+		</form>
+
+	<?php } else {
+
+		$key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
+		$result = wpmu_activate_signup($key);
+		if ( is_wp_error($result) ) {
+			if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
+			    $signup = $result->get_error_data();
+				?>
+				<h2><?php _e('Your account is now active!'); ?></h2>
+				<?php
+				echo '<p class="lead-in">';
+				if ( $signup->domain . $signup->path == '' ) {
+					printf( __('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;.  Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword', 'login' ) );
+				} else {
+					printf( __('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;.  Please check your email inbox at %4$s for your password and login instructions.  If you do not receive an email, please check your junk or spam folder.  If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword' ) );
+				}
+				echo '</p>';
+			} else {
+				?>
+				<h2><?php _e('An error occurred during the activation'); ?></h2>
+				<?php
+			    echo '<p>'.$result->get_error_message().'</p>';
+			}
+		} else {
+			extract($result);
+			$url = get_blogaddress_by_id( (int) $blog_id);
+			$user = new WP_User( (int) $user_id);
+			?>
+			<h2><?php _e('Your account is now active!'); ?></h2>
+
+			<div id="signup-welcome">
+				<p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
+				<p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $password; ?></p>
+			</div>
+
+			<?php if ( $url != network_home_url('', 'http') ) : ?>
+				<p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, $url . 'wp-login.php' ); ?></p>
+			<?php else: ?>
+				<p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url('wp-login.php', 'login'), network_home_url() ); ?></p>
+			<?php endif;
+		}
+	}
+	?>
+</div>
+<script type="text/javascript">
+	var key_input = document.getElementById('key');
+	key_input && key_input.focus();
+</script>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-admin/admin-ajax.php
===================================================================
--- /tags/3.1/wp-admin/admin-ajax.php	(revision 17487)
+++ /tags/3.1/wp-admin/admin-ajax.php	(revision 17487)
@@ -0,0 +1,1475 @@
+<?php
+/**
+ * WordPress AJAX Process Execution.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Executing AJAX process.
+ *
+ * @since 2.1.0
+ */
+define('DOING_AJAX', true);
+define('WP_ADMIN', true);
+
+if ( ! isset( $_REQUEST['action'] ) )
+	die('-1');
+
+require_once('../wp-load.php');
+
+require_once('./includes/admin.php');
+@header('Content-Type: text/html; charset=' . get_option('blog_charset'));
+send_nosniff_header();
+
+do_action('admin_init');
+
+if ( ! is_user_logged_in() ) {
+
+	if ( isset( $_POST['action'] ) && $_POST['action'] == 'autosave' ) {
+		$id = isset($_POST['post_ID'])? (int) $_POST['post_ID'] : 0;
+
+		if ( ! $id )
+			die('-1');
+
+		$message = sprintf( __('<strong>ALERT: You are logged out!</strong> Could not save draft. <a href="%s" target="_blank">Please log in again.</a>'), wp_login_url() );
+		$x = new WP_Ajax_Response( array(
+			'what' => 'autosave',
+			'id' => $id,
+			'data' => $message
+		) );
+		$x->send();
+	}
+
+	if ( !empty( $_REQUEST['action'] ) )
+		do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
+
+	die('-1');
+}
+
+if ( isset( $_GET['action'] ) ) :
+switch ( $action = $_GET['action'] ) :
+case 'fetch-list' :
+
+	$list_class = $_GET['list_args']['class'];
+	check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
+
+	$current_screen = (object) $_GET['list_args']['screen'];
+	//TODO fix this in a better way see #15336
+	$current_screen->is_network = 'false' === $current_screen->is_network ? false : true;
+	$current_screen->is_user = 'false' === $current_screen->is_user ? false : true;
+
+	define( 'WP_NETWORK_ADMIN', $current_screen->is_network );
+	define( 'WP_USER_ADMIN', $current_screen->is_user );
+
+	$wp_list_table = _get_list_table( $list_class );
+	if ( ! $wp_list_table )
+		die( '0' );
+
+	if ( ! $wp_list_table->ajax_user_can() )
+		die( '-1' );
+
+	$wp_list_table->ajax_response();
+
+	die( '0' );
+	break;
+case 'ajax-tag-search' :
+	if ( isset( $_GET['tax'] ) ) {
+		$taxonomy = sanitize_key( $_GET['tax'] );
+		$tax = get_taxonomy( $taxonomy );
+		if ( ! $tax )
+			die( '0' );
+		if ( ! current_user_can( $tax->cap->assign_terms ) )
+			die( '-1' );
+	} else {
+		die('0');
+	}
+
+	$s = stripslashes( $_GET['q'] );
+
+	if ( false !== strpos( $s, ',' ) ) {
+		$s = explode( ',', $s );
+		$s = $s[count( $s ) - 1];
+	}
+	$s = trim( $s );
+	if ( strlen( $s ) < 2 )
+		die; // require 2 chars for matching
+
+	$results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) );
+
+	echo join( $results, "\n" );
+	die;
+	break;
+case 'wp-compression-test' :
+	if ( !current_user_can( 'manage_options' ) )
+		die('-1');
+
+	if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
+		update_site_option('can_compress_scripts', 0);
+		die('0');
+	}
+
+	if ( isset($_GET['test']) ) {
+		header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
+		header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
+		header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
+		header( 'Pragma: no-cache' );
+		header('Content-Type: application/x-javascript; charset=UTF-8');
+		$force_gzip = ( defined('ENFORCE_GZIP') && ENFORCE_GZIP );
+		$test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
+
+		 if ( 1 == $_GET['test'] ) {
+		 	echo $test_str;
+		 	die;
+		 } elseif ( 2 == $_GET['test'] ) {
+			if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) )
+				die('-1');
+			if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
+				header('Content-Encoding: deflate');
+				$out = gzdeflate( $test_str, 1 );
+			} elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
+				header('Content-Encoding: gzip');
+				$out = gzencode( $test_str, 1 );
+			} else {
+				die('-1');
+			}
+			echo $out;
+			die;
+		} elseif ( 'no' == $_GET['test'] ) {
+			update_site_option('can_compress_scripts', 0);
+		} elseif ( 'yes' == $_GET['test'] ) {
+			update_site_option('can_compress_scripts', 1);
+		}
+	}
+
+	die('0');
+	break;
+case 'imgedit-preview' :
+	$post_id = intval($_GET['postid']);
+	if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
+		die('-1');
+
+	check_ajax_referer( "image_editor-$post_id" );
+
+	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
+	if ( ! stream_preview_image($post_id) )
+		die('-1');
+
+	die();
+	break;
+case 'menu-quick-search':
+	if ( ! current_user_can( 'edit_theme_options' ) )
+		die('-1');
+
+	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
+
+	_wp_ajax_menu_quick_search( $_REQUEST );
+
+	exit;
+	break;
+case 'oembed-cache' :
+	$return = ( $wp_embed->cache_oembed( $_GET['post'] ) ) ? '1' : '0';
+	die( $return );
+	break;
+default :
+	do_action( 'wp_ajax_' . $_GET['action'] );
+	die('0');
+	break;
+endswitch;
+endif;
+
+/**
+ * Sends back current comment total and new page links if they need to be updated.
+ *
+ * Contrary to normal success AJAX response ("1"), die with time() on success.
+ *
+ * @since 2.7
+ *
+ * @param int $comment_id
+ * @return die
+ */
+function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
+	$total = (int) @$_POST['_total'];
+	$per_page = (int) @$_POST['_per_page'];
+	$page = (int) @$_POST['_page'];
+	$url = esc_url_raw( @$_POST['_url'] );
+	// JS didn't send us everything we need to know. Just die with success message
+	if ( !$total || !$per_page || !$page || !$url )
+		die( (string) time() );
+
+	$total += $delta;
+	if ( $total < 0 )
+		$total = 0;
+
+	// Only do the expensive stuff on a page-break, and about 1 other time per page
+	if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
+		$post_id = 0;
+		$status = 'total_comments'; // What type of comment count are we looking for?
+		$parsed = parse_url( $url );
+		if ( isset( $parsed['query'] ) ) {
+			parse_str( $parsed['query'], $query_vars );
+			if ( !empty( $query_vars['comment_status'] ) )
+				$status = $query_vars['comment_status'];
+			if ( !empty( $query_vars['p'] ) )
+				$post_id = (int) $query_vars['p'];
+		}
+
+		$comment_count = wp_count_comments($post_id);
+
+		if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count
+			$total = $comment_count->$status;
+			// else use the decremented value from above
+	}
+
+	$time = time(); // The time since the last comment count
+
+	$x = new WP_Ajax_Response( array(
+		'what' => 'comment',
+		'id' => $comment_id, // here for completeness - not used
+		'supplemental' => array(
+			'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ),
+			'total_pages' => ceil( $total / $per_page ),
+			'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),
+			'total' => $total,
+			'time' => $time
+		)
+	) );
+	$x->send();
+}
+
+function _wp_ajax_add_hierarchical_term() {
+	$action = $_POST['action'];
+	$taxonomy = get_taxonomy(substr($action, 4));
+	check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
+	if ( !current_user_can( $taxonomy->cap->edit_terms ) )
+		die('-1');
+	$names = explode(',', $_POST['new'.$taxonomy->name]);
+	$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
+	if ( 0 > $parent )
+		$parent = 0;
+	if ( $taxonomy->name == 'category' )
+		$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
+	else
+		$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
+	$checked_categories = array_map( 'absint', (array) $post_category );
+	$popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
+
+	foreach ( $names as $cat_name ) {
+		$cat_name = trim($cat_name);
+		$category_nicename = sanitize_title($cat_name);
+		if ( '' === $category_nicename )
+			continue;
+		if ( !($cat_id = term_exists($cat_name, $taxonomy->name, $parent)) ) {
+			$new_term = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent));
+			$cat_id = $new_term['term_id'];
+		}
+		$checked_categories[] = $cat_id;
+		if ( $parent ) // Do these all at once in a second
+			continue;
+		$category = get_term( $cat_id, $taxonomy->name );
+		ob_start();
+			wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids ));
+		$data = ob_get_contents();
+		ob_end_clean();
+		$add = array(
+			'what' => $taxonomy->name,
+			'id' => $cat_id,
+			'data' => str_replace( array("\n", "\t"), '', $data),
+			'position' => -1
+		);
+	}
+
+	if ( $parent ) { // Foncy - replace the parent and all its children
+		$parent = get_term( $parent, $taxonomy->name );
+		$term_id = $parent->term_id;
+
+		while ( $parent->parent ) { // get the top parent
+			$parent = &get_term( $parent->parent, $taxonomy->name );
+			if ( is_wp_error( $parent ) )
+				break;
+			$term_id = $parent->term_id;
+		}
+
+		ob_start();
+			wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
+		$data = ob_get_contents();
+		ob_end_clean();
+		$add = array(
+			'what' => $taxonomy->name,
+			'id' => $term_id,
+			'data' => str_replace( array("\n", "\t"), '', $data),
+			'position' => -1
+		);
+	}
+
+	ob_start();
+		wp_dropdown_categories( array(
+			'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',
+			'hierarchical' => 1, 'show_option_none' => '&mdash; '.$taxonomy->labels->parent_item.' &mdash;'
+		) );
+	$sup = ob_get_contents();
+	ob_end_clean();
+	$add['supplemental'] = array( 'newcat_parent' => $sup );
+
+	$x = new WP_Ajax_Response( $add );
+	$x->send();
+}
+
+$id = isset($_POST['id'])? (int) $_POST['id'] : 0;
+switch ( $action = $_POST['action'] ) :
+case 'delete-comment' : // On success, die with time() instead of 1
+	if ( !$comment = get_comment( $id ) )
+		die( (string) time() );
+	if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
+		die('-1');
+
+	check_ajax_referer( "delete-comment_$id" );
+	$status = wp_get_comment_status( $comment->comment_ID );
+
+	$delta = -1;
+	if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
+		if ( 'trash' == $status )
+			die( (string) time() );
+		$r = wp_trash_comment( $comment->comment_ID );
+	} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
+		if ( 'trash' != $status )
+			die( (string) time() );
+		$r = wp_untrash_comment( $comment->comment_ID );
+		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
+			$delta = 1;
+	} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
+		if ( 'spam' == $status )
+			die( (string) time() );
+		$r = wp_spam_comment( $comment->comment_ID );
+	} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
+		if ( 'spam' != $status )
+			die( (string) time() );
+		$r = wp_unspam_comment( $comment->comment_ID );
+		if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
+			$delta = 1;
+	} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
+		$r = wp_delete_comment( $comment->comment_ID );
+	} else {
+		die('-1');
+	}
+
+	if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
+		_wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
+	die( '0' );
+	break;
+case 'delete-tag' :
+	$tag_id = (int) $_POST['tag_ID'];
+	check_ajax_referer( "delete-tag_$tag_id" );
+
+	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
+	$tax = get_taxonomy($taxonomy);
+
+	if ( !current_user_can( $tax->cap->delete_terms ) )
+		die('-1');
+
+	$tag = get_term( $tag_id, $taxonomy );
+	if ( !$tag || is_wp_error( $tag ) )
+		die('1');
+
+	if ( wp_delete_term($tag_id, $taxonomy))
+		die('1');
+	else
+		die('0');
+	break;
+case 'delete-link' :
+	check_ajax_referer( "delete-bookmark_$id" );
+	if ( !current_user_can( 'manage_links' ) )
+		die('-1');
+
+	$link = get_bookmark( $id );
+	if ( !$link || is_wp_error( $link ) )
+		die('1');
+
+	if ( wp_delete_link( $id ) )
+		die('1');
+	else
+		die('0');
+	break;
+case 'delete-meta' :
+	check_ajax_referer( "delete-meta_$id" );
+	if ( !$meta = get_post_meta_by_id( $id ) )
+		die('1');
+
+	if ( !current_user_can( 'edit_post', $meta->post_id ) )
+		die('-1');
+	if ( delete_meta( $meta->meta_id ) )
+		die('1');
+	die('0');
+	break;
+case 'delete-post' :
+	check_ajax_referer( "{$action}_$id" );
+	if ( !current_user_can( 'delete_post', $id ) )
+		die('-1');
+
+	if ( !get_post( $id ) )
+		die('1');
+
+	if ( wp_delete_post( $id ) )
+		die('1');
+	else
+		die('0');
+	break;
+case 'trash-post' :
+case 'untrash-post' :
+	check_ajax_referer( "{$action}_$id" );
+	if ( !current_user_can( 'delete_post', $id ) )
+		die('-1');
+
+	if ( !get_post( $id ) )
+		die('1');
+
+	if ( 'trash-post' == $action )
+		$done = wp_trash_post( $id );
+	else
+		$done = wp_untrash_post( $id );
+
+	if ( $done )
+		die('1');
+
+	die('0');
+	break;
+case 'delete-page' :
+	check_ajax_referer( "{$action}_$id" );
+	if ( !current_user_can( 'delete_page', $id ) )
+		die('-1');
+
+	if ( !get_page( $id ) )
+		die('1');
+
+	if ( wp_delete_post( $id ) )
+		die('1');
+	else
+		die('0');
+	break;
+case 'dim-comment' : // On success, die with time() instead of 1
+
+	if ( !$comment = get_comment( $id ) ) {
+		$x = new WP_Ajax_Response( array(
+			'what' => 'comment',
+			'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id))
+		) );
+		$x->send();
+	}
+
+	if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
+		die('-1');
+
+	$current = wp_get_comment_status( $comment->comment_ID );
+	if ( $_POST['new'] == $current )
+		die( (string) time() );
+
+	check_ajax_referer( "approve-comment_$id" );
+	if ( in_array( $current, array( 'unapproved', 'spam' ) ) )
+		$result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
+	else
+		$result = wp_set_comment_status( $comment->comment_ID, 'hold', true );
+
+	if ( is_wp_error($result) ) {
+		$x = new WP_Ajax_Response( array(
+			'what' => 'comment',
+			'id' => $result
+		) );
+		$x->send();
+	}
+
+	// Decide if we need to send back '1' or a more complicated response including page links and comment counts
+	_wp_ajax_delete_comment_response( $comment->comment_ID );
+	die( '0' );
+	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);
+		$slug = sanitize_title($cat_name);
+		if ( '' === $slug )
+			continue;
+		if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) {
+			$cat_id = wp_insert_term( $cat_name, 'link_category' );
+		}
+		$cat_id = $cat_id['term_id'];
+		$cat_name = esc_html(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='" . esc_attr($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-tag' :
+	check_ajax_referer( 'add-tag' );
+	$post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
+	$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
+	$tax = get_taxonomy($taxonomy);
+
+	if ( !current_user_can( $tax->cap->edit_terms ) )
+		die('-1');
+
+	$x = new WP_Ajax_Response();
+
+	$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
+
+	if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
+		$message = __('An error has occurred. Please reload the page and try again.');
+		if ( is_wp_error($tag) && $tag->get_error_message() )
+			$message = $tag->get_error_message();
+
+		$x->add( array(
+			'what' => 'taxonomy',
+			'data' => new WP_Error('error', $message )
+		) );
+		$x->send();
+	}
+
+	set_current_screen( $_POST['screen'] );
+
+	$wp_list_table = _get_list_table('WP_Terms_List_Table');
+
+	$level = 0;
+	if ( is_taxonomy_hierarchical($taxonomy) ) {
+		$level = count( get_ancestors( $tag->term_id, $taxonomy ) );
+		ob_start();
+		$wp_list_table->single_row( $tag, $level );
+		$noparents = ob_get_clean();
+	}
+
+	ob_start();
+	$wp_list_table->single_row( $tag );
+	$parents = ob_get_clean();
+
+	$x->add( array(
+		'what' => 'taxonomy',
+		'supplemental' => compact('parents', 'noparents')
+		) );
+	$x->add( array(
+		'what' => 'term',
+		'position' => $level,
+		'supplemental' => (array) $tag
+		) );
+	$x->send();
+	break;
+case 'get-tagcloud' :
+	if ( isset( $_POST['tax'] ) ) {
+		$taxonomy = sanitize_key( $_POST['tax'] );
+		$tax = get_taxonomy( $taxonomy );
+		if ( ! $tax )
+			die( '0' );
+		if ( ! current_user_can( $tax->cap->assign_terms ) )
+			die( '-1' );
+	} else {
+		die('0');
+	}
+
+	$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
+
+	if ( empty( $tags ) )
+		die( isset( $tax->no_tagcloud ) ? $tax->no_tagcloud : __('No tags found!') );
+
+	if ( is_wp_error( $tags ) )
+		die( $tags->get_error_message() );
+
+	foreach ( $tags as $key => $tag ) {
+		$tags[ $key ]->link = '#';
+		$tags[ $key ]->id = $tag->term_id;
+	}
+
+	// We need raw tag names here, so don't filter the output
+	$return = wp_generate_tag_cloud( $tags, array('filter' => 0) );
+
+	if ( empty($return) )
+		die('0');
+
+	echo $return;
+
+	exit;
+	break;
+case 'get-comments' :
+	check_ajax_referer( $action );
+
+	set_current_screen( 'edit-comments' );
+
+	$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
+
+	if ( !current_user_can( 'edit_post', $post_id ) )
+		die('-1');
+
+	$wp_list_table->prepare_items();
+
+	if ( !$wp_list_table->has_items() )
+		die('1');
+
+	$comment_list_item = '';
+	$x = new WP_Ajax_Response();
+	foreach ( $wp_list_table->items as $comment ) {
+		get_comment( $comment );
+		ob_start();
+			$wp_list_table->single_row( $comment );
+			$comment_list_item .= ob_get_contents();
+		ob_end_clean();
+	}
+	$x->add( array(
+		'what' => 'comments',
+		'data' => $comment_list_item
+	) );
+	$x->send();
+	break;
+case 'replyto-comment' :
+	check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
+
+	set_current_screen( 'edit-comments' );
+
+	$comment_post_ID = (int) $_POST['comment_post_ID'];
+	if ( !current_user_can( 'edit_post', $comment_post_ID ) )
+		die('-1');
+
+	$status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
+
+	if ( empty($status) )
+		die('1');
+	elseif ( in_array($status, array('draft', 'pending', 'trash') ) )
+		die( __('Error: you are replying to a comment on a draft post.') );
+
+	$user = wp_get_current_user();
+	if ( $user->ID ) {
+		$comment_author       = $wpdb->escape($user->display_name);
+		$comment_author_email = $wpdb->escape($user->user_email);
+		$comment_author_url   = $wpdb->escape($user->user_url);
+		$comment_content      = trim($_POST['content']);
+		if ( current_user_can('unfiltered_html') ) {
+			if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) {
+				kses_remove_filters(); // start with a clean slate
+				kses_init_filters(); // set up the filters
+			}
+		}
+	} else {
+		die( __('Sorry, you must be logged in to reply to a comment.') );
+	}
+
+	if ( '' == $comment_content )
+		die( __('Error: please type a comment.') );
+
+	$comment_parent = absint($_POST['comment_ID']);
+	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
+
+	$comment_id = wp_new_comment( $commentdata );
+	$comment = get_comment($comment_id);
+	if ( ! $comment ) die('1');
+
+	$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
+
+	$x = new WP_Ajax_Response();
+
+	ob_start();
+		if ( 'dashboard' == $_REQUEST['mode'] ) {
+			require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
+			_wp_dashboard_recent_comments_row( $comment );
+		} else {
+			if ( 'single' == $_REQUEST['mode'] ) {
+				$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
+			} else {
+				$wp_list_table = _get_list_table('WP_Comments_List_Table');
+			}
+			$wp_list_table->single_row( $comment );
+		}
+		$comment_list_item = ob_get_contents();
+	ob_end_clean();
+
+	$x->add( array(
+		'what' => 'comment',
+		'id' => $comment->comment_ID,
+		'data' => $comment_list_item,
+		'position' => $position
+	));
+
+	$x->send();
+	break;
+case 'edit-comment' :
+	check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
+
+	set_current_screen( 'edit-comments' );
+
+	$comment_post_ID = (int) $_POST['comment_post_ID'];
+	if ( ! current_user_can( 'edit_post', $comment_post_ID ) )
+		die('-1');
+
+	if ( '' == $_POST['content'] )
+		die( __('Error: please type a comment.') );
+
+	$comment_id = (int) $_POST['comment_ID'];
+	$_POST['comment_status'] = $_POST['status'];
+	edit_comment();
+
+	$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
+	$comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
+
+	$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
+	$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table' );
+
+	ob_start();
+		$wp_list_table->single_row( get_comment( $comment_id ) );
+		$comment_list_item = ob_get_contents();
+	ob_end_clean();
+
+	$x = new WP_Ajax_Response();
+
+	$x->add( array(
+		'what' => 'edit_comment',
+		'id' => $comment->comment_ID,
+		'data' => $comment_list_item,
+		'position' => $position
+	));
+
+	$x->send();
+	break;
+case 'add-menu-item' :
+	if ( ! current_user_can( 'edit_theme_options' ) )
+		die('-1');
+
+	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
+
+	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
+
+	// For performance reasons, we omit some object properties from the checklist.
+	// The following is a hacky way to restore them when adding non-custom items.
+
+	$menu_items_data = array();
+	foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
+		if (
+			! empty( $menu_item_data['menu-item-type'] ) &&
+			'custom' != $menu_item_data['menu-item-type'] &&
+			! empty( $menu_item_data['menu-item-object-id'] )
+		) {
+			switch( $menu_item_data['menu-item-type'] ) {
+				case 'post_type' :
+					$_object = get_post( $menu_item_data['menu-item-object-id'] );
+				break;
+
+				case 'taxonomy' :
+					$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
+				break;
+			}
+
+			$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
+			$_menu_item = array_shift( $_menu_items );
+
+			// Restore the missing menu item properties
+			$menu_item_data['menu-item-description'] = $_menu_item->description;
+		}
+
+		$menu_items_data[] = $menu_item_data;
+	}
+
+	$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
+	if ( is_wp_error( $item_ids ) )
+		die('-1');
+
+	foreach ( (array) $item_ids as $menu_item_id ) {
+		$menu_obj = get_post( $menu_item_id );
+		if ( ! empty( $menu_obj->ID ) ) {
+			$menu_obj = wp_setup_nav_menu_item( $menu_obj );
+			$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
+			$menu_items[] = $menu_obj;
+		}
+	}
+
+	if ( ! empty( $menu_items ) ) {
+		$args = array(
+			'after' => '',
+			'before' => '',
+			'link_after' => '',
+			'link_before' => '',
+			'walker' => new Walker_Nav_Menu_Edit,
+		);
+		echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
+	}
+	break;
+case 'add-meta' :
+	check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' );
+	$c = 0;
+	$pid = (int) $_POST['post_id'];
+	$post = get_post( $pid );
+
+	if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
+		if ( !current_user_can( 'edit_post', $pid ) )
+			die('-1');
+		if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
+			die('1');
+		if ( $post->post_status == 'auto-draft' ) {
+			$save_POST = $_POST; // Backup $_POST
+			$_POST = array(); // Make it empty for edit_post()
+			$_POST['action'] = 'draft'; // Warning fix
+			$_POST['post_ID'] = $pid;
+			$_POST['post_type'] = $post->post_type;
+			$_POST['post_status'] = 'draft';
+			$now = current_time('timestamp', 1);
+			$_POST['post_title'] = sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now));
+
+			if ( $pid = edit_post() ) {
+				if ( is_wp_error( $pid ) ) {
+					$x = new WP_Ajax_Response( array(
+						'what' => 'meta',
+						'data' => $pid
+					) );
+					$x->send();
+				}
+				$_POST = $save_POST; // Now we can restore original $_POST again
+				if ( !$mid = add_meta( $pid ) )
+					die(__('Please provide a custom field value.'));
+			} else {
+				die('0');
+			}
+		} else if ( !$mid = add_meta( $pid ) ) {
+			die(__('Please provide a custom field 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 { // Update?
+		$mid = (int) array_pop( $var_by_ref = array_keys($_POST['meta']) );
+		$key = $_POST['meta'][$mid]['key'];
+		$value = $_POST['meta'][$mid]['value'];
+		if ( '' == trim($key) )
+			die(__('Please provide a custom field name.'));
+		if ( '' == trim($value) )
+			die(__('Please provide a custom field 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 ( $meta->meta_value != stripslashes($value) || $meta->meta_key != stripslashes($key) ) {
+			if ( !$u = update_meta( $mid, $key, $value ) )
+				die('0'); // 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, '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();
+	break;
+case 'add-user' :
+	check_ajax_referer( $action );
+	if ( !current_user_can('create_users') )
+		die('-1');
+	if ( !$user_id = add_user() )
+		die('0');
+	elseif ( is_wp_error( $user_id ) ) {
+		$x = new WP_Ajax_Response( array(
+			'what' => 'user',
+			'id' => $user_id
+		) );
+		$x->send();
+	}
+	$user_object = new WP_User( $user_id );
+
+	$wp_list_table = _get_list_table('WP_Users_List_Table');
+
+	$x = new WP_Ajax_Response( array(
+		'what' => 'user',
+		'id' => $user_id,
+		'data' => $wp_list_table->single_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()
+	define( 'DOING_AUTOSAVE', true );
+
+	$nonce_age = check_ajax_referer( 'autosave', 'autosavenonce' );
+
+	$_POST['post_category'] = explode(",", $_POST['catslist']);
+	if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
+		unset($_POST['post_category']);
+
+	$do_autosave = (bool) $_POST['autosave'];
+	$do_lock = true;
+
+	$data = '';
+	/* translators: draft saved date format, see http://php.net/date */
+	$draft_saved_date_format = __('g:i:s a');
+	/* translators: %s: date and time */
+	$message = sprintf( __('Draft saved at %s.'), date_i18n( $draft_saved_date_format ) );
+
+	$supplemental = array();
+	if ( isset($login_grace_period) )
+		$supplemental['session_expired'] = add_query_arg( 'interim-login', 1, wp_login_url() );
+
+	$id = $revision_id = 0;
+
+	$post_ID = (int) $_POST['post_ID'];
+	$_POST['ID'] = $post_ID;
+	$post = get_post($post_ID);
+	if ( 'auto-draft' == $post->post_status )
+		$_POST['post_status'] = 'draft';
+
+	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.' ),
+			esc_html( $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.'));
+	} else {
+		if ( !current_user_can('edit_post', $post_ID) )
+			die(__('You are not allowed to edit this post.'));
+	}
+
+	if ( $do_autosave ) {
+		// Drafts and auto-drafts are just overwritten by autosave
+		if ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) {
+			$id = edit_post();
+		} else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.
+			$revision_id = wp_create_post_autosave( $post->ID );
+			if ( is_wp_error($revision_id) )
+				$id = $revision_id;
+			else
+				$id = $post->ID;
+		}
+		$data = $message;
+	} else {
+		if ( isset( $_POST['auto_draft'] ) && '1' == $_POST['auto_draft'] )
+			$id = 0; // This tells us it didn't actually save
+		else
+			$id = $post->ID;
+	}
+
+	if ( $do_lock && ( isset( $_POST['auto_draft'] ) && ( $_POST['auto_draft'] != '1' ) ) && $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 'closed-postboxes' :
+	check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
+	$closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed']) : array();
+	$closed = array_filter($closed);
+
+	$hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden']) : array();
+	$hidden = array_filter($hidden);
+
+	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
+
+	if ( !preg_match( '/^[a-z_-]+$/', $page ) )
+		die('-1');
+
+	if ( ! $user = wp_get_current_user() )
+		die('-1');
+
+	if ( is_array($closed) )
+		update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
+
+	if ( is_array($hidden) ) {
+		$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
+		update_user_option($user->ID, "metaboxhidden_$page", $hidden, true);
+	}
+
+	die('1');
+	break;
+case 'hidden-columns' :
+	check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
+	$hidden = isset( $_POST['hidden'] ) ? $_POST['hidden'] : '';
+	$hidden = explode( ',', $_POST['hidden'] );
+	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
+
+	if ( !preg_match( '/^[a-z_-]+$/', $page ) )
+		die('-1');
+
+	if ( ! $user = wp_get_current_user() )
+		die('-1');
+
+	if ( is_array($hidden) )
+		update_user_option($user->ID, "manage{$page}columnshidden", $hidden, true);
+
+	die('1');
+	break;
+case 'menu-get-metabox' :
+	if ( ! current_user_can( 'edit_theme_options' ) )
+		die('-1');
+
+	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
+
+	if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) {
+		$type = 'posttype';
+		$callback = 'wp_nav_menu_item_post_type_meta_box';
+		$items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
+	} elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) {
+		$type = 'taxonomy';
+		$callback = 'wp_nav_menu_item_taxonomy_meta_box';
+		$items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' );
+	}
+
+	if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) {
+		$item = apply_filters( 'nav_menu_meta_box_object', $items[ $_POST['item-object'] ] );
+		ob_start();
+		call_user_func_array($callback, array(
+			null,
+			array(
+				'id' => 'add-' . $item->name,
+				'title' => $item->labels->name,
+				'callback' => $callback,
+				'args' => $item,
+			)
+		));
+
+		$markup = ob_get_clean();
+
+		echo json_encode(array(
+			'replace-id' => $type . '-' . $item->name,
+			'markup' => $markup,
+		));
+	}
+
+	exit;
+	break;
+case 'menu-quick-search':
+	if ( ! current_user_can( 'edit_theme_options' ) )
+		die('-1');
+
+	require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
+
+	_wp_ajax_menu_quick_search( $_REQUEST );
+
+	exit;
+	break;
+case 'wp-link-ajax':
+	require_once ABSPATH . 'wp-admin/includes/internal-linking.php';
+
+	check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' );
+
+	$args = array();
+
+	if ( isset( $_POST['search'] ) )
+		$args['s'] = stripslashes( $_POST['search'] );
+	$args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
+
+	$results = wp_link_query( $args );
+
+	if ( ! isset( $results ) )
+		die( '0' );
+
+	echo json_encode( $results );
+	echo "\n";
+
+	exit;
+	break;
+case 'menu-locations-save':
+	if ( ! current_user_can( 'edit_theme_options' ) )
+		die('-1');
+	check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
+	if ( ! isset( $_POST['menu-locations'] ) )
+		die('0');
+	set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
+	die('1');
+	break;
+case 'meta-box-order':
+	check_ajax_referer( 'meta-box-order' );
+	$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
+	$page_columns = isset( $_POST['page_columns'] ) ? (int) $_POST['page_columns'] : 0;
+	$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
+
+	if ( !preg_match( '/^[a-z_-]+$/', $page ) )
+		die('-1');
+
+	if ( ! $user = wp_get_current_user() )
+		die('-1');
+
+	if ( $order )
+		update_user_option($user->ID, "meta-box-order_$page", $order, true);
+
+	if ( $page_columns )
+		update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
+
+	die('1');
+	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'] : null;
+	die(get_sample_permalink_html($post_id, $title, $slug));
+break;
+case 'inline-save':
+	check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
+
+	if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
+		exit;
+
+	if ( 'page' == $_POST['post_type'] ) {
+		if ( ! current_user_can( 'edit_page', $post_ID ) )
+			die( __('You are not allowed to edit this page.') );
+	} else {
+		if ( ! current_user_can( 'edit_post', $post_ID ) )
+			die( __('You are not allowed to edit this post.') );
+	}
+
+	set_current_screen( $_POST['screen'] );
+
+	if ( $last = wp_check_post_lock( $post_ID ) ) {
+		$last_user = get_userdata( $last );
+		$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
+		printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ),	esc_html( $last_user_name ) );
+		exit;
+	}
+
+	$data = &$_POST;
+
+	$post = get_post( $post_ID, ARRAY_A );
+	$post = add_magic_quotes($post); //since it is from db
+
+	$data['content'] = $post['post_content'];
+	$data['excerpt'] = $post['post_excerpt'];
+
+	// rename
+	$data['user_ID'] = $GLOBALS['user_ID'];
+
+	if ( isset($data['post_parent']) )
+		$data['parent_id'] = $data['post_parent'];
+
+	// status
+	if ( isset($data['keep_private']) && 'private' == $data['keep_private'] )
+		$data['post_status'] = 'private';
+	else
+		$data['post_status'] = $data['_status'];
+
+	if ( empty($data['comment_status']) )
+		$data['comment_status'] = 'closed';
+	if ( empty($data['ping_status']) )
+		$data['ping_status'] = 'closed';
+
+	// update the post
+	edit_post();
+
+	$wp_list_table = _get_list_table('WP_Posts_List_Table');
+
+	$mode = $_POST['post_view'];
+	$wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
+
+	exit;
+	break;
+case 'inline-save-tax':
+	check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
+
+	$taxonomy = sanitize_key( $_POST['taxonomy'] );
+	$tax = get_taxonomy( $taxonomy );
+	if ( ! $tax )
+		die( '0' );
+
+	if ( ! current_user_can( $tax->cap->edit_terms ) )
+		die( '-1' );
+
+	set_current_screen( 'edit-' . $taxonomy );
+
+	$wp_list_table = _get_list_table('WP_Terms_List_Table');
+
+	if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
+		die(-1);
+
+	$tag = get_term( $id, $taxonomy );
+	$_POST['description'] = $tag->description;
+
+	$updated = wp_update_term($id, $taxonomy, $_POST);
+	if ( $updated && !is_wp_error($updated) ) {
+		$tag = get_term( $updated['term_id'], $taxonomy );
+		if ( !$tag || is_wp_error( $tag ) ) {
+			if ( is_wp_error($tag) && $tag->get_error_message() )
+				die( $tag->get_error_message() );
+			die( __('Item not updated.') );
+		}
+
+		echo $wp_list_table->single_row( $tag );
+	} else {
+		if ( is_wp_error($updated) && $updated->get_error_message() )
+			die( $updated->get_error_message() );
+		die( __('Item not updated.') );
+	}
+
+	exit;
+	break;
+case 'find_posts':
+	check_ajax_referer( 'find-posts' );
+
+	if ( empty($_POST['ps']) )
+		exit;
+
+	if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) )
+		$what = $_POST['post_type'];
+	else
+		$what = 'post';
+
+	$s = stripslashes($_POST['ps']);
+	preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
+	$search_terms = array_map('_search_terms_tidy', $matches[0]);
+
+	$searchand = $search = '';
+	foreach ( (array) $search_terms as $term ) {
+		$term = esc_sql( like_escape( $term ) );
+		$search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
+		$searchand = ' AND ';
+	}
+	$term = esc_sql( like_escape( $s ) );
+	if ( count($search_terms) > 1 && $search_terms[0] != $s )
+		$search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')";
+
+	$posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" );
+
+	if ( ! $posts ) {
+		$posttype = get_post_type_object($what);
+		exit($posttype->labels->not_found);
+	}
+
+	$html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__('Date').'</th><th>'.__('Status').'</th></tr></thead><tbody>';
+	foreach ( $posts as $post ) {
+
+		switch ( $post->post_status ) {
+			case 'publish' :
+			case 'private' :
+				$stat = __('Published');
+				break;
+			case 'future' :
+				$stat = __('Scheduled');
+				break;
+			case 'pending' :
+				$stat = __('Pending Review');
+				break;
+			case 'draft' :
+				$stat = __('Draft');
+				break;
+		}
+
+		if ( '0000-00-00 00:00:00' == $post->post_date ) {
+			$time = '';
+		} else {
+			/* translators: date format in table columns, see http://php.net/date */
+			$time = mysql2date(__('Y/m/d'), $post->post_date);
+		}
+
+		$html .= '<tr class="found-posts"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>';
+		$html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat ).'</td></tr>'."\n\n";
+	}
+	$html .= '</tbody></table>';
+
+	$x = new WP_Ajax_Response();
+	$x->add( array(
+		'what' => $what,
+		'data' => $html
+	));
+	$x->send();
+
+	break;
+case 'widgets-order' :
+	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
+
+	if ( !current_user_can('edit_theme_options') )
+		die('-1');
+
+	unset( $_POST['savewidgets'], $_POST['action'] );
+
+	// save widgets order for all sidebars
+	if ( is_array($_POST['sidebars']) ) {
+		$sidebars = array();
+		foreach ( $_POST['sidebars'] as $key => $val ) {
+			$sb = array();
+			if ( !empty($val) ) {
+				$val = explode(',', $val);
+				foreach ( $val as $k => $v ) {
+					if ( strpos($v, 'widget-') === false )
+						continue;
+
+					$sb[$k] = substr($v, strpos($v, '_') + 1);
+				}
+			}
+			$sidebars[$key] = $sb;
+		}
+		wp_set_sidebars_widgets($sidebars);
+		die('1');
+	}
+
+	die('-1');
+	break;
+case 'save-widget' :
+	check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
+
+	if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
+		die('-1');
+
+	unset( $_POST['savewidgets'], $_POST['action'] );
+
+	do_action('load-widgets.php');
+	do_action('widgets.php');
+	do_action('sidebar_admin_setup');
+
+	$id_base = $_POST['id_base'];
+	$widget_id = $_POST['widget-id'];
+	$sidebar_id = $_POST['sidebar'];
+	$multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
+	$settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false;
+	$error = '<p>' . __('An error has occurred. Please reload the page and try again.') . '</p>';
+
+	$sidebars = wp_get_sidebars_widgets();
+	$sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array();
+
+	// delete
+	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
+
+		if ( !isset($wp_registered_widgets[$widget_id]) )
+			die($error);
+
+		$sidebar = array_diff( $sidebar, array($widget_id) );
+		$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
+	} elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
+		if ( !$multi_number )
+			die($error);
+
+		$_POST['widget-' . $id_base] = array( $multi_number => array_shift($settings) );
+		$widget_id = $id_base . '-' . $multi_number;
+		$sidebar[] = $widget_id;
+	}
+	$_POST['widget-id'] = $sidebar;
+
+	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
+
+		if ( $name == $id_base ) {
+			if ( !is_callable( $control['callback'] ) )
+				continue;
+
+			ob_start();
+				call_user_func_array( $control['callback'], $control['params'] );
+			ob_end_clean();
+			break;
+		}
+	}
+
+	if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
+		$sidebars[$sidebar_id] = $sidebar;
+		wp_set_sidebars_widgets($sidebars);
+		echo "deleted:$widget_id";
+		die();
+	}
+
+	if ( !empty($_POST['add_new']) )
+		die();
+
+	if ( $form = $wp_registered_widget_controls[$widget_id] )
+		call_user_func_array( $form['callback'], $form['params'] );
+
+	die();
+	break;
+case 'image-editor':
+	$attachment_id = intval($_POST['postid']);
+	if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
+		die('-1');
+
+	check_ajax_referer( "image_editor-$attachment_id" );
+	include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
+
+	$msg = false;
+	switch ( $_POST['do'] ) {
+		case 'save' :
+			$msg = wp_save_image($attachment_id);
+			$msg = json_encode($msg);
+			die($msg);
+			break;
+		case 'scale' :
+			$msg = wp_save_image($attachment_id);
+			break;
+		case 'restore' :
+			$msg = wp_restore_image($attachment_id);
+			break;
+	}
+
+	wp_image_editor($attachment_id, $msg);
+	die();
+	break;
+case 'set-post-thumbnail':
+	$post_ID = intval( $_POST['post_id'] );
+	if ( !current_user_can( 'edit_post', $post_ID ) )
+		die( '-1' );
+	$thumbnail_id = intval( $_POST['thumbnail_id'] );
+
+	check_ajax_referer( "set_post_thumbnail-$post_ID" );
+
+	if ( $thumbnail_id == '-1' ) {
+		delete_post_meta( $post_ID, '_thumbnail_id' );
+		die( _wp_post_thumbnail_html() );
+	}
+
+	if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
+		die( _wp_post_thumbnail_html( $thumbnail_id ) );
+	die( '0' );
+	break;
+case 'date_format' :
+	die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) );
+	break;
+case 'time_format' :
+	die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
+	break;
+default :
+	do_action( 'wp_ajax_' . $_POST['action'] );
+	die('0');
+	break;
+endswitch;
+?>
Index: /tags/3.1/wp-admin/admin-footer.php
===================================================================
--- /tags/3.1/wp-admin/admin-footer.php	(revision 17487)
+++ /tags/3.1/wp-admin/admin-footer.php	(revision 17487)
@@ -0,0 +1,43 @@
+<?php
+/**
+ * WordPress Administration Template Footer
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+// don't load directly
+if ( !defined('ABSPATH') )
+	die('-1');
+?>
+
+<div class="clear"></div></div><!-- wpbody-content -->
+<div class="clear"></div></div><!-- wpbody -->
+<div class="clear"></div></div><!-- wpcontent -->
+</div><!-- wpwrap -->
+
+<div id="footer">
+<p id="footer-left" class="alignleft"><?php
+do_action( 'in_admin_footer' );
+$upgrade = apply_filters( 'update_footer', '' );
+echo apply_filters( 'admin_footer_text', '<span id="footer-thankyou">' . __('Thank you for creating with <a href="http://wordpress.org/">WordPress</a>.').'</span> | '.__('<a href="http://codex.wordpress.org/">Documentation</a>').' | '.__('<a href="http://wordpress.org/support/forum/4">Feedback</a>') ); ?>
+</p>
+<p id="footer-upgrade" class="alignright"><?php echo $upgrade; ?></p>
+<div class="clear"></div>
+</div>
+<?php
+do_action('admin_footer', '');
+do_action('admin_print_footer_scripts');
+do_action("admin_footer-" . $GLOBALS['hook_suffix']);
+
+// get_site_option() won't exist when auto upgrading from <= 2.7
+if ( function_exists('get_site_option') ) {
+	if ( false === get_site_option('can_compress_scripts') )
+		compression_test();
+}
+
+?>
+
+<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
+</body>
+</html>
Index: /tags/3.1/wp-admin/admin-functions.php
===================================================================
--- /tags/3.1/wp-admin/admin-functions.php	(revision 17487)
+++ /tags/3.1/wp-admin/admin-functions.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Administration Functions
+ *
+ * This file is deprecated, use 'wp-admin/includes/admin.php' instead.
+ *
+ * @deprecated 2.5
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/admin.php' );
+
+/** WordPress Administration API: Includes all Administration functions. */
+require_once(ABSPATH . 'wp-admin/includes/admin.php');
+?>
Index: /tags/3.1/wp-admin/admin-header.php
===================================================================
--- /tags/3.1/wp-admin/admin-header.php	(revision 17487)
+++ /tags/3.1/wp-admin/admin-header.php	(revision 17487)
@@ -0,0 +1,196 @@
+<?php
+/**
+ * WordPress Administration Template Header
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+if ( ! defined( 'WP_ADMIN' ) )
+	require_once( './admin.php' );
+
+get_admin_page_title();
+$title = esc_html( strip_tags( $title ) );
+
+if ( is_network_admin() )
+	$admin_title = __( 'Network Admin' );
+elseif ( is_user_admin() )
+	$admin_title = __( 'Global Dashboard' );
+else
+	$admin_title = get_bloginfo( 'name' );
+
+if ( $admin_title == $title )
+	$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), $title );
+else
+	$admin_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $title, $admin_title );
+
+$admin_title = apply_filters( 'admin_title', $admin_title, $title );
+
+wp_user_settings();
+wp_menu_unfold();
+
+?>
+<!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 echo $admin_title; ?></title>
+<?php
+
+wp_admin_css( 'global' );
+wp_admin_css();
+wp_admin_css( 'colors' );
+wp_admin_css( 'ie' );
+if ( is_multisite() )
+	wp_admin_css( 'ms' );
+wp_enqueue_script('utils');
+
+$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
+?>
+<script type="text/javascript">
+//<![CDATA[
+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();}}};
+var userSettings = {
+		'url': '<?php echo SITECOOKIEPATH; ?>',
+		'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
+		'time':'<?php echo time() ?>'
+	},
+	ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
+	pagenow = '<?php echo $current_screen->id; ?>',
+	typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
+	adminpage = '<?php echo $admin_body_class; ?>',
+	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
+	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
+	isRtl = <?php echo (int) is_rtl(); ?>;
+//]]>
+</script>
+<?php
+
+if ( in_array( $pagenow, array('post.php', 'post-new.php') ) ) {
+	add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
+	add_action( 'admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30 );
+	wp_enqueue_script('quicktags');
+}
+
+do_action('admin_enqueue_scripts', $hook_suffix);
+do_action("admin_print_styles-$hook_suffix");
+do_action('admin_print_styles');
+do_action("admin_print_scripts-$hook_suffix");
+do_action('admin_print_scripts');
+do_action("admin_head-$hook_suffix");
+do_action('admin_head');
+
+if ( get_user_setting('mfold') == 'f' )
+	$admin_body_class .= ' folded';
+
+if ( is_admin_bar_showing() )
+	$admin_body_class .= ' admin-bar';
+
+if ( $is_iphone ) { ?>
+<style type="text/css">.row-actions{visibility:visible;}</style>
+<?php } ?>
+</head>
+<body class="wp-admin no-js <?php echo apply_filters( 'admin_body_class', '' ) . " $admin_body_class"; ?>">
+<script type="text/javascript">
+//<![CDATA[
+(function(){
+var c = document.body.className;
+c = c.replace(/no-js/, 'js');
+document.body.className = c;
+})();
+//]]>
+</script>
+
+<div id="wpwrap">
+<div id="wpcontent">
+<div id="wphead">
+<?php
+
+if ( is_network_admin() )
+	$blog_name = sprintf( __('%s Network Admin'), esc_html($current_site->site_name) );
+elseif ( is_user_admin() )
+	$blog_name = sprintf( __('%s Global Dashboard'), esc_html($current_site->site_name) );
+else
+	$blog_name = get_bloginfo('name', 'display');
+if ( '' == $blog_name ) {
+	$blog_name = __( 'Visit Site' );
+} else {
+	$blog_name_excerpt = wp_html_excerpt($blog_name, 40);
+	if ( $blog_name != $blog_name_excerpt )
+		$blog_name_excerpt = trim($blog_name_excerpt) . '&hellip;';
+	$blog_name = $blog_name_excerpt;
+	unset($blog_name_excerpt);
+}
+$title_class = '';
+if ( function_exists('mb_strlen') ) {
+	if ( mb_strlen($blog_name, 'UTF-8') > 30 )
+		$title_class = 'class="long-title"';
+} else {
+	if ( strlen($blog_name) > 30 )
+		$title_class = 'class="long-title"';
+}
+?>
+
+<img id="header-logo" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" alt="" width="32" height="32" />
+<h1 id="site-heading" <?php echo $title_class ?>>
+	<a href="<?php echo trailingslashit( get_bloginfo( 'url' ) ); ?>" title="<?php esc_attr_e('Visit Site') ?>">
+		<span id="site-title"><?php echo $blog_name ?></span>
+	</a>
+<?php if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ): ?>
+	<a id="privacy-on-link" href="options-privacy.php" title="<?php echo esc_attr( apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') ) ); ?>"><?php echo apply_filters('privacy_on_link_text', __('Search Engines Blocked') ); ?></a>
+<?php endif; ?>
+</h1>
+
+<?php do_action('in_admin_header'); ?>
+
+<div id="wphead-info">
+<div id="user_info">
+<p><?php
+$links = array();
+$links[5] = sprintf(__('Howdy, <a href="%1$s" title="Edit your profile">%2$s</a>'), 'profile.php', $user_identity);
+if ( is_multisite() && is_super_admin() ) {
+	if ( !is_network_admin() )
+		$links[10] = '| <a href="' . network_admin_url() . '" title="' . ( ! empty( $update_title ) ? $update_title : esc_attr__('Network Admin') ) . '">' . __('Network Admin') . ( ! empty( $total_update_count ) ? ' (' . number_format_i18n( $total_update_count ) . ')' : '' ) . '</a>';
+	else
+		$links[10] = '| <a href="' . get_dashboard_url( get_current_user_id() ) . '" title="' . esc_attr__('Site Admin') . '">' . __('Site Admin') . '</a>';
+}
+$links[15] = '| <a href="' . wp_logout_url() . '" title="' . esc_attr__('Log Out') . '">' . __('Log Out') . '</a>';
+
+$links = apply_filters('admin_user_info_links', $links, $current_user);
+ksort($links);
+
+echo implode(' ', $links);
+?></p>
+</div>
+
+<?php favorite_actions($current_screen); ?>
+</div>
+</div>
+
+<div id="wpbody">
+<?php
+unset($title_class, $blog_name, $total_update_count, $update_title);
+
+require(ABSPATH . 'wp-admin/menu-header.php');
+
+$current_screen->parent_file = $parent_file;
+$current_screen->parent_base = preg_replace('/\?.*$/', '', $parent_file);
+$current_screen->parent_base = str_replace('.php', '', $current_screen->parent_base);
+?>
+
+<div id="wpbody-content">
+<?php
+screen_meta($current_screen);
+
+if ( is_network_admin() )
+	do_action('network_admin_notices');
+elseif ( is_user_admin() )
+	do_action('user_admin_notices');
+else
+	do_action('admin_notices');
+
+do_action('all_admin_notices');
+
+if ( $parent_file == 'options-general.php' )
+	require(ABSPATH . 'wp-admin/options-head.php');
Index: /tags/3.1/wp-admin/admin-post.php
===================================================================
--- /tags/3.1/wp-admin/admin-post.php	(revision 17487)
+++ /tags/3.1/wp-admin/admin-post.php	(revision 17487)
@@ -0,0 +1,33 @@
+<?php
+/**
+ * WordPress Administration Generic POST Handler.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** We are located in WordPress Administration Panels */
+define('WP_ADMIN', true);
+
+if ( defined('ABSPATH') )
+	require_once(ABSPATH . 'wp-load.php');
+else
+	require_once('../wp-load.php');
+
+require_once(ABSPATH . 'wp-admin/includes/admin.php');
+
+nocache_headers();
+
+do_action('admin_init');
+
+$action = 'admin_post';
+
+if ( !wp_validate_auth_cookie() )
+	$action .= '_nopriv';
+
+if ( !empty($_REQUEST['action']) )
+	$action .= '_' . $_REQUEST['action'];
+
+do_action($action);
+
+?>
Index: /tags/3.1/wp-admin/admin.php
===================================================================
--- /tags/3.1/wp-admin/admin.php	(revision 17487)
+++ /tags/3.1/wp-admin/admin.php	(revision 17487)
@@ -0,0 +1,238 @@
+<?php
+/**
+ * WordPress Administration Bootstrap
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * In WordPress Administration Panels
+ *
+ * @since 2.3.2
+ */
+if ( ! defined('WP_ADMIN') )
+	define('WP_ADMIN', TRUE);
+
+if ( ! defined('WP_NETWORK_ADMIN') )
+	define('WP_NETWORK_ADMIN', FALSE);
+
+if ( ! defined('WP_USER_ADMIN') )
+	define('WP_USER_ADMIN', FALSE);
+
+if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) {
+	define('WP_BLOG_ADMIN', TRUE);
+}
+
+if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') )
+	define('WP_LOAD_IMPORTERS', true);
+
+require_once(dirname(dirname(__FILE__)) . '/wp-load.php');
+
+if ( get_option('db_upgraded') ) {
+	$wp_rewrite->flush_rules();
+	update_option( 'db_upgraded',  false );
+
+	/**
+	 * Runs on the next page load after successful upgrade
+	 *
+	 * @since 2.8
+	 */
+	do_action('after_db_upgrade');
+} elseif ( get_option('db_version') != $wp_db_version ) {
+	if ( !is_multisite() ) {
+		wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))));
+		exit;
+	} elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
+		/**
+		 * On really small MU installs run the upgrader every time,
+		 * else run it less often to reduce load.
+		 *
+		 * @since 2.8.4b
+		 */
+		$c = get_blog_count();
+		if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) {
+			require_once( ABSPATH . WPINC . '/http.php' );
+			$response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) );
+			do_action( 'after_mu_upgrade', $response );
+			unset($response);
+		}
+		unset($c);
+	}
+}
+
+require_once(ABSPATH . 'wp-admin/includes/admin.php');
+
+auth_redirect();
+
+nocache_headers();
+
+// Schedule trash collection
+if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )
+	wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
+
+set_screen_options();
+
+$date_format = get_option('date_format');
+$time_format = get_option('time_format');
+
+wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'text', 'trackback', 'pingback'));
+
+wp_enqueue_script( 'common' );
+wp_enqueue_script( 'jquery-color' );
+
+$editing = false;
+
+if ( isset($_GET['page']) ) {
+	$plugin_page = stripslashes($_GET['page']);
+	$plugin_page = plugin_basename($plugin_page);
+}
+
+if ( isset($_GET['post_type']) )
+	$typenow = sanitize_key($_GET['post_type']);
+else
+	$typenow = '';
+
+if ( isset($_GET['taxonomy']) )
+	$taxnow = sanitize_key($_GET['taxonomy']);
+else
+	$taxnow = '';
+
+if ( WP_NETWORK_ADMIN )
+	require(ABSPATH . 'wp-admin/network/menu.php');
+elseif ( WP_USER_ADMIN )
+	require(ABSPATH . 'wp-admin/user/menu.php');
+else
+	require(ABSPATH . 'wp-admin/menu.php');
+
+if ( current_user_can( 'manage_options' ) )
+	@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );
+
+do_action('admin_init');
+
+if ( isset($plugin_page) ) {
+	if ( !empty($typenow) )
+		$the_parent = $pagenow . '?post_type=' . $typenow;
+	else
+		$the_parent = $pagenow;
+	if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
+		$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
+		// backwards compatibility for plugins using add_management_page
+		if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
+			// There could be plugin specific params on the URL, so we need the whole query string
+			if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
+				$query_string = $_SERVER[ 'QUERY_STRING' ];
+			else
+				$query_string = 'page=' . $plugin_page;
+			wp_redirect( admin_url('tools.php?' . $query_string) );
+			exit;
+		}
+	}
+	unset($the_parent);
+}
+
+$hook_suffix = '';
+if ( isset($page_hook) )
+	$hook_suffix = $page_hook;
+else if ( isset($plugin_page) )
+	$hook_suffix = $plugin_page;
+else if ( isset($pagenow) )
+	$hook_suffix = $pagenow;
+
+set_current_screen();
+
+// Handle plugin admin pages.
+if ( isset($plugin_page) ) {
+	if ( $page_hook ) {
+		do_action('load-' . $page_hook);
+		if (! isset($_GET['noheader']))
+			require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		do_action($page_hook);
+	} else {
+		if ( validate_file($plugin_page) )
+			wp_die(__('Invalid plugin page'));
+
+
+		if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) )
+			wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
+
+		do_action('load-' . $plugin_page);
+
+		if ( !isset($_GET['noheader']))
+			require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
+			include(WPMU_PLUGIN_DIR . "/$plugin_page");
+		else
+			include(WP_PLUGIN_DIR . "/$plugin_page");
+	}
+
+	include(ABSPATH . 'wp-admin/admin-footer.php');
+
+	exit();
+} else if (isset($_GET['import'])) {
+
+	$importer = $_GET['import'];
+
+	if ( ! current_user_can('import') )
+		wp_die(__('You are not allowed to import.'));
+
+	if ( validate_file($importer) ) {
+		wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
+		exit;
+	}
+
+	// Allow plugins to define importers as well
+	if ( !isset($wp_importers) || !isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2])) {
+		if (! file_exists(ABSPATH . "wp-admin/import/$importer.php")) {
+			wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
+			exit;
+		}
+		include(ABSPATH . "wp-admin/import/$importer.php");
+	}
+
+	$parent_file = 'tools.php';
+	$submenu_file = 'import.php';
+	$title = __('Import');
+
+	if (! isset($_GET['noheader']))
+		require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+	require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
+
+	define('WP_IMPORTING', true);
+
+	if ( apply_filters( 'force_filtered_html_on_import', false ) )
+		kses_init_filters();  // Always filter imported data with kses on multisite.
+
+	call_user_func($wp_importers[$importer][2]);
+
+	include(ABSPATH . 'wp-admin/admin-footer.php');
+
+	// Make sure rules are flushed
+	global $wp_rewrite;
+	$wp_rewrite->flush_rules(false);
+
+	exit();
+} else {
+	do_action("load-$pagenow");
+	// Backwards compatibility with old load-page-new.php, load-page.php,
+	// and load-categories.php actions.
+	if ( $typenow == 'page' ) {
+		if ( $pagenow == 'post-new.php' )
+			do_action( 'load-page-new.php' );
+		elseif ( $pagenow == 'post.php' )
+			do_action( 'load-page.php' );
+	}  elseif ( $pagenow == 'edit-tags.php' ) {
+		if ( $taxnow == 'category' )
+			do_action( 'load-categories.php' );
+		elseif ( $taxnow == 'link_category' )
+			do_action( 'load-edit-link-categories.php' );
+	}
+}
+
+if ( !empty($_REQUEST['action']) )
+	do_action('admin_action_' . $_REQUEST['action']);
+
+?>
Index: /tags/3.1/wp-admin/async-upload.php
===================================================================
--- /tags/3.1/wp-admin/async-upload.php	(revision 17487)
+++ /tags/3.1/wp-admin/async-upload.php	(revision 17487)
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Accepts file uploads from swfupload or other asynchronous upload methods.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+define('WP_ADMIN', true);
+
+if ( defined('ABSPATH') )
+	require_once(ABSPATH . 'wp-load.php');
+else
+	require_once('../wp-load.php');
+
+// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
+if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
+	$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
+elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
+	$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
+if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) )
+	$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
+unset($current_user);
+require_once('./admin.php');
+
+header('Content-Type: text/plain; charset=' . get_option('blog_charset'));
+
+if ( !current_user_can('upload_files') )
+	wp_die(__('You do not have permission to upload files.'));
+
+// just fetch the detail form for that attachment
+if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
+	$post = get_post( $id );
+	if ( 'attachment' != $post->post_type )
+		wp_die( __( 'Unknown post type.' ) );
+	$post_type_object = get_post_type_object( 'attachment' );
+	if ( ! current_user_can( $post_type_object->cap->edit_post, $id ) )
+		wp_die( __( 'You are not allowed to edit this item.' ) );
+
+	if ( 2 == $_REQUEST['fetch'] ) {
+		add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
+		echo get_media_item($id, array( 'send' => false, 'delete' => true ));
+	} else {
+		add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
+		echo get_media_item($id);
+	}
+	exit;
+}
+
+check_admin_referer('media-form');
+
+$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
+if ( is_wp_error($id) ) {
+	echo '<div class="error-div">
+	<a class="dismiss" href="#" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">' . __('Dismiss') . '</a>
+	<strong>' . sprintf(__('&#8220;%s&#8221; has failed to upload due to an error'), esc_html($_FILES['async-upload']['name']) ) . '</strong><br />' .
+	esc_html($id->get_error_message()) . '</div>';
+	exit;
+}
+
+if ( $_REQUEST['short'] ) {
+	// short form response - attachment ID only
+	echo $id;
+} else {
+	// long form response - big chunk o html
+	$type = $_REQUEST['type'];
+	echo apply_filters("async_upload_{$type}", $id);
+}
+
+?>
Index: /tags/3.1/wp-admin/comment.php
===================================================================
--- /tags/3.1/wp-admin/comment.php	(revision 17487)
+++ /tags/3.1/wp-admin/comment.php	(revision 17487)
@@ -0,0 +1,289 @@
+<?php
+/**
+ * Comment Management Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
+require_once('./admin.php');
+
+$parent_file = 'edit-comments.php';
+$submenu_file = 'edit-comments.php';
+
+wp_reset_vars( array('action') );
+
+if ( isset( $_POST['deletecomment'] ) )
+	$action = 'deletecomment';
+
+if ( 'cdc' == $action )
+	$action = 'delete';
+elseif ( 'mac' == $action )
+	$action = 'approve';
+
+if ( isset( $_GET['dt'] ) ) {
+	if ( 'spam' == $_GET['dt'] )
+		$action = 'spam';
+	elseif ( 'trash' == $_GET['dt'] )
+		$action = 'trash';
+}
+
+/**
+ * Display error message at bottom of comments.
+ *
+ * @param string $msg Error Message. Assumed to contain HTML and be sanitized.
+ */
+function comment_footer_die( $msg ) {
+	echo "<div class='wrap'><p>$msg</p></div>";
+	include('./admin-footer.php');
+	die;
+}
+
+switch( $action ) {
+
+case 'editcomment' :
+	$title = __('Edit Comment');
+
+	add_contextual_help( $current_screen, '<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' .
+	'<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>' .
+	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+	'<p>' . __( '<a href="http://codex.wordpress.org/Administration_Panels#Comments" target="_blank">Documentation on Comments</a>' ) . '</p>' .
+	'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank" >Support Forums</a>' ) . '</p>'
+	);
+
+	wp_enqueue_script('comment');
+	require_once('./admin-header.php');
+
+	$comment_id = absint( $_GET['c'] );
+
+	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_comment', $comment_id ) )
+		comment_footer_die( __('You are not allowed to edit this comment.') );
+
+	if ( 'trash' == $comment->comment_approved )
+		comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') );
+
+	$comment = get_comment_to_edit( $comment_id );
+
+	include('./edit-form-comment.php');
+
+	break;
+
+case 'delete'  :
+case 'approve' :
+case 'trash'   :
+case 'spam'    :
+
+	$title = __('Moderate Comment');
+
+	$comment_id = absint( $_GET['c'] );
+
+	if ( !$comment = get_comment_to_edit( $comment_id ) ) {
+		wp_redirect( admin_url('edit-comments.php?error=1') );
+		die();
+	}
+
+	if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) {
+		wp_redirect( admin_url('edit-comments.php?error=2') );
+		die();
+	}
+
+	// No need to re-approve/re-trash/re-spam a comment.
+	if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) {
+		wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
+		die();
+ 	}
+
+	require_once('./admin-header.php');
+
+	$formaction    = $action . 'comment';
+	$nonce_action  = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
+	$nonce_action .= $comment_id;
+
+?>
+<div class='wrap'>
+
+<div class="narrow">
+
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<?php
+switch ( $action ) {
+	case 'spam' :
+		$caution_msg = __('You are about to mark the following comment as spam:');
+		$button      = __('Spam Comment');
+		break;
+	case 'trash' :
+		$caution_msg = __('You are about to move the following comment to the Trash:');
+		$button      = __('Trash Comment');
+		break;
+	case 'delete' :
+		$caution_msg = __('You are about to delete the following comment:');
+		$button      = __('Permanently Delete Comment');
+		break;
+	default :
+		$caution_msg = __('You are about to approve the following comment:');
+		$button      = __('Approve Comment');
+		break;
+}
+
+if ( $comment->comment_approved != '0' ) { // if not unapproved
+	$message = '';
+	switch ( $comment->comment_approved ) {
+		case '1' :
+			$message = __('This comment is currently approved.');
+			break;
+		case 'spam' :
+			$message  = __('This comment is currently marked as spam.');
+			break;
+		case 'trash' :
+			$message  = __('This comment is currently in the Trash.');
+			break;
+	}
+	if ( $message )
+		echo '<div class="updated"><p>' . $message . '</p></div>';
+}
+?>
+<p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
+
+<table class="form-table comment-ays">
+<tr class="alt">
+<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>
+<td><?php echo $comment->comment_author_email; ?></td>
+</tr>
+<?php } ?>
+<?php if ( $comment->comment_author_url ) { ?>
+<tr>
+<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"><?php /* translators: field name in comment form */ _ex('Comment', 'noun'); ?></th>
+<td><?php echo $comment->comment_content; ?></td>
+</tr>
+</table>
+
+<p><?php _e('Are you sure you want to do this?'); ?></p>
+
+<form action='comment.php' method='get'>
+
+<table width="100%">
+<tr>
+<td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td>
+<td class="textright"><?php submit_button( $button, 'button' ); ?></td>
+</tr>
+</table>
+
+<?php wp_nonce_field( $nonce_action ); ?>
+<input type='hidden' name='action' value='<?php echo esc_attr($formaction); ?>' />
+<input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' />
+<input type='hidden' name='noredir' value='1' />
+</form>
+
+</div>
+</div>
+<?php
+	break;
+
+case 'deletecomment'    :
+case 'trashcomment'     :
+case 'untrashcomment'   :
+case 'spamcomment'      :
+case 'unspamcomment'    :
+case 'approvecomment'   :
+case 'unapprovecomment' :
+	$comment_id = absint( $_REQUEST['c'] );
+
+	if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
+		check_admin_referer( 'approve-comment_' . $comment_id );
+	else
+		check_admin_referer( 'delete-comment_' . $comment_id );
+
+	$noredir = isset($_REQUEST['noredir']);
+
+	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_comment', $comment->comment_ID ) )
+		comment_footer_die( __('You are not allowed to edit comments on this post.') );
+
+	if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') )
+		$redir = wp_get_referer();
+	elseif ( '' != wp_get_original_referer() && ! $noredir )
+		$redir = wp_get_original_referer();
+	elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
+		$redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
+	else
+		$redir = admin_url('edit-comments.php');
+
+	$redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir );
+
+	switch ( $action ) {
+		case 'deletecomment' :
+			wp_delete_comment( $comment_id );
+			$redir = add_query_arg( array('deleted' => '1'), $redir );
+			break;
+		case 'trashcomment' :
+			wp_trash_comment($comment_id);
+			$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
+			break;
+		case 'untrashcomment' :
+			wp_untrash_comment($comment_id);
+			$redir = add_query_arg( array('untrashed' => '1'), $redir );
+			break;
+		case 'spamcomment' :
+			wp_spam_comment($comment_id);
+			$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
+			break;
+		case 'unspamcomment' :
+			wp_unspam_comment($comment_id);
+			$redir = add_query_arg( array('unspammed' => '1'), $redir );
+			break;
+		case 'approvecomment' :
+			wp_set_comment_status( $comment_id, 'approve' );
+			$redir = add_query_arg( array( 'approved' => 1 ), $redir );
+			break;
+		case 'unapprovecomment' :
+			wp_set_comment_status( $comment_id, 'hold' );
+			$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
+			break;
+	}
+
+	wp_redirect( $redir );
+	die;
+	break;
+
+case 'editedcomment' :
+
+	$comment_id = absint( $_POST['comment_ID'] );
+	$comment_post_id = absint( $_POST['comment_post_ID'] );
+
+	check_admin_referer( 'update-comment_' . $comment_id );
+
+	edit_comment();
+
+	$location = ( empty( $_POST['referredby'] ) ? "edit-comments.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');
+
+?>
Index: /tags/3.1/wp-admin/css/colors-classic-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-classic-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-classic-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+.bar{border-right-color:transparent;border-left-color:#99d;}.plugins .togl{border-right-color:transparent;border-left-color:#ccc;}.post-com-count{background-image:url(../images/bubble_bg-rtl.gif);}.tablenav .tablenav-pages a{background:#eee url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -379px;}#upload-menu li.current{border-right-color:transparent;border-left-color:#448abd;}#adminmenu .wp-submenu .current a.current{background:transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat scroll right -289px;}#adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;}.folded #adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;}#adminmenu li.wp-has-current-submenu .wp-menu-toggle,#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle{background:transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -207px;}#adminmenu .wp-has-current-submenu ul li a.current{background:url(../images/menu-dark-rtl-vs.gif) top right no-repeat!important;}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,#adminmenu .menu-top .current{background:url(../images/menu-bits-rtl-vs.gif?ver=20101117) top right repeat-x;}#adminmenu li.wp-has-current-submenu ul li a{background:url(../images/menu-dark-rtl-vs.gif) bottom right no-repeat!important;}#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle{background:transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat right -207px;}#adminmenu .wp-has-submenu:hover .wp-menu-toggle,#adminmenu .wp-menu-open .wp-menu-toggle{background:transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -109px;}#adminmenu a.wp-has-submenu{background:#eff8ff url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -379px;}#adminmenu .wp-submenu a{background:#fff url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat scroll right -99px;}#adminmenu li.wp-has-current-submenu a.wp-has-submenu{background:#b5b5b5 url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right top;}.meta-box-sortables .postbox:hover .handlediv{background:transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat scroll right -111px;}#favorite-toggle{background:transparent url(../images/fav-arrow-rtl.gif?ver=20100531) no-repeat right -4px;}
Index: /tags/3.1/wp-admin/css/colors-classic-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-classic-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-classic-rtl.dev.css	(revision 17487)
@@ -0,0 +1,78 @@
+.bar {
+	border-right-color: transparent;
+	border-left-color: #99d;
+}
+
+.plugins .togl {
+	border-right-color: transparent;
+	border-left-color: #ccc;
+}
+
+.post-com-count {
+	background-image: url(../images/bubble_bg-rtl.gif);
+}
+.tablenav .tablenav-pages a {
+	background: #eee url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -379px;
+}
+#upload-menu li.current {
+	border-right-color: transparent;
+	border-left-color: #448abd;
+}
+
+#adminmenu .wp-submenu .current a.current {
+	background: transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat scroll  right -289px;
+}
+
+#adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -207px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+	background: url(../images/menu-dark-rtl-vs.gif) top right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu .menu-top .current {
+	background: url(../images/menu-bits-rtl-vs.gif?ver=20101117) top right repeat-x;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+	background: url(../images/menu-dark-rtl-vs.gif) bottom right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat right -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -109px;
+}
+
+#adminmenu a.wp-has-submenu {
+	background: #eff8ff url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right -379px;
+}
+
+#adminmenu .wp-submenu a {
+	background: #fff url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat scroll right -99px;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-submenu {
+	background: #b5b5b5 url(../images/menu-bits-rtl-vs.gif?ver=20101117) repeat-x scroll right top;
+}
+
+.meta-box-sortables .postbox:hover .handlediv {
+	background: transparent url(../images/menu-bits-rtl-vs.gif?ver=20101117) no-repeat scroll right -111px;
+}
+#favorite-toggle {
+	background: transparent url(../images/fav-arrow-rtl.gif?ver=20100531) no-repeat right -4px;
+}
Index: /tags/3.1/wp-admin/css/colors-classic.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-classic.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-classic.css	(revision 17487)
@@ -0,0 +1,1 @@
+html,.wp-dialog{background-color:#fcfcfb;}* html input,* html .widget{border-color:#dfdfdf;}textarea,input[type="text"],input[type="password"],input[type="file"],input[type="button"],input[type="submit"],input[type="reset"],select{border-color:#dfdfdf;background-color:#fff;}kbd,code{background:#eaeaea;}input[readonly]{background-color:#eee;}.find-box-search{border-color:#dfdfdf;background-color:#f1f1f1;}.find-box{background-color:#f1f1f1;}.find-box-inside{background-color:#fff;}a.page-numbers:hover{border-color:#999;}body,#wpbody,.form-table .pre{color:#174f69;}body>#upload-menu{border-bottom-color:#fff;}#postcustomstuff table,#your-profile fieldset,#rightnow,div.dashboard-widget,#dashboard-widgets p.dashboard-widget-links,#replyrow #ed_reply_toolbar input{border-color:#D1E5EE;}#poststuff .inside label.spam,#poststuff .inside label.deleted{color:red;}#poststuff .inside label.waiting{color:orange;}#poststuff .inside label.approved{color:green;}#postcustomstuff table{border-color:#dfdfdf;background-color:#F9F9F9;}#postcustomstuff thead th{background-color:#F1F1F1;}#postcustomstuff table input,#postcustomstuff table textarea{border-color:#dfdfdf;background-color:#fff;}.widefat{border-color:#D1E5EE;background-color:#fff;}div.dashboard-widget-error{background-color:#c43;}div.dashboard-widget-notice{background-color:#cfe1ef;}div.dashboard-widget-submit{border-top-color:#ccc;}div.tabs-panel,.wp-tab-panel,ul.category-tabs li.tabs,ul.add-menu-item-tabs li.tabs,.wp-tab-active{border-color:#dfdfdf;}ul.category-tabs li.tabs,ul.add-menu-item-tabs li.tabs,.wp-tab-active{background-color:#f1f1f1;}input.disabled,textarea.disabled{background-color:#ccc;}#plugin-information .action-button a,#plugin-information .action-button a:hover,#plugin-information .action-button a:visited{color:#fff;}.widget .widget-top,.postbox h3,.stuffbox h3{background:#cfdfe9 url("../images/blue-grad.png?ver=20101102") repeat-x left top;text-shadow:#fff 0 1px 0;}.form-table th,.form-wrap label{color:#222;text-shadow:#fff 0 1px 0;}.description,.form-wrap p{color:#666;}strong .post-com-count span{background-color:#21759b;}.sorthelper{background-color:#ccf3fa;}.ac_match,.subsubsub a.current{color:#000;}.wrap h2{color:#174f69;}.ac_over{background-color:#f0f0b8;}.ac_results{background-color:#fff;border-color:#808080;}.ac_results li{color:#101010;}.alternate,.alt{background-color:#F8F7F3;}.available-theme a.screenshot{background-color:#f1f1f1;border-color:#ddd;}.bar{background-color:#e8e8e8;border-right-color:#99d;}#media-upload,#media-upload .media-item .slidetoggle{background:#fff;}#media-upload .slidetoggle{border-top-color:#dfdfdf;}div.error,.login #login_error{background-color:#ffebe8;border-color:#c00;}div.error a{color:#c00;}.form-invalid{background-color:#ffebe8!important;}.form-invalid input,.form-invalid select{border-color:#c00!important;}.submit{border-color:#DFDFDF;}.highlight{background-color:#e4f2fd;color:#000;}.howto,.nonessential,#edit-slug-box,.form-input-tip,.rss-widget span.rss-date,.subsubsub{color:#666;}.media-item{border-bottom-color:#dfdfdf;}#wpbody-content #media-items .describe{border-top-color:#dfdfdf;}.media-upload-form label.form-help,td.help{color:#9a9a9a;}.post-com-count{background-image:url(../images/bubble_bg.gif);color:#fff;}.post-com-count span{background-color:#bbb;color:#fff;}.post-com-count:hover span{background-color:#d54e21;}.quicktags,.search{background-color:#ccc;color:#000;}.side-info h5{border-bottom-color:#dadada;}.side-info ul{color:#666;}.button,.button-secondary,.submit input,input[type=button],input[type=submit]{border-color:#bbb;color:#464646;}.button:hover,.button-secondary:hover,.submit input:hover,input[type=button]:hover,input[type=submit]:hover{color:#000;border-color:#666;}.button,.submit input,.button-secondary{background:#f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;text-shadow:rgba(255,255,255,1) 0 1px 0;}.button:active,.submit input:active,.button-secondary:active{background:#eee url(../images/white-grad-active.png) repeat-x scroll left top;}input.button-primary,button.button-primary,a.button-primary{border-color:#298cba;font-weight:bold;color:#fff;background:#21759B url(../images/button-grad.png) repeat-x scroll left top;text-shadow:rgba(0,0,0,0.3) 0 -1px 0;}input.button-primary:active,button.button-primary:active,a.button-primary:active{background:#21759b url(../images/button-grad-active.png) repeat-x scroll left top;color:#eaf2fa;}input.button-primary:hover,button.button-primary:hover,a.button-primary:hover,a.button-primary:focus,a.button-primary:active{border-color:#13455b;color:#eaf2fa;}.button-disabled,.button[disabled],.button:disabled,.button-secondary[disabled],.button-secondary:disabled,a.button.disabled{color:#aaa!important;border-color:#ddd!important;}.button-primary-disabled,.button-primary[disabled],.button-primary:disabled{color:#9FD0D5!important;background:#298CBA!important;}a:hover,a:active,a:focus{color:#d54e21;}#wphead #viewsite a:hover,#adminmenu a:hover,#adminmenu ul.wp-submenu a:hover,#the-comment-list .comment a:hover,#rightnow a:hover,#media-upload a.del-link:hover,div.dashboard-widget-submit input:hover,.subsubsub a:hover,.subsubsub a.current:hover,.ui-tabs-nav a:hover,.plugins .inactive a:hover,#all-plugins-table .plugins .inactive a:hover,#search-plugins-table .plugins .inactive a:hover{color:#d54e21;}#the-comment-list .comment-item,#dashboard-widgets #dashboard_quick_press form p.submit{border-color:#dfdfdf;}#side-sortables .category-tabs .tabs a,#side-sortables .add-menu-item-tabs .tabs a,.wp-tab-bar .wp-tab-active a{color:#333;}#rightnow .rbutton{background-color:#ebebeb;color:#264761;}.submitbox .submit{background-color:#464646;color:#ccc;}.plugins a.delete:hover,#all-plugins-table .plugins a.delete:hover,#search-plugins-table .plugins a.delete:hover,.submitbox .submitdelete{color:#f00;border-bottom-color:#f00;}.submitbox .submitdelete:hover,#media-items a.delete:hover{color:#fff;background-color:#f00;border-bottom-color:#f00;}#normal-sortables .submitbox .submitdelete:hover{color:#000;background-color:#f00;border-bottom-color:#f00;}.tablenav .dots{border-color:transparent;}.tablenav .next,.tablenav .prev{border-color:transparent;color:#21759b;}.tablenav .next:hover,.tablenav .prev:hover{border-color:transparent;color:#d54e21;}div.updated,.login .message{background-color:#ffffe0;border-color:#e6db55;}.update-message{color:#000;}a.page-numbers{border-bottom-color:#B8D3E2;}.commentlist li{border-bottom-color:#ccc;}.widefat td,.widefat th{border-color:#dfdfdf;}.widefat th{text-shadow:rgba(255,255,255,0.8) 0 1px 0;}.widefat thead tr th,.widefat tfoot tr th,h3.dashboard-widget-title,h3.dashboard-widget-title span,h3.dashboard-widget-title small,.find-box-head{color:#333;background:#cfdfe9 url(../images/blue-grad.png?ver=20101102) repeat-x scroll left top;}th.sortable a:hover,th.sortable a:active,th.sortable a:focus{color:#333;}h3.dashboard-widget-title small a{color:#d7d7d7;}h3.dashboard-widget-title small a:hover{color:#fff;}a,#adminmenu a,#poststuff #edButtonPreview,#poststuff #edButtonHTML,#the-comment-list p.comment-author strong a,#media-upload a.del-link,#media-items a.delete,.plugins a.delete,.ui-tabs-nav a{color:#21759b;}#adminmenu #awaiting-mod,#adminmenu .update-plugins,#sidemenu a .update-plugins,#rightnow .reallynow{background-color:#464646;color:#fff;-moz-box-shadow:#fff 0 -1px 0;-khtml-box-shadow:#fff 0 -1px 0;-webkit-box-shadow:#fff 0 -1px 0;box-shadow:#fff 0 -1px 0;}#plugin-information .action-button{background-color:#d54e21;color:#fff;}#adminmenu li.current a #awaiting-mod,#adminmenu li a.wp-has-current-submenu .update-plugins{background-color:#464646;color:#fff;-moz-box-shadow:#fff 0 -1px 0;-khtml-box-shadow:#fff 0 -1px 0;-webkit-box-shadow:#fff 0 -1px 0;box-shadow:#fff 0 -1px 0;}div#media-upload-header,div#plugin-information-header{background-color:#f9f9f9;border-bottom-color:#dfdfdf;}#currenttheme img{border-color:#666;}#dashboard_secondary div.dashboard-widget-content ul li a{background-color:#f9f9f9;}input.readonly,textarea.readonly{background-color:#ddd;}#ed_toolbar input,#ed_reply_toolbar input{background:#fff url("../images/fade-butt.png") repeat-x 0 -2px;}#editable-post-name{background-color:#fffbcc;}#edit-slug-box strong,.tablenav .displaying-num,#submitted-on,.submitted-on{color:#777;}.login #nav a{color:#21759b!important;}.login #nav a:hover{color:#d54e21!important;}#footer{color:#777;border-color:#b0c8d7;background:#cfdfe9;background:-moz-linear-gradient(bottom,#cfdfe9,#eff8ff);background:-webkit-gradient(linear,left bottom,left top,from(#cfdfe9),to(#eff8ff));}#media-items,.imgedit-group{border-color:#dfdfdf;}.checkbox,.side-info,.plugins tr,#your-profile #rich_editing{background-color:#fff;}.plugins .inactive,.plugins .inactive th,.plugins .inactive td,tr.inactive+tr.plugin-update-tr .plugin-update{background-color:#efede7;}.plugin-update-tr .update-message{background-color:#fffbe4;border-color:#dfdfdf;}.plugins .active,.plugins .active th,.plugins .active td{color:#000;}.plugins .inactive a{color:#579;}#the-comment-list tr.undo,#the-comment-list div.undo{background-color:#f4f4f4;}#the-comment-list .unapproved{background-color:#ffffe0;}#the-comment-list .approve a{color:#006505;}#the-comment-list .unapprove a{color:#d98500;}table.widefat span.delete a,table.widefat span.trash a,table.widefat span.spam a,#dashboard_recent_comments .delete a,#dashboard_recent_comments .trash a,#dashboard_recent_comments .spam a{color:#bc0b0b;}.widget,#widget-list .widget-top,.postbox,#titlediv,#poststuff .postarea,.stuffbox{border-color:#D1E5EE;}.widget,.postbox{background-color:#fff;}.ui-sortable .postbox h3{color:#174f69;}.widget .widget-top,.ui-sortable .postbox h3:hover{color:#174f69;}.curtime #timestamp{background-image:url(../images/date-button.gif);}#quicktags #ed_link{color:#00f;}#rightnow .youhave{background-color:#f0f6fb;}#rightnow a{color:#448abd;}.tagchecklist span a,#bulk-titles div a{background:url(../images/xit.gif) no-repeat;}.tagchecklist span a:hover,#bulk-titles div a:hover{background:url(../images/xit.gif) no-repeat -10px 0;}#update-nag,.update-nag{background-color:#FFFBCC;border-color:#E6DB55;color:#555;}.login #backtoblog a{color:#464646;}#wphead{border-bottom:#b0c8d7 1px solid;background:#cfdfe9;background:-moz-linear-gradient(bottom,#cfdfe9,#eff8ff);background:-webkit-gradient(linear,left bottom,left top,from(#cfdfe9),to(#eff8ff));}#wphead h1 a{color:#174f69;}#user_info{color:#777;}#user_info a:link,#user_info a:visited,#footer a:link,#footer a:visited{color:#174f69;text-decoration:none;}#user_info a:hover,#footer a:hover{color:#000;text-decoration:underline!important;}div#media-upload-error,.file-error,abbr.required,.widget-control-remove:hover,table.widefat .delete a:hover,table.widefat .trash a:hover,table.widefat .spam a:hover,#dashboard_recent_comments .delete a:hover,#dashboard_recent_comments .trash a:hover #dashboard_recent_comments .spam a:hover{color:#f00;}#pass-strength-result{background-color:#eee;border-color:#ddd!important;}#pass-strength-result.bad{background-color:#ffb78c;border-color:#ff853c!important;}#pass-strength-result.good{background-color:#ffec8b;border-color:#fc0!important;}#pass-strength-result.short{background-color:#ffa0a0;border-color:#f04040!important;}#pass-strength-result.strong{background-color:#c3ff88;border-color:#8dff1c!important;}#quicktags{border-color:#cfdfe9;background-color:#cfdfe9;background-image:url("../images/ed-bg-vs.gif?ver=20101102");}#ed_toolbar input{border-color:#C3C3C3;}#ed_toolbar input:hover{border-color:#aaa;background:#ddd;}#poststuff .wp_themeSkin .mceStatusbar{border-color:#EDEDED;}#poststuff #edButtonPreview,#poststuff #edButtonHTML{background-color:#eff8ff;border-color:#D1E5EE;color:#999;}#poststuff #editor-toolbar .active{border-bottom-color:#eff8ff;background-color:#eff8ff;color:#333;}#post-status-info{background-color:#eff8ff;}.wp_themeSkin *,.wp_themeSkin a:hover,.wp_themeSkin a:link,.wp_themeSkin a:visited,.wp_themeSkin a:active{color:#000;}.wp_themeSkin iframe{background:#fff;}.wp_themeSkin .mceStatusbar{color:#000;background-color:#f5f5f5;}.wp_themeSkin .mceButton{background-color:#e9e8e8;border-color:#B2B2B2;}.wp_themeSkin a.mceButtonEnabled:hover,.wp_themeSkin a.mceButtonActive,.wp_themeSkin a.mceButtonSelected{background:#d5d5d5;border-color:#777!important;}.wp_themeSkin .mceButtonDisabled{border-color:#ccc!important;}.wp_themeSkin .mceListBox .mceText,.wp_themeSkin .mceListBox .mceOpen{border-color:#B2B2B2;background-color:#d5d5d5;}.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,.wp_themeSkin .mceListBoxHover .mceOpen,.wp_themeSkin .mceListBoxSelected .mceOpen,.wp_themeSkin .mceListBoxSelected .mceText{border-color:#777!important;background-color:#d5d5d5;}.wp_themeSkin table.mceListBoxEnabled:hover .mceText,.wp_themeSkin .mceListBoxHover .mceText{border-color:#777!important;}.wp_themeSkin select.mceListBox{border-color:#B2B2B2;background-color:#fff;}.wp_themeSkin .mceSplitButton a.mceAction,.wp_themeSkin .mceSplitButton a.mceOpen{border-color:#B2B2B2;}.wp_themeSkin .mceSplitButton a.mceOpen:hover,.wp_themeSkin .mceSplitButtonSelected a.mceOpen,.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,.wp_themeSkin .mceSplitButton a.mceAction:hover{background-color:#d5d5d5;border-color:#777!important;}.wp_themeSkin .mceSplitButtonActive{background-color:#B2B2B2;}.wp_themeSkin div.mceColorSplitMenu table{background-color:#ebebeb;border-color:#B2B2B2;}.wp_themeSkin .mceColorSplitMenu a{border-color:#B2B2B2;}.wp_themeSkin .mceColorSplitMenu a.mceMoreColors{border-color:#fff;}.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover{border-color:#0A246A;background-color:#B6BDD2;}.wp_themeSkin a.mceMoreColors:hover{border-color:#0A246A;}.wp_themeSkin .mceMenu{border-color:#ddd;}.wp_themeSkin .mceMenu table{background-color:#ebeaeb;}.wp_themeSkin .mceMenu .mceText{color:#000;}.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,.wp_themeSkin .mceMenu .mceMenuItemActive{background-color:#f5f5f5;}.wp_themeSkin td.mceMenuItemSeparator{background-color:#aaa;}.wp_themeSkin .mceMenuItemTitle a{background-color:#ccc;border-bottom-color:#aaa;}.wp_themeSkin .mceMenuItemTitle span.mceText{color:#000;}.wp_themeSkin .mceMenuItemDisabled .mceText{color:#888;}.wp_themeSkin tr.mceFirst td.mceToolbar{background:#cfdfe9 url("../images/ed-bg-vs.gif?ver=20101102") repeat-x scroll left top;border-color:#cfdfe9;}.wp-admin #mceModalBlocker{background:#000;}.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft{background:#444;border-left:1px solid #999;border-top:1px solid #999;-moz-border-radius:4px 0 0 0;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px;}.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight{background:#444;border-right:1px solid #999;border-top:1px solid #999;border-top-right-radius:4px;-khtml-border-top-right-radius:4px;-webkit-border-top-right-radius:4px;-moz-border-radius:0 4px 0 0;}.wp-admin .clearlooks2 .mceMiddle .mceLeft{background:#f1f1f1;border-left:1px solid #999;}.wp-admin .clearlooks2 .mceMiddle .mceRight{background:#f1f1f1;border-right:1px solid #999;}.wp-admin .clearlooks2 .mceBottom{background:#f1f1f1;border-bottom:1px solid #999;}.wp-admin .clearlooks2 .mceBottom .mceLeft{background:#f1f1f1;border-bottom:1px solid #999;border-left:1px solid #999;}.wp-admin .clearlooks2 .mceBottom .mceCenter{background:#f1f1f1;border-bottom:1px solid #999;}.wp-admin .clearlooks2 .mceBottom .mceRight{background:#f1f1f1;border-bottom:1px solid #999;border-right:1px solid #999;}.wp-admin .clearlooks2 .mceFocus .mceTop span{color:#e5e5e5;}#editorcontainer,#post-status-info,#titlediv #title,.editwidget .widget-inside{border-color:#D1E5EE;}#titlediv #title{background-color:#fff;}#tTips p#tTips_inside{background-color:#ddd;color:#333;}#timestampdiv input,#namediv input,#poststuff .inside .the-tagcloud{border-color:#ddd;}#adminmenu *{border-color:#d1e5ee;}#adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;}.folded #adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;}#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle{background:transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -207px;}#adminmenu .wp-has-submenu:hover .wp-menu-toggle,#adminmenu .wp-menu-open .wp-menu-toggle{background:transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -109px;}#adminmenu a.menu-top{background:#eff8ff url(../images/menu-bits-vs.gif?ver=20101102) repeat-x scroll left -379px;}#adminmenu .wp-submenu a{background:#fff url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll 0 -99px;}#adminmenu .wp-has-current-submenu ul li a{background:none;}#adminmenu .wp-has-current-submenu ul li a.current{background:url(../images/menu-dark-vs.gif) top left no-repeat!important;}.wp-has-current-submenu .wp-submenu{border-top:none!important;}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu{border-bottom:#aaa 1px solid;}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,#adminmenu li.current a.menu-top{background:#d0dfe9 url(../images/menu-bits-vs.gif?ver=20101102) top left repeat-x;border:#5589aa 1px solid;color:#464646;}#adminmenu li.wp-has-current-submenu .wp-submenu,#adminmenu li.wp-has-current-submenu ul li a{border-right-color:#5589aa!important;border-left-color:#5589aa!important;}#adminmenu li.wp-has-current-submenu ul li a{background:url(../images/menu-dark-vs.gif) bottom left no-repeat!important;}#adminmenu li.wp-has-current-submenu ul{border-bottom-color:#5589aa;}#adminmenu .wp-submenu .current a.current{background:transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll 0 -289px;}#adminmenu .wp-submenu a:hover{background-color:#f8f7f3!important;color:#333!important;}#adminmenu .wp-submenu li.current,#adminmenu .wp-submenu li.current a,#adminmenu .wp-submenu li.current a:hover{color:#333;background-color:#efede7;background-image:none;border-color:#5589aa;}#adminmenu .wp-submenu ul{background-color:#fff;}.folded #adminmenu li.menu-top,#adminmenu .wp-submenu .wp-submenu-head{background:#eff8ff url(../images/menu-bits-vs.gif?ver=20101102) repeat-x scroll left -379px;}.folded #adminmenu li.wp-has-current-submenu,.folded #adminmenu li.menu-top.current{background:#e0e0e0 url(../images/menu-bits-vs.gif?ver=20101102) top left repeat-x;border:#5589aa 1px solid;color:#464646;}#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head{background:#d0dfe9 url(../images/menu-bits-vs.gif?ver=20101102) repeat-x 0 0;border:1px solid;color:#464646;}#adminmenu div.wp-submenu{background-color:transparent;}#adminmenu .menu-icon-dashboard div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -61px -33px;}#adminmenu .menu-icon-dashboard:hover div.wp-menu-image,#adminmenu .menu-icon-dashboard.wp-has-current-submenu div.wp-menu-image,#adminmenu .menu-icon-dashboard.current div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -61px -1px;}#adminmenu .menu-icon-post div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -272px -33px;}#adminmenu .menu-icon-post:hover div.wp-menu-image,#adminmenu .menu-icon-post.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -272px -1px;}#adminmenu .menu-icon-media div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -121px -33px;}#adminmenu .menu-icon-media:hover div.wp-menu-image,#adminmenu .menu-icon-media.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -121px -1px;}#adminmenu .menu-icon-links div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -91px -33px;}#adminmenu .menu-icon-links:hover div.wp-menu-image,#adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -91px -1px;}#adminmenu .menu-icon-page div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -151px -33px;}#adminmenu .menu-icon-page:hover div.wp-menu-image,#adminmenu .menu-icon-page.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -151px -1px;}#adminmenu .menu-icon-comments div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -31px -33px;}#adminmenu .menu-icon-comments:hover div.wp-menu-image,#adminmenu .menu-icon-comments.wp-has-current-submenu div.wp-menu-image,#adminmenu .menu-icon-comments.current div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -31px -1px;}#adminmenu .menu-icon-appearance div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -1px -33px;}#adminmenu .menu-icon-appearance:hover div.wp-menu-image,#adminmenu .menu-icon-appearance.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -1px -1px;}#adminmenu .menu-icon-plugins div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -181px -33px;}#adminmenu .menu-icon-plugins:hover div.wp-menu-image,#adminmenu .menu-icon-plugins.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -181px -1px;}#adminmenu .menu-icon-users div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -301px -33px;}#adminmenu .menu-icon-users:hover div.wp-menu-image,#adminmenu .menu-icon-users.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -301px -1px;}#adminmenu .menu-icon-tools div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -211px -33px;}#adminmenu .menu-icon-tools:hover div.wp-menu-image,#adminmenu .menu-icon-tools.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -211px -1px;}#adminmenu .menu-icon-settings div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -241px -33px;}#adminmenu .menu-icon-settings:hover div.wp-menu-image,#adminmenu .menu-icon-settings.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -241px -1px;}#adminmenu .menu-icon-site div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -361px -33px;}#adminmenu .menu-icon-site:hover div.wp-menu-image,#adminmenu .menu-icon-site.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -361px -1px;}table.diff .diff-deletedline{background-color:#fdd;}table.diff .diff-deletedline del{background-color:#f99;}table.diff .diff-addedline{background-color:#dfd;}table.diff .diff-addedline ins{background-color:#9f9;}#att-info{background-color:#E4F2FD;}#sidemenu a{background-color:#f9f9f9;border-color:#f9f9f9;border-bottom-color:#dfdfdf;}#sidemenu a.current{background-color:#fff;border-color:#dfdfdf #dfdfdf #fff;color:#D54E21;}#screen-options-wrap,#contextual-help-wrap{background-color:#F8F7F3;border-color:#D1e5ee;}#screen-meta-links a.show-settings{color:#606060;}#screen-meta-links a.show-settings:hover{color:#000;}#replysubmit{background-color:#f1f1f1;border-top-color:#ddd;}#replyerror{border-color:#ddd;background-color:#f9f9f9;}#edithead,#replyhead{background-color:#f1f1f1;}#ed_reply_toolbar{background-color:#e9e9e9;}.vim-current,.vim-current th,.vim-current td{background-color:#E4F2FD!important;}.star-average,.star.star-rating{background-color:#fc0;}div.star.select:hover{background-color:#d00;}#plugin-information .fyi ul{background-color:#eaf3fa;}#plugin-information .fyi h2.mainheader{background-color:#cee1ef;}#plugin-information pre,#plugin-information code{background-color:#ededff;}#plugin-information pre{border:1px solid #ccc;}.inline-edit-row fieldset input[type="text"],.inline-edit-row fieldset textarea,#bulk-titles,#replyrow input{border-color:#ddd;}.inline-editor div.title{background-color:#EAF3FA;}.inline-editor ul.cat-checklist{background-color:#fff;border-color:#ddd;}.inline-editor .categories .catshow,.inline-editor .categories .cathide{color:#21759b;}.inline-editor .quick-edit-save{background-color:#f1f1f1;}#replyrow #ed_reply_toolbar input:hover{border-color:#aaa;background:#ddd;}fieldset.inline-edit-col-right .inline-edit-col{border-color:#dfdfdf;}.attention{color:#D54E21;}body.press-this .postbox:hover .handlediv,body.press-this .stuffbox:hover .handlediv,.meta-box-sortables .postbox:hover .handlediv{background:transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -111px;}#major-publishing-actions{background:#eaf2fa;}.tablenav .tablenav-pages{color:#555;}.tablenav .tablenav-pages a{border-color:#d1e5ee;background:#eee url('../images/menu-bits-vs.gif?ver=20101102') repeat-x scroll left -379px;}.tablenav .tablenav-pages a:hover,.tablenav .tablenav-pages a:focus{color:#d54e21;}.tablenav .tablenav-pages a.disabled,.tablenav .tablenav-pages a.disabled:hover,.tablenav .tablenav-pages a.disabled:focus{color:#aaa;}.tablenav .tablenav-pages .current{background:#dfdfdf;border-color:#d3d3d3;}#availablethemes,#availablethemes td{border-color:#ddd;}#current-theme img{border-color:#999;}#TB_window #TB_title a.tb-theme-preview-link,#TB_window #TB_title a.tb-theme-preview-link:visited{color:#999;}#TB_window #TB_title a.tb-theme-preview-link:hover,#TB_window #TB_title a.tb-theme-preview-link:focus{color:#ccc;}.misc-pub-section{border-bottom-color:#eee;}#minor-publishing{border-bottom-color:#ddd;}#post-body .misc-pub-section{border-right-color:#eee;}.post-com-count span{background-color:#bbb;}.form-table .color-palette td{border-color:#fff;}.sortable-placeholder{border-color:#bbb;background-color:#f5f5f5;}#post-body ul.category-tabs li.tabs a,#post-body ul.add-menu-item-tabs li.tabs a,body.press-this ul.category-tabs li.tabs a{color:#333;}#wp_editimgbtn,#wp_delimgbtn,#wp_editgallery,#wp_delgallery{border-color:#999;background-color:#eee;}#wp_editimgbtn:hover,#wp_delimgbtn:hover,#wp_editgallery:hover,#wp_delgallery:hover{border-color:#555;background-color:#ccc;}#favorite-first{border-color:#c0c0c0;background:#f1f1f1;background:-moz-linear-gradient(bottom,#e7e7e7,#fff);background:-webkit-gradient(linear,left bottom,left top,from(#e7e7e7),to(#fff));}#favorite-inside{border-color:#c0c0c0;background-color:#fff;}#favorite-toggle{background:transparent url(../images/fav-arrow.gif?ver=20100531) no-repeat 0 -4px;}#favorite-actions a{color:#464646;}#favorite-actions a:hover{color:#000;}#favorite-inside a:hover{text-decoration:underline;}#screen-meta .screen-meta-toggle{background:#D1E5ee;}#screen-meta a.show-settings,.toggle-arrow{background-image:url("../images/screen-options-toggle-vs.gif?ver=20100531");}#icon-edit,#icon-post{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -552px -5px;}#icon-index{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -137px -5px;}#icon-upload{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -251px -5px;}#icon-link-manager,#icon-link,#icon-link-category{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -190px -5px;}#icon-edit-pages,#icon-page{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -312px -5px;}#icon-edit-comments{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -72px -5px;}#icon-themes{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -11px -5px;}#icon-plugins{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -370px -5px;}#icon-users,#icon-profile,#icon-user-edit{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -600px -5px;}#icon-tools,#icon-admin{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -432px -5px;}#icon-options-general{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -492px -5px;}#icon-ms-admin{background:transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -659px -5px;}.view-switch #view-switch-list{background:transparent url(../images/list.png) no-repeat 0 0;}.view-switch .current #view-switch-list{background:transparent url(../images/list.png) no-repeat -40px 0;}.view-switch #view-switch-excerpt{background:transparent url(../images/list.png) no-repeat -20px 0;}.view-switch .current #view-switch-excerpt{background:transparent url(../images/list.png) no-repeat -60px 0;}#header-logo{background:transparent url(../images/wp-logo-vs.png?ver=20101102) no-repeat scroll center center;}.popular-tags,.feature-filter{background-color:#fff;border-color:#DFDFDF;}#theme-information .action-button{border-top-color:#DFDFDF;}.theme-listing br.line{border-bottom-color:#ccc;}div.widgets-sortables,#widgets-left .inactive{border-color:#D1E5EE;background-color:#f8f7f3;-moz-border-radius-bottomleft:8px;-moz-border-radius-bottomright:8px;}#available-widgets .widget-holder{background-color:#fff;border-color:#ddd;}#widgets-left .sidebar-name{background-color:#aaa;background-image:url(../images/ed-bg-vs.gif?ver=20101102);text-shadow:#fff 0 1px 0;border-color:#dfdfdf;}#widgets-right .sidebar-name{background-image:url(../images/button-grad.png);text-shadow:#174f69 0 -1px 0;background-color:#cfdfe9;border-color:#174f69;color:#fff;}.sidebar-name:hover,#removing-widget{color:#d54e21;}#removing-widget span{color:black;}#widgets-left .sidebar-name-arrow{background:transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -109px;}#widgets-right .sidebar-name-arrow{background:url("../images/widgets-arrow-vs.gif?ver=20100531") no-repeat scroll 0 -1px transparent;}.in-widget-title{color:#606060;}.deleting .widget-title *{color:#aaa;}.imgedit-menu div{border-color:#d5d5d5;background-color:#f1f1f1;}.imgedit-menu div:hover{border-color:#c1c1c1;background-color:#eaeaea;}.imgedit-menu div.disabled{border-color:#ccc;background-color:#ddd;filter:alpha(opacity=50);opacity:.5;}#dashboard_recent_comments div.undo{border-top-color:#dfdfdf;}.comment-ays,.comment-ays th{border-color:#ddd;}.comment-ays th{background-color:#f1f1f1;}#nav-menu-header,#nav-menu-footer,.menu-item-handle{background:url("../images/ed-bg-vs.gif?ver=20101102") repeat-x scroll left top #cfdfe9;border-top:solid #D1E5EE 1px;}#menu-management .nav-tab-active{background:#eff8ff;border-bottom-color:#eff8ff;}
Index: /tags/3.1/wp-admin/css/colors-classic.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-classic.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-classic.dev.css	(revision 17487)
@@ -0,0 +1,1706 @@
+html,
+.wp-dialog {
+	background-color: #fcfcfb;
+}
+
+* html input,
+* html .widget {
+	border-color: #dfdfdf;
+}
+
+textarea,
+input[type="text"],
+input[type="password"],
+input[type="file"],
+input[type="button"],
+input[type="submit"],
+input[type="reset"],
+select {
+	border-color: #dfdfdf;
+	background-color: #fff;
+}
+
+kbd,
+code {
+	background: #eaeaea;
+}
+
+input[readonly] {
+	background-color: #eee;
+}
+
+.find-box-search {
+	border-color: #dfdfdf;
+	background-color: #f1f1f1;
+}
+
+.find-box {
+	background-color: #f1f1f1;
+}
+
+.find-box-inside {
+	background-color: #fff;
+}
+
+a.page-numbers:hover {
+	border-color: #999;
+}
+
+body,
+#wpbody,
+.form-table .pre {
+	color: #174f69;
+}
+
+body > #upload-menu {
+	border-bottom-color: #fff;
+}
+
+#postcustomstuff table,
+#your-profile fieldset,
+#rightnow,
+div.dashboard-widget,
+#dashboard-widgets p.dashboard-widget-links,
+#replyrow #ed_reply_toolbar input {
+	border-color: #D1E5EE
+}
+
+#poststuff .inside label.spam,
+#poststuff .inside label.deleted {
+	color: red;
+}
+
+#poststuff .inside label.waiting {
+	color: orange;
+}
+
+#poststuff .inside label.approved {
+	color: green;
+}
+
+#postcustomstuff table {
+	border-color: #dfdfdf;
+	background-color: #F9F9F9;
+}
+
+#postcustomstuff thead th {
+	background-color: #F1F1F1;
+}
+
+#postcustomstuff table input,
+#postcustomstuff table textarea {
+	border-color: #dfdfdf;
+	background-color: #fff;
+}
+
+.widefat {
+	border-color: #D1E5EE;
+	background-color: #fff;
+}
+
+div.dashboard-widget-error {
+	background-color: #c43;
+}
+
+div.dashboard-widget-notice {
+	background-color: #cfe1ef;
+}
+
+div.dashboard-widget-submit {
+	border-top-color: #ccc;
+}
+
+div.tabs-panel,
+.wp-tab-panel,
+ul.category-tabs li.tabs,
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
+	border-color: #dfdfdf;
+}
+
+ul.category-tabs li.tabs,
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
+	background-color: #f1f1f1;
+}
+
+input.disabled,
+textarea.disabled {
+	background-color: #ccc;
+}
+/* #upload-menu li a.upload-tab-link, */
+#plugin-information .action-button a,
+#plugin-information .action-button a:hover,
+#plugin-information .action-button a:visited {
+	color: #fff;
+}
+
+.widget .widget-top,
+.postbox h3,
+.stuffbox h3 {
+	background: #cfdfe9 url("../images/blue-grad.png?ver=20101102") repeat-x left top;
+	text-shadow: #fff 0 1px 0;
+}
+
+.form-table th,
+.form-wrap label {
+	color: #222;
+	text-shadow: #fff 0 1px 0;
+}
+
+.description,
+.form-wrap p {
+	color: #666;
+}
+
+strong .post-com-count span {
+	background-color: #21759b;
+}
+
+.sorthelper {
+	background-color: #ccf3fa;
+}
+
+.ac_match,
+.subsubsub a.current {
+	color: #000;
+}
+
+.wrap h2 {
+	color: #174f69;
+}
+
+.ac_over {
+	background-color: #f0f0b8;
+}
+
+.ac_results {
+	background-color: #fff;
+	border-color: #808080;
+}
+
+.ac_results li {
+	color: #101010;
+}
+
+.alternate,
+.alt {
+	background-color: #F8F7F3;
+}
+
+.available-theme a.screenshot {
+	background-color: #f1f1f1;
+	border-color: #ddd;
+}
+
+.bar {
+	background-color: #e8e8e8;
+	border-right-color: #99d;
+}
+
+#media-upload,
+#media-upload .media-item .slidetoggle {
+	background: #fff;
+}
+
+#media-upload .slidetoggle {
+	border-top-color: #dfdfdf;
+}
+
+div.error,
+.login #login_error {
+	background-color: #ffebe8;
+	border-color: #c00;
+}
+
+div.error a {
+	color: #c00;
+}
+
+.form-invalid {
+	background-color: #ffebe8 !important;
+}
+
+.form-invalid input,
+.form-invalid select {
+	border-color: #c00 !important;
+}
+
+.submit {
+	border-color: #DFDFDF;
+}
+
+.highlight {
+	background-color: #e4f2fd;
+	color: #000;
+}
+
+.howto,
+.nonessential,
+#edit-slug-box,
+.form-input-tip,
+.rss-widget span.rss-date,
+.subsubsub {
+	color: #666;
+}
+
+.media-item {
+	border-bottom-color: #dfdfdf;
+}
+
+#wpbody-content #media-items .describe {
+	border-top-color: #dfdfdf;
+}
+
+.media-upload-form label.form-help,
+td.help {
+	color: #9a9a9a;
+}
+
+.post-com-count {
+	background-image: url(../images/bubble_bg.gif);
+	color: #fff;
+}
+
+.post-com-count span {
+	background-color: #bbb;
+	color: #fff;
+}
+
+.post-com-count:hover span {
+	background-color: #d54e21;
+}
+
+.quicktags, .search {
+	background-color: #ccc;
+	color: #000;
+}
+
+.side-info h5 {
+	border-bottom-color: #dadada;
+}
+
+.side-info ul {
+	color: #666;
+}
+
+.button,
+.button-secondary,
+.submit input,
+input[type=button],
+input[type=submit] {
+	border-color: #bbb;
+	color: #464646;
+}
+
+.button:hover,
+.button-secondary:hover,
+.submit input:hover,
+input[type=button]:hover,
+input[type=submit]:hover {
+	color: #000;
+	border-color: #666;
+}
+
+.button,
+.submit input,
+.button-secondary {
+	background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
+	text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+.button:active,
+.submit input:active,
+.button-secondary:active {
+	background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
+}
+
+input.button-primary,
+button.button-primary,
+a.button-primary {
+	border-color: #298cba;
+	font-weight: bold;
+	color: #fff;
+	background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
+	text-shadow: rgba(0,0,0,0.3) 0 -1px 0;
+}
+
+input.button-primary:active,
+button.button-primary:active,
+a.button-primary:active {
+	background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top;
+	color: #eaf2fa;
+}
+
+input.button-primary:hover,
+button.button-primary:hover,
+a.button-primary:hover,
+a.button-primary:focus,
+a.button-primary:active {
+	border-color: #13455b;
+	color: #eaf2fa;
+}
+
+.button-disabled,
+.button[disabled],
+.button:disabled,
+.button-secondary[disabled],
+.button-secondary:disabled,
+a.button.disabled {
+	color: #aaa !important;
+	border-color: #ddd !important;
+}
+
+.button-primary-disabled,
+.button-primary[disabled],
+.button-primary:disabled {
+	color: #9FD0D5 !important;
+	background: #298CBA !important;
+}
+
+a:hover,
+a:active,
+a:focus {
+	color: #d54e21;
+}
+
+#wphead #viewsite a:hover,
+#adminmenu a:hover,
+#adminmenu ul.wp-submenu a:hover,
+#the-comment-list .comment a:hover,
+#rightnow a:hover,
+#media-upload a.del-link:hover,
+div.dashboard-widget-submit input:hover,
+.subsubsub a:hover,
+.subsubsub a.current:hover,
+.ui-tabs-nav a:hover,
+.plugins .inactive a:hover,
+#all-plugins-table .plugins .inactive a:hover,
+#search-plugins-table .plugins .inactive a:hover {
+	color: #d54e21;
+}
+
+#the-comment-list .comment-item,
+#dashboard-widgets #dashboard_quick_press form p.submit {
+	border-color: #dfdfdf;
+}
+
+#side-sortables .category-tabs .tabs a,
+#side-sortables .add-menu-item-tabs .tabs a,
+.wp-tab-bar .wp-tab-active a {
+	color: #333;
+}
+
+#rightnow .rbutton {
+	background-color: #ebebeb;
+	color: #264761;
+}
+
+.submitbox .submit {
+	background-color: #464646;
+	color: #ccc;
+}
+
+.plugins a.delete:hover,
+#all-plugins-table .plugins a.delete:hover,
+#search-plugins-table .plugins a.delete:hover,
+.submitbox .submitdelete {
+	color: #f00;
+	border-bottom-color: #f00;
+}
+
+.submitbox .submitdelete:hover,
+#media-items a.delete:hover {
+	color: #fff;
+	background-color: #f00;
+	border-bottom-color: #f00;
+}
+
+#normal-sortables .submitbox .submitdelete:hover {
+	color: #000;
+	background-color: #f00;
+	border-bottom-color: #f00;
+}
+
+.tablenav .dots {
+	border-color: transparent;
+}
+
+.tablenav .next,
+.tablenav .prev {
+	border-color: transparent;
+	color: #21759b;
+}
+
+.tablenav .next:hover,
+.tablenav .prev:hover {
+	border-color: transparent;
+	color: #d54e21;
+}
+
+div.updated,
+.login .message {
+	background-color: #ffffe0;
+	border-color: #e6db55;
+}
+
+.update-message {
+	color: #000;
+}
+
+a.page-numbers {
+	border-bottom-color: #B8D3E2;
+}
+
+.commentlist li {
+	border-bottom-color: #ccc;
+}
+
+.widefat td,
+.widefat th {
+	border-color: #dfdfdf;
+}
+
+.widefat th {
+	text-shadow: rgba(255,255,255,0.8) 0 1px 0;
+}
+
+.widefat thead tr th,
+.widefat tfoot tr th,
+h3.dashboard-widget-title,
+h3.dashboard-widget-title span,
+h3.dashboard-widget-title small,
+.find-box-head {
+	color: #333;
+	background: #cfdfe9 url(../images/blue-grad.png?ver=20101102) repeat-x scroll left top;
+}
+
+th.sortable a:hover, th.sortable a:active, th.sortable a:focus {
+	color: #333;
+}
+
+h3.dashboard-widget-title small a {
+	color: #d7d7d7;
+}
+
+h3.dashboard-widget-title small a:hover {
+	color: #fff;
+}
+
+a,
+#adminmenu a,
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML,
+#the-comment-list p.comment-author strong a,
+#media-upload a.del-link,
+#media-items a.delete,
+.plugins a.delete,
+.ui-tabs-nav a {
+	color: #21759b;
+}
+
+#adminmenu #awaiting-mod,
+#adminmenu .update-plugins,
+#sidemenu a .update-plugins,
+#rightnow .reallynow {
+	background-color: #464646;
+	color: #fff;
+	-moz-box-shadow: #fff 0 -1px 0;
+	-khtml-box-shadow: #fff 0 -1px 0;
+	-webkit-box-shadow: #fff 0 -1px 0;
+	box-shadow: #fff 0 -1px 0;
+}
+#plugin-information .action-button {
+	background-color: #d54e21;
+	color: #fff;
+}
+
+#adminmenu li.current a #awaiting-mod,
+#adminmenu  li a.wp-has-current-submenu .update-plugins{
+	background-color: #464646;
+	color: #fff;
+	-moz-box-shadow: #fff 0 -1px 0;
+	-khtml-box-shadow: #fff 0 -1px 0;
+	-webkit-box-shadow: #fff 0 -1px 0;
+	box-shadow: #fff 0 -1px 0;
+}
+
+div#media-upload-header,
+div#plugin-information-header {
+	background-color: #f9f9f9;
+	border-bottom-color: #dfdfdf;
+}
+
+#currenttheme img {
+	border-color: #666;
+}
+
+#dashboard_secondary div.dashboard-widget-content ul li a {
+	background-color: #f9f9f9;
+}
+
+input.readonly, textarea.readonly {
+	background-color: #ddd;
+}
+
+#ed_toolbar input,
+#ed_reply_toolbar input {
+	background: #fff url("../images/fade-butt.png") repeat-x 0 -2px;
+}
+
+#editable-post-name {
+	background-color: #fffbcc;
+}
+
+#edit-slug-box strong,
+.tablenav .displaying-num,
+#submitted-on,
+.submitted-on {
+	color: #777;
+}
+
+.login #nav a {
+	color: #21759b !important;
+}
+
+.login #nav a:hover {
+	color: #d54e21 !important;
+}
+
+#footer {
+	color: #777;
+	border-color: #b0c8d7;
+	background: #cfdfe9; /* fallback color */
+	background:-moz-linear-gradient(bottom,  #cfdfe9,  #eff8ff);
+	background:-webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#eff8ff));
+}
+
+#media-items,
+.imgedit-group {
+	border-color: #dfdfdf;
+}
+
+.checkbox,
+.side-info,
+.plugins tr,
+#your-profile #rich_editing {
+	background-color: #fff;
+}
+
+.plugins .inactive,
+.plugins .inactive th,
+.plugins .inactive td,
+tr.inactive + tr.plugin-update-tr .plugin-update {
+	background-color: #efede7;
+}
+
+.plugin-update-tr .update-message {
+	background-color: #fffbe4;
+	border-color: #dfdfdf;
+}
+
+.plugins .active,
+.plugins .active th,
+.plugins .active td {
+	color: #000;
+}
+
+.plugins .inactive a {
+	color: #557799;
+}
+
+#the-comment-list tr.undo,
+#the-comment-list div.undo {
+	background-color: #f4f4f4;
+}
+
+#the-comment-list .unapproved {
+	background-color: #ffffe0;
+}
+
+#the-comment-list .approve a {
+	color: #006505;
+}
+
+#the-comment-list .unapprove a {
+	color: #d98500;
+}
+
+table.widefat span.delete a,
+table.widefat span.trash a,
+table.widefat span.spam a,
+#dashboard_recent_comments .delete a,
+#dashboard_recent_comments .trash a,
+#dashboard_recent_comments .spam a {
+	color: #bc0b0b;
+}
+
+.widget,
+#widget-list .widget-top,
+.postbox,
+#titlediv,
+#poststuff .postarea,
+.stuffbox {
+	border-color: #D1E5EE;
+}
+
+.widget,
+.postbox {
+	background-color: #fff;
+}
+
+.ui-sortable .postbox h3 {
+	color: #174f69;
+}
+
+.widget .widget-top,
+.ui-sortable .postbox h3:hover {
+	color: #174f69;
+}
+
+.curtime #timestamp {
+	background-image: url(../images/date-button.gif);
+}
+
+#quicktags #ed_link {
+	color: #00f;
+}
+
+#rightnow .youhave {
+	background-color: #f0f6fb;
+}
+
+#rightnow a {
+	color: #448abd;
+}
+
+.tagchecklist span a,
+#bulk-titles div a {
+	background: url(../images/xit.gif) no-repeat;
+}
+
+.tagchecklist span a:hover,
+#bulk-titles div a:hover {
+	background: url(../images/xit.gif) no-repeat -10px 0;
+}
+
+#update-nag, .update-nag {
+	background-color: #FFFBCC;
+	border-color: #E6DB55;
+	color: #555;
+}
+
+.login #backtoblog a {
+	color: #464646;
+}
+
+#wphead {
+	border-bottom:#b0c8d7 1px solid;
+	background: #cfdfe9; /* fallback color */
+	background:-moz-linear-gradient(bottom,  #cfdfe9,  #eff8ff);
+	background:-webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#eff8ff));
+}
+
+#wphead h1 a {
+	color: #174f69;
+}
+
+#user_info {
+	color: #777;
+}
+
+#user_info a:link,
+#user_info a:visited,
+#footer a:link,
+#footer a:visited {
+	color: #174f69;
+	text-decoration: none;
+}
+
+#user_info a:hover,
+#footer a:hover {
+	color: #000;
+	text-decoration: underline !important;
+}
+
+div#media-upload-error,
+.file-error,
+abbr.required,
+.widget-control-remove:hover,
+table.widefat .delete a:hover,
+table.widefat .trash a:hover,
+table.widefat .spam a:hover,
+#dashboard_recent_comments .delete a:hover,
+#dashboard_recent_comments .trash a:hover
+#dashboard_recent_comments .spam a:hover {
+	color: #f00;
+}
+
+#pass-strength-result {
+	background-color: #eee;
+	border-color: #ddd !important;
+}
+
+#pass-strength-result.bad {
+	background-color: #ffb78c;
+	border-color: #ff853c !important;
+}
+
+#pass-strength-result.good {
+	background-color: #ffec8b;
+	border-color: #fc0 !important;
+}
+
+#pass-strength-result.short {
+	background-color: #ffa0a0;
+	border-color: #f04040 !important;
+}
+
+#pass-strength-result.strong {
+	background-color: #c3ff88;
+	border-color: #8dff1c !important;
+}
+
+/* editors */
+#quicktags {
+	border-color: #cfdfe9;
+	background-color: #cfdfe9;
+	background-image: url("../images/ed-bg-vs.gif?ver=20101102");
+}
+
+#ed_toolbar input {
+	border-color: #C3C3C3;
+}
+
+#ed_toolbar input:hover {
+	border-color: #aaa;
+	background: #ddd;
+}
+
+#poststuff .wp_themeSkin .mceStatusbar {
+	border-color: #EDEDED;
+}
+
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+	background-color: #eff8ff;
+	border-color: #D1E5EE;
+	color: #999;
+}
+
+#poststuff #editor-toolbar .active {
+	border-bottom-color: #eff8ff;
+	background-color: #eff8ff;
+	color: #333;
+}
+
+/* TinyMCE */
+#post-status-info {
+	background-color: #eff8ff;
+}
+
+.wp_themeSkin *,
+.wp_themeSkin a:hover,
+.wp_themeSkin a:link,
+.wp_themeSkin a:visited,
+.wp_themeSkin a:active {
+	 color: #000;
+}
+
+/* Containers */
+.wp_themeSkin iframe {
+	background: #fff;
+}
+
+/* Layout */
+.wp_themeSkin .mceStatusbar {
+	color: #000;
+	background-color: #f5f5f5;
+}
+
+/* Button */
+.wp_themeSkin .mceButton {
+	background-color: #e9e8e8;
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin a.mceButtonEnabled:hover,
+.wp_themeSkin a.mceButtonActive,
+.wp_themeSkin a.mceButtonSelected {
+	background: #d5d5d5;
+	border-color: #777 !important;
+}
+
+.wp_themeSkin .mceButtonDisabled {
+	border-color: #ccc !important;
+}
+
+/* ListBox */
+.wp_themeSkin .mceListBox .mceText,
+.wp_themeSkin .mceListBox .mceOpen  {
+	border-color: #B2B2B2;
+	background-color: #d5d5d5;
+}
+
+.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
+.wp_themeSkin .mceListBoxHover .mceOpen,
+.wp_themeSkin .mceListBoxSelected .mceOpen,
+.wp_themeSkin .mceListBoxSelected .mceText {
+	border-color: #777 !important;
+	background-color: #d5d5d5;
+}
+
+.wp_themeSkin table.mceListBoxEnabled:hover .mceText,
+.wp_themeSkin .mceListBoxHover .mceText {
+	border-color: #777 !important;
+}
+
+.wp_themeSkin select.mceListBox {
+	border-color: #B2B2B2;
+	background-color: #fff;
+}
+
+/* SplitButton */
+.wp_themeSkin .mceSplitButton a.mceAction,
+.wp_themeSkin .mceSplitButton a.mceOpen {
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin .mceSplitButton a.mceOpen:hover,
+.wp_themeSkin .mceSplitButtonSelected a.mceOpen,
+.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,
+.wp_themeSkin .mceSplitButton a.mceAction:hover {
+	background-color: #d5d5d5;
+	border-color: #777 !important;
+}
+
+.wp_themeSkin .mceSplitButtonActive {
+	background-color: #B2B2B2;
+}
+
+/* ColorSplitButton */
+.wp_themeSkin div.mceColorSplitMenu table {
+	background-color: #ebebeb;
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin .mceColorSplitMenu a {
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
+	border-color: #fff;
+}
+
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {
+	border-color: #0A246A;
+	background-color: #B6BDD2;
+}
+
+.wp_themeSkin a.mceMoreColors:hover {
+	border-color: #0A246A;
+}
+
+/* Menu */
+.wp_themeSkin .mceMenu {
+	border-color: #ddd;
+}
+
+.wp_themeSkin .mceMenu table {
+	background-color: #ebeaeb;
+}
+
+.wp_themeSkin .mceMenu .mceText {
+	color: #000;
+}
+
+.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,
+.wp_themeSkin .mceMenu .mceMenuItemActive {
+	background-color: #f5f5f5;
+}
+.wp_themeSkin td.mceMenuItemSeparator {
+	background-color: #aaa;
+}
+.wp_themeSkin .mceMenuItemTitle a {
+	background-color: #ccc;
+	border-bottom-color: #aaa;
+}
+.wp_themeSkin .mceMenuItemTitle span.mceText {
+	color: #000;
+}
+.wp_themeSkin .mceMenuItemDisabled .mceText {
+	color: #888;
+}
+
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+	background: #cfdfe9 url("../images/ed-bg-vs.gif?ver=20101102") repeat-x scroll left top;
+	border-color: #cfdfe9;
+}
+
+.wp-admin #mceModalBlocker {
+	background: #000;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft {
+	background: #444444;
+	border-left: 1px solid #999;
+	border-top: 1px solid #999;
+	-moz-border-radius: 4px 0 0 0;
+	-webkit-border-top-left-radius: 4px;
+	-khtml-border-top-left-radius: 4px;
+	border-top-left-radius: 4px;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight {
+	background: #444444;
+	border-right: 1px solid #999;
+	border-top: 1px solid #999;
+	border-top-right-radius: 4px;
+	-khtml-border-top-right-radius: 4px;
+	-webkit-border-top-right-radius: 4px;
+	-moz-border-radius: 0 4px 0 0;
+}
+
+.wp-admin .clearlooks2 .mceMiddle .mceLeft {
+	background: #f1f1f1;
+	border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceMiddle .mceRight {
+	background: #f1f1f1;
+	border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceLeft {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+	border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceCenter {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceRight {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+	border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop span {
+	color: #e5e5e5;
+}
+/* end TinyMCE */
+
+#editorcontainer,
+#post-status-info,
+#titlediv #title,
+.editwidget .widget-inside {
+	border-color: #D1E5EE;
+}
+
+#titlediv #title {
+	background-color: #fff;
+}
+
+#tTips p#tTips_inside {
+	background-color: #ddd;
+	color: #333;
+}
+
+#timestampdiv input,
+#namediv input,
+#poststuff .inside .the-tagcloud {
+	border-color: #ddd;
+}
+
+/* menu */
+#adminmenu * {
+	border-color: #d1e5ee;
+}
+
+#adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -109px;
+}
+
+#adminmenu a.menu-top {
+	background: #eff8ff url(../images/menu-bits-vs.gif?ver=20101102) repeat-x scroll left -379px;
+}
+
+#adminmenu .wp-submenu a {
+	background: #fff url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll 0 -99px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a {
+	background: none;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+	background: url(../images/menu-dark-vs.gif) top left no-repeat !important;
+}
+
+.wp-has-current-submenu .wp-submenu {
+	border-top: none !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu {
+	border-bottom: #aaa 1px solid;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu li.current a.menu-top {
+	background: #d0dfe9 url(../images/menu-bits-vs.gif?ver=20101102) top left repeat-x;
+	border: #5589aa 1px solid;
+	color: #464646;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-submenu,
+#adminmenu li.wp-has-current-submenu ul li a {
+	border-right-color: #5589aa !important;
+	border-left-color: #5589aa !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+	background: url(../images/menu-dark-vs.gif) bottom left no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul {
+	border-bottom-color: #5589aa;
+}
+
+#adminmenu .wp-submenu .current a.current {
+	background: transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll  0 -289px;
+}
+
+#adminmenu .wp-submenu a:hover {
+	background-color: #f8f7f3 !important;
+	color: #333 !important;
+}
+
+#adminmenu .wp-submenu li.current,
+#adminmenu .wp-submenu li.current a,
+#adminmenu .wp-submenu li.current a:hover {
+	color: #333;
+	background-color: #efede7;
+	background-image: none;
+	border-color: #5589aa;
+}
+
+#adminmenu .wp-submenu ul {
+	background-color: #fff;
+}
+
+.folded #adminmenu li.menu-top,
+#adminmenu .wp-submenu .wp-submenu-head {
+	background: #eff8ff url(../images/menu-bits-vs.gif?ver=20101102) repeat-x scroll left -379px;
+}
+
+.folded #adminmenu li.wp-has-current-submenu,
+.folded #adminmenu li.menu-top.current {
+	background: #e0e0e0 url(../images/menu-bits-vs.gif?ver=20101102) top left repeat-x;
+	border: #5589aa 1px solid;
+	color: #464646;
+}
+
+#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
+	background: #d0dfe9 url(../images/menu-bits-vs.gif?ver=20101102) repeat-x 0% 0%;
+	border: 1px solid;
+	color: #464646;
+}
+
+#adminmenu div.wp-submenu {
+	background-color: transparent;
+}
+
+/* menu icons */
+#adminmenu .menu-icon-dashboard div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -61px -33px;
+}
+
+#adminmenu .menu-icon-dashboard:hover div.wp-menu-image,
+#adminmenu .menu-icon-dashboard.wp-has-current-submenu div.wp-menu-image,
+#adminmenu .menu-icon-dashboard.current div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -61px -1px;
+}
+
+#adminmenu .menu-icon-post div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -272px -33px;
+}
+
+#adminmenu .menu-icon-post:hover div.wp-menu-image,
+#adminmenu .menu-icon-post.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -272px -1px;
+}
+
+#adminmenu .menu-icon-media div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -121px -33px;
+}
+
+#adminmenu .menu-icon-media:hover div.wp-menu-image,
+#adminmenu .menu-icon-media.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -121px -1px;
+}
+
+#adminmenu .menu-icon-links div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -91px -33px;
+}
+
+#adminmenu .menu-icon-links:hover div.wp-menu-image,
+#adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -91px -1px;
+}
+
+#adminmenu .menu-icon-page div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -151px -33px;
+}
+
+#adminmenu .menu-icon-page:hover div.wp-menu-image,
+#adminmenu .menu-icon-page.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -151px -1px;
+}
+
+#adminmenu .menu-icon-comments div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -31px -33px;
+}
+
+#adminmenu .menu-icon-comments:hover div.wp-menu-image,
+#adminmenu .menu-icon-comments.wp-has-current-submenu div.wp-menu-image,
+#adminmenu .menu-icon-comments.current div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -31px -1px;
+}
+
+#adminmenu .menu-icon-appearance div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -1px -33px;
+}
+
+#adminmenu .menu-icon-appearance:hover div.wp-menu-image,
+#adminmenu .menu-icon-appearance.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -1px -1px;
+}
+
+#adminmenu .menu-icon-plugins div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -181px -33px;
+}
+
+#adminmenu .menu-icon-plugins:hover div.wp-menu-image,
+#adminmenu .menu-icon-plugins.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -181px -1px;
+}
+
+#adminmenu .menu-icon-users div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -301px -33px;
+}
+
+#adminmenu .menu-icon-users:hover div.wp-menu-image,
+#adminmenu .menu-icon-users.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -301px -1px;
+}
+
+#adminmenu .menu-icon-tools div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -211px -33px;
+}
+
+#adminmenu .menu-icon-tools:hover div.wp-menu-image,
+#adminmenu .menu-icon-tools.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -211px -1px;
+}
+
+#adminmenu .menu-icon-settings div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -241px -33px;
+}
+
+#adminmenu .menu-icon-settings:hover div.wp-menu-image,
+#adminmenu .menu-icon-settings.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -241px -1px;
+}
+
+#adminmenu .menu-icon-site div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -361px -33px;
+}
+
+#adminmenu .menu-icon-site:hover div.wp-menu-image,
+#adminmenu .menu-icon-site.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu-vs.png?ver=20100531') no-repeat scroll -361px -1px;
+}
+/* end menu */
+
+
+/* Diff */
+table.diff .diff-deletedline {
+	background-color: #fdd;
+}
+
+table.diff .diff-deletedline del {
+	background-color: #f99;
+}
+
+table.diff .diff-addedline {
+	background-color: #dfd;
+}
+
+table.diff .diff-addedline ins {
+	background-color: #9f9;
+}
+
+#att-info {
+	background-color: #E4F2FD;
+}
+
+/* edit image */
+#sidemenu a {
+	background-color: #f9f9f9;
+	border-color: #f9f9f9;
+	border-bottom-color: #dfdfdf;
+}
+
+#sidemenu a.current {
+	background-color: #fff;
+	border-color: #dfdfdf #dfdfdf #fff;
+	color: #D54E21;
+}
+
+#screen-options-wrap,
+#contextual-help-wrap {
+	background-color: #F8F7F3;
+	border-color: #D1e5ee;
+}
+
+#screen-meta-links a.show-settings {
+	color: #606060;
+}
+
+#screen-meta-links a.show-settings:hover {
+	color: #000;
+}
+
+#replysubmit {
+	background-color: #f1f1f1;
+	border-top-color: #ddd;
+}
+
+#replyerror {
+	border-color: #ddd;
+	background-color: #f9f9f9;
+}
+
+#edithead,
+#replyhead {
+	background-color: #f1f1f1;
+}
+
+#ed_reply_toolbar {
+	background-color: #e9e9e9;
+}
+
+/* table vim shortcuts */
+.vim-current,
+.vim-current th,
+.vim-current td {
+	background-color: #E4F2FD !important;
+}
+
+/* Install Plugins */
+.star-average,
+.star.star-rating {
+	background-color: #fc0;
+}
+
+div.star.select:hover {
+	background-color: #d00;
+}
+
+#plugin-information .fyi ul {
+	background-color: #eaf3fa;
+}
+
+#plugin-information .fyi h2.mainheader {
+	background-color: #cee1ef;
+}
+
+#plugin-information pre,
+#plugin-information code {
+	background-color: #ededff;
+}
+
+#plugin-information pre {
+	border: 1px solid #ccc;
+}
+
+/* inline editor */
+.inline-edit-row fieldset input[type="text"],
+.inline-edit-row fieldset textarea,
+#bulk-titles,
+#replyrow input {
+	border-color: #ddd;
+}
+
+.inline-editor div.title {
+	background-color: #EAF3FA;
+}
+
+.inline-editor ul.cat-checklist {
+	background-color: #fff;
+	border-color: #ddd;
+}
+
+.inline-editor .categories .catshow,
+.inline-editor .categories .cathide {
+	color: #21759b;
+}
+
+.inline-editor .quick-edit-save {
+	background-color: #f1f1f1;
+}
+
+#replyrow #ed_reply_toolbar input:hover {
+	border-color: #aaa;
+	background: #ddd;
+}
+
+fieldset.inline-edit-col-right .inline-edit-col {
+	border-color: #dfdfdf;
+}
+
+.attention {
+	color: #D54E21;
+}
+
+body.press-this .postbox:hover .handlediv,
+body.press-this .stuffbox:hover .handlediv,
+.meta-box-sortables .postbox:hover .handlediv {
+	background: transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -111px;
+}
+
+#major-publishing-actions {
+	background: #eaf2fa;
+}
+
+.tablenav .tablenav-pages {
+	color: #555;
+}
+
+.tablenav .tablenav-pages a {
+	border-color: #d1e5ee;
+	background: #eee url('../images/menu-bits-vs.gif?ver=20101102') repeat-x scroll left -379px;
+}
+
+.tablenav .tablenav-pages a:hover,
+.tablenav .tablenav-pages a:focus {
+	color: #d54e21;
+}
+
+.tablenav .tablenav-pages a.disabled,
+.tablenav .tablenav-pages a.disabled:hover,
+.tablenav .tablenav-pages a.disabled:focus {
+	color: #aaa;
+}
+
+.tablenav .tablenav-pages .current {
+	background: #dfdfdf;
+	border-color: #d3d3d3;
+}
+
+#availablethemes,
+#availablethemes td {
+	border-color: #ddd;
+}
+
+#current-theme img {
+	border-color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link,
+#TB_window #TB_title a.tb-theme-preview-link:visited {
+	color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link:hover,
+#TB_window #TB_title a.tb-theme-preview-link:focus {
+	color: #ccc;
+}
+
+.misc-pub-section {
+	border-bottom-color: #eee;
+}
+
+#minor-publishing {
+	border-bottom-color: #ddd;
+}
+
+#post-body .misc-pub-section {
+	border-right-color: #eee;
+}
+
+.post-com-count span {
+	background-color: #bbb;
+}
+
+.form-table .color-palette td {
+	border-color: #fff;
+}
+
+.sortable-placeholder {
+	border-color: #bbb;
+	background-color: #f5f5f5;
+}
+
+#post-body ul.category-tabs li.tabs a,
+#post-body ul.add-menu-item-tabs li.tabs a,
+body.press-this ul.category-tabs li.tabs a {
+	color: #333;
+}
+
+#wp_editimgbtn,
+#wp_delimgbtn,
+#wp_editgallery,
+#wp_delgallery {
+	border-color: #999;
+	background-color: #eee;
+}
+
+#wp_editimgbtn:hover,
+#wp_delimgbtn:hover,
+#wp_editgallery:hover,
+#wp_delgallery:hover {
+	border-color: #555;
+	background-color: #ccc;
+}
+
+#favorite-first {
+	border-color: #c0c0c0;
+	background: #f1f1f1; /* fallback color */
+	background:-moz-linear-gradient(bottom,  #e7e7e7,  #fff);
+	background:-webkit-gradient(linear, left bottom, left top, from(#e7e7e7), to(#fff));
+}
+
+#favorite-inside {
+	border-color: #c0c0c0;
+	background-color: #fff;
+}
+
+#favorite-toggle {
+	background: transparent url(../images/fav-arrow.gif?ver=20100531) no-repeat 0 -4px;
+}
+
+#favorite-actions a {
+	color: #464646;
+}
+
+#favorite-actions a:hover {
+	color: #000;
+}
+
+#favorite-inside a:hover {
+	text-decoration: underline;
+}
+
+#screen-meta .screen-meta-toggle {
+	background: #D1E5ee;
+}
+
+#screen-meta a.show-settings,
+.toggle-arrow {
+	background-image:url("../images/screen-options-toggle-vs.gif?ver=20100531");
+}
+
+#icon-edit,
+#icon-post {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -552px -5px;
+}
+
+#icon-index {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -137px -5px;
+}
+
+#icon-upload {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -251px -5px;
+}
+
+#icon-link-manager,
+#icon-link,
+#icon-link-category {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -190px -5px;
+}
+
+#icon-edit-pages,
+#icon-page {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -312px -5px;
+}
+
+#icon-edit-comments {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -72px -5px;
+}
+
+#icon-themes {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -11px -5px;
+}
+
+#icon-plugins {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -370px -5px;
+}
+
+#icon-users,
+#icon-profile,
+#icon-user-edit {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -600px -5px;
+}
+
+#icon-tools,
+#icon-admin {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -432px -5px;
+}
+
+#icon-options-general {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -492px -5px;
+}
+
+#icon-ms-admin {
+	background: transparent url(../images/icons32-vs.png?ver=20100531) no-repeat -659px -5px;
+}
+
+.view-switch #view-switch-list {
+	background: transparent url(../images/list.png) no-repeat 0 0;
+}
+
+.view-switch .current #view-switch-list {
+	background: transparent url(../images/list.png) no-repeat -40px 0;
+}
+
+.view-switch #view-switch-excerpt {
+	background: transparent url(../images/list.png) no-repeat -20px 0;
+}
+
+.view-switch .current #view-switch-excerpt {
+	background: transparent url(../images/list.png) no-repeat -60px 0;
+}
+
+#header-logo {
+	background: transparent url(../images/wp-logo-vs.png?ver=20101102) no-repeat scroll center center;
+}
+
+.popular-tags,
+.feature-filter {
+	background-color: #fff;
+	border-color: #DFDFDF;
+}
+
+#theme-information .action-button {
+	border-top-color: #DFDFDF;
+}
+
+.theme-listing br.line {
+	border-bottom-color: #ccc;
+}
+
+div.widgets-sortables,
+#widgets-left .inactive {
+	border-color: #D1E5EE;
+	background-color: #f8f7f3;
+	-moz-border-radius-bottomleft:8px;
+-moz-border-radius-bottomright:8px
+}
+
+#available-widgets .widget-holder {
+	background-color: #fff;
+	border-color: #ddd;
+}
+
+#widgets-left .sidebar-name {
+	background-color: #aaa;
+	background-image: url(../images/ed-bg-vs.gif?ver=20101102);
+	text-shadow: #fff 0 1px 0;
+	border-color: #dfdfdf;
+}
+
+#widgets-right .sidebar-name {
+	background-image: url(../images/button-grad.png);
+	text-shadow: #174f69 0 -1px 0;
+	background-color: #cfdfe9;
+	border-color: #174f69;
+	color: #ffffff;
+}
+
+.sidebar-name:hover,
+#removing-widget {
+	color: #d54e21;
+}
+
+#removing-widget span {
+	color: black;
+}
+
+#widgets-left .sidebar-name-arrow {
+	background: transparent url(../images/menu-bits-vs.gif?ver=20101102) no-repeat scroll left -109px;
+}
+
+#widgets-right .sidebar-name-arrow {
+	background: url("../images/widgets-arrow-vs.gif?ver=20100531") no-repeat scroll 0 -1px transparent;
+}
+
+.in-widget-title {
+	color: #606060;
+}
+
+.deleting .widget-title * {
+	color: #aaa;
+}
+
+.imgedit-menu div {
+	border-color: #d5d5d5;
+	background-color: #f1f1f1;
+}
+
+.imgedit-menu div:hover {
+	border-color: #c1c1c1;
+	background-color: #eaeaea;
+}
+
+.imgedit-menu div.disabled {
+	border-color: #ccc;
+	background-color: #ddd;
+	filter: alpha(opacity=50);
+	opacity: 0.5;
+}
+
+#dashboard_recent_comments div.undo {
+	border-top-color: #dfdfdf;
+}
+
+.comment-ays,
+.comment-ays th {
+	border-color: #ddd;
+}
+
+.comment-ays th {
+	background-color: #f1f1f1;
+}
+
+#nav-menu-header, #nav-menu-footer, .menu-item-handle {
+	background: url("../images/ed-bg-vs.gif?ver=20101102") repeat-x scroll left top #cfdfe9;
+	border-top: solid #D1E5EE 1px;
+}
+
+#menu-management .nav-tab-active {
+	background: #eff8ff;
+	border-bottom-color: #eff8ff;
+}
Index: /tags/3.1/wp-admin/css/colors-fresh-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-fresh-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-fresh-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+.bar{border-right-color:transparent;border-left-color:#99d;}.plugins .togl{border-right-color:transparent;border-left-color:#ccc;}.post-com-count{background-image:url(../images/bubble_bg-rtl.gif);}.tablenav .tablenav-pages a{background:#eee url('../images/menu-bits-rtl.gif?ver=20100531') repeat-x scroll right -379px;}#upload-menu li.current{border-right-color:transparent;border-left-color:#448abd;}#adminmenu .wp-submenu .current a.current{background:transparent url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -289px;}#adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;}.folded #adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;}#adminmenu li.wp-has-current-submenu .wp-menu-toggle,#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle{background:transparent url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right -207px;}#adminmenu .wp-has-current-submenu ul li a.current{background:url(../images/menu-dark-rtl.gif) top right no-repeat!important;}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,#adminmenu .menu-top .current{background:url(../images/menu-bits-rtl.gif?ver=20100531) top right repeat-x;}#adminmenu li.wp-has-current-submenu ul li a{background:url(../images/menu-dark-rtl.gif) bottom right no-repeat!important;}#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle{background:transparent url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat right -207px;}#adminmenu .wp-has-submenu:hover .wp-menu-toggle,#adminmenu .wp-menu-open .wp-menu-toggle{background:transparent url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right -109px;}#adminmenu a.wp-has-submenu{background:#f1f1f1 url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right -379px;}#adminmenu .wp-submenu a{background:#fff url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -310px;}#adminmenu li.wp-has-current-submenu a.wp-has-submenu{background:#b5b5b5 url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right top;}.meta-box-sortables .postbox:hover .handlediv{background:transparent url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -111px;}#favorite-toggle{background:transparent url(../images/fav-arrow-rtl.gif?ver=20100531) no-repeat right -4px;}
Index: /tags/3.1/wp-admin/css/colors-fresh-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-fresh-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-fresh-rtl.dev.css	(revision 17487)
@@ -0,0 +1,78 @@
+.bar {
+	border-right-color: transparent;
+	border-left-color: #99d;
+}
+
+.plugins .togl {
+	border-right-color: transparent;
+	border-left-color: #ccc;
+}
+
+.post-com-count {
+	background-image: url(../images/bubble_bg-rtl.gif);
+}
+.tablenav .tablenav-pages a {
+	background: #eee url('../images/menu-bits-rtl.gif?ver=20100531') repeat-x scroll right -379px;
+}
+#upload-menu li.current {
+	border-right-color: transparent;
+	border-left-color: #448abd;
+}
+
+#adminmenu .wp-submenu .current a.current {
+	background: transparent url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll  right -289px;
+}
+
+#adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right -207px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+	background: url(../images/menu-dark-rtl.gif) top right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu .menu-top .current {
+	background: url(../images/menu-bits-rtl.gif?ver=20100531) top right repeat-x;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+	background: url(../images/menu-dark-rtl.gif) bottom right no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle, #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat right -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+	background: transparent url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right -109px;
+}
+
+#adminmenu a.wp-has-submenu {
+	background: #f1f1f1 url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right -379px;
+}
+
+#adminmenu .wp-submenu a {
+	background: #fff url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -310px;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-submenu {
+	background: #b5b5b5 url(../images/menu-bits-rtl.gif?ver=20100531) repeat-x scroll right top;
+}
+
+.meta-box-sortables .postbox:hover .handlediv {
+	background: transparent url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -111px;
+}
+#favorite-toggle {
+	background: transparent url(../images/fav-arrow-rtl.gif?ver=20100531) no-repeat right -4px;
+}
Index: /tags/3.1/wp-admin/css/colors-fresh.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-fresh.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-fresh.css	(revision 17487)
@@ -0,0 +1,1 @@
+html,.wp-dialog{background-color:#f9f9f9;}* html input,* html .widget{border-color:#dfdfdf;}textarea,input[type="text"],input[type="password"],input[type="file"],input[type="button"],input[type="submit"],input[type="reset"],select{border-color:#dfdfdf;background-color:#fff;}kbd,code{background:#eaeaea;}input[readonly]{background-color:#eee;}.find-box-search{border-color:#dfdfdf;background-color:#f1f1f1;}.find-box{background-color:#f1f1f1;}.find-box-inside{background-color:#fff;}a.page-numbers:hover{border-color:#999;}body,#wpbody,.form-table .pre{color:#333;}body>#upload-menu{border-bottom-color:#fff;}#postcustomstuff table,#your-profile fieldset,#rightnow,div.dashboard-widget,#dashboard-widgets p.dashboard-widget-links,#replyrow #ed_reply_toolbar input{border-color:#ccc;}#poststuff .inside label.spam,#poststuff .inside label.deleted{color:red;}#poststuff .inside label.waiting{color:orange;}#poststuff .inside label.approved{color:green;}#postcustomstuff table{border-color:#dfdfdf;background-color:#F9F9F9;}#postcustomstuff thead th{background-color:#F1F1F1;}#postcustomstuff table input,#postcustomstuff table textarea{border-color:#dfdfdf;background-color:#fff;}.widefat{border-color:#dfdfdf;background-color:#fff;}div.dashboard-widget-error{background-color:#c43;}div.dashboard-widget-notice{background-color:#cfe1ef;}div.dashboard-widget-submit{border-top-color:#ccc;}div.tabs-panel,.wp-tab-panel,ul.category-tabs li.tabs,ul.add-menu-item-tabs li.tabs,.wp-tab-active{border-color:#dfdfdf;}ul.category-tabs li.tabs,ul.add-menu-item-tabs li.tabs,.wp-tab-active{background-color:#f1f1f1;}input.disabled,textarea.disabled{background-color:#ccc;}#plugin-information .action-button a,#plugin-information .action-button a:hover,#plugin-information .action-button a:visited{color:#fff;}.widget .widget-top,.postbox h3,.stuffbox h3{background:#dfdfdf url("../images/gray-grad.png") repeat-x left top;text-shadow:#fff 0 1px 0;}.form-table th,.form-wrap label{color:#222;text-shadow:#fff 0 1px 0;}.description,.form-wrap p{color:#666;}strong .post-com-count span{background-color:#21759b;}.sorthelper{background-color:#ccf3fa;}.ac_match,.subsubsub a.current{color:#000;}.wrap h2{color:#464646;}.ac_over{background-color:#f0f0b8;}.ac_results{background-color:#fff;border-color:#808080;}.ac_results li{color:#101010;}.alternate,.alt{background-color:#f9f9f9;}.available-theme a.screenshot{background-color:#f1f1f1;border-color:#ddd;}.bar{background-color:#e8e8e8;border-right-color:#99d;}#media-upload,#media-upload .media-item .slidetoggle{background:#fff;}#media-upload .slidetoggle{border-top-color:#dfdfdf;}div.error,.login #login_error{background-color:#ffebe8;border-color:#c00;}div.error a{color:#c00;}.form-invalid{background-color:#ffebe8!important;}.form-invalid input,.form-invalid select{border-color:#c00!important;}.submit{border-color:#DFDFDF;}.highlight{background-color:#e4f2fd;color:#000;}.howto,.nonessential,#edit-slug-box,.form-input-tip,.rss-widget span.rss-date,.subsubsub{color:#666;}.media-item{border-bottom-color:#dfdfdf;}#wpbody-content #media-items .describe{border-top-color:#dfdfdf;}.media-upload-form label.form-help,td.help{color:#9a9a9a;}.post-com-count{background-image:url(../images/bubble_bg.gif);color:#fff;}.post-com-count span{background-color:#bbb;color:#fff;}.post-com-count:hover span{background-color:#d54e21;}.quicktags,.search{background-color:#ccc;color:#000;}.side-info h5{border-bottom-color:#dadada;}.side-info ul{color:#666;}.button,.button-secondary,.submit input,input[type=button],input[type=submit]{border-color:#bbb;color:#464646;}.button:hover,.button-secondary:hover,.submit input:hover,input[type=button]:hover,input[type=submit]:hover{color:#000;border-color:#666;}.button,.submit input,.button-secondary{background:#f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;text-shadow:rgba(255,255,255,1) 0 1px 0;}.button:active,.submit input:active,.button-secondary:active{background:#eee url(../images/white-grad-active.png) repeat-x scroll left top;}input.button-primary,button.button-primary,a.button-primary{border-color:#298cba;font-weight:bold;color:#fff;background:#21759B url(../images/button-grad.png) repeat-x scroll left top;text-shadow:rgba(0,0,0,0.3) 0 -1px 0;}input.button-primary:active,button.button-primary:active,a.button-primary:active{background:#21759b url(../images/button-grad-active.png) repeat-x scroll left top;color:#eaf2fa;}input.button-primary:hover,button.button-primary:hover,a.button-primary:hover,a.button-primary:focus,a.button-primary:active{border-color:#13455b;color:#eaf2fa;}.button-disabled,.button[disabled],.button:disabled,.button-secondary[disabled],.button-secondary:disabled,a.button.disabled{color:#aaa!important;border-color:#ddd!important;}.button-primary-disabled,.button-primary[disabled],.button-primary:disabled{color:#9FD0D5!important;background:#298CBA!important;}a:hover,a:active,a:focus{color:#d54e21;}#wphead #viewsite a:hover,#adminmenu a:hover,#adminmenu ul.wp-submenu a:hover,#the-comment-list .comment a:hover,#rightnow a:hover,#media-upload a.del-link:hover,div.dashboard-widget-submit input:hover,.subsubsub a:hover,.subsubsub a.current:hover,.ui-tabs-nav a:hover,.plugins .inactive a:hover,#all-plugins-table .plugins .inactive a:hover,#search-plugins-table .plugins .inactive a:hover{color:#d54e21;}#the-comment-list .comment-item,#dashboard-widgets #dashboard_quick_press form p.submit{border-color:#dfdfdf;}#side-sortables .category-tabs .tabs a,#side-sortables .add-menu-item-tabs .tabs a,.wp-tab-bar .wp-tab-active a{color:#333;}#rightnow .rbutton{background-color:#ebebeb;color:#264761;}.submitbox .submit{background-color:#464646;color:#ccc;}.plugins a.delete:hover,#all-plugins-table .plugins a.delete:hover,#search-plugins-table .plugins a.delete:hover,.submitbox .submitdelete{color:#f00;border-bottom-color:#f00;}.submitbox .submitdelete:hover,#media-items a.delete:hover{color:#fff;background-color:#f00;border-bottom-color:#f00;}#normal-sortables .submitbox .submitdelete:hover{color:#000;background-color:#f00;border-bottom-color:#f00;}.tablenav .dots{border-color:transparent;}.tablenav .next,.tablenav .prev{border-color:transparent;color:#21759b;}.tablenav .next:hover,.tablenav .prev:hover{border-color:transparent;color:#d54e21;}div.updated,.login .message{background-color:#ffffe0;border-color:#e6db55;}.update-message{color:#000;}a.page-numbers{border-bottom-color:#B8D3E2;}.commentlist li{border-bottom-color:#ccc;}.widefat td,.widefat th{border-color:#dfdfdf;}.widefat th{text-shadow:rgba(255,255,255,0.8) 0 1px 0;}.widefat thead tr th,.widefat tfoot tr th,h3.dashboard-widget-title,h3.dashboard-widget-title span,h3.dashboard-widget-title small,.find-box-head{color:#333;background:#dfdfdf url(../images/gray-grad.png) repeat-x scroll left top;}th.sortable a:hover,th.sortable a:active,th.sortable a:focus{color:#333;}h3.dashboard-widget-title small a{color:#d7d7d7;}h3.dashboard-widget-title small a:hover{color:#fff;}a,#adminmenu a,#poststuff #edButtonPreview,#poststuff #edButtonHTML,#the-comment-list p.comment-author strong a,#media-upload a.del-link,#media-items a.delete,.plugins a.delete,.ui-tabs-nav a{color:#21759b;}#adminmenu #awaiting-mod,#adminmenu .update-plugins,#sidemenu a .update-plugins,#rightnow .reallynow{background-color:#464646;color:#fff;-moz-box-shadow:#fff 0 -1px 0;-khtml-box-shadow:#fff 0 -1px 0;-webkit-box-shadow:#fff 0 -1px 0;box-shadow:#fff 0 -1px 0;}#plugin-information .action-button{background-color:#d54e21;color:#fff;}#adminmenu li.current a #awaiting-mod,#adminmenu li a.wp-has-current-submenu .update-plugins{background-color:#464646;color:#fff;-moz-box-shadow:#fff 0 -1px 0;-khtml-box-shadow:#fff 0 -1px 0;-webkit-box-shadow:#fff 0 -1px 0;box-shadow:#fff 0 -1px 0;}div#media-upload-header,div#plugin-information-header{background-color:#f9f9f9;border-bottom-color:#dfdfdf;}#currenttheme img{border-color:#666;}#dashboard_secondary div.dashboard-widget-content ul li a{background-color:#f9f9f9;}input.readonly,textarea.readonly{background-color:#ddd;}#ed_toolbar input,#ed_reply_toolbar input{background:#fff url("../images/fade-butt.png") repeat-x 0 -2px;}#editable-post-name{background-color:#fffbcc;}#edit-slug-box strong,.tablenav .displaying-num,#submitted-on,.submitted-on{color:#777;}.login #nav a{color:#21759b!important;}.login #nav a:hover{color:#d54e21!important;}#footer{color:#777;border-color:#d1d1d1;background:#d9d9d9;background:-moz-linear-gradient(bottom,#d7d7d7,#e4e4e4);background:-webkit-gradient(linear,left bottom,left top,from(#d7d7d7),to(#e4e4e4));}#media-items,.imgedit-group{border-color:#dfdfdf;}.checkbox,.side-info,.plugins tr,#your-profile #rich_editing{background-color:#fff;}.plugins .inactive,.plugins .inactive th,.plugins .inactive td,tr.inactive+tr.plugin-update-tr .plugin-update{background-color:#eee;}.plugin-update-tr .update-message{background-color:#fffbe4;border-color:#dfdfdf;}.plugins .active,.plugins .active th,.plugins .active td{color:#000;}.plugins .inactive a{color:#579;}#the-comment-list tr.undo,#the-comment-list div.undo{background-color:#f4f4f4;}#the-comment-list .unapproved{background-color:#ffffe0;}#the-comment-list .approve a{color:#006505;}#the-comment-list .unapprove a{color:#d98500;}table.widefat span.delete a,table.widefat span.trash a,table.widefat span.spam a,#dashboard_recent_comments .delete a,#dashboard_recent_comments .trash a,#dashboard_recent_comments .spam a{color:#bc0b0b;}.widget,#widget-list .widget-top,.postbox,#titlediv,#poststuff .postarea,.stuffbox{border-color:#dfdfdf;}.widget,.postbox{background-color:#fff;}.ui-sortable .postbox h3{color:#464646;}.widget .widget-top,.ui-sortable .postbox h3:hover{color:#000;}.curtime #timestamp{background-image:url(../images/date-button.gif);}#quicktags #ed_link{color:#00f;}#rightnow .youhave{background-color:#f0f6fb;}#rightnow a{color:#448abd;}.tagchecklist span a,#bulk-titles div a{background:url(../images/xit.gif) no-repeat;}.tagchecklist span a:hover,#bulk-titles div a:hover{background:url(../images/xit.gif) no-repeat -10px 0;}#update-nag,.update-nag{background-color:#FFFBCC;border-color:#E6DB55;color:#555;}.login #backtoblog a{color:#464646;}#wphead{border-bottom:#c6c6c6 1px solid;background:#d9d9d9;background:-moz-linear-gradient(bottom,#d7d7d7,#e4e4e4);background:-webkit-gradient(linear,left bottom,left top,from(#d7d7d7),to(#e4e4e4));}#wphead h1 a{color:#464646;}#user_info{color:#777;}#user_info a:link,#user_info a:visited,#footer a:link,#footer a:visited{color:#222;text-decoration:none;}#user_info a:hover,#footer a:hover{color:#000;text-decoration:underline!important;}div#media-upload-error,.file-error,abbr.required,.widget-control-remove:hover,table.widefat .delete a:hover,table.widefat .trash a:hover,table.widefat .spam a:hover,#dashboard_recent_comments .delete a:hover,#dashboard_recent_comments .trash a:hover #dashboard_recent_comments .spam a:hover{color:#f00;}#pass-strength-result{background-color:#eee;border-color:#ddd!important;}#pass-strength-result.bad{background-color:#ffb78c;border-color:#ff853c!important;}#pass-strength-result.good{background-color:#ffec8b;border-color:#fc0!important;}#pass-strength-result.short{background-color:#ffa0a0;border-color:#f04040!important;}#pass-strength-result.strong{background-color:#c3ff88;border-color:#8dff1c!important;}#quicktags{border-color:#dfdfdf;background-color:#dfdfdf;background-image:url("../images/ed-bg.gif");}#ed_toolbar input{border-color:#C3C3C3;}#ed_toolbar input:hover{border-color:#aaa;background:#ddd;}#poststuff .wp_themeSkin .mceStatusbar{border-color:#EDEDED;}#poststuff #edButtonPreview,#poststuff #edButtonHTML{background-color:#f1f1f1;border-color:#dfdfdf;color:#999;}#poststuff #editor-toolbar .active{border-bottom-color:#e9e9e9;background-color:#e9e9e9;color:#333;}#post-status-info{background-color:#EDEDED;}.wp_themeSkin *,.wp_themeSkin a:hover,.wp_themeSkin a:link,.wp_themeSkin a:visited,.wp_themeSkin a:active{color:#000;}.wp_themeSkin iframe{background:#fff;}.wp_themeSkin .mceStatusbar{color:#000;background-color:#f5f5f5;}.wp_themeSkin .mceButton{background-color:#e9e8e8;border-color:#B2B2B2;}.wp_themeSkin a.mceButtonEnabled:hover,.wp_themeSkin a.mceButtonActive,.wp_themeSkin a.mceButtonSelected{background:#d5d5d5;border-color:#777!important;}.wp_themeSkin .mceButtonDisabled{border-color:#ccc!important;}.wp_themeSkin .mceListBox .mceText,.wp_themeSkin .mceListBox .mceOpen{border-color:#B2B2B2;background-color:#d5d5d5;}.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,.wp_themeSkin .mceListBoxHover .mceOpen,.wp_themeSkin .mceListBoxSelected .mceOpen,.wp_themeSkin .mceListBoxSelected .mceText{border-color:#777!important;background-color:#d5d5d5;}.wp_themeSkin table.mceListBoxEnabled:hover .mceText,.wp_themeSkin .mceListBoxHover .mceText{border-color:#777!important;}.wp_themeSkin select.mceListBox{border-color:#B2B2B2;background-color:#fff;}.wp_themeSkin .mceSplitButton a.mceAction,.wp_themeSkin .mceSplitButton a.mceOpen{border-color:#B2B2B2;}.wp_themeSkin .mceSplitButton a.mceOpen:hover,.wp_themeSkin .mceSplitButtonSelected a.mceOpen,.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,.wp_themeSkin .mceSplitButton a.mceAction:hover{background-color:#d5d5d5;border-color:#777!important;}.wp_themeSkin .mceSplitButtonActive{background-color:#B2B2B2;}.wp_themeSkin div.mceColorSplitMenu table{background-color:#ebebeb;border-color:#B2B2B2;}.wp_themeSkin .mceColorSplitMenu a{border-color:#B2B2B2;}.wp_themeSkin .mceColorSplitMenu a.mceMoreColors{border-color:#fff;}.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover{border-color:#0A246A;background-color:#B6BDD2;}.wp_themeSkin a.mceMoreColors:hover{border-color:#0A246A;}.wp_themeSkin .mceMenu{border-color:#ddd;}.wp_themeSkin .mceMenu table{background-color:#ebeaeb;}.wp_themeSkin .mceMenu .mceText{color:#000;}.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,.wp_themeSkin .mceMenu .mceMenuItemActive{background-color:#f5f5f5;}.wp_themeSkin td.mceMenuItemSeparator{background-color:#aaa;}.wp_themeSkin .mceMenuItemTitle a{background-color:#ccc;border-bottom-color:#aaa;}.wp_themeSkin .mceMenuItemTitle span.mceText{color:#000;}.wp_themeSkin .mceMenuItemDisabled .mceText{color:#888;}.wp_themeSkin tr.mceFirst td.mceToolbar{background:#dfdfdf url("../images/ed-bg.gif") repeat-x scroll left top;border-color:#dfdfdf;}.wp-admin #mceModalBlocker{background:#000;}.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft{background:#444;border-left:1px solid #999;border-top:1px solid #999;-moz-border-radius:4px 0 0 0;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px;}.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight{background:#444;border-right:1px solid #999;border-top:1px solid #999;border-top-right-radius:4px;-khtml-border-top-right-radius:4px;-webkit-border-top-right-radius:4px;-moz-border-radius:0 4px 0 0;}.wp-admin .clearlooks2 .mceMiddle .mceLeft{background:#f1f1f1;border-left:1px solid #999;}.wp-admin .clearlooks2 .mceMiddle .mceRight{background:#f1f1f1;border-right:1px solid #999;}.wp-admin .clearlooks2 .mceBottom{background:#f1f1f1;border-bottom:1px solid #999;}.wp-admin .clearlooks2 .mceBottom .mceLeft{background:#f1f1f1;border-bottom:1px solid #999;border-left:1px solid #999;}.wp-admin .clearlooks2 .mceBottom .mceCenter{background:#f1f1f1;border-bottom:1px solid #999;}.wp-admin .clearlooks2 .mceBottom .mceRight{background:#f1f1f1;border-bottom:1px solid #999;border-right:1px solid #999;}.wp-admin .clearlooks2 .mceFocus .mceTop span{color:#e5e5e5;}#editorcontainer,#post-status-info,#titlediv #title,.editwidget .widget-inside{border-color:#dfdfdf;}#titlediv #title{background-color:#fff;}#tTips p#tTips_inside{background-color:#ddd;color:#333;}#timestampdiv input,#namediv input,#poststuff .inside .the-tagcloud{border-color:#ddd;}#adminmenu *{border-color:#e3e3e3;}#adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;}.folded #adminmenu li.wp-menu-separator{background:transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;}#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle{background:transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -207px;}#adminmenu .wp-has-submenu:hover .wp-menu-toggle,#adminmenu .wp-menu-open .wp-menu-toggle{background:transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -109px;}#adminmenu a.menu-top{background:#f1f1f1 url(../images/menu-bits.gif?ver=20100610) repeat-x scroll left -379px;}#adminmenu .wp-submenu a{background:#fff url(../images/menu-bits.gif?ver=20100610) no-repeat scroll 0 -310px;}#adminmenu .wp-has-current-submenu ul li a{background:none;}#adminmenu .wp-has-current-submenu ul li a.current{background:url(../images/menu-dark.gif) top left no-repeat!important;}.wp-has-current-submenu .wp-submenu{border-top:none!important;}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu{border-bottom:#aaa 1px solid;}#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,#adminmenu li.current a.menu-top{background:#e0e0e0 url(../images/menu-bits.gif?ver=20100610) top left repeat-x;border:#aaa 1px solid;color:#000;}#adminmenu li.wp-has-current-submenu .wp-submenu,#adminmenu li.wp-has-current-submenu ul li a{border-right-color:#aaa!important;border-left-color:#aaa!important;}#adminmenu li.wp-has-current-submenu ul li a{background:url(../images/menu-dark.gif) bottom left no-repeat!important;}#adminmenu li.wp-has-current-submenu ul{border-bottom-color:#aaa;}#adminmenu .wp-submenu .current a.current{background:transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll 0 -289px;}#adminmenu .wp-submenu a:hover{background-color:#EAF2FA!important;color:#333!important;}#adminmenu .wp-submenu li.current,#adminmenu .wp-submenu li.current a,#adminmenu .wp-submenu li.current a:hover{color:#333;background-color:#f5f5f5;background-image:none;border-color:#e3e3e3;}#adminmenu .wp-submenu ul{background-color:#fff;}.folded #adminmenu li.menu-top,#adminmenu .wp-submenu .wp-submenu-head{background-color:#F1F1F1;}.folded #adminmenu li.wp-has-current-submenu,.folded #adminmenu li.menu-top.current{background-color:#e6e6e6;}#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head{background-color:#EAEAEA;border-color:#aaa;}#adminmenu div.wp-submenu{background-color:transparent;}#adminmenu .menu-icon-dashboard div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -61px -33px;}#adminmenu .menu-icon-dashboard:hover div.wp-menu-image,#adminmenu .menu-icon-dashboard.wp-has-current-submenu div.wp-menu-image,#adminmenu .menu-icon-dashboard.current div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -61px -1px;}#adminmenu .menu-icon-post div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -272px -33px;}#adminmenu .menu-icon-post:hover div.wp-menu-image,#adminmenu .menu-icon-post.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -272px -1px;}#adminmenu .menu-icon-media div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -121px -33px;}#adminmenu .menu-icon-media:hover div.wp-menu-image,#adminmenu .menu-icon-media.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -121px -1px;}#adminmenu .menu-icon-links div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -91px -33px;}#adminmenu .menu-icon-links:hover div.wp-menu-image,#adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -91px -1px;}#adminmenu .menu-icon-page div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -151px -33px;}#adminmenu .menu-icon-page:hover div.wp-menu-image,#adminmenu .menu-icon-page.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -151px -1px;}#adminmenu .menu-icon-comments div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -31px -33px;}#adminmenu .menu-icon-comments:hover div.wp-menu-image,#adminmenu .menu-icon-comments.wp-has-current-submenu div.wp-menu-image,#adminmenu .menu-icon-comments.current div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -31px -1px;}#adminmenu .menu-icon-appearance div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -1px -33px;}#adminmenu .menu-icon-appearance:hover div.wp-menu-image,#adminmenu .menu-icon-appearance.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -1px -1px;}#adminmenu .menu-icon-plugins div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -181px -33px;}#adminmenu .menu-icon-plugins:hover div.wp-menu-image,#adminmenu .menu-icon-plugins.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -181px -1px;}#adminmenu .menu-icon-users div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -301px -33px;}#adminmenu .menu-icon-users:hover div.wp-menu-image,#adminmenu .menu-icon-users.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -301px -1px;}#adminmenu .menu-icon-tools div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -211px -33px;}#adminmenu .menu-icon-tools:hover div.wp-menu-image,#adminmenu .menu-icon-tools.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -211px -1px;}#adminmenu .menu-icon-settings div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -241px -33px;}#adminmenu .menu-icon-settings:hover div.wp-menu-image,#adminmenu .menu-icon-settings.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -241px -1px;}#adminmenu .menu-icon-site div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -361px -33px;}#adminmenu .menu-icon-site:hover div.wp-menu-image,#adminmenu .menu-icon-site.wp-has-current-submenu div.wp-menu-image{background:transparent url('../images/menu.png?ver=20100531') no-repeat scroll -361px -1px;}table.diff .diff-deletedline{background-color:#fdd;}table.diff .diff-deletedline del{background-color:#f99;}table.diff .diff-addedline{background-color:#dfd;}table.diff .diff-addedline ins{background-color:#9f9;}#att-info{background-color:#E4F2FD;}#sidemenu a{background-color:#f9f9f9;border-color:#f9f9f9;border-bottom-color:#dfdfdf;}#sidemenu a.current{background-color:#fff;border-color:#dfdfdf #dfdfdf #fff;color:#D54E21;}#screen-options-wrap,#contextual-help-wrap{background-color:#f1f1f1;border-color:#dfdfdf;}#screen-meta-links a.show-settings{color:#606060;}#screen-meta-links a.show-settings:hover{color:#000;}#replysubmit{background-color:#f1f1f1;border-top-color:#ddd;}#replyerror{border-color:#ddd;background-color:#f9f9f9;}#edithead,#replyhead{background-color:#f1f1f1;}#ed_reply_toolbar{background-color:#e9e9e9;}.vim-current,.vim-current th,.vim-current td{background-color:#E4F2FD!important;}.star-average,.star.star-rating{background-color:#fc0;}div.star.select:hover{background-color:#d00;}#plugin-information .fyi ul{background-color:#eaf3fa;}#plugin-information .fyi h2.mainheader{background-color:#cee1ef;}#plugin-information pre,#plugin-information code{background-color:#ededff;}#plugin-information pre{border:1px solid #ccc;}.inline-edit-row fieldset input[type="text"],.inline-edit-row fieldset textarea,#bulk-titles,#replyrow input{border-color:#ddd;}.inline-editor div.title{background-color:#EAF3FA;}.inline-editor ul.cat-checklist{background-color:#fff;border-color:#ddd;}.inline-editor .categories .catshow,.inline-editor .categories .cathide{color:#21759b;}.inline-editor .quick-edit-save{background-color:#f1f1f1;}#replyrow #ed_reply_toolbar input:hover{border-color:#aaa;background:#ddd;}fieldset.inline-edit-col-right .inline-edit-col{border-color:#dfdfdf;}.attention{color:#D54E21;}.meta-box-sortables .postbox:hover .handlediv{background:transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -111px;}#major-publishing-actions{background:#eaf2fa;}.tablenav .tablenav-pages{color:#555;}.tablenav .tablenav-pages a{border-color:#e3e3e3;background:#eee url('../images/menu-bits.gif?ver=20100610') repeat-x scroll left -379px;}.tablenav .tablenav-pages a:hover,.tablenav .tablenav-pages a:focus{color:#d54e21;}.tablenav .tablenav-pages a.disabled,.tablenav .tablenav-pages a.disabled:hover,.tablenav .tablenav-pages a.disabled:focus{color:#aaa;}.tablenav .tablenav-pages .current{background:#dfdfdf;border-color:#d3d3d3;}#availablethemes,#availablethemes td{border-color:#ddd;}#current-theme img{border-color:#999;}#TB_window #TB_title a.tb-theme-preview-link,#TB_window #TB_title a.tb-theme-preview-link:visited{color:#999;}#TB_window #TB_title a.tb-theme-preview-link:hover,#TB_window #TB_title a.tb-theme-preview-link:focus{color:#ccc;}.misc-pub-section{border-bottom-color:#eee;}#minor-publishing{border-bottom-color:#ddd;}#post-body .misc-pub-section{border-right-color:#eee;}.post-com-count span{background-color:#bbb;}.form-table .color-palette td{border-color:#fff;}.sortable-placeholder{border-color:#bbb;background-color:#f5f5f5;}#post-body ul.category-tabs li.tabs a,#post-body ul.add-menu-item-tabs li.tabs a,body.press-this ul.category-tabs li.tabs a{color:#333;}#wp_editimgbtn,#wp_delimgbtn,#wp_editgallery,#wp_delgallery{border-color:#999;background-color:#eee;}#wp_editimgbtn:hover,#wp_delimgbtn:hover,#wp_editgallery:hover,#wp_delgallery:hover{border-color:#555;background-color:#ccc;}#favorite-first{border-color:#c0c0c0;background:#f1f1f1;background:-moz-linear-gradient(bottom,#e7e7e7,#fff);background:-webkit-gradient(linear,left bottom,left top,from(#e7e7e7),to(#fff));}#favorite-inside{border-color:#c0c0c0;background-color:#fff;}#favorite-toggle{background:transparent url(../images/fav-arrow.gif?ver=20100531) no-repeat 0 -4px;}#favorite-actions a{color:#464646;}#favorite-actions a:hover{color:#000;}#favorite-inside a:hover{text-decoration:underline;}#screen-meta a.show-settings,.toggle-arrow{background-image:url("../images/screen-options-toggle.gif?ver=20100531");}#icon-edit,#icon-post{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -552px -5px;}#icon-index{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -137px -5px;}#icon-upload{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -251px -5px;}#icon-link-manager,#icon-link,#icon-link-category{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -190px -5px;}#icon-edit-pages,#icon-page{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -312px -5px;}#icon-edit-comments{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -72px -5px;}#icon-themes{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -11px -5px;}#icon-plugins{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -370px -5px;}#icon-users,#icon-profile,#icon-user-edit{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -600px -5px;}#icon-tools,#icon-admin{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -432px -5px;}#icon-options-general{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -492px -5px;}#icon-ms-admin{background:transparent url(../images/icons32.png?ver=20100531) no-repeat -659px -5px;}.view-switch #view-switch-list{background:transparent url(../images/list.png) no-repeat 0 0;}.view-switch .current #view-switch-list{background:transparent url(../images/list.png) no-repeat -40px 0;}.view-switch #view-switch-excerpt{background:transparent url(../images/list.png) no-repeat -20px 0;}.view-switch .current #view-switch-excerpt{background:transparent url(../images/list.png) no-repeat -60px 0;}#header-logo{background:transparent url(../images/wp-logo.png?ver=20100531) no-repeat scroll center center;}.popular-tags,.feature-filter{background-color:#fff;border-color:#DFDFDF;}#theme-information .action-button{border-top-color:#DFDFDF;}.theme-listing br.line{border-bottom-color:#ccc;}div.widgets-sortables,#widgets-left .inactive{background-color:#f1f1f1;border-color:#ddd;}#available-widgets .widget-holder{background-color:#fff;border-color:#ddd;}#widgets-left .sidebar-name{background-color:#aaa;background-image:url(../images/ed-bg.gif);text-shadow:#fff 0 1px 0;border-color:#dfdfdf;}#widgets-right .sidebar-name{background-image:url(../images/fav.png);text-shadow:#3f3f3f 0 -1px 0;background-color:#636363;border-color:#636363;color:#fff;}.sidebar-name:hover,#removing-widget{color:#d54e21;}#removing-widget span{color:black;}#widgets-left .sidebar-name-arrow{background:transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -109px;}#widgets-right .sidebar-name-arrow{background:transparent url(../images/widgets-arrow.gif?ver=20100531) no-repeat scroll 0 -1px;}.in-widget-title{color:#606060;}.deleting .widget-title *{color:#aaa;}.imgedit-menu div{border-color:#d5d5d5;background-color:#f1f1f1;}.imgedit-menu div:hover{border-color:#c1c1c1;background-color:#eaeaea;}.imgedit-menu div.disabled{border-color:#ccc;background-color:#ddd;filter:alpha(opacity=50);opacity:.5;}#dashboard_recent_comments div.undo{border-top-color:#dfdfdf;}.comment-ays,.comment-ays th{border-color:#ddd;}.comment-ays th{background-color:#f1f1f1;}#nav-menu-header,#nav-menu-footer,.menu-item-handle{background:url("../images/gray-grad.png") repeat-x scroll left top #dfdfdf;}#menu-management .nav-tab-active{background:#ececec;border-bottom-color:#ececec;}
Index: /tags/3.1/wp-admin/css/colors-fresh.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/colors-fresh.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/colors-fresh.dev.css	(revision 17487)
@@ -0,0 +1,1694 @@
+html,
+.wp-dialog {
+	background-color: #f9f9f9;
+}
+
+* html input,
+* html .widget {
+	border-color: #dfdfdf;
+}
+
+textarea,
+input[type="text"],
+input[type="password"],
+input[type="file"],
+input[type="button"],
+input[type="submit"],
+input[type="reset"],
+select {
+	border-color: #dfdfdf;
+	background-color: #fff;
+}
+
+kbd,
+code {
+	background: #eaeaea;
+}
+
+input[readonly] {
+	background-color: #eee;
+}
+
+.find-box-search {
+	border-color: #dfdfdf;
+	background-color: #f1f1f1;
+}
+
+.find-box {
+	background-color: #f1f1f1;
+}
+
+.find-box-inside {
+	background-color: #fff;
+}
+
+a.page-numbers:hover {
+	border-color: #999;
+}
+
+body,
+#wpbody,
+.form-table .pre {
+	color: #333;
+}
+
+body > #upload-menu {
+	border-bottom-color: #fff;
+}
+
+#postcustomstuff table,
+#your-profile fieldset,
+#rightnow,
+div.dashboard-widget,
+#dashboard-widgets p.dashboard-widget-links,
+#replyrow #ed_reply_toolbar input {
+	border-color: #ccc;
+}
+
+#poststuff .inside label.spam,
+#poststuff .inside label.deleted {
+	color: red;
+}
+
+#poststuff .inside label.waiting {
+	color: orange;
+}
+
+#poststuff .inside label.approved {
+	color: green;
+}
+
+#postcustomstuff table {
+	border-color: #dfdfdf;
+	background-color: #F9F9F9;
+}
+
+#postcustomstuff thead th {
+	background-color: #F1F1F1;
+}
+
+#postcustomstuff table input,
+#postcustomstuff table textarea {
+	border-color: #dfdfdf;
+	background-color: #fff;
+}
+
+.widefat {
+	border-color: #dfdfdf;
+	background-color: #fff;
+}
+
+div.dashboard-widget-error {
+	background-color: #c43;
+}
+
+div.dashboard-widget-notice {
+	background-color: #cfe1ef;
+}
+
+div.dashboard-widget-submit {
+	border-top-color: #ccc;
+}
+
+div.tabs-panel,
+.wp-tab-panel,
+ul.category-tabs li.tabs,
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
+	border-color: #dfdfdf;
+}
+
+ul.category-tabs li.tabs,
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
+	background-color: #f1f1f1;
+}
+
+input.disabled,
+textarea.disabled {
+	background-color: #ccc;
+}
+/* #upload-menu li a.upload-tab-link, */
+#plugin-information .action-button a,
+#plugin-information .action-button a:hover,
+#plugin-information .action-button a:visited {
+	color: #fff;
+}
+
+.widget .widget-top,
+.postbox h3,
+.stuffbox h3 {
+	background: #dfdfdf url("../images/gray-grad.png") repeat-x left top;
+	text-shadow: #fff 0 1px 0;
+}
+
+.form-table th,
+.form-wrap label {
+	color: #222;
+	text-shadow: #fff 0 1px 0;
+}
+
+.description,
+.form-wrap p {
+	color: #666;
+}
+
+strong .post-com-count span {
+	background-color: #21759b;
+}
+
+.sorthelper {
+	background-color: #ccf3fa;
+}
+
+.ac_match,
+.subsubsub a.current {
+	color: #000;
+}
+
+.wrap h2 {
+	color: #464646;
+}
+
+.ac_over {
+	background-color: #f0f0b8;
+}
+
+.ac_results {
+	background-color: #fff;
+	border-color: #808080;
+}
+
+.ac_results li {
+	color: #101010;
+}
+
+.alternate,
+.alt {
+	background-color: #f9f9f9;
+}
+
+.available-theme a.screenshot {
+	background-color: #f1f1f1;
+	border-color: #ddd;
+}
+
+.bar {
+	background-color: #e8e8e8;
+	border-right-color: #99d;
+}
+
+#media-upload,
+#media-upload .media-item .slidetoggle {
+	background: #fff;
+}
+
+#media-upload .slidetoggle {
+	border-top-color: #dfdfdf;
+}
+
+div.error,
+.login #login_error {
+	background-color: #ffebe8;
+	border-color: #c00;
+}
+
+div.error a {
+	color: #c00;
+}
+
+.form-invalid {
+	background-color: #ffebe8 !important;
+}
+
+.form-invalid input,
+.form-invalid select {
+	border-color: #c00 !important;
+}
+
+.submit {
+	border-color: #DFDFDF;
+}
+
+.highlight {
+	background-color: #e4f2fd;
+	color: #000;
+}
+
+.howto,
+.nonessential,
+#edit-slug-box,
+.form-input-tip,
+.rss-widget span.rss-date,
+.subsubsub {
+	color: #666;
+}
+
+.media-item {
+	border-bottom-color: #dfdfdf;
+}
+
+#wpbody-content #media-items .describe {
+	border-top-color: #dfdfdf;
+}
+
+.media-upload-form label.form-help,
+td.help {
+	color: #9a9a9a;
+}
+
+.post-com-count {
+	background-image: url(../images/bubble_bg.gif);
+	color: #fff;
+}
+
+.post-com-count span {
+	background-color: #bbb;
+	color: #fff;
+}
+
+.post-com-count:hover span {
+	background-color: #d54e21;
+}
+
+.quicktags, .search {
+	background-color: #ccc;
+	color: #000;
+}
+
+.side-info h5 {
+	border-bottom-color: #dadada;
+}
+
+.side-info ul {
+	color: #666;
+}
+
+.button,
+.button-secondary,
+.submit input,
+input[type=button],
+input[type=submit] {
+	border-color: #bbb;
+	color: #464646;
+}
+
+.button:hover,
+.button-secondary:hover,
+.submit input:hover,
+input[type=button]:hover,
+input[type=submit]:hover {
+	color: #000;
+	border-color: #666;
+}
+
+.button,
+.submit input,
+.button-secondary {
+	background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
+	text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+.button:active,
+.submit input:active,
+.button-secondary:active {
+	background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
+}
+
+input.button-primary,
+button.button-primary,
+a.button-primary {
+	border-color: #298cba;
+	font-weight: bold;
+	color: #fff;
+	background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
+	text-shadow: rgba(0,0,0,0.3) 0 -1px 0;
+}
+
+input.button-primary:active,
+button.button-primary:active,
+a.button-primary:active {
+	background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top;
+	color: #eaf2fa;
+}
+
+input.button-primary:hover,
+button.button-primary:hover,
+a.button-primary:hover,
+a.button-primary:focus,
+a.button-primary:active {
+	border-color: #13455b;
+	color: #eaf2fa;
+}
+
+.button-disabled,
+.button[disabled],
+.button:disabled,
+.button-secondary[disabled],
+.button-secondary:disabled,
+a.button.disabled {
+	color: #aaa !important;
+	border-color: #ddd !important;
+}
+
+.button-primary-disabled,
+.button-primary[disabled],
+.button-primary:disabled {
+	color: #9FD0D5 !important;
+	background: #298CBA !important;
+}
+
+a:hover,
+a:active,
+a:focus {
+	color: #d54e21;
+}
+
+#wphead #viewsite a:hover,
+#adminmenu a:hover,
+#adminmenu ul.wp-submenu a:hover,
+#the-comment-list .comment a:hover,
+#rightnow a:hover,
+#media-upload a.del-link:hover,
+div.dashboard-widget-submit input:hover,
+.subsubsub a:hover,
+.subsubsub a.current:hover,
+.ui-tabs-nav a:hover,
+.plugins .inactive a:hover,
+#all-plugins-table .plugins .inactive a:hover,
+#search-plugins-table .plugins .inactive a:hover {
+	color: #d54e21;
+}
+
+#the-comment-list .comment-item,
+#dashboard-widgets #dashboard_quick_press form p.submit {
+	border-color: #dfdfdf;
+}
+
+#side-sortables .category-tabs .tabs a,
+#side-sortables .add-menu-item-tabs .tabs a,
+.wp-tab-bar .wp-tab-active a {
+	color: #333;
+}
+
+#rightnow .rbutton {
+	background-color: #ebebeb;
+	color: #264761;
+}
+
+.submitbox .submit {
+	background-color: #464646;
+	color: #ccc;
+}
+
+.plugins a.delete:hover,
+#all-plugins-table .plugins a.delete:hover,
+#search-plugins-table .plugins a.delete:hover,
+.submitbox .submitdelete {
+	color: #f00;
+	border-bottom-color: #f00;
+}
+
+.submitbox .submitdelete:hover,
+#media-items a.delete:hover {
+	color: #fff;
+	background-color: #f00;
+	border-bottom-color: #f00;
+}
+
+#normal-sortables .submitbox .submitdelete:hover {
+	color: #000;
+	background-color: #f00;
+	border-bottom-color: #f00;
+}
+
+.tablenav .dots {
+	border-color: transparent;
+}
+
+.tablenav .next,
+.tablenav .prev {
+	border-color: transparent;
+	color: #21759b;
+}
+
+.tablenav .next:hover,
+.tablenav .prev:hover {
+	border-color: transparent;
+	color: #d54e21;
+}
+
+div.updated,
+.login .message {
+	background-color: #ffffe0;
+	border-color: #e6db55;
+}
+
+.update-message {
+	color: #000;
+}
+
+a.page-numbers {
+	border-bottom-color: #B8D3E2;
+}
+
+.commentlist li {
+	border-bottom-color: #ccc;
+}
+
+.widefat td,
+.widefat th {
+	border-color: #dfdfdf;
+}
+
+.widefat th {
+	text-shadow: rgba(255,255,255,0.8) 0 1px 0;
+}
+
+.widefat thead tr th,
+.widefat tfoot tr th,
+h3.dashboard-widget-title,
+h3.dashboard-widget-title span,
+h3.dashboard-widget-title small,
+.find-box-head {
+	color: #333;
+	background: #dfdfdf url(../images/gray-grad.png) repeat-x scroll left top;
+}
+
+th.sortable a:hover, th.sortable a:active, th.sortable a:focus {
+	color: #333;
+}
+
+h3.dashboard-widget-title small a {
+	color: #d7d7d7;
+}
+
+h3.dashboard-widget-title small a:hover {
+	color: #fff;
+}
+
+a,
+#adminmenu a,
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML,
+#the-comment-list p.comment-author strong a,
+#media-upload a.del-link,
+#media-items a.delete,
+.plugins a.delete,
+.ui-tabs-nav a {
+	color: #21759b;
+}
+
+#adminmenu #awaiting-mod,
+#adminmenu .update-plugins,
+#sidemenu a .update-plugins,
+#rightnow .reallynow {
+	background-color: #464646;
+	color: #fff;
+	-moz-box-shadow: #fff 0 -1px 0;
+	-khtml-box-shadow: #fff 0 -1px 0;
+	-webkit-box-shadow: #fff 0 -1px 0;
+	box-shadow: #fff 0 -1px 0;
+}
+#plugin-information .action-button {
+	background-color: #d54e21;
+	color: #fff;
+}
+
+#adminmenu li.current a #awaiting-mod,
+#adminmenu  li a.wp-has-current-submenu .update-plugins{
+	background-color: #464646;
+	color: #fff;
+	-moz-box-shadow: #fff 0 -1px 0;
+	-khtml-box-shadow: #fff 0 -1px 0;
+	-webkit-box-shadow: #fff 0 -1px 0;
+	box-shadow: #fff 0 -1px 0;
+}
+
+div#media-upload-header,
+div#plugin-information-header {
+	background-color: #f9f9f9;
+	border-bottom-color: #dfdfdf;
+}
+
+#currenttheme img {
+	border-color: #666;
+}
+
+#dashboard_secondary div.dashboard-widget-content ul li a {
+	background-color: #f9f9f9;
+}
+
+input.readonly, textarea.readonly {
+	background-color: #ddd;
+}
+
+#ed_toolbar input,
+#ed_reply_toolbar input {
+	background: #fff url("../images/fade-butt.png") repeat-x 0 -2px;
+}
+
+#editable-post-name {
+	background-color: #fffbcc;
+}
+
+#edit-slug-box strong,
+.tablenav .displaying-num,
+#submitted-on,
+.submitted-on {
+	color: #777;
+}
+
+.login #nav a {
+	color: #21759b !important;
+}
+
+.login #nav a:hover {
+	color: #d54e21 !important;
+}
+
+#footer {
+	color: #777;
+	border-color: #d1d1d1;
+	background: #d9d9d9; /* fallback color */
+	background:-moz-linear-gradient(bottom,  #d7d7d7,  #e4e4e4);
+	background:-webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4));
+}
+
+#media-items,
+.imgedit-group {
+	border-color: #dfdfdf;
+}
+
+.checkbox,
+.side-info,
+.plugins tr,
+#your-profile #rich_editing {
+	background-color: #fff;
+}
+
+.plugins .inactive,
+.plugins .inactive th,
+.plugins .inactive td,
+tr.inactive + tr.plugin-update-tr .plugin-update {
+	background-color: #eee;
+}
+
+.plugin-update-tr .update-message {
+	background-color: #fffbe4;
+	border-color: #dfdfdf;
+}
+
+.plugins .active,
+.plugins .active th,
+.plugins .active td {
+	color: #000;
+}
+
+.plugins .inactive a {
+	color: #557799;
+}
+
+#the-comment-list tr.undo,
+#the-comment-list div.undo {
+	background-color: #f4f4f4;
+}
+
+#the-comment-list .unapproved {
+	background-color: #ffffe0;
+}
+
+#the-comment-list .approve a {
+	color: #006505;
+}
+
+#the-comment-list .unapprove a {
+	color: #d98500;
+}
+
+table.widefat span.delete a,
+table.widefat span.trash a,
+table.widefat span.spam a,
+#dashboard_recent_comments .delete a,
+#dashboard_recent_comments .trash a,
+#dashboard_recent_comments .spam a {
+	color: #bc0b0b;
+}
+
+.widget,
+#widget-list .widget-top,
+.postbox,
+#titlediv,
+#poststuff .postarea,
+.stuffbox {
+	border-color: #dfdfdf;
+}
+
+.widget,
+.postbox {
+	background-color: #fff;
+}
+
+.ui-sortable .postbox h3 {
+	color: #464646;
+}
+
+.widget .widget-top,
+.ui-sortable .postbox h3:hover {
+	color: #000;
+}
+
+.curtime #timestamp {
+	background-image: url(../images/date-button.gif);
+}
+
+#quicktags #ed_link {
+	color: #00f;
+}
+
+#rightnow .youhave {
+	background-color: #f0f6fb;
+}
+
+#rightnow a {
+	color: #448abd;
+}
+
+.tagchecklist span a,
+#bulk-titles div a {
+	background: url(../images/xit.gif) no-repeat;
+}
+
+.tagchecklist span a:hover,
+#bulk-titles div a:hover {
+	background: url(../images/xit.gif) no-repeat -10px 0;
+}
+
+#update-nag, .update-nag {
+	background-color: #FFFBCC;
+	border-color: #E6DB55;
+	color: #555;
+}
+
+.login #backtoblog a {
+	color: #464646;
+}
+
+#wphead {
+	border-bottom:#c6c6c6 1px solid;
+	background: #d9d9d9; /* fallback color */
+	background:-moz-linear-gradient(bottom,  #d7d7d7,  #e4e4e4);
+	background:-webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4));
+}
+
+#wphead h1 a {
+	color: #464646;
+}
+
+#user_info {
+	color: #777;
+}
+
+#user_info a:link,
+#user_info a:visited,
+#footer a:link,
+#footer a:visited {
+	color: #222;
+	text-decoration: none;
+}
+
+#user_info a:hover,
+#footer a:hover {
+	color: #000;
+	text-decoration: underline !important;
+}
+
+div#media-upload-error,
+.file-error,
+abbr.required,
+.widget-control-remove:hover,
+table.widefat .delete a:hover,
+table.widefat .trash a:hover,
+table.widefat .spam a:hover,
+#dashboard_recent_comments .delete a:hover,
+#dashboard_recent_comments .trash a:hover
+#dashboard_recent_comments .spam a:hover {
+	color: #f00;
+}
+
+#pass-strength-result {
+	background-color: #eee;
+	border-color: #ddd !important;
+}
+
+#pass-strength-result.bad {
+	background-color: #ffb78c;
+	border-color: #ff853c !important;
+}
+
+#pass-strength-result.good {
+	background-color: #ffec8b;
+	border-color: #fc0 !important;
+}
+
+#pass-strength-result.short {
+	background-color: #ffa0a0;
+	border-color: #f04040 !important;
+}
+
+#pass-strength-result.strong {
+	background-color: #c3ff88;
+	border-color: #8dff1c !important;
+}
+
+/* editors */
+#quicktags {
+	border-color: #dfdfdf;
+	background-color: #dfdfdf;
+	background-image: url("../images/ed-bg.gif");
+}
+
+#ed_toolbar input {
+	border-color: #C3C3C3;
+}
+
+#ed_toolbar input:hover {
+	border-color: #aaa;
+	background: #ddd;
+}
+
+#poststuff .wp_themeSkin .mceStatusbar {
+	border-color: #EDEDED;
+}
+
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+	background-color: #f1f1f1;
+	border-color: #dfdfdf;
+	color: #999;
+}
+
+#poststuff #editor-toolbar .active {
+	border-bottom-color: #e9e9e9;
+	background-color: #e9e9e9;
+	color: #333;
+}
+
+/* TinyMCE */
+#post-status-info {
+	background-color: #EDEDED;
+}
+
+.wp_themeSkin *,
+.wp_themeSkin a:hover,
+.wp_themeSkin a:link,
+.wp_themeSkin a:visited,
+.wp_themeSkin a:active {
+	 color: #000;
+}
+
+/* Containers */
+.wp_themeSkin iframe {
+	background: #fff;
+}
+
+/* Layout */
+.wp_themeSkin .mceStatusbar {
+	color: #000;
+	background-color: #f5f5f5;
+}
+
+/* Button */
+.wp_themeSkin .mceButton {
+	background-color: #e9e8e8;
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin a.mceButtonEnabled:hover,
+.wp_themeSkin a.mceButtonActive,
+.wp_themeSkin a.mceButtonSelected {
+	background: #d5d5d5;
+	border-color: #777 !important;
+}
+
+.wp_themeSkin .mceButtonDisabled {
+	border-color: #ccc !important;
+}
+
+/* ListBox */
+.wp_themeSkin .mceListBox .mceText,
+.wp_themeSkin .mceListBox .mceOpen  {
+	border-color: #B2B2B2;
+	background-color: #d5d5d5;
+}
+
+.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
+.wp_themeSkin .mceListBoxHover .mceOpen,
+.wp_themeSkin .mceListBoxSelected .mceOpen,
+.wp_themeSkin .mceListBoxSelected .mceText {
+	border-color: #777 !important;
+	background-color: #d5d5d5;
+}
+
+.wp_themeSkin table.mceListBoxEnabled:hover .mceText,
+.wp_themeSkin .mceListBoxHover .mceText {
+	border-color: #777 !important;
+}
+
+.wp_themeSkin select.mceListBox {
+	border-color: #B2B2B2;
+	background-color: #fff;
+}
+
+/* SplitButton */
+.wp_themeSkin .mceSplitButton a.mceAction,
+.wp_themeSkin .mceSplitButton a.mceOpen {
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin .mceSplitButton a.mceOpen:hover,
+.wp_themeSkin .mceSplitButtonSelected a.mceOpen,
+.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,
+.wp_themeSkin .mceSplitButton a.mceAction:hover {
+	background-color: #d5d5d5;
+	border-color: #777 !important;
+}
+
+.wp_themeSkin .mceSplitButtonActive {
+	background-color: #B2B2B2;
+}
+
+/* ColorSplitButton */
+.wp_themeSkin div.mceColorSplitMenu table {
+	background-color: #ebebeb;
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin .mceColorSplitMenu a {
+	border-color: #B2B2B2;
+}
+
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
+	border-color: #fff;
+}
+
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {
+	border-color: #0A246A;
+	background-color: #B6BDD2;
+}
+
+.wp_themeSkin a.mceMoreColors:hover {
+	border-color: #0A246A;
+}
+
+/* Menu */
+.wp_themeSkin .mceMenu {
+	border-color: #ddd;
+}
+
+.wp_themeSkin .mceMenu table {
+	background-color: #ebeaeb;
+}
+
+.wp_themeSkin .mceMenu .mceText {
+	color: #000;
+}
+
+.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,
+.wp_themeSkin .mceMenu .mceMenuItemActive {
+	background-color: #f5f5f5;
+}
+.wp_themeSkin td.mceMenuItemSeparator {
+	background-color: #aaa;
+}
+.wp_themeSkin .mceMenuItemTitle a {
+	background-color: #ccc;
+	border-bottom-color: #aaa;
+}
+.wp_themeSkin .mceMenuItemTitle span.mceText {
+	color: #000;
+}
+.wp_themeSkin .mceMenuItemDisabled .mceText {
+	color: #888;
+}
+
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+	background: #dfdfdf url("../images/ed-bg.gif") repeat-x scroll left top;
+	border-color: #dfdfdf;
+}
+
+.wp-admin #mceModalBlocker {
+	background: #000;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft {
+	background: #444444;
+	border-left: 1px solid #999;
+	border-top: 1px solid #999;
+	-moz-border-radius: 4px 0 0 0;
+	-webkit-border-top-left-radius: 4px;
+	-khtml-border-top-left-radius: 4px;
+	border-top-left-radius: 4px;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight {
+	background: #444444;
+	border-right: 1px solid #999;
+	border-top: 1px solid #999;
+	border-top-right-radius: 4px;
+	-khtml-border-top-right-radius: 4px;
+	-webkit-border-top-right-radius: 4px;
+	-moz-border-radius: 0 4px 0 0;
+}
+
+.wp-admin .clearlooks2 .mceMiddle .mceLeft {
+	background: #f1f1f1;
+	border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceMiddle .mceRight {
+	background: #f1f1f1;
+	border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceLeft {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+	border-left: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceCenter {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceBottom .mceRight {
+	background: #f1f1f1;
+	border-bottom: 1px solid #999;
+	border-right: 1px solid #999;
+}
+
+.wp-admin .clearlooks2 .mceFocus .mceTop span {
+	color: #e5e5e5;
+}
+/* end TinyMCE */
+
+#editorcontainer,
+#post-status-info,
+#titlediv #title,
+.editwidget .widget-inside {
+	border-color: #dfdfdf;
+}
+
+#titlediv #title {
+	background-color: #fff;
+}
+
+#tTips p#tTips_inside {
+	background-color: #ddd;
+	color: #333;
+}
+
+#timestampdiv input,
+#namediv input,
+#poststuff .inside .the-tagcloud {
+	border-color: #ddd;
+}
+
+/* menu */
+#adminmenu * {
+	border-color: #e3e3e3;
+}
+
+#adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll left 5px;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+	background: transparent url(../images/menu-arrows.gif) no-repeat scroll right -34px;
+}
+
+#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
+#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
+	background: transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -207px;
+}
+
+#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
+#adminmenu .wp-menu-open .wp-menu-toggle {
+	background: transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -109px;
+}
+
+#adminmenu a.menu-top {
+	background: #f1f1f1 url(../images/menu-bits.gif?ver=20100610) repeat-x scroll left -379px;
+}
+
+#adminmenu .wp-submenu a {
+	background: #fff url(../images/menu-bits.gif?ver=20100610) no-repeat scroll 0 -310px;
+}
+
+#adminmenu .wp-has-current-submenu ul li a {
+	background: none;
+}
+
+#adminmenu .wp-has-current-submenu ul li a.current {
+	background: url(../images/menu-dark.gif) top left no-repeat !important;
+}
+
+.wp-has-current-submenu .wp-submenu {
+	border-top: none !important;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu {
+	border-bottom: #aaa 1px solid;
+}
+
+#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
+#adminmenu li.current a.menu-top {
+	background: #e0e0e0 url(../images/menu-bits.gif?ver=20100610) top left repeat-x;
+	border: #aaa 1px solid;
+	color: #000;
+}
+
+#adminmenu li.wp-has-current-submenu .wp-submenu,
+#adminmenu li.wp-has-current-submenu ul li a {
+	border-right-color: #aaa !important;
+	border-left-color: #aaa !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul li a {
+	background: url(../images/menu-dark.gif) bottom left no-repeat !important;
+}
+
+#adminmenu li.wp-has-current-submenu ul {
+	border-bottom-color: #aaa;
+}
+
+#adminmenu .wp-submenu .current a.current {
+	background: transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll  0 -289px;
+}
+
+#adminmenu .wp-submenu a:hover {
+	background-color: #EAF2FA !important;
+	color: #333 !important;
+}
+
+#adminmenu .wp-submenu li.current,
+#adminmenu .wp-submenu li.current a,
+#adminmenu .wp-submenu li.current a:hover {
+	color: #333;
+	background-color: #f5f5f5;
+	background-image: none;
+	border-color: #e3e3e3;
+}
+
+#adminmenu .wp-submenu ul {
+	background-color: #fff;
+}
+
+.folded #adminmenu li.menu-top,
+#adminmenu .wp-submenu .wp-submenu-head {
+	background-color: #F1F1F1;
+}
+
+.folded #adminmenu li.wp-has-current-submenu,
+.folded #adminmenu li.menu-top.current {
+	background-color: #e6e6e6;
+}
+
+#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
+	background-color: #EAEAEA;
+	border-color: #aaa;
+}
+
+#adminmenu div.wp-submenu {
+	background-color: transparent;
+}
+
+/* menu icons */
+#adminmenu .menu-icon-dashboard div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -61px -33px;
+}
+
+#adminmenu .menu-icon-dashboard:hover div.wp-menu-image,
+#adminmenu .menu-icon-dashboard.wp-has-current-submenu div.wp-menu-image,
+#adminmenu .menu-icon-dashboard.current div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -61px -1px;
+}
+
+#adminmenu .menu-icon-post div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -272px -33px;
+}
+
+#adminmenu .menu-icon-post:hover div.wp-menu-image,
+#adminmenu .menu-icon-post.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -272px -1px;
+}
+
+#adminmenu .menu-icon-media div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -121px -33px;
+}
+
+#adminmenu .menu-icon-media:hover div.wp-menu-image,
+#adminmenu .menu-icon-media.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -121px -1px;
+}
+
+#adminmenu .menu-icon-links div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -91px -33px;
+}
+
+#adminmenu .menu-icon-links:hover div.wp-menu-image,
+#adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -91px -1px;
+}
+
+#adminmenu .menu-icon-page div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -151px -33px;
+}
+
+#adminmenu .menu-icon-page:hover div.wp-menu-image,
+#adminmenu .menu-icon-page.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -151px -1px;
+}
+
+#adminmenu .menu-icon-comments div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -31px -33px;
+}
+
+#adminmenu .menu-icon-comments:hover div.wp-menu-image,
+#adminmenu .menu-icon-comments.wp-has-current-submenu div.wp-menu-image,
+#adminmenu .menu-icon-comments.current div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -31px -1px;
+}
+
+#adminmenu .menu-icon-appearance div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -1px -33px;
+}
+
+#adminmenu .menu-icon-appearance:hover div.wp-menu-image,
+#adminmenu .menu-icon-appearance.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -1px -1px;
+}
+
+#adminmenu .menu-icon-plugins div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -181px -33px;
+}
+
+#adminmenu .menu-icon-plugins:hover div.wp-menu-image,
+#adminmenu .menu-icon-plugins.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -181px -1px;
+}
+
+#adminmenu .menu-icon-users div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -301px -33px;
+}
+
+#adminmenu .menu-icon-users:hover div.wp-menu-image,
+#adminmenu .menu-icon-users.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -301px -1px;
+}
+
+#adminmenu .menu-icon-tools div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -211px -33px;
+}
+
+#adminmenu .menu-icon-tools:hover div.wp-menu-image,
+#adminmenu .menu-icon-tools.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -211px -1px;
+}
+
+#adminmenu .menu-icon-settings div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -241px -33px;
+}
+
+#adminmenu .menu-icon-settings:hover div.wp-menu-image,
+#adminmenu .menu-icon-settings.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -241px -1px;
+}
+
+#adminmenu .menu-icon-site div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -361px -33px;
+}
+
+#adminmenu .menu-icon-site:hover div.wp-menu-image,
+#adminmenu .menu-icon-site.wp-has-current-submenu div.wp-menu-image {
+	background: transparent url('../images/menu.png?ver=20100531') no-repeat scroll -361px -1px;
+}
+/* end menu */
+
+
+/* Diff */
+table.diff .diff-deletedline {
+	background-color: #fdd;
+}
+
+table.diff .diff-deletedline del {
+	background-color: #f99;
+}
+
+table.diff .diff-addedline {
+	background-color: #dfd;
+}
+
+table.diff .diff-addedline ins {
+	background-color: #9f9;
+}
+
+#att-info {
+	background-color: #E4F2FD;
+}
+
+/* edit image */
+#sidemenu a {
+	background-color: #f9f9f9;
+	border-color: #f9f9f9;
+	border-bottom-color: #dfdfdf;
+}
+
+#sidemenu a.current {
+	background-color: #fff;
+	border-color: #dfdfdf #dfdfdf #fff;
+	color: #D54E21;
+}
+
+#screen-options-wrap,
+#contextual-help-wrap {
+	background-color: #f1f1f1;
+	border-color: #dfdfdf;
+}
+
+#screen-meta-links a.show-settings {
+	color: #606060;
+}
+
+#screen-meta-links a.show-settings:hover {
+	color: #000;
+}
+
+#replysubmit {
+	background-color: #f1f1f1;
+	border-top-color: #ddd;
+}
+
+#replyerror {
+	border-color: #ddd;
+	background-color: #f9f9f9;
+}
+
+#edithead,
+#replyhead {
+	background-color: #f1f1f1;
+}
+
+#ed_reply_toolbar {
+	background-color: #e9e9e9;
+}
+
+/* table vim shortcuts */
+.vim-current,
+.vim-current th,
+.vim-current td {
+	background-color: #E4F2FD !important;
+}
+
+/* Install Plugins */
+.star-average,
+.star.star-rating {
+	background-color: #fc0;
+}
+
+div.star.select:hover {
+	background-color: #d00;
+}
+
+#plugin-information .fyi ul {
+	background-color: #eaf3fa;
+}
+
+#plugin-information .fyi h2.mainheader {
+	background-color: #cee1ef;
+}
+
+#plugin-information pre,
+#plugin-information code {
+	background-color: #ededff;
+}
+
+#plugin-information pre {
+	border: 1px solid #ccc;
+}
+
+/* inline editor */
+.inline-edit-row fieldset input[type="text"],
+.inline-edit-row fieldset textarea,
+#bulk-titles,
+#replyrow input {
+	border-color: #ddd;
+}
+
+.inline-editor div.title {
+	background-color: #EAF3FA;
+}
+
+.inline-editor ul.cat-checklist {
+	background-color: #fff;
+	border-color: #ddd;
+}
+
+.inline-editor .categories .catshow,
+.inline-editor .categories .cathide {
+	color: #21759b;
+}
+
+.inline-editor .quick-edit-save {
+	background-color: #f1f1f1;
+}
+
+#replyrow #ed_reply_toolbar input:hover {
+	border-color: #aaa;
+	background: #ddd;
+}
+
+fieldset.inline-edit-col-right .inline-edit-col {
+	border-color: #dfdfdf;
+}
+
+.attention {
+	color: #D54E21;
+}
+
+.meta-box-sortables .postbox:hover .handlediv {
+	background: transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -111px;
+}
+
+#major-publishing-actions {
+	background: #eaf2fa;
+}
+
+.tablenav .tablenav-pages {
+	color: #555;
+}
+
+.tablenav .tablenav-pages a {
+	border-color: #e3e3e3;
+	background: #eee url('../images/menu-bits.gif?ver=20100610') repeat-x scroll left -379px;
+}
+
+.tablenav .tablenav-pages a:hover,
+.tablenav .tablenav-pages a:focus {
+	color: #d54e21;
+}
+
+.tablenav .tablenav-pages a.disabled,
+.tablenav .tablenav-pages a.disabled:hover,
+.tablenav .tablenav-pages a.disabled:focus {
+	color: #aaa;
+}
+
+.tablenav .tablenav-pages .current {
+	background: #dfdfdf;
+	border-color: #d3d3d3;
+}
+
+#availablethemes,
+#availablethemes td {
+	border-color: #ddd;
+}
+
+#current-theme img {
+	border-color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link,
+#TB_window #TB_title a.tb-theme-preview-link:visited {
+	color: #999;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link:hover,
+#TB_window #TB_title a.tb-theme-preview-link:focus {
+	color: #ccc;
+}
+
+.misc-pub-section {
+	border-bottom-color: #eee;
+}
+
+#minor-publishing {
+	border-bottom-color: #ddd;
+}
+
+#post-body .misc-pub-section {
+	border-right-color: #eee;
+}
+
+.post-com-count span {
+	background-color: #bbb;
+}
+
+.form-table .color-palette td {
+	border-color: #fff;
+}
+
+.sortable-placeholder {
+	border-color: #bbb;
+	background-color: #f5f5f5;
+}
+
+#post-body ul.category-tabs li.tabs a,
+#post-body ul.add-menu-item-tabs li.tabs a,
+body.press-this ul.category-tabs li.tabs a {
+	color: #333;
+}
+
+#wp_editimgbtn,
+#wp_delimgbtn,
+#wp_editgallery,
+#wp_delgallery {
+	border-color: #999;
+	background-color: #eee;
+}
+
+#wp_editimgbtn:hover,
+#wp_delimgbtn:hover,
+#wp_editgallery:hover,
+#wp_delgallery:hover {
+	border-color: #555;
+	background-color: #ccc;
+}
+
+#favorite-first {
+	border-color: #c0c0c0;
+	background: #f1f1f1; /* fallback color */
+	background:-moz-linear-gradient(bottom,  #e7e7e7,  #fff);
+	background:-webkit-gradient(linear, left bottom, left top, from(#e7e7e7), to(#fff));
+}
+
+#favorite-inside {
+	border-color: #c0c0c0;
+	background-color: #fff;
+}
+
+#favorite-toggle {
+	background: transparent url(../images/fav-arrow.gif?ver=20100531) no-repeat 0 -4px;
+}
+
+#favorite-actions a {
+	color: #464646;
+}
+
+#favorite-actions a:hover {
+	color: #000;
+}
+
+#favorite-inside a:hover {
+	text-decoration: underline;
+}
+
+#screen-meta a.show-settings,
+.toggle-arrow {
+	background-image:url("../images/screen-options-toggle.gif?ver=20100531");
+}
+
+#icon-edit,
+#icon-post {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -552px -5px;
+}
+
+#icon-index {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -137px -5px;
+}
+
+#icon-upload {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -251px -5px;
+}
+
+#icon-link-manager,
+#icon-link,
+#icon-link-category {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -190px -5px;
+}
+
+#icon-edit-pages,
+#icon-page {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -312px -5px;
+}
+
+#icon-edit-comments {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -72px -5px;
+}
+
+#icon-themes {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -11px -5px;
+}
+
+#icon-plugins {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -370px -5px;
+}
+
+#icon-users,
+#icon-profile,
+#icon-user-edit {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -600px -5px;
+}
+
+#icon-tools,
+#icon-admin {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -432px -5px;
+}
+
+#icon-options-general {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -492px -5px;
+}
+
+#icon-ms-admin {
+	background: transparent url(../images/icons32.png?ver=20100531) no-repeat -659px -5px;
+}
+
+.view-switch #view-switch-list {
+	background: transparent url(../images/list.png) no-repeat 0 0;
+}
+
+.view-switch .current #view-switch-list {
+	background: transparent url(../images/list.png) no-repeat -40px 0;
+}
+
+.view-switch #view-switch-excerpt {
+	background: transparent url(../images/list.png) no-repeat -20px 0;
+}
+
+.view-switch .current #view-switch-excerpt {
+	background: transparent url(../images/list.png) no-repeat -60px 0;
+}
+
+#header-logo {
+	background: transparent url(../images/wp-logo.png?ver=20100531) no-repeat scroll center center;
+}
+
+.popular-tags,
+.feature-filter {
+	background-color: #fff;
+	border-color: #DFDFDF;
+}
+
+#theme-information .action-button {
+	border-top-color: #DFDFDF;
+}
+
+.theme-listing br.line {
+	border-bottom-color: #ccc;
+}
+
+div.widgets-sortables,
+#widgets-left .inactive {
+	background-color: #f1f1f1;
+	border-color: #ddd;
+}
+
+#available-widgets .widget-holder {
+	background-color: #fff;
+	border-color: #ddd;
+}
+
+#widgets-left .sidebar-name {
+	background-color: #aaa;
+	background-image: url(../images/ed-bg.gif);
+	text-shadow: #fff 0 1px 0;
+	border-color: #dfdfdf;
+}
+
+#widgets-right .sidebar-name {
+	background-image: url(../images/fav.png);
+	text-shadow: #3f3f3f 0 -1px 0;
+	background-color: #636363;
+	border-color: #636363;
+	color: #fff;
+}
+
+.sidebar-name:hover,
+#removing-widget {
+	color: #d54e21;
+}
+
+#removing-widget span {
+	color: black;
+}
+
+#widgets-left .sidebar-name-arrow {
+	background: transparent url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -109px;
+}
+
+#widgets-right .sidebar-name-arrow {
+	background: transparent url(../images/widgets-arrow.gif?ver=20100531) no-repeat scroll 0 -1px;
+}
+
+.in-widget-title {
+	color: #606060;
+}
+
+.deleting .widget-title * {
+	color: #aaa;
+}
+
+.imgedit-menu div {
+	border-color: #d5d5d5;
+	background-color: #f1f1f1;
+}
+
+.imgedit-menu div:hover {
+	border-color: #c1c1c1;
+	background-color: #eaeaea;
+}
+
+.imgedit-menu div.disabled {
+	border-color: #ccc;
+	background-color: #ddd;
+	filter: alpha(opacity=50);
+	opacity: 0.5;
+}
+
+#dashboard_recent_comments div.undo {
+	border-top-color: #dfdfdf;
+}
+
+.comment-ays,
+.comment-ays th {
+	border-color: #ddd;
+}
+
+.comment-ays th {
+	background-color: #f1f1f1;
+}
+
+#nav-menu-header, #nav-menu-footer, .menu-item-handle {
+	background: url("../images/gray-grad.png") repeat-x scroll left top #dfdfdf;
+}
+
+#menu-management .nav-tab-active {
+	background: #ececec;
+	border-bottom-color: #ececec;
+}
Index: /tags/3.1/wp-admin/css/dashboard-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/dashboard-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/dashboard-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+#dashboard-widgets-wrap .has-sidebar{margin-right:0;margin-left:-51%;}#dashboard-widgets-wrap .has-sidebar .has-sidebar-content{margin-right:0;margin-left:51%;}.view-all{right:auto;left:0;}#dashboard_right_now p.sub,#dashboard-widgets h4,#dashboard_quick_press h4,a.rsswidget,#dashboard_plugins h4,#dashboard_plugins h5,#dashboard_recent_comments .comment-meta .approve{font-family:Tahoma,Arial;}#dashboard_right_now p.sub{font-style:normal;left:auto;right:15px;}#dashboard_right_now td.b{padding-right:0;padding-left:6px;text-align:left;font-family:Tahoma,Arial;}#dashboard_right_now .t{padding-right:0;padding-left:12px;}#dashboard_right_now .table_content{float:right;}#dashboard_right_now .table_discussion{float:left;}#dashboard_right_now .versions a{font-family:Tahoma,Arial;}#dashboard_right_now a.button{float:left;clear:left;}#dashboard-widgets h3 .postbox-title-action{right:auto;left:30px;}#the-comment-list .pingback{padding-left:0!important;padding-right:9px!important;}#the-comment-list .comment-item{padding:1em 70px 1em 10px;}#the-comment-list .comment-item .avatar{float:right;margin-left:0;margin-right:-60px;}.rss-widget cite{text-align:left;}.rss-widget span.rss-date{font-family:Tahoma,Arial;margin-left:0;margin-right:3px;}#dashboard_quick_press h4{float:right;text-align:left;}#dashboard_quick_press h4 label{margin-right:0;margin-left:10px;}#dashboard_quick_press .input-text-wrap,#dashboard_quick_press .textarea-wrap{margin:0 5em 1em 0;}#dashboard_quick_press #media-buttons{margin:0 5em .5em 0;padding:0 10px 0 0;}#dashboard-widgets #dashboard_quick_press form p.submit{margin-left:0;margin-right:4.6em;}#dashboard-widgets #dashboard_quick_press form p.submit input{float:right;}#dashboard-widgets #dashboard_quick_press form p.submit #save-post{margin:0 10px 0 1em;}#dashboard-widgets #dashboard_quick_press form p.submit #publish{float:left;}#dashboard-widgets #dashboard_quick_press form p.submit img.waiting{margin:4px 0 0 6px;}#dashboard_recent_drafts h4 abbr{font-family:Tahoma,Arial;margin-left:0;margin-right:3px;}
Index: /tags/3.1/wp-admin/css/dashboard-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/dashboard-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/dashboard-rtl.dev.css	(revision 17487)
@@ -0,0 +1,107 @@
+#dashboard-widgets-wrap .has-sidebar {
+	margin-right: 0;
+	margin-left: -51%;
+}
+#dashboard-widgets-wrap .has-sidebar .has-sidebar-content {
+	margin-right: 0;
+	margin-left: 51%;
+}
+.view-all {
+	right: auto;
+	left: 0;
+}
+#dashboard_right_now p.sub, #dashboard-widgets h4, #dashboard_quick_press h4, a.rsswidget, #dashboard_plugins h4, #dashboard_plugins h5, #dashboard_recent_comments .comment-meta .approve {
+	font-family: Tahoma, Arial;
+}
+#dashboard_right_now p.sub  {
+	font-style:normal;
+	left:auto;
+	right:15px;
+}
+#dashboard_right_now td.b {
+	padding-right: 0;
+	padding-left: 6px;
+	text-align: left;
+	font-family: Tahoma, Arial;
+}
+#dashboard_right_now .t {
+	padding-right: 0;
+	padding-left: 12px;
+}
+#dashboard_right_now .table_content {
+	float:right;
+}
+#dashboard_right_now .table_discussion {
+	float:left;
+}
+#dashboard_right_now .versions a {
+	font-family: Tahoma, Arial;
+}
+#dashboard_right_now a.button {
+	float: left;
+	clear: left;
+}
+#dashboard-widgets h3 .postbox-title-action {
+	right: auto;
+	left: 30px;
+}
+#the-comment-list .pingback {
+	padding-left: 0 !important;
+	padding-right: 9px !important;
+}
+/* Recent Comments */
+#the-comment-list .comment-item {
+	padding: 1em 70px 1em 10px;
+}
+#the-comment-list .comment-item .avatar {
+	float: right;
+	margin-left: 0;
+	margin-right: -60px;
+}
+/* Feeds */
+.rss-widget cite {
+	text-align: left;
+}
+.rss-widget span.rss-date {
+	font-family: Tahoma, Arial;
+	margin-left: 0;
+	margin-right: 3px;
+}
+/* QuickPress */
+#dashboard_quick_press h4 {
+	float: right;
+	text-align: left;
+}
+#dashboard_quick_press h4 label {
+	margin-right: 0;
+	margin-left: 10px;
+}
+#dashboard_quick_press .input-text-wrap, #dashboard_quick_press .textarea-wrap {
+	margin: 0 5em 1em 0;
+}
+#dashboard_quick_press #media-buttons {
+	margin: 0 5em .5em 0;
+	padding: 0 10px 0 0;
+}
+#dashboard-widgets #dashboard_quick_press form p.submit {
+	margin-left: 0;
+	margin-right: 4.6em;
+}
+#dashboard-widgets #dashboard_quick_press form p.submit input {
+	float: right;
+}
+#dashboard-widgets #dashboard_quick_press form p.submit #save-post {
+	margin: 0 10px 0 1em;
+}
+#dashboard-widgets #dashboard_quick_press form p.submit #publish {
+	float: left;
+}
+#dashboard-widgets #dashboard_quick_press form p.submit img.waiting {
+	margin: 4px 0 0 6px;
+}
+/* Recent Drafts */
+#dashboard_recent_drafts h4 abbr {
+	font-family: Tahoma, Arial;
+	margin-left:0;
+	margin-right: 3px;
+}
Index: /tags/3.1/wp-admin/css/dashboard.css
===================================================================
--- /tags/3.1/wp-admin/css/dashboard.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/dashboard.css	(revision 17487)
@@ -0,0 +1,1 @@
+.postbox p,.postbox ul,.postbox ol,.postbox blockquote,#wp-version-message{font-size:11px;}.edit-box{display:none;}h3:hover .edit-box{display:inline;}form .input-text-wrap{border-style:solid;border-width:1px;padding:2px 3px;border-color:#ccc;}#dashboard-widgets form .input-text-wrap input{border:0 none;outline:none;margin:0;padding:0;width:99%;color:#333;}form .textarea-wrap{border-style:solid;border-width:1px;padding:2px;border-color:#ccc;}#dashboard-widgets form .textarea-wrap textarea{border:0 none;padding:0;outline:none;width:99%;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;}#dashboard-widgets .postbox form .submit{float:none;margin:.5em 0 0;padding:0;border:none;}#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit input{margin:0;}#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish{min-width:0;}div.postbox div.inside{margin:10px;position:relative;}#dashboard-widgets a{text-decoration:none;}#dashboard-widgets h3 a{text-decoration:underline;}#dashboard-widgets h3 .postbox-title-action{position:absolute;right:30px;padding:0;}#dashboard-widgets h4{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-size:13px;margin:0 0 .2em;padding:0;}#dashboard_right_now p.sub,#dashboard_right_now .table,#dashboard_right_now .versions{margin:-12px;}#dashboard_right_now .inside{font-size:12px;padding-top:20px;}#dashboard_right_now p.sub{font-style:italic;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;padding:5px 10px 15px;color:#777;font-size:13px;position:absolute;top:-17px;left:15px;}#dashboard_right_now .table{margin:0 -9px;padding:0 10px;position:relative;}#dashboard_right_now .table_content{float:left;border-top:#ececec 1px solid;width:45%;}#dashboard_right_now .table_discussion{float:right;border-top:#ececec 1px solid;width:45%;}#dashboard_right_now table td{padding:3px 0;white-space:nowrap;}#dashboard_right_now table tr.first td{border-top:none;}#dashboard_right_now td.b{padding-right:6px;text-align:right;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-size:14px;width:1%;}#dashboard_right_now td.b a{font-size:18px;}#dashboard_right_now td.b a:hover{color:#d54e21;}#dashboard_right_now .t{font-size:12px;padding-right:12px;padding-top:6px;color:#777;}#dashboard_right_now .t a{white-space:nowrap;}#dashboard_right_now .spam{color:red;}#dashboard_right_now .waiting{color:#e66f00;}#dashboard_right_now .approved{color:green;}#dashboard_right_now .versions{padding:6px 10px 12px;clear:both;}#dashboard_right_now .versions .b{font-weight:bold;}#dashboard_right_now a.button{float:right;clear:right;position:relative;top:-5px;}#dashboard_recent_comments h3{margin-bottom:0;}#dashboard_recent_comments .inside{margin-top:0;}#dashboard_recent_comments .comment-meta .approve{font-style:italic;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-size:10px;}#the-comment-list{position:relative;}#the-comment-list .comment-item{padding:1em 10px;border-top:1px solid;}#the-comment-list .pingback{padding-left:9px!important;}#the-comment-list .comment-item,#the-comment-list #replyrow{margin:0 -10px;}#the-comment-list .comment-item:first-child{border-top:none;}#the-comment-list .comment-item .avatar{float:left;margin:0 10px 5px 0;}#the-comment-list .comment-item h4{line-height:1.4;margin-top:-.2em;font-weight:normal;color:#999;}#the-comment-list .comment-item h4 cite{font-style:normal;font-weight:normal;}#the-comment-list .comment-item blockquote,#the-comment-list .comment-item blockquote p{margin:0;padding:0;display:inline;}#dashboard_recent_comments #the-comment-list .trackback blockquote,#dashboard_recent_comments #the-comment-list .pingback blockquote{display:block;}#the-comment-list .comment-item p.row-actions{margin:3px 0 0;padding:0;font-size:10px;}#dashboard_quick_press h4{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;float:left;width:5.5em;clear:both;font-weight:normal;text-align:right;padding-top:5px;font-size:12px;}#dashboard_quick_press h4 label{margin-right:10px;}#dashboard_quick_press{min-height:200px;}#dashboard_quick_press.closed{min-height:0;}#dashboard_quick_press .input-text-wrap,#dashboard_quick_press .textarea-wrap{margin:0 0 1em 5em;}#dashboard_quick_press #media-buttons{margin:0 0 .5em 5em;padding:0 0 0 10px;font-size:11px;}#dashboard_quick_press #media-buttons a{vertical-align:bottom;}#dashboard-widgets #dashboard_quick_press form p.submit{margin-left:4.6em;}#dashboard-widgets #dashboard_quick_press form p.submit input{float:left;}#dashboard-widgets #dashboard_quick_press form p.submit #save-post{margin:0 1em 0 10px;}#dashboard-widgets #dashboard_quick_press form p.submit #publish{float:right;}#dashboard-widgets #dashboard_quick_press form p.submit img.waiting{vertical-align:middle;visibility:hidden;margin:4px 6px 0 0;}#dashboard_recent_drafts ul{margin:0;padding:0;list-style:none;}#dashboard_recent_drafts ul li{margin-bottom:.6em;}#dashboard_recent_drafts h4{font-weight:normal;}#dashboard_recent_drafts h4 abbr{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-size:11px;color:#999;margin-left:3px;}#dashboard_recent_drafts p{margin:0;padding:0;}.rss-widget ul{margin:0;padding:0;list-style:none;}a.rsswidget{font-size:13px;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;line-height:1.7em;}.rss-widget ul li{line-height:1.5em;margin-bottom:12px;}.rss-widget span.rss-date{margin-left:3px;}.rss-widget cite{display:block;text-align:right;margin:0 0 1em;padding:0;}.rss-widget cite:before{content:'\2014';}#dashboard_plugins h4{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;}#dashboard_plugins h5{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-size:13px!important;margin:0;display:inline;line-height:1.4em;}#dashboard_plugins h5 a{font-weight:normal;line-height:1.7em;}#dashboard_plugins p{margin:0 0 1.4em;line-height:1.4em;}.dashboard-comment-wrap{overflow:hidden;word-wrap:break-word;}
Index: /tags/3.1/wp-admin/css/dashboard.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/dashboard.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/dashboard.dev.css	(revision 17487)
@@ -0,0 +1,413 @@
+.postbox p, .postbox ul, .postbox ol, .postbox blockquote, #wp-version-message { font-size: 11px; }
+
+.edit-box {
+	display: none;
+}
+
+h3:hover .edit-box {
+	display: inline;
+}
+
+form .input-text-wrap {
+	border-style: solid;
+	border-width: 1px;
+	padding: 2px 3px;
+	border-color: #ccc;
+}
+
+#dashboard-widgets form .input-text-wrap input {
+	border: 0 none;
+	outline: none;
+	margin: 0;
+	padding: 0;
+	width: 99%;
+	color: #333;
+}
+
+form .textarea-wrap {
+	border-style: solid;
+	border-width: 1px;
+	padding: 2px;
+	border-color: #ccc;
+}
+
+#dashboard-widgets form .textarea-wrap textarea {
+	border: 0 none;
+	padding: 0;
+	outline: none;
+	width: 99%;
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#dashboard-widgets .postbox form .submit {
+	float: none;
+	margin: .5em 0 0;
+	padding: 0;
+	border: none;
+}
+
+#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit input {
+	margin: 0;
+}
+
+#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish {
+	min-width: 0;
+}
+
+div.postbox div.inside {
+	margin: 10px;
+	position: relative;
+}
+
+#dashboard-widgets a {
+	text-decoration: none;
+}
+
+#dashboard-widgets h3 a {
+	text-decoration: underline;
+}
+
+#dashboard-widgets h3 .postbox-title-action {
+	position: absolute;
+	right: 30px;
+	padding: 0;
+}
+
+#dashboard-widgets h4 {
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	font-size: 13px;
+	margin: 0 0 .2em;
+	padding: 0;
+}
+
+/* Right Now */
+
+#dashboard_right_now p.sub,
+#dashboard_right_now .table, #dashboard_right_now .versions {
+	margin: -12px;
+}
+
+#dashboard_right_now .inside {
+	font-size: 12px;
+	padding-top: 20px;
+}
+
+#dashboard_right_now p.sub {
+	font-style: italic;
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	padding: 5px 10px 15px;
+	color: #777;
+	font-size: 13px;
+	position: absolute;
+	top: -17px;
+	left: 15px;
+}
+
+#dashboard_right_now .table {
+	margin: 0 -9px;
+	padding: 0 10px;
+	position: relative;
+}
+
+#dashboard_right_now .table_content {
+	float: left;
+	border-top: #ececec 1px solid;
+	width: 45%;
+}
+
+#dashboard_right_now .table_discussion {
+	float: right;
+	border-top: #ececec 1px solid;
+	width: 45%;
+}
+
+#dashboard_right_now table td {
+	padding: 3px 0;
+	white-space: nowrap;
+}
+
+#dashboard_right_now table tr.first td {
+	border-top: none;
+}
+
+#dashboard_right_now td.b {
+	padding-right: 6px;
+	text-align: right;
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	font-size: 14px;
+	width: 1%;
+}
+
+#dashboard_right_now td.b a {
+	font-size: 18px;
+}
+
+#dashboard_right_now td.b a:hover {
+	color: #d54e21;
+}
+
+#dashboard_right_now .t {
+	font-size: 12px;
+	padding-right: 12px;
+	padding-top: 6px;
+	color: #777;
+}
+
+#dashboard_right_now .t a {
+	white-space: nowrap;
+}
+
+#dashboard_right_now .spam {
+	color: red;
+}
+
+#dashboard_right_now .waiting {
+	color: #e66f00;
+}
+
+#dashboard_right_now .approved {
+	color: green;
+}
+
+#dashboard_right_now .versions {
+	padding: 6px 10px 12px;
+	clear: both;
+}
+
+#dashboard_right_now .versions .b {
+	font-weight: bold;
+}
+
+#dashboard_right_now a.button {
+	float: right;
+	clear: right;
+	position: relative;
+	top: -5px;
+}
+
+/* Recent Comments */
+
+#dashboard_recent_comments h3 {
+	margin-bottom: 0;
+}
+
+#dashboard_recent_comments .inside {
+	margin-top: 0;
+}
+
+#dashboard_recent_comments .comment-meta .approve {
+	font-style: italic;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-size: 10px;
+}
+
+#the-comment-list {
+	position: relative;
+}
+
+#the-comment-list .comment-item {
+	padding: 1em 10px;
+	border-top: 1px solid;
+}
+
+#the-comment-list .pingback {
+	padding-left: 9px !important;
+}
+
+#the-comment-list .comment-item,
+#the-comment-list #replyrow {
+	margin: 0 -10px;
+}
+
+#the-comment-list .comment-item:first-child {
+	border-top: none;
+}
+
+#the-comment-list .comment-item .avatar {
+	float: left;
+	margin: 0 10px 5px 0;
+}
+
+#the-comment-list .comment-item h4 {
+	line-height: 1.4;
+	margin-top: -.2em;
+	font-weight: normal;
+	color: #999;
+}
+
+#the-comment-list .comment-item h4 cite {
+	font-style: normal;
+	font-weight: normal;
+}
+
+#the-comment-list .comment-item blockquote,
+#the-comment-list .comment-item blockquote p {
+	margin: 0;
+	padding: 0;
+	display: inline;
+}
+
+#dashboard_recent_comments #the-comment-list .trackback blockquote,
+#dashboard_recent_comments #the-comment-list .pingback blockquote {
+	display: block;
+}
+
+#the-comment-list .comment-item p.row-actions {
+	margin: 3px 0 0;
+	padding: 0;
+	font-size: 10px;
+}
+
+/* QuickPress */
+
+#dashboard_quick_press h4 {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	float: left;
+	width: 5.5em;
+	clear: both;
+	font-weight: normal;
+	text-align: right;
+	padding-top: 5px;
+	font-size: 12px;
+}
+
+#dashboard_quick_press h4 label {
+	margin-right: 10px;
+}
+
+#dashboard_quick_press {
+	min-height: 200px;
+}
+
+#dashboard_quick_press.closed {
+	min-height: 0;
+}
+
+#dashboard_quick_press .input-text-wrap,
+#dashboard_quick_press .textarea-wrap {
+	margin: 0 0 1em 5em;
+}
+
+#dashboard_quick_press #media-buttons {
+	margin: 0 0 .5em 5em;
+	padding: 0 0 0 10px;
+	font-size: 11px;
+}
+
+#dashboard_quick_press #media-buttons a {
+	vertical-align: bottom;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit {
+	margin-left: 4.6em;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit input {
+	float: left;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit #save-post {
+	margin: 0 1em 0 10px;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit #publish {
+	float: right;
+}
+
+#dashboard-widgets #dashboard_quick_press form p.submit img.waiting {
+	vertical-align: middle;
+	visibility: hidden;
+	margin: 4px 6px 0 0;
+}
+
+/* Recent Drafts */
+#dashboard_recent_drafts ul {
+	margin: 0;
+	padding: 0;
+	list-style: none;
+}
+
+#dashboard_recent_drafts ul li {
+	margin-bottom: 0.6em;
+}
+
+#dashboard_recent_drafts h4 {
+	font-weight: normal;
+}
+
+#dashboard_recent_drafts h4 abbr {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-size: 11px;
+	color: #999;
+	margin-left: 3px;
+}
+
+#dashboard_recent_drafts p {
+	margin: 0;
+	padding: 0;
+}
+
+/* Feeds */
+
+.rss-widget ul {
+	margin: 0;
+	padding: 0;
+	list-style: none;
+}
+
+a.rsswidget {
+	font-size: 13px;
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	line-height: 1.7em;
+}
+
+.rss-widget ul li {
+	line-height: 1.5em;
+	margin-bottom: 12px;
+}
+
+.rss-widget span.rss-date {
+	margin-left: 3px;
+}
+
+.rss-widget cite {
+	display: block;
+	text-align: right;
+	margin: 0 0 1em;
+	padding: 0;
+}
+
+.rss-widget cite:before {
+	content: '\2014';
+}
+
+/* Plugins */
+
+#dashboard_plugins h4 {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
+
+#dashboard_plugins h5 {
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	font-size: 13px !important;
+	margin: 0;
+	display: inline;
+	line-height: 1.4em;
+}
+
+#dashboard_plugins h5 a {
+	font-weight: normal;
+	line-height: 1.7em;
+}
+
+#dashboard_plugins p {
+	margin: 0 0 1.4em;
+	line-height: 1.4em;
+}
+
+.dashboard-comment-wrap {
+	overflow: hidden;
+	word-wrap: break-word;
+}
Index: /tags/3.1/wp-admin/css/farbtastic-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/farbtastic-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/farbtastic-rtl.css	(revision 17487)
@@ -0,0 +1,7 @@
+.farbtastic .color, .farbtastic .overlay {
+	left: 0;
+	right: 47px;
+}
+.farbtastic .marker {
+	margin: -8px -8px 0 0;
+}
Index: /tags/3.1/wp-admin/css/farbtastic.css
===================================================================
--- /tags/3.1/wp-admin/css/farbtastic.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/farbtastic.css	(revision 17487)
@@ -0,0 +1,32 @@
+.farbtastic {
+  position: relative;
+}
+.farbtastic * {
+  position: absolute;
+  cursor: crosshair;
+}
+.farbtastic, .farbtastic .wheel {
+  width: 195px;
+  height: 195px;
+}
+.farbtastic .color, .farbtastic .overlay {
+  top: 47px;
+  left: 47px;
+  width: 101px;
+  height: 101px;
+}
+.farbtastic .wheel {
+  background: url(../images/wheel.png) no-repeat;
+  width: 195px;
+  height: 195px;
+}
+.farbtastic .overlay {
+  background: url(../images/mask.png) no-repeat;
+}
+.farbtastic .marker {
+  width: 17px;
+  height: 17px;
+  margin: -8px 0 0 -8px;
+  overflow: hidden;
+  background: url(../images/marker.png) no-repeat;
+}
Index: /tags/3.1/wp-admin/css/global-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/global-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/global-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+#adminmenu{float:right;clear:right;margin-right:-160px;margin-left:5px;}body.folded #adminmenu{margin-left:0;margin-right:-45px;}.inner-sidebar{float:left;clear:left;}.has-right-sidebar #post-body{clear:right;float:right;margin-right:0;margin-left:-340px;}.has-right-sidebar #post-body-content{margin-left:300px;margin-right:0;}#wpbody{margin-left:0;margin-right:175px;}.folded #wpbody{margin-left:0;margin-right:60px;}#wpbody-content{float:right;}#col-right{float:left;clear:left;}.wrap{margin:0 5px 0 15px;}body,td,textarea,input,select{font-family:Tahoma,arial;}.alignleft{float:right;}.alignright{float:left;}.subsubsub{float:right;}.widefat th{text-align:right;}.widefat th input{margin:0 8px 0 0;}.wrap h2{font-family:arial;padding:14px 0 3px 15px;font-style:normal;}.wrap h2.long-header{padding-left:0;}.updated,.error{clear:both;}.screen-reader-text,.screen-reader-text span{left:auto;text-indent:-1000em;}
Index: /tags/3.1/wp-admin/css/global-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/global-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/global-rtl.dev.css	(revision 17487)
@@ -0,0 +1,83 @@
+/* 2 column liquid layout */
+#adminmenu {
+	float: right;
+	clear: right;
+	margin-right:-160px;
+	margin-left: 5px;
+}
+body.folded #adminmenu {
+	margin-left: 0;
+	margin-right: -45px;
+}
+/* inner 2 column liquid layout */
+.inner-sidebar {
+	float: left;
+	clear: left;
+}
+
+.has-right-sidebar #post-body {
+	clear:right;
+	float:right;
+	margin-right:0;
+	margin-left:-340px;
+}
+
+.has-right-sidebar #post-body-content {
+	margin-left: 300px;
+	margin-right:0;
+}
+
+#wpbody {
+	margin-left:0;
+	margin-right: 175px;
+}
+.folded #wpbody {
+	margin-left: 0;
+	margin-right: 60px;
+}
+#wpbody-content {
+	float: right;
+}
+/* 2 columns main area */
+#col-right {
+	float: left;
+	clear: left;
+}
+.wrap {
+	margin: 0 5px 0 15px;
+}
+/* styles for use by people extending the WordPress interface */
+body, td, textarea, input, select {
+	font-family: Tahoma, arial;
+}
+.alignleft {
+	float: right;
+}
+.alignright {
+	float: left;
+}
+.subsubsub {
+	float: right;
+}
+.widefat th {
+	text-align: right;
+}
+.widefat th input {
+	margin: 0 8px 0 0;
+}
+.wrap h2 {
+	font-family: arial;
+	padding: 14px 0 3px 15px;
+	font-style: normal;
+}
+.wrap h2.long-header {
+	padding-left: 0;
+}
+.updated, .error {
+	clear: both;
+}
+
+.screen-reader-text, .screen-reader-text span {
+	left:auto;
+	text-indent:-1000em;
+}
Index: /tags/3.1/wp-admin/css/global.css
===================================================================
--- /tags/3.1/wp-admin/css/global.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/global.css	(revision 17487)
@@ -0,0 +1,1 @@
+html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;background:transparent;}body{line-height:1;}ol,ul{list-style:none;}blockquote,q{quotes:none;}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;}ins{text-decoration:none;}del{text-decoration:line-through;}#wpwrap{height:auto;min-height:100%;width:100%;}#wpcontent{height:100%;padding-bottom:50px;}#wpbody{clear:both;margin-left:175px;}.folded #wpbody{margin-left:60px;}#wpbody-content{float:left;width:100%;}#adminmenu{float:left;clear:left;width:145px;margin-top:15px;margin-right:5px;margin-bottom:15px;margin-left:-160px;position:relative;padding:0;list-style:none;}.folded #adminmenu{margin-left:-45px;}.folded #adminmenu,.folded #adminmenu li.menu-top{width:28px;}#footer{clear:both;position:relative;width:100%;}.inner-sidebar{float:right;clear:right;display:none;width:281px;position:relative;}.inner-sidebar #side-sortables{width:280px;min-height:300px;}.has-right-sidebar .inner-sidebar{display:block;}.has-right-sidebar #post-body{float:left;clear:left;width:100%;margin-right:-340px;}.has-right-sidebar #post-body-content{margin-right:300px;}#col-container{overflow:hidden;padding:0;margin:0;}#col-left{padding:0;margin:0;overflow:hidden;width:39%;}#col-right{float:right;clear:right;overflow:hidden;padding:0;margin:0;width:59%;}.alignleft{float:left;}.alignright{float:right;}.textleft{text-align:left;}.textright{text-align:right;}.clear{clear:both;}.screen-reader-text,.screen-reader-text span{position:absolute;left:-1000em;height:1px;width:1px;overflow:hidden;}.hidden,.js .closed .inside,.js .hide-if-js,.no-js .hide-if-no-js{display:none;}input[type="text"],input[type="password"],textarea{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;}input[type="checkbox"],input[type="radio"]{vertical-align:middle;}html,body{height:100%;}body,td,textarea,input,select{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-size:13px;}body,textarea{line-height:1.4em;}input,select{line-height:15px;}p{margin:1em 0;}blockquote{margin:1em;}label{cursor:pointer;}li,dd{margin-bottom:6px;}p,li,dl,dd,dt{line-height:140%;}textarea,input,select{margin:1px;padding:3px;}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-size:1em;font-weight:bold;margin:1.33em 0;}h5{display:block;font-size:.83em;font-weight:bold;margin:1.67em 0;}h6{display:block;font-size:.67em;font-weight:bold;margin:2.33em 0;}ul.ul-disc{list-style:disc outside;}ul.ul-square{list-style:square outside;}ol.ol-decimal{list-style:decimal outside;}ul.ul-disc,ul.ul-square,ol.ol-decimal{margin-left:1.8em;}ul.ul-disc>li,ul.ul-square>li,ol.ol-decimal>li{margin:0 0 .5em;}.subsubsub{list-style:none;margin:8px 0 5px;padding:0;white-space:nowrap;font-size:11px;float:left;}.subsubsub a{line-height:2;padding:.2em;text-decoration:none;}.subsubsub a .count,.subsubsub a.current .count{color:#999;font-weight:normal;}.subsubsub a.current{font-weight:bold;background:none;border:none;}.subsubsub li{display:inline;margin:0;padding:0;}.widefat{border-width:1px;border-style:solid;border-spacing:0;width:100%;clear:both;margin:0;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;}.widefat *{word-wrap:break-word;}.widefat a{text-decoration:none;}.widefat thead th:first-of-type{-moz-border-radius-topleft:3px;-khtml-border-top-left-radius:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px;}.widefat thead th:last-of-type{-moz-border-radius-topright:3px;-khtml-border-top-right-radius:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px;}.widefat tfoot th:first-of-type{-moz-border-radius-bottomleft:3px;-khtml-border-bottom-left-radius:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}.widefat tfoot th:last-of-type{-moz-border-radius-bottomright:3px;-khtml-border-bottom-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;}.widefat td,.widefat th{border-bottom-width:1px;border-bottom-style:solid;font-size:11px;}.widefat .no-items td{border-bottom-width:0;}.widefat td{padding:3px 7px;vertical-align:top;}.widefat td p,.widefat td ol,.widefat td ul{font-size:11px;}.widefat th{padding:7px 7px 8px;text-align:left;line-height:1.3em;}.widefat th input{margin:0 0 0 8px;padding:0;vertical-align:text-top;}.widefat .check-column{width:2.2em;padding:0;}.widefat tbody th.check-column{padding:7px 0 22px;vertical-align:top;}.widefat .num,.column-comments,.column-links,.column-posts{text-align:center;}.widefat th#comments{vertical-align:middle;}.wrap{margin:0 15px 0 5px;}div.updated,div.error{border-width:1px;border-style:solid;padding:0 .6em;margin:5px 15px 2px;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;}div.updated p,div.error p{margin:.5em 0;padding:2px;}.wrap div.updated,.wrap div.error{margin:5px 0 15px;}.wrap h2{font:italic normal normal 24px/29px Georgia,"Times New Roman","Bitstream Charter",Times,serif;margin:0;padding:14px 15px 3px 0;line-height:35px;text-shadow:rgba(255,255,255,1) 0 1px 0;}.wrap h2.long-header{padding-right:0;}
Index: /tags/3.1/wp-admin/css/global.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/global.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/global.dev.css	(revision 17487)
@@ -0,0 +1,514 @@
+/* http://meyerweb.com/eric/tools/css/reset/ */
+/* v1.0 | 20080212 */
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	outline: 0;
+/*	font-size: 100%;
+	vertical-align: baseline; */
+	background: transparent;
+}
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+
+/* remember to define focus styles! */
+/*
+:focus {
+	outline: 0;
+}
+*/
+/* remember to highlight inserts somehow! */
+ins {
+	text-decoration: none;
+}
+del {
+	text-decoration: line-through;
+}
+
+/* tables still need 'cellspacing="0"' in the markup */
+/*
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}
+*/
+/* end reset css */
+
+
+/* 2 column liquid layout */
+#wpwrap {
+	height: auto;
+	min-height: 100%;
+	width: 100%;
+}
+
+#wpcontent {
+	height: 100%;
+	padding-bottom: 50px;
+}
+
+#wpbody {
+	clear: both;
+	margin-left: 175px;
+}
+
+.folded #wpbody {
+	margin-left: 60px;
+}
+
+#wpbody-content {
+	float: left;
+	width: 100%;
+}
+
+#adminmenu {
+	float: left;
+	clear: left;
+	width: 145px;
+	margin-top: 15px;
+	margin-right: 5px;
+	margin-bottom: 15px;
+	margin-left: -160px;
+	position: relative;
+	padding: 0;
+	list-style: none;
+}
+
+.folded #adminmenu {
+	margin-left: -45px;
+}
+
+.folded #adminmenu,
+.folded #adminmenu li.menu-top {
+	width: 28px;
+}
+
+#footer {
+	clear: both;
+	position: relative;
+	width: 100%;
+}
+
+/* inner 2 column liquid layout */
+.inner-sidebar {
+	float: right;
+	clear: right;
+	display: none;
+	width: 281px;
+	position: relative;
+}
+
+.inner-sidebar #side-sortables {
+	width: 280px;
+	min-height: 300px;
+}
+
+.has-right-sidebar .inner-sidebar {
+	display: block;
+}
+
+.has-right-sidebar #post-body {
+	float: left;
+	clear: left;
+	width: 100%;
+	margin-right: -340px;
+}
+
+.has-right-sidebar #post-body-content {
+	margin-right: 300px;
+}
+
+/* 2 columns main area */
+
+#col-container {
+	overflow: hidden;
+	padding: 0;
+	margin: 0;
+}
+
+#col-left {
+	padding: 0;
+	margin: 0;
+	overflow: hidden;
+	width: 39%;
+}
+
+#col-right {
+	float: right;
+	clear: right;
+	overflow: hidden;
+	padding: 0;
+	margin: 0;
+	width: 59%;
+}
+
+/* utility classes */
+.alignleft {
+	float: left;
+}
+
+.alignright {
+	float: right;
+}
+
+.textleft {
+	text-align: left;
+}
+
+.textright {
+	text-align: right;
+}
+
+.clear {
+	clear: both;
+}
+
+/* Hide visually but not from screen readers */
+.screen-reader-text,
+.screen-reader-text span {
+	position: absolute;
+	left: -1000em;
+	height: 1px;
+	width: 1px;
+	overflow: hidden;
+}
+
+.hidden,
+.js .closed .inside,
+.js .hide-if-js,
+.no-js .hide-if-no-js {
+	display: none;
+}
+
+/* include margin and padding in the width calculation of input and textarea */
+input[type="text"],
+input[type="password"],
+textarea {
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	-ms-box-sizing: border-box; /* ie8 only */
+	box-sizing: border-box;
+}
+
+input[type="checkbox"],
+input[type="radio"] {
+	vertical-align: middle;
+}
+
+/* styles for use by people extending the WordPress interface */
+html,
+body {
+	height: 100%;
+}
+
+body,
+td,
+textarea,
+input,
+select {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-size: 13px;
+}
+
+body,
+textarea {
+	line-height: 1.4em;
+}
+
+input,
+select {
+	line-height: 15px;
+}
+
+p {
+	margin: 1em 0;
+}
+
+blockquote {
+	margin: 1em;
+}
+
+label {
+	cursor: pointer;
+}
+
+li,
+dd {
+	margin-bottom: 6px;
+}
+
+p,
+li,
+dl,
+dd,
+dt {
+	line-height: 140%;
+}
+
+textarea,
+input,
+select {
+	margin: 1px;
+	padding: 3px;
+}
+
+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-size: 1em;
+  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;
+}
+
+ul.ul-disc {
+	list-style: disc outside;
+}
+
+ul.ul-square {
+	list-style: square outside;
+}
+
+ol.ol-decimal {
+	list-style: decimal outside;
+}
+
+ul.ul-disc,
+ul.ul-square,
+ol.ol-decimal {
+	margin-left: 1.8em;
+}
+
+ul.ul-disc > li,
+ul.ul-square > li,
+ol.ol-decimal > li {
+	margin: 0 0 0.5em;
+}
+
+.subsubsub {
+	list-style: none;
+	margin: 8px 0 5px;
+	padding: 0;
+	white-space: nowrap;
+	font-size: 11px;
+	float: left;
+}
+
+.subsubsub a {
+	line-height: 2;
+	padding: .2em;
+	text-decoration: none;
+}
+
+.subsubsub a .count, .subsubsub a.current .count {
+	color: #999;
+	font-weight: normal;
+}
+
+.subsubsub a.current {
+	font-weight: bold;
+	background: none;
+	border: none;
+}
+
+.subsubsub li {
+	display: inline;
+	margin: 0;
+	padding: 0;
+}
+
+.widefat {
+	border-width: 1px;
+	border-style: solid;
+	border-spacing: 0;
+	width: 100%;
+	clear: both;
+	margin: 0;
+	-moz-border-radius: 4px;
+	-khtml-border-radius: 4px;
+	-webkit-border-radius: 4px;
+	border-radius: 4px;
+}
+
+.widefat * {
+	word-wrap: break-word;
+}
+
+.widefat a {
+	text-decoration: none;
+}
+
+.widefat thead th:first-of-type {
+	-moz-border-radius-topleft: 3px;
+	-khtml-border-top-left-radius: 3px;
+	-webkit-border-top-left-radius: 3px;
+	border-top-left-radius: 3px;
+}
+.widefat thead th:last-of-type {
+	-moz-border-radius-topright: 3px;
+	-khtml-border-top-right-radius: 3px;
+	-webkit-border-top-right-radius: 3px;
+	border-top-right-radius: 3px;
+}
+.widefat tfoot th:first-of-type {
+	-moz-border-radius-bottomleft: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	border-bottom-left-radius: 3px;
+}
+.widefat tfoot th:last-of-type {
+	-moz-border-radius-bottomright: 3px;
+	-khtml-border-bottom-right-radius: 3px;
+	-webkit-border-bottom-right-radius: 3px;
+	border-bottom-right-radius: 3px;
+}
+
+.widefat td,
+.widefat th {
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+	font-size: 11px;
+}
+
+.widefat .no-items td {
+	border-bottom-width: 0;
+}
+
+.widefat td {
+	padding: 3px 7px;
+	vertical-align: top;
+}
+
+.widefat td p,
+.widefat td ol,
+.widefat td ul {
+	font-size: 11px;
+}
+
+.widefat th {
+	padding: 7px 7px 8px;
+	text-align: left;
+	line-height: 1.3em;
+}
+
+.widefat th input {
+	margin: 0 0 0 8px;
+	padding: 0;
+	vertical-align: text-top;
+}
+
+.widefat .check-column {
+	width: 2.2em;
+	padding: 0;
+
+}
+
+.widefat tbody th.check-column {
+	padding: 7px 0 22px;
+	vertical-align: top;
+}
+
+.widefat .num,
+.column-comments,
+.column-links,
+.column-posts {
+	text-align: center;
+}
+
+.widefat th#comments {
+	vertical-align: middle;
+}
+
+.wrap {
+	margin: 0 15px 0 5px;
+}
+
+div.updated,
+div.error {
+	border-width: 1px;
+	border-style: solid;
+	padding: 0 0.6em;
+	margin: 5px 15px 2px;
+	-moz-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+}
+
+div.updated p,
+div.error p {
+	margin: 0.5em 0;
+	padding: 2px;
+}
+
+.wrap div.updated,
+.wrap div.error {
+	margin: 5px 0 15px;
+}
+
+.wrap h2 {
+	font: italic normal normal 24px/29px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	margin: 0;
+	padding: 14px 15px 3px 0;
+	line-height: 35px;
+	text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+.wrap h2.long-header {
+	padding-right: 0;
+}
Index: /tags/3.1/wp-admin/css/ie-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/ie-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/ie-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+html{direction:ltr;}body{direction:rtl;}* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle{background:url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -109px;}* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle{background:url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -206px;}* html #adminmenu{margin-left:0;margin-right:-80px;}* html div.folded #adminmenu{margin-left:0;margin-right:-22px;}#wpcontent #adminmenu .wp-submenu li.wp-submenu-head{padding:3px 10px 4px 4px;}.inline-edit-row fieldset label span.title{float:right;}.inline-edit-row fieldset label span.input-text-wrap{margin-right:0;}p.search-box{float:left;}* html #poststuff h2{margin-right:0;}#bh{margin:7px 10px 0 0;float:left;}#user_info+div#favorite-actions{right:auto;left:15px;}#wphead-info{float:left;}div#dashboard-widgets{padding-right:0;padding-left:1px;}.tagchecklist span a{margin:4px -9px 0 0;}.widefat th input{margin:0 5px 0 0;}#TB_window{width:670px;position:absolute;top:50%;left:50%;margin-right:335px!important;}#dashboard_plugins{direction:ltr;}#dashboard_plugins h3.hndle{direction:rtl;}#dashboard_incoming_links ul li,#dashboard_secondary ul li,#dashboard_primary ul li,p.row-actions{width:100%;}#favorite-inside{position:absolute;right:0;}#post-status-info{height:25px;}#screen-meta{position:static;}p.submit{height:22px;}.inner-sidebar{position:static;}form#widgets-filter{position:static;}* html .meta-box-sortables .postbox .handlediv{background:transparent url(../images/menu-bits-rtl-vs.gif) no-repeat scroll right -111px;}.menu-max-depth-0 #menu-management{width:460px;}.menu-max-depth-1 #menu-management{width:490px;}.menu-max-depth-2 #menu-management{width:520px;}.menu-max-depth-3 #menu-management{width:550px;}.menu-max-depth-4 #menu-management{width:580px;}.menu-max-depth-5 #menu-management{width:610px;}.menu-max-depth-6 #menu-management{width:640px;}.menu-max-depth-7 #menu-management{width:670px;}.menu-max-depth-8 #menu-management{width:700px;}.menu-max-depth-9 #menu-management{width:730px;}.menu-max-depth-10 #menu-management{width:760px;}.menu-max-depth-11 #menu-management{width:790px;}.menu-item-depth-0{margin-left:0;}.menu-item-depth-1{margin-left:-30px;}.menu-item-depth-2{margin-left:-60px;}.menu-item-depth-3{margin-left:-90px;}.menu-item-depth-4{margin-left:-120px;}.menu-item-depth-5{margin-left:-150px;}.menu-item-depth-6{margin-left:-180px;}.menu-item-depth-7{margin-left:-210px;}.menu-item-depth-8{margin-left:-240px;}.menu-item-depth-9{margin-left:-270px;}.menu-item-depth-10{margin-left:-300px;}.menu-item-depth-11{margin-left:-330px;}#menu-to-edit li dl{padding:0!important;margin:0!important;}.ui-sortable-helper .menu-item-transport{margin-top:13px;}.ui-sortable-helper .menu-item-transport .menu-item-transport{margin-top:0;}.sortable-placeholder{margin-top:0!important;margin-left:0!important;margin-bottom:13px!important;padding:0!important;}.auto-add-pages{clear:both;float:none;}#nav-menus-frame .open-label span{float:none;display:inline-block;}#nav-menus-frame .delete-action{float:none;}
Index: /tags/3.1/wp-admin/css/ie-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/ie-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/ie-rtl.dev.css	(revision 17487)
@@ -0,0 +1,156 @@
+html {
+	direction: ltr;
+}
+body {
+	direction: rtl;
+}
+* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle {
+	background: url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -109px;
+}
+
+* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle {
+	background: url(../images/menu-bits-rtl.gif?ver=20100531) no-repeat scroll right -206px;
+}
+* html #adminmenu {
+	margin-left:0;
+	margin-right: -80px;
+}
+* html div.folded #adminmenu {
+	margin-left: 0;
+	margin-right: -22px;
+}
+#wpcontent #adminmenu .wp-submenu li.wp-submenu-head {
+	padding: 3px 10px 4px 4px;
+}
+.inline-edit-row fieldset label span.title {
+	float: right;
+}
+.inline-edit-row fieldset label span.input-text-wrap {
+	margin-right: 0;
+}
+p.search-box {
+	float: left;
+}
+* html #poststuff h2 {
+	margin-right: 0;
+}
+#bh {
+	margin: 7px 10px 0 0;
+	float: left;
+}
+#user_info + div#favorite-actions {
+	right: auto;
+	left: 15px;
+}
+#wphead-info {
+	float: left;
+}
+/* without this dashboard widgets appear in one column for some screen widths */
+div#dashboard-widgets {
+	padding-right: 0;
+	padding-left: 1px;
+}
+.tagchecklist span a {
+	margin: 4px -9px 0 0;
+}
+.widefat th input {
+	margin: 0 5px 0 0;
+}
+/* ---------- add by navid */
+#TB_window {
+	width: 670px;
+	position: absolute;
+	top: 50%;
+	left: 50%;
+	margin-right: 335px !important;
+}
+#dashboard_plugins {
+	direction: ltr;
+}
+#dashboard_plugins h3.hndle {
+	direction: rtl;
+}
+#dashboard_incoming_links ul li,
+#dashboard_secondary ul li,
+#dashboard_primary ul li,
+p.row-actions {
+	width: 100%;
+}
+#favorite-inside {
+	position: absolute;
+	right:0;
+}
+#post-status-info {
+	height: 25px;
+}
+#screen-meta {
+	position: static;
+}
+p.submit { /* quick edit and reply in edit-comments.php */
+	height:22px;
+}
+.inner-sidebar { /* fix edit single comment */
+	position: static;
+}
+form#widgets-filter { /* fix widget page */
+	position: static;
+}
+
+* html .meta-box-sortables .postbox .handlediv {
+	background: transparent url(../images/menu-bits-rtl-vs.gif) no-repeat scroll right -111px;
+}
+
+/* nav menus */
+.menu-max-depth-0 #menu-management { width: 460px; }
+.menu-max-depth-1 #menu-management { width: 490px; }
+.menu-max-depth-2 #menu-management { width: 520px; }
+.menu-max-depth-3 #menu-management { width: 550px; }
+.menu-max-depth-4 #menu-management { width: 580px; }
+.menu-max-depth-5 #menu-management { width: 610px; }
+.menu-max-depth-6 #menu-management { width: 640px; }
+.menu-max-depth-7 #menu-management { width: 670px; }
+.menu-max-depth-8 #menu-management { width: 700px; }
+.menu-max-depth-9 #menu-management { width: 730px; }
+.menu-max-depth-10 #menu-management { width: 760px; }
+.menu-max-depth-11 #menu-management { width: 790px; }
+
+.menu-item-depth-0 { margin-left: 0px; }
+.menu-item-depth-1 { margin-left: -30px; }
+.menu-item-depth-2 { margin-left: -60px; }
+.menu-item-depth-3 { margin-left: -90px; }
+.menu-item-depth-4 { margin-left: -120px; }
+.menu-item-depth-5 { margin-left: -150px; }
+.menu-item-depth-6 { margin-left: -180px; }
+.menu-item-depth-7 { margin-left: -210px; }
+.menu-item-depth-8 { margin-left: -240px; }
+.menu-item-depth-9 { margin-left: -270px; }
+.menu-item-depth-10 { margin-left: -300px; }
+.menu-item-depth-11 { margin-left: -330px; }
+
+#menu-to-edit li dl {
+	padding: 0 !important;
+	margin: 0 !important;
+}
+.ui-sortable-helper .menu-item-transport {
+	margin-top: 13px;
+}
+	.ui-sortable-helper .menu-item-transport .menu-item-transport {
+		margin-top: 0;
+	}
+.sortable-placeholder {
+	margin-top: 0 !important;
+	margin-left: 0 !important;
+	margin-bottom: 13px !important;
+	padding: 0 !important;
+}
+.auto-add-pages {
+	clear: both;
+	float: none;
+}
+#nav-menus-frame .open-label span {
+	float: none;
+	display: inline-block;
+}
+#nav-menus-frame .delete-action {
+	float: none;
+}
Index: /tags/3.1/wp-admin/css/ie.css
===================================================================
--- /tags/3.1/wp-admin/css/ie.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/ie.css	(revision 17487)
@@ -0,0 +1,1 @@
+#wpbody-content input.button,#wpbody-content input.button-secondary,#wpbody-content input.button-highlighted{padding:2px 3px;}#minor-publishing-actions input,#major-publishing-actions input{min-width:auto;padding-left:0;padding-right:0;}#wpbody-content .postbox{border:1px solid #dfdfdf;}#wpbody-content .postbox h3{margin-bottom:-1px;}* html .meta-box-sortables .postbox .handlediv{background:transparent url(../images/menu-bits-vs.gif) no-repeat scroll left -111px;}* html .edit-box{display:inline;}* html .inner-sidebar #side-sortables,* html .postbox-container .meta-box-sortables{height:300px;}* html #wpbody-content #screen-options-link-wrap{display:inline-block;width:150px;text-align:center;}* html #wpbody-content #contextual-help-link-wrap{display:inline-block;width:100px;text-align:center;}* html #adminmenu{margin-left:-80px;}* html .folded #adminmenu{margin-left:-22px;}* html #wpcontent #adminmenu li.menu-top{display:inline;padding:0;margin:0;}* html #footer{margin:0;}.folded #adminmenu li.menu-top{display:block;zoom:100%;}ul#adminmenu{z-index:99;}#adminmenu li.menu-top a.menu-top{min-width:auto;width:auto;}#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu{font-style:normal;}* html #wpcontent #adminmenu .wp-menu-open .wp-menu-toggle{background:none;}* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle{background:url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -109px;}* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle{background:url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -206px;}* html #adminmenu div.wp-menu-image{height:29px;}#wpcontent #adminmenu .wp-submenu li{padding:0;}#adminmenu,.major-publishing-actions,.wp-submenu,.wp-submenu li,.wp-menu-toggle{zoom:100%;}.folded #adminmenu li.wp-menu-separator{width:28px;}#wpcontent #adminmenu .wp-submenu li.wp-submenu-head{padding:3px 4px 4px 10px;zoom:100%;}.folded #adminmenu .menu-top{height:30px;}.folded #adminmenu .wp-submenu{margin:-1px 0 0 0;}#template,#template div,#editcat,#addcat,* html .stuffbox h3{zoom:100%;}.submitbox{margin-top:10px;}#wpbody-content .quick-edit-row-post .inline-edit-col-left{width:39%;}#wpbody-content .inline-edit-row-post .inline-edit-col-center{width:19%;}#wpbody-content .quick-edit-row-page .inline-edit-col-left{width:49%;}#wpbody-content .bulk-edit-row .inline-edit-col-left{width:29%;}.inline-edit-row p.submit{zoom:100%;}.inline-edit-row fieldset label span.title{display:block;float:left;width:5em;}.inline-edit-row fieldset label span.input-text-wrap{margin-left:0;zoom:100%;}#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input{line-height:130%;}#wpbody-content .inline-edit-row .input-text-wrap input{width:95%;}#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input{width:8em;}input{line-height:1;}* html .row-actions{visibility:visible;}#dashboard-widgets h3 a{height:20px;line-height:20px;}#wphead-info{float:right;}#titlediv #title{width:98%;}a.button{line-height:1.4em;margin:1px;padding:2px 6px;}* html div.widget-liquid-left,* html div.widget-liquid-right{display:block;position:relative;}#screen-options-wrap{overflow:hidden;}#favorite-actions{z-index:12;}#favorite-inside,#favorite-inside a,.favorite-action{zoom:100%;}#the-comment-list .comment-item,#post-status-info,#wpwrap,#wpcontent,#wrap,#postdivrich,#postdiv,#poststuff,.metabox-holder,#titlediv,#post-body,#editorcontainer,.tablenav,.widget-liquid-left,.widget-liquid-right,#widgets-left,.widgets-sortables,#dragHelper,.widget .widget-top,.widget,.widget-control-actions,.tagchecklist,#col-container,#col-left,#col-right,.fileedit-sub{display:block;zoom:100%;}p.search-box{position:static;float:right;margin:-3px 0 4px;}* html #editorcontainer{padding:0;}#editorcontainer #content{overflow:auto;margin:auto;width:98%;}form#template div{width:100%;}#ed_toolbar input,#ed_reply_toolbar input{overflow:visible;padding:0 4px;}#poststuff h2{font-size:1.6em;}* html #poststuff h2{margin-left:0;}#bh{margin:7px 10px 0 0;float:right;}div#dashboard-widgets{padding-right:1px;}.tagchecklist span,.tagchecklist span a{display:inline-block;display:block;}.tagchecklist span a{margin:4px 0 0 -9px;}.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 .actions select{width:155px;}table.ie-fixed{table-layout:fixed;}.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;}.widefat{empty-cells:show;border-collapse:collapse;}.tablenav a.button-secondary{display:inline-block;padding:2px 5px;}* html .stuffbox,* html .stuffbox input,* html .stuffbox textarea{border:1px solid #DFDFDF;}* html .feature-filter .feature-group li{width:145px;}* html .widget-top .widget-title-action a{background:url("../images/menu-bits.gif?ver=20100610") no-repeat scroll 0 -110px;}* html div.widget-liquid-left{width:99%;}#wp_inactive_widgets{padding-bottom:8px;}* html .widgets-sortables{height:50px;}* html a#content_resize{right:-2px;}* html .widget-title h4{width:205px;}* html #removing-widget .in-widget-title{display:none;}#available-widgets .widget-holder{padding-bottom:65px;}#widgets-left .inactive{padding-bottom:10px;}.widget-liquid-right .widget,#wp_inactive_widgets .widget{position:relative;}* html .media-item .pinkynail{height:32px;width:40px;}#wpcontent .button-primary-disabled{color:#9FD0D5;background:#298CBA;}#wpcontent #ajax-loading,#wpcontent .ajax-loading{vertical-align:baseline;}* html .describe .field input.text,* html .describe .field textarea{width:440px;}#the-comment-list .unapproved tr,#the-comment-list .unapproved td{background-color:#ffffe0;}.imgedit-submit{width:300px;}* html input{border:1px solid #dfdfdf;}#nav-menu-header,#nav-menus-frame,#wpbody,.menu li{zoom:100%;}#update-nav-menu #post-body{overflow:hidden;}.menu li{min-width:100%;}.menu li.sortable-placeholder{min-width:400px;}
Index: /tags/3.1/wp-admin/css/ie.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/ie.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/ie.dev.css	(revision 17487)
@@ -0,0 +1,465 @@
+/* Fixes for IE bugs */
+
+#wpbody-content input.button,
+#wpbody-content input.button-secondary,
+#wpbody-content input.button-highlighted {
+	padding: 2px 3px;
+}
+
+#minor-publishing-actions input,
+#major-publishing-actions input {
+	min-width: auto;
+	padding-left: 0;
+	padding-right: 0;
+}
+
+#wpbody-content .postbox {
+	border: 1px solid #dfdfdf;
+}
+
+#wpbody-content .postbox h3 {
+	margin-bottom: -1px;
+}
+
+* html .meta-box-sortables .postbox .handlediv {
+	background: transparent url(../images/menu-bits-vs.gif) no-repeat scroll left -111px;
+}
+
+* html .edit-box {
+	display: inline;
+}
+
+* html .inner-sidebar #side-sortables,
+* html .postbox-container .meta-box-sortables {
+	height: 300px;
+}
+
+* html #wpbody-content #screen-options-link-wrap {
+	display: inline-block;
+	width: 150px;
+	text-align: center;
+}
+
+* html #wpbody-content #contextual-help-link-wrap {
+	display: inline-block;
+	width: 100px;
+	text-align: center;
+}
+
+* html #adminmenu {
+	margin-left: -80px;
+}
+
+* html .folded #adminmenu {
+	margin-left: -22px;
+}
+
+* html #wpcontent #adminmenu li.menu-top {
+	display: inline;
+	padding: 0;
+	margin: 0;
+}
+
+* html #footer {
+	margin: 0;
+}
+
+.folded #adminmenu li.menu-top {
+	display: block;
+	zoom: 100%;
+}
+
+ul#adminmenu {
+	z-index: 99;
+}
+
+#adminmenu li.menu-top a.menu-top {
+	min-width: auto;
+	width: auto;
+}
+
+#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu {
+	font-style: normal;
+}
+
+* html #wpcontent #adminmenu .wp-menu-open .wp-menu-toggle {
+	background: none;
+}
+
+* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle {
+	background: url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -109px;
+}
+
+* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle {
+	background: url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -206px;
+}
+
+* html #adminmenu div.wp-menu-image {
+	height: 29px;
+}
+
+#wpcontent #adminmenu .wp-submenu li {
+	padding: 0;
+}
+
+#adminmenu,
+.major-publishing-actions,
+.wp-submenu,
+.wp-submenu li,
+.wp-menu-toggle {
+	zoom: 100%;
+}
+
+.folded #adminmenu li.wp-menu-separator {
+	width: 28px;
+}
+
+#wpcontent #adminmenu .wp-submenu li.wp-submenu-head {
+	padding: 3px 4px 4px 10px;
+	zoom: 100%;
+}
+
+.folded #adminmenu .menu-top {
+	height: 30px;
+}
+
+.folded #adminmenu .wp-submenu {
+	margin: -1px 0 0 0;
+}
+
+#template,
+#template div,
+#editcat,
+#addcat,
+* html .stuffbox h3 {
+	zoom: 100%;
+}
+
+.submitbox {
+	margin-top: 10px;
+}
+
+/* Inline Editor */
+#wpbody-content .quick-edit-row-post .inline-edit-col-left {
+	width: 39%;
+}
+
+#wpbody-content .inline-edit-row-post .inline-edit-col-center {
+	width: 19%;
+}
+
+#wpbody-content .quick-edit-row-page .inline-edit-col-left {
+	width: 49%;
+}
+
+#wpbody-content .bulk-edit-row .inline-edit-col-left {
+	width: 29%;
+}
+
+.inline-edit-row p.submit {
+	zoom: 100%;
+}
+
+.inline-edit-row fieldset label span.title {
+	display: block;
+	float: left;
+	width: 5em;
+}
+
+.inline-edit-row fieldset label span.input-text-wrap {
+	margin-left: 0;
+	zoom: 100%;
+}
+
+#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input {
+	line-height: 130%;
+}
+
+#wpbody-content .inline-edit-row .input-text-wrap input {
+	width: 95%;
+}
+
+#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input {
+	width: 8em;
+}
+/* end Inline Editor */
+
+input {
+	line-height: 1;
+}
+
+* html .row-actions {
+	visibility: visible;
+}
+
+#dashboard-widgets h3 a {
+	height: 20px;
+	line-height: 20px;
+}
+
+#wphead-info {
+	float: right;
+}
+
+#titlediv #title {
+	width: 98%;
+}
+
+a.button {
+	line-height: 1.4em;
+	margin: 1px;
+	padding: 2px 6px;
+}
+
+* html div.widget-liquid-left,
+* html div.widget-liquid-right {
+	display: block;
+	position: relative;
+}
+
+#screen-options-wrap {
+	overflow: hidden;
+}
+
+#favorite-actions {
+	z-index: 12;
+}
+
+#favorite-inside,
+#favorite-inside a,
+.favorite-action {
+	zoom: 100%;
+}
+
+#the-comment-list .comment-item,
+#post-status-info,
+#wpwrap,
+#wpcontent,
+#wrap,
+#postdivrich,
+#postdiv,
+#poststuff,
+.metabox-holder,
+#titlediv,
+#post-body,
+#editorcontainer,
+.tablenav,
+.widget-liquid-left,
+.widget-liquid-right,
+#widgets-left,
+.widgets-sortables,
+#dragHelper,
+.widget .widget-top,
+.widget,
+.widget-control-actions,
+.tagchecklist,
+#col-container,
+#col-left,
+#col-right,
+.fileedit-sub {
+	display: block;
+	zoom: 100%;
+}
+
+p.search-box {
+	position: static;
+	float: right;
+	margin: -3px 0 4px;
+}
+
+* html #editorcontainer {
+	padding: 0;
+}
+
+#editorcontainer #content {
+	overflow: auto;
+	margin: auto;
+	width: 98%;
+}
+
+form#template div {
+	width: 100%;
+}
+
+#ed_toolbar input,
+#ed_reply_toolbar input {
+	overflow: visible;
+	padding: 0 4px;
+}
+
+#poststuff h2 {
+	font-size: 1.6em;
+}
+
+* html #poststuff h2 {
+	margin-left: 0;
+}
+
+#bh {
+	margin: 7px 10px 0 0;
+	float: right;
+}
+
+/* without this dashboard widgets appear in one column for some screen widths */
+div#dashboard-widgets {
+	padding-right: 1px;
+}
+
+.tagchecklist span, .tagchecklist span a {
+	display: inline-block;
+	display: block;
+}
+
+.tagchecklist span a {
+	margin: 4px 0 0 -9px;
+}
+
+.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 .actions select {
+	width: 155px;
+}
+
+table.ie-fixed {
+	table-layout: fixed;
+}
+
+.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;
+}
+
+.widefat {
+	empty-cells: show;
+	border-collapse: collapse;
+}
+
+.tablenav a.button-secondary {
+	display: inline-block;
+	padding: 2px 5px;
+}
+
+* html .stuffbox,
+* html .stuffbox input,
+* html .stuffbox textarea {
+	border: 1px solid #DFDFDF;
+}
+
+* html .feature-filter .feature-group li {
+	width: 145px;
+}
+
+* html .widget-top .widget-title-action a {
+	background: url("../images/menu-bits.gif?ver=20100610") no-repeat scroll 0 -110px;
+}
+
+* html div.widget-liquid-left {
+	width: 99%;
+}
+
+#wp_inactive_widgets {
+	padding-bottom: 8px;
+}
+
+* html .widgets-sortables {
+	height: 50px;
+}
+
+* html a#content_resize {
+	right: -2px;
+}
+
+* html .widget-title h4 {
+	width: 205px;
+}
+
+* html #removing-widget .in-widget-title {
+	display: none;
+}
+
+#available-widgets .widget-holder {
+	padding-bottom: 65px;
+}
+
+#widgets-left .inactive {
+	padding-bottom: 10px;
+}
+
+.widget-liquid-right .widget,
+#wp_inactive_widgets .widget {
+	position: relative;
+}
+
+* html .media-item .pinkynail {
+	height: 32px;
+	width: 40px;
+}
+
+#wpcontent .button-primary-disabled {
+	color: #9FD0D5;
+	background: #298CBA;
+}
+
+#wpcontent #ajax-loading,
+#wpcontent .ajax-loading {
+	vertical-align: baseline;
+}
+
+* html .describe .field input.text,
+* html .describe .field textarea {
+	width: 440px;
+}
+
+#the-comment-list .unapproved tr,
+#the-comment-list .unapproved td {
+	background-color: #ffffe0;
+}
+
+.imgedit-submit {
+	width: 300px;
+}
+
+* html input {
+	border: 1px solid #dfdfdf;
+}
+
+#nav-menu-header,
+#nav-menus-frame,
+#wpbody,
+.menu li {
+	zoom:100%;
+}
+
+#update-nav-menu #post-body {
+	overflow:hidden;
+}
+
+.menu li {
+	min-width:100%;
+}
+
+.menu li.sortable-placeholder {
+	min-width:400px;
+}
Index: /tags/3.1/wp-admin/css/install-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/install-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/install-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+body{font-family:Tahoma,arial;}h1{font-family:arial;margin:5px -4px 0 0;}ul,ol{padding:5px 22px 5px 5px;}.step,th{text-align:right;}.submit input,.button,.button-secondary{font-family:Tahoma,arial;margin-right:0;}.form-table th{text-align:right;}#user_login,#admin_email,#pass1,#pass2{direction:ltr;}
Index: /tags/3.1/wp-admin/css/install-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/install-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/install-rtl.dev.css	(revision 17487)
@@ -0,0 +1,23 @@
+body {
+	font-family: Tahoma, arial;
+}
+h1 {
+	font-family: arial;
+	margin: 5px -4px 0 0;
+}
+ul, ol {
+	padding: 5px 22px 5px 5px;
+}
+.step, th {
+	text-align: right;
+}
+.submit input, .button, .button-secondary {
+	font-family: Tahoma, arial;
+	margin-right: 0;
+}
+.form-table th {
+	text-align: right;
+}
+#user_login, #admin_email, #pass1, #pass2 {
+	direction: ltr;
+}
Index: /tags/3.1/wp-admin/css/install.css
===================================================================
--- /tags/3.1/wp-admin/css/install.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/install.css	(revision 17487)
@@ -0,0 +1,1 @@
+html{background:#f9f9f9;}body{background:#fff;color:#333;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;margin:2em auto;width:700px;padding:1em 2em;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;border:1px solid #dfdfdf;}a{color:#2583ad;text-decoration:none;}a:hover{color:#d54e21;}h1{border-bottom:1px solid #dadada;clear:both;color:#666;font:24px Georgia,"Times New Roman",Times,serif;margin:5px 0 0 -4px;padding:0;padding-bottom:7px;}h2{font-size:16px;}p,li,dd,dt{padding-bottom:2px;font-size:12px;line-height:18px;}code,.code{font-size:13px;}ul,ol,dl{padding:5px 5px 5px 22px;}a img{border:0;}abbr{border:0;font-variant:normal;}#logo{margin:6px 0 14px 0;border-bottom:none;text-align:center;}.step{margin:20px 0 15px;}.step,th{text-align:left;padding:0;}.submit input,.button,.button-secondary{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;text-decoration:none;font-size:14px!important;line-height:16px;padding:6px 12px;cursor:pointer;border:1px solid #bbb;color:#464646;-moz-border-radius:15px;-khtml-border-radius:15px;-webkit-border-radius:15px;border-radius:15px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;-khtml-box-sizing:content-box;box-sizing:content-box;}.button:hover,.button-secondary:hover,.submit input:hover{color:#000;border-color:#666;}.button,.submit input,.button-secondary{background:#f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;}.button:active,.submit input:active,.button-secondary:active{background:#eee url(../images/white-grad-active.png) repeat-x scroll left top;}textarea{border:1px solid #bbb;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;}.form-table{border-collapse:collapse;margin-top:1em;width:100%;}.form-table td{margin-bottom:9px;padding:10px;border-bottom:8px solid #fff;font-size:12px;}.form-table th{font-size:13px;text-align:left;padding:16px 10px 10px 10px;border-bottom:8px solid #fff;width:130px;vertical-align:top;}.form-table tr{background:#f3f3f3;}.form-table code{line-height:18px;font-size:18px;}.form-table p{margin:4px 0 0 0;font-size:11px;}.form-table input{line-height:20px;font-size:15px;padding:2px;}.form-table th p{font-weight:normal;}#error-page{margin-top:50px;}#error-page p{font-size:12px;line-height:18px;margin:25px 0 20px;}#error-page code,.code{font-family:Consolas,Monaco,Courier,monospace;}#pass-strength-result{background-color:#eee;border-color:#ddd!important;border-style:solid;border-width:1px;margin:5px 5px 5px 1px;padding:5px;text-align:center;width:200px;display:none;}#pass-strength-result.bad{background-color:#ffb78c;border-color:#ff853c!important;}#pass-strength-result.good{background-color:#ffec8b;border-color:#fc0!important;}#pass-strength-result.short{background-color:#ffa0a0;border-color:#f04040!important;}#pass-strength-result.strong{background-color:#c3ff88;border-color:#8dff1c!important;}.message{border:1px solid #e6db55;padding:.3em .6em;margin:5px 0 15px;background-color:#ffffe0;}
Index: /tags/3.1/wp-admin/css/install.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/install.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/install.dev.css	(revision 17487)
@@ -0,0 +1,213 @@
+html {
+	background: #f9f9f9;
+}
+
+body {
+	background: #fff;
+	color: #333;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	margin: 2em auto;
+	width: 700px;
+	padding: 1em 2em;
+	-moz-border-radius: 11px;
+	-khtml-border-radius: 11px;
+	-webkit-border-radius: 11px;
+	border-radius: 11px;
+	border: 1px solid #dfdfdf;
+}
+
+a {
+	color: #2583ad;
+	text-decoration: none;
+}
+
+a:hover {
+	color: #d54e21;
+}
+
+h1 {
+	border-bottom: 1px solid #dadada;
+	clear: both;
+	color: #666;
+	font: 24px Georgia, "Times New Roman", Times, serif;
+	margin: 5px 0 0 -4px;
+	padding: 0;
+	padding-bottom: 7px;
+}
+
+h2 {
+	font-size: 16px;
+}
+
+p, li, dd, dt {
+	padding-bottom: 2px;
+	font-size: 12px;
+	line-height: 18px;
+}
+
+code, .code {
+	font-size: 13px;
+}
+
+ul, ol, dl {
+	padding: 5px 5px 5px 22px;
+}
+
+a img {
+	border:0
+}
+abbr {
+	border: 0;
+	font-variant: normal;
+}
+#logo {
+	margin: 6px 0 14px 0;
+	border-bottom: none;
+	text-align:center
+}
+.step {
+	margin: 20px 0 15px;
+}
+.step, th {
+	text-align: left;
+	padding: 0;
+}
+
+.submit input, .button, .button-secondary {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	text-decoration: none;
+	font-size: 14px !important;
+	line-height: 16px;
+	padding: 6px 12px;
+	cursor: pointer;
+	border: 1px solid #bbb;
+	color: #464646;
+	-moz-border-radius: 15px;
+	-khtml-border-radius: 15px;
+	-webkit-border-radius: 15px;
+	border-radius: 15px;
+	-moz-box-sizing: content-box;
+	-webkit-box-sizing: content-box;
+	-khtml-box-sizing: content-box;
+	box-sizing: content-box;
+}
+
+.button:hover, .button-secondary:hover, .submit input:hover {
+	color: #000;
+	border-color: #666;
+}
+
+.button, .submit input, .button-secondary {
+	background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
+}
+
+.button:active, .submit input:active, .button-secondary:active {
+	background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
+}
+
+textarea {
+	border: 1px solid #bbb;
+	-moz-border-radius: 4px;
+	-khtml-border-radius: 4px;
+	-webkit-border-radius: 4px;
+	border-radius: 4px;
+}
+
+.form-table {
+	border-collapse: collapse;
+	margin-top: 1em;
+	width: 100%;
+}
+
+.form-table td {
+	margin-bottom: 9px;
+	padding: 10px;
+	border-bottom: 8px solid #fff;
+	font-size: 12px;
+}
+
+.form-table th {
+	font-size: 13px;
+	text-align: left;
+	padding: 16px 10px 10px 10px;
+	border-bottom: 8px solid #fff;
+	width: 130px;
+	vertical-align: top;
+}
+
+.form-table tr {
+	background: #f3f3f3;
+}
+
+.form-table code {
+	line-height: 18px;
+	font-size: 18px;
+}
+
+.form-table p {
+	margin: 4px 0 0 0;
+	font-size: 11px;
+}
+
+.form-table input {
+	line-height: 20px;
+	font-size: 15px;
+	padding: 2px;
+}
+
+.form-table th p {
+	font-weight: normal;
+}
+
+#error-page {
+	margin-top: 50px;
+}
+
+#error-page p {
+	font-size: 12px;
+	line-height: 18px;
+	margin: 25px 0 20px;
+}
+
+#error-page code, .code {
+	font-family: Consolas, Monaco, Courier, monospace;
+}
+
+#pass-strength-result {
+	background-color: #eee;
+	border-color: #ddd !important;
+	border-style: solid;
+	border-width: 1px;
+	margin: 5px 5px 5px 1px;
+	padding: 5px;
+	text-align: center;
+	width: 200px;
+	display: none;
+}
+
+#pass-strength-result.bad {
+	background-color: #ffb78c;
+	border-color: #ff853c !important;
+}
+
+#pass-strength-result.good {
+	background-color: #ffec8b;
+	border-color: #ffcc00 !important;
+}
+
+#pass-strength-result.short {
+	background-color: #ffa0a0;
+	border-color: #f04040 !important;
+}
+
+#pass-strength-result.strong {
+	background-color: #c3ff88;
+	border-color: #8dff1c !important;
+}
+
+.message {
+	border: 1px solid #e6db55;
+	padding: 0.3em 0.6em;
+	margin: 5px 0 15px;
+	background-color: #ffffe0;
+}
Index: /tags/3.1/wp-admin/css/login-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/login-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/login-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+body{font-family:Tahoma,arial;}form{margin-right:8px;margin-left:0;}form .forgetmenot{float:right;}#login form .submit input{font-family:Tahoma,arial;}form .submit{float:left;}#backtoblog a{padding:8px 15px 0 0;}#login_error,.message{margin:0 8px 16px 0;}#nav{margin:0 8px 0 0;}#user_pass,#user_login,#user_email{margin-left:6px;margin-right:0;direction:ltr;}h1 a{text-decoration:none;}
Index: /tags/3.1/wp-admin/css/login-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/login-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/login-rtl.dev.css	(revision 17487)
@@ -0,0 +1,29 @@
+body {
+	font-family: Tahoma, arial;
+}
+form {
+	margin-right: 8px;
+	margin-left: 0;
+}
+form .forgetmenot {
+	float: right;
+}
+#login form .submit input {
+	font-family: Tahoma, arial;
+}
+form .submit { float: left; }
+#backtoblog a {
+	padding: 8px 15px 0 0;
+}
+#login_error, .message {
+	margin: 0 8px 16px 0;
+}
+#nav { margin: 0 8px 0 0; }
+#user_pass, #user_login, #user_email {
+	margin-left: 6px;
+	margin-right: 0;
+	direction:ltr;
+}
+h1 a {
+	text-decoration: none;
+}
Index: /tags/3.1/wp-admin/css/login.css
===================================================================
--- /tags/3.1/wp-admin/css/login.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/login.css	(revision 17487)
@@ -0,0 +1,1 @@
+*{margin:0;padding:0;}body{padding-top:30px;font:11px "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;}form{margin-left:8px;padding:16px 16px 40px 16px;font-weight:normal;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;background:#fff;border:1px solid #e5e5e5;-moz-box-shadow:rgba(200,200,200,1) 0 4px 18px;-webkit-box-shadow:rgba(200,200,200,1) 0 4px 18px;-khtml-box-shadow:rgba(200,200,200,1) 0 4px 18px;box-shadow:rgba(200,200,200,1) 0 4px 18px;}form .forgetmenot{font-weight:normal;float:left;margin-bottom:0;}.button-primary{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;padding:3px 10px;border:none;font-size:12px;border-width:1px;border-style:solid;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;cursor:pointer;text-decoration:none;margin-top:-3px;}#login form p{margin-bottom:0;}label{color:#777;font-size:13px;}form .forgetmenot label{font-size:11px;line-height:19px;}form .submit,.alignright{float:right;}form p{margin-bottom:24px;}h1 a{background:url(../images/logo-login.gif) no-repeat top center;width:326px;height:67px;text-indent:-9999px;overflow:hidden;padding-bottom:15px;display:block;}#nav{text-shadow:rgba(255,255,255,1) 0 1px 0;}#backtoblog{position:absolute;top:0;left:0;border-bottom:#c6c6c6 1px solid;background:#d9d9d9;background:-moz-linear-gradient(bottom,#d7d7d7,#e4e4e4);background:-webkit-gradient(linear,left bottom,left top,from(#d7d7d7),to(#e4e4e4));height:30px;width:100%;}#backtoblog a{text-decoration:none;display:block;padding:8px 0 0 15px;}#login{width:320px;margin:7em auto;}#login_error,.message{margin:0 0 16px 8px;border-width:1px;border-style:solid;padding:12px;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;}#nav{margin:0 0 0 8px;padding:16px;}body form .input{font-size:24px;width:97%;padding:3px;margin-top:2px;margin-right:6px;margin-bottom:16px;border:1px solid #e5e5e5;background:#fbfbfb;}input{color:#555;}.clear{clear:both;}#pass-strength-result{font-weight:bold;border-style:solid;border-width:1px;margin:12px 0 6px;padding:6px 5px;text-align:center;}
Index: /tags/3.1/wp-admin/css/login.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/login.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/login.dev.css	(revision 17487)
@@ -0,0 +1,147 @@
+* { margin: 0; padding: 0; }
+
+body {
+	padding-top: 30px;
+	font: 11px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
+
+form {
+	margin-left: 8px;
+	padding: 16px 16px 40px 16px;
+	font-weight: normal;
+	-moz-border-radius: 11px;
+	-khtml-border-radius: 11px;
+	-webkit-border-radius: 11px;
+	border-radius: 11px;
+	background: #fff;
+	border: 1px solid #e5e5e5;
+	-moz-box-shadow: rgba(200,200,200,1) 0 4px 18px;
+	-webkit-box-shadow: rgba(200,200,200,1) 0 4px 18px;
+	-khtml-box-shadow: rgba(200,200,200,1) 0 4px 18px;
+	box-shadow: rgba(200,200,200,1) 0 4px 18px;
+}
+
+form .forgetmenot {
+	font-weight: normal;
+	float: left;
+	margin-bottom: 0;
+}
+
+.button-primary {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	padding: 3px 10px;
+	border: none;
+	font-size: 12px;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 11px;
+	-khtml-border-radius: 11px;
+	-webkit-border-radius: 11px;
+	border-radius: 11px;
+	cursor: pointer;
+	text-decoration: none;
+	margin-top: -3px;
+}
+
+#login form p {
+	margin-bottom: 0;
+}
+
+label {
+	color: #777;
+	font-size: 13px;
+}
+
+form .forgetmenot label {
+	font-size: 11px;
+	line-height: 19px;
+}
+
+form .submit,
+.alignright {
+	float: right;
+}
+
+form p {
+	margin-bottom: 24px;
+}
+
+h1 a {
+	background: url(../images/logo-login.gif) no-repeat top center;
+	width: 326px;
+	height: 67px;
+	text-indent: -9999px;
+	overflow: hidden;
+	padding-bottom: 15px;
+	display: block;
+}
+
+#nav {
+	text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+#backtoblog {
+	position: absolute;
+	top: 0;
+	left: 0;
+	border-bottom: #c6c6c6 1px solid;
+	background: #d9d9d9; /* fallback color */
+	background: -moz-linear-gradient(bottom,  #d7d7d7,  #e4e4e4);
+	background: -webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4));
+	height: 30px;
+	width: 100%;
+}
+
+#backtoblog a {
+	text-decoration: none;
+	display: block;
+	padding: 8px 0 0 15px;
+}
+
+#login { width: 320px; margin: 7em auto; }
+
+#login_error,
+.message {
+	margin: 0 0 16px 8px;
+	border-width: 1px;
+	border-style: solid;
+	padding: 12px;
+	-moz-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+}
+
+#nav {
+	margin: 0 0 0 8px;
+	padding: 16px;
+}
+
+body form .input {
+	font-size: 24px;
+	width: 97%;
+	padding: 3px;
+	margin-top: 2px;
+	margin-right: 6px;
+	margin-bottom: 16px;
+	border: 1px solid #e5e5e5;
+	background: #fbfbfb;
+}
+
+input {
+	color: #555;
+}
+
+.clear {
+	clear: both;
+}
+
+#pass-strength-result {
+	font-weight: bold;
+	border-style: solid;
+	border-width: 1px;
+	margin: 12px 0 6px;
+	padding: 6px 5px;
+	text-align: center;
+}
+
Index: /tags/3.1/wp-admin/css/media-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/media-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/media-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+body#media-upload ul#sidemenu{left:auto;right:0;}#search-filter{text-align:left;}.align .field label{padding:0 28px 0 0;margin:0 0 0 1em;}.image-align-none-label,.image-align-left-label,.image-align-center-label,.image-align-right-label{background-position:center right;}tr.image-size div.image-size-item{float:right;}tr.image-size label{margin:0 1em 0 0;}.filename.original{float:right;}.crunching{text-align:left;margin-right:0;margin-left:5px;}button.dismiss{right:auto;left:5px;}.file-error{margin:0 50px 5px 0;}.progress{left:auto;right:0;}.describe td{padding:0 0 0 5px;}.bar{border-right-width:0;border-left-width:3px;border-right-style:none;border-left-style:solid;}#media-upload .media-upload-form p{margin:0 0 1em 1em;}.filename{float:right;margin-left:0;margin-right:10px;}#media-upload .describe th.label{text-align:right;}.menu_order{float:left;}.media-upload-form label.form-help,td.help,#media-upload p.help,#media-upload label.help{font-family:Tahoma,Arial;}#gallery-settings #basic th.label{padding:5px 0 5px 5px;}#gallery-settings .title,h3.media-title{font-family:Tahoma,Arial;}#gallery-settings .describe th.label{text-align:right;}#gallery-settings label,#gallery-settings legend{margin-right:0;margin-left:15px;}#gallery-settings .align .field label{margin:0 0 0 1.5em;}
Index: /tags/3.1/wp-admin/css/media-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/media-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/media-rtl.dev.css	(revision 17487)
@@ -0,0 +1,85 @@
+body#media-upload ul#sidemenu {
+	left: auto;
+	right: 0;
+}
+#search-filter {
+	text-align: left;
+}
+/* specific to the image upload form */
+.align .field label {
+	padding: 0 28px 0 0;
+	margin: 0 0 0 1em;
+}
+.image-align-none-label, .image-align-left-label, .image-align-center-label, .image-align-right-label {
+	background-position: center right;
+}
+tr.image-size div.image-size-item {
+	float: right;
+}
+tr.image-size label {
+	margin: 0 1em 0 0;
+}
+.filename.original {
+	float: right;
+}
+.crunching {
+	text-align: left;
+	margin-right: 0;
+	margin-left: 5px;
+}
+button.dismiss {
+	right: auto;
+	left: 5px;
+}
+.file-error {
+	margin: 0 50px 5px 0;
+}
+.progress {
+	left: auto;
+	right: 0;
+}
+.describe td {
+	padding: 0 0 0 5px;
+}
+.bar {
+	border-right-width: 0;
+	border-left-width: 3px;
+	border-right-style: none;
+	border-left-style: solid;
+}
+
+/* Specific to Uploader */
+#media-upload .media-upload-form p {
+	margin: 0 0 1em 1em;
+}
+.filename {
+	float: right;
+	margin-left: 0;
+	margin-right: 10px;
+}
+#media-upload .describe th.label {
+	text-align: right;
+}
+.menu_order {
+	float: left;
+}
+.media-upload-form label.form-help, td.help, #media-upload p.help, #media-upload label.help {
+	font-family: Tahoma, Arial;
+}
+#gallery-settings #basic th.label {
+	padding: 5px 0 5px 5px;
+}
+#gallery-settings .title, h3.media-title {
+	font-family: Tahoma, Arial;
+}
+#gallery-settings .describe th.label {
+	text-align: right;
+}
+#gallery-settings label,
+#gallery-settings legend {
+	margin-right: 0;
+	margin-left: 15px;
+}
+#gallery-settings .align .field label {
+	margin: 0 0 0 1.5em;
+}
Index: /tags/3.1/wp-admin/css/media.css
===================================================================
--- /tags/3.1/wp-admin/css/media.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/media.css	(revision 17487)
@@ -0,0 +1,1 @@
+div#media-upload-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;}body#media-upload ul#sidemenu{font-weight:normal;margin:0 5px;left:0;bottom:-1px;float:none;overflow:hidden;}div#media-upload-error{margin:1em;font-weight:bold;}form{margin:1em;}#search-filter{text-align:right;}th{position:relative;}.media-upload-form label.form-help,td.help{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-style:italic;font-weight:normal;}.media-upload-form p.help{margin:0;padding:0;}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em 0;padding:0;}.image-align-none-label{background:url(../images/align-none.png) no-repeat center left;}.image-align-left-label{background:url(../images/align-left.png) no-repeat center left;}.image-align-center-label{background:url(../images/align-center.png) no-repeat center left;}.image-align-right-label{background:url(../images/align-right.png) no-repeat center left;}tr.image-size td{width:460px;}tr.image-size div.image-size-item{float:left;width:25%;margin:0;}#library-form .progress,#gallery-form .progress,#flash-upload-ui,.insert-gallery,.describe.startopen,.describe.startclosed{display:none;}.media-item .thumbnail{max-width:128px;max-height:128px;}thead.media-item-info tr{background-color:transparent;}thead.media-item-info th,thead.media-item-info td{border:none;margin:0;}.form-table thead.media-item-info{border:8px solid #fff;}abbr.required{text-decoration:none;border:none;}.describe label{display:inline;}.describe td{vertical-align:middle;padding:0 5px 8px 0;}.describe td.error{padding:2px 8px;}.describe td.A1{width:132px;}.describe input[type="text"],.describe textarea{width:460px;border-width:1px;border-style:solid;}.hidden{height:0;width:0;overflow:hidden;border:none;}#media-upload p.ml-submit{padding:1em 0;}#media-upload p.help,#media-upload label.help{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-style:italic;font-weight:normal;}#media-upload tr.image-size td.field{text-align:center;}#media-upload #media-items{border-width:1px;border-style:solid;border-bottom:none;width:623px;}#media-upload .media-item{border-bottom-width:1px;border-bottom-style:solid;min-height:36px;width:100%;}#media-upload .ui-sortable .media-item{cursor:move;}.filename{line-height:36px;padding:0 10px;overflow:hidden;}#media-upload .describe{width:100%;clear:both;cursor:default;}#media-upload .slidetoggle{border-top-width:1px;border-top-style:solid;}#media-upload .describe th.label{padding-top:.2em;text-align:left;min-width:120px;}#media-upload tr.align td.field{text-align:center;}#media-upload tr.image-size{margin-bottom:1em;height:3em;}#media-upload #filter{width:623px;}#media-upload #filter .subsubsub{margin:8px 0;}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto;}#media-upload .del-attachment{display:none;margin:5px 0;}.menu_order{float:right;font-size:11px;margin:10px 10px 0;}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px;}.ui-sortable-helper{background-color:#fff;border:1px solid #aaa;opacity:.6;filter:alpha(opacity=60);}#media-upload th.order-head{width:20%;text-align:center;}#media-upload th.actions-head{width:25%;text-align:center;}#media-upload a.wp-post-thumbnail{margin:0 20px;}#media-items a.delete{display:block;float:right;}#media-upload .widefat{width:626px;border-style:solid solid none;}.sorthelper{height:37px;width:623px;display:block;}#gallery-settings th.label{width:160px;}#gallery-settings #basic th.label{padding:5px 5px 5px 0;}#gallery-settings .title{clear:both;padding:0 0 3px;font-size:1.6em;border-bottom:1px solid #DADADA;}h3.media-title{font-size:1.6em;}h4.media-sub-title{border-bottom:1px solid #DADADA;font-size:1.3em;margin:12px;padding:0 0 3px;}#gallery-settings .title,h3.media-title,h4.media-sub-title{font-family:Georgia,"Times New Roman",Times,serif;font-weight:normal;color:#5A5A5A;}#gallery-settings .describe td{vertical-align:middle;height:3em;}#gallery-settings .describe th.label{padding-top:.5em;text-align:left;}#gallery-settings .describe{padding:5px;width:615px;clear:both;cursor:default;}#gallery-settings .describe select{width:15em;}#gallery-settings .describe select option,#gallery-settings .describe td{padding:0;}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#464646;margin-right:15px;}#gallery-settings .align .field label{margin:0 1.5em 0 0;}#gallery-settings p.ml-submit{border-top:1px solid #dfdfdf;}#gallery-settings select#columns{width:6em;}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px;}#sort-buttons a{text-decoration:none;}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px;}#sort-buttons span{margin-right:25px;}
Index: /tags/3.1/wp-admin/css/media.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/media.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/media.dev.css	(revision 17487)
@@ -0,0 +1,383 @@
+div#media-upload-header {
+	margin: 0;
+	padding: 0 5px;
+	font-weight: bold;
+	position: relative;
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+}
+
+body#media-upload ul#sidemenu {
+	font-weight: normal;
+	margin: 0 5px;
+	left: 0;
+	bottom: -1px;
+	float: none;
+	overflow: hidden;
+}
+
+div#media-upload-error {
+	margin: 1em;
+	font-weight: bold;
+}
+
+form {
+	margin: 1em;
+}
+
+#search-filter {
+	text-align: right;
+}
+
+th {
+	position: relative;
+}
+
+.media-upload-form label.form-help, td.help {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-style: italic;
+	font-weight: normal;
+}
+
+.media-upload-form p.help {
+	margin: 0;
+	padding: 0;
+}
+
+.media-upload-form fieldset {
+	width: 100%;
+	border: none;
+	text-align: justify;
+	margin: 0 0 1em 0;
+	padding: 0;
+}
+
+/* specific to the image upload form */
+
+
+.image-align-none-label {
+	background: url(../images/align-none.png) no-repeat center left;
+}
+
+.image-align-left-label {
+	background: url(../images/align-left.png) no-repeat center left;
+}
+
+.image-align-center-label {
+	background: url(../images/align-center.png) no-repeat center left;
+}
+
+.image-align-right-label {
+	background: url(../images/align-right.png) no-repeat center left;
+}
+
+tr.image-size td {
+	width: 460px;
+}
+
+tr.image-size div.image-size-item {
+	float: left;
+	width: 25%;
+	margin: 0;
+}
+
+#library-form .progress,
+#gallery-form .progress,
+#flash-upload-ui,
+.insert-gallery,
+.describe.startopen,
+.describe.startclosed {
+	display: none;
+}
+
+.media-item .thumbnail {
+	max-width: 128px;
+	max-height: 128px;
+}
+
+thead.media-item-info tr {
+	background-color: transparent;
+}
+
+thead.media-item-info th,
+thead.media-item-info td {
+	border: none;
+	margin: 0;
+}
+
+.form-table thead.media-item-info {
+	border: 8px solid #fff;
+}
+
+abbr.required {
+	text-decoration: none;
+	border: none;
+}
+
+.describe label {
+	display: inline;
+}
+
+.describe td {
+	vertical-align: middle;
+	padding: 0 5px 8px 0;
+}
+
+.describe td.error {
+	padding: 2px 8px;
+}
+
+.describe td.A1 {
+	width: 132px;
+}
+
+.describe input[type="text"],
+.describe textarea {
+	width: 460px;
+	border-width: 1px;
+	border-style: solid;
+}
+
+.hidden {
+	height: 0;
+	width: 0;
+	overflow: hidden;
+	border: none;
+}
+
+/* Specific to Uploader */
+
+#media-upload p.ml-submit {
+	padding: 1em 0;
+}
+
+#media-upload p.help,
+#media-upload label.help {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-style: italic;
+	font-weight: normal;
+}
+
+#media-upload tr.image-size td.field {
+	text-align: center;
+}
+
+#media-upload #media-items {
+	border-width: 1px;
+	border-style: solid;
+	border-bottom: none;
+	width: 623px;
+}
+
+#media-upload .media-item {
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+	min-height: 36px;
+	width: 100%;
+}
+
+#media-upload .ui-sortable .media-item {
+	cursor: move;
+}
+
+.filename {
+	line-height: 36px;
+	padding: 0 10px;
+	overflow: hidden;
+}
+
+#media-upload .describe {
+	width: 100%;
+	clear: both;
+	cursor: default;
+}
+
+#media-upload .slidetoggle {
+	border-top-width: 1px;
+	border-top-style: solid;
+}
+
+#media-upload .describe th.label {
+	padding-top: .2em;
+	text-align: left;
+	min-width: 120px;
+}
+
+#media-upload tr.align td.field {
+	text-align: center;
+}
+
+#media-upload tr.image-size {
+	margin-bottom: 1em;
+	height: 3em;
+}
+
+#media-upload #filter {
+	width: 623px;
+}
+
+#media-upload #filter .subsubsub {
+	margin: 8px 0;
+}
+
+#filter .tablenav select {
+	border-style: solid;
+	border-width: 1px;
+	padding: 2px;
+	vertical-align: top;
+	width: auto;
+}
+
+#media-upload .del-attachment {
+	display: none;
+	margin: 5px 0;
+}
+
+.menu_order {
+	float: right;
+	font-size: 11px;
+	margin: 10px 10px 0;
+}
+
+.menu_order_input {
+	border: 1px solid #ddd;
+	font-size: 10px;
+	padding: 1px;
+	width: 23px;
+}
+
+.ui-sortable-helper {
+	background-color: #fff;
+	border: 1px solid #aaa;
+	opacity: 0.6;
+	filter: alpha(opacity=60);
+}
+
+#media-upload th.order-head {
+	width: 20%;
+	text-align: center;
+}
+
+#media-upload th.actions-head {
+	width: 25%;
+	text-align: center;
+}
+
+#media-upload a.wp-post-thumbnail {
+	margin: 0 20px;
+}
+
+#media-items a.delete {
+	display: block;
+	float: right;
+}
+
+#media-upload .widefat {
+	width: 626px;
+	border-style: solid solid none;
+}
+
+.sorthelper {
+	height: 37px;
+	width: 623px;
+	display: block;
+}
+
+#gallery-settings th.label {
+	width: 160px;
+}
+
+#gallery-settings #basic th.label {
+	padding: 5px 5px 5px 0;
+}
+
+#gallery-settings .title {
+	clear: both;
+	padding: 0 0 3px;
+	font-size: 1.6em;
+	border-bottom: 1px solid #DADADA;
+}
+
+h3.media-title  {
+	font-size: 1.6em;
+}
+
+h4.media-sub-title  {
+	border-bottom: 1px solid #DADADA;
+	font-size: 1.3em;
+	margin: 12px;
+	padding: 0 0 3px;
+}
+
+#gallery-settings .title,
+h3.media-title,
+h4.media-sub-title {
+	font-family: Georgia,"Times New Roman",Times,serif;
+	font-weight: normal;
+	color: #5A5A5A;
+}
+
+#gallery-settings .describe td {
+	vertical-align: middle;
+	height: 3em;
+}
+
+#gallery-settings .describe th.label {
+	padding-top: .5em;
+	text-align: left;
+}
+
+#gallery-settings .describe {
+	padding: 5px;
+	width: 615px;
+	clear: both;
+	cursor: default;
+}
+
+#gallery-settings .describe select {
+	width: 15em;
+}
+
+#gallery-settings .describe select option,
+#gallery-settings .describe td {
+	padding: 0;
+}
+
+#gallery-settings label,
+#gallery-settings legend {
+	font-size: 13px;
+	color: #464646;
+	margin-right: 15px;
+}
+
+#gallery-settings .align .field label {
+	margin: 0 1.5em 0 0;
+}
+
+#gallery-settings p.ml-submit {
+	border-top: 1px solid #dfdfdf;
+}
+
+#gallery-settings select#columns {
+	width: 6em;
+}
+
+#sort-buttons {
+	font-size: 0.8em;
+	margin: 3px 25px -8px 0;
+	text-align: right;
+	max-width: 625px;
+}
+
+#sort-buttons a {
+	text-decoration: none;
+}
+
+#sort-buttons #asc,
+#sort-buttons #showall {
+	padding-left: 5px;
+}
+
+#sort-buttons span {
+	margin-right: 25px;
+}
Index: /tags/3.1/wp-admin/css/ms.css
===================================================================
--- /tags/3.1/wp-admin/css/ms.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/ms.css	(revision 17487)
@@ -0,0 +1,1 @@
+#dashboard_right_now p.musub{margin-top:12px;border-top:1px solid #ececec;padding-left:16px;position:static;}#dashboard_right_now td.b a.musublink{font-size:16px;}#dashboard_right_now div.musubtable{border-top:none;}#dashboard_right_now div.musubtable .t{white-space:normal;}.site-deleted{background:#ff8573;}.site-spammed{background:#faafaa;}.site-archived{background:#ffebe8;}.site-mature{background:#fecac2;}
Index: /tags/3.1/wp-admin/css/ms.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/ms.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/ms.dev.css	(revision 17487)
@@ -0,0 +1,33 @@
+/* Dashboard: MS Specific Data */
+#dashboard_right_now p.musub {
+	margin-top: 12px;
+	border-top: 1px solid #ececec;
+	padding-left: 16px;
+	position: static;
+}
+
+#dashboard_right_now td.b a.musublink {
+	font-size: 16px;
+}
+
+#dashboard_right_now div.musubtable {
+	border-top: none;
+}
+
+#dashboard_right_now div.musubtable .t {
+	white-space: normal;
+}
+
+/* Background Color for Site Status */
+.site-deleted {
+	background: #ff8573;
+}
+.site-spammed {
+	background: #faafaa;
+}
+.site-archived {
+	background: #ffebe8;
+}
+.site-mature {
+	background: #fecac2;
+}
Index: /tags/3.1/wp-admin/css/nav-menu-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/nav-menu-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/nav-menu-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+#nav-menus-frame{margin-right:300px;margin-left:0;}#wpbody-content #menu-settings-column{margin-right:-300px;margin-left:0;float:right;}#menu-management-liquid{float:right;}#menu-management{margin-left:20px;margin-right:0;}#post-body{padding:0 10px 10px 0;}.post-body-plain{padding:10px 0 0 10px;}#menu-management .nav-tabs-arrow-left{right:0;left:auto;}#menu-management .nav-tabs-arrow-right{left:0;right:auto;text-align:left;}#menu-management .nav-tabs{padding-right:20px;padding-left:10px;}.js #menu-management .nav-tabs{float:right;margin-right:0;margin-left:-400px;}#select-nav-menu-container{text-align:left;}#wpbody .open-label{float:right;}#wpbody .open-label span{padding-left:10px;padding-right:0;}.js .input-with-default-title{font-style:normal;font-weight:bold;}.postbox .howto input{float:left;}#nav-menu-theme-locations .button-controls{text-align:left;}.meta-sep,.submitdelete,.submitcancel{float:right;}#cancel-save{margin-right:20px;margin-left:0;}.list-controls{float:right;}.add-to-menu{float:left;}#add-custom-link label span{float:right;padding-left:5px;padding-right:0;}.howto span{float:right;}.list li .menu-item-title input{margin-left:3px;margin-right:0;}.menu-item-handle{padding-right:10px;padding-left:0;}.menu-item-edit-active .menu-item-handle{-moz-border-radius:6px 6px 0 0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;-khtml-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:0;border-bottom-left-radius:0;border-bottom-right-radius:0;}.menu-item-handle .item-title{margin-left:13em;margin-right:0;}.menu-item-depth-0{margin-right:0;margin-left:0;}.menu-item-depth-1{margin-right:30px;margin-left:0;}.menu-item-depth-2{margin-right:60px;margin-left:0;}.menu-item-depth-3{margin-right:90px;margin-left:0;}.menu-item-depth-4{margin-right:120px;margin-left:0;}.menu-item-depth-5{margin-right:150px;margin-left:0;}.menu-item-depth-6{margin-right:180px;margin-left:0;}.menu-item-depth-7{margin-right:210px;margin-left:0;}.menu-item-depth-8{margin-right:240px;margin-left:0;}.menu-item-depth-9{margin-right:270px;margin-left:0;}.menu-item-depth-10{margin-right:300px;margin-left:0;}.menu-item-depth-11{margin-right:330px;margin-left:0;}.menu-item-depth-0 .menu-item-transport{margin-right:0;margin-left:0;}.menu-item-depth-1 .menu-item-transport{margin-right:-30px;margin-left:0;}.menu-item-depth-2 .menu-item-transport{margin-right:-60px;margin-left:0;}.menu-item-depth-3 .menu-item-transport{margin-right:-90px;margin-left:0;}.menu-item-depth-4 .menu-item-transport{margin-right:-120px;margin-left:0;}.menu-item-depth-5 .menu-item-transport{margin-right:-150px;margin-left:0;}.menu-item-depth-6 .menu-item-transport{margin-right:-180px;margin-left:0;}.menu-item-depth-7 .menu-item-transport{margin-right:-210px;margin-left:0;}.menu-item-depth-8 .menu-item-transport{margin-right:-240px;margin-left:0;}.menu-item-depth-9 .menu-item-transport{margin-right:-270px;margin-left:0;}.menu-item-depth-10 .menu-item-transport{margin-right:-300px;margin-left:0;}.menu-item-depth-11 .menu-item-transport{margin-right:-330px;margin-left:0;}.item-type{padding-left:10px;padding-right:0;}.item-controls{left:20px;right:auto;}.item-controls .item-order{padding-left:10px;padding-right:0;}.item-edit{background-image:url("../images/menu-bits-rtl.gif?ver=20100531");background-position:100% -105px;left:-20px;right:auto;-moz-border-radius-bottomright:3px;-moz-border-radius-bottomleft:0;-webkit-border-bottom-right-radius:3px;-webkit-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:3px;-khtml-border-bottom-left-radius:0;border-bottom-right-radius:3px;border-bottom-left-radius:0;}.menu-item-settings{padding:10px 10px 10px 0;border-width:0 1px 1px 1px;}.link-to-original{font-style:normal;font-weight:bold;}.link-to-original a{padding-right:4px;padding-left:0;}.menu-item-settings .description-thin,.menu-item-settings .description-wide{margin-left:10px;margin-right:0;float:right;}.major-publishing-actions .publishing-action{text-align:left;float:left;}.major-publishing-actions .delete-action{text-align:right;float:right;padding-left:15px;padding-right:0;}.menu-name-label{margin-left:15px;margin-right:0;}.auto-add-pages{float:right;}
Index: /tags/3.1/wp-admin/css/nav-menu-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/nav-menu-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/nav-menu-rtl.dev.css	(revision 17487)
@@ -0,0 +1,206 @@
+#nav-menus-frame {
+	margin-right: 300px;
+	margin-left: 0;
+}
+
+#wpbody-content #menu-settings-column {
+	margin-right: -300px;
+	margin-left: 0;
+	float: right;
+}
+
+/* Menu Container */
+#menu-management-liquid {
+	float: right;
+}
+#menu-management {
+	margin-left: 20px;
+	margin-right: 0;
+}
+
+
+	#post-body {
+		padding:0 10px 10px 0;
+	}
+
+	.post-body-plain {
+		padding: 10px 0 0 10px;
+	}
+
+/* Menu Tabs */
+
+	#menu-management .nav-tabs-arrow-left {
+		right: 0;
+		left:auto;
+	}
+	#menu-management .nav-tabs-arrow-right {
+		left: 0;
+		right:auto;
+		text-align: left;
+	}
+
+#menu-management .nav-tabs {
+	padding-right: 20px;
+	padding-left: 10px;
+}
+.js #menu-management .nav-tabs {
+	float: right;
+	margin-right: 0px;
+	margin-left: -400px;
+}
+
+#select-nav-menu-container {
+	text-align: left;
+}
+
+#wpbody .open-label {
+	float:right;
+}
+
+#wpbody .open-label span {
+	padding-left: 10px;
+	padding-right:0;
+}
+
+	.js .input-with-default-title {
+		font-style: normal;
+		font-weight:bold;
+	}
+
+/* Add Menu Item Boxes */
+.postbox .howto input {
+	float: left;
+}
+#nav-menu-theme-locations .button-controls {
+	text-align: left;
+}
+
+/* Button Primary Actions */
+
+.meta-sep,
+.submitdelete,
+.submitcancel {
+	float:right;
+}
+
+#cancel-save { margin-right: 20px; margin-left: 0; }
+
+/* Button Secondary Actions */
+.list-controls { float: right;  }
+.add-to-menu {
+	float: left;
+}
+
+/* Custom Links */
+#add-custom-link label span { float: right; padding-left: 5px; padding-right:0;}
+.howto span { float: right; }
+
+.list li .menu-item-title input { margin-left: 3px; margin-right: 0 }
+
+/* Nav Menu */
+.menu-item-handle {
+	padding-right: 10px;
+	padding-left: 0;
+}
+.menu-item-edit-active .menu-item-handle {
+	-moz-border-radius: 6px 6px 0 0;
+	-webkit-border-bottom-left-radius: 0;
+	-webkit-border-bottom-right-radius: 0;
+	-khtml-border-bottom-left-radius: 0;
+	-khtml-border-bottom-right-radius: 0;
+	border-bottom-left-radius: 0;
+	border-bottom-right-radius: 0;
+}
+.menu-item-handle .item-title {
+	margin-left:13em;
+	margin-right:0;
+}
+
+
+/* WARNING: The factor of 30px is hardcoded into the nav-menus javascript. */
+.menu-item-depth-0 { margin-right: 0px; margin-left:0;}
+.menu-item-depth-1 { margin-right: 30px; margin-left:0;}
+.menu-item-depth-2 { margin-right: 60px; margin-left:0;}
+.menu-item-depth-3 { margin-right: 90px; margin-left:0;}
+.menu-item-depth-4 { margin-right: 120px; margin-left:0;}
+.menu-item-depth-5 { margin-right: 150px; margin-left:0;}
+.menu-item-depth-6 { margin-right: 180px; margin-left:0;}
+.menu-item-depth-7 { margin-right: 210px; margin-left:0;}
+.menu-item-depth-8 { margin-right: 240px; margin-left:0;}
+.menu-item-depth-9 { margin-right: 270px; margin-left:0;}
+.menu-item-depth-10 { margin-right: 300px; margin-left:0;}
+.menu-item-depth-11 { margin-right: 330px; margin-left:0;}
+
+.menu-item-depth-0 .menu-item-transport { margin-right: 0px; margin-left:0;}
+.menu-item-depth-1 .menu-item-transport { margin-right: -30px; margin-left:0;}
+.menu-item-depth-2 .menu-item-transport { margin-right: -60px; margin-left:0;}
+.menu-item-depth-3 .menu-item-transport { margin-right: -90px; margin-left:0;}
+.menu-item-depth-4 .menu-item-transport { margin-right: -120px; margin-left:0;}
+.menu-item-depth-5 .menu-item-transport { margin-right: -150px; margin-left:0;}
+.menu-item-depth-6 .menu-item-transport { margin-right: -180px; margin-left:0;}
+.menu-item-depth-7 .menu-item-transport { margin-right: -210px; margin-left:0;}
+.menu-item-depth-8 .menu-item-transport { margin-right: -240px; margin-left:0;}
+.menu-item-depth-9 .menu-item-transport { margin-right: -270px; margin-left:0;}
+.menu-item-depth-10 .menu-item-transport { margin-right: -300px; margin-left:0;}
+.menu-item-depth-11 .menu-item-transport { margin-right: -330px; margin-left:0;}
+
+/* Menu item controls */
+.item-type { padding-left: 10px;  padding-right:0;}
+.item-controls { left: 20px; right: auto;}
+.item-controls .item-order { padding-left: 10px; padding-right: 0;}
+
+.item-edit {
+	background-image: url("../images/menu-bits-rtl.gif?ver=20100531");
+	background-position: 100% -105px;
+	left: -20px;
+	right:auto;
+	-moz-border-radius-bottomright: 3px;
+	-moz-border-radius-bottomleft: 0;
+	-webkit-border-bottom-right-radius: 3px;
+	-webkit-border-bottom-left-radius: 0;
+	-khtml-border-bottom-right-radius: 3px;
+	-khtml-border-bottom-left-radius: 0;
+	border-bottom-right-radius: 3px;
+	border-bottom-left-radius: 0;
+}
+
+/* Menu editing */
+.menu-item-settings {
+	padding: 10px 10px 10px 0;
+	border-width: 0 1px 1px 1px;
+}
+
+.link-to-original {
+	font-style: normal;
+	font-weight: bold;
+}
+	.link-to-original a {
+		padding-right: 4px;
+		padding-left:0;
+	}
+
+.menu-item-settings .description-thin,
+.menu-item-settings .description-wide {
+	margin-left: 10px;
+	margin-right:0;
+	float: right;
+}
+
+/* Major/minor publishing actions (classes) */
+.major-publishing-actions .publishing-action {
+	text-align: left;
+	float: left;
+}
+.major-publishing-actions .delete-action {
+	text-align: right;
+	float: right;
+	padding-left: 15px;
+	padding-right:0;
+}
+.menu-name-label {
+	margin-left: 15px;
+	margin-right:0;
+}
+.auto-add-pages {
+	float: right;
+}
Index: /tags/3.1/wp-admin/css/nav-menu.css
===================================================================
--- /tags/3.1/wp-admin/css/nav-menu.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/nav-menu.css	(revision 17487)
@@ -0,0 +1,1 @@
+html,body{min-width:950px;}#nav-menus-frame{margin-left:300px;}#wpbody-content #menu-settings-column{display:inline;width:281px;margin-left:-300px;clear:both;float:left;padding-top:24px;}.no-js #wpbody-content #menu-settings-column{padding-top:31px;}#menu-settings-column .inside{clear:both;padding:0 10px;}.metabox-holder-disabled .postbox{opacity:.5;filter:alpha(opacity=50);}.metabox-holder-disabled .button-controls .select-all{display:none;}#wpbody{position:relative;}#menu-management-liquid{float:left;min-width:100%;}#menu-management{position:relative;margin-right:20px;margin-top:-3px;width:100%;}#menu-management .menu-edit{margin-bottom:20px;}#nav-menu-header,#post-body,#nav-menu-footer{border-color:#ccc;border-style:solid;}#nav-menu-header{border-width:1px 1px 0 1px;-moz-border-radius-topleft:6px;-webkit-border-top-left-radius:6px;-khtml-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-topright:6px;-webkit-border-top-right-radius:6px;-khtml-border-top-right-radius:6px;border-top-right-radius:6px;}#post-body{background:#fff;padding:10px;border-width:0 1px;}#post-body div.updated{margin:0;}#post-body-content{position:relative;}#menu-management .menu-add-new abbr{font-weight:bold;}#nav-menu-footer{border-width:0 1px 1px 1px;-moz-border-radius-bottomleft:6px;-webkit-border-bottom-left-radius:6px;-khtml-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-moz-border-radius-bottomright:6px;-webkit-border-bottom-right-radius:6px;-khtml-border-bottom-right-radius:6px;border-bottom-right-radius:6px;}#menu-management .nav-tabs-nav{margin:0 20px;}#menu-management .nav-tabs-arrow{width:10px;padding:0 5px 4px;cursor:pointer;position:absolute;top:0;line-height:22px;font-size:18px;text-shadow:0 1px 0 #fff;}#menu-management .nav-tabs-arrow a{color:#C1C1C1;}#menu-management .nav-tabs-arrow a:hover{color:#D54E21;}#menu-management .nav-tabs-arrow a:active{color:#464646;}#menu-management .nav-tabs-arrow-left{left:0;}#menu-management .nav-tabs-arrow-right{right:0;text-align:right;}#menu-management .nav-tabs-wrapper{width:100%;height:28px;margin-bottom:-1px;overflow:hidden;}#menu-management .nav-tabs{padding-left:20px;padding-right:10px;}.js #menu-management .nav-tabs{float:left;margin-left:0;margin-right:-400px;}#menu-management .nav-tab{margin-bottom:0;background:#f4f4f4;font-weight:bold;border-color:#dfdfdf;}#menu-management .nav-tab-active{border-color:#ccc;}#select-nav-menu-container{text-align:right;padding:0 10px 3px 10px;margin-bottom:5px;}#select-nav-menu{width:100px;display:inline;}#menu-name-label{margin-top:-2px;}#wpbody .open-label{display:block;float:left;}#wpbody .open-label span{padding-right:10px;}.js .input-with-default-title{color:#aaa;font-style:italic;}#menu-management .inside{padding:0 10px;}.postbox .howto input{width:180px;float:right;}.customlinkdiv .howto input{width:210px;}#nav-menu-theme-locations .howto select{width:100%;}#nav-menu-theme-locations .button-controls{text-align:right;}.add-menu-item-view-all{height:400px;}#menu-container .submit{margin:0 0 10px;padding:0;}.meta-sep,.submitdelete,.submitcancel{display:block;float:left;font-size:11px;margin:4px 0;line-height:15px;}.meta-sep{padding:0 2px;}#cancel-save{color:#f00;text-decoration:underline;font-size:11px;margin-left:20px;margin-top:5px;}#cancel-save:hover{background-color:#F00;color:#fff;}.list-controls{float:left;margin-top:5px;}.add-to-menu{float:right;}.postbox img.waiting{display:none;vertical-align:middle;}.button-controls{clear:both;margin:10px 0;}.show-all,.hide-all{cursor:pointer;}.hide-all{display:none;}#menu-name{width:270px;}#manage-menu .inside{padding:0;}#available-links dt{display:block;}#add-custom-link .howto{font-size:11px;}#add-custom-link label span{display:block;float:left;margin-top:5px;padding-right:5px;}.menu-item-textbox{width:180px;}.howto span{margin-top:4px;display:block;float:left;}.quick-search{width:190px;}.list-wrap{display:none;clear:both;margin-bottom:10px;}.list-container{max-height:200px;overflow-y:auto;padding:10px 10px 5px;border:1px solid #DFDFDF;-moz-border-radius:4px;}.postbox p.submit{margin-bottom:0;}.list li{display:none;margin:0;margin-bottom:5px;}.list li .menu-item-title{cursor:pointer;display:block;}.list li .menu-item-title input{margin-right:3px;margin-top:-3px;}#menu-container .inside{padding-bottom:10px;}.menu{padding-top:1em;}#menu-to-edit{padding:1em 0;}.menu ul{width:100%;}.menu li{margin-bottom:0;position:relative;}.menu-item-bar{clear:both;line-height:1.5em;position:relative;margin-top:13px;}.menu-item-handle{border:1px solid #E6E6E6;position:relative;padding-left:10px;height:auto;width:400px;line-height:35px;text-shadow:0 1px 0 #FFF;font-weight:bold;overflow:hidden;border-radius:6px;-webkit-border-radius:6px;-moz-border-radius:6px;-khtml-border-radius:6px;word-wrap:break-word;}.menu-item-edit-active .menu-item-handle{-moz-border-radius:6px 6px 0 0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:0;-khtml-border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;}.no-js .menu-item-edit-active .item-edit{display:none;}.js .menu-item-handle{cursor:move;}.menu li.deleting .menu-item-handle{background-color:#f66;background-image:none;text-shadow:0 0 0 #ccc;}.menu-item-handle .item-title{padding:7px 0;line-height:20px;display:block;margin-right:13em;}li.menu-item.ui-sortable-helper dl{margin-top:0;}li.menu-item.ui-sortable-helper .menu-item-transport dl{margin-top:13px;}.menu .sortable-placeholder{height:35px;width:410px;margin-top:13px;}.menu-item-depth-0{margin-left:0;}.menu-item-depth-1{margin-left:30px;}.menu-item-depth-2{margin-left:60px;}.menu-item-depth-3{margin-left:90px;}.menu-item-depth-4{margin-left:120px;}.menu-item-depth-5{margin-left:150px;}.menu-item-depth-6{margin-left:180px;}.menu-item-depth-7{margin-left:210px;}.menu-item-depth-8{margin-left:240px;}.menu-item-depth-9{margin-left:270px;}.menu-item-depth-10{margin-left:300px;}.menu-item-depth-11{margin-left:330px;}.menu-item-depth-0 .menu-item-transport{margin-left:0;}.menu-item-depth-1 .menu-item-transport{margin-left:-30px;}.menu-item-depth-2 .menu-item-transport{margin-left:-60px;}.menu-item-depth-3 .menu-item-transport{margin-left:-90px;}.menu-item-depth-4 .menu-item-transport{margin-left:-120px;}.menu-item-depth-5 .menu-item-transport{margin-left:-150px;}.menu-item-depth-6 .menu-item-transport{margin-left:-180px;}.menu-item-depth-7 .menu-item-transport{margin-left:-210px;}.menu-item-depth-8 .menu-item-transport{margin-left:-240px;}.menu-item-depth-9 .menu-item-transport{margin-left:-270px;}.menu-item-depth-10 .menu-item-transport{margin-left:-300px;}.menu-item-depth-11 .menu-item-transport{margin-left:-330px;}body.menu-max-depth-0{min-width:950px!important;}body.menu-max-depth-1{min-width:980px!important;}body.menu-max-depth-2{min-width:1010px!important;}body.menu-max-depth-3{min-width:1040px!important;}body.menu-max-depth-4{min-width:1070px!important;}body.menu-max-depth-5{min-width:1100px!important;}body.menu-max-depth-6{min-width:1130px!important;}body.menu-max-depth-7{min-width:1160px!important;}body.menu-max-depth-8{min-width:1190px!important;}body.menu-max-depth-9{min-width:1220px!important;}body.menu-max-depth-10{min-width:1250px!important;}body.menu-max-depth-11{min-width:1280px!important;}.item-type{text-transform:uppercase;font-size:11px;color:#999;padding-right:10px;}.item-controls{font-size:11px;position:absolute;right:20px;top:-1px;}.item-controls a{text-decoration:none;}.item-controls a:hover{cursor:pointer;}.item-controls .item-order{padding-right:10px;}.item-controls .item-order a{font-weight:bold;}body.js .item-order{display:none;}.item-controls .menu-item-delete:hover{color:#f00;}.item-edit{background:url("../images/menu-bits.gif?ver=20100610") no-repeat scroll 0 -105px;position:absolute;right:-20px;top:0;display:block;width:23px;height:36px;overflow:hidden;text-indent:-999em;border-bottom:1px solid #eee;-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}.menu-instructions-inactive{display:none;}.menu-item-settings{background:#F9F9F9;display:block;width:400px;padding:10px 0 10px 10px;border:solid #E6E6E6;border-width:0 1px 1px 1px;-moz-border-radius:0 0 6px 6px;-webkit-border-bottom-right-radius:6px;-webkit-border-bottom-left-radius:6px;-khtml-border-bottom-right-radius:6px;-khtml-border-bottom-left-radius:6px;}.menu-item-edit-active .menu-item-settings{display:block;}.menu-item-edit-inactive .menu-item-settings{display:none;}.add-menu-item-pagelinks{margin:.5em auto;text-align:center;}.link-to-original{display:block;margin:0 0 10px;padding:3px 5px 5px;font-size:11px;color:#777;font-style:italic;border:1px solid #dfdfdf;border-radius:6px;-webkit-border-radius:6px;-moz-border-radius:6px;-khtml-border-radius:6px;}.link-to-original a{padding-left:4px;font-style:normal;}.hidden-field{display:none;}.menu-item-settings .description-thin,.menu-item-settings .description-wide{margin-right:10px;float:left;}.description-thin{width:190px;height:40px;}.description-wide{width:390px;}.menu-item-actions{padding-top:15px;}#cancel-save{cursor:pointer;}#cancel-save:hover{color:#fff!important;}#update-menu-item{color:#fff!important;}#update-menu-item:hover,#update-menu-item:active,#update-menu-item:focus{color:#eaf2fa!important;border-color:#13455b!important;}.major-publishing-actions{clear:both;padding:5px 10px;}.major-publishing-actions .publishing-action{text-align:right;float:right;line-height:23px;margin:5px 0 1px;}.major-publishing-actions .delete-action{vertical-align:middle;text-align:left;float:left;padding-right:15px;margin-top:5px;}.menu-name-label span,.auto-add-pages label{font-size:11px;font-style:normal;}.menu-name-label{margin-right:15px;}.auto-add-pages input{margin-top:0;}.auto-add-pages{margin-top:4px;float:left;}.submitbox .submitcancel{color:#21759B;border-bottom:1px solid #21759B;padding:1px 2px;text-decoration:none;}.submitbox .submitcancel:hover{background:#21759B;color:#fff;}.major-publishing-actions .form-invalid{border-radius:4px;-webkit-border-radius:4px;-moz-border-radius:4px;-khtml-border-radius:4px;padding-left:4px;margin-left:-4px;}#menu-item-name-wrap:after,#menu-item-url-wrap:after,#menu-name-label:after,#menu-settings-column .inside:after,#nav-menus-frame:after,#post-body-content:after,.button-controls:after,.major-publishing-actions:after,.menu-item-settings:after{clear:both;content:".";display:block;height:0;visibility:hidden;}#nav-menus-frame,.button-controls,#menu-item-url-wrap,#menu-item-name-wrap{display:block;}
Index: /tags/3.1/wp-admin/css/nav-menu.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/nav-menu.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/nav-menu.dev.css	(revision 17487)
@@ -0,0 +1,574 @@
+/**
+ * WordPress Administration Custom Navigation
+ * Interface CSS
+ *
+ * @version 2.0.0
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+html,
+body {
+	min-width: 950px;
+}
+
+#nav-menus-frame {
+	margin-left: 300px;
+}
+
+#wpbody-content #menu-settings-column {
+	display:inline;
+	width:281px;
+	margin-left: -300px;
+	clear: both;
+	float: left;
+	padding-top: 24px;
+}
+	.no-js #wpbody-content #menu-settings-column {
+		padding-top: 31px;
+	}
+
+#menu-settings-column .inside {
+	clear: both;
+	padding:0 10px;
+}
+
+.metabox-holder-disabled .postbox {
+	opacity: 0.5;
+	filter: alpha(opacity=50);
+}
+
+.metabox-holder-disabled .button-controls .select-all {
+	display: none;
+}
+#wpbody {
+	position: relative;
+}
+
+/* Menu Container */
+#menu-management-liquid {
+	float: left;
+	min-width: 100%;
+}
+#menu-management {
+	position: relative;
+	margin-right: 20px;
+	margin-top: -3px;
+	width: 100%;
+}
+	#menu-management .menu-edit {
+		margin-bottom: 20px;
+	}
+
+	#nav-menu-header, #post-body, #nav-menu-footer {
+		border-color: #ccc;
+		border-style: solid;
+	}
+
+	#nav-menu-header {
+		border-width: 1px 1px 0 1px;
+		-moz-border-radius-topleft: 6px;
+		-webkit-border-top-left-radius: 6px;
+		-khtml-border-top-left-radius: 6px;
+		border-top-left-radius: 6px;
+		-moz-border-radius-topright: 6px;
+		-webkit-border-top-right-radius: 6px;
+		-khtml-border-top-right-radius: 6px;
+		border-top-right-radius: 6px;
+	}
+
+	#post-body {
+		background: #fff;
+		padding: 10px;
+		border-width: 0 1px;
+	}
+
+	#post-body div.updated {
+		margin: 0;
+	}
+
+	#post-body-content {
+		position: relative;
+	}
+
+	#menu-management .menu-add-new abbr {
+		font-weight:bold;
+	}
+
+#nav-menu-footer {
+	border-width: 0 1px 1px 1px;
+	-moz-border-radius-bottomleft: 6px;
+	-webkit-border-bottom-left-radius: 6px;
+	-khtml-border-bottom-left-radius: 6px;
+	border-bottom-left-radius: 6px;
+	-moz-border-radius-bottomright: 6px;
+	-webkit-border-bottom-right-radius: 6px;
+	-khtml-border-bottom-right-radius: 6px;
+	border-bottom-right-radius: 6px;
+}
+
+/* Menu Tabs */
+
+#menu-management .nav-tabs-nav {
+	margin: 0 20px;
+}
+
+#menu-management .nav-tabs-arrow {
+	width: 10px;
+	padding: 0 5px 4px;
+	cursor: pointer;
+	position: absolute;
+	top: 0;
+	line-height: 22px;
+	font-size: 18px;
+	text-shadow: 0 1px 0 #fff;
+}
+	#menu-management .nav-tabs-arrow a { color: #C1C1C1; }
+	#menu-management .nav-tabs-arrow a:hover { color: #D54E21; }
+	#menu-management .nav-tabs-arrow a:active { color: #464646; }
+	#menu-management .nav-tabs-arrow-left {
+		left: 0;
+	}
+	#menu-management .nav-tabs-arrow-right {
+		right: 0;
+		text-align: right;
+	}
+
+
+#menu-management .nav-tabs-wrapper {
+	width: 100%;
+	height: 28px;
+	margin-bottom: -1px;
+	overflow: hidden;
+}
+
+#menu-management .nav-tabs {
+	padding-left: 20px;
+	padding-right: 10px;
+}
+.js #menu-management .nav-tabs {
+	float: left;
+	margin-left: 0px;
+	margin-right: -400px;
+}
+
+#menu-management .nav-tab {
+	margin-bottom: 0;
+	background: #f4f4f4;
+	font-weight: bold;
+	border-color: #dfdfdf;
+}
+
+#menu-management .nav-tab-active {
+	border-color:#ccc;
+}
+
+#select-nav-menu-container {
+	text-align: right;
+	padding: 0 10px 3px 10px;
+	margin-bottom: 5px;
+}
+	#select-nav-menu {
+		width: 100px;
+		display: inline;
+	}
+
+#menu-name-label {
+	margin-top: -2px;
+}
+
+#wpbody .open-label {
+	display: block;
+	float:left;
+}
+#wpbody .open-label span {
+	padding-right: 10px;
+}
+
+	.js .input-with-default-title {
+		color: #aaa;
+		font-style: italic;
+	}
+
+#menu-management .inside { padding: 0 10px; }
+
+/* Add Menu Item Boxes */
+.postbox .howto input {
+	width: 180px;
+	float: right;
+}
+.customlinkdiv .howto input {
+	width: 210px;
+}
+#nav-menu-theme-locations .howto select {
+	width: 100%;
+}
+#nav-menu-theme-locations .button-controls {
+	text-align: right;
+}
+.add-menu-item-view-all {
+	height: 400px;
+}
+
+/* Button Primary Actions */
+#menu-container .submit { margin: 0px 0px 10px; padding: 0px; }
+
+.meta-sep,
+.submitdelete,
+.submitcancel {
+	display:block;
+	float:left;
+	font-size: 11px;
+	margin: 4px 0;
+	line-height: 15px;
+}
+.meta-sep {
+	padding: 0 2px;
+}
+
+#cancel-save { color: #ff0000; text-decoration: underline; font-size: 11px; margin-left: 20px; margin-top: 5px; }
+#cancel-save:hover { background-color: #FF0000; color: #fff; }
+
+/* Button Secondary Actions */
+.list-controls { float: left; margin-top: 5px; }
+.add-to-menu {
+	float: right;
+}
+
+.postbox img.waiting {
+	display: none;
+	vertical-align: middle;
+}
+
+.button-controls {
+	clear:both;
+	margin: 10px 0;
+}
+.show-all, .hide-all { cursor: pointer; }
+.hide-all { display: none; }
+
+/* Create Menu */
+#menu-name { width: 270px; }
+#manage-menu .inside { padding: 0px 0px; }
+
+/* Custom Links */
+#available-links dt { display: block; }
+#add-custom-link .howto { font-size: 11px; }
+#add-custom-link label span { display: block; float: left; margin-top: 5px; padding-right: 5px; }
+.menu-item-textbox { width: 180px; }
+.howto span { margin-top: 4px; display: block; float: left; }
+
+/* Menu item types */
+.quick-search { width: 190px; }
+.list-wrap { display: none; clear: both; margin-bottom: 10px; }
+.list-container { max-height: 200px; overflow-y: auto; padding: 10px 10px 5px; border: 1px solid #DFDFDF; -moz-border-radius: 4px; }
+.postbox p.submit { margin-bottom: 0; }
+
+/* Listings */
+.list li { display: none; margin: 0; margin-bottom: 5px; }
+
+.list li .menu-item-title { cursor: pointer; display: block; }
+.list li .menu-item-title input { margin-right: 3px; margin-top: -3px; }
+
+/* Nav Menu */
+#menu-container .inside { padding-bottom: 10px; }
+
+.menu {
+	padding-top:1em;
+}
+
+#menu-to-edit {
+	padding: 1em 0;
+}
+
+.menu ul {
+	width: 100%;
+}
+.menu ul.sub-menu {
+}
+.menu li {
+	margin-bottom: 0;
+	position:relative;
+}
+.menu-item-bar {
+	clear:both;
+	line-height:1.5em;
+	position:relative;
+	margin-top: 13px;
+}
+.menu-item-handle {
+	border: 1px solid #E6E6E6;
+	position: relative;
+	padding-left: 10px;
+	height: auto;
+	width: 400px;
+	line-height: 35px;
+	text-shadow: 0 1px 0 #FFFFFF;
+	font-weight:bold;
+	overflow: hidden;
+	border-radius: 6px;
+	-webkit-border-radius: 6px;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	word-wrap: break-word;
+}
+.menu-item-edit-active .menu-item-handle {
+	-moz-border-radius: 6px 6px 0 0;
+	-webkit-border-bottom-right-radius: 0;
+	-webkit-border-bottom-left-radius: 0;
+	-khtml-border-bottom-right-radius: 0;
+	-khtml-border-bottom-left-radius: 0;
+	border-bottom-right-radius: 0;
+	border-bottom-left-radius: 0;
+}
+.no-js .menu-item-edit-active .item-edit {
+	display: none;
+}
+.js .menu-item-handle {
+	cursor: move;
+}
+.menu li.deleting .menu-item-handle {
+	background-color: #f66;
+	background-image: none;
+	text-shadow: 0 0 0 #ccc;
+}
+
+.menu-item-handle .item-title {
+	padding: 7px 0;
+	line-height: 20px;
+	display:block;
+	margin-right:13em;
+}
+
+/* Sortables */
+li.menu-item.ui-sortable-helper dl {
+	margin-top: 0;
+}
+	li.menu-item.ui-sortable-helper .menu-item-transport dl {
+		margin-top: 13px;
+	}
+.menu .sortable-placeholder {
+	height: 35px;
+	width: 410px;
+	margin-top: 13px;
+}
+
+/* WARNING: The factor of 30px is hardcoded into the nav-menus javascript. */
+.menu-item-depth-0 { margin-left: 0px; }
+.menu-item-depth-1 { margin-left: 30px; }
+.menu-item-depth-2 { margin-left: 60px; }
+.menu-item-depth-3 { margin-left: 90px; }
+.menu-item-depth-4 { margin-left: 120px; }
+.menu-item-depth-5 { margin-left: 150px; }
+.menu-item-depth-6 { margin-left: 180px; }
+.menu-item-depth-7 { margin-left: 210px; }
+.menu-item-depth-8 { margin-left: 240px; }
+.menu-item-depth-9 { margin-left: 270px; }
+.menu-item-depth-10 { margin-left: 300px; }
+.menu-item-depth-11 { margin-left: 330px; }
+
+.menu-item-depth-0 .menu-item-transport { margin-left: 0px; }
+.menu-item-depth-1 .menu-item-transport { margin-left: -30px; }
+.menu-item-depth-2 .menu-item-transport { margin-left: -60px; }
+.menu-item-depth-3 .menu-item-transport { margin-left: -90px; }
+.menu-item-depth-4 .menu-item-transport { margin-left: -120px; }
+.menu-item-depth-5 .menu-item-transport { margin-left: -150px; }
+.menu-item-depth-6 .menu-item-transport { margin-left: -180px; }
+.menu-item-depth-7 .menu-item-transport { margin-left: -210px; }
+.menu-item-depth-8 .menu-item-transport { margin-left: -240px; }
+.menu-item-depth-9 .menu-item-transport { margin-left: -270px; }
+.menu-item-depth-10 .menu-item-transport { margin-left: -300px; }
+.menu-item-depth-11 .menu-item-transport { margin-left: -330px; }
+
+body.menu-max-depth-0 { min-width: 950px !important; }
+body.menu-max-depth-1 { min-width: 980px !important; }
+body.menu-max-depth-2 { min-width: 1010px !important; }
+body.menu-max-depth-3 { min-width: 1040px !important; }
+body.menu-max-depth-4 { min-width: 1070px !important; }
+body.menu-max-depth-5 { min-width: 1100px !important; }
+body.menu-max-depth-6 { min-width: 1130px !important; }
+body.menu-max-depth-7 { min-width: 1160px !important; }
+body.menu-max-depth-8 { min-width: 1190px !important; }
+body.menu-max-depth-9 { min-width: 1220px !important; }
+body.menu-max-depth-10 { min-width: 1250px !important; }
+body.menu-max-depth-11 { min-width: 1280px !important; }
+
+/* Menu item controls */
+.item-type { text-transform: uppercase; font-size: 11px; color: #999999; padding-right: 10px; }
+.item-controls { font-size: 11px; position: absolute; right: 20px; top: -1px; }
+.item-controls a { text-decoration: none; }
+.item-controls a:hover { cursor: pointer; }
+.item-controls .item-order { padding-right: 10px;}
+.item-controls .item-order a {
+	font-weight:bold;
+}
+
+body.js .item-order {
+	display:none;
+}
+
+.item-controls .menu-item-delete:hover { color: #ff0000; }
+
+.item-edit {
+	background: url("../images/menu-bits.gif?ver=20100610") no-repeat scroll 0 -105px;
+	position: absolute;
+	right: -20px;
+	top: 0;
+	display: block;
+	width: 23px;
+	height: 36px;
+	overflow: hidden;
+	text-indent:-999em;
+	border-bottom: 1px solid #eee;
+	-moz-border-radius-bottomleft: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	border-bottom-left-radius: 3px;
+}
+
+/* Menu editing */
+.menu-instructions-inactive {
+	display: none;
+}
+.menu-item-settings {
+	background: #F9F9F9;
+	display:block;
+	width: 400px;
+	padding: 10px 0 10px 10px;
+	border: solid #E6E6E6;
+	border-width: 0 1px 1px 1px;
+	-moz-border-radius: 0 0 6px 6px;
+	-webkit-border-bottom-right-radius: 6px;
+	-webkit-border-bottom-left-radius: 6px;
+	-khtml-border-bottom-right-radius: 6px;
+	-khtml-border-bottom-left-radius: 6px;
+}
+.menu-item-edit-active .menu-item-settings {
+	display:block;
+}
+
+.menu-item-edit-inactive .menu-item-settings {
+	display:none;
+}
+
+.add-menu-item-pagelinks {
+	margin:.5em auto;
+	text-align:center;
+}
+
+.link-to-original {
+	display: block;
+	margin: 0 0 10px;
+	padding: 3px 5px 5px;
+	font-size: 11px;
+	color: #777;
+	font-style: italic;
+	border: 1px solid #dfdfdf;
+	border-radius: 6px;
+	-webkit-border-radius: 6px;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+}
+	.link-to-original a {
+		padding-left: 4px;
+		font-style: normal;
+	}
+
+.hidden-field {
+	display: none;
+}
+
+.menu-item-settings .description-thin,
+.menu-item-settings .description-wide {
+	margin-right: 10px;
+	float: left;
+}
+.description-thin {
+	width: 190px;
+	height: 40px;
+}
+.description-wide {
+	width: 390px;
+}
+
+.menu-item-actions {
+	padding-top: 15px;
+}
+
+#cancel-save { cursor: pointer; }
+#cancel-save:hover { color: #fff !important; }
+#update-menu-item { color: #fff !important; }
+#update-menu-item:hover,
+#update-menu-item:active,
+#update-menu-item:focus { color: #eaf2fa !important; border-color: #13455b !important; }
+
+/* Major/minor publishing actions (classes) */
+.major-publishing-actions {
+	clear:both;
+	padding: 5px 10px;
+}
+.major-publishing-actions .publishing-action {
+	text-align: right;
+	float: right;
+	line-height: 23px;
+	margin: 5px 0 1px;
+}
+.major-publishing-actions .delete-action {
+	vertical-align: middle;
+	text-align: left;
+	float: left;
+	padding-right: 15px;
+	margin-top: 5px;
+}
+.menu-name-label span, .auto-add-pages label {
+	font-size: 11px;
+	font-style: normal;
+}
+.menu-name-label {
+	margin-right: 15px;
+}
+.auto-add-pages input {
+	margin-top: 0;
+}
+.auto-add-pages {
+	margin-top: 4px;
+	float: left;
+}
+.submitbox .submitcancel {
+	color: #21759B;
+	border-bottom: 1px solid #21759B;
+	padding: 1px 2px;
+	text-decoration: none;
+}
+.submitbox .submitcancel:hover {
+	background: #21759B;
+	color: #fff;
+}
+
+.major-publishing-actions .form-invalid {
+	border-radius: 4px;
+	-webkit-border-radius: 4px;
+	-moz-border-radius: 4px;
+	-khtml-border-radius: 4px;
+	padding-left: 4px;
+	margin-left: -4px;
+}
+
+/* Clearfix */
+#menu-item-name-wrap:after,
+#menu-item-url-wrap:after,
+#menu-name-label:after,
+#menu-settings-column .inside:after,
+#nav-menus-frame:after,
+#post-body-content:after,
+.button-controls:after,
+.major-publishing-actions:after,
+.menu-item-settings:after {
+	clear: both;
+	content: ".";
+	display: block;
+	height: 0;
+	visibility: hidden;
+}
+#nav-menus-frame, .button-controls, #menu-item-url-wrap, #menu-item-name-wrap { display: block; }
Index: /tags/3.1/wp-admin/css/plugin-install-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/plugin-install-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/plugin-install-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+div.star{left:auto;right:0;letter-spacing:0;}.star img,div.star a,div.star a:hover,div.star a:visited{right:auto;left:0;}#plugin-information ul#sidemenu{left:auto;right:0;}#plugin-information h2{margin-right:0;margin-left:200px;}#plugin-information .fyi{margin-left:5px;margin-right:20px;}#plugin-information .fyi h2{margin-left:0;}#plugin-information .fyi ul{padding:10px 7px 10px 5px;}#plugin-information #section-screenshots li p{padding-left:0;padding-right:20px;}#plugin-information .updated,#plugin-information pre{margin-right:0;margin-left:215px;}#plugin-information .updated,#plugin-information .error{clear:none;direction:rtl;}#section-description{direction:ltr;}
Index: /tags/3.1/wp-admin/css/plugin-install-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/plugin-install-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/plugin-install-rtl.dev.css	(revision 17487)
@@ -0,0 +1,43 @@
+div.star {
+	left: auto;
+	right: 0;
+	letter-spacing: 0;
+}
+.star img, div.star a, div.star a:hover, div.star a:visited {
+	right: auto;
+	left: 0;
+}
+#plugin-information ul#sidemenu {
+	left: auto;
+	right: 0;
+}
+#plugin-information h2 {
+	margin-right: 0;
+	margin-left: 200px;
+}
+#plugin-information .fyi {
+	margin-left: 5px;
+	margin-right: 20px;
+}
+#plugin-information .fyi h2 {
+	margin-left: 0;
+}
+#plugin-information .fyi ul {
+	padding: 10px 7px 10px 5px;
+}
+#plugin-information #section-screenshots li p {
+	padding-left: 0;
+	padding-right: 20px;
+}
+#plugin-information .updated,
+#plugin-information pre {
+	margin-right: 0;
+	margin-left: 215px;
+}
+#plugin-information .updated, #plugin-information .error {
+	clear: none;
+	direction: rtl;
+}
+#section-description {
+	direction: ltr;
+}
Index: /tags/3.1/wp-admin/css/plugin-install.css
===================================================================
--- /tags/3.1/wp-admin/css/plugin-install.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/plugin-install.css	(revision 17487)
@@ -0,0 +1,1 @@
+div.star-holder{position:relative;height:19px;width:100px;font-size:19px;}div.action-links{font-weight:normal;margin:6px 0 0;}div.star{height:100%;position:absolute;top:0;left:0;background-color:transparent;letter-spacing:1ex;border:none;}.star1{width:20%;}.star2{width:40%;}.star3{width:60%;}.star4{width:80%;}.star5{width:100%;}.star img,div.star a,div.star a:hover,div.star a:visited{display:block;position:absolute;right:0;border:none;text-decoration:none;}div.star img{width:19px;height:19px;border-left:1px solid #fff;border-right:1px solid #fff;}#plugin-information-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}#plugin-information ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}#plugin-information p.action-button{width:100%;padding-bottom:0;margin-bottom:0;margin-top:10px;-moz-border-radius:3px 0 0 3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}#plugin-information .action-button a{text-align:center;font-weight:bold;text-decoration:none;display:block;line-height:2em;}#plugin-information h2{clear:none!important;margin-right:200px;}#plugin-information .fyi{margin:0 10px 50px;width:210px;}#plugin-information .fyi h2{font-size:.9em;margin-bottom:0;margin-right:0;}#plugin-information .fyi h2.mainheader{padding:5px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;}#plugin-information .fyi ul{padding:10px 5px 10px 7px;margin:0;list-style:none;-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px;}#plugin-information .fyi li{margin-right:0;}#plugin-information #section-holder{padding:10px;}#plugin-information .section ul,#plugin-information .section ol{margin-left:16px;list-style-type:square;list-style-image:none;}#plugin-information #section-screenshots li img{vertical-align:text-top;}#plugin-information #section-screenshots li p{font-style:italic;padding-left:20px;padding-bottom:2em;}#plugin-information .updated,#plugin-information pre{margin-right:215px;}#plugin-information pre{padding:7px;}
Index: /tags/3.1/wp-admin/css/plugin-install.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/plugin-install.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/plugin-install.dev.css	(revision 17487)
@@ -0,0 +1,152 @@
+/* NOTE: the following CSS rules(.star*) are taken more or less straight from the bbPress rating plugin. */
+div.star-holder {
+	position: relative;
+	height: 19px;
+	width: 100px;
+	font-size: 19px;
+}
+
+div.action-links {
+	font-weight: normal;
+	margin: 6px 0 0;
+}
+
+div.star {
+	height: 100%;
+	position: absolute;
+	top: 0;
+	left: 0;
+	background-color: transparent;
+	letter-spacing: 1ex;
+	border: none;
+}
+
+.star1 { width: 20%; }
+.star2 { width: 40%; }
+.star3 { width: 60%; }
+.star4 { width: 80%; }
+.star5 { width: 100%; }
+
+.star img, div.star a, div.star a:hover, div.star a:visited {
+	display: block;
+	position: absolute;
+	right: 0;
+	border: none;
+	text-decoration: none;
+}
+
+div.star img {
+	width: 19px;
+	height: 19px;
+	border-left: 1px solid #fff;
+	border-right: 1px solid #fff;
+}
+
+/* Header on thickbox */
+#plugin-information-header {
+	margin: 0;
+	padding: 0 5px;
+	font-weight: bold;
+	position: relative;
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+	height: 2.5em;
+}
+#plugin-information ul#sidemenu {
+	font-weight: normal;
+	margin: 0 5px;
+	position: absolute;
+	left: 0;
+	bottom: -1px;
+}
+
+/* Install sidemenu */
+#plugin-information p.action-button {
+	width: 100%;
+	padding-bottom: 0;
+	margin-bottom: 0;
+	margin-top: 10px;
+	-moz-border-radius: 3px 0 0 3px;
+	-webkit-border-top-left-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	border-top-left-radius: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	border-bottom-left-radius: 3px;
+}
+
+#plugin-information .action-button a {
+	text-align: center;
+	font-weight: bold;
+	text-decoration: none;
+	display: block;
+	line-height: 2em;
+}
+
+#plugin-information h2 {
+	clear: none !important;
+	margin-right: 200px;
+}
+
+#plugin-information .fyi {
+	margin: 0 10px 50px;
+	width: 210px;
+}
+
+#plugin-information .fyi h2 {
+	font-size: 0.9em;
+	margin-bottom: 0;
+	margin-right: 0;
+}
+
+#plugin-information .fyi h2.mainheader {
+	padding: 5px;
+	-moz-border-radius-topleft: 3px;
+	-webkit-border-top-left-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	border-top-left-radius: 3px;
+}
+
+#plugin-information .fyi ul {
+	padding: 10px 5px 10px 7px;
+	margin: 0;
+	list-style: none;
+	-moz-border-radius-bottomleft: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	border-bottom-left-radius: 3px;
+}
+
+#plugin-information .fyi li {
+	margin-right: 0;
+}
+
+#plugin-information #section-holder {
+	padding: 10px;
+}
+
+#plugin-information .section ul,
+#plugin-information .section ol {
+	margin-left: 16px;
+	list-style-type: square;
+	list-style-image: none;
+}
+
+#plugin-information #section-screenshots li img {
+	vertical-align: text-top;
+}
+
+#plugin-information #section-screenshots li p {
+	font-style: italic;
+	padding-left: 20px;
+	padding-bottom: 2em;
+}
+
+#plugin-information .updated,
+#plugin-information pre {
+	margin-right: 215px;
+}
+
+#plugin-information pre {
+	padding: 7px;
+}
Index: /tags/3.1/wp-admin/css/press-this-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/press-this-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/press-this-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+body{font-family:Tahoma,Arial;}#poststuff #edButtonPreview,#poststuff #edButtonHTML{margin:0 0 0 5px;float:right;}div#poststuff{padding-left:0;padding-right:10px;}.posting{margin-right:0;margin-left:228px;left:auto;right:0;}#side-info-column{float:left;right:auto;left:0;margin-right:0;margin-left:10px;}#side-info-column .sleeve{padding-left:0;padding-right:10px;}h3.tb{margin-left:0;margin-right:5px;}#actions{float:left;}#extra_fields #actions{right:auto;left:4px;}#actions li{float:right;margin-right:0;margin-left:10px;}#extra_fields .button{margin-right:0;margin-left:5px;}#img_container a{float:right;}#category-add input,#category-add select{font-family:Tahoma,Arial;}.inline-editor ul.cat-checklist ul,.categorydiv ul.categorychecklist ul,#linkcategorydiv ul.categorychecklist ul{margin-left:0;margin-right:18px;}#tagsdiv #newtag{margin-right:0;margin-left:5px;}#tagadd{margin-left:0;margin-right:3px;}#tagchecklist span{margin-left:.5em;margin-right:10px;float:right;}#tagchecklist span a{margin:6px -9px 0 0;float:right;}#content{margin-left:0;margin-right:1%;}.submit input,.button,.button-primary,.button-secondary,.button-highlighted,#postcustomstuff .submit input{font-family:Tahoma,Arial,sans-serif;}.ac_results li{text-align:right;}#TB_ajaxContent #options{right:auto;left:25px;}#post_status{margin-left:0;margin-right:10px;}#footer{padding:10px 60px 0 0;}
Index: /tags/3.1/wp-admin/css/press-this-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/press-this-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/press-this-rtl.dev.css	(revision 17487)
@@ -0,0 +1,130 @@
+body {
+	font-family: Tahoma, Arial;
+}
+
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+	margin: 0 0 0 5px;
+	float: right;
+}
+
+/* Editor/Main Column */
+div#poststuff {
+	padding-left: 0;
+	padding-right: 10px;
+}
+
+.posting {
+	margin-right: 0;
+	margin-left: 228px;
+	left: auto;
+	right: 0;
+}
+
+#side-info-column {
+	float: left;
+	right: auto;
+	left: 0;
+	margin-right: 0;
+	margin-left: 10px;
+}
+
+#side-info-column .sleeve {
+	padding-left: 0;
+	padding-right: 10px;
+}
+
+h3.tb {
+	margin-left: 0;
+	margin-right: 5px;
+}
+
+#actions {
+	float: left;
+}
+
+#extra_fields #actions {
+	right: auto;
+	left: 4px;
+}
+
+#actions li {
+	float: right;
+	margin-right: 0;
+	margin-left: 10px;
+}
+
+#extra_fields .button {
+	margin-right: 0;
+	margin-left: 5px;
+}
+
+/* Photo Styles */
+#img_container a {
+	float: right;
+}
+
+#category-add input, #category-add select {
+	font-family: Tahoma, Arial;
+}
+
+.inline-editor ul.cat-checklist ul,
+.categorydiv ul.categorychecklist ul,
+#linkcategorydiv ul.categorychecklist ul {
+	margin-left: 0;
+	margin-right: 18px;
+}
+
+/* Tags */
+#tagsdiv #newtag {
+	margin-right: 0;
+	margin-left: 5px;
+}
+
+#tagadd {
+	margin-left: 0;
+	margin-right: 3px;
+}
+
+#tagchecklist span {
+	margin-left: .5em;
+	margin-right: 10px;
+	float: right;
+}
+#tagchecklist span a {
+	margin: 6px -9px 0 0;
+	float: right;
+}
+
+#content {
+	margin-left: 0;
+	margin-right: 1%;
+}
+
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+	font-family: Tahoma, Arial, sans-serif;
+}
+
+.ac_results li {
+	text-align: right;
+}
+
+#TB_ajaxContent #options {
+	right: auto;
+	left: 25px;
+}
+
+#post_status {
+	margin-left: 0;
+	margin-right: 10px;
+}
+
+/* Footer */
+#footer {
+	padding: 10px 60px 0 0;
+}
Index: /tags/3.1/wp-admin/css/press-this.css
===================================================================
--- /tags/3.1/wp-admin/css/press-this.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/press-this.css	(revision 17487)
@@ -0,0 +1,1 @@
+body{font:13px "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;color:#333;margin:0;padding:0;min-width:675px;min-height:400px;}img{border:none;}#wphead{border-top:none;padding-top:4px;background:#444!important;}.tagchecklist span a{background:transparent url(../images/xit.gif) no-repeat 0 0;}#poststuff #edButtonPreview,#poststuff #edButtonHTML{-moz-border-radius:3px 3px 0 0;-webkit-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;border-top-right-radius:3px;border-top-left-radius:3px;border-style:solid;border-width:1px;cursor:pointer;display:block;height:18px;margin:0 5px 0 0;padding:0 5px 0;font-size:10px;line-height:18px;float:left;}.howto{margin-top:2px;margin-bottom:3px;font-size:11px;font-style:italic;display:block;}input.text{outline-color:-moz-use-text-color;outline-style:none;outline-width:medium;width:100%;}#message{-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}div#poststuff{margin:10px;}div.zerosize{border:0 none;height:0;margin:0;overflow:hidden;padding:0;width:0;}#poststuff #edButtonPreview.active,#poststuff #edButtonHTML.active{display:none;}.posting{margin-right:212px;position:relative;}#side-info-column{float:right;width:200px;position:relative;right:0;}#side-info-column .sleeve{padding-top:5px;}#poststuff .inside{font-size:11px;margin:8px;}#poststuff h2,#poststuff h3{font-size:12px;font-weight:bold;line-height:1;margin:0;padding:7px 9px;}#tagsdiv-post_tag h3,#categorydiv h3{cursor:pointer;}h3.tb{text-shadow:0 1px 0 #fff;font-weight:bold;font-size:12px;margin-left:5px;}#TB_window{border:1px solid #333;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}.postbox,.stuffbox{margin-bottom:10px;border-width:1px;border-style:solid;line-height:1;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}.postbox:hover .handlediv,.stuffbox:hover .handlediv{background:transparent url(../images/menu-bits.gif) no-repeat scroll left -111px;}.handlediv{float:right;height:26px;width:23px;}#title,.tbtitle{-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;border-style:solid;border-width:1px;font-size:1.7em;outline:none;padding:3px 4px;border-color:#dfdfdf;}.tbtitle{font-size:12px;padding:3px;}#title{width:97%;}.editor-container{-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;border:1px solid #dfdfdf;background-color:#fff;}.postdivrich{padding-top:25px;position:relative;}.actions{float:right;margin:-19px 0 0;}#extra-fields .actions{margin:-15px -5px 0 0;}.actions li{float:left;list-style:none;margin-right:10px;}#extra-fields .button{margin-right:5px;padding:3px 6px;border-radius:10px;-webkit-border-radius:10px;-khtml-border-radius:10px;-moz-border-radius:10px;}.photolist{margin-top:-10px;}#photo_saving{margin:0 8px 8px;vertical-align:middle;}#img_container{background-color:#fff;}#img_container_container{overflow:auto;}#extra-fields{margin-top:10px;position:relative;}#waiting{margin-top:10px;}#extra-fields .postbox{margin-bottom:5px;}#extra-fields .titlewrap{padding:0;overflow:auto;height:100px;}#img_container a{display:block;float:left;overflow:hidden;vertical-align:center;}#img_container img,#img_container a{width:68px;height:68px;}#img_container img{border:none;background-color:#f4f4f4;cursor:pointer;}#img_container a,#img_container a:link,#img_container a:visited{border:1px solid #ccc;display:block;position:relative;}#img_container a:hover,#img_container a:active{border-color:#000;z-index:1000;border-width:2px;margin:-1px;}#embed-code{width:100%;height:98px;}#viewsite{padding:0;margin:0 0 20px 5px;font-size:10px;clear:both;}.wp-hidden-children .wp-hidden-child{display:none;}.category-add input{width:94%;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-size:12px;margin:1px;}.category-add select{width:100%;-x-system-font:none;border-style:solid;border-width:1px;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-size:11px;height:2em;line-height:20px;padding:2px;margin:1px;vertical-align:top;}.category-add input.category-add-sumbit{width:auto;}.categorydiv div.tabs-panel,#linkcategorydiv div.tabs-panel{height:100px;overflow:auto;padding:.5em .9em;border-style:solid;border-width:1px;}.category-tabs li{display:inline;padding-right:8px;}.category-tabs a{text-decoration:none;}.categorydiv ul,#linkcategorydiv ul{list-style:none;padding:0;margin:0;}.inline-editor ul.cat-checklist ul,.categorydiv ul.categorychecklist ul,#linkcategorydiv ul.categorychecklist ul{margin-left:18px;}ul.categorychecklist li{margin:0;padding:0;line-height:19px;}.categorydiv .tabs-panel{border-width:3px;border-style:solid;}ul.category-tabs{margin-top:12px;margin-bottom:6px;}ul.category-tabs li.tabs{border-style:solid solid none;border-width:1px 1px 0;}ul.category-tabs li{padding:5px 8px;-moz-border-radius:3px 3px 0 0;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;border-top-left-radius:3px;border-top-right-radius:3px;}.screen-reader-text{display:none;}.tagsdiv .newtag{margin-right:5px;}.jaxtag{clear:both;margin:0;}.tagadd{margin-left:3px;}.tagchecklist{margin-top:3px;margin-bottom:1em;font-size:12px;overflow:auto;}.tagchecklist strong{position:absolute;font-size:.75em;}.tagchecklist span{margin-right:.5em;margin-left:10px;display:block;float:left;font-size:11px;line-height:1.8em;white-space:nowrap;cursor:default;}.tagchecklist span a{margin:6px 0 0 -9px;cursor:pointer;width:10px;height:10px;display:block;float:left;text-indent:-9999px;overflow:hidden;position:absolute;}#content{margin:5px 0;padding:0 5px;border:0 none;height:365px;width:97%!important;}* html .postdivrich{zoom:1;}#saving{display:inline;vertical-align:middle;}.submit input,.button,.button-primary,.button-secondary,.button-highlighted,#postcustomstuff .submit input{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;text-decoration:none;font-size:11px!important;line-height:16px;padding:2px 8px;cursor:pointer;border-width:1px;border-style:solid;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;}.button-primary{background:#21759B url(../images/button-grad.png) repeat-x scroll left top;border-color:#21759B;color:#fff;}.ac_results{padding:0;margin:0;list-style:none;position:absolute;z-index:10000;display:none;border-width:1px;border-style:solid;}.ac_results li{padding:2px 5px;white-space:nowrap;text-align:left;}.ac_over{cursor:pointer;}.ac_match{text-decoration:underline;}#TB_ajaxContent #options{position:absolute;top:20px;right:25px;padding:5px;}#TB_ajaxContent h3{margin-bottom:.25em;}.updated{margin:10px 0;padding:0;border-width:1px;border-style:solid;width:99%;}.updated p,.error p{margin:.6em 0;padding:0 .6em;}.error a{text-decoration:underline;}.updated a{text-decoration:none;padding-bottom:2px;}#post_status{margin-left:10px;margin-bottom:1em;display:block;}#footer{height:65px;display:block;width:640px;padding:10px 0 0 60px;margin:0;position:absolute;bottom:0;font-size:12px;}#footer p{margin:0;padding:7px 0;}#footer p a{text-decoration:none;}#footer p a:hover{text-decoration:underline;}.centered{text-align:center;}.hidden{display:none;}.postbox input[type="text"],.postbox textarea,.stuffbox input[type="text"],.stuffbox textarea{border-width:1px;border-style:solid;}.taghint{color:#aaa;margin:-17px 0 0 7px;visibility:hidden;}input.newtag ~ div.taghint{visibility:visible;}input.newtag:focus ~ div.taghint{visibility:hidden;}
Index: /tags/3.1/wp-admin/css/press-this.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/press-this.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/press-this.dev.css	(revision 17487)
@@ -0,0 +1,618 @@
+body {
+	font: 13px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	color: #333;
+	margin: 0;
+	padding: 0;
+	min-width: 675px;
+	min-height: 400px;
+}
+
+img {
+	border: none;
+}
+
+/* Header */
+#wphead {
+	border-top: none;
+	padding-top: 4px;
+	background: #444 !important;
+}
+
+.tagchecklist span a {
+	background: transparent url(../images/xit.gif) no-repeat 0 0;
+}
+
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+	-moz-border-radius: 3px 3px 0 0;
+	-webkit-border-top-right-radius: 3px;
+	-webkit-border-top-left-radius: 3px;
+	-khtml-border-top-right-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	border-top-right-radius: 3px;
+	border-top-left-radius: 3px;
+	border-style: solid;
+	border-width: 1px;
+	cursor: pointer;
+	display: block;
+	height: 18px;
+	margin: 0 5px 0 0;
+	padding: 0 5px 0;
+	font-size: 10px;
+	line-height: 18px;
+	float: left;
+}
+
+.howto {
+	margin-top: 2px;
+	margin-bottom: 3px;
+	font-size: 11px;
+	font-style: italic;
+	display: block;
+}
+
+input.text {
+	outline-color: -moz-use-text-color;
+	outline-style: none;
+	outline-width: medium;
+	width: 100%;
+}
+
+#message {
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+/* Editor/Main Column */
+div#poststuff {
+	margin: 10px;
+}
+
+div.zerosize {
+	border: 0 none;
+	height: 0;
+	margin: 0;
+	overflow: hidden;
+	padding: 0;
+	width: 0;
+}
+
+#poststuff #edButtonPreview.active,
+#poststuff #edButtonHTML.active {
+	display: none;
+}
+
+.posting {
+	margin-right: 212px;
+	position: relative;
+}
+
+#side-info-column {
+	float: right;
+	width: 200px;
+	position: relative;
+	right: 0;
+}
+
+#side-info-column .sleeve {
+	padding-top: 5px;
+}
+
+#poststuff .inside {
+	font-size: 11px;
+	margin: 8px;
+}
+
+#poststuff h2,#poststuff h3 {
+	font-size: 12px;
+	font-weight: bold;
+	line-height: 1;
+	margin: 0;
+	padding: 7px 9px;
+}
+
+#tagsdiv-post_tag h3,
+#categorydiv h3 {
+	cursor: pointer;
+}
+
+h3.tb {
+	text-shadow: 0 1px 0 #fff;
+	font-weight: bold;
+	font-size: 12px;
+	margin-left: 5px;
+}
+
+#TB_window {
+	border: 1px solid #333;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+.postbox,
+.stuffbox {
+	margin-bottom: 10px;
+	border-width: 1px;
+	border-style: solid;
+	line-height: 1;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+.postbox:hover .handlediv,
+.stuffbox:hover .handlediv {
+	background: transparent url(../images/menu-bits.gif) no-repeat scroll left -111px;
+}
+
+.handlediv {
+	float: right;
+	height: 26px;
+	width: 23px;
+}
+
+#title,
+.tbtitle {
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+	border-style: solid;
+	border-width: 1px;
+	font-size: 1.7em;
+	outline: none;
+	padding: 3px 4px;
+	border-color: #dfdfdf;
+}
+
+.tbtitle {
+	font-size: 12px;
+	padding: 3px;
+}
+
+#title {
+	width: 97%;
+}
+
+.editor-container {
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+	border: 1px solid #dfdfdf;
+	background-color: #fff;
+}
+
+.postdivrich {
+	padding-top: 25px;
+	position: relative;
+}
+
+.actions {
+	float: right;
+	margin: -19px 0 0;
+}
+
+#extra-fields .actions {
+	margin: -15px -5px 0 0;
+}
+
+.actions li {
+	float: left;
+	list-style: none;
+	margin-right: 10px;
+}
+
+#extra-fields .button {
+	margin-right: 5px;
+	padding: 3px 6px;
+	border-radius: 10px;
+	-webkit-border-radius: 10px;
+	-khtml-border-radius: 10px;
+	-moz-border-radius: 10px;
+}
+
+/* Photo Styles */
+.photolist {
+	margin-top: -10px;
+}
+
+#photo_saving {
+	margin: 0 8px 8px;
+	vertical-align: middle;
+}
+
+#img_container {
+	background-color: #fff;
+}
+
+#img_container_container {
+	overflow: auto;
+}
+
+#extra-fields {
+	margin-top: 10px;
+	position: relative;
+}
+
+#waiting {
+	margin-top: 10px;
+}
+
+#extra-fields .postbox {
+	margin-bottom: 5px;
+}
+
+#extra-fields .titlewrap {
+	padding: 0;
+	overflow: auto;
+	height: 100px;
+}
+
+#img_container a {
+	display: block;
+	float: left;
+	overflow: hidden;
+	vertical-align: center;
+}
+
+#img_container img,
+#img_container a {
+	width: 68px;
+	height: 68px;
+}
+
+#img_container img {
+	border: none;
+	background-color: #f4f4f4;
+	cursor: pointer;
+}
+
+#img_container a,
+#img_container a:link,
+#img_container a:visited {
+	border: 1px solid #ccc;
+	display: block;
+	position: relative;
+}
+
+#img_container a:hover,
+#img_container a:active {
+	border-color: #000;
+	z-index: 1000;
+	border-width: 2px;
+	margin: -1px;
+}
+
+/* Video */
+#embed-code {
+	width: 100%;
+	height: 98px;
+}
+
+/* Submit Column */
+#viewsite {
+	padding: 0;
+	margin: 0 0 20px 5px;
+	font-size: 10px;
+	clear: both;
+}
+
+.wp-hidden-children
+.wp-hidden-child {
+	display: none;
+}
+
+/* Categories */
+
+.category-add input {
+	width: 94%;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-size: 12px;
+	margin: 1px;
+}
+
+.category-add select {
+	width: 100%;
+	-x-system-font: none;
+	border-style: solid;
+	border-width: 1px;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-size: 11px;
+	height: 2em;
+	line-height: 20px;
+	padding: 2px;
+	margin: 1px;
+	vertical-align: top;
+}
+
+.category-add input.category-add-sumbit {
+	width: auto;
+}
+
+.categorydiv div.tabs-panel,
+#linkcategorydiv div.tabs-panel {
+	height: 100px;
+	overflow: auto;
+	padding: 0.5em 0.9em;
+	border-style: solid;
+	border-width: 1px;
+}
+
+.category-tabs li {
+	display: inline;
+	padding-right: 8px;
+}
+
+.category-tabs a {
+	text-decoration: none;
+}
+
+.categorydiv ul,
+#linkcategorydiv ul {
+	list-style: none;
+	padding: 0;
+	margin: 0;
+}
+
+.inline-editor ul.cat-checklist ul,
+.categorydiv ul.categorychecklist ul,
+#linkcategorydiv ul.categorychecklist ul {
+	margin-left: 18px;
+}
+
+ul.categorychecklist li {
+	margin: 0;
+	padding: 0;
+	line-height: 19px;
+}
+
+.categorydiv .tabs-panel {
+	border-width: 3px;
+	border-style: solid;
+}
+
+ul.category-tabs {
+	margin-top: 12px;
+	margin-bottom: 6px;
+}
+
+ul.category-tabs li.tabs {
+	border-style: solid solid none;
+	border-width: 1px 1px 0;
+}
+
+ul.category-tabs li {
+	padding: 5px 8px;
+	-moz-border-radius: 3px 3px 0 0;
+	-webkit-border-top-left-radius: 3px;
+	-webkit-border-top-right-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	-khtml-border-top-right-radius: 3px;
+	border-top-left-radius: 3px;
+	border-top-right-radius: 3px;
+}
+
+/* Tags */
+.screen-reader-text {
+	display: none;
+}
+
+.tagsdiv .newtag {
+	margin-right: 5px;
+}
+
+.jaxtag {
+	clear: both;
+	margin: 0;
+}
+
+.tagadd {
+	margin-left: 3px;
+}
+
+.tagchecklist {
+	margin-top: 3px;
+	margin-bottom: 1em;
+	font-size: 12px;
+	overflow: auto;
+}
+
+.tagchecklist strong {
+	position: absolute;
+	font-size: .75em;
+}
+
+.tagchecklist span {
+	margin-right: .5em;
+	margin-left: 10px;
+	display: block;
+	float: left;
+	font-size: 11px;
+	line-height: 1.8em;
+	white-space: nowrap;
+	cursor: default;
+}
+
+.tagchecklist span a {
+	margin: 6px 0 0 -9px;
+	cursor: pointer;
+	width: 10px;
+	height: 10px;
+	display: block;
+	float: left;
+	text-indent: -9999px;
+	overflow: hidden;
+	position: absolute;
+}
+
+#content {
+	margin: 5px 0;
+	padding: 0 5px;
+	border: 0 none;
+	height: 365px;
+	width: 97% !important;
+}
+
+* html .postdivrich {
+	zoom: 1;
+}
+
+/* Submit */
+#saving {
+	display: inline;
+	vertical-align: middle;
+}
+
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	text-decoration: none;
+	font-size: 11px !important;
+	line-height: 16px;
+	padding: 2px 8px;
+	cursor: pointer;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 11px;
+	-khtml-border-radius: 11px;
+	-webkit-border-radius: 11px;
+	border-radius: 11px;
+}
+
+.button-primary {
+	background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
+	border-color: #21759B;
+	color: #fff;
+}
+
+.ac_results {
+	padding: 0;
+	margin: 0;
+	list-style: none;
+	position: absolute;
+	z-index: 10000;
+	display: none;
+	border-width: 1px;
+	border-style: solid;
+}
+
+.ac_results li {
+	padding: 2px 5px;
+	white-space: nowrap;
+	text-align: left;
+}
+
+.ac_over {
+	cursor: pointer;
+}
+
+.ac_match {
+	text-decoration: underline;
+}
+
+#TB_ajaxContent #options {
+	position: absolute;
+	top: 20px;
+	right: 25px;
+	padding: 5px;
+}
+
+#TB_ajaxContent h3 {
+	margin-bottom: .25em;
+}
+
+.updated {
+	margin: 10px 0;
+	padding: 0;
+	border-width: 1px;
+	border-style: solid;
+	width: 99%;
+}
+
+.updated p,
+.error p {
+	margin: 0.6em 0;
+	padding: 0 0.6em;
+}
+
+.error a {
+	text-decoration: underline;
+}
+
+.updated a {
+	text-decoration: none;
+	padding-bottom: 2px;
+}
+
+#post_status {
+	margin-left: 10px;
+	margin-bottom: 1em;
+	display: block;
+}
+
+/* Footer */
+#footer {
+	height: 65px;
+	display: block;
+	width: 640px;
+	padding: 10px 0 0 60px;
+	margin: 0;
+	position: absolute;
+	bottom: 0;
+	font-size: 12px;
+}
+
+#footer p {
+	margin: 0;
+	padding: 7px 0;
+}
+
+#footer p a {
+	text-decoration: none;
+}
+
+#footer p a:hover {
+	text-decoration: underline;
+}
+
+/* Utility Classes */
+.centered {
+	text-align: center;
+}
+
+.hidden {
+	display: none;
+}
+
+.postbox input[type="text"],
+.postbox textarea,
+.stuffbox input[type="text"],
+.stuffbox textarea {
+	border-width: 1px;
+	border-style: solid;
+}
+
+/* tag hints */
+.taghint {
+	color: #aaa;
+	margin: -17px 0 0 7px;
+	visibility: hidden;
+}
+
+input.newtag ~ div.taghint {
+	visibility: visible;
+}
+
+input.newtag:focus ~ div.taghint {
+	visibility: hidden;
+}
Index: /tags/3.1/wp-admin/css/theme-editor-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-editor-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-editor-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+#templateside{float: left;}
Index: /tags/3.1/wp-admin/css/theme-editor-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-editor-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-editor-rtl.dev.css	(revision 17487)
@@ -0,0 +1,3 @@
+#templateside {
+	float: left;
+}
Index: /tags/3.1/wp-admin/css/theme-editor.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-editor.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-editor.css	(revision 17487)
@@ -0,0 +1,1 @@
+.alignleft h3{margin:0;}h3 span{font-weight:normal;}#template textarea{font-family:Consolas,Monaco,Courier,monospace;font-size:12px;width:97%;}#template p{width:97%;}#templateside{float:right;width:190px;word-wrap:break-word;}#templateside h3,#postcustomstuff p.submit{margin:0;}#templateside h4{margin:1em 0 0;}#templateside ol,#templateside ul{margin:.5em;padding:0;}#templateside li{margin:4px 0;}#templateside ul li a span.highlight{display:block;}.nonessential{font-size:11px;font-style:italic;padding-left:12px;}.highlight{padding:3px 3px 3px 12px;margin-left:-12px;font-weight:bold;-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px;}div.tablenav{margin-right:210px;}#documentation{margin-top:10px;}#documentation label{line-height:22px;vertical-align:top;font-weight:bold;}.fileedit-sub{padding:10px 0 8px;line-height:180%;}
Index: /tags/3.1/wp-admin/css/theme-editor.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-editor.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-editor.dev.css	(revision 17487)
@@ -0,0 +1,80 @@
+.alignleft h3 {
+	margin: 0;
+}
+
+h3 span {
+	font-weight: normal;
+}
+
+#template textarea {
+	font-family: Consolas, Monaco, Courier, monospace;
+	font-size: 12px;
+	width: 97%;
+}
+
+#template p {
+	width: 97%;
+}
+
+#templateside {
+	float: right;
+	width: 190px;
+	word-wrap: break-word;
+}
+
+#templateside h3,
+#postcustomstuff p.submit {
+	margin: 0;
+}
+
+#templateside h4 {
+	margin: 1em 0 0;
+}
+
+#templateside ol,
+#templateside ul {
+	margin: .5em;
+	padding: 0;
+}
+
+#templateside li {
+	margin: 4px 0;
+}
+
+#templateside ul li a span.highlight {
+	display:block;
+}
+
+.nonessential {
+	font-size: 11px;
+	font-style: italic;
+	padding-left: 12px;
+}
+
+.highlight {
+	padding: 3px 3px 3px 12px;
+	margin-left: -12px;
+	font-weight: bold;
+	-moz-border-radius: 8px;
+	-khtml-border-radius: 8px;
+	-webkit-border-radius: 8px;
+	border-radius: 8px;
+}
+
+div.tablenav {
+	margin-right: 210px;
+}
+
+#documentation {
+	margin-top: 10px;
+}
+#documentation label {
+	line-height: 22px;
+	vertical-align: top;
+	font-weight: bold;
+}
+
+.fileedit-sub {
+	padding: 10px 0 8px;
+	line-height: 180%;
+}
Index: /tags/3.1/wp-admin/css/theme-install-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-install-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-install-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+div.star{left:auto;right:0;}.star img,div.star a,div.star a:hover,div.star a:visited{right:auto;left:0;}.theme-listing .theme-item h3{font-style:normal;}#theme-information .theme-preview-img{float:right;margin:5px 15px 10px 25px;}#theme-information .action-button #cancel{float:right;}#theme-information .action-button #install{float:left;}.feature-filter .feature-group{float:right;}.feature-filter .feature-name{float:right;text-align:left;}.feature-filter .feature-group li{float:right;padding-right:0;padding-left:25px;}
Index: /tags/3.1/wp-admin/css/theme-install-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-install-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-install-rtl.dev.css	(revision 17487)
@@ -0,0 +1,41 @@
+div.star {
+	left:auto;
+	right: 0;
+}
+
+.star img, div.star a, div.star a:hover, div.star a:visited {
+	right: auto;
+	left: 0;
+}
+
+.theme-listing .theme-item h3 {
+	font-style: normal;
+}
+
+#theme-information .theme-preview-img {
+	float: right;
+	margin: 5px 15px 10px 25px;
+}
+
+#theme-information .action-button #cancel {
+	float: right;
+}
+
+#theme-information .action-button #install {
+	float: left;
+}
+
+.feature-filter .feature-group {
+	float: right;
+}
+
+.feature-filter .feature-name {
+	float: right;
+	text-align: left;
+}
+
+.feature-filter .feature-group li {
+	float: right;
+	padding-right: 0;
+	padding-left: 25px;
+}
Index: /tags/3.1/wp-admin/css/theme-install.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-install.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-install.css	(revision 17487)
@@ -0,0 +1,1 @@
+div.star-holder{position:relative;height:19px;width:100px;font-size:19px;}div.star{height:100%;position:absolute;top:0;left:0;background-color:transparent;letter-spacing:1ex;border:none;}.star1{width:20%;}.star2{width:40%;}.star3{width:60%;}.star4{width:80%;}.star5{width:100%;}.star img,div.star a,div.star a:hover,div.star a:visited{display:block;position:absolute;right:0;border:none;text-decoration:none;}div.star img{width:19px;height:19px;border-left:1px solid #fff;border-right:1px solid #fff;}.theme-listing .theme-item{display:inline-block;width:200px;border:thin solid #ccc;vertical-align:top;}.theme-listing .theme-item h3{text-align:center;font-size:14px;font-style:italic;margin:0;padding:0;}.theme-listing .theme-item img{max-width:150px;max-height:150px;}.theme-listing .theme-item-info span{display:none;}.theme-listing .theme-item:hover .theme-item-info span{display:inline;}.theme-listing .theme-item:hover .theme-item-info span.dots{display:none;}.theme-listing .theme-item-info span.action-links{font-weight:bold;text-align:center;}.theme-listing br.line{border-bottom-width:1px;border-bottom-style:solid;margin-bottom:3px;}.available-theme{padding:20px 15px;}#theme-information .theme-preview-img{float:left;margin:5px 25px 10px 15px;width:300px;}#theme-information .action-button{border-top-width:1px;border-top-style:solid;margin:10px 5px 0;}#theme-information .action-button #cancel{float:left;margin:10px 15px;}#theme-information .action-button #install{float:right;margin:10px 15px;}#theme-information .available-theme h3{margin:1em 0;}body#theme-information{height:auto;}.feature-filter{-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px;border-width:1px;border-style:solid;padding:8px 12px 0;}.feature-filter .feature-group{float:left;margin-bottom:20px;width:725px;}.feature-filter .feature-name{float:left;text-align:right;width:95px;}.feature-filter .feature-group li{display:inline;float:left;list-style-type:none;padding-right:25px;min-width:145px;}.feature-container{width:100%;overflow:auto;margin-bottom:10px;}.feature-group{margin-bottom:0!important;}
Index: /tags/3.1/wp-admin/css/theme-install.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/theme-install.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/theme-install.dev.css	(revision 17487)
@@ -0,0 +1,155 @@
+/* NOTE: the following CSS rules(.star*) are taken more or less straight from the bbPress rating plugin. */
+div.star-holder {
+	position: relative;
+	height: 19px;
+	width: 100px;
+	font-size: 19px;
+}
+
+div.star {
+	height: 100%;
+	position: absolute;
+	top: 0;
+	left: 0;
+	background-color: transparent;
+	letter-spacing: 1ex;
+	border: none;
+}
+
+.star1 { width: 20%; }
+.star2 { width: 40%; }
+.star3 { width: 60%; }
+.star4 { width: 80%; }
+.star5 { width: 100%; }
+
+.star img, div.star a, div.star a:hover, div.star a:visited {
+	display: block;
+	position: absolute;
+	right: 0;
+	border: none;
+	text-decoration: none;
+}
+
+div.star img {
+	width: 19px;
+	height: 19px;
+	border-left: 1px solid #fff;
+	border-right: 1px solid #fff;
+}
+
+.theme-listing .theme-item {
+	display: inline-block;
+	width: 200px;
+	border: thin solid #ccc;
+	vertical-align: top;
+}
+
+.theme-listing .theme-item h3 {
+	text-align: center;
+	font-size: 14px;
+	font-style: italic;
+	margin: 0;
+	padding: 0;
+}
+
+.theme-listing .theme-item img {
+	max-width: 150px;
+	max-height: 150px;
+}
+
+.theme-listing .theme-item-info span {
+	display: none;
+}
+
+.theme-listing .theme-item:hover .theme-item-info span {
+	display: inline;
+}
+
+.theme-listing .theme-item:hover .theme-item-info span.dots {
+	display: none;
+}
+
+.theme-listing .theme-item-info span.action-links {
+	font-weight: bold;
+	text-align: center;
+}
+
+.theme-listing br.line {
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+	margin-bottom: 3px;
+}
+
+.available-theme {
+	padding: 20px 15px;
+}
+
+#theme-information .theme-preview-img {
+	float: left;
+	margin: 5px 25px 10px 15px;
+	width: 300px;
+}
+
+#theme-information .action-button {
+	border-top-width: 1px;
+	border-top-style: solid;
+	margin: 10px 5px 0;
+}
+
+#theme-information .action-button #cancel {
+	float: left;
+	margin: 10px 15px;
+}
+
+#theme-information .action-button #install {
+	float: right;
+	margin: 10px 15px;
+}
+
+#theme-information .available-theme h3 {
+	margin: 1em 0;
+}
+
+body#theme-information {
+	height: auto;
+}
+
+.feature-filter {
+	-moz-border-radius: 8px;
+	-khtml-border-radius: 8px;
+	-webkit-border-radius: 8px;
+	border-radius: 8px;
+	border-width: 1px;
+	border-style: solid;
+	padding: 8px 12px 0;
+}
+
+.feature-filter .feature-group {
+	float: left;
+	margin-bottom: 20px;
+	width: 725px;
+}
+
+.feature-filter .feature-name {
+	float: left;
+	text-align: right;
+	width: 95px;
+}
+
+.feature-filter .feature-group li {
+	display: inline;
+	float: left;
+	list-style-type: none;
+	padding-right: 25px;
+	min-width: 145px;
+}
+
+.feature-container {
+width: 100%;
+overflow: auto;
+margin-bottom: 10px;
+}
+
+.feature-group {
+	margin-bottom: 0px !important;
+}
Index: /tags/3.1/wp-admin/css/widgets-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/widgets-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/widgets-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+#widget-list .widget,#wp_inactive_widgets .widget{float: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{margin-right:0;margin-left:8px;float:right;}
Index: /tags/3.1/wp-admin/css/widgets-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/widgets-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/widgets-rtl.dev.css	(revision 17487)
@@ -0,0 +1,14 @@
+#widget-list .widget,
+#wp_inactive_widgets .widget {
+	float: 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 {
+	margin-right: 0;
+	margin-left: 8px;
+	float: right;
+}
Index: /tags/3.1/wp-admin/css/widgets.css
===================================================================
--- /tags/3.1/wp-admin/css/widgets.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/widgets.css	(revision 17487)
@@ -0,0 +1,1 @@
+html,body{min-width:950px;}div.widget-liquid-left{float:left;clear:left;width:100%;margin-right:-325px;}div#widgets-left{margin-left:5px;margin-right:325px;}div#widgets-right{width:285px;margin:0 auto;}div.widget-liquid-right{float:right;clear:right;width:300px;}.widget-liquid-right .widget,#wp_inactive_widgets .widget,.widget-liquid-right .sidebar-description{width:250px;margin:0 auto 20px;overflow:hidden;}.widget-liquid-right .sidebar-description{margin-bottom:10px;}#wp_inactive_widgets .widget{margin:0 10px 20px;float:left;}div.sidebar-name h3{margin:0;padding:5px 12px;font-size:13px;height:19px;overflow:hidden;white-space:nowrap;}div.sidebar-name{background-repeat:repeat-x;background-position:0 0;cursor:pointer;font-size:13px;border-width:1px;border-style:solid;-moz-border-radius-topleft:8px;-moz-border-radius-topright:8px;-webkit-border-top-right-radius:8px;-webkit-border-top-left-radius:8px;-khtml-border-top-right-radius:8px;-khtml-border-top-left-radius:8px;border-top-right-radius:8px;border-top-left-radius:8px;}.js .closed .sidebar-name{-moz-border-radius-bottomleft:8px;-moz-border-radius-bottomright:8px;-webkit-border-bottom-right-radius:8px;-webkit-border-bottom-left-radius:8px;-khtml-border-bottom-right-radius:8px;-khtml-border-bottom-left-radius:8px;border-bottom-right-radius:8px;border-bottom-left-radius:8px;}.widget-liquid-right .widgets-sortables,#widgets-left .widget-holder{border-width:0 1px 1px;border-style:none solid solid;-moz-border-radius-bottomleft:8px;-moz-border-radius-bottomright:8px;-webkit-border-bottom-right-radius:8px;-webkit-border-bottom-left-radius:8px;-khtml-border-bottom-right-radius:8px;-khtml-border-bottom-left-radius:8px;border-bottom-right-radius:8px;border-bottom-left-radius:8px;}.js .closed .widgets-sortables,.js .closed .widget-holder{display:none;}.widget-liquid-right .widgets-sortables{padding:15px 0 0;}#available-widgets .widget-holder{padding:7px 5px 0;}#wp_inactive_widgets{padding:5px 5px 0;}#widget-list .widget{width:250px;margin:0 10px 15px;border:0 none;float:left;}#widget-list .widget-description{padding:5px 8px;}#widget-list .widget-top{border-width:1px;border-style:solid;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}.widget-placeholder{border-width:1px;border-style:dashed;margin:0 auto 20px;height:26px;width:250px;}#wp_inactive_widgets .widget-placeholder{margin:0 10px 20px;float:left;}div.widgets-holder-wrap{padding:0;margin:10px 0 20px;}#widgets-left #available-widgets{background-color:transparent;border:0 none;}ul#widget-list{list-style:none;margin:0;padding:0;min-height:100px;}.widget .widget-top{font-size:12px;font-weight:bold;height:26px;overflow:hidden;}.widget-top .widget-title{padding:5px 9px;}.widget-top .widget-title-action{float:right;}a.widget-action{display:block;width:24px;height:26px;}#available-widgets a.widget-action{display:none;}.widget-top a.widget-action{background:url("../images/menu-bits.gif?ver=20100610") no-repeat scroll 0 -110px;}.widget .widget-inside,.widget .widget-description{padding:12px 12px 10px;font-size:11px;line-height:16px;}.widget-inside,.widget-description{display:none;}#available-widgets .widget-description{display:block;}.widget .widget-inside p{margin:0 0 1em;padding:0;}.widget-title h4{margin:0;line-height:1.3;overflow:hidden;white-space:nowrap;}.widgets-sortables{min-height:90px;}.widget-control-actions{margin-top:8px;}.widget-control-actions a{text-decoration:none;}.widget-control-actions a:hover{text-decoration:underline;}.widget-control-actions .ajax-feedback{padding-bottom:3px;}.widget-control-actions div.alignleft{margin-top:6px;}div#sidebar-info{padding:0 1em;margin-bottom:1em;font-size:11px;}.widget-title a,.widget-title a:hover{text-decoration:none;border-bottom:none;}.widget-control-edit{display:block;font-size:11px;font-weight:normal;line-height:26px;padding:0 8px 0 0;}a.widget-control-edit{text-decoration:none;}.widget-control-edit .add,.widget-control-edit .edit{display:none;}#available-widgets .widget-control-edit .add,#widgets-right .widget-control-edit .edit,#wp_inactive_widgets .widget-control-edit .edit{display:inline;}.editwidget{margin:0 auto 15px;}.editwidget .widget-inside{display:block;border-width:1px;border-style:solid;padding:10px;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}.inactive p.description{margin:5px 15px 8px;}#available-widgets p.description{margin:0 12px 12px;}.widget-position{margin-top:8px;}.inactive{padding-top:2px;}.sidebar-name-arrow{float:right;height:29px;width:26px;}.widget-title .in-widget-title{font-size:11px;white-space:nowrap;}#removing-widget{display:none;font-weight:normal;padding-left:15px;font-size:12px;}.widget-control-noform,#access-off,.widgets_access .widget-action,.widgets_access .sidebar-name-arrow,.widgets_access #access-on,.widgets_access .widget-holder .description{display:none;}.widgets_access .widget-holder,.widgets_access #widget-list{padding-top:10px;}.widgets_access #access-off{display:inline;}.widgets_access #wpbody-content .widget-title-action,.widgets_access #wpbody-content .widget-control-edit,.widgets_access .closed .widgets-sortables,.widgets_access .closed .widget-holder{display:block;}.widgets_access .closed .sidebar-name{-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:0;-khtml-border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;}.widgets_access .sidebar-name,.widgets_access .widget .widget-top{cursor:default;}
Index: /tags/3.1/wp-admin/css/widgets.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/widgets.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/widgets.dev.css	(revision 17487)
@@ -0,0 +1,370 @@
+html,
+body {
+	min-width: 950px;
+}
+
+/* 2 column liquid layout */
+div.widget-liquid-left {
+	float: left;
+	clear: left;
+	width: 100%;
+	margin-right: -325px;
+}
+
+div#widgets-left {
+	margin-left: 5px;
+	margin-right: 325px;
+}
+
+div#widgets-right {
+	width: 285px;
+	margin: 0 auto;
+}
+
+div.widget-liquid-right {
+	float: right;
+	clear: right;
+	width: 300px;
+}
+
+.widget-liquid-right .widget,
+#wp_inactive_widgets .widget,
+.widget-liquid-right .sidebar-description {
+	width: 250px;
+	margin: 0 auto 20px;
+	overflow: hidden;
+}
+
+.widget-liquid-right .sidebar-description {
+	margin-bottom: 10px;
+}
+
+#wp_inactive_widgets .widget {
+	margin: 0 10px 20px;
+	float: left;
+}
+
+div.sidebar-name h3 {
+	margin: 0;
+	padding: 5px 12px;
+	font-size: 13px;
+	height: 19px;
+	overflow: hidden;
+	white-space: nowrap;
+}
+
+div.sidebar-name {
+	background-repeat: repeat-x;
+	background-position: 0 0;
+	cursor: pointer;
+	font-size: 13px;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius-topleft: 8px;
+	-moz-border-radius-topright: 8px;
+	-webkit-border-top-right-radius: 8px;
+	-webkit-border-top-left-radius: 8px;
+	-khtml-border-top-right-radius: 8px;
+	-khtml-border-top-left-radius: 8px;
+	border-top-right-radius: 8px;
+	border-top-left-radius: 8px;
+}
+
+.js .closed .sidebar-name {
+	-moz-border-radius-bottomleft: 8px;
+	-moz-border-radius-bottomright: 8px;
+	-webkit-border-bottom-right-radius: 8px;
+	-webkit-border-bottom-left-radius: 8px;
+	-khtml-border-bottom-right-radius: 8px;
+	-khtml-border-bottom-left-radius: 8px;
+	border-bottom-right-radius: 8px;
+	border-bottom-left-radius: 8px;
+}
+
+.widget-liquid-right .widgets-sortables,
+#widgets-left .widget-holder {
+	border-width: 0 1px 1px;
+	border-style: none solid solid;
+    -moz-border-radius-bottomleft: 8px;
+	-moz-border-radius-bottomright: 8px;
+	-webkit-border-bottom-right-radius: 8px;
+	-webkit-border-bottom-left-radius: 8px;
+	-khtml-border-bottom-right-radius: 8px;
+	-khtml-border-bottom-left-radius: 8px;
+	border-bottom-right-radius: 8px;
+	border-bottom-left-radius: 8px;
+}
+
+.js .closed .widgets-sortables,
+.js .closed .widget-holder {
+	display: none;
+}
+
+.widget-liquid-right .widgets-sortables {
+	padding: 15px 0 0;
+}
+
+#available-widgets .widget-holder {
+	padding: 7px 5px 0;
+}
+
+#wp_inactive_widgets {
+	padding: 5px 5px 0;
+}
+
+#widget-list .widget {
+	width: 250px;
+	margin: 0 10px 15px;
+	border: 0 none;
+	float: left;
+}
+
+#widget-list .widget-description {
+	padding: 5px 8px;
+}
+
+#widget-list .widget-top {
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+.widget-placeholder {
+	border-width: 1px;
+	border-style: dashed;
+	margin: 0 auto 20px;
+	height: 26px;
+	width: 250px;
+}
+
+#wp_inactive_widgets .widget-placeholder {
+	margin: 0 10px 20px;
+	float: left;
+}
+
+div.widgets-holder-wrap {
+	padding: 0;
+	margin: 10px 0 20px;
+}
+
+#widgets-left #available-widgets {
+	background-color: transparent;
+	border: 0 none;
+}
+
+ul#widget-list {
+	list-style: none;
+	margin: 0;
+	padding: 0;
+	min-height: 100px;
+}
+
+.widget .widget-top {
+	font-size: 12px;
+	font-weight: bold;
+	height: 26px;
+	overflow: hidden;
+}
+
+.widget-top .widget-title {
+	padding: 5px 9px;
+}
+
+.widget-top .widget-title-action {
+	float: right;
+}
+
+a.widget-action {
+	display: block;
+	width: 24px;
+	height: 26px;
+}
+
+#available-widgets a.widget-action {
+	display: none;
+}
+
+.widget-top a.widget-action {
+	background: url("../images/menu-bits.gif?ver=20100610") no-repeat scroll 0 -110px;
+}
+
+.widget .widget-inside,
+.widget .widget-description {
+	padding: 12px 12px 10px;
+	font-size: 11px;
+	line-height: 16px;
+}
+
+.widget-inside,
+.widget-description {
+	display: none;
+}
+
+#available-widgets .widget-description {
+	display: block;
+}
+
+.widget .widget-inside p {
+	margin: 0 0 1em;
+	padding: 0;
+}
+
+.widget-title h4 {
+	margin: 0;
+	line-height: 1.3;
+	overflow: hidden;
+	white-space: nowrap;
+}
+
+.widgets-sortables {
+	min-height: 90px;
+}
+
+.widget-control-actions {
+	margin-top: 8px;
+}
+
+.widget-control-actions a {
+	text-decoration: none;
+}
+
+.widget-control-actions a:hover {
+	text-decoration: underline;
+}
+
+.widget-control-actions .ajax-feedback {
+	padding-bottom: 3px;
+}
+
+.widget-control-actions div.alignleft {
+	margin-top: 6px;
+}
+
+div#sidebar-info {
+	padding: 0 1em;
+	margin-bottom: 1em;
+	font-size: 11px;
+}
+
+.widget-title a,
+.widget-title a:hover {
+	text-decoration: none;
+	border-bottom: none;
+}
+
+.widget-control-edit {
+	display: block;
+	font-size: 11px;
+	font-weight: normal;
+	line-height: 26px;
+	padding: 0 8px 0 0;
+}
+
+a.widget-control-edit {
+	text-decoration: none;
+}
+
+.widget-control-edit .add,
+.widget-control-edit .edit {
+	display: none;
+}
+
+#available-widgets .widget-control-edit .add,
+#widgets-right .widget-control-edit .edit,
+#wp_inactive_widgets .widget-control-edit .edit {
+	display: inline;
+}
+
+.editwidget {
+	margin: 0 auto 15px;
+}
+
+.editwidget .widget-inside {
+	display: block;
+	border-width: 1px;
+	border-style: solid;
+	padding: 10px;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+.inactive p.description {
+	margin: 5px 15px 8px;
+}
+
+#available-widgets p.description {
+	margin: 0 12px 12px;
+}
+
+.widget-position {
+	margin-top: 8px;
+}
+
+.inactive {
+	padding-top: 2px;
+}
+
+.sidebar-name-arrow {
+	float: right;
+	height: 29px;
+	width: 26px;
+}
+
+.widget-title .in-widget-title {
+	font-size: 11px;
+	white-space: nowrap;
+}
+
+#removing-widget {
+	display: none;
+	font-weight: normal;
+	padding-left: 15px;
+	font-size: 12px;
+}
+
+.widget-control-noform,
+#access-off,
+.widgets_access .widget-action,
+.widgets_access .sidebar-name-arrow,
+.widgets_access #access-on,
+.widgets_access .widget-holder .description {
+	display: none;
+}
+
+.widgets_access .widget-holder,
+.widgets_access #widget-list {
+	padding-top: 10px;
+}
+
+.widgets_access #access-off {
+	display: inline;
+}
+
+.widgets_access #wpbody-content .widget-title-action,
+.widgets_access #wpbody-content .widget-control-edit,
+.widgets_access .closed .widgets-sortables,
+.widgets_access .closed .widget-holder {
+	display: block;
+}
+
+.widgets_access .closed .sidebar-name {
+	-moz-border-radius-bottomleft: 0;
+	-moz-border-radius-bottomright: 0;
+	-webkit-border-bottom-right-radius: 0;
+	-webkit-border-bottom-left-radius: 0;
+	-khtml-border-bottom-right-radius: 0;
+	-khtml-border-bottom-left-radius: 0;
+	border-bottom-right-radius: 0;
+	border-bottom-left-radius: 0;
+}
+
+.widgets_access .sidebar-name,
+.widgets_access .widget .widget-top {
+	cursor: default;
+}
+
Index: /tags/3.1/wp-admin/css/wp-admin-rtl.css
===================================================================
--- /tags/3.1/wp-admin/css/wp-admin-rtl.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/wp-admin-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+td.available-theme{text-align:right;}#current-theme img{float:right;margin-right:0;margin-left:1em;}.quicktags,.search{font-family:Tahoma,Arial,sans-serif;}#doaction,#doaction2,#post-query-submit{margin-right:0;margin-left:8px;}#save-post{float:right;}#minor-publishing .ajax-loading{padding:3px 4px 0 0;float:right;}.preview{float:left;}#sticky-span{margin-left:0;margin-right:18px;}#post-body .misc-pub-section{border-right-width:0;border-left-width:1px;border-right-style:none;border-left-style:solid;float:right;}#post-body .misc-pub-section-last{border-left:0;}#delete-action{text-align:right;float:right;}#publishing-action{text-align:left;float:left;}.side-info ul{padding-left:0;padding-right:18px;}.submit input,.button,.button-primary,.button-secondary,.button-highlighted,#postcustomstuff .submit input{font-family:Tahoma,Arial,sans-serif;}#wpcontent select{font-family:Tahoma,Arial,sans-serif;}#quicktags{background-position:right top;}#template div{margin-right:0;margin-left:190px;}* html #template div{margin-left:0;}.list-ajax-loading{float:left;margin-right:0;margin-left:9px;}#your-profile legend{font-family:Tahoma,Arial,sans-serif;}#ajax-response.alignleft{margin-left:0;margin-right:2em;}.page-numbers{margin-right:0;margin-left:1px;}.column-author img,.column-username img{float:right;margin-right:0;margin-left:10px;}.tablenav a.button-secondary{margin-right:0;margin-left:8px;}.tablenav .actions{padding-right:0;padding-left:8px;}.tablenav .tablenav-pages{float:left;}.tablenav .displaying-num{margin-right:0;margin-left:10px;font-family:Tahoma,Arial,sans-serif;font-style:normal;}#postcustomstuff table input,#postcustomstuff table select,#postcustomstuff table textarea{margin:8px 8px 8px 0;}#pass-strength-result{float:right;margin:12px 1px 5px 5px;}#user_info{float:left;}#header-logo{float:right;margin:7px 15px 0 0;}#wphead h1{font-family:Tahoma,Arial,sans-serif;float:right;}#wphead h1.long-title{font-family:Tahoma,Arial,sans-serif;}#adminmenu .wp-submenu a{padding-left:0;padding-right:12px;border-width:0 0 0 1px;border-style:none none none solid;font-family:Tahoma,Arial,sans-serif;}#adminmenu a.menu-top,#adminmenu .wp-submenu-head{font-family:Tahoma,Arial,sans-serif;}#adminmenu img.wp-menu-image{float:right;}.folded #adminmenu img.wp-menu-image{padding:7px 6px 0 0;}#adminmenu a.separator{cursor:e-resize;}.folded #adminmenu a.separator{cursor:w-resize;}#adminmenu .wp-submenu .wp-submenu-head{padding:6px 10px 6px 4px;}.folded #adminmenu .wp-submenu{margin:-1px 28px 0 0;}.folded #adminmenu .wp-submenu a{padding-left:0;padding-right:10px;}.folded #adminmenu a.wp-has-submenu{margin-left:0;margin-right:40px;}#adminmenu .wp-menu-toggle{float:left;padding:1px 0 0 2px;clear:left;}#adminmenu div.wp-menu-image{float:right;}#wphead-info{margin:0 15px 0 0;padding-right:0;padding-left:15px;}#adminmenu #awaiting-mod,#adminmenu span.update-plugins,#sidemenu li a span.update-plugins{font-family:Tahoma,Arial,sans-serif;margin-left:0;margin-right:7px;}.post-com-count-wrapper{font-family:Tahoma,Arial,sans-serif;}.column-response .post-com-count{float:right;margin-right:0;margin-left:5px;}.form-table th{text-align:right;}.form-table input.tog{margin-right:0;margin-left:2px;float:right;}.form-table table.color-palette{float:right;}#profile-page .form-table #rich_editing{margin-right:0;margin-left:5px;}#normal-sortables .postbox .submit{float:left;}#post-body .tagsdiv #newtag{margin-right:0;margin-left:5px;}#post-status-info{padding:0 7px 0 15px;}#comment-status-radio input{margin:2px 0 5px 3px;}.tagchecklist{margin-left:0;margin-right:10px;}.tagchecklist strong{margin-left:0;margin-right:-8px;}.tagchecklist span{float:right;}.tagchecklist span a{margin:6px -9px 0 0;float:right;}.ac_results li{text-align:right;}#poststuff h2{clear:right;}.description,.form-wrap p{font-family:Tahoma,Arial,sans-serif;}.sorting-indicator{margin-left:0;margin-right:7px;}th.sortable a span,th.sorted a span{float:right;}.fixed .column-comments a{float:right;}.autosave-info{padding:2px 2px 2px 15px;text-align:left;}.meta-box-sortables .postbox .handlediv{float:left;}.howto{font-family:Tahoma,Arial,sans-serif;}.postarea h3 label{float:right;}.postarea #add-media-button{float:left;right:auto;left:10px;}.wp_themeSkin tr.mceFirst td.mceToolbar{background-position:right top;}#poststuff #edButtonPreview,#poststuff #edButtonHTML{margin:5px 0 0 5px;float:left;}#poststuff #edButtonHTML{margin-right:0;margin-left:15px;}#media-buttons a{padding:0 10px 5px 0;}.submitbox .submit{text-align:right;}.inside-submitbox #post_status{margin:2px -2px 2px 0;}.submitbox .submit input{margin-right:0;margin-left:4px;}.category-adder{margin-left:0;margin-right:120px;}#post-body ul.category-tabs li.tabs,#post-body ul.add-menu-item-tabs li.tabs{-moz-border-radius:0 3px 3px 0;-webkit-border-top-left-radius:0;-webkit-border-top-right-radius:3px;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:3px;border-top-left-radius:0;border-top-right-radius:3px;border-bottom-left-radius:0;border-bottom-right-radius:3px;}#post-body ul.category-tabs,#post-body ul.add-menu-item-tabs{float:right;text-align:left;margin:0 0 0 -120px;}#post-body .categorydiv div.tabs-panel,#post-body .taxonomy div.tabs-panel,#post-body #linkcategorydiv div.tabs-panel{margin:0 120px 0 5px;}#front-page-warning,#front-static-pages ul,.inline-editor ul.cat-checklist ul,.categorydiv ul.categorychecklist ul,.customlinkdiv ul.categorychecklist ul,.posttypediv ul.categorychecklist ul,.taxonomydiv ul.categorychecklist ul,#linkcategorydiv ul.categorychecklist ul{margin-left:0;margin-right:18px;}p.search-box{float:left;}#posts-filter fieldset{float:right;margin:0 0 1em 1.5ex;}#posts-filter fieldset legend{padding:0 1px .2em 0;}.view-switch{float:left;}.filter{float:right;margin:-5px 10px 0 0;}#the-comment-list td.comment p.comment-author{margin-right:0;}#the-comment-list p.comment-author img{float:right;margin-right:0;margin-left:8px;}.tablenav .delete{margin-right:0;margin-left:20px;}td.action-links,th.action-links{text-align:left;}.filter .subsubsub{margin-left:0;margin-right:-10px;}#wp-word-count{margin-right:10px;}.tool-box .title{font-family:Tahoma,Arial,sans-serif;}.settings-toggle{text-align:left;margin:5px 0 15px 7px;}.curtime #timestamp{background-position:right top;padding-left:0;padding-right:18px;}#sidemenu{margin:-30px 315px 0 15px;float:left;padding-left:0;padding-right:10px;}#sidemenu a{float:right;}#replysubmit .button{margin-right:0;margin-left:5px;}#edithead .inside{float:right;margin:3px 5px 2px 0;}#replyrow #ed_reply_toolbar input{margin:1px 1px 1px 2px;}#screen-meta-links{margin:0 0 0 18px;}#screen-options-link-wrap,#contextual-help-link-wrap{float:left;font-family:Tahoma,Arial,sans-serif;margin:0 0 0 6px;}#contextual-help-wrap li{margin-left:0;margin-right:18px;}#screen-meta a.show-settings{padding:0 6px 0 16px;background-position:left top;}.metabox-prefs label{padding-right:0;padding-left:15px;}.metabox-prefs label input{margin:0 2px 0 5px;}.inline-editor .save,.inline-editor .cancel{margin-right:0;margin-left:5px;}#replysubmit img.waiting,.inline-edit-save img.waiting{float:left;}.trash-undo-inside,.spam-undo-inside,.spam-undo-inside .avatar,.trash-undo-inside .avatar{margin-right:0;margin-left:8px;}#bulk-titles div a{float:right;margin:3px -2px 0 3px;}#wpbody-content .filename{margin-left:0;margin-right:10px;}#wpbody-content .inline-edit-row fieldset{float:right;}#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col{border-left:0 none;border-right:1px solid;}#wpbody-content .bulk-edit-row .inline-edit-col-bottom{float:left;}.inline-edit-row fieldset label span.title{float:right;}.inline-edit-row fieldset label span.input-text-wrap{margin-left:0;margin-right:5em;}.quick-edit-row-post fieldset.inline-edit-col-right label span.title{padding-right:0;padding-left:.5em;}#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child{margin-right:0;margin-left:.5em;}.inline-edit-row fieldset span.title,.inline-edit-row fieldset span.checkbox-title{font-family:Tahoma,Arial,sans-serif;}.inline-edit-row fieldset .inline-edit-date{float:right;}.inline-edit-row fieldset ul.cat-checklist label,.inline-edit-row .catshow,.inline-edit-row .cathide,.inline-edit-row #bulk-titles div{font-family:Tahoma,Arial,sans-serif;}.quick-edit-row-post fieldset label.inline-edit-status{float:right;}.describe-toggle-on,.describe-toggle-off{float:left;margin-right:0;margin-left:20px;}#wpbody-content #media-items .filename{float:right;margin-left:0;margin-right:10px;}.media-item .pinkynail{float:right;}#find-posts-response .found-radio{padding:8px 8px 0 0;}.find-box-buttons{left:auto;right:12px;}.find-box-search label{padding-right:0;padding-left:6px;}#favorite-actions{float:left;}#favorite-first{padding:3px 12px 4px 30px;}#favorite-inside a{padding:3px 10px 3px 5px;}#favorite-toggle{right:auto;left:0;background:transparent url(../images/fav-arrow-rtl.gif?ver=20100531) no-repeat 10px -4px;}#utc-time,#local-time{padding-left:0;padding-right:25px;font-family:Tahoma,Arial;}.icon32{float:right;margin:14px 0 0 6px;}.subtitle{padding-left:0;padding-right:25px;}ol{list-style-type:decimal;margin-left:0;margin-right:2em;}.postbox-container{float:right;padding-left:.5%;padding-right:0;}#wpbody-content .describe th{text-align:right;}.describe .media-item-info .A1B1{padding:0 10px 0 0;}.media-upload-form td label{margin-left:6px;margin-right:2px;}.media-upload-form .align .field label{padding:0 22px 0 0;margin:0 0 0 1em;}.media-upload-form tr.image-size label{margin:0 3px 0 0;}#wpbody-content .describe p.help{padding:0 5px 0 0;}.media-item .error-div a.dismiss,.describe-toggle-on,.describe-toggle-off{float:left;margin-right:0;margin-left:20px;}.describe-toggle-on,.describe-toggle-off{float:left;margin-left:20px;margin-right:0;}.media-item .error-div{padding-left:0;padding-right:10px;}.media-item .pinkynail{float:right;}.crunching{text-align:left;margin-left:5px;margin-right:0;}.bar{border-left-width:3px;border-left-style:solid;border-right:none;}.clearlooks2 .mceTop .mceLeft{width:100%!important;}.taghint{margin:15px 12px -24px 0;}#poststuff .tagsdiv .howto{margin:0 8px 6px 0;}#broken-themes{text-align:right;}.describe .del-link{padding-right:5px;padding-left:0;}.comment-ays th{border-left-style:solid;border-left-width:1px;}.appearance_page_custom-header #available-headers .default-header{float:right;margin:0 0 20px 20px;}.appearance_page_custom-header #available-headers label input{margin-right:0;margin-left:10px;}#custom-background label{padding-right:0;padding-left:15px;}#author-email,#author-url,#rss-url-1,#edit-slug-box,#post_name,#trackback_url,#metakeyinput,#post_password,#slug,#category_nicename,#link_url,#link_image,#rss_uri,#menu_order,#email,#newcomment_author_url,#pages-exclude,#template textarea,#user_login,#url,#pass1,#pass2,#aim,#yim,#jabber,#siteurl,#home,#admin_email,#gmt_offset,#default_post_edit_rows,#mailserver_url,#mailserver_login,#mailserver_pass,#mailserver_port,#ping_sites,#posts_per_page,#posts_per_rss,#blog_charset,#close_comments_days_old,#comments_per_page,#comment_max_links,#moderation_keys,#blacklist_keys,#thumbnail_size_w,#thumbnail_size_h,#medium_size_w,#medium_size_h,#large_size_w,#large_size_h,#permalink_structure,#category_base,#tag_base,#upload_path,#upload_url_path,#rules{direction:ltr;}#quicktags #ed_em,#ed_reply_toolbar #ed_reply_em,.tablenav .displaying-num,#footer,#footer a,p.help,p.description,span.description,.form-wrap p,#side-sortables .comments-box thead th,#normal-sortables .comments-box thead th,.howto,.inline-edit-row fieldset span.title,.inline-edit-row fieldset span.checkbox-title,#utc-time,#local-time,form.upgrade .hint,p.install-help,.imgedit-help{font-style:normal;}
Index: /tags/3.1/wp-admin/css/wp-admin-rtl.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/wp-admin-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/wp-admin-rtl.dev.css	(revision 17487)
@@ -0,0 +1,728 @@
+/* 0 - 200
+=================================== */
+td.available-theme {
+	text-align: right;
+}
+#current-theme img {
+	float: right;
+	margin-right: 0;
+	margin-left: 1em;
+}
+.quicktags, .search {
+	font-family: Tahoma, Arial, sans-serif;
+}
+/* 200 - 500
+=================================== */
+#doaction,
+#doaction2,
+#post-query-submit {
+	margin-right: 0;
+	margin-left: 8px;
+}
+#save-post {
+	float: right;
+}
+#minor-publishing .ajax-loading {
+	padding: 3px 4px 0 0;
+	float: right;
+}
+.preview {
+	float: left;
+}
+#sticky-span {
+	margin-left: 0;
+	margin-right: 18px;
+}
+#post-body .misc-pub-section {
+	border-right-width: 0;
+	border-left-width: 1px;
+	border-right-style: none;
+	border-left-style: solid;
+	float: right;
+}
+#post-body .misc-pub-section-last {
+	border-left: 0;
+}
+#delete-action {
+	text-align: right;
+	float: right;
+}
+#publishing-action {
+	text-align: left;
+	float: left;
+}
+.side-info ul {
+	padding-left: 0;
+	padding-right: 18px;
+}
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted,
+#postcustomstuff .submit input {
+	font-family: Tahoma, Arial, sans-serif;
+}
+#wpcontent select {
+	font-family: Tahoma, Arial, sans-serif;
+}
+#quicktags {
+	background-position: right top;
+}
+/* 500 - 700
+=================================== */
+#template div {
+	margin-right: 0;
+	margin-left: 190px;
+}
+* html #template div {
+	margin-left: 0;
+}
+
+.list-ajax-loading {
+	float: left;
+	margin-right: 0;
+	margin-left: 9px;
+}
+
+#your-profile legend {
+	font-family: Tahoma, Arial, sans-serif;
+}
+#ajax-response.alignleft {
+	margin-left: 0;
+	margin-right: 2em;
+}
+.page-numbers {
+	margin-right: 0;
+	margin-left: 1px;
+}
+.column-author img, .column-username img {
+	float: right;
+	margin-right: 0;
+	margin-left: 10px;
+}
+.tablenav a.button-secondary {
+	margin-right: 0;
+	margin-left: 8px;
+}
+.tablenav .actions {
+	padding-right: 0;
+	padding-left: 8px;
+}
+.tablenav .tablenav-pages {
+	float: left;
+}
+.tablenav .displaying-num {
+	margin-right: 0;
+	margin-left: 10px;
+	font-family: Tahoma, Arial, sans-serif;
+	font-style: normal;
+}
+#postcustomstuff table input,
+#postcustomstuff table select,
+#postcustomstuff table textarea {
+	margin: 8px 8px 8px 0;
+}
+/* 700 - 1000
+=================================== */
+#pass-strength-result {
+	float: right;
+	margin: 12px 1px 5px 5px;
+}
+/* Admin Header */
+#user_info {
+	float: left;
+}
+#header-logo {
+	float: right;
+	margin: 7px 15px 0 0;
+}
+#wphead h1 {
+	font-family: Tahoma, Arial, sans-serif;
+	float: right;
+}
+#wphead h1.long-title {
+	font-family: Tahoma, Arial, sans-serif;
+}
+#adminmenu .wp-submenu a {
+	padding-left: 0;
+	padding-right: 12px;
+	border-width: 0 0 0 1px;
+	border-style: none none none solid;
+	font-family: Tahoma, Arial, sans-serif;
+}
+#adminmenu a.menu-top,
+#adminmenu .wp-submenu-head {
+	font-family: Tahoma, Arial, sans-serif;
+}
+#adminmenu img.wp-menu-image {
+	float: right;
+}
+.folded #adminmenu img.wp-menu-image {
+	padding: 7px 6px 0 0;
+}
+#adminmenu a.separator {
+	cursor: e-resize;
+}
+.folded #adminmenu a.separator {
+ 	cursor: w-resize;
+}
+#adminmenu .wp-submenu .wp-submenu-head {
+	padding: 6px 10px 6px 4px;
+}
+.folded #adminmenu .wp-submenu {
+	margin: -1px 28px 0 0;
+}
+.folded #adminmenu .wp-submenu a {
+	padding-left: 0;
+	padding-right: 10px;
+}
+.folded #adminmenu a.wp-has-submenu {
+	margin-left: 0;
+	margin-right: 40px;
+}
+#adminmenu .wp-menu-toggle {
+	float: left;
+	padding: 1px 0 0 2px;
+	clear: left;
+}
+#adminmenu div.wp-menu-image {
+	float: right;
+}
+#wphead-info {
+	margin: 0 15px 0 0;
+	padding-right:0;
+	padding-left: 15px;
+}
+/* end side admin menu */
+/* 1000 - 1300
+=================================== */
+#adminmenu #awaiting-mod,
+#adminmenu span.update-plugins,
+#sidemenu li a span.update-plugins {
+	font-family: Tahoma, Arial, sans-serif;
+	margin-left: 0;
+	margin-right: 7px;
+}
+.post-com-count-wrapper {
+	font-family: Tahoma, Arial, sans-serif;
+}
+.column-response .post-com-count {
+	float: right;
+	margin-right: 0;
+	margin-left: 5px;
+}
+/* Tables used on comment.php and option/setting pages */
+.form-table th {
+	text-align: right;
+}
+.form-table input.tog {
+	margin-right: 0;
+	margin-left: 2px;
+	float: right;
+}
+.form-table table.color-palette {
+	float: right;
+}
+#profile-page .form-table #rich_editing {
+	margin-right: 0;
+	margin-left: 5px;
+}
+/* Post Screen */
+/* 1300 - 1500
+=================================== */
+#normal-sortables .postbox .submit {
+	float: left;
+}
+#post-body .tagsdiv #newtag {
+	margin-right: 0;
+	margin-left: 5px;
+}
+#post-status-info {
+	padding: 0 7px 0 15px;
+}
+#comment-status-radio input {
+	margin: 2px 0 5px 3px;
+}
+.tagchecklist {
+	margin-left: 0;
+	margin-right: 10px;
+}
+.tagchecklist strong {
+	margin-left: 0;
+	margin-right: -8px;
+}
+.tagchecklist span {
+	float: right;
+}
+.tagchecklist span a {
+	margin: 6px -9px 0 0;
+	float: right;
+}
+.ac_results li {
+	text-align: right;
+}
+#poststuff h2 {
+	clear: right;
+}
+.description, .form-wrap p {
+	font-family: Tahoma, Arial, sans-serif;
+}
+.sorting-indicator {
+	margin-left: 0;
+	margin-right: 7px;
+}
+th.sortable a span,
+th.sorted a span {
+	float: right;
+}
+.fixed .column-comments a {
+	float: right;
+}
+
+/* 1500 - 1800
+=================================== */
+.autosave-info {
+	padding: 2px 2px 2px 15px;
+	text-align: left;
+}
+.meta-box-sortables .postbox .handlediv {
+	float: left;
+}
+.howto {
+	font-family: Tahoma, Arial, sans-serif;
+}
+.postarea h3 label {
+	float: right;
+}
+.postarea #add-media-button {
+	float: left;
+	right: auto;
+	left: 10px;
+}
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+	background-position: right top;
+}
+#poststuff #edButtonPreview,
+#poststuff #edButtonHTML {
+	margin: 5px 0 0 5px;
+	float: left;
+}
+#poststuff #edButtonHTML {
+	margin-right: 0;
+	margin-left: 15px;
+}
+#media-buttons a {
+	padding: 0 10px 5px 0;
+}
+.submitbox .submit {
+	text-align: right;
+}
+
+.inside-submitbox #post_status {
+	margin: 2px -2px 2px 0;
+}
+.submitbox .submit input {
+	margin-right: 0;
+	margin-left: 4px;
+}
+/* Categories */
+.category-adder {
+	margin-left: 0;
+	margin-right: 120px;
+}
+#post-body ul.category-tabs li.tabs,
+#post-body ul.add-menu-item-tabs li.tabs {
+	-moz-border-radius: 0 3px 3px 0;
+	-webkit-border-top-left-radius: 0;
+	-webkit-border-top-right-radius: 3px;
+	-webkit-border-bottom-left-radius: 0;
+	-webkit-border-bottom-right-radius: 3px;
+	border-top-left-radius: 0;
+	border-top-right-radius: 3px;
+	border-bottom-left-radius: 0;
+	border-bottom-right-radius: 3px;
+}
+#post-body ul.category-tabs,
+#post-body ul.add-menu-item-tabs {
+	float: right;
+	text-align: left;
+	margin: 0 0 0 -120px;
+}
+#post-body .categorydiv div.tabs-panel,
+#post-body .taxonomy div.tabs-panel,
+#post-body #linkcategorydiv div.tabs-panel {
+	margin: 0 120px 0 5px;
+}
+/* 1800 - 2000
+=================================== */
+#front-page-warning,
+#front-static-pages ul,
+.inline-editor ul.cat-checklist ul,
+.categorydiv ul.categorychecklist ul,
+.customlinkdiv ul.categorychecklist ul,
+.posttypediv ul.categorychecklist ul,
+.taxonomydiv ul.categorychecklist ul,
+#linkcategorydiv ul.categorychecklist ul{
+	margin-left: 0;
+	margin-right: 18px;
+}
+/* positioning etc. */
+p.search-box {
+	float: left;
+}
+#posts-filter fieldset {
+	float: right;
+	margin: 0 0 1em 1.5ex;
+}
+#posts-filter fieldset legend {
+	padding: 0 1px .2em 0;
+}
+.view-switch {
+	float: left;
+}
+.filter {
+	float: right;
+	margin: -5px 10px 0 0;
+}
+#the-comment-list td.comment p.comment-author {
+	margin-right: 0;
+}
+#the-comment-list p.comment-author img {
+	float: right;
+	margin-right: 0;
+	margin-left: 8px;
+}
+.tablenav .delete {
+	margin-right: 0;
+	margin-left: 20px;
+}
+td.action-links, th.action-links {
+	text-align: left;
+}
+/* 2000 - 2300
+=================================== */
+.filter .subsubsub {
+	margin-left: 0;
+	margin-right: -10px;
+}
+#wp-word-count {
+	margin-right: 10px;
+}
+.tool-box .title {
+	font-family: Tahoma, Arial, sans-serif;
+}
+.settings-toggle {
+	text-align: left;
+	margin: 5px 0 15px 7px;
+}
+.curtime #timestamp {
+	background-position: right top;
+	padding-left: 0;
+	padding-right: 18px;
+}
+/* media popup 0819 */
+#sidemenu {
+	margin: -30px 315px 0 15px;
+	float: left;
+	padding-left: 0;
+	padding-right: 10px;
+}
+#sidemenu a {
+	float: right;
+}
+#replysubmit .button {
+	margin-right: 0;
+	margin-left: 5px;
+}
+/* 2300 - 2500
+=================================== */
+#edithead .inside {
+	float: right;
+	margin: 3px 5px 2px 0;
+}
+#replyrow #ed_reply_toolbar input {
+	margin: 1px 1px 1px 2px;
+}
+/* show/hide settings */
+#screen-meta-links {
+	margin: 0 0 0 18px;
+}
+#screen-options-link-wrap,
+#contextual-help-link-wrap {
+	float: left;
+	font-family: Tahoma, Arial, sans-serif;
+	margin: 0 0 0 6px;
+}
+#contextual-help-wrap li {
+	margin-left: 0;
+	margin-right: 18px;
+}
+#screen-meta a.show-settings {
+	padding: 0 6px 0 16px;
+	background-position: left top;
+}
+.metabox-prefs label {
+	padding-right: 0;
+	padding-left: 15px;
+}
+.metabox-prefs label input {
+	margin: 0 2px 0 5px;
+}
+.inline-editor .save,
+.inline-editor .cancel {
+	margin-right: 0;
+	margin-left: 5px;
+}
+#replysubmit img.waiting,
+.inline-edit-save img.waiting {
+	float: left;
+}
+.trash-undo-inside,
+.spam-undo-inside,
+.spam-undo-inside .avatar,
+.trash-undo-inside .avatar {
+	margin-right: 0;
+	margin-left: 8px;
+}
+/* 2500 - 2700
+=================================== */
+#bulk-titles div a {
+	float: right;
+	margin: 3px -2px 0 3px;
+}
+#wpbody-content .filename {
+	margin-left: 0;
+	margin-right: 10px;
+}
+#wpbody-content .inline-edit-row fieldset {
+	float: right;
+}
+#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col {
+	border-left: 0 none;
+	border-right: 1px solid;
+}
+#wpbody-content .bulk-edit-row .inline-edit-col-bottom {
+	float: left;
+}
+.inline-edit-row fieldset label span.title {
+	float: right;
+}
+.inline-edit-row fieldset label span.input-text-wrap {
+	margin-left: 0;
+	margin-right: 5em;
+}
+.quick-edit-row-post fieldset.inline-edit-col-right label span.title {
+	padding-right: 0;
+	padding-left: 0.5em;
+}
+#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child {
+	margin-right: 0;
+	margin-left: 0.5em;
+}
+/* 2700 - 3000
+=================================== */
+.inline-edit-row fieldset span.title,
+.inline-edit-row fieldset span.checkbox-title {
+	font-family: Tahoma, Arial, sans-serif;
+}
+.inline-edit-row fieldset .inline-edit-date {
+	float: right;
+}
+.inline-edit-row fieldset ul.cat-checklist label,
+.inline-edit-row .catshow,
+.inline-edit-row .cathide,
+.inline-edit-row #bulk-titles div {
+	font-family: Tahoma, Arial, sans-serif;
+}
+.quick-edit-row-post fieldset label.inline-edit-status {
+	float: right;
+}
+.describe-toggle-on, .describe-toggle-off {
+	float: left;
+	margin-right: 0;
+	margin-left: 20px;
+}
+#wpbody-content #media-items .filename {
+	float: right;
+	margin-left: 0;
+	margin-right: 10px;
+}
+.media-item .pinkynail {
+	float: right;
+}
+#find-posts-response .found-radio {
+	padding: 8px 8px 0 0;
+}
+.find-box-buttons {
+	left: auto;
+	right: 12px;
+}
+.find-box-search label {
+	padding-right: 0;
+	padding-left: 6px;
+}
+/* favorite-actions */
+#favorite-actions {
+	float: left;
+}
+#favorite-first {
+	padding: 3px 12px 4px 30px;
+}
+#favorite-inside {
+}
+#favorite-inside a {
+	padding: 3px 10px 3px 5px;
+}
+#favorite-toggle {
+	right: auto;
+	left: 0;
+	background:transparent url(../images/fav-arrow-rtl.gif?ver=20100531) no-repeat 10px -4px;
+}
+#utc-time, #local-time {
+	padding-left: 0;
+	padding-right: 25px;
+	font-family: Tahoma, Arial;
+}
+.icon32 {
+	float: right;
+	margin: 14px 0 0 6px;
+}
+.subtitle {
+	padding-left: 0;
+	padding-right: 25px;
+}
+
+ol {
+	list-style-type:decimal;
+	margin-left:0;
+	margin-right:2em;
+}
+
+.postbox-container {
+	float: right;
+	padding-left: 0.5%;
+	padding-right: 0;
+}
+
+/* Media library */
+#wpbody-content .describe th {
+	text-align: right;
+}
+
+.describe .media-item-info .A1B1 {
+	padding: 0 10px 0 0;
+}
+
+.media-upload-form td label {
+	margin-left: 6px;
+	margin-right: 2px;
+}
+
+.media-upload-form .align .field label {
+	padding: 0 22px 0 0;
+	margin: 0 0 0 1em;
+}
+
+.media-upload-form tr.image-size label {
+	margin: 0 3px 0 0 ;
+}
+
+#wpbody-content .describe p.help {
+	padding: 0 5px 0 0 ;
+}
+
+.media-item .error-div a.dismiss,
+.describe-toggle-on,
+.describe-toggle-off {
+	float: left;
+	margin-right: 0;
+	margin-left: 20px;
+}
+
+.describe-toggle-on,
+.describe-toggle-off {
+	float: left;
+	margin-left: 20px;
+	margin-right: 0;
+}
+
+.media-item .error-div {
+	padding-left: 0;
+	padding-right: 10px;
+}
+
+.media-item .pinkynail {
+	float: right;
+}
+
+.crunching {
+	text-align: left;
+	margin-left: 5px;
+	margin-right: 0;
+}
+
+.bar {
+	border-left-width: 3px;
+	border-left-style: solid;
+	border-right: none;
+}
+
+
+/* TinyMCE
+=================================== */
+.clearlooks2 .mceTop .mceLeft {
+	width:100% !important;
+}
+
+/* tag hints */
+.taghint {
+	margin: 15px 12px -24px 0;
+}
+
+#poststuff .tagsdiv .howto {
+	margin: 0 8px 6px 0;
+}
+
+#broken-themes {
+	text-align: right;
+}
+
+.describe .del-link {
+	padding-right: 5px;
+	padding-left: 0;
+}
+
+.comment-ays th {
+	border-left-style: solid;
+	border-left-width: 1px;
+}
+
+/* Custom Header */
+.appearance_page_custom-header #available-headers .default-header {
+	float: right;
+	margin: 0 0 20px 20px;
+}
+.appearance_page_custom-header #available-headers label input {
+	margin-right: 0;
+	margin-left: 10px;
+}
+
+#custom-background label {
+	padding-right: 0;
+	padding-left: 15px;
+}
+
+/* ltr
+=================================== */
+#author-email, #author-url, #rss-url-1, #edit-slug-box, #post_name, #trackback_url, #metakeyinput, #post_password, #slug, #category_nicename, #link_url, #link_image, #rss_uri, #menu_order, #email, #newcomment_author_url, #pages-exclude, #template textarea, #user_login, #url, #pass1, #pass2, #aim, #yim, #jabber, #siteurl, #home, #admin_email, #gmt_offset, #default_post_edit_rows, #mailserver_url, #mailserver_login, #mailserver_pass, #mailserver_port, #ping_sites, #posts_per_page, #posts_per_rss, #blog_charset, #close_comments_days_old, #comments_per_page, #comment_max_links, #moderation_keys, #blacklist_keys, #thumbnail_size_w, #thumbnail_size_h, #medium_size_w, #medium_size_h, #large_size_w, #large_size_h, #permalink_structure, #category_base, #tag_base, #upload_path, #upload_url_path, #rules {
+	direction: ltr;
+}
+
+/* no italic
+=================================== */
+
+#quicktags #ed_em, #ed_reply_toolbar #ed_reply_em, .tablenav .displaying-num, #footer, #footer a, p.help, p.description, span.description, .form-wrap p, #side-sortables .comments-box thead th,
+#normal-sortables .comments-box thead th, .howto, .inline-edit-row fieldset span.title, .inline-edit-row fieldset span.checkbox-title, #utc-time, #local-time, form.upgrade .hint, p.install-help, .imgedit-help  {
+	font-style: normal;
+}
Index: /tags/3.1/wp-admin/css/wp-admin.css
===================================================================
--- /tags/3.1/wp-admin/css/wp-admin.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/wp-admin.css	(revision 17487)
@@ -0,0 +1,1 @@
+p,ul,ol,blockquote,input,select{font-size:12px;}ol{list-style-type:decimal;margin-left:2em;}.code,code{font-family:Consolas,Monaco,Courier,monospace;}kbd,code{padding:1px 3px;margin:0 1px;font-size:11px;}.quicktags,.search{font:12px Georgia,"Times New Roman","Bitstream Charter",Times,serif;}.icon32{float:left;height:36px;margin:14px 6px 0 0;width:36px;}.key-labels label{line-height:24px;}.subtitle{font-size:.75em;line-height:1;padding-left:25px;}.pre{white-space:pre-wrap;white-space:-moz-pre-wrap!important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;}.howto{font-style:italic;display:block;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;}p.install-help{margin:8px 0;font-style:italic;}textarea,input[type="text"],input[type="password"],input[type="file"],input[type="button"],input[type="submit"],input[type="reset"],select{border-width:1px;border-style:solid;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;}select option{padding:2px;}.submit{padding:1.5em 0;margin:5px 0;-moz-border-radius:0 0 3px 3px;-webkit-border-bottom-left-radius:3px;-webkit-border-bottom-right-radius:3px;-khtml-border-bottom-left-radius:3px;-khtml-border-bottom-right-radius:3px;border-bottom-left-radius:3px;border-bottom-right-radius:3px;}form p.submit a.cancel:hover{text-decoration:none;}.submit input,.button,input.button,.button-primary,input.button-primary,.button-secondary,input.button-secondary,.button-highlighted,input.button-highlighted,#postcustomstuff .submit input{text-decoration:none;font-size:11px!important;line-height:13px;padding:3px 8px;cursor:pointer;border-width:1px;border-style:solid;-moz-border-radius:11px;-khtml-border-radius:11px;-webkit-border-radius:11px;border-radius:11px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;-khtml-box-sizing:content-box;box-sizing:content-box;}#minor-publishing-actions input,#major-publishing-actions input,#minor-publishing-actions .preview{min-width:80px;text-align:center;}textarea.all-options,input.all-options{width:250px;}input.large-text,textarea.large-text{width:99%;}input.regular-text,#adduser .form-field input{width:25em;}input.small-text{width:50px;}#doaction,#doaction2,#post-query-submit{margin-right:8px;}.tablenav select[name="action"],.tablenav select[name="action2"]{width:130px;}.tablenav select[name="m"]{width:155px;}.tablenav select#cat{width:170px;}#wpcontent select{padding:2px;height:2em;font-size:11px;}#wpcontent option{padding:2px;}#timezone_string option{margin-left:1em;}label,#your-profile label+a{vertical-align:middle;}#misc-publishing-actions label{vertical-align:baseline;}#pass-strength-result{border-style:solid;border-width:1px;float:left;margin:12px 5px 5px 1px;padding:3px 5px;text-align:center;width:200px;display:none;}.indicator-hint{padding-top:8px;}p.search-box{float:right;margin:-5px 0 0;}#major-publishing-actions{padding:6px;clear:both;border-top:none;}#delete-action{line-height:25px;vertical-align:middle;text-align:left;float:left;}#publishing-action{text-align:right;float:right;line-height:23px;}#post-body #minor-publishing{padding-bottom:10px;}#post-body #misc-publishing-actions{padding:0;}#post-body .misc-pub-section{border-right-width:1px;border-right-style:solid;border-bottom:0 none;min-height:30px;float:left;max-width:32%;}#post-body .misc-pub-section-last{border-right:0;}#misc-publishing-actions{padding:6px 0 16px 0;}.misc-pub-section{padding:6px;border-bottom-width:1px;border-bottom-style:solid;}.misc-pub-section-last{border-bottom:0 none;}#minor-publishing-actions{padding:6px;text-align:right;}#minor-publishing{border-bottom-width:1px;border-bottom-style:solid;}#save-post{float:left;}#minor-publishing .ajax-loading{padding:3px 0 0 4px;float:left;}.preview{float:right;}#sticky-span{margin-left:18px;}#post-status-display,#post-visibility-display{font-weight:bold;}.side-info{margin:0;padding:4px;font-size:11px;}.side-info h5{padding-bottom:7px;font-size:14px;margin:12px 2px 5px;border-bottom-width:1px;border-bottom-style:solid;}.side-info ul{margin:0;padding-left:18px;list-style:square;}a.button,a.button-primary,a.button-secondary{line-height:15px;padding:3px 10px;white-space:nowrap;-webkit-border-radius:10px;}.approve{display:none;}.unapproved .approve,.spam .approve,.trash .approve{display:inline;}.unapproved .unapprove{display:none;}.add-new-h2{font-style:normal;margin:0 6px;position:relative;top:-3px;}td.action-links,th.action-links{text-align:right;}.describe .del-link{padding-left:5px;}#update-nag,.update-nag{line-height:19px;padding:5px 0;font-size:12px;text-align:center;margin:0 15px;border-width:1px;border-style:solid;border-top-width:0;border-top-style:none;-moz-border-radius:0 0 6px 6px;-webkit-border-bottom-right-radius:6px;-webkit-border-bottom-left-radius:6px;-khtml-border-bottom-right-radius:6px;-khtml-border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-bottom-left-radius:6px;}.plugins .plugin-update{padding:0;}.plugin-update .update-message{margin:0 10px 8px 31px;font-weight:bold;}ul#dismissed-updates{display:none;}form.upgrade{margin-top:8px;}form.upgrade .hint{font-style:italic;font-size:85%;margin:-0.5em 0 2em 0;}.ajax-feedback{visibility:hidden;vertical-align:bottom;}#ajax-response.alignleft{margin-left:2em;}#editorcontainer #content{padding:6px;line-height:150%;border:0 none;outline:none;resize:vertical;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-khtml-box-sizing:border-box;box-sizing:border-box;}#editorcontainer,#quicktags{border-style:solid;border-width:1px;border-collapse:separate;-moz-border-radius:6px 6px 0 0;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:6px;-khtml-border-top-right-radius:6px;-khtml-border-top-left-radius:6px;border-top-right-radius:6px;border-top-left-radius:6px;}#quicktags{padding:0;margin-bottom:-3px;border-bottom-width:3px;background-image:url("../images/ed-bg.gif");background-position:left top;background-repeat:repeat-x;}#quicktags #ed_toolbar{padding:2px 4px 0;}#ed_toolbar input,#ed_reply_toolbar input{margin:3px 1px 4px;line-height:18px;display:inline-block;min-width:26px;padding:2px 4px;font-size:12px;}#ed_reply_toolbar input{margin:1px 2px 1px 1px;}#quicktags #ed_link,#ed_reply_toolbar #ed_reply_link{text-decoration:underline;}#quicktags #ed_del,#ed_reply_toolbar #ed_reply_del{text-decoration:line-through;}#quicktags #ed_em,#ed_reply_toolbar #ed_reply_em{font-style:italic;}#wp_editbtns,#wp_gallerybtns{padding:2px;position:absolute;display:none;z-index:999998;}#wp_editimgbtn,#wp_delimgbtn,#wp_editgallery,#wp_delgallery{margin:2px;padding:2px;border-width:1px;border-style:solid;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;}#wphead-info{margin:0 0 0 15px;padding-right:15px;}#user_info{float:right;font-size:12px;line-height:46px;height:46px;}#user_info p{margin:0;padding:0;line-height:46px;}#wphead{height:46px;}#wphead a,#adminmenu a,#sidemenu a,#taglist a,#catlist a,#show-settings a{text-decoration:none;}#header-logo{float:left;margin:7px 0 0 15px;}#wphead h1{font:normal 22px Georgia,"Times New Roman","Bitstream Charter",Times,serif;padding:10px 8px 5px;margin:0;float:left;}#wphead h1.long-title{font:normal 18px Georgia,"Times New Roman","Bitstream Charter",Times,serif;padding:12px 10px 5px;}#wphead #privacy-on-link{font-size:50%;font-style:normal;line-height:17px;padding:0 6px;vertical-align:middle;}#wphead h1 a:hover{text-decoration:none;}#wphead h1 a:hover #site-title,#wphead h1 a#privacy-on-link:hover{text-decoration:underline;}#favorite-actions{float:right;margin:11px 12px 0;min-width:130px;position:relative;}#favorite-first{-moz-border-radius:12px;-khtml-border-radius:12px;-webkit-border-radius:12px;border-radius:12px;line-height:15px;padding:3px 30px 4px 12px;border-width:1px;border-style:solid;}#favorite-inside{margin:0;padding:2px 1px;border-width:1px;border-style:solid;position:absolute;z-index:11;display:none;-moz-border-radius:0 0 12px 12px;-webkit-border-bottom-right-radius:12px;-webkit-border-bottom-left-radius:12px;-khtml-border-bottom-right-radius:12px;-khtml-border-bottom-left-radius:12px;border-bottom-right-radius:12px;border-bottom-left-radius:12px;}#favorite-actions a{display:block;text-decoration:none;font-size:11px;}#favorite-inside a{padding:3px 5px 3px 10px;}#favorite-toggle{height:22px;position:absolute;right:0;top:1px;width:28px;}#favorite-actions .slide-down{-moz-border-radius:12px 12px 0 0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:0;-khtml-border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-bottom:none;}#screen-meta{position:relative;clear:both;}#screen-meta-links{margin:0 18px 0 0;}#screen-meta .screen-reader-text{visibility:hidden;}#screen-options-link-wrap,#contextual-help-link-wrap{float:right;height:22px;padding:0;margin:0 6px 0 0;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;background:#e3e3e3;-moz-border-radius-bottomleft:3px;-moz-border-radius-bottomright:3px;-webkit-border-bottom-left-radius:3px;-webkit-border-bottom-right-radius:3px;}#contextual-help-wrap li{list-style-type:disc;margin-left:18px;}.toggle-arrow{background-repeat:no-repeat;background-position:top left;background-color:transparent;height:22px;line-height:22px;display:block;}.toggle-arrow-active{background-position:bottom left;}#screen-meta a.show-settings{text-decoration:none;z-index:1;padding:0 16px 0 6px;height:22px;line-height:22px;font-size:10px;display:block;background-repeat:no-repeat;background-position:top right;background-color:transparent;text-shadow:rgba(255,255,255,0.7) 0 1px 0;}#screen-meta a.show-settings:hover{text-decoration:none;}#screen-options-wrap h5,#contextual-help-wrap h5{margin:8px 0;font-size:13px;}#screen-options-wrap,#contextual-help-wrap{border-style:none solid solid;border-top:0 none;border-width:0 1px 1px;margin:0 15px;padding:8px 12px 12px;-moz-border-radius:0 0 4px 4px;-webkit-border-radius:0 0 4px 4px;-khtml-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;}.metabox-prefs label{display:inline-block;padding-right:15px;white-space:nowrap;line-height:30px;}.metabox-prefs label input{margin:0 5px 0 2px;}.metabox-prefs label a{display:none;}#adminmenu *{-webkit-user-select:none;-moz-user-select:none;-khtml-user-select:none;user-select:none;}#adminmenu .wp-submenu{display:none;list-style:none;padding:0;margin:0;position:relative;z-index:2;border-width:1px 0 0;border-style:solid none none;}#adminmenu .wp-submenu a{font:normal 11px/18px "Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;}#adminmenu .wp-submenu li.current,#adminmenu .wp-submenu li.current a,#adminmenu .wp-submenu li.current a:hover{font-weight:bold;}#adminmenu a.menu-top,#adminmenu .wp-submenu-head{font:normal 13px/18px Georgia,"Times New Roman","Bitstream Charter",Times,serif;}#adminmenu div.wp-submenu-head{display:none;}.folded #adminmenu div.wp-submenu-head,.folded #adminmenu li.wp-has-submenu div.sub-open{display:block;}.folded #adminmenu a.menu-top,.folded #adminmenu .wp-submenu,.folded #adminmenu li.wp-menu-open .wp-submenu,.folded #adminmenu div.wp-menu-toggle{display:none;}#adminmenu li.wp-menu-open .wp-submenu,.no-js #adminmenu .open-if-no-js .wp-submenu{display:block;}#adminmenu div.wp-menu-image{float:left;width:28px;height:28px;}#adminmenu li{margin:0;padding:0;cursor:pointer;}#adminmenu a{display:block;line-height:18px;padding:1px 5px 3px;}#adminmenu li.menu-top{min-height:26px;}#adminmenu a.menu-top{line-height:18px;min-width:10em;padding:5px 5px;border-width:1px 1px 0;border-style:solid solid none;}#adminmenu .wp-submenu a{margin:0;padding-left:12px;border-width:0 1px 0 0;border-style:none solid none none;}#adminmenu .menu-top-last ul.wp-submenu{border-width:0 0 1px;border-style:none none solid;}#adminmenu .wp-submenu li{padding:0;margin:0;}.folded #adminmenu li.menu-top{width:28px;height:30px;overflow:hidden;border-width:1px 1px 0;border-style:solid solid none;}#adminmenu .menu-top-first a.menu-top,.folded #adminmenu li.menu-top-first,#adminmenu .wp-submenu .wp-submenu-head{border-width:1px 1px 0;border-style:solid solid none;-moz-border-radius-topleft:6px;-moz-border-radius-topright:6px;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:6px;-khtml-border-top-right-radius:6px;-khtml-border-top-left-radius:6px;border-top-right-radius:6px;border-top-left-radius:6px;}#adminmenu .menu-top-last a.menu-top,.folded #adminmenu li.menu-top-last{border-width:1px;border-style:solid;-moz-border-radius-bottomleft:6px;-moz-border-radius-bottomright:6px;-webkit-border-bottom-right-radius:6px;-webkit-border-bottom-left-radius:6px;-khtml-border-bottom-right-radius:6px;-khtml-border-bottom-left-radius:6px;border-bottom-right-radius:6px;border-bottom-left-radius:6px;}#adminmenu li.wp-menu-open a.menu-top-last{border-bottom:0 none;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:0;-khtml-border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;}#adminmenu .wp-menu-image img{float:left;padding:8px 6px 0;opacity:.6;filter:alpha(opacity=60);}#adminmenu li.menu-top:hover .wp-menu-image img,#adminmenu li.wp-has-current-submenu .wp-menu-image img{opacity:1;filter:alpha(opacity=100);}#adminmenu li.wp-menu-separator{height:21px;padding:0;margin:0;}#adminmenu a.separator{cursor:w-resize;height:20px;padding:0;}.folded #adminmenu a.separator{cursor:e-resize;}#adminmenu .wp-menu-separator-last{height:10px;width:1px;}#adminmenu .wp-submenu .wp-submenu-head{border-width:1px;border-style:solid;padding:6px 4px 6px 10px;cursor:default;}.folded #adminmenu .wp-submenu{position:absolute;margin:-1px 0 0 28px;padding:0 8px 8px;z-index:999;border:0 none;}.folded #adminmenu .wp-submenu ul{width:140px;border-width:0 0 1px;border-style:none none solid;}.folded #adminmenu .wp-submenu li.wp-first-item{border-top:0 none;}.folded #adminmenu .wp-submenu a{padding-left:10px;}.folded #adminmenu a.wp-has-submenu{margin-left:40px;}#adminmenu li.menu-top-last .wp-submenu ul{border-width:0 0 1px;border-style:none none solid;}#adminmenu .wp-menu-toggle{width:22px;clear:right;float:right;margin:1px 0 0;height:27px;padding:1px 2px 0 0;cursor:default;}#adminmenu li.wp-has-current-submenu ul{border-bottom-width:1px;border-bottom-style:solid;}#adminmenu .wp-menu-image a{height:24px;}#adminmenu .wp-menu-image img{padding:6px 0 0 1px;}#adminmenu #awaiting-mod,#adminmenu span.update-plugins,#sidemenu li a span.update-plugins{position:absolute;font-family:Helvetica,Arial,sans-serif;font-size:9px;line-height:17px;font-weight:bold;margin-top:1px;margin-left:7px;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}#adminmenu li #awaiting-mod span,#adminmenu li span.update-plugins span,#sidemenu li a span.update-plugins span{display:block;padding:0 6px;}#adminmenu li span.count-0,#sidemenu li a .count-0{display:none;}.post-com-count-wrapper{min-width:22px;font-family:Helvetica,Arial,sans-serif;}.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;}.post-com-count span{font-size:9px;font-weight:bold;height:1.7em;line-height:1.70em;min-width:.7em;padding:0 6px;display:inline-block;cursor:pointer;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;}strong .post-com-count{background-position:center -55px;}.post-com-count:hover{background-position:center -3px;}.column-response .post-com-count{float:left;margin-right:5px;text-align:center;}.response-links{float:left;}#the-comment-list .attachment-80x60{padding:4px 8px;}body.wp-admin{min-width:785px;}body.admin-bar #wphead{padding-top:28px;}.narrow{width:70%;margin-bottom:40px;}.narrow p{line-height:150%;}.widefat th,.widefat td{overflow:hidden;}.widefat td p{margin:2px 0 .8em;}.widefat .column-comment p{margin:.6em 0;}.widget .widget-top,.postbox h3{cursor:move;-webkit-user-select:none;-moz-user-select:none;-khtml-user-select:none;user-select:none;}.postbox-container{float:left;padding-right:.5%;}.postbox-container .meta-box-sortables{min-height:300px;}.postbox .hndle span{padding:6px 0;}.postbox .hndle{cursor:move;}.hndle a{font-size:11px;font-weight:normal;}.postbox .handlediv{float:right;width:23px;height:26px;}.sortable-placeholder{border-width:1px;border-style:dashed;margin-bottom:20px;}.widget,.postbox,.stuffbox{margin-bottom:20px;border-width:1px;border-style:solid;line-height:1;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}.widget .widget-top,.postbox h3,.postbox h3,.stuffbox h3{-moz-border-radius:6px 6px 0 0;-webkit-border-top-right-radius:6px;-webkit-border-top-left-radius:6px;-khtml-border-top-right-radius:6px;-khtml-border-top-left-radius:6px;border-top-right-radius:6px;border-top-left-radius:6px;}.postbox.closed h3{-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;-khtml-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;-khtml-border-bottom-right-radius:4px;border-bottom-right-radius:4px;}.postbox table.form-table{margin-bottom:0;}.postbox input[type="text"],.postbox textarea,.stuffbox input[type="text"],.stuffbox textarea{border-width:1px;border-style:solid;}.temp-border{border:1px dotted #ccc;}.columns-prefs label{padding:0 5px;}#wpbody-content .metabox-holder{padding-top:10px;}#dashboard-widgets .meta-box-sortables{margin:0 5px;}#dashboard_recent_comments div.undo{border-top-style:solid;border-top-width:1px;margin:0 -10px;padding:3px 8px;font-size:11px;}#the-comment-list td.comment p.comment-author{margin-top:0;margin-left:0;}#the-comment-list p.comment-author img{float:left;margin-right:8px;}#the-comment-list p.comment-author strong a{border:none;}#the-comment-list td{vertical-align:top;}#the-comment-list td.comment{word-wrap:break-word;}#the-comment-list .check-column{padding-top:8px;}table.fixed{table-layout:fixed;}.fixed .column-rating,.fixed .column-visible{width:8%;}.fixed .column-date,.fixed .column-parent,.fixed .column-links{width:10%;}.fixed .column-response,.fixed .column-author,.fixed .column-categories,.fixed .column-tags,.fixed .column-rel,.fixed .column-role{width:15%;}.fixed .column-comments{width:4em;padding:8px 0;text-align:left;}.fixed .column-comments .vers{padding-left:3px;}.fixed .column-comments a{float:left;}.fixed .column-slug{width:25%;}.fixed .column-posts{width:10%;}.fixed .column-icon{width:80px;}#commentsdiv .fixed .column-author,#comments-form .fixed .column-author{width:20%;}#commentsdiv.postbox .inside{line-height:1.4em;margin:0;}#commentsdiv.postbox .inside .row-actions{line-height:18px;}#commentsdiv.postbox .inside td{padding:1em 10px;}#commentsdiv.postbox .inside .column-author{width:33%;}#commentsdiv.postbox .inside p{margin:6px 10px 8px;}#commentsdiv.postbox .column-comment p{margin:.6em 0;}#commentsdiv.postbox #replyrow td{padding:0;}.sorting-indicator{display:none;width:7px;height:4px;margin-top:5px;margin-left:7px;background-image:url(../images/sort.gif);background-repeat:no-repeat;}.fixed .column-comments .sorting-indicator{margin-top:3px;}.widefat th.sortable,.widefat th.sorted{padding:0;}th.sortable a,th.sorted a{display:block;overflow:hidden;padding:7px 7px 8px;}.fixed .column-comments.sortable a,.fixed .column-comments.sorted a{padding:8px 0;}th.sortable a span,th.sorted a span{float:left;cursor:pointer;}th.sorted.asc .sorting-indicator,th.desc:hover span.sorting-indicator{display:block;background-position:0 0;}th.sorted.desc .sorting-indicator,th.asc:hover span.sorting-indicator{display:block;background-position:-7px 0;}.tablenav-pages a{border-bottom-style:solid;border-bottom-width:2px;font-weight:bold;margin-right:1px;padding:0 2px;}.tablenav-pages .current-page{text-align:center;}.tablenav-pages .next-page{margin-left:2px;}.tablenav a.button-secondary{display:block;margin:3px 8px 0 0;}.tablenav{clear:both;height:30px;margin:6px 0 4px;vertical-align:middle;}.tablenav .tablenav-pages{float:right;display:block;cursor:default;height:30px;line-height:30px;font-size:11px;}.tablenav .one-page{display:none;}.tablenav .tablenav-pages a,.tablenav-pages span.current{text-decoration:none;border:none;padding:3px 6px;border-width:1px;border-style:solid;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;}.tablenav .tablenav-pages a.disabled:hover{cursor:default;}.tablenav .tablenav-pages a.disabled:active{cursor:default;}.tablenav .displaying-num{margin-right:10px;font-size:12px;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-style:italic;}.tablenav .actions{padding:2px 8px 0 0;}.tablenav .delete{margin-right:20px;}.view-switch{float:right;margin:6px 8px 0;}.view-switch a{text-decoration:none;}.filter{float:left;margin:-5px 0 0 10px;}.filter .subsubsub{margin-left:-10px;margin-top:13px;}.screen-per-page{width:3em;}#posts-filter fieldset{float:left;margin:0 1.5ex 1em 0;padding:0;}#posts-filter fieldset legend{padding:0 0 .2em 1px;}span.post-state-format{font-weight:normal;}tr.inline-edit-row td{padding:0 .5em;}#wpbody-content .inline-edit-row fieldset{font-size:12px;float:left;margin:0;padding:0;width:100%;}#wpbody-content .inline-edit-row fieldset .inline-edit-col{padding:0 .5em;}#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col{border-width:0 0 0 1px;border-style:none none none solid;}#wpbody-content .quick-edit-row-post .inline-edit-col-left{width:40%;}#wpbody-content .quick-edit-row-post .inline-edit-col-right{width:39%;}#wpbody-content .inline-edit-row-post .inline-edit-col-center{width:20%;}#wpbody-content .quick-edit-row-page .inline-edit-col-left{width:50%;}#wpbody-content .quick-edit-row-page .inline-edit-col-right,#wpbody-content .bulk-edit-row-post .inline-edit-col-right{width:49%;}#wpbody-content .bulk-edit-row .inline-edit-col-left{width:30%;}#wpbody-content .bulk-edit-row-page .inline-edit-col-right{width:69%;}#wpbody-content .bulk-edit-row .inline-edit-col-bottom{float:right;width:69%;}#wpbody-content .inline-edit-row-page .inline-edit-col-right,#wpbody-content .bulk-edit-row-post .inline-edit-col-right{margin-top:27px;}.inline-edit-row fieldset .inline-edit-group{clear:both;}.inline-edit-row fieldset .inline-edit-group:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.inline-edit-row p.submit{clear:both;padding:.5em;margin:.5em 0 0;}.inline-edit-row span.error{line-height:22px;margin:0 15px;padding:3px 5px;}.inline-edit-row h4{margin:.2em 0;padding:0;line-height:23px;}.inline-edit-row fieldset span.title,.inline-edit-row fieldset span.checkbox-title{margin:0;padding:0;line-height:27px;}.inline-edit-row fieldset label,.inline-edit-row fieldset span.inline-edit-categories-label{display:block;margin:.2em 0;}.inline-edit-row fieldset label.inline-edit-tags{margin-top:0;}.inline-edit-row fieldset label.inline-edit-tags span.title{margin:.2em 0;}.inline-edit-row fieldset label span.title{display:block;float:left;width:5em;}.inline-edit-row fieldset label span.input-text-wrap{display:block;margin-left:5em;}.quick-edit-row-post fieldset.inline-edit-col-right label span.title{width:auto;padding-right:.5em;}.inline-edit-row .input-text-wrap input[type=text]{width:100%;}.inline-edit-row fieldset label input[type=checkbox]{vertical-align:text-bottom;}.inline-edit-row fieldset label textarea{width:100%;height:4em;}#wpbody-content .bulk-edit-row fieldset .inline-edit-group label{max-width:50%;}#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child{margin-right:.5em;}.inline-edit-row h4{text-transform:uppercase;}.inline-edit-row fieldset span.title,.inline-edit-row fieldset span.checkbox-title{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-style:italic;line-height:1.8em;}.inline-edit-row fieldset input[type="text"],.inline-edit-row fieldset textarea{border-style:solid;border-width:1px;}.inline-edit-row fieldset .inline-edit-date{float:left;}.inline-edit-row fieldset input[name=jj],.inline-edit-row fieldset input[name=hh],.inline-edit-row fieldset input[name=mn]{font-size:12px;width:2.1em;}.inline-edit-row fieldset input[name=aa]{font-size:12px;width:3.5em;}.inline-edit-row fieldset label input.inline-edit-password-input{width:8em;}.inline-edit-row .catshow,.inline-edit-row .cathide{cursor:pointer;}ul.cat-checklist{height:12em;border-style:solid;border-width:1px;overflow-y:scroll;padding:0 5px;margin:0;}#bulk-titles{display:block;height:12em;border-style:solid;border-width:1px;overflow-y:scroll;padding:0 5px;margin:0 0 5px;}.inline-edit-row fieldset ul.cat-checklist li,.inline-edit-row fieldset ul.cat-checklist input{margin:0;}.inline-edit-row fieldset ul.cat-checklist label,.inline-edit-row .catshow,.inline-edit-row .cathide,.inline-edit-row #bulk-titles div{font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;font-style:normal;font-size:11px;}table .inline-edit-row fieldset ul.cat-hover{height:auto;max-height:30em;overflow-y:auto;position:absolute;}.inline-edit-row fieldset label input.inline-edit-menu-order-input{width:3em;}.inline-edit-row fieldset label input.inline-edit-slug-input{width:75%;}.quick-edit-row-post fieldset label.inline-edit-status{float:left;}#bulk-titles{line-height:140%;}#bulk-titles div{margin:.2em .3em;}#bulk-titles div a{cursor:pointer;display:block;float:left;height:10px;margin:3px 3px 0 -2px;overflow:hidden;position:relative;text-indent:-9999px;width:10px;}#titlediv{position:relative;margin-bottom:20px;}#titlediv label{cursor:text;}#titlediv div.inside{margin:0;}#poststuff #titlewrap{border:0;padding:0;}#titlediv #title{padding:3px 4px;border-width:1px;border-style:solid;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;font-size:1.7em;line-height:100%;width:100%;outline:none;}#titlediv #title-prompt-text{color:#bbb;position:absolute;font-size:1.7em;padding:8px;}#poststuff .inside-submitbox,#side-sortables .inside-submitbox{margin:0 3px;font-size:11px;}input#link_description,input#link_url{width:98%;}#pending{background:0 none;border:0 none;padding:0;font-size:11px;margin-top:-1px;}#edit-slug-box{height:1em;margin-top:8px;padding:0 7px;}#editable-post-name-full{display:none;}#editable-post-name input{width:16em;}.postarea h3 label{float:left;}.postarea #add-media-button{float:right;margin:7px 0 0;position:relative;right:10px;}#poststuff #editor-toolbar{height:30px;}.wp_themeSkin tr.mceFirst td.mceToolbar{border-width:0 0 1px;border-style:none none solid;}#edButtonPreview,#edButtonHTML{height:18px;margin:5px 5px 0 0;padding:4px 5px 2px;float:right;cursor:pointer;border-width:1px;border-style:solid;-moz-border-radius:3px 3px 0 0;-webkit-border-top-right-radius:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;border-top-right-radius:3px;border-top-left-radius:3px;}.js .theEditor{color:white;}#poststuff #edButtonHTML{margin-right:15px;}#media-buttons{cursor:default;padding:8px 8px 0;}#media-buttons a{cursor:pointer;padding:0 0 5px 10px;}#media-buttons img,#submitpost #ajax-loading,#submitpost .ajax-loading{vertical-align:middle;}#wpcontent .ajax-loading{visibility:hidden;}.submitbox .submit{text-align:left;padding:12px 10px 10px;font-size:11px;}.submitbox .submitdelete{border-bottom-width:1px;border-bottom-style:solid;text-decoration:none;padding:1px 2px;}.inside-submitbox #post_status{margin:2px 0 2px -2px;}.submitbox .submit a:hover{border-bottom-width:1px;border-bottom-style:solid;}.submitbox .submit input{margin-bottom:8px;margin-right:4px;padding:6px;}#post-status-select,#post-format{line-height:2.5em;margin-top:3px;}#post-body #normal-sortables{min-height:50px;}#post-body #advanced-sortables{min-height:20px;}.postbox{position:relative;min-width:255px;width:99.5%;}#trackback_url{width:99%;}#normal-sortables .postbox .submit{background:transparent none;border:0 none;float:right;padding:0 12px;margin:0;}#side-sortables .category-add input{width:94%;}#side-sortables .category-add select{width:100%;}#side-sortables .category-add input.category-add-sumbit,#post-body .category-add input.category-add input.category-add-sumbit{width:auto;}#post-body ul.category-tabs,#post-body ul.add-menu-item-tabs{float:left;width:120px;text-align:right;margin:0 -120px 0 5px;padding:0;}#post-body ul.category-tabs li,#post-body ul.add-menu-item-tabs li{padding:8px;}#post-body ul.category-tabs li.tabs,#post-body ul.add-menu-item-tabs li.tabs{-moz-border-radius:3px 0 0 3px;-webkit-border-top-left-radius:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-top-left-radius:3px;border-bottom-left-radius:3px;}#post-body ul.category-tabs li.tabs a,#post-body ul.add-menu-item-tabs li.tabs a{font-weight:bold;text-decoration:none;}.wp-tab-panel,.categorydiv div.tabs-panel,.customlinkdiv div.tabs-panel,.posttypediv div.tabs-panel,.taxonomydiv div.tabs-panel,#linkcategorydiv div.tabs-panel{height:200px;overflow:auto;padding:.5em .9em;border-style:solid;border-width:1px;}.nav-menus-php .customlinkdiv div.tabs-panel,.nav-menus-php .posttypediv div.tabs-panel,.nav-menus-php .taxonomydiv div.tabs-panel{height:auto;max-height:205px;}div.tabs-panel-active{display:block;}div.tabs-panel-inactive{display:none;}#post-body .categorydiv div.tabs-panel,.taxonomy div.tabs-panel,#post-body #linkcategorydiv div.tabs-panel{margin:0 5px 0 125px;}#side-sortables .category-tabs li,#side-sortables .add-menu-item-tabs li,.wp-tab-bar li{display:inline;}#side-sortables .category-tabs a,#side-sortables .add-menu-item-tabs a,.wp-tab-bar a{text-decoration:none;}#side-sortables .category-tabs,#side-sortables .add-menu-item-tabs,.wp-tab-bar{margin-bottom:3px;}.categorydiv ul,.customlinkdiv ul,.posttypediv ul,.taxonomydiv ul,#linkcategorydiv ul{list-style:none;padding:0;margin:0;}#normal-sortables .postbox #replyrow .submit{float:none;margin:0;padding:3px 7px;}#side-sortables .submitbox .submit input,#side-sortables .submitbox .submit .preview,#side-sortables .submitbox .submit a.preview:hover{border:0 none;}#side-sortables .inside-submitbox .insidebox,.stuffbox .insidebox{margin:11px 0;}#side-sortables .comments-box,#normal-sortables .comments-box{border:0 none;}ul.category-tabs,ul.add-menu-item-tabs,ul.wp-tab-bar{margin-top:12px;}#side-sortables .comments-box thead th,#normal-sortables .comments-box thead th{background:transparent;padding:0 7px 4px;font-style:italic;}ul.category-tabs li.tabs,ul.add-menu-item-tabs li.tabs,.wp-tab-active{border-style:solid solid none;border-width:1px 1px 0;}#commentsdiv img.waiting{padding-left:5px;}#post-body .category-tabs li.tabs,#post-body .add-menu-item-tabs li.tabs{border-style:solid none solid solid;border-width:1px 0 1px 1px;margin-right:-1px;}ul.category-tabs li,ul.add-menu-item-tabs li,ul.wp-tab-bar li{padding:5px;-moz-border-radius:3px 3px 0 0;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;border-top-left-radius:3px;border-top-right-radius:3px;}form#tags-filter{position:relative;}p.search-box{float:right;margin:-5px 0 0;}.screen-per-page{width:3em;}#posts-filter fieldset{float:left;margin:0 1.5ex 1em 0;padding:0;}#posts-filter fieldset legend{padding:0 0 .2em 1px;}td.post-title strong,td.plugin-title strong{display:block;margin-bottom:.2em;}td.post-title p,td.plugin-title p{margin:6px 0;}.wp-hidden-children .wp-hidden-child,.ui-tabs-hide{display:none;}.commentlist .avatar{vertical-align:text-top;}#post-body .tagsdiv #newtag{margin-right:5px;width:16em;}#side-sortables input#post_password{width:94%;}#side-sortables .tagsdiv #newtag{width:68%;}#post-status-info{border-width:0 1px 1px;border-style:none solid solid;width:100%;-moz-border-radius:0 0 6px 6px;-webkit-border-bottom-left-radius:6px;-webkit-border-bottom-right-radius:6px;-khtml-border-bottom-left-radius:6px;-khtml-border-bottom-right-radius:6px;border-bottom-left-radius:6px;border-bottom-right-radius:6px;}#post-status-info td{font-size:11px;}.autosave-info{padding:2px 15px 2px 2px;text-align:right;}#editorcontent #post-status-info{border:none;}#post-body .wp_themeSkin .mceStatusbar a.mceResize{display:block;background:transparent url(../images/resize.gif) no-repeat scroll right bottom;width:12px;cursor:se-resize;margin:0 2px;position:relative;top:22px;}#wp-word-count{display:block;padding:2px 7px;}#timestampdiv select{height:20px;line-height:14px;padding:0;vertical-align:top;}#jj,#hh,#mn{width:2em;padding:1px;font-size:12px;}#aa{width:3.4em;padding:1px;font-size:12px;}.curtime #timestamp{background-repeat:no-repeat;background-position:left top;padding-left:18px;}#timestampdiv{padding-top:5px;line-height:23px;}#timestampdiv p{margin:8px 0 6px;}#timestampdiv input{border-width:1px;border-style:solid;}#postcustomstuff table,#postcustomstuff input,#postcustomstuff textarea{border-width:1px;border-style:solid;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;}#postcustomstuff .updatemeta,#postcustomstuff .deletemeta{margin:auto;}#postcustomstuff thead th{padding:5px 8px 8px;}#postcustom #postcustomstuff .submit{border:0 none;float:none;padding:5px 8px;}#side-sortables #postcustom #postcustomstuff .submit{padding:0 5px;}#side-sortables #postcustom #postcustomstuff td.left input{margin:3px 3px 0;}#side-sortables #postcustom #postcustomstuff #the-list textarea{height:85px;margin:3px;}#postcustomstuff table{margin:0;width:100%;border-width:1px;border-style:solid;border-spacing:0;}#postcustomstuff table input,#postcustomstuff table select,#postcustomstuff table textarea{width:95%;margin:8px 0 8px 8px;}#postcustomstuff th.left,#postcustomstuff td.left{width:38%;}#postcustomstuff .submit input{width:auto;}#postcustomstuff #newmeta .submit{padding:0 8px;}#postcustomstuff table #addmetasub{width:auto;}#postcustomstuff #newmetaleft{vertical-align:top;}#postcustomstuff #newmetaleft a{padding:0 10px;text-decoration:none;}table.diff{width:100%;}table.diff col.content{width:50%;}table.diff tr{background-color:transparent;}table.diff td,table.diff th{padding:.5em;font-family:Consolas,Monaco,Courier,monospace;border:none;}table.diff .diff-deletedline del,table.diff .diff-addedline ins{text-decoration:none;}.category-adder{margin-left:120px;padding:4px 0;}.category-adder h4{margin:0 0 8px;}#side-sortables .category-adder{margin:0;}#post-body .category-add input,.category-add select{width:30%;}#side-sortables .category-add select{width:100%;}#side-sortables .category-add input.category-add-sumbit,#post-body .category-add input.category-add input.category-add-sumbit{width:auto;}#post-body ul.category-tabs,#post-body ul.add-menu-item-tabs{float:left;width:120px;text-align:right;margin:0 -120px 0 5px;padding:0;}#post-body ul.category-tabs li,#post-body ul.add-menu-item-tabs li{padding:8px;}#post-body ul.category-tabs li.tabs,#post-body ul.add-menu-item-tabs li.tabs{-moz-border-radius:3px 0 0 3px;-webkit-border-top-left-radius:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-top-left-radius:3px;border-bottom-left-radius:3px;}#post-body ul.category-tabs li.tabs a,#post-body ul.add-menu-item-tabs li.tabs a{font-weight:bold;text-decoration:none;}.categorydiv div.tabs-panel,.customlinkdiv div.tabs-panel,.posttypediv div.tabs-panel,.taxonomydiv div.tabs-panel,#linkcategorydiv div.tabs-panel{height:200px;overflow:auto;padding:.5em .9em;border-style:solid;border-width:1px;}.nav-menus-php .customlinkdiv div.tabs-panel,.nav-menus-php .posttypediv div.tabs-panel,.nav-menus-php .taxonomydiv div.tabs-panel{height:auto;max-height:205px;}div.tabs-panel-active{display:block;}div.tabs-panel-inactive{display:none;}#post-body .categorydiv div.tabs-panel,.taxonomy div.tabs-panel,#post-body #linkcategorydiv div.tabs-panel{margin:0 5px 0 125px;}#side-sortables .category-tabs li,#side-sortables .add-menu-item-tabs li{display:inline;}#side-sortables .category-tabs a,#side-sortables .add-menu-item-tabs a{text-decoration:none;}#side-sortables .category-tabs,#side-sortables .add-menu-item-tabs{margin-bottom:3px;}.categorydiv ul,.customlinkdiv ul,.posttypediv ul,.taxonomydiv ul,#linkcategorydiv ul{list-style:none;padding:0;margin:0;}#front-page-warning,#front-static-pages ul,ul.export-filters,.inline-editor ul.cat-checklist ul,.categorydiv ul.categorychecklist ul,.customlinkdiv ul.categorychecklist ul,.posttypediv ul.categorychecklist ul,.taxonomydiv ul.categorychecklist ul,#linkcategorydiv ul.categorychecklist ul{margin-left:18px;}ul.categorychecklist li{margin:0;padding:0;line-height:19px;word-wrap:break-word;}.categorydiv .tabs-panel,.customlinkdiv .tabs-panel,.posttypediv .tabs-panel,.taxonomydiv .tabs-panel{border-width:3px;border-style:solid;}ul.category-tabs,ul.add-menu-item-tabs{margin-top:12px;}ul.category-tabs li.tabs,ul.add-menu-item-tabs li.tabs{border-style:solid solid none;border-width:1px 1px 0;}#post-body .category-tabs li.tabs,#post-body .add-menu-item-tabs li.tabs{border-style:solid none solid solid;border-width:1px 0 1px 1px;margin-right:-1px;}ul.category-tabs li,ul.add-menu-item-tabs li{padding:5px;-moz-border-radius:3px 3px 0 0;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;border-top-left-radius:3px;border-top-right-radius:3px;}.form-wrap{margin:10px 0;width:97%;}.form-wrap p,.form-wrap label{font-size:11px;}.form-wrap label{display:block;padding:2px;font-size:12px;}.form-field input,.form-field textarea{border-style:solid;border-width:1px;width:95%;}p.description,.form-wrap p{margin:2px 0 5px;}p.help,p.description,span.description,.form-wrap p{font-size:12px;font-style:italic;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;}.form-wrap .form-field{margin:0 0 10px;padding:8px;}.col-wrap h3{margin:12px 0;font-size:1.1em;}.col-wrap p.submit{margin-top:-10px;}.taghint{color:#aaa;margin:15px 0 -24px 12px;}#poststuff .tagsdiv .howto{margin:0 0 6px 8px;}.ajaxtag .newtag{background:transparent;position:relative;}.tagsdiv .newtag{width:180px;}.tagsdiv .the-tags{display:block;height:60px;margin:0 auto;overflow:auto;width:260px;}#post-body-content .tagsdiv .the-tags{margin:0 5px;}p.popular-tags{-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px;border-width:1px;border-style:solid;line-height:2em;padding:8px 12px 12px;text-align:justify;}p.popular-tags a{padding:0 3px;}.tagcloud{width:97%;margin:0 0 40px;text-align:justify;}.tagcloud h3{margin:2px 0 12px;}.ac_results{padding:0;margin:0;list-style:none;position:absolute;z-index:10000;display:none;border-width:1px;border-style:solid;}.ac_results li{padding:2px 5px;white-space:nowrap;text-align:left;}.ac_over{cursor:pointer;}.ac_match{text-decoration:underline;}#wpbody-content #media-items .describe{border-collapse:collapse;width:100%;border-top-style:solid;border-top-width:1px;clear:both;cursor:default;padding:5px;}#wpbody-content .describe th{vertical-align:top;text-align:left;padding:10px;width:140px;}#wpbody-content .describe .media-item-info tr{background-color:transparent;}#wpbody-content .describe .media-item-info td{padding:4px 10px 0;}.describe .media-item-info .A1B1{padding:0 0 0 10px;}#wpbody-content .filename{padding:0 10px;}#wpbody-content .media-item .thumbnail{max-height:128px;max-width:128px;}#wpbody-content #async-upload-wrap a{display:none;}.media-upload-form td label{margin-right:6px;margin-left:2px;}.media-upload-form .align .field label{display:inline;padding:0 0 0 22px;margin:0 1em 0 0;font-weight:bold;}.media-upload-form tr.image-size label{margin:0 0 0 3px;font-weight:bold;}.media-upload-form th.label label{font-weight:bold;margin:.5em;font-size:13px;}.media-upload-form th.label label span{padding:0 5px;}abbr.required{border:medium none;text-decoration:none;}#wpbody-content .describe input[type="text"],#wpbody-content .describe textarea{width:460px;}#wpbody-content .describe p.help{margin:0;padding:0 0 0 5px;}.media-item .error-div a.dismiss,.describe-toggle-on,.describe-toggle-off{display:block;line-height:36px;float:right;margin-right:20px;}.describe-toggle-off{display:none;}#wpbody-content .media-item{border-bottom-style:solid;border-bottom-width:1px;min-height:36px;position:relative;width:100%;}#wpbody-content .media-single .media-item{border-bottom-style:none;border-bottom-width:0;}#wpbody-content #media-items{border-style:solid solid none;border-width:1px;width:670px;}#wpbody-content #media-items .filename{line-height:36px;overflow:hidden;}.media-item .error-div{padding-left:10px;}.media-item .pinkynail{float:left;margin:2px;max-width:40px;max-height:32px;}.media-item .startopen,.media-item .startclosed{display:none;}.media-item .original{position:relative;height:34px;width:503px;}.media-item .percent{font-weight:bold;}.crunching{display:block;line-height:32px;text-align:right;margin-right:5px;}.progress{position:relative;margin-bottom:-36px;height:36px;}.bar{width:0;height:100%;border-right-width:3px;border-right-style:solid;}.upload-php .fixed .column-parent{width:25%;}.find-box{width:500px;height:300px;overflow:hidden;padding:33px 5px 40px;position:absolute;z-index:1000;}.find-box-head{cursor:move;font-weight:bold;height:2em;line-height:2em;padding:1px 12px;position:absolute;top:5px;width:100%;}.find-box-inside{overflow:auto;width:100%;height:100%;}.find-box-search{padding:12px;border-width:1px;border-style:none none solid;}#find-posts-response{margin:8px 0;padding:0 1px;}#find-posts-response table{width:100%;}#find-posts-response .found-radio{padding:5px 0 0 8px;width:15px;}.find-box-buttons{width:480px;margin:8px;}.find-box-search label{padding-right:6px;}.find-box #resize-se{position:absolute;right:1px;bottom:1px;}#favorite-actions{float:right;margin:11px 12px 0;min-width:130px;position:relative;}#favorite-first{-moz-border-radius:12px;-khtml-border-radius:12px;-webkit-border-radius:12px;border-radius:12px;line-height:15px;padding:3px 30px 4px 12px;border-width:1px;border-style:solid;}#favorite-inside{margin:0;padding:2px 1px;border-width:1px;border-style:solid;position:absolute;z-index:11;display:none;-moz-border-radius:0 0 12px 12px;-webkit-border-bottom-right-radius:12px;-webkit-border-bottom-left-radius:12px;-khtml-border-bottom-right-radius:12px;-khtml-border-bottom-left-radius:12px;border-bottom-right-radius:12px;border-bottom-left-radius:12px;}#favorite-actions a{display:block;text-decoration:none;font-size:11px;}#favorite-inside a{padding:3px 5px 3px 10px;}#favorite-toggle{height:22px;position:absolute;right:0;top:1px;width:28px;}#favorite-actions .slide-down{-moz-border-radius:12px 12px 0 0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-khtml-border-bottom-right-radius:0;-khtml-border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-bottom:none;}ul#dismissed-updates{display:none;}form.upgrade{margin-top:8px;}form.upgrade .hint{font-style:italic;font-size:85%;margin:-0.5em 0 2em 0;}#poststuff .inside .the-tagcloud{margin:5px 0 10px;padding:8px;border-width:1px;border-style:solid;line-height:1.8em;word-spacing:3px;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}br.clear{height:2px;line-height:2px;}.swfupload{margin:5px 10px;vertical-align:middle;}.describe .image-editor{vertical-align:top;}.imgedit-wrap{position:relative;}.imgedit-settings p{margin:8px 0;}.describe .imgedit-wrap table td{vertical-align:top;padding-top:0;}.imgedit-wrap p,.describe .imgedit-wrap table td{font-size:11px;line-height:18px;}.describe .imgedit-wrap table td.imgedit-settings{padding:0 5px;}td.imgedit-settings input{vertical-align:middle;}.imgedit-wait{position:absolute;top:0;background:#FFF url(../images/wpspin_light.gif) no-repeat scroll 22px 10px;opacity:.7;filter:alpha(opacity=70);width:100%;height:500px;display:none;}.media-disabled,.imgedit-settings .disabled{color:grey;}.imgedit-wait-spin{padding:0 4px 4px;vertical-align:bottom;visibility:hidden;}.imgedit-menu{margin:0 0 12px;min-width:300px;}.imgedit-menu div{float:left;width:32px;height:32px;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;border-width:1px;border-style:solid;}.imgedit-crop-wrap{position:relative;}.imgedit-crop{background:transparent url(../images/imgedit-icons.png) no-repeat scroll -9px -31px;margin:0 8px 0 0;}.imgedit-crop.disabled:hover{background-position:-9px -31px;}.imgedit-crop:hover{background-position:-9px -1px;}.imgedit-rleft{background:transparent url(../images/imgedit-icons.png) no-repeat scroll -46px -31px;margin:0 3px;}.imgedit-rleft.disabled:hover{background-position:-46px -31px;}.imgedit-rleft:hover{background-position:-46px -1px;}.imgedit-rright{background:transparent url(../images/imgedit-icons.png) no-repeat scroll -77px -31px;margin:0 8px 0 3px;}.imgedit-rright.disabled:hover{background-position:-77px -31px;}.imgedit-rright:hover{background-position:-77px -1px;}.imgedit-flipv{background:transparent url(../images/imgedit-icons.png) no-repeat scroll -115px -31px;margin:0 3px;}.imgedit-flipv.disabled:hover{background-position:-115px -31px;}.imgedit-flipv:hover{background-position:-115px -1px;}.imgedit-fliph{background:transparent url(../images/imgedit-icons.png) no-repeat scroll -147px -31px;margin:0 8px 0 3px;}.imgedit-fliph.disabled:hover{background-position:-147px -31px;}.imgedit-fliph:hover{background-position:-147px -1px;}.imgedit-undo{background:transparent url(../images/imgedit-icons.png) no-repeat scroll -184px -31px;margin:0 3px;}.imgedit-undo.disabled:hover{background-position:-184px -31px;}.imgedit-undo:hover{background-position:-184px -1px;}.imgedit-redo{background:transparent url(../images/imgedit-icons.png) no-repeat scroll -215px -31px;margin:0 8px 0 3px;}.imgedit-redo.disabled:hover{background-position:-215px -31px;}.imgedit-redo:hover{background-position:-215px -1px;}.imgedit-applyto img{margin:0 8px 0 0;}.imgedit-group-top{margin:5px 0;}.imgedit-applyto .imgedit-label{padding:2px 0 0;display:block;}.imgedit-help{display:none;font-style:italic;margin-bottom:8px;}.imgedit-help ul li{font-size:11px;}a.imgedit-help-toggle{text-decoration:none;}#wpbody-content .imgedit-response div{width:600px;margin:8px;}.form-table td.imgedit-response{padding:0;}.imgedit-submit{margin:8px 0;}.imgedit-submit-btn{margin-left:20px;}.imgedit-wrap .nowrap{white-space:nowrap;}span.imgedit-scale-warn{color:red;font-size:20px;font-style:normal;visibility:hidden;vertical-align:middle;}.imgedit-group{border-width:1px;border-style:solid;-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px;margin-bottom:8px;padding:2px 10px;}.form-table{border-collapse:collapse;margin-top:.5em;width:100%;margin-bottom:-8px;clear:both;}.form-table td{margin-bottom:9px;padding:8px 10px;line-height:20px;font-size:11px;}.form-table th,.form-wrap label{font-weight:normal;text-shadow:rgba(255,255,255,1) 0 1px 0;}.form-table th{vertical-align:top;text-align:left;padding:10px;width:200px;}.form-table th.th-full{width:auto;}.form-table div.color-option{display:block;clear:both;margin-top:12px;}.form-table input.tog{margin-top:2px;margin-right:2px;float:left;}.form-table td p{margin-top:4px;}.form-table table.color-palette{vertical-align:bottom;float:left;margin:-12px 3px 11px;}.form-table .color-palette td{border-width:1px 1px 0;border-style:solid solid none;height:10px;line-height:20px;width:10px;}.commentlist li{padding:1em 1em .2em;margin:0;border-bottom-width:1px;border-bottom-style:solid;}.commentlist li li{border-bottom:0;padding:0;}.commentlist p{padding:0;margin:0 0 .8em;}#replyrow{font-size:11px;}#replyrow input{border-width:1px;border-style:solid;}#replyrow td{padding:2px;}#replyrow #editorcontainer{border:0 none;}#replysubmit{margin:0;padding:3px 7px;text-align:center;}#replysubmit img.waiting,.inline-edit-save img.waiting{padding:4px 10px 0;vertical-align:top;float:right;}#replysubmit .button{margin-right:5px;}#replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center;}#replyrow #editor-toolbar{display:none;}#replyhead{font-size:12px;font-weight:bold;padding:2px 10px 4px;}#edithead .inside{float:left;padding:3px 0 2px 5px;margin:0;text-align:center;font-size:11px;}#edithead .inside input{width:180px;font-size:11px;}#edithead label{padding:2px 0;}#replycontainer{padding:5px;border:0 none;height:120px;overflow:hidden;position:relative;}#replycontent{resize:none;margin:0;width:100%;height:100%;padding:0;line-height:150%;border:0 none;outline:none;font-size:12px;}#replyrow #ed_reply_toolbar{margin:0;padding:2px 3px;}.comment-ays{margin-bottom:0;border-style:solid;border-width:1px;}.comment-ays th{border-right-style:solid;border-right-width:1px;}.trash-undo-inside,.spam-undo-inside{margin:1px 8px 1px 0;line-height:16px;}.spam-undo-inside .avatar,.trash-undo-inside .avatar{height:20px;width:20px;margin-right:8px;vertical-align:middle;}.stuffbox .editcomment{clear:none;}#comment-status-radio p{margin:3px 0 5px;}#comment-status-radio input{margin:2px 3px 5px 0;vertical-align:middle;}#comment-status-radio label{padding:5px 0;}.commentlist .avatar{vertical-align:text-top;}.theme-install-php .tablenav{height:auto;}table#availablethemes{border-spacing:0;border-width:1px 0;border-style:solid none;margin:10px auto;width:100%;}table#availablethemes .no-items td{border-width:0;padding:5px;}td.available-theme{vertical-align:top;width:240px;margin:0;padding:20px;text-align:left;}table#availablethemes td{border-width:0 1px 1px;border-style:none solid solid;}table#availablethemes td.right,table#availablethemes td.left{border-right:0 none;border-left:0 none;}table#availablethemes td.bottom{border-bottom:0 none;}.available-theme a.screenshot{width:240px;height:180px;display:block;border-width:1px;border-style:solid;margin-bottom:10px;overflow:hidden;}.available-theme img{width:240px;}.available-theme h3{margin:15px 0 5px;}#current-theme{margin:1em 0 1.5em;}#current-theme a{border-bottom:none;}#current-theme h3{font-size:17px;font-weight:normal;margin:0;}#current-theme .theme-description{margin-top:5px;}#current-theme img{float:left;border-width:1px;border-style:solid;margin-right:1em;margin-bottom:1.5em;width:150px;}.theme-options span{text-transform:uppercase;font-size:13px;}.theme-options a{font-size:15px;}#TB_window #TB_title a.tb-theme-preview-link,#TB_window #TB_title a.tb-theme-preview-link:visited{font-weight:bold;text-decoration:none;}#TB_window #TB_title{background-color:#222;color:#cfcfcf;}#broken-themes{text-align:left;width:50%;border-spacing:3px;padding:3px;}.theme-install-php h4{margin:2.5em 0 8px;}.appearance_page_custom-header #headimg{border:1px solid #DFDFDF;min-height:100px;width:100%;}.appearance_page_custom-header #upload-form p label{font-size:11px;}.appearance_page_custom-header #available-headers .default-header{float:left;margin:0 20px 20px 0;}.appearance_page_custom-header #available-headers label input{margin-right:10px;}.appearance_page_custom-header #available-headers label img{vertical-align:middle;}div#custom-background-image{min-height:100px;border:1px solid #dfdfdf;}div#custom-background-image img{max-width:400px;max-height:300px;}#custom-background label{padding-right:15px;}.nav-tab{border-style:solid;border-color:#ccc #ccc #f9f9f9;border-width:1px 1px 0;color:#c1c1c1;text-shadow:rgba(255,255,255,1) 0 1px 0;font-size:12px;line-height:16px;display:inline-block;padding:4px 14px 6px;text-decoration:none;margin:0 6px -1px 0;-moz-border-radius:5px 5px 0 0;-webkit-border-top-left-radius:5px;-webkit-border-top-right-radius:5px;-khtml-border-top-left-radius:5px;-khtml-border-top-right-radius:5px;border-top-left-radius:5px;border-top-right-radius:5px;}.nav-tab-active{border-width:1px;color:#464646;}h2.nav-tab-wrapper,h3.nav-tab-wrapper{border-bottom:1px solid #ccc;padding-bottom:0;}h2 .nav-tab{padding:4px 20px 6px;font:italic normal normal 24px/35px Georgia,"Times New Roman","Bitstream Charter",Times,serif;}.plugins .name,#pass-strength-result.strong,#pass-strength-result.short,.button-highlighted,input.button-highlighted,#quicktags #ed_strong,#ed_reply_toolbar #ed_reply_strong{font-weight:bold;}.plugins p{margin:0 4px;padding:0;}.plugins .desc p{margin:0 0 8px;}.plugins td.desc{line-height:1.5em;}.plugins .desc ul,.plugins .desc ol{margin:0 0 0 2em;}.plugins .desc ul{list-style-type:disc;}.plugins .row-actions-visible{padding:0;}.plugins tbody th.check-column{padding:7px 0;}.plugins td,.plugins th{border-bottom:0 none;}.plugins .inactive td,.plugins .inactive th,.plugins .active td,.plugins .active th{border-top-style:solid;border-top-width:1px;padding:5px 7px 0;}#wpbody-content .plugins .plugin-title,#wpbody-content .plugins .theme-title{padding-right:12px;white-space:nowrap;}.plugins .second,.plugins .row-actions-visible{padding:0 0 5px;}.plugins-php .widefat tfoot th,.plugins-php .widefat tfoot td{border-top-style:solid;border-top-width:1px;}.plugin-update-tr .update-message{margin:5px;padding:3px 5px;border-width:1px;border-style:solid;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;}.plugin-install-php h4{margin:2.5em 0 8px;}#profile-page .form-table textarea{width:500px;margin-bottom:6px;}#profile-page .form-table #rich_editing{margin-right:5px;}#your-profile legend{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-size:22px;}#your-profile #rich_editing{border:none;}#display_name{width:15em;}#createuser .form-field input{width:25em;}#utc-time,#local-time{padding-left:25px;font-style:italic;font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif;}.defaultavatarpicker .avatar{margin:2px 0;vertical-align:middle;}#footer{margin-top:-46px;border-top:1px;border-style:solid;}#footer,#footer a{font-size:12px;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-style:italic;}#footer p{margin:0;padding:15px;line-height:15px;}#footer a{text-decoration:none;}#footer a:hover{text-decoration:underline;}#excerpt,.attachmentlinks{margin:0;height:4em;width:98%;}#template div{margin-right:190px;}p.pagenav{margin:0;display:inline;}.pagenav span{font-weight:bold;margin:0 6px;}.row-title{font-size:12px!important;font-weight:bold;}.column-author img,.column-username img{float:left;margin-right:10px;margin-top:3px;}.row-actions{visibility:hidden;padding:2px 0 0;}tr:hover .row-actions,div.comment-item:hover .row-actions{visibility:visible;}.row-actions-visible{padding:2px 0 0;}.form-table .pre{padding:8px;margin:0;}table.form-table td .updated{font-size:13px;}.tagchecklist{margin-left:14px;font-size:12px;overflow:auto;}.tagchecklist strong{margin-left:-8px;position:absolute;}.tagchecklist span{margin-right:25px;display:block;float:left;font-size:11px;line-height:1.8em;white-space:nowrap;cursor:default;}.tagchecklist span a{margin:6px 0 0 -9px;cursor:pointer;width:10px;height:10px;display:block;float:left;text-indent:-9999px;overflow:hidden;position:absolute;}#poststuff h2{margin-top:20px;font-size:1.5em;margin-bottom:15px;padding:0 0 3px;clear:left;}#poststuff h3,.metabox-holder h3{font-size:12px;font-weight:bold;padding:7px 9px;margin:0;line-height:1;}#poststuff .inside,#poststuff .inside p{font-size:11px;margin:6px 6px 8px;}#poststuff .inside .submitbox p{margin:1em 0;}#post-visibility-select,#post-formats-select{line-height:1.5em;margin-top:3px;}#poststuff #submitdiv .inside{margin:0;}#titlediv,#poststuff .postarea{margin-bottom:20px;}td.post-title strong,td.plugin-title strong{display:block;margin-bottom:.2em;}td.post-title p,td.plugin-title p{margin:6px 0;}.wp-hidden-children .wp-hidden-child,.ui-tabs-hide{display:none;}#templateside ul li a{text-decoration:none;}.tool-box{margin:15px 0 35px;}.tool-box .buttons{margin:15px 0;}.tool-box .title{margin:8px 0;font:18px/24px Georgia,"Times New Roman","Bitstream Charter",Times,serif;}.pressthis a{font-size:1.2em;}#sidemenu{margin:-30px 15px 0 315px;list-style:none;position:relative;float:right;padding-left:10px;font-size:12px;}#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;}#sidemenu li{display:inline;line-height:200%;list-style:none;text-align:center;white-space:nowrap;margin:0;padding:0;}#sidemenu a.current{font-weight:normal;padding-left:6px;padding-right:6px;-moz-border-radius:4px 4px 0 0;-webkit-border-top-left-radius:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-left-radius:4px;-khtml-border-top-right-radius:4px;border-top-left-radius:4px;border-top-right-radius:4px;border-width:1px;border-style:solid;}#sidemenu li a .count-0{display:none;}#poststuff .inside .the-tagcloud{margin:5px 0 10px;padding:8px;border-width:1px;border-style:solid;line-height:1.8em;word-spacing:3px;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;}.plugin-install #description,.plugin-install-network #description{width:60%;}table .vers,table .column-visible,table .column-rating{text-align:left;}body.iframe{height:98%;}.anchors{margin:10px 20px 10px 20px;}div.nav{height:2em;padding:7px 10px;vertical-align:text-top;margin:5px 0;}.nav .button-secondary{padding:2px 4px;}* html #themeselect{padding:0 3px;height:22px;}.settings-toggle{text-align:right;margin:5px 7px 15px 0;font-size:12px;}.settings-toggle h3{margin:0;}form#tags-filter{position:relative;}td.media-icon{text-align:center;width:80px;padding-top:8px;padding-bottom:8px;}td.media-icon img{max-width:80px;max-height:60px;}.screen-per-page{width:3em;}* html #template div{margin-right:0;}.list-ajax-loading{float:right;margin-right:9px;margin-top:-1px;}.tablenav .list-ajax-loading{margin-top:7px;}#howto{font-size:11px;margin:0 5px;display:block;}.import-system{font-size:16px;}#namediv table{width:100%;}#namediv td.first{width:10px;white-space:nowrap;}#namediv input{width:98%;}#namediv p{margin:10px 0;}#submitdiv h3{margin-bottom:0!important;}.zerosize{height:0;width:0;margin:0;border:0;padding:0;overflow:hidden;position:absolute;}br.clear{height:2px;line-height:2px;}.checkbox{border:none;margin:0;padding:0;}#content{margin:0;width:100%;}fieldset{border:0;padding:0;margin:0;}#linksubmitdiv div.inside,div.inside{padding:0;margin:0;}.post-categories{display:inline;margin:0;padding:0;}.post-categories li{display:inline;}
Index: /tags/3.1/wp-admin/css/wp-admin.dev.css
===================================================================
--- /tags/3.1/wp-admin/css/wp-admin.dev.css	(revision 17487)
+++ /tags/3.1/wp-admin/css/wp-admin.dev.css	(revision 17487)
@@ -0,0 +1,4316 @@
+/*------------------------------------------------------------------------------
+
+
+Hello, this is the main WordPress admin CSS file.
+All the important stuff is in here.
+
+
+TABLE OF CONTENTS:
+------------------
+ 1.0 - Text Elements
+ 2.0 - Forms
+ 3.0 - Actions
+ 4.0 - Notifications
+ 5.0 - TinyMCE
+ 6.0 - Admin Header
+	6.1 - Favorites Menu
+	6.2 - Screen Options Tabs
+ 7.0 - Main Navigation
+ 8.0 - Layout Blocks
+ 9.0 - Dashboard
+10.0 - List Posts
+	10.1 - Inline Editing
+11.0 - Write/Edit Post Screen
+	11.1 - Custom Fields
+	11.2 - Post Revisions
+12.0 - Categories
+13.0 - Tags
+14.0 - Media Screen
+	14.1 - Media Uploader
+	14.2 - Image Editor
+15.0 - Comments Screen
+16.0 - Themes
+	16.1 - Custom Header
+	16.2 - Custom Background
+	16.3 - Tabbed Admin Screen Interface
+17.0 - Plugins
+18.0 - Users
+19.0 - Tools
+20.0 - Settings
+21.0 - Admin Footer
+22.0 - Misc
+23.0 - Dead
+
+
+------------------------------------------------------------------------------*/
+
+
+
+
+/*------------------------------------------------------------------------------
+  1.0 - Text Styles
+------------------------------------------------------------------------------*/
+
+p,
+ul,
+ol,
+blockquote,
+input,
+select {
+	font-size: 12px;
+}
+
+ol {
+	list-style-type: decimal;
+	margin-left: 2em;
+}
+
+.code, code {
+	font-family: Consolas, Monaco, Courier, monospace;
+}
+
+kbd, code {
+	padding: 1px 3px;
+	margin: 0 1px;
+	font-size: 11px;
+}
+
+.quicktags, .search {
+	font: 12px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+}
+
+.icon32 {
+	float: left;
+	height: 36px;
+	margin: 14px 6px 0 0;
+	width: 36px;
+}
+
+.key-labels label {
+	line-height: 24px;
+}
+
+.subtitle {
+	font-size: 0.75em;
+	line-height: 1;
+	padding-left: 25px;
+}
+
+.pre {
+	/* http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/ */
+	white-space: pre-wrap; /* css-3 */
+	white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
+	white-space: -pre-wrap; /* Opera 4-6 */
+	white-space: -o-pre-wrap; /* Opera 7 */
+	word-wrap: break-word; /* Internet Explorer 5.5+ */
+}
+
+.howto {
+	font-style: italic;
+	display: block;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
+
+p.install-help {
+	margin: 8px 0;
+	font-style: italic;
+}
+
+
+/*------------------------------------------------------------------------------
+  2.0 - Forms
+------------------------------------------------------------------------------*/
+
+textarea,
+input[type="text"],
+input[type="password"],
+input[type="file"],
+input[type="button"],
+input[type="submit"],
+input[type="reset"],
+select {
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 4px;
+	-khtml-border-radius: 4px;
+	-webkit-border-radius: 4px;
+	border-radius: 4px;
+}
+
+select option {
+	padding: 2px;
+}
+
+.submit {
+	padding: 1.5em 0;
+	margin: 5px 0;
+	-moz-border-radius: 0 0 3px 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-webkit-border-bottom-right-radius: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	-khtml-border-bottom-right-radius: 3px;
+	border-bottom-left-radius: 3px;
+	border-bottom-right-radius: 3px;
+}
+
+form p.submit a.cancel:hover {
+	text-decoration: none;
+}
+
+.submit input,
+.button,
+input.button,
+.button-primary,
+input.button-primary,
+.button-secondary,
+input.button-secondary,
+.button-highlighted,
+input.button-highlighted,
+#postcustomstuff .submit input {
+	text-decoration: none;
+	font-size: 11px !important;
+	line-height: 13px;
+	padding: 3px 8px;
+	cursor: pointer;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 11px;
+	-khtml-border-radius: 11px;
+	-webkit-border-radius: 11px;
+	border-radius: 11px;
+	-moz-box-sizing: content-box;
+	-webkit-box-sizing: content-box;
+	-khtml-box-sizing: content-box;
+	box-sizing: content-box;
+}
+
+#minor-publishing-actions input,
+#major-publishing-actions input,
+#minor-publishing-actions .preview {
+	min-width: 80px;
+	text-align: center;
+}
+
+textarea.all-options, input.all-options {
+	width: 250px;
+}
+
+input.large-text,
+textarea.large-text {
+	width: 99%;
+}
+
+input.regular-text,
+#adduser .form-field input {
+	width: 25em;
+}
+
+input.small-text {
+	width: 50px;
+}
+
+#doaction,
+#doaction2,
+#post-query-submit {
+	margin-right: 8px;
+}
+
+.tablenav select[name="action"],
+.tablenav select[name="action2"] {
+	width: 130px;
+}
+
+.tablenav select[name="m"] {
+	width: 155px;
+}
+
+.tablenav select#cat {
+	width: 170px;
+}
+
+#wpcontent select {
+	padding: 2px;
+	height: 2em;
+	font-size: 11px;
+}
+
+#wpcontent option {
+	padding: 2px;
+}
+
+#timezone_string option {
+	margin-left: 1em;
+}
+
+label,
+#your-profile label + a {
+	vertical-align: middle;
+}
+
+#misc-publishing-actions label {
+	vertical-align: baseline;
+}
+
+#pass-strength-result {
+	border-style: solid;
+	border-width: 1px;
+	float: left;
+	margin: 12px 5px 5px 1px;
+	padding: 3px 5px;
+	text-align: center;
+	width: 200px;
+	display: none;
+}
+.indicator-hint {
+	padding-top: 8px;
+}
+
+p.search-box {
+	float: right;
+	margin: -5px 0 0;
+}
+
+
+/*------------------------------------------------------------------------------
+  3.0 - Actions
+------------------------------------------------------------------------------*/
+
+#major-publishing-actions {
+	padding: 6px;
+	clear: both;
+	border-top: none;
+}
+
+
+
+#delete-action {
+	line-height: 25px;
+	vertical-align: middle;
+	text-align: left;
+	float: left;
+}
+
+#publishing-action {
+	text-align: right;
+	float: right;
+	line-height: 23px;
+}
+
+#post-body #minor-publishing {
+	padding-bottom: 10px;
+}
+
+#post-body #misc-publishing-actions {
+	padding: 0;
+}
+
+#post-body .misc-pub-section {
+	border-right-width: 1px;
+	border-right-style: solid;
+	border-bottom: 0 none;
+	min-height: 30px;
+	float: left;
+	max-width: 32%;
+}
+
+#post-body .misc-pub-section-last {
+	border-right: 0;
+}
+
+#misc-publishing-actions {
+	padding: 6px 0 16px 0;
+}
+
+.misc-pub-section {
+	padding: 6px;
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+}
+
+.misc-pub-section-last {
+	border-bottom: 0 none;
+}
+
+#minor-publishing-actions {
+	padding: 6px;
+	text-align: right;
+}
+
+#minor-publishing {
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+}
+
+#save-post {
+	float: left;
+}
+
+#minor-publishing .ajax-loading {
+	padding: 3px 0 0 4px;
+	float: left;
+}
+
+.preview {
+	float: right;
+}
+
+
+
+#sticky-span {
+	margin-left: 18px;
+}
+
+#post-status-display,
+#post-visibility-display {
+	font-weight: bold;
+}
+
+.side-info {
+	margin: 0;
+	padding: 4px;
+	font-size: 11px;
+}
+
+.side-info h5 {
+	padding-bottom: 7px;
+	font-size: 14px;
+	margin: 12px 2px 5px;
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+}
+
+.side-info ul {
+	margin: 0;
+	padding-left: 18px;
+	list-style: square;
+}
+
+a.button,
+a.button-primary,
+a.button-secondary {
+	line-height: 15px;
+	padding: 3px 10px;
+	white-space: nowrap;
+	-webkit-border-radius: 10px;
+}
+
+.approve {
+	display: none;
+}
+
+.unapproved .approve,
+.spam .approve,
+.trash .approve {
+	display: inline;
+}
+
+.unapproved .unapprove {
+	display: none;
+}
+
+.add-new-h2 {
+	font-style: normal;
+	margin: 0 6px;
+	position: relative;
+	top: -3px;
+}
+
+td.action-links,
+th.action-links {
+	text-align: right;
+}
+
+.describe .del-link {
+	padding-left: 5px;
+}
+
+
+/*------------------------------------------------------------------------------
+  4.0 - Notifications
+------------------------------------------------------------------------------*/
+
+#update-nag, .update-nag {
+	line-height: 19px;
+	padding: 5px 0;
+	font-size: 12px;
+	text-align: center;
+	margin: 0 15px;
+	border-width: 1px;
+	border-style: solid;
+	border-top-width: 0;
+	border-top-style: none;
+	-moz-border-radius: 0 0 6px 6px;
+	-webkit-border-bottom-right-radius: 6px;
+	-webkit-border-bottom-left-radius: 6px;
+	-khtml-border-bottom-right-radius: 6px;
+	-khtml-border-bottom-left-radius: 6px;
+	border-bottom-right-radius: 6px;
+	border-bottom-left-radius: 6px;
+}
+
+.plugins .plugin-update {
+	padding: 0;
+}
+
+.plugin-update .update-message {
+	margin: 0 10px 8px 31px;
+	font-weight: bold;
+}
+
+ul#dismissed-updates {
+	display: none;
+}
+form.upgrade {
+	margin-top: 8px;
+}
+
+form.upgrade .hint {
+	font-style: italic;
+	font-size: 85%;
+	margin: -0.5em 0 2em 0;
+}
+
+.ajax-feedback {
+	visibility: hidden;
+	vertical-align: bottom;
+}
+
+#ajax-response.alignleft {
+	margin-left: 2em;
+}
+
+
+/*------------------------------------------------------------------------------
+  5.0 - TinyMCE
+------------------------------------------------------------------------------*/
+
+#editorcontainer #content {
+	padding: 6px;
+	line-height: 150%;
+	border: 0 none;
+	outline: none;
+	resize: vertical;
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	-khtml-box-sizing: border-box;
+	box-sizing: border-box;
+}
+
+#editorcontainer,
+#quicktags {
+	border-style: solid;
+	border-width: 1px;
+	border-collapse: separate;
+	-moz-border-radius: 6px 6px 0 0;
+	-webkit-border-top-right-radius: 6px;
+	-webkit-border-top-left-radius: 6px;
+	-khtml-border-top-right-radius: 6px;
+	-khtml-border-top-left-radius: 6px;
+	border-top-right-radius: 6px;
+	border-top-left-radius: 6px;
+}
+
+#quicktags {
+	padding: 0;
+	margin-bottom: -3px;
+	border-bottom-width: 3px;
+	background-image: url("../images/ed-bg.gif");
+	background-position: left top;
+	background-repeat: repeat-x;
+}
+
+#quicktags #ed_toolbar {
+	padding: 2px 4px 0;
+}
+
+#ed_toolbar input,
+#ed_reply_toolbar input {
+	margin: 3px 1px 4px;
+	line-height: 18px;
+	display: inline-block;
+	min-width: 26px;
+	padding: 2px 4px;
+	font-size: 12px;
+}
+
+#ed_reply_toolbar input {
+	margin: 1px 2px 1px 1px;
+}
+
+#quicktags #ed_link,
+#ed_reply_toolbar #ed_reply_link {
+	text-decoration: underline;
+}
+
+#quicktags #ed_del,
+#ed_reply_toolbar #ed_reply_del {
+	text-decoration: line-through;
+}
+
+#quicktags #ed_em,
+#ed_reply_toolbar #ed_reply_em {
+	font-style: italic;
+}
+
+#wp_editbtns,
+#wp_gallerybtns {
+	padding: 2px;
+	position: absolute;
+	display: none;
+	z-index: 999998;
+}
+
+#wp_editimgbtn,
+#wp_delimgbtn,
+#wp_editgallery,
+#wp_delgallery {
+	margin: 2px;
+	padding: 2px;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+}
+
+
+/*------------------------------------------------------------------------------
+  6.0 - Admin Header
+------------------------------------------------------------------------------*/
+#wphead-info {
+	margin: 0 0 0 15px;
+	padding-right: 15px;
+}
+
+#user_info {
+	float: right;
+	font-size: 12px;
+	line-height: 46px;
+	height: 46px;
+}
+
+#user_info p {
+	margin: 0;
+	padding: 0;
+	line-height: 46px;
+}
+
+#wphead {
+	height: 46px;
+}
+
+#wphead a,
+#adminmenu a,
+#sidemenu a,
+#taglist a,
+#catlist a,
+#show-settings a {
+	text-decoration: none;
+}
+
+#header-logo {
+	float: left;
+	margin: 7px 0 0 15px;
+}
+
+#wphead h1 {
+	font: normal 22px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	padding: 10px 8px 5px;
+	margin: 0;
+	float: left;
+}
+
+#wphead h1.long-title {
+	font: normal 18px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	padding: 12px 10px 5px;
+}
+
+#wphead #privacy-on-link {
+	font-size: 50%;
+	font-style: normal;
+	line-height: 17px;
+	padding: 0 6px;
+	vertical-align: middle;
+}
+
+#wphead h1 a:hover {
+	text-decoration:none;
+}
+#wphead h1 a:hover #site-title,
+#wphead h1 a#privacy-on-link:hover {
+	text-decoration:underline;
+}
+
+
+/*------------------------------------------------------------------------------
+  6.1 - Favorites Menu
+------------------------------------------------------------------------------*/
+
+#favorite-actions {
+	float: right;
+	margin: 11px 12px 0;
+	min-width: 130px;
+	position: relative;
+}
+
+#favorite-first {
+	-moz-border-radius: 12px;
+	-khtml-border-radius: 12px;
+	-webkit-border-radius: 12px;
+	border-radius: 12px;
+	line-height: 15px;
+	padding: 3px 30px 4px 12px;
+	border-width: 1px;
+	border-style: solid;
+}
+
+#favorite-inside {
+	margin: 0 0 0 0px;
+	padding: 2px 1px;
+	border-width: 1px;
+	border-style: solid;
+	position: absolute;
+	z-index: 11;
+	display: none;
+	-moz-border-radius: 0 0 12px 12px;
+	-webkit-border-bottom-right-radius: 12px;
+	-webkit-border-bottom-left-radius: 12px;
+	-khtml-border-bottom-right-radius: 12px;
+	-khtml-border-bottom-left-radius: 12px;
+	border-bottom-right-radius: 12px;
+	border-bottom-left-radius: 12px;
+}
+
+#favorite-actions a {
+	display: block;
+	text-decoration: none;
+	font-size: 11px;
+}
+
+#favorite-inside a {
+	padding: 3px 5px 3px 10px;
+}
+
+#favorite-toggle {
+	height: 22px;
+	position: absolute;
+	right: 0;
+	top: 1px;
+	width: 28px;
+}
+
+#favorite-actions .slide-down {
+	-moz-border-radius: 12px 12px 0 0;
+	-webkit-border-bottom-right-radius: 0;
+	-webkit-border-bottom-left-radius: 0;
+	-khtml-border-bottom-right-radius: 0;
+	-khtml-border-bottom-left-radius: 0;
+	border-bottom-right-radius: 0;
+	border-bottom-left-radius: 0;
+	border-bottom: none;
+}
+
+
+/*------------------------------------------------------------------------------
+  6.2 - Screen Options Tabs
+------------------------------------------------------------------------------*/
+
+#screen-meta {
+	position: relative;
+	clear: both;
+}
+
+#screen-meta-links {
+	margin: 0 18px 0 0;
+}
+
+#screen-meta .screen-reader-text {
+	visibility: hidden;
+}
+
+#screen-options-link-wrap,
+#contextual-help-link-wrap {
+	float: right;
+	height: 22px;
+	padding: 0;
+	margin: 0 6px 0 0;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	background: #e3e3e3;
+	-moz-border-radius-bottomleft: 3px;
+	-moz-border-radius-bottomright: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-webkit-border-bottom-right-radius: 3px;
+}
+
+#contextual-help-wrap li {
+	list-style-type: disc;
+	margin-left: 18px;
+}
+.toggle-arrow {
+	background-repeat: no-repeat;
+	background-position: top left;
+	background-color: transparent;
+	height: 22px;
+	line-height: 22px;
+	display: block;
+}
+.toggle-arrow-active {
+	background-position: bottom left;
+}
+#screen-meta a.show-settings {
+	text-decoration: none;
+	z-index: 1;
+	padding: 0 16px 0 6px;
+	height: 22px;
+	line-height: 22px;
+	font-size: 10px;
+	display: block;
+	background-repeat: no-repeat;
+	background-position: top right;
+	background-color: transparent;
+	text-shadow: rgba(255,255,255,0.7) 0 1px 0;
+}
+
+#screen-meta a.show-settings:hover {
+	text-decoration: none;
+}
+
+#screen-options-wrap h5,
+#contextual-help-wrap h5 {
+	margin: 8px 0;
+	font-size: 13px;
+}
+
+#screen-options-wrap,
+#contextual-help-wrap {
+	border-style: none solid solid;
+	border-top: 0 none;
+	border-width: 0 1px 1px;
+	margin: 0 15px;
+	padding: 8px 12px 12px;
+	-moz-border-radius: 0 0 4px 4px;
+	-webkit-border-radius: 0 0 4px 4px;
+	-khtml-border-radius: 0 0 4px 4px;
+	border-radius: 0 0 4px 4px;
+}
+
+.metabox-prefs label {
+	display: inline-block;
+	padding-right: 15px;
+	white-space: nowrap;
+	line-height: 30px;
+}
+
+.metabox-prefs label input {
+	margin: 0 5px 0 2px;
+}
+
+.metabox-prefs label a {
+	display: none;
+}
+
+
+/*------------------------------------------------------------------------------
+  7.0 - Main Navigation (Left Menu)
+------------------------------------------------------------------------------*/
+
+/* side admin menu */
+#adminmenu * {
+	-webkit-user-select: none;
+	-moz-user-select: none;
+	-khtml-user-select: none;
+	user-select: none;
+}
+
+#adminmenu .wp-submenu {
+	display: none;
+	list-style: none;
+	padding: 0;
+	margin: 0;
+	position: relative;
+	z-index: 2;
+	border-width: 1px 0 0;
+	border-style: solid none none;
+}
+
+#adminmenu .wp-submenu a {
+	font: normal 11px/18px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
+
+#adminmenu .wp-submenu li.current,
+#adminmenu .wp-submenu li.current a,
+#adminmenu .wp-submenu li.current a:hover {
+	font-weight: bold;
+}
+
+#adminmenu a.menu-top,
+#adminmenu .wp-submenu-head {
+	font: normal 13px/18px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+}
+
+#adminmenu div.wp-submenu-head {
+	display: none;
+}
+
+.folded #adminmenu div.wp-submenu-head,
+.folded #adminmenu li.wp-has-submenu div.sub-open {
+	display: block;
+}
+
+.folded #adminmenu a.menu-top,
+.folded #adminmenu .wp-submenu,
+.folded #adminmenu li.wp-menu-open .wp-submenu,
+.folded #adminmenu div.wp-menu-toggle {
+	display: none;
+}
+
+#adminmenu li.wp-menu-open .wp-submenu,
+.no-js #adminmenu .open-if-no-js .wp-submenu {
+	display: block;
+}
+
+#adminmenu div.wp-menu-image {
+	float: left;
+	width: 28px;
+	height: 28px;
+}
+
+#adminmenu li {
+	margin: 0;
+	padding: 0;
+	cursor: pointer;
+}
+
+#adminmenu a {
+	display: block;
+	line-height: 18px;
+	padding: 1px 5px 3px;
+}
+
+#adminmenu li.menu-top {
+	min-height: 26px;
+}
+
+#adminmenu a.menu-top {
+	line-height: 18px;
+	min-width: 10em;
+	padding: 5px 5px;
+	border-width: 1px 1px 0;
+	border-style: solid solid none;
+}
+
+#adminmenu .wp-submenu a {
+	margin: 0;
+	padding-left: 12px;
+	border-width: 0 1px 0 0;
+	border-style: none solid none none;
+}
+
+#adminmenu .menu-top-last ul.wp-submenu {
+	border-width: 0 0 1px;
+	border-style: none none solid;
+}
+
+#adminmenu .wp-submenu li {
+	padding: 0;
+	margin: 0;
+}
+
+.folded #adminmenu li.menu-top {
+	width: 28px;
+	height: 30px;
+	overflow: hidden;
+	border-width: 1px 1px 0;
+	border-style: solid solid none;
+}
+
+#adminmenu .menu-top-first a.menu-top,
+.folded #adminmenu li.menu-top-first,
+#adminmenu .wp-submenu .wp-submenu-head {
+	border-width: 1px 1px 0;
+	border-style: solid solid none;
+	-moz-border-radius-topleft :6px;
+	-moz-border-radius-topright: 6px;
+	-webkit-border-top-right-radius: 6px;
+	-webkit-border-top-left-radius: 6px;
+	-khtml-border-top-right-radius: 6px;
+	-khtml-border-top-left-radius: 6px;
+	border-top-right-radius: 6px;
+	border-top-left-radius: 6px;
+}
+
+#adminmenu .menu-top-last a.menu-top,
+.folded #adminmenu li.menu-top-last {
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius-bottomleft: 6px;
+	-moz-border-radius-bottomright: 6px;
+	-webkit-border-bottom-right-radius: 6px;
+	-webkit-border-bottom-left-radius: 6px;
+	-khtml-border-bottom-right-radius: 6px;
+	-khtml-border-bottom-left-radius: 6px;
+	border-bottom-right-radius: 6px;
+	border-bottom-left-radius: 6px;
+}
+
+#adminmenu li.wp-menu-open a.menu-top-last {
+	border-bottom: 0 none;
+	-moz-border-radius-bottomright: 0;
+	-moz-border-radius-bottomleft: 0;
+	-webkit-border-bottom-right-radius: 0;
+	-webkit-border-bottom-left-radius: 0;
+	-khtml-border-bottom-right-radius: 0;
+	-khtml-border-bottom-left-radius: 0;
+	border-bottom-right-radius: 0;
+	border-bottom-left-radius: 0;
+}
+
+#adminmenu .wp-menu-image img {
+	float: left;
+	padding: 8px 6px 0;
+	opacity: 0.6;
+	filter: alpha(opacity=60);
+}
+
+#adminmenu li.menu-top:hover .wp-menu-image img,
+#adminmenu li.wp-has-current-submenu .wp-menu-image img {
+	opacity: 1;
+	filter: alpha(opacity=100);
+}
+
+#adminmenu li.wp-menu-separator {
+	height: 21px;
+	padding: 0;
+	margin: 0;
+}
+
+#adminmenu a.separator {
+	cursor: w-resize;
+	height: 20px;
+	padding: 0;
+}
+
+.folded #adminmenu a.separator {
+ 	cursor: e-resize;
+}
+
+#adminmenu .wp-menu-separator-last {
+	height: 10px;
+	width: 1px;
+}
+
+#adminmenu .wp-submenu .wp-submenu-head {
+	border-width: 1px;
+	border-style: solid;
+	padding: 6px 4px 6px 10px;
+	cursor: default;
+}
+
+.folded #adminmenu .wp-submenu {
+	position: absolute;
+	margin: -1px 0 0 28px;
+	padding: 0 8px 8px;
+	z-index: 999;
+	border: 0 none;
+}
+
+.folded #adminmenu .wp-submenu ul {
+	width: 140px;
+	border-width: 0 0 1px;
+	border-style: none none solid;
+}
+
+.folded #adminmenu .wp-submenu li.wp-first-item {
+	border-top: 0 none;
+}
+
+.folded #adminmenu .wp-submenu a {
+	padding-left: 10px;
+}
+
+.folded #adminmenu a.wp-has-submenu {
+	margin-left: 40px;
+}
+
+#adminmenu li.menu-top-last .wp-submenu ul {
+	border-width: 0 0 1px;
+	border-style: none none solid;
+}
+
+#adminmenu .wp-menu-toggle {
+	width: 22px;
+	clear: right;
+	float: right;
+	margin: 1px 0 0;
+	height: 27px;
+	padding: 1px 2px 0 0;
+	cursor: default;
+}
+
+#adminmenu li.wp-has-current-submenu ul {
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+}
+
+#adminmenu .wp-menu-image a {
+	height: 24px;
+}
+
+#adminmenu .wp-menu-image img {
+	padding: 6px 0 0 1px;
+}
+
+#adminmenu #awaiting-mod,
+#adminmenu span.update-plugins,
+#sidemenu li a span.update-plugins {
+	position: absolute;
+	font-family: Helvetica, Arial, sans-serif;
+	font-size: 9px;
+	line-height: 17px;
+	font-weight: bold;
+	margin-top: 1px;
+	margin-left: 7px;
+	-moz-border-radius: 10px;
+	-khtml-border-radius: 10px;
+	-webkit-border-radius: 10px;
+	border-radius: 10px;
+}
+
+#adminmenu li #awaiting-mod span,
+#adminmenu li span.update-plugins span,
+#sidemenu li a span.update-plugins span {
+	display: block;
+	padding: 0 6px;
+}
+
+#adminmenu li span.count-0,
+#sidemenu li a .count-0 {
+	display: none;
+}
+
+.post-com-count-wrapper {
+	min-width: 22px;
+	font-family: Helvetica, Arial, sans-serif;
+}
+
+.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;
+}
+
+.post-com-count span {
+	font-size: 9px;
+	font-weight: bold;
+	height: 1.7em;
+	line-height: 1.70em;
+	min-width: 0.7em;
+	padding: 0 6px;
+	display: inline-block;
+	cursor: pointer;
+	-moz-border-radius: 5px;
+	-khtml-border-radius: 5px;
+	-webkit-border-radius: 5px;
+	border-radius: 5px;
+}
+
+strong .post-com-count {
+	background-position: center -55px;
+}
+
+.post-com-count:hover {
+	background-position: center -3px;
+}
+
+.column-response .post-com-count {
+	float: left;
+	margin-right: 5px;
+	text-align: center;
+}
+
+.response-links {
+	float: left;
+}
+
+#the-comment-list .attachment-80x60 {
+	padding: 4px 8px;
+}
+
+
+/*------------------------------------------------------------------------------
+  8.0 - Layout Blocks
+------------------------------------------------------------------------------*/
+
+body.wp-admin {
+	min-width: 785px;
+}
+
+body.admin-bar #wphead {
+	padding-top: 28px;
+}
+
+.narrow {
+	width: 70%;
+	margin-bottom: 40px;
+}
+
+.narrow p {
+	line-height: 150%;
+}
+
+.widefat th,
+.widefat td {
+	overflow: hidden;
+}
+
+.widefat td p {
+	margin: 2px 0 0.8em;
+}
+
+.widefat .column-comment p {
+	margin: 0.6em 0;
+}
+
+.widget .widget-top,
+.postbox h3 {
+	cursor: move;
+	-webkit-user-select: none;
+	-moz-user-select: none;
+	-khtml-user-select: none;
+	user-select: none;
+}
+
+.postbox-container {
+	float: left;
+	padding-right: 0.5%;
+}
+
+.postbox-container .meta-box-sortables {
+	min-height: 300px;
+}
+
+.postbox .hndle span {
+	padding: 6px 0;
+}
+
+.postbox .hndle {
+	cursor: move;
+}
+
+.hndle a {
+	font-size: 11px;
+	font-weight: normal;
+}
+
+.postbox .handlediv {
+	float: right;
+	width: 23px;
+	height: 26px;
+}
+
+.sortable-placeholder {
+	border-width: 1px;
+	border-style: dashed;
+	margin-bottom: 20px;
+}
+
+.widget,
+.postbox,
+.stuffbox {
+	margin-bottom: 20px;
+	border-width: 1px;
+	border-style: solid;
+	line-height: 1;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+.widget .widget-top,
+.postbox h3,
+.postbox h3,
+.stuffbox h3 {
+	-moz-border-radius: 6px 6px 0 0;
+	-webkit-border-top-right-radius: 6px;
+	-webkit-border-top-left-radius: 6px;
+	-khtml-border-top-right-radius: 6px;
+	-khtml-border-top-left-radius: 6px;
+	border-top-right-radius: 6px;
+	border-top-left-radius: 6px;
+}
+
+.postbox.closed h3 {
+	-moz-border-radius-bottomleft: 4px;
+	-webkit-border-bottom-left-radius: 4px;
+	-khtml-border-bottom-left-radius: 4px;
+	border-bottom-left-radius: 4px;
+	-moz-border-radius-bottomright: 4px;
+	-webkit-border-bottom-right-radius: 4px;
+	-khtml-border-bottom-right-radius: 4px;
+	border-bottom-right-radius: 4px;
+}
+
+.postbox table.form-table {
+	margin-bottom: 0;
+}
+
+.postbox input[type="text"],
+.postbox textarea,
+.stuffbox input[type="text"],
+.stuffbox textarea {
+	border-width: 1px;
+	border-style: solid;
+}
+
+.temp-border {
+	border: 1px dotted #ccc;
+}
+
+.columns-prefs label {
+	padding: 0 5px;
+}
+
+
+/*------------------------------------------------------------------------------
+  9.0 - Dashboard
+------------------------------------------------------------------------------*/
+
+#wpbody-content .metabox-holder {
+	padding-top: 10px;
+}
+
+#dashboard-widgets .meta-box-sortables {
+	margin: 0 5px;
+}
+
+#dashboard_recent_comments div.undo {
+	border-top-style: solid;
+	border-top-width: 1px;
+	margin: 0 -10px;
+	padding: 3px 8px;
+	font-size: 11px;
+}
+
+#the-comment-list td.comment p.comment-author {
+	margin-top: 0;
+	margin-left: 0;
+}
+
+#the-comment-list p.comment-author img {
+	float: left;
+	margin-right: 8px;
+}
+
+#the-comment-list p.comment-author strong a {
+	border: none;
+}
+
+#the-comment-list td {
+	vertical-align: top;
+}
+
+#the-comment-list td.comment {
+	word-wrap: break-word;
+}
+
+#the-comment-list .check-column {
+	padding-top: 8px;
+}
+
+
+/*------------------------------------------------------------------------------
+  10.0 - List Posts (/Pages/etc)
+------------------------------------------------------------------------------*/
+
+table.fixed {
+	table-layout: fixed;
+}
+.fixed .column-rating,
+.fixed .column-visible {
+	width: 8%;
+}
+.fixed .column-date,
+.fixed .column-parent,
+.fixed .column-links {
+	width: 10%;
+}
+.fixed .column-response,
+.fixed .column-author,
+.fixed .column-categories,
+.fixed .column-tags,
+.fixed .column-rel,
+.fixed .column-role {
+	width: 15%;
+}
+.fixed .column-comments {
+	width: 4em;
+	padding: 8px 0;
+	text-align: left;
+}
+.fixed .column-comments .vers {
+	padding-left: 3px;
+}
+.fixed .column-comments a {
+	float: left;
+}
+.fixed .column-slug {
+	width: 25%;
+}
+.fixed .column-posts {
+	width: 10%;
+}
+.fixed .column-icon {
+	width: 80px;
+}
+#commentsdiv .fixed .column-author,
+#comments-form .fixed .column-author {
+	width: 20%;
+}
+#commentsdiv.postbox .inside {
+	line-height:1.4em;
+	margin:0;
+}
+#commentsdiv.postbox .inside .row-actions {
+	line-height:18px;
+}
+#commentsdiv.postbox .inside td {
+	padding:1em 10px;
+}
+#commentsdiv.postbox .inside .column-comment p {
+}
+#commentsdiv.postbox .inside .column-author {
+	width:33%;
+}
+#commentsdiv.postbox .inside p {
+	margin:6px 10px 8px;
+}
+#commentsdiv.postbox .column-comment p {
+	margin:0.6em 0;
+}
+#commentsdiv.postbox #replyrow td {
+	padding:0;
+}
+.sorting-indicator {
+	display: none;
+	width: 7px;
+	height: 4px;
+	margin-top: 5px;
+	margin-left: 7px;
+	background-image: url(../images/sort.gif);
+	background-repeat: no-repeat;
+}
+.fixed .column-comments .sorting-indicator {
+	margin-top: 3px;
+}
+.widefat th.sortable,
+.widefat th.sorted {
+	padding: 0;
+}
+th.sortable a,
+th.sorted a {
+	display: block;
+	overflow: hidden;
+	padding: 7px 7px 8px;
+}
+.fixed .column-comments.sortable a,
+.fixed .column-comments.sorted a {
+	padding: 8px 0;
+}
+th.sortable a span,
+th.sorted a span {
+	float: left;
+	cursor: pointer;
+}
+th.sorted.asc .sorting-indicator,
+th.desc:hover span.sorting-indicator {
+	display: block;
+	background-position: 0 0;
+}
+th.sorted.desc .sorting-indicator,
+th.asc:hover span.sorting-indicator {
+	display: block;
+	background-position: -7px 0;
+}
+
+/* Bulk Actions */
+
+.tablenav-pages a {
+	border-bottom-style: solid;
+	border-bottom-width: 2px;
+	font-weight: bold;
+	margin-right: 1px;
+	padding: 0 2px;
+}
+.tablenav-pages .current-page {
+	text-align: center;
+}
+.tablenav-pages .next-page {
+	margin-left: 2px;
+}
+
+.tablenav a.button-secondary {
+	display: block;
+	margin: 3px 8px 0 0;
+}
+
+.tablenav {
+	clear: both;
+	height: 30px;
+	margin: 6px 0 4px;
+	vertical-align: middle;
+}
+
+.tablenav .tablenav-pages {
+	float: right;
+	display: block;
+	cursor: default;
+	height: 30px;
+	line-height: 30px;
+	font-size: 11px;
+}
+
+.tablenav .one-page {
+	display: none;
+}
+
+.tablenav .tablenav-pages a,
+.tablenav-pages span.current  {
+	text-decoration: none;
+	border: none;
+	padding: 3px 6px;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 5px;
+	-khtml-border-radius: 5px;
+	-webkit-border-radius: 5px;
+	border-radius: 5px;
+}
+
+.tablenav .tablenav-pages a.disabled:hover {
+	cursor: default;
+}
+
+.tablenav .tablenav-pages a.disabled:active {
+	cursor: default;
+}
+
+.tablenav .displaying-num {
+	margin-right: 10px;
+	font-size: 12px;
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	font-style: italic;
+}
+
+.tablenav .actions {
+	padding: 2px 8px 0 0;
+}
+
+.tablenav .delete {
+	margin-right: 20px;
+}
+
+.view-switch {
+	float: right;
+	margin: 6px 8px 0;
+}
+
+.view-switch a {
+	text-decoration: none;
+}
+
+.filter {
+	float: left;
+	margin: -5px 0 0 10px;
+}
+
+.filter .subsubsub {
+	margin-left: -10px;
+	margin-top: 13px;
+}
+.screen-per-page {
+	width: 3em;
+}
+
+#posts-filter fieldset {
+	float: left;
+	margin: 0 1.5ex 1em 0;
+	padding: 0;
+}
+
+#posts-filter fieldset legend {
+	padding: 0 0 .2em 1px;
+}
+
+span.post-state-format {
+	font-weight: normal;
+}
+
+
+/*------------------------------------------------------------------------------
+  10.1 - Inline Editing
+------------------------------------------------------------------------------*/
+
+/*
+.quick-edit* is for Quick Edit
+.bulk-edit* is for Bulk Edit
+.inline-edit* is for everything
+*/
+
+/*	Layout */
+tr.inline-edit-row td {
+	padding: 0 0.5em;
+}
+
+#wpbody-content .inline-edit-row fieldset {
+	font-size: 12px;
+	float: left;
+	margin: 0;
+	padding: 0;
+	width: 100%;
+}
+
+#wpbody-content .inline-edit-row fieldset .inline-edit-col {
+	padding: 0 0.5em;
+}
+
+#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col {
+	border-width: 0 0 0 1px;
+	border-style: none none none solid;
+}
+
+#wpbody-content .quick-edit-row-post .inline-edit-col-left {
+	width: 40%;
+}
+
+#wpbody-content .quick-edit-row-post .inline-edit-col-right {
+	width: 39%;
+}
+
+#wpbody-content .inline-edit-row-post .inline-edit-col-center {
+	width: 20%;
+}
+
+#wpbody-content .quick-edit-row-page .inline-edit-col-left {
+	width: 50%;
+}
+
+#wpbody-content .quick-edit-row-page .inline-edit-col-right,
+#wpbody-content .bulk-edit-row-post .inline-edit-col-right {
+	width: 49%;
+}
+
+#wpbody-content .bulk-edit-row .inline-edit-col-left {
+	width: 30%;
+}
+
+#wpbody-content .bulk-edit-row-page .inline-edit-col-right {
+	width: 69%;
+}
+
+#wpbody-content .bulk-edit-row .inline-edit-col-bottom {
+	float: right;
+	width: 69%;
+}
+
+#wpbody-content .inline-edit-row-page .inline-edit-col-right,
+#wpbody-content .bulk-edit-row-post .inline-edit-col-right {
+	margin-top: 27px;
+}
+
+.inline-edit-row fieldset .inline-edit-group {
+	clear: both;
+}
+
+.inline-edit-row fieldset .inline-edit-group:after {
+	content: ".";
+	display: block;
+	height: 0;
+	clear: both;
+	visibility: hidden;
+}
+
+.inline-edit-row p.submit {
+	clear: both;
+	padding: 0.5em;
+	margin: 0.5em 0 0;
+}
+
+.inline-edit-row span.error {
+	line-height: 22px;
+	margin: 0 15px;
+	padding: 3px 5px;
+}
+
+/*	Positioning */
+.inline-edit-row h4 {
+	margin: .2em 0;
+	padding: 0;
+	line-height: 23px;
+}
+.inline-edit-row fieldset span.title,
+.inline-edit-row fieldset span.checkbox-title {
+	margin: 0;
+	padding: 0;
+	line-height: 27px;
+}
+
+.inline-edit-row fieldset label,
+.inline-edit-row fieldset span.inline-edit-categories-label {
+	display: block;
+	margin: .2em 0;
+}
+
+.inline-edit-row fieldset label.inline-edit-tags {
+	margin-top: 0;
+}
+
+.inline-edit-row fieldset label.inline-edit-tags span.title {
+	margin: .2em 0;
+}
+
+.inline-edit-row fieldset label span.title {
+	display: block;
+	float: left;
+	width: 5em;
+}
+
+.inline-edit-row fieldset label span.input-text-wrap {
+	display: block;
+	margin-left: 5em;
+}
+
+.quick-edit-row-post fieldset.inline-edit-col-right label span.title {
+	width: auto;
+	padding-right: 0.5em;
+}
+
+.inline-edit-row .input-text-wrap input[type=text] {
+	width: 100%;
+}
+
+.inline-edit-row fieldset label input[type=checkbox] {
+	vertical-align: text-bottom;
+}
+
+.inline-edit-row fieldset label textarea {
+	width: 100%;
+	height: 4em;
+}
+
+#wpbody-content .bulk-edit-row fieldset .inline-edit-group label {
+	max-width: 50%;
+}
+
+#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child {
+	margin-right: 0.5em
+}
+
+/*	Styling */
+.inline-edit-row h4 {
+	text-transform: uppercase;
+}
+
+.inline-edit-row fieldset span.title,
+.inline-edit-row fieldset span.checkbox-title {
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	font-style: italic;
+	line-height: 1.8em;
+}
+
+/*	Specific Elements */
+.inline-edit-row fieldset input[type="text"],
+.inline-edit-row fieldset textarea {
+	border-style: solid;
+	border-width: 1px;
+}
+
+.inline-edit-row fieldset .inline-edit-date {
+	float: left;
+}
+
+.inline-edit-row fieldset input[name=jj],
+.inline-edit-row fieldset input[name=hh],
+.inline-edit-row fieldset input[name=mn] {
+	font-size: 12px;
+	width: 2.1em;
+}
+
+.inline-edit-row fieldset input[name=aa] {
+	font-size: 12px;
+	width: 3.5em;
+}
+
+.inline-edit-row fieldset label input.inline-edit-password-input {
+	width: 8em;
+}
+
+.inline-edit-row .catshow,
+.inline-edit-row .cathide {
+	cursor: pointer;
+}
+
+ul.cat-checklist {
+	height: 12em;
+	border-style: solid;
+	border-width: 1px;
+	overflow-y: scroll;
+	padding: 0 5px;
+	margin: 0;
+}
+
+#bulk-titles {
+	display: block;
+	height: 12em;
+	border-style: solid;
+	border-width: 1px;
+	overflow-y: scroll;
+	padding: 0 5px;
+	margin: 0 0 5px;
+}
+
+.inline-edit-row fieldset ul.cat-checklist li,
+.inline-edit-row fieldset ul.cat-checklist input {
+	margin: 0;
+}
+
+.inline-edit-row fieldset ul.cat-checklist label,
+.inline-edit-row .catshow,
+.inline-edit-row .cathide,
+.inline-edit-row #bulk-titles div {
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+	font-style: normal;
+	font-size: 11px;
+}
+
+table .inline-edit-row fieldset ul.cat-hover {
+	height: auto;
+	max-height: 30em;
+	overflow-y: auto;
+	position: absolute;
+}
+
+.inline-edit-row fieldset label input.inline-edit-menu-order-input {
+	width: 3em;
+}
+
+.inline-edit-row fieldset label input.inline-edit-slug-input {
+	width: 75%;
+}
+
+.quick-edit-row-post fieldset label.inline-edit-status {
+	float: left;
+}
+
+#bulk-titles {
+	line-height: 140%;
+}
+#bulk-titles div {
+	margin: 0.2em 0.3em;
+}
+
+#bulk-titles div a {
+	cursor: pointer;
+	display: block;
+	float: left;
+	height: 10px;
+	margin: 3px 3px 0 -2px;
+	overflow: hidden;
+	position: relative;
+	text-indent: -9999px;
+	width: 10px;
+}
+
+
+/*------------------------------------------------------------------------------
+  11.0 - Write/Edit Post Screen
+------------------------------------------------------------------------------*/
+
+#titlediv {
+	position: relative;
+	margin-bottom: 20px;
+}
+#titlediv label { cursor: text; }
+
+#titlediv div.inside {
+	margin: 0;
+}
+
+#poststuff #titlewrap {
+	border: 0;
+	padding: 0;
+
+}
+
+#titlediv #title {
+	padding: 3px 4px;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+	font-size: 1.7em;
+	line-height: 100%;
+	width: 100%;
+	outline: none;
+}
+
+#titlediv #title-prompt-text {
+	color: #bbb;
+	position: absolute;
+	font-size: 1.7em;
+	padding: 8px;
+}
+
+#poststuff .inside-submitbox,
+#side-sortables .inside-submitbox {
+	margin: 0 3px;
+	font-size: 11px;
+}
+
+input#link_description,
+input#link_url {
+	width: 98%;
+}
+
+#pending {
+	background: 0 none;
+	border: 0 none;
+	padding: 0;
+	font-size: 11px;
+	margin-top: -1px;
+}
+
+#edit-slug-box {
+	height: 1em;
+	margin-top: 8px;
+	padding: 0 7px;
+}
+
+#editable-post-name-full {
+	display: none;
+}
+
+#editable-post-name input {
+	width: 16em;
+}
+
+.postarea h3 label {
+	float: left;
+}
+
+.postarea #add-media-button {
+	float: right;
+	margin: 7px 0pt 0pt;
+	position: relative;
+	right: 10px;
+}
+
+#poststuff #editor-toolbar {
+	height: 30px;
+}
+
+.wp_themeSkin tr.mceFirst td.mceToolbar {
+	border-width: 0 0 1px;
+	border-style: none none solid;
+}
+
+#edButtonPreview,
+#edButtonHTML {
+	height: 18px;
+	margin: 5px 5px 0 0;
+	padding: 4px 5px 2px;
+	float: right;
+	cursor: pointer;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 3px 3px 0 0;
+	-webkit-border-top-right-radius: 3px;
+	-webkit-border-top-left-radius: 3px;
+	-khtml-border-top-right-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	border-top-right-radius: 3px;
+	border-top-left-radius: 3px;
+}
+
+.js .theEditor {
+	color: white;
+}
+
+#poststuff #edButtonHTML {
+	margin-right: 15px;
+}
+
+#media-buttons {
+	cursor: default;
+	padding: 8px 8px 0;
+}
+
+#media-buttons a {
+	cursor: pointer;
+	padding: 0 0 5px 10px;
+}
+
+#media-buttons img,
+#submitpost #ajax-loading,
+#submitpost .ajax-loading {
+	vertical-align: middle;
+}
+
+#wpcontent .ajax-loading {
+	visibility: hidden;
+}
+
+.submitbox .submit {
+	text-align: left;
+	padding: 12px 10px 10px;
+	font-size: 11px;
+}
+
+.submitbox .submitdelete {
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+	text-decoration: none;
+	padding: 1px 2px;
+}
+
+.inside-submitbox #post_status {
+	margin: 2px 0 2px -2px;
+}
+
+.submitbox .submit a:hover {
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+}
+
+.submitbox .submit input {
+	margin-bottom: 8px;
+	margin-right: 4px;
+	padding: 6px;
+}
+
+#post-status-select, #post-format {
+	line-height: 2.5em;
+	margin-top: 3px;
+}
+
+/* Post Screen */
+#post-body #normal-sortables {
+	min-height: 50px;
+}
+
+#post-body #advanced-sortables {
+	min-height: 20px;
+}
+
+.postbox {
+	position: relative;
+	min-width: 255px;
+	width: 99.5%;
+}
+
+#trackback_url {
+	width: 99%;
+}
+
+#normal-sortables .postbox .submit {
+	background: transparent none;
+	border: 0 none;
+	float: right;
+	padding: 0 12px;
+	margin:0;
+}
+
+#side-sortables .category-add input {
+	width: 94%;
+}
+
+#side-sortables .category-add select {
+	width: 100%;
+}
+
+#side-sortables .category-add input.category-add-sumbit, #post-body .category-add input.category-add input.category-add-sumbit {
+	width: auto;
+}
+
+#post-body ul.category-tabs,
+#post-body ul.add-menu-item-tabs {
+	float: left;
+	width: 120px;
+	text-align: right;
+	/* Negative margin for the sake of those without JS: all tabs display */
+	margin: 0 -120px 0 5px;
+	padding: 0;
+}
+
+#post-body ul.category-tabs li,
+#post-body ul.add-menu-item-tabs li {
+	padding: 8px;
+}
+
+#post-body ul.category-tabs li.tabs,
+#post-body ul.add-menu-item-tabs li.tabs {
+	-moz-border-radius: 3px 0 0 3px;
+	-webkit-border-top-left-radius: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	border-top-left-radius: 3px;
+	border-bottom-left-radius: 3px;
+}
+
+#post-body ul.category-tabs li.tabs a,
+#post-body ul.add-menu-item-tabs li.tabs a {
+	font-weight: bold;
+	text-decoration: none;
+}
+
+.wp-tab-panel,
+.categorydiv div.tabs-panel,
+.customlinkdiv div.tabs-panel,
+.posttypediv div.tabs-panel,
+.taxonomydiv div.tabs-panel,
+#linkcategorydiv div.tabs-panel {
+	height: 200px;
+	overflow: auto;
+	padding: 0.5em 0.9em;
+	border-style: solid;
+	border-width: 1px;
+}
+
+.nav-menus-php .customlinkdiv div.tabs-panel,
+.nav-menus-php .posttypediv div.tabs-panel,
+.nav-menus-php .taxonomydiv div.tabs-panel {
+	height: auto;
+	max-height: 205px;
+}
+
+div.tabs-panel-active {
+	display:block;
+}
+
+div.tabs-panel-inactive {
+	display:none;
+}
+
+#post-body .categorydiv div.tabs-panel,
+.taxonomy div.tabs-panel,
+#post-body #linkcategorydiv div.tabs-panel {
+	margin: 0 5px 0 125px;
+}
+
+#side-sortables .category-tabs li,
+#side-sortables .add-menu-item-tabs li,
+.wp-tab-bar li {
+	display: inline;
+}
+
+#side-sortables .category-tabs a,
+#side-sortables .add-menu-item-tabs a,
+.wp-tab-bar a {
+	text-decoration: none;
+}
+
+#side-sortables .category-tabs,
+#side-sortables .add-menu-item-tabs,
+.wp-tab-bar {
+	margin-bottom: 3px;
+}
+
+.categorydiv ul,
+.customlinkdiv ul,
+.posttypediv ul,
+.taxonomydiv ul,
+#linkcategorydiv ul {
+	list-style: none;
+	padding: 0;
+	margin: 0;
+}
+
+#normal-sortables .postbox #replyrow .submit {
+	float: none;
+	margin: 0;
+	padding: 3px 7px;
+}
+
+#side-sortables .submitbox .submit input,
+#side-sortables .submitbox .submit .preview,
+#side-sortables .submitbox .submit a.preview:hover {
+	border: 0 none;
+}
+
+#side-sortables .inside-submitbox .insidebox,
+.stuffbox .insidebox {
+	margin: 11px 0;
+}
+
+#side-sortables .comments-box,
+#normal-sortables .comments-box {
+	border: 0 none;
+}
+ul.category-tabs,
+ul.add-menu-item-tabs,
+ul.wp-tab-bar {
+	margin-top: 12px;
+}
+
+#side-sortables .comments-box thead th,
+#normal-sortables .comments-box thead th {
+	background: transparent;
+	padding: 0 7px 4px;
+	font-style: italic;
+}
+
+ul.category-tabs li.tabs,
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
+	border-style: solid solid none;
+	border-width: 1px 1px 0;
+}
+
+#commentsdiv img.waiting {
+	padding-left: 5px;
+}
+
+#post-body .category-tabs li.tabs,
+#post-body .add-menu-item-tabs li.tabs {
+	border-style: solid none solid solid;
+	border-width: 1px 0 1px 1px;
+	margin-right: -1px;
+}
+
+ul.category-tabs li,
+ul.add-menu-item-tabs li,
+ul.wp-tab-bar li {
+	padding: 5px;
+	-moz-border-radius: 3px 3px 0 0;
+	-webkit-border-top-left-radius: 3px;
+	-webkit-border-top-right-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	-khtml-border-top-right-radius: 3px;
+	border-top-left-radius: 3px;
+	border-top-right-radius: 3px;
+}
+
+/* positioning etc. */
+
+form#tags-filter {
+	position: relative;
+}
+
+p.search-box {
+	float: right;
+	margin: -5px 0 0;
+}
+
+.screen-per-page {
+	width: 3em;
+}
+
+#posts-filter fieldset {
+	float: left;
+	margin: 0 1.5ex 1em 0;
+	padding: 0;
+}
+
+#posts-filter fieldset legend {
+	padding: 0 0 .2em 1px;
+}
+
+/* Edit posts */
+
+td.post-title strong, td.plugin-title strong {
+	display: block;
+	margin-bottom: .2em;
+}
+
+td.post-title p, td.plugin-title p {
+	margin: 6px 0;
+}
+
+/* Global classes */
+
+.wp-hidden-children .wp-hidden-child,
+.ui-tabs-hide {
+	display: none;
+}
+
+.commentlist .avatar {
+	vertical-align: text-top;
+}
+
+#post-body .tagsdiv #newtag {
+	margin-right: 5px;
+	width: 16em;
+}
+
+#side-sortables input#post_password {
+	width: 94%
+}
+
+#side-sortables .tagsdiv #newtag {
+	width: 68%;
+}
+
+#post-status-info {
+	border-width: 0 1px 1px;
+	border-style: none solid solid;
+	width: 100%;
+	-moz-border-radius: 0 0 6px 6px;
+	-webkit-border-bottom-left-radius: 6px;
+	-webkit-border-bottom-right-radius: 6px;
+	-khtml-border-bottom-left-radius: 6px;
+	-khtml-border-bottom-right-radius: 6px;
+	border-bottom-left-radius: 6px;
+	border-bottom-right-radius: 6px;
+}
+
+#post-status-info td {
+	font-size: 11px;
+}
+
+.autosave-info {
+	padding: 2px 15px 2px 2px;
+	text-align: right;
+}
+
+#editorcontent #post-status-info {
+	border: none;
+}
+
+#post-body .wp_themeSkin .mceStatusbar a.mceResize {
+	display: block;
+	background: transparent url(../images/resize.gif) no-repeat scroll right bottom;
+	width: 12px;
+	cursor: se-resize;
+	margin: 0 2px;
+	position: relative;
+	top: 22px;
+}
+
+#wp-word-count {
+	display: block;
+	padding: 2px 7px;
+}
+
+#timestampdiv select {
+	height: 20px;
+	line-height: 14px;
+	padding: 0;
+	vertical-align: top;
+}
+
+#jj, #hh, #mn {
+	width: 2em;
+	padding: 1px;
+	font-size: 12px;
+}
+
+#aa {
+	width: 3.4em;
+	padding: 1px;
+	font-size: 12px;
+}
+
+.curtime #timestamp {
+	background-repeat: no-repeat;
+	background-position: left top;
+	padding-left: 18px;
+}
+
+#timestampdiv {
+	padding-top: 5px;
+	line-height: 23px;
+}
+
+#timestampdiv p {
+	margin: 8px 0 6px;
+}
+
+#timestampdiv input {
+	border-width: 1px;
+	border-style: solid;
+}
+
+
+/*------------------------------------------------------------------------------
+  11.1 - Custom Fields
+------------------------------------------------------------------------------*/
+
+#postcustomstuff table,
+#postcustomstuff input,
+#postcustomstuff textarea {
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+}
+
+#postcustomstuff .updatemeta,
+#postcustomstuff .deletemeta {
+	margin: auto;
+}
+
+#postcustomstuff thead th {
+	padding: 5px 8px 8px;
+}
+
+#postcustom #postcustomstuff .submit {
+	border: 0 none;
+	float: none;
+	padding: 5px 8px;
+}
+
+#side-sortables #postcustom #postcustomstuff .submit {
+	padding: 0 5px;
+}
+
+#side-sortables #postcustom #postcustomstuff td.left input {
+	margin: 3px 3px 0;
+}
+
+#side-sortables #postcustom #postcustomstuff #the-list textarea {
+	height: 85px;
+	margin: 3px;
+}
+
+#postcustomstuff table {
+	margin: 0;
+	width: 100%;
+	border-width: 1px;
+	border-style: solid;
+	border-spacing: 0;
+}
+
+#postcustomstuff table input,
+#postcustomstuff table select,
+#postcustomstuff table textarea {
+	width: 95%;
+	margin: 8px 0 8px 8px;
+}
+
+#postcustomstuff th.left,
+#postcustomstuff td.left {
+	width: 38%;
+}
+
+#postcustomstuff .submit input {
+	width: auto;
+}
+
+#postcustomstuff #newmeta .submit {
+	padding: 0 8px;
+}
+
+#postcustomstuff table #addmetasub {
+	width: auto;
+}
+
+#postcustomstuff #newmetaleft {
+	vertical-align: top;
+}
+
+#postcustomstuff #newmetaleft a {
+	padding: 0 10px;
+	text-decoration: none;
+}
+
+
+/*------------------------------------------------------------------------------
+  11.2 - Post Revisions
+------------------------------------------------------------------------------*/
+
+table.diff {
+	width: 100%;
+}
+
+table.diff col.content {
+	width: 50%;
+}
+
+table.diff tr {
+	background-color: transparent;
+}
+
+table.diff td, table.diff th {
+	padding: .5em;
+	font-family: Consolas, Monaco, Courier, monospace;
+	border: none;
+}
+
+table.diff .diff-deletedline del, table.diff .diff-addedline ins {
+	text-decoration: none;
+}
+
+
+/*------------------------------------------------------------------------------
+  12.0 - Categories
+------------------------------------------------------------------------------*/
+
+.category-adder {
+	margin-left: 120px;
+	padding: 4px 0;
+}
+
+.category-adder h4 {
+	margin: 0 0 8px;
+}
+
+#side-sortables .category-adder {
+	margin: 0;
+}
+
+#post-body .category-add input, .category-add select {
+	width: 30%;
+}
+
+#side-sortables .category-add select {
+	width: 100%;
+}
+
+#side-sortables .category-add input.category-add-sumbit, #post-body .category-add input.category-add input.category-add-sumbit {
+	width: auto;
+}
+
+#post-body ul.category-tabs,
+#post-body ul.add-menu-item-tabs {
+	float: left;
+	width: 120px;
+	text-align: right;
+	/* Negative margin for the sake of those without JS: all tabs display */
+	margin: 0 -120px 0 5px;
+	padding: 0;
+}
+
+#post-body ul.category-tabs li,
+#post-body ul.add-menu-item-tabs li {
+	padding: 8px;
+}
+
+#post-body ul.category-tabs li.tabs,
+#post-body ul.add-menu-item-tabs li.tabs {
+	-moz-border-radius: 3px 0 0 3px;
+	-webkit-border-top-left-radius: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	border-top-left-radius: 3px;
+	border-bottom-left-radius: 3px;
+}
+
+#post-body ul.category-tabs li.tabs a,
+#post-body ul.add-menu-item-tabs li.tabs a {
+	font-weight: bold;
+	text-decoration: none;
+}
+
+.categorydiv div.tabs-panel,
+.customlinkdiv div.tabs-panel,
+.posttypediv div.tabs-panel,
+.taxonomydiv div.tabs-panel,
+#linkcategorydiv div.tabs-panel {
+	height: 200px;
+	overflow: auto;
+	padding: 0.5em 0.9em;
+	border-style: solid;
+	border-width: 1px;
+}
+
+.nav-menus-php .customlinkdiv div.tabs-panel,
+.nav-menus-php .posttypediv div.tabs-panel,
+.nav-menus-php .taxonomydiv div.tabs-panel {
+	height: auto;
+	max-height: 205px;
+}
+
+div.tabs-panel-active {
+	display:block;
+}
+
+div.tabs-panel-inactive {
+	display:none;
+}
+
+#post-body .categorydiv div.tabs-panel,
+.taxonomy div.tabs-panel,
+#post-body #linkcategorydiv div.tabs-panel {
+	margin: 0 5px 0 125px;
+}
+
+#side-sortables .category-tabs li,
+#side-sortables .add-menu-item-tabs li {
+	display: inline;
+}
+
+#side-sortables .category-tabs a,
+#side-sortables .add-menu-item-tabs a {
+	text-decoration: none;
+}
+
+#side-sortables .category-tabs,
+#side-sortables .add-menu-item-tabs {
+	margin-bottom: 3px;
+}
+
+.categorydiv ul,
+.customlinkdiv ul,
+.posttypediv ul,
+.taxonomydiv ul,
+#linkcategorydiv ul {
+	list-style: none;
+	padding: 0;
+	margin: 0;
+}
+
+#front-page-warning,
+#front-static-pages ul,
+ul.export-filters,
+.inline-editor ul.cat-checklist ul,
+.categorydiv ul.categorychecklist ul,
+.customlinkdiv ul.categorychecklist ul,
+.posttypediv ul.categorychecklist ul,
+.taxonomydiv ul.categorychecklist ul,
+#linkcategorydiv ul.categorychecklist ul {
+	margin-left: 18px;
+}
+
+ul.categorychecklist li {
+	margin: 0;
+	padding: 0;
+	line-height: 19px;
+	word-wrap: break-word;
+}
+
+.categorydiv .tabs-panel,
+.customlinkdiv .tabs-panel,
+.posttypediv .tabs-panel,
+.taxonomydiv .tabs-panel {
+	border-width: 3px;
+	border-style: solid;
+}
+
+ul.category-tabs,
+ul.add-menu-item-tabs {
+	margin-top: 12px;
+}
+
+ul.category-tabs li.tabs,
+ul.add-menu-item-tabs li.tabs {
+	border-style: solid solid none;
+	border-width: 1px 1px 0;
+}
+
+#post-body .category-tabs li.tabs,
+#post-body .add-menu-item-tabs li.tabs {
+	border-style: solid none solid solid;
+	border-width: 1px 0 1px 1px;
+	margin-right: -1px;
+}
+
+ul.category-tabs li,
+ul.add-menu-item-tabs li {
+	padding: 5px;
+	-moz-border-radius: 3px 3px 0 0;
+	-webkit-border-top-left-radius: 3px;
+	-webkit-border-top-right-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	-khtml-border-top-right-radius: 3px;
+	border-top-left-radius: 3px;
+	border-top-right-radius: 3px;
+}
+
+.form-wrap {
+	margin: 10px 0;
+	width: 97%;
+}
+
+.form-wrap p,
+.form-wrap label {
+	font-size: 11px;
+}
+
+.form-wrap label {
+	display: block;
+	padding: 2px;
+	font-size: 12px;
+}
+
+.form-field input,
+.form-field textarea {
+	border-style: solid;
+	border-width: 1px;
+	width: 95%;
+}
+
+p.description,
+.form-wrap p {
+	margin: 2px 0 5px;
+}
+
+p.help,
+p.description,
+span.description,
+.form-wrap p {
+	font-size: 12px;
+	font-style: italic;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
+
+.form-wrap .form-field {
+	margin: 0 0 10px;
+	padding: 8px;
+}
+
+.col-wrap h3 {
+	margin: 12px 0;
+	font-size: 1.1em;
+}
+
+.col-wrap p.submit {
+	margin-top: -10px;
+}
+
+
+/*------------------------------------------------------------------------------
+  13.0 - Tags
+------------------------------------------------------------------------------*/
+
+.taghint {
+	color: #aaa;
+	margin: 15px 0 -24px 12px;
+}
+
+#poststuff .tagsdiv .howto {
+	margin: 0 0 6px 8px;
+}
+
+.ajaxtag .newtag {
+	background: transparent;
+	position: relative;
+}
+
+.tagsdiv .newtag {
+	width: 180px;
+}
+
+.tagsdiv .the-tags {
+	display: block;
+	height: 60px;
+	margin: 0 auto;
+	overflow: auto;
+	width: 260px;
+}
+
+#post-body-content .tagsdiv .the-tags {
+	margin: 0 5px;
+}
+
+p.popular-tags {
+	-moz-border-radius: 8px;
+	-khtml-border-radius: 8px;
+	-webkit-border-radius: 8px;
+	border-radius: 8px;
+	border-width: 1px;
+	border-style: solid;
+	line-height: 2em;
+	padding: 8px 12px 12px;
+	text-align: justify;
+}
+
+p.popular-tags a {
+	padding: 0 3px;
+}
+
+.tagcloud {
+	width: 97%;
+	margin: 0 0 40px;
+	text-align: justify;
+}
+
+.tagcloud h3 {
+	margin: 2px 0 12px;
+}
+
+.ac_results {
+	padding: 0;
+	margin: 0;
+	list-style: none;
+	position: absolute;
+	z-index: 10000;
+	display: none;
+	border-width: 1px;
+	border-style: solid;
+}
+
+.ac_results li {
+	padding: 2px 5px;
+	white-space: nowrap;
+	text-align: left;
+}
+
+.ac_over {
+	cursor: pointer;
+}
+
+.ac_match {
+	text-decoration: underline;
+}
+
+
+/*------------------------------------------------------------------------------
+  14.0 - Media Screen
+------------------------------------------------------------------------------*/
+
+#wpbody-content #media-items .describe {
+	border-collapse: collapse;
+	width: 100%;
+	border-top-style: solid;
+	border-top-width: 1px;
+	clear: both;
+	cursor: default;
+	padding: 5px;
+}
+
+#wpbody-content .describe th {
+	vertical-align: top;
+	text-align: left;
+	padding: 10px;
+	width: 140px;
+}
+
+#wpbody-content .describe .media-item-info tr {
+	background-color: transparent;
+}
+
+#wpbody-content .describe .media-item-info td {
+	padding: 4px 10px 0;
+}
+
+.describe .media-item-info .A1B1 {
+	padding: 0 0 0 10px;
+}
+
+#wpbody-content .filename {
+	padding: 0 10px;
+}
+
+#wpbody-content .media-item .thumbnail {
+	max-height: 128px;
+	max-width: 128px;
+}
+
+#wpbody-content #async-upload-wrap a {
+	display: none;
+}
+
+.media-upload-form td label {
+	margin-right: 6px;
+	margin-left: 2px;
+}
+
+.media-upload-form .align .field label {
+	display: inline;
+	padding: 0 0 0 22px;
+	margin: 0 1em 0 0;
+	font-weight: bold;
+}
+
+.media-upload-form tr.image-size label {
+	margin: 0 0 0 3px;
+	font-weight: bold;
+}
+
+.media-upload-form th.label label {
+	font-weight: bold;
+	margin: 0.5em;
+	font-size: 13px;
+}
+
+.media-upload-form th.label label span {
+	padding: 0 5px;
+}
+
+abbr.required {
+	border: medium none;
+	text-decoration: none;
+}
+
+#wpbody-content .describe input[type="text"],
+#wpbody-content .describe textarea {
+	width: 460px;
+}
+
+#wpbody-content .describe p.help {
+	margin: 0;
+	padding: 0 0 0 5px;
+}
+
+.media-item .error-div a.dismiss,
+.describe-toggle-on,
+.describe-toggle-off {
+	display: block;
+	line-height: 36px;
+	float: right;
+	margin-right: 20px;
+}
+
+.describe-toggle-off {
+	display: none;
+}
+
+#wpbody-content .media-item {
+	border-bottom-style: solid;
+	border-bottom-width: 1px;
+	min-height: 36px;
+	position: relative;
+	width: 100%;
+}
+
+#wpbody-content .media-single .media-item {
+	border-bottom-style: none;
+	border-bottom-width: 0;
+}
+
+#wpbody-content #media-items {
+	border-style: solid solid none;
+	border-width: 1px;
+	width: 670px;
+}
+
+#wpbody-content #media-items .filename {
+	line-height: 36px;
+	overflow: hidden;
+}
+
+.media-item .error-div {
+	padding-left: 10px;
+}
+
+.media-item .pinkynail {
+	float: left;
+	margin: 2px;
+	max-width: 40px;
+	max-height: 32px;
+}
+
+.media-item .startopen,
+.media-item .startclosed {
+	display: none;
+}
+
+.media-item .original {
+	position: relative;
+	height: 34px;
+	width: 503px;
+}
+
+.media-item .percent {
+	font-weight: bold;
+}
+
+.crunching {
+	display: block;
+	line-height: 32px;
+	text-align: right;
+	margin-right: 5px;
+}
+
+.progress {
+	position: relative;
+	margin-bottom: -36px;
+	height: 36px;
+}
+
+.bar {
+	width: 0;
+	height: 100%;
+	border-right-width: 3px;
+	border-right-style: solid;
+}
+
+.upload-php .fixed .column-parent {
+	width: 25%;
+}
+
+
+/*------------------------------------------------------------------------------
+  14.1 - Media Uploader
+------------------------------------------------------------------------------*/
+
+.find-box {
+	width: 500px;
+	height: 300px;
+	overflow: hidden;
+	padding: 33px 5px 40px;
+	position: absolute;
+	z-index: 1000;
+}
+
+.find-box-head {
+	cursor: move;
+	font-weight: bold;
+	height: 2em;
+	line-height: 2em;
+	padding: 1px 12px;
+	position: absolute;
+	top: 5px;
+	width: 100%;
+}
+
+.find-box-inside {
+	overflow: auto;
+	width: 100%;
+	height: 100%;
+}
+
+.find-box-search {
+	padding: 12px;
+	border-width: 1px;
+	border-style: none none solid;
+}
+
+#find-posts-response {
+	margin: 8px 0;
+	padding: 0 1px;
+}
+
+#find-posts-response table {
+	width: 100%;
+}
+
+#find-posts-response .found-radio {
+	padding: 5px 0 0 8px;
+	width: 15px;
+}
+
+.find-box-buttons {
+	width: 480px;
+	margin: 8px;
+}
+
+.find-box-search label {
+	padding-right: 6px;
+}
+
+.find-box #resize-se {
+	position: absolute;
+	right: 1px;
+	bottom: 1px;
+}
+
+/* favorite-actions */
+#favorite-actions {
+	float: right;
+	margin: 11px 12px 0;
+	min-width: 130px;
+	position: relative;
+}
+
+#favorite-first {
+	-moz-border-radius: 12px;
+	-khtml-border-radius: 12px;
+	-webkit-border-radius: 12px;
+	border-radius: 12px;
+	line-height: 15px;
+	padding: 3px 30px 4px 12px;
+	border-width: 1px;
+	border-style: solid;
+}
+
+#favorite-inside {
+	margin: 0 0 0 0px;
+	padding: 2px 1px;
+	border-width: 1px;
+	border-style: solid;
+	position: absolute;
+	z-index: 11;
+	display: none;
+	-moz-border-radius: 0 0 12px 12px;
+	-webkit-border-bottom-right-radius: 12px;
+	-webkit-border-bottom-left-radius: 12px;
+	-khtml-border-bottom-right-radius: 12px;
+	-khtml-border-bottom-left-radius: 12px;
+	border-bottom-right-radius: 12px;
+	border-bottom-left-radius: 12px;
+}
+
+#favorite-actions a {
+	display: block;
+	text-decoration: none;
+	font-size: 11px;
+}
+
+#favorite-inside a {
+	padding: 3px 5px 3px 10px;
+}
+
+#favorite-toggle {
+	height: 22px;
+	position: absolute;
+	right: 0;
+	top: 1px;
+	width: 28px;
+}
+
+#favorite-actions .slide-down {
+	-moz-border-radius: 12px 12px 0 0;
+	-webkit-border-bottom-right-radius: 0;
+	-webkit-border-bottom-left-radius: 0;
+	-khtml-border-bottom-right-radius: 0;
+	-khtml-border-bottom-left-radius: 0;
+	border-bottom-right-radius: 0;
+	border-bottom-left-radius: 0;
+	border-bottom: none;
+}
+
+ul#dismissed-updates {
+	display: none;
+}
+
+form.upgrade {
+	margin-top: 8px;
+}
+
+form.upgrade .hint {
+	font-style: italic;
+	font-size: 85%;
+	margin: -0.5em 0 2em 0;
+}
+
+#poststuff .inside .the-tagcloud {
+	margin: 5px 0 10px;
+	padding: 8px;
+	border-width: 1px;
+	border-style: solid;
+	line-height: 1.8em;
+	word-spacing: 3px;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+br.clear {
+	height: 2px;
+	line-height: 2px;
+}
+
+.swfupload {
+	margin: 5px 10px;
+	vertical-align: middle;
+}
+
+
+/*------------------------------------------------------------------------------
+  14.2 - Image Editor
+------------------------------------------------------------------------------*/
+
+.describe .image-editor {
+	vertical-align: top;
+}
+
+.imgedit-wrap {
+	position: relative;
+}
+
+.imgedit-settings p {
+	margin: 8px 0;
+}
+
+.describe .imgedit-wrap table td {
+	vertical-align: top;
+	padding-top: 0;
+}
+
+.imgedit-wrap p,
+.describe .imgedit-wrap table td {
+	font-size: 11px;
+	line-height: 18px;
+}
+
+.describe .imgedit-wrap table td.imgedit-settings {
+	padding: 0 5px;
+}
+
+td.imgedit-settings input {
+	vertical-align: middle;
+}
+
+.imgedit-wait {
+	position: absolute;
+	top: 0;
+	background: #FFFFFF url(../images/wpspin_light.gif) no-repeat scroll 22px 10px;
+	opacity: 0.7;
+	filter: alpha(opacity=70);
+	width: 100%;
+	height: 500px;
+	display: none;
+}
+
+.media-disabled,
+.imgedit-settings .disabled  {
+	color: grey;
+}
+
+.imgedit-wait-spin {
+	padding: 0 4px 4px;
+	vertical-align: bottom;
+	visibility: hidden;
+}
+
+.imgedit-menu {
+	margin: 0 0 12px;
+	min-width: 300px;
+}
+
+.imgedit-menu div {
+	float: left;
+	width: 32px;
+	height: 32px;
+	-moz-border-radius: 4px;
+	-khtml-border-radius: 4px;
+	-webkit-border-radius: 4px;
+	border-radius: 4px;
+	border-width: 1px;
+	border-style: solid;
+}
+
+.imgedit-crop-wrap {
+	position: relative;
+}
+
+.imgedit-crop {
+	background: transparent url(../images/imgedit-icons.png) no-repeat scroll -9px -31px;
+	margin: 0 8px 0 0;
+}
+
+.imgedit-crop.disabled:hover {
+	background-position: -9px -31px;
+}
+
+.imgedit-crop:hover {
+	background-position: -9px -1px;
+}
+
+.imgedit-rleft {
+	background: transparent url(../images/imgedit-icons.png) no-repeat scroll -46px -31px;
+	margin: 0 3px;
+}
+
+.imgedit-rleft.disabled:hover {
+	background-position: -46px -31px;
+}
+
+.imgedit-rleft:hover {
+	background-position: -46px -1px;
+}
+
+.imgedit-rright {
+	background: transparent url(../images/imgedit-icons.png) no-repeat scroll -77px -31px;
+	margin: 0 8px 0 3px;
+}
+
+.imgedit-rright.disabled:hover {
+	background-position: -77px -31px;
+}
+
+.imgedit-rright:hover {
+	background-position: -77px -1px;
+}
+
+.imgedit-flipv {
+	background: transparent url(../images/imgedit-icons.png) no-repeat scroll -115px -31px;
+	margin: 0 3px;
+}
+
+.imgedit-flipv.disabled:hover {
+	background-position: -115px -31px;
+}
+
+.imgedit-flipv:hover {
+	background-position: -115px -1px;
+}
+
+.imgedit-fliph {
+	background: transparent url(../images/imgedit-icons.png) no-repeat scroll -147px -31px;
+	margin: 0 8px 0 3px;
+}
+
+.imgedit-fliph.disabled:hover {
+	background-position: -147px -31px;
+}
+
+.imgedit-fliph:hover {
+	background-position: -147px -1px;
+}
+
+.imgedit-undo {
+	background: transparent url(../images/imgedit-icons.png) no-repeat scroll -184px -31px;
+	margin: 0 3px;
+}
+
+.imgedit-undo.disabled:hover {
+	background-position: -184px -31px;
+}
+
+.imgedit-undo:hover {
+	background-position: -184px -1px;
+}
+
+.imgedit-redo {
+	background: transparent url(../images/imgedit-icons.png) no-repeat scroll -215px -31px;
+	margin: 0 8px 0 3px;
+}
+
+.imgedit-redo.disabled:hover {
+	background-position: -215px -31px;
+}
+
+.imgedit-redo:hover {
+	background-position: -215px -1px;
+}
+
+.imgedit-applyto img {
+	margin: 0 8px 0 0;
+}
+
+.imgedit-group-top {
+	margin: 5px 0;
+}
+
+.imgedit-applyto .imgedit-label {
+	padding: 2px 0 0;
+	display: block;
+}
+
+.imgedit-help {
+	display: none;
+	font-style: italic;
+	margin-bottom: 8px;
+}
+
+.imgedit-help ul li {
+	font-size: 11px;
+}
+
+a.imgedit-help-toggle {
+	text-decoration: none;
+}
+
+#wpbody-content .imgedit-response div {
+	width: 600px;
+	margin: 8px;
+}
+
+.form-table td.imgedit-response {
+	padding: 0;
+}
+
+.imgedit-submit {
+	margin: 8px 0;
+}
+
+.imgedit-submit-btn {
+	margin-left: 20px;
+}
+
+.imgedit-wrap .nowrap {
+	white-space: nowrap;
+}
+
+span.imgedit-scale-warn {
+	color: red;
+	font-size: 20px;
+	font-style: normal;
+	visibility: hidden;
+	vertical-align: middle;
+}
+
+.imgedit-group {
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 8px;
+	-khtml-border-radius: 8px;
+	-webkit-border-radius: 8px;
+	border-radius: 8px;
+	margin-bottom: 8px;
+	padding: 2px 10px;
+}
+
+
+/*------------------------------------------------------------------------------
+  15.0 - Comments Screen
+------------------------------------------------------------------------------*/
+
+.form-table {
+	border-collapse: collapse;
+	margin-top: 0.5em;
+	width: 100%;
+	margin-bottom: -8px;
+	clear: both;
+}
+
+.form-table td {
+	margin-bottom: 9px;
+	padding: 8px 10px;
+	line-height: 20px;
+	font-size: 11px;
+}
+
+.form-table th,
+.form-wrap label {
+	font-weight: normal;
+	text-shadow: rgba(255,255,255,1) 0 1px 0;
+}
+
+.form-table th {
+	vertical-align: top;
+	text-align: left;
+	padding: 10px;
+	width: 200px;
+}
+
+.form-table th.th-full {
+	width: auto;
+}
+
+.form-table div.color-option {
+	display: block;
+	clear: both;
+	margin-top: 12px;
+}
+
+.form-table input.tog {
+	margin-top: 2px;
+	margin-right: 2px;
+	float: left;
+}
+
+.form-table td p {
+	margin-top: 4px;
+}
+
+.form-table table.color-palette {
+	vertical-align: bottom;
+	float: left;
+	margin: -12px 3px 11px;
+}
+
+.form-table .color-palette td {
+	border-width: 1px 1px 0;
+	border-style: solid solid none;
+	height: 10px;
+	line-height: 20px;
+	width: 10px;
+}
+
+.commentlist li {
+	padding: 1em 1em .2em;
+	margin: 0;
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+}
+
+.commentlist li li {
+	border-bottom: 0;
+	padding: 0;
+}
+
+.commentlist p {
+	padding: 0;
+	margin: 0 0 .8em;
+}
+
+/* reply to comments */
+#replyrow {
+	font-size: 11px;
+}
+
+#replyrow input {
+	border-width: 1px;
+	border-style: solid;
+}
+
+#replyrow td {
+	padding: 2px;
+}
+
+#replyrow #editorcontainer {
+	border: 0 none;
+}
+
+#replysubmit {
+	margin: 0;
+	padding: 3px 7px;
+	text-align:center;
+}
+
+#replysubmit img.waiting,
+.inline-edit-save img.waiting {
+	padding: 4px 10px 0;
+	vertical-align: top;
+	float: right;
+}
+
+#replysubmit .button {
+	margin-right: 5px;
+}
+
+#replysubmit .error {
+	color:red;
+	line-height:21px;
+	text-align:center;
+	vertical-align:center;
+}
+
+#replyrow #editor-toolbar {
+	display: none;
+}
+
+#replyhead {
+	font-size: 12px;
+	font-weight: bold;
+	padding: 2px 10px 4px;
+}
+
+#edithead .inside {
+	float: left;
+	padding: 3px 0 2px 5px;
+	margin: 0;
+	text-align: center;
+	font-size: 11px;
+}
+
+#edithead .inside input {
+	width: 180px;
+	font-size: 11px;
+}
+
+#edithead label {
+	padding: 2px 0;
+}
+
+#replycontainer {
+	padding: 5px;
+	border: 0 none;
+	height: 120px;
+	overflow: hidden;
+	position: relative;
+}
+
+#replycontent {
+	resize: none;
+	margin: 0;
+	width: 100%;
+	height: 100%;
+	padding: 0;
+	line-height: 150%;
+	border: 0 none;
+	outline: none;
+	font-size: 12px;
+}
+
+#replyrow #ed_reply_toolbar {
+	margin: 0;
+	padding: 2px 3px;
+}
+
+.comment-ays {
+	margin-bottom: 0;
+	border-style: solid;
+	border-width: 1px;
+}
+
+.comment-ays th {
+	border-right-style: solid;
+	border-right-width: 1px;
+}
+
+.trash-undo-inside,
+.spam-undo-inside {
+	margin: 1px 8px 1px 0;
+	line-height: 16px;
+}
+
+.spam-undo-inside .avatar,
+.trash-undo-inside .avatar {
+	height: 20px;
+	width: 20px;
+	margin-right: 8px;
+	vertical-align: middle;
+}
+
+.stuffbox .editcomment {
+	clear: none;
+}
+
+#comment-status-radio p {
+	margin: 3px 0 5px;
+}
+
+#comment-status-radio input {
+	margin: 2px 3px 5px 0;
+	vertical-align: middle;
+}
+
+#comment-status-radio label {
+	padding: 5px 0;
+}
+
+.commentlist .avatar {
+	vertical-align: text-top;
+}
+
+
+/*------------------------------------------------------------------------------
+  16.0 - Themes
+------------------------------------------------------------------------------*/
+
+.theme-install-php .tablenav {
+	height:auto;
+}
+
+table#availablethemes {
+	border-spacing: 0;
+	border-width: 1px 0;
+	border-style: solid none;
+	margin: 10px auto;
+	width: 100%;
+}
+
+table#availablethemes .no-items td{
+	border-width:0;
+	padding:5px;
+}
+
+td.available-theme {
+	vertical-align: top;
+	width: 240px;
+	margin: 0;
+	padding: 20px;
+	text-align: left;
+}
+
+table#availablethemes td {
+	border-width: 0 1px 1px;
+	border-style: none solid solid;
+}
+
+table#availablethemes td.right,
+table#availablethemes td.left  {
+	border-right: 0 none;
+	border-left: 0 none;
+}
+
+table#availablethemes td.bottom {
+	border-bottom: 0 none;
+}
+
+.available-theme a.screenshot {
+	width: 240px;
+	height: 180px;
+	display: block;
+	border-width: 1px;
+	border-style: solid;
+	margin-bottom: 10px;
+	overflow: hidden;
+}
+
+.available-theme img {
+	width: 240px;
+}
+
+.available-theme h3 {
+	margin: 15px 0 5px;
+}
+
+#current-theme {
+	margin: 1em 0 1.5em;
+}
+
+#current-theme a {
+	border-bottom: none;
+}
+
+#current-theme h3 {
+	font-size: 17px;
+	font-weight: normal;
+	margin: 0;
+}
+
+#current-theme .theme-description {
+	margin-top: 5px;
+}
+
+#current-theme img {
+	float: left;
+	border-width: 1px;
+	border-style: solid;
+	margin-right: 1em;
+	margin-bottom: 1.5em;
+	width: 150px;
+}
+
+.theme-options span {
+	text-transform: uppercase;
+	font-size: 13px;
+}
+
+.theme-options a {
+	font-size: 15px;
+}
+
+#TB_window #TB_title a.tb-theme-preview-link,
+#TB_window #TB_title a.tb-theme-preview-link:visited {
+	font-weight: bold;
+	text-decoration: none;
+}
+
+#TB_window #TB_title {
+	background-color: #222;
+	color: #cfcfcf;
+}
+
+#broken-themes {
+	text-align: left;
+	width: 50%;
+	border-spacing: 3px;
+	padding: 3px;
+}
+
+.theme-install-php h4 {
+	margin: 2.5em 0 8px;
+}
+
+
+/*------------------------------------------------------------------------------
+  16.1 - Custom Header Screen
+------------------------------------------------------------------------------*/
+
+.appearance_page_custom-header #headimg {
+	border: 1px solid #DFDFDF;
+	min-height: 100px;
+	width: 100%;
+}
+
+.appearance_page_custom-header #upload-form p label {
+	font-size: 11px;
+}
+
+.appearance_page_custom-header  #available-headers .default-header {
+	float: left;
+	margin: 0 20px 20px 0;
+}
+
+.appearance_page_custom-header #available-headers label input {
+	margin-right: 10px;
+}
+
+.appearance_page_custom-header #available-headers label img {
+	vertical-align: middle;
+}
+
+
+/*------------------------------------------------------------------------------
+  16.2 - Custom Background Screen
+------------------------------------------------------------------------------*/
+
+div#custom-background-image {
+	min-height: 100px;
+	border: 1px solid #dfdfdf;
+}
+
+div#custom-background-image img {
+	max-width: 400px;
+	max-height: 300px;
+}
+
+#custom-background label {
+	padding-right: 15px;
+}
+
+
+/*------------------------------------------------------------------------------
+  16.3 - Tabbed Admin Screen Interface (Experimental)
+------------------------------------------------------------------------------*/
+
+.nav-tab {
+	border-style: solid;
+	border-color: #ccc #ccc #f9f9f9;
+	border-width: 1px 1px 0;
+	color: #c1c1c1;
+	text-shadow: rgba(255,255,255,1) 0 1px 0;
+	font-size: 12px;
+	line-height: 16px;
+	display: inline-block;
+	padding: 4px 14px 6px;
+	text-decoration: none;
+	margin: 0 6px -1px 0;
+	-moz-border-radius: 5px 5px 0 0;
+	-webkit-border-top-left-radius: 5px;
+	-webkit-border-top-right-radius: 5px;
+	-khtml-border-top-left-radius: 5px;
+	-khtml-border-top-right-radius: 5px;
+	border-top-left-radius: 5px;
+	border-top-right-radius: 5px;
+}
+
+.nav-tab-active {
+	border-width: 1px;
+	color: #464646;
+}
+
+h2.nav-tab-wrapper, h3.nav-tab-wrapper {
+	border-bottom: 1px solid #ccc;
+	padding-bottom: 0;
+}
+
+h2 .nav-tab {
+	padding: 4px 20px 6px;
+	font: italic normal normal 24px/35px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+}
+
+
+/*------------------------------------------------------------------------------
+  17.0 - Plugins
+------------------------------------------------------------------------------*/
+
+.plugins .name,
+#pass-strength-result.strong,
+#pass-strength-result.short,
+.button-highlighted,
+input.button-highlighted,
+#quicktags #ed_strong,
+#ed_reply_toolbar #ed_reply_strong {
+	font-weight: bold;
+}
+
+.plugins p {
+	margin: 0 4px;
+	padding: 0;
+}
+
+.plugins .desc p {
+	margin: 0 0 8px;
+}
+
+.plugins td.desc {
+	line-height: 1.5em;
+}
+
+.plugins .desc ul,
+.plugins .desc ol {
+	margin: 0 0 0 2em;
+}
+
+.plugins .desc ul {
+	list-style-type: disc;
+}
+
+.plugins .row-actions-visible {
+	padding: 0;
+}
+
+.plugins tbody th.check-column {
+	padding: 7px 0;
+}
+
+.plugins td, .plugins th {
+	border-bottom: 0 none;
+}
+
+.plugins .inactive td,
+.plugins .inactive th,
+.plugins .active td,
+.plugins .active th {
+	border-top-style: solid;
+	border-top-width: 1px;
+	padding: 5px 7px 0;
+}
+
+#wpbody-content .plugins .plugin-title, #wpbody-content .plugins .theme-title {
+	padding-right: 12px;
+	white-space:nowrap;
+}
+
+.plugins .second, .plugins .row-actions-visible {
+	padding: 0 0 5px;
+}
+
+.plugins-php .widefat tfoot th,
+.plugins-php .widefat tfoot td {
+	border-top-style: solid;
+	border-top-width: 1px;
+}
+
+.plugin-update-tr .update-message {
+	margin: 5px;
+	padding: 3px 5px;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 5px;
+	-khtml-border-radius: 5px;
+	-webkit-border-radius: 5px;
+	border-radius: 5px;
+}
+
+.plugin-install-php h4 {
+	margin: 2.5em 0 8px;
+}
+
+
+/*------------------------------------------------------------------------------
+  18.0 - Users
+------------------------------------------------------------------------------*/
+
+#profile-page .form-table textarea {
+	width: 500px;
+	margin-bottom: 6px;
+}
+
+#profile-page .form-table #rich_editing {
+	margin-right: 5px
+}
+
+#your-profile legend {
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	font-size: 22px;
+}
+
+#your-profile #rich_editing {
+	border: none;
+}
+
+#display_name {
+	width: 15em;
+}
+
+#createuser .form-field input {
+	width: 25em;
+}
+
+/*------------------------------------------------------------------------------
+  19.0 - Tools
+------------------------------------------------------------------------------*/
+
+
+
+
+/*------------------------------------------------------------------------------
+  20.0 - Settings
+------------------------------------------------------------------------------*/
+
+#utc-time, #local-time {
+	padding-left: 25px;
+	font-style: italic;
+	font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
+}
+
+.defaultavatarpicker .avatar {
+	margin: 2px 0;
+	vertical-align: middle;
+}
+
+
+/*------------------------------------------------------------------------------
+  21.0 - Admin Footer
+------------------------------------------------------------------------------*/
+
+#footer {
+	margin-top: -46px;
+	border-top: 1px;
+	border-style: solid;
+}
+
+#footer,
+#footer a {
+	font-size: 12px;
+	font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	font-style: italic;
+}
+
+#footer p {
+	margin: 0;
+	padding: 15px;
+	line-height: 15px;
+}
+
+#footer a {
+	text-decoration: none;
+}
+
+#footer a:hover {
+	text-decoration: underline;
+}
+
+
+/*------------------------------------------------------------------------------
+  22.0 - Misc
+------------------------------------------------------------------------------*/
+
+#excerpt, .attachmentlinks {
+	margin: 0;
+	height: 4em;
+	width: 98%;
+}
+
+#template div {
+	margin-right: 190px;
+}
+
+p.pagenav {
+	margin: 0;
+	display: inline;
+}
+
+.pagenav span {
+	font-weight: bold;
+	margin: 0 6px;
+}
+
+.row-title {
+	font-size: 12px !important;
+	font-weight: bold;
+}
+
+.column-author img, .column-username img {
+	float: left;
+	margin-right: 10px;
+	margin-top: 3px;
+}
+
+.row-actions {
+	visibility: hidden;
+	padding: 2px 0 0;
+}
+
+tr:hover .row-actions,
+div.comment-item:hover .row-actions {
+	visibility: visible;
+}
+
+.row-actions-visible {
+	padding: 2px 0 0;
+}
+
+.form-table .pre {
+	padding: 8px;
+	margin: 0;
+}
+
+table.form-table td .updated {
+	font-size: 13px;
+}
+
+
+.tagchecklist {
+	margin-left: 14px;
+	font-size: 12px;
+	overflow: auto;
+}
+.tagchecklist strong {
+	margin-left: -8px;
+	position: absolute;
+}
+.tagchecklist span {
+	margin-right: 25px;
+	display: block;
+	float: left;
+	font-size: 11px;
+	line-height: 1.8em;
+	white-space: nowrap;
+	cursor: default;
+}
+.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;
+}
+
+
+#poststuff h2 {
+	margin-top: 20px;
+	font-size: 1.5em;
+	margin-bottom: 15px;
+	padding: 0 0 3px;
+	clear: left;
+}
+#poststuff h3,
+.metabox-holder h3 {
+	font-size: 12px;
+	font-weight: bold;
+	padding: 7px 9px;
+	margin: 0;
+	line-height: 1;
+}
+#poststuff .inside,
+#poststuff .inside p {
+	font-size: 11px;
+	margin: 6px 6px 8px;
+}
+#poststuff .inside .submitbox p {
+	margin: 1em 0;
+}
+#post-visibility-select, #post-formats-select {
+	line-height: 1.5em;
+	margin-top: 3px;
+}
+#poststuff #submitdiv .inside {
+	margin: 0;
+}
+#titlediv, #poststuff .postarea {
+	margin-bottom: 20px;
+}
+
+
+td.post-title strong, td.plugin-title strong {
+	display: block;
+	margin-bottom: .2em;
+}
+td.post-title p, td.plugin-title p {
+	margin: 6px 0;
+}
+
+
+.wp-hidden-children .wp-hidden-child,
+.ui-tabs-hide {
+	display: none;
+}
+
+#templateside ul li a {
+	text-decoration: none;
+}
+
+
+.tool-box {
+	margin: 15px 0 35px;
+}
+.tool-box .buttons {
+	margin: 15px 0;
+}
+.tool-box .title {
+	margin: 8px 0;
+	font: 18px/24px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+}
+
+
+.pressthis a {
+	font-size: 1.2em;
+}
+
+
+#sidemenu {
+	margin: -30px 15px 0 315px;
+	list-style: none;
+	position: relative;
+	float: right;
+	padding-left: 10px;
+	font-size: 12px;
+}
+#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;
+}
+#sidemenu li {
+	display: inline;
+	line-height: 200%;
+	list-style: none;
+	text-align: center;
+	white-space: nowrap;
+	margin: 0;
+	padding: 0;
+}
+#sidemenu a.current {
+	font-weight: normal;
+	padding-left: 6px;
+	padding-right: 6px;
+	-moz-border-radius: 4px 4px 0 0;
+	-webkit-border-top-left-radius: 4px;
+	-webkit-border-top-right-radius: 4px;
+	-khtml-border-top-left-radius: 4px;
+	-khtml-border-top-right-radius: 4px;
+	border-top-left-radius: 4px;
+	border-top-right-radius: 4px;
+	border-width: 1px;
+	border-style: solid;
+}
+#sidemenu li a .count-0 {
+	display: none;
+}
+
+#poststuff .inside .the-tagcloud {
+	margin: 5px 0 10px;
+	padding: 8px;
+	border-width: 1px;
+	border-style: solid;
+	line-height: 1.8em;
+	word-spacing: 3px;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
+.plugin-install #description, .plugin-install-network #description {
+	width: 60%;
+}
+
+table .vers,
+table .column-visible,
+table .column-rating {
+	text-align: left;
+}
+
+
+/* Scrollbar fix for bulk upgrade iframe */
+body.iframe {
+	height: 98%;
+}
+
+
+/*------------------------------------------------------------------------------
+  23.0  - Dead
+------------------------------------------------------------------------------*/
+
+/* - Not used anywhere in WordPress - verify and then deprecate
+------------------------------------------------------------------------------*/
+.anchors {
+	margin: 10px 20px 10px 20px;
+}
+div.nav {
+	height: 2em;
+	padding: 7px 10px;
+	vertical-align: text-top;
+	margin: 5px 0;
+}
+.nav .button-secondary {
+	padding: 2px 4px;
+}
+* html #themeselect {
+	padding: 0 3px;
+	height: 22px;
+}
+.settings-toggle {
+	text-align: right;
+	margin: 5px 7px 15px 0;
+	font-size: 12px;
+}
+.settings-toggle h3 {
+	margin: 0;
+}
+form#tags-filter {
+	position: relative;
+}
+
+/* - Only used once or twice in all of WP - deprecate for global style
+------------------------------------------------------------------------------*/
+td.media-icon {
+	text-align: center;
+	width: 80px;
+	padding-top: 8px;
+	padding-bottom: 8px;
+}
+
+td.media-icon img {
+	max-width: 80px;
+	max-height: 60px;
+}
+.screen-per-page {
+	width: 3em;
+}
+* html #template div {margin-right: 0;}
+
+.list-ajax-loading {
+	float: right;
+	margin-right: 9px;
+	margin-top: -1px;
+}
+.tablenav .list-ajax-loading {
+	margin-top: 7px;
+}
+#howto {
+	font-size: 11px;
+	margin: 0 5px;
+	display: block;
+}
+.import-system {font-size: 16px;}
+#namediv table {
+	width: 100%;
+}
+#namediv td.first {
+	width: 10px;
+	white-space: nowrap;
+}
+#namediv input {
+	width: 98%;
+}
+#namediv p {
+	margin: 10px 0;
+}
+#submitdiv h3 {
+	margin-bottom: 0 !important;
+}
+
+/* - Used - but could/should be deprecated with a CSS reset
+------------------------------------------------------------------------------*/
+.zerosize {
+	height: 0;
+	width: 0;
+	margin: 0;
+	border: 0;
+	padding: 0;
+	overflow: hidden;
+	position: absolute;
+}
+br.clear {
+	height: 2px;
+	line-height: 2px;
+}
+.checkbox {
+	border: none;
+	margin: 0;
+	padding: 0;
+}
+#content {
+	margin: 0;
+	width: 100%;
+}
+fieldset {
+	border: 0;
+	padding: 0;
+	margin: 0;
+}
+#linksubmitdiv div.inside,
+div.inside {
+	padding: 0;
+	margin: 0;
+}
+.post-categories {
+	display: inline;
+	margin: 0;
+	padding: 0;
+}
+.post-categories li {
+	display: inline;
+}
Index: /tags/3.1/wp-admin/custom-background.php
===================================================================
--- /tags/3.1/wp-admin/custom-background.php	(revision 17487)
+++ /tags/3.1/wp-admin/custom-background.php	(revision 17487)
@@ -0,0 +1,359 @@
+<?php
+/**
+ * The custom background script.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * The custom background class.
+ *
+ * @since 3.0.0
+ * @package WordPress
+ * @subpackage Administration
+ */
+class Custom_Background {
+
+	/**
+	 * Callback for administration header.
+	 *
+	 * @var callback
+	 * @since 3.0.0
+	 * @access private
+	 */
+	var $admin_header_callback;
+
+	/**
+	 * Callback for header div.
+	 *
+	 * @var callback
+	 * @since 3.0.0
+	 * @access private
+	 */
+	var $admin_image_div_callback;
+
+	/**
+	 * Holds the page menu hook.
+	 *
+	 * @var string
+	 * @since 3.0.0
+	 * @access private
+	 */
+	var $page = '';
+
+	/**
+	 * PHP4 Constructor - Register administration header callback.
+	 *
+	 * @since 3.0.0
+	 * @param callback $admin_header_callback
+	 * @param callback $admin_image_div_callback Optional custom image div output callback.
+	 * @return Custom_Background
+	 */
+	function Custom_Background($admin_header_callback = '', $admin_image_div_callback = '') {
+		$this->admin_header_callback = $admin_header_callback;
+		$this->admin_image_div_callback = $admin_image_div_callback;
+	}
+
+	/**
+	 * Set up the hooks for the Custom Background admin page.
+	 *
+	 * @since 3.0.0
+	 */
+	function init() {
+		if ( ! current_user_can('edit_theme_options') )
+			return;
+
+		$this->page = $page = add_theme_page(__('Background'), __('Background'), 'edit_theme_options', 'custom-background', array(&$this, 'admin_page'));
+
+		add_action("load-$page", array(&$this, 'admin_load'));
+		add_action("load-$page", array(&$this, 'take_action'), 49);
+		add_action("load-$page", array(&$this, 'handle_upload'), 49);
+
+		if ( $this->admin_header_callback )
+			add_action("admin_head-$page", $this->admin_header_callback, 51);
+	}
+
+	/**
+	 * Set up the enqueue for the CSS & JavaScript files.
+	 *
+	 * @since 3.0.0
+	 */
+	function admin_load() {
+		add_contextual_help( $this->page, '<p>' . __( 'You can customize the look of your site without touching any of your theme&#8217;s code by using a custom background. Your background can be an image or a color.' ) . '</p>' .
+		'<p>' . __( 'To use a background image, simply upload it, then choose your display options below. You can display a single instance of your image, or tile it to fill the screen. You can have your background fixed in place, so your site content moves on top of it, or you can have it scroll with your site.' ) . '</p>' .
+		'<p>' . __( 'You can also choose a background color. If you know the hexadecimal code for the color you want, enter it in the Color field. If not, click on the Select a Color link, and a color picker will allow you to choose the exact shade you want.' ) . '</p>' .
+		'<p>' . __( 'Don&#8217;t forget to click on the Save Changes button when you are finished.' ) . '</p>' .
+		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+		'<p>' . __( '<a href="http://codex.wordpress.org/Appearance_Background_SubPanel" target="_blank">Documentation on Custom Background</a>' ) . '</p>' .
+		'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' );
+		wp_enqueue_script('custom-background');
+		wp_enqueue_style('farbtastic');
+	}
+
+	/**
+	 * Execute custom background modification.
+	 *
+	 * @since 3.0.0
+	 */
+	function take_action() {
+
+		if ( empty($_POST) )
+			return;
+
+		if ( isset($_POST['reset-background']) ) {
+			check_admin_referer('custom-background-reset', '_wpnonce-custom-background-reset');
+			remove_theme_mod('background_image');
+			remove_theme_mod('background_image_thumb');
+			$this->updated = true;
+			return;
+		}
+
+		if ( isset($_POST['remove-background']) ) {
+			// @TODO: Uploaded files are not removed here.
+			check_admin_referer('custom-background-remove', '_wpnonce-custom-background-remove');
+			set_theme_mod('background_image', '');
+			set_theme_mod('background_image_thumb', '');
+			$this->updated = true;
+			return;
+		}
+
+		if ( isset($_POST['background-repeat']) ) {
+			check_admin_referer('custom-background');
+			if ( in_array($_POST['background-repeat'], array('repeat', 'no-repeat', 'repeat-x', 'repeat-y')) )
+				$repeat = $_POST['background-repeat'];
+			else
+				$repeat = 'repeat';
+			set_theme_mod('background_repeat', $repeat);
+		}
+
+		if ( isset($_POST['background-position-x']) ) {
+			check_admin_referer('custom-background');
+			if ( in_array($_POST['background-position-x'], array('center', 'right', 'left')) )
+				$position = $_POST['background-position-x'];
+			else
+				$position = 'left';
+			set_theme_mod('background_position_x', $position);
+		}
+
+		if ( isset($_POST['background-attachment']) ) {
+			check_admin_referer('custom-background');
+			if ( in_array($_POST['background-attachment'], array('fixed', 'scroll')) )
+				$attachment = $_POST['background-attachment'];
+			else
+				$attachment = 'fixed';
+			set_theme_mod('background_attachment', $attachment);
+		}
+
+		if ( isset($_POST['background-color']) ) {
+			check_admin_referer('custom-background');
+			$color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']);
+			if ( strlen($color) == 6 || strlen($color) == 3 )
+				set_theme_mod('background_color', $color);
+			else
+				set_theme_mod('background_color', '');
+		}
+
+		$this->updated = true;
+	}
+
+	/**
+	 * Display the custom background page.
+	 *
+	 * @since 3.0.0
+	 */
+	function admin_page() {
+?>
+<div class="wrap" id="custom-background">
+<?php screen_icon(); ?>
+<h2><?php _e('Custom Background'); ?></h2>
+<?php if ( !empty($this->updated) ) { ?>
+<div id="message" class="updated">
+<p><?php printf( __( 'Background updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p>
+</div>
+<?php }
+
+	if ( $this->admin_image_div_callback ) {
+		call_user_func($this->admin_image_div_callback);
+	} else {
+?>
+<h3><?php _e('Background Image'); ?></h3>
+<table class="form-table">
+<tbody>
+<tr valign="top">
+<th scope="row"><?php _e('Preview'); ?></th>
+<td>
+<?php
+$background_styles = '';
+if ( $bgcolor = get_background_color() )
+	$background_styles .= 'background-color: #' . $bgcolor . ';';
+
+if ( get_background_image() ) {
+	// background-image URL must be single quote, see below
+	$background_styles .= ' background-image: url(\'' . get_theme_mod('background_image_thumb', '') . '\');'
+		. ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';'
+		. ' background-position: top ' . get_theme_mod('background_position_x', 'left');
+}
+?>
+<div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?>
+<?php if ( get_background_image() ) { ?>
+<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" alt="" /><br />
+<img class="custom-background-image" src="<?php echo get_theme_mod('background_image_thumb', ''); ?>" style="visibility:hidden;" alt="" />
+<?php } ?>
+</div>
+<?php } ?>
+</td>
+</tr>
+<?php if ( get_background_image() ) : ?>
+<tr valign="top">
+<th scope="row"><?php _e('Remove Image'); ?></th>
+<td>
+<form method="post" action="">
+<?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?>
+<?php submit_button( __( 'Remove Background Image' ), 'button', 'remove-background', false ); ?><br/>
+<?php _e('This will remove the background image. You will not be able to restore any customizations.') ?>
+</form>
+</td>
+</tr>
+<?php endif; ?>
+
+<?php if ( defined( 'BACKGROUND_IMAGE' ) ) : // Show only if a default background image exists ?>
+<tr valign="top">
+<th scope="row"><?php _e('Restore Original Image'); ?></th>
+<td>
+<form method="post" action="">
+<?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?>
+<?php submit_button( __( 'Restore Original Image' ), 'button', 'reset-background', false ); ?><br/>
+<?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?>
+</form>
+</td>
+</tr>
+
+<?php endif; ?>
+<tr valign="top">
+<th scope="row"><?php _e('Upload Image'); ?></th>
+<td><form enctype="multipart/form-data" id="upload-form" method="post" action="">
+<label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
+<input type="hidden" name="action" value="save" />
+<?php wp_nonce_field('custom-background-upload', '_wpnonce-custom-background-upload') ?>
+<?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?>
+</p>
+</form>
+</td>
+</tr>
+</tbody>
+</table>
+
+<h3><?php _e('Display Options') ?></h3>
+<form method="post" action="">
+<table class="form-table">
+<tbody>
+<?php if ( get_background_image() ) : ?>
+<tr valign="top">
+<th scope="row"><?php _e( 'Position' ); ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Position' ); ?></span></legend>
+<label>
+<input name="background-position-x" type="radio" value="left"<?php checked('left', get_theme_mod('background_position_x', 'left')); ?> />
+<?php _e('Left') ?>
+</label>
+<label>
+<input name="background-position-x" type="radio" value="center"<?php checked('center', get_theme_mod('background_position_x', 'left')); ?> />
+<?php _e('Center') ?>
+</label>
+<label>
+<input name="background-position-x" type="radio" value="right"<?php checked('right', get_theme_mod('background_position_x', 'left')); ?> />
+<?php _e('Right') ?>
+</label>
+</fieldset></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e( 'Repeat' ); ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Repeat' ); ?></span></legend>
+<label><input type="radio" name="background-repeat" value="no-repeat"<?php checked('no-repeat', get_theme_mod('background_repeat', 'repeat')); ?>> <?php _e('No Repeat'); ?></option></label>
+	<label><input type="radio" name="background-repeat" value="repeat"<?php checked('repeat', get_theme_mod('background_repeat', 'repeat')); ?>> <?php _e('Tile'); ?></option></label>
+	<label><input type="radio" name="background-repeat" value="repeat-x"<?php checked('repeat-x', get_theme_mod('background_repeat', 'repeat')); ?>> <?php _e('Tile Horizontally'); ?></option></label>
+	<label><input type="radio" name="background-repeat" value="repeat-y"<?php checked('repeat-y', get_theme_mod('background_repeat', 'repeat')); ?>> <?php _e('Tile Vertically'); ?></option></label>
+</fieldset></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e( 'Attachment' ); ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Attachment' ); ?></span></legend>
+<label>
+<input name="background-attachment" type="radio" value="scroll" <?php checked('scroll', get_theme_mod('background_attachment', 'scroll')); ?> />
+<?php _e('Scroll') ?>
+</label>
+<label>
+<input name="background-attachment" type="radio" value="fixed" <?php checked('fixed', get_theme_mod('background_attachment', 'scroll')); ?> />
+<?php _e('Fixed') ?>
+</label>
+</fieldset></td>
+</tr>
+<?php endif; // get_background_image() ?>
+<tr valign="top">
+<th scope="row"><?php _e( 'Color' ); ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend>
+<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" />
+<a class="hide-if-no-js" href="#" id="pickcolor"><?php _e('Select a Color'); ?></a>
+<div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
+</fieldset></td>
+</tr>
+</tbody>
+</table>
+
+<?php wp_nonce_field('custom-background'); ?>
+<?php submit_button( null, 'primary', 'save-background-options' ); ?>
+</form>
+
+</div>
+<?php
+	}
+
+	/**
+	 * Handle an Image upload for the background image.
+	 *
+	 * @since 3.0.0
+	 */
+	function handle_upload() {
+
+		if ( empty($_FILES) )
+			return;
+
+		check_admin_referer('custom-background-upload', '_wpnonce-custom-background-upload');
+		$overrides = array('test_form' => false);
+		$file = wp_handle_upload($_FILES['import'], $overrides);
+
+		if ( isset($file['error']) )
+			wp_die( $file['error'] );
+
+		$url = $file['url'];
+		$type = $file['type'];
+		$file = $file['file'];
+		$filename = basename($file);
+
+		// Construct the object array
+		$object = array(
+			'post_title' => $filename,
+			'post_content' => $url,
+			'post_mime_type' => $type,
+			'guid' => $url
+		);
+
+		// Save the data
+		$id = wp_insert_attachment($object, $file);
+
+		// Add the meta-data
+		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
+
+		set_theme_mod('background_image', esc_url($url));
+
+		$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
+		set_theme_mod('background_image_thumb', esc_url( $thumbnail[0] ) );
+
+		do_action('wp_create_file_in_uploads', $file, $id); // For replication
+		$this->updated = true;
+	}
+
+}
+?>
Index: /tags/3.1/wp-admin/custom-header.php
===================================================================
--- /tags/3.1/wp-admin/custom-header.php	(revision 17487)
+++ /tags/3.1/wp-admin/custom-header.php	(revision 17487)
@@ -0,0 +1,735 @@
+<?php
+/**
+ * The custom header image script.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * The custom header image class.
+ *
+ * @since 2.1.0
+ * @package WordPress
+ * @subpackage Administration
+ */
+class Custom_Image_Header {
+
+	/**
+	 * Callback for administration header.
+	 *
+	 * @var callback
+	 * @since 2.1.0
+	 * @access private
+	 */
+	var $admin_header_callback;
+
+	/**
+	 * Callback for header div.
+	 *
+	 * @var callback
+	 * @since 3.0.0
+	 * @access private
+	 */
+	var $admin_image_div_callback;
+
+	/**
+	 * Holds default headers.
+	 *
+	 * @var array
+	 * @since 3.0.0
+	 * @access private
+	 */
+	var $default_headers = array();
+
+	/**
+	 * Holds the page menu hook.
+	 *
+	 * @var string
+	 * @since 3.0.0
+	 * @access private
+	 */
+	var $page = '';
+
+	/**
+	 * PHP4 Constructor - Register administration header callback.
+	 *
+	 * @since 2.1.0
+	 * @param callback $admin_header_callback
+	 * @param callback $admin_image_div_callback Optional custom image div output callback.
+	 * @return Custom_Image_Header
+	 */
+	function Custom_Image_Header($admin_header_callback, $admin_image_div_callback = '') {
+		$this->admin_header_callback = $admin_header_callback;
+		$this->admin_image_div_callback = $admin_image_div_callback;
+	}
+
+	/**
+	 * Set up the hooks for the Custom Header admin page.
+	 *
+	 * @since 2.1.0
+	 */
+	function init() {
+		if ( ! current_user_can('edit_theme_options') )
+			return;
+
+		$this->page = $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array(&$this, 'admin_page'));
+
+		add_action("admin_print_scripts-$page", array(&$this, 'js_includes'));
+		add_action("admin_print_styles-$page", array(&$this, 'css_includes'));
+		add_action("admin_head-$page", array(&$this, 'help') );
+		add_action("admin_head-$page", array(&$this, 'take_action'), 50);
+		add_action("admin_head-$page", array(&$this, 'js'), 50);
+		add_action("admin_head-$page", $this->admin_header_callback, 51);
+	}
+
+	/**
+	 * Adds contextual help.
+	 *
+	 * @since 3.0.0
+	 */
+	function help() {
+		add_contextual_help( $this->page, '<p>' . __( 'You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately.' ) . '</p>' .
+		'<p>' . __( 'If you want to discard your custom header and go back to the default included in your theme, click on the buttons to remove the custom image and restore the original header image.' ) . '</p>' .
+		'<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you&#8217;d like and click the Save Changes button.' ) . '</p>' .
+		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+		'<p>' . __( '<a href="http://codex.wordpress.org/Appearance_Header_SubPanel" target="_blank">Documentation on Custom Header</a>' ) . '</p>' .
+		'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' );
+	}
+
+	/**
+	 * Get the current step.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @return int Current step
+	 */
+	function step() {
+		if ( ! isset( $_GET['step'] ) )
+			return 1;
+
+		$step = (int) $_GET['step'];
+		if ( $step < 1 || 3 < $step )
+			$step = 1;
+
+		return $step;
+	}
+
+	/**
+	 * Set up the enqueue for the JavaScript files.
+	 *
+	 * @since 2.1.0
+	 */
+	function js_includes() {
+		$step = $this->step();
+
+		if ( ( 1 == $step || 3 == $step ) && $this->header_text() )
+			wp_enqueue_script('farbtastic');
+		elseif ( 2 == $step )
+			wp_enqueue_script('imgareaselect');
+	}
+
+	/**
+	 * Set up the enqueue for the CSS files
+	 *
+	 * @since 2.7
+	 */
+	function css_includes() {
+		$step = $this->step();
+
+		if ( ( 1 == $step || 3 == $step ) && $this->header_text() )
+			wp_enqueue_style('farbtastic');
+		elseif ( 2 == $step )
+			wp_enqueue_style('imgareaselect');
+	}
+
+	/**
+	 * Check if header text is allowed
+	 *
+	 * @since 3.0.0
+	 */
+	function header_text() {
+		if ( defined( 'NO_HEADER_TEXT' ) && NO_HEADER_TEXT )
+			return false;
+
+		return true;
+	}
+
+	/**
+	 * Execute custom header modification.
+	 *
+	 * @since 2.6.0
+	 */
+	function take_action() {
+		if ( ! current_user_can('edit_theme_options') )
+			return;
+
+		if ( empty( $_POST ) )
+			return;
+
+		$this->updated = true;
+
+		if ( isset( $_POST['resetheader'] ) ) {
+			check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
+			remove_theme_mod( 'header_image' );
+			return;
+		}
+
+		if ( isset( $_POST['resettext'] ) ) {
+			check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
+			remove_theme_mod('header_textcolor');
+			return;
+		}
+
+		if ( isset( $_POST['removeheader'] ) ) {
+			check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
+			set_theme_mod( 'header_image', '' );
+			return;
+		}
+
+		if ( isset( $_POST['text-color'] ) ) {
+			check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
+			$_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] );
+			if ( 'blank' == $_POST['text-color'] ) {
+				set_theme_mod( 'header_textcolor', 'blank' );
+			} else {
+				$color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']);
+				if ( strlen($color) == 6 || strlen($color) == 3 )
+					set_theme_mod('header_textcolor', $color);
+			}
+		}
+
+		if ( isset($_POST['default-header']) ) {
+			check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
+			$this->process_default_headers();
+			if ( isset($this->default_headers[$_POST['default-header']]) )
+				set_theme_mod('header_image', esc_url($this->default_headers[$_POST['default-header']]['url']));
+		}
+	}
+
+	/**
+	 * Process the default headers
+	 *
+	 * @since 3.0.0
+	 */
+	function process_default_headers() {
+		global $_wp_default_headers;
+
+		if ( !empty($this->headers) )
+			return;
+
+		if ( !isset($_wp_default_headers) )
+			return;
+
+		$this->default_headers = $_wp_default_headers;
+		foreach ( array_keys($this->default_headers) as $header ) {
+			$this->default_headers[$header]['url'] =  sprintf( $this->default_headers[$header]['url'], get_template_directory_uri(), get_stylesheet_directory_uri() );
+			$this->default_headers[$header]['thumbnail_url'] =  sprintf( $this->default_headers[$header]['thumbnail_url'], get_template_directory_uri(), get_stylesheet_directory_uri() );
+		}
+	}
+
+	/**
+	 * Display UI for selecting one of several default headers.
+	 *
+	 * @since 3.0.0
+	 */
+	function show_default_header_selector() {
+		echo '<div id="available-headers">';
+		foreach ( $this->default_headers as $header_key => $header ) {
+			$header_thumbnail = $header['thumbnail_url'];
+			$header_url = $header['url'];
+			$header_desc = $header['description'];
+			echo '<div class="default-header">';
+			echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_theme_mod( 'header_image' ), false) . ' />';
+			echo '<img src="' . $header_thumbnail . '" alt="' . esc_attr($header_desc) .'" title="' . esc_attr($header_desc) .'" /></label>';
+			echo '</div>';
+		}
+		echo '<div class="clear"></div></div>';
+	}
+
+	/**
+	 * Execute Javascript depending on step.
+	 *
+	 * @since 2.1.0
+	 */
+	function js() {
+		$step = $this->step();
+		if ( ( 1 == $step || 3 == $step ) && $this->header_text() )
+			$this->js_1();
+		elseif ( 2 == $step )
+			$this->js_2();
+	}
+
+	/**
+	 * Display Javascript based on Step 1 and 3.
+	 *
+	 * @since 2.6.0
+	 */
+	function js_1() { ?>
+<script type="text/javascript">
+/* <![CDATA[ */
+	var text_objects = ['#name', '#desc', '#text-color-row'];
+	var farbtastic;
+	var default_color = '#<?php echo HEADER_TEXTCOLOR; ?>';
+	var old_color = null;
+
+	function pickColor(color) {
+		jQuery('#name').css('color', color);
+		jQuery('#desc').css('color', color);
+		jQuery('#text-color').val(color);
+		farbtastic.setColor(color);
+	}
+
+	function toggle_text(s) {
+		if (jQuery(s).attr('id') == 'showtext' && jQuery('#text-color').val() != 'blank')
+			return;
+
+		if (jQuery(s).attr('id') == 'hidetext' && jQuery('#text-color').val() == 'blank')
+			return;
+
+		if (jQuery('#text-color').val() == 'blank') {
+			//Show text
+			if (old_color == '#blank')
+				old_color = default_color;
+
+			jQuery( text_objects.toString() ).show();
+			jQuery('#text-color').val(old_color);
+			jQuery('#name').css('color', old_color);
+			jQuery('#desc').css('color', old_color);
+			pickColor(old_color);
+		} else {
+			//Hide text
+			jQuery( text_objects.toString() ).hide();
+			old_color = jQuery('#text-color').val();
+			jQuery('#text-color').val('blank');
+		}
+	}
+
+	jQuery(document).ready(function() {
+		jQuery('#pickcolor').click(function() {
+			jQuery('#color-picker').show();
+		});
+
+		jQuery('input[name="hidetext"]').click(function() {
+			toggle_text(this);
+		});
+
+		jQuery('#defaultcolor').click(function() {
+			pickColor(default_color);
+			jQuery('#text-color').val(default_color)
+		});
+
+		jQuery('#text-color').keyup(function() {
+			var _hex = jQuery('#text-color').val();
+			var hex = _hex;
+			if ( hex[0] != '#' )
+				hex = '#' + hex;
+			hex = hex.replace(/[^#a-fA-F0-9]+/, '');
+			if ( hex != _hex )
+				jQuery('#text-color').val(hex);
+			if ( hex.length == 4 || hex.length == 7 )
+				pickColor( hex );
+		});
+
+		jQuery(document).mousedown(function(){
+			jQuery('#color-picker').each( function() {
+				var display = jQuery(this).css('display');
+				if (display == 'block')
+					jQuery(this).fadeOut(2);
+			});
+		});
+
+		farbtastic = jQuery.farbtastic('#color-picker', function(color) { pickColor(color); });
+		<?php if ( $color = get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?>
+		pickColor('#<?php echo $color; ?>');
+		<?php } ?>
+
+		<?php if ( 'blank' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() ) { ?>
+		toggle_text();
+		<?php } ?>
+		});
+</script>
+<?php
+	}
+
+	/**
+	 * Display Javascript based on Step 2.
+	 *
+	 * @since 2.6.0
+	 */
+	function js_2() { ?>
+<script type="text/javascript">
+/* <![CDATA[ */
+	function onEndCrop( coords ) {
+		jQuery( '#x1' ).val(coords.x);
+		jQuery( '#y1' ).val(coords.y);
+		jQuery( '#width' ).val(coords.w);
+		jQuery( '#height' ).val(coords.h);
+	}
+
+	jQuery(document).ready(function() {
+		var xinit = <?php echo HEADER_IMAGE_WIDTH; ?>;
+		var yinit = <?php echo HEADER_IMAGE_HEIGHT; ?>;
+		var ratio = xinit / yinit;
+		var ximg = jQuery('img#upload').width();
+		var yimg = jQuery('img#upload').height();
+
+		if ( yimg < yinit || ximg < xinit ) {
+			if ( ximg / yimg > ratio ) {
+				yinit = yimg;
+				xinit = yinit * ratio;
+			} else {
+				xinit = ximg;
+				yinit = xinit / ratio;
+			}
+		}
+
+		jQuery('img#upload').imgAreaSelect({
+			handles: true,
+			keys: true,
+			aspectRatio: xinit + ':' + yinit,
+			show: true,
+			x1: 0,
+			y1: 0,
+			x2: xinit,
+			y2: yinit,
+			maxHeight: <?php echo HEADER_IMAGE_HEIGHT; ?>,
+			maxWidth: <?php echo HEADER_IMAGE_WIDTH; ?>,
+			onInit: function () {
+				jQuery('#width').val(xinit);
+				jQuery('#height').val(yinit);
+			},
+			onSelectChange: function(img, c) {
+				jQuery('#x1').val(c.x1);
+				jQuery('#y1').val(c.y1);
+				jQuery('#width').val(c.width);
+				jQuery('#height').val(c.height);
+			}
+		});
+	});
+/* ]]> */
+</script>
+<?php
+	}
+
+	/**
+	 * Display first step of custom header image page.
+	 *
+	 * @since 2.1.0
+	 */
+	function step_1() {
+		$this->process_default_headers();
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php _e('Custom Header'); ?></h2>
+
+<?php if ( ! empty( $this->updated ) ) { ?>
+<div id="message" class="updated">
+<p><?php printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p>
+</div>
+<?php } ?>
+
+<h3><?php _e( 'Header Image' ) ?></h3>
+<table class="form-table">
+<tbody>
+
+
+<tr valign="top">
+<th scope="row"><?php _e( 'Preview' ); ?></th>
+<td >
+	<?php if ( $this->admin_image_div_callback ) {
+	  call_user_func( $this->admin_image_div_callback );
+	} else {
+	?>
+	<div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;background-image:url(<?php esc_url ( header_image() ) ?>);">
+		<?php
+		if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() )
+			$style = ' style="display:none;"';
+		else
+			$style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"';
+		?>
+		<h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>"><?php bloginfo( 'name' ); ?></a></h1>
+		<div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
+	</div>
+	<?php } ?>
+</td>
+</tr>
+<?php if ( current_theme_supports( 'custom-header-uploads' ) ) : ?>
+<tr valign="top">
+<th scope="row"><?php _e( 'Upload Image' ); ?></th>
+<td>
+	<p><?php _e( 'You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.' ); ?><br />
+	<?php printf( __( 'Images of exactly <strong>%1$d &times; %2$d pixels</strong> will be used as-is.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); ?></p>
+	<form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>">
+	<p>
+		<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
+		<input type="file" id="upload" name="import" />
+		<input type="hidden" name="action" value="save" />
+		<?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ) ?>
+		<?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?>
+	</p>
+	</form>
+</td>
+</tr>
+<?php endif; ?>
+</tbody>
+</table>
+
+<form method="post" action="<?php echo esc_attr( add_query_arg( 'step', 1 ) ) ?>">
+<table class="form-table">
+<tbody>
+	<?php if ( ! empty( $this->default_headers ) ) : ?>
+<tr valign="top">
+<th scope="row"><?php _e( 'Default Images' ); ?></th>
+<td>
+<?php if ( current_theme_supports( 'custom-header-uploads' ) ) : ?>
+	<p><?php _e( 'If you don&lsquo;t want to upload your own image, you can use one of these cool headers.' ) ?></p>
+<?php else: ?>
+	<p><?php _e( 'You can use one of these cool headers.' ) ?>
+<?php endif; ?>
+	<?php
+		$this->show_default_header_selector();
+	?>
+</td>
+</tr>
+	<?php endif;
+
+	if ( get_header_image() ) : ?>
+<tr valign="top">
+<th scope="row"><?php _e( 'Remove Image' ); ?></th>
+<td>
+	<p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ) ?></p>
+	<?php submit_button( __( 'Remove Header Image' ), 'button', 'removeheader', false ); ?>
+</td>
+</tr>
+	<?php endif;
+
+	if ( defined( 'HEADER_IMAGE' ) ) : ?>
+<tr valign="top">
+<th scope="row"><?php _e( 'Reset Image' ); ?></th>
+<td>
+	<p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p>
+	<?php submit_button( __( 'Restore Original Header Image' ), 'button', 'resetheader', false ); ?>
+</td>
+</tr>
+	<?php endif; ?>
+</tbody>
+</table>
+
+	<?php if ( $this->header_text() ) : ?>
+<h3><?php _e( 'Header Text' ) ?></h3>
+<table class="form-table">
+<tbody>
+<tr valign="top" class="hide-if-no-js">
+<th scope="row"><?php _e( 'Display Text' ); ?></th>
+<td>
+	<p>
+	<?php $hidetext = get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ); ?>
+	<label><input type="radio" value="1" name="hidetext" id="hidetext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) )  ? true : false ); ?> /> <?php _e( 'No' ); ?></label>
+	<label><input type="radio" value="0" name="hidetext" id="showtext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? false : true ); ?> /> <?php _e( 'Yes' ); ?></label>
+	</p>
+</td>
+</tr>
+
+<tr valign="top" id="text-color-row">
+<th scope="row"><?php _e( 'Text Color' ); ?></th>
+<td>
+	<p>
+		<input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ); ?>" />
+		<span class="description hide-if-js"><?php _e( 'If you want to hide header text, add <strong>#blank</strong> as text color.' );?></span>
+		<input type="button" class="button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color' ); ?>" id="pickcolor" />
+	</p>
+	<div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
+</td>
+</tr>
+
+	<?php if ( defined('HEADER_TEXTCOLOR') && get_theme_mod('header_textcolor') ) { ?>
+<tr valign="top">
+<th scope="row"><?php _e('Reset Text Color'); ?></th>
+<td>
+	<p><?php _e( 'This will restore the original header text. You will not be able to restore any customizations.' ) ?></p>
+	<?php submit_button( __( 'Restore Original Header Text' ), 'button', 'resettext', false ); ?>
+</td>
+</tr>
+	<?php } ?>
+
+</tbody>
+</table>
+	<?php endif;
+
+do_action( 'custom_header_options' );
+
+wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
+
+<?php submit_button( null, 'primary', 'save-header-options' ); ?>
+</form>
+</div>
+
+<?php }
+
+	/**
+	 * Display second step of custom header image page.
+	 *
+	 * @since 2.1.0
+	 */
+	function step_2() {
+		check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload');
+		if ( ! current_theme_supports( 'custom-header-uploads' ) )
+			wp_die( 'Cheatin&#8217; uh?' );
+
+		$overrides = array('test_form' => false);
+		$file = wp_handle_upload($_FILES['import'], $overrides);
+
+		if ( isset($file['error']) )
+			wp_die( $file['error'],  __( 'Image Upload Error' ) );
+
+		$url = $file['url'];
+		$type = $file['type'];
+		$file = $file['file'];
+		$filename = basename($file);
+
+		// Construct the object array
+		$object = array(
+		'post_title' => $filename,
+		'post_content' => $url,
+		'post_mime_type' => $type,
+		'guid' => $url);
+
+		// Save the data
+		$id = wp_insert_attachment($object, $file);
+
+		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', esc_url($url));
+			do_action('wp_create_file_in_uploads', $file, $id); // For replication
+			return $this->finished();
+		} elseif ( $width > HEADER_IMAGE_WIDTH ) {
+			$oitar = $width / HEADER_IMAGE_WIDTH;
+			$image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file));
+			if ( is_wp_error( $image ) )
+				wp_die( __( 'Image could not be processed.  Please go back and try again.' ), __( 'Image Processing Error' ) );
+
+			$image = apply_filters('wp_create_file_in_uploads', $image, $id); // For replication
+
+			$url = str_replace(basename($url), basename($image), $url);
+			$width = $width / $oitar;
+			$height = $height / $oitar;
+		} else {
+			$oitar = 1;
+		}
+		?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php _e( 'Crop Header Image' ); ?></h2>
+
+<form method="post" action="<?php echo esc_attr(add_query_arg('step', 3)); ?>">
+	<p class="hide-if-no-js"><?php _e('Choose the part of the image you want to use as your header.'); ?></p>
+	<p class="hide-if-js"><strong><?php _e( 'You need Javascript to choose a part of the image.'); ?></strong></p>
+
+	<div id="crop_image" style="position: relative">
+		<img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />
+	</div>
+
+	<input type="hidden" name="x1" id="x1" value="0"/>
+	<input type="hidden" name="y1" id="y1" value="0"/>
+	<input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>"/>
+	<input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>"/>
+	<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $id ); ?>" />
+	<input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" />
+	<?php wp_nonce_field( 'custom-header-crop-image' ) ?>
+
+	<?php submit_button( __( 'Crop and Publish' ) ); ?>
+	</p>
+</form>
+</div>
+		<?php
+	}
+
+	/**
+	 * Display third step of custom header image page.
+	 *
+	 * @since 2.1.0
+	 */
+	function step_3() {
+		check_admin_referer('custom-header-crop-image');
+		if ( ! current_theme_supports( 'custom-header-uploads' ) )
+			wp_die( 'Cheatin&#8217; uh?' );
+
+		if ( $_POST['oitar'] > 1 ) {
+			$_POST['x1'] = $_POST['x1'] * $_POST['oitar'];
+			$_POST['y1'] = $_POST['y1'] * $_POST['oitar'];
+			$_POST['width'] = $_POST['width'] * $_POST['oitar'];
+			$_POST['height'] = $_POST['height'] * $_POST['oitar'];
+		}
+
+		$original = get_attached_file( $_POST['attachment_id'] );
+
+		$cropped = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT);
+		if ( is_wp_error( $cropped ) )
+			wp_die( __( 'Image could not be processed.  Please go back and try again.' ), __( 'Image Processing Error' ) );
+
+		$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
+		);
+
+		// 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
+		$medium = str_replace(basename($original), 'midsize-'.basename($original), $original);
+		@unlink( apply_filters( 'wp_delete_file', $medium ) );
+		@unlink( apply_filters( 'wp_delete_file', $original ) );
+
+		return $this->finished();
+	}
+
+	/**
+	 * Display last step of custom header image page.
+	 *
+	 * @since 2.1.0
+	 */
+	function finished() {
+		$this->updated = true;
+		$this->step_1();
+	}
+
+	/**
+	 * Display the page based on the current step.
+	 *
+	 * @since 2.1.0
+	 */
+	function admin_page() {
+		if ( ! current_user_can('edit_theme_options') )
+			wp_die(__('You do not have permission to customize headers.'));
+		$step = $this->step();
+		if ( 1 == $step )
+			$this->step_1();
+		elseif ( 2 == $step )
+			$this->step_2();
+		elseif ( 3 == $step )
+			$this->step_3();
+	}
+
+}
+?>
Index: /tags/3.1/wp-admin/edit-comments.php
===================================================================
--- /tags/3.1/wp-admin/edit-comments.php	(revision 17487)
+++ /tags/3.1/wp-admin/edit-comments.php	(revision 17487)
@@ -0,0 +1,248 @@
+<?php
+/**
+ * Edit Comments Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+if ( !current_user_can('edit_posts') )
+	wp_die(__('Cheatin&#8217; uh?'));
+
+$wp_list_table = _get_list_table('WP_Comments_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+
+$doaction = $wp_list_table->current_action();
+
+if ( $doaction ) {
+	check_admin_referer( 'bulk-comments' );
+
+	if ( 'delete_all' == $doaction && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
+		$comment_status = $wpdb->escape( $_REQUEST['comment_status'] );
+		$delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
+		$comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
+		$doaction = 'delete';
+	} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
+		$comment_ids = $_REQUEST['delete_comments'];
+		$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
+	} elseif ( isset( $_REQUEST['ids'] ) ) {
+		$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
+	} elseif ( wp_get_referer() ) {
+		wp_redirect( wp_get_referer() );
+		exit;
+	}
+
+	$approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0;
+
+	$redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() );
+	$redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to );
+
+	foreach ( $comment_ids as $comment_id ) { // Check the permissions on each
+		if ( !current_user_can( 'edit_comment', $comment_id ) )
+			continue;
+
+		switch ( $doaction ) {
+			case 'approve' :
+				wp_set_comment_status( $comment_id, 'approve' );
+				$approved++;
+				break;
+			case 'unapprove' :
+				wp_set_comment_status( $comment_id, 'hold' );
+				$unapproved++;
+				break;
+			case 'spam' :
+				wp_spam_comment( $comment_id );
+				$spammed++;
+				break;
+			case 'unspam' :
+				wp_unspam_comment( $comment_id );
+				$unspammed++;
+				break;
+			case 'trash' :
+				wp_trash_comment( $comment_id );
+				$trashed++;
+				break;
+			case 'untrash' :
+				wp_untrash_comment( $comment_id );
+				$untrashed++;
+				break;
+			case 'delete' :
+				wp_delete_comment( $comment_id );
+				$deleted++;
+				break;
+		}
+	}
+
+	if ( $approved )
+		$redirect_to = add_query_arg( 'approved', $approved, $redirect_to );
+	if ( $unapproved )
+		$redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to );
+	if ( $spammed )
+		$redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
+	if ( $unspammed )
+		$redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to );
+	if ( $trashed )
+		$redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to );
+	if ( $untrashed )
+		$redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to );
+	if ( $deleted )
+		$redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
+	if ( $trashed || $spammed )
+		$redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to );
+
+	wp_redirect( $redirect_to );
+	exit;
+} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
+	 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
+	 exit;
+}
+
+$wp_list_table->prepare_items();
+
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+wp_enqueue_script('admin-comments');
+enqueue_comment_hotkeys_js();
+
+if ( $post_id )
+	$title = sprintf(__('Comments on &#8220;%s&#8221;'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
+else
+	$title = __('Comments');
+
+add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) );
+
+add_contextual_help( $current_screen, '<p>' . __( 'You can manage comments made on your site similar to the way you manage Posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' .
+	'<p>' . __( 'A yellow row means the comment is waiting for you to moderate it.' ) . '</p>' .
+	'<p>' . __( 'In the Author column, in addition to the author&#8217;s name, email address, and blog URL, the commenter&#8217;s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '</p>' .
+	'<p>' . __( 'In the Comment column, above each comment it says &#8220;Submitted on,&#8221; followed by the date and time the comment was left on your site. Clicking on the date/time link will take you to that comment on your live site.' ) . '</p>' .
+	'<p>' . __( 'In the In Response To column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The &#8220;#&#8221; permalink symbol below leads to that post on your live site. The small bubble with the number in it shows how many comments that post has received. If the bubble is gray, you have moderated all comments for that post. If it is blue, there are pending comments. Clicking the bubble will filter the comments screen to show only comments on that post.' ) . '</p>' .
+	'<p>' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link below to learn more.' ) . '</p>' .
+	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+	'<p>' . __( '<a href="http://codex.wordpress.org/Administration_Panels#Comments" target="_blank">Documentation on Comments</a>' ) . '</p>' .
+	'<p>' . __( '<a href="http://codex.wordpress.org/Comment_Spam" target="_blank">Documentation on Comment Spam</a>' ) . '</p>' .
+	'<p>' . __( '<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">Documentation on Keyboard Shortcuts</a>' ) . '</p>' .
+	'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
+);
+require_once('./admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php
+if ( $post_id )
+	echo sprintf(__('Comments on &#8220;%s&#8221;'),
+		sprintf('<a href="%s">%s</a>',
+			get_edit_post_link($post_id),
+			wp_html_excerpt(_draft_or_post_title($post_id), 50)
+		)
+	);
+else
+	echo __('Comments');
+
+if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
+	printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
+</h2>
+
+<?php
+if ( isset( $_REQUEST['error'] ) ) {
+	$error = (int) $_REQUEST['error'];
+	$error_msg = '';
+	switch ( $error ) {
+		case 1 :
+			$error_msg = __( 'Oops, no comment with this ID.' );
+			break;
+		case 2 :
+			$error_msg = __( 'You are not allowed to edit comments on this post.' );
+			break;
+	}
+	if ( $error_msg )
+		echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>';
+}
+
+if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) {
+	$approved  = isset( $_REQUEST['approved']  ) ? (int) $_REQUEST['approved']  : 0;
+	$deleted   = isset( $_REQUEST['deleted']   ) ? (int) $_REQUEST['deleted']   : 0;
+	$trashed   = isset( $_REQUEST['trashed']   ) ? (int) $_REQUEST['trashed']   : 0;
+	$untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0;
+	$spammed   = isset( $_REQUEST['spammed']   ) ? (int) $_REQUEST['spammed']   : 0;
+	$unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
+	$same      = isset( $_REQUEST['same'] )      ? (int) $_REQUEST['same']      : 0;
+
+	if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
+		if ( $approved > 0 )
+			$messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
+
+		if ( $spammed > 0 ) {
+			$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
+			$messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
+		}
+
+		if ( $unspammed > 0 )
+			$messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
+
+		if ( $trashed > 0 ) {
+			$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
+			$messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
+		}
+
+		if ( $untrashed > 0 )
+			$messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed );
+
+		if ( $deleted > 0 )
+			$messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
+
+		if ( $same > 0 && $comment = get_comment( $same ) ) {
+			switch ( $comment->comment_approved ) {
+				case '1' :
+					$messages[] = __('This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
+					break;
+				case 'trash' :
+					$messages[] = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>';
+					break;
+				case 'spam' :
+					$messages[] = __( 'This comment is already marked as spam.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
+					break;
+			}
+		}
+
+		echo '<div id="moderated" class="updated"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
+	}
+}
+?>
+
+<?php $wp_list_table->views(); ?>
+
+<form id="comments-form" action="" method="get">
+
+<?php $wp_list_table->search_box( __( 'Search Comments' ), 'comment' ); ?>
+
+<?php if ( $post_id ) : ?>
+<input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />
+<?php endif; ?>
+<input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
+<input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr(current_time('mysql', 1)); ?>" />
+
+<input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('total_items') ); ?>" />
+<input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('per_page') ); ?>" />
+<input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('page') ); ?>" />
+
+<?php if ( isset($_REQUEST['paged']) ) { ?>
+	<input type="hidden" name="paged" value="<?php echo esc_attr( absint( $_REQUEST['paged'] ) ); ?>" />
+<?php } ?>
+
+<?php $wp_list_table->display(); ?>
+</form>
+</div>
+
+<div id="ajax-response"></div>
+
+<?php
+wp_comment_reply('-1', true, 'detail');
+wp_comment_trashnotice();
+include('./admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/edit-form-advanced.php
===================================================================
--- /tags/3.1/wp-admin/edit-form-advanced.php	(revision 17487)
+++ /tags/3.1/wp-admin/edit-form-advanced.php	(revision 17487)
@@ -0,0 +1,322 @@
+<?php
+/**
+ * Post advanced form for inclusion in the administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+// don't load directly
+if ( !defined('ABSPATH') )
+	die('-1');
+
+wp_enqueue_script('post');
+
+if ( post_type_supports($post_type, 'editor') ) {
+	if ( user_can_richedit() )
+		wp_enqueue_script('editor');
+	wp_enqueue_script('word-count');
+}
+
+if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) {
+	add_thickbox();
+	wp_enqueue_script('media-upload');
+}
+
+/**
+ * Post ID global
+ * @name $post_ID
+ * @var int
+ */
+$post_ID = isset($post_ID) ? (int) $post_ID : 0;
+$temp_ID = isset($temp_ID) ? (int) $temp_ID : 0;
+$user_ID = isset($user_ID) ? (int) $user_ID : 0;
+$action = isset($action) ? $action : '';
+
+$messages = array();
+$messages['post'] = array(
+	 0 => '', // Unused. Messages start at index 1.
+	 1 => sprintf( __('Post updated. <a href="%s">View post</a>'), esc_url( get_permalink($post_ID) ) ),
+	 2 => __('Custom field updated.'),
+	 3 => __('Custom field deleted.'),
+	 4 => __('Post updated.'),
+	/* translators: %s: date and time of the revision */
+	 5 => isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
+	 6 => sprintf( __('Post published. <a href="%s">View post</a>'), esc_url( get_permalink($post_ID) ) ),
+	 7 => __('Post saved.'),
+	 8 => sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
+	 9 => sprintf( __('Post scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview post</a>'),
+		// translators: Publish box date format, see http://php.net/date
+		date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
+	10 => sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
+);
+$messages['page'] = array(
+	 0 => '', // Unused. Messages start at index 1.
+	 1 => sprintf( __('Page updated. <a href="%s">View page</a>'), esc_url( get_permalink($post_ID) ) ),
+	 2 => __('Custom field updated.'),
+	 3 => __('Custom field deleted.'),
+	 4 => __('Page updated.'),
+	 5 => isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
+	 6 => sprintf( __('Page published. <a href="%s">View page</a>'), esc_url( get_permalink($post_ID) ) ),
+	 7 => __('Page saved.'),
+	 8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
+	 9 => sprintf( __('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
+	10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
+);
+
+$messages = apply_filters( 'post_updated_messages', $messages );
+
+$message = false;
+if ( isset($_GET['message']) ) {
+	$_GET['message'] = absint( $_GET['message'] );
+	if ( isset($messages[$post_type][$_GET['message']]) )
+		$message = $messages[$post_type][$_GET['message']];
+	elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) )
+		$message = $messages['post'][$_GET['message']];
+}
+
+$notice = false;
+$form_extra = '';
+if ( 'auto-draft' == $post->post_status ) {
+	if ( 'edit' == $action )
+		$post->post_title = '';
+	$autosave = false;
+	$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
+} else {
+	$autosave = wp_get_post_autosave( $post_ID );
+}
+
+$form_action = 'editpost';
+$nonce_action = 'update-' . $post_type . '_' . $post_ID;
+$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
+
+// Detect if there exists an autosave newer than the post and if that autosave is different than the post
+if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
+	foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
+		if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
+			$notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below.  <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
+			break;
+		}
+	}
+	unset($autosave_field, $_autosave_field);
+}
+
+$post_type_object = get_post_type_object($post_type);
+
+// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
+require_once('./includes/meta-boxes.php');
+
+add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $post_type, 'side', 'core');
+
+if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
+	add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', $post_type, 'side', 'core' );
+
+// all taxonomies
+foreach ( get_object_taxonomies($post_type) as $tax_name ) {
+	$taxonomy = get_taxonomy($tax_name);
+	if ( ! $taxonomy->show_ui )
+		continue;
+
+	$label = $taxonomy->labels->name;
+
+	if ( !is_taxonomy_hierarchical($tax_name) )
+		add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', $post_type, 'side', 'core', array( 'taxonomy' => $tax_name ));
+	else
+		add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', $post_type, 'side', 'core', array( 'taxonomy' => $tax_name ));
+}
+
+if ( post_type_supports($post_type, 'page-attributes') )
+	add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', $post_type, 'side', 'core');
+
+if ( current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' )
+	&& ( ! is_multisite() || ( ( $mu_media_buttons = get_site_option( 'mu_media_buttons', array() ) ) && ! empty( $mu_media_buttons['image'] ) ) ) )
+		add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', $post_type, 'side', 'low');
+
+if ( post_type_supports($post_type, 'excerpt') )
+	add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $post_type, 'normal', 'core');
+
+if ( post_type_supports($post_type, 'trackbacks') )
+	add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', $post_type, 'normal', 'core');
+
+if ( post_type_supports($post_type, 'custom-fields') )
+	add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core');
+
+do_action('dbx_post_advanced');
+if ( post_type_supports($post_type, 'comments') )
+	add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', $post_type, 'normal', 'core');
+
+if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
+	add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
+
+if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )
+	add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
+
+if ( post_type_supports($post_type, 'author') ) {
+	if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
+		add_meta_box('authordiv', __('Author'), 'post_author_meta_box', $post_type, 'normal', 'core');
+}
+
+if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
+	add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', $post_type, 'normal', 'core');
+
+do_action('add_meta_boxes', $post_type, $post);
+do_action('add_meta_boxes_' . $post_type, $post);
+
+do_action('do_meta_boxes', $post_type, 'normal', $post);
+do_action('do_meta_boxes', $post_type, 'advanced', $post);
+do_action('do_meta_boxes', $post_type, 'side', $post);
+
+add_screen_option('layout_columns', array('max' => 2) );
+
+if ( 'post' == $post_type ) {
+	add_contextual_help($current_screen,
+	'<p>' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of the box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '</p>' .
+	'<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>' .
+	'<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The screen icon just before that allows you to expand the edit box to full screen. The HTML mode allows you to enter raw HTML along with your post text. You can insert media files by clicking the icons above the post editor and following the directions.') . '</p>' .
+	'<p>' . __('<strong>Publish</strong> - You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.') . '</p>' .
+	( ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) ? '<p>' . __( '<strong>Post Format</strong> - This designates how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Please refer to the Codex for <a href="http://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>.' ) . '</p>' : '' ) .
+	'<p>' . __('<strong>Featured Image</strong> - This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the featured image as a post thumbnail on the home page, a custom header, etc.') . '</p>' .
+	'<p>' . __('<strong>Send Trackbacks</strong> - Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>' .
+	'<p>' . __('<strong>Discussion</strong> - You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>' .
+	'<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Posts_Add_New_SubPanel" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+	);
+} elseif ( 'page' == $post_type ) {
+	add_contextual_help($current_screen, '<p>' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the &#8220;Parent&#8221; of the other, creating a group of Pages.') . '</p>' .
+	'<p>' . __('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. The Page editor mostly works the same Post editor, but there are some Page-specific features in the Page Attributes box:') . '</p>' .
+	'<p>' . __('<strong>Parent</strong> - You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.') . '</p>' .
+	'<p>' . __('<strong>Template</strong> - Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.') . '</p>' .
+	'<p>' . __('<strong>Order</strong> - Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Pages_Add_New_SubPanel" target="_blank">Documentation on Adding New Pages</a>') . '</p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Pages_Pages_SubPanel#Editing_Individual_Pages" target="_blank">Documentation on Editing Pages</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+	);
+}
+
+require_once('./admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+<?php if ( $notice ) : ?>
+<div id="notice" class="error"><p><?php echo $notice ?></p></div>
+<?php endif; ?>
+<?php if ( $message ) : ?>
+<div id="message" class="updated"><p><?php echo $message; ?></p></div>
+<?php endif; ?>
+<form name="post" action="post.php" method="post" id="post"<?php do_action('post_edit_form_tag'); ?>>
+<?php wp_nonce_field($nonce_action); ?>
+<input type="hidden" name="parent_id" value="<?php echo esc_attr( $post->post_parent ); ?>" />
+<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 esc_attr( $form_action ) ?>" />
+<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ) ?>" />
+<input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
+<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ) ?>" />
+<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status) ?>" />
+<input type="hidden" id="referredby" name="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
+<?php
+if ( 'draft' != $post->post_status )
+	wp_original_referer_field(true, 'previous');
+
+echo $form_extra;
+
+wp_nonce_field( 'autosave', 'autosavenonce', false );
+wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
+wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
+?>
+
+<div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
+<div id="side-info-column" class="inner-sidebar">
+
+<?php
+('page' == $post_type) ? do_action('submitpage_box') : do_action('submitpost_box');
+$side_meta_boxes = do_meta_boxes($post_type, 'side', $post);
+?>
+</div>
+
+<div id="post-body">
+<div id="post-body-content">
+<?php if ( post_type_supports($post_type, 'title') ) { ?>
+<div id="titlediv">
+<div id="titlewrap">
+	<label class="hide-if-no-js" style="visibility:hidden" id="title-prompt-text" for="title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label>
+	<input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off" />
+</div>
+<div class="inside">
+<?php
+$sample_permalink_html = ! empty( $post_type_object->publicly_queryable ) ? get_sample_permalink_html($post->ID) : '';
+$shortlink = wp_get_shortlink($post->ID, 'post');
+if ( !empty($shortlink) )
+    $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
+
+if ( ! empty( $post_type_object->publicly_queryable ) && ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
+	<div id="edit-slug-box">
+	<?php
+		if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
+			echo $sample_permalink_html;
+	?>
+	</div>
+<?php
+}
+?>
+</div>
+<?php
+wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
+?>
+</div>
+<?php } ?>
+
+<?php if ( post_type_supports($post_type, 'editor') ) { ?>
+<div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
+
+<?php the_editor($post->post_content); ?>
+
+<table id="post-status-info" cellspacing="0"><tbody><tr>
+	<td id="wp-word-count"></td>
+	<td class="autosave-info">
+	<span id="autosave">&nbsp;</span>
+<?php
+	if ( 'auto-draft' != $post->post_status ) {
+		echo '<span id="last-edit">';
+		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'), esc_html( $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));
+		}
+		echo '</span>';
+	} ?>
+	</td>
+</tr></tbody></table>
+
+</div>
+
+<?php
+}
+
+do_meta_boxes($post_type, 'normal', $post);
+
+( 'page' == $post_type ) ? do_action('edit_page_form') : do_action('edit_form_advanced');
+
+do_meta_boxes($post_type, 'advanced', $post);
+
+do_action('dbx_post_sidebar'); ?>
+
+</div>
+</div>
+<br class="clear" />
+</div><!-- /poststuff -->
+</form>
+</div>
+
+<?php wp_comment_reply(); ?>
+
+<?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; ?>
Index: /tags/3.1/wp-admin/edit-form-comment.php
===================================================================
--- /tags/3.1/wp-admin/edit-form-comment.php	(revision 17487)
+++ /tags/3.1/wp-admin/edit-form-comment.php	(revision 17487)
@@ -0,0 +1,147 @@
+<?php
+/**
+ * Edit comment form for inclusion in another file.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+// don't load directly
+if ( !defined('ABSPATH') )
+	die('-1');
+
+/**
+ * @var string
+ */
+$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='" . esc_attr($comment->comment_ID) . "' />\n<input type='hidden' name='comment_post_ID' value='" . esc_attr($comment->comment_post_ID);
+$comment->comment_author_email = esc_attr($comment->comment_author_email);
+?>
+
+<form name="post" action="comment.php" method="post" id="post">
+<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php _e('Edit Comment'); ?></h2>
+
+<div id="poststuff" class="metabox-holder has-right-sidebar">
+<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
+<input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
+
+<div id="side-info-column" class="inner-sidebar">
+<div id="submitdiv" class="stuffbox" >
+<h3><span class='hndle'><?php _e('Status') ?></span></h3>
+<div class="inside">
+<div class="submitbox" id="submitcomment">
+<div id="minor-publishing">
+
+<div id="minor-publishing-actions">
+<div id="preview-action">
+<a class="preview button" href="<?php echo get_comment_link(); ?>" target="_blank"><?php _e('View Comment'); ?></a>
+</div>
+<div class="clear"></div>
+</div>
+
+<div id="misc-publishing-actions">
+
+<div class="misc-pub-section" id="comment-status-radio">
+<label class="approved"><input type="radio"<?php checked( $comment->comment_approved, '1' ); ?> name="comment_status" value="1" /><?php /* translators: comment type radio button */ _ex('Approved', 'adjective') ?></label><br />
+<label class="waiting"><input type="radio"<?php checked( $comment->comment_approved, '0' ); ?> name="comment_status" value="0" /><?php /* translators: comment type radio button */ _ex('Pending', 'adjective') ?></label><br />
+<label class="spam"><input type="radio"<?php checked( $comment->comment_approved, 'spam' ); ?> name="comment_status" value="spam" /><?php /* translators: comment type radio button */ _ex('Spam', 'adjective'); ?></label>
+</div>
+
+<div class="misc-pub-section curtime misc-pub-section-last">
+<?php
+// translators: Publish box date formt, see http://php.net/date
+$datef = __( 'M j, Y @ G:i' );
+$stamp = __('Submitted on: <b>%1$s</b>');
+$date = date_i18n( $datef, strtotime( $comment->comment_date ) );
+?>
+<span id="timestamp"><?php printf($stamp, $date); ?></span>&nbsp;<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
+<div id='timestampdiv' class='hide-if-js'><?php touch_time(('editcomment' == $action), 0, 5); ?></div>
+</div>
+</div> <!-- misc actions -->
+<div class="clear"></div>
+</div>
+
+<div id="major-publishing-actions">
+<div id="delete-action">
+<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=" . ( !EMPTY_TRASH_DAYS ? 'deletecomment' : 'trashcomment' ) . "&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . ( !EMPTY_TRASH_DAYS ? __('Delete Permanently') : __('Move to Trash') ) . "</a>\n"; ?>
+</div>
+<div id="publishing-action">
+<?php submit_button( __( 'Update Comment' ), 'primary', 'save', false, array( 'tabindex' => '4' ) ); ?>
+</div>
+<div class="clear"></div>
+</div>
+</div>
+</div>
+</div>
+</div>
+
+<div id="post-body">
+<div id="post-body-content">
+<div id="namediv" class="stuffbox">
+<h3><label for="name"><?php _e( 'Author' ) ?></label></h3>
+<div class="inside">
+<table class="form-table editcomment">
+<tbody>
+<tr valign="top">
+	<td class="first"><?php _e( 'Name:' ); ?></td>
+	<td><input type="text" name="newcomment_author" size="30" value="<?php echo esc_attr( $comment->comment_author ); ?>" tabindex="1" id="name" /></td>
+</tr>
+<tr valign="top">
+	<td class="first">
+	<?php
+		if ( $comment->comment_author_email ) {
+			printf( __( 'E-mail (%s):' ), get_comment_author_email_link( __( 'send e-mail' ), '', '' ) );
+		} else {
+			_e( 'E-mail:' );
+		}
+?></td>
+	<td><input type="text" name="newcomment_author_email" size="30" value="<?php echo $comment->comment_author_email; ?>" tabindex="2" id="email" /></td>
+</tr>
+<tr valign="top">
+	<td class="first">
+	<?php
+		if ( ! empty( $comment->comment_author_url ) && 'http://' != $comment->comment_author_url ) {
+			$link = '<a href="' . $comment->comment_author_url . '" rel="external nofollow" target="_blank">' . __('visit site') . '</a>';
+			printf( __( 'URL (%s):' ), apply_filters('get_comment_author_link', $link ) );
+		} else {
+			_e( 'URL:' );
+		} ?></td>
+	<td><input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" class="code" value="<?php echo esc_attr($comment->comment_author_url); ?>" tabindex="3" /></td>
+</tr>
+</tbody>
+</table>
+<br />
+</div>
+</div>
+
+<div id="postdiv" class="postarea">
+<?php the_editor($comment->comment_content, 'content', 'newcomment_author_url', false, 4); ?>
+<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
+</div>
+
+<?php
+do_action('add_meta_boxes', 'comment', $comment);
+do_action('add_meta_boxes_comment', $comment);
+
+do_meta_boxes('comment', 'normal', $comment);
+?>
+<input type="hidden" name="c" value="<?php echo esc_attr($comment->comment_ID) ?>" />
+<input type="hidden" name="p" value="<?php echo esc_attr($comment->comment_post_ID) ?>" />
+<input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url(stripslashes(wp_get_referer())); ?>" />
+<?php wp_original_referer_field(true, 'previous'); ?>
+<input type="hidden" name="noredir" value="1" />
+
+</div>
+</div>
+</div>
+</div>
+</form>
+
+<script type="text/javascript">
+try{document.post.name.focus();}catch(e){}
+</script>
Index: /tags/3.1/wp-admin/edit-link-form.php
===================================================================
--- /tags/3.1/wp-admin/edit-link-form.php	(revision 17487)
+++ /tags/3.1/wp-admin/edit-link-form.php	(revision 17487)
@@ -0,0 +1,129 @@
+<?php
+/**
+ * Edit links form for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+// don't load directly
+if ( !defined('ABSPATH') )
+	die('-1');
+
+if ( ! empty($link_id) ) {
+	$heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
+	$submit_text = __('Update Link');
+	$form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+	$nonce_action = 'update-bookmark_' . $link_id;
+} else {
+	$heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
+	$submit_text = __('Add Link');
+	$form = '<form name="addlink" id="addlink" method="post" action="link.php">';
+	$nonce_action = 'add-bookmark';
+}
+
+require_once('./includes/meta-boxes.php');
+
+add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', 'link', 'side', 'core');
+add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', 'link', 'normal', 'core');
+add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', 'link', 'normal', 'core');
+add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', 'link', 'normal', 'core');
+add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', 'link', 'normal', 'core');
+
+do_action('add_meta_boxes', 'link', $link);
+do_action('add_meta_boxes_link', $link);
+
+do_action('do_meta_boxes', 'link', 'normal', $link);
+do_action('do_meta_boxes', 'link', 'advanced', $link);
+do_action('do_meta_boxes', 'link', 'side', $link);
+
+add_screen_option('layout_columns', array('max' => 2) );
+
+add_contextual_help($current_screen,
+	'<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link&#8217;s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' .
+	'<p>' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don&#8217;t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' .
+	'<p>' . __( 'XFN stands for <a href="http://gmpg.org/xfn/" target="_blank">XHTML Friends Network</a>, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.' ) . '</p>' .
+	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+	'<p>' . __( '<a href="http://codex.wordpress.org/Links_Add_New_SubPanel" target="_blank">Documentation on Creating Links</a>' ) . '</p>' .
+	'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
+);
+
+require_once ('admin-header.php');
+
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<?php if ( isset( $_GET['added'] ) ) : ?>
+<div id="message" class="updated"><p><?php _e('Link added.'); ?></p></div>
+<?php endif; ?>
+
+<?php
+if ( !empty($form) )
+	echo $form;
+if ( !empty($link_added) )
+	echo $link_added;
+
+wp_nonce_field( $nonce_action );
+wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
+wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
+
+<div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
+
+<div id="side-info-column" class="inner-sidebar">
+<?php
+
+do_action('submitlink_box');
+$side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
+
+?>
+</div>
+
+<div id="post-body">
+<div id="post-body-content">
+<div id="namediv" class="stuffbox">
+<h3><label for="link_name"><?php _e('Name') ?></label></h3>
+<div class="inside">
+	<input type="text" name="link_name" size="30" tabindex="1" value="<?php echo esc_attr($link->link_name); ?>" id="link_name" />
+    <p><?php _e('Example: Nifty blogging software'); ?></p>
+</div>
+</div>
+
+<div id="addressdiv" class="stuffbox">
+<h3><label for="link_url"><?php _e('Web Address') ?></label></h3>
+<div class="inside">
+	<input type="text" name="link_url" size="30" class="code" tabindex="1" value="<?php echo esc_attr($link->link_url); ?>" id="link_url" />
+    <p><?php _e('Example: <code>http://wordpress.org/</code> &#8212; don&#8217;t forget the <code>http://</code>'); ?></p>
+</div>
+</div>
+
+<div id="descriptiondiv" class="stuffbox">
+<h3><label for="link_description"><?php _e('Description') ?></label></h3>
+<div class="inside">
+	<input type="text" name="link_description" size="30" tabindex="1" value="<?php echo isset($link->link_description) ? esc_attr($link->link_description) : ''; ?>" id="link_description" />
+    <p><?php _e('This will be shown when someone hovers over the link in the blogroll, or optionally below the link.'); ?></p>
+</div>
+</div>
+
+<?php
+
+do_meta_boxes('link', 'normal', $link);
+
+do_meta_boxes('link', 'advanced', $link);
+
+if ( $link_id ) : ?>
+<input type="hidden" name="action" value="save" />
+<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
+<input type="hidden" name="order_by" value="<?php echo esc_attr($order_by); ?>" />
+<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
+<?php else: ?>
+<input type="hidden" name="action" value="add" />
+<?php endif; ?>
+
+</div>
+</div>
+</div>
+
+</form>
+</div>
Index: /tags/3.1/wp-admin/edit-tag-form.php
===================================================================
--- /tags/3.1/wp-admin/edit-tag-form.php	(revision 17487)
+++ /tags/3.1/wp-admin/edit-tag-form.php	(revision 17487)
@@ -0,0 +1,93 @@
+<?php
+/**
+ * Edit tag form for inclusion in administration panels.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+// don't load directly
+if ( !defined('ABSPATH') )
+	die('-1');
+
+if ( empty($tag_ID) ) { ?>
+	<div id="message" class="updated"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
+<?php
+	return;
+}
+
+// Back compat hooks
+if ( 'category' == $taxonomy )
+	do_action('edit_category_form_pre', $tag );
+elseif ( 'link_category' == $taxonomy )
+	do_action('edit_link_category_form_pre', $tag );
+else
+	do_action('edit_tag_form_pre', $tag);
+
+do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy);  ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo $tax->labels->edit_item; ?></h2>
+<div id="ajax-response"></div>
+<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">
+<input type="hidden" name="action" value="editedtag" />
+<input type="hidden" name="tag_ID" value="<?php echo esc_attr($tag->term_id) ?>" />
+<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy) ?>" />
+<?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
+	<table class="form-table">
+		<tr class="form-field form-required">
+			<th scope="row" valign="top"><label for="name"><?php _ex('Name', 'Taxonomy Name'); ?></label></th>
+			<td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" />
+			<p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
+		</tr>
+<?php if ( !global_terms_enabled() ) { ?>
+		<tr class="form-field">
+			<th scope="row" valign="top"><label for="slug"><?php _ex('Slug', 'Taxonomy Slug'); ?></label></th>
+			<td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo esc_attr(apply_filters('editable_slug', $tag->slug)); ?>" size="40" />
+			<p class="description"><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>
+		</tr>
+<?php } ?>
+<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
+		<tr class="form-field">
+			<th scope="row" valign="top"><label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label></th>
+			<td>
+				<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude_tree' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?><br />
+				<?php if ( 'category' == $taxonomy ) : ?>
+				<span class="description"><?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.'); ?></span>
+				<?php endif; ?>
+			</td>
+		</tr>
+<?php endif; // is_taxonomy_hierarchical() ?>
+		<tr class="form-field">
+			<th scope="row" valign="top"><label for="description"><?php _ex('Description', 'Taxonomy Description'); ?></label></th>
+			<td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo $tag->description; // textarea_escaped ?></textarea><br />
+			<span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span></td>
+		</tr>
+		<?php
+		// Back compat hooks
+		if ( 'category' == $taxonomy )
+			do_action('edit_category_form_fields', $tag);
+		if ( 'link_category' == $taxonomy )
+			do_action('edit_link_category_form_fields', $tag);
+		else
+			do_action('edit_tag_form_fields', $tag);
+
+		do_action($taxonomy . '_edit_form_fields', $tag, $taxonomy);
+		?>
+	</table>
+<?php
+// Back compat hooks
+if ( 'category' == $taxonomy )
+	do_action('edit_category_form', $tag);
+if ( 'link_category' == $taxonomy )
+	do_action('edit_link_category_form', $tag);
+else
+	do_action('edit_tag_form', $tag);
+
+do_action($taxonomy . '_edit_form', $tag, $taxonomy);
+
+submit_button( __('Update') );
+?>
+</form>
+</div>
Index: /tags/3.1/wp-admin/edit-tags.php
===================================================================
--- /tags/3.1/wp-admin/edit-tags.php	(revision 17487)
+++ /tags/3.1/wp-admin/edit-tags.php	(revision 17487)
@@ -0,0 +1,394 @@
+<?php
+/**
+ * Edit Tags Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+$tax = get_taxonomy( $taxnow );
+if ( !current_user_can( $tax->cap->manage_terms ) )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+$wp_list_table = _get_list_table('WP_Terms_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+
+$title = $tax->labels->name;
+
+if ( 'post' != $post_type ) {
+	$parent_file = "edit.php?post_type=$post_type";
+	$submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
+} else if ( 'link_category' == $tax->name ) {
+	$parent_file = 'link-manager.php';
+	$submenu_file = 'edit-tags.php?taxonomy=link_category';
+} else {
+	$parent_file = 'edit.php';
+	$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
+}
+
+add_screen_option( 'per_page', array('label' => $title, 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page') );
+
+switch ( $wp_list_table->current_action() ) {
+
+case 'add-tag':
+
+	check_admin_referer( 'add-tag' );
+
+	if ( !current_user_can( $tax->cap->edit_terms ) )
+		wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+	$ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
+	$location = 'edit-tags.php?taxonomy=' . $taxonomy;
+	if ( 'post' != $post_type )
+		$location .= '&post_type=' . $post_type;
+
+	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', 1, $location );
+	else
+		$location = add_query_arg( 'message', 4, $location );
+	wp_redirect( $location );
+	exit;
+break;
+
+case 'delete':
+	$location = 'edit-tags.php?taxonomy=' . $taxonomy;
+	if ( 'post' != $post_type )
+		$location .= '&post_type=' . $post_type;
+	if ( $referer = wp_get_referer() ) {
+		if ( false !== strpos( $referer, 'edit-tags.php' ) )
+			$location = $referer;
+	}
+
+	if ( !isset( $_REQUEST['tag_ID'] ) ) {
+		wp_redirect( $location );
+		exit;
+	}
+
+	$tag_ID = (int) $_REQUEST['tag_ID'];
+	check_admin_referer( 'delete-tag_' .  $tag_ID );
+
+	if ( !current_user_can( $tax->cap->delete_terms ) )
+		wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+	wp_delete_term( $tag_ID, $taxonomy );
+
+	$location = add_query_arg( 'message', 2, $location );
+	wp_redirect( $location );
+	exit;
+
+break;
+
+case 'bulk-delete':
+	check_admin_referer( 'bulk-tags' );
+
+	if ( !current_user_can( $tax->cap->delete_terms ) )
+		wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+	$tags = (array) $_REQUEST['delete_tags'];
+	foreach ( $tags as $tag_ID ) {
+		wp_delete_term( $tag_ID, $taxonomy );
+	}
+
+	$location = 'edit-tags.php?taxonomy=' . $taxonomy;
+	if ( 'post' != $post_type )
+		$location .= '&post_type=' . $post_type;
+	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;
+
+case 'edit':
+	$title = $tax->labels->edit_item;
+
+	require_once ( 'admin-header.php' );
+	$tag_ID = (int) $_REQUEST['tag_ID'];
+
+	$tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' );
+	include( './edit-tag-form.php' );
+
+break;
+
+case 'editedtag':
+	$tag_ID = (int) $_POST['tag_ID'];
+	check_admin_referer( 'update-tag_' . $tag_ID );
+
+	if ( !current_user_can( $tax->cap->edit_terms ) )
+		wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+	$ret = wp_update_term( $tag_ID, $taxonomy, $_POST );
+
+	$location = 'edit-tags.php?taxonomy=' . $taxonomy;
+	if ( 'post' != $post_type )
+		$location .= '&post_type=' . $post_type;
+
+	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;
+
+default:
+if ( ! empty($_REQUEST['_wp_http_referer']) ) {
+	$location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) );
+
+	if ( ! empty( $_REQUEST['paged'] ) )
+		$location = add_query_arg( 'paged', (int) $_REQUEST['paged'] );
+
+	wp_redirect( $location );
+	exit;
+}
+
+$wp_list_table->prepare_items();
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+wp_enqueue_script('admin-tags');
+if ( current_user_can($tax->cap->edit_terms) )
+	wp_enqueue_script('inline-edit-tax');
+
+if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy  ) {
+	$help ='';
+	if ( 'category' == $taxonomy )
+		$help = '<p>' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is &#8220;Uncategorized&#8221; until you change it in your <a href="%s">writing settings</a>.' ) , 'options-writing.php' ) . '</p>';
+	elseif ( 'link_category' == $taxonomy )
+		$help = '<p>' . __( 'You can create groups of links by using link categories. Link category names must be unique and link categories are separate from the categories you use for posts.' ) . '</p>';
+	else
+		$help = '<p>' . __( 'You can assign keywords to your posts using Post Tags. Unlike categories, tags have no hierarchy, meaning there&#8217;s no relationship from one tag to another.' ) . '</p>';
+
+	if ( 'link_category' == $taxonomy )
+		$help .= '<p>' . __( 'You can delete link categories in the Bulk Action pulldown, but that action does not delete the links within the category. Instead, it moves them to the default link category.' ) . '</p>';
+	else
+		$help .='<p>' . __( 'What&#8217;s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>';
+
+	if ( 'category' == $taxonomy )
+		$help .= '<p>' . __( 'When adding a new category on this screen, you&#8217;ll fill in the following fields:' ) . '</p>';
+	elseif ( 'post_tag' == $taxonomy )
+		$help .= '<p>' . __( 'When adding a new tag on this screen, you&#8217;ll fill in the following fields:' ) . '</p>';
+
+	if ( 'category' == $taxonomy || 'post_tag' == $taxonomy  )
+
+		$help .= '<ul>' .
+		'<li>' . __( '<strong>Name</strong> - The name is how it appears on your site.' ) . '</li>';
+
+	if ( ! global_terms_enabled()  )
+	if ( 'category' == $taxonomy || 'post_tag' == $taxonomy  )
+		$help .= '<li>' . __( '<strong>Slug</strong> - The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>';
+
+	if ( 'category' == $taxonomy )
+		$help .= '<li>' . __( '<strong>Parent</strong> - 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. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>';
+
+	if ( 'category' == $taxonomy || 'post_tag' == $taxonomy  )
+		$help .= '<li>' . __( '<strong>Description</strong> - The description is not prominent by default; however, some themes may display it.' ) . '</li>' .
+		'</ul>' .
+		'<p>' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '</p>' .
+		'<p><strong>' . __( 'For more information:' ) . '</strong></p>';
+
+	if ( 'category' == $taxonomy )
+		$help .= '<p>' . __( '<a href="http://codex.wordpress.org/Posts_Categories_SubPanel" target="_blank">Documentation on Categories</a>' ) . '</p>';
+	elseif ( 'link_category' == $taxonomy )
+		$help .= '<p>' . __( '<a href="http://codex.wordpress.org/Links_Link_Categories_SubPanel" target="_blank">Documentation on Link Categories</a>' ) . '</p>';
+	else
+		$help .= '<p>' . __( '<a href="http://codex.wordpress.org/Posts_Post_Tags_SubPanel" target="_blank">Documentation on Post Tags</a>' ) . '</p>';
+
+	$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
+
+	add_contextual_help($current_screen, $help);
+	unset($help);
+}
+
+require_once ('admin-header.php');
+
+if ( !current_user_can($tax->cap->edit_terms) )
+	wp_die( __('You are not allowed to edit this item.') );
+
+$messages[1] = __('Item added.');
+$messages[2] = __('Item deleted.');
+$messages[3] = __('Item updated.');
+$messages[4] = __('Item not added.');
+$messages[5] = __('Item not updated.');
+$messages[6] = __('Items deleted.');
+
+?>
+
+<div class="wrap nosubsub">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title );
+if ( !empty($_REQUEST['s']) )
+	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
+</h2>
+
+<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?>
+<div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div>
+<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
+endif; ?>
+<div id="ajax-response"></div>
+
+<form class="search-form" action="" method="get">
+<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
+<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
+
+<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
+
+</form>
+<br class="clear" />
+
+<div id="col-container">
+
+<div id="col-right">
+<div class="col-wrap">
+<form id="posts-filter" action="" method="post">
+<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
+<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
+
+<?php $wp_list_table->display(); ?>
+
+<br class="clear" />
+</form>
+
+<?php if ( 'category' == $taxonomy ) : ?>
+<div class="form-wrap">
+<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_cat_name(get_option('default_category')))) ?></p>
+<?php if ( current_user_can( 'import' ) ) : ?>
+<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'import.php') ?></p>
+<?php endif; ?>
+</div>
+<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?>
+<div class="form-wrap">
+<p><?php printf(__('Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>'), 'import.php') ;?>.</p>
+</div>
+<?php endif;
+do_action('after-' . $taxonomy . '-table', $taxonomy);
+?>
+
+</div>
+</div><!-- /col-right -->
+
+<div id="col-left">
+<div class="col-wrap">
+
+<?php
+
+if ( !is_null( $tax->labels->popular_items ) ) {
+	if ( current_user_can( $tax->cap->edit_terms ) )
+		$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) );
+	else
+		$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false ) );
+
+	if ( $tag_cloud ) :
+	?>
+<div class="tagcloud">
+<h3><?php echo $tax->labels->popular_items; ?></h3>
+<?php echo $tag_cloud; unset( $tag_cloud ); ?>
+</div>
+<?php
+endif;
+}
+
+if ( current_user_can($tax->cap->edit_terms) ) {
+	// Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form
+	if ( 'category' == $taxonomy )
+		do_action('add_category_form_pre', (object)array('parent' => 0) );
+	elseif ( 'link_category' == $taxonomy )
+		do_action('add_link_category_form_pre', (object)array('parent' => 0) );
+	else
+		do_action('add_tag_form_pre', $taxonomy);
+
+	do_action($taxonomy . '_pre_add_form', $taxonomy);
+?>
+
+<div class="form-wrap">
+<h3><?php echo $tax->labels->add_new_item; ?></h3>
+<form id="addtag" method="post" action="edit-tags.php" class="validate">
+<input type="hidden" name="action" value="add-tag" />
+<input type="hidden" name="screen" value="<?php echo esc_attr($current_screen->id); ?>" />
+<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
+<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
+<?php wp_nonce_field('add-tag'); ?>
+
+<div class="form-field form-required">
+	<label for="tag-name"><?php _ex('Name', 'Taxonomy Name'); ?></label>
+	<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
+	<p><?php _e('The name is how it appears on your site.'); ?></p>
+</div>
+<?php if ( ! global_terms_enabled() ) : ?>
+<div class="form-field">
+	<label for="tag-slug"><?php _ex('Slug', 'Taxonomy Slug'); ?></label>
+	<input name="slug" id="tag-slug" type="text" value="" size="40" />
+	<p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
+</div>
+<?php endif; // global_terms_enabled() ?>
+<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
+<div class="form-field">
+	<label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label>
+	<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
+	<?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?>
+		<p><?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.'); ?></p>
+	<?php endif; ?>
+</div>
+<?php endif; // is_taxonomy_hierarchical() ?>
+<div class="form-field">
+	<label for="tag-description"><?php _ex('Description', 'Taxonomy Description'); ?></label>
+	<textarea name="description" id="tag-description" rows="5" cols="40"></textarea>
+	<p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p>
+</div>
+
+<?php
+if ( ! is_taxonomy_hierarchical($taxonomy) )
+	do_action('add_tag_form_fields', $taxonomy);
+do_action($taxonomy . '_add_form_fields', $taxonomy);
+
+submit_button( $tax->labels->add_new_item, 'button' );
+
+// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form
+if ( 'category' == $taxonomy )
+	do_action('edit_category_form', (object)array('parent' => 0) );
+elseif ( 'link_category' == $taxonomy )
+	do_action('edit_link_category_form', (object)array('parent' => 0) );
+else
+	do_action('add_tag_form', $taxonomy);
+
+do_action($taxonomy . '_add_form', $taxonomy);
+?>
+</form></div>
+<?php } ?>
+
+</div>
+</div><!-- /col-left -->
+
+</div><!-- /col-container -->
+</div><!-- /wrap -->
+
+<?php $wp_list_table->inline_edit(); ?>
+
+<?php
+break;
+}
+
+include('./admin-footer.php');
+
+?>
Index: /tags/3.1/wp-admin/edit.php
===================================================================
--- /tags/3.1/wp-admin/edit.php	(revision 17487)
+++ /tags/3.1/wp-admin/edit.php	(revision 17487)
@@ -0,0 +1,267 @@
+<?php
+/**
+ * Edit Posts Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( !isset($_GET['post_type']) )
+	$post_type = 'post';
+elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
+	$post_type = $_GET['post_type'];
+else
+	wp_die( __('Invalid post type') );
+
+$_GET['post_type'] = $post_type;
+
+$post_type_object = get_post_type_object( $post_type );
+
+if ( !current_user_can($post_type_object->cap->edit_posts) )
+	wp_die(__('Cheatin&#8217; uh?'));
+
+$wp_list_table = _get_list_table('WP_Posts_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+
+// Back-compat for viewing comments of an entry
+foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
+	if ( ! empty( $_REQUEST[ $_redirect ] ) ) {
+		wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) );
+		exit;
+	}
+}
+unset( $_redirect );
+
+if ( 'post' != $post_type ) {
+	$parent_file = "edit.php?post_type=$post_type";
+	$submenu_file = "edit.php?post_type=$post_type";
+	$post_new_file = "post-new.php?post_type=$post_type";
+} else {
+	$parent_file = 'edit.php';
+	$submenu_file = 'edit.php';
+	$post_new_file = 'post-new.php';
+}
+
+$doaction = $wp_list_table->current_action();
+
+if ( $doaction ) {
+	check_admin_referer('bulk-posts');
+
+	$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
+	$sendback = add_query_arg( 'paged', $pagenum, $sendback );
+	if ( strpos($sendback, 'post.php') !== false )
+		$sendback = admin_url($post_new_file);
+
+	if ( 'delete_all' == $doaction ) {
+		$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
+		if ( get_post_status_object($post_status) ) // Check the post status exists first
+			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
+		$doaction = 'delete';
+	} elseif ( isset( $_REQUEST['media'] ) ) {
+		$post_ids = $_REQUEST['media'];
+	} elseif ( isset( $_REQUEST['ids'] ) ) {
+		$post_ids = explode( ',', $_REQUEST['ids'] );
+	} elseif ( !empty( $_REQUEST['post'] ) ) {
+		$post_ids = array_map('intval', $_REQUEST['post']);
+	}
+
+	if ( !isset( $post_ids ) ) {
+		wp_redirect( $sendback );
+		exit;
+	}
+
+	switch ( $doaction ) {
+		case 'trash':
+			$trashed = 0;
+			foreach( (array) $post_ids as $post_id ) {
+				if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+					wp_die( __('You are not allowed to move this item to the Trash.') );
+
+				if ( !wp_trash_post($post_id) )
+					wp_die( __('Error in moving to Trash.') );
+
+				$trashed++;
+			}
+			$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids) ), $sendback );
+			break;
+		case 'untrash':
+			$untrashed = 0;
+			foreach( (array) $post_ids as $post_id ) {
+				if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+					wp_die( __('You are not allowed to restore this item from the Trash.') );
+
+				if ( !wp_untrash_post($post_id) )
+					wp_die( __('Error in restoring from Trash.') );
+
+				$untrashed++;
+			}
+			$sendback = add_query_arg('untrashed', $untrashed, $sendback);
+			break;
+		case 'delete':
+			$deleted = 0;
+			foreach( (array) $post_ids as $post_id ) {
+				$post_del = & get_post($post_id);
+
+				if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+					wp_die( __('You are not allowed to delete this item.') );
+
+				if ( $post_del->post_type == 'attachment' ) {
+					if ( ! wp_delete_attachment($post_id) )
+						wp_die( __('Error in deleting...') );
+				} else {
+					if ( !wp_delete_post($post_id) )
+						wp_die( __('Error in deleting...') );
+				}
+				$deleted++;
+			}
+			$sendback = add_query_arg('deleted', $deleted, $sendback);
+			break;
+		case 'edit':
+			$done = bulk_edit_posts($_REQUEST);
+
+			if ( is_array($done) ) {
+				$done['updated'] = count( $done['updated'] );
+				$done['skipped'] = count( $done['skipped'] );
+				$done['locked'] = count( $done['locked'] );
+				$sendback = add_query_arg( $done, $sendback );
+			}
+			break;
+	}
+
+	$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view'), $sendback );
+
+	wp_redirect($sendback);
+	exit();
+} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) {
+	 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
+	 exit;
+}
+
+$wp_list_table->prepare_items();
+
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+wp_enqueue_script('inline-edit-post');
+
+$title = $post_type_object->labels->name;
+
+if ( 'post' == $post_type ) {
+	add_contextual_help($current_screen,
+	'<p>' . __('You can customize the display of this screen in a number of ways:') . '</p>' .
+	'<ul>' .
+	'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
+	'<li>' . __('You can filter the list of posts by post status using the text links in the upper left to show All, Published, Draft, or Trashed posts. The default view is to show all posts.') . '</li>' .
+	'<li>' . __('You can view posts in a simple title list or with an excerpt. Choose the view you prefer by clicking on the icons at the top of the list on the right.') . '</li>' .
+	'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
+	'</ul>' .
+	'<p>' . __('Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:') . '</p>' .
+	'<ul>' .
+	'<li>' . __('Edit takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.') . '</li>' .
+	'<li>' . __('Quick Edit provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.') . '</li>' .
+	'<li>' . __('Trash removes your post from this list and places it in the trash, from which you can permanently delete it.') . '</li>' .
+	'<li>' . __('Preview will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post&#8217;s status.') . '</li>' .
+	'</ul>' .
+	'<p>' . __('You can also edit multiple posts at once. Select the posts you want to edit using the checkboxes, select Edit from the Bulk Actions menu and click Apply. You will be able to change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Posts_Posts_SubPanel" target="_blank">Documentation on Managing Posts</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+	);
+} elseif ( 'page' == $post_type ) {
+	add_contextual_help($current_screen,
+	'<p>' . __('Pages are similar to Posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest Pages under other Pages by making one the &#8220;Parent&#8221; of the other, creating a group of Pages.') . '</p>' .
+	'<p>' . __('Managing Pages is very similar to managing Posts, and the screens can be customized in the same way.') . '</p>' .
+	'<p>' . __('You can also perform the same types of actions, including narrowing the list by using the filters, acting on a Page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple Pages at once.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Pages_Pages_SubPanel" target="_blank">Documentation on Managing Pages</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+	);
+}
+
+add_screen_option( 'per_page', array('label' => $title, 'default' => 20) );
+
+require_once('./admin-header.php');
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $post_type_object->labels->name ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php
+if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
+	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
+</h2>
+
+<?php
+if ( isset($_REQUEST['posted']) && $_REQUEST['posted'] ) : $_REQUEST['posted'] = (int) $_REQUEST['posted']; ?>
+<div id="message" class="updated"><p><strong><?php _e('This has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_REQUEST['posted'] ); ?>"><?php _e('View Post'); ?></a> | <a href="<?php echo get_edit_post_link( $_REQUEST['posted'] ); ?>"><?php _e('Edit Post'); ?></a></p></div>
+<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
+endif; ?>
+
+<?php if ( isset($_REQUEST['locked']) || isset($_REQUEST['skipped']) || isset($_REQUEST['updated']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) ) { ?>
+<div id="message" class="updated"><p>
+<?php if ( isset($_REQUEST['updated']) && (int) $_REQUEST['updated'] ) {
+	printf( _n( '%s post updated.', '%s posts updated.', $_REQUEST['updated'] ), number_format_i18n( $_REQUEST['updated'] ) );
+	unset($_REQUEST['updated']);
+}
+
+if ( isset($_REQUEST['skipped']) && (int) $_REQUEST['skipped'] )
+	unset($_REQUEST['skipped']);
+
+if ( isset($_REQUEST['locked']) && (int) $_REQUEST['locked'] ) {
+	printf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $_REQUEST['locked'] ), number_format_i18n( $_REQUEST['locked'] ) );
+	unset($_REQUEST['locked']);
+}
+
+if ( isset($_REQUEST['deleted']) && (int) $_REQUEST['deleted'] ) {
+	printf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $_REQUEST['deleted'] ), number_format_i18n( $_REQUEST['deleted'] ) );
+	unset($_REQUEST['deleted']);
+}
+
+if ( isset($_REQUEST['trashed']) && (int) $_REQUEST['trashed'] ) {
+	printf( _n( 'Item moved to the Trash.', '%s items moved to the Trash.', $_REQUEST['trashed'] ), number_format_i18n( $_REQUEST['trashed'] ) );
+	$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
+	echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
+	unset($_REQUEST['trashed']);
+}
+
+if ( isset($_REQUEST['untrashed']) && (int) $_REQUEST['untrashed'] ) {
+	printf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $_REQUEST['untrashed'] ), number_format_i18n( $_REQUEST['untrashed'] ) );
+	unset($_REQUEST['undeleted']);
+}
+
+$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
+?>
+</p></div>
+<?php } ?>
+
+<?php $wp_list_table->views(); ?>
+
+<form id="posts-filter" action="" method="get">
+
+<?php $wp_list_table->search_box( $post_type_object->labels->search_items, 'post' ); ?>
+
+<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
+<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
+<?php if ( ! empty( $_REQUEST['show_sticky'] ) ) { ?>
+<input type="hidden" name="show_sticky" value="1" />
+<?php } ?>
+
+<?php $wp_list_table->display(); ?>
+
+</form>
+
+<?php
+if ( $wp_list_table->has_items() )
+	$wp_list_table->inline_edit();
+?>
+
+<div id="ajax-response"></div>
+<br class="clear" />
+</div>
+
+<?php
+include('./admin-footer.php');
Index: /tags/3.1/wp-admin/export.php
===================================================================
--- /tags/3.1/wp-admin/export.php	(revision 17487)
+++ /tags/3.1/wp-admin/export.php	(revision 17487)
@@ -0,0 +1,206 @@
+<?php
+/**
+ * WordPress Export Administration Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
+require_once ('admin.php');
+
+if ( !current_user_can('export') )
+	wp_die(__('You do not have sufficient permissions to export the content of this site.'));
+
+/** Load WordPress export API */
+require_once('./includes/export.php');
+$title = __('Export');
+
+function add_js() {
+?>
+<script type="text/javascript">
+//<![CDATA[
+	jQuery(document).ready(function($){
+ 		var form = $('#export-filters'),
+ 			filters = form.find('.export-filters');
+ 		filters.hide();
+ 		form.find('input:radio').change(function() {
+			filters.slideUp('fast');
+			switch ( $(this).val() ) {
+				case 'posts': $('#post-filters').slideDown(); break;
+				case 'pages': $('#page-filters').slideDown(); break;
+			}
+ 		});
+	});
+//]]>
+</script>
+<?php
+}
+add_action( 'admin_head', 'add_js' );
+
+add_contextual_help( $current_screen,
+	'<p>' . __('You can export a file of your site&#8217;s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to  limit the export by category, author, date range by month, or publishing status.') . '</p>' .
+	'<p>' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Tools_Export_SubPanel" target="_blank">Documentation on Export</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+if ( isset( $_GET['download'] ) ) {
+	$args = array();
+
+	if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) {
+		$args['content'] = 'all';
+	} else if ( 'posts' == $_GET['content'] ) {
+		$args['content'] = 'post';
+
+		if ( $_GET['cat'] )
+			$args['category'] = (int) $_GET['cat'];
+
+		if ( $_GET['post_author'] )
+			$args['author'] = (int) $_GET['post_author'];
+
+		if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) {
+			$args['start_date'] = $_GET['post_start_date'];
+			$args['end_date'] = $_GET['post_end_date'];
+		}
+
+		if ( $_GET['post_status'] )
+			$args['status'] = $_GET['post_status'];
+	} else if ( 'pages' == $_GET['content'] ) {
+		$args['content'] = 'page';
+
+		if ( $_GET['page_author'] )
+			$args['author'] = (int) $_GET['page_author'];
+
+		if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) {
+			$args['start_date'] = $_GET['page_start_date'];
+			$args['end_date'] = $_GET['page_end_date'];
+		}
+
+		if ( $_GET['page_status'] )
+			$args['status'] = $_GET['page_status'];
+	} else {
+		$args['content'] = $_GET['content'];
+	}
+
+	export_wp( $args );
+	die();
+}
+
+require_once ('admin-header.php');
+
+function export_date_options() {
+	global $wpdb, $wp_locale;
+
+	$months = $wpdb->get_results( "
+		SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
+		FROM $wpdb->posts
+		WHERE post_type = 'post' AND post_status != 'auto-draft'
+		ORDER BY post_date DESC
+	" );
+
+	$month_count = count( $months );
+	if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
+		return;
+
+	foreach ( $months as $date ) {
+		if ( 0 == $date->year )
+			continue;
+
+		$month = zeroise( $date->month, 2 );
+		echo '<option value="' . $date->year . '-' . $month . '" />' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>';
+	}
+}
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<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, pages, comments, custom fields, categories, and tags.'); ?></p>
+<p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function in another WordPress installation to import this site.'); ?></p>
+
+<h3><?php _e( 'Choose what to export' ); ?></h3>
+<form action="" method="get" id="export-filters">
+<input type="hidden" name="download" value="true" />
+<p><label><input type="radio" name="content" value="all" checked="checked" /> <?php _e( 'All content' ); ?></label>
+<span class="description"><?php _e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus and custom posts.' ); ?></span></p>
+
+<p><label><input type="radio" name="content" value="posts" /> <?php _e( 'Posts' ); ?></label></p>
+<ul id="post-filters" class="export-filters">
+	<li>
+		<label><?php _e( 'Categories:' ); ?></label>
+		<?php wp_dropdown_categories( array( 'show_option_all' => __('All') ) ); ?>
+	</li>
+	<li>
+		<label><?php _e( 'Authors:' ); ?></label>
+<?php
+		$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
+		wp_dropdown_users( array( 'include' => $authors, 'name' => 'post_author', 'multi' => true, 'show_option_all' => __('All') ) );
+?>
+	</li>
+	<li>
+		<label><?php _e( 'Date range:' ); ?></label>
+		<select name="post_start_date">
+			<option value="0"><?php _e( 'Start Date' ); ?></option>
+			<?php export_date_options(); ?>
+		</select>
+		<select name="post_end_date">
+			<option value="0"><?php _e( 'End Date' ); ?></option>
+			<?php export_date_options(); ?>
+		</select>
+	</li>
+	<li>
+		<label><?php _e( 'Status:' ); ?></label>
+		<select name="post_status">
+			<option value="0"><?php _e( 'All' ); ?></option>
+			<?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
+			foreach ( $post_stati as $status ) : ?>
+			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
+			<?php endforeach; ?>
+		</select>
+	</li>
+</ul>
+
+<p><label><input type="radio" name="content" value="pages" /> <?php _e( 'Pages' ); ?></label></p>
+<ul id="page-filters" class="export-filters">
+	<li>
+		<label><?php _e( 'Authors:' ); ?></label>
+<?php
+		$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" );
+		wp_dropdown_users( array( 'include' => $authors, 'name' => 'page_author', 'multi' => true, 'show_option_all' => __('All') ) );
+?>
+	</li>
+	<li>
+		<label><?php _e( 'Date range:' ); ?></label>
+		<select name="page_start_date">
+			<option value="0"><?php _e( 'Start Date' ); ?></option>
+			<?php export_date_options(); ?>
+		</select>
+		<select name="page_end_date">
+			<option value="0"><?php _e( 'End Date' ); ?></option>
+			<?php export_date_options(); ?>
+		</select>
+	</li>
+	<li>
+		<label><?php _e( 'Status:' ); ?></label>
+		<select name="page_status">
+			<option value="0"><?php _e( 'All' ); ?></option>
+			<?php foreach ( $post_stati as $status ) : ?>
+			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
+			<?php endforeach; ?>
+		</select>
+	</li>
+</ul>
+
+<?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?>
+<p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p>
+<?php endforeach; ?>
+
+<?php submit_button( __('Download Export File'), 'secondary' ); ?>
+</form>
+</div>
+
+<?php include('admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/gears-manifest.php
===================================================================
--- /tags/3.1/wp-admin/gears-manifest.php	(revision 17487)
+++ /tags/3.1/wp-admin/gears-manifest.php	(revision 17487)
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Defines the Gears manifest file for Google Gears offline storage.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Disable error reporting
+ *
+ * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
+ */
+error_reporting(0);
+
+/** Set ABSPATH for execution */
+define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
+
+require(ABSPATH . '/wp-admin/includes/manifest.php');
+
+$files = get_manifest();
+
+header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
+header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
+header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
+header( 'Pragma: no-cache' );
+header( 'Content-Type: application/x-javascript; charset=UTF-8' );
+?>
+{
+"betaManifestVersion" : 1,
+"version" : "<?php echo $man_version; ?>",
+"entries" : [
+<?php
+$entries = '';
+
+foreach ( $files as $file ) {
+	// Set ignoreQuery, defaulting to true
+	$ignore_query = ( isset($file[2]) && !$file[2] ) ? '' : ', "ignoreQuery" : true ';
+
+	// If version is not set, just output the file
+	if ( !isset($file[1]) )
+		$entries .= '{ "url" : "' . $file[0] . '"' . $ignore_query . ' }' . "\n";
+	// Output url and src
+	else
+		$entries .= '{ "url" : "' . $file[0] . '", "src" : "' . $file[0] . '?' . $file[1] . '"' . $ignore_query . ' },' . "\n";
+}
+
+echo trim( trim($entries), ',' );
+?>
+
+]}
Index: /tags/3.1/wp-admin/import.php
===================================================================
--- /tags/3.1/wp-admin/import.php	(revision 17487)
+++ /tags/3.1/wp-admin/import.php	(revision 17487)
@@ -0,0 +1,147 @@
+<?php
+/**
+ * Import WordPress Administration Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+define('WP_LOAD_IMPORTERS', true);
+
+/** Load WordPress Bootstrap */
+require_once ('admin.php');
+
+if ( !current_user_can('import') )
+	wp_die(__('You do not have sufficient permissions to import content in this site.'));
+
+$title = __('Import');
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.') . '</p>' .
+	'<p>' . __('In previous versions of WordPress, all the importers were built-in, but they have been turned into plugins as of version 3.0 since most people only use them once or infrequently.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Tools_Import_SubPanel" target="_blank">Documentation on Import</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$popular_importers = array();
+if ( current_user_can('install_plugins') )
+	$popular_importers = array(
+		'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ),
+		'wpcat2tag' => array(__('Categories and Tags Converter'), __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'), 'install', 'wp-cat2tag' ),
+		'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), 'install' ),
+		'movabletype' => array( __('Movable Type and TypePad'), __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), 'install', 'mt' ),
+		'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ),
+		'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ),
+		'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' )
+	);
+
+if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) {
+	wp_redirect( admin_url('import.php?import=' . $popular_importers[$_GET['invalid']][3]) );
+	exit;
+}
+
+add_thickbox();
+wp_enqueue_script( 'plugin-install' );
+wp_admin_css( 'plugin-install' );
+
+require_once ('admin-header.php');
+$parent_file = 'tools.php';
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+<?php if ( ! empty( $_GET['invalid'] ) ) : ?>
+	<div class="error"><p><strong><?php _e('ERROR:')?></strong> <?php printf( __('The <strong>%s</strong> importer is invalid or is not installed.'), esc_html( $_GET['invalid'] ) ); ?></p></div>
+<?php endif; ?>
+<p><?php _e('If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:'); ?></p>
+
+<?php
+
+// Load all importers so that they can register.
+$import_loc = 'wp-admin/import';
+$import_root = ABSPATH . $import_loc;
+
+if ( file_exists( $import_root ) ) {
+	$imports_dir = opendir($import_root);
+	if ($imports_dir) {
+		while (($file = readdir($imports_dir)) !== false) {
+			if ($file[0] == '.') {
+				continue;
+			} elseif (substr($file, -4) == '.php') {
+				require_once($import_root . '/' . $file);
+			}
+		}
+	}
+	closedir( $imports_dir );
+}
+
+$importers = get_importers();
+
+// If a popular importer is not registered, create a dummy registration that links to the plugin installer.
+foreach ( $popular_importers as $pop_importer => $pop_data ) {
+	if ( isset($importers[$pop_importer] ) )
+		continue;
+	if ( isset( $pop_data[3] ) && isset( $importers[ $pop_data[3] ] ) )
+		continue;
+
+	$importers[$pop_importer] = $popular_importers[$pop_importer];
+}
+
+if (empty ($importers)) {
+	echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
+} else {
+	uasort($importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
+?>
+<table class="widefat" cellspacing="0">
+
+<?php
+	$style = '';
+	foreach ($importers as $id => $data) {
+		$style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
+		$action = '';
+		if ( 'install' == $data[2] ) {
+			$plugin_slug = $id . '-importer';
+			if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) {
+				// Looks like Importer is installed, But not active
+				$plugins = get_plugins( '/' . $plugin_slug );
+				if ( !empty($plugins) ) {
+					$keys = array_keys($plugins);
+					$plugin_file = $plugin_slug . '/' . $keys[0];
+					$action = '<a href="' . esc_url(wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $plugin_file . '&from=import'), 'activate-plugin_' . $plugin_file)) .
+											'"title="' . esc_attr__('Activate importer') . '"">' . $data[0] . '</a>';
+				}
+			}
+			if ( empty($action) )
+				$action = '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug .
+										'&from=import&TB_iframe=true&width=600&height=550' ) ) . '" class="thickbox" title="' .
+										esc_attr__('Install importer') . '">' . $data[0] . '</a>';
+		} else {
+			$action = "<a href='" . esc_url("admin.php?import=$id") . "' title='" . esc_attr( wptexturize(strip_tags($data[1])) ) ."'>{$data[0]}</a>";
+		}
+
+		if ($style != '')
+			$style = 'class="'.$style.'"';
+		echo "
+			<tr $style>
+				<td class='import-system row-title'>$action</td>
+				<td class='desc'>{$data[1]}</td>
+			</tr>";
+	}
+?>
+
+</table>
+<?php
+}
+
+if ( current_user_can('install_plugins') )
+	echo '<p>' . sprintf( __('If the importer you need is not listed, <a href="%s">search the plugins directory</a> to see if an importer is available.'), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '</p>';
+?>
+
+</div>
+
+<?php
+
+include ('admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/includes/admin.php
===================================================================
--- /tags/3.1/wp-admin/includes/admin.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/admin.php	(revision 17487)
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Includes all of the WordPress Administration API files.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Bookmark Administration API */
+require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
+
+/** WordPress Comment Administration API */
+require_once(ABSPATH . 'wp-admin/includes/comment.php');
+
+/** WordPress Administration File API */
+require_once(ABSPATH . 'wp-admin/includes/file.php');
+
+/** WordPress Image Administration API */
+require_once(ABSPATH . 'wp-admin/includes/image.php');
+
+/** WordPress Media Administration API */
+require_once(ABSPATH . 'wp-admin/includes/media.php');
+
+/** WordPress Import Administration API */
+require_once(ABSPATH . 'wp-admin/includes/import.php');
+
+/** WordPress Misc Administration API */
+require_once(ABSPATH . 'wp-admin/includes/misc.php');
+
+/** WordPress Plugin Administration API */
+require_once(ABSPATH . 'wp-admin/includes/plugin.php');
+
+/** WordPress Post Administration API */
+require_once(ABSPATH . 'wp-admin/includes/post.php');
+
+/** WordPress Taxonomy Administration API */
+require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
+
+/** WordPress Template Administration API */
+require_once(ABSPATH . 'wp-admin/includes/template.php');
+
+/** WordPress List Table Administration API and base class */
+require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
+require_once(ABSPATH . 'wp-admin/includes/list-table.php');
+
+/** WordPress Theme Administration API */
+require_once(ABSPATH . 'wp-admin/includes/theme.php');
+
+/** WordPress User Administration API */
+require_once(ABSPATH . 'wp-admin/includes/user.php');
+
+/** WordPress Update Administration API */
+require_once(ABSPATH . 'wp-admin/includes/update.php');
+
+/** WordPress Deprecated Administration API */
+require_once(ABSPATH . 'wp-admin/includes/deprecated.php');
+
+/** WordPress Multi-Site support API */
+if ( is_multisite() ) {
+	require_once(ABSPATH . 'wp-admin/includes/ms.php');
+	require_once(ABSPATH . 'wp-admin/includes/ms-deprecated.php');
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/bookmark.php
===================================================================
--- /tags/3.1/wp-admin/includes/bookmark.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/bookmark.php	(revision 17487)
@@ -0,0 +1,269 @@
+<?php
+/**
+ * WordPress Bookmark Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Add a link to using values provided in $_POST.
+ *
+ * @since 2.0.0
+ *
+ * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
+ */
+function add_link() {
+	return edit_link();
+}
+
+/**
+ * Update or insert a link using values provided in $_POST.
+ *
+ * @since 2.0.0
+ *
+ * @param int $link_id Optional. ID of the link to edit.
+ * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
+ */
+function edit_link( $link_id = 0 ) {
+	if ( !current_user_can( 'manage_links' ) )
+		wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+	$_POST['link_url'] = esc_html( $_POST['link_url'] );
+	$_POST['link_url'] = esc_url($_POST['link_url']);
+	$_POST['link_name'] = esc_html( $_POST['link_name'] );
+	$_POST['link_image'] = esc_html( $_POST['link_image'] );
+	$_POST['link_rss'] = esc_url($_POST['link_rss']);
+	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
+		$_POST['link_visible'] = 'Y';
+
+	if ( !empty( $link_id ) ) {
+		$_POST['link_id'] = $link_id;
+		return wp_update_link( $_POST );
+	} else {
+		return wp_insert_link( $_POST );
+	}
+}
+
+/**
+ * Retrieve the default link for editing.
+ *
+ * @since 2.0.0
+ *
+ * @return object Default link
+ */
+function get_default_link_to_edit() {
+	if ( isset( $_GET['linkurl'] ) )
+		$link->link_url = esc_url( $_GET['linkurl'] );
+	else
+		$link->link_url = '';
+
+	if ( isset( $_GET['name'] ) )
+		$link->link_name = esc_attr( $_GET['name'] );
+	else
+		$link->link_name = '';
+
+	$link->link_visible = 'Y';
+
+	return $link;
+}
+
+/**
+ * Delete link specified from database
+ *
+ * @since 2.0.0
+ *
+ * @param int $link_id ID of the link to delete
+ * @return bool True
+ */
+function wp_delete_link( $link_id ) {
+	global $wpdb;
+
+	do_action( 'delete_link', $link_id );
+
+	wp_delete_object_term_relationships( $link_id, 'link_category' );
+
+	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->links WHERE link_id = %d", $link_id ) );
+
+	do_action( 'deleted_link', $link_id );
+
+	clean_bookmark_cache( $link_id );
+
+	return true;
+}
+
+/**
+ * Retrieves the link categories associated with the link specified.
+ *
+ * @since 2.1.0
+ *
+ * @param int $link_id Link ID to look up
+ * @return array The requested link's categories
+ */
+function wp_get_link_cats( $link_id = 0 ) {
+
+	$cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') );
+
+	return array_unique( $cats );
+}
+
+/**
+ * Retrieve link data based on ID.
+ *
+ * @since 2.0.0
+ *
+ * @param int $link_id ID of link to retrieve
+ * @return object Link for editing
+ */
+function get_link_to_edit( $link_id ) {
+	return get_bookmark( $link_id, OBJECT, 'edit' );
+}
+
+/**
+ * This function inserts/updates links into/in the database.
+ *
+ * @since 2.0.0
+ *
+ * @param array $linkdata Elements that make up the link to insert.
+ * @param bool $wp_error Optional. If true return WP_Error object on failure.
+ * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
+ */
+function wp_insert_link( $linkdata, $wp_error = false ) {
+	global $wpdb;
+
+	$defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
+
+	$linkdata = wp_parse_args( $linkdata, $defaults );
+	$linkdata = sanitize_bookmark( $linkdata, 'db' );
+
+	extract( stripslashes_deep( $linkdata ), EXTR_SKIP );
+
+	$update = false;
+
+	if ( !empty( $link_id ) )
+		$update = true;
+
+	if ( trim( $link_name ) == '' ) {
+		if ( trim( $link_url ) != '' ) {
+			$link_name = $link_url;
+		} else {
+			return 0;
+		}
+	}
+
+	if ( trim( $link_url ) == '' )
+		return 0;
+
+	if ( empty( $link_rating ) )
+		$link_rating = 0;
+
+	if ( empty( $link_image ) )
+		$link_image = '';
+
+	if ( empty( $link_target ) )
+		$link_target = '';
+
+	if ( empty( $link_visible ) )
+		$link_visible = 'Y';
+
+	if ( empty( $link_owner ) )
+		$link_owner = get_current_user_id();
+
+	if ( empty( $link_notes ) )
+		$link_notes = '';
+
+	if ( empty( $link_description ) )
+		$link_description = '';
+
+	if ( empty( $link_rss ) )
+		$link_rss = '';
+
+	if ( empty( $link_rel ) )
+		$link_rel = '';
+
+	// Make sure we set a valid category
+	if ( ! isset( $link_category ) || 0 == count( $link_category ) || !is_array( $link_category ) ) {
+		$link_category = array( get_option( 'default_link_category' ) );
+	}
+
+	if ( $update ) {
+		if ( false === $wpdb->update( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id') ) ) {
+			if ( $wp_error )
+				return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error );
+			else
+				return 0;
+		}
+	} else {
+		if ( false === $wpdb->insert( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss') ) ) {
+			if ( $wp_error )
+				return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error );
+			else
+				return 0;
+		}
+		$link_id = (int) $wpdb->insert_id;
+	}
+
+	wp_set_link_cats( $link_id, $link_category );
+
+	if ( $update )
+		do_action( 'edit_link', $link_id );
+	else
+		do_action( 'add_link', $link_id );
+
+	clean_bookmark_cache( $link_id );
+
+	return $link_id;
+}
+
+/**
+ * Update link with the specified link categories.
+ *
+ * @since 2.1.0
+ *
+ * @param int $link_id ID of link to update
+ * @param array $link_categories Array of categories to
+ */
+function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
+	// If $link_categories isn't already an array, make it one:
+	if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
+		$link_categories = array( get_option( 'default_link_category' ) );
+
+	$link_categories = array_map( 'intval', $link_categories );
+	$link_categories = array_unique( $link_categories );
+
+	wp_set_object_terms( $link_id, $link_categories, 'link_category' );
+
+	clean_bookmark_cache( $link_id );
+}
+
+/**
+ * Update a link in the database.
+ *
+ * @since 2.0.0
+ *
+ * @param array $linkdata Link data to update.
+ * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success.
+ */
+function wp_update_link( $linkdata ) {
+	$link_id = (int) $linkdata['link_id'];
+
+	$link = get_bookmark( $link_id, ARRAY_A );
+
+	// Escape data pulled from DB.
+	$link = add_magic_quotes( $link );
+
+	// Passed link category list overwrites existing category list if not empty.
+	if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
+			 && 0 != count( $linkdata['link_category'] ) )
+		$link_cats = $linkdata['link_category'];
+	else
+		$link_cats = $link['link_category'];
+
+	// Merge old and new fields with new fields overwriting old ones.
+	$linkdata = array_merge( $link, $linkdata );
+	$linkdata['link_category'] = $link_cats;
+
+	return wp_insert_link( $linkdata );
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-ftp-pure.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-ftp-pure.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-ftp-pure.php	(revision 17487)
@@ -0,0 +1,190 @@
+<?php
+/**
+ * PemFTP - A Ftp implementation in pure PHP
+ *
+ * @package PemFTP
+ * @since 2.5
+ *
+ * @version 1.0
+ * @copyright Alexey Dotsenko
+ * @author Alexey Dotsenko
+ * @link http://www.phpclasses.org/browse/package/1743.html Site
+ * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ */
+
+/**
+ * FTP implementation using fsockopen to connect.
+ *
+ * @package PemFTP
+ * @subpackage Pure
+ * @since 2.5
+ *
+ * @version 1.0
+ * @copyright Alexey Dotsenko
+ * @author Alexey Dotsenko
+ * @link http://www.phpclasses.org/browse/package/1743.html Site
+ * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ */
+class ftp extends ftp_base {
+
+	function ftp($verb=FALSE, $le=FALSE) {
+		$this->__construct($verb, $le);
+	}
+
+	function __construct($verb=FALSE, $le=FALSE) {
+		parent::__construct(false, $verb, $le);
+	}
+
+// <!-- --------------------------------------------------------------------------------------- -->
+// <!--       Private functions                                                                 -->
+// <!-- --------------------------------------------------------------------------------------- -->
+
+	function _settimeout($sock) {
+		if(!@stream_set_timeout($sock, $this->_timeout)) {
+			$this->PushError('_settimeout','socket set send timeout');
+			$this->_quit();
+			return FALSE;
+		}
+		return TRUE;
+	}
+
+	function _connect($host, $port) {
+		$this->SendMSG("Creating socket");
+		$sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout);
+		if (!$sock) {
+			$this->PushError('_connect','socket connect failed', $errstr." (".$errno.")");
+			return FALSE;
+		}
+		$this->_connected=true;
+		return $sock;
+	}
+
+	function _readmsg($fnction="_readmsg"){
+		if(!$this->_connected) {
+			$this->PushError($fnction, 'Connect first');
+			return FALSE;
+		}
+		$result=true;
+		$this->_message="";
+		$this->_code=0;
+		$go=true;
+		do {
+			$tmp=@fgets($this->_ftp_control_sock, 512);
+			if($tmp===false) {
+				$go=$result=false;
+				$this->PushError($fnction,'Read failed');
+			} else {
+				$this->_message.=$tmp;
+				if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false;
+			}
+		} while($go);
+		if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
+		$this->_code=(int)$regs[1];
+		return $result;
+	}
+
+	function _exec($cmd, $fnction="_exec") {
+		if(!$this->_ready) {
+			$this->PushError($fnction,'Connect first');
+			return FALSE;
+		}
+		if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
+		$status=@fputs($this->_ftp_control_sock, $cmd.CRLF);
+		if($status===false) {
+			$this->PushError($fnction,'socket write failed');
+			return FALSE;
+		}
+		$this->_lastaction=time();
+		if(!$this->_readmsg($fnction)) return FALSE;
+		return TRUE;
+	}
+
+	function _data_prepare($mode=FTP_ASCII) {
+		if(!$this->_settype($mode)) return FALSE;
+		if($this->_passive) {
+			if(!$this->_exec("PASV", "pasv")) {
+				$this->_data_close();
+				return FALSE;
+			}
+			if(!$this->_checkCode()) {
+				$this->_data_close();
+				return FALSE;
+			}
+			$ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message));
+			$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
+            $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
+			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
+			$this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout);
+			if(!$this->_ftp_data_sock) {
+				$this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")");
+				$this->_data_close();
+				return FALSE;
+			}
+			else $this->_ftp_data_sock;
+		} else {
+			$this->SendMSG("Only passive connections available!");
+			return FALSE;
+		}
+		return TRUE;
+	}
+
+	function _data_read($mode=FTP_ASCII, $fp=NULL) {
+		if(is_resource($fp)) $out=0;
+		else $out="";
+		if(!$this->_passive) {
+			$this->SendMSG("Only passive connections available!");
+			return FALSE;
+		}
+		while (!feof($this->_ftp_data_sock)) {
+			$block=fread($this->_ftp_data_sock, $this->_ftp_buff_size);
+			if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
+			if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
+			else $out.=$block;
+		}
+		return $out;
+	}
+
+	function _data_write($mode=FTP_ASCII, $fp=NULL) {
+		if(is_resource($fp)) $out=0;
+		else $out="";
+		if(!$this->_passive) {
+			$this->SendMSG("Only passive connections available!");
+			return FALSE;
+		}
+		if(is_resource($fp)) {
+			while(!feof($fp)) {
+				$block=fread($fp, $this->_ftp_buff_size);
+				if(!$this->_data_write_block($mode, $block)) return false;
+			}
+		} elseif(!$this->_data_write_block($mode, $fp)) return false;
+		return TRUE;
+	}
+
+	function _data_write_block($mode, $block) {
+		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
+		do {
+			if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) {
+				$this->PushError("_data_write","Can't write to socket");
+				return FALSE;
+			}
+			$block=substr($block, $t);
+		} while(!empty($block));
+		return true;
+	}
+
+	function _data_close() {
+		@fclose($this->_ftp_data_sock);
+		$this->SendMSG("Disconnected data from remote host");
+		return TRUE;
+	}
+
+	function _quit($force=FALSE) {
+		if($this->_connected or $force) {
+			@fclose($this->_ftp_control_sock);
+			$this->_connected=false;
+			$this->SendMSG("Socket closed");
+		}
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-ftp-sockets.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-ftp-sockets.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-ftp-sockets.php	(revision 17487)
@@ -0,0 +1,250 @@
+<?php
+/**
+ * PemFTP - A Ftp implementation in pure PHP
+ *
+ * @package PemFTP
+ * @since 2.5
+ *
+ * @version 1.0
+ * @copyright Alexey Dotsenko
+ * @author Alexey Dotsenko
+ * @link http://www.phpclasses.org/browse/package/1743.html Site
+ * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ */
+
+/**
+ * Socket Based FTP implementation
+ *
+ * @package PemFTP
+ * @subpackage Socket
+ * @since 2.5
+ *
+ * @version 1.0
+ * @copyright Alexey Dotsenko
+ * @author Alexey Dotsenko
+ * @link http://www.phpclasses.org/browse/package/1743.html Site
+ * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ */
+class ftp extends ftp_base {
+
+	function ftp($verb=FALSE, $le=FALSE) {
+		$this->__construct($verb, $le);
+	}
+
+	function __construct($verb=FALSE, $le=FALSE) {
+		parent::__construct(true, $verb, $le);
+	}
+
+// <!-- --------------------------------------------------------------------------------------- -->
+// <!--       Private functions                                                                 -->
+// <!-- --------------------------------------------------------------------------------------- -->
+
+	function _settimeout($sock) {
+		if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
+			$this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock)));
+			@socket_close($sock);
+			return FALSE;
+		}
+		if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
+			$this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock)));
+			@socket_close($sock);
+			return FALSE;
+		}
+		return true;
+	}
+
+	function _connect($host, $port) {
+		$this->SendMSG("Creating socket");
+		if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
+			$this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock)));
+			return FALSE;
+		}
+		if(!$this->_settimeout($sock)) return FALSE;
+		$this->SendMSG("Connecting to \"".$host.":".$port."\"");
+		if (!($res = @socket_connect($sock, $host, $port))) {
+			$this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock)));
+			@socket_close($sock);
+			return FALSE;
+		}
+		$this->_connected=true;
+		return $sock;
+	}
+
+	function _readmsg($fnction="_readmsg"){
+		if(!$this->_connected) {
+			$this->PushError($fnction,'Connect first');
+			return FALSE;
+		}
+		$result=true;
+		$this->_message="";
+		$this->_code=0;
+		$go=true;
+		do {
+			$tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ);
+			if($tmp===false) {
+				$go=$result=false;
+				$this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock)));
+			} else {
+				$this->_message.=$tmp;
+				$go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs);
+			}
+		} while($go);
+		if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
+		$this->_code=(int)$regs[1];
+		return $result;
+	}
+
+	function _exec($cmd, $fnction="_exec") {
+		if(!$this->_ready) {
+			$this->PushError($fnction,'Connect first');
+			return FALSE;
+		}
+		if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
+		$status=@socket_write($this->_ftp_control_sock, $cmd.CRLF);
+		if($status===false) {
+			$this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream)));
+			return FALSE;
+		}
+		$this->_lastaction=time();
+		if(!$this->_readmsg($fnction)) return FALSE;
+		return TRUE;
+	}
+
+	function _data_prepare($mode=FTP_ASCII) {
+		if(!$this->_settype($mode)) return FALSE;
+		$this->SendMSG("Creating data socket");
+		$this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
+		if ($this->_ftp_data_sock < 0) {
+			$this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock)));
+			return FALSE;
+		}
+		if(!$this->_settimeout($this->_ftp_data_sock)) {
+			$this->_data_close();
+			return FALSE;
+		}
+		if($this->_passive) {
+			if(!$this->_exec("PASV", "pasv")) {
+				$this->_data_close();
+				return FALSE;
+			}
+			if(!$this->_checkCode()) {
+				$this->_data_close();
+				return FALSE;
+			}
+			$ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message));
+			$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
+            $this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
+			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
+			if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
+				$this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock)));
+				$this->_data_close();
+				return FALSE;
+			}
+			else $this->_ftp_temp_sock=$this->_ftp_data_sock;
+		} else {
+			if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) {
+				$this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock)));
+				$this->_data_close();
+				return FALSE;
+			}
+			if(!@socket_bind($this->_ftp_data_sock,$addr)){
+				$this->PushError("_data_prepare","can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
+				$this->_data_close();
+				return FALSE;
+			}
+			if(!@socket_listen($this->_ftp_data_sock)) {
+				$this->PushError("_data_prepare","can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
+				$this->_data_close();
+				return FALSE;
+			}
+			if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
+				$this->PushError("_data_prepare","can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock)));
+				$this->_data_close();
+				return FALSE;
+			}
+			if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) {
+				$this->_data_close();
+				return FALSE;
+			}
+			if(!$this->_checkCode()) {
+				$this->_data_close();
+				return FALSE;
+			}
+		}
+		return TRUE;
+	}
+
+	function _data_read($mode=FTP_ASCII, $fp=NULL) {
+		$NewLine=$this->_eol_code[$this->OS_local];
+		if(is_resource($fp)) $out=0;
+		else $out="";
+		if(!$this->_passive) {
+			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
+			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
+			if($this->_ftp_temp_sock===FALSE) {
+				$this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
+				$this->_data_close();
+				return FALSE;
+			}
+		}
+
+		while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) {
+			if($block==="") break;
+			if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
+			if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
+			else $out.=$block;
+		}
+		return $out;
+	}
+
+	function _data_write($mode=FTP_ASCII, $fp=NULL) {
+		$NewLine=$this->_eol_code[$this->OS_local];
+		if(is_resource($fp)) $out=0;
+		else $out="";
+		if(!$this->_passive) {
+			$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
+			$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
+			if($this->_ftp_temp_sock===FALSE) {
+				$this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
+				$this->_data_close();
+				return false;
+			}
+		}
+		if(is_resource($fp)) {
+			while(!feof($fp)) {
+				$block=fread($fp, $this->_ftp_buff_size);
+				if(!$this->_data_write_block($mode, $block)) return false;
+			}
+		} elseif(!$this->_data_write_block($mode, $fp)) return false;
+		return true;
+	}
+
+	function _data_write_block($mode, $block) {
+		if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
+		do {
+			if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) {
+				$this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
+				$this->_data_close();
+				return FALSE;
+			}
+			$block=substr($block, $t);
+		} while(!empty($block));
+		return true;
+	}
+
+	function _data_close() {
+		@socket_close($this->_ftp_temp_sock);
+		@socket_close($this->_ftp_data_sock);
+		$this->SendMSG("Disconnected data from remote host");
+		return TRUE;
+	}
+
+	function _quit() {
+		if($this->_connected) {
+			@socket_close($this->_ftp_control_sock);
+			$this->_connected=false;
+			$this->SendMSG("Socket closed");
+		}
+	}
+}
+?>
Index: /tags/3.1/wp-admin/includes/class-ftp.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-ftp.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-ftp.php	(revision 17487)
@@ -0,0 +1,906 @@
+<?php
+/**
+ * PemFTP - A Ftp implementation in pure PHP
+ *
+ * @package PemFTP
+ * @since 2.5
+ *
+ * @version 1.0
+ * @copyright Alexey Dotsenko
+ * @author Alexey Dotsenko
+ * @link http://www.phpclasses.org/browse/package/1743.html Site
+ * @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
+ */
+
+/**
+ * Defines the newline characters, if not defined already.
+ *
+ * This can be redefined.
+ *
+ * @since 2.5
+ * @var string
+ */
+if(!defined('CRLF')) define('CRLF',"\r\n");
+
+/**
+ * Sets whatever to autodetect ASCII mode.
+ *
+ * This can be redefined.
+ *
+ * @since 2.5
+ * @var int
+ */
+if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
+
+/**
+ *
+ * This can be redefined.
+ * @since 2.5
+ * @var int
+ */
+if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
+
+/**
+ *
+ * This can be redefined.
+ * @since 2.5
+ * @var int
+ */
+if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
+
+/**
+ * Whether to force FTP.
+ *
+ * This can be redefined.
+ *
+ * @since 2.5
+ * @var bool
+ */
+if(!defined('FTP_FORCE')) define('FTP_FORCE', true);
+
+/**
+ * @since 2.5
+ * @var string
+ */
+define('FTP_OS_Unix','u');
+
+/**
+ * @since 2.5
+ * @var string
+ */
+define('FTP_OS_Windows','w');
+
+/**
+ * @since 2.5
+ * @var string
+ */
+define('FTP_OS_Mac','m');
+
+/**
+ * PemFTP base class
+ *
+ */
+class ftp_base {
+	/* Public variables */
+	var $LocalEcho;
+	var $Verbose;
+	var $OS_local;
+	var $OS_remote;
+
+	/* Private variables */
+	var $_lastaction;
+	var $_errors;
+	var $_type;
+	var $_umask;
+	var $_timeout;
+	var $_passive;
+	var $_host;
+	var $_fullhost;
+	var $_port;
+	var $_datahost;
+	var $_dataport;
+	var $_ftp_control_sock;
+	var $_ftp_data_sock;
+	var $_ftp_temp_sock;
+	var $_ftp_buff_size;
+	var $_login;
+	var $_password;
+	var $_connected;
+	var $_ready;
+	var $_code;
+	var $_message;
+	var $_can_restore;
+	var $_port_available;
+	var $_curtype;
+	var $_features;
+
+	var $_error_array;
+	var $AuthorizedTransferMode;
+	var $OS_FullName;
+	var $_eol_code;
+	var $AutoAsciiExt;
+
+	/* Constructor */
+	function ftp_base($port_mode=FALSE) {
+		$this->__construct($port_mode);
+	}
+
+	function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) {
+		$this->LocalEcho=$le;
+		$this->Verbose=$verb;
+		$this->_lastaction=NULL;
+		$this->_error_array=array();
+		$this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n");
+		$this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY);
+		$this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS');
+		$this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT");
+		$this->_port_available=($port_mode==TRUE);
+		$this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support"));
+		$this->_connected=FALSE;
+		$this->_ready=FALSE;
+		$this->_can_restore=FALSE;
+		$this->_code=0;
+		$this->_message="";
+		$this->_ftp_buff_size=4096;
+		$this->_curtype=NULL;
+		$this->SetUmask(0022);
+		$this->SetType(FTP_AUTOASCII);
+		$this->SetTimeout(30);
+		$this->Passive(!$this->_port_available);
+		$this->_login="anonymous";
+		$this->_password="anon@ftp.com";
+		$this->_features=array();
+	    $this->OS_local=FTP_OS_Unix;
+		$this->OS_remote=FTP_OS_Unix;
+		$this->features=array();
+		if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
+		elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
+	}
+
+// <!-- --------------------------------------------------------------------------------------- -->
+// <!--       Public functions                                                                  -->
+// <!-- --------------------------------------------------------------------------------------- -->
+
+	function parselisting($line) {
+		$is_windows = ($this->OS_remote == FTP_OS_Windows);
+		if ($is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/",$line,$lucifer)) {
+			$b = array();
+			if ($lucifer[3]<70) { $lucifer[3]+=2000; } else { $lucifer[3]+=1900; } // 4digit year fix
+			$b['isdir'] = ($lucifer[7]=="<DIR>");
+			if ( $b['isdir'] )
+				$b['type'] = 'd';
+			else
+				$b['type'] = 'f';
+			$b['size'] = $lucifer[7];
+			$b['month'] = $lucifer[1];
+			$b['day'] = $lucifer[2];
+			$b['year'] = $lucifer[3];
+			$b['hour'] = $lucifer[4];
+			$b['minute'] = $lucifer[5];
+			$b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
+			$b['am/pm'] = $lucifer[6];
+			$b['name'] = $lucifer[8];
+		} else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
+			//echo $line."\n";
+			$lcount=count($lucifer);
+			if ($lcount<8) return '';
+			$b = array();
+			$b['isdir'] = $lucifer[0]{0} === "d";
+			$b['islink'] = $lucifer[0]{0} === "l";
+			if ( $b['isdir'] )
+				$b['type'] = 'd';
+			elseif ( $b['islink'] )
+				$b['type'] = 'l';
+			else
+				$b['type'] = 'f';
+			$b['perms'] = $lucifer[0];
+			$b['number'] = $lucifer[1];
+			$b['owner'] = $lucifer[2];
+			$b['group'] = $lucifer[3];
+			$b['size'] = $lucifer[4];
+			if ($lcount==8) {
+				sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']);
+				sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']);
+				$b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']);
+				$b['name'] = $lucifer[7];
+			} else {
+				$b['month'] = $lucifer[5];
+				$b['day'] = $lucifer[6];
+				if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
+					$b['year'] = date("Y");
+					$b['hour'] = $l2[1];
+					$b['minute'] = $l2[2];
+				} else {
+					$b['year'] = $lucifer[7];
+					$b['hour'] = 0;
+					$b['minute'] = 0;
+				}
+				$b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute']));
+				$b['name'] = $lucifer[8];
+			}
+		}
+
+		return $b;
+	}
+
+	function SendMSG($message = "", $crlf=true) {
+		if ($this->Verbose) {
+			echo $message.($crlf?CRLF:"");
+			flush();
+		}
+		return TRUE;
+	}
+
+	function SetType($mode=FTP_AUTOASCII) {
+		if(!in_array($mode, $this->AuthorizedTransferMode)) {
+			$this->SendMSG("Wrong type");
+			return FALSE;
+		}
+		$this->_type=$mode;
+		$this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) );
+		return TRUE;
+	}
+
+	function _settype($mode=FTP_ASCII) {
+		if($this->_ready) {
+			if($mode==FTP_BINARY) {
+				if($this->_curtype!=FTP_BINARY) {
+					if(!$this->_exec("TYPE I", "SetType")) return FALSE;
+					$this->_curtype=FTP_BINARY;
+				}
+			} elseif($this->_curtype!=FTP_ASCII) {
+				if(!$this->_exec("TYPE A", "SetType")) return FALSE;
+				$this->_curtype=FTP_ASCII;
+			}
+		} else return FALSE;
+		return TRUE;
+	}
+
+	function Passive($pasv=NULL) {
+		if(is_null($pasv)) $this->_passive=!$this->_passive;
+		else $this->_passive=$pasv;
+		if(!$this->_port_available and !$this->_passive) {
+			$this->SendMSG("Only passive connections available!");
+			$this->_passive=TRUE;
+			return FALSE;
+		}
+		$this->SendMSG("Passive mode ".($this->_passive?"on":"off"));
+		return TRUE;
+	}
+
+	function SetServer($host, $port=21, $reconnect=true) {
+		if(!is_long($port)) {
+	        $this->verbose=true;
+    	    $this->SendMSG("Incorrect port syntax");
+			return FALSE;
+		} else {
+			$ip=@gethostbyname($host);
+	        $dns=@gethostbyaddr($host);
+	        if(!$ip) $ip=$host;
+	        if(!$dns) $dns=$host;
+	        // Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
+	        // -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
+	        $ipaslong = ip2long($ip);
+			if ( ($ipaslong == false) || ($ipaslong === -1) ) {
+				$this->SendMSG("Wrong host name/address \"".$host."\"");
+				return FALSE;
+			}
+	        $this->_host=$ip;
+	        $this->_fullhost=$dns;
+	        $this->_port=$port;
+	        $this->_dataport=$port-1;
+		}
+		$this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
+		if($reconnect){
+			if($this->_connected) {
+				$this->SendMSG("Reconnecting");
+				if(!$this->quit(FTP_FORCE)) return FALSE;
+				if(!$this->connect()) return FALSE;
+			}
+		}
+		return TRUE;
+	}
+
+	function SetUmask($umask=0022) {
+		$this->_umask=$umask;
+		umask($this->_umask);
+		$this->SendMSG("UMASK 0".decoct($this->_umask));
+		return TRUE;
+	}
+
+	function SetTimeout($timeout=30) {
+		$this->_timeout=$timeout;
+		$this->SendMSG("Timeout ".$this->_timeout);
+		if($this->_connected)
+			if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE;
+		return TRUE;
+	}
+
+	function connect($server=NULL) {
+		if(!empty($server)) {
+			if(!$this->SetServer($server)) return false;
+		}
+		if($this->_ready) return true;
+	    $this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
+		if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
+			$this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
+			return FALSE;
+		}
+		$this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting.");
+		do {
+			if(!$this->_readmsg()) return FALSE;
+			if(!$this->_checkCode()) return FALSE;
+			$this->_lastaction=time();
+		} while($this->_code<200);
+		$this->_ready=true;
+		$syst=$this->systype();
+		if(!$syst) $this->SendMSG("Can't detect remote OS");
+		else {
+			if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows;
+			elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac;
+			elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix;
+			else $this->OS_remote=FTP_OS_Mac;
+			$this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]);
+		}
+		if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
+		else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
+		return TRUE;
+	}
+
+	function quit($force=false) {
+		if($this->_ready) {
+			if(!$this->_exec("QUIT") and !$force) return FALSE;
+			if(!$this->_checkCode() and !$force) return FALSE;
+			$this->_ready=false;
+			$this->SendMSG("Session finished");
+		}
+		$this->_quit();
+		return TRUE;
+	}
+
+	function login($user=NULL, $pass=NULL) {
+		if(!is_null($user)) $this->_login=$user;
+		else $this->_login="anonymous";
+		if(!is_null($pass)) $this->_password=$pass;
+		else $this->_password="anon@anon.com";
+		if(!$this->_exec("USER ".$this->_login, "login")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		if($this->_code!=230) {
+			if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE;
+			if(!$this->_checkCode()) return FALSE;
+		}
+		$this->SendMSG("Authentication succeeded");
+		if(empty($this->_features)) {
+			if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
+			else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
+		}
+		return TRUE;
+	}
+
+	function pwd() {
+		if(!$this->_exec("PWD", "pwd")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message);
+	}
+
+	function cdup() {
+		if(!$this->_exec("CDUP", "cdup")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return true;
+	}
+
+	function chdir($pathname) {
+		if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return TRUE;
+	}
+
+	function rmdir($pathname) {
+		if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return TRUE;
+	}
+
+	function mkdir($pathname) {
+		if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return TRUE;
+	}
+
+	function rename($from, $to) {
+		if(!$this->_exec("RNFR ".$from, "rename")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		if($this->_code==350) {
+			if(!$this->_exec("RNTO ".$to, "rename")) return FALSE;
+			if(!$this->_checkCode()) return FALSE;
+		} else return FALSE;
+		return TRUE;
+	}
+
+	function filesize($pathname) {
+		if(!isset($this->_features["SIZE"])) {
+			$this->PushError("filesize", "not supported by server");
+			return FALSE;
+		}
+		if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
+	}
+
+	function abort() {
+		if(!$this->_exec("ABOR", "abort")) return FALSE;
+		if(!$this->_checkCode()) {
+			if($this->_code!=426) return FALSE;
+			if(!$this->_readmsg("abort")) return FALSE;
+			if(!$this->_checkCode()) return FALSE;
+		}
+		return true;
+	}
+
+	function mdtm($pathname) {
+		if(!isset($this->_features["MDTM"])) {
+			$this->PushError("mdtm", "not supported by server");
+			return FALSE;
+		}
+		if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		$mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
+		$date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d");
+		$timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]);
+		return $timestamp;
+	}
+
+	function systype() {
+		if(!$this->_exec("SYST", "systype")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		$DATA = explode(" ", $this->_message);
+		return array($DATA[1], $DATA[3]);
+	}
+
+	function delete($pathname) {
+		if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return TRUE;
+	}
+
+	function site($command, $fnction="site") {
+		if(!$this->_exec("SITE ".$command, $fnction)) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return TRUE;
+	}
+
+	function chmod($pathname, $mode) {
+		if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE;
+		return TRUE;
+	}
+
+	function restore($from) {
+		if(!isset($this->_features["REST"])) {
+			$this->PushError("restore", "not supported by server");
+			return FALSE;
+		}
+		if($this->_curtype!=FTP_BINARY) {
+			$this->PushError("restore", "can't restore in ASCII mode");
+			return FALSE;
+		}
+		if(!$this->_exec("REST ".$from, "resore")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return TRUE;
+	}
+
+	function features() {
+		if(!$this->_exec("FEAT", "features")) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		$f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY);
+		$this->_features=array();
+		foreach($f as $k=>$v) {
+			$v=explode(" ", trim($v));
+			$this->_features[array_shift($v)]=$v;
+		}
+		return true;
+	}
+
+	function rawlist($pathname="", $arg="") {
+		return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist");
+	}
+
+	function nlist($pathname="") {
+		return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist");
+	}
+
+	function is_exists($pathname) {
+		return $this->file_exists($pathname);
+	}
+
+	function file_exists($pathname) {
+		$exists=true;
+		if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE;
+		else {
+			if(!$this->_checkCode()) $exists=FALSE;
+			$this->abort();
+		}
+		if($exists) $this->SendMSG("Remote file ".$pathname." exists");
+		else $this->SendMSG("Remote file ".$pathname." does not exist");
+		return $exists;
+	}
+
+	function fget($fp, $remotefile,$rest=0) {
+		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
+		$pi=pathinfo($remotefile);
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
+		else $mode=FTP_BINARY;
+		if(!$this->_data_prepare($mode)) {
+			return FALSE;
+		}
+		if($this->_can_restore and $rest!=0) $this->restore($rest);
+		if(!$this->_exec("RETR ".$remotefile, "get")) {
+			$this->_data_close();
+			return FALSE;
+		}
+		if(!$this->_checkCode()) {
+			$this->_data_close();
+			return FALSE;
+		}
+		$out=$this->_data_read($mode, $fp);
+		$this->_data_close();
+		if(!$this->_readmsg()) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return $out;
+	}
+
+	function get($remotefile, $localfile=NULL, $rest=0) {
+		if(is_null($localfile)) $localfile=$remotefile;
+		if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten");
+		$fp = @fopen($localfile, "w");
+		if (!$fp) {
+			$this->PushError("get","can't open local file", "Cannot create \"".$localfile."\"");
+			return FALSE;
+		}
+		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
+		$pi=pathinfo($remotefile);
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
+		else $mode=FTP_BINARY;
+		if(!$this->_data_prepare($mode)) {
+			fclose($fp);
+			return FALSE;
+		}
+		if($this->_can_restore and $rest!=0) $this->restore($rest);
+		if(!$this->_exec("RETR ".$remotefile, "get")) {
+			$this->_data_close();
+			fclose($fp);
+			return FALSE;
+		}
+		if(!$this->_checkCode()) {
+			$this->_data_close();
+			fclose($fp);
+			return FALSE;
+		}
+		$out=$this->_data_read($mode, $fp);
+		fclose($fp);
+		$this->_data_close();
+		if(!$this->_readmsg()) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return $out;
+	}
+
+	function fput($remotefile, $fp) {
+		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
+		$pi=pathinfo($remotefile);
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
+		else $mode=FTP_BINARY;
+		if(!$this->_data_prepare($mode)) {
+			return FALSE;
+		}
+		if($this->_can_restore and $rest!=0) $this->restore($rest);
+		if(!$this->_exec("STOR ".$remotefile, "put")) {
+			$this->_data_close();
+			return FALSE;
+		}
+		if(!$this->_checkCode()) {
+			$this->_data_close();
+			return FALSE;
+		}
+		$ret=$this->_data_write($mode, $fp);
+		$this->_data_close();
+		if(!$this->_readmsg()) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return $ret;
+	}
+
+	function put($localfile, $remotefile=NULL, $rest=0) {
+		if(is_null($remotefile)) $remotefile=$localfile;
+		if (!file_exists($localfile)) {
+			$this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\"");
+			return FALSE;
+		}
+		$fp = @fopen($localfile, "r");
+
+		if (!$fp) {
+			$this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\"");
+			return FALSE;
+		}
+		if($this->_can_restore and $rest!=0) fseek($fp, $rest);
+		$pi=pathinfo($localfile);
+		if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
+		else $mode=FTP_BINARY;
+		if(!$this->_data_prepare($mode)) {
+			fclose($fp);
+			return FALSE;
+		}
+		if($this->_can_restore and $rest!=0) $this->restore($rest);
+		if(!$this->_exec("STOR ".$remotefile, "put")) {
+			$this->_data_close();
+			fclose($fp);
+			return FALSE;
+		}
+		if(!$this->_checkCode()) {
+			$this->_data_close();
+			fclose($fp);
+			return FALSE;
+		}
+		$ret=$this->_data_write($mode, $fp);
+		fclose($fp);
+		$this->_data_close();
+		if(!$this->_readmsg()) return FALSE;
+		if(!$this->_checkCode()) return FALSE;
+		return $ret;
+	}
+
+	function mput($local=".", $remote=NULL, $continious=false) {
+		$local=realpath($local);
+		if(!@file_exists($local)) {
+			$this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\"");
+			return FALSE;
+		}
+		if(!is_dir($local)) return $this->put($local, $remote);
+		if(empty($remote)) $remote=".";
+		elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE;
+		if($handle = opendir($local)) {
+			$list=array();
+			while (false !== ($file = readdir($handle))) {
+				if ($file != "." && $file != "..") $list[]=$file;
+			}
+			closedir($handle);
+		} else {
+			$this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\"");
+			return FALSE;
+		}
+		if(empty($list)) return TRUE;
+		$ret=true;
+		foreach($list as $el) {
+			if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el);
+			else $t=$this->put($local."/".$el, $remote."/".$el);
+			if(!$t) {
+				$ret=FALSE;
+				if(!$continious) break;
+			}
+		}
+		return $ret;
+
+	}
+
+	function mget($remote, $local=".", $continious=false) {
+		$list=$this->rawlist($remote, "-lA");
+		if($list===false) {
+			$this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
+			return FALSE;
+		}
+		if(empty($list)) return true;
+		if(!@file_exists($local)) {
+			if(!@mkdir($local)) {
+				$this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\"");
+				return FALSE;
+			}
+		}
+		foreach($list as $k=>$v) {
+			$list[$k]=$this->parselisting($v);
+			if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
+		}
+		$ret=true;
+		foreach($list as $el) {
+			if($el["type"]=="d") {
+				if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) {
+					$this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
+					$ret=false;
+					if(!$continious) break;
+				}
+			} else {
+				if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) {
+					$this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
+					$ret=false;
+					if(!$continious) break;
+				}
+			}
+			@chmod($local."/".$el["name"], $el["perms"]);
+			$t=strtotime($el["date"]);
+			if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t);
+		}
+		return $ret;
+	}
+
+	function mdel($remote, $continious=false) {
+		$list=$this->rawlist($remote, "-la");
+		if($list===false) {
+			$this->PushError("mdel","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
+			return false;
+		}
+
+		foreach($list as $k=>$v) {
+			$list[$k]=$this->parselisting($v);
+			if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
+		}
+		$ret=true;
+
+		foreach($list as $el) {
+			if ( empty($el) )
+				continue;
+
+			if($el["type"]=="d") {
+				if(!$this->mdel($remote."/".$el["name"], $continious)) {
+					$ret=false;
+					if(!$continious) break;
+				}
+			} else {
+				if (!$this->delete($remote."/".$el["name"])) {
+					$this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\"");
+					$ret=false;
+					if(!$continious) break;
+				}
+			}
+		}
+
+		if(!$this->rmdir($remote)) {
+			$this->PushError("mdel", "can't delete folder", "Can't delete remote folder \"".$remote."/".$el["name"]."\"");
+			$ret=false;
+		}
+		return $ret;
+	}
+
+	function mmkdir($dir, $mode = 0777) {
+		if(empty($dir)) return FALSE;
+		if($this->is_exists($dir) or $dir == "/" ) return TRUE;
+		if(!$this->mmkdir(dirname($dir), $mode)) return false;
+		$r=$this->mkdir($dir, $mode);
+		$this->chmod($dir,$mode);
+		return $r;
+	}
+
+	function glob($pattern, $handle=NULL) {
+		$path=$output=null;
+		if(PHP_OS=='WIN32') $slash='\\';
+		else $slash='/';
+		$lastpos=strrpos($pattern,$slash);
+		if(!($lastpos===false)) {
+			$path=substr($pattern,0,-$lastpos-1);
+			$pattern=substr($pattern,$lastpos);
+		} else $path=getcwd();
+		if(is_array($handle) and !empty($handle)) {
+			while($dir=each($handle)) {
+				if($this->glob_pattern_match($pattern,$dir))
+				$output[]=$dir;
+			}
+		} else {
+			$handle=@opendir($path);
+			if($handle===false) return false;
+			while($dir=readdir($handle)) {
+				if($this->glob_pattern_match($pattern,$dir))
+				$output[]=$dir;
+			}
+			closedir($handle);
+		}
+		if(is_array($output)) return $output;
+		return false;
+	}
+
+	function glob_pattern_match($pattern,$string) {
+		$out=null;
+		$chunks=explode(';',$pattern);
+		foreach($chunks as $pattern) {
+			$escape=array('$','^','.','{','}','(',')','[',']','|');
+			while(strpos($pattern,'**')!==false)
+				$pattern=str_replace('**','*',$pattern);
+			foreach($escape as $probe)
+				$pattern=str_replace($probe,"\\$probe",$pattern);
+			$pattern=str_replace('?*','*',
+				str_replace('*?','*',
+					str_replace('*',".*",
+						str_replace('?','.{1,1}',$pattern))));
+			$out[]=$pattern;
+		}
+		if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string));
+		else {
+			foreach($out as $tester)
+				if($this->my_regexp("^$tester$",$string)) return true;
+		}
+		return false;
+	}
+
+	function glob_regexp($pattern,$probe) {
+		$sensitive=(PHP_OS!='WIN32');
+		return ($sensitive?
+			ereg($pattern,$probe):
+			eregi($pattern,$probe)
+		);
+	}
+
+	function dirlist($remote) {
+		$list=$this->rawlist($remote, "-la");
+		if($list===false) {
+			$this->PushError("dirlist","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
+			return false;
+		}
+
+		$dirlist = array();
+		foreach($list as $k=>$v) {
+			$entry=$this->parselisting($v);
+			if ( empty($entry) )
+				continue;
+
+			if($entry["name"]=="." or $entry["name"]=="..")
+				continue;
+
+			$dirlist[$entry['name']] = $entry;
+		}
+
+		return $dirlist;
+	}
+// <!-- --------------------------------------------------------------------------------------- -->
+// <!--       Private functions                                                                 -->
+// <!-- --------------------------------------------------------------------------------------- -->
+	function _checkCode() {
+		return ($this->_code<400 and $this->_code>0);
+	}
+
+	function _list($arg="", $cmd="LIST", $fnction="_list") {
+		if(!$this->_data_prepare()) return false;
+		if(!$this->_exec($cmd.$arg, $fnction)) {
+			$this->_data_close();
+			return FALSE;
+		}
+		if(!$this->_checkCode()) {
+			$this->_data_close();
+			return FALSE;
+		}
+		$out="";
+		if($this->_code<200) {
+			$out=$this->_data_read();
+			$this->_data_close();
+			if(!$this->_readmsg()) return FALSE;
+			if(!$this->_checkCode()) return FALSE;
+			if($out === FALSE ) return FALSE;
+			$out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY);
+//			$this->SendMSG(implode($this->_eol_code[$this->OS_local], $out));
+		}
+		return $out;
+	}
+
+// <!-- --------------------------------------------------------------------------------------- -->
+// <!-- Partie : gestion des erreurs                                                            -->
+// <!-- --------------------------------------------------------------------------------------- -->
+// Gnre une erreur pour traitement externe  la classe
+	function PushError($fctname,$msg,$desc=false){
+		$error=array();
+		$error['time']=time();
+		$error['fctname']=$fctname;
+		$error['msg']=$msg;
+		$error['desc']=$desc;
+		if($desc) $tmp=' ('.$desc.')'; else $tmp='';
+		$this->SendMSG($fctname.': '.$msg.$tmp);
+		return(array_push($this->_error_array,$error));
+	}
+
+// Rcupre une erreur externe
+	function PopError(){
+		if(count($this->_error_array)) return(array_pop($this->_error_array));
+			else return(false);
+	}
+}
+
+$mod_sockets=TRUE;
+if (!extension_loaded('sockets')) {
+	$prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
+	if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE;
+}
+
+require_once "class-ftp-".($mod_sockets?"sockets":"pure").".php";
+?>
Index: /tags/3.1/wp-admin/includes/class-pclzip.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-pclzip.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-pclzip.php	(revision 17487)
@@ -0,0 +1,5687 @@
+<?php
+// --------------------------------------------------------------------------------
+// PhpConcept Library - Zip Module 2.8.2
+// --------------------------------------------------------------------------------
+// License GNU/LGPL - Vincent Blavet - August 2009
+// http://www.phpconcept.net
+// --------------------------------------------------------------------------------
+//
+// Presentation :
+//   PclZip is a PHP library that manage ZIP archives.
+//   So far tests show that archives generated by PclZip are readable by
+//   WinZip application and other tools.
+//
+// Description :
+//   See readme.txt and http://www.phpconcept.net
+//
+// Warning :
+//   This library and the associated files are non commercial, non professional
+//   work.
+//   It should not have unexpected results. However if any damage is caused by
+//   this software the author can not be responsible.
+//   The use of this software is at the risk of the user.
+//
+// --------------------------------------------------------------------------------
+// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
+// --------------------------------------------------------------------------------
+
+  // ----- Constants
+  if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
+    define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
+  }
+
+  // ----- File list separator
+  // In version 1.x of PclZip, the separator for file list is a space
+  // (which is not a very smart choice, specifically for windows paths !).
+  // A better separator should be a comma (,). This constant gives you the
+  // abilty to change that.
+  // However notice that changing this value, may have impact on existing
+  // scripts, using space separated filenames.
+  // Recommanded values for compatibility with older versions :
+  //define( 'PCLZIP_SEPARATOR', ' ' );
+  // Recommanded values for smart separation of filenames.
+  if (!defined('PCLZIP_SEPARATOR')) {
+    define( 'PCLZIP_SEPARATOR', ',' );
+  }
+
+  // ----- Error configuration
+  // 0 : PclZip Class integrated error handling
+  // 1 : PclError external library error handling. By enabling this
+  //     you must ensure that you have included PclError library.
+  // [2,...] : reserved for futur use
+  if (!defined('PCLZIP_ERROR_EXTERNAL')) {
+    define( 'PCLZIP_ERROR_EXTERNAL', 0 );
+  }
+
+  // ----- Optional static temporary directory
+  //       By default temporary files are generated in the script current
+  //       path.
+  //       If defined :
+  //       - MUST BE terminated by a '/'.
+  //       - MUST be a valid, already created directory
+  //       Samples :
+  // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
+  // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
+  if (!defined('PCLZIP_TEMPORARY_DIR')) {
+    define( 'PCLZIP_TEMPORARY_DIR', '' );
+  }
+
+  // ----- Optional threshold ratio for use of temporary files
+  //       Pclzip sense the size of the file to add/extract and decide to
+  //       use or not temporary file. The algorythm is looking for
+  //       memory_limit of PHP and apply a ratio.
+  //       threshold = memory_limit * ratio.
+  //       Recommended values are under 0.5. Default 0.47.
+  //       Samples :
+  // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
+  if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
+    define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
+  }
+
+// --------------------------------------------------------------------------------
+// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
+// --------------------------------------------------------------------------------
+
+  // ----- Global variables
+  $g_pclzip_version = "2.8.2";
+
+  // ----- Error codes
+  //   -1 : Unable to open file in binary write mode
+  //   -2 : Unable to open file in binary read mode
+  //   -3 : Invalid parameters
+  //   -4 : File does not exist
+  //   -5 : Filename is too long (max. 255)
+  //   -6 : Not a valid zip file
+  //   -7 : Invalid extracted file size
+  //   -8 : Unable to create directory
+  //   -9 : Invalid archive extension
+  //  -10 : Invalid archive format
+  //  -11 : Unable to delete file (unlink)
+  //  -12 : Unable to rename file (rename)
+  //  -13 : Invalid header checksum
+  //  -14 : Invalid archive size
+  define( 'PCLZIP_ERR_USER_ABORTED', 2 );
+  define( 'PCLZIP_ERR_NO_ERROR', 0 );
+  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
+  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
+  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
+  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
+  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
+  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
+  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
+  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
+  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
+  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
+  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
+  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
+  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
+  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
+  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
+  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
+  define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
+  define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
+  define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
+  define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
+  define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
+
+  // ----- Options values
+  define( 'PCLZIP_OPT_PATH', 77001 );
+  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
+  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
+  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
+  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
+  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
+  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
+  define( 'PCLZIP_OPT_BY_NAME', 77008 );
+  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
+  define( 'PCLZIP_OPT_BY_EREG', 77010 );
+  define( 'PCLZIP_OPT_BY_PREG', 77011 );
+  define( 'PCLZIP_OPT_COMMENT', 77012 );
+  define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
+  define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
+  define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
+  define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
+  define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
+  // Having big trouble with crypt. Need to multiply 2 long int
+  // which is not correctly supported by PHP ...
+  //define( 'PCLZIP_OPT_CRYPT', 77018 );
+  define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
+  define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
+  define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
+  define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
+  define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
+  define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
+  define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
+
+  // ----- File description attributes
+  define( 'PCLZIP_ATT_FILE_NAME', 79001 );
+  define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
+  define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
+  define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
+  define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
+  define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
+
+  // ----- Call backs values
+  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
+  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
+  define( 'PCLZIP_CB_PRE_ADD', 78003 );
+  define( 'PCLZIP_CB_POST_ADD', 78004 );
+  /* For futur use
+  define( 'PCLZIP_CB_PRE_LIST', 78005 );
+  define( 'PCLZIP_CB_POST_LIST', 78006 );
+  define( 'PCLZIP_CB_PRE_DELETE', 78007 );
+  define( 'PCLZIP_CB_POST_DELETE', 78008 );
+  */
+
+  // --------------------------------------------------------------------------------
+  // Class : PclZip
+  // Description :
+  //   PclZip is the class that represent a Zip archive.
+  //   The public methods allow the manipulation of the archive.
+  // Attributes :
+  //   Attributes must not be accessed directly.
+  // Methods :
+  //   PclZip() : Object creator
+  //   create() : Creates the Zip archive
+  //   listContent() : List the content of the Zip archive
+  //   extract() : Extract the content of the archive
+  //   properties() : List the properties of the archive
+  // --------------------------------------------------------------------------------
+  class PclZip
+  {
+    // ----- Filename of the zip file
+    var $zipname = '';
+
+    // ----- File descriptor of the zip file
+    var $zip_fd = 0;
+
+    // ----- Internal error handling
+    var $error_code = 1;
+    var $error_string = '';
+
+    // ----- Current status of the magic_quotes_runtime
+    // This value store the php configuration for magic_quotes
+    // The class can then disable the magic_quotes and reset it after
+    var $magic_quotes_status;
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZip()
+  // Description :
+  //   Creates a PclZip object and set the name of the associated Zip archive
+  //   filename.
+  //   Note that no real action is taken, if the archive does not exist it is not
+  //   created. Use create() for that.
+  // --------------------------------------------------------------------------------
+  function PclZip($p_zipname)
+  {
+
+    // ----- Tests the zlib
+    if (!function_exists('gzopen'))
+    {
+      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
+    }
+
+    // ----- Set the attributes
+    $this->zipname = $p_zipname;
+    $this->zip_fd = 0;
+    $this->magic_quotes_status = -1;
+
+    // ----- Return
+    return;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function :
+  //   create($p_filelist, $p_add_dir="", $p_remove_dir="")
+  //   create($p_filelist, $p_option, $p_option_value, ...)
+  // Description :
+  //   This method supports two different synopsis. The first one is historical.
+  //   This method creates a Zip Archive. The Zip file is created in the
+  //   filesystem. The files and directories indicated in $p_filelist
+  //   are added in the archive. See the parameters description for the
+  //   supported format of $p_filelist.
+  //   When a directory is in the list, the directory and its content is added
+  //   in the archive.
+  //   In this synopsis, the function takes an optional variable list of
+  //   options. See bellow the supported options.
+  // Parameters :
+  //   $p_filelist : An array containing file or directory names, or
+  //                 a string containing one filename or one directory name, or
+  //                 a string containing a list of filenames and/or directory
+  //                 names separated by spaces.
+  //   $p_add_dir : A path to add before the real path of the archived file,
+  //                in order to have it memorized in the archive.
+  //   $p_remove_dir : A path to remove from the real path of the file to archive,
+  //                   in order to have a shorter path memorized in the archive.
+  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
+  //                   is removed first, before $p_add_dir is added.
+  // Options :
+  //   PCLZIP_OPT_ADD_PATH :
+  //   PCLZIP_OPT_REMOVE_PATH :
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :
+  //   PCLZIP_OPT_COMMENT :
+  //   PCLZIP_CB_PRE_ADD :
+  //   PCLZIP_CB_POST_ADD :
+  // Return Values :
+  //   0 on failure,
+  //   The list of the added files, with a status of the add action.
+  //   (see PclZip::listContent() for list entry format)
+  // --------------------------------------------------------------------------------
+  function create($p_filelist)
+  {
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Set default values
+    $v_options = array();
+    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+
+    // ----- Look for arguments
+    if ($v_size > 1) {
+      // ----- Get the arguments
+      $v_arg_list = func_get_args();
+
+      // ----- Remove from the options list the first argument
+      array_shift($v_arg_list);
+      $v_size--;
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_ADD => 'optional',
+                                                   PCLZIP_CB_POST_ADD => 'optional',
+                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
+                                                   PCLZIP_OPT_COMMENT => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+                                                   //, PCLZIP_OPT_CRYPT => 'optional'
+                                             ));
+        if ($v_result != 1) {
+          return 0;
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+
+        // ----- Get the first argument
+        $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
+		                       "Invalid number / type of arguments");
+          return 0;
+        }
+      }
+    }
+
+    // ----- Look for default option values
+    $this->privOptionDefaultThreshold($v_options);
+
+    // ----- Init
+    $v_string_list = array();
+    $v_att_list = array();
+    $v_filedescr_list = array();
+    $p_result_list = array();
+
+    // ----- Look if the $p_filelist is really an array
+    if (is_array($p_filelist)) {
+
+      // ----- Look if the first element is also an array
+      //       This will mean that this is a file description entry
+      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
+        $v_att_list = $p_filelist;
+      }
+
+      // ----- The list is a list of string names
+      else {
+        $v_string_list = $p_filelist;
+      }
+    }
+
+    // ----- Look if the $p_filelist is a string
+    else if (is_string($p_filelist)) {
+      // ----- Create a list from the string
+      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
+    }
+
+    // ----- Invalid variable type for $p_filelist
+    else {
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
+      return 0;
+    }
+
+    // ----- Reformat the string list
+    if (sizeof($v_string_list) != 0) {
+      foreach ($v_string_list as $v_string) {
+        if ($v_string != '') {
+          $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
+        }
+        else {
+        }
+      }
+    }
+
+    // ----- For each file in the list check the attributes
+    $v_supported_attributes
+    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
+             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
+             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
+             ,PCLZIP_ATT_FILE_MTIME => 'optional'
+             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
+             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
+						);
+    foreach ($v_att_list as $v_entry) {
+      $v_result = $this->privFileDescrParseAtt($v_entry,
+                                               $v_filedescr_list[],
+                                               $v_options,
+                                               $v_supported_attributes);
+      if ($v_result != 1) {
+        return 0;
+      }
+    }
+
+    // ----- Expand the filelist (expand directories)
+    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
+    if ($v_result != 1) {
+      return 0;
+    }
+
+    // ----- Call the create fct
+    $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
+    if ($v_result != 1) {
+      return 0;
+    }
+
+    // ----- Return
+    return $p_result_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function :
+  //   add($p_filelist, $p_add_dir="", $p_remove_dir="")
+  //   add($p_filelist, $p_option, $p_option_value, ...)
+  // Description :
+  //   This method supports two synopsis. The first one is historical.
+  //   This methods add the list of files in an existing archive.
+  //   If a file with the same name already exists, it is added at the end of the
+  //   archive, the first one is still present.
+  //   If the archive does not exist, it is created.
+  // Parameters :
+  //   $p_filelist : An array containing file or directory names, or
+  //                 a string containing one filename or one directory name, or
+  //                 a string containing a list of filenames and/or directory
+  //                 names separated by spaces.
+  //   $p_add_dir : A path to add before the real path of the archived file,
+  //                in order to have it memorized in the archive.
+  //   $p_remove_dir : A path to remove from the real path of the file to archive,
+  //                   in order to have a shorter path memorized in the archive.
+  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
+  //                   is removed first, before $p_add_dir is added.
+  // Options :
+  //   PCLZIP_OPT_ADD_PATH :
+  //   PCLZIP_OPT_REMOVE_PATH :
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :
+  //   PCLZIP_OPT_COMMENT :
+  //   PCLZIP_OPT_ADD_COMMENT :
+  //   PCLZIP_OPT_PREPEND_COMMENT :
+  //   PCLZIP_CB_PRE_ADD :
+  //   PCLZIP_CB_POST_ADD :
+  // Return Values :
+  //   0 on failure,
+  //   The list of the added files, with a status of the add action.
+  //   (see PclZip::listContent() for list entry format)
+  // --------------------------------------------------------------------------------
+  function add($p_filelist)
+  {
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Set default values
+    $v_options = array();
+    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+
+    // ----- Look for arguments
+    if ($v_size > 1) {
+      // ----- Get the arguments
+      $v_arg_list = func_get_args();
+
+      // ----- Remove form the options list the first argument
+      array_shift($v_arg_list);
+      $v_size--;
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_ADD => 'optional',
+                                                   PCLZIP_CB_POST_ADD => 'optional',
+                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
+                                                   PCLZIP_OPT_COMMENT => 'optional',
+                                                   PCLZIP_OPT_ADD_COMMENT => 'optional',
+                                                   PCLZIP_OPT_PREPEND_COMMENT => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+                                                   //, PCLZIP_OPT_CRYPT => 'optional'
+												   ));
+        if ($v_result != 1) {
+          return 0;
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+
+        // ----- Get the first argument
+        $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
+
+          // ----- Return
+          return 0;
+        }
+      }
+    }
+
+    // ----- Look for default option values
+    $this->privOptionDefaultThreshold($v_options);
+
+    // ----- Init
+    $v_string_list = array();
+    $v_att_list = array();
+    $v_filedescr_list = array();
+    $p_result_list = array();
+
+    // ----- Look if the $p_filelist is really an array
+    if (is_array($p_filelist)) {
+
+      // ----- Look if the first element is also an array
+      //       This will mean that this is a file description entry
+      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
+        $v_att_list = $p_filelist;
+      }
+
+      // ----- The list is a list of string names
+      else {
+        $v_string_list = $p_filelist;
+      }
+    }
+
+    // ----- Look if the $p_filelist is a string
+    else if (is_string($p_filelist)) {
+      // ----- Create a list from the string
+      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
+    }
+
+    // ----- Invalid variable type for $p_filelist
+    else {
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
+      return 0;
+    }
+
+    // ----- Reformat the string list
+    if (sizeof($v_string_list) != 0) {
+      foreach ($v_string_list as $v_string) {
+        $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
+      }
+    }
+
+    // ----- For each file in the list check the attributes
+    $v_supported_attributes
+    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
+             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
+             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
+             ,PCLZIP_ATT_FILE_MTIME => 'optional'
+             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
+             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
+						);
+    foreach ($v_att_list as $v_entry) {
+      $v_result = $this->privFileDescrParseAtt($v_entry,
+                                               $v_filedescr_list[],
+                                               $v_options,
+                                               $v_supported_attributes);
+      if ($v_result != 1) {
+        return 0;
+      }
+    }
+
+    // ----- Expand the filelist (expand directories)
+    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
+    if ($v_result != 1) {
+      return 0;
+    }
+
+    // ----- Call the create fct
+    $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
+    if ($v_result != 1) {
+      return 0;
+    }
+
+    // ----- Return
+    return $p_result_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : listContent()
+  // Description :
+  //   This public method, gives the list of the files and directories, with their
+  //   properties.
+  //   The properties of each entries in the list are (used also in other functions) :
+  //     filename : Name of the file. For a create or add action it is the filename
+  //                given by the user. For an extract function it is the filename
+  //                of the extracted file.
+  //     stored_filename : Name of the file / directory stored in the archive.
+  //     size : Size of the stored file.
+  //     compressed_size : Size of the file's data compressed in the archive
+  //                       (without the headers overhead)
+  //     mtime : Last known modification date of the file (UNIX timestamp)
+  //     comment : Comment associated with the file
+  //     folder : true | false
+  //     index : index of the file in the archive
+  //     status : status of the action (depending of the action) :
+  //              Values are :
+  //                ok : OK !
+  //                filtered : the file / dir is not extracted (filtered by user)
+  //                already_a_directory : the file can not be extracted because a
+  //                                      directory with the same name already exists
+  //                write_protected : the file can not be extracted because a file
+  //                                  with the same name already exists and is
+  //                                  write protected
+  //                newer_exist : the file was not extracted because a newer file exists
+  //                path_creation_fail : the file is not extracted because the folder
+  //                                     does not exist and can not be created
+  //                write_error : the file was not extracted because there was a
+  //                              error while writing the file
+  //                read_error : the file was not extracted because there was a error
+  //                             while reading the file
+  //                invalid_header : the file was not extracted because of an archive
+  //                                 format error (bad file header)
+  //   Note that each time a method can continue operating when there
+  //   is an action error on a file, the error is only logged in the file status.
+  // Return Values :
+  //   0 on an unrecoverable failure,
+  //   The list of the files in the archive.
+  // --------------------------------------------------------------------------------
+  function listContent()
+  {
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      return(0);
+    }
+
+    // ----- Call the extracting fct
+    $p_list = array();
+    if (($v_result = $this->privList($p_list)) != 1)
+    {
+      unset($p_list);
+      return(0);
+    }
+
+    // ----- Return
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function :
+  //   extract($p_path="./", $p_remove_path="")
+  //   extract([$p_option, $p_option_value, ...])
+  // Description :
+  //   This method supports two synopsis. The first one is historical.
+  //   This method extract all the files / directories from the archive to the
+  //   folder indicated in $p_path.
+  //   If you want to ignore the 'root' part of path of the memorized files
+  //   you can indicate this in the optional $p_remove_path parameter.
+  //   By default, if a newer file with the same name already exists, the
+  //   file is not extracted.
+  //
+  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
+  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
+  //   at the end of the path value of PCLZIP_OPT_PATH.
+  // Parameters :
+  //   $p_path : Path where the files and directories are to be extracted
+  //   $p_remove_path : First part ('root' part) of the memorized path
+  //                    (if any similar) to remove while extracting.
+  // Options :
+  //   PCLZIP_OPT_PATH :
+  //   PCLZIP_OPT_ADD_PATH :
+  //   PCLZIP_OPT_REMOVE_PATH :
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :
+  //   PCLZIP_CB_PRE_EXTRACT :
+  //   PCLZIP_CB_POST_EXTRACT :
+  // Return Values :
+  //   0 or a negative value on failure,
+  //   The list of the extracted files, with a status of the action.
+  //   (see PclZip::listContent() for list entry format)
+  // --------------------------------------------------------------------------------
+  function extract()
+  {
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      return(0);
+    }
+
+    // ----- Set default values
+    $v_options = array();
+//    $v_path = "./";
+    $v_path = '';
+    $v_remove_path = "";
+    $v_remove_all_path = false;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+
+    // ----- Default values for option
+    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
+
+    // ----- Look for arguments
+    if ($v_size > 0) {
+      // ----- Get the arguments
+      $v_arg_list = func_get_args();
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
+                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
+                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
+                                                   PCLZIP_OPT_BY_NAME => 'optional',
+                                                   PCLZIP_OPT_BY_EREG => 'optional',
+                                                   PCLZIP_OPT_BY_PREG => 'optional',
+                                                   PCLZIP_OPT_BY_INDEX => 'optional',
+                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
+                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
+                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
+                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
+                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+												    ));
+        if ($v_result != 1) {
+          return 0;
+        }
+
+        // ----- Set the arguments
+        if (isset($v_options[PCLZIP_OPT_PATH])) {
+          $v_path = $v_options[PCLZIP_OPT_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+          // ----- Check for '/' in last path char
+          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
+            $v_path .= '/';
+          }
+          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+
+        // ----- Get the first argument
+        $v_path = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_remove_path = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
+
+          // ----- Return
+          return 0;
+        }
+      }
+    }
+
+    // ----- Look for default option values
+    $this->privOptionDefaultThreshold($v_options);
+
+    // ----- Trace
+
+    // ----- Call the extracting fct
+    $p_list = array();
+    $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
+	                                     $v_remove_all_path, $v_options);
+    if ($v_result < 1) {
+      unset($p_list);
+      return(0);
+    }
+
+    // ----- Return
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+
+  // --------------------------------------------------------------------------------
+  // Function :
+  //   extractByIndex($p_index, $p_path="./", $p_remove_path="")
+  //   extractByIndex($p_index, [$p_option, $p_option_value, ...])
+  // Description :
+  //   This method supports two synopsis. The first one is historical.
+  //   This method is doing a partial extract of the archive.
+  //   The extracted files or folders are identified by their index in the
+  //   archive (from 0 to n).
+  //   Note that if the index identify a folder, only the folder entry is
+  //   extracted, not all the files included in the archive.
+  // Parameters :
+  //   $p_index : A single index (integer) or a string of indexes of files to
+  //              extract. The form of the string is "0,4-6,8-12" with only numbers
+  //              and '-' for range or ',' to separate ranges. No spaces or ';'
+  //              are allowed.
+  //   $p_path : Path where the files and directories are to be extracted
+  //   $p_remove_path : First part ('root' part) of the memorized path
+  //                    (if any similar) to remove while extracting.
+  // Options :
+  //   PCLZIP_OPT_PATH :
+  //   PCLZIP_OPT_ADD_PATH :
+  //   PCLZIP_OPT_REMOVE_PATH :
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :
+  //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
+  //     not as files.
+  //     The resulting content is in a new field 'content' in the file
+  //     structure.
+  //     This option must be used alone (any other options are ignored).
+  //   PCLZIP_CB_PRE_EXTRACT :
+  //   PCLZIP_CB_POST_EXTRACT :
+  // Return Values :
+  //   0 on failure,
+  //   The list of the extracted files, with a status of the action.
+  //   (see PclZip::listContent() for list entry format)
+  // --------------------------------------------------------------------------------
+  //function extractByIndex($p_index, options...)
+  function extractByIndex($p_index)
+  {
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      return(0);
+    }
+
+    // ----- Set default values
+    $v_options = array();
+//    $v_path = "./";
+    $v_path = '';
+    $v_remove_path = "";
+    $v_remove_all_path = false;
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+
+    // ----- Default values for option
+    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
+
+    // ----- Look for arguments
+    if ($v_size > 1) {
+      // ----- Get the arguments
+      $v_arg_list = func_get_args();
+
+      // ----- Remove form the options list the first argument
+      array_shift($v_arg_list);
+      $v_size--;
+
+      // ----- Look for first arg
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+        // ----- Parse the options
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                            array (PCLZIP_OPT_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',
+                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
+                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
+                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
+                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
+                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
+                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+												   ));
+        if ($v_result != 1) {
+          return 0;
+        }
+
+        // ----- Set the arguments
+        if (isset($v_options[PCLZIP_OPT_PATH])) {
+          $v_path = $v_options[PCLZIP_OPT_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+        }
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+          // ----- Check for '/' in last path char
+          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
+            $v_path .= '/';
+          }
+          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
+        }
+        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
+          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
+        }
+        else {
+        }
+      }
+
+      // ----- Look for 2 args
+      // Here we need to support the first historic synopsis of the
+      // method.
+      else {
+
+        // ----- Get the first argument
+        $v_path = $v_arg_list[0];
+
+        // ----- Look for the optional second argument
+        if ($v_size == 2) {
+          $v_remove_path = $v_arg_list[1];
+        }
+        else if ($v_size > 2) {
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
+
+          // ----- Return
+          return 0;
+        }
+      }
+    }
+
+    // ----- Trace
+
+    // ----- Trick
+    // Here I want to reuse extractByRule(), so I need to parse the $p_index
+    // with privParseOptions()
+    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
+    $v_options_trick = array();
+    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
+                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
+    if ($v_result != 1) {
+        return 0;
+    }
+    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
+
+    // ----- Look for default option values
+    $this->privOptionDefaultThreshold($v_options);
+
+    // ----- Call the extracting fct
+    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
+        return(0);
+    }
+
+    // ----- Return
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function :
+  //   delete([$p_option, $p_option_value, ...])
+  // Description :
+  //   This method removes files from the archive.
+  //   If no parameters are given, then all the archive is emptied.
+  // Parameters :
+  //   None or optional arguments.
+  // Options :
+  //   PCLZIP_OPT_BY_INDEX :
+  //   PCLZIP_OPT_BY_NAME :
+  //   PCLZIP_OPT_BY_EREG :
+  //   PCLZIP_OPT_BY_PREG :
+  // Return Values :
+  //   0 on failure,
+  //   The list of the files which are still present in the archive.
+  //   (see PclZip::listContent() for list entry format)
+  // --------------------------------------------------------------------------------
+  function delete()
+  {
+    $v_result=1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      return(0);
+    }
+
+    // ----- Set default values
+    $v_options = array();
+
+    // ----- Look for variable options arguments
+    $v_size = func_num_args();
+
+    // ----- Look for arguments
+    if ($v_size > 0) {
+      // ----- Get the arguments
+      $v_arg_list = func_get_args();
+
+      // ----- Parse the options
+      $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
+                                        array (PCLZIP_OPT_BY_NAME => 'optional',
+                                               PCLZIP_OPT_BY_EREG => 'optional',
+                                               PCLZIP_OPT_BY_PREG => 'optional',
+                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
+      if ($v_result != 1) {
+          return 0;
+      }
+    }
+
+    // ----- Magic quotes trick
+    $this->privDisableMagicQuotes();
+
+    // ----- Call the delete fct
+    $v_list = array();
+    if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
+      $this->privSwapBackMagicQuotes();
+      unset($v_list);
+      return(0);
+    }
+
+    // ----- Magic quotes trick
+    $this->privSwapBackMagicQuotes();
+
+    // ----- Return
+    return $v_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : deleteByIndex()
+  // Description :
+  //   ***** Deprecated *****
+  //   delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
+  // --------------------------------------------------------------------------------
+  function deleteByIndex($p_index)
+  {
+
+    $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
+
+    // ----- Return
+    return $p_list;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : properties()
+  // Description :
+  //   This method gives the properties of the archive.
+  //   The properties are :
+  //     nb : Number of files in the archive
+  //     comment : Comment associated with the archive file
+  //     status : not_exist, ok
+  // Parameters :
+  //   None
+  // Return Values :
+  //   0 on failure,
+  //   An array with the archive properties.
+  // --------------------------------------------------------------------------------
+  function properties()
+  {
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Magic quotes trick
+    $this->privDisableMagicQuotes();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      $this->privSwapBackMagicQuotes();
+      return(0);
+    }
+
+    // ----- Default properties
+    $v_prop = array();
+    $v_prop['comment'] = '';
+    $v_prop['nb'] = 0;
+    $v_prop['status'] = 'not_exist';
+
+    // ----- Look if file exists
+    if (@is_file($this->zipname))
+    {
+      // ----- Open the zip file
+      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
+      {
+        $this->privSwapBackMagicQuotes();
+
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
+
+        // ----- Return
+        return 0;
+      }
+
+      // ----- Read the central directory informations
+      $v_central_dir = array();
+      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+      {
+        $this->privSwapBackMagicQuotes();
+        return 0;
+      }
+
+      // ----- Close the zip file
+      $this->privCloseFd();
+
+      // ----- Set the user attributes
+      $v_prop['comment'] = $v_central_dir['comment'];
+      $v_prop['nb'] = $v_central_dir['entries'];
+      $v_prop['status'] = 'ok';
+    }
+
+    // ----- Magic quotes trick
+    $this->privSwapBackMagicQuotes();
+
+    // ----- Return
+    return $v_prop;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : duplicate()
+  // Description :
+  //   This method creates an archive by copying the content of an other one. If
+  //   the archive already exist, it is replaced by the new one without any warning.
+  // Parameters :
+  //   $p_archive : The filename of a valid archive, or
+  //                a valid PclZip object.
+  // Return Values :
+  //   1 on success.
+  //   0 or a negative value on error (error code).
+  // --------------------------------------------------------------------------------
+  function duplicate($p_archive)
+  {
+    $v_result = 1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Look if the $p_archive is a PclZip object
+    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
+    {
+
+      // ----- Duplicate the archive
+      $v_result = $this->privDuplicate($p_archive->zipname);
+    }
+
+    // ----- Look if the $p_archive is a string (so a filename)
+    else if (is_string($p_archive))
+    {
+
+      // ----- Check that $p_archive is a valid zip file
+      // TBC : Should also check the archive format
+      if (!is_file($p_archive)) {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
+        $v_result = PCLZIP_ERR_MISSING_FILE;
+      }
+      else {
+        // ----- Duplicate the archive
+        $v_result = $this->privDuplicate($p_archive);
+      }
+    }
+
+    // ----- Invalid variable
+    else
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : merge()
+  // Description :
+  //   This method merge the $p_archive_to_add archive at the end of the current
+  //   one ($this).
+  //   If the archive ($this) does not exist, the merge becomes a duplicate.
+  //   If the $p_archive_to_add archive does not exist, the merge is a success.
+  // Parameters :
+  //   $p_archive_to_add : It can be directly the filename of a valid zip archive,
+  //                       or a PclZip object archive.
+  // Return Values :
+  //   1 on success,
+  //   0 or negative values on error (see below).
+  // --------------------------------------------------------------------------------
+  function merge($p_archive_to_add)
+  {
+    $v_result = 1;
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Check archive
+    if (!$this->privCheckFormat()) {
+      return(0);
+    }
+
+    // ----- Look if the $p_archive_to_add is a PclZip object
+    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
+    {
+
+      // ----- Merge the archive
+      $v_result = $this->privMerge($p_archive_to_add);
+    }
+
+    // ----- Look if the $p_archive_to_add is a string (so a filename)
+    else if (is_string($p_archive_to_add))
+    {
+
+      // ----- Create a temporary archive
+      $v_object_archive = new PclZip($p_archive_to_add);
+
+      // ----- Merge the archive
+      $v_result = $this->privMerge($v_object_archive);
+    }
+
+    // ----- Invalid variable
+    else
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+
+
+  // --------------------------------------------------------------------------------
+  // Function : errorCode()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function errorCode()
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      return(PclErrorCode());
+    }
+    else {
+      return($this->error_code);
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : errorName()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function errorName($p_with_code=false)
+  {
+    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
+                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
+                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
+                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
+                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
+                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
+                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
+                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
+                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
+                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
+                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
+                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
+                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
+                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
+                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
+                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
+                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
+                      PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
+                      PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
+                      ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
+                      ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
+                    );
+
+    if (isset($v_name[$this->error_code])) {
+      $v_value = $v_name[$this->error_code];
+    }
+    else {
+      $v_value = 'NoName';
+    }
+
+    if ($p_with_code) {
+      return($v_value.' ('.$this->error_code.')');
+    }
+    else {
+      return($v_value);
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : errorInfo()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function errorInfo($p_full=false)
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      return(PclErrorString());
+    }
+    else {
+      if ($p_full) {
+        return($this->errorName(true)." : ".$this->error_string);
+      }
+      else {
+        return($this->error_string." [code ".$this->error_code."]");
+      }
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------------
+// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
+// *****                                                        *****
+// *****       THESES FUNCTIONS MUST NOT BE USED DIRECTLY       *****
+// --------------------------------------------------------------------------------
+
+
+
+  // --------------------------------------------------------------------------------
+  // Function : privCheckFormat()
+  // Description :
+  //   This method check that the archive exists and is a valid zip archive.
+  //   Several level of check exists. (futur)
+  // Parameters :
+  //   $p_level : Level of check. Default 0.
+  //              0 : Check the first bytes (magic codes) (default value))
+  //              1 : 0 + Check the central directory (futur)
+  //              2 : 1 + Check each file header (futur)
+  // Return Values :
+  //   true on success,
+  //   false on error, the error code is set.
+  // --------------------------------------------------------------------------------
+  function privCheckFormat($p_level=0)
+  {
+    $v_result = true;
+
+	// ----- Reset the file system cache
+    clearstatcache();
+
+    // ----- Reset the error handler
+    $this->privErrorReset();
+
+    // ----- Look if the file exits
+    if (!is_file($this->zipname)) {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
+      return(false);
+    }
+
+    // ----- Check that the file is readeable
+    if (!is_readable($this->zipname)) {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
+      return(false);
+    }
+
+    // ----- Check the magic code
+    // TBC
+
+    // ----- Check the central header
+    // TBC
+
+    // ----- Check each file header
+    // TBC
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privParseOptions()
+  // Description :
+  //   This internal methods reads the variable list of arguments ($p_options_list,
+  //   $p_size) and generate an array with the options and values ($v_result_list).
+  //   $v_requested_options contains the options that can be present and those that
+  //   must be present.
+  //   $v_requested_options is an array, with the option value as key, and 'optional',
+  //   or 'mandatory' as value.
+  // Parameters :
+  //   See above.
+  // Return Values :
+  //   1 on success.
+  //   0 on failure.
+  // --------------------------------------------------------------------------------
+  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
+  {
+    $v_result=1;
+
+    // ----- Read the options
+    $i=0;
+    while ($i<$p_size) {
+
+      // ----- Check if the option is supported
+      if (!isset($v_requested_options[$p_options_list[$i]])) {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
+
+        // ----- Return
+        return PclZip::errorCode();
+      }
+
+      // ----- Look for next option
+      switch ($p_options_list[$i]) {
+        // ----- Look for options that request a path value
+        case PCLZIP_OPT_PATH :
+        case PCLZIP_OPT_REMOVE_PATH :
+        case PCLZIP_OPT_ADD_PATH :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
+          $i++;
+        break;
+
+        case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+            return PclZip::errorCode();
+          }
+
+          // ----- Check for incompatible options
+          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
+            return PclZip::errorCode();
+          }
+
+          // ----- Check the value
+          $v_value = $p_options_list[$i+1];
+          if ((!is_integer($v_value)) || ($v_value<0)) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value (and convert it in bytes)
+          $v_result_list[$p_options_list[$i]] = $v_value*1048576;
+          $i++;
+        break;
+
+        case PCLZIP_OPT_TEMP_FILE_ON :
+          // ----- Check for incompatible options
+          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
+            return PclZip::errorCode();
+          }
+
+          $v_result_list[$p_options_list[$i]] = true;
+        break;
+
+        case PCLZIP_OPT_TEMP_FILE_OFF :
+          // ----- Check for incompatible options
+          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
+            return PclZip::errorCode();
+          }
+          // ----- Check for incompatible options
+          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
+            return PclZip::errorCode();
+          }
+
+          $v_result_list[$p_options_list[$i]] = true;
+        break;
+
+        case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          if (   is_string($p_options_list[$i+1])
+              && ($p_options_list[$i+1] != '')) {
+            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
+            $i++;
+          }
+          else {
+          }
+        break;
+
+        // ----- Look for options that request an array of string for value
+        case PCLZIP_OPT_BY_NAME :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          if (is_string($p_options_list[$i+1])) {
+              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
+          }
+          else if (is_array($p_options_list[$i+1])) {
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
+          }
+          else {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+          $i++;
+        break;
+
+        // ----- Look for options that request an EREG or PREG expression
+        case PCLZIP_OPT_BY_EREG :
+          // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
+          // to PCLZIP_OPT_BY_PREG
+          $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
+        case PCLZIP_OPT_BY_PREG :
+        //case PCLZIP_OPT_CRYPT :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          if (is_string($p_options_list[$i+1])) {
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
+          }
+          else {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+          $i++;
+        break;
+
+        // ----- Look for options that takes a string
+        case PCLZIP_OPT_COMMENT :
+        case PCLZIP_OPT_ADD_COMMENT :
+        case PCLZIP_OPT_PREPEND_COMMENT :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
+			                     "Missing parameter value for option '"
+								 .PclZipUtilOptionText($p_options_list[$i])
+								 ."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          if (is_string($p_options_list[$i+1])) {
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
+          }
+          else {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
+			                     "Wrong parameter value for option '"
+								 .PclZipUtilOptionText($p_options_list[$i])
+								 ."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+          $i++;
+        break;
+
+        // ----- Look for options that request an array of index
+        case PCLZIP_OPT_BY_INDEX :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_work_list = array();
+          if (is_string($p_options_list[$i+1])) {
+
+              // ----- Remove spaces
+              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
+
+              // ----- Parse items
+              $v_work_list = explode(",", $p_options_list[$i+1]);
+          }
+          else if (is_integer($p_options_list[$i+1])) {
+              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
+          }
+          else if (is_array($p_options_list[$i+1])) {
+              $v_work_list = $p_options_list[$i+1];
+          }
+          else {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Reduce the index list
+          // each index item in the list must be a couple with a start and
+          // an end value : [0,3], [5-5], [8-10], ...
+          // ----- Check the format of each item
+          $v_sort_flag=false;
+          $v_sort_value=0;
+          for ($j=0; $j<sizeof($v_work_list); $j++) {
+              // ----- Explode the item
+              $v_item_list = explode("-", $v_work_list[$j]);
+              $v_size_item_list = sizeof($v_item_list);
+
+              // ----- TBC : Here we might check that each item is a
+              // real integer ...
+
+              // ----- Look for single value
+              if ($v_size_item_list == 1) {
+                  // ----- Set the option value
+                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
+                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
+              }
+              elseif ($v_size_item_list == 2) {
+                  // ----- Set the option value
+                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
+                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
+              }
+              else {
+                  // ----- Error log
+                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+                  // ----- Return
+                  return PclZip::errorCode();
+              }
+
+
+              // ----- Look for list sort
+              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
+                  $v_sort_flag=true;
+
+                  // ----- TBC : An automatic sort should be writen ...
+                  // ----- Error log
+                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+                  // ----- Return
+                  return PclZip::errorCode();
+              }
+              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
+          }
+
+          // ----- Sort the items
+          if ($v_sort_flag) {
+              // TBC : To Be Completed
+          }
+
+          // ----- Next option
+          $i++;
+        break;
+
+        // ----- Look for options that request no value
+        case PCLZIP_OPT_REMOVE_ALL_PATH :
+        case PCLZIP_OPT_EXTRACT_AS_STRING :
+        case PCLZIP_OPT_NO_COMPRESSION :
+        case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
+        case PCLZIP_OPT_REPLACE_NEWER :
+        case PCLZIP_OPT_STOP_ON_ERROR :
+          $v_result_list[$p_options_list[$i]] = true;
+        break;
+
+        // ----- Look for options that request an octal value
+        case PCLZIP_OPT_SET_CHMOD :
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
+          $i++;
+        break;
+
+        // ----- Look for options that request a call-back
+        case PCLZIP_CB_PRE_EXTRACT :
+        case PCLZIP_CB_POST_EXTRACT :
+        case PCLZIP_CB_PRE_ADD :
+        case PCLZIP_CB_POST_ADD :
+        /* for futur use
+        case PCLZIP_CB_PRE_DELETE :
+        case PCLZIP_CB_POST_DELETE :
+        case PCLZIP_CB_PRE_LIST :
+        case PCLZIP_CB_POST_LIST :
+        */
+          // ----- Check the number of parameters
+          if (($i+1) >= $p_size) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Get the value
+          $v_function_name = $p_options_list[$i+1];
+
+          // ----- Check that the value is a valid existing function
+          if (!function_exists($v_function_name)) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+
+          // ----- Set the attribute
+          $v_result_list[$p_options_list[$i]] = $v_function_name;
+          $i++;
+        break;
+
+        default :
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
+		                       "Unknown parameter '"
+							   .$p_options_list[$i]."'");
+
+          // ----- Return
+          return PclZip::errorCode();
+      }
+
+      // ----- Next options
+      $i++;
+    }
+
+    // ----- Look for mandatory options
+    if ($v_requested_options !== false) {
+      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
+        // ----- Look for mandatory option
+        if ($v_requested_options[$key] == 'mandatory') {
+          // ----- Look if present
+          if (!isset($v_result_list[$key])) {
+            // ----- Error log
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
+
+            // ----- Return
+            return PclZip::errorCode();
+          }
+        }
+      }
+    }
+
+    // ----- Look for default values
+    if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
+
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privOptionDefaultThreshold()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privOptionDefaultThreshold(&$p_options)
+  {
+    $v_result=1;
+
+    if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
+        || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
+      return $v_result;
+    }
+
+    // ----- Get 'memory_limit' configuration value
+    $v_memory_limit = ini_get('memory_limit');
+    $v_memory_limit = trim($v_memory_limit);
+    $last = strtolower(substr($v_memory_limit, -1));
+
+    if($last == 'g')
+        //$v_memory_limit = $v_memory_limit*1024*1024*1024;
+        $v_memory_limit = $v_memory_limit*1073741824;
+    if($last == 'm')
+        //$v_memory_limit = $v_memory_limit*1024*1024;
+        $v_memory_limit = $v_memory_limit*1048576;
+    if($last == 'k')
+        $v_memory_limit = $v_memory_limit*1024;
+
+    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
+
+
+    // ----- Sanity check : No threshold if value lower than 1M
+    if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
+      unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privFileDescrParseAtt()
+  // Description :
+  // Parameters :
+  // Return Values :
+  //   1 on success.
+  //   0 on failure.
+  // --------------------------------------------------------------------------------
+  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
+  {
+    $v_result=1;
+
+    // ----- For each file in the list check the attributes
+    foreach ($p_file_list as $v_key => $v_value) {
+
+      // ----- Check if the option is supported
+      if (!isset($v_requested_options[$v_key])) {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
+
+        // ----- Return
+        return PclZip::errorCode();
+      }
+
+      // ----- Look for attribute
+      switch ($v_key) {
+        case PCLZIP_ATT_FILE_NAME :
+          if (!is_string($v_value)) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+
+          $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
+
+          if ($p_filedescr['filename'] == '') {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+
+        break;
+
+        case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
+          if (!is_string($v_value)) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+
+          $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
+
+          if ($p_filedescr['new_short_name'] == '') {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+        break;
+
+        case PCLZIP_ATT_FILE_NEW_FULL_NAME :
+          if (!is_string($v_value)) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+
+          $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
+
+          if ($p_filedescr['new_full_name'] == '') {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+        break;
+
+        // ----- Look for options that takes a string
+        case PCLZIP_ATT_FILE_COMMENT :
+          if (!is_string($v_value)) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+
+          $p_filedescr['comment'] = $v_value;
+        break;
+
+        case PCLZIP_ATT_FILE_MTIME :
+          if (!is_integer($v_value)) {
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
+            return PclZip::errorCode();
+          }
+
+          $p_filedescr['mtime'] = $v_value;
+        break;
+
+        case PCLZIP_ATT_FILE_CONTENT :
+          $p_filedescr['content'] = $v_value;
+        break;
+
+        default :
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
+		                           "Unknown parameter '".$v_key."'");
+
+          // ----- Return
+          return PclZip::errorCode();
+      }
+
+      // ----- Look for mandatory options
+      if ($v_requested_options !== false) {
+        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
+          // ----- Look for mandatory option
+          if ($v_requested_options[$key] == 'mandatory') {
+            // ----- Look if present
+            if (!isset($p_file_list[$key])) {
+              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
+              return PclZip::errorCode();
+            }
+          }
+        }
+      }
+
+    // end foreach
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privFileDescrExpand()
+  // Description :
+  //   This method look for each item of the list to see if its a file, a folder
+  //   or a string to be added as file. For any other type of files (link, other)
+  //   just ignore the item.
+  //   Then prepare the information that will be stored for that file.
+  //   When its a folder, expand the folder with all the files that are in that
+  //   folder (recursively).
+  // Parameters :
+  // Return Values :
+  //   1 on success.
+  //   0 on failure.
+  // --------------------------------------------------------------------------------
+  function privFileDescrExpand(&$p_filedescr_list, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Create a result list
+    $v_result_list = array();
+
+    // ----- Look each entry
+    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
+
+      // ----- Get filedescr
+      $v_descr = $p_filedescr_list[$i];
+
+      // ----- Reduce the filename
+      $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
+      $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
+
+      // ----- Look for real file or folder
+      if (file_exists($v_descr['filename'])) {
+        if (@is_file($v_descr['filename'])) {
+          $v_descr['type'] = 'file';
+        }
+        else if (@is_dir($v_descr['filename'])) {
+          $v_descr['type'] = 'folder';
+        }
+        else if (@is_link($v_descr['filename'])) {
+          // skip
+          continue;
+        }
+        else {
+          // skip
+          continue;
+        }
+      }
+
+      // ----- Look for string added as file
+      else if (isset($v_descr['content'])) {
+        $v_descr['type'] = 'virtual_file';
+      }
+
+      // ----- Missing file
+      else {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
+
+        // ----- Return
+        return PclZip::errorCode();
+      }
+
+      // ----- Calculate the stored filename
+      $this->privCalculateStoredFilename($v_descr, $p_options);
+
+      // ----- Add the descriptor in result list
+      $v_result_list[sizeof($v_result_list)] = $v_descr;
+
+      // ----- Look for folder
+      if ($v_descr['type'] == 'folder') {
+        // ----- List of items in folder
+        $v_dirlist_descr = array();
+        $v_dirlist_nb = 0;
+        if ($v_folder_handler = @opendir($v_descr['filename'])) {
+          while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
+
+            // ----- Skip '.' and '..'
+            if (($v_item_handler == '.') || ($v_item_handler == '..')) {
+                continue;
+            }
+
+            // ----- Compose the full filename
+            $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
+
+            // ----- Look for different stored filename
+            // Because the name of the folder was changed, the name of the
+            // files/sub-folders also change
+            if (($v_descr['stored_filename'] != $v_descr['filename'])
+                 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
+              if ($v_descr['stored_filename'] != '') {
+                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
+              }
+              else {
+                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
+              }
+            }
+
+            $v_dirlist_nb++;
+          }
+
+          @closedir($v_folder_handler);
+        }
+        else {
+          // TBC : unable to open folder in read mode
+        }
+
+        // ----- Expand each element of the list
+        if ($v_dirlist_nb != 0) {
+          // ----- Expand
+          if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
+            return $v_result;
+          }
+
+          // ----- Concat the resulting list
+          $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
+        }
+        else {
+        }
+
+        // ----- Free local array
+        unset($v_dirlist_descr);
+      }
+    }
+
+    // ----- Get the result list
+    $p_filedescr_list = $v_result_list;
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privCreate()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
+  {
+    $v_result=1;
+    $v_list_detail = array();
+
+    // ----- Magic quotes trick
+    $this->privDisableMagicQuotes();
+
+    // ----- Open the file in write mode
+    if (($v_result = $this->privOpenFd('wb')) != 1)
+    {
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Add the list of files
+    $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
+
+    // ----- Close
+    $this->privCloseFd();
+
+    // ----- Magic quotes trick
+    $this->privSwapBackMagicQuotes();
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAdd()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
+  {
+    $v_result=1;
+    $v_list_detail = array();
+
+    // ----- Look if the archive exists or is empty
+    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
+    {
+
+      // ----- Do a create
+      $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
+
+      // ----- Return
+      return $v_result;
+    }
+    // ----- Magic quotes trick
+    $this->privDisableMagicQuotes();
+
+    // ----- Open the zip file
+    if (($v_result=$this->privOpenFd('rb')) != 1)
+    {
+      // ----- Magic quotes trick
+      $this->privSwapBackMagicQuotes();
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      $this->privCloseFd();
+      $this->privSwapBackMagicQuotes();
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    @rewind($this->zip_fd);
+
+    // ----- Creates a temporay file
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
+
+    // ----- Open the temporary file in write mode
+    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
+    {
+      $this->privCloseFd();
+      $this->privSwapBackMagicQuotes();
+
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Copy the files from the archive to the temporary file
+    // TBC : Here I should better append the file and go back to erase the central dir
+    $v_size = $v_central_dir['offset'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = fread($this->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Swap the file descriptor
+    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
+    // the following methods on the temporary fil and not the real archive
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Add the files
+    $v_header_list = array();
+    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
+    {
+      fclose($v_zip_temp_fd);
+      $this->privCloseFd();
+      @unlink($v_zip_temp_name);
+      $this->privSwapBackMagicQuotes();
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Store the offset of the central dir
+    $v_offset = @ftell($this->zip_fd);
+
+    // ----- Copy the block of file headers from the old archive
+    $v_size = $v_central_dir['size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
+      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Create the Central Dir files header
+    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
+    {
+      // ----- Create the file header
+      if ($v_header_list[$i]['status'] == 'ok') {
+        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
+          fclose($v_zip_temp_fd);
+          $this->privCloseFd();
+          @unlink($v_zip_temp_name);
+          $this->privSwapBackMagicQuotes();
+
+          // ----- Return
+          return $v_result;
+        }
+        $v_count++;
+      }
+
+      // ----- Transform the header to a 'usable' info
+      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+    }
+
+    // ----- Zip file comment
+    $v_comment = $v_central_dir['comment'];
+    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
+      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
+    }
+    if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
+      $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
+    }
+    if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
+      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
+    }
+
+    // ----- Calculate the size of the central header
+    $v_size = @ftell($this->zip_fd)-$v_offset;
+
+    // ----- Create the central dir footer
+    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
+    {
+      // ----- Reset the file list
+      unset($v_header_list);
+      $this->privSwapBackMagicQuotes();
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Swap back the file descriptor
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Close
+    $this->privCloseFd();
+
+    // ----- Close the temporary file
+    @fclose($v_zip_temp_fd);
+
+    // ----- Magic quotes trick
+    $this->privSwapBackMagicQuotes();
+
+    // ----- Delete the zip file
+    // TBC : I should test the result ...
+    @unlink($this->zipname);
+
+    // ----- Rename the temporary file
+    // TBC : I should test the result ...
+    //@rename($v_zip_temp_name, $this->zipname);
+    PclZipUtilRename($v_zip_temp_name, $this->zipname);
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privOpenFd()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privOpenFd($p_mode)
+  {
+    $v_result=1;
+
+    // ----- Look if already open
+    if ($this->zip_fd != 0)
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Open the zip file
+    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privCloseFd()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privCloseFd()
+  {
+    $v_result=1;
+
+    if ($this->zip_fd != 0)
+      @fclose($this->zip_fd);
+    $this->zip_fd = 0;
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAddList()
+  // Description :
+  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
+  //   different from the real path of the file. This is usefull if you want to have PclTar
+  //   running in any directory, and memorize relative path from an other directory.
+  // Parameters :
+  //   $p_list : An array containing the file or directory names to add in the tar
+  //   $p_result_list : list of added files with their properties (specially the status field)
+  //   $p_add_dir : Path to add in the filename path archived
+  //   $p_remove_dir : Path to remove in the filename path archived
+  // Return Values :
+  // --------------------------------------------------------------------------------
+//  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
+  function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Add the files
+    $v_header_list = array();
+    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
+    {
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Store the offset of the central dir
+    $v_offset = @ftell($this->zip_fd);
+
+    // ----- Create the Central Dir files header
+    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
+    {
+      // ----- Create the file header
+      if ($v_header_list[$i]['status'] == 'ok') {
+        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
+          // ----- Return
+          return $v_result;
+        }
+        $v_count++;
+      }
+
+      // ----- Transform the header to a 'usable' info
+      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+    }
+
+    // ----- Zip file comment
+    $v_comment = '';
+    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
+      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
+    }
+
+    // ----- Calculate the size of the central header
+    $v_size = @ftell($this->zip_fd)-$v_offset;
+
+    // ----- Create the central dir footer
+    if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
+    {
+      // ----- Reset the file list
+      unset($v_header_list);
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAddFileList()
+  // Description :
+  // Parameters :
+  //   $p_filedescr_list : An array containing the file description
+  //                      or directory names to add in the zip
+  //   $p_result_list : list of added files with their properties (specially the status field)
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
+  {
+    $v_result=1;
+    $v_header = array();
+
+    // ----- Recuperate the current number of elt in list
+    $v_nb = sizeof($p_result_list);
+
+    // ----- Loop on the files
+    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
+      // ----- Format the filename
+      $p_filedescr_list[$j]['filename']
+      = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
+
+
+      // ----- Skip empty file names
+      // TBC : Can this be possible ? not checked in DescrParseAtt ?
+      if ($p_filedescr_list[$j]['filename'] == "") {
+        continue;
+      }
+
+      // ----- Check the filename
+      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
+          && (!file_exists($p_filedescr_list[$j]['filename']))) {
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
+        return PclZip::errorCode();
+      }
+
+      // ----- Look if it is a file or a dir with no all path remove option
+      // or a dir with all its path removed
+//      if (   (is_file($p_filedescr_list[$j]['filename']))
+//          || (   is_dir($p_filedescr_list[$j]['filename'])
+      if (   ($p_filedescr_list[$j]['type'] == 'file')
+          || ($p_filedescr_list[$j]['type'] == 'virtual_file')
+          || (   ($p_filedescr_list[$j]['type'] == 'folder')
+              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
+                  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
+          ) {
+
+        // ----- Add the file
+        $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
+                                       $p_options);
+        if ($v_result != 1) {
+          return $v_result;
+        }
+
+        // ----- Store the file infos
+        $p_result_list[$v_nb++] = $v_header;
+      }
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAddFile()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAddFile($p_filedescr, &$p_header, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Working variable
+    $p_filename = $p_filedescr['filename'];
+
+    // TBC : Already done in the fileAtt check ... ?
+    if ($p_filename == "") {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Look for a stored different filename
+    /* TBC : Removed
+    if (isset($p_filedescr['stored_filename'])) {
+      $v_stored_filename = $p_filedescr['stored_filename'];
+    }
+    else {
+      $v_stored_filename = $p_filedescr['stored_filename'];
+    }
+    */
+
+    // ----- Set the file properties
+    clearstatcache();
+    $p_header['version'] = 20;
+    $p_header['version_extracted'] = 10;
+    $p_header['flag'] = 0;
+    $p_header['compression'] = 0;
+    $p_header['crc'] = 0;
+    $p_header['compressed_size'] = 0;
+    $p_header['filename_len'] = strlen($p_filename);
+    $p_header['extra_len'] = 0;
+    $p_header['disk'] = 0;
+    $p_header['internal'] = 0;
+    $p_header['offset'] = 0;
+    $p_header['filename'] = $p_filename;
+// TBC : Removed    $p_header['stored_filename'] = $v_stored_filename;
+    $p_header['stored_filename'] = $p_filedescr['stored_filename'];
+    $p_header['extra'] = '';
+    $p_header['status'] = 'ok';
+    $p_header['index'] = -1;
+
+    // ----- Look for regular file
+    if ($p_filedescr['type']=='file') {
+      $p_header['external'] = 0x00000000;
+      $p_header['size'] = filesize($p_filename);
+    }
+
+    // ----- Look for regular folder
+    else if ($p_filedescr['type']=='folder') {
+      $p_header['external'] = 0x00000010;
+      $p_header['mtime'] = filemtime($p_filename);
+      $p_header['size'] = filesize($p_filename);
+    }
+
+    // ----- Look for virtual file
+    else if ($p_filedescr['type'] == 'virtual_file') {
+      $p_header['external'] = 0x00000000;
+      $p_header['size'] = strlen($p_filedescr['content']);
+    }
+
+
+    // ----- Look for filetime
+    if (isset($p_filedescr['mtime'])) {
+      $p_header['mtime'] = $p_filedescr['mtime'];
+    }
+    else if ($p_filedescr['type'] == 'virtual_file') {
+      $p_header['mtime'] = time();
+    }
+    else {
+      $p_header['mtime'] = filemtime($p_filename);
+    }
+
+    // ------ Look for file comment
+    if (isset($p_filedescr['comment'])) {
+      $p_header['comment_len'] = strlen($p_filedescr['comment']);
+      $p_header['comment'] = $p_filedescr['comment'];
+    }
+    else {
+      $p_header['comment_len'] = 0;
+      $p_header['comment'] = '';
+    }
+
+    // ----- Look for pre-add callback
+    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
+      if ($v_result == 0) {
+        // ----- Change the file status
+        $p_header['status'] = "skipped";
+        $v_result = 1;
+      }
+
+      // ----- Update the informations
+      // Only some fields can be modified
+      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
+        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
+      }
+    }
+
+    // ----- Look for empty stored filename
+    if ($p_header['stored_filename'] == "") {
+      $p_header['status'] = "filtered";
+    }
+
+    // ----- Check the path length
+    if (strlen($p_header['stored_filename']) > 0xFF) {
+      $p_header['status'] = 'filename_too_long';
+    }
+
+    // ----- Look if no error, or file not skipped
+    if ($p_header['status'] == 'ok') {
+
+      // ----- Look for a file
+      if ($p_filedescr['type'] == 'file') {
+        // ----- Look for using temporary file to zip
+        if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
+            && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
+                || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
+                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
+          $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
+          if ($v_result < PCLZIP_ERR_NO_ERROR) {
+            return $v_result;
+          }
+        }
+
+        // ----- Use "in memory" zip algo
+        else {
+
+        // ----- Open the source file
+        if (($v_file = @fopen($p_filename, "rb")) == 0) {
+          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
+          return PclZip::errorCode();
+        }
+
+        // ----- Read the file content
+        $v_content = @fread($v_file, $p_header['size']);
+
+        // ----- Close the file
+        @fclose($v_file);
+
+        // ----- Calculate the CRC
+        $p_header['crc'] = @crc32($v_content);
+
+        // ----- Look for no compression
+        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
+          // ----- Set header parameters
+          $p_header['compressed_size'] = $p_header['size'];
+          $p_header['compression'] = 0;
+        }
+
+        // ----- Look for normal compression
+        else {
+          // ----- Compress the content
+          $v_content = @gzdeflate($v_content);
+
+          // ----- Set header parameters
+          $p_header['compressed_size'] = strlen($v_content);
+          $p_header['compression'] = 8;
+        }
+
+        // ----- Call the header generation
+        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+          @fclose($v_file);
+          return $v_result;
+        }
+
+        // ----- Write the compressed (or not) content
+        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
+
+        }
+
+      }
+
+      // ----- Look for a virtual file (a file from string)
+      else if ($p_filedescr['type'] == 'virtual_file') {
+
+        $v_content = $p_filedescr['content'];
+
+        // ----- Calculate the CRC
+        $p_header['crc'] = @crc32($v_content);
+
+        // ----- Look for no compression
+        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
+          // ----- Set header parameters
+          $p_header['compressed_size'] = $p_header['size'];
+          $p_header['compression'] = 0;
+        }
+
+        // ----- Look for normal compression
+        else {
+          // ----- Compress the content
+          $v_content = @gzdeflate($v_content);
+
+          // ----- Set header parameters
+          $p_header['compressed_size'] = strlen($v_content);
+          $p_header['compression'] = 8;
+        }
+
+        // ----- Call the header generation
+        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+          @fclose($v_file);
+          return $v_result;
+        }
+
+        // ----- Write the compressed (or not) content
+        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
+      }
+
+      // ----- Look for a directory
+      else if ($p_filedescr['type'] == 'folder') {
+        // ----- Look for directory last '/'
+        if (@substr($p_header['stored_filename'], -1) != '/') {
+          $p_header['stored_filename'] .= '/';
+        }
+
+        // ----- Set the file properties
+        $p_header['size'] = 0;
+        //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
+        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
+
+        // ----- Call the header generation
+        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
+        {
+          return $v_result;
+        }
+      }
+    }
+
+    // ----- Look for post-add callback
+    if (isset($p_options[PCLZIP_CB_POST_ADD])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
+      if ($v_result == 0) {
+        // ----- Ignored
+        $v_result = 1;
+      }
+
+      // ----- Update the informations
+      // Nothing can be modified
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privAddFileUsingTempFile()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
+  {
+    $v_result=PCLZIP_ERR_NO_ERROR;
+
+    // ----- Working variable
+    $p_filename = $p_filedescr['filename'];
+
+
+    // ----- Open the source file
+    if (($v_file = @fopen($p_filename, "rb")) == 0) {
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
+      return PclZip::errorCode();
+    }
+
+    // ----- Creates a compressed temporary file
+    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
+    if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
+      fclose($v_file);
+      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+    $v_size = filesize($p_filename);
+    while ($v_size != 0) {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = @fread($v_file, $v_read_size);
+      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+      @gzputs($v_file_compressed, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Close the file
+    @fclose($v_file);
+    @gzclose($v_file_compressed);
+
+    // ----- Check the minimum file size
+    if (filesize($v_gzip_temp_name) < 18) {
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
+      return PclZip::errorCode();
+    }
+
+    // ----- Extract the compressed attributes
+    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the gzip file header
+    $v_binary_data = @fread($v_file_compressed, 10);
+    $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
+
+    // ----- Check some parameters
+    $v_data_header['os'] = bin2hex($v_data_header['os']);
+
+    // ----- Read the gzip file footer
+    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
+    $v_binary_data = @fread($v_file_compressed, 8);
+    $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
+
+    // ----- Set the attributes
+    $p_header['compression'] = ord($v_data_header['cm']);
+    //$p_header['mtime'] = $v_data_header['mtime'];
+    $p_header['crc'] = $v_data_footer['crc'];
+    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
+
+    // ----- Close the file
+    @fclose($v_file_compressed);
+
+    // ----- Call the header generation
+    if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+      return $v_result;
+    }
+
+    // ----- Add the compressed data
+    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
+    {
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+    fseek($v_file_compressed, 10);
+    $v_size = $p_header['compressed_size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = @fread($v_file_compressed, $v_read_size);
+      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Close the file
+    @fclose($v_file_compressed);
+
+    // ----- Unlink the temporary file
+    @unlink($v_gzip_temp_name);
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privCalculateStoredFilename()
+  // Description :
+  //   Based on file descriptor properties and global options, this method
+  //   calculate the filename that will be stored in the archive.
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privCalculateStoredFilename(&$p_filedescr, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Working variables
+    $p_filename = $p_filedescr['filename'];
+    if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
+      $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
+    }
+    else {
+      $p_add_dir = '';
+    }
+    if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
+      $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
+    }
+    else {
+      $p_remove_dir = '';
+    }
+    if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+    }
+    else {
+      $p_remove_all_dir = 0;
+    }
+
+
+    // ----- Look for full name change
+    if (isset($p_filedescr['new_full_name'])) {
+      // ----- Remove drive letter if any
+      $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
+    }
+
+    // ----- Look for path and/or short name change
+    else {
+
+      // ----- Look for short name change
+      // Its when we cahnge just the filename but not the path
+      if (isset($p_filedescr['new_short_name'])) {
+        $v_path_info = pathinfo($p_filename);
+        $v_dir = '';
+        if ($v_path_info['dirname'] != '') {
+          $v_dir = $v_path_info['dirname'].'/';
+        }
+        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
+      }
+      else {
+        // ----- Calculate the stored filename
+        $v_stored_filename = $p_filename;
+      }
+
+      // ----- Look for all path to remove
+      if ($p_remove_all_dir) {
+        $v_stored_filename = basename($p_filename);
+      }
+      // ----- Look for partial path remove
+      else if ($p_remove_dir != "") {
+        if (substr($p_remove_dir, -1) != '/')
+          $p_remove_dir .= "/";
+
+        if (   (substr($p_filename, 0, 2) == "./")
+            || (substr($p_remove_dir, 0, 2) == "./")) {
+
+          if (   (substr($p_filename, 0, 2) == "./")
+              && (substr($p_remove_dir, 0, 2) != "./")) {
+            $p_remove_dir = "./".$p_remove_dir;
+          }
+          if (   (substr($p_filename, 0, 2) != "./")
+              && (substr($p_remove_dir, 0, 2) == "./")) {
+            $p_remove_dir = substr($p_remove_dir, 2);
+          }
+        }
+
+        $v_compare = PclZipUtilPathInclusion($p_remove_dir,
+                                             $v_stored_filename);
+        if ($v_compare > 0) {
+          if ($v_compare == 2) {
+            $v_stored_filename = "";
+          }
+          else {
+            $v_stored_filename = substr($v_stored_filename,
+                                        strlen($p_remove_dir));
+          }
+        }
+      }
+
+      // ----- Remove drive letter if any
+      $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
+
+      // ----- Look for path to add
+      if ($p_add_dir != "") {
+        if (substr($p_add_dir, -1) == "/")
+          $v_stored_filename = $p_add_dir.$v_stored_filename;
+        else
+          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
+      }
+    }
+
+    // ----- Filename (reduce the path of stored name)
+    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
+    $p_filedescr['stored_filename'] = $v_stored_filename;
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privWriteFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privWriteFileHeader(&$p_header)
+  {
+    $v_result=1;
+
+    // ----- Store the offset position of the file
+    $p_header['offset'] = ftell($this->zip_fd);
+
+    // ----- Transform UNIX mtime to DOS format mdate/mtime
+    $v_date = getdate($p_header['mtime']);
+    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
+    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
+
+    // ----- Packed data
+    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
+	                      $p_header['version_extracted'], $p_header['flag'],
+                          $p_header['compression'], $v_mtime, $v_mdate,
+                          $p_header['crc'], $p_header['compressed_size'],
+						  $p_header['size'],
+                          strlen($p_header['stored_filename']),
+						  $p_header['extra_len']);
+
+    // ----- Write the first 148 bytes of the header in the archive
+    fputs($this->zip_fd, $v_binary_data, 30);
+
+    // ----- Write the variable fields
+    if (strlen($p_header['stored_filename']) != 0)
+    {
+      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
+    }
+    if ($p_header['extra_len'] != 0)
+    {
+      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privWriteCentralFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privWriteCentralFileHeader(&$p_header)
+  {
+    $v_result=1;
+
+    // TBC
+    //for(reset($p_header); $key = key($p_header); next($p_header)) {
+    //}
+
+    // ----- Transform UNIX mtime to DOS format mdate/mtime
+    $v_date = getdate($p_header['mtime']);
+    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
+    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
+
+
+    // ----- Packed data
+    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
+	                      $p_header['version'], $p_header['version_extracted'],
+                          $p_header['flag'], $p_header['compression'],
+						  $v_mtime, $v_mdate, $p_header['crc'],
+                          $p_header['compressed_size'], $p_header['size'],
+                          strlen($p_header['stored_filename']),
+						  $p_header['extra_len'], $p_header['comment_len'],
+                          $p_header['disk'], $p_header['internal'],
+						  $p_header['external'], $p_header['offset']);
+
+    // ----- Write the 42 bytes of the header in the zip file
+    fputs($this->zip_fd, $v_binary_data, 46);
+
+    // ----- Write the variable fields
+    if (strlen($p_header['stored_filename']) != 0)
+    {
+      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
+    }
+    if ($p_header['extra_len'] != 0)
+    {
+      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
+    }
+    if ($p_header['comment_len'] != 0)
+    {
+      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privWriteCentralHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
+  {
+    $v_result=1;
+
+    // ----- Packed data
+    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
+	                      $p_nb_entries, $p_size,
+						  $p_offset, strlen($p_comment));
+
+    // ----- Write the 22 bytes of the header in the zip file
+    fputs($this->zip_fd, $v_binary_data, 22);
+
+    // ----- Write the variable fields
+    if (strlen($p_comment) != 0)
+    {
+      fputs($this->zip_fd, $p_comment, strlen($p_comment));
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privList()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privList(&$p_list)
+  {
+    $v_result=1;
+
+    // ----- Magic quotes trick
+    $this->privDisableMagicQuotes();
+
+    // ----- Open the zip file
+    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
+    {
+      // ----- Magic quotes trick
+      $this->privSwapBackMagicQuotes();
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      $this->privSwapBackMagicQuotes();
+      return $v_result;
+    }
+
+    // ----- Go to beginning of Central Dir
+    @rewind($this->zip_fd);
+    if (@fseek($this->zip_fd, $v_central_dir['offset']))
+    {
+      $this->privSwapBackMagicQuotes();
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Read each entry
+    for ($i=0; $i<$v_central_dir['entries']; $i++)
+    {
+      // ----- Read the file header
+      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
+      {
+        $this->privSwapBackMagicQuotes();
+        return $v_result;
+      }
+      $v_header['index'] = $i;
+
+      // ----- Get the only interesting attributes
+      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
+      unset($v_header);
+    }
+
+    // ----- Close the zip file
+    $this->privCloseFd();
+
+    // ----- Magic quotes trick
+    $this->privSwapBackMagicQuotes();
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privConvertHeader2FileInfo()
+  // Description :
+  //   This function takes the file informations from the central directory
+  //   entries and extract the interesting parameters that will be given back.
+  //   The resulting file infos are set in the array $p_info
+  //     $p_info['filename'] : Filename with full path. Given by user (add),
+  //                           extracted in the filesystem (extract).
+  //     $p_info['stored_filename'] : Stored filename in the archive.
+  //     $p_info['size'] = Size of the file.
+  //     $p_info['compressed_size'] = Compressed size of the file.
+  //     $p_info['mtime'] = Last modification date of the file.
+  //     $p_info['comment'] = Comment associated with the file.
+  //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.
+  //     $p_info['status'] = status of the action on the file.
+  //     $p_info['crc'] = CRC of the file content.
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privConvertHeader2FileInfo($p_header, &$p_info)
+  {
+    $v_result=1;
+
+    // ----- Get the interesting attributes
+    $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
+    $p_info['filename'] = $v_temp_path;
+    $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
+    $p_info['stored_filename'] = $v_temp_path;
+    $p_info['size'] = $p_header['size'];
+    $p_info['compressed_size'] = $p_header['compressed_size'];
+    $p_info['mtime'] = $p_header['mtime'];
+    $p_info['comment'] = $p_header['comment'];
+    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
+    $p_info['index'] = $p_header['index'];
+    $p_info['status'] = $p_header['status'];
+    $p_info['crc'] = $p_header['crc'];
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractByRule()
+  // Description :
+  //   Extract a file or directory depending of rules (by index, by name, ...)
+  // Parameters :
+  //   $p_file_list : An array where will be placed the properties of each
+  //                  extracted file
+  //   $p_path : Path to add while writing the extracted files
+  //   $p_remove_path : Path to remove (from the file memorized path) while writing the
+  //                    extracted files. If the path does not match the file path,
+  //                    the file is extracted with its memorized path.
+  //                    $p_remove_path does not apply to 'list' mode.
+  //                    $p_path and $p_remove_path are commulative.
+  // Return Values :
+  //   1 on success,0 or less on error (see error code list)
+  // --------------------------------------------------------------------------------
+  function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Magic quotes trick
+    $this->privDisableMagicQuotes();
+
+    // ----- Check the path
+    if (   ($p_path == "")
+	    || (   (substr($p_path, 0, 1) != "/")
+		    && (substr($p_path, 0, 3) != "../")
+			&& (substr($p_path,1,2)!=":/")))
+      $p_path = "./".$p_path;
+
+    // ----- Reduce the path last (and duplicated) '/'
+    if (($p_path != "./") && ($p_path != "/"))
+    {
+      // ----- Look for the path end '/'
+      while (substr($p_path, -1) == "/")
+      {
+        $p_path = substr($p_path, 0, strlen($p_path)-1);
+      }
+    }
+
+    // ----- Look for path to remove format (should end by /)
+    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
+    {
+      $p_remove_path .= '/';
+    }
+    $p_remove_path_size = strlen($p_remove_path);
+
+    // ----- Open the zip file
+    if (($v_result = $this->privOpenFd('rb')) != 1)
+    {
+      $this->privSwapBackMagicQuotes();
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      // ----- Close the zip file
+      $this->privCloseFd();
+      $this->privSwapBackMagicQuotes();
+
+      return $v_result;
+    }
+
+    // ----- Start at beginning of Central Dir
+    $v_pos_entry = $v_central_dir['offset'];
+
+    // ----- Read each entry
+    $j_start = 0;
+    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
+    {
+
+      // ----- Read next Central dir entry
+      @rewind($this->zip_fd);
+      if (@fseek($this->zip_fd, $v_pos_entry))
+      {
+        // ----- Close the zip file
+        $this->privCloseFd();
+        $this->privSwapBackMagicQuotes();
+
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+        // ----- Return
+        return PclZip::errorCode();
+      }
+
+      // ----- Read the file header
+      $v_header = array();
+      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
+      {
+        // ----- Close the zip file
+        $this->privCloseFd();
+        $this->privSwapBackMagicQuotes();
+
+        return $v_result;
+      }
+
+      // ----- Store the index
+      $v_header['index'] = $i;
+
+      // ----- Store the file position
+      $v_pos_entry = ftell($this->zip_fd);
+
+      // ----- Look for the specific extract rules
+      $v_extract = false;
+
+      // ----- Look for extract by name rule
+      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
+          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
+
+          // ----- Look if the filename is in the list
+          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
+
+              // ----- Look for a directory
+              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
+
+                  // ----- Look if the directory is in the filename path
+                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
+                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+                      $v_extract = true;
+                  }
+              }
+              // ----- Look for a filename
+              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
+                  $v_extract = true;
+              }
+          }
+      }
+
+      // ----- Look for extract by ereg rule
+      // ereg() is deprecated with PHP 5.3
+      /*
+      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
+               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
+
+          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
+              $v_extract = true;
+          }
+      }
+      */
+
+      // ----- Look for extract by preg rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
+               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
+
+          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
+              $v_extract = true;
+          }
+      }
+
+      // ----- Look for extract by index rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
+               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
+
+          // ----- Look if the index is in the list
+          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
+
+              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
+                  $v_extract = true;
+              }
+              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
+                  $j_start = $j+1;
+              }
+
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
+                  break;
+              }
+          }
+      }
+
+      // ----- Look for no rule, which means extract all the archive
+      else {
+          $v_extract = true;
+      }
+
+	  // ----- Check compression method
+	  if (   ($v_extract)
+	      && (   ($v_header['compression'] != 8)
+		      && ($v_header['compression'] != 0))) {
+          $v_header['status'] = 'unsupported_compression';
+
+          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
+
+              $this->privSwapBackMagicQuotes();
+
+              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
+			                       "Filename '".$v_header['stored_filename']."' is "
+				  	    	  	   ."compressed by an unsupported compression "
+				  	    	  	   ."method (".$v_header['compression'].") ");
+
+              return PclZip::errorCode();
+		  }
+	  }
+
+	  // ----- Check encrypted files
+	  if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
+          $v_header['status'] = 'unsupported_encryption';
+
+          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
+
+              $this->privSwapBackMagicQuotes();
+
+              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
+			                       "Unsupported encryption for "
+				  	    	  	   ." filename '".$v_header['stored_filename']
+								   ."'");
+
+              return PclZip::errorCode();
+		  }
+    }
+
+      // ----- Look for real extraction
+      if (($v_extract) && ($v_header['status'] != 'ok')) {
+          $v_result = $this->privConvertHeader2FileInfo($v_header,
+		                                        $p_file_list[$v_nb_extracted++]);
+          if ($v_result != 1) {
+              $this->privCloseFd();
+              $this->privSwapBackMagicQuotes();
+              return $v_result;
+          }
+
+          $v_extract = false;
+      }
+
+      // ----- Look for real extraction
+      if ($v_extract)
+      {
+
+        // ----- Go to the file position
+        @rewind($this->zip_fd);
+        if (@fseek($this->zip_fd, $v_header['offset']))
+        {
+          // ----- Close the zip file
+          $this->privCloseFd();
+
+          $this->privSwapBackMagicQuotes();
+
+          // ----- Error log
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+          // ----- Return
+          return PclZip::errorCode();
+        }
+
+        // ----- Look for extraction as string
+        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
+
+          $v_string = '';
+
+          // ----- Extracting the file
+          $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
+          if ($v_result1 < 1) {
+            $this->privCloseFd();
+            $this->privSwapBackMagicQuotes();
+            return $v_result1;
+          }
+
+          // ----- Get the only interesting attributes
+          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
+          {
+            // ----- Close the zip file
+            $this->privCloseFd();
+            $this->privSwapBackMagicQuotes();
+
+            return $v_result;
+          }
+
+          // ----- Set the file content
+          $p_file_list[$v_nb_extracted]['content'] = $v_string;
+
+          // ----- Next extracted file
+          $v_nb_extracted++;
+
+          // ----- Look for user callback abort
+          if ($v_result1 == 2) {
+          	break;
+          }
+        }
+        // ----- Look for extraction in standard output
+        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
+		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
+          // ----- Extracting the file in standard output
+          $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
+          if ($v_result1 < 1) {
+            $this->privCloseFd();
+            $this->privSwapBackMagicQuotes();
+            return $v_result1;
+          }
+
+          // ----- Get the only interesting attributes
+          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
+            $this->privCloseFd();
+            $this->privSwapBackMagicQuotes();
+            return $v_result;
+          }
+
+          // ----- Look for user callback abort
+          if ($v_result1 == 2) {
+          	break;
+          }
+        }
+        // ----- Look for normal extraction
+        else {
+          // ----- Extracting the file
+          $v_result1 = $this->privExtractFile($v_header,
+		                                      $p_path, $p_remove_path,
+											  $p_remove_all_path,
+											  $p_options);
+          if ($v_result1 < 1) {
+            $this->privCloseFd();
+            $this->privSwapBackMagicQuotes();
+            return $v_result1;
+          }
+
+          // ----- Get the only interesting attributes
+          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
+          {
+            // ----- Close the zip file
+            $this->privCloseFd();
+            $this->privSwapBackMagicQuotes();
+
+            return $v_result;
+          }
+
+          // ----- Look for user callback abort
+          if ($v_result1 == 2) {
+          	break;
+          }
+        }
+      }
+    }
+
+    // ----- Close the zip file
+    $this->privCloseFd();
+    $this->privSwapBackMagicQuotes();
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractFile()
+  // Description :
+  // Parameters :
+  // Return Values :
+  //
+  // 1 : ... ?
+  // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
+  // --------------------------------------------------------------------------------
+  function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Read the file header
+    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
+    {
+      // ----- Return
+      return $v_result;
+    }
+
+
+    // ----- Check that the file header is coherent with $p_entry info
+    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
+        // TBC
+    }
+
+    // ----- Look for all path to remove
+    if ($p_remove_all_path == true) {
+        // ----- Look for folder entry that not need to be extracted
+        if (($p_entry['external']&0x00000010)==0x00000010) {
+
+            $p_entry['status'] = "filtered";
+
+            return $v_result;
+        }
+
+        // ----- Get the basename of the path
+        $p_entry['filename'] = basename($p_entry['filename']);
+    }
+
+    // ----- Look for path to remove
+    else if ($p_remove_path != "")
+    {
+      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
+      {
+
+        // ----- Change the file status
+        $p_entry['status'] = "filtered";
+
+        // ----- Return
+        return $v_result;
+      }
+
+      $p_remove_path_size = strlen($p_remove_path);
+      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
+      {
+
+        // ----- Remove the path
+        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
+
+      }
+    }
+
+    // ----- Add the path
+    if ($p_path != '') {
+      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
+    }
+
+    // ----- Check a base_dir_restriction
+    if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
+      $v_inclusion
+      = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
+                                $p_entry['filename']);
+      if ($v_inclusion == 0) {
+
+        PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
+			                     "Filename '".$p_entry['filename']."' is "
+								 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
+
+        return PclZip::errorCode();
+      }
+    }
+
+    // ----- Look for pre-extract callback
+    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
+      if ($v_result == 0) {
+        // ----- Change the file status
+        $p_entry['status'] = "skipped";
+        $v_result = 1;
+      }
+
+      // ----- Look for abort result
+      if ($v_result == 2) {
+        // ----- This status is internal and will be changed in 'skipped'
+        $p_entry['status'] = "aborted";
+      	$v_result = PCLZIP_ERR_USER_ABORTED;
+      }
+
+      // ----- Update the informations
+      // Only some fields can be modified
+      $p_entry['filename'] = $v_local_header['filename'];
+    }
+
+
+    // ----- Look if extraction should be done
+    if ($p_entry['status'] == 'ok') {
+
+    // ----- Look for specific actions while the file exist
+    if (file_exists($p_entry['filename']))
+    {
+
+      // ----- Look if file is a directory
+      if (is_dir($p_entry['filename']))
+      {
+
+        // ----- Change the file status
+        $p_entry['status'] = "already_a_directory";
+
+        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+        // For historical reason first PclZip implementation does not stop
+        // when this kind of error occurs.
+        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
+
+            PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
+			                     "Filename '".$p_entry['filename']."' is "
+								 ."already used by an existing directory");
+
+            return PclZip::errorCode();
+		    }
+      }
+      // ----- Look if file is write protected
+      else if (!is_writeable($p_entry['filename']))
+      {
+
+        // ----- Change the file status
+        $p_entry['status'] = "write_protected";
+
+        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+        // For historical reason first PclZip implementation does not stop
+        // when this kind of error occurs.
+        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
+
+            PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
+			                     "Filename '".$p_entry['filename']."' exists "
+								 ."and is write protected");
+
+            return PclZip::errorCode();
+		    }
+      }
+
+      // ----- Look if the extracted file is older
+      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
+      {
+        // ----- Change the file status
+        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
+		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
+	  	  }
+		    else {
+            $p_entry['status'] = "newer_exist";
+
+            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+            // For historical reason first PclZip implementation does not stop
+            // when this kind of error occurs.
+            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
+		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
+
+                PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
+			             "Newer version of '".$p_entry['filename']."' exists "
+					    ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
+
+                return PclZip::errorCode();
+		      }
+		    }
+      }
+      else {
+      }
+    }
+
+    // ----- Check the directory availability and create it if necessary
+    else {
+      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
+        $v_dir_to_check = $p_entry['filename'];
+      else if (!strstr($p_entry['filename'], "/"))
+        $v_dir_to_check = "";
+      else
+        $v_dir_to_check = dirname($p_entry['filename']);
+
+        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
+
+          // ----- Change the file status
+          $p_entry['status'] = "path_creation_fail";
+
+          // ----- Return
+          //return $v_result;
+          $v_result = 1;
+        }
+      }
+    }
+
+    // ----- Look if extraction should be done
+    if ($p_entry['status'] == 'ok') {
+
+      // ----- Do the extraction (if not a folder)
+      if (!(($p_entry['external']&0x00000010)==0x00000010))
+      {
+        // ----- Look for not compressed file
+        if ($p_entry['compression'] == 0) {
+
+    		  // ----- Opening destination file
+          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
+          {
+
+            // ----- Change the file status
+            $p_entry['status'] = "write_error";
+
+            // ----- Return
+            return $v_result;
+          }
+
+
+          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+          $v_size = $p_entry['compressed_size'];
+          while ($v_size != 0)
+          {
+            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+            $v_buffer = @fread($this->zip_fd, $v_read_size);
+            /* Try to speed up the code
+            $v_binary_data = pack('a'.$v_read_size, $v_buffer);
+            @fwrite($v_dest_file, $v_binary_data, $v_read_size);
+            */
+            @fwrite($v_dest_file, $v_buffer, $v_read_size);
+            $v_size -= $v_read_size;
+          }
+
+          // ----- Closing the destination file
+          fclose($v_dest_file);
+
+          // ----- Change the file mtime
+          touch($p_entry['filename'], $p_entry['mtime']);
+
+
+        }
+        else {
+          // ----- TBC
+          // Need to be finished
+          if (($p_entry['flag'] & 1) == 1) {
+            PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
+            return PclZip::errorCode();
+          }
+
+
+          // ----- Look for using temporary file to unzip
+          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
+              && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
+                  || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
+                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
+            $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
+            if ($v_result < PCLZIP_ERR_NO_ERROR) {
+              return $v_result;
+            }
+          }
+
+          // ----- Look for extract in memory
+          else {
+
+
+            // ----- Read the compressed file in a buffer (one shot)
+            $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+            // ----- Decompress the file
+            $v_file_content = @gzinflate($v_buffer);
+            unset($v_buffer);
+            if ($v_file_content === FALSE) {
+
+              // ----- Change the file status
+              // TBC
+              $p_entry['status'] = "error";
+
+              return $v_result;
+            }
+
+            // ----- Opening destination file
+            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
+
+              // ----- Change the file status
+              $p_entry['status'] = "write_error";
+
+              return $v_result;
+            }
+
+            // ----- Write the uncompressed data
+            @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
+            unset($v_file_content);
+
+            // ----- Closing the destination file
+            @fclose($v_dest_file);
+
+          }
+
+          // ----- Change the file mtime
+          @touch($p_entry['filename'], $p_entry['mtime']);
+        }
+
+        // ----- Look for chmod option
+        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
+
+          // ----- Change the mode of the file
+          @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
+        }
+
+      }
+    }
+
+  	// ----- Change abort status
+  	if ($p_entry['status'] == "aborted") {
+        $p_entry['status'] = "skipped";
+  	}
+
+    // ----- Look for post-extract callback
+    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
+
+      // ----- Look for abort result
+      if ($v_result == 2) {
+      	$v_result = PCLZIP_ERR_USER_ABORTED;
+      }
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractFileUsingTempFile()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privExtractFileUsingTempFile(&$p_entry, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Creates a temporary file
+    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
+    if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
+      fclose($v_file);
+      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
+      return PclZip::errorCode();
+    }
+
+
+    // ----- Write gz file format header
+    $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
+    @fwrite($v_dest_file, $v_binary_data, 10);
+
+    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+    $v_size = $p_entry['compressed_size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = @fread($this->zip_fd, $v_read_size);
+      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+      @fwrite($v_dest_file, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Write gz file format footer
+    $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
+    @fwrite($v_dest_file, $v_binary_data, 8);
+
+    // ----- Close the temporary file
+    @fclose($v_dest_file);
+
+    // ----- Opening destination file
+    if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
+      $p_entry['status'] = "write_error";
+      return $v_result;
+    }
+
+    // ----- Open the temporary gz file
+    if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
+      @fclose($v_dest_file);
+      $p_entry['status'] = "read_error";
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
+      return PclZip::errorCode();
+    }
+
+
+    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+    $v_size = $p_entry['size'];
+    while ($v_size != 0) {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = @gzread($v_src_file, $v_read_size);
+      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+      @fwrite($v_dest_file, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+    @fclose($v_dest_file);
+    @gzclose($v_src_file);
+
+    // ----- Delete the temporary file
+    @unlink($v_gzip_temp_name);
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractFileInOutput()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privExtractFileInOutput(&$p_entry, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Read the file header
+    if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
+      return $v_result;
+    }
+
+
+    // ----- Check that the file header is coherent with $p_entry info
+    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
+        // TBC
+    }
+
+    // ----- Look for pre-extract callback
+    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+//      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
+      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
+      if ($v_result == 0) {
+        // ----- Change the file status
+        $p_entry['status'] = "skipped";
+        $v_result = 1;
+      }
+
+      // ----- Look for abort result
+      if ($v_result == 2) {
+        // ----- This status is internal and will be changed in 'skipped'
+        $p_entry['status'] = "aborted";
+      	$v_result = PCLZIP_ERR_USER_ABORTED;
+      }
+
+      // ----- Update the informations
+      // Only some fields can be modified
+      $p_entry['filename'] = $v_local_header['filename'];
+    }
+
+    // ----- Trace
+
+    // ----- Look if extraction should be done
+    if ($p_entry['status'] == 'ok') {
+
+      // ----- Do the extraction (if not a folder)
+      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
+        // ----- Look for not compressed file
+        if ($p_entry['compressed_size'] == $p_entry['size']) {
+
+          // ----- Read the file in a buffer (one shot)
+          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+          // ----- Send the file to the output
+          echo $v_buffer;
+          unset($v_buffer);
+        }
+        else {
+
+          // ----- Read the compressed file in a buffer (one shot)
+          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+          // ----- Decompress the file
+          $v_file_content = gzinflate($v_buffer);
+          unset($v_buffer);
+
+          // ----- Send the file to the output
+          echo $v_file_content;
+          unset($v_file_content);
+        }
+      }
+    }
+
+	// ----- Change abort status
+	if ($p_entry['status'] == "aborted") {
+      $p_entry['status'] = "skipped";
+	}
+
+    // ----- Look for post-extract callback
+    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
+
+      // ----- Look for abort result
+      if ($v_result == 2) {
+      	$v_result = PCLZIP_ERR_USER_ABORTED;
+      }
+    }
+
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privExtractFileAsString()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
+  {
+    $v_result=1;
+
+    // ----- Read the file header
+    $v_header = array();
+    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
+    {
+      // ----- Return
+      return $v_result;
+    }
+
+
+    // ----- Check that the file header is coherent with $p_entry info
+    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
+        // TBC
+    }
+
+    // ----- Look for pre-extract callback
+    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
+      if ($v_result == 0) {
+        // ----- Change the file status
+        $p_entry['status'] = "skipped";
+        $v_result = 1;
+      }
+
+      // ----- Look for abort result
+      if ($v_result == 2) {
+        // ----- This status is internal and will be changed in 'skipped'
+        $p_entry['status'] = "aborted";
+      	$v_result = PCLZIP_ERR_USER_ABORTED;
+      }
+
+      // ----- Update the informations
+      // Only some fields can be modified
+      $p_entry['filename'] = $v_local_header['filename'];
+    }
+
+
+    // ----- Look if extraction should be done
+    if ($p_entry['status'] == 'ok') {
+
+      // ----- Do the extraction (if not a folder)
+      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
+        // ----- Look for not compressed file
+  //      if ($p_entry['compressed_size'] == $p_entry['size'])
+        if ($p_entry['compression'] == 0) {
+
+          // ----- Reading the file
+          $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
+        }
+        else {
+
+          // ----- Reading the file
+          $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+          // ----- Decompress the file
+          if (($p_string = @gzinflate($v_data)) === FALSE) {
+              // TBC
+          }
+        }
+
+        // ----- Trace
+      }
+      else {
+          // TBC : error : can not extract a folder in a string
+      }
+
+    }
+
+  	// ----- Change abort status
+  	if ($p_entry['status'] == "aborted") {
+        $p_entry['status'] = "skipped";
+  	}
+
+    // ----- Look for post-extract callback
+    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+
+      // ----- Generate a local information
+      $v_local_header = array();
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+      // ----- Swap the content to header
+      $v_local_header['content'] = $p_string;
+      $p_string = '';
+
+      // ----- Call the callback
+      // Here I do not use call_user_func() because I need to send a reference to the
+      // header.
+      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
+
+      // ----- Swap back the content to header
+      $p_string = $v_local_header['content'];
+      unset($v_local_header['content']);
+
+      // ----- Look for abort result
+      if ($v_result == 2) {
+      	$v_result = PCLZIP_ERR_USER_ABORTED;
+      }
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privReadFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privReadFileHeader(&$p_header)
+  {
+    $v_result=1;
+
+    // ----- Read the 4 bytes signature
+    $v_binary_data = @fread($this->zip_fd, 4);
+    $v_data = unpack('Vid', $v_binary_data);
+
+    // ----- Check signature
+    if ($v_data['id'] != 0x04034b50)
+    {
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the first 42 bytes of the header
+    $v_binary_data = fread($this->zip_fd, 26);
+
+    // ----- Look for invalid block size
+    if (strlen($v_binary_data) != 26)
+    {
+      $p_header['filename'] = "";
+      $p_header['status'] = "invalid_header";
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Extract the values
+    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
+
+    // ----- Get filename
+    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
+
+    // ----- Get extra_fields
+    if ($v_data['extra_len'] != 0) {
+      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
+    }
+    else {
+      $p_header['extra'] = '';
+    }
+
+    // ----- Extract properties
+    $p_header['version_extracted'] = $v_data['version'];
+    $p_header['compression'] = $v_data['compression'];
+    $p_header['size'] = $v_data['size'];
+    $p_header['compressed_size'] = $v_data['compressed_size'];
+    $p_header['crc'] = $v_data['crc'];
+    $p_header['flag'] = $v_data['flag'];
+    $p_header['filename_len'] = $v_data['filename_len'];
+
+    // ----- Recuperate date in UNIX format
+    $p_header['mdate'] = $v_data['mdate'];
+    $p_header['mtime'] = $v_data['mtime'];
+    if ($p_header['mdate'] && $p_header['mtime'])
+    {
+      // ----- Extract time
+      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
+      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
+      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
+
+      // ----- Extract date
+      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
+      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
+      $v_day = $p_header['mdate'] & 0x001F;
+
+      // ----- Get UNIX date format
+      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
+
+    }
+    else
+    {
+      $p_header['mtime'] = time();
+    }
+
+    // TBC
+    //for(reset($v_data); $key = key($v_data); next($v_data)) {
+    //}
+
+    // ----- Set the stored filename
+    $p_header['stored_filename'] = $p_header['filename'];
+
+    // ----- Set the status field
+    $p_header['status'] = "ok";
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privReadCentralFileHeader()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privReadCentralFileHeader(&$p_header)
+  {
+    $v_result=1;
+
+    // ----- Read the 4 bytes signature
+    $v_binary_data = @fread($this->zip_fd, 4);
+    $v_data = unpack('Vid', $v_binary_data);
+
+    // ----- Check signature
+    if ($v_data['id'] != 0x02014b50)
+    {
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Read the first 42 bytes of the header
+    $v_binary_data = fread($this->zip_fd, 42);
+
+    // ----- Look for invalid block size
+    if (strlen($v_binary_data) != 42)
+    {
+      $p_header['filename'] = "";
+      $p_header['status'] = "invalid_header";
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Extract the values
+    $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
+
+    // ----- Get filename
+    if ($p_header['filename_len'] != 0)
+      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
+    else
+      $p_header['filename'] = '';
+
+    // ----- Get extra
+    if ($p_header['extra_len'] != 0)
+      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
+    else
+      $p_header['extra'] = '';
+
+    // ----- Get comment
+    if ($p_header['comment_len'] != 0)
+      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
+    else
+      $p_header['comment'] = '';
+
+    // ----- Extract properties
+
+    // ----- Recuperate date in UNIX format
+    //if ($p_header['mdate'] && $p_header['mtime'])
+    // TBC : bug : this was ignoring time with 0/0/0
+    if (1)
+    {
+      // ----- Extract time
+      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
+      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
+      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
+
+      // ----- Extract date
+      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
+      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
+      $v_day = $p_header['mdate'] & 0x001F;
+
+      // ----- Get UNIX date format
+      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
+
+    }
+    else
+    {
+      $p_header['mtime'] = time();
+    }
+
+    // ----- Set the stored filename
+    $p_header['stored_filename'] = $p_header['filename'];
+
+    // ----- Set default status to ok
+    $p_header['status'] = 'ok';
+
+    // ----- Look if it is a directory
+    if (substr($p_header['filename'], -1) == '/') {
+      //$p_header['external'] = 0x41FF0010;
+      $p_header['external'] = 0x00000010;
+    }
+
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privCheckFileHeaders()
+  // Description :
+  // Parameters :
+  // Return Values :
+  //   1 on success,
+  //   0 on error;
+  // --------------------------------------------------------------------------------
+  function privCheckFileHeaders(&$p_local_header, &$p_central_header)
+  {
+    $v_result=1;
+
+  	// ----- Check the static values
+  	// TBC
+  	if ($p_local_header['filename'] != $p_central_header['filename']) {
+  	}
+  	if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
+  	}
+  	if ($p_local_header['flag'] != $p_central_header['flag']) {
+  	}
+  	if ($p_local_header['compression'] != $p_central_header['compression']) {
+  	}
+  	if ($p_local_header['mtime'] != $p_central_header['mtime']) {
+  	}
+  	if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
+  	}
+
+  	// ----- Look for flag bit 3
+  	if (($p_local_header['flag'] & 8) == 8) {
+          $p_local_header['size'] = $p_central_header['size'];
+          $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
+          $p_local_header['crc'] = $p_central_header['crc'];
+  	}
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privReadEndCentralDir()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privReadEndCentralDir(&$p_central_dir)
+  {
+    $v_result=1;
+
+    // ----- Go to the end of the zip file
+    $v_size = filesize($this->zipname);
+    @fseek($this->zip_fd, $v_size);
+    if (@ftell($this->zip_fd) != $v_size)
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- First try : look if this is an archive with no commentaries (most of the time)
+    // in this case the end of central dir is at 22 bytes of the file end
+    $v_found = 0;
+    if ($v_size > 26) {
+      @fseek($this->zip_fd, $v_size-22);
+      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
+      {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
+
+        // ----- Return
+        return PclZip::errorCode();
+      }
+
+      // ----- Read for bytes
+      $v_binary_data = @fread($this->zip_fd, 4);
+      $v_data = @unpack('Vid', $v_binary_data);
+
+      // ----- Check signature
+      if ($v_data['id'] == 0x06054b50) {
+        $v_found = 1;
+      }
+
+      $v_pos = ftell($this->zip_fd);
+    }
+
+    // ----- Go back to the maximum possible size of the Central Dir End Record
+    if (!$v_found) {
+      $v_maximum_size = 65557; // 0xFFFF + 22;
+      if ($v_maximum_size > $v_size)
+        $v_maximum_size = $v_size;
+      @fseek($this->zip_fd, $v_size-$v_maximum_size);
+      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
+      {
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
+
+        // ----- Return
+        return PclZip::errorCode();
+      }
+
+      // ----- Read byte per byte in order to find the signature
+      $v_pos = ftell($this->zip_fd);
+      $v_bytes = 0x00000000;
+      while ($v_pos < $v_size)
+      {
+        // ----- Read a byte
+        $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)
+        {
+          $v_pos++;
+          break;
+        }
+
+        $v_pos++;
+      }
+
+      // ----- Look if not found end of central dir
+      if ($v_pos == $v_size)
+      {
+
+        // ----- Error log
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
+
+        // ----- Return
+        return PclZip::errorCode();
+      }
+    }
+
+    // ----- Read the first 18 bytes of the header
+    $v_binary_data = fread($this->zip_fd, 18);
+
+    // ----- Look for invalid block size
+    if (strlen($v_binary_data) != 18)
+    {
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Extract the values
+    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
+
+    // ----- Check the global size
+    if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
+
+	  // ----- Removed in release 2.2 see readme file
+	  // The check of the file size is a little too strict.
+	  // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
+	  // While decrypted, zip has training 0 bytes
+	  if (0) {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
+	                       'The central dir is not at the end of the archive.'
+						   .' Some trailing bytes exists after the archive.');
+
+      // ----- Return
+      return PclZip::errorCode();
+	  }
+    }
+
+    // ----- Get comment
+    if ($v_data['comment_size'] != 0) {
+      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
+    }
+    else
+      $p_central_dir['comment'] = '';
+
+    $p_central_dir['entries'] = $v_data['entries'];
+    $p_central_dir['disk_entries'] = $v_data['disk_entries'];
+    $p_central_dir['offset'] = $v_data['offset'];
+    $p_central_dir['size'] = $v_data['size'];
+    $p_central_dir['disk'] = $v_data['disk'];
+    $p_central_dir['disk_start'] = $v_data['disk_start'];
+
+    // TBC
+    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
+    //}
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privDeleteByRule()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privDeleteByRule(&$p_result_list, &$p_options)
+  {
+    $v_result=1;
+    $v_list_detail = array();
+
+    // ----- Open the zip file
+    if (($v_result=$this->privOpenFd('rb')) != 1)
+    {
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      $this->privCloseFd();
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    @rewind($this->zip_fd);
+
+    // ----- Scan all the files
+    // ----- Start at beginning of Central Dir
+    $v_pos_entry = $v_central_dir['offset'];
+    @rewind($this->zip_fd);
+    if (@fseek($this->zip_fd, $v_pos_entry))
+    {
+      // ----- Close the zip file
+      $this->privCloseFd();
+
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Read each entry
+    $v_header_list = array();
+    $j_start = 0;
+    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
+    {
+
+      // ----- Read the file header
+      $v_header_list[$v_nb_extracted] = array();
+      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
+      {
+        // ----- Close the zip file
+        $this->privCloseFd();
+
+        return $v_result;
+      }
+
+
+      // ----- Store the index
+      $v_header_list[$v_nb_extracted]['index'] = $i;
+
+      // ----- Look for the specific extract rules
+      $v_found = false;
+
+      // ----- Look for extract by name rule
+      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
+          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
+
+          // ----- Look if the filename is in the list
+          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
+
+              // ----- Look for a directory
+              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
+
+                  // ----- Look if the directory is in the filename path
+                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
+                      && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+                      $v_found = true;
+                  }
+                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
+                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+                      $v_found = true;
+                  }
+              }
+              // ----- Look for a filename
+              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
+                  $v_found = true;
+              }
+          }
+      }
+
+      // ----- Look for extract by ereg rule
+      // ereg() is deprecated with PHP 5.3
+      /*
+      else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
+               && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
+
+          if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
+              $v_found = true;
+          }
+      }
+      */
+
+      // ----- Look for extract by preg rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
+               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
+
+          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
+              $v_found = true;
+          }
+      }
+
+      // ----- Look for extract by index rule
+      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
+               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
+
+          // ----- Look if the index is in the list
+          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
+
+              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
+                  $v_found = true;
+              }
+              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
+                  $j_start = $j+1;
+              }
+
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
+                  break;
+              }
+          }
+      }
+      else {
+      	$v_found = true;
+      }
+
+      // ----- Look for deletion
+      if ($v_found)
+      {
+        unset($v_header_list[$v_nb_extracted]);
+      }
+      else
+      {
+        $v_nb_extracted++;
+      }
+    }
+
+    // ----- Look if something need to be deleted
+    if ($v_nb_extracted > 0) {
+
+        // ----- Creates a temporay file
+        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
+
+        // ----- Creates a temporary zip archive
+        $v_temp_zip = new PclZip($v_zip_temp_name);
+
+        // ----- Open the temporary zip file in write mode
+        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
+            $this->privCloseFd();
+
+            // ----- Return
+            return $v_result;
+        }
+
+        // ----- Look which file need to be kept
+        for ($i=0; $i<sizeof($v_header_list); $i++) {
+
+            // ----- Calculate the position of the header
+            @rewind($this->zip_fd);
+            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Error log
+                PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+                // ----- Return
+                return PclZip::errorCode();
+            }
+
+            // ----- Read the file header
+            $v_local_header = array();
+            if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                return $v_result;
+            }
+
+            // ----- Check that local file header is same as central file header
+            if ($this->privCheckFileHeaders($v_local_header,
+			                                $v_header_list[$i]) != 1) {
+                // TBC
+            }
+            unset($v_local_header);
+
+            // ----- Write the file header
+            if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                return $v_result;
+            }
+
+            // ----- Read/write the data block
+            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
+                // ----- Close the zip file
+                $this->privCloseFd();
+                $v_temp_zip->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                return $v_result;
+            }
+        }
+
+        // ----- Store the offset of the central dir
+        $v_offset = @ftell($v_temp_zip->zip_fd);
+
+        // ----- Re-Create the Central Dir files header
+        for ($i=0; $i<sizeof($v_header_list); $i++) {
+            // ----- Create the file header
+            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
+                $v_temp_zip->privCloseFd();
+                $this->privCloseFd();
+                @unlink($v_zip_temp_name);
+
+                // ----- Return
+                return $v_result;
+            }
+
+            // ----- Transform the header to a 'usable' info
+            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+        }
+
+
+        // ----- Zip file comment
+        $v_comment = '';
+        if (isset($p_options[PCLZIP_OPT_COMMENT])) {
+          $v_comment = $p_options[PCLZIP_OPT_COMMENT];
+        }
+
+        // ----- Calculate the size of the central header
+        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
+
+        // ----- Create the central dir footer
+        if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
+            // ----- Reset the file list
+            unset($v_header_list);
+            $v_temp_zip->privCloseFd();
+            $this->privCloseFd();
+            @unlink($v_zip_temp_name);
+
+            // ----- Return
+            return $v_result;
+        }
+
+        // ----- Close
+        $v_temp_zip->privCloseFd();
+        $this->privCloseFd();
+
+        // ----- Delete the zip file
+        // TBC : I should test the result ...
+        @unlink($this->zipname);
+
+        // ----- Rename the temporary file
+        // TBC : I should test the result ...
+        //@rename($v_zip_temp_name, $this->zipname);
+        PclZipUtilRename($v_zip_temp_name, $this->zipname);
+
+        // ----- Destroy the temporary archive
+        unset($v_temp_zip);
+    }
+
+    // ----- Remove every files : reset the file
+    else if ($v_central_dir['entries'] != 0) {
+        $this->privCloseFd();
+
+        if (($v_result = $this->privOpenFd('wb')) != 1) {
+          return $v_result;
+        }
+
+        if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
+          return $v_result;
+        }
+
+        $this->privCloseFd();
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privDirCheck()
+  // Description :
+  //   Check if a directory exists, if not it creates it and all the parents directory
+  //   which may be useful.
+  // Parameters :
+  //   $p_dir : Directory path to check.
+  // Return Values :
+  //    1 : OK
+  //   -1 : Unable to create directory
+  // --------------------------------------------------------------------------------
+  function privDirCheck($p_dir, $p_is_dir=false)
+  {
+    $v_result = 1;
+
+
+    // ----- Remove the final '/'
+    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
+    {
+      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
+    }
+
+    // ----- Check the directory availability
+    if ((is_dir($p_dir)) || ($p_dir == ""))
+    {
+      return 1;
+    }
+
+    // ----- Extract parent directory
+    $p_parent_dir = dirname($p_dir);
+
+    // ----- Just a check
+    if ($p_parent_dir != $p_dir)
+    {
+      // ----- Look for parent directory
+      if ($p_parent_dir != "")
+      {
+        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
+        {
+          return $v_result;
+        }
+      }
+    }
+
+    // ----- Create the directory
+    if (!@mkdir($p_dir, 0777))
+    {
+      // ----- Error log
+      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privMerge()
+  // Description :
+  //   If $p_archive_to_add does not exist, the function exit with a success result.
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privMerge(&$p_archive_to_add)
+  {
+    $v_result=1;
+
+    // ----- Look if the archive_to_add exists
+    if (!is_file($p_archive_to_add->zipname))
+    {
+
+      // ----- Nothing to merge, so merge is a success
+      $v_result = 1;
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Look if the archive exists
+    if (!is_file($this->zipname))
+    {
+
+      // ----- Do a duplicate
+      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Open the zip file
+    if (($v_result=$this->privOpenFd('rb')) != 1)
+    {
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir = array();
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
+    {
+      $this->privCloseFd();
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    @rewind($this->zip_fd);
+
+    // ----- Open the archive_to_add file
+    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
+    {
+      $this->privCloseFd();
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Read the central directory informations
+    $v_central_dir_to_add = array();
+    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
+    {
+      $this->privCloseFd();
+      $p_archive_to_add->privCloseFd();
+
+      return $v_result;
+    }
+
+    // ----- Go to beginning of File
+    @rewind($p_archive_to_add->zip_fd);
+
+    // ----- Creates a temporay file
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
+
+    // ----- Open the temporary file in write mode
+    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
+    {
+      $this->privCloseFd();
+      $p_archive_to_add->privCloseFd();
+
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Copy the files from the archive to the temporary file
+    // TBC : Here I should better append the file and go back to erase the central dir
+    $v_size = $v_central_dir['offset'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = fread($this->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Copy the files from the archive_to_add into the temporary file
+    $v_size = $v_central_dir_to_add['offset'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Store the offset of the central dir
+    $v_offset = @ftell($v_zip_temp_fd);
+
+    // ----- Copy the block of file headers from the old archive
+    $v_size = $v_central_dir['size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = @fread($this->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Copy the block of file headers from the archive_to_add
+    $v_size = $v_central_dir_to_add['size'];
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Merge the file comments
+    $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
+
+    // ----- Calculate the size of the (new) central header
+    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
+
+    // ----- Swap the file descriptor
+    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
+    // the following methods on the temporary fil and not the real archive fd
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Create the central dir footer
+    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
+    {
+      $this->privCloseFd();
+      $p_archive_to_add->privCloseFd();
+      @fclose($v_zip_temp_fd);
+      $this->zip_fd = null;
+
+      // ----- Reset the file list
+      unset($v_header_list);
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Swap back the file descriptor
+    $v_swap = $this->zip_fd;
+    $this->zip_fd = $v_zip_temp_fd;
+    $v_zip_temp_fd = $v_swap;
+
+    // ----- Close
+    $this->privCloseFd();
+    $p_archive_to_add->privCloseFd();
+
+    // ----- Close the temporary file
+    @fclose($v_zip_temp_fd);
+
+    // ----- Delete the zip file
+    // TBC : I should test the result ...
+    @unlink($this->zipname);
+
+    // ----- Rename the temporary file
+    // TBC : I should test the result ...
+    //@rename($v_zip_temp_name, $this->zipname);
+    PclZipUtilRename($v_zip_temp_name, $this->zipname);
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privDuplicate()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privDuplicate($p_archive_filename)
+  {
+    $v_result=1;
+
+    // ----- Look if the $p_archive_filename exists
+    if (!is_file($p_archive_filename))
+    {
+
+      // ----- Nothing to duplicate, so duplicate is a success.
+      $v_result = 1;
+
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Open the zip file
+    if (($v_result=$this->privOpenFd('wb')) != 1)
+    {
+      // ----- Return
+      return $v_result;
+    }
+
+    // ----- Open the temporary file in write mode
+    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
+    {
+      $this->privCloseFd();
+
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
+
+      // ----- Return
+      return PclZip::errorCode();
+    }
+
+    // ----- Copy the files from the archive to the temporary file
+    // TBC : Here I should better append the file and go back to erase the central dir
+    $v_size = filesize($p_archive_filename);
+    while ($v_size != 0)
+    {
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
+      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+      $v_size -= $v_read_size;
+    }
+
+    // ----- Close
+    $this->privCloseFd();
+
+    // ----- Close the temporary file
+    @fclose($v_zip_temp_fd);
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privErrorLog()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privErrorLog($p_error_code=0, $p_error_string='')
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      PclError($p_error_code, $p_error_string);
+    }
+    else {
+      $this->error_code = $p_error_code;
+      $this->error_string = $p_error_string;
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privErrorReset()
+  // Description :
+  // Parameters :
+  // --------------------------------------------------------------------------------
+  function privErrorReset()
+  {
+    if (PCLZIP_ERROR_EXTERNAL == 1) {
+      PclErrorReset();
+    }
+    else {
+      $this->error_code = 0;
+      $this->error_string = '';
+    }
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privDisableMagicQuotes()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privDisableMagicQuotes()
+  {
+    $v_result=1;
+
+    // ----- Look if function exists
+    if (   (!function_exists("get_magic_quotes_runtime"))
+	    || (!function_exists("set_magic_quotes_runtime"))) {
+      return $v_result;
+	}
+
+    // ----- Look if already done
+    if ($this->magic_quotes_status != -1) {
+      return $v_result;
+	}
+
+	// ----- Get and memorize the magic_quote value
+	$this->magic_quotes_status = @get_magic_quotes_runtime();
+
+	// ----- Disable magic_quotes
+	if ($this->magic_quotes_status == 1) {
+	  @set_magic_quotes_runtime(0);
+	}
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : privSwapBackMagicQuotes()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function privSwapBackMagicQuotes()
+  {
+    $v_result=1;
+
+    // ----- Look if function exists
+    if (   (!function_exists("get_magic_quotes_runtime"))
+	    || (!function_exists("set_magic_quotes_runtime"))) {
+      return $v_result;
+	}
+
+    // ----- Look if something to do
+    if ($this->magic_quotes_status != -1) {
+      return $v_result;
+	}
+
+	// ----- Swap back magic_quotes
+	if ($this->magic_quotes_status == 1) {
+  	  @set_magic_quotes_runtime($this->magic_quotes_status);
+	}
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  }
+  // End of class
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilPathReduction()
+  // Description :
+  // Parameters :
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function PclZipUtilPathReduction($p_dir)
+  {
+    $v_result = "";
+
+    // ----- Look for not empty path
+    if ($p_dir != "") {
+      // ----- Explode path by directory names
+      $v_list = explode("/", $p_dir);
+
+      // ----- Study directories from last to first
+      $v_skip = 0;
+      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
+        // ----- Look for current path
+        if ($v_list[$i] == ".") {
+          // ----- Ignore this directory
+          // Should be the first $i=0, but no check is done
+        }
+        else if ($v_list[$i] == "..") {
+		  $v_skip++;
+        }
+        else if ($v_list[$i] == "") {
+		  // ----- First '/' i.e. root slash
+		  if ($i == 0) {
+            $v_result = "/".$v_result;
+		    if ($v_skip > 0) {
+		        // ----- It is an invalid path, so the path is not modified
+		        // TBC
+		        $v_result = $p_dir;
+                $v_skip = 0;
+		    }
+		  }
+		  // ----- Last '/' i.e. indicates a directory
+		  else if ($i == (sizeof($v_list)-1)) {
+            $v_result = $v_list[$i];
+		  }
+		  // ----- Double '/' inside the path
+		  else {
+            // ----- Ignore only the double '//' in path,
+            // but not the first and last '/'
+		  }
+        }
+        else {
+		  // ----- Look for item to skip
+		  if ($v_skip > 0) {
+		    $v_skip--;
+		  }
+		  else {
+            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
+		  }
+        }
+      }
+
+      // ----- Look for skip
+      if ($v_skip > 0) {
+        while ($v_skip > 0) {
+            $v_result = '../'.$v_result;
+            $v_skip--;
+        }
+      }
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilPathInclusion()
+  // Description :
+  //   This function indicates if the path $p_path is under the $p_dir tree. Or,
+  //   said in an other way, if the file or sub-dir $p_path is inside the dir
+  //   $p_dir.
+  //   The function indicates also if the path is exactly the same as the dir.
+  //   This function supports path with duplicated '/' like '//', but does not
+  //   support '.' or '..' statements.
+  // Parameters :
+  // Return Values :
+  //   0 if $p_path is not inside directory $p_dir
+  //   1 if $p_path is inside directory $p_dir
+  //   2 if $p_path is exactly the same as $p_dir
+  // --------------------------------------------------------------------------------
+  function PclZipUtilPathInclusion($p_dir, $p_path)
+  {
+    $v_result = 1;
+
+    // ----- Look for path beginning by ./
+    if (   ($p_dir == '.')
+        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
+      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
+    }
+    if (   ($p_path == '.')
+        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
+      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
+    }
+
+    // ----- Explode dir and path by directory separator
+    $v_list_dir = explode("/", $p_dir);
+    $v_list_dir_size = sizeof($v_list_dir);
+    $v_list_path = explode("/", $p_path);
+    $v_list_path_size = sizeof($v_list_path);
+
+    // ----- Study directories paths
+    $i = 0;
+    $j = 0;
+    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
+
+      // ----- Look for empty dir (path reduction)
+      if ($v_list_dir[$i] == '') {
+        $i++;
+        continue;
+      }
+      if ($v_list_path[$j] == '') {
+        $j++;
+        continue;
+      }
+
+      // ----- Compare the items
+      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
+        $v_result = 0;
+      }
+
+      // ----- Next items
+      $i++;
+      $j++;
+    }
+
+    // ----- Look if everything seems to be the same
+    if ($v_result) {
+      // ----- Skip all the empty items
+      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
+      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
+
+      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
+        // ----- There are exactly the same
+        $v_result = 2;
+      }
+      else if ($i < $v_list_dir_size) {
+        // ----- The path is shorter than the dir
+        $v_result = 0;
+      }
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilCopyBlock()
+  // Description :
+  // Parameters :
+  //   $p_mode : read/write compression mode
+  //             0 : src & dest normal
+  //             1 : src gzip, dest normal
+  //             2 : src normal, dest gzip
+  //             3 : src & dest gzip
+  // Return Values :
+  // --------------------------------------------------------------------------------
+  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
+  {
+    $v_result = 1;
+
+    if ($p_mode==0)
+    {
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        $v_buffer = @fread($p_src, $v_read_size);
+        @fwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+    }
+    else if ($p_mode==1)
+    {
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        $v_buffer = @gzread($p_src, $v_read_size);
+        @fwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+    }
+    else if ($p_mode==2)
+    {
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        $v_buffer = @fread($p_src, $v_read_size);
+        @gzwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+    }
+    else if ($p_mode==3)
+    {
+      while ($p_size != 0)
+      {
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+        $v_buffer = @gzread($p_src, $v_read_size);
+        @gzwrite($p_dest, $v_buffer, $v_read_size);
+        $p_size -= $v_read_size;
+      }
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilRename()
+  // Description :
+  //   This function tries to do a simple rename() function. If it fails, it
+  //   tries to copy the $p_src file in a new $p_dest file and then unlink the
+  //   first one.
+  // Parameters :
+  //   $p_src : Old filename
+  //   $p_dest : New filename
+  // Return Values :
+  //   1 on success, 0 on failure.
+  // --------------------------------------------------------------------------------
+  function PclZipUtilRename($p_src, $p_dest)
+  {
+    $v_result = 1;
+
+    // ----- Try to rename the files
+    if (!@rename($p_src, $p_dest)) {
+
+      // ----- Try to copy & unlink the src
+      if (!@copy($p_src, $p_dest)) {
+        $v_result = 0;
+      }
+      else if (!@unlink($p_src)) {
+        $v_result = 0;
+      }
+    }
+
+    // ----- Return
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilOptionText()
+  // Description :
+  //   Translate option value in text. Mainly for debug purpose.
+  // Parameters :
+  //   $p_option : the option value.
+  // Return Values :
+  //   The option text value.
+  // --------------------------------------------------------------------------------
+  function PclZipUtilOptionText($p_option)
+  {
+
+    $v_list = get_defined_constants();
+    for (reset($v_list); $v_key = key($v_list); next($v_list)) {
+	    $v_prefix = substr($v_key, 0, 10);
+	    if ((   ($v_prefix == 'PCLZIP_OPT')
+           || ($v_prefix == 'PCLZIP_CB_')
+           || ($v_prefix == 'PCLZIP_ATT'))
+	        && ($v_list[$v_key] == $p_option)) {
+        return $v_key;
+	    }
+    }
+
+    $v_result = 'Unknown';
+
+    return $v_result;
+  }
+  // --------------------------------------------------------------------------------
+
+  // --------------------------------------------------------------------------------
+  // Function : PclZipUtilTranslateWinPath()
+  // Description :
+  //   Translate windows path by replacing '\' by '/' and optionally removing
+  //   drive letter.
+  // Parameters :
+  //   $p_path : path to translate.
+  //   $p_remove_disk_letter : true | false
+  // Return Values :
+  //   The path translated.
+  // --------------------------------------------------------------------------------
+  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
+  {
+    if (stristr(php_uname(), 'windows')) {
+      // ----- Look for potential disk letter
+      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
+          $p_path = substr($p_path, $v_position+1);
+      }
+      // ----- Change potential windows directory separator
+      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
+          $p_path = strtr($p_path, '\\', '/');
+      }
+    }
+    return $p_path;
+  }
+  // --------------------------------------------------------------------------------
+
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-comments-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-comments-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-comments-list-table.php	(revision 17487)
@@ -0,0 +1,557 @@
+<?php
+/**
+ * Comments and Post Comments List Table classes.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ */
+
+/**
+ * Comments List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Comments_List_Table extends WP_List_Table {
+
+	var $checkbox = true;
+
+	var $pending_count = array();
+
+	function WP_Comments_List_Table() {
+		global $post_id;
+
+		$post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : 0;
+
+		if ( get_option('show_avatars') )
+			add_filter( 'comment_author', 'floated_admin_avatar' );
+
+		parent::WP_List_Table( array(
+			'plural' => 'comments',
+			'singular' => 'comment',
+			'ajax' => true,
+		) );
+	}
+
+	function ajax_user_can() {
+		return current_user_can('edit_posts');
+	}
+
+	function prepare_items() {
+		global $post_id, $comment_status, $search, $comment_type;
+
+		$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
+		if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )
+			$comment_status = 'all';
+
+		$comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
+
+		$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
+
+		$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
+
+		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
+		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
+
+		$comments_per_page = $this->get_per_page( $comment_status );
+
+		$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
+
+		if ( isset( $_REQUEST['number'] ) ) {
+			$number = (int) $_REQUEST['number'];
+		}
+		else {
+			$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
+		}
+
+		$page = $this->get_pagenum();
+
+		if ( isset( $_REQUEST['start'] ) ) {
+			$start = $_REQUEST['start'];
+		} else {
+			$start = ( $page - 1 ) * $comments_per_page;
+		}
+
+		if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
+			$start += $_REQUEST['offset'];
+		}
+
+		$status_map = array(
+			'moderated' => 'hold',
+			'approved' => 'approve'
+		);
+
+		$args = array(
+			'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status,
+			'search' => $search,
+			'user_id' => $user_id,
+			'offset' => $start,
+			'number' => $number,
+			'post_id' => $post_id,
+			'type' => $comment_type,
+			'orderby' => $orderby,
+			'order' => $order,
+		);
+
+		$_comments = get_comments( $args );
+
+		update_comment_cache( $_comments );
+
+		$this->items = array_slice( $_comments, 0, $comments_per_page );
+		$this->extra_items = array_slice( $_comments, $comments_per_page );
+
+		$total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
+
+		$_comment_post_ids = array();
+		foreach ( $_comments as $_c ) {
+			$_comment_post_ids[] = $_c->comment_post_ID;
+		}
+
+		$this->pending_count = get_pending_comments_num( $_comment_post_ids );
+
+		$this->set_pagination_args( array(
+			'total_items' => $total_comments,
+			'per_page' => $comments_per_page,
+		) );
+	}
+
+	function get_per_page( $comment_status = 'all' ) {
+		$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
+		$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
+		return $comments_per_page;
+	}
+
+	function no_items() {
+		global $comment_status;
+
+		if ( 'moderated' == $comment_status )
+			_e( 'No comments awaiting moderation&hellip; yet.' );
+		else
+			_e( 'No comments found.' );
+	}
+
+	function get_views() {
+		global $post_id, $comment_status;
+
+		$status_links = array();
+		$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
+		//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
+		//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
+		$stati = array(
+				'all' => _nx_noop('All', 'All', 'comments'), // singular not used
+				'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'),
+				'approved' => _n_noop('Approved', 'Approved'), // singular not used
+				'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'),
+				'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')
+			);
+
+		if ( !EMPTY_TRASH_DAYS )
+			unset($stati['trash']);
+
+		$link = 'edit-comments.php';
+		if ( !empty($comment_type) && 'all' != $comment_type )
+			$link = add_query_arg( 'comment_type', $comment_type, $link );
+
+		foreach ( $stati as $status => $label ) {
+			$class = ( $status == $comment_status ) ? ' class="current"' : '';
+
+			if ( !isset( $num_comments->$status ) )
+				$num_comments->$status = 10;
+			$link = add_query_arg( 'comment_status', $status, $link );
+			if ( $post_id )
+				$link = add_query_arg( 'p', absint( $post_id ), $link );
+			/*
+			// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
+			if ( !empty( $_REQUEST['s'] ) )
+				$link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link );
+			*/
+			$status_links[$status] = "<a href='$link'$class>" . sprintf(
+				translate_nooped_plural( $label, $num_comments->$status ),
+				number_format_i18n( $num_comments->$status )
+			) . '</a>';
+		}
+
+		$status_links = apply_filters( 'comment_status_links', $status_links );
+		return $status_links;
+	}
+
+	function get_bulk_actions() {
+		global $comment_status;
+
+		$actions = array();
+		if ( in_array( $comment_status, array( 'all', 'approved' ) ) )
+			$actions['unapprove'] = __( 'Unapprove' );
+		if ( in_array( $comment_status, array( 'all', 'moderated', 'spam' ) ) )
+			$actions['approve'] = __( 'Approve' );
+		if ( in_array( $comment_status, array( 'all', 'moderated', 'approved' ) ) )
+			$actions['spam'] = _x( 'Mark as Spam', 'comment' );
+
+		if ( 'trash' == $comment_status )
+			$actions['untrash'] = __( 'Restore' );
+		elseif ( 'spam' == $comment_status )
+			$actions['unspam'] = _x( 'Not Spam', 'comment' );
+
+		if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS )
+			$actions['delete'] = __( 'Delete Permanently' );
+		else
+			$actions['trash'] = __( 'Move to Trash' );
+
+		return $actions;
+	}
+
+	function extra_tablenav( $which ) {
+		global $comment_status, $comment_type;
+?>
+		<div class="alignleft actions">
+<?php
+		if ( 'top' == $which ) {
+?>
+			<select name="comment_type">
+				<option value=""><?php _e( 'Show all comment types' ); ?></option>
+<?php
+				$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
+					'comment' => __( 'Comments' ),
+					'pings' => __( 'Pings' ),
+				) );
+
+				foreach ( $comment_types as $type => $label )
+					echo "\t<option value='" . esc_attr( $type ) . "'" . selected( $comment_type, $type, false ) . ">$label</option>\n";
+			?>
+			</select>
+<?php
+			submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
+		}
+
+		if ( ( 'spam' == $comment_status || 'trash' == $comment_status ) && current_user_can( 'moderate_comments' ) ) {
+			wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
+			$title = ( 'spam' == $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
+			submit_button( $title, 'button-secondary apply', 'delete_all', false );
+		}
+		do_action( 'manage_comments_nav', $comment_status );
+		echo '</div>';
+	}
+
+	function current_action() {
+		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
+			return 'delete_all';
+
+		return parent::current_action();
+	}
+
+	function get_columns() {
+		global $post_id;
+
+		$columns = array();
+
+		if ( $this->checkbox )
+			$columns['cb'] = '<input type="checkbox" />';
+
+		$columns['author'] = __( 'Author' );
+		$columns['comment'] = _x( 'Comment', 'column name' );
+
+		if ( !$post_id )
+			$columns['response'] = _x( 'In Response To', 'column name' );
+
+		return $columns;
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'author'   => 'comment_author',
+			'response' => 'comment_post_ID'
+		);
+	}
+
+	function display() {
+		extract( $this->_args );
+
+		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
+
+		$this->display_tablenav( 'top' );
+
+?>
+<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
+	<thead>
+	<tr>
+		<?php $this->print_column_headers(); ?>
+	</tr>
+	</thead>
+
+	<tfoot>
+	<tr>
+		<?php $this->print_column_headers( false ); ?>
+	</tr>
+	</tfoot>
+
+	<tbody id="the-comment-list" class="list:comment">
+		<?php $this->display_rows_or_placeholder(); ?>
+	</tbody>
+
+	<tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
+		<?php $this->items = $this->extra_items; $this->display_rows(); ?>
+	</tbody>
+</table>
+<?php
+
+		$this->display_tablenav( 'bottom' );
+	}
+
+	function single_row( $a_comment ) {
+		global $post, $comment, $the_comment_status;
+
+		$comment = $a_comment;
+		$the_comment_status = wp_get_comment_status( $comment->comment_ID );
+
+		$post = get_post( $comment->comment_post_ID );
+
+		$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
+
+		echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
+		echo $this->single_row_columns( $comment );
+		echo "</tr>";
+	}
+
+	function column_cb( $comment ) {
+		if ( $this->user_can )
+			echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
+	}
+
+	function column_comment( $comment ) {
+		global $post, $comment_status, $the_comment_status;
+
+		$user_can = $this->user_can;
+
+		$comment_url = esc_url( get_comment_link( $comment->comment_ID ) );
+
+		$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 );
+
+		if ( $user_can ) {
+			$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
+			$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
+
+			$url = "comment.php?c=$comment->comment_ID";
+
+			$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
+			$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
+			$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
+			$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
+			$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
+			$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
+			$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
+		}
+
+		echo '<div class="submitted-on">';
+		/* translators: 2: comment date, 3: comment time */
+		printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
+			/* translators: comment date format. See http://php.net/date */ get_comment_date( __( 'Y/m/d' ) ),
+			/* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );
+
+		if ( $comment->comment_parent ) {
+			$parent = get_comment( $comment->comment_parent );
+			$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
+			$name = get_comment_author( $parent->comment_ID );
+			printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
+		}
+
+		echo '</div>';
+		comment_text();
+		if ( $user_can ) { ?>
+		<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
+		<textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?></textarea>
+		<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
+		<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
+		<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
+		<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
+		</div>
+		<?php
+		}
+
+		if ( $user_can ) {
+			// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
+			$actions = array(
+				'approve' => '', 'unapprove' => '',
+				'reply' => '',
+				'quickedit' => '',
+				'edit' => '',
+				'spam' => '', 'unspam' => '',
+				'trash' => '', 'untrash' => '', 'delete' => ''
+			);
+
+			if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
+				if ( 'approved' == $the_comment_status )
+					$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+				else if ( 'unapproved' == $the_comment_status )
+					$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+			} else {
+				$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+				$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+			}
+
+			if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
+				$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
+			} elseif ( 'spam' == $the_comment_status ) {
+				$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
+			} elseif ( 'trash' == $the_comment_status ) {
+				$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
+			}
+
+			if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
+				$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
+			} else {
+				$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
+			}
+
+			if ( 'trash' != $the_comment_status ) {
+				$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
+				$actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick&nbsp;Edit' ) . '</a>';
+				if ( 'spam' != $the_comment_status )
+					$actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
+			}
+
+			$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
+
+			$i = 0;
+			echo '<div class="row-actions">';
+			foreach ( $actions as $action => $link ) {
+				++$i;
+				( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
+
+				// Reply and quickedit need a hide-if-no-js span when not added with ajax
+				if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )
+					$action .= ' hide-if-no-js';
+				elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
+					if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
+						$action .= ' approve';
+					else
+						$action .= ' unapprove';
+				}
+
+				echo "<span class='$action'>$sep$link</span>";
+			}
+			echo '</div>';
+		}
+	}
+
+	function column_author( $comment ) {
+		global $comment_status;
+
+		$author_url = get_comment_author_url();
+		if ( 'http://' == $author_url )
+			$author_url = '';
+		$author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url );
+		if ( strlen( $author_url_display ) > 50 )
+			$author_url_display = substr( $author_url_display, 0, 49 ) . '...';
+
+		echo "<strong>"; comment_author(); echo '</strong><br />';
+		if ( !empty( $author_url ) )
+			echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
+
+		if ( $this->user_can ) {
+			if ( !empty( $comment->comment_author_email ) ) {
+				comment_author_email_link();
+				echo '<br />';
+			}
+			echo '<a href="edit-comments.php?s=';
+			comment_author_IP();
+			echo '&amp;mode=detail';
+			if ( 'spam' == $comment_status )
+				echo '&amp;comment_status=spam';
+			echo '">';
+			comment_author_IP();
+			echo '</a>';
+		}
+	}
+
+	function column_date( $comment ) {
+		return get_comment_date( __( 'Y/m/d \a\t g:ia' ) );
+	}
+
+	function column_response( $comment ) {
+		global $post;
+
+		if ( isset( $this->pending_count[$post->ID] ) ) {
+			$pending_comments = $this->pending_count[$post->ID];
+		} else {
+			$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
+			$pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID];
+		}
+
+		if ( current_user_can( 'edit_post', $post->ID ) ) {
+			$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
+			$post_link .= get_the_title( $post->ID ) . '</a>';
+		} else {
+			$post_link = get_the_title( $post->ID );
+		}
+
+		echo '<div class="response-links"><span class="post-com-count-wrapper">';
+		echo $post_link . '<br />';
+		$this->comments_bubble( $post->ID, $pending_comments );
+		echo '</span> ';
+		echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
+		echo '</div>';
+		if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) )
+			echo $thumb;
+	}
+
+	function column_default( $comment, $column_name ) {
+		do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
+	}
+}
+
+/**
+ * Post Comments List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ *
+ * @see WP_Comments_Table
+ */
+class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
+
+	function get_column_info() {
+		$this->_column_headers = array(
+			array(
+			'author'   => __( 'Author' ),
+			'comment'  => _x( 'Comment', 'column name' ),
+			),
+			array(),
+			array(),
+		);
+
+		return $this->_column_headers;
+	}
+
+	function get_table_classes() {
+		$classes = parent::get_table_classes();
+		$classes[] = 'comments-box';
+		return $classes;
+	}
+
+	function display( $output_empty = false ) {
+		extract( $this->_args );
+
+		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
+?>
+<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0" style="display:none;">
+	<tbody id="the-comment-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
+		<?php if ( ! $output_empty ) $this->display_rows_or_placeholder(); ?>
+	</tbody>
+</table>
+<?php
+	}
+
+	function get_per_page( $comment_status = false ) {
+		return 10;
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-filesystem-base.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-filesystem-base.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-filesystem-base.php	(revision 17487)
@@ -0,0 +1,321 @@
+<?php
+/**
+ * Base WordPress Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * Base WordPress Filesystem class for which Filesystem implementations extend
+ *
+ * @since 2.5
+ */
+class WP_Filesystem_Base {
+	/**
+	 * Whether to display debug data for the connection.
+	 *
+	 * @since 2.5
+	 * @access public
+	 * @var bool
+	 */
+	var $verbose = false;
+	/**
+	 * Cached list of local filepaths to maped remote filepaths.
+	 *
+	 * @since 2.7
+	 * @access private
+	 * @var array
+	 */
+	var $cache = array();
+
+	/**
+	 * The Access method of the current connection, Set automatically.
+	 *
+	 * @since 2.5
+	 * @access public
+	 * @var string
+	 */
+	var $method = '';
+
+	/**
+	 * Returns the path on the remote filesystem of ABSPATH
+	 *
+	 * @since 2.7
+	 * @access public
+	 * @return string The location of the remote path.
+	 */
+	function abspath() {
+		$folder = $this->find_folder(ABSPATH);
+		//Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
+		if ( ! $folder && $this->is_dir('/wp-includes') )
+			$folder = '/';
+		return $folder;
+	}
+	/**
+	 * Returns the path on the remote filesystem of WP_CONTENT_DIR
+	 *
+	 * @since 2.7
+	 * @access public
+	 * @return string The location of the remote path.
+	 */
+	function wp_content_dir() {
+		return $this->find_folder(WP_CONTENT_DIR);
+	}
+	/**
+	 * Returns the path on the remote filesystem of WP_PLUGIN_DIR
+	 *
+	 * @since 2.7
+	 * @access public
+	 *
+	 * @return string The location of the remote path.
+	 */
+	function wp_plugins_dir() {
+		return $this->find_folder(WP_PLUGIN_DIR);
+	}
+	/**
+	 * Returns the path on the remote filesystem of the Themes Directory
+	 *
+	 * @since 2.7
+	 * @access public
+	 *
+	 * @return string The location of the remote path.
+	 */
+	function wp_themes_dir() {
+		return $this->wp_content_dir() . '/themes';
+	}
+
+	/**
+	 * Locates a folder on the remote filesystem.
+	 *
+	 * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
+	 *
+	 * @since 2.5
+	 * @deprecated 2.7
+	 * @access public
+	 *
+	 * @param string $base The folder to start searching from
+	 * @param bool $echo True to display debug information
+	 * @return string The location of the remote path.
+	 */
+	function find_base_dir($base = '.', $echo = false) {
+		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
+		$this->verbose = $echo;
+		return $this->abspath();
+	}
+	/**
+	 * Locates a folder on the remote filesystem.
+	 *
+	 * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
+	 *
+	 * @since 2.5
+	 * @deprecated 2.7
+	 * @access public
+	 *
+	 * @param string $base The folder to start searching from
+	 * @param bool $echo True to display debug information
+	 * @return string The location of the remote path.
+	 */
+	function get_base_dir($base = '.', $echo = false) {
+		_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
+		$this->verbose = $echo;
+		return $this->abspath();
+	}
+
+	/**
+	 * Locates a folder on the remote filesystem.
+	 *
+	 * Assumes that on Windows systems, Stripping off the Drive letter is OK
+	 * Sanitizes \\ to / in windows filepaths.
+	 *
+	 * @since 2.7
+	 * @access public
+	 *
+	 * @param string $folder the folder to locate
+	 * @return string The location of the remote path.
+	 */
+	function find_folder($folder) {
+
+		if ( strpos($this->method, 'ftp') !== false ) {
+			$constant_overrides = array( 'FTP_BASE' => ABSPATH, 'FTP_CONTENT_DIR' => WP_CONTENT_DIR, 'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR );
+			foreach ( $constant_overrides as $constant => $dir )
+				if ( defined($constant) && $folder === $dir )
+					return trailingslashit(constant($constant));
+		} elseif ( 'direct' == $this->method ) {
+			$folder = str_replace('\\', '/', $folder); //Windows path sanitiation
+			return trailingslashit($folder);
+		}
+
+		$folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows driveletter if its there.
+		$folder = str_replace('\\', '/', $folder); //Windows path sanitiation
+
+		if ( isset($this->cache[ $folder ] ) )
+			return $this->cache[ $folder ];
+
+		if ( $this->exists($folder) ) { //Folder exists at that absolute path.
+			$folder = trailingslashit($folder);
+			$this->cache[ $folder ] = $folder;
+			return $folder;
+		}
+		if ( $return = $this->search_for_folder($folder) )
+			$this->cache[ $folder ] = $return;
+		return $return;
+	}
+
+	/**
+	 * Locates a folder on the remote filesystem.
+	 *
+	 * Expects Windows sanitized path
+	 *
+	 * @since 2.7
+	 * @access private
+	 *
+	 * @param string $folder the folder to locate
+	 * @param string $base the folder to start searching from
+	 * @param bool $loop if the function has recursed, Internal use only
+	 * @return string The location of the remote path.
+	 */
+	function search_for_folder($folder, $base = '.', $loop = false ) {
+		if ( empty( $base ) || '.' == $base )
+			$base = trailingslashit($this->cwd());
+
+		$folder = untrailingslashit($folder);
+
+		$folder_parts = explode('/', $folder);
+		$last_path = $folder_parts[ count($folder_parts) - 1 ];
+
+		$files = $this->dirlist( $base );
+
+		foreach ( $folder_parts as $key ) {
+			if ( $key == $last_path )
+				continue; //We want this to be caught by the next code block.
+
+			//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:
+				$newdir = trailingslashit(path_join($base, $key));
+				if ( $this->verbose )
+					printf( __('Changing to %s') . '<br/>', $newdir );
+				if ( $ret = $this->search_for_folder( $folder, $newdir, $loop) )
+					return $ret;
+			}
+		}
+
+		//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[ $last_path ] ) ) {
+			if ( $this->verbose )
+				printf( __('Found %s') . '<br/>',  $base . $last_path );
+			return trailingslashit($base . $last_path);
+		}
+		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->search_for_folder($folder, '/', true);
+
+	}
+
+	/**
+	 * Returns the *nix style file permissions for a file
+	 *
+	 * From the PHP documentation page for fileperms()
+	 *
+	 * @link http://docs.php.net/fileperms
+	 * @since 2.5
+	 * @access public
+	 *
+	 * @param string $file string filename
+	 * @return int octal representation of permissions
+	 */
+	function gethchmod($file){
+		$perms = $this->getchmod($file);
+		if (($perms & 0xC000) == 0xC000) // Socket
+			$info = 's';
+		elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
+			$info = 'l';
+		elseif (($perms & 0x8000) == 0x8000) // Regular
+			$info = '-';
+		elseif (($perms & 0x6000) == 0x6000) // Block special
+			$info = 'b';
+		elseif (($perms & 0x4000) == 0x4000) // Directory
+			$info = 'd';
+		elseif (($perms & 0x2000) == 0x2000) // Character special
+			$info = 'c';
+		elseif (($perms & 0x1000) == 0x1000) // FIFO pipe
+			$info = 'p';
+		else // Unknown
+			$info = 'u';
+
+		// Owner
+		$info .= (($perms & 0x0100) ? 'r' : '-');
+		$info .= (($perms & 0x0080) ? 'w' : '-');
+		$info .= (($perms & 0x0040) ?
+					(($perms & 0x0800) ? 's' : 'x' ) :
+					(($perms & 0x0800) ? 'S' : '-'));
+
+		// Group
+		$info .= (($perms & 0x0020) ? 'r' : '-');
+		$info .= (($perms & 0x0010) ? 'w' : '-');
+		$info .= (($perms & 0x0008) ?
+					(($perms & 0x0400) ? 's' : 'x' ) :
+					(($perms & 0x0400) ? 'S' : '-'));
+
+		// World
+		$info .= (($perms & 0x0004) ? 'r' : '-');
+		$info .= (($perms & 0x0002) ? 'w' : '-');
+		$info .= (($perms & 0x0001) ?
+					(($perms & 0x0200) ? 't' : 'x' ) :
+					(($perms & 0x0200) ? 'T' : '-'));
+		return $info;
+	}
+
+	/**
+	 * Converts *nix style file permissions to a octal number.
+	 *
+	 * Converts '-rw-r--r--' to 0644
+	 * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
+ 	 *
+	 * @link http://docs.php.net/manual/en/function.chmod.php#49614
+	 * @since 2.5
+	 * @access public
+	 *
+	 * @param string $mode string *nix style file permission
+	 * @return int octal representation
+	 */
+	function getnumchmodfromh($mode) {
+		$realmode = '';
+		$legal =  array('', 'w', 'r', 'x', '-');
+		$attarray = preg_split('//', $mode);
+
+		for ($i=0; $i < count($attarray); $i++)
+		   if ($key = array_search($attarray[$i], $legal))
+			   $realmode .= $legal[$key];
+
+		$mode = str_pad($realmode, 9, '-');
+		$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
+		$mode = strtr($mode,$trans);
+
+		$newmode = '';
+		$newmode .= $mode[0] + $mode[1] + $mode[2];
+		$newmode .= $mode[3] + $mode[4] + $mode[5];
+		$newmode .= $mode[6] + $mode[7] + $mode[8];
+		return $newmode;
+	}
+
+	/**
+	 * Determines if the string provided contains binary characters.
+	 *
+	 * @since 2.7
+	 * @access private
+	 *
+	 * @param string $text String to test against
+	 * @return bool true if string is binary, false otherwise
+	 */
+	function is_binary( $text ) {
+		return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127)
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-filesystem-direct.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-filesystem-direct.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-filesystem-direct.php	(revision 17487)
@@ -0,0 +1,361 @@
+<?php
+/**
+ * WordPress Direct Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * WordPress Filesystem Class for direct PHP file and folder manipulation.
+ *
+ * @since 2.5
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
+class WP_Filesystem_Direct extends WP_Filesystem_Base {
+	var $errors = null;
+	/**
+	 * constructor
+	 *
+	 * @param mixed $arg ingored argument
+	 */
+	function WP_Filesystem_Direct($arg) {
+		$this->method = 'direct';
+		$this->errors = new WP_Error();
+	}
+	/**
+	 * connect filesystem.
+	 *
+	 * @return bool Returns true on success or false on failure (always true for WP_Filesystem_Direct).
+	 */
+	function connect() {
+		return true;
+	}
+	/**
+	 * Reads entire file into a string
+	 *
+	 * @param string $file Name of the file to read.
+	 * @return string|bool The function returns the read data or false on failure.
+	 */
+	function get_contents($file) {
+		return @file_get_contents($file);
+	}
+	/**
+	 * Reads entire file into an array
+	 *
+	 * @param string $file Path to the file.
+	 * @return array|bool the file contents in an array or false on failure.
+	 */
+	function get_contents_array($file) {
+		return @file($file);
+	}
+	/**
+	 * Write a string to a file
+	 *
+	 * @param string $file Remote path to the file where to write the data.
+	 * @param string $contents The data to write.
+	 * @param int $mode (optional) The file permissions as octal number, usually 0644.
+	 * @return bool False upon failure.
+	 */
+	function put_contents($file, $contents, $mode = false ) {
+		if ( ! ($fp = @fopen($file, 'w')) )
+			return false;
+		@fwrite($fp, $contents);
+		@fclose($fp);
+		$this->chmod($file, $mode);
+		return true;
+	}
+	/**
+	 * Gets the current working directory
+	 *
+	 * @return string|bool the current working directory on success, or false on failure.
+	 */
+	function cwd() {
+		return @getcwd();
+	}
+	/**
+	 * Change directory
+	 *
+	 * @param string $dir The new current directory.
+	 * @return bool Returns true on success or false on failure.
+	 */
+	function chdir($dir) {
+		return @chdir($dir);
+	}
+	/**
+	 * Changes file group
+	 *
+	 * @param string $file Path to the file.
+	 * @param mixed $group A group name or number.
+	 * @param bool $recursive (optional) If set True changes file group recursivly. Defaults to False.
+	 * @return bool Returns true on success or false on failure.
+	 */
+	function chgrp($file, $group, $recursive = false) {
+		if ( ! $this->exists($file) )
+			return false;
+		if ( ! $recursive )
+			return @chgrp($file, $group);
+		if ( ! $this->is_dir($file) )
+			return @chgrp($file, $group);
+		//Is a directory, and we want recursive
+		$file = trailingslashit($file);
+		$filelist = $this->dirlist($file);
+		foreach ($filelist as $filename)
+			$this->chgrp($file . $filename, $group, $recursive);
+
+		return true;
+	}
+	/**
+	 * Changes filesystem permissions
+	 *
+	 * @param string $file Path to the file.
+	 * @param int $mode (optional) The permissions as octal number, usually 0644 for files, 0755 for dirs.
+	 * @param bool $recursive (optional) If set True changes file group recursivly. Defaults to False.
+	 * @return bool Returns true on success or false on failure.
+	 */
+	function chmod($file, $mode = false, $recursive = false) {
+		if ( ! $mode ) {
+			if ( $this->is_file($file) )
+				$mode = FS_CHMOD_FILE;
+			elseif ( $this->is_dir($file) )
+				$mode = FS_CHMOD_DIR;
+			else
+				return false;
+		}
+
+		if ( ! $recursive || ! $this->is_dir($file) )
+			return @chmod($file, $mode);
+		//Is a directory, and we want recursive
+		$file = trailingslashit($file);
+		$filelist = $this->dirlist($file);
+		foreach ( (array)$filelist as $filename => $filemeta)
+			$this->chmod($file . $filename, $mode, $recursive);
+
+		return true;
+	}
+	/**
+	 * Changes file owner
+	 *
+	 * @param string $file Path to the file.
+	 * @param mixed $owner A user name or number.
+	 * @param bool $recursive (optional) If set True changes file owner recursivly. Defaults to False.
+	 * @return bool Returns true on success or false on failure.
+	 */
+	function chown($file, $owner, $recursive = false) {
+		if ( ! $this->exists($file) )
+			return false;
+		if ( ! $recursive )
+			return @chown($file, $owner);
+		if ( ! $this->is_dir($file) )
+			return @chown($file, $owner);
+		//Is a directory, and we want recursive
+		$filelist = $this->dirlist($file);
+		foreach ($filelist as $filename) {
+			$this->chown($file . '/' . $filename, $owner, $recursive);
+		}
+		return true;
+	}
+	/**
+	 * Gets file owner
+	 *
+	 * @param string $file Path to the file.
+	 * @return string Username of the user.
+	 */
+	function owner($file) {
+		$owneruid = @fileowner($file);
+		if ( ! $owneruid )
+			return false;
+		if ( ! function_exists('posix_getpwuid') )
+			return $owneruid;
+		$ownerarray = posix_getpwuid($owneruid);
+		return $ownerarray['name'];
+	}
+	/**
+	 * Gets file permissions
+	 *
+	 * FIXME does not handle errors in fileperms()
+	 *
+	 * @param string $file Path to the file.
+	 * @return string Mode of the file (last 4 digits).
+	 */
+	function getchmod($file) {
+		return substr(decoct(@fileperms($file)),3);
+	}
+	function group($file) {
+		$gid = @filegroup($file);
+		if ( ! $gid )
+			return false;
+		if ( ! function_exists('posix_getgrgid') )
+			return $gid;
+		$grouparray = posix_getgrgid($gid);
+		return $grouparray['name'];
+	}
+
+	function copy($source, $destination, $overwrite = false) {
+		if ( ! $overwrite && $this->exists($destination) )
+			return false;
+
+		return copy($source, $destination);
+	}
+
+	function move($source, $destination, $overwrite = false) {
+		if ( ! $overwrite && $this->exists($destination) )
+			return false;
+
+		// try using rename first.  if that fails (for example, source is read only) try copy
+		if ( @rename($source, $destination) )
+			return true;
+
+		if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) {
+			$this->delete($source);
+			return true;
+		} else {
+			return false;
+		}
+	}
+
+	function delete($file, $recursive = false) {
+		if ( empty($file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
+			return false;
+		$file = str_replace('\\', '/', $file); //for win32, occasional problems deleteing files otherwise
+
+		if ( $this->is_file($file) )
+			return @unlink($file);
+		if ( ! $recursive && $this->is_dir($file) )
+			return @rmdir($file);
+
+		//At this point its a folder, and we're in recursive mode
+		$file = trailingslashit($file);
+		$filelist = $this->dirlist($file, true);
+
+		$retval = true;
+		if ( is_array($filelist) ) //false if no files, So check first.
+			foreach ($filelist as $filename => $fileinfo)
+				if ( ! $this->delete($file . $filename, $recursive) )
+					$retval = false;
+
+		if ( file_exists($file) && ! @rmdir($file) )
+			$retval = false;
+		return $retval;
+	}
+
+	function exists($file) {
+		return @file_exists($file);
+	}
+
+	function is_file($file) {
+		return @is_file($file);
+	}
+
+	function is_dir($path) {
+		return @is_dir($path);
+	}
+
+	function is_readable($file) {
+		return @is_readable($file);
+	}
+
+	function is_writable($file) {
+		return @is_writable($file);
+	}
+
+	function atime($file) {
+		return @fileatime($file);
+	}
+
+	function mtime($file) {
+		return @filemtime($file);
+	}
+	function size($file) {
+		return @filesize($file);
+	}
+
+	function touch($file, $time = 0, $atime = 0) {
+		if ($time == 0)
+			$time = time();
+		if ($atime == 0)
+			$atime = time();
+		return @touch($file, $time, $atime);
+	}
+
+	function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
+		// safe mode fails with a trailing slash under certain PHP versions.
+		$path = untrailingslashit($path);
+		if ( empty($path) )
+			$path = '/';
+
+		if ( ! $chmod )
+			$chmod = FS_CHMOD_DIR;
+
+		if ( ! @mkdir($path) )
+			return false;
+		$this->chmod($path, $chmod);
+		if ( $chown )
+			$this->chown($path, $chown);
+		if ( $chgrp )
+			$this->chgrp($path, $chgrp);
+		return true;
+	}
+
+	function rmdir($path, $recursive = false) {
+		return $this->delete($path, $recursive);
+	}
+
+	function dirlist($path, $include_hidden = true, $recursive = false) {
+		if ( $this->is_file($path) ) {
+			$limit_file = basename($path);
+			$path = dirname($path);
+		} else {
+			$limit_file = false;
+		}
+
+		if ( ! $this->is_dir($path) )
+			return false;
+
+		$dir = @dir($path);
+		if ( ! $dir )
+			return false;
+
+		$ret = array();
+
+		while (false !== ($entry = $dir->read()) ) {
+			$struc = array();
+			$struc['name'] = $entry;
+
+			if ( '.' == $struc['name'] || '..' == $struc['name'] )
+				continue;
+
+			if ( ! $include_hidden && '.' == $struc['name'][0] )
+				continue;
+
+			if ( $limit_file && $struc['name'] != $limit_file)
+				continue;
+
+			$struc['perms'] 	= $this->gethchmod($path.'/'.$entry);
+			$struc['permsn']	= $this->getnumchmodfromh($struc['perms']);
+			$struc['number'] 	= false;
+			$struc['owner']    	= $this->owner($path.'/'.$entry);
+			$struc['group']    	= $this->group($path.'/'.$entry);
+			$struc['size']    	= $this->size($path.'/'.$entry);
+			$struc['lastmodunix']= $this->mtime($path.'/'.$entry);
+			$struc['lastmod']   = date('M j',$struc['lastmodunix']);
+			$struc['time']    	= date('h:i:s',$struc['lastmodunix']);
+			$struc['type']		= $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
+
+			if ( 'd' == $struc['type'] ) {
+				if ( $recursive )
+					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
+				else
+					$struc['files'] = array();
+			}
+
+			$ret[ $struc['name'] ] = $struc;
+		}
+		$dir->close();
+		unset($dir);
+		return $ret;
+	}
+}
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-filesystem-ftpext.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-filesystem-ftpext.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-filesystem-ftpext.php	(revision 17487)
@@ -0,0 +1,387 @@
+<?php
+/**
+ * WordPress FTP Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * WordPress Filesystem Class for implementing FTP.
+ *
+ * @since 2.5
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
+class WP_Filesystem_FTPext extends WP_Filesystem_Base {
+	var $link;
+	var $errors = null;
+	var $options = array();
+
+	function WP_Filesystem_FTPext($opt='') {
+		$this->method = 'ftpext';
+		$this->errors = new WP_Error();
+
+		//Check if possible to use ftp functions.
+		if ( ! extension_loaded('ftp') ) {
+			$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
+			return false;
+		}
+
+		// Set defaults:
+		//This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
+
+		if ( ! defined('FS_TIMEOUT') )
+			define('FS_TIMEOUT', 240);
+
+		if ( empty($opt['port']) )
+			$this->options['port'] = 21;
+		else
+			$this->options['port'] = $opt['port'];
+
+		if ( empty($opt['hostname']) )
+			$this->errors->add('empty_hostname', __('FTP hostname is required'));
+		else
+			$this->options['hostname'] = $opt['hostname'];
+
+		if ( ! empty($opt['base']) )
+			$this->wp_base = $opt['base'];
+
+		// Check if the options provided are OK.
+		if ( empty($opt['username']) )
+			$this->errors->add('empty_username', __('FTP username is required'));
+		else
+			$this->options['username'] = $opt['username'];
+
+		if ( empty($opt['password']) )
+			$this->errors->add('empty_password', __('FTP password is required'));
+		else
+			$this->options['password'] = $opt['password'];
+
+		$this->options['ssl'] = false;
+		if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] )
+			$this->options['ssl'] = true;
+	}
+
+	function connect() {
+		if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
+			$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
+		else
+			$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
+
+		if ( ! $this->link ) {
+			$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
+			return false;
+		}
+
+		if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) {
+			$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
+			return false;
+		}
+
+		//Set the Connection to use Passive FTP
+		@ftp_pasv( $this->link, true );
+		if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT )
+			@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
+
+		return true;
+	}
+
+	function get_contents($file, $type = '', $resumepos = 0 ) {
+		if ( empty($type) )
+			$type = FTP_BINARY;
+
+		$tempfile = wp_tempnam($file);
+		$temp = fopen($tempfile, 'w+');
+
+		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
+		$contents = '';
+
+		while ( ! feof($temp) )
+			$contents .= fread($temp, 8192);
+
+		fclose($temp);
+		unlink($tempfile);
+		return $contents;
+	}
+	function get_contents_array($file) {
+		return explode("\n", $this->get_contents($file));
+	}
+
+	function put_contents($file, $contents, $mode = false ) {
+		$tempfile = wp_tempnam($file);
+		$temp = fopen($tempfile, 'w+');
+		if ( ! $temp )
+			return false;
+
+		fwrite($temp, $contents);
+		fseek($temp, 0); //Skip back to the start of the file being written to
+
+		$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
+		$ret = @ftp_fput($this->link, $file, $temp, $type);
+
+		fclose($temp);
+		unlink($tempfile);
+
+		$this->chmod($file, $mode);
+
+		return $ret;
+	}
+	function cwd() {
+		$cwd = @ftp_pwd($this->link);
+		if ( $cwd )
+			$cwd = trailingslashit($cwd);
+		return $cwd;
+	}
+	function chdir($dir) {
+		return @ftp_chdir($this->link, $dir);
+	}
+	function chgrp($file, $group, $recursive = false ) {
+		return false;
+	}
+	function chmod($file, $mode = false, $recursive = false) {
+		if ( ! $mode ) {
+			if ( $this->is_file($file) )
+				$mode = FS_CHMOD_FILE;
+			elseif ( $this->is_dir($file) )
+				$mode = FS_CHMOD_DIR;
+			else
+				return false;
+		}
+
+		// chmod any sub-objects if recursive.
+		if ( $recursive && $this->is_dir($file) ) {
+			$filelist = $this->dirlist($file);
+			foreach ( (array)$filelist as $filename => $filemeta )
+				$this->chmod($file . '/' . $filename, $mode, $recursive);
+		}
+
+		// chmod the file or directory
+		if ( ! function_exists('ftp_chmod') )
+			return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
+		return (bool)@ftp_chmod($this->link, $mode, $file);
+	}
+	function chown($file, $owner, $recursive = false ) {
+		return false;
+	}
+	function owner($file) {
+		$dir = $this->dirlist($file);
+		return $dir[$file]['owner'];
+	}
+	function getchmod($file) {
+		$dir = $this->dirlist($file);
+		return $dir[$file]['permsn'];
+	}
+	function group($file) {
+		$dir = $this->dirlist($file);
+		return $dir[$file]['group'];
+	}
+	function copy($source, $destination, $overwrite = false ) {
+		if ( ! $overwrite && $this->exists($destination) )
+			return false;
+		$content = $this->get_contents($source);
+		if ( false === $content)
+			return false;
+		return $this->put_contents($destination, $content);
+	}
+	function move($source, $destination, $overwrite = false) {
+		return ftp_rename($this->link, $source, $destination);
+	}
+
+	function delete($file, $recursive = false ) {
+		if ( empty($file) )
+			return false;
+		if ( $this->is_file($file) )
+			return @ftp_delete($this->link, $file);
+		if ( !$recursive )
+			return @ftp_rmdir($this->link, $file);
+
+		$filelist = $this->dirlist( trailingslashit($file) );
+		if ( !empty($filelist) )
+			foreach ( $filelist as $delete_file )
+				$this->delete( trailingslashit($file) . $delete_file['name'], $recursive);
+		return @ftp_rmdir($this->link, $file);
+	}
+
+	function exists($file) {
+		$list = @ftp_nlist($this->link, $file);
+		return !empty($list); //empty list = no file, so invert.
+	}
+	function is_file($file) {
+		return $this->exists($file) && !$this->is_dir($file);
+	}
+	function is_dir($path) {
+		$cwd = $this->cwd();
+		$result = @ftp_chdir($this->link, trailingslashit($path) );
+		if ( $result && $path == $this->cwd() || $this->cwd() != $cwd ) {
+			@ftp_chdir($this->link, $cwd);
+			return true;
+		}
+		return false;
+	}
+	function is_readable($file) {
+		//Get dir list, Check if the file is readable by the current user??
+		return true;
+	}
+	function is_writable($file) {
+		//Get dir list, Check if the file is writable by the current user??
+		return true;
+	}
+	function atime($file) {
+		return false;
+	}
+	function mtime($file) {
+		return ftp_mdtm($this->link, $file);
+	}
+	function size($file) {
+		return ftp_size($this->link, $file);
+	}
+	function touch($file, $time = 0, $atime = 0) {
+		return false;
+	}
+	function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
+		if ( !@ftp_mkdir($this->link, $path) )
+			return false;
+		$this->chmod($path, $chmod);
+		if ( $chown )
+			$this->chown($path, $chown);
+		if ( $chgrp )
+			$this->chgrp($path, $chgrp);
+		return true;
+	}
+	function rmdir($path, $recursive = false) {
+		return $this->delete($path, $recursive);
+	}
+
+	function parselisting($line) {
+		static $is_windows;
+		if ( is_null($is_windows) )
+			$is_windows = stripos( ftp_systype($this->link), 'win') !== false;
+
+		if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) {
+			$b = array();
+			if ( $lucifer[3] < 70 )
+				$lucifer[3] +=2000;
+			else
+				$lucifer[3] += 1900; // 4digit year fix
+			$b['isdir'] = ( $lucifer[7] == '<DIR>');
+			if ( $b['isdir'] )
+				$b['type'] = 'd';
+			else
+				$b['type'] = 'f';
+			$b['size'] = $lucifer[7];
+			$b['month'] = $lucifer[1];
+			$b['day'] = $lucifer[2];
+			$b['year'] = $lucifer[3];
+			$b['hour'] = $lucifer[4];
+			$b['minute'] = $lucifer[5];
+			$b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
+			$b['am/pm'] = $lucifer[6];
+			$b['name'] = $lucifer[8];
+		} elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
+			//echo $line."\n";
+			$lcount = count($lucifer);
+			if ( $lcount < 8 )
+				return '';
+			$b = array();
+			$b['isdir'] = $lucifer[0]{0} === 'd';
+			$b['islink'] = $lucifer[0]{0} === 'l';
+			if ( $b['isdir'] )
+				$b['type'] = 'd';
+			elseif ( $b['islink'] )
+				$b['type'] = 'l';
+			else
+				$b['type'] = 'f';
+			$b['perms'] = $lucifer[0];
+			$b['number'] = $lucifer[1];
+			$b['owner'] = $lucifer[2];
+			$b['group'] = $lucifer[3];
+			$b['size'] = $lucifer[4];
+			if ( $lcount == 8 ) {
+				sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']);
+				sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']);
+				$b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
+				$b['name'] = $lucifer[7];
+			} else {
+				$b['month'] = $lucifer[5];
+				$b['day'] = $lucifer[6];
+				if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) {
+					$b['year'] = date("Y");
+					$b['hour'] = $l2[1];
+					$b['minute'] = $l2[2];
+				} else {
+					$b['year'] = $lucifer[7];
+					$b['hour'] = 0;
+					$b['minute'] = 0;
+				}
+				$b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) );
+				$b['name'] = $lucifer[8];
+			}
+		}
+
+		return $b;
+	}
+
+	function dirlist($path = '.', $include_hidden = true, $recursive = false) {
+		if ( $this->is_file($path) ) {
+			$limit_file = basename($path);
+			$path = dirname($path) . '/';
+		} else {
+			$limit_file = false;
+		}
+
+		$pwd = @ftp_pwd($this->link);
+		if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesnt exist
+			return false;
+		$list = @ftp_rawlist($this->link, '-a', false);
+		@ftp_chdir($this->link, $pwd);
+
+		if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least)
+			return false;
+
+		$dirlist = array();
+		foreach ( $list as $k => $v ) {
+			$entry = $this->parselisting($v);
+			if ( empty($entry) )
+				continue;
+
+			if ( '.' == $entry['name'] || '..' == $entry['name'] )
+				continue;
+
+			if ( ! $include_hidden && '.' == $entry['name'][0] )
+				continue;
+
+			if ( $limit_file && $entry['name'] != $limit_file)
+				continue;
+
+			$dirlist[ $entry['name'] ] = $entry;
+		}
+
+		$ret = array();
+		foreach ( (array)$dirlist as $struc ) {
+			if ( 'd' == $struc['type'] ) {
+				if ( $recursive )
+					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
+				else
+					$struc['files'] = array();
+			}
+
+			$ret[ $struc['name'] ] = $struc;
+		}
+		return $ret;
+	}
+
+	function __destruct() {
+		if ( $this->link )
+			ftp_close($this->link);
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-filesystem-ftpsockets.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-filesystem-ftpsockets.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-filesystem-ftpsockets.php	(revision 17487)
@@ -0,0 +1,327 @@
+<?php
+/**
+ * WordPress FTP Sockets Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * WordPress Filesystem Class for implementing FTP Sockets.
+ *
+ * @since 2.5
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
+class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
+	var $ftp = false;
+	var $errors = null;
+	var $options = array();
+
+	function WP_Filesystem_ftpsockets($opt = '') {
+		$this->method = 'ftpsockets';
+		$this->errors = new WP_Error();
+
+		//Check if possible to use ftp functions.
+		if ( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' )
+				return false;
+		$this->ftp = new ftp();
+
+		//Set defaults:
+		if ( empty($opt['port']) )
+			$this->options['port'] = 21;
+		else
+			$this->options['port'] = $opt['port'];
+
+		if ( empty($opt['hostname']) )
+			$this->errors->add('empty_hostname', __('FTP hostname is required'));
+		else
+			$this->options['hostname'] = $opt['hostname'];
+
+		if ( ! empty($opt['base']) )
+			$this->wp_base = $opt['base'];
+
+		// Check if the options provided are OK.
+		if ( empty ($opt['username']) )
+			$this->errors->add('empty_username', __('FTP username is required'));
+		else
+			$this->options['username'] = $opt['username'];
+
+		if ( empty ($opt['password']) )
+			$this->errors->add('empty_password', __('FTP password is required'));
+		else
+			$this->options['password'] = $opt['password'];
+	}
+
+	function connect() {
+		if ( ! $this->ftp )
+			return false;
+
+		$this->ftp->setTimeout(FS_CONNECT_TIMEOUT);
+
+		if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port']) ) {
+			$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
+			return false;
+		}
+
+		if ( ! $this->ftp->connect() ) {
+			$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
+			return false;
+		}
+
+		if ( ! $this->ftp->login($this->options['username'], $this->options['password']) ) {
+			$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
+			return false;
+		}
+
+		$this->ftp->SetType(FTP_AUTOASCII);
+		$this->ftp->Passive(true);
+		$this->ftp->setTimeout(FS_TIMEOUT);
+		return true;
+	}
+
+	function get_contents($file, $type = '', $resumepos = 0) {
+		if ( ! $this->exists($file) )
+			return false;
+
+		if ( empty($type) )
+			$type = FTP_AUTOASCII;
+		$this->ftp->SetType($type);
+
+		$temp = wp_tempnam( $file );
+
+		if ( ! $temphandle = fopen($temp, 'w+') )
+			return false;
+
+		if ( ! $this->ftp->fget($temphandle, $file) ) {
+			fclose($temphandle);
+			unlink($temp);
+			return ''; //Blank document, File does exist, Its just blank.
+		}
+
+		fseek($temphandle, 0); //Skip back to the start of the file being written to
+		$contents = '';
+
+		while ( ! feof($temphandle) )
+			$contents .= fread($temphandle, 8192);
+
+		fclose($temphandle);
+		unlink($temp);
+		return $contents;
+	}
+
+	function get_contents_array($file) {
+		return explode("\n", $this->get_contents($file) );
+	}
+
+	function put_contents($file, $contents, $mode = false ) {
+		$temp = wp_tempnam( $file );
+		if ( ! $temphandle = @fopen($temp, 'w+') ) {
+			unlink($temp);
+			return false;
+		}
+
+		fwrite($temphandle, $contents);
+		fseek($temphandle, 0); //Skip back to the start of the file being written to
+
+		$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
+		$this->ftp->SetType($type);
+
+		$ret = $this->ftp->fput($file, $temphandle);
+
+		fclose($temphandle);
+		unlink($temp);
+
+		$this->chmod($file, $mode);
+
+		return $ret;
+	}
+
+	function cwd() {
+		$cwd = $this->ftp->pwd();
+		if ( $cwd )
+			$cwd = trailingslashit($cwd);
+		return $cwd;
+	}
+
+	function chdir($file) {
+		return $this->ftp->chdir($file);
+	}
+
+	function chgrp($file, $group, $recursive = false ) {
+		return false;
+	}
+
+	function chmod($file, $mode = false, $recursive = false ) {
+		if ( ! $mode ) {
+			if ( $this->is_file($file) )
+				$mode = FS_CHMOD_FILE;
+			elseif ( $this->is_dir($file) )
+				$mode = FS_CHMOD_DIR;
+			else
+				return false;
+		}
+
+		// chmod any sub-objects if recursive.
+		if ( $recursive && $this->is_dir($file) ) {
+			$filelist = $this->dirlist($file);
+			foreach ( (array)$filelist as $filename => $filemeta )
+				$this->chmod($file . '/' . $filename, $mode, $recursive);
+		}
+
+		// chmod the file or directory
+		return $this->ftp->chmod($file, $mode);
+	}
+
+	function chown($file, $owner, $recursive = false ) {
+		return false;
+	}
+
+	function owner($file) {
+		$dir = $this->dirlist($file);
+		return $dir[$file]['owner'];
+	}
+
+	function getchmod($file) {
+		$dir = $this->dirlist($file);
+		return $dir[$file]['permsn'];
+	}
+
+	function group($file) {
+		$dir = $this->dirlist($file);
+		return $dir[$file]['group'];
+	}
+
+	function copy($source, $destination, $overwrite = false ) {
+		if ( ! $overwrite && $this->exists($destination) )
+			return false;
+
+		$content = $this->get_contents($source);
+		if ( false === $content )
+			return false;
+
+		return $this->put_contents($destination, $content);
+	}
+
+	function move($source, $destination, $overwrite = false ) {
+		return $this->ftp->rename($source, $destination);
+	}
+
+	function delete($file, $recursive = false ) {
+		if ( empty($file) )
+			return false;
+		if ( $this->is_file($file) )
+			return $this->ftp->delete($file);
+		if ( !$recursive )
+			return $this->ftp->rmdir($file);
+
+		return $this->ftp->mdel($file);
+	}
+
+	function exists($file) {
+		return $this->ftp->is_exists($file);
+	}
+
+	function is_file($file) {
+		if ( $this->is_dir($file) )
+			return false;
+		if ( $this->exists($file) )
+			return true;
+		return false;
+	}
+
+	function is_dir($path) {
+		$cwd = $this->cwd();
+		if ( $this->chdir($path) ) {
+			$this->chdir($cwd);
+			return true;
+		}
+		return false;
+	}
+
+	function is_readable($file) {
+		//Get dir list, Check if the file is writable by the current user??
+		return true;
+	}
+
+	function is_writable($file) {
+		//Get dir list, Check if the file is writable by the current user??
+		return true;
+	}
+
+	function atime($file) {
+		return false;
+	}
+
+	function mtime($file) {
+		return $this->ftp->mdtm($file);
+	}
+
+	function size($file) {
+		return $this->ftp->filesize($file);
+	}
+
+	function touch($file, $time = 0, $atime = 0 ) {
+		return false;
+	}
+
+	function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
+		if ( ! $this->ftp->mkdir($path) )
+			return false;
+		if ( ! $chmod )
+			$chmod = FS_CHMOD_DIR;
+		$this->chmod($path, $chmod);
+		if ( $chown )
+			$this->chown($path, $chown);
+		if ( $chgrp )
+			$this->chgrp($path, $chgrp);
+		return true;
+	}
+
+	function rmdir($path, $recursive = false ) {
+		$this->delete($path, $recursive);
+	}
+
+	function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
+		if ( $this->is_file($path) ) {
+			$limit_file = basename($path);
+			$path = dirname($path) . '/';
+		} else {
+			$limit_file = false;
+		}
+
+		$list = $this->ftp->dirlist($path);
+		if ( empty($list) && !$this->exists($path) )
+			return false;
+
+		$ret = array();
+		foreach ( $list as $struc ) {
+
+			if ( '.' == $struc['name'] || '..' == $struc['name'] )
+				continue;
+
+			if ( ! $include_hidden && '.' == $struc['name'][0] )
+				continue;
+
+			if ( $limit_file && $struc['name'] != $limit_file )
+				continue;
+
+			if ( 'd' == $struc['type'] ) {
+				if ( $recursive )
+					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
+				else
+					$struc['files'] = array();
+			}
+
+			$ret[ $struc['name'] ] = $struc;
+		}
+		return $ret;
+	}
+
+	function __destruct() {
+		$this->ftp->quit();
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-filesystem-ssh2.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-filesystem-ssh2.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-filesystem-ssh2.php	(revision 17487)
@@ -0,0 +1,383 @@
+<?php
+/**
+ * WordPress SSH2 Filesystem.
+ *
+ * @package WordPress
+ * @subpackage Filesystem
+ */
+
+/**
+ * WordPress Filesystem Class for implementing SSH2.
+ *
+ * To use this class you must follow these steps for PHP 5.2.6+
+ *
+ * @contrib http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes
+ *
+ * Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now, But many users have found the latest versions work)
+ *
+ * cd /usr/src
+ * wget http://surfnet.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.14.tar.gz
+ * tar -zxvf libssh2-0.14.tar.gz
+ * cd libssh2-0.14/
+ * ./configure
+ * make all install
+ *
+ * Note: Do not leave the directory yet!
+ *
+ * Enter: pecl install -f ssh2
+ *
+ * Copy the ssh.so file it creates to your PHP Module Directory.
+ * Open up your PHP.INI file and look for where extensions are placed.
+ * Add in your PHP.ini file: extension=ssh2.so
+ *
+ * Restart Apache!
+ * Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp  exist.
+ *
+ * Note: as of WordPress 2.8, This utilises the PHP5+ function 'stream_get_contents'
+ *
+ * @since 2.7
+ * @package WordPress
+ * @subpackage Filesystem
+ * @uses WP_Filesystem_Base Extends class
+ */
+class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
+
+	var $link = false;
+	var $sftp_link = false;
+	var $keys = false;
+	var $errors = array();
+	var $options = array();
+
+	function WP_Filesystem_SSH2($opt='') {
+		$this->method = 'ssh2';
+		$this->errors = new WP_Error();
+
+		//Check if possible to use ssh2 functions.
+		if ( ! extension_loaded('ssh2') ) {
+			$this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available'));
+			return false;
+		}
+		if ( !function_exists('stream_get_contents') ) {
+			$this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however, we require the PHP5 function <code>stream_get_contents()</code>'));
+			return false;
+		}
+
+		// Set defaults:
+		if ( empty($opt['port']) )
+			$this->options['port'] = 22;
+		else
+			$this->options['port'] = $opt['port'];
+
+		if ( empty($opt['hostname']) )
+			$this->errors->add('empty_hostname', __('SSH2 hostname is required'));
+		else
+			$this->options['hostname'] = $opt['hostname'];
+
+		if ( ! empty($opt['base']) )
+			$this->wp_base = $opt['base'];
+
+		// Check if the options provided are OK.
+		if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) {
+			$this->options['public_key'] = $opt['public_key'];
+			$this->options['private_key'] = $opt['private_key'];
+
+			$this->options['hostkey'] = array('hostkey' => 'ssh-rsa');
+
+			$this->keys = true;
+		} elseif ( empty ($opt['username']) ) {
+			$this->errors->add('empty_username', __('SSH2 username is required'));
+		}
+
+		if ( !empty($opt['username']) )
+			$this->options['username'] = $opt['username'];
+
+		if ( empty ($opt['password']) ) {
+			if ( !$this->keys )	//password can be blank if we are using keys
+				$this->errors->add('empty_password', __('SSH2 password is required'));
+		} else {
+			$this->options['password'] = $opt['password'];
+		}
+
+	}
+
+	function connect() {
+		if ( ! $this->keys ) {
+			$this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);
+		} else {
+			$this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);
+		}
+
+		if ( ! $this->link ) {
+			$this->errors->add('connect', sprintf(__('Failed to connect to SSH2 Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
+			return false;
+		}
+
+		if ( !$this->keys ) {
+			if ( ! @ssh2_auth_password($this->link, $this->options['username'], $this->options['password']) ) {
+				$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
+				return false;
+			}
+		} else {
+			if ( ! @ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) {
+				$this->errors->add('auth', sprintf(__('Public and Private keys incorrect for %s'), $this->options['username']));
+				return false;
+			}
+		}
+
+		$this->sftp_link = ssh2_sftp($this->link);
+
+		return true;
+	}
+
+	function run_command( $command, $returnbool = false) {
+
+		if ( ! $this->link )
+			return false;
+
+		if ( ! ($stream = ssh2_exec($this->link, $command)) ) {
+			$this->errors->add('command', sprintf(__('Unable to perform command: %s'), $command));
+		} else {
+			stream_set_blocking( $stream, true );
+			stream_set_timeout( $stream, FS_TIMEOUT );
+			$data = stream_get_contents( $stream );
+			fclose( $stream );
+
+			if ( $returnbool )
+				return ( $data === false ) ? false : '' != trim($data);
+			else
+				return $data;
+		}
+		return false;
+	}
+
+	function get_contents($file, $type = '', $resumepos = 0 ) {
+		$file = ltrim($file, '/');
+		return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function get_contents_array($file) {
+		$file = ltrim($file, '/');
+		return file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function put_contents($file, $contents, $mode = false ) {
+		$file = ltrim($file, '/');
+		$ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents);
+
+		$this->chmod($file, $mode);
+
+		return false !== $ret;
+	}
+
+	function cwd() {
+		$cwd = $this->run_command('pwd');
+		if ( $cwd )
+			$cwd = trailingslashit($cwd);
+		return $cwd;
+	}
+
+	function chdir($dir) {
+		return $this->run_command('cd ' . $dir, true);
+	}
+
+	function chgrp($file, $group, $recursive = false ) {
+		if ( ! $this->exists($file) )
+			return false;
+		if ( ! $recursive || ! $this->is_dir($file) )
+			return $this->run_command(sprintf('chgrp %o %s', $mode, escapeshellarg($file)), true);
+		return $this->run_command(sprintf('chgrp -R %o %s', $mode, escapeshellarg($file)), true);
+	}
+
+	function chmod($file, $mode = false, $recursive = false) {
+		if ( ! $this->exists($file) )
+			return false;
+
+		if ( ! $mode ) {
+			if ( $this->is_file($file) )
+				$mode = FS_CHMOD_FILE;
+			elseif ( $this->is_dir($file) )
+				$mode = FS_CHMOD_DIR;
+			else
+				return false;
+		}
+
+		if ( ! $recursive || ! $this->is_dir($file) )
+			return $this->run_command(sprintf('chmod %o %s', $mode, escapeshellarg($file)), true);
+		return $this->run_command(sprintf('chmod -R %o %s', $mode, escapeshellarg($file)), true);
+	}
+
+	function chown($file, $owner, $recursive = false ) {
+		if ( ! $this->exists($file) )
+			return false;
+		if ( ! $recursive || ! $this->is_dir($file) )
+			return $this->run_command(sprintf('chown %o %s', $mode, escapeshellarg($file)), true);
+		return $this->run_command(sprintf('chown -R %o %s', $mode, escapeshellarg($file)), true);
+	}
+
+	function owner($file) {
+		$owneruid = @fileowner('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
+		if ( ! $owneruid )
+			return false;
+		if ( ! function_exists('posix_getpwuid') )
+			return $owneruid;
+		$ownerarray = posix_getpwuid($owneruid);
+		return $ownerarray['name'];
+	}
+
+	function getchmod($file) {
+		return substr(decoct(@fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/') )),3);
+	}
+
+	function group($file) {
+		$gid = @filegroup('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
+		if ( ! $gid )
+			return false;
+		if ( ! function_exists('posix_getgrgid') )
+			return $gid;
+		$grouparray = posix_getgrgid($gid);
+		return $grouparray['name'];
+	}
+
+	function copy($source, $destination, $overwrite = false ) {
+		if ( ! $overwrite && $this->exists($destination) )
+			return false;
+		$content = $this->get_contents($source);
+		if ( false === $content)
+			return false;
+		return $this->put_contents($destination, $content);
+	}
+
+	function move($source, $destination, $overwrite = false) {
+		return @ssh2_sftp_rename($this->link, $source, $destination);
+	}
+
+	function delete($file, $recursive = false) {
+		if ( $this->is_file($file) )
+			return ssh2_sftp_unlink($this->sftp_link, $file);
+		if ( ! $recursive )
+			 return ssh2_sftp_rmdir($this->sftp_link, $file);
+		$filelist = $this->dirlist($file);
+		if ( is_array($filelist) ) {
+			foreach ( $filelist as $filename => $fileinfo) {
+				$this->delete($file . '/' . $filename, $recursive);
+			}
+		}
+		return ssh2_sftp_rmdir($this->sftp_link, $file);
+	}
+
+	function exists($file) {
+		$file = ltrim($file, '/');
+		return file_exists('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function is_file($file) {
+		$file = ltrim($file, '/');
+		return is_file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function is_dir($path) {
+		$path = ltrim($path, '/');
+		return is_dir('ssh2.sftp://' . $this->sftp_link . '/' . $path);
+	}
+
+	function is_readable($file) {
+		$file = ltrim($file, '/');
+		return is_readable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function is_writable($file) {
+		$file = ltrim($file, '/');
+		return is_writable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function atime($file) {
+		$file = ltrim($file, '/');
+		return fileatime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function mtime($file) {
+		$file = ltrim($file, '/');
+		return filemtime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function size($file) {
+		$file = ltrim($file, '/');
+		return filesize('ssh2.sftp://' . $this->sftp_link . '/' . $file);
+	}
+
+	function touch($file, $time = 0, $atime = 0) {
+		//Not implmented.
+	}
+
+	function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
+		$path = untrailingslashit($path);
+		if ( ! $chmod )
+			$chmod = FS_CHMOD_DIR;
+		if ( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) )
+			return false;
+		if ( $chown )
+			$this->chown($path, $chown);
+		if ( $chgrp )
+			$this->chgrp($path, $chgrp);
+		return true;
+	}
+
+	function rmdir($path, $recursive = false) {
+		return $this->delete($path, $recursive);
+	}
+
+	function dirlist($path, $include_hidden = true, $recursive = false) {
+		if ( $this->is_file($path) ) {
+			$limit_file = basename($path);
+			$path = dirname($path);
+		} else {
+			$limit_file = false;
+		}
+
+		if ( ! $this->is_dir($path) )
+			return false;
+
+		$ret = array();
+		$dir = @dir('ssh2.sftp://' . $this->sftp_link .'/' . ltrim($path, '/') );
+
+		if ( ! $dir )
+			return false;
+
+		while (false !== ($entry = $dir->read()) ) {
+			$struc = array();
+			$struc['name'] = $entry;
+
+			if ( '.' == $struc['name'] || '..' == $struc['name'] )
+				continue; //Do not care about these folders.
+
+			if ( ! $include_hidden && '.' == $struc['name'][0] )
+				continue;
+
+			if ( $limit_file && $struc['name'] != $limit_file )
+				continue;
+
+			$struc['perms'] 	= $this->gethchmod($path.'/'.$entry);
+			$struc['permsn']	= $this->getnumchmodfromh($struc['perms']);
+			$struc['number'] 	= false;
+			$struc['owner']    	= $this->owner($path.'/'.$entry);
+			$struc['group']    	= $this->group($path.'/'.$entry);
+			$struc['size']    	= $this->size($path.'/'.$entry);
+			$struc['lastmodunix']= $this->mtime($path.'/'.$entry);
+			$struc['lastmod']   = date('M j',$struc['lastmodunix']);
+			$struc['time']    	= date('h:i:s',$struc['lastmodunix']);
+			$struc['type']		= $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
+
+			if ( 'd' == $struc['type'] ) {
+				if ( $recursive )
+					$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
+				else
+					$struc['files'] = array();
+			}
+
+			$ret[ $struc['name'] ] = $struc;
+		}
+		$dir->close();
+		unset($dir);
+		return $ret;
+	}
+}
Index: /tags/3.1/wp-admin/includes/class-wp-importer.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-importer.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-importer.php	(revision 17487)
@@ -0,0 +1,311 @@
+<?php
+/**
+ * WP_Importer base class
+ */
+class WP_Importer {
+	/**
+	 * Class Constructor
+	 *
+	 * @return void
+	 */
+	function __construct() {}
+
+	function WP_Importer() {
+		$this->__construct();
+	}
+
+	/**
+	 * Returns array with imported permalinks from WordPress database
+	 *
+	 * @param string $bid
+	 * @return array
+	 */
+	function get_imported_posts( $importer_name, $bid ) {
+		global $wpdb;
+
+		$hashtable = array();
+
+		$limit = 100;
+		$offset = 0;
+
+		// Grab all posts in chunks
+		do {
+			$meta_key = $importer_name . '_' . $bid . '_permalink';
+			$sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '%s' LIMIT %d,%d", $meta_key, $offset, $limit );
+			$results = $wpdb->get_results( $sql );
+
+			// Increment offset
+			$offset = ( $limit + $offset );
+
+			if ( !empty( $results ) ) {
+				foreach ( $results as $r ) {
+					// Set permalinks into array
+					$hashtable[$r->meta_value] = intval( $r->post_id );
+				}
+			}
+		} while ( count( $results ) == $limit );
+
+		// unset to save memory
+		unset( $results, $r );
+
+		return $hashtable;
+	}
+
+	/**
+	 * Return count of imported permalinks from WordPress database
+	 *
+	 * @param string $bid
+	 * @return int
+	 */
+	function count_imported_posts( $importer_name, $bid ) {
+		global $wpdb;
+
+		$count = 0;
+
+		// Get count of permalinks
+		$meta_key = $importer_name . '_' . $bid . '_permalink';
+		$sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = '%s'", $meta_key );
+
+		$result = $wpdb->get_results( $sql );
+
+		if ( !empty( $result ) )
+			$count = intval( $result[0]->cnt );
+
+		// unset to save memory
+		unset( $results );
+
+		return $count;
+	}
+
+	/**
+	 * Set array with imported comments from WordPress database
+	 *
+	 * @param string $bid
+	 * @return array
+	 */
+	function get_imported_comments( $bid ) {
+		global $wpdb;
+
+		$hashtable = array();
+
+		$limit = 100;
+		$offset = 0;
+
+		// Grab all comments in chunks
+		do {
+			$sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit );
+			$results = $wpdb->get_results( $sql );
+
+			// Increment offset
+			$offset = ( $limit + $offset );
+
+			if ( !empty( $results ) ) {
+				foreach ( $results as $r ) {
+					// Explode comment_agent key
+					list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent );
+					$source_comment_id = intval( $source_comment_id );
+
+					// Check if this comment came from this blog
+					if ( $bid == $ca_bid ) {
+						$hashtable[$source_comment_id] = intval( $r->comment_ID );
+					}
+				}
+			}
+		} while ( count( $results ) == $limit );
+
+		// unset to save memory
+		unset( $results, $r );
+
+		return $hashtable;
+	}
+
+	function set_blog( $blog_id ) {
+		if ( is_numeric( $blog_id ) ) {
+			$blog_id = (int) $blog_id;
+		} else {
+			$blog = 'http://' . preg_replace( '#^https?://#', '', $blog_id );
+			if ( ( !$parsed = parse_url( $blog ) ) || empty( $parsed['host'] ) ) {
+				fwrite( STDERR, "Error: can not determine blog_id from $blog_id\n" );
+				exit();
+			}
+			if ( empty( $parsed['path'] ) )
+				$parsed['path'] = '/';
+			$blog = get_blog_details( array( 'domain' => $parsed['host'], 'path' => $parsed['path'] ) );
+			if ( !$blog ) {
+				fwrite( STDERR, "Error: Could not find blog\n" );
+				exit();
+			}
+			$blog_id = (int) $blog->blog_id;
+			// Restore global $current_blog
+			global $current_blog;
+			$current_blog = $blog;
+		}
+
+		if ( function_exists( 'is_multisite' ) ) {
+			if ( is_multisite() )
+				switch_to_blog( $blog_id );
+		}
+
+		return $blog_id;
+	}
+
+	function set_user( $user_id ) {
+		if ( is_numeric( $user_id ) ) {
+			$user_id = (int) $user_id;
+		} else {
+			$user_id = (int) username_exists( $user_id );
+		}
+
+		if ( !$user_id || !wp_set_current_user( $user_id ) ) {
+			fwrite( STDERR, "Error: can not find user\n" );
+			exit();
+		}
+
+		return $user_id;
+	}
+
+	/**
+	 * Sort by strlen, longest string first
+	 *
+	 * @param string $a
+	 * @param string $b
+	 * @return int
+	 */
+	function cmpr_strlen( $a, $b ) {
+		return strlen( $b ) - strlen( $a );
+	}
+
+	/**
+	 * GET URL
+	 *
+	 * @param string $url
+	 * @param string $username
+	 * @param string $password
+	 * @param bool $head
+	 * @return array
+	 */
+	function get_page( $url, $username = '', $password = '', $head = false ) {
+		// Increase the timeout
+		add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) );
+
+		$headers = array();
+		$args = array();
+		if ( true === $head )
+			$args['method'] = 'HEAD';
+		if ( !empty( $username ) && !empty( $password ) )
+			$headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password" );
+
+		$args['headers'] = $headers;
+
+		return wp_remote_request( $url, $args );
+	}
+
+	/**
+	 * Bump up the request timeout for http requests
+	 *
+	 * @param int $val
+	 * @return int
+	 */
+	function bump_request_timeout( $val ) {
+		return 60;
+	}
+
+	/**
+	 * Check if user has exceeded disk quota
+	 *
+	 * @return bool
+	 */
+	function is_user_over_quota() {
+		global $current_blog;
+
+		if ( function_exists( 'upload_is_user_over_quota' ) ) {
+			if ( upload_is_user_over_quota( 1 ) ) {
+				echo "Sorry, you have used your upload quota.\n";
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * Replace newlines, tabs, and multiple spaces with a single space
+	 *
+	 * @param string $string
+	 * @return string
+	 */
+	function min_whitespace( $string ) {
+		return preg_replace( '|[\r\n\t ]+|', ' ', $string );
+	}
+
+	/**
+	 * Reset global variables that grow out of control during imports
+	 *
+	 * @return void
+	 */
+	function stop_the_insanity() {
+		global $wpdb, $wp_actions;
+		// Or define( 'WP_IMPORTING', true );
+		$wpdb->queries = array();
+		// Reset $wp_actions to keep it from growing out of control
+		$wp_actions = array();
+	}
+}
+
+/**
+ * Returns value of command line params.
+ * Exits when a required param is not set.
+ *
+ * @param string $param
+ * @param bool $required
+ * @return mixed
+ */
+function get_cli_args( $param, $required = false ) {
+	$args = $_SERVER['argv'];
+
+	$out = array();
+
+	$last_arg = null;
+	$return = null;
+
+	$il = sizeof( $args );
+
+	for ( $i = 1, $il; $i < $il; $i++ ) {
+		if ( (bool) preg_match( "/^--(.+)/", $args[$i], $match ) ) {
+			$parts = explode( "=", $match[1] );
+			$key = preg_replace( "/[^a-z0-9]+/", "", $parts[0] );
+
+			if ( isset( $parts[1] ) ) {
+				$out[$key] = $parts[1];
+			} else {
+				$out[$key] = true;
+			}
+
+			$last_arg = $key;
+		} else if ( (bool) preg_match( "/^-([a-zA-Z0-9]+)/", $args[$i], $match ) ) {
+			for ( $j = 0, $jl = strlen( $match[1] ); $j < $jl; $j++ ) {
+				$key = $match[1]{$j};
+				$out[$key] = true;
+			}
+
+			$last_arg = $key;
+		} else if ( $last_arg !== null ) {
+			$out[$last_arg] = $args[$i];
+		}
+	}
+
+	// Check array for specified param
+	if ( isset( $out[$param] ) ) {
+		// Set return value
+		$return = $out[$param];
+	}
+
+	// Check for missing required param
+	if ( !isset( $out[$param] ) && $required ) {
+		// Display message and exit
+		echo "\"$param\" parameter is required but was not specified\n";
+		exit();
+	}
+
+	return $return;
+}
Index: /tags/3.1/wp-admin/includes/class-wp-links-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-links-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-links-list-table.php	(revision 17487)
@@ -0,0 +1,186 @@
+<?php
+/**
+ * Links Manager List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Links_List_Table extends WP_List_Table {
+
+	function WP_Links_List_Table() {
+		parent::WP_List_Table( array(
+			'plural' => 'bookmarks',
+		) );
+	}
+
+	function ajax_user_can() {
+		return current_user_can( 'manage_links' );
+	}
+
+	function prepare_items() {
+		global $cat_id, $s, $orderby, $order;
+
+		wp_reset_vars( array( 'action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'orderby', 'order', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]', 's' ) );
+
+		$args = array( 'hide_invisible' => 0, 'hide_empty' => 0 );
+
+		if ( 'all' != $cat_id )
+			$args['category'] = $cat_id;
+		if ( !empty( $s ) )
+			$args['search'] = $s;
+		if ( !empty( $orderby ) )
+			$args['orderby'] = $orderby;
+		if ( !empty( $order ) )
+			$args['order'] = $order;
+
+		$this->items = get_bookmarks( $args );
+	}
+
+	function no_items() {
+		_e( 'No links found.' );
+	}
+
+	function get_bulk_actions() {
+		$actions = array();
+		$actions['delete'] = __( 'Delete' );
+
+		return $actions;
+	}
+
+	function extra_tablenav( $which ) {
+		global $cat_id;
+
+		if ( 'top' != $which )
+			return;
+?>
+		<div class="alignleft actions">
+<?php
+			$dropdown_options = array(
+				'selected' => $cat_id,
+				'name' => 'cat_id',
+				'taxonomy' => 'link_category',
+				'show_option_all' => __( 'View all categories' ),
+				'hide_empty' => true,
+				'hierarchical' => 1,
+				'show_count' => 0,
+				'orderby' => 'name',
+			);
+			wp_dropdown_categories( $dropdown_options );
+			submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
+?>
+		</div>
+<?php
+	}
+
+	function get_columns() {
+		return array(
+			'cb'         => '<input type="checkbox" />',
+			'name'       => __( 'Name' ),
+			'url'        => __( 'URL' ),
+			'categories' => __( 'Categories' ),
+			'rel'        => __( 'Relationship' ),
+			'visible'    => __( 'Visible' ),
+			'rating'     => __( 'Rating' )
+		);
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'name'    => 'name',
+			'url'     => 'url',
+			'visible' => 'visible',
+			'rating'  => 'rating'
+		);
+	}
+
+	function display_rows() {
+		global $cat_id;
+
+		$alt = 0;
+
+		foreach ( $this->items as $link ) {
+			$link = sanitize_bookmark( $link );
+			$link->link_name = esc_attr( $link->link_name );
+			$link->link_category = wp_get_link_cats( $link->link_id );
+
+			$short_url = url_shorten( $link->link_url );
+
+			$visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' );
+			$rating  = $link->link_rating;
+			$style = ( $alt++ % 2 ) ? '' : ' class="alternate"';
+
+			$edit_link = get_edit_bookmark_link( $link );
+?>
+		<tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
+<?php
+
+			list( $columns, $hidden ) = $this->get_column_info();
+
+			foreach ( $columns as $column_name => $column_display_name ) {
+				$class = "class='column-$column_name'";
+
+				$style = '';
+				if ( in_array( $column_name, $hidden ) )
+					$style = ' style="display:none;"';
+
+				$attributes = $class . $style;
+
+				switch ( $column_name ) {
+					case 'cb':
+						echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'. esc_attr( $link->link_id ) .'" /></th>';
+						break;
+
+					case 'name':
+						echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $link->link_name ) ) . "'>$link->link_name</a></strong><br />";
+
+						$actions = array();
+						$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
+						$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . "</a>";
+						echo $this->row_actions( $actions );
+
+						echo '</td>';
+						break;
+					case 'url':
+						echo "<td $attributes><a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a></td>";
+						break;
+					case 'categories':
+						?><td <?php echo $attributes ?>><?php
+						$cat_names = array();
+						foreach ( $link->link_category as $category ) {
+							$cat = get_term( $category, 'link_category', OBJECT, 'display' );
+							if ( is_wp_error( $cat ) )
+								echo $cat->get_error_message();
+							$cat_name = $cat->name;
+							if ( $cat_id != $category )
+								$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
+							$cat_names[] = $cat_name;
+						}
+						echo implode( ', ', $cat_names );
+						?></td><?php
+						break;
+					case 'rel':
+						?><td <?php echo $attributes ?>><?php echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; ?></td><?php
+						break;
+					case 'visible':
+						?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
+						break;
+					case 'rating':
+	 					?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php
+						break;
+					default:
+						?>
+						<td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td>
+						<?php
+						break;
+				}
+			}
+?>
+		</tr>
+<?php
+		}
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-list-table.php	(revision 17487)
@@ -0,0 +1,894 @@
+<?php
+/**
+ * Base class for displaying a list of items in an ajaxified HTML table.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ */
+
+/**
+ * Base class for displaying a list of items in an ajaxified HTML table.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_List_Table {
+
+	/**
+	 * The current list of items
+	 *
+	 * @since 3.1.0
+	 * @var array
+	 * @access protected
+	 */
+	var $items;
+
+	/**
+	 * Various information about the current table
+	 *
+	 * @since 3.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $_args;
+
+	/**
+	 * Various information needed for displaying the pagination
+	 *
+	 * @since 3.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $_pagination_args = array();
+
+	/**
+	 * The current screen
+	 *
+	 * @since 3.1.0
+	 * @var object
+	 * @access protected
+	 */
+	var $screen;
+
+	/**
+	 * Cached bulk actions
+	 *
+	 * @since 3.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $_actions;
+
+	/**
+	 * Cached pagination output
+	 *
+	 * @since 3.1.0
+	 * @var string
+	 * @access private
+	 */
+	var $_pagination;
+
+	/**
+	 * Constructor. The child class should call this constructor from it's own constructor
+	 *
+	 * @param array $args An associative array with information about the current table
+	 * @access protected
+	 */
+	function WP_List_Table( $args = array() ) {
+		$args = wp_parse_args( $args, array(
+			'plural' => '',
+			'singular' => '',
+			'ajax' => false
+		) );
+
+		$screen = get_current_screen();
+
+		add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 );
+
+		if ( !$args['plural'] )
+			$args['plural'] = $screen->base;
+
+		$this->_args = $args;
+
+		if ( $args['ajax'] ) {
+			// wp_enqueue_script( 'list-table' );
+			add_action( 'admin_footer', array( &$this, '_js_vars' ) );
+		}
+	}
+
+	/**
+	 * Checks the current user's permissions
+	 * @uses wp_die()
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 * @abstract
+	 */
+	function ajax_user_can() {
+		die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
+	}
+
+	/**
+	 * Prepares the list of items for displaying.
+	 * @uses WP_List_Table::set_pagination_args()
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 * @abstract
+	 */
+	function prepare_items() {
+		die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
+	}
+
+	/**
+	 * An internal method that sets all the necessary pagination arguments
+	 *
+	 * @param array $args An associative array with information about the pagination
+	 * @access protected
+	 */
+	function set_pagination_args( $args ) {
+		$args = wp_parse_args( $args, array(
+			'total_items' => 0,
+			'total_pages' => 0,
+			'per_page' => 0,
+		) );
+
+		if ( !$args['total_pages'] && $args['per_page'] > 0 )
+			$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
+
+		$this->_pagination_args = $args;
+	}
+
+	/**
+	 * Access the pagination args
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @param string $key
+	 * @return array
+	 */
+	function get_pagination_arg( $key ) {
+		if ( 'page' == $key )
+			return $this->get_pagenum();
+
+		if ( isset( $this->_pagination_args[$key] ) )
+			return $this->_pagination_args[$key];
+	}
+
+	/**
+	 * Whether the table has items to display or not
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @return bool
+	 */
+	function has_items() {
+		return !empty( $this->items );
+	}
+
+	/**
+	 * Message to be displayed when there are no items
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 */
+	function no_items() {
+		_e( 'No items found.' );
+	}
+
+	/**
+	 * Display the search box.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @param string $text The search button text
+	 * @param string $input_id The search input id
+	 */
+	function search_box( $text, $input_id ) {
+		if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
+			return;
+
+		$input_id = $input_id . '-search-input';
+
+		if ( ! empty( $_REQUEST['orderby'] ) )
+			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
+		if ( ! empty( $_REQUEST['order'] ) )
+			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
+?>
+<p class="search-box">
+	<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
+	<input type="text" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
+	<?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
+</p>
+<?php
+	}
+
+	/**
+	 * Get an associative array ( id => link ) with the list
+	 * of views available on this table.
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @return array
+	 */
+	function get_views() {
+		return array();
+	}
+
+	/**
+	 * Display the bulk actions dropdown.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 */
+	function views() {
+		$screen = get_current_screen();
+
+		$views = $this->get_views();
+		$views = apply_filters( 'views_' . $screen->id, $views );
+
+		if ( empty( $views ) )
+			return;
+
+		echo "<ul class='subsubsub'>\n";
+		foreach ( $views as $class => $view ) {
+			$views[ $class ] = "\t<li class='$class'>$view";
+		}
+		echo implode( " |</li>\n", $views ) . "</li>\n";
+		echo "</ul>";
+	}
+
+	/**
+	 * Get an associative array ( option_name => option_title ) with the list
+	 * of bulk actions available on this table.
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @return array
+	 */
+	function get_bulk_actions() {
+		return array();
+	}
+
+	/**
+	 * Display the bulk actions dropdown.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 */
+	function bulk_actions() {
+		$screen = get_current_screen();
+
+		if ( is_null( $this->_actions ) ) {
+			$no_new_actions = $this->_actions = $this->get_bulk_actions();
+			// This filter can currently only be used to remove actions.
+			$this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions );
+			$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
+			$two = '';
+		} else {
+			$two = '2';
+		}
+
+		if ( empty( $this->_actions ) )
+			return;
+
+		echo "<select name='action$two'>\n";
+		echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions' ) . "</option>\n";
+		foreach ( $this->_actions as $name => $title )
+			echo "\t<option value='$name'>$title</option>\n";
+		echo "</select>\n";
+
+		submit_button( __( 'Apply' ), 'button-secondary action', false, false, array( 'id' => "doaction$two" ) );
+		echo "\n";
+	}
+
+	/**
+	 * Get the current action selected from the bulk actions dropdown.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @return string|bool The action name or False if no action was selected
+	 */
+	function current_action() {
+		if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
+			return $_REQUEST['action'];
+
+		if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
+			return $_REQUEST['action2'];
+
+		return false;
+	}
+
+	/**
+	 * Generate row actions div
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @param array $actions The list of actions
+	 * @param bool $always_visible Wether the actions should be always visible
+	 * @return string
+	 */
+	function row_actions( $actions, $always_visible = false ) {
+		$action_count = count( $actions );
+		$i = 0;
+
+		if ( !$action_count )
+			return '';
+
+		$out = '<div class="' . ( $always_visible ? 'row-actions-visible' : 'row-actions' ) . '">';
+		foreach ( $actions as $action => $link ) {
+			++$i;
+			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+			$out .= "<span class='$action'>$link$sep</span>";
+		}
+		$out .= '</div>';
+
+		return $out;
+	}
+
+	/**
+	 * Display a monthly dropdown for filtering items
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 */
+	function months_dropdown( $post_type ) {
+		global $wpdb, $wp_locale;
+
+		$months = $wpdb->get_results( $wpdb->prepare( "
+			SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
+			FROM $wpdb->posts
+			WHERE post_type = %s
+			ORDER BY post_date DESC
+		", $post_type ) );
+
+		$month_count = count( $months );
+
+		if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
+			return;
+
+		$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
+?>
+		<select name='m'>
+			<option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
+<?php
+		foreach ( $months as $arc_row ) {
+			if ( 0 == $arc_row->year )
+				continue;
+
+			$month = zeroise( $arc_row->month, 2 );
+			$year = $arc_row->year;
+
+			printf( "<option %s value='%s'>%s</option>\n",
+				selected( $m, $year . $month, false ),
+				esc_attr( $arc_row->year . $month ),
+				$wp_locale->get_month( $month ) . " $year"
+			);
+		}
+?>
+		</select>
+<?php
+	}
+
+	/**
+	 * Display a view switcher
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 */
+	function view_switcher( $current_mode ) {
+		$modes = array(
+			'list'    => __( 'List View' ),
+			'excerpt' => __( 'Excerpt View' )
+		);
+
+?>
+		<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
+		<div class="view-switch">
+<?php
+			foreach ( $modes as $mode => $title ) {
+				$class = ( $current_mode == $mode ) ? 'class="current"' : '';
+				echo "<a href='" . esc_url( add_query_arg( 'mode', $mode, $_SERVER['REQUEST_URI'] ) ) . "' $class><img id='view-switch-$mode' src='" . esc_url( includes_url( 'images/blank.gif' ) ) . "' width='20' height='20' title='$title' alt='$title' /></a>\n";
+			}
+		?>
+		</div>
+<?php
+	}
+
+	/**
+	 * Display a comment count bubble
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @param int $post_id
+	 * @param int $pending_comments
+	 */
+	function comments_bubble( $post_id, $pending_comments ) {
+		$pending_phrase = sprintf( __( '%s pending' ), number_format( $pending_comments ) );
+
+		if ( $pending_comments )
+			echo '<strong>';
+
+		echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . "</span></a>";
+
+		if ( $pending_comments )
+			echo '</strong>';
+	}
+
+	/**
+	 * Get the current page number
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @return int
+	 */
+	function get_pagenum() {
+		$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
+
+		if( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
+			$pagenum = $this->_pagination_args['total_pages'];
+
+		return max( 1, $pagenum );
+	}
+
+	/**
+	 * Get number of items to display on a single page
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @return int
+	 */
+	function get_items_per_page( $option, $default = 20 ) {
+		$per_page = (int) get_user_option( $option );
+		if ( empty( $per_page ) || $per_page < 1 )
+			$per_page = $default;
+
+		return (int) apply_filters( $option, $per_page );
+	}
+
+	/**
+	 * Display the pagination.
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 */
+	function pagination( $which ) {
+		if ( empty( $this->_pagination_args ) )
+			return;
+
+		extract( $this->_pagination_args );
+
+		$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
+
+		$current = $this->get_pagenum();
+
+		$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+
+		$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
+
+		$page_links = array();
+
+		$disable_first = $disable_last = '';
+		if ( $current == 1 )
+			$disable_first = ' disabled';
+		if ( $current == $total_pages )
+			$disable_last = ' disabled';
+
+		$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
+			'first-page' . $disable_first,
+			esc_attr__( 'Go to the first page' ),
+			esc_url( remove_query_arg( 'paged', $current_url ) ),
+			'&laquo;'
+		);
+
+		$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
+			'prev-page' . $disable_first,
+			esc_attr__( 'Go to the previous page' ),
+			esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
+			'&lsaquo;'
+		);
+
+		if ( 'bottom' == $which )
+			$html_current_page = $current;
+		else
+			$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='%s' value='%s' size='%d' />",
+				esc_attr__( 'Current page' ),
+				esc_attr( 'paged' ),
+				$current,
+				strlen( $total_pages )
+			);
+
+		$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
+		$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
+
+		$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
+			'next-page' . $disable_last,
+			esc_attr__( 'Go to the next page' ),
+			esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
+			'&rsaquo;'
+		);
+
+		$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
+			'last-page' . $disable_last,
+			esc_attr__( 'Go to the last page' ),
+			esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
+			'&raquo;'
+		);
+
+		$output .= "\n" . join( "\n", $page_links );
+
+		$page_class = $total_pages < 2 ? ' one-page' : '';
+
+		$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
+
+		echo $this->_pagination;
+	}
+
+	/**
+	 * Get a list of columns. The format is:
+	 * 'internal-name' => 'Title'
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 * @abstract
+	 *
+	 * @return array
+	 */
+	function get_columns() {
+		die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
+	}
+
+	/**
+	 * Get a list of sortable columns. The format is:
+	 * 'internal-name' => 'orderby'
+	 * or
+	 * 'internal-name' => array( 'orderby', true )
+	 *
+	 * The second format will make the initial sorting order be descending
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @return array
+	 */
+	function get_sortable_columns() {
+		return array();
+	}
+
+	/**
+	 * Get a list of all, hidden and sortable columns, with filter applied
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @return array
+	 */
+	function get_column_info() {
+		if ( isset( $this->_column_headers ) )
+			return $this->_column_headers;
+
+		$screen = get_current_screen();
+
+		$columns = get_column_headers( $screen );
+		$hidden = get_hidden_columns( $screen );
+
+		$_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
+
+		$sortable = array();
+		foreach ( $_sortable as $id => $data ) {
+			if ( empty( $data ) )
+				continue;
+
+			$data = (array) $data;
+			if ( !isset( $data[1] ) )
+				$data[1] = false;
+
+			$sortable[$id] = $data;
+		}
+
+		$this->_column_headers = array( $columns, $hidden, $sortable );
+
+		return $this->_column_headers;
+	}
+
+	/**
+	 * Return number of visible columns
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @return int
+	 */
+	function get_column_count() {
+		list ( $columns, $hidden ) = $this->get_column_info();
+		$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
+		return count( $columns ) - count( $hidden );
+	}
+
+	/**
+	 * Print column headers, accounting for hidden and sortable columns.
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @param bool $with_id Whether to set the id attribute or not
+	 */
+	function print_column_headers( $with_id = true ) {
+		$screen = get_current_screen();
+
+		list( $columns, $hidden, $sortable ) = $this->get_column_info();
+
+		$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+		$current_url = remove_query_arg( 'paged', $current_url );
+
+		if ( isset( $_GET['orderby'] ) )
+			$current_orderby = $_GET['orderby'];
+		else
+			$current_orderby = '';
+
+		if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
+			$current_order = 'desc';
+		else
+			$current_order = 'asc';
+
+		foreach ( $columns as $column_key => $column_display_name ) {
+			$class = array( 'manage-column', "column-$column_key" );
+
+			$style = '';
+			if ( in_array( $column_key, $hidden ) )
+				$style = 'display:none;';
+
+			$style = ' style="' . $style . '"';
+
+			if ( 'cb' == $column_key )
+				$class[] = 'check-column';
+			elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
+				$class[] = 'num';
+
+			if ( isset( $sortable[$column_key] ) ) {
+				list( $orderby, $desc_first ) = $sortable[$column_key];
+
+				if ( $current_orderby == $orderby ) {
+					$order = 'asc' == $current_order ? 'desc' : 'asc';
+					$class[] = 'sorted';
+					$class[] = $current_order;
+				} else {
+					$order = $desc_first ? 'desc' : 'asc';
+					$class[] = 'sortable';
+					$class[] = $desc_first ? 'asc' : 'desc';
+				}
+
+				$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
+			}
+
+			$id = $with_id ? "id='$column_key'" : '';
+
+			if ( !empty( $class ) )
+				$class = "class='" . join( ' ', $class ) . "'";
+
+			echo "<th scope='col' $id $class $style>$column_display_name</th>";
+		}
+	}
+
+	/**
+	 * Display the table
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 */
+	function display() {
+		extract( $this->_args );
+
+		$this->display_tablenav( 'top' );
+
+?>
+<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
+	<thead>
+	<tr>
+		<?php $this->print_column_headers(); ?>
+	</tr>
+	</thead>
+
+	<tfoot>
+	<tr>
+		<?php $this->print_column_headers( false ); ?>
+	</tr>
+	</tfoot>
+
+	<tbody id="the-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
+		<?php $this->display_rows_or_placeholder(); ?>
+	</tbody>
+</table>
+<?php
+		$this->display_tablenav( 'bottom' );
+	}
+
+	/**
+	 * Get a list of CSS classes for the <table> tag
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @return array
+	 */
+	function get_table_classes() {
+		return array( 'widefat', 'fixed', $this->_args['plural'] );
+	}
+
+	/**
+	 * Generate the table navigation above or below the table
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 */
+	function display_tablenav( $which ) {
+		if ( 'top' == $which )
+			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
+?>
+	<div class="tablenav <?php echo esc_attr( $which ); ?>">
+
+		<div class="alignleft actions">
+			<?php $this->bulk_actions( $which ); ?>
+		</div>
+<?php
+		$this->extra_tablenav( $which );
+		$this->pagination( $which );
+?>
+
+		<br class="clear" />
+	</div>
+<?php
+	}
+
+	/**
+	 * Extra controls to be displayed between bulk actions and pagination
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 */
+	function extra_tablenav( $which ) {}
+
+	/**
+	 * Generate the <tbody> part of the table
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 */
+	function display_rows_or_placeholder() {
+		if ( $this->has_items() ) {
+			$this->display_rows();
+		} else {
+			list( $columns, $hidden ) = $this->get_column_info();
+			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
+			$this->no_items();
+			echo '</td></tr>';
+		}
+	}
+
+	/**
+	 * Generate the table rows
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 */
+	function display_rows() {
+		foreach ( $this->items as $item )
+			$this->single_row( $item );
+	}
+
+	/**
+	 * Generates content for a single row of the table
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @param object $item The current item
+	 */
+	function single_row( $item ) {
+		static $row_class = '';
+		$row_class = ( $row_class == '' ? ' class="alternate"' : '' );
+
+		echo '<tr' . $row_class . '>';
+		echo $this->single_row_columns( $item );
+		echo '</tr>';
+	}
+
+	/**
+	 * Generates the columns for a single row of the table
+	 *
+	 * @since 3.1.0
+	 * @access protected
+	 *
+	 * @param object $item The current item
+	 */
+	function single_row_columns( $item ) {
+		list( $columns, $hidden ) = $this->get_column_info();
+
+		foreach ( $columns as $column_name => $column_display_name ) {
+			$class = "class='$column_name column-$column_name'";
+
+			$style = '';
+			if ( in_array( $column_name, $hidden ) )
+				$style = ' style="display:none;"';
+
+			$attributes = "$class$style";
+
+			if ( 'cb' == $column_name ) {
+				echo '<th scope="row" class="check-column">';
+				echo $this->column_cb( $item );
+				echo '</th>';
+			}
+			elseif ( method_exists( $this, 'column_' . $column_name ) ) {
+				echo "<td $attributes>";
+				echo call_user_func( array( &$this, 'column_' . $column_name ), $item );
+				echo "</td>";
+			}
+			else {
+				echo "<td $attributes>";
+				echo $this->column_default( $item, $column_name );
+				echo "</td>";
+			}
+		}
+	}
+
+	/**
+	 * Handle an incoming ajax request (called from admin-ajax.php)
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 */
+	function ajax_response() {
+		$this->prepare_items();
+
+		extract( $this->_args );
+		extract( $this->_pagination_args );
+
+		ob_start();
+		if ( ! empty( $_REQUEST['no_placeholder'] ) )
+			$this->display_rows();
+		else
+			$this->display_rows_or_placeholder();
+
+		$rows = ob_get_clean();
+
+		$response = array( 'rows' => $rows );
+
+		if ( isset( $total_items ) )
+			$response['total_items_i18n'] = sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) );
+
+		if ( isset( $total_pages ) ) {
+			$response['total_pages'] = $total_pages;
+			$response['total_pages_i18n'] = number_format_i18n( $total_pages );
+		}
+
+		die( json_encode( $response ) );
+	}
+
+	/**
+	 * Send required variables to JavaScript land
+	 *
+	 * @access private
+	 */
+	function _js_vars() {
+		$args = array(
+			'class' => get_class( $this ),
+			'screen' => get_current_screen()
+		);
+
+		printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
+	}
+}
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-media-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-media-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-media-list-table.php	(revision 17487)
@@ -0,0 +1,374 @@
+<?php
+/**
+ * Media Library List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Media_List_Table extends WP_List_Table {
+
+	function WP_Media_List_Table() {
+		$this->detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
+
+		parent::WP_List_Table( array(
+			'plural' => 'media'
+		) );
+	}
+
+	function ajax_user_can() {
+		return current_user_can('upload_files');
+	}
+
+	function prepare_items() {
+		global $lost, $wpdb, $wp_query, $post_mime_types, $avail_post_mime_types;
+
+		$q = $_REQUEST;
+
+		if ( !empty( $lost ) )
+			$q['post__in'] = implode( ',', $lost );
+
+		list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $q );
+
+ 		$this->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status'];
+
+		$this->set_pagination_args( array(
+			'total_items' => $wp_query->found_posts,
+			'total_pages' => $wp_query->max_num_pages,
+			'per_page' => $wp_query->query_vars['posts_per_page'],
+		) );
+	}
+
+	function get_views() {
+		global $wpdb, $post_mime_types, $avail_post_mime_types;
+
+		$type_links = array();
+		$_num_posts = (array) wp_count_attachments();
+		$_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
+		if ( !isset( $total_orphans ) )
+				$total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" );
+		$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] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
+
+		$class = ( empty($_GET['post_mime_type']) && !$this->detached && !isset($_GET['status']) ) ? ' class="current"' : '';
+		$type_links['all'] = "<a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>';
+		foreach ( $post_mime_types as $mime_type => $label ) {
+			$class = '';
+
+			if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
+				continue;
+
+			if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
+				$class = ' class="current"';
+			if ( !empty( $num_posts[$mime_type] ) )
+				$type_links[$mime_type] = "<a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
+		}
+		$type_links['detached'] = '<a href="upload.php?detached=1"' . ( $this->detached ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</a>';
+
+		if ( !empty($_num_posts['trash']) )
+			$type_links['trash'] = '<a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>';
+
+		return $type_links;
+	}
+
+	function get_bulk_actions() {
+		$actions = array();
+		$actions['delete'] = __( 'Delete Permanently' );
+		if ( $this->detached )
+			$actions['attach'] = __( 'Attach to a post' );
+
+		return $actions;
+	}
+
+	function extra_tablenav( $which ) {
+		global $post_type;
+		$post_type_obj = get_post_type_object( $post_type );
+?>
+		<div class="alignleft actions">
+<?php
+		if ( 'top' == $which && !is_singular() && !$this->detached && !$this->is_trash ) {
+			$this->months_dropdown( $post_type );
+
+			do_action( 'restrict_manage_posts' );
+			submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
+		}
+
+		if ( $this->detached ) {
+			submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false );
+		} elseif ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
+			submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false );
+		} ?>
+		</div>
+<?php
+	}
+
+	function current_action() {
+		if ( isset( $_REQUEST['find_detached'] ) )
+			return 'find_detached';
+
+		if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
+			return 'attach';
+
+		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
+			return 'delete_all';
+
+		return parent::current_action();
+	}
+
+	function has_items() {
+		return have_posts();
+	}
+
+	function no_items() {
+		_e( 'No media attachments found.' );
+	}
+
+	function get_columns() {
+		$posts_columns = array();
+		$posts_columns['cb'] = '<input type="checkbox" />';
+		$posts_columns['icon'] = '';
+		/* translators: column name */
+		$posts_columns['title'] = _x( 'File', 'column name' );
+		$posts_columns['author'] = __( 'Author' );
+		//$posts_columns['tags'] = _x( 'Tags', 'column name' );
+		/* translators: column name */
+		if ( !$this->detached ) {
+			$posts_columns['parent'] = _x( 'Attached to', 'column name' );
+			$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
+		}
+		/* translators: column name */
+		$posts_columns['date'] = _x( 'Date', 'column name' );
+		$posts_columns = apply_filters( 'manage_media_columns', $posts_columns, $this->detached );
+
+		return $posts_columns;
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'title'    => 'title',
+			'author'   => 'author',
+			'parent'   => 'parent',
+			'comments' => 'comment_count',
+			'date'     => array( 'date', true ),
+		);
+	}
+
+	function display_rows() {
+		global $post, $id;
+
+		add_filter( 'the_title','esc_html' );
+		$alt = '';
+
+		while ( have_posts() ) : the_post();
+
+			if ( $this->is_trash && $post->post_status != 'trash'
+			||  !$this->is_trash && $post->post_status == 'trash' )
+				continue;
+
+			$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
+			$post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other';
+			$att_title = _draft_or_post_title();
+?>
+	<tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
+<?php
+
+list( $columns, $hidden ) = $this->get_column_info();
+foreach ( $columns as $column_name => $column_display_name ) {
+	$class = "class='$column_name column-$column_name'";
+
+	$style = '';
+	if ( in_array( $column_name, $hidden ) )
+		$style = ' style="display:none;"';
+
+	$attributes = $class . $style;
+
+	switch ( $column_name ) {
+
+	case 'cb':
+?>
+		<th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /><?php } ?></th>
+<?php
+		break;
+
+	case 'icon':
+		$attributes = 'class="column-icon media-icon"' . $style;
+?>
+		<td <?php echo $attributes ?>><?php
+			if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
+				if ( $this->is_trash ) {
+					echo $thumb;
+				} else {
+?>
+				<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
+					<?php echo $thumb; ?>
+				</a>
+
+<?php			}
+			}
+?>
+		</td>
+<?php
+		break;
+
+	case 'title':
+?>
+		<td <?php echo $attributes ?>><strong><?php if ( $this->is_trash ) echo $att_title; else { ?><a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>"><?php echo $att_title; ?></a><?php } ?></strong>
+			<p>
+<?php
+			if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
+				echo esc_html( strtoupper( $matches[1] ) );
+			else
+				echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
+?>
+			</p>
+<?php
+		echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
+?>
+		</td>
+<?php
+		break;
+
+	case 'author':
+?>
+		<td <?php echo $attributes ?>><?php the_author() ?></td>
+<?php
+		break;
+
+	case 'tags':
+?>
+		<td <?php echo $attributes ?>><?php
+		$tags = get_the_tags();
+		if ( !empty( $tags ) ) {
+			$out = array();
+			foreach ( $tags as $c )
+				$out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'post_tag', 'display' ) ) . "</a>";
+			echo join( ', ', $out );
+		} else {
+			_e( 'No Tags' );
+		}
+?>
+		</td>
+<?php
+		break;
+
+	case 'desc':
+?>
+		<td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
+<?php
+		break;
+
+	case 'date':
+		if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
+			$t_time = $h_time = __( 'Unpublished' );
+		} else {
+			$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
+			$m_time = $post->post_date;
+			$time = get_post_time( 'G', true, $post, false );
+			if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
+				if ( $t_diff < 0 )
+					$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 echo $attributes ?>><?php echo $h_time ?></td>
+<?php
+		break;
+
+	case 'parent':
+		if ( $post->post_parent > 0 ) {
+			if ( get_post( $post->post_parent ) ) {
+				$title =_draft_or_post_title( $post->post_parent );
+			}
+?>
+			<td <?php echo $attributes ?>>
+				<strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>,
+				<?php echo get_the_time( __( 'Y/m/d' ) ); ?>
+			</td>
+<?php
+		} else {
+?>
+			<td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
+			<a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' );return false;" href="#the-list"><?php _e( 'Attach' ); ?></a></td>
+<?php
+		}
+		break;
+
+	case 'comments':
+		$attributes = 'class="comments column-comments num"' . $style;
+?>
+		<td <?php echo $attributes ?>>
+			<div class="post-com-count-wrapper">
+<?php
+		$pending_comments = get_pending_comments_num( $post->ID );
+
+		$this->comments_bubble( $post->ID, $pending_comments );
+?>
+			</div>
+		</td>
+<?php
+		break;
+
+	default:
+?>
+		<td <?php echo $attributes ?>>
+			<?php do_action( 'manage_media_custom_column', $column_name, $id ); ?>
+		</td>
+<?php
+		break;
+	}
+}
+?>
+	</tr>
+<?php endwhile;
+	}
+
+	function _get_row_actions( $post, $att_title ) {
+		$actions = array();
+
+		if ( $this->detached ) {
+			if ( current_user_can( 'edit_post', $post->ID ) )
+				$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
+			if ( current_user_can( 'delete_post', $post->ID ) )
+				if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
+					$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-attachment_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
+				} else {
+					$delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
+					$actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-attachment_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
+				}
+			$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
+			if ( current_user_can( 'edit_post', $post->ID ) )
+				$actions['attach'] = '<a href="#the-list" onclick="findPosts.open( \'media[]\',\''.$post->ID.'\' );return false;" class="hide-if-no-js">'.__( 'Attach' ).'</a>';
+		}
+		else {
+			if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash )
+				$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
+			if ( current_user_can( 'delete_post', $post->ID ) ) {
+				if ( $this->is_trash )
+					$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$post->ID", 'untrash-attachment_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
+				elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
+					$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-attachment_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
+				if ( $this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) {
+					$delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
+					$actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-attachment_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
+				}
+			}
+			if ( !$this->is_trash ) {
+				$title =_draft_or_post_title( $post->post_parent );
+				$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
+			}
+		}
+
+		$actions = apply_filters( 'media_row_actions', $actions, $post, $this->detached );
+
+		return $actions;
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-ms-sites-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-ms-sites-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-ms-sites-list-table.php	(revision 17487)
@@ -0,0 +1,340 @@
+<?php
+/**
+ * Sites List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_MS_Sites_List_Table extends WP_List_Table {
+
+	function WP_MS_Sites_List_Table() {
+		parent::WP_List_Table( array(
+			'plural' => 'sites',
+		) );
+	}
+
+	function ajax_user_can() {
+		return current_user_can( 'manage_sites' );
+	}
+
+	function prepare_items() {
+		global $s, $mode, $wpdb, $current_site;
+
+		$mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
+
+		$per_page = $this->get_items_per_page( 'sites_network_per_page' );
+
+		$pagenum = $this->get_pagenum();
+
+		$s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : '';
+		$wild = '';
+		if ( false !== strpos($s, '*') ) {
+			$wild = '%';
+			$s = trim($s, '*');
+		}
+
+		$like_s = esc_sql( like_escape( $s ) );
+
+		$large_network = false;
+		// If the network is large and a search is not being performed, show only the latest blogs with no paging in order
+		// to avoid expensive count queries.
+		if ( !$s && ( get_blog_count() >= 10000 ) ) {
+			if ( !isset($_REQUEST['orderby']) )
+				$_GET['orderby'] = $_REQUEST['orderby'] = '';
+			if ( !isset($_REQUEST['order']) )
+				$_GET['order'] = $_REQUEST['order'] = 'DESC';
+			$large_network = true;
+		}
+
+		$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
+
+		if ( empty($s) ) {
+			// Nothing to do.
+		} elseif ( preg_match('/^[0-9]+\./', $s) ) {
+			// IP address
+			$reg_blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE ( '{$like_s}$wild' )" );
+
+			if ( !$reg_blog_ids )
+				$reg_blog_ids = array( 0 );
+
+			$query = "SELECT *
+				FROM {$wpdb->blogs}
+				WHERE site_id = '{$wpdb->siteid}'
+				AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")";
+		} else {
+			if ( is_numeric($s) ) {
+				$query .= " AND ( {$wpdb->blogs}.blog_id = '{$like_s}' )";
+			} elseif ( is_subdomain_install() ) {
+				$blog_s = str_replace( '.' . $current_site->domain, '', $like_s );
+				$blog_s .= $wild . '.' . $current_site->domain;
+				$query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ) ";
+			} else {
+				if ( $like_s != trim('/', $current_site->path) )
+					$blog_s = $current_site->path .= $like_s . $wild . '/';
+				else
+					$blog_s = $like_s;
+				$query .= " AND  ( {$wpdb->blogs}.path LIKE '$blog_s' )";
+			}
+		}
+
+		$order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
+		if ( $order_by == 'registered' ) {
+			$query .= ' ORDER BY registered ';
+		} elseif ( $order_by == 'lastupdated' ) {
+			$query .= ' ORDER BY last_updated ';
+		} elseif ( $order_by == 'blogname' ) {
+			if ( is_subdomain_install() )
+				$query .= ' ORDER BY domain ';
+			else
+				$query .= ' ORDER BY path ';
+		} elseif ( $order_by == 'blog_id' ) {
+			$query .= ' ORDER BY blog_id ';
+		} else {
+			$order_by = null;
+		}
+
+		if ( isset( $order_by ) ) {
+			$order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
+			$query .= $order;
+		}
+
+		// Don't do an unbounded count on large networks
+		if ( ! $large_network )
+			$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
+
+		$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
+		$this->items = $wpdb->get_results( $query, ARRAY_A );
+
+		if ( $large_network )
+			$total = count($this->items);
+
+		$this->set_pagination_args( array(
+			'total_items' => $total,
+			'per_page' => $per_page,
+		) );
+	}
+
+	function no_items() {
+		_e( 'No sites found.' );
+	}
+
+	function get_bulk_actions() {
+		$actions = array();
+		if ( current_user_can( 'delete_sites' ) )
+			$actions['delete'] = __( 'Delete' );
+		$actions['spam'] = _x( 'Mark as Spam', 'site' );
+		$actions['notspam'] = _x( 'Not Spam', 'site' );
+
+		return $actions;
+	}
+
+	function pagination( $which ) {
+		global $mode;
+
+		parent::pagination( $which );
+
+		if ( 'top' == $which )
+			$this->view_switcher( $mode );
+	}
+
+	function get_columns() {
+		$blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
+		$sites_columns = array(
+			'cb'          => '<input type="checkbox" />',
+			'blogname'    => $blogname_columns,
+			'lastupdated' => __( 'Last Updated' ),
+			'registered'  => _x( 'Registered', 'site' ),
+			'users'       => __( 'Users' )
+		);
+
+		if ( has_filter( 'wpmublogsaction' ) )
+			$sites_columns['plugins'] = __( 'Actions' );
+
+		$sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns );
+
+		return $sites_columns;
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'blogname'    => 'blogname',
+			'lastupdated' => 'lastupdated',
+			'registered'  => 'blog_id',
+		);
+	}
+
+	function display_rows() {
+		global $current_site, $mode;
+
+		$status_list = array(
+			'archived' => array( 'site-archived', __( 'Archived' ) ),
+			'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
+			'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
+			'mature'   => array( 'site-mature', __( 'Mature' ) )
+		);
+
+		$class = '';
+		foreach ( $this->items as $blog ) {
+			$class = ( 'alternate' == $class ) ? '' : 'alternate';
+			reset( $status_list );
+
+			$blog_states = array();
+			foreach ( $status_list as $status => $col ) {
+				if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
+					$class = $col[0];
+					$blog_states[] = $col[1];
+				}
+			}
+			$blog_state = '';
+			if ( ! empty( $blog_states ) ) {
+				$state_count = count( $blog_states );
+				$i = 0;
+				$blog_state .= ' - ';
+				foreach ( $blog_states as $state ) {
+					++$i;
+					( $i == $state_count ) ? $sep = '' : $sep = ', ';
+					$blog_state .= "<span class='post-state'>$state$sep</span>";
+				}
+			}
+			echo "<tr class='$class'>";
+
+			$blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
+
+			list( $columns, $hidden ) = $this->get_column_info();
+
+			foreach ( $columns as $column_name => $column_display_name ) {
+				$style = '';
+				if ( in_array( $column_name, $hidden ) )
+					$style = ' style="display:none;"';
+
+				switch ( $column_name ) {
+					case 'cb': ?>
+						<th scope="row" class="check-column">
+							<input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
+						</th>
+					<?php
+					break;
+
+					case 'id':?>
+						<th valign="top" scope="row">
+							<?php echo $blog['blog_id'] ?>
+						</th>
+					<?php
+					break;
+
+					case 'blogname':
+						echo "<td class='column-$column_name $column_name'$style>"; ?>
+							<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
+							<?php
+							if ( 'list' != $mode )
+								echo '<p>' . sprintf( _x( '%1$s &#8211; <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '</p>';
+
+							// Preordered.
+							$actions = array(
+								'edit' => '', 'backend' => '',
+								'activate' => '', 'deactivate' => '',
+								'archive' => '', 'unarchive' => '',
+								'spam' => '', 'unspam' => '',
+								'delete' => '',
+								'visit' => '',
+							);
+
+							$actions['edit']	= '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
+							$actions['backend']	= "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
+							if ( $current_site->blog_id != $blog['blog_id'] ) {
+								if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
+									$actions['activate']	= '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
+								else
+									$actions['deactivate']	= '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>';
+
+								if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
+									$actions['unarchive']	= '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=unarchiveblog&amp;id=' .  $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>';
+								else
+									$actions['archive']	= '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
+
+								if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
+									$actions['unspam']	= '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
+								else
+									$actions['spam']	= '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
+
+								if ( current_user_can( 'delete_site', $blog['blog_id'] ) )
+									$actions['delete']	= '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'edit.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] . '&amp;msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>';
+							}
+
+							$actions['visit']	= "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
+
+							$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
+							echo $this->row_actions( $actions );
+					?>
+						</td>
+					<?php
+					break;
+
+					case 'lastupdated':
+						echo "<td valign='top' class='$column_name column-$column_name'$style>";
+							if ( 'list' == $mode )
+								$date = 'Y/m/d';
+							else
+								$date = 'Y/m/d \<\b\r \/\> g:i:s a';
+							echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?>
+						</td>
+					<?php
+					break;
+				case 'registered':
+						echo "<td valign='top' class='$column_name column-$column_name'$style>";
+						if ( $blog['registered'] == '0000-00-00 00:00:00' )
+							echo '&#x2014;';
+						else
+							echo mysql2date( $date, $blog['registered'] );
+						?>
+						</td>
+					<?php
+					break;
+				case 'users':
+						echo "<td valign='top' class='$column_name column-$column_name'$style>";
+							$blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) );
+							if ( is_array( $blogusers ) ) {
+								$blogusers_warning = '';
+								if ( count( $blogusers ) > 5 ) {
+									$blogusers = array_slice( $blogusers, 0, 5 );
+									$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'More' ) . '</a>';
+								}
+								foreach ( $blogusers as $user_object ) {
+									echo '<a href="' . esc_url( network_admin_url( 'user-edit.php?user_id=' . $user_object->ID ) ) . '">' . esc_html( $user_object->user_login ) . '</a> ';
+									if ( 'list' != $mode )
+										echo '( ' . $user_object->user_email . ' )';
+									echo '<br />';
+								}
+								if ( $blogusers_warning != '' )
+									echo '<strong>' . $blogusers_warning . '</strong><br />';
+							}
+							?>
+						</td>
+					<?php
+					break;
+
+				case 'plugins': ?>
+					<?php if ( has_filter( 'wpmublogsaction' ) ) {
+					echo "<td valign='top' class='$column_name column-$column_name'$style>";
+						do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
+					</td>
+					<?php }
+					break;
+
+				default:
+					echo "<td class='$column_name column-$column_name'$style>";
+					do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
+					echo "</td>";
+					break;
+				}
+			}
+			?>
+			</tr>
+			<?php
+		}
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-ms-themes-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-ms-themes-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-ms-themes-list-table.php	(revision 17487)
@@ -0,0 +1,361 @@
+<?php
+/**
+ * MS Themes List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_MS_Themes_List_Table extends WP_List_Table {
+
+	var $site_id;
+	var $is_site_themes;
+
+	function WP_MS_Themes_List_Table() {
+		global $status, $page;
+
+		$default_status = get_user_option( 'themes_last_view' );
+		if ( empty( $default_status ) )
+			$default_status = 'all';
+		$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : $default_status;
+		if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search' ) ) )
+			$status = 'all';
+		if ( $status != $default_status && 'search' != $status )
+			update_user_meta( get_current_user_id(), 'themes_last_view', $status );
+
+		$page = $this->get_pagenum();
+
+		$screen = get_current_screen();
+		$this->is_site_themes = ( 'site-themes-network' == $screen->id ) ? true : false;
+
+		if ( $this->is_site_themes )
+			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
+
+		parent::WP_List_Table( array(
+			'plural' => 'themes'
+		) );
+	}
+
+	function get_table_classes() {
+		return array( 'widefat', 'plugins' );	// todo: remove and add CSS for .themes
+	}
+
+	function ajax_user_can() {
+		$menu_perms = get_site_option( 'menu_items', array() );
+
+		if ( empty( $menu_perms['themes'] ) && ! is_super_admin() )
+			return false;
+
+		if ( $this->is_site_themes && !current_user_can('manage_sites') )
+			return false;
+		elseif ( !$this->is_site_themes && !current_user_can('manage_network_themes') )
+			return false;
+		return true;
+	}
+
+	function prepare_items() {
+		global $status, $themes, $totals, $page, $orderby, $order, $s;
+
+		wp_reset_vars( array( 'orderby', 'order', 's' ) );
+
+		$themes = array(
+			'all' => apply_filters( 'all_themes', get_themes() ),
+			'search' => array(),
+			'enabled' => array(),
+			'disabled' => array(),
+			'upgrade' => array()
+		);
+
+		$site_allowed_themes = get_site_allowed_themes();
+		if ( !$this->is_site_themes ) {
+			$allowed_themes = $site_allowed_themes;
+			$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' );
+		} else {
+			$allowed_themes = wpmu_get_blog_allowedthemes( $this->site_id );
+			$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' );
+		}
+
+		$current = get_site_transient( 'update_themes' );
+
+		foreach ( (array) $themes['all'] as $key => $theme ) {
+			$theme_key = $theme['Stylesheet'];
+
+			if ( isset( $allowed_themes [ $theme_key ] ) )  {
+				$themes['all'][$key]['enabled'] = true;
+				$themes['enabled'][$key] = $themes['all'][$key];
+			}
+			else {
+				$themes['all'][$key]['enabled'] = false;
+				$themes['disabled'][$key] = $themes['all'][$key];
+			}
+			if ( isset( $current->response[ $theme['Template'] ] ) )
+				$themes['upgrade'][$key] = $themes['all'][$key];
+
+			if ( $this->is_site_themes && isset( $site_allowed_themes[$theme_key] ) ) {
+				unset( $themes['all'][$key] );
+				unset( $themes['enabled'][$key] );
+				unset( $themes['disabled'][$key] );
+			}
+		}
+
+		if ( !current_user_can( 'update_themes' ) || $this->is_site_themes )
+			$themes['upgrade'] = array();
+
+		if ( $s ) {
+			$status = 'search';
+			$themes['search'] = array_filter( $themes['all'], array( &$this, '_search_callback' ) );
+		}
+
+		$totals = array();
+		foreach ( $themes as $type => $list )
+			$totals[ $type ] = count( $list );
+
+		if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
+			$status = 'all';
+
+		$this->items = $themes[ $status ];
+		$total_this_page = $totals[ $status ];
+
+		if ( $orderby ) {
+			$orderby = ucfirst( $orderby );
+			$order = strtoupper( $order );
+
+			uasort( $this->items, array( &$this, '_order_callback' ) );
+		}
+
+		$start = ( $page - 1 ) * $themes_per_page;
+
+		if ( $total_this_page > $themes_per_page )
+			$this->items = array_slice( $this->items, $start, $themes_per_page );
+
+		$this->set_pagination_args( array(
+			'total_items' => $total_this_page,
+			'per_page' => $themes_per_page,
+		) );
+	}
+
+	function _search_callback( $theme ) {
+		static $term;
+		if ( is_null( $term ) )
+			$term = stripslashes( $_REQUEST['s'] );
+
+		$search_fields = array( 'Name', 'Title', 'Description', 'Author', 'Author Name', 'Author URI', 'Template', 'Stylesheet' );
+		foreach ( $search_fields as $field )
+			if ( stripos( $theme[ $field ], $term ) !== false )
+				return true;
+
+		return false;
+	}
+
+	function _order_callback( $theme_a, $theme_b ) {
+		global $orderby, $order;
+
+		$a = $theme_a[$orderby];
+		$b = $theme_b[$orderby];
+
+		if ( $a == $b )
+			return 0;
+
+		if ( 'DESC' == $order )
+			return ( $a < $b ) ? 1 : -1;
+		else
+			return ( $a < $b ) ? -1 : 1;
+	}
+
+	function no_items() {
+		global $themes;
+
+		if ( !empty( $themes['all'] ) )
+			_e( 'No themes found.' );
+		else
+			_e( 'You do not appear to have any themes available at this time.' );
+	}
+
+	function get_columns() {
+		global $status;
+
+		return array(
+			'cb'          => '<input type="checkbox" />',
+			'name'        => __( 'Theme' ),
+			'description' => __( 'Description' ),
+		);
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'name'         => 'name',
+		);
+	}
+
+	function get_views() {
+		global $totals, $status;
+
+		$status_links = array();
+		foreach ( $totals as $type => $count ) {
+			if ( !$count )
+				continue;
+
+			switch ( $type ) {
+				case 'all':
+					$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes' );
+					break;
+				case 'enabled':
+					$text = _n( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count );
+					break;
+				case 'disabled':
+					$text = _n( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count );
+					break;
+				case 'upgrade':
+					$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
+					break;
+			}
+
+			if ( $this->is_site_themes )
+				$url = 'site-themes.php?id=' . $this->site_id;
+			else
+				$url = 'themes.php';
+
+			if ( 'search' != $type ) {
+				$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
+					esc_url( add_query_arg('theme_status', $type, $url) ),
+					( $type == $status ) ? ' class="current"' : '',
+					sprintf( $text, number_format_i18n( $count ) )
+				);
+			}
+		}
+
+		return $status_links;
+	}
+
+	function get_bulk_actions() {
+		global $status;
+
+		$actions = array();
+		if ( 'enabled' != $status )
+			$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
+		if ( 'disabled' != $status )
+			$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
+		if ( ! $this->is_site_themes ) {
+			if ( current_user_can( 'delete_themes' ) )
+				$actions['delete-selected'] = __( 'Delete' );
+			if ( current_user_can( 'update_themes' ) )
+				$actions['update-selected'] = __( 'Update' );
+		}
+		return $actions;
+	}
+
+	function bulk_actions( $which ) {
+		global $status;
+		parent::bulk_actions( $which );
+	}
+
+	function current_action() {
+		return parent::current_action();
+	}
+
+	function display_rows() {
+		foreach ( $this->items as $key => $theme )
+			$this->single_row( $key, $theme );
+	}
+
+	function single_row( $key, $theme ) {
+		global $status, $page, $s;
+
+		$context = $status;
+
+		if ( $this->is_site_themes )
+			$url = "site-themes.php?id={$this->site_id}&amp;";
+		else
+			$url = 'themes.php?';
+
+		// preorder
+		$actions = array(
+			'enable' => '',
+			'disable' => '',
+			'edit' => '',
+			'delete' => ''
+		);
+
+		$theme_key = $theme['Stylesheet'];
+
+		if ( empty( $theme['enabled'] ) )
+			$actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
+		else
+			$actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
+
+		if ( current_user_can('edit_themes') )
+			$actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . urlencode( $theme['Name'] )) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
+
+		if ( empty( $theme['enabled'] ) && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) )
+			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;checked[]=' . $theme_key . '&amp;theme_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
+
+		$actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
+		$actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
+
+		$class = empty( $theme['enabled'] ) ? 'inactive' : 'active';
+		$checkbox_id = "checkbox_" . md5($theme['Name']);
+		$checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme['Name'] . "</label>";
+
+		$description = '<p>' . $theme['Description'] . '</p>';
+		$theme_name = $theme['Name'];
+
+		$id = sanitize_title( $theme_name );
+
+		echo "<tr id='$id' class='$class'>";
+
+		list( $columns, $hidden ) = $this->get_column_info();
+
+		foreach ( $columns as $column_name => $column_display_name ) {
+			$style = '';
+			if ( in_array( $column_name, $hidden ) )
+				$style = ' style="display:none;"';
+
+			switch ( $column_name ) {
+				case 'cb':
+					echo "<th scope='row' class='check-column'>$checkbox</th>";
+					break;
+				case 'name':
+					echo "<td class='theme-title'$style><strong>$theme_name</strong>";
+					echo $this->row_actions( $actions, true );
+					echo "</td>";
+					break;
+				case 'description':
+					echo "<td class='column-description desc'$style>
+						<div class='theme-description'>$description</div>
+						<div class='$class second theme-version-author-uri'>";
+
+					$theme_meta = array();
+
+					if ( !empty( $theme['Version'] ) )
+						$theme_meta[] = sprintf( __( 'Version %s' ), $theme['Version'] );
+
+					if ( !empty( $theme['Author'] ) )
+						$theme_meta[] = sprintf( __( 'By %s' ), $theme['Author'] );
+
+					if ( !empty( $theme['Theme URI'] ) )
+						$theme_meta[] = '<a href="' . $theme['Theme URI'] . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
+
+					$theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
+					echo implode( ' | ', $theme_meta );
+
+					echo "</div></td>";
+					break;
+
+				default:
+					echo "<td class='$column_name column-$column_name'$style>";
+					do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
+					echo "</td>";
+			}
+		}
+
+		echo "</tr>";
+
+		if ( $this->is_site_themes )
+			remove_action( "after_theme_row_$theme_key", 'wp_theme_update_row' );
+		do_action( 'after_theme_row', $theme_key, $theme, $status );
+		do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-ms-users-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-ms-users-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-ms-users-list-table.php	(revision 17487)
@@ -0,0 +1,276 @@
+<?php
+/**
+ * Multisite Users List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_MS_Users_List_Table extends WP_List_Table {
+
+	function ajax_user_can() {
+		return current_user_can( 'manage_network_users' );
+	}
+
+	function prepare_items() {
+		global $usersearch, $role, $wpdb, $mode;
+
+		$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
+
+		$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
+
+		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
+
+		$paged = $this->get_pagenum();
+
+		$args = array(
+			'number' => $users_per_page,
+			'offset' => ( $paged-1 ) * $users_per_page,
+			'search' => $usersearch,
+			'blog_id' => 0,
+			'fields' => 'all_with_meta'
+		);
+
+		$args['search'] = ltrim($args['search'], '*');
+
+		if ( $role == 'super' ) {
+			$logins = implode( "', '", get_super_admins() );
+			$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
+		}
+
+		// If the network is large and a search is not being performed, show only the latest users with no paging in order
+		// to avoid expensive count queries.
+		if ( !$usersearch && ( get_blog_count() >= 10000 ) ) {
+			if ( !isset($_REQUEST['orderby']) )
+				$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
+			if ( !isset($_REQUEST['order']) )
+				$_GET['order'] = $_REQUEST['order'] = 'DESC';
+			$args['count_total'] = false;
+		}
+
+		if ( isset( $_REQUEST['orderby'] ) )
+			$args['orderby'] = $_REQUEST['orderby'];
+
+		if ( isset( $_REQUEST['order'] ) )
+			$args['order'] = $_REQUEST['order'];
+
+		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
+
+		// Query the user IDs for this page
+		$wp_user_search = new WP_User_Query( $args );
+
+		$this->items = $wp_user_search->get_results();
+
+		$this->set_pagination_args( array(
+			'total_items' => $wp_user_search->get_total(),
+			'per_page' => $users_per_page,
+		) );
+	}
+
+	function get_bulk_actions() {
+		$actions = array();
+		if ( current_user_can( 'delete_users' ) )
+			$actions['delete'] = __( 'Delete' );
+		$actions['spam'] = _x( 'Mark as Spam', 'user' );
+		$actions['notspam'] = _x( 'Not Spam', 'user' );
+
+		return $actions;
+	}
+
+	function no_items() {
+		_e( 'No users found.' );
+	}
+
+	function get_views() {
+		global $wp_roles, $role;
+
+		$total_users = get_user_count();
+		$super_admins = get_super_admins();
+		$total_admins = count( $super_admins );
+
+		$current_role = false;
+		$class = $role != 'super' ? ' class="current"' : '';
+		$role_links = array();
+		$role_links['all'] = "<a href='" . network_admin_url('users.php') . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
+		$class = $role == 'super' ? ' class="current"' : '';
+		$role_links['super'] = "<a href='" . network_admin_url('users.php?role=super') . "'$class>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
+
+		return $role_links;
+	}
+
+	function pagination( $which ) {
+		global $mode;
+
+		parent::pagination ( $which );
+
+		if ( 'top' == $which )
+			$this->view_switcher( $mode );
+	}
+
+	function get_columns() {
+		$users_columns = array(
+			'cb'         => '<input type="checkbox" />',
+			'username'   => __( 'Username' ),
+			'name'       => __( 'Name' ),
+			'email'      => __( 'E-mail' ),
+			'registered' => _x( 'Registered', 'user' ),
+			'blogs'      => __( 'Sites' )
+		);
+		$users_columns = apply_filters( 'wpmu_users_columns', $users_columns );
+
+		return $users_columns;
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'username'   => 'login',
+			'name'       => 'name',
+			'email'      => 'email',
+			'registered' => 'id',
+		);
+	}
+
+	function display_rows() {
+		global $current_site, $mode;
+
+		$alt = '';
+		$super_admins = get_super_admins();
+		foreach ( $this->items as $user ) {
+			$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
+
+			$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
+
+			foreach ( $status_list as $status => $col ) {
+				if ( $user->$status )
+					$alt .= " $col";
+			}
+
+			?>
+			<tr class="<?php echo $alt; ?>">
+			<?php
+
+			list( $columns, $hidden ) = $this->get_column_info();
+
+			foreach ( $columns as $column_name => $column_display_name ) :
+				$class = "class='$column_name column-$column_name'";
+
+				$style = '';
+				if ( in_array( $column_name, $hidden ) )
+					$style = ' style="display:none;"';
+
+				$attributes = "$class$style";
+
+
+				switch ( $column_name ) {
+					case 'cb': ?>
+						<th scope="row" class="check-column">
+							<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
+						</th>
+					<?php
+					break;
+
+					case 'username':
+						$avatar	= get_avatar( $user->user_email, 32 );
+						if ( get_current_user_id() == $user->ID ) {
+							$edit_link = esc_url( network_admin_url( 'profile.php' ) );
+						} else {
+							$edit_link = esc_url( network_admin_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), 'user-edit.php?user_id=' . $user->ID ) ) );
+						}
+
+						echo "<td $attributes>"; ?>
+							<?php echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo stripslashes( $user->user_login ); ?></a><?php
+							if ( in_array( $user->user_login, $super_admins ) )
+								echo ' - ' . __( 'Super Admin' );
+							?></strong>
+							<br/>
+							<?php
+								$actions = array();
+								$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
+
+								if ( current_user_can( 'delete_user', $user->ID) && ! in_array( $user->user_login, $super_admins ) ) {
+									$actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'edit.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
+								}
+
+								echo $this->row_actions( $actions );
+							?>
+						</td>
+					<?php
+					break;
+
+					case 'name':
+						echo "<td $attributes>$user->first_name $user->last_name</td>";
+					break;
+
+					case 'email':
+						echo "<td $attributes><a href='mailto:$user->user_email'>$user->user_email</a></td>";
+					break;
+
+					case 'registered':
+						if ( 'list' == $mode )
+							$date = 'Y/m/d';
+						else
+							$date = 'Y/m/d \<\b\r \/\> g:i:s a';
+
+						echo "<td $attributes>" . mysql2date( $date, $user->user_registered ) . "</td>";
+					break;
+
+					case 'blogs':
+						$blogs = get_blogs_of_user( $user->ID, true );
+						echo "<td $attributes>";
+							if ( is_array( $blogs ) ) {
+								foreach ( (array) $blogs as $key => $val ) {
+									if ( !can_edit_network( $val->site_id ) )
+										continue;
+
+									$path	= ( $val->path == '/' ) ? '' : $val->path;
+									echo '<span class="site-' . $val->site_id . '" >';
+									echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
+									echo ' <small class="row-actions">';
+									$actions = array();
+									$actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
+
+									$class = '';
+									if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
+										$class .= 'site-spammed ';
+									if ( get_blog_status( $val->userblog_id, 'mature' ) == 1 )
+										$class .= 'site-mature ';
+									if ( get_blog_status( $val->userblog_id, 'deleted' ) == 1 )
+										$class .= 'site-deleted ';
+									if ( get_blog_status( $val->userblog_id, 'archived' ) == 1 )
+										$class .= 'site-archived ';
+
+									$actions['view'] = '<a class="' . $class . '" href="' .  esc_url( get_home_url( $val->userblog_id ) )  . '">' . __( 'View' ) . '</a>';
+
+									$actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
+
+									$i=0;
+									$action_count = count( $actions );
+									foreach ( $actions as $action => $link ) {
+										++$i;
+										( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+										echo "<span class='$action'>$link$sep</span>";
+									}
+									echo '</small></span><br/>';
+								}
+							}
+							?>
+						</td>
+					<?php
+					break;
+
+					default:
+						echo "<td $attributes>";
+						echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
+						echo "</td>";
+					break;
+				}
+			endforeach
+			?>
+			</tr>
+			<?php
+		}
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-plugin-install-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-plugin-install-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-plugin-install-list-table.php	(revision 17487)
@@ -0,0 +1,237 @@
+<?php
+/**
+ * Plugin Installer List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Plugin_Install_List_Table extends WP_List_Table {
+
+	function ajax_user_can() {
+		return current_user_can('install_plugins');
+	}
+
+	function prepare_items() {
+		include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
+
+		global $tabs, $tab, $paged, $type, $term;
+
+		wp_reset_vars( array( 'tab' ) );
+
+		$paged = $this->get_pagenum();
+
+		$per_page = 30;
+
+		// These are the tabs which are shown on the page
+		$tabs = array();
+		$tabs['dashboard'] = __( 'Search' );
+		if ( 'search' == $tab )
+			$tabs['search']	= __( 'Search Results' );
+		$tabs['upload'] = __( 'Upload' );
+		$tabs['featured'] = _x( 'Featured','Plugin Installer' );
+		$tabs['popular']  = _x( 'Popular','Plugin Installer' );
+		$tabs['new']      = _x( 'Newest','Plugin Installer' );
+		$tabs['updated']  = _x( 'Recently Updated','Plugin Installer' );
+
+		$nonmenu_tabs = array( 'plugin-information' ); //Valid actions to perform which do not have a Menu item.
+
+		$tabs = apply_filters( 'install_plugins_tabs', $tabs );
+		$nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
+
+		// If a non-valid menu tab has been selected, And its not a non-menu action.
+		if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
+			$tab = key( $tabs );
+
+		$args = array( 'page' => $paged, 'per_page' => $per_page );
+
+		switch ( $tab ) {
+			case 'search':
+				$type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
+				$term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
+
+				switch ( $type ) {
+					case 'tag':
+						$args['tag'] = sanitize_title_with_dashes( $term );
+						break;
+					case 'term':
+						$args['search'] = $term;
+						break;
+					case 'author':
+						$args['author'] = $term;
+						break;
+				}
+
+				add_action( 'install_plugins_table_header', 'install_search_form' );
+				break;
+
+			case 'featured':
+			case 'popular':
+			case 'new':
+			case 'updated':
+				$args['browse'] = $tab;
+				break;
+
+			default:
+				$args = false;
+		}
+
+		if ( !$args )
+			return;
+
+		$api = plugins_api( 'query_plugins', $args );
+
+		if ( is_wp_error( $api ) )
+			wp_die( $api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' );
+
+		$this->items = $api->plugins;
+
+		$this->set_pagination_args( array(
+			'total_items' => $api->info['results'],
+			'per_page' => $per_page,
+		) );
+	}
+
+	function no_items() {
+		_e( 'No plugins match your request.' );
+	}
+
+	function get_views() {
+		global $tabs, $tab;
+
+		$display_tabs = array();
+		foreach ( (array) $tabs as $action => $text ) {
+			$class = ( $action == $tab ) ? ' class="current"' : '';
+			$href = self_admin_url('plugin-install.php?tab=' . $action);
+			$display_tabs['plugin-install-'.$action] = "<a href='$href'$class>$text</a>";
+		}
+
+		return $display_tabs;
+	}
+
+	function display_tablenav( $which ) {
+		if ( 'top' ==  $which ) { ?>
+			<div class="tablenav top">
+				<div class="alignleft actions">
+					<?php do_action( 'install_plugins_table_header' ); ?>
+				</div>
+				<?php $this->pagination( $which ); ?>
+				<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
+				<br class="clear" />
+			</div>
+		<?php } else { ?>
+			<div class="tablenav bottom">
+				<?php $this->pagination( $which ); ?>
+				<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
+				<br class="clear" />
+			</div>
+		<?php
+		}
+	}
+
+	function get_table_classes() {
+		extract( $this->_args );
+
+		return array( 'widefat', $plural );
+	}
+
+	function get_columns() {
+		return array(
+			'name'        => __( 'Name' ),
+			'version'     => __( 'Version' ),
+			'rating'      => __( 'Rating' ),
+			'description' => __( 'Description' ),
+		);
+	}
+
+	function display_rows() {
+		$plugins_allowedtags = array(
+			'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
+			'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ),
+			'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(),
+			'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()
+		);
+
+		list( $columns, $hidden ) = $this->get_column_info();
+
+		$style = array();
+		foreach ( $columns as $column_name => $column_display_name ) {
+			$style[ $column_name ] = in_array( $column_name, $hidden ) ? 'style="display:none;"' : '';
+		}
+
+		foreach ( (array) $this->items as $plugin ) {
+			if ( is_object( $plugin ) )
+				$plugin = (array) $plugin;
+
+			$title = wp_kses( $plugin['name'], $plugins_allowedtags );
+			//Limit description to 400char, and remove any HTML.
+			$description = strip_tags( $plugin['description'] );
+			if ( strlen( $description ) > 400 )
+				$description = mb_substr( $description, 0, 400 ) . '&#8230;';
+			//remove any trailing entities
+			$description = preg_replace( '/&[^;\s]{0,6}$/', '', $description );
+			//strip leading/trailing & multiple consecutive lines
+			$description = trim( $description );
+			$description = preg_replace( "|(\r?\n)+|", "\n", $description );
+			//\n => <br>
+			$description = nl2br( $description );
+			$version = wp_kses( $plugin['version'], $plugins_allowedtags );
+
+			$name = strip_tags( $title . ' ' . $version );
+
+			$author = $plugin['author'];
+			if ( ! empty( $plugin['author'] ) )
+				$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '.</cite>';
+
+			$author = wp_kses( $author, $plugins_allowedtags );
+
+			$action_links = array();
+			$action_links[] = '<a href="' . self_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
+								'&amp;TB_iframe=true&amp;width=600&amp;height=550' ) . '" class="thickbox" title="' .
+								esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '">' . __( 'Details' ) . '</a>';
+
+			if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
+				$status = install_plugin_install_status( $plugin );
+
+				switch ( $status['status'] ) {
+					case 'install':
+						if ( $status['url'] )
+							$action_links[] = '<a class="install-now" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
+						break;
+					case 'update_available':
+						if ( $status['url'] )
+							$action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . sprintf( __( 'Update Now' ), $status['version'] ) . '</a>';
+						break;
+					case 'latest_installed':
+					case 'newer_installed':
+						$action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . __( 'Installed' ) . '</span>';
+						break;
+				}
+			}
+
+			$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
+		?>
+		<tr>
+			<td class="name column-name"<?php echo $style['name']; ?>><strong><?php echo $title; ?></strong>
+				<div class="action-links"><?php if ( !empty( $action_links ) ) echo implode( ' | ', $action_links ); ?></div>
+			</td>
+			<td class="vers column-version"<?php echo $style['version']; ?>><?php echo $version; ?></td>
+			<td class="vers column-rating"<?php echo $style['rating']; ?>>
+				<div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings'] ), number_format_i18n( $plugin['num_ratings'] ) ) ?>">
+					<div class="star star-rating" style="width: <?php echo esc_attr( $plugin['rating'] ) ?>px"></div>
+					<div class="star star5"><img src="<?php echo admin_url( 'images/star.gif' ); ?>" alt="<?php _e( '5 stars' ) ?>" /></div>
+					<div class="star star4"><img src="<?php echo admin_url( 'images/star.gif' ); ?>" alt="<?php _e( '4 stars' ) ?>" /></div>
+					<div class="star star3"><img src="<?php echo admin_url( 'images/star.gif' ); ?>" alt="<?php _e( '3 stars' ) ?>" /></div>
+					<div class="star star2"><img src="<?php echo admin_url( 'images/star.gif' ); ?>" alt="<?php _e( '2 stars' ) ?>" /></div>
+					<div class="star star1"><img src="<?php echo admin_url( 'images/star.gif' ); ?>" alt="<?php _e( '1 star' ) ?>" /></div>
+				</div>
+			</td>
+			<td class="desc column-description"<?php echo $style['description']; ?>><?php echo $description, $author; ?></td>
+		</tr>
+		<?php
+		}
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-plugins-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-plugins-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-plugins-list-table.php	(revision 17487)
@@ -0,0 +1,453 @@
+<?php
+/**
+ * Plugins List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Plugins_List_Table extends WP_List_Table {
+
+	function WP_Plugins_List_Table() {
+		global $status, $page;
+
+		$default_status = get_user_option( 'plugins_last_view' );
+		if ( empty( $default_status ) )
+			$default_status = 'all';
+		$status = isset( $_REQUEST['plugin_status'] ) ? $_REQUEST['plugin_status'] : $default_status;
+		if ( !in_array( $status, array( 'all', 'active', 'inactive', 'recently_activated', 'upgrade', 'network', 'mustuse', 'dropins', 'search' ) ) )
+			$status = 'all';
+		if ( $status != $default_status && 'search' != $status )
+			update_user_meta( get_current_user_id(), 'plugins_last_view', $status );
+
+		$page = $this->get_pagenum();
+
+		parent::WP_List_Table( array(
+			'plural' => 'plugins',
+		) );
+	}
+	
+	function get_table_classes() {
+		return array( 'widefat', $this->_args['plural'] );
+	}
+
+	function ajax_user_can() {
+		if ( is_multisite() ) {
+			$menu_perms = get_site_option( 'menu_items', array() );
+
+			if ( empty( $menu_perms['plugins'] ) && ! is_super_admin() )
+				return false;
+		}
+
+		return current_user_can('activate_plugins');
+	}
+
+	function prepare_items() {
+		global $status, $plugins, $totals, $page, $orderby, $order, $s;
+
+		wp_reset_vars( array( 'orderby', 'order', 's' ) );
+
+		$plugins = array(
+			'all' => apply_filters( 'all_plugins', get_plugins() ),
+			'search' => array(),
+			'active' => array(),
+			'inactive' => array(),
+			'recently_activated' => array(),
+			'upgrade' => array(),
+			'mustuse' => array(),
+			'dropins' => array()
+		);
+
+		$screen = get_current_screen();
+
+		if ( ! is_multisite() || ( $screen->is_network && current_user_can('manage_network_plugins') ) ) {
+			if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
+				$plugins['mustuse'] = get_mu_plugins();
+			if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
+				$plugins['dropins'] = get_dropins();
+
+			$current = get_site_transient( 'update_plugins' );
+			foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
+				if ( isset( $current->response[ $plugin_file ] ) )
+					$plugins['upgrade'][ $plugin_file ] = $plugin_data;
+			}
+		}
+
+		set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 );
+
+		$recently_activated = get_option( 'recently_activated', array() );
+
+		$one_week = 7*24*60*60;
+		foreach ( $recently_activated as $key => $time )
+			if ( $time + $one_week < time() )
+				unset( $recently_activated[$key] );
+		update_option( 'recently_activated', $recently_activated );
+
+		foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
+			// Filter into individual sections
+			if ( is_multisite() && is_network_only_plugin( $plugin_file ) && !$screen->is_network ) {
+				unset( $plugins['all'][ $plugin_file] );
+			} elseif ( is_plugin_active_for_network($plugin_file) && !$screen->is_network ) {
+				unset( $plugins['all'][ $plugin_file ] );
+			} elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
+				$plugins['network'][ $plugin_file ] = $plugin_data;
+			} elseif ( ( !$screen->is_network && is_plugin_active( $plugin_file ) )
+				|| ( $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
+				$plugins['active'][ $plugin_file ] = $plugin_data;
+			} else {
+				if ( !$screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
+					$plugins['recently_activated'][ $plugin_file ] = $plugin_data;
+				$plugins['inactive'][ $plugin_file ] = $plugin_data;
+			}
+		}
+
+		if ( !current_user_can( 'update_plugins' ) )
+			$plugins['upgrade'] = array();
+
+		if ( $s ) {
+			$status = 'search';
+			$plugins['search'] = array_filter( $plugins['all'], array( &$this, '_search_callback' ) );
+		}
+
+		$totals = array();
+		foreach ( $plugins as $type => $list )
+			$totals[ $type ] = count( $list );
+
+		if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
+			$status = 'all';
+
+		$this->items = array();
+		foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
+			// Translate, Don't Apply Markup, Sanitize HTML
+			$this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
+		}
+
+		$total_this_page = $totals[ $status ];
+
+		if ( $orderby ) {
+			$orderby = ucfirst( $orderby );
+			$order = strtoupper( $order );
+
+			uasort( $this->items, array( &$this, '_order_callback' ) );
+		}
+
+		$plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ) );
+
+		$start = ( $page - 1 ) * $plugins_per_page;
+
+		if ( $total_this_page > $plugins_per_page )
+			$this->items = array_slice( $this->items, $start, $plugins_per_page );
+
+		$this->set_pagination_args( array(
+			'total_items' => $total_this_page,
+			'per_page' => $plugins_per_page,
+		) );
+	}
+
+	function _search_callback( $plugin ) {
+		static $term;
+		if ( is_null( $term ) )
+			$term = stripslashes( $_REQUEST['s'] );
+
+		foreach ( $plugin as $value )
+			if ( stripos( $value, $term ) !== false )
+				return true;
+
+		return false;
+	}
+
+	function _order_callback( $plugin_a, $plugin_b ) {
+		global $orderby, $order;
+
+		$a = $plugin_a[$orderby];
+		$b = $plugin_b[$orderby];
+
+		if ( $a == $b )
+			return 0;
+
+		if ( 'DESC' == $order )
+			return ( $a < $b ) ? 1 : -1;
+		else
+			return ( $a < $b ) ? -1 : 1;
+	}
+
+	function no_items() {
+		global $plugins;
+
+		if ( !empty( $plugins['all'] ) )
+			_e( 'No plugins found.' );
+		else
+			_e( 'You do not appear to have any plugins available at this time.' );
+	}
+
+	function get_columns() {
+		global $status;
+
+		return array(
+			'cb'          => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
+			'name'        => __( 'Plugin' ),
+			'description' => __( 'Description' ),
+		);
+	}
+
+	function get_sortable_columns() {
+		return array();
+	}
+
+	function display_tablenav( $which ) {
+		global $status;
+
+		if ( !in_array( $status, array( 'mustuse', 'dropins' ) ) )
+			parent::display_tablenav( $which );
+	}
+
+	function get_views() {
+		global $totals, $status;
+
+		$status_links = array();
+		foreach ( $totals as $type => $count ) {
+			if ( !$count )
+				continue;
+
+			switch ( $type ) {
+				case 'all':
+					$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' );
+					break;
+				case 'active':
+					$text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count );
+					break;
+				case 'recently_activated':
+					$text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count );
+					break;
+				case 'inactive':
+					$text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
+					break;
+				case 'network':
+					$text = _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $count );
+					break;
+				case 'mustuse':
+					$text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
+					break;
+				case 'dropins':
+					$text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
+					break;
+				case 'upgrade':
+					$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
+					break;
+			}
+
+			if ( 'search' != $type ) {
+				$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
+					add_query_arg('plugin_status', $type, 'plugins.php'),
+					( $type == $status ) ? ' class="current"' : '',
+					sprintf( $text, number_format_i18n( $count ) )
+					);
+			}
+		}
+
+		return $status_links;
+	}
+
+	function get_bulk_actions() {
+		global $status;
+
+		$actions = array();
+
+		$screen = get_current_screen();
+
+		if ( 'active' != $status ) {
+			$action = $screen->is_network ? 'network-activate-selected' : 'activate-selected';
+			$actions[ $action ] = __( 'Activate' );
+		}
+
+		if ( 'inactive' != $status && 'recent' != $status )
+			$actions['deactivate-selected'] = __( 'Deactivate' );
+
+		if ( !is_multisite() || $screen->is_network ) {
+			if ( current_user_can( 'update_plugins' ) )
+				$actions['update-selected'] = __( 'Update' );
+			if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
+				$actions['delete-selected'] = __( 'Delete' );
+		}
+
+		return $actions;
+	}
+
+	function bulk_actions( $which ) {
+		global $status;
+
+		if ( in_array( $status, array( 'mustuse', 'dropins' ) ) )
+			return;
+
+		parent::bulk_actions( $which );
+	}
+
+	function extra_tablenav( $which ) {
+		global $status;
+
+		if ( 'recently_activated' == $status ) { ?>
+			<div class="alignleft actions">
+				<?php submit_button( __( 'Clear List' ), 'secondary', 'clear-recent-list', false ); ?>
+			</div>
+		<?php }
+	}
+
+	function current_action() {
+		if ( isset($_POST['clear-recent-list']) )
+			return 'clear-recent-list';
+
+		return parent::current_action();
+	}
+
+	function display_rows() {
+		global $status;
+
+		$screen = get_current_screen();
+
+		if ( is_multisite() && !$screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) )
+			return;
+
+		foreach ( $this->items as $plugin_file => $plugin_data )
+			$this->single_row( $plugin_file, $plugin_data );
+	}
+
+	function single_row( $plugin_file, $plugin_data ) {
+		global $status, $page, $s;
+
+		$context = $status;
+
+		$screen = get_current_screen();
+
+		// preorder
+		$actions = array(
+			'network_deactivate' => '', 'deactivate' => '',
+			'network_only' => '', 'activate' => '',
+			'network_activate' => '',
+			'edit' => '',
+			'delete' => '',
+		);
+
+		if ( 'mustuse' == $context ) {
+			$is_active = true;
+		} elseif ( 'dropins' == $context ) {
+			$dropins = _get_dropins();
+			$plugin_name = $plugin_file;
+			if ( $plugin_file != $plugin_data['Name'] )
+				$plugin_name .= '<br/>' . $plugin_data['Name'];
+			if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
+				$is_active = true;
+				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
+			} elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
+				$is_active = true;
+				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
+			} else {
+				$is_active = false;
+				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>';
+			}
+			if ( $plugin_data['Description'] )
+				$description .= '<p>' . $plugin_data['Description'] . '</p>';
+		} else {
+			$is_active_for_network = is_plugin_active_for_network($plugin_file);
+			if ( $screen->is_network )
+				$is_active = $is_active_for_network;
+			else
+				$is_active = is_plugin_active( $plugin_file );
+
+			if ( $is_active_for_network && !is_super_admin() && !$screen->is_network )
+				return;
+
+			if ( $screen->is_network ) {
+				if ( $is_active_for_network ) {
+					if ( current_user_can( 'manage_network_plugins' ) )
+						$actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
+				} else {
+					if ( current_user_can( 'manage_network_plugins' ) )
+						$actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
+					if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) )
+						$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
+				}
+			} else {
+				if ( $is_active ) {
+					$actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
+				} else {
+					$actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
+
+					if ( ! is_multisite() && current_user_can('delete_plugins') )
+						$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
+				} // end if $is_active
+			 } // end if $screen->is_network
+
+			if ( ( ! is_multisite() || $screen->is_network ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
+				$actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
+		} // end if $context
+
+		$prefix = $screen->is_network ? 'network_admin_' : '';
+		$actions = apply_filters( $prefix . 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
+		$actions = apply_filters( $prefix . "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
+
+		$class = $is_active ? 'active' : 'inactive';
+		$checkbox_id =  "checkbox_" . md5($plugin_data['Name']);
+		$checkbox = in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $plugin_data['Name'] . "</label>";
+		if ( 'dropins' != $context ) {
+			$description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;' ) . '</p>';
+			$plugin_name = $plugin_data['Name'];
+		}
+
+		$id = sanitize_title( $plugin_name );
+
+		echo "<tr id='$id' class='$class'>";
+
+		list( $columns, $hidden ) = $this->get_column_info();
+
+		foreach ( $columns as $column_name => $column_display_name ) {
+			$style = '';
+			if ( in_array( $column_name, $hidden ) )
+				$style = ' style="display:none;"';
+
+			switch ( $column_name ) {
+				case 'cb':
+					echo "<th scope='row' class='check-column'>$checkbox</th>";
+					break;
+				case 'name':
+					echo "<td class='plugin-title'$style><strong>$plugin_name</strong>";
+					echo $this->row_actions( $actions, true );
+					echo "</td>";
+					break;
+				case 'description':
+					echo "<td class='column-description desc'$style>
+						<div class='plugin-description'>$description</div>
+						<div class='$class second plugin-version-author-uri'>";
+
+					$plugin_meta = array();
+					if ( !empty( $plugin_data['Version'] ) )
+						$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
+					if ( !empty( $plugin_data['Author'] ) ) {
+						$author = $plugin_data['Author'];
+						if ( !empty( $plugin_data['AuthorURI'] ) )
+							$author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
+						$plugin_meta[] = sprintf( __( 'By %s' ), $author );
+					}
+					if ( ! empty( $plugin_data['PluginURI'] ) )
+						$plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin site' ) . '">' . __( 'Visit plugin site' ) . '</a>';
+
+					$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
+					echo implode( ' | ', $plugin_meta );
+
+					echo "</div></td>";
+					break;
+				default:
+					echo "<td class='$column_name column-$column_name'$style>";
+					do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data );
+					echo "</td>";
+			}
+		}
+
+		echo "</tr>";
+
+		do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
+		do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-posts-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-posts-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-posts-list-table.php	(revision 17487)
@@ -0,0 +1,1019 @@
+<?php
+/**
+ * Posts List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Posts_List_Table extends WP_List_Table {
+
+	/**
+	 * Whether the items should be displayed hierarchically or linearly
+	 *
+	 * @since 3.1.0
+	 * @var bool
+	 * @access protected
+	 */
+	var $hierarchical_display;
+
+	/**
+	 * Holds the number of pending comments for each post
+	 *
+	 * @since 3.1.0
+	 * @var int
+	 * @access protected
+	 */
+	var $comment_pending_count;
+
+	/**
+	 * Holds the number of posts for this user
+	 *
+	 * @since 3.1.0
+	 * @var int
+	 * @access private
+	 */
+	var $user_posts_count;
+
+	/**
+	 * Holds the number of posts which are sticky.
+	 *
+	 * @since 3.1.0
+	 * @var int
+	 * @access private
+	 */
+	var $sticky_posts_count = 0;
+
+	function WP_Posts_List_Table() {
+		global $post_type_object, $post_type, $wpdb;
+
+		if ( !isset( $_REQUEST['post_type'] ) )
+			$post_type = 'post';
+		elseif ( in_array( $_REQUEST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) )
+			$post_type = $_REQUEST['post_type'];
+		else
+			wp_die( __( 'Invalid post type' ) );
+		$_REQUEST['post_type'] = $post_type;
+
+		$post_type_object = get_post_type_object( $post_type );
+
+		if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
+			$this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
+				SELECT COUNT( 1 ) FROM $wpdb->posts
+				WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' )
+				AND post_author = %d
+			", $post_type, get_current_user_id() ) );
+
+			if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) )
+				$_GET['author'] = get_current_user_id();
+		}
+
+		if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
+			$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
+			$this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) );
+		}
+
+		parent::WP_List_Table( array(
+			'plural' => 'posts',
+		) );
+	}
+
+	function ajax_user_can() {
+		global $post_type_object;
+
+		return current_user_can( $post_type_object->cap->edit_posts );
+	}
+
+	function prepare_items() {
+		global $post_type_object, $post_type, $avail_post_stati, $wp_query, $per_page, $mode;
+
+		$avail_post_stati = wp_edit_posts_query();
+
+		$this->hierarchical_display = ( $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'] );
+
+		$total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
+
+		$per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
+ 		$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
+
+		if ( $this->hierarchical_display )
+			$total_pages = ceil( $total_items / $per_page );
+		else
+			$total_pages = $wp_query->max_num_pages;
+
+		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
+
+		$this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
+
+		$this->set_pagination_args( array(
+			'total_items' => $total_items,
+			'total_pages' => $total_pages,
+			'per_page' => $per_page
+		) );
+	}
+
+	function has_items() {
+		return have_posts();
+	}
+
+	function no_items() {
+		global $post_type_object;
+
+		if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
+			echo $post_type_object->labels->not_found_in_trash;
+		else
+			echo $post_type_object->labels->not_found;
+	}
+
+	function get_views() {
+		global $post_type, $post_type_object, $locked_post_status, $avail_post_stati;
+
+		if ( !empty($locked_post_status) )
+			return array();
+
+		$status_links = array();
+		$num_posts = wp_count_posts( $post_type, 'readable' );
+		$class = '';
+		$allposts = '';
+
+		$current_user_id = get_current_user_id();
+
+		if ( $this->user_posts_count ) {
+			if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
+				$class = ' class="current"';
+			$status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
+			$allposts = '&all_posts=1';
+		}
+
+		$total_posts = array_sum( (array) $num_posts );
+
+		// Subtract post types that are not included in the admin all list.
+		foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
+			$total_posts -= $num_posts->$state;
+
+		$class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
+		$status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
+
+		foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
+			$class = '';
+
+			$status_name = $status->name;
+
+			if ( !in_array( $status_name, $avail_post_stati ) )
+				continue;
+
+			if ( empty( $num_posts->$status_name ) )
+				continue;
+
+			if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
+				$class = ' class="current"';
+
+			$status_links[$status_name] = "<a href='edit.php?post_status=$status_name&amp;post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
+		}
+
+		if ( ! empty( $this->sticky_posts_count ) ) {
+			$class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
+
+			$sticky_link = array( 'sticky' => "<a href='edit.php?post_type=$post_type&amp;show_sticky=1'$class>" . sprintf( _nx( 'Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '</a>' );
+
+			// Sticky comes after Publish, or if not listed, after All.
+			$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
+			$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
+		}
+
+		return $status_links;
+	}
+
+	function get_bulk_actions() {
+		$actions = array();
+
+		if ( $this->is_trash )
+			$actions['untrash'] = __( 'Restore' );
+		else
+			$actions['edit'] = __( 'Edit' );
+
+		if ( $this->is_trash || !EMPTY_TRASH_DAYS )
+			$actions['delete'] = __( 'Delete Permanently' );
+		else
+			$actions['trash'] = __( 'Move to Trash' );
+
+		return $actions;
+	}
+
+	function extra_tablenav( $which ) {
+		global $post_type, $post_type_object, $cat;
+?>
+		<div class="alignleft actions">
+<?php
+		if ( 'top' == $which && !is_singular() ) {
+
+			$this->months_dropdown( $post_type );
+
+			if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
+				$dropdown_options = array(
+					'show_option_all' => __( 'View all categories' ),
+					'hide_empty' => 0,
+					'hierarchical' => 1,
+					'show_count' => 0,
+					'orderby' => 'name',
+					'selected' => $cat
+				);
+				wp_dropdown_categories( $dropdown_options );
+			}
+			do_action( 'restrict_manage_posts' );
+			submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
+		}
+
+		if ( $this->is_trash && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
+			submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false );
+		}
+?>
+		</div>
+<?php
+	}
+
+	function current_action() {
+		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
+			return 'delete_all';
+
+		return parent::current_action();
+	}
+
+	function pagination( $which ) {
+		global $post_type_object, $mode;
+
+		parent::pagination( $which );
+
+		if ( 'top' == $which && !$post_type_object->hierarchical )
+			$this->view_switcher( $mode );
+	}
+
+	function get_table_classes() {
+		global $post_type_object;
+
+		return array( 'widefat', 'fixed', $post_type_object->hierarchical ? 'pages' : 'posts' );
+	}
+
+	function get_columns() {
+		$screen = get_current_screen();
+
+		if ( empty( $screen ) )
+			$post_type = 'post';
+		else
+			$post_type = $screen->post_type;
+
+		$posts_columns = array();
+
+		$posts_columns['cb'] = '<input type="checkbox" />';
+
+		/* translators: manage posts column name */
+		$posts_columns['title'] = _x( 'Title', 'column name' );
+
+		if ( post_type_supports( $post_type, 'author' ) )
+			$posts_columns['author'] = __( 'Author' );
+
+		if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) )
+			$posts_columns['categories'] = __( 'Categories' );
+
+		if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) )
+			$posts_columns['tags'] = __( 'Tags' );
+
+		$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
+		if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
+			$posts_columns['comments'] = '<div class="vers"><img alt="' . esc_attr__( 'Comments' ) . '" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
+
+		$posts_columns['date'] = __( 'Date' );
+
+		if ( 'page' == $post_type )
+			$posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
+		else
+			$posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
+		$posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
+
+		return $posts_columns;
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'title'    => 'title',
+			'author'   => 'author',
+			'parent'   => 'parent',
+			'comments' => 'comment_count',
+			'date'     => array( 'date', true )
+		);
+	}
+
+	function display_rows( $posts = array() ) {
+		global $wp_query, $post_type_object, $per_page;
+
+		if ( empty( $posts ) )
+			$posts = $wp_query->posts;
+
+		if ( $this->hierarchical_display ) {
+			$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
+		} else {
+			$this->_display_rows( $posts );
+		}
+	}
+
+	function _display_rows( $posts ) {
+		global $post, $mode;
+
+		add_filter( 'the_title', 'esc_html' );
+
+		// Create array of post IDs.
+		$post_ids = array();
+
+		foreach ( $posts as $a_post )
+			$post_ids[] = $a_post->ID;
+
+		$this->comment_pending_count = get_pending_comments_num( $post_ids );
+
+		foreach ( $posts as $post )
+			$this->single_row( $post );
+	}
+
+	function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
+		global $wpdb;
+
+		$level = 0;
+
+		if ( ! $pages ) {
+			$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
+
+			if ( ! $pages )
+				return false;
+		}
+
+		/*
+		 * arrange pages into two parts: top level pages and children_pages
+		 * children_pages is two dimensional array, eg.
+		 * children_pages[10][] contains all sub-pages whose parent is 10.
+		 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
+		 * If searching, ignore hierarchy and treat everything as top level
+		 */
+		if ( empty( $_REQUEST['s'] ) ) {
+
+			$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->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
+					clean_page_cache( $page->ID );
+				}
+
+				if ( 0 == $page->post_parent )
+					$top_level_pages[] = $page;
+				else
+					$children_pages[ $page->post_parent ][] = $page;
+			}
+
+			$pages = &$top_level_pages;
+		}
+
+		$count = 0;
+		$start = ( $pagenum - 1 ) * $per_page;
+		$end = $start + $per_page;
+
+		foreach ( $pages as $page ) {
+			if ( $count >= $end )
+				break;
+
+			if ( $count >= $start )
+				echo "\t" . $this->single_row( $page, $level );
+
+			$count++;
+
+			if ( isset( $children_pages ) )
+				$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
+		}
+
+		// if it is the last pagenum and there are orphaned pages, display them with paging as well
+		if ( isset( $children_pages ) && $count < $end ){
+			foreach ( $children_pages as $orphans ){
+				foreach ( $orphans as $op ) {
+					if ( $count >= $end )
+						break;
+					if ( $count >= $start )
+						echo "\t" . $this->single_row( $op, 0 );
+					$count++;
+				}
+			}
+		}
+	}
+
+	/**
+	 * Given a top level page ID, display the nested hierarchy of sub-pages
+	 * together with paging support
+	 *
+	 * @since 3.1.0 (Standalone function exists since 2.6.0)
+	 *
+	 * @param unknown_type $children_pages
+	 * @param unknown_type $count
+	 * @param unknown_type $parent
+	 * @param unknown_type $level
+	 * @param unknown_type $pagenum
+	 * @param unknown_type $per_page
+	 */
+	function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
+
+		if ( ! isset( $children_pages[$parent] ) )
+			return;
+
+		$start = ( $pagenum - 1 ) * $per_page;
+		$end = $start + $per_page;
+
+		foreach ( $children_pages[$parent] as $page ) {
+
+			if ( $count >= $end )
+				break;
+
+			// If the page starts in a subtree, print the parents.
+			if ( $count == $start && $page->post_parent > 0 ) {
+				$my_parents = array();
+				$my_parent = $page->post_parent;
+				while ( $my_parent ) {
+					$my_parent = get_post( $my_parent );
+					$my_parents[] = $my_parent;
+					if ( !$my_parent->post_parent )
+						break;
+					$my_parent = $my_parent->post_parent;
+				}
+				$num_parents = count( $my_parents );
+				while ( $my_parent = array_pop( $my_parents ) ) {
+					echo "\t" . $this->single_row( $my_parent, $level - $num_parents );
+					$num_parents--;
+				}
+			}
+
+			if ( $count >= $start )
+				echo "\t" . $this->single_row( $page, $level );
+
+			$count++;
+
+			$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
+		}
+
+		unset( $children_pages[$parent] ); //required in order to keep track of orphans
+	}
+
+	function single_row( $a_post, $level = 0 ) {
+		global $post, $current_screen, $mode;
+		static $rowclass;
+
+		$global_post = $post;
+		$post = $a_post;
+		setup_postdata( $post );
+
+		$rowclass = 'alternate' == $rowclass ? '' : 'alternate';
+		$post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
+		$edit_link = get_edit_post_link( $post->ID );
+		$title = _draft_or_post_title();
+		$post_type_object = get_post_type_object( $post->post_type );
+		$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
+		$post_format = get_post_format( $post->ID );
+		$post_format_class = ( $post_format && !is_wp_error($post_format) ) ? 'format-' . sanitize_html_class( $post_format ) : 'format-default';
+	?>
+		<tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status . ' ' . $post_format_class); ?> iedit' valign="top">
+	<?php
+
+		list( $columns, $hidden ) = $this->get_column_info();
+
+		foreach ( $columns as $column_name => $column_display_name ) {
+			$class = "class=\"$column_name column-$column_name\"";
+
+			$style = '';
+			if ( in_array( $column_name, $hidden ) )
+				$style = ' style="display:none;"';
+
+			$attributes = "$class$style";
+
+			switch ( $column_name ) {
+
+			case 'cb':
+			?>
+			<th scope="row" class="check-column"><?php if ( $can_edit_post ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
+			<?php
+			break;
+
+			case 'title':
+				if ( $this->hierarchical_display ) {
+					$attributes = 'class="post-title page-title column-title"' . $style;
+
+					if ( 0 == $level && (int) $post->post_parent > 0 ) {
+						//sent level 0 by accident, by default, or because we don't know the actual level
+						$find_main_page = (int) $post->post_parent;
+						while ( $find_main_page > 0 ) {
+							$parent = get_page( $find_main_page );
+
+							if ( is_null( $parent ) )
+								break;
+
+							$level++;
+							$find_main_page = (int) $parent->post_parent;
+
+							if ( !isset( $parent_name ) )
+								$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
+						}
+					}
+
+					$post->post_title = esc_html( $post->post_title );
+					$pad = str_repeat( '&#8212; ', $level );
+?>
+			<td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); echo isset( $parent_name ) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?></strong>
+<?php
+				}
+				else {
+					$attributes = 'class="post-title page-title column-title"' . $style;
+?>
+			<td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states( $post ); ?></strong>
+<?php
+					if ( 'excerpt' == $mode ) {
+						the_excerpt();
+					}
+				}
+
+				$actions = array();
+				if ( $can_edit_post && 'trash' != $post->post_status ) {
+					$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
+					$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
+				}
+				if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
+					if ( 'trash' == $post->post_status )
+						$actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
+					elseif ( EMPTY_TRASH_DAYS )
+						$actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
+					if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
+						$actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
+				}
+				if ( in_array( $post->post_status, array( 'pending', 'draft' ) ) ) {
+					if ( $can_edit_post )
+						$actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
+				} elseif ( 'trash' != $post->post_status ) {
+					$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
+				}
+
+				$actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post );
+				echo $this->row_actions( $actions );
+
+				get_inline_data( $post );
+				echo '</td>';
+			break;
+
+			case 'date':
+				if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
+					$t_time = $h_time = __( 'Unpublished' );
+					$time_diff = 0;
+				} else {
+					$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
+					$m_time = $post->post_date;
+					$time = get_post_time( 'G', true, $post );
+
+					$time_diff = time() - $time;
+
+					if ( $time_diff > 0 && $time_diff < 24*60*60 )
+						$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
+					else
+						$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
+				}
+
+				echo '<td ' . $attributes . '>';
+				if ( 'excerpt' == $mode )
+					echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
+				else
+					echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
+				echo '<br />';
+				if ( 'publish' == $post->post_status ) {
+					_e( 'Published' );
+				} elseif ( 'future' == $post->post_status ) {
+					if ( $time_diff > 0 )
+						echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
+					else
+						_e( 'Scheduled' );
+				} else {
+					_e( 'Last Modified' );
+				}
+				echo '</td>';
+			break;
+
+			case 'categories':
+			?>
+			<td <?php echo $attributes ?>><?php
+				$categories = get_the_category();
+				if ( !empty( $categories ) ) {
+					$out = array();
+					foreach ( $categories as $c ) {
+						$out[] = sprintf( '<a href="%s">%s</a>',
+							esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ),
+							esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) )
+						);
+					}
+					echo join( ', ', $out );
+				} else {
+					_e( 'Uncategorized' );
+				}
+			?></td>
+			<?php
+			break;
+
+			case 'tags':
+			?>
+			<td <?php echo $attributes ?>><?php
+				$tags = get_the_tags( $post->ID );
+				if ( !empty( $tags ) ) {
+					$out = array();
+					foreach ( $tags as $c ) {
+						$out[] = sprintf( '<a href="%s">%s</a>',
+							esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ),
+							esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) )
+						);
+					}
+					echo join( ', ', $out );
+				} else {
+					_e( 'No Tags' );
+				}
+			?></td>
+			<?php
+			break;
+
+			case 'comments':
+			?>
+			<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
+			<?php
+				$pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
+
+				$this->comments_bubble( $post->ID, $pending_comments );
+			?>
+			</div></td>
+			<?php
+			break;
+
+			case 'author':
+			?>
+			<td <?php echo $attributes ?>><?php
+				printf( '<a href="%s">%s</a>',
+					esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
+					get_the_author()
+				);
+			?></td>
+			<?php
+			break;
+
+			default:
+			?>
+			<td <?php echo $attributes ?>><?php
+				if ( is_post_type_hierarchical( $post->post_type ) )
+					do_action( 'manage_pages_custom_column', $column_name, $post->ID );
+				else
+					do_action( 'manage_posts_custom_column', $column_name, $post->ID );
+				do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
+			?></td>
+			<?php
+			break;
+		}
+	}
+	?>
+		</tr>
+	<?php
+		$post = $global_post;
+	}
+
+	/**
+	 * Outputs the hidden row displayed when inline editing
+	 *
+	 * @since 3.1.0
+	 */
+	function inline_edit() {
+		global $mode;
+
+		$screen = get_current_screen();
+
+		$post = get_default_post_to_edit( $screen->post_type );
+		$post_type_object = get_post_type_object( $screen->post_type );
+
+		$taxonomy_names = get_object_taxonomies( $screen->post_type );
+		$hierarchical_taxonomies = array();
+		$flat_taxonomies = array();
+		foreach ( $taxonomy_names as $taxonomy_name ) {
+			$taxonomy = get_taxonomy( $taxonomy_name );
+
+			if ( !$taxonomy->show_ui )
+				continue;
+
+			if ( $taxonomy->hierarchical )
+				$hierarchical_taxonomies[] = $taxonomy;
+			else
+				$flat_taxonomies[] = $taxonomy;
+		}
+
+		$m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
+		$can_publish = current_user_can( $post_type_object->cap->publish_posts );
+		$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
+
+	?>
+
+	<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
+		<?php
+		$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
+		$bulk = 0;
+		while ( $bulk < 2 ) { ?>
+
+		<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
+			echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";
+		?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
+
+		<fieldset class="inline-edit-col-left"><div class="inline-edit-col">
+			<h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
+	<?php
+
+	if ( post_type_supports( $screen->post_type, 'title' ) ) :
+		if ( $bulk ) : ?>
+			<div id="bulk-title-div">
+				<div id="bulk-titles"></div>
+			</div>
+
+	<?php else : // $bulk ?>
+
+			<label>
+				<span class="title"><?php _e( 'Title' ); ?></span>
+				<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
+			</label>
+
+			<label>
+				<span class="title"><?php _e( 'Slug' ); ?></span>
+				<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
+			</label>
+
+	<?php endif; // $bulk
+	endif; // post_type_supports title ?>
+
+	<?php if ( !$bulk ) : ?>
+			<label><span class="title"><?php _e( 'Date' ); ?></span></label>
+			<div class="inline-edit-date">
+				<?php touch_time( 1, 1, 4, 1 ); ?>
+			</div>
+			<br class="clear" />
+	<?php endif; // $bulk
+
+		if ( post_type_supports( $screen->post_type, 'author' ) ) :
+			$authors_dropdown = '';
+
+			if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
+				$users_opt = array(
+					'hide_if_only_one_author' => false,
+					'who' => 'authors',
+					'name' => 'post_author',
+					'class'=> 'authors',
+					'multi' => 1,
+					'echo' => 0
+				);
+				if ( $bulk )
+					$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
+
+				if ( $authors = wp_dropdown_users( $users_opt ) ) :
+					$authors_dropdown  = '<label class="inline-edit-author">';
+					$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
+					$authors_dropdown .= $authors;
+					$authors_dropdown .= '</label>';
+				endif;
+			endif; // authors
+	?>
+
+	<?php if ( !$bulk ) echo $authors_dropdown;
+	endif; // post_type_supports author
+
+	if ( !$bulk ) :
+	?>
+
+			<div class="inline-edit-group">
+				<label class="alignleft">
+					<span class="title"><?php _e( 'Password' ); ?></span>
+					<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
+				</label>
+
+				<em style="margin:5px 10px 0 0" class="alignleft">
+					<?php
+					/* translators: Between password field and private checkbox on post quick edit interface */
+					echo __( '&ndash;OR&ndash;' );
+					?>
+				</em>
+				<label class="alignleft inline-edit-private">
+					<input type="checkbox" name="keep_private" value="private" />
+					<span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
+				</label>
+			</div>
+
+	<?php endif; ?>
+
+		</div></fieldset>
+
+	<?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
+
+		<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
+
+	<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
+
+			<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?>
+				<span class="catshow"><?php _e( '[more]' ); ?></span>
+				<span class="cathide" style="display:none;"><?php _e( '[less]' ); ?></span>
+			</span>
+			<input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
+			<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
+				<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
+			</ul>
+
+	<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
+
+		</div></fieldset>
+
+	<?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
+
+		<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
+
+	<?php
+		if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
+			echo $authors_dropdown;
+	?>
+
+	<?php if ( $post_type_object->hierarchical ) : ?>
+
+			<label>
+				<span class="title"><?php _e( 'Parent' ); ?></span>
+	<?php
+		$dropdown_args = array( 'post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __( 'Main Page (no parent)' ), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title' );
+		if ( $bulk )
+			$dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
+		$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
+		wp_dropdown_pages( $dropdown_args );
+	?>
+			</label>
+
+	<?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
+			if ( !$bulk ) : ?>
+
+			<label>
+				<span class="title"><?php _e( 'Order' ); ?></span>
+				<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
+			</label>
+
+	<?php	endif; // !$bulk ?>
+
+			<label>
+				<span class="title"><?php _e( 'Template' ); ?></span>
+				<select name="page_template">
+	<?php	if ( $bulk ) : ?>
+					<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
+	<?php	endif; // $bulk ?>
+					<option value="default"><?php _e( 'Default Template' ); ?></option>
+					<?php page_template_dropdown() ?>
+				</select>
+			</label>
+
+	<?php
+		endif; // post_type_supports page-attributes
+	endif; // $post_type_object->hierarchical ?>
+
+	<?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
+
+	<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
+
+			<label class="inline-edit-tags">
+				<span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
+				<textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
+			</label>
+
+	<?php endforeach; //$flat_taxonomies as $taxonomy ?>
+
+	<?php endif; // count( $flat_taxonomies ) && !$bulk  ?>
+
+	<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
+		if ( $bulk ) : ?>
+
+			<div class="inline-edit-group">
+		<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
+			<label class="alignleft">
+				<span class="title"><?php _e( 'Comments' ); ?></span>
+				<select name="comment_status">
+					<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
+					<option value="open"><?php _e( 'Allow' ); ?></option>
+					<option value="closed"><?php _e( 'Do not allow' ); ?></option>
+				</select>
+			</label>
+		<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
+			<label class="alignright">
+				<span class="title"><?php _e( 'Pings' ); ?></span>
+				<select name="ping_status">
+					<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
+					<option value="open"><?php _e( 'Allow' ); ?></option>
+					<option value="closed"><?php _e( 'Do not allow' ); ?></option>
+				</select>
+			</label>
+		<?php endif; ?>
+			</div>
+
+	<?php else : // $bulk ?>
+
+			<div class="inline-edit-group">
+			<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
+				<label class="alignleft">
+					<input type="checkbox" name="comment_status" value="open" />
+					<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
+				</label>
+			<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
+				<label class="alignleft">
+					<input type="checkbox" name="ping_status" value="open" />
+					<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
+				</label>
+			<?php endif; ?>
+			</div>
+
+	<?php endif; // $bulk
+	endif; // post_type_supports comments or pings ?>
+
+			<div class="inline-edit-group">
+				<label class="inline-edit-status alignleft">
+					<span class="title"><?php _e( 'Status' ); ?></span>
+					<select name="_status">
+	<?php if ( $bulk ) : ?>
+						<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
+	<?php endif; // $bulk ?>
+					<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
+						<option value="publish"><?php _e( 'Published' ); ?></option>
+						<option value="future"><?php _e( 'Scheduled' ); ?></option>
+	<?php if ( $bulk ) : ?>
+						<option value="private"><?php _e( 'Private' ) ?></option>
+	<?php endif; // $bulk ?>
+					<?php endif; ?>
+						<option value="pending"><?php _e( 'Pending Review' ); ?></option>
+						<option value="draft"><?php _e( 'Draft' ); ?></option>
+					</select>
+				</label>
+
+	<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
+
+	<?php	if ( $bulk ) : ?>
+
+				<label class="alignright">
+					<span class="title"><?php _e( 'Sticky' ); ?></span>
+					<select name="sticky">
+						<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
+						<option value="sticky"><?php _e( 'Sticky' ); ?></option>
+						<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
+					</select>
+				</label>
+
+	<?php	else : // $bulk ?>
+
+				<label class="alignleft">
+					<input type="checkbox" name="sticky" value="sticky" />
+					<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
+				</label>
+
+	<?php	endif; // $bulk ?>
+
+	<?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
+
+			</div>
+
+		</div></fieldset>
+
+	<?php
+		list( $columns ) = $this->get_column_info();
+
+		foreach ( $columns as $column_name => $column_display_name ) {
+			if ( isset( $core_columns[$column_name] ) )
+				continue;
+			do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
+		}
+	?>
+		<p class="submit inline-edit-save">
+			<a accesskey="c" href="#inline-edit" title="<?php _e( 'Cancel' ); ?>" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
+			<?php if ( ! $bulk ) {
+				wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
+				$update_text = __( 'Update' );
+				?>
+				<a accesskey="s" href="#inline-edit" title="<?php _e( 'Update' ); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
+				<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+			<?php } else {
+				submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
+			} ?>
+			<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
+			<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
+			<br class="clear" />
+		</p>
+		</td></tr>
+	<?php
+		$bulk++;
+		}
+?>
+		</tbody></table></form>
+<?php
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-terms-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-terms-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-terms-list-table.php	(revision 17487)
@@ -0,0 +1,379 @@
+<?php
+/**
+ * Terms List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Terms_List_Table extends WP_List_Table {
+
+	var $callback_args;
+
+	function WP_Terms_List_Table() {
+		global $post_type, $taxonomy, $tax;
+
+		wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) );
+
+		if ( empty( $taxonomy ) )
+			$taxonomy = 'post_tag';
+
+		if ( !taxonomy_exists( $taxonomy ) )
+			wp_die( __( 'Invalid taxonomy' ) );
+
+		$tax = get_taxonomy( $taxonomy );
+
+		if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'public' => true ) ) ) )
+			$post_type = 'post';
+
+		parent::WP_List_Table( array(
+			'plural' => 'tags',
+			'singular' => 'tag',
+		) );
+	}
+
+	function ajax_user_can() {
+		global $tax;
+
+		return current_user_can( $tax->cap->manage_terms );
+	}
+
+	function prepare_items() {
+		global $taxonomy;
+
+		$tags_per_page = $this->get_items_per_page( 'edit_' .  $taxonomy . '_per_page' );
+
+		if ( 'post_tag' == $taxonomy ) {
+			$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
+			$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
+		} elseif ( 'category' == $taxonomy ) {
+			$tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter
+		}
+
+		$search = !empty( $_REQUEST['s'] ) ? trim( stripslashes( $_REQUEST['s'] ) ) : '';
+
+		$args = array(
+			'search' => $search,
+			'page' => $this->get_pagenum(),
+			'number' => $tags_per_page,
+		);
+
+		if ( !empty( $_REQUEST['orderby'] ) )
+			$args['orderby'] = trim( stripslashes( $_REQUEST['orderby'] ) );
+
+		if ( !empty( $_REQUEST['order'] ) )
+			$args['order'] = trim( stripslashes( $_REQUEST['order'] ) );
+
+		$this->callback_args = $args;
+
+		$this->set_pagination_args( array(
+			'total_items' => wp_count_terms( $taxonomy, compact( 'search' ) ),
+			'per_page' => $tags_per_page,
+		) );
+	}
+
+	function has_items() {
+		// todo: populate $this->items in prepare_items()
+		return true;
+	}
+
+	function get_bulk_actions() {
+		$actions = array();
+		$actions['delete'] = __( 'Delete' );
+
+		return $actions;
+	}
+
+	function current_action() {
+		if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
+			return 'bulk-delete';
+
+		return parent::current_action();
+	}
+
+	function get_columns() {
+		global $taxonomy, $typenow;
+
+		$columns = array(
+			'cb'          => '<input type="checkbox" />',
+			'name'        => __( 'Name' ),
+			'description' => __( 'Description' ),
+			'slug'        => __( 'Slug' ),
+		);
+
+		if ( 'link_category' == $taxonomy ) {
+			$columns['links'] = __( 'Links' );
+		} else {
+			$post_type = empty( $typenow ) ? 'post' : $typenow;
+			$post_type_object = get_post_type_object( $post_type );
+			$columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' );
+		}
+
+		return $columns;
+	}
+
+	function get_sortable_columns() {
+		return array(
+			'name'        => 'name',
+			'description' => 'description',
+			'slug'        => 'slug',
+			'posts'       => 'count',
+			'links'       => 'count'
+		);
+	}
+
+	function display_rows_or_placeholder() {
+		global $taxonomy;
+
+		$args = wp_parse_args( $this->callback_args, array(
+			'page' => 1,
+			'number' => 20,
+			'search' => '',
+			'hide_empty' => 0
+		) );
+
+		extract( $args, EXTR_SKIP );
+
+		$args['offset'] = $offset = ( $page - 1 ) * $number;
+
+		// convert it to table rows
+		$out = '';
+		$count = 0;
+
+		$terms = array();
+
+		if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) {
+			// We'll need the full set of terms then.
+			$args['number'] = $args['offset'] = 0;
+
+			$terms = get_terms( $taxonomy, $args );
+			if ( !empty( $search ) ) // Ignore children on searches.
+				$children = array();
+			else
+				$children = _get_term_hierarchy( $taxonomy );
+
+			// Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
+			$out .= $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
+		} else {
+			$terms = get_terms( $taxonomy, $args );
+			foreach ( $terms as $term )
+				$out .= $this->single_row( $term, 0, $taxonomy );
+			$count = $number; // Only displaying a single page.
+		}
+
+		if ( empty( $terms ) ) {
+			list( $columns, $hidden ) = $this->get_column_info();
+			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
+			$this->no_items();
+			echo '</td></tr>';
+		} else {
+			echo $out;
+		}
+	}
+
+	function _rows( $taxonomy, $terms, &$children, $start = 0, $per_page = 20, &$count, $parent = 0, $level = 0 ) {
+
+		$end = $start + $per_page;
+
+		$output = '';
+		foreach ( $terms as $key => $term ) {
+
+			if ( $count >= $end )
+				break;
+
+			if ( $term->parent != $parent && empty( $_REQUEST['s'] ) )
+				continue;
+
+			// If the page starts in a subtree, print the parents.
+			if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
+				$my_parents = $parent_ids = array();
+				$p = $term->parent;
+				while ( $p ) {
+					$my_parent = get_term( $p, $taxonomy );
+					$my_parents[] = $my_parent;
+					$p = $my_parent->parent;
+					if ( in_array( $p, $parent_ids ) ) // Prevent parent loops.
+						break;
+					$parent_ids[] = $p;
+				}
+				unset( $parent_ids );
+
+				$num_parents = count( $my_parents );
+				while ( $my_parent = array_pop( $my_parents ) ) {
+					$output .=  "\t" . $this->single_row( $my_parent, $level - $num_parents, $taxonomy );
+					$num_parents--;
+				}
+			}
+
+			if ( $count >= $start )
+				$output .= "\t" . $this->single_row( $term, $level, $taxonomy );
+
+			++$count;
+
+			unset( $terms[$key] );
+
+			if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) )
+				$output .= $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 );
+		}
+
+		return $output;
+	}
+
+	function single_row( $tag, $level = 0 ) {
+		static $row_class = '';
+		$row_class = ( $row_class == '' ? ' class="alternate"' : '' );
+
+		$this->level = $level;
+
+		echo '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
+		echo $this->single_row_columns( $tag );
+		echo '</tr>';
+	}
+
+	function column_cb( $tag ) {
+		global $taxonomy, $tax;
+
+		$default_term = get_option( 'default_' . $taxonomy );
+
+		if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
+			return '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" />';
+		else
+			return '&nbsp;';
+	}
+
+	function column_name( $tag ) {
+		global $taxonomy, $tax, $post_type;
+
+		$default_term = get_option( 'default_' . $taxonomy );
+
+		$pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
+		$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
+		$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
+		$edit_link = get_edit_term_link( $tag->term_id, $taxonomy, $post_type );
+
+		$out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
+
+		$actions = array();
+		if ( current_user_can( $tax->cap->edit_terms ) ) {
+			$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
+			$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
+		}
+		if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
+			$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
+
+		$actions = apply_filters( 'tag_row_actions', $actions, $tag );
+		$actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
+
+		$out .= $this->row_actions( $actions );
+		$out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
+		$out .= '<div class="name">' . $qe_data->name . '</div>';
+		$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
+		$out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>';
+
+		return $out;
+	}
+
+	function column_description( $tag ) {
+		return $tag->description;
+	}
+
+	function column_slug( $tag ) {
+		return apply_filters( 'editable_slug', $tag->slug );
+	}
+
+	function column_posts( $tag ) {
+		global $taxonomy, $post_type;
+
+		$count = number_format_i18n( $tag->count );
+
+		$tax = get_taxonomy( $taxonomy );
+
+		if ( ! $tax->public )
+			return $count;
+
+		if ( $tax->query_var ) {
+			$args = array( $tax->query_var => $tag->slug );
+		} else {
+			$args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug );
+		}
+
+		$args['post_type'] = $post_type;
+
+		return "<a href='" . add_query_arg( $args, 'edit.php' ) . "'>$count</a>";
+	}
+
+	function column_links( $tag ) {
+		$count = number_format_i18n( $tag->count );
+		if ( $count )
+			$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
+		return $count;
+	}
+
+	function column_default( $tag, $column_name ) {
+		$screen = get_current_screen();
+
+		return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
+	}
+
+	/**
+	 * Outputs the hidden row displayed when inline editing
+	 *
+	 * @since 3.1.0
+	 */
+	function inline_edit() {
+		global $tax;
+
+		if ( ! current_user_can( $tax->cap->edit_terms ) )
+			return;
+?>
+
+	<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
+		<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
+
+			<fieldset><div class="inline-edit-col">
+				<h4><?php _e( 'Quick Edit' ); ?></h4>
+
+				<label>
+					<span class="title"><?php _e( 'Name' ); ?></span>
+					<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
+				</label>
+	<?php if ( !global_terms_enabled() ) { ?>
+				<label>
+					<span class="title"><?php _e( 'Slug' ); ?></span>
+					<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
+				</label>
+	<?php } ?>
+			</div></fieldset>
+	<?php
+
+		$core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
+
+		list( $columns ) = $this->get_column_info();
+
+		foreach ( $columns as $column_name => $column_display_name ) {
+			if ( isset( $core_columns[$column_name] ) )
+				continue;
+
+			do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $tax->name );
+		}
+
+	?>
+
+		<p class="inline-edit-save submit">
+			<a accesskey="c" href="#inline-edit" title="<?php _e( 'Cancel' ); ?>" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></a>
+			<?php $update_text = $tax->labels->update_item; ?>
+			<a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
+			<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+			<span class="error" style="display:none;"></span>
+			<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
+			<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $tax->name ); ?>" />
+			<br class="clear" />
+		</p>
+		</td></tr>
+		</tbody></table></form>
+	<?php
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-theme-install-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-theme-install-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-theme-install-list-table.php	(revision 17487)
@@ -0,0 +1,185 @@
+<?php
+/**
+ * Theme Installer List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Theme_Install_List_Table extends WP_List_Table {
+
+	function ajax_user_can() {
+		return current_user_can('install_themes');
+	}
+
+	function prepare_items() {
+		include( ABSPATH . 'wp-admin/includes/theme-install.php' );
+
+		global $tabs, $tab, $paged, $type, $term, $theme_field_defaults;
+
+		wp_reset_vars( array( 'tab' ) );
+
+		$paged = $this->get_pagenum();
+
+		$per_page = 30;
+
+		// These are the tabs which are shown on the page,
+		$tabs = array();
+		$tabs['dashboard'] = __( 'Search' );
+		if ( 'search' == $tab )
+			$tabs['search']	= __( 'Search Results' );
+		$tabs['upload'] = __( 'Upload' );
+		$tabs['featured'] = _x( 'Featured','Theme Installer' );
+		//$tabs['popular']  = _x( 'Popular','Theme Installer' );
+		$tabs['new']      = _x( 'Newest','Theme Installer' );
+		$tabs['updated']  = _x( 'Recently Updated','Theme Installer' );
+
+		$nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item.
+
+		$tabs = apply_filters( 'install_themes_tabs', $tabs );
+		$nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs );
+
+		// If a non-valid menu tab has been selected, And its not a non-menu action.
+		if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) )
+			$tab = key( $tabs );
+
+		$args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults );
+
+		switch ( $tab ) {
+			case 'search':
+				$type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
+				$term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
+
+				switch ( $type ) {
+					case 'tag':
+						$terms = explode( ',', $term );
+						$terms = array_map( 'trim', $terms );
+						$terms = array_map( 'sanitize_title_with_dashes', $terms );
+						$args['tag'] = $terms;
+						break;
+					case 'term':
+						$args['search'] = $term;
+						break;
+					case 'author':
+						$args['author'] = $term;
+						break;
+				}
+
+				if ( !empty( $_POST['features'] ) ) {
+					$terms = $_POST['features'];
+					$terms = array_map( 'trim', $terms );
+					$terms = array_map( 'sanitize_title_with_dashes', $terms );
+					$args['tag'] = $terms;
+					$_REQUEST['s'] = implode( ',', $terms );
+					$_REQUEST['type'] = 'tag';
+				}
+
+				add_action( 'install_themes_table_header', 'install_theme_search_form' );
+				break;
+
+			case 'featured':
+			//case 'popular':
+			case 'new':
+			case 'updated':
+				$args['browse'] = $tab;
+				break;
+
+			default:
+				$args = false;
+		}
+
+		if ( !$args )
+			return;
+
+		$api = themes_api( 'query_themes', $args );
+
+		if ( is_wp_error( $api ) )
+			wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' );
+
+		$this->items = $api->themes;
+
+		$this->set_pagination_args( array(
+			'total_items' => $api->info['results'],
+			'per_page' => $per_page,
+		) );
+	}
+
+	function no_items() {
+		_e( 'No themes match your request.' );
+	}
+
+	function get_views() {
+		global $tabs, $tab;
+
+		$display_tabs = array();
+		foreach ( (array) $tabs as $action => $text ) {
+			$class = ( $action == $tab ) ? ' class="current"' : '';
+			$href = self_admin_url('theme-install.php?tab=' . $action);
+			$display_tabs['theme-install-'.$action] = "<a href='$href'$class>$text</a>";
+		}
+
+		return $display_tabs;
+	}
+
+	function get_columns() {
+		return array();
+	}
+
+	function display() {
+
+		// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
+?>
+		<div class="tablenav top">
+			<div class="alignleft actions">
+				<?php do_action( 'install_themes_table_header' ); ?>
+			</div>
+			<?php $this->pagination( 'top' ); ?>
+			<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
+			<br class="clear" />
+		</div>
+
+		<table id="availablethemes" cellspacing="0" cellpadding="0">
+			<tbody id="the-list" class="list:themes">
+				<?php $this->display_rows_or_placeholder(); ?>
+			</tbody>
+		</table>
+
+		<div class="tablenav bottom">
+			<?php $this->pagination( 'bottom' ); ?>
+			<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
+			<br class="clear" />
+		</div>
+<?php
+	}
+
+	function display_rows() {
+		$themes = $this->items;
+
+		$rows = ceil( count( $themes ) / 3 );
+		$table = array();
+		$theme_keys = array_keys( $themes );
+		for ( $row = 1; $row <= $rows; $row++ )
+			for ( $col = 1; $col <= 3; $col++ )
+				$table[$row][$col] = array_shift( $theme_keys );
+
+		foreach ( $table as $row => $cols ) {
+			echo "\t<tr>\n";
+			foreach ( $cols as $col => $theme_index ) {
+				$class = array( 'available-theme' );
+				if ( $row == 1 ) $class[] = 'top';
+				if ( $col == 1 ) $class[] = 'left';
+				if ( $row == $rows ) $class[] = 'bottom';
+				if ( $col == 3 ) $class[] = 'right';
+				?>
+				<td class="<?php echo join( ' ', $class ); ?>"><?php
+					if ( isset( $themes[$theme_index] ) )
+						display_theme( $themes[$theme_index] );
+				?></td>
+			<?php } // end foreach $cols
+			echo "\t</tr>\n";
+		} // end foreach $table
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-themes-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-themes-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-themes-list-table.php	(revision 17487)
@@ -0,0 +1,241 @@
+<?php
+/**
+ * Themes List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Themes_List_Table extends WP_List_Table {
+
+	var $search = array();
+	var $features = array();
+
+	function ajax_user_can() {
+		// Do not check edit_theme_options here. AJAX calls for available themes require switch_themes.
+		return current_user_can('switch_themes');
+	}
+
+	function prepare_items() {
+		global $ct;
+
+		$ct = current_theme_info();
+
+		$themes = get_allowed_themes();
+
+		$search = !empty( $_REQUEST['s'] ) ? trim( stripslashes( $_REQUEST['s'] ) ) : '';
+
+		if ( '' !== $search ) {
+			$this->search = array_merge( $this->search, array_filter( array_map( 'trim', explode( ',', $search ) ) ) );
+			$this->search = array_unique( $this->search );
+		}
+
+		if ( !empty( $_REQUEST['features'] ) ) {
+			$this->features = $_REQUEST['features'];
+			$this->features = array_map( 'trim', $this->features );
+			$this->features = array_map( 'sanitize_title_with_dashes', $this->features );
+			$this->features = array_unique( $this->features );
+		}
+
+		if ( $this->search || $this->features ) {
+			foreach ( $themes as $key => $theme ) {
+				if ( !$this->search_theme( $theme ) )
+					unset( $themes[ $key ] );
+			}
+		}
+
+		unset( $themes[$ct->name] );
+		uksort( $themes, "strnatcasecmp" );
+
+		$per_page = 15;
+		$page = $this->get_pagenum();
+
+		$start = ( $page - 1 ) * $per_page;
+
+		$this->items = array_slice( $themes, $start, $per_page );
+
+		$this->set_pagination_args( array(
+			'total_items' => count( $themes ),
+			'per_page' => $per_page,
+		) );
+	}
+
+	function no_items() {
+		if ( $this->search || $this->features ) {
+			_e( 'No items found.' );
+			return;
+		}
+
+		if ( is_multisite() ) {
+			if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) {
+				printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ), network_admin_url( 'theme-install.php' ) );
+
+				return;
+			} elseif ( current_user_can( 'manage_network_themes' ) ) {
+				printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ) );
+
+				return;
+			}
+			// else, fallthrough. install_themes doesn't help if you can't enable it.
+		} else {
+			if ( current_user_can( 'install_themes' ) ) {
+				printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), admin_url( 'theme-install.php' ) );
+
+				return;
+			}
+		}
+		// Fallthrough.
+		printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) );
+	}
+
+	function tablenav( $which = 'top' ) {
+		if ( $this->get_pagination_arg( 'total_pages' ) <= 1 )
+			return;
+		?>
+		<div class="tablenav <?php echo $which; ?>">
+			<?php $this->pagination( $which ); ?>
+		   <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
+		  <br class="clear" />
+		</div>
+		<?php
+	}
+
+	function display() {
+		// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
+?>
+		<?php $this->tablenav( 'top' ); ?>
+
+		<table id="availablethemes" cellspacing="0" cellpadding="0">
+			<tbody id="the-list" class="list:themes">
+				<?php $this->display_rows_or_placeholder(); ?>
+			</tbody>
+		</table>
+
+		<?php $this->tablenav( 'bottom' ); ?>
+<?php
+	}
+
+	function get_columns() {
+		return array();
+	}
+
+	function display_rows() {
+		$themes = $this->items;
+		$theme_names = array_keys( $themes );
+		natcasesort( $theme_names );
+
+		$table = array();
+		$rows = ceil( count( $theme_names ) / 3 );
+		for ( $row = 1; $row <= $rows; $row++ )
+			for ( $col = 1; $col <= 3; $col++ )
+				$table[$row][$col] = array_shift( $theme_names );
+
+		foreach ( $table as $row => $cols ) {
+?>
+<tr>
+<?php
+foreach ( $cols as $col => $theme_name ) {
+	$class = array( 'available-theme' );
+	if ( $row == 1 ) $class[] = 'top';
+	if ( $col == 1 ) $class[] = 'left';
+	if ( $row == $rows ) $class[] = 'bottom';
+	if ( $col == 3 ) $class[] = 'right';
+?>
+	<td class="<?php echo join( ' ', $class ); ?>">
+<?php if ( !empty( $theme_name ) ) :
+	$template = $themes[$theme_name]['Template'];
+	$stylesheet = $themes[$theme_name]['Stylesheet'];
+	$title = $themes[$theme_name]['Title'];
+	$version = $themes[$theme_name]['Version'];
+	$description = $themes[$theme_name]['Description'];
+	$author = $themes[$theme_name]['Author'];
+	$screenshot = $themes[$theme_name]['Screenshot'];
+	$stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
+	$template_dir = $themes[$theme_name]['Template Dir'];
+	$parent_theme = $themes[$theme_name]['Parent Theme'];
+	$theme_root = $themes[$theme_name]['Theme Root'];
+	$theme_root_uri = $themes[$theme_name]['Theme Root URI'];
+	$preview_link = esc_url( get_option( 'home' ) . '/' );
+	if ( is_ssl() )
+		$preview_link = str_replace( 'http://', 'https://', $preview_link );
+	$preview_link = htmlspecialchars( add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ), $preview_link ) );
+	$preview_text = esc_attr( sprintf( __( 'Preview of &#8220;%s&#8221;' ), $title ) );
+	$tags = $themes[$theme_name]['Tags'];
+	$thickbox_class = 'thickbox thickbox-preview';
+	$activate_link = wp_nonce_url( "themes.php?action=activate&amp;template=".urlencode( $template )."&amp;stylesheet=".urlencode( $stylesheet ), 'switch-theme_' . $template );
+	$activate_text = esc_attr( sprintf( __( 'Activate &#8220;%s&#8221;' ), $title ) );
+	$actions = array();
+	$actions[] = '<a href="' . $activate_link .  '" class="activatelink" title="' . $activate_text . '">' . __( 'Activate' ) . '</a>';
+	$actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $theme_name ) ) . '">' . __( 'Preview' ) . '</a>';
+	if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
+		$actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&amp;template=$stylesheet", 'delete-theme_' . $stylesheet ) . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n  'Cancel' to stop, 'OK' to delete." ), $theme_name ) ) . "' );" . '">' . __( 'Delete' ) . '</a>';
+	$actions = apply_filters( 'theme_action_links', $actions, $themes[$theme_name] );
+
+	$actions = implode ( ' | ', $actions );
+?>
+		<a href="<?php echo $preview_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
+<?php if ( $screenshot ) : ?>
+			<img src="<?php echo $theme_root_uri . '/' . $stylesheet . '/' . $screenshot; ?>" alt="" />
+<?php endif; ?>
+		</a>
+<h3><?php
+	/* translators: 1: theme title, 2: theme version, 3: theme author */
+	printf( __( '%1$s %2$s by %3$s' ), $title, $version, $author ) ; ?></h3>
+<p class="description"><?php echo $description; ?></p>
+<span class='action-links'><?php echo $actions ?></span>
+	<?php if ( current_user_can( 'edit_themes' ) && $parent_theme ) {
+	/* translators: 1: theme title, 2:  template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?>
+	<p><?php printf( __( 'The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.' ), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme ); ?></p>
+<?php } else { ?>
+	<p><?php printf( __( 'All of this theme&#8217;s files are located in <code>%2$s</code>.' ), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ) ); ?></p>
+<?php } ?>
+<?php if ( $tags ) : ?>
+<p><?php _e( 'Tags:' ); ?> <?php echo join( ', ', $tags ); ?></p>
+<?php endif; ?>
+		<?php theme_update_available( $themes[$theme_name] ); ?>
+<?php endif; // end if not empty theme_name ?>
+	</td>
+<?php } // end foreach $cols ?>
+</tr>
+<?php } // end foreach $table
+	}
+
+	function search_theme( $theme ) {
+		$matched = 0;
+
+		// Match all phrases
+		if ( count( $this->search ) > 0 ) {
+			foreach ( $this->search as $word ) {
+				$matched = 0;
+
+				// In a tag?
+				if ( in_array( $word, array_map( 'sanitize_title_with_dashes', $theme['Tags'] ) ) )
+					$matched = 1;
+
+				// In one of the fields?
+				foreach ( array( 'Name', 'Title', 'Description', 'Author', 'Template', 'Stylesheet' ) AS $field ) {
+					if ( stripos( $theme[$field], $word ) !== false )
+						$matched++;
+				}
+
+				if ( $matched == 0 )
+					return false;
+			}
+		}
+
+		// Now search the features
+		if ( count( $this->features ) > 0 ) {
+			foreach ( $this->features as $word ) {
+				// In a tag?
+				if ( !in_array( $word, array_map( 'sanitize_title_with_dashes', $theme['Tags'] ) ) )
+					return false;
+			}
+		}
+
+		// Only get here if each word exists in the tags or one of the fields
+		return true;
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/class-wp-upgrader.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-upgrader.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-upgrader.php	(revision 17487)
@@ -0,0 +1,1468 @@
+<?php
+/**
+ * A File upgrader class for WordPress.
+ *
+ * This set of classes are designed to be used to upgrade/install a local set of files on the filesystem via the Filesystem Abstraction classes.
+ *
+ * @link http://trac.wordpress.org/ticket/7875 consolidate plugin/theme/core upgrade/install functions
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+
+/**
+ * WordPress Upgrader class for Upgrading/Installing a local set of files via the Filesystem Abstraction classes from a Zip file.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class WP_Upgrader {
+	var $strings = array();
+	var $skin = null;
+	var $result = array();
+
+	function WP_Upgrader($skin = null) {
+		return $this->__construct($skin);
+	}
+	function __construct($skin = null) {
+		if ( null == $skin )
+			$this->skin = new WP_Upgrader_Skin();
+		else
+			$this->skin = $skin;
+	}
+
+	function init() {
+		$this->skin->set_upgrader($this);
+		$this->generic_strings();
+	}
+
+	function generic_strings() {
+		$this->strings['bad_request'] = __('Invalid Data provided.');
+		$this->strings['fs_unavailable'] = __('Could not access filesystem.');
+		$this->strings['fs_error'] = __('Filesystem error.');
+		$this->strings['fs_no_root_dir'] = __('Unable to locate WordPress Root directory.');
+		$this->strings['fs_no_content_dir'] = __('Unable to locate WordPress Content directory (wp-content).');
+		$this->strings['fs_no_plugins_dir'] = __('Unable to locate WordPress Plugin directory.');
+		$this->strings['fs_no_themes_dir'] = __('Unable to locate WordPress Theme directory.');
+		/* translators: %s: directory name */
+		$this->strings['fs_no_folder'] = __('Unable to locate needed folder (%s).');
+
+		$this->strings['download_failed'] = __('Download failed.');
+		$this->strings['installing_package'] = __('Installing the latest version&#8230;');
+		$this->strings['folder_exists'] = __('Destination folder already exists.');
+		$this->strings['mkdir_failed'] = __('Could not create directory.');
+		$this->strings['bad_package'] = __('Incompatible Archive.');
+
+		$this->strings['maintenance_start'] = __('Enabling Maintenance mode&#8230;');
+		$this->strings['maintenance_end'] = __('Disabling Maintenance mode&#8230;');
+	}
+
+	function fs_connect( $directories = array() ) {
+		global $wp_filesystem;
+
+		if ( false === ($credentials = $this->skin->request_filesystem_credentials()) )
+			return false;
+
+		if ( ! WP_Filesystem($credentials) ) {
+			$error = true;
+			if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
+				$error = $wp_filesystem->errors;
+			$this->skin->request_filesystem_credentials($error); //Failed to connect, Error and request again
+			return false;
+		}
+
+		if ( ! is_object($wp_filesystem) )
+			return new WP_Error('fs_unavailable', $this->strings['fs_unavailable'] );
+
+		if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
+			return new WP_Error('fs_error', $this->strings['fs_error'], $wp_filesystem->errors);
+
+		foreach ( (array)$directories as $dir ) {
+			switch ( $dir ) {
+				case ABSPATH:
+					if ( ! $wp_filesystem->abspath() )
+						return new WP_Error('fs_no_root_dir', $this->strings['fs_no_root_dir']);
+					break;
+				case WP_CONTENT_DIR:
+					if ( ! $wp_filesystem->wp_content_dir() )
+						return new WP_Error('fs_no_content_dir', $this->strings['fs_no_content_dir']);
+					break;
+				case WP_PLUGIN_DIR:
+					if ( ! $wp_filesystem->wp_plugins_dir() )
+						return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']);
+					break;
+				case WP_CONTENT_DIR . '/themes':
+					if ( ! $wp_filesystem->find_folder(WP_CONTENT_DIR . '/themes') )
+						return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']);
+					break;
+				default:
+					if ( ! $wp_filesystem->find_folder($dir) )
+						return new WP_Error('fs_no_folder', sprintf($this->strings['fs_no_folder'], $dir));
+					break;
+			}
+		}
+		return true;
+	} //end fs_connect();
+
+	function download_package($package) {
+
+		if ( ! preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package) ) //Local file or remote?
+			return $package; //must be a local file..
+
+		if ( empty($package) )
+			return new WP_Error('no_package', $this->strings['no_package']);
+
+		$this->skin->feedback('downloading_package', $package);
+
+		$download_file = download_url($package);
+
+		if ( is_wp_error($download_file) )
+			return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());
+
+		return $download_file;
+	}
+
+	function unpack_package($package, $delete_package = true) {
+		global $wp_filesystem;
+
+		$this->skin->feedback('unpack_package');
+
+		$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
+
+		//Clean up contents of upgrade directory beforehand.
+		$upgrade_files = $wp_filesystem->dirlist($upgrade_folder);
+		if ( !empty($upgrade_files) ) {
+			foreach ( $upgrade_files as $file )
+				$wp_filesystem->delete($upgrade_folder . $file['name'], true);
+		}
+
+		//We need a working directory
+		$working_dir = $upgrade_folder . basename($package, '.zip');
+
+		// Clean up working directory
+		if ( $wp_filesystem->is_dir($working_dir) )
+			$wp_filesystem->delete($working_dir, true);
+
+		// Unzip package to working directory
+		$result = unzip_file($package, $working_dir); //TODO optimizations, Copy when Move/Rename would suffice?
+
+		// Once extracted, delete the package if required.
+		if ( $delete_package )
+			unlink($package);
+
+		if ( is_wp_error($result) ) {
+			$wp_filesystem->delete($working_dir, true);
+			return $result;
+		}
+
+		return $working_dir;
+	}
+
+	function install_package($args = array()) {
+		global $wp_filesystem;
+		$defaults = array( 'source' => '', 'destination' => '', //Please always pass these
+						'clear_destination' => false, 'clear_working' => false,
+						'hook_extra' => array());
+
+		$args = wp_parse_args($args, $defaults);
+		extract($args);
+
+		@set_time_limit( 300 );
+
+		if ( empty($source) || empty($destination) )
+			return new WP_Error('bad_request', $this->strings['bad_request']);
+
+		$this->skin->feedback('installing_package');
+
+		$res = apply_filters('upgrader_pre_install', true, $hook_extra);
+		if ( is_wp_error($res) )
+			return $res;
+
+		//Retain the Original source and destinations
+		$remote_source = $source;
+		$local_destination = $destination;
+
+		$source_files = array_keys( $wp_filesystem->dirlist($remote_source) );
+		$remote_destination = $wp_filesystem->find_folder($local_destination);
+
+		//Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
+		if ( 1 == count($source_files) && $wp_filesystem->is_dir( trailingslashit($source) . $source_files[0] . '/') ) //Only one folder? Then we want its contents.
+			$source = trailingslashit($source) . trailingslashit($source_files[0]);
+		elseif ( count($source_files) == 0 )
+			return new WP_Error('bad_package', $this->strings['bad_package']); //There are no files?
+		//else //Its only a single file, The upgrader will use the foldername of this file as the destination folder. foldername is based on zip filename.
+
+		//Hook ability to change the source file location..
+		$source = apply_filters('upgrader_source_selection', $source, $remote_source, $this);
+		if ( is_wp_error($source) )
+			return $source;
+
+		//Has the source location changed? If so, we need a new source_files list.
+		if ( $source !== $remote_source )
+			$source_files = array_keys( $wp_filesystem->dirlist($source) );
+
+		//Protection against deleting files in any important base directories.
+		if ( in_array( $destination, array(ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes') ) ) {
+			$remote_destination = trailingslashit($remote_destination) . trailingslashit(basename($source));
+			$destination = trailingslashit($destination) . trailingslashit(basename($source));
+		}
+
+		if ( $wp_filesystem->exists($remote_destination) ) {
+			if ( $clear_destination ) {
+				//We're going to clear the destination if theres something there
+				$this->skin->feedback('remove_old');
+				$removed = $wp_filesystem->delete($remote_destination, true);
+				$removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
+
+				if ( is_wp_error($removed) )
+					return $removed;
+				else if ( ! $removed )
+					return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
+			} else {
+				//If we're not clearing the destination folder and something exists there allready, Bail.
+				//But first check to see if there are actually any files in the folder.
+				$_files = $wp_filesystem->dirlist($remote_destination);
+				if ( ! empty($_files) ) {
+					$wp_filesystem->delete($remote_source, true); //Clear out the source files.
+					return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination );
+				}
+			}
+		}
+
+		//Create destination if needed
+		if ( !$wp_filesystem->exists($remote_destination) )
+			if ( !$wp_filesystem->mkdir($remote_destination, FS_CHMOD_DIR) )
+				return new WP_Error('mkdir_failed', $this->strings['mkdir_failed'], $remote_destination);
+
+		// Copy new version of item into place.
+		$result = copy_dir($source, $remote_destination);
+		if ( is_wp_error($result) ) {
+			if ( $clear_working )
+				$wp_filesystem->delete($remote_source, true);
+			return $result;
+		}
+
+		//Clear the Working folder?
+		if ( $clear_working )
+			$wp_filesystem->delete($remote_source, true);
+
+		$destination_name = basename( str_replace($local_destination, '', $destination) );
+		if ( '.' == $destination_name )
+			$destination_name = '';
+
+		$this->result = compact('local_source', 'source', 'source_name', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination', 'delete_source_dir');
+
+		$res = apply_filters('upgrader_post_install', true, $hook_extra, $this->result);
+		if ( is_wp_error($res) ) {
+			$this->result = $res;
+			return $res;
+		}
+
+		//Bombard the calling function will all the info which we've just used.
+		return $this->result;
+	}
+
+	function run($options) {
+
+		$defaults = array( 	'package' => '', //Please always pass this.
+							'destination' => '', //And this
+							'clear_destination' => false,
+							'clear_working' => true,
+							'is_multi' => false,
+							'hook_extra' => array() //Pass any extra $hook_extra args here, this will be passed to any hooked filters.
+						);
+
+		$options = wp_parse_args($options, $defaults);
+		extract($options);
+
+		//Connect to the Filesystem first.
+		$res = $this->fs_connect( array(WP_CONTENT_DIR, $destination) );
+		if ( ! $res ) //Mainly for non-connected filesystem.
+			return false;
+
+		if ( is_wp_error($res) ) {
+			$this->skin->error($res);
+			return $res;
+		}
+
+		if ( !$is_multi ) // call $this->header separately if running multiple times
+			$this->skin->header();
+
+		$this->skin->before();
+
+		//Download the package (Note, This just returns the filename of the file if the package is a local file)
+		$download = $this->download_package( $package );
+		if ( is_wp_error($download) ) {
+			$this->skin->error($download);
+			$this->skin->after();
+			return $download;
+		}
+
+		//Unzip's the file into a temporary directory
+		$working_dir = $this->unpack_package( $download );
+		if ( is_wp_error($working_dir) ) {
+			$this->skin->error($working_dir);
+			$this->skin->after();
+			return $working_dir;
+		}
+
+		//With the given options, this installs it to the destination directory.
+		$result = $this->install_package( array(
+											'source' => $working_dir,
+											'destination' => $destination,
+											'clear_destination' => $clear_destination,
+											'clear_working' => $clear_working,
+											'hook_extra' => $hook_extra
+										) );
+		$this->skin->set_result($result);
+		if ( is_wp_error($result) ) {
+			$this->skin->error($result);
+			$this->skin->feedback('process_failed');
+		} else {
+			//Install Suceeded
+			$this->skin->feedback('process_success');
+		}
+		$this->skin->after();
+
+		if ( !$is_multi )
+			$this->skin->footer();
+
+		return $result;
+	}
+
+	function maintenance_mode($enable = false) {
+		global $wp_filesystem;
+		$file = $wp_filesystem->abspath() . '.maintenance';
+		if ( $enable ) {
+			$this->skin->feedback('maintenance_start');
+			// Create maintenance file to signal that we are upgrading
+			$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
+			$wp_filesystem->delete($file);
+			$wp_filesystem->put_contents($file, $maintenance_string, FS_CHMOD_FILE);
+		} else if ( !$enable && $wp_filesystem->exists($file) ) {
+			$this->skin->feedback('maintenance_end');
+			$wp_filesystem->delete($file);
+		}
+	}
+
+}
+
+/**
+ * Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class Plugin_Upgrader extends WP_Upgrader {
+
+	var $result;
+	var $bulk = false;
+	var $show_before = '';
+
+	function upgrade_strings() {
+		$this->strings['up_to_date'] = __('The plugin is at the latest version.');
+		$this->strings['no_package'] = __('Update package not available.');
+		$this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>&#8230;');
+		$this->strings['unpack_package'] = __('Unpacking the update&#8230;');
+		$this->strings['deactivate_plugin'] = __('Deactivating the plugin&#8230;');
+		$this->strings['remove_old'] = __('Removing the old version of the plugin&#8230;');
+		$this->strings['remove_old_failed'] = __('Could not remove the old plugin.');
+		$this->strings['process_failed'] = __('Plugin update failed.');
+		$this->strings['process_success'] = __('Plugin updated successfully.');
+	}
+
+	function install_strings() {
+		$this->strings['no_package'] = __('Install package not available.');
+		$this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>&#8230;');
+		$this->strings['unpack_package'] = __('Unpacking the package&#8230;');
+		$this->strings['installing_package'] = __('Installing the plugin&#8230;');
+		$this->strings['process_failed'] = __('Plugin install failed.');
+		$this->strings['process_success'] = __('Plugin installed successfully.');
+	}
+
+	function install($package) {
+
+		$this->init();
+		$this->install_strings();
+
+		$this->run(array(
+					'package' => $package,
+					'destination' => WP_PLUGIN_DIR,
+					'clear_destination' => false, //Do not overwrite files.
+					'clear_working' => true,
+					'hook_extra' => array()
+					));
+
+		// Force refresh of plugin update information
+		delete_site_transient('update_plugins');
+
+	}
+
+	function upgrade($plugin) {
+
+		$this->init();
+		$this->upgrade_strings();
+
+		$current = get_site_transient( 'update_plugins' );
+		if ( !isset( $current->response[ $plugin ] ) ) {
+			$this->skin->before();
+			$this->skin->set_result(false);
+			$this->skin->error('up_to_date');
+			$this->skin->after();
+			return false;
+		}
+
+		// Get the URL to the zip file
+		$r = $current->response[ $plugin ];
+
+		add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
+		add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
+		//'source_selection' => array(&$this, 'source_selection'), //theres a track ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
+
+		$this->run(array(
+					'package' => $r->package,
+					'destination' => WP_PLUGIN_DIR,
+					'clear_destination' => true,
+					'clear_working' => true,
+					'hook_extra' => array(
+								'plugin' => $plugin
+					)
+				));
+
+		// Cleanup our hooks, incase something else does a upgrade on this connection.
+		remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
+		remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
+
+		if ( ! $this->result || is_wp_error($this->result) )
+			return $this->result;
+
+		// Force refresh of plugin update information
+		delete_site_transient('update_plugins');
+	}
+
+	function bulk_upgrade($plugins) {
+
+		$this->init();
+		$this->bulk = true;
+		$this->upgrade_strings();
+
+		$current = get_site_transient( 'update_plugins' );
+
+		add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
+
+		$this->skin->header();
+
+		// Connect to the Filesystem first.
+		$res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) );
+		if ( ! $res ) {
+			$this->skin->footer();
+			return false;
+		}
+
+		$this->skin->bulk_header();
+
+		// Only start maintenance mode if running in Multisite OR the plugin is in use
+		$maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible.
+		foreach ( $plugins as $plugin )
+			$maintenance = $maintenance || (is_plugin_active($plugin) && isset($current->response[ $plugin ]) ); // Only activate Maintenance mode if a plugin is active AND has an update available
+		if ( $maintenance )
+			$this->maintenance_mode(true);
+
+		$results = array();
+
+		$this->update_count = count($plugins);
+		$this->update_current = 0;
+		foreach ( $plugins as $plugin ) {
+			$this->update_current++;
+			$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
+
+			if ( !isset( $current->response[ $plugin ] ) ) {
+				$this->skin->set_result(false);
+				$this->skin->before();
+				$this->skin->error('up_to_date');
+				$this->skin->after();
+				$results[$plugin] = false;
+				continue;
+			}
+
+			// Get the URL to the zip file
+			$r = $current->response[ $plugin ];
+
+			$this->skin->plugin_active = is_plugin_active($plugin);
+
+			$result = $this->run(array(
+						'package' => $r->package,
+						'destination' => WP_PLUGIN_DIR,
+						'clear_destination' => true,
+						'clear_working' => true,
+						'is_multi' => true,
+						'hook_extra' => array(
+									'plugin' => $plugin
+						)
+					));
+
+			$results[$plugin] = $this->result;
+
+			// Prevent credentials auth screen from displaying multiple times
+			if ( false === $result )
+				break;
+		} //end foreach $plugins
+
+		$this->maintenance_mode(false);
+
+		$this->skin->bulk_footer();
+
+		$this->skin->footer();
+
+		// Cleanup our hooks, incase something else does a upgrade on this connection.
+		remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
+
+		// Force refresh of plugin update information
+		delete_site_transient('update_plugins');
+
+		return $results;
+	}
+
+	//return plugin info.
+	function plugin_info() {
+		if ( ! is_array($this->result) )
+			return false;
+		if ( empty($this->result['destination_name']) )
+			return false;
+
+		$plugin = get_plugins('/' . $this->result['destination_name']); //Ensure to pass with leading slash
+		if ( empty($plugin) )
+			return false;
+
+		$pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
+
+		return $this->result['destination_name'] . '/' . $pluginfiles[0];
+	}
+
+	//Hooked to pre_install
+	function deactivate_plugin_before_upgrade($return, $plugin) {
+
+		if ( is_wp_error($return) ) //Bypass.
+			return $return;
+
+		$plugin = isset($plugin['plugin']) ? $plugin['plugin'] : '';
+		if ( empty($plugin) )
+			return new WP_Error('bad_request', $this->strings['bad_request']);
+
+		if ( is_plugin_active($plugin) ) {
+			$this->skin->feedback('deactivate_plugin');
+			//Deactivate the plugin silently, Prevent deactivation hooks from running.
+			deactivate_plugins($plugin, true);
+		}
+	}
+
+	//Hooked to upgrade_clear_destination
+	function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) {
+		global $wp_filesystem;
+
+		if ( is_wp_error($removed) )
+			return $removed; //Pass errors through.
+
+		$plugin = isset($plugin['plugin']) ? $plugin['plugin'] : '';
+		if ( empty($plugin) )
+			return new WP_Error('bad_request', $this->strings['bad_request']);
+
+		$plugins_dir = $wp_filesystem->wp_plugins_dir();
+		$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) );
+
+		if ( ! $wp_filesystem->exists($this_plugin_dir) ) //If its already vanished.
+			return $removed;
+
+		// If plugin is in its own directory, recursively delete the directory.
+		if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
+			$deleted = $wp_filesystem->delete($this_plugin_dir, true);
+		else
+			$deleted = $wp_filesystem->delete($plugins_dir . $plugin);
+
+		if ( ! $deleted )
+			return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
+
+		return $removed;
+	}
+}
+
+/**
+ * Theme Upgrader class for WordPress Themes, It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class Theme_Upgrader extends WP_Upgrader {
+
+	var $result;
+
+	function upgrade_strings() {
+		$this->strings['up_to_date'] = __('The theme is at the latest version.');
+		$this->strings['no_package'] = __('Update package not available.');
+		$this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>&#8230;');
+		$this->strings['unpack_package'] = __('Unpacking the update&#8230;');
+		$this->strings['remove_old'] = __('Removing the old version of the theme&#8230;');
+		$this->strings['remove_old_failed'] = __('Could not remove the old theme.');
+		$this->strings['process_failed'] = __('Theme update failed.');
+		$this->strings['process_success'] = __('Theme updated successfully.');
+	}
+
+	function install_strings() {
+		$this->strings['no_package'] = __('Install package not available.');
+		$this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>&#8230;');
+		$this->strings['unpack_package'] = __('Unpacking the package&#8230;');
+		$this->strings['installing_package'] = __('Installing the theme&#8230;');
+		$this->strings['process_failed'] = __('Theme install failed.');
+		$this->strings['process_success'] = __('Theme installed successfully.');
+	}
+
+	function install($package) {
+
+		$this->init();
+		$this->install_strings();
+
+		$options = array(
+						'package' => $package,
+						'destination' => WP_CONTENT_DIR . '/themes',
+						'clear_destination' => false, //Do not overwrite files.
+						'clear_working' => true
+						);
+
+		$this->run($options);
+
+		if ( ! $this->result || is_wp_error($this->result) )
+			return $this->result;
+
+		// Force refresh of theme update information
+		delete_site_transient('update_themes');
+
+		if ( empty($result['destination_name']) )
+			return false;
+		else
+			return $result['destination_name'];
+	}
+
+	function upgrade($theme) {
+
+		$this->init();
+		$this->upgrade_strings();
+
+		// Is an update available?
+		$current = get_site_transient( 'update_themes' );
+		if ( !isset( $current->response[ $theme ] ) ) {
+			$this->skin->before();
+			$this->skin->set_result(false);
+			$this->skin->error('up_to_date');
+			$this->skin->after();
+			return false;
+		}
+
+		$r = $current->response[ $theme ];
+
+		add_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2);
+		add_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2);
+		add_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4);
+
+		$options = array(
+						'package' => $r['package'],
+						'destination' => WP_CONTENT_DIR . '/themes',
+						'clear_destination' => true,
+						'clear_working' => true,
+						'hook_extra' => array(
+											'theme' => $theme
+											)
+						);
+
+		$this->run($options);
+
+		if ( ! $this->result || is_wp_error($this->result) )
+			return $this->result;
+
+		// Force refresh of theme update information
+		delete_site_transient('update_themes');
+
+		return true;
+	}
+
+	function bulk_upgrade($themes) {
+
+		$this->init();
+		$this->bulk = true;
+		$this->upgrade_strings();
+
+		$current = get_site_transient( 'update_themes' );
+
+		add_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2);
+		add_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2);
+		add_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4);
+
+		$this->skin->header();
+
+		// Connect to the Filesystem first.
+		$res = $this->fs_connect( array(WP_CONTENT_DIR) );
+		if ( ! $res ) {
+			$this->skin->footer();
+			return false;
+		}
+
+		$this->skin->bulk_header();
+
+		// Only start maintenance mode if running in Multisite OR the theme is in use
+		$maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible.
+		foreach ( $themes as $theme )
+			$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
+		if ( $maintenance )
+			$this->maintenance_mode(true);
+
+		$results = array();
+
+		$this->update_count = count($themes);
+		$this->update_current = 0;
+		foreach ( $themes as $theme ) {
+			$this->update_current++;
+
+			if ( !isset( $current->response[ $theme ] ) ) {
+				$this->skin->set_result(false);
+				$this->skin->before();
+				$this->skin->error('up_to_date');
+				$this->skin->after();
+				$results[$theme] = false;
+				continue;
+			}
+
+			$this->skin->theme_info = $this->theme_info($theme);
+
+			// Get the URL to the zip file
+			$r = $current->response[ $theme ];
+
+			$options = array(
+							'package' => $r['package'],
+							'destination' => WP_CONTENT_DIR . '/themes',
+							'clear_destination' => true,
+							'clear_working' => true,
+							'hook_extra' => array(
+												'theme' => $theme
+												)
+							);
+
+			$result = $this->run($options);
+
+			$results[$theme] = $this->result;
+
+			// Prevent credentials auth screen from displaying multiple times
+			if ( false === $result )
+				break;
+		} //end foreach $plugins
+
+		$this->maintenance_mode(false);
+
+		$this->skin->bulk_footer();
+
+		$this->skin->footer();
+
+		// Cleanup our hooks, incase something else does a upgrade on this connection.
+		remove_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2);
+		remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2);
+		remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4);
+
+		// Force refresh of theme update information
+		delete_site_transient('update_themes');
+
+		return $results;
+	}
+
+	function current_before($return, $theme) {
+
+		if ( is_wp_error($return) )
+			return $return;
+
+		$theme = isset($theme['theme']) ? $theme['theme'] : '';
+
+		if ( $theme != get_stylesheet() ) //If not current
+			return $return;
+		//Change to maintenance mode now.
+		if ( ! $this->bulk )
+			$this->maintenance_mode(true);
+
+		return $return;
+	}
+	function current_after($return, $theme) {
+		if ( is_wp_error($return) )
+			return $return;
+
+		$theme = isset($theme['theme']) ? $theme['theme'] : '';
+
+		if ( $theme != get_stylesheet() ) //If not current
+			return $return;
+
+		//Ensure stylesheet name hasnt changed after the upgrade:
+		// @TODO: Note, This doesnt handle the Template changing, or the Template name changing.
+		if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
+			$theme_info = $this->theme_info();
+			$stylesheet = $this->result['destination_name'];
+			$template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
+			switch_theme($template, $stylesheet, true);
+		}
+
+		//Time to remove maintenance mode
+		if ( ! $this->bulk )
+			$this->maintenance_mode(false);
+		return $return;
+	}
+
+	function delete_old_theme($removed, $local_destination, $remote_destination, $theme) {
+		global $wp_filesystem;
+
+		$theme = isset($theme['theme']) ? $theme['theme'] : '';
+
+		if ( is_wp_error($removed) || empty($theme) )
+			return $removed; //Pass errors through.
+
+		$themes_dir = $wp_filesystem->wp_themes_dir();
+		if ( $wp_filesystem->exists( trailingslashit($themes_dir) . $theme ) )
+			if ( ! $wp_filesystem->delete( trailingslashit($themes_dir) . $theme, true ) )
+				return false;
+		return true;
+	}
+
+	function theme_info($theme = null) {
+
+		if ( empty($theme) ) {
+			if ( !empty($this->result['destination_name']) )
+				$theme = $this->result['destination_name'];
+			else
+				return false;
+		}
+		return get_theme_data(WP_CONTENT_DIR . '/themes/' . $theme . '/style.css');
+	}
+
+}
+
+/**
+ * Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combiantion with the wp-admin/includes/update-core.php file
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class Core_Upgrader extends WP_Upgrader {
+
+	function upgrade_strings() {
+		$this->strings['up_to_date'] = __('WordPress is at the latest version.');
+		$this->strings['no_package'] = __('Update package not available.');
+		$this->strings['downloading_package'] = __('Downloading update from <span class="code">%s</span>&#8230;');
+		$this->strings['unpack_package'] = __('Unpacking the update&#8230;');
+		$this->strings['copy_failed'] = __('Could not copy files.');
+	}
+
+	function upgrade($current) {
+		global $wp_filesystem;
+
+		$this->init();
+		$this->upgrade_strings();
+
+		if ( !empty($feedback) )
+			add_filter('update_feedback', $feedback);
+
+		// Is an update available?
+		if ( !isset( $current->response ) || $current->response == 'latest' )
+			return new WP_Error('up_to_date', $this->strings['up_to_date']);
+
+		$res = $this->fs_connect( array(ABSPATH, WP_CONTENT_DIR) );
+		if ( is_wp_error($res) )
+			return $res;
+
+		$wp_dir = trailingslashit($wp_filesystem->abspath());
+
+		$download = $this->download_package( $current->package );
+		if ( is_wp_error($download) )
+			return $download;
+
+		$working_dir = $this->unpack_package( $download );
+		if ( is_wp_error($working_dir) )
+			return $working_dir;
+
+		// Copy update-core.php from the new version into place.
+		if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
+			$wp_filesystem->delete($working_dir, true);
+			return new WP_Error('copy_failed', $this->strings['copy_failed']);
+		}
+		$wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
+
+		require(ABSPATH . 'wp-admin/includes/update-core.php');
+
+		return update_core($working_dir, $wp_dir);
+	}
+
+}
+
+/**
+ * Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class WP_Upgrader_Skin {
+
+	var $upgrader;
+	var $done_header = false;
+	var $result = false;
+
+	function WP_Upgrader_Skin($args = array()) {
+		return $this->__construct($args);
+	}
+	function __construct($args = array()) {
+		$defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
+		$this->options = wp_parse_args($args, $defaults);
+	}
+
+	function set_upgrader(&$upgrader) {
+		if ( is_object($upgrader) )
+			$this->upgrader =& $upgrader;
+		$this->add_strings();
+	}
+
+	function add_strings() {
+	}
+
+	function set_result($result) {
+		$this->result = $result;
+	}
+
+	function request_filesystem_credentials($error = false) {
+		$url = $this->options['url'];
+		$context = $this->options['context'];
+		if ( !empty($this->options['nonce']) )
+			$url = wp_nonce_url($url, $this->options['nonce']);
+		return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now.
+	}
+
+	function header() {
+		if ( $this->done_header )
+			return;
+		$this->done_header = true;
+		echo '<div class="wrap">';
+		echo screen_icon();
+		echo '<h2>' . $this->options['title'] . '</h2>';
+	}
+	function footer() {
+		echo '</div>';
+	}
+
+	function error($errors) {
+		if ( ! $this->done_header )
+			$this->header();
+		if ( is_string($errors) ) {
+			$this->feedback($errors);
+		} elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
+			foreach ( $errors->get_error_messages() as $message ) {
+				if ( $errors->get_error_data() )
+					$this->feedback($message . ' ' . $errors->get_error_data() );
+				else
+					$this->feedback($message);
+			}
+		}
+	}
+
+	function feedback($string) {
+		if ( isset( $this->upgrader->strings[$string] ) )
+			$string = $this->upgrader->strings[$string];
+
+		if ( strpos($string, '%') !== false ) {
+			$args = func_get_args();
+			$args = array_splice($args, 1);
+			if ( !empty($args) )
+				$string = vsprintf($string, $args);
+		}
+		if ( empty($string) )
+			return;
+		show_message($string);
+	}
+	function before() {}
+	function after() {}
+
+}
+
+/**
+ * Plugin Upgrader Skin for WordPress Plugin Upgrades.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
+	var $plugin = '';
+	var $plugin_active = false;
+	var $plugin_network_active = false;
+
+	function Plugin_Upgrader_Skin($args = array()) {
+		return $this->__construct($args);
+	}
+
+	function __construct($args = array()) {
+		$defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
+		$args = wp_parse_args($args, $defaults);
+
+		$this->plugin = $args['plugin'];
+
+		$this->plugin_active = is_plugin_active( $this->plugin );
+		$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
+
+		parent::__construct($args);
+	}
+
+	function after() {
+		$this->plugin = $this->upgrader->plugin_info();
+		if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
+			show_message(__('Reactivating the plugin&#8230;'));
+			echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
+		}
+
+		$update_actions =  array(
+			'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
+			'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
+		);
+		if ( $this->plugin_active )
+			unset( $update_actions['activate_plugin'] );
+		if ( ! $this->result || is_wp_error($this->result) )
+			unset( $update_actions['activate_plugin'] );
+
+		$update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin);
+		if ( ! empty($update_actions) )
+			$this->feedback(implode(' | ', (array)$update_actions));
+	}
+
+	function before() {
+		if ( $this->upgrader->show_before ) {
+			echo $this->upgrader->show_before;
+			$this->upgrader->show_before = '';
+		}
+	}
+}
+
+/**
+ * Plugin Upgrader Skin for WordPress Plugin Upgrades.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 3.0.0
+ */
+class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
+	var $in_loop = false;
+	var $error = false;
+
+	function Bulk_Upgrader_Skin($args = array()) {
+		return $this->__construct($args);
+	}
+
+	function __construct($args = array()) {
+		$defaults = array( 'url' => '', 'nonce' => '' );
+		$args = wp_parse_args($args, $defaults);
+
+		parent::__construct($args);
+	}
+
+	function add_strings() {
+		$this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
+		$this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>.');
+		$this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
+		$this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>'.__('Show Details').'</span><span class="hidden">'.__('Hide Details').'</span>.</a>';
+		$this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
+	}
+
+	function feedback($string) {
+		if ( isset( $this->upgrader->strings[$string] ) )
+			$string = $this->upgrader->strings[$string];
+
+		if ( strpos($string, '%') !== false ) {
+			$args = func_get_args();
+			$args = array_splice($args, 1);
+			if ( !empty($args) )
+				$string = vsprintf($string, $args);
+		}
+		if ( empty($string) )
+			return;
+		if ( $this->in_loop )
+			echo "$string<br />\n";
+		else
+			echo "<p>$string</p>\n";
+	}
+
+	function header() {
+		// Nothing, This will be displayed within a iframe.
+	}
+
+	function footer() {
+		// Nothing, This will be displayed within a iframe.
+	}
+	function error($error) {
+		if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
+			$this->error = $this->upgrader->strings[$error];
+
+		if ( is_wp_error($error) ) {
+			foreach ( $error->get_error_messages() as $emessage ) {
+				if ( $error->get_error_data() )
+					$messages[] = $emessage . ' ' . $error->get_error_data();
+				else
+					$messages[] = $emessage;
+			}
+			$this->error = implode(', ', $messages);
+		}
+		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
+	}
+
+	function bulk_header() {
+		$this->feedback('skin_upgrade_start');
+	}
+
+	function bulk_footer() {
+		$this->feedback('skin_upgrade_end');
+	}
+
+	function before($title = '') {
+		$this->in_loop = true;
+		printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <img alt="" src="' . admin_url( 'images/wpspin_light.gif' ) . '" class="hidden waiting-' . $this->upgrader->update_current . '" style="vertical-align:middle;" /></h4>',  $title, $this->upgrader->update_current, $this->upgrader->update_count);
+		echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
+		echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
+		$this->flush_output();
+	}
+
+	function after($title = '') {
+		echo '</p></div>';
+		if ( $this->error || ! $this->result ) {
+			if ( $this->error )
+				echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, $this->error) . '</p></div>';
+			else
+				echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
+
+			echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
+		}
+		if ( !empty($this->result) && !is_wp_error($this->result) ) {
+			echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>';
+			echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
+		}
+
+		$this->reset();
+		$this->flush_output();
+	}
+
+	function reset() {
+		$this->in_loop = false;
+		$this->error = false;
+	}
+
+	function flush_output() {
+		wp_ob_end_flush_all();
+		flush();
+	}
+}
+
+class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
+	var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
+	function Plugin_Upgrader_Skin($args = array()) {
+		parent::__construct($args);
+	}
+
+	function add_strings() {
+		parent::add_strings();
+		$this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
+	}
+
+	function before() {
+		parent::before($this->plugin_info['Title']);
+	}
+
+	function after() {
+		parent::after($this->plugin_info['Title']);
+	}
+	function bulk_footer() {
+		parent::bulk_footer();
+		$update_actions =  array(
+			'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
+			'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
+		);
+
+		$update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
+		if ( ! empty($update_actions) )
+			$this->feedback(implode(' | ', (array)$update_actions));
+	}
+}
+
+class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
+	var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
+	function Theme_Upgrader_Skin($args = array()) {
+		parent::__construct($args);
+	}
+
+	function add_strings() {
+		parent::add_strings();
+		$this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
+	}
+
+	function before() {
+		parent::before($this->theme_info['Name']);
+	}
+
+	function after() {
+		parent::after($this->theme_info['Name']);
+	}
+	function bulk_footer() {
+		parent::bulk_footer();
+		$update_actions =  array(
+			'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
+			'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
+		);
+
+		$update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info);
+		if ( ! empty($update_actions) )
+			$this->feedback(implode(' | ', (array)$update_actions));
+	}
+}
+
+/**
+ * Plugin Installer Skin for WordPress Plugin Installer.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class Plugin_Installer_Skin extends WP_Upgrader_Skin {
+	var $api;
+	var $type;
+
+	function Plugin_Installer_Skin($args = array()) {
+		return $this->__construct($args);
+	}
+
+	function __construct($args = array()) {
+		$defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
+		$args = wp_parse_args($args, $defaults);
+
+		$this->type = $args['type'];
+		$this->api = isset($args['api']) ? $args['api'] : array();
+
+		parent::__construct($args);
+	}
+
+	function before() {
+		if ( !empty($this->api) )
+			$this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
+	}
+
+	function after() {
+
+		$plugin_file = $this->upgrader->plugin_info();
+
+		$install_actions = array();
+
+		$from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins';
+
+		if ( 'import' == $from )
+			$install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;from=import&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin &amp; Run Importer') . '</a>';
+		else
+			$install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
+
+		if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
+			$install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
+			unset( $install_actions['activate_plugin'] );
+		}
+
+		if ( 'import' == $from )
+			$install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
+		else if ( $this->type == 'web' )
+			$install_actions['plugins_page'] = '<a href="' . self_admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>';
+		else
+			$install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>';
+
+
+		if ( ! $this->result || is_wp_error($this->result) ) {
+			unset( $install_actions['activate_plugin'] );
+			unset( $install_actions['network_activate'] );
+		}
+		$install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
+		if ( ! empty($install_actions) )
+			$this->feedback(implode(' | ', (array)$install_actions));
+	}
+}
+
+/**
+ * Theme Installer Skin for the WordPress Theme Installer.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class Theme_Installer_Skin extends WP_Upgrader_Skin {
+	var $api;
+	var $type;
+
+	function Theme_Installer_Skin($args = array()) {
+		return $this->__construct($args);
+	}
+
+	function __construct($args = array()) {
+		$defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
+		$args = wp_parse_args($args, $defaults);
+
+		$this->type = $args['type'];
+		$this->api = isset($args['api']) ? $args['api'] : array();
+
+		parent::__construct($args);
+	}
+
+	function before() {
+		if ( !empty($this->api) ) {
+			/* translators: 1: theme name, 2: version */
+			$this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the theme <strong>%1$s %2$s</strong>.'), $this->api->name, $this->api->version);
+		}
+	}
+
+	function after() {
+		if ( empty($this->upgrader->result['destination_name']) )
+			return;
+
+		$theme_info = $this->upgrader->theme_info();
+		if ( empty($theme_info) )
+			return;
+		$name = $theme_info['Name'];
+		$stylesheet = $this->upgrader->result['destination_name'];
+		$template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
+
+		$preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) );
+		$activate_link = wp_nonce_url("themes.php?action=activate&amp;template=" . urlencode($template) . "&amp;stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template);
+
+		$install_actions = array(
+			'preview' => '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>',
+			'activate' => '<a href="' . $activate_link .  '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>'
+							);
+
+		if ( $this->type == 'web' )
+			$install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
+		else
+			$install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
+
+		if ( ! $this->result || is_wp_error($this->result) || is_network_admin() )
+			unset( $install_actions['activate'], $install_actions['preview'] );
+
+		$install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
+		if ( ! empty($install_actions) )
+			$this->feedback(implode(' | ', (array)$install_actions));
+	}
+}
+
+/**
+ * Theme Upgrader Skin for WordPress Theme Upgrades.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
+	var $theme = '';
+
+	function Theme_Upgrader_Skin($args = array()) {
+		return $this->__construct($args);
+	}
+
+	function __construct($args = array()) {
+		$defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
+		$args = wp_parse_args($args, $defaults);
+
+		$this->theme = $args['theme'];
+
+		parent::__construct($args);
+	}
+
+	function after() {
+
+		$update_actions = array();
+		if ( !empty($this->upgrader->result['destination_name']) &&
+			($theme_info = $this->upgrader->theme_info()) &&
+			!empty($theme_info) ) {
+
+			$name = $theme_info['Name'];
+			$stylesheet = $this->upgrader->result['destination_name'];
+			$template = !empty($theme_info['Template']) ? $theme_info['Template'] : $stylesheet;
+
+			$preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) );
+			$activate_link = wp_nonce_url("themes.php?action=activate&amp;template=" . urlencode($template) . "&amp;stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template);
+
+			$update_actions['preview'] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>';
+			$update_actions['activate'] = '<a href="' . $activate_link .  '" class="activatelink" title="' . esc_attr( sprintf( __('Activate &#8220;%s&#8221;'), $name ) ) . '">' . __('Activate') . '</a>';
+
+			if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() )
+				unset($update_actions['preview'], $update_actions['activate']);
+		}
+
+		$update_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
+
+		$update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
+		if ( ! empty($update_actions) )
+			$this->feedback(implode(' | ', (array)$update_actions));
+	}
+}
+
+/**
+ * Upgrade Skin helper for File uploads. This class handles the upload process and passes it as if its a local file to the Upgrade/Installer functions.
+ *
+ * @TODO More Detailed docs, for methods as well.
+ *
+ * @package WordPress
+ * @subpackage Upgrader
+ * @since 2.8.0
+ */
+class File_Upload_Upgrader {
+	var $package;
+	var $filename;
+
+	function File_Upload_Upgrader($form, $urlholder) {
+		return $this->__construct($form, $urlholder);
+	}
+	function __construct($form, $urlholder) {
+		if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+			wp_die($uploads['error']);
+
+		if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
+			wp_die(__('Please select a file'));
+
+		if ( !empty($_FILES) )
+			$this->filename = $_FILES[$form]['name'];
+		else if ( isset($_GET[$urlholder]) )
+			$this->filename = $_GET[$urlholder];
+
+		//Handle a newly uploaded file, Else assume its already been uploaded
+		if ( !empty($_FILES) ) {
+			$this->filename = wp_unique_filename( $uploads['basedir'], $this->filename );
+			$this->package = $uploads['basedir'] . '/' . $this->filename;
+
+			// Move the file to the uploads dir
+			if ( false === @ move_uploaded_file( $_FILES[$form]['tmp_name'], $this->package) )
+				wp_die( sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path']));
+		} else {
+			$this->package = $uploads['basedir'] . '/' . $this->filename;
+		}
+	}
+}
Index: /tags/3.1/wp-admin/includes/class-wp-users-list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/class-wp-users-list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/class-wp-users-list-table.php	(revision 17487)
@@ -0,0 +1,319 @@
+<?php
+/**
+ * Users List Table class.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ * @access private
+ */
+class WP_Users_List_Table extends WP_List_Table {
+
+	var $site_id;
+	var $is_site_users;
+
+	function WP_Users_List_Table() {
+		$screen = get_current_screen();
+		$this->is_site_users = 'site-users-network' == $screen->id;
+
+		if ( $this->is_site_users )
+			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
+
+		parent::WP_List_Table( array(
+			'singular' => 'user',
+			'plural'   => 'users'
+		) );
+	}
+
+	function ajax_user_can() {
+		if ( $this->is_site_users )
+			return current_user_can( 'manage_sites' );
+		else
+			return current_user_can( 'list_users' );
+	}
+
+	function prepare_items() {
+		global $role, $usersearch;
+
+		$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
+
+		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
+
+		$per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
+		$users_per_page = $this->get_items_per_page( $per_page );
+
+		$paged = $this->get_pagenum();
+
+		$args = array(
+			'number' => $users_per_page,
+			'offset' => ( $paged-1 ) * $users_per_page,
+			'role' => $role,
+			'search' => $usersearch,
+			'fields' => 'all_with_meta'
+		);
+
+		$args['search'] = '*' . $args['search'] . '*';
+
+		if ( $this->is_site_users )
+			$args['blog_id'] = $this->site_id;
+
+		if ( isset( $_REQUEST['orderby'] ) )
+			$args['orderby'] = $_REQUEST['orderby'];
+
+		if ( isset( $_REQUEST['order'] ) )
+			$args['order'] = $_REQUEST['order'];
+
+		// Query the user IDs for this page
+		$wp_user_search = new WP_User_Query( $args );
+
+		$this->items = $wp_user_search->get_results();
+
+		$this->set_pagination_args( array(
+			'total_items' => $wp_user_search->get_total(),
+			'per_page' => $users_per_page,
+		) );
+	}
+
+	function no_items() {
+		_e( 'No matching users were found.' );
+	}
+
+	function get_views() {
+		global $wp_roles, $role;
+
+		if ( $this->is_site_users ) {
+			$url = 'site-users.php?id=' . $this->site_id;
+			switch_to_blog( $this->site_id );
+			$users_of_blog = count_users();
+			restore_current_blog();
+		} else {
+			$url = 'users.php';
+			$users_of_blog = count_users();
+		}
+		$total_users = $users_of_blog['total_users'];
+		$avail_roles =& $users_of_blog['avail_roles'];
+		unset($users_of_blog);
+
+		$current_role = false;
+		$class = empty($role) ? ' class="current"' : '';
+		$role_links = array();
+		$role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
+		foreach ( $wp_roles->get_names() as $this_role => $name ) {
+			if ( !isset($avail_roles[$this_role]) )
+				continue;
+
+			$class = '';
+
+			if ( $this_role == $role ) {
+				$current_role = $role;
+				$class = ' class="current"';
+			}
+
+			$name = translate_user_role( $name );
+			/* translators: User role name with count */
+			$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, $avail_roles[$this_role] );
+			$role_links[$this_role] = "<a href='" . add_query_arg( 'role', $this_role, $url ) . "'$class>$name</a>";
+		}
+
+		return $role_links;
+	}
+
+	function get_bulk_actions() {
+		$actions = array();
+
+		if ( is_multisite() ) {
+			if ( current_user_can( 'remove_users' ) )
+				$actions['remove'] = __( 'Remove' );
+		} else {
+			if ( current_user_can( 'delete_users' ) )
+				$actions['delete'] = __( 'Delete' );
+		}
+
+		return $actions;
+	}
+
+	function extra_tablenav( $which ) {
+		if ( 'top' != $which )
+			return;
+		if ( ! current_user_can( 'promote_users' ) )
+			return;
+?>
+	<div class="alignleft actions">
+		<label class="screen-reader-text" for="new_role"><?php _e( 'Change role to&hellip;' ) ?></label>
+		<select name="new_role" id="new_role">
+			<option value=''><?php _e( 'Change role to&hellip;' ) ?></option>
+			<?php wp_dropdown_roles(); ?>
+		</select>
+		<?php submit_button( __( 'Change' ), 'secondary', 'changeit', false ); ?>
+	</div>
+<?php
+	}
+
+	function current_action() {
+		if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
+			return 'promote';
+
+		return parent::current_action();
+	}
+
+	function get_columns() {
+		$c = array(
+			'cb'       => '<input type="checkbox" />',
+			'username' => __( 'Username' ),
+			'name'     => __( 'Name' ),
+			'email'    => __( 'E-mail' ),
+			'role'     => __( 'Role' ),
+			'posts'    => __( 'Posts' )
+		);
+
+		if ( $this->is_site_users )
+			unset( $c['posts'] );
+
+		return $c;
+	}
+
+	function get_sortable_columns() {
+		$c = array(
+			'username' => 'login',
+			'name'     => 'name',
+			'email'    => 'email',
+		);
+
+		if ( $this->is_site_users )
+			unset( $c['posts'] );
+
+		return $c;
+	}
+
+	function display_rows() {
+		// Query the post counts for this page
+		if ( ! $this->is_site_users )
+			$post_counts = count_many_users_posts( array_keys( $this->items ) );
+
+		$style = '';
+		foreach ( $this->items as $userid => $user_object ) {
+			$role = reset( $user_object->roles );
+
+			if ( is_multisite() && empty( $role ) )
+				continue;
+
+			$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
+			echo "\n\t", $this->single_row( $user_object, $style, $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
+		}
+	}
+
+	/**
+	 * Generate HTML for a single row on the users.php admin panel.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param object $user_object
+	 * @param string $style Optional. Attributes added to the TR element.  Must be sanitized.
+	 * @param string $role Key for the $wp_roles array.
+	 * @param int $numposts Optional. Post count to display for this user.  Defaults to zero, as in, a new user has made zero posts.
+	 * @return string
+	 */
+	function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
+		global $wp_roles;
+
+		if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) )
+			$user_object = new WP_User( (int) $user_object );
+		$user_object = sanitize_user_object( $user_object, 'display' );
+		$email = $user_object->user_email;
+
+		if ( $this->is_site_users )
+			$url = "site-users.php?id={$this->site_id}&amp;";
+		else
+			$url = 'users.php?';
+
+		$checkbox = '';
+		// Check if the user for this row is editable
+		if ( current_user_can( 'list_users' ) ) {
+			// Set up the user editing link
+			// TODO: make profile/user-edit determination a separate function
+			if ( get_current_user_id() == $user_object->ID ) {
+				$edit_link = 'profile.php';
+			} else {
+				$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
+			}
+
+			// Set up the hover actions for this user
+			$actions = array();
+
+			if ( current_user_can( 'edit_user',  $user_object->ID ) ) {
+				$edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
+				$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
+			} else {
+				$edit = "<strong>$user_object->user_login</strong><br />";
+			}
+
+			if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) )
+				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>";
+			if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) )
+				$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";
+			$actions = apply_filters( 'user_row_actions', $actions, $user_object );
+			$edit .= $this->row_actions( $actions );
+
+			// Set up the checkbox ( because the user is editable, otherwise its empty )
+			$checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
+
+		} else {
+			$edit = '<strong>' . $user_object->user_login . '</strong>';
+		}
+		$role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' );
+		$avatar = get_avatar( $user_object->ID, 32 );
+
+		$r = "<tr id='user-$user_object->ID'$style>";
+
+		list( $columns, $hidden ) = $this->get_column_info();
+
+		foreach ( $columns as $column_name => $column_display_name ) {
+			$class = "class=\"$column_name column-$column_name\"";
+
+			$style = '';
+			if ( in_array( $column_name, $hidden ) )
+				$style = ' style="display:none;"';
+
+			$attributes = "$class$style";
+
+			switch ( $column_name ) {
+				case 'cb':
+					$r .= "<th scope='row' class='check-column'>$checkbox</th>";
+					break;
+				case 'username':
+					$r .= "<td $attributes>$avatar $edit</td>";
+					break;
+				case 'name':
+					$r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
+					break;
+				case 'email':
+					$r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a></td>";
+					break;
+				case 'role':
+					$r .= "<td $attributes>$role_name</td>";
+					break;
+				case 'posts':
+					$attributes = 'class="posts column-posts num"' . $style;
+					$r .= "<td $attributes>";
+					if ( $numposts > 0 ) {
+						$r .= "<a href='edit.php?author=$user_object->ID' title='" . esc_attr__( 'View posts by this author' ) . "' class='edit'>";
+						$r .= $numposts;
+						$r .= '</a>';
+					} else {
+						$r .= 0;
+					}
+					$r .= "</td>";
+					break;
+				default:
+					$r .= "<td $attributes>";
+					$r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
+					$r .= "</td>";
+			}
+		}
+		$r .= '</tr>';
+
+		return $r;
+	}
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/comment.php
===================================================================
--- /tags/3.1/wp-admin/includes/comment.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/comment.php	(revision 17487)
@@ -0,0 +1,159 @@
+<?php
+/**
+ * WordPress Comment Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ *
+ * @param string $comment_author Author of the comment
+ * @param string $comment_date Date of the comment
+ * @return mixed Comment ID on success.
+ */
+function comment_exists($comment_author, $comment_date) {
+	global $wpdb;
+
+	$comment_author = stripslashes($comment_author);
+	$comment_date = stripslashes($comment_date);
+
+	return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments
+			WHERE comment_author = %s AND comment_date = %s", $comment_author, $comment_date) );
+}
+
+/**
+ * Update a comment with values provided in $_POST.
+ *
+ * @since 2.0.0
+ */
+function edit_comment() {
+
+	if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) )
+		wp_die ( __( 'You are not allowed to edit comments on this post.' ) );
+
+	$_POST['comment_author'] = $_POST['newcomment_author'];
+	$_POST['comment_author_email'] = $_POST['newcomment_author_email'];
+	$_POST['comment_author_url'] = $_POST['newcomment_author_url'];
+	$_POST['comment_approved'] = $_POST['comment_status'];
+	$_POST['comment_content'] = $_POST['content'];
+	$_POST['comment_ID'] = (int) $_POST['comment_ID'];
+
+	foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') 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'];
+		$jj = $_POST['jj'];
+		$hh = $_POST['hh'];
+		$mn = $_POST['mn'];
+		$ss = $_POST['ss'];
+		$jj = ($jj > 31 ) ? 31 : $jj;
+		$hh = ($hh > 23 ) ? $hh -24 : $hh;
+		$mn = ($mn > 59 ) ? $mn -60 : $mn;
+		$ss = ($ss > 59 ) ? $ss -60 : $ss;
+		$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
+	}
+
+	wp_update_comment( $_POST );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param int $id ID of comment to retrieve
+ * @return bool|object Comment if found. False on failure.
+ */
+function get_comment_to_edit( $id ) {
+	if ( !$comment = get_comment($id) )
+		return false;
+
+	$comment->comment_ID = (int) $comment->comment_ID;
+	$comment->comment_post_ID = (int) $comment->comment_post_ID;
+
+	$comment->comment_content = format_to_edit( $comment->comment_content );
+	$comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);
+
+	$comment->comment_author = format_to_edit( $comment->comment_author );
+	$comment->comment_author_email = format_to_edit( $comment->comment_author_email );
+	$comment->comment_author_url = format_to_edit( $comment->comment_author_url );
+	$comment->comment_author_url = esc_url($comment->comment_author_url);
+
+	return $comment;
+}
+
+/**
+ * Get the number of pending comments on a post or posts
+ *
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param int|array $post_id Either a single Post ID or an array of Post IDs
+ * @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs
+ */
+function get_pending_comments_num( $post_id ) {
+	global $wpdb;
+
+	$single = false;
+	if ( !is_array($post_id) ) {
+		$post_id_array = (array) $post_id;
+		$single = true;
+	} else {
+		$post_id_array = $post_id;
+	}
+	$post_id_array = array_map('intval', $post_id_array);
+	$post_id_in = "'" . implode("', '", $post_id_array) . "'";
+
+	$pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A );
+
+	if ( $single ) {
+		if ( empty($pending) )
+			return 0;
+		else
+			return absint($pending[0]['num_comments']);
+	}
+
+	$pending_keyed = array();
+
+	// Default to zero pending for all posts in request
+	foreach ( $post_id_array as $id )
+		$pending_keyed[$id] = 0;
+
+	if ( !empty($pending) )
+		foreach ( $pending as $pend )
+			$pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']);
+
+	return $pending_keyed;
+}
+
+/**
+ * Add avatars to relevant places in admin, or try to.
+ *
+ * @since 2.5.0
+ * @uses $comment
+ *
+ * @param string $name User name.
+ * @return string Avatar with Admin name.
+ */
+function floated_admin_avatar( $name ) {
+	global $comment;
+	$avatar = get_avatar( $comment, 32 );
+	return "$avatar $name";
+}
+
+function enqueue_comment_hotkeys_js() {
+	if ( 'true' == get_user_option( 'comment_shortcuts' ) )
+		wp_enqueue_script( 'jquery-table-hotkeys' );
+}
+?>
Index: /tags/3.1/wp-admin/includes/continents-cities.php
===================================================================
--- /tags/3.1/wp-admin/includes/continents-cities.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/continents-cities.php	(revision 17487)
@@ -0,0 +1,493 @@
+<?php
+
+/* Continent and city translations for timezone selection.
+ * This file is not included anywhere. It exists solely for use by xgettext.
+ */
+
+__('Africa', 'continents-cities');
+__('Abidjan', 'continents-cities');
+__('Accra', 'continents-cities');
+__('Addis Ababa', 'continents-cities');
+__('Algiers', 'continents-cities');
+__('Asmara', 'continents-cities');
+__('Asmera', 'continents-cities');
+__('Bamako', 'continents-cities');
+__('Bangui', 'continents-cities');
+__('Banjul', 'continents-cities');
+__('Bissau', 'continents-cities');
+__('Blantyre', 'continents-cities');
+__('Brazzaville', 'continents-cities');
+__('Bujumbura', 'continents-cities');
+__('Cairo', 'continents-cities');
+__('Casablanca', 'continents-cities');
+__('Ceuta', 'continents-cities');
+__('Conakry', 'continents-cities');
+__('Dakar', 'continents-cities');
+__('Dar es Salaam', 'continents-cities');
+__('Djibouti', 'continents-cities');
+__('Douala', 'continents-cities');
+__('El Aaiun', 'continents-cities');
+__('Freetown', 'continents-cities');
+__('Gaborone', 'continents-cities');
+__('Harare', 'continents-cities');
+__('Johannesburg', 'continents-cities');
+__('Kampala', 'continents-cities');
+__('Khartoum', 'continents-cities');
+__('Kigali', 'continents-cities');
+__('Kinshasa', 'continents-cities');
+__('Lagos', 'continents-cities');
+__('Libreville', 'continents-cities');
+__('Lome', 'continents-cities');
+__('Luanda', 'continents-cities');
+__('Lubumbashi', 'continents-cities');
+__('Lusaka', 'continents-cities');
+__('Malabo', 'continents-cities');
+__('Maputo', 'continents-cities');
+__('Maseru', 'continents-cities');
+__('Mbabane', 'continents-cities');
+__('Mogadishu', 'continents-cities');
+__('Monrovia', 'continents-cities');
+__('Nairobi', 'continents-cities');
+__('Ndjamena', 'continents-cities');
+__('Niamey', 'continents-cities');
+__('Nouakchott', 'continents-cities');
+__('Ouagadougou', 'continents-cities');
+__('Porto-Novo', 'continents-cities');
+__('Sao Tome', 'continents-cities');
+__('Timbuktu', 'continents-cities');
+__('Tripoli', 'continents-cities');
+__('Tunis', 'continents-cities');
+__('Windhoek', 'continents-cities');
+__('America', 'continents-cities');
+__('Adak', 'continents-cities');
+__('Anchorage', 'continents-cities');
+__('Anguilla', 'continents-cities');
+__('Antigua', 'continents-cities');
+__('Araguaina', 'continents-cities');
+__('Argentina', 'continents-cities');
+__('Buenos Aires', 'continents-cities');
+__('Catamarca', 'continents-cities');
+__('ComodRivadavia', 'continents-cities');
+__('Cordoba', 'continents-cities');
+__('Jujuy', 'continents-cities');
+__('La Rioja', 'continents-cities');
+__('Mendoza', 'continents-cities');
+__('Rio Gallegos', 'continents-cities');
+__('San Juan', 'continents-cities');
+__('San Luis', 'continents-cities');
+__('Tucuman', 'continents-cities');
+__('Ushuaia', 'continents-cities');
+__('Aruba', 'continents-cities');
+__('Asuncion', 'continents-cities');
+__('Atikokan', 'continents-cities');
+__('Atka', 'continents-cities');
+__('Bahia', 'continents-cities');
+__('Barbados', 'continents-cities');
+__('Belem', 'continents-cities');
+__('Belize', 'continents-cities');
+__('Blanc-Sablon', 'continents-cities');
+__('Boa Vista', 'continents-cities');
+__('Bogota', 'continents-cities');
+__('Boise', 'continents-cities');
+__('Cambridge Bay', 'continents-cities');
+__('Campo Grande', 'continents-cities');
+__('Cancun', 'continents-cities');
+__('Caracas', 'continents-cities');
+__('Cayenne', 'continents-cities');
+__('Cayman', 'continents-cities');
+__('Chicago', 'continents-cities');
+__('Chihuahua', 'continents-cities');
+__('Coral Harbour', 'continents-cities');
+__('Costa Rica', 'continents-cities');
+__('Cuiaba', 'continents-cities');
+__('Curacao', 'continents-cities');
+__('Danmarkshavn', 'continents-cities');
+__('Dawson', 'continents-cities');
+__('Dawson Creek', 'continents-cities');
+__('Denver', 'continents-cities');
+__('Detroit', 'continents-cities');
+__('Dominica', 'continents-cities');
+__('Edmonton', 'continents-cities');
+__('Eirunepe', 'continents-cities');
+__('El Salvador', 'continents-cities');
+__('Ensenada', 'continents-cities');
+__('Fort Wayne', 'continents-cities');
+__('Fortaleza', 'continents-cities');
+__('Glace Bay', 'continents-cities');
+__('Godthab', 'continents-cities');
+__('Goose Bay', 'continents-cities');
+__('Grand Turk', 'continents-cities');
+__('Grenada', 'continents-cities');
+__('Guadeloupe', 'continents-cities');
+__('Guatemala', 'continents-cities');
+__('Guayaquil', 'continents-cities');
+__('Guyana', 'continents-cities');
+__('Halifax', 'continents-cities');
+__('Havana', 'continents-cities');
+__('Hermosillo', 'continents-cities');
+__('Indiana', 'continents-cities');
+__('Indianapolis', 'continents-cities');
+__('Knox', 'continents-cities');
+__('Marengo', 'continents-cities');
+__('Petersburg', 'continents-cities');
+__('Tell City', 'continents-cities');
+__('Vevay', 'continents-cities');
+__('Vincennes', 'continents-cities');
+__('Winamac', 'continents-cities');
+__('Inuvik', 'continents-cities');
+__('Iqaluit', 'continents-cities');
+__('Jamaica', 'continents-cities');
+__('Juneau', 'continents-cities');
+__('Kentucky', 'continents-cities');
+__('Louisville', 'continents-cities');
+__('Monticello', 'continents-cities');
+__('Knox IN', 'continents-cities');
+__('La Paz', 'continents-cities');
+__('Lima', 'continents-cities');
+__('Los Angeles', 'continents-cities');
+__('Maceio', 'continents-cities');
+__('Managua', 'continents-cities');
+__('Manaus', 'continents-cities');
+__('Marigot', 'continents-cities');
+__('Martinique', 'continents-cities');
+__('Mazatlan', 'continents-cities');
+__('Menominee', 'continents-cities');
+__('Merida', 'continents-cities');
+__('Mexico City', 'continents-cities');
+__('Miquelon', 'continents-cities');
+__('Moncton', 'continents-cities');
+__('Monterrey', 'continents-cities');
+__('Montevideo', 'continents-cities');
+__('Montreal', 'continents-cities');
+__('Montserrat', 'continents-cities');
+__('Nassau', 'continents-cities');
+__('New York', 'continents-cities');
+__('Nipigon', 'continents-cities');
+__('Nome', 'continents-cities');
+__('Noronha', 'continents-cities');
+__('North Dakota', 'continents-cities');
+__('Center', 'continents-cities');
+__('New Salem', 'continents-cities');
+__('Panama', 'continents-cities');
+__('Pangnirtung', 'continents-cities');
+__('Paramaribo', 'continents-cities');
+__('Phoenix', 'continents-cities');
+__('Port-au-Prince', 'continents-cities');
+__('Port of Spain', 'continents-cities');
+__('Porto Acre', 'continents-cities');
+__('Porto Velho', 'continents-cities');
+__('Puerto Rico', 'continents-cities');
+__('Rainy River', 'continents-cities');
+__('Rankin Inlet', 'continents-cities');
+__('Recife', 'continents-cities');
+__('Regina', 'continents-cities');
+__('Resolute', 'continents-cities');
+__('Rio Branco', 'continents-cities');
+__('Rosario', 'continents-cities');
+__('Santiago', 'continents-cities');
+__('Santo Domingo', 'continents-cities');
+__('Sao Paulo', 'continents-cities');
+__('Scoresbysund', 'continents-cities');
+__('Shiprock', 'continents-cities');
+__('St Barthelemy', 'continents-cities');
+__('St Johns', 'continents-cities');
+__('St Kitts', 'continents-cities');
+__('St Lucia', 'continents-cities');
+__('St Thomas', 'continents-cities');
+__('St Vincent', 'continents-cities');
+__('Swift Current', 'continents-cities');
+__('Tegucigalpa', 'continents-cities');
+__('Thule', 'continents-cities');
+__('Thunder Bay', 'continents-cities');
+__('Tijuana', 'continents-cities');
+__('Toronto', 'continents-cities');
+__('Tortola', 'continents-cities');
+__('Vancouver', 'continents-cities');
+__('Virgin', 'continents-cities');
+__('Whitehorse', 'continents-cities');
+__('Winnipeg', 'continents-cities');
+__('Yakutat', 'continents-cities');
+__('Yellowknife', 'continents-cities');
+__('Antarctica', 'continents-cities');
+__('Casey', 'continents-cities');
+__('Davis', 'continents-cities');
+__('DumontDUrville', 'continents-cities');
+__('Mawson', 'continents-cities');
+__('McMurdo', 'continents-cities');
+__('Palmer', 'continents-cities');
+__('Rothera', 'continents-cities');
+__('South Pole', 'continents-cities');
+__('Syowa', 'continents-cities');
+__('Vostok', 'continents-cities');
+__('Arctic', 'continents-cities');
+__('Longyearbyen', 'continents-cities');
+__('Asia', 'continents-cities');
+__('Aden', 'continents-cities');
+__('Almaty', 'continents-cities');
+__('Amman', 'continents-cities');
+__('Anadyr', 'continents-cities');
+__('Aqtau', 'continents-cities');
+__('Aqtobe', 'continents-cities');
+__('Ashgabat', 'continents-cities');
+__('Ashkhabad', 'continents-cities');
+__('Baghdad', 'continents-cities');
+__('Bahrain', 'continents-cities');
+__('Baku', 'continents-cities');
+__('Bangkok', 'continents-cities');
+__('Beirut', 'continents-cities');
+__('Bishkek', 'continents-cities');
+__('Brunei', 'continents-cities');
+__('Calcutta', 'continents-cities');
+__('Choibalsan', 'continents-cities');
+__('Chongqing', 'continents-cities');
+__('Chungking', 'continents-cities');
+__('Colombo', 'continents-cities');
+__('Dacca', 'continents-cities');
+__('Damascus', 'continents-cities');
+__('Dhaka', 'continents-cities');
+__('Dili', 'continents-cities');
+__('Dubai', 'continents-cities');
+__('Dushanbe', 'continents-cities');
+__('Gaza', 'continents-cities');
+__('Harbin', 'continents-cities');
+__('Ho Chi Minh', 'continents-cities');
+__('Hong Kong', 'continents-cities');
+__('Hovd', 'continents-cities');
+__('Irkutsk', 'continents-cities');
+__('Istanbul', 'continents-cities');
+__('Jakarta', 'continents-cities');
+__('Jayapura', 'continents-cities');
+__('Jerusalem', 'continents-cities');
+__('Kabul', 'continents-cities');
+__('Kamchatka', 'continents-cities');
+__('Karachi', 'continents-cities');
+__('Kashgar', 'continents-cities');
+__('Katmandu', 'continents-cities');
+__('Kolkata', 'continents-cities');
+__('Krasnoyarsk', 'continents-cities');
+__('Kuala Lumpur', 'continents-cities');
+__('Kuching', 'continents-cities');
+__('Kuwait', 'continents-cities');
+__('Macao', 'continents-cities');
+__('Macau', 'continents-cities');
+__('Magadan', 'continents-cities');
+__('Makassar', 'continents-cities');
+__('Manila', 'continents-cities');
+__('Muscat', 'continents-cities');
+__('Nicosia', 'continents-cities');
+__('Novosibirsk', 'continents-cities');
+__('Omsk', 'continents-cities');
+__('Oral', 'continents-cities');
+__('Phnom Penh', 'continents-cities');
+__('Pontianak', 'continents-cities');
+__('Pyongyang', 'continents-cities');
+__('Qatar', 'continents-cities');
+__('Qyzylorda', 'continents-cities');
+__('Rangoon', 'continents-cities');
+__('Riyadh', 'continents-cities');
+__('Saigon', 'continents-cities');
+__('Sakhalin', 'continents-cities');
+__('Samarkand', 'continents-cities');
+__('Seoul', 'continents-cities');
+__('Shanghai', 'continents-cities');
+__('Singapore', 'continents-cities');
+__('Taipei', 'continents-cities');
+__('Tashkent', 'continents-cities');
+__('Tbilisi', 'continents-cities');
+__('Tehran', 'continents-cities');
+__('Tel Aviv', 'continents-cities');
+__('Thimbu', 'continents-cities');
+__('Thimphu', 'continents-cities');
+__('Tokyo', 'continents-cities');
+__('Ujung Pandang', 'continents-cities');
+__('Ulaanbaatar', 'continents-cities');
+__('Ulan Bator', 'continents-cities');
+__('Urumqi', 'continents-cities');
+__('Vientiane', 'continents-cities');
+__('Vladivostok', 'continents-cities');
+__('Yakutsk', 'continents-cities');
+__('Yekaterinburg', 'continents-cities');
+__('Yerevan', 'continents-cities');
+__('Atlantic', 'continents-cities');
+__('Azores', 'continents-cities');
+__('Bermuda', 'continents-cities');
+__('Canary', 'continents-cities');
+__('Cape Verde', 'continents-cities');
+__('Faeroe', 'continents-cities');
+__('Faroe', 'continents-cities');
+__('Jan Mayen', 'continents-cities');
+__('Madeira', 'continents-cities');
+__('Reykjavik', 'continents-cities');
+__('South Georgia', 'continents-cities');
+__('St Helena', 'continents-cities');
+__('Stanley', 'continents-cities');
+__('Australia', 'continents-cities');
+__('ACT', 'continents-cities');
+__('Adelaide', 'continents-cities');
+__('Brisbane', 'continents-cities');
+__('Broken Hill', 'continents-cities');
+__('Canberra', 'continents-cities');
+__('Currie', 'continents-cities');
+__('Darwin', 'continents-cities');
+__('Eucla', 'continents-cities');
+__('Hobart', 'continents-cities');
+__('LHI', 'continents-cities');
+__('Lindeman', 'continents-cities');
+__('Lord Howe', 'continents-cities');
+__('Melbourne', 'continents-cities');
+__('North', 'continents-cities');
+__('NSW', 'continents-cities');
+__('Perth', 'continents-cities');
+__('Queensland', 'continents-cities');
+__('South', 'continents-cities');
+__('Sydney', 'continents-cities');
+__('Tasmania', 'continents-cities');
+__('Victoria', 'continents-cities');
+__('West', 'continents-cities');
+__('Yancowinna', 'continents-cities');
+__('Etc', 'continents-cities');
+__('GMT', 'continents-cities');
+__('GMT+0', 'continents-cities');
+__('GMT+1', 'continents-cities');
+__('GMT+10', 'continents-cities');
+__('GMT+11', 'continents-cities');
+__('GMT+12', 'continents-cities');
+__('GMT+2', 'continents-cities');
+__('GMT+3', 'continents-cities');
+__('GMT+4', 'continents-cities');
+__('GMT+5', 'continents-cities');
+__('GMT+6', 'continents-cities');
+__('GMT+7', 'continents-cities');
+__('GMT+8', 'continents-cities');
+__('GMT+9', 'continents-cities');
+__('GMT-0', 'continents-cities');
+__('GMT-1', 'continents-cities');
+__('GMT-10', 'continents-cities');
+__('GMT-11', 'continents-cities');
+__('GMT-12', 'continents-cities');
+__('GMT-13', 'continents-cities');
+__('GMT-14', 'continents-cities');
+__('GMT-2', 'continents-cities');
+__('GMT-3', 'continents-cities');
+__('GMT-4', 'continents-cities');
+__('GMT-5', 'continents-cities');
+__('GMT-6', 'continents-cities');
+__('GMT-7', 'continents-cities');
+__('GMT-8', 'continents-cities');
+__('GMT-9', 'continents-cities');
+__('GMT0', 'continents-cities');
+__('Greenwich', 'continents-cities');
+__('UCT', 'continents-cities');
+__('Universal', 'continents-cities');
+__('UTC', 'continents-cities');
+__('Zulu', 'continents-cities');
+__('Europe', 'continents-cities');
+__('Amsterdam', 'continents-cities');
+__('Andorra', 'continents-cities');
+__('Athens', 'continents-cities');
+__('Belfast', 'continents-cities');
+__('Belgrade', 'continents-cities');
+__('Berlin', 'continents-cities');
+__('Bratislava', 'continents-cities');
+__('Brussels', 'continents-cities');
+__('Bucharest', 'continents-cities');
+__('Budapest', 'continents-cities');
+__('Chisinau', 'continents-cities');
+__('Copenhagen', 'continents-cities');
+__('Dublin', 'continents-cities');
+__('Gibraltar', 'continents-cities');
+__('Guernsey', 'continents-cities');
+__('Helsinki', 'continents-cities');
+__('Isle of Man', 'continents-cities');
+__('Jersey', 'continents-cities');
+__('Kaliningrad', 'continents-cities');
+__('Kiev', 'continents-cities');
+__('Lisbon', 'continents-cities');
+__('Ljubljana', 'continents-cities');
+__('London', 'continents-cities');
+__('Luxembourg', 'continents-cities');
+__('Madrid', 'continents-cities');
+__('Malta', 'continents-cities');
+__('Mariehamn', 'continents-cities');
+__('Minsk', 'continents-cities');
+__('Monaco', 'continents-cities');
+__('Moscow', 'continents-cities');
+__('Oslo', 'continents-cities');
+__('Paris', 'continents-cities');
+__('Podgorica', 'continents-cities');
+__('Prague', 'continents-cities');
+__('Riga', 'continents-cities');
+__('Rome', 'continents-cities');
+__('Samara', 'continents-cities');
+__('San Marino', 'continents-cities');
+__('Sarajevo', 'continents-cities');
+__('Simferopol', 'continents-cities');
+__('Skopje', 'continents-cities');
+__('Sofia', 'continents-cities');
+__('Stockholm', 'continents-cities');
+__('Tallinn', 'continents-cities');
+__('Tirane', 'continents-cities');
+__('Tiraspol', 'continents-cities');
+__('Uzhgorod', 'continents-cities');
+__('Vaduz', 'continents-cities');
+__('Vatican', 'continents-cities');
+__('Vienna', 'continents-cities');
+__('Vilnius', 'continents-cities');
+__('Volgograd', 'continents-cities');
+__('Warsaw', 'continents-cities');
+__('Zagreb', 'continents-cities');
+__('Zaporozhye', 'continents-cities');
+__('Zurich', 'continents-cities');
+__('Indian', 'continents-cities');
+__('Antananarivo', 'continents-cities');
+__('Chagos', 'continents-cities');
+__('Christmas', 'continents-cities');
+__('Cocos', 'continents-cities');
+__('Comoro', 'continents-cities');
+__('Kerguelen', 'continents-cities');
+__('Mahe', 'continents-cities');
+__('Maldives', 'continents-cities');
+__('Mauritius', 'continents-cities');
+__('Mayotte', 'continents-cities');
+__('Reunion', 'continents-cities');
+__('Pacific', 'continents-cities');
+__('Apia', 'continents-cities');
+__('Auckland', 'continents-cities');
+__('Chatham', 'continents-cities');
+__('Easter', 'continents-cities');
+__('Efate', 'continents-cities');
+__('Enderbury', 'continents-cities');
+__('Fakaofo', 'continents-cities');
+__('Fiji', 'continents-cities');
+__('Funafuti', 'continents-cities');
+__('Galapagos', 'continents-cities');
+__('Gambier', 'continents-cities');
+__('Guadalcanal', 'continents-cities');
+__('Guam', 'continents-cities');
+__('Honolulu', 'continents-cities');
+__('Johnston', 'continents-cities');
+__('Kiritimati', 'continents-cities');
+__('Kosrae', 'continents-cities');
+__('Kwajalein', 'continents-cities');
+__('Majuro', 'continents-cities');
+__('Marquesas', 'continents-cities');
+__('Midway', 'continents-cities');
+__('Nauru', 'continents-cities');
+__('Niue', 'continents-cities');
+__('Norfolk', 'continents-cities');
+__('Noumea', 'continents-cities');
+__('Pago Pago', 'continents-cities');
+__('Palau', 'continents-cities');
+__('Pitcairn', 'continents-cities');
+__('Ponape', 'continents-cities');
+__('Port Moresby', 'continents-cities');
+__('Rarotonga', 'continents-cities');
+__('Saipan', 'continents-cities');
+__('Samoa', 'continents-cities');
+__('Tahiti', 'continents-cities');
+__('Tarawa', 'continents-cities');
+__('Tongatapu', 'continents-cities');
+__('Truk', 'continents-cities');
+__('Wake', 'continents-cities');
+__('Wallis', 'continents-cities');
+__('Yap', 'continents-cities');
Index: /tags/3.1/wp-admin/includes/dashboard.php
===================================================================
--- /tags/3.1/wp-admin/includes/dashboard.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/dashboard.php	(revision 17487)
@@ -0,0 +1,1151 @@
+<?php
+/**
+ * WordPress Dashboard Widget Administration Panel API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Registers dashboard widgets.
+ *
+ * Handles POST data, sets up filters.
+ *
+ * @since 2.5.0
+ */
+function wp_dashboard_setup() {
+	global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
+	$wp_dashboard_control_callbacks = array();
+	$screen = get_current_screen();
+
+	$update = false;
+	$widget_options = get_option( 'dashboard_widget_options' );
+	if ( !$widget_options || !is_array($widget_options) )
+		$widget_options = array();
+
+	/* Register Widgets and Controls */
+
+	// Right Now
+	if ( is_blog_admin() && current_user_can('edit_posts') )
+		wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
+
+	if ( is_network_admin() )
+		wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
+
+	// Recent Comments Widget
+	if ( is_blog_admin() && current_user_can('moderate_comments') ) {
+		if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
+			$update = true;
+			$widget_options['dashboard_recent_comments'] = array(
+				'items' => 5,
+			);
+		}
+		$recent_comments_title = __( 'Recent Comments' );
+		wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
+	}
+
+	// Incoming Links Widget
+	if ( is_blog_admin() && current_user_can('publish_posts') ) {
+		if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
+			$update = true;
+			$num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
+			$widget_options['dashboard_incoming_links'] = array(
+				'home' => get_option('home'),
+				'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
+				'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
+				'items' => $num_items,
+				'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
+			);
+		}
+		wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
+	}
+
+	// WP Plugins Widget
+	if ( ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) )
+		wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
+
+	// QuickPress Widget
+	if ( is_blog_admin() && current_user_can('edit_posts') )
+		wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
+
+	// Recent Drafts
+	if ( is_blog_admin() && current_user_can('edit_posts') )
+		wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
+
+	// Primary feed (Dev Blog) Widget
+	if ( !isset( $widget_options['dashboard_primary'] ) ) {
+		$update = true;
+		$widget_options['dashboard_primary'] = array(
+			'link' => apply_filters( 'dashboard_primary_link',  __( 'http://wordpress.org/news/' ) ),
+			'url' => apply_filters( 'dashboard_primary_feed',  __( 'http://wordpress.org/news/feed/' ) ),
+			'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
+			'items' => 2,
+			'show_summary' => 1,
+			'show_author' => 0,
+			'show_date' => 1,
+		);
+	}
+	wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
+
+	// Secondary Feed (Planet) Widget
+	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/' ) ),
+			'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
+			'items' => 5,
+			'show_summary' => 0,
+			'show_author' => 0,
+			'show_date' => 0,
+		);
+	}
+	wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
+
+	// Hook to register new widgets
+	// Filter widget order
+	if ( is_network_admin() ) {
+		do_action( 'wp_network_dashboard_setup' );
+		$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
+	} elseif ( is_user_admin() ) {
+		do_action( 'wp_user_dashboard_setup' );
+		$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
+	} else {
+		do_action( 'wp_dashboard_setup' );
+		$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
+	}
+
+	foreach ( $dashboard_widgets as $widget_id ) {
+		$name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
+		wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
+	}
+
+	if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
+		ob_start(); // hack - but the same hack wp-admin/widgets.php uses
+		wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
+		ob_end_clean();
+		wp_redirect( remove_query_arg( 'edit' ) );
+		exit;
+	}
+
+	if ( $update )
+		update_option( 'dashboard_widget_options', $widget_options );
+
+	do_action('do_meta_boxes', $screen->id, 'normal', '');
+	do_action('do_meta_boxes', $screen->id, 'side', '');
+}
+
+function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
+	$screen = get_current_screen();
+	global $wp_dashboard_control_callbacks;
+
+	if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
+		$wp_dashboard_control_callbacks[$widget_id] = $control_callback;
+		if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
+			list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
+			$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
+			$callback = '_wp_dashboard_control_callback';
+		} else {
+			list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
+			$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
+		}
+	}
+
+	if ( is_blog_admin () )
+		$side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
+	else if (is_network_admin() )
+		$side_widgets = array('dashboard_primary', 'dashboard_secondary');
+	else
+		$side_widgets = array();
+
+	$location = 'normal';
+	if ( in_array($widget_id, $side_widgets) )
+		$location = 'side';
+	add_meta_box( $widget_id, $widget_name , $callback, $screen->id, $location, 'core' );
+}
+
+function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
+	echo '<form action="" method="post" class="dashboard-widget-control-form">';
+	wp_dashboard_trigger_widget_control( $meta_box['id'] );
+	echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
+	submit_button( __('Submit') );
+	echo '</form>';
+}
+
+/**
+ * Displays the dashboard.
+ *
+ * @since 2.5.0
+ */
+function wp_dashboard() {
+	global $screen_layout_columns;
+
+	$screen = get_current_screen();
+
+	$hide2 = $hide3 = $hide4 = '';
+	switch ( $screen_layout_columns ) {
+		case 4:
+			$width = 'width:24.5%;';
+			break;
+		case 3:
+			$width = 'width:32.67%;';
+			$hide4 = 'display:none;';
+			break;
+		case 2:
+			$width = 'width:49%;';
+			$hide3 = $hide4 = 'display:none;';
+			break;
+		default:
+			$width = 'width:98%;';
+			$hide2 = $hide3 = $hide4 = 'display:none;';
+	}
+?>
+<div id="dashboard-widgets" class="metabox-holder">
+<?php
+	echo "\t<div class='postbox-container' style='$width'>\n";
+	do_meta_boxes( $screen->id, 'normal', '' );
+
+	echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n";
+	do_meta_boxes( $screen->id, 'side', '' );
+
+	echo "\t</div><div class='postbox-container' style='{$hide3}$width'>\n";
+	do_meta_boxes( $screen->id, 'column3', '' );
+
+	echo "\t</div><div class='postbox-container' style='{$hide4}$width'>\n";
+	do_meta_boxes( $screen->id, 'column4', '' );
+?>
+</div></div>
+
+<form style="display:none" method="get" action="">
+	<p>
+<?php
+	wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
+	wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
+?>
+	</p>
+</form>
+
+<?php
+}
+
+/* Dashboard Widgets */
+
+function wp_dashboard_right_now() {
+	global $wp_registered_sidebars;
+
+	$num_posts = wp_count_posts( 'post' );
+	$num_pages = wp_count_posts( 'page' );
+
+	$num_cats  = wp_count_terms('category');
+
+	$num_tags = wp_count_terms('post_tag');
+
+	$num_comm = wp_count_comments( );
+
+	echo "\n\t".'<div class="table table_content">';
+	echo "\n\t".'<p class="sub">' . __('Content') . '</p>'."\n\t".'<table>';
+	echo "\n\t".'<tr class="first">';
+
+	// Posts
+	$num = number_format_i18n( $num_posts->publish );
+	$text = _n( 'Post', 'Posts', intval($num_posts->publish) );
+	if ( current_user_can( 'edit_posts' ) ) {
+		$num = "<a href='edit.php'>$num</a>";
+		$text = "<a href='edit.php'>$text</a>";
+	}
+	echo '<td class="first b b-posts">' . $num . '</td>';
+	echo '<td class="t posts">' . $text . '</td>';
+
+	echo '</tr><tr>';
+	/* TODO: Show status breakdown on hover
+	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( _n( '%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( _n( '%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( _n( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
+	}
+	if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
+		$pending_text = sprintf( _n( '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 = '';
+	}
+	*/
+
+	// Pages
+	$num = number_format_i18n( $num_pages->publish );
+	$text = _n( 'Page', 'Pages', $num_pages->publish );
+	if ( current_user_can( 'edit_pages' ) ) {
+		$num = "<a href='edit.php?post_type=page'>$num</a>";
+		$text = "<a href='edit.php?post_type=page'>$text</a>";
+	}
+	echo '<td class="first b b_pages">' . $num . '</td>';
+	echo '<td class="t pages">' . $text . '</td>';
+
+	echo '</tr><tr>';
+
+	// Categories
+	$num = number_format_i18n( $num_cats );
+	$text = _n( 'Category', 'Categories', $num_cats );
+	if ( current_user_can( 'manage_categories' ) ) {
+		$num = "<a href='edit-tags.php?taxonomy=category'>$num</a>";
+		$text = "<a href='edit-tags.php?taxonomy=category'>$text</a>";
+	}
+	echo '<td class="first b b-cats">' . $num . '</td>';
+	echo '<td class="t cats">' . $text . '</td>';
+
+	echo '</tr><tr>';
+
+	// Tags
+	$num = number_format_i18n( $num_tags );
+	$text = _n( 'Tag', 'Tags', $num_tags );
+	if ( current_user_can( 'manage_categories' ) ) {
+		$num = "<a href='edit-tags.php'>$num</a>";
+		$text = "<a href='edit-tags.php'>$text</a>";
+	}
+	echo '<td class="first b b-tags">' . $num . '</td>';
+	echo '<td class="t tags">' . $text . '</td>';
+
+	echo "</tr>";
+	do_action('right_now_content_table_end');
+	echo "\n\t</table>\n\t</div>";
+
+
+	echo "\n\t".'<div class="table table_discussion">';
+	echo "\n\t".'<p class="sub">' . __('Discussion') . '</p>'."\n\t".'<table>';
+	echo "\n\t".'<tr class="first">';
+
+	// Total Comments
+	$num = '<span class="total-count">' . number_format_i18n($num_comm->total_comments) . '</span>';
+	$text = _n( 'Comment', 'Comments', $num_comm->total_comments );
+	if ( current_user_can( 'moderate_comments' ) ) {
+		$num = '<a href="edit-comments.php">' . $num . '</a>';
+		$text = '<a href="edit-comments.php">' . $text . '</a>';
+	}
+	echo '<td class="b b-comments">' . $num . '</td>';
+	echo '<td class="last t comments">' . $text . '</td>';
+
+	echo '</tr><tr>';
+
+	// Approved Comments
+	$num = '<span class="approved-count">' . number_format_i18n($num_comm->approved) . '</span>';
+	$text = _nx( 'Approved', 'Approved', $num_comm->approved, 'Right Now' );
+	if ( current_user_can( 'moderate_comments' ) ) {
+		$num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
+		$text = "<a class='approved' href='edit-comments.php?comment_status=approved'>$text</a>";
+	}
+	echo '<td class="b b_approved">' . $num . '</td>';
+	echo '<td class="last t">' . $text . '</td>';
+
+	echo "</tr>\n\t<tr>";
+
+	// Pending Comments
+	$num = '<span class="pending-count">' . number_format_i18n($num_comm->moderated) . '</span>';
+	$text = _n( 'Pending', 'Pending', $num_comm->moderated );
+	if ( current_user_can( 'moderate_comments' ) ) {
+		$num = "<a href='edit-comments.php?comment_status=moderated'>$num</a>";
+		$text = "<a class='waiting' href='edit-comments.php?comment_status=moderated'>$text</a>";
+	}
+	echo '<td class="b b-waiting">' . $num . '</td>';
+	echo '<td class="last t">' . $text . '</td>';
+
+	echo "</tr>\n\t<tr>";
+
+	// Spam Comments
+	$num = number_format_i18n($num_comm->spam);
+	$text = _nx( 'Spam', 'Spam', $num_comm->spam, 'comment' );
+	if ( current_user_can( 'moderate_comments' ) ) {
+		$num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
+		$text = "<a class='spam' href='edit-comments.php?comment_status=spam'>$text</a>";
+	}
+	echo '<td class="b b-spam">' . $num . '</td>';
+	echo '<td class="last t">' . $text . '</td>';
+
+	echo "</tr>";
+	do_action('right_now_table_end');
+	do_action('right_now_discussion_table_end');
+	echo "\n\t</table>\n\t</div>";
+
+	echo "\n\t".'<div class="versions">';
+	$ct = current_theme_info();
+
+	echo "\n\t<p>";
+	if ( !empty($wp_registered_sidebars) ) {
+		$sidebars_widgets = wp_get_sidebars_widgets();
+		$num_widgets = 0;
+		foreach ( (array) $sidebars_widgets as $k => $v ) {
+			if ( 'wp_inactive_widgets' == $k )
+				continue;
+			if ( is_array($v) )
+				$num_widgets = $num_widgets + count($v);
+		}
+		$num = number_format_i18n( $num_widgets );
+
+		$switch_themes = $ct->title;
+		if ( current_user_can( 'switch_themes') ) {
+			echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
+			$switch_themes = '<a href="themes.php">' . $switch_themes . '</a>';
+		}
+		if ( current_user_can( 'edit_theme_options' ) ) {
+			printf(_n('Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $switch_themes, $num);
+		} else {
+			printf(_n('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $switch_themes, $num);
+		}
+	} else {
+		if ( current_user_can( 'switch_themes' ) ) {
+			echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
+			printf( __('Theme <span class="b"><a href="themes.php">%1$s</a></span>'), $ct->title );
+		} else {
+			printf( __('Theme <span class="b">%1$s</span>'), $ct->title );
+		}
+	}
+	echo '</p>';
+
+	update_right_now_message();
+
+	echo "\n\t".'<br class="clear" /></div>';
+	do_action( 'rightnow_end' );
+	do_action( 'activity_box_end' );
+}
+
+function wp_network_dashboard_right_now() {
+	$actions = array();
+	if ( current_user_can('create_sites') )
+		$actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>';
+	if ( current_user_can('create_users') )
+		$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
+
+	$c_users = get_user_count();
+	$c_blogs = get_blog_count();
+
+	$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
+	$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
+
+	$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
+
+	if ( $actions ) {
+		echo '<ul class="subsubsub">';
+		foreach ( $actions as $class => $action ) {
+			 $actions[ $class ] = "\t<li class='$class'>$action";
+		}
+		echo implode( " |</li>\n", $actions ) . "</li>\n";
+		echo '</ul>';
+	}
+?>
+	<br class="clear" />
+
+	<p class="youhave"><?php echo $sentence; ?></p>
+	<?php do_action( 'wpmuadminresult', '' ); ?>
+
+	<form name="searchform" action="<?php echo network_admin_url('users.php'); ?>" method="get">
+		<p>
+			<input type="text" name="s" value="" size="17" />
+			<?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
+		</p>
+	</form>
+
+	<form name="searchform" action="<?php echo network_admin_url('sites.php'); ?>" method="get">
+		<p>
+			<input type="text" name="s" value="" size="17" />
+			<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
+		</p>
+	</form>
+<?php
+	do_action( 'mu_rightnow_end' );
+	do_action( 'mu_activity_box_end' );
+}
+
+function wp_dashboard_quick_press_output() {
+	global $post_ID;
+
+	$drafts = false;
+	if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
+		$view = get_permalink( $_POST['post_ID'] );
+		$edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) );
+		if ( 'post-quickpress-publish' == $_POST['action'] ) {
+			if ( current_user_can('publish_posts') )
+				printf( '<div class="updated"><p>' . __( 'Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );
+			else
+				printf( '<div class="updated"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
+		} else {
+			printf( '<div class="updated"><p>' . __( 'Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
+			$drafts_query = new WP_Query( array(
+				'post_type' => 'post',
+				'post_status' => 'draft',
+				'author' => $GLOBALS['current_user']->ID,
+				'posts_per_page' => 1,
+				'orderby' => 'modified',
+				'order' => 'DESC'
+			) );
+
+			if ( $drafts_query->posts )
+				$drafts =& $drafts_query->posts;
+		}
+		printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );
+		$_REQUEST = array(); // hack for get_default_post_to_edit()
+	}
+
+	/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
+	$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
+	if ( $last_post_id ) {
+		$post = get_post( $last_post_id );
+		if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
+			$post = get_default_post_to_edit('post', true);
+			update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+		} else {
+			$post->post_title = ''; // Remove the auto draft title
+		}
+	} else {
+		$post = get_default_post_to_edit('post', true);
+		update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+	}
+
+	$post_ID = (int) $post->ID;
+?>
+
+	<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
+		<h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>
+		<div class="input-text-wrap">
+			<input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" />
+		</div>
+
+		<?php if ( current_user_can( 'upload_files' ) ) : ?>
+		<div id="media-buttons" class="hide-if-no-js">
+			<?php do_action( 'media_buttons' ); ?>
+		</div>
+		<?php endif; ?>
+
+		<h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>
+		<div class="textarea-wrap">
+			<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo esc_textarea( $post->post_content ); ?></textarea>
+		</div>
+
+		<script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>
+
+		<h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
+		<div class="input-text-wrap">
+			<input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
+		</div>
+
+		<p class="submit">
+			<input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
+			<input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" />
+			<input type="hidden" name="post_type" value="post" />
+			<?php wp_nonce_field('add-post'); ?>
+			<?php submit_button( __( 'Save Draft' ), 'button', 'save', false, array( 'id' => 'save-post', 'tabindex'=> 4 ) ); ?>
+			<input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
+			<span id="publishing-action">
+				<input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
+			</span>
+			<br class="clear" />
+		</p>
+
+	</form>
+
+<?php
+	if ( $drafts )
+		wp_dashboard_recent_drafts( $drafts );
+}
+
+function wp_dashboard_quick_press() {
+	echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
+}
+
+function wp_dashboard_recent_drafts( $drafts = false ) {
+	if ( !$drafts ) {
+		$drafts_query = new WP_Query( array(
+			'post_type' => 'post',
+			'post_status' => 'draft',
+			'author' => $GLOBALS['current_user']->ID,
+			'posts_per_page' => 5,
+			'orderby' => 'modified',
+			'order' => 'DESC'
+		) );
+		$drafts =& $drafts_query->posts;
+	}
+
+	if ( $drafts && is_array( $drafts ) ) {
+		$list = array();
+		foreach ( $drafts as $draft ) {
+			$url = get_edit_post_link( $draft->ID );
+			$title = _draft_or_post_title( $draft->ID );
+			$item = "<h4><a href='$url' title='" . sprintf( __( 'Edit &#8220;%s&#8221;' ), esc_attr( $title ) ) . "'>" . esc_html($title) . "</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';
+			if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
+				$item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '&hellip;' : '' ) . '</p>';
+			$list[] = $item;
+		}
+?>
+	<ul>
+		<li><?php echo join( "</li>\n<li>", $list ); ?></li>
+	</ul>
+	<p class="textright"><a href="edit.php?post_status=draft" class="button"><?php _e('View all'); ?></a></p>
+<?php
+	} else {
+		_e('There are no drafts at the moment');
+	}
+}
+
+/**
+ * Display recent comments dashboard widget content.
+ *
+ * @since 2.5.0
+ */
+function wp_dashboard_recent_comments() {
+	global $wpdb;
+
+	if ( current_user_can('edit_posts') )
+		$allowed_states = array('0', '1');
+	else
+		$allowed_states = array('1');
+
+	// Select all comment types and filter out spam later for better query performance.
+	$comments = array();
+	$start = 0;
+
+	$widgets = get_option( 'dashboard_widget_options' );
+	$total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] )
+		? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;
+
+	while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {
+
+		foreach ( $possible as $comment ) {
+			if ( count( $comments ) >= $total_items )
+				break;
+			if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) )
+				$comments[] = $comment;
+		}
+
+		$start = $start + 50;
+	}
+
+	if ( $comments ) :
+?>
+
+		<div id="the-comment-list" class="list:comment">
+<?php
+		foreach ( $comments as $comment )
+			_wp_dashboard_recent_comments_row( $comment );
+?>
+
+		</div>
+
+<?php
+		if ( current_user_can('edit_posts') ) { ?>
+			<p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p>
+<?php	}
+
+		wp_comment_reply( -1, false, 'dashboard', false );
+		wp_comment_trashnotice();
+
+	else :
+?>
+
+	<p><?php _e( 'No comments yet.' ); ?></p>
+
+<?php
+	endif; // $comments;
+}
+
+function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
+	$GLOBALS['comment'] =& $comment;
+
+	$comment_post_url = get_edit_post_link( $comment->comment_post_ID );
+	$comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID ));
+	$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
+	$comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>';
+
+	$actions_string = '';
+	if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
+		// preorder it: Approve | Reply | Edit | Spam | Trash
+		$actions = array(
+			'approve' => '', 'unapprove' => '',
+			'reply' => '',
+			'edit' => '',
+			'spam' => '',
+			'trash' => '', 'delete' => ''
+		);
+
+		$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
+		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
+
+		$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
+		$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
+		$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
+		$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
+		$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
+
+		$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+		$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+		$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
+		$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
+		$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */  _x( 'Spam', 'verb' ) . '</a>';
+		if ( !EMPTY_TRASH_DAYS )
+			$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
+		else
+			$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
+
+		$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
+
+		$i = 0;
+		foreach ( $actions as $action => $link ) {
+			++$i;
+			( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
+
+			// Reply and quickedit need a hide-if-no-js span
+			if ( 'reply' == $action || 'quickedit' == $action )
+				$action .= ' hide-if-no-js';
+
+			$actions_string .= "<span class='$action'>$sep$link</span>";
+		}
+	}
+
+?>
+
+		<div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
+			<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
+
+			<?php echo get_avatar( $comment, 50 ); ?>
+
+			<div class="dashboard-comment-wrap">
+			<h4 class="comment-meta">
+				<?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__( 'From %1$s on %2$s%3$s' ),
+					'<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?>
+			</h4>
+
+			<?php
+			else :
+				switch ( $comment->comment_type ) :
+				case 'pingback' :
+					$type = __( 'Pingback' );
+					break;
+				case 'trackback' :
+					$type = __( 'Trackback' );
+					break;
+				default :
+					$type = ucwords( $comment->comment_type );
+				endswitch;
+				$type = esc_html( $type );
+			?>
+			<div class="dashboard-comment-wrap">
+			<?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
+			<h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link." ".$comment_link ); ?></h4>
+			<p class="comment-author"><?php comment_author_link(); ?></p>
+
+			<?php endif; // comment_type ?>
+			<blockquote><p><?php comment_excerpt(); ?></p></blockquote>
+			<p class="row-actions"><?php echo $actions_string; ?></p>
+			</div>
+		</div>
+<?php
+}
+
+/**
+ * The recent comments dashboard widget control.
+ *
+ * @since 3.0.0
+ */
+function wp_dashboard_recent_comments_control() {
+	if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
+		$widget_options = array();
+
+	if ( !isset($widget_options['dashboard_recent_comments']) )
+		$widget_options['dashboard_recent_comments'] = array();
+
+	if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) {
+		$number = absint( $_POST['widget-recent-comments']['items'] );
+		$widget_options['dashboard_recent_comments']['items'] = $number;
+		update_option( 'dashboard_widget_options', $widget_options );
+	}
+
+	$number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : '';
+
+	echo '<p><label for="comments-number">' . __('Number of comments to show:') . '</label>';
+	echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /></p>';
+}
+
+function wp_dashboard_incoming_links() {
+	echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
+}
+
+/**
+ * Display incoming links dashboard widget content.
+ *
+ * @since 2.5.0
+ */
+function wp_dashboard_incoming_links_output() {
+	$widgets = get_option( 'dashboard_widget_options' );
+	@extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
+	$rss = fetch_feed( $url );
+
+	if ( is_wp_error($rss) ) {
+		if ( is_admin() || current_user_can('manage_options') ) {
+			echo '<p>';
+			printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
+			echo '</p>';
+		}
+		return;
+	}
+
+	if ( !$rss->get_item_quantity() ) {
+		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&hellip; yet. It&#8217;s okay &#8212; there is no rush.') . "</p>\n";
+		$rss->__destruct();
+		unset($rss);
+		return;
+	}
+
+	echo "<ul>\n";
+
+	if ( !isset($items) )
+		$items = 10;
+
+	foreach ( $rss->get_items(0, $items) as $item ) {
+		$publisher = '';
+		$site_link = '';
+		$link = '';
+		$content = '';
+		$date = '';
+		$link = esc_url( strip_tags( $item->get_link() ) );
+
+		$author = $item->get_author();
+		if ( $author ) {
+			$site_link = esc_url( strip_tags( $author->get_link() ) );
+
+			if ( !$publisher = esc_html( strip_tags( $author->get_name() ) ) )
+				$publisher = __( 'Somebody' );
+		} else {
+		  $publisher = __( 'Somebody' );
+		}
+		if ( $site_link )
+			$publisher = "<a href='$site_link'>$publisher</a>";
+		else
+			$publisher = "<strong>$publisher</strong>";
+
+		$content = $item->get_content();
+		$content = wp_html_excerpt($content, 50) . ' ...';
+
+		if ( $link )
+			/* translators: incoming links feed, %1$s is other person, %3$s is content */
+			$text = __( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"' );
+		else
+			/* translators: incoming links feed, %1$s is other person, %3$s is content */
+			$text = __( '%1$s linked here saying, "%3$s"' );
+
+		if ( !empty($show_date) ) {
+			if ( !empty($show_author) || !empty($show_summary) )
+				/* translators: incoming links feed, %4$s is the date */
+				$text .= ' ' . __( 'on %4$s' );
+			$date = esc_html( strip_tags( $item->get_date() ) );
+			$date = strtotime( $date );
+			$date = gmdate( get_option( 'date_format' ), $date );
+		}
+
+		echo "\t<li>" . sprintf( $text, $publisher, $link, $content, $date ) . "</li>\n";
+	}
+
+	echo "</ul>\n";
+	$rss->__destruct();
+	unset($rss);
+}
+
+function wp_dashboard_incoming_links_control() {
+	wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
+}
+
+function wp_dashboard_primary() {
+	echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
+}
+
+function wp_dashboard_primary_control() {
+	wp_dashboard_rss_control( 'dashboard_primary' );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param string $widget_id
+ */
+function wp_dashboard_rss_output( $widget_id ) {
+	$widgets = get_option( 'dashboard_widget_options' );
+	echo '<div class="rss-widget">';
+	wp_widget_rss_output( $widgets[$widget_id] );
+	echo "</div>";
+}
+
+function wp_dashboard_secondary() {
+	echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
+}
+
+function wp_dashboard_secondary_control() {
+	wp_dashboard_rss_control( 'dashboard_secondary' );
+}
+
+/**
+ * Display secondary dashboard RSS widget feed.
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function wp_dashboard_secondary_output() {
+	$widgets = get_option( 'dashboard_widget_options' );
+	@extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
+	$rss = @fetch_feed( $url );
+
+	if ( is_wp_error($rss) ) {
+		if ( is_admin() || current_user_can('manage_options') ) {
+			echo '<div class="rss-widget"><p>';
+			printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
+			echo '</p></div>';
+		}
+	} elseif ( !$rss->get_item_quantity() ) {
+		$rss->__destruct();
+		unset($rss);
+		return false;
+	} else {
+		echo '<div class="rss-widget">';
+		wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
+		echo '</div>';
+		$rss->__destruct();
+		unset($rss);
+	}
+}
+
+function wp_dashboard_plugins() {
+	echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
+}
+
+/**
+ * Display plugins most popular, newest plugins, and recently updated widget text.
+ *
+ * @since 2.5.0
+ */
+function wp_dashboard_plugins_output() {
+	$popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
+	$new     = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
+	$updated = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/updated/' );
+
+	if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
+		$plugin_slugs = array_keys( get_plugins() );
+		set_transient( 'plugin_slugs', $plugin_slugs, 86400 );
+	}
+
+	foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) {
+		if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
+			continue;
+
+		$items = $$feed->get_items(0, 5);
+
+		// Pick a random, non-installed plugin
+		while ( true ) {
+			// Abort this foreach loop iteration if there's no plugins left of this type
+			if ( 0 == count($items) )
+				continue 2;
+
+			$item_key = array_rand($items);
+			$item = $items[$item_key];
+
+			list($link, $frag) = explode( '#', $item->get_link() );
+
+			$link = esc_url($link);
+			if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
+				$slug = $matches[1];
+			else {
+				unset( $items[$item_key] );
+				continue;
+			}
+
+			// Is this random plugin's slug already installed? If so, try again.
+			reset( $plugin_slugs );
+			foreach ( $plugin_slugs as $plugin_slug ) {
+				if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
+					unset( $items[$item_key] );
+					continue 2;
+				}
+			}
+
+			// If we get to this point, then the random plugin isn't installed and we can stop the while().
+			break;
+		}
+
+		// Eliminate some common badly formed plugin descriptions
+		while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
+			unset($items[$item_key]);
+
+		if ( !isset($items[$item_key]) )
+			continue;
+
+		// current bbPress feed item titles are: user on "topic title"
+		if ( preg_match( '/&quot;(.*)&quot;/s', $item->get_title(), $matches ) )
+			$title = $matches[1];
+		else // but let's make it forward compatible if things change
+			$title = $item->get_title();
+		$title = esc_html( $title );
+
+		$description = esc_html( strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
+
+		$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
+							'&amp;TB_iframe=true&amp;width=600&amp;height=800';
+
+		echo "<h4>$label</h4>\n";
+		echo "<h5><a href='$link'>$title</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
+		echo "<p>$description</p>\n";
+
+		$$feed->__destruct();
+		unset($$feed);
+	}
+}
+
+/**
+ * Checks to see if all of the feed url in $check_urls are cached.
+ *
+ * If $check_urls is empty, look for the rss feed url found in the dashboard
+ * widget optios of $widget_id. If cached, call $callback, a function that
+ * echoes out output for this widget. If not cache, echo a "Loading..." stub
+ * which is later replaced by AJAX call (see top of /wp-admin/index.php)
+ *
+ * @since 2.5.0
+ *
+ * @param string $widget_id
+ * @param callback $callback
+ * @param array $check_urls RSS feeds
+ * @return bool False on failure. True on success.
+ */
+function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
+	$loading = '<p class="widget-loading">' . __( 'Loading&#8230;' ) . '</p>';
+
+	if ( empty($check_urls) ) {
+		$widgets = get_option( 'dashboard_widget_options' );
+		if ( empty($widgets[$widget_id]['url']) ) {
+			echo $loading;
+			return false;
+		}
+		$check_urls = array( $widgets[$widget_id]['url'] );
+	}
+
+	include_once ABSPATH . WPINC . '/class-feed.php';
+	foreach ( $check_urls as $check_url ) {
+		$cache = new WP_Feed_Cache_Transient('', md5($check_url), '');
+		if ( ! $cache->load() ) {
+			echo $loading;
+			return false;
+		}
+	}
+
+	if ( $callback && is_callable( $callback ) ) {
+		$args = array_slice( func_get_args(), 2 );
+		array_unshift( $args, $widget_id );
+		call_user_func_array( $callback, $args );
+	}
+
+	return true;
+}
+
+/* Dashboard Widgets Controls */
+
+// Calls widget_control callback
+/**
+ * Calls widget control callback.
+ *
+ * @since 2.5.0
+ *
+ * @param int $widget_control_id Registered Widget ID.
+ */
+function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
+	global $wp_dashboard_control_callbacks;
+
+	if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) {
+		call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
+	}
+}
+
+/**
+ * The RSS dashboard widget control.
+ *
+ * Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
+ * from RSS-type widgets.
+ *
+ * @since 2.5.0
+ *
+ * @param string $widget_id
+ * @param array $form_inputs
+ */
+function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
+	if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
+		$widget_options = array();
+
+	if ( !isset($widget_options[$widget_id]) )
+		$widget_options[$widget_id] = array();
+
+	$number = 1; // Hack to use wp_widget_rss_form()
+	$widget_options[$widget_id]['number'] = $number;
+
+	if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
+		$_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] );
+		$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
+		// title is optional.  If black, fill it if possible
+		if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
+			$rss = fetch_feed($widget_options[$widget_id]['url']);
+			if ( is_wp_error($rss) ) {
+				$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
+			} else {
+				$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
+				$rss->__destruct();
+				unset($rss);
+			}
+		}
+		update_option( 'dashboard_widget_options', $widget_options );
+	}
+
+	wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
+}
+
+// Display File upload quota on dashboard
+function wp_dashboard_quota() {
+	if ( !is_multisite() || !current_user_can('edit_posts') || get_site_option( 'upload_space_check_disabled' ) )
+		return true;
+
+	$quota = get_space_allowed();
+	$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
+
+	if ( $used > $quota )
+		$percentused = '100';
+	else
+		$percentused = ( $used / $quota ) * 100;
+	$used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
+	$used = round( $used, 2 );
+	$percentused = number_format( $percentused );
+
+	?>
+	<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
+	<div class="table table_content musubtable">
+	<table>
+		<tr class="first">
+			<td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td>
+			<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
+		</tr>
+	</table>
+	</div>
+	<div class="table table_discussion musubtable">
+	<table>
+		<tr class="first">
+			<td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td>
+			<td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
+		</tr>
+	</table>
+	</div>
+	<br class="clear" />
+	<?php
+}
+add_action( 'activity_box_end', 'wp_dashboard_quota' );
+
+/**
+ * Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
+ */
+function wp_dashboard_empty() {}
+
+?>
Index: /tags/3.1/wp-admin/includes/deprecated.php
===================================================================
--- /tags/3.1/wp-admin/includes/deprecated.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/deprecated.php	(revision 17487)
@@ -0,0 +1,690 @@
+<?php
+/**
+ * Deprecated admin functions from past WordPress versions. You shouldn't use these
+ * functions and look for the alternatives instead. The functions will be removed
+ * in a later version.
+ *
+ * @package WordPress
+ * @subpackage Deprecated
+ */
+
+/*
+ * Deprecated functions come here to die.
+ */
+
+/**
+ * @since 2.1
+ * @deprecated 2.1
+ * @deprecated Use wp_tiny_mce().
+ * @see wp_tiny_mce()
+ */
+function tinymce_include() {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_tiny_mce()' );
+
+	wp_tiny_mce();
+}
+
+/**
+ * Unused Admin function.
+ *
+ * @since 2.0
+ * @deprecated 2.5
+ *
+ */
+function documentation_link() {
+	_deprecated_function( __FUNCTION__, '2.5' );
+	return;
+}
+
+/**
+ * Calculates the new dimentions for a downsampled image.
+ *
+ * @since 2.0.0
+ * @deprecated 3.0.0
+ * @deprecated Use wp_constrain_dimensions()
+ *
+ * @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 ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'wp_constrain_dimensions()' );
+	return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 0.71
+ * @deprecated 2.6.0
+ * @deprecated Use wp_category_checklist()
+ * @see wp_category_checklist()
+ *
+ * @param unknown_type $default
+ * @param unknown_type $parent
+ * @param unknown_type $popular_ids
+ */
+function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
+	_deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' );
+	global $post_ID;
+	wp_category_checklist( $post_ID );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.1.0
+ * @deprecated 2.6.0
+ * @deprecated Use wp_link_category_checklist()
+ * @see wp_link_category_checklist()
+ *
+ * @param unknown_type $default
+ */
+function dropdown_link_categories( $default = 0 ) {
+	_deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );
+	global $link_id;
+	wp_link_category_checklist( $link_id );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.2.0
+ * @deprecated 3.0.0
+ * @deprecated Use wp_dropdown_categories()
+ * @see wp_dropdown_categories()
+ *
+ * @param unknown_type $currentcat
+ * @param unknown_type $currentparent
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @param unknown_type $categories
+ * @return unknown
+ */
+function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
+	if (!$categories )
+		$categories = get_categories( array('hide_empty' => 0) );
+
+	if ( $categories ) {
+		foreach ( $categories as $category ) {
+			if ( $currentcat != $category->term_id && $parent == $category->parent) {
+				$pad = str_repeat( '&#8211; ', $level );
+				$category->name = esc_html( $category->name );
+				echo "\n\t<option value='$category->term_id'";
+				if ( $currentparent == $category->term_id )
+					echo " selected='selected'";
+				echo ">$pad$category->name</option>";
+				wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
+			}
+		}
+	} else {
+		return false;
+	}
+}
+
+/**
+ * Register a setting and its sanitization callback
+ *
+ * @since 2.7.0
+ * @deprecated 3.0.0
+ * @deprecated Use register_setting()
+ * @see register_setting()
+ *
+ * @param string $option_group A settings group name.  Should correspond to a whitelisted option key name.
+ * 	Default whitelisted option key names include "general," "discussion," and "reading," among others.
+ * @param string $option_name The name of an option to sanitize and save.
+ * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
+ * @return unknown
+ */
+function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'register_setting()' );
+	return register_setting( $option_group, $option_name, $sanitize_callback );
+}
+
+/**
+ * Unregister a setting
+ *
+ * @since 2.7.0
+ * @deprecated 3.0.0
+ * @deprecated Use unregister_setting()
+ * @see unregister_setting()
+ *
+ * @param unknown_type $option_group
+ * @param unknown_type $option_name
+ * @param unknown_type $sanitize_callback
+ * @return unknown
+ */
+function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' );
+	return unregister_setting( $option_group, $option_name, $sanitize_callback );
+}
+
+/**
+ * Determines the language to use for CodePress syntax highlighting.
+ *
+ * @since 2.8.0
+ * @deprecated 3.0.0
+ *
+ * @param string $filename
+**/
+function codepress_get_lang( $filename ) {
+	_deprecated_function( __FUNCTION__, '3.0' );
+	return;
+}
+
+/**
+ * Adds Javascript required to make CodePress work on the theme/plugin editors.
+ *
+ * @since 2.8.0
+ * @deprecated 3.0.0
+**/
+function codepress_footer_js() {
+	_deprecated_function( __FUNCTION__, '3.0' );
+	return;
+}
+
+/**
+ * Determine whether to use CodePress.
+ *
+ * @since 2.8
+ * @deprecated 3.0.0
+**/
+function use_codepress() {
+	_deprecated_function( __FUNCTION__, '3.0' );
+	return;
+}
+
+
+/**
+ * @deprecated 3.1.0
+ *
+ * @return array List of user IDs.
+ */
+function get_author_user_ids() {
+	_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
+
+	global $wpdb;
+	if ( !is_multisite() )
+		$level_key = $wpdb->get_blog_prefix() . 'user_level';
+	else
+		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
+
+	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
+}
+
+/**
+ * @deprecated 3.1.0
+ *
+ * @param int $user_id User ID.
+ * @return array|bool List of editable authors. False if no editable users.
+ */
+function get_editable_authors( $user_id ) {
+	_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
+
+	global $wpdb;
+
+	$editable = get_editable_user_ids( $user_id );
+
+	if ( !$editable ) {
+		return false;
+	} else {
+		$editable = join(',', $editable);
+		$authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
+	}
+
+	return apply_filters('get_editable_authors', $authors);
+}
+
+/**
+ * @deprecated 3.1.0
+ *
+ * @param int $user_id User ID.
+ * @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
+ * @return unknown
+ */
+function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
+	_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
+
+	global $wpdb;
+
+	$user = new WP_User( $user_id );
+	$post_type_obj = get_post_type_object($post_type);
+
+	if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
+		if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
+			return array($user->id);
+		else
+			return array();
+	}
+
+	if ( !is_multisite() )
+		$level_key = $wpdb->get_blog_prefix() . 'user_level';
+	else
+		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
+
+	$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
+	if ( $exclude_zeros )
+		$query .= " AND meta_value != '0'";
+
+	return $wpdb->get_col( $query );
+}
+
+/**
+ * @deprecated 3.1.0
+ */
+function get_nonauthor_user_ids() {
+	_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
+
+	global $wpdb;
+
+	if ( !is_multisite() )
+		$level_key = $wpdb->get_blog_prefix() . 'user_level';
+	else
+		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
+
+	return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
+}
+
+if ( !class_exists('WP_User_Search') ) :
+/**
+ * WordPress User Search class.
+ *
+ * @since 2.1.0
+ * @deprecated 3.1.0
+ */
+class WP_User_Search {
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var unknown_type
+	 */
+	var $results;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var unknown_type
+	 */
+	var $search_term;
+
+	/**
+	 * Page number.
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var int
+	 */
+	var $page;
+
+	/**
+	 * Role name that users have.
+	 *
+	 * @since 2.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $role;
+
+	/**
+	 * Raw page number.
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var int|bool
+	 */
+	var $raw_page;
+
+	/**
+	 * Amount of users to display per page.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var int
+	 */
+	var $users_per_page = 50;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var unknown_type
+	 */
+	var $first_user;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var int
+	 */
+	var $last_user;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var string
+	 */
+	var $query_limit;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 * @var string
+	 */
+	var $query_orderby;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 * @var string
+	 */
+	var $query_from;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 * @var string
+	 */
+	var $query_where;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var int
+	 */
+	var $total_users_for_query = 0;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var bool
+	 */
+	var $too_many_total_users = false;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var unknown_type
+	 */
+	var $search_errors;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 2.7.0
+	 * @access private
+	 * @var unknown_type
+	 */
+	var $paging_text;
+
+	/**
+	 * PHP4 Constructor - Sets up the object properties.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string $search_term Search terms string.
+	 * @param int $page Optional. Page ID.
+	 * @param string $role Role name.
+	 * @return WP_User_Search
+	 */
+	function WP_User_Search ($search_term = '', $page = '', $role = '') {
+		_deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' );
+
+		$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();
+	}
+
+	/**
+	 * {@internal Missing Short Description}}
+	 *
+	 * {@internal Missing Long Description}}
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 */
+	function prepare_query() {
+		global $wpdb;
+		$this->first_user = ($this->page - 1) * $this->users_per_page;
+
+		$this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
+		$this->query_orderby = ' 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 = " FROM $wpdb->users";
+		$this->query_where = " WHERE 1=1 $search_sql";
+
+		if ( $this->role ) {
+			$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
+			$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
+		} elseif ( is_multisite() ) {
+			$level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
+			$this->query_from .= ", $wpdb->usermeta";
+			$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
+		}
+
+		do_action_ref_array( 'pre_user_search', array( &$this ) );
+	}
+
+	/**
+	 * {@internal Missing Short Description}}
+	 *
+	 * {@internal Missing Long Description}}
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 */
+	function query() {
+		global $wpdb;
+
+		$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
+
+		if ( $this->results )
+			$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
+		else
+			$this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
+	}
+
+	/**
+	 * {@internal Missing Short Description}}
+	 *
+	 * {@internal Missing Long Description}}
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 */
+	function prepare_vars_for_template_usage() {
+		$this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
+	}
+
+	/**
+	 * {@internal Missing Short Description}}
+	 *
+	 * {@internal Missing Long Description}}
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 */
+	function do_paging() {
+		if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
+			$args = array();
+			if( ! empty($this->search_term) )
+				$args['usersearch'] = urlencode($this->search_term);
+			if( ! empty($this->role) )
+				$args['role'] = urlencode($this->role);
+
+			$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' => $args
+			) );
+			if ( $this->paging_text ) {
+				$this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
+					number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
+					number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
+					number_format_i18n( $this->total_users_for_query ),
+					$this->paging_text
+				);
+			}
+		}
+	}
+
+	/**
+	 * {@internal Missing Short Description}}
+	 *
+	 * {@internal Missing Long Description}}
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @return unknown
+	 */
+	function get_results() {
+		return (array) $this->results;
+	}
+
+	/**
+	 * Displaying paging text.
+	 *
+	 * @see do_paging() Builds paging text.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 */
+	function page_links() {
+		echo $this->paging_text;
+	}
+
+	/**
+	 * Whether paging is enabled.
+	 *
+	 * @see do_paging() Builds paging text.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @return bool
+	 */
+	function results_are_paged() {
+		if ( $this->paging_text )
+			return true;
+		return false;
+	}
+
+	/**
+	 * Whether there are search terms.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @return bool
+	 */
+	function is_search() {
+		if ( $this->search_term )
+			return true;
+		return false;
+	}
+}
+endif;
+
+/**
+ * Retrieve editable posts from other users.
+ *
+ * @deprecated 3.1.0
+ *
+ * @param int $user_id User ID to not retrieve posts from.
+ * @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
+ * @return array List of posts from others.
+ */
+function get_others_unpublished_posts($user_id, $type='any') {
+	_deprecated_function( __FUNCTION__, '3.1' );
+
+	global $wpdb;
+
+	$editable = get_editable_user_ids( $user_id );
+
+	if ( in_array($type, array('draft', 'pending')) )
+		$type_sql = " post_status = '$type' ";
+	else
+		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
+
+	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
+
+	if ( !$editable ) {
+		$other_unpubs = '';
+	} else {
+		$editable = join(',', $editable);
+		$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
+	}
+
+	return apply_filters('get_others_drafts', $other_unpubs);
+}
+
+/**
+ * Retrieve drafts from other users.
+ *
+ * @deprecated 3.1.0
+ *
+ * @param int $user_id User ID.
+ * @return array List of drafts from other users.
+ */
+function get_others_drafts($user_id) {
+	_deprecated_function( __FUNCTION__, '3.1' );
+
+	return get_others_unpublished_posts($user_id, 'draft');
+}
+
+/**
+ * Retrieve pending review posts from other users.
+ *
+ * @deprecated 3.1.0
+ *
+ * @param int $user_id User ID.
+ * @return array List of posts with pending review post type from other users.
+ */
+function get_others_pending($user_id) {
+	_deprecated_function( __FUNCTION__, '3.1' );
+
+	return get_others_unpublished_posts($user_id, 'pending');
+}
Index: /tags/3.1/wp-admin/includes/export.php
===================================================================
--- /tags/3.1/wp-admin/includes/export.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/export.php	(revision 17487)
@@ -0,0 +1,418 @@
+<?php
+/**
+ * WordPress Export Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Version number for the export format.
+ *
+ * Bump this when something changes that might affect compatibility.
+ *
+ * @since 2.5.0
+ */
+define( 'WXR_VERSION', '1.1' );
+
+/**
+ * Generates the WXR export file for download
+ *
+ * @since 2.1.0
+ *
+ * @param array $args Filters defining what should be included in the export
+ */
+function export_wp( $args = array() ) {
+	global $wpdb, $post;
+
+	$defaults = array( 'content' => 'all', 'author' => false, 'category' => false,
+		'start_date' => false, 'end_date' => false, 'status' => false,
+	);
+	$args = wp_parse_args( $args, $defaults );
+
+	do_action( 'export_wp' );
+
+	$sitename = sanitize_key( get_bloginfo( 'name' ) );
+	if ( ! empty($sitename) ) $sitename .= '.';
+	$filename = $sitename . '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 );
+
+	if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) {
+		$ptype = get_post_type_object( $args['content'] );
+		if ( ! $ptype->can_export )
+			$args['content'] = 'post';
+
+		$where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] );
+	} else {
+		$post_types = get_post_types( array( 'can_export' => true ) );
+		$esses = array_fill( 0, count($post_types), '%s' );
+		$where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (". implode(',',$esses) .")", $post_types );
+	}
+
+	if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) )
+		$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] );
+	else
+		$where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
+
+	$join = '';
+	if ( $args['category'] && 'post' == $args['content'] ) {
+		if ( $term = term_exists( $args['category'], 'category' ) ) {
+			$join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
+			$where .= $wpdb->prepare( " AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id'] );
+		}
+	}
+
+	if ( 'post' == $args['content'] || 'page' == $args['content'] ) {
+		if ( $args['author'] )
+			$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] );
+
+		if ( $args['start_date'] )
+			$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime($args['start_date']) ) );
+
+		if ( $args['end_date'] )
+			$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($args['end_date'])) ) );
+	}
+
+	// grab a snapshot of post IDs, just in case it changes during the export
+	$post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" );
+
+	// get the requested terms ready, empty unless posts filtered by category or all content
+	$cats = $tags = $terms = array();
+	if ( isset( $term ) && $term ) {
+		$cat = get_term( $term['term_id'], 'category' );
+		$cats = array( $cat->term_id => $cat );
+		unset( $term, $cat );
+	} else if ( 'all' == $args['content'] ) {
+		$categories = (array) get_categories( array( 'get' => 'all' ) );
+		$tags = (array) get_tags( array( 'get' => 'all' ) );
+
+		$custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
+		$custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
+
+		// put categories in order with no child going before its parent
+		while ( $cat = array_shift( $categories ) ) {
+			if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) )
+				$cats[$cat->term_id] = $cat;
+			else
+				$categories[] = $cat;
+		}
+
+		// put terms in order with no child going before its parent
+		while ( $t = array_shift( $custom_terms ) ) {
+			if ( $t->parent == 0 || isset( $terms[$t->parent] ) )
+				$terms[$t->term_id] = $t;
+			else
+				$custom_terms[] = $t;
+		}
+
+		unset( $categories, $custom_taxonomies, $custom_terms );
+	}
+
+	/**
+	 * Wrap given string in XML CDATA tag.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string $str String to wrap in XML CDATA tag.
+	 */
+	function wxr_cdata( $str ) {
+		if ( seems_utf8( $str ) == false )
+			$str = utf8_encode( $str );
+
+		// $str = ent2ncr(esc_html($str));
+		$str = "<![CDATA[$str" . ( ( substr( $str, -1 ) == ']' ) ? ' ' : '') . "]]>";
+
+		return $str;
+	}
+
+	/**
+	 * Return the URL of the site
+	 *
+	 * @since 2.5.0
+	 *
+	 * @return string Site URL.
+	 */
+	function wxr_site_url() {
+		// ms: the base url
+		if ( is_multisite() )
+			return network_home_url();
+		// wp: the blog url
+		else
+			return get_bloginfo_rss( 'url' );
+	}
+
+	/**
+	 * Output a cat_name XML tag from a given category object
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param object $category Category Object
+	 */
+	function wxr_cat_name( $category ) {
+		if ( empty( $category->name ) )
+			return;
+
+		echo '<wp:cat_name>' . wxr_cdata( $category->name ) . '</wp:cat_name>';
+	}
+
+	/**
+	 * Output a category_description XML tag from a given category object
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param object $category Category Object
+	 */
+	function wxr_category_description( $category ) {
+		if ( empty( $category->description ) )
+			return;
+
+		echo '<wp:category_description>' . wxr_cdata( $category->description ) . '</wp:category_description>';
+	}
+
+	/**
+	 * Output a tag_name XML tag from a given tag object
+	 *
+	 * @since 2.3.0
+	 *
+	 * @param object $tag Tag Object
+	 */
+	function wxr_tag_name( $tag ) {
+		if ( empty( $tag->name ) )
+			return;
+
+		echo '<wp:tag_name>' . wxr_cdata( $tag->name ) . '</wp:tag_name>';
+	}
+
+	/**
+	 * Output a tag_description XML tag from a given tag object
+	 *
+	 * @since 2.3.0
+	 *
+	 * @param object $tag Tag Object
+	 */
+	function wxr_tag_description( $tag ) {
+		if ( empty( $tag->description ) )
+			return;
+
+		echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . '</wp:tag_description>';
+	}
+
+	/**
+	 * Output a term_name XML tag from a given term object
+	 *
+	 * @since 2.9.0
+	 *
+	 * @param object $term Term Object
+	 */
+	function wxr_term_name( $term ) {
+		if ( empty( $term->name ) )
+			return;
+
+		echo '<wp:term_name>' . wxr_cdata( $term->name ) . '</wp:term_name>';
+	}
+
+	/**
+	 * Output a term_description XML tag from a given term object
+	 *
+	 * @since 2.9.0
+	 *
+	 * @param object $term Term Object
+	 */
+	function wxr_term_description( $term ) {
+		if ( empty( $term->description ) )
+			return;
+
+		echo '<wp:term_description>' . wxr_cdata( $term->description ) . '</wp:term_description>';
+	}
+
+	/**
+	 * Output list of authors with posts
+	 *
+	 * @since 3.1.0
+	 */
+	function wxr_authors_list() {
+		global $wpdb;
+
+		$authors = array();
+		$results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" );
+		foreach ( (array) $results as $result )
+			$authors[] = get_userdata( $result->post_author );
+
+		$authors = array_filter( $authors );
+
+		foreach( $authors as $author ) {
+			echo "\t<wp:author>";
+			echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
+			echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
+			echo '<wp:author_email>' . $author->user_email . '</wp:author_email>';
+			echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
+			echo '<wp:author_first_name>' . wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
+			echo '<wp:author_last_name>' . wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
+			echo "</wp:author>\n";
+		}
+	}
+
+	/**
+	 * Ouput all navigation menu terms
+	 *
+	 * @since 3.1.0
+	 */
+	function wxr_nav_menu_terms() {
+		$nav_menus = wp_get_nav_menus();
+		if ( empty( $nav_menus ) || ! is_array( $nav_menus ) )
+			return;
+
+		foreach ( $nav_menus as $menu ) {
+			echo "\t<wp:term><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$menu->slug}</wp:term_slug>";
+			wxr_term_name( $menu );
+			echo "</wp:term>\n";
+		}
+	}
+
+	/**
+	 * Output list of taxonomy terms, in XML tag format, associated with a post
+	 *
+	 * @since 2.3.0
+	 */
+	function wxr_post_taxonomy() {
+		global $post;
+
+		$taxonomies = get_object_taxonomies( $post->post_type );
+		if ( empty( $taxonomies ) )
+			return;
+		$terms = wp_get_object_terms( $post->ID, $taxonomies );
+
+		foreach ( (array) $terms as $term ) {
+			echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . "</category>\n";
+		}
+	}
+
+	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 site. -->
+<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
+<!-- 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 site. -->
+
+<!-- To import this information into a WordPress site follow these steps: -->
+<!-- 1. Log in to that site as an administrator. -->
+<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
+<!-- 3. Install the "WordPress" importer from the list. -->
+<!-- 4. Activate & Run Importer. -->
+<!-- 5. Upload this file using the form provided on that page. -->
+<!-- 6. You will first be asked to map the authors in this export file to users -->
+<!--    on the site. For each author, you may choose to map to an -->
+<!--    existing user on the site or to create a new user. -->
+<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
+<!--    contained in this file into your site. -->
+
+<?php the_generator( 'export' ); ?>
+<rss version="2.0"
+	xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
+	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/<?php echo WXR_VERSION; ?>/"
+>
+
+<channel>
+	<title><?php bloginfo_rss( 'name' ); ?></title>
+	<link><?php bloginfo_rss( 'url' ); ?></link>
+	<description><?php bloginfo_rss( 'description' ); ?></description>
+	<pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
+	<language><?php echo get_option( 'rss_language' ); ?></language>
+	<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
+	<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
+	<wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
+
+<?php wxr_authors_list(); ?>
+
+<?php foreach ( $cats as $c ) : ?>
+	<wp:category><wp:term_id><?php echo $c->term_id ?></wp:term_id><wp:category_nicename><?php echo $c->slug; ?></wp:category_nicename><wp:category_parent><?php echo $c->parent ? $cats[$c->parent]->slug : ''; ?></wp:category_parent><?php wxr_cat_name( $c ); ?><?php wxr_category_description( $c ); ?></wp:category>
+<?php endforeach; ?>
+<?php foreach ( $tags as $t ) : ?>
+	<wp:tag><wp:term_id><?php echo $t->term_id ?></wp:term_id><wp:tag_slug><?php echo $t->slug; ?></wp:tag_slug><?php wxr_tag_name( $t ); ?><?php wxr_tag_description( $t ); ?></wp:tag>
+<?php endforeach; ?>
+<?php foreach ( $terms as $t ) : ?>
+	<wp:term><wp:term_id><?php echo $t->term_id ?></wp:term_id><wp:term_taxonomy><?php echo $t->taxonomy; ?></wp:term_taxonomy><wp:term_slug><?php echo $t->slug; ?></wp:term_slug><wp:term_parent><?php echo $t->parent ? $terms[$t->parent]->slug : ''; ?></wp:term_parent><?php wxr_term_name( $t ); ?><?php wxr_term_description( $t ); ?></wp:term>
+<?php endforeach; ?>
+<?php if ( 'all' == $args['content'] ) wxr_nav_menu_terms(); ?>
+
+	<?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" );
+
+	// Begin Loop
+	foreach ( $posts as $post ) {
+		setup_postdata( $post );
+		$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
+?>
+	<item>
+		<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 echo get_the_author_meta( 'login' ); ?></dc:creator>
+		<guid isPermaLink="false"><?php esc_url( the_guid() ); ?></guid>
+		<description></description>
+		<content:encoded><?php echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) ); ?></content:encoded>
+		<excerpt:encoded><?php echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) ); ?></excerpt: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>
+		<wp:post_password><?php echo $post->post_password; ?></wp:post_password>
+		<wp:is_sticky><?php echo $is_sticky; ?></wp:is_sticky>
+<?php	if ( $post->post_type == 'attachment' ) : ?>
+		<wp:attachment_url><?php echo wp_get_attachment_url( $post->ID ); ?></wp:attachment_url>
+<?php 	endif; ?>
+<?php 	wxr_post_taxonomy(); ?>
+<?php	$postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
+		if ( $postmeta ) : foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) : ?>
+		<wp:postmeta>
+			<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
+			<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
+		</wp:postmeta>
+<?php	endif; endforeach; endif; ?>
+<?php	$comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $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 esc_url_raw( $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 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>
+			<wp:comment_user_id><?php echo $c->user_id; ?></wp:comment_user_id>
+		</wp:comment>
+<?php	endforeach; endif; ?>
+	</item>
+<?php
+	}
+	}
+} ?>
+</channel>
+</rss>
+<?php
+}
Index: /tags/3.1/wp-admin/includes/file.php
===================================================================
--- /tags/3.1/wp-admin/includes/file.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/file.php	(revision 17487)
@@ -0,0 +1,1082 @@
+<?php
+/**
+ * File contains all the administration image manipulation functions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** The descriptions for theme files. */
+$wp_file_descriptions = array(
+	'index.php' => __( 'Main Index Template' ),
+	'style.css' => __( 'Stylesheet' ),
+	'editor-style.css' => __( 'Visual Editor Stylesheet' ),
+	'editor-style-rtl.css' => __( 'Visual Editor RTL 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' ),
+	'author.php' => __( 'Author Template' ),
+	'tag.php' => __( 'Tag Template' ),
+	'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' ),
+	'image.php' => __('Image Attachment Template'),
+	'video.php' => __('Video Attachment Template'),
+	'audio.php' => __('Audio Attachment Template'),
+	'application.php' => __('Application 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' ),
+);
+
+/**
+ * Get the description for standard WordPress theme files and other various standard
+ * WordPress files
+ *
+ * @since 1.5.0
+ *
+ * @uses _cleanup_header_comment
+ * @uses $wp_file_descriptions
+ * @param string $file Filesystem path or filename
+ * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist
+ */
+function get_file_description( $file ) {
+	global $wp_file_descriptions;
+
+	if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
+		return $wp_file_descriptions[basename( $file )];
+	}
+	elseif ( file_exists( $file ) && is_file( $file ) ) {
+		$template_data = implode( '', file( $file ) );
+		if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
+			return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
+	}
+
+	return basename( $file );
+}
+
+/**
+ * Get the absolute filesystem path to the root of the WordPress installation
+ *
+ * @since 1.5.0
+ *
+ * @uses get_option
+ * @return string Full filesystem path to the root of the WordPress installation
+ */
+function get_home_path() {
+	$home = get_option( 'home' );
+	$siteurl = get_option( 'siteurl' );
+	if ( $home != '' && $home != $siteurl ) {
+	        $wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
+	        $pos = strpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
+	        $home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
+		$home_path = trailingslashit( $home_path );
+	} else {
+		$home_path = ABSPATH;
+	}
+
+	return $home_path;
+}
+
+/**
+ * Get the real file system path to a file to edit within the admin
+ *
+ * If the $file is index.php or .htaccess this function will assume it is relative
+ * to the install root, otherwise it is assumed the file is relative to the wp-content
+ * directory
+ *
+ * @since 1.5.0
+ *
+ * @uses get_home_path
+ * @uses WP_CONTENT_DIR full filesystem path to the wp-content directory
+ * @param string $file filesystem path relative to the WordPress install directory or to the wp-content directory
+ * @return string full file system path to edit
+ */
+function get_real_file_to_edit( $file ) {
+	if ('index.php' == $file || '.htaccess' == $file ) {
+		$real_file = get_home_path() . $file;
+	} else {
+		$real_file = WP_CONTENT_DIR . $file;
+	}
+
+	return $real_file;
+}
+
+/**
+ * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep.
+ * The depth of the recursiveness can be controlled by the $levels param.
+ *
+ * @since 2.6.0
+ *
+ * @param string $folder Full path to folder
+ * @param int $levels (optional) Levels of folders to follow, Default: 100 (PHP Loop limit).
+ * @return bool|array False on failure, Else array of files
+ */
+function list_files( $folder = '', $levels = 100 ) {
+	if ( empty($folder) )
+		return false;
+
+	if ( ! $levels )
+		return false;
+
+	$files = array();
+	if ( $dir = @opendir( $folder ) ) {
+		while (($file = readdir( $dir ) ) !== false ) {
+			if ( in_array($file, array('.', '..') ) )
+				continue;
+			if ( is_dir( $folder . '/' . $file ) ) {
+				$files2 = list_files( $folder . '/' . $file, $levels - 1);
+				if ( $files2 )
+					$files = array_merge($files, $files2 );
+				else
+					$files[] = $folder . '/' . $file . '/';
+			} else {
+				$files[] = $folder . '/' . $file;
+			}
+		}
+	}
+	@closedir( $dir );
+	return $files;
+}
+
+/**
+ * Determines a writable directory for temporary files.
+ * Function's preference is to WP_CONTENT_DIR followed by the return value of <code>sys_get_temp_dir()</code>, before finally defaulting to /tmp/
+ *
+ * In the event that this function does not find a writable location, It may be overridden by the <code>WP_TEMP_DIR</code> constant in your <code>wp-config.php</code> file.
+ *
+ * @since 2.5.0
+ *
+ * @return string Writable temporary directory
+ */
+function get_temp_dir() {
+	static $temp;
+	if ( defined('WP_TEMP_DIR') )
+		return trailingslashit(WP_TEMP_DIR);
+
+	if ( $temp )
+		return trailingslashit($temp);
+
+	$temp = WP_CONTENT_DIR . '/';
+	if ( is_dir($temp) && @is_writable($temp) )
+		return $temp;
+
+	if  ( function_exists('sys_get_temp_dir') ) {
+		$temp = sys_get_temp_dir();
+		if ( @is_writable($temp) )
+			return trailingslashit($temp);
+	}
+
+	$temp = ini_get('upload_tmp_dir');
+	if ( is_dir($temp) && @is_writable($temp) )
+		return trailingslashit($temp);
+
+	$temp = '/tmp/';
+	return $temp;
+}
+
+/**
+ * Returns a filename of a Temporary unique file.
+ * Please note that the calling function must unlink() this itself.
+ *
+ * The filename is based off the passed parameter or defaults to the current unix timestamp,
+ * while the directory can either be passed as well, or by leaving  it blank, default to a writable temporary directory.
+ *
+ * @since 2.6.0
+ *
+ * @param string $filename (optional) Filename to base the Unique file off
+ * @param string $dir (optional) Directory to store the file in
+ * @return string a writable filename
+ */
+function wp_tempnam($filename = '', $dir = '') {
+	if ( empty($dir) )
+		$dir = get_temp_dir();
+	$filename = basename($filename);
+	if ( empty($filename) )
+		$filename = time();
+
+	$filename = preg_replace('|\..*$|', '.tmp', $filename);
+	$filename = $dir . wp_unique_filename($dir, $filename);
+	touch($filename);
+	return $filename;
+}
+
+/**
+ * Make sure that the file that was requested to edit, is allowed to be edited
+ *
+ * Function will die if if you are not allowed to edit the file
+ *
+ * @since 1.5.0
+ *
+ * @uses wp_die
+ * @uses validate_file
+ * @param string $file file the users is attempting to edit
+ * @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly
+ * @return null
+ */
+function validate_file_to_edit( $file, $allowed_files = '' ) {
+	$code = validate_file( $file, $allowed_files );
+
+	if (!$code )
+		return $file;
+
+	switch ( $code ) {
+		case 1 :
+			wp_die( __('Sorry, can&#8217;t edit files with &#8220;..&#8221; in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.' ));
+
+		//case 2 :
+		//	wp_die( __('Sorry, can&#8217;t call files with their real path.' ));
+
+		case 3 :
+			wp_die( __('Sorry, that file cannot be edited.' ));
+	}
+}
+
+/**
+ * Handle PHP uploads in WordPress, sanitizing file names, checking extensions for mime type,
+ * and moving the file to the appropriate directory within the uploads directory.
+ *
+ * @since 2.0
+ *
+ * @uses wp_handle_upload_error
+ * @uses apply_filters
+ * @uses is_multisite
+ * @uses wp_check_filetype_and_ext
+ * @uses current_user_can
+ * @uses wp_upload_dir
+ * @uses wp_unique_filename
+ * @uses delete_transient
+ * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file.
+ * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
+ * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
+ */
+function wp_handle_upload( &$file, $overrides = false, $time = null ) {
+	// The default error handler.
+	if ( ! function_exists( 'wp_handle_upload_error' ) ) {
+		function wp_handle_upload_error( &$file, $message ) {
+			return array( 'error'=>$message );
+		}
+	}
+
+	$file = apply_filters( 'wp_handle_upload_prefilter', $file );
+
+	// You may define your own function and pass the name in $overrides['upload_error_handler']
+	$upload_error_handler = 'wp_handle_upload_error';
+
+	// You may have had one or more 'wp_handle_upload_prefilter' functions error out the file.  Handle that gracefully.
+	if ( isset( $file['error'] ) && !is_numeric( $file['error'] ) && $file['error'] )
+		return $upload_error_handler( $file, $file['error'] );
+
+	// You may define your own function and pass the name in $overrides['unique_filename_callback']
+	$unique_filename_callback = null;
+
+	// $_POST['action'] must be set and its value must equal $overrides['action'] or this:
+	$action = 'wp_handle_upload';
+
+	// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
+	$upload_error_strings = array( false,
+		__( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ),
+		__( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ),
+		__( "The uploaded file was only partially uploaded." ),
+		__( "No file was uploaded." ),
+		'',
+		__( "Missing a temporary folder." ),
+		__( "Failed to write file to disk." ),
+		__( "File upload stopped by extension." ));
+
+	// All tests are on by default. Most can be turned off by $override[{test_name}] = false;
+	$test_form = true;
+	$test_size = true;
+	$test_upload = true;
+
+	// 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 ) )
+		extract( $overrides, EXTR_OVERWRITE );
+
+	// A correct form post will pass this test.
+	if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
+		return call_user_func($upload_error_handler, $file, __( 'Invalid form submission.' ));
+
+	// A successful upload will pass this test. It makes no sense to override this one.
+	if ( $file['error'] > 0 )
+		return call_user_func($upload_error_handler, $file, $upload_error_strings[$file['error']] );
+
+	// A non-empty file will pass this test.
+	if ( $test_size && !($file['size'] > 0 ) ) {
+		if ( is_multisite() )
+			$error_msg = __( 'File is empty. Please upload something more substantial.' );
+		else
+			$error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
+		return call_user_func($upload_error_handler, $file, $error_msg);
+	}
+
+	// A properly uploaded file will pass this test. There should be no reason to override this one.
+	if ( $test_upload && ! @ is_uploaded_file( $file['tmp_name'] ) )
+		return call_user_func($upload_error_handler, $file, __( 'Specified file failed upload test.' ));
+
+	// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
+	if ( $test_type ) {
+		$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes );
+
+		extract( $wp_filetype );
+
+		// Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
+		if ( $proper_filename )
+			$file['name'] = $proper_filename;
+
+		if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
+			return call_user_func($upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ));
+
+		if ( !$ext )
+			$ext = ltrim(strrchr($file['name'], '.'), '.');
+
+		if ( !$type )
+			$type = $file['type'];
+	} else {
+		$type = '';
+	}
+
+	// A writable uploads dir will pass this test. Again, there's no point overriding this one.
+	if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
+		return call_user_func($upload_error_handler, $file, $uploads['error'] );
+
+	$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
+
+	// Move the file to the uploads dir
+	$new_file = $uploads['path'] . "/$filename";
+	if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
+		return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
+
+	// Set correct file permissions
+	$stat = stat( dirname( $new_file ));
+	$perms = $stat['mode'] & 0000666;
+	@ chmod( $new_file, $perms );
+
+	// Compute the URL
+	$url = $uploads['url'] . "/$filename";
+
+	if ( is_multisite() )
+		delete_transient( 'dirsize_cache' );
+
+	return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'upload' );
+}
+
+/**
+ * Handle sideloads, which is the process of retriving a media item from another server instead of
+ * a traditional media upload.  This process involves sanitizing the filename, checking extensions
+ * for mime type, and moving the file to the appropriate directory within the uploads directory.
+ *
+ * @since 2.6.0
+ *
+ * @uses wp_handle_upload_error
+ * @uses apply_filters
+ * @uses wp_check_filetype_and_ext
+ * @uses current_user_can
+ * @uses wp_upload_dir
+ * @uses wp_unique_filename
+ * @param array $file an array similar to that of a PHP $_FILES POST array
+ * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
+ * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
+ */
+function wp_handle_sideload( &$file, $overrides = false ) {
+	// The default error handler.
+	if (! function_exists( 'wp_handle_upload_error' ) ) {
+		function wp_handle_upload_error( &$file, $message ) {
+			return array( 'error'=>$message );
+		}
+	}
+
+	// You may define your own function and pass the name in $overrides['upload_error_handler']
+	$upload_error_handler = 'wp_handle_upload_error';
+
+	// You may define your own function and pass the name in $overrides['unique_filename_callback']
+	$unique_filename_callback = null;
+
+	// $_POST['action'] must be set and its value must equal $overrides['action'] or this:
+	$action = 'wp_handle_sideload';
+
+	// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
+	$upload_error_strings = array( false,
+		__( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ),
+		__( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ),
+		__( "The uploaded file was only partially uploaded." ),
+		__( "No file was uploaded." ),
+		'',
+		__( "Missing a temporary folder." ),
+		__( "Failed to write file to disk." ),
+		__( "File upload stopped by extension." ));
+
+	// All tests are on by default. Most can be turned off by $override[{test_name}] = false;
+	$test_form = true;
+	$test_size = true;
+
+	// 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 ) )
+		extract( $overrides, EXTR_OVERWRITE );
+
+	// A correct form post will pass this test.
+	if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
+		return $upload_error_handler( $file, __( 'Invalid form submission.' ));
+
+	// A successful upload will pass this test. It makes no sense to override this one.
+	if ( ! empty( $file['error'] ) )
+		return $upload_error_handler( $file, $upload_error_strings[$file['error']] );
+
+	// A non-empty file will pass this test.
+	if ( $test_size && !(filesize($file['tmp_name']) > 0 ) )
+		return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.' ));
+
+	// A properly uploaded file will pass this test. There should be no reason to override this one.
+	if (! @ is_file( $file['tmp_name'] ) )
+		return $upload_error_handler( $file, __( 'Specified file does not exist.' ));
+
+	// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
+	if ( $test_type ) {
+		$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes );
+
+		extract( $wp_filetype );
+
+		// Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
+		if ( $proper_filename )
+			$file['name'] = $proper_filename;
+
+		if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
+			return $upload_error_handler( $file, __( 'Sorry, this file type is not permitted for security reasons.' ));
+
+		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'] );
+
+	$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
+
+	// Strip the query strings.
+	$filename = str_replace('?','-', $filename);
+	$filename = str_replace('&','-', $filename);
+
+	// Move the file to the uploads dir
+	$new_file = $uploads['path'] . "/$filename";
+	if ( false === @ rename( $file['tmp_name'], $new_file ) ) {
+		return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
+	}
+
+	// Set correct file permissions
+	$stat = stat( dirname( $new_file ));
+	$perms = $stat['mode'] & 0000666;
+	@ chmod( $new_file, $perms );
+
+	// Compute the URL
+	$url = $uploads['url'] . "/$filename";
+
+	$return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'sideload' );
+
+	return $return;
+}
+
+/**
+ * Downloads a url to a local temporary file using the WordPress HTTP Class.
+ * Please note, That the calling function must unlink() the  file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $url the URL of the file to download
+ * @param int $timeout The timeout for the request to download the file default 300 seconds
+ * @return mixed WP_Error on failure, string Filename on success.
+ */
+function download_url( $url, $timeout = 300 ) {
+	//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 = wp_tempnam($url);
+	if ( ! $tmpfname )
+		return new WP_Error('http_no_file', __('Could not create Temporary file.'));
+
+	$handle = @fopen($tmpfname, 'wb');
+	if ( ! $handle )
+		return new WP_Error('http_no_file', __('Could not create Temporary file.'));
+
+	$response = wp_remote_get($url, array('timeout' => $timeout));
+
+	if ( is_wp_error($response) ) {
+		fclose($handle);
+		unlink($tmpfname);
+		return $response;
+	}
+
+	if ( $response['response']['code'] != '200' ){
+		fclose($handle);
+		unlink($tmpfname);
+		return new WP_Error('http_404', trim($response['response']['message']));
+	}
+
+	fwrite($handle, $response['body']);
+	fclose($handle);
+
+	return $tmpfname;
+}
+
+/**
+ * Unzip's a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction.
+ * Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present.
+ *
+ * Attempts to increase the PHP Memory limit to 256M before uncompressing,
+ * However, The most memory required shouldn't be much larger than the Archive itself.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Full path and filename of zip archive
+ * @param string $to Full path on the filesystem to extract archive to
+ * @return mixed WP_Error on failure, True on success
+ */
+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.'));
+
+	// Unzip can use a lot of memory, but not this much hopefully
+	@ini_set('memory_limit', '256M');
+
+	$needed_dirs = array();
+	$to = trailingslashit($to);
+
+	// Determine any parent dir's needed (of the upgrade directory)
+	if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist
+		$path = preg_split('![/\\\]!', untrailingslashit($to));
+		for ( $i = count($path); $i >= 0; $i-- ) {
+			if ( empty($path[$i]) )
+				continue;
+
+			$dir = implode('/', array_slice($path, 0, $i+1) );
+			if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter.
+				continue;
+
+			if ( ! $wp_filesystem->is_dir($dir) )
+				$needed_dirs[] = $dir;
+			else
+				break; // A folder exists, therefor, we dont need the check the levels below this
+		}
+	}
+
+	if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) ) {
+		$result = _unzip_file_ziparchive($file, $to, $needed_dirs);
+		if ( true === $result ) {
+			return $result;
+		} elseif ( is_wp_error($result) ) {
+			if ( 'incompatible_archive' != $result->get_error_code() )
+				return $result;
+		}
+	}
+	// Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
+	return _unzip_file_pclzip($file, $to, $needed_dirs);
+}
+
+/**
+ * This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the ZipArchive class.
+ * Assumes that WP_Filesystem() has already been called and set up.
+ *
+ * @since 3.0.0
+ * @see unzip_file
+ * @access private
+ *
+ * @param string $file Full path and filename of zip archive
+ * @param string $to Full path on the filesystem to extract archive to
+ * @param array $needed_dirs A partial list of required folders needed to be created.
+ * @return mixed WP_Error on failure, True on success
+ */
+function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
+	global $wp_filesystem;
+
+	$z = new ZipArchive();
+
+	// PHP4-compat - php4 classes can't contain constants
+	$zopen = $z->open($file, /* ZIPARCHIVE::CHECKCONS */ 4);
+	if ( true !== $zopen )
+		return new WP_Error('incompatible_archive', __('Incompatible Archive.'));
+
+	for ( $i = 0; $i < $z->numFiles; $i++ ) {
+		if ( ! $info = $z->statIndex($i) )
+			return new WP_Error('stat_failed', __('Could not retrieve file from archive.'));
+
+		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
+			continue;
+
+		if ( '/' == substr($info['name'], -1) ) // directory
+			$needed_dirs[] = $to . untrailingslashit($info['name']);
+		else
+			$needed_dirs[] = $to . untrailingslashit(dirname($info['name']));
+	}
+
+	$needed_dirs = array_unique($needed_dirs);
+	foreach ( $needed_dirs as $dir ) {
+		// Check the parent folders of the folders all exist within the creation array.
+		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
+			continue;
+		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
+			continue;
+
+		$parent_folder = dirname($dir);
+		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
+			$needed_dirs[] = $parent_folder;
+			$parent_folder = dirname($parent_folder);
+		}
+	}
+	asort($needed_dirs);
+
+	// Create those directories if need be:
+	foreach ( $needed_dirs as $_dir ) {
+		if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the Dir exists upon creation failure. Less I/O this way.
+			return new WP_Error('mkdir_failed', __('Could not create directory.'), $_dir);
+	}
+	unset($needed_dirs);
+
+	for ( $i = 0; $i < $z->numFiles; $i++ ) {
+		if ( ! $info = $z->statIndex($i) )
+			return new WP_Error('stat_failed', __('Could not retrieve file from archive.'));
+
+		if ( '/' == substr($info['name'], -1) ) // directory
+			continue;
+
+		if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
+			continue;
+
+		$contents = $z->getFromIndex($i);
+		if ( false === $contents )
+			return new WP_Error('extract_failed', __('Could not extract file from archive.'), $info['name']);
+
+		if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
+			return new WP_Error('copy_failed', __('Could not copy file.'), $to . $info['filename']);
+	}
+
+	$z->close();
+
+	return true;
+}
+
+/**
+ * This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the PclZip library.
+ * Assumes that WP_Filesystem() has already been called and set up.
+ *
+ * @since 3.0.0
+ * @see unzip_file
+ * @access private
+ *
+ * @param string $file Full path and filename of zip archive
+ * @param string $to Full path on the filesystem to extract archive to
+ * @param array $needed_dirs A partial list of required folders needed to be created.
+ * @return mixed WP_Error on failure, True on success
+ */
+function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
+	global $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.'));
+
+	// Determine any children directories needed (From within the archive)
+	foreach ( $archive_files as $file ) {
+		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory
+			continue;
+
+		$needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) );
+	}
+
+	$needed_dirs = array_unique($needed_dirs);
+	foreach ( $needed_dirs as $dir ) {
+		// Check the parent folders of the folders all exist within the creation array.
+		if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
+			continue;
+		if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
+			continue;
+
+		$parent_folder = dirname($dir);
+		while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
+			$needed_dirs[] = $parent_folder;
+			$parent_folder = dirname($parent_folder);
+		}
+	}
+	asort($needed_dirs);
+
+	// Create those directories if need be:
+	foreach ( $needed_dirs as $_dir ) {
+		if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the dir exists upon creation failure. Less I/O this way.
+			return new WP_Error('mkdir_failed', __('Could not create directory.'), $_dir);
+	}
+	unset($needed_dirs);
+
+	// Extract the files from the zip
+	foreach ( $archive_files as $file ) {
+		if ( $file['folder'] )
+			continue;
+
+		if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
+			continue;
+
+		if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
+			return new WP_Error('copy_failed', __('Could not copy file.'), $to . $file['filename']);
+	}
+	return true;
+}
+
+/**
+ * Copies a directory from one location to another via the WordPress Filesystem Abstraction.
+ * Assumes that WP_Filesystem() has already been called and setup.
+ *
+ * @since 2.5.0
+ *
+ * @param string $from source directory
+ * @param string $to destination directory
+ * @return mixed WP_Error on failure, True on success.
+ */
+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) ) {
+				// If copy failed, chmod file to 0644 and try again.
+				$wp_filesystem->chmod($to . $filename, 0644);
+				if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) )
+					return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
+			}
+			$wp_filesystem->chmod($to . $filename, FS_CHMOD_FILE);
+		} elseif ( 'd' == $fileinfo['type'] ) {
+			if ( !$wp_filesystem->is_dir($to . $filename) ) {
+				if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
+					return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
+			}
+			$result = copy_dir($from . $filename, $to . $filename);
+			if ( is_wp_error($result) )
+				return $result;
+		}
+	}
+	return true;
+}
+
+/**
+ * Initialises and connects the WordPress Filesystem Abstraction classes.
+ * This function will include the chosen transport and attempt connecting.
+ *
+ * Plugins may add extra transports, And force WordPress to use them by returning the filename via the 'filesystem_method_file' filter.
+ *
+ * @since 2.5.0
+ *
+ * @param array $args (optional) Connection args, These are passed directly to the WP_Filesystem_*() classes.
+ * @param string $context (optional) Context for get_filesystem_method(), See function declaration for more information.
+ * @return boolean false on failure, true on success
+ */
+function WP_Filesystem( $args = false, $context = false ) {
+	global $wp_filesystem;
+
+	require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
+
+	$method = get_filesystem_method($args, $context);
+
+	if ( ! $method )
+		return false;
+
+	if ( ! class_exists("WP_Filesystem_$method") ) {
+		$abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
+		if ( ! file_exists($abstraction_file) )
+			return;
+
+		require_once($abstraction_file);
+	}
+	$method = "WP_Filesystem_$method";
+
+	$wp_filesystem = new $method($args);
+
+	//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
+	if ( ! defined('FS_CONNECT_TIMEOUT') )
+		define('FS_CONNECT_TIMEOUT', 30);
+	if ( ! defined('FS_TIMEOUT') )
+		define('FS_TIMEOUT', 30);
+
+	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
+		return false;
+
+	if ( !$wp_filesystem->connect() )
+		return false; //There was an erorr connecting to the server.
+
+	// Set the permission constants if not already set.
+	if ( ! defined('FS_CHMOD_DIR') )
+		define('FS_CHMOD_DIR', 0755 );
+	if ( ! defined('FS_CHMOD_FILE') )
+		define('FS_CHMOD_FILE', 0644 );
+
+	return true;
+}
+
+/**
+ * Determines which Filesystem Method to use.
+ * The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsoxkopen())
+ *
+ * Note that the return value of this function can be overridden in 2 ways
+ *  - By defining FS_METHOD in your <code>wp-config.php</code> file
+ *  - By using the filesystem_method filter
+ * Valid values for these are: 'direct', 'ssh', 'ftpext' or 'ftpsockets'
+ * Plugins may also define a custom transport handler, See the WP_Filesystem function for more information.
+ *
+ * @since 2.5.0
+ *
+ * @param array $args Connection details.
+ * @param string $context Full path to the directory that is tested for being writable.
+ * @return string The transport to use, see description for valid return values.
+ */
+function get_filesystem_method($args = array(), $context = false) {
+	$method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
+
+	if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
+		if ( !$context )
+			$context = WP_CONTENT_DIR;
+		$context = trailingslashit($context);
+		$temp_file_name = $context . 'temp-write-test-' . time();
+		$temp_handle = @fopen($temp_file_name, 'w');
+		if ( $temp_handle ) {
+			if ( getmyuid() == @fileowner($temp_file_name) )
+				$method = 'direct';
+			@fclose($temp_handle);
+			@unlink($temp_file_name);
+		}
+ 	}
+
+	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
+	if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
+	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
+	return apply_filters('filesystem_method', $method, $args);
+}
+
+/**
+ * Displays a form to the user to request for their FTP/SSH details in order to  connect to the filesystem.
+ * All chosen/entered details are saved, Excluding the Password.
+ *
+ * Hostnames may be in the form of hostname:portnumber (eg: wordpress.org:2467) to specify an alternate FTP/SSH port.
+ *
+ * Plugins may override this form by returning true|false via the <code>request_filesystem_credentials</code> filter.
+ *
+ * @since 2.5.0
+ *
+ * @param string $form_post the URL to post the form to
+ * @param string $type the chosen Filesystem method in use
+ * @param boolean $error if the current request has failed to connect
+ * @param string $context The directory which is needed access to, The write-test will be performed on  this directory by get_filesystem_method()
+ * @param string $extra_fields Extra POST fields which should be checked for to be included in the post.
+ * @return boolean False on failure. True on success.
+ */
+function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null) {
+	$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields );
+	if ( '' !== $req_cred )
+		return $req_cred;
+
+	if ( empty($type) )
+		$type = get_filesystem_method(array(), $context);
+
+	if ( 'direct' == $type )
+		return true;
+
+	if ( is_null( $extra_fields ) )
+		$extra_fields = array( 'version', 'locale' );
+
+	$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
+
+	// 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']) ? stripslashes($_POST['hostname']) : $credentials['hostname']);
+	$credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? stripslashes($_POST['username']) : $credentials['username']);
+	$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? stripslashes($_POST['password']) : '');
+
+	// Check to see if we are setting the public/private keys for ssh
+	$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? stripslashes($_POST['public_key']) : '');
+	$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? stripslashes($_POST['private_key']) : '');
+
+	//sanitize the hostname, Some people might pass in odd-data:
+	$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
+
+	if ( strpos($credentials['hostname'], ':') ) {
+		list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
+		if ( ! is_numeric($credentials['port']) )
+			unset($credentials['port']);
+	} else {
+		unset($credentials['port']);
+	}
+
+	if ( (defined('FTP_SSH') && FTP_SSH) || (defined('FS_METHOD') && 'ssh' == FS_METHOD) )
+		$credentials['connection_type'] = 'ssh';
+	else if ( (defined('FTP_SSL') && FTP_SSL) && 'ftpext' == $type ) //Only the FTP Extension understands SSL
+		$credentials['connection_type'] = 'ftps';
+	else if ( !empty($_POST['connection_type']) )
+		$credentials['connection_type'] = stripslashes($_POST['connection_type']);
+	else if ( !isset($credentials['connection_type']) ) //All else fails (And its not defaulted to something else saved), Default to FTP
+		$credentials['connection_type'] = 'ftp';
+
+	if ( ! $error &&
+			(
+				( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) ||
+				( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) )
+			) ) {
+		$stored_credentials = $credentials;
+		if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
+			$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
+
+		unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
+		update_option('ftp_credentials', $stored_credentials);
+		return $credentials;
+	}
+	$hostname = '';
+	$username = '';
+	$password = '';
+	$connection_type = '';
+	if ( !empty($credentials) )
+		extract($credentials, EXTR_OVERWRITE);
+	if ( $error ) {
+		$error_string = __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.');
+		if ( is_wp_error($error) )
+			$error_string = esc_html( $error->get_error_message() );
+		echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
+	}
+
+	$types = array();
+	if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
+		$types[ 'ftp' ] = __('FTP');
+	if ( extension_loaded('ftp') ) //Only this supports FTPS
+		$types[ 'ftps' ] = __('FTPS (SSL)');
+	if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
+		$types[ 'ssh' ] = __('SSH2');
+
+	$types = apply_filters('fs_ftp_connection_types', $types, $credentials, $type, $error, $context);
+
+?>
+<script type="text/javascript">
+<!--
+jQuery(function($){
+	jQuery("#ssh").click(function () {
+		jQuery("#ssh_keys").show();
+	});
+	jQuery("#ftp, #ftps").click(function () {
+		jQuery("#ssh_keys").hide();
+	});
+	jQuery('form input[value=""]:first').focus();
+});
+-->
+</script>
+<form action="<?php echo $form_post ?>" method="post">
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php _e('Connection Information') ?></h2>
+<p><?php
+	$label_user = __('Username');
+	$label_pass = __('Password');
+	_e('To perform the requested action, WordPress needs to access your web server.');
+	echo ' ';
+	if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) {
+		if ( isset( $types['ssh'] ) ) {
+			_e('Please enter your FTP or SSH credentials to proceed.');
+			$label_user = __('FTP/SSH Username');
+			$label_pass = __('FTP/SSH Password');
+		} else {
+			_e('Please enter your FTP credentials to proceed.');
+			$label_user = __('FTP Username');
+			$label_pass = __('FTP Password');
+		}
+		echo ' ';
+	}
+	_e('If you do not remember your credentials, you should contact your web host.');
+?></p>
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>
+<td><input name="hostname" type="text" id="hostname" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> size="40" /></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><label for="username"><?php echo $label_user; ?></label></th>
+<td><input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> size="40" /></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><label for="password"><?php echo $label_pass; ?></label></th>
+<td><input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> size="40" /></td>
+</tr>
+
+<?php if ( isset($types['ssh']) ) : ?>
+<tr id="ssh_keys" valign="top" style="<?php if ( 'ssh' != $connection_type ) echo 'display:none' ?>">
+<th scope="row"><?php _e('Authentication Keys') ?>
+<div class="key-labels textright">
+<label for="public_key"><?php _e('Public Key:') ?></label ><br />
+<label for="private_key"><?php _e('Private Key:') ?></label>
+</div></th>
+<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> size="40" />
+<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
+</tr>
+<?php endif; ?>
+
+<tr valign="top">
+<th scope="row"><?php _e('Connection Type') ?></th>
+<td>
+<fieldset><legend class="screen-reader-text"><span><?php _e('Connection Type') ?></span></legend>
+<?php
+	$disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
+	foreach ( $types as $name => $text ) : ?>
+	<label for="<?php echo esc_attr($name) ?>">
+		<input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); echo $disabled; ?> />
+		<?php echo $text ?>
+	</label>
+	<?php endforeach; ?>
+</fieldset>
+</td>
+</tr>
+</table>
+
+<?php
+foreach ( (array) $extra_fields as $field ) {
+	if ( isset( $_POST[ $field ] ) )
+		echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( stripslashes( $_POST[ $field ] ) ) . '" />';
+}
+submit_button( __( 'Proceed' ), 'button', 'upgrade' );
+?>
+</div>
+</form>
+<?php
+	return false;
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/image-edit.php
===================================================================
--- /tags/3.1/wp-admin/includes/image-edit.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/image-edit.php	(revision 17487)
@@ -0,0 +1,668 @@
+<?php
+/**
+ * WordPress Image Editor
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+function wp_image_editor($post_id, $msg = false) {
+	$nonce = wp_create_nonce("image_editor-$post_id");
+	$meta = wp_get_attachment_metadata($post_id);
+	$thumb = image_get_intermediate_size($post_id, 'thumbnail');
+	$sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']);
+	$note = '';
+
+	if ( is_array($meta) && isset($meta['width']) )
+		$big = max( $meta['width'], $meta['height'] );
+	else
+		die( __('Image data does not exist. Please re-upload the image.') );
+
+	$sizer = $big > 400 ? 400 / $big : 1;
+
+	$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
+	$can_restore = !empty($backup_sizes) && isset($backup_sizes['full-orig'])
+		&& $backup_sizes['full-orig']['file'] != basename($meta['file']);
+
+	if ( $msg ) {
+		if ( isset($msg->error) )
+			$note = "<div class='error'><p>$msg->error</p></div>";
+		elseif ( isset($msg->msg) )
+			$note = "<div class='updated'><p>$msg->msg</p></div>";
+	}
+
+	?>
+	<div class="imgedit-wrap">
+	<?php echo $note; ?>
+	<table id="imgedit-panel-<?php echo $post_id; ?>"><tbody>
+	<tr><td>
+	<div class="imgedit-menu">
+		<div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php
+
+	// On some setups GD library does not provide imagerotate() - Ticket #11536
+	if ( function_exists('imagerotate') ) { ?>
+		<div class="imgedit-rleft"  onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div>
+		<div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div>
+<?php } else {
+		$note_gdlib = esc_attr__('Image rotation is not supported by your web host (function imagerotate() is missing)');
+?>
+	    <div class="imgedit-rleft disabled"  title="<?php echo $note_gdlib; ?>"></div>
+	    <div class="imgedit-rright disabled" title="<?php echo $note_gdlib; ?>"></div>
+<?php } ?>
+
+		<div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div>
+		<div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php esc_attr_e( 'Flip horizontally' ); ?>"></div>
+
+		<div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php esc_attr_e( 'Undo' ); ?>"></div>
+		<div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php esc_attr_e( 'Redo' ); ?>"></div>
+		<br class="clear" />
+	</div>
+
+	<input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
+	<input type="hidden" id="imgedit-minthumb-<?php echo $post_id; ?>" value="<?php echo ( get_option('thumbnail_size_w') . ':' . get_option('thumbnail_size_h') ); ?>" />
+	<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
+	<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
+	<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
+	<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo $meta['width']; ?>" />
+	<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo $meta['height']; ?>" />
+
+	<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
+	<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url('admin-ajax.php'); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
+	</div>
+
+	<div class="imgedit-submit">
+		<input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button" value="<?php esc_attr_e( 'Cancel' ); ?>" />
+		<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" />
+	</div>
+	</td>
+
+	<td class="imgedit-settings">
+	<div class="imgedit-group">
+	<div class="imgedit-group-top">
+		<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Scale Image'); ?></strong></a>
+		<div class="imgedit-help">
+		<p><?php _e('You can proportionally scale the original image. For best results the scaling should be done before performing any other operations on it like crop, rotate, etc. Note that if you make the image larger it may become fuzzy.'); ?></p>
+		<p><?php printf( __('Original dimensions %s'), $meta['width'] . '&times;' . $meta['height'] ); ?></p>
+		<div class="imgedit-submit">
+		<span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo $meta['width']; ?>" />&times;<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo $meta['height']; ?>" />
+		<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span></span>
+		<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" />
+		</div>
+		</div>
+	</div>
+
+<?php if ( $can_restore ) { ?>
+
+	<div class="imgedit-group-top">
+		<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Restore Original Image'); ?></strong></a>
+		<div class="imgedit-help">
+		<p><?php _e('Discard any changes and restore the original image.');
+
+		if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE )
+			echo ' '.__('Previously edited copies of the image will not be deleted.');
+
+		?></p>
+		<div class="imgedit-submit">
+		<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
+		</div>
+		</div>
+	</div>
+
+<?php } ?>
+
+	</div>
+
+	<div class="imgedit-group">
+	<div class="imgedit-group-top">
+		<strong><?php _e('Image Crop'); ?></strong>
+		<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
+		<div class="imgedit-help">
+		<p><?php _e('The image can be cropped by clicking on it and dragging to select the desired part. While dragging the dimensions of the selection are displayed below.'); ?></p>
+		<strong><?php _e('Keyboard Shortcuts'); ?></strong>
+		<ul>
+		<li><?php _e('Arrow: move by 10px'); ?></li>
+		<li><?php _e('Shift + arrow: move by 1px'); ?></li>
+		<li><?php _e('Ctrl + arrow: resize by 10px'); ?></li>
+		<li><?php _e('Ctrl + Shift + arrow: resize by 1px'); ?></li>
+		<li><?php _e('Shift + drag: lock aspect ratio'); ?></li>
+		</ul>
+
+		<p><strong><?php _e('Crop Aspect Ratio'); ?></strong><br />
+		<?php _e('You can specify the crop selection aspect ratio then hold down the Shift key while dragging to lock it. The values can be 1:1 (square), 4:3, 16:9, etc. If there is a selection, specifying aspect ratio will set it immediately.'); ?></p>
+
+		<p><strong><?php _e('Crop Selection'); ?></strong><br />
+		<?php _e('Once started, the selection can be adjusted by entering new values (in pixels). Note that these values are scaled to approximately match the original image dimensions. The minimum selection size equals the thumbnail size as set in the Media settings.'); ?></p>
+		</div>
+	</div>
+
+	<p>
+		<?php _e('Aspect ratio:'); ?>
+		<span  class="nowrap">
+		<input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" style="width:3em;" />
+		:
+		<input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" style="width:3em;" />
+		</span>
+	</p>
+
+	<p id="imgedit-crop-sel-<?php echo $post_id; ?>">
+		<?php _e('Selection:'); ?>
+		<span  class="nowrap">
+		<input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" style="width:4em;" />
+		:
+		<input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" style="width:4em;" />
+		</span>
+	</p>
+	</div>
+
+	<?php if ( $thumb && $sub_sizes ) {
+		$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
+	?>
+
+	<div class="imgedit-group imgedit-applyto">
+	<div class="imgedit-group-top">
+		<strong><?php _e('Thumbnail Settings'); ?></strong>
+		<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
+		<p class="imgedit-help"><?php _e('The thumbnail image can be cropped differently. For example it can be square or contain only a portion of the original image to showcase it better. Here you can select whether to apply changes to all image sizes or make the thumbnail different.'); ?></p>
+	</div>
+
+	<p>
+		<img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" /><br /><?php _e('Current thumbnail'); ?>
+	</p>
+
+	<p id="imgedit-save-target-<?php echo $post_id; ?>">
+		<strong><?php _e('Apply changes to:'); ?></strong><br />
+
+		<label class="imgedit-label">
+		<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
+		<?php _e('All image sizes'); ?></label>
+
+		<label class="imgedit-label">
+		<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
+		<?php _e('Thumbnail'); ?></label>
+
+		<label class="imgedit-label">
+		<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
+		<?php _e('All sizes except thumbnail'); ?></label>
+	</p>
+	</div>
+
+	<?php } ?>
+
+	</td></tr>
+	</tbody></table>
+	<div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
+	<script type="text/javascript">imageEdit.init(<?php echo $post_id; ?>);</script>
+	<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e("There are unsaved changes that will be lost.  'OK' to continue, 'Cancel' to return to the Image Editor."); ?></div>
+	</div>
+<?php
+}
+
+function load_image_to_edit($post_id, $mime_type, $size = 'full') {
+	$filepath = get_attached_file($post_id);
+
+	if ( $filepath && file_exists($filepath) ) {
+		if ( 'full' != $size && ( $data = image_get_intermediate_size($post_id, $size) ) ) {
+			$filepath = apply_filters('load_image_to_edit_filesystempath', path_join( dirname($filepath), $data['file'] ), $post_id, $size);
+		}
+	} elseif ( WP_Http_Fopen::test() ) {
+		$filepath = apply_filters('load_image_to_edit_attachmenturl', wp_get_attachment_url($post_id) , $post_id, $size);
+	}
+
+	$filepath = apply_filters('load_image_to_edit_path', $filepath, $post_id, $size);
+	if ( empty($filepath) )
+		return false;
+
+	switch ( $mime_type ) {
+		case 'image/jpeg':
+			$image = imagecreatefromjpeg($filepath);
+			break;
+		case 'image/png':
+			$image = imagecreatefrompng($filepath);
+			break;
+		case 'image/gif':
+			$image = imagecreatefromgif($filepath);
+			break;
+		default:
+			$image = false;
+			break;
+	}
+	if ( is_resource($image) ) {
+		$image = apply_filters('load_image_to_edit', $image, $post_id, $size);
+		if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
+			imagealphablending($image, false);
+			imagesavealpha($image, true);
+		}
+	}
+	return $image;
+}
+
+function wp_stream_image($image, $mime_type, $post_id) {
+	$image = apply_filters('image_save_pre', $image, $post_id);
+
+	switch ( $mime_type ) {
+		case 'image/jpeg':
+			header('Content-Type: image/jpeg');
+			return imagejpeg($image, null, 90);
+		case 'image/png':
+			header('Content-Type: image/png');
+			return imagepng($image);
+		case 'image/gif':
+			header('Content-Type: image/gif');
+			return imagegif($image);
+		default:
+			return false;
+	}
+}
+
+function wp_save_image_file($filename, $image, $mime_type, $post_id) {
+	$image = apply_filters('image_save_pre', $image, $post_id);
+	$saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id);
+	if ( null !== $saved )
+		return $saved;
+
+	switch ( $mime_type ) {
+		case 'image/jpeg':
+			return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
+		case 'image/png':
+			return imagepng($image, $filename);
+		case 'image/gif':
+			return imagegif($image, $filename);
+		default:
+			return false;
+	}
+}
+
+function _image_get_preview_ratio($w, $h) {
+	$max = max($w, $h);
+	return $max > 400 ? (400 / $max) : 1;
+}
+
+function _rotate_image_resource($img, $angle) {
+	if ( function_exists('imagerotate') ) {
+		$rotated = imagerotate($img, $angle, 0);
+		if ( is_resource($rotated) ) {
+			imagedestroy($img);
+			$img = $rotated;
+		}
+	}
+	return $img;
+}
+
+
+function _flip_image_resource($img, $horz, $vert) {
+	$w = imagesx($img);
+	$h = imagesy($img);
+	$dst = wp_imagecreatetruecolor($w, $h);
+	if ( is_resource($dst) ) {
+		$sx = $vert ? ($w - 1) : 0;
+		$sy = $horz ? ($h - 1) : 0;
+		$sw = $vert ? -$w : $w;
+		$sh = $horz ? -$h : $h;
+
+		if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) {
+			imagedestroy($img);
+			$img = $dst;
+		}
+	}
+	return $img;
+}
+
+function _crop_image_resource($img, $x, $y, $w, $h) {
+	$dst = wp_imagecreatetruecolor($w, $h);
+	if ( is_resource($dst) ) {
+		if ( imagecopy($dst, $img, 0, 0, $x, $y, $w, $h) ) {
+			imagedestroy($img);
+			$img = $dst;
+		}
+	}
+	return $img;
+}
+
+function image_edit_apply_changes($img, $changes) {
+
+	if ( !is_array($changes) )
+		return $img;
+
+	// expand change operations
+	foreach ( $changes as $key => $obj ) {
+		if ( isset($obj->r) ) {
+			$obj->type = 'rotate';
+			$obj->angle = $obj->r;
+			unset($obj->r);
+		} elseif ( isset($obj->f) ) {
+			$obj->type = 'flip';
+			$obj->axis = $obj->f;
+			unset($obj->f);
+		} elseif ( isset($obj->c) ) {
+			$obj->type = 'crop';
+			$obj->sel = $obj->c;
+			unset($obj->c);
+		}
+		$changes[$key] = $obj;
+	}
+
+	// combine operations
+	if ( count($changes) > 1 ) {
+		$filtered = array($changes[0]);
+		for ( $i = 0, $j = 1; $j < count($changes); $j++ ) {
+			$combined = false;
+			if ( $filtered[$i]->type == $changes[$j]->type ) {
+				switch ( $filtered[$i]->type ) {
+					case 'rotate':
+						$filtered[$i]->angle += $changes[$j]->angle;
+						$combined = true;
+						break;
+					case 'flip':
+						$filtered[$i]->axis ^= $changes[$j]->axis;
+						$combined = true;
+						break;
+				}
+			}
+			if ( !$combined )
+				$filtered[++$i] = $changes[$j];
+		}
+		$changes = $filtered;
+		unset($filtered);
+	}
+
+	// image resource before applying the changes
+	$img = apply_filters('image_edit_before_change', $img, $changes);
+
+	foreach ( $changes as $operation ) {
+		switch ( $operation->type ) {
+			case 'rotate':
+				if ( $operation->angle != 0 )
+					$img = _rotate_image_resource($img, $operation->angle);
+				break;
+			case 'flip':
+				if ( $operation->axis != 0 )
+					$img = _flip_image_resource($img, ($operation->axis & 1) != 0, ($operation->axis & 2) != 0);
+				break;
+			case 'crop':
+				$sel = $operation->sel;
+				$scale = 1 / _image_get_preview_ratio( imagesx($img), imagesy($img) ); // discard preview scaling
+				$img = _crop_image_resource($img, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale);
+				break;
+		}
+	}
+
+	return $img;
+}
+
+function stream_preview_image($post_id) {
+	$post = get_post($post_id);
+	@ini_set('memory_limit', '256M');
+	$img = load_image_to_edit( $post_id, $post->post_mime_type, array(400, 400) );
+
+	if ( !is_resource($img) )
+		return false;
+
+	$changes = !empty($_REQUEST['history']) ? json_decode( stripslashes($_REQUEST['history']) ) : null;
+	if ( $changes )
+		$img = image_edit_apply_changes($img, $changes);
+
+	// scale the image
+	$w = imagesx($img);
+	$h = imagesy($img);
+	$ratio = _image_get_preview_ratio($w, $h);
+	$w2 = $w * $ratio;
+	$h2 = $h * $ratio;
+
+	$preview = wp_imagecreatetruecolor($w2, $h2);
+	imagecopyresampled( $preview, $img, 0, 0, 0, 0, $w2, $h2, $w, $h );
+	wp_stream_image($preview, $post->post_mime_type, $post_id);
+
+	imagedestroy($preview);
+	imagedestroy($img);
+	return true;
+}
+
+function wp_restore_image($post_id) {
+	$meta = wp_get_attachment_metadata($post_id);
+	$file = get_attached_file($post_id);
+	$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
+	$restored = false;
+	$msg = new stdClass;
+
+	if ( !is_array($backup_sizes) ) {
+		$msg->error = __('Cannot load image metadata.');
+		return $msg;
+	}
+
+	$parts = pathinfo($file);
+	$suffix = time() . rand(100, 999);
+	$default_sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
+
+	if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) {
+		$data = $backup_sizes['full-orig'];
+
+		if ( $parts['basename'] != $data['file'] ) {
+			if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
+				// delete only if it's edited image
+				if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
+					$delpath = apply_filters('wp_delete_file', $file);
+					@unlink($delpath);
+				}
+			} else {
+				$backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']);
+			}
+		}
+
+		$restored_file = path_join($parts['dirname'], $data['file']);
+		$restored = update_attached_file($post_id, $restored_file);
+
+		$meta['file'] = _wp_relative_upload_path( $restored_file );
+		$meta['width'] = $data['width'];
+		$meta['height'] = $data['height'];
+		list ( $uwidth, $uheight ) = wp_constrain_dimensions($meta['width'], $meta['height'], 128, 96);
+		$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
+	}
+
+	foreach ( $default_sizes as $default_size ) {
+		if ( isset($backup_sizes["$default_size-orig"]) ) {
+			$data = $backup_sizes["$default_size-orig"];
+			if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) {
+				if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
+					// delete only if it's edited image
+					if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {
+						$delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) );
+						@unlink($delpath);
+					}
+				} else {
+					$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
+				}
+			}
+
+			$meta['sizes'][$default_size] = $data;
+		} else {
+			unset($meta['sizes'][$default_size]);
+		}
+	}
+
+	if ( !wp_update_attachment_metadata($post_id, $meta) || !update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes) ) {
+		$msg->error = __('Cannot save image metadata.');
+		return $msg;
+	}
+
+	if ( !$restored )
+		$msg->error = __('Image metadata is inconsistent.');
+	else
+		$msg->msg = __('Image restored successfully.');
+
+	return $msg;
+}
+
+function wp_save_image($post_id) {
+	$return = new stdClass;
+	$success = $delete = $scaled = $nocrop = false;
+	$post = get_post($post_id);
+	@ini_set('memory_limit', '256M');
+	$img = load_image_to_edit($post_id, $post->post_mime_type);
+
+	if ( !is_resource($img) ) {
+		$return->error = esc_js( __('Unable to create new image.') );
+		return $return;
+	}
+
+	$fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0;
+	$fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0;
+	$target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
+	$scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do'];
+
+	if ( $scale && $fwidth > 0 && $fheight > 0 ) {
+		$sX = imagesx($img);
+		$sY = imagesy($img);
+
+		// check if it has roughly the same w / h ratio
+		$diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2);
+		if ( -0.1 < $diff && $diff < 0.1 ) {
+			// scale the full size image
+			$dst = wp_imagecreatetruecolor($fwidth, $fheight);
+			if ( imagecopyresampled( $dst, $img, 0, 0, 0, 0, $fwidth, $fheight, $sX, $sY ) ) {
+				imagedestroy($img);
+				$img = $dst;
+				$scaled = true;
+			}
+		}
+
+		if ( !$scaled ) {
+			$return->error = esc_js( __('Error while saving the scaled image. Please reload the page and try again.') );
+			return $return;
+		}
+	} elseif ( !empty($_REQUEST['history']) ) {
+		$changes = json_decode( stripslashes($_REQUEST['history']) );
+		if ( $changes )
+			$img = image_edit_apply_changes($img, $changes);
+	} else {
+		$return->error = esc_js( __('Nothing to save, the image has not changed.') );
+		return $return;
+	}
+
+	$meta = wp_get_attachment_metadata($post_id);
+	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
+
+	if ( !is_array($meta) ) {
+		$return->error = esc_js( __('Image data does not exist. Please re-upload the image.') );
+		return $return;
+	}
+
+	if ( !is_array($backup_sizes) )
+		$backup_sizes = array();
+
+	// generate new filename
+	$path = get_attached_file($post_id);
+	$path_parts = pathinfo52( $path );
+	$filename = $path_parts['filename'];
+	$suffix = time() . rand(100, 999);
+
+	if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
+		isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) {
+
+		if ( 'thumbnail' == $target )
+			$new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}";
+		else
+			$new_path = $path;
+	} else {
+		while( true ) {
+			$filename = preg_replace( '/-e([0-9]+)$/', '', $filename );
+			$filename .= "-e{$suffix}";
+			$new_filename = "{$filename}.{$path_parts['extension']}";
+			$new_path = "{$path_parts['dirname']}/$new_filename";
+			if ( file_exists($new_path) )
+				$suffix++;
+			else
+				break;
+		}
+	}
+
+	// save the full-size file, also needed to create sub-sizes
+	if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) {
+		$return->error = esc_js( __('Unable to save the image.') );
+		return $return;
+	}
+
+	if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) {
+		$tag = false;
+		if ( isset($backup_sizes['full-orig']) ) {
+			if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] )
+				$tag = "full-$suffix";
+		} else {
+			$tag = 'full-orig';
+		}
+
+		if ( $tag )
+			$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
+
+		$success = update_attached_file($post_id, $new_path);
+
+		$meta['file'] = _wp_relative_upload_path($new_path);
+		$meta['width'] = imagesx($img);
+		$meta['height'] = imagesy($img);
+
+		list ( $uwidth, $uheight ) = wp_constrain_dimensions($meta['width'], $meta['height'], 128, 96);
+		$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
+
+		if ( $success && ('nothumb' == $target || 'all' == $target) ) {
+			$sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
+			if ( 'nothumb' == $target )
+				$sizes = array_diff( $sizes, array('thumbnail') );
+		}
+
+		$return->fw = $meta['width'];
+		$return->fh = $meta['height'];
+	} elseif ( 'thumbnail' == $target ) {
+		$sizes = array( 'thumbnail' );
+		$success = $delete = $nocrop = true;
+	}
+
+	if ( isset($sizes) ) {
+		foreach ( $sizes as $size ) {
+			$tag = false;
+			if ( isset($meta['sizes'][$size]) ) {
+				if ( isset($backup_sizes["$size-orig"]) ) {
+					if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] )
+						$tag = "$size-$suffix";
+				} else {
+					$tag = "$size-orig";
+				}
+
+				if ( $tag )
+					$backup_sizes[$tag] = $meta['sizes'][$size];
+			}
+
+			$crop = $nocrop ? false : get_option("{$size}_crop");
+			$resized = image_make_intermediate_size($new_path, get_option("{$size}_size_w"), get_option("{$size}_size_h"), $crop );
+
+			if ( $resized )
+				$meta['sizes'][$size] = $resized;
+			else
+				unset($meta['sizes'][$size]);
+		}
+	}
+
+	if ( $success ) {
+		wp_update_attachment_metadata($post_id, $meta);
+		update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
+
+		if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
+			$file_url = wp_get_attachment_url($post_id);
+			if ( $thumb = $meta['sizes']['thumbnail'] )
+				$return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
+			else
+				$return->thumbnail = "$file_url?w=128&h=128";
+		}
+	} else {
+		$delete = true;
+	}
+
+	if ( $delete ) {
+		$delpath = apply_filters('wp_delete_file', $new_path);
+		@unlink($delpath);
+	}
+
+	imagedestroy($img);
+
+	$return->msg = esc_js( __('Image saved') );
+	return $return;
+}
+
Index: /tags/3.1/wp-admin/includes/image.php
===================================================================
--- /tags/3.1/wp-admin/includes/image.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/image.php	(revision 17487)
@@ -0,0 +1,341 @@
+<?php
+/**
+ * File contains all the administration image manipulation functions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Create a thumbnail from an Image given a maximum side size.
+ *
+ * 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.
+ *
+ * @since 1.2.0
+ *
+ * @param mixed $file Filename of the original image, Or attachment id.
+ * @param int $max_side Maximum length of a single side for the thumbnail.
+ * @param mixed $deprecated Never used.
+ * @return string Thumbnail path on success, Error string on failure.
+ */
+function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '1.2' );
+	$thumbpath = image_resize( $file, $max_side, $max_side );
+	return apply_filters( 'wp_create_thumbnail', $thumbpath );
+}
+
+/**
+ * Crop an Image to a given size.
+ *
+ * @since 2.1.0
+ *
+ * @param string|int $src_file The source file or Attachment ID.
+ * @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 Optional. If the source crop points are absolute.
+ * @param string $dst_file Optional. The destination file to write to.
+ * @return string|WP_Error|false New filepath on success, WP_Error or false 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 ( is_numeric( $src_file ) ) // Handle int as attachment ID
+		$src_file = get_attached_file( $src_file );
+
+	$src = wp_load_image( $src_file );
+
+	if ( !is_resource( $src ) )
+		return new WP_Error( 'error_loading_image', $src, $src_file );
+
+	$dst = wp_imagecreatetruecolor( $dst_w, $dst_h );
+
+	if ( $src_abs ) {
+		$src_w -= $src_x;
+		$src_h -= $src_y;
+	}
+
+	if (function_exists('imageantialias'))
+		imageantialias( $dst, true );
+
+	imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
+
+	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 );
+
+	if ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) )
+		return $dst_file;
+	else
+		return false;
+}
+
+/**
+ * Generate post thumbnail attachment meta data.
+ *
+ * @since 2.1.0
+ *
+ * @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 )) && file_is_displayable_image($file) ) {
+		$imagesize = getimagesize( $file );
+		$metadata['width'] = $imagesize[0];
+		$metadata['height'] = $imagesize[1];
+		list($uwidth, $uheight) = wp_constrain_dimensions($metadata['width'], $metadata['height'], 128, 96);
+		$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
+
+		// Make the file path relative to the upload dir
+		$metadata['file'] = _wp_relative_upload_path($file);
+
+		// make thumbnails and other intermediate sizes
+		global $_wp_additional_image_sizes;
+
+		foreach ( get_intermediate_image_sizes() as $s ) {
+			$sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => FALSE );
+			if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
+				$sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
+			else
+				$sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
+			if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
+				$sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
+			else
+				$sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
+			if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
+				$sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes
+			else
+				$sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
+		}
+
+		$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
+
+		foreach ($sizes as $size => $size_data ) {
+			$resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['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, $attachment_id );
+}
+
+/**
+ * Calculated the new dimentions for a downsampled image.
+ *
+ * @since 2.0.0
+ * @see wp_constrain_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_constrain_dimensions( $width, $height, 128, 96 );
+}
+
+/**
+ * Convert a fraction string to a decimal.
+ *
+ * @since 2.5.0
+ *
+ * @param string $str
+ * @return int|float
+ */
+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.
+ *
+ * @since 2.5.0
+ *
+ * @param string $str
+ * @return int
+ */
+function wp_exif_date2ts($str) {
+	@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.
+ *
+ * Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
+ * created_timestamp, focal_length, shutter_speed, and title.
+ *
+ * The IPTC metadata that is retrieved is APP13, credit, byline, created date
+ * and time, caption, copyright, and title. Also includes FNumber, Model,
+ * DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
+ *
+ * @todo Try other exif libraries if available.
+ * @since 2.5.0
+ *
+ * @param string $file
+ * @return bool|array False on failure. Image metadata array on success.
+ */
+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'] );
+
+			// headline, "A brief synopsis of the caption."
+			if ( ! empty( $iptc['2#105'][0] ) )
+				$meta['title'] = utf8_encode( trim( $iptc['2#105'][0] ) );
+			// title, "Many use the Title field to store the filename of the image, though the field may be used in many ways."
+			elseif ( ! empty( $iptc['2#005'][0] ) )
+				$meta['title'] = utf8_encode( trim( $iptc['2#005'][0] ) );
+
+			if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
+				$caption = utf8_encode( trim( $iptc['2#120'][0] ) );
+				if ( empty( $meta['title'] ) ) {
+					// Assume the title is stored in 2:120 if it's short.
+					if ( strlen( $caption ) < 80 )
+						$meta['title'] = $caption;
+					else
+						$meta['caption'] = $caption;
+				} elseif ( $caption != $meta['title'] ) {
+					$meta['caption'] = $caption;
+				}
+			}
+
+			if ( ! empty( $iptc['2#110'][0] ) ) // credit
+				$meta['credit'] = utf8_encode(trim($iptc['2#110'][0]));
+			elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline
+				$meta['credit'] = utf8_encode(trim($iptc['2#080'][0]));
+
+			if ( ! empty( $iptc['2#055'][0] ) and ! empty( $iptc['2#060'][0] ) ) // created date and time
+				$meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
+
+			if ( ! empty( $iptc['2#116'][0] ) ) // copyright
+				$meta['copyright'] = utf8_encode( trim( $iptc['2#116'][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['Title'] ) )
+			$meta['title'] = utf8_encode( trim( $exif['Title'] ) );
+
+		if ( ! empty( $exif['ImageDescription'] ) ) {
+			if ( empty( $meta['title'] ) && strlen( $exif['ImageDescription'] ) < 80 ) {
+				// Assume the title is stored in ImageDescription
+				$meta['title'] = utf8_encode( trim( $exif['ImageDescription'] ) );
+				if ( ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] )
+					$meta['caption'] = utf8_encode( trim( $exif['COMPUTED']['UserComment'] ) );
+			} elseif ( trim( $exif['ImageDescription'] ) != $meta['title'] ) {
+				$meta['caption'] = utf8_encode( trim( $exif['ImageDescription'] ) );
+			}
+		} elseif ( ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
+			$meta['caption'] = utf8_encode( trim( $exif['Comments'] ) );
+		}
+
+		if ( ! empty( $exif['Artist'] ) )
+			$meta['credit'] = utf8_encode( trim( $exif['Artist'] ) );
+		elseif ( ! empty($exif['Author'] ) )
+			$meta['credit'] = utf8_encode( trim( $exif['Author'] ) );
+
+		if ( ! empty( $exif['Copyright'] ) )
+			$meta['copyright'] = utf8_encode( trim( $exif['Copyright'] ) );
+		if ( ! empty($exif['FNumber'] ) )
+			$meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
+		if ( ! empty($exif['Model'] ) )
+			$meta['camera'] = utf8_encode( 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'] = utf8_encode( trim( $exif['ISOSpeedRatings'] ) );
+		if ( ! empty($exif['ExposureTime'] ) )
+			$meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] );
+	}
+
+	return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
+
+}
+
+/**
+ * Validate that file is an image.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path File path to test if valid image.
+ * @return bool True if valid image, false if not valid image.
+ */
+function file_is_valid_image($path) {
+	$size = @getimagesize($path);
+	return !empty($size);
+}
+
+/**
+ * Validate that file is suitable for displaying within a web page.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'file_is_displayable_image' on $result and $path.
+ *
+ * @param string $path File path to test.
+ * @return bool True if suitable, false if not suitable.
+ */
+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;
+	else
+		$result = true;
+
+	return apply_filters('file_is_displayable_image', $result, $path);
+}
Index: /tags/3.1/wp-admin/includes/import.php
===================================================================
--- /tags/3.1/wp-admin/includes/import.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/import.php	(revision 17487)
@@ -0,0 +1,92 @@
+<?php
+/**
+ * WordPress Administration Importer API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Retrieve list of importers.
+ *
+ * @since 2.0.0
+ *
+ * @return array
+ */
+function get_importers() {
+	global $wp_importers;
+	if ( is_array($wp_importers) )
+		uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
+	return $wp_importers;
+}
+
+/**
+ * Register importer for WordPress.
+ *
+ * @since 2.0.0
+ *
+ * @param string $id Importer tag. Used to uniquely identify importer.
+ * @param string $name Importer name and title.
+ * @param string $description Importer description.
+ * @param callback $callback Callback to run.
+ * @return WP_Error Returns WP_Error when $callback is WP_Error.
+ */
+function register_importer( $id, $name, $description, $callback ) {
+	global $wp_importers;
+	if ( is_wp_error( $callback ) )
+		return $callback;
+	$wp_importers[$id] = array ( $name, $description, $callback );
+}
+
+/**
+ * Cleanup importer.
+ *
+ * Removes attachment based on ID.
+ *
+ * @since 2.0.0
+ *
+ * @param string $id Importer ID.
+ */
+function wp_import_cleanup( $id ) {
+	wp_delete_attachment( $id );
+}
+
+/**
+ * Handle importer uploading and add attachment.
+ *
+ * @since 2.0.0
+ *
+ * @return array Uploaded file's details on success, error message on failure
+ */
+function wp_import_handle_upload() {
+	if ( !isset($_FILES['import']) ) {
+		$file['error'] = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
+		return $file;
+	}
+
+	$overrides = array( 'test_form' => false, 'test_type' => false );
+	$_FILES['import']['name'] .= '.txt';
+	$file = wp_handle_upload( $_FILES['import'], $overrides );
+
+	if ( isset( $file['error'] ) )
+		return $file;
+
+	$url = $file['url'];
+	$type = $file['type'];
+	$file = $file['file'];
+	$filename = basename( $file );
+
+	// Construct the object array
+	$object = array( 'post_title' => $filename,
+		'post_content' => $url,
+		'post_mime_type' => $type,
+		'guid' => $url
+	);
+
+	// Save the data
+	$id = wp_insert_attachment( $object, $file );
+
+	return array( 'file' => $file, 'id' => $id );
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/internal-linking.php
===================================================================
--- /tags/3.1/wp-admin/includes/internal-linking.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/internal-linking.php	(revision 17487)
@@ -0,0 +1,124 @@
+<?php
+/**
+ * Internal linking functions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 3.1.0
+ */
+
+/**
+ * Performs post queries for internal linking.
+ *
+ * @since 3.1.0
+ *
+ * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments.
+ * @return array Results.
+ */
+function wp_link_query( $args = array() ) {
+	$pts = get_post_types( array( 'publicly_queryable' => true ), 'objects' );
+	$pt_names = array_keys( $pts );
+
+	$query = array(
+		'post_type' => $pt_names,
+		'suppress_filters' => true,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false,
+		'post_status' => 'publish',
+		'order' => 'DESC',
+		'orderby' => 'post_date',
+		'posts_per_page' => 20,
+	);
+
+	$args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1;
+
+	if ( isset( $args['s'] ) )
+		$query['s'] = $args['s'];
+
+	$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0;
+
+	// Do main query.
+	$get_posts = new WP_Query;
+	$posts = $get_posts->query( $query );
+	// Check if any posts were found.
+	if ( ! $get_posts->post_count )
+		return false;
+
+	// Build results.
+	$results = array();
+	foreach ( $posts as $post ) {
+		if ( 'post' == $post->post_type )
+			$info = mysql2date( __( 'Y/m/d' ), $post->post_date );
+		else
+			$info = $pts[ $post->post_type ]->labels->singular_name;
+
+		$results[] = array(
+			'ID' => $post->ID,
+			'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ),
+			'permalink' => get_permalink( $post->ID ),
+			'info' => $info,
+		);
+	}
+
+	return $results;
+}
+
+/**
+ * Dialog for internal linking.
+ *
+ * @since 3.1.0
+ */
+function wp_link_dialog() {
+?>
+<form id="wp-link" tabindex="-1">
+<?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?>
+<div id="link-selector">
+	<div id="link-options">
+		<p class="howto"><?php _e( 'Enter the destination URL' ); ?></p>
+		<div>
+			<label for="url-field"><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" tabindex="10" autocomplete="off" /></label>
+		</div>
+		<div>
+			<label for="link-title-field"><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" tabindex="20" autocomplete="off" /></label>
+		</div>
+		<div class="link-target">
+			<label for="link-target-checkbox"><input type="checkbox" id="link-target-checkbox" tabindex="30" /> <?php _e( 'Open link in a new window/tab' ); ?></label>
+		</div>
+	</div>
+	<?php $show_internal = '1' == get_user_setting( 'wplink', '0' ); ?>
+	<p class="howto toggle-arrow <?php if ( $show_internal ) echo 'toggle-arrow-active'; ?>" id="internal-toggle"><?php _e( 'Or link to existing content' ); ?></p>
+	<div id="search-panel"<?php if ( ! $show_internal ) echo ' style="display:none"'; ?>>
+		<div class="link-search-wrapper">
+			<label for="search-field">
+				<span><?php _e( 'Search' ); ?></span>
+				<input type="text" id="search-field" class="link-search-field" tabindex="60" autocomplete="off" />
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+			</label>
+		</div>
+		<div id="search-results" class="query-results">
+			<ul></ul>
+			<div class="river-waiting">
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+			</div>
+		</div>
+		<div id="most-recent-results" class="query-results">
+			<div class="query-notice"><em><?php _e( 'No search term specified. Showing recent items.' ); ?></em></div>
+			<ul></ul>
+			<div class="river-waiting">
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+			</div>
+		</div>
+	</div>
+</div>
+<div class="submitbox">
+	<div id="wp-link-cancel">
+		<a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>
+	</div>
+	<div id="wp-link-update">
+		<?php submit_button( __('Update'), 'primary', 'wp-link-submit', false, array('tabindex' => 100)); ?>
+	</div>
+</div>
+</form>
+<?php
+}
+?>
Index: /tags/3.1/wp-admin/includes/list-table.php
===================================================================
--- /tags/3.1/wp-admin/includes/list-table.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/list-table.php	(revision 17487)
@@ -0,0 +1,104 @@
+<?php
+/**
+ * Helper functions for displaying a list of items in an ajaxified HTML table.
+ *
+ * @package WordPress
+ * @subpackage List_Table
+ * @since 3.1.0
+ */
+
+/**
+ * Fetch an instance of a WP_List_Table class.
+ *
+ * @access private
+ * @since 3.1.0
+ *
+ * @param string $class The type of the list table, which is the class name.
+ * @return object|bool Object on success, false if the class does not exist.
+ */
+function _get_list_table( $class ) {
+	$core_classes = array(
+		//Site Admin
+		'WP_Posts_List_Table' => 'posts',
+		'WP_Media_List_Table' => 'media',
+		'WP_Terms_List_Table' => 'terms',
+		'WP_Users_List_Table' => 'users',
+		'WP_Comments_List_Table' => 'comments',
+		'WP_Post_Comments_List_Table' => 'comments',
+		'WP_Links_List_Table' => 'links',
+		'WP_Plugin_Install_List_Table' => 'plugin-install',
+		'WP_Themes_List_Table' => 'themes',
+		'WP_Theme_Install_List_Table' => 'theme-install',
+		'WP_Plugins_List_Table' => 'plugins',
+		// Network Admin
+		'WP_MS_Sites_List_Table' => 'ms-sites',
+		'WP_MS_Users_List_Table' => 'ms-users',
+		'WP_MS_Themes_List_Table' => 'ms-themes',
+	);
+
+	if ( isset( $core_classes[ $class ] ) ) {
+		require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $core_classes[ $class ] . '-list-table.php' );
+		return new $class;
+	}
+
+	return false;
+}
+
+/**
+ * Register column headers for a particular screen.
+ *
+ * @since 2.7.0
+ *
+ * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
+ * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
+ * @see get_column_headers(), print_column_headers(), get_hidden_columns()
+ */
+function register_column_headers($screen, $columns) {
+	$wp_list_table = new _WP_List_Table_Compat($screen, $columns);
+}
+
+/**
+ * Prints column headers for a particular screen.
+ *
+ * @since 2.7.0
+ */
+function print_column_headers($screen, $id = true) {
+	$wp_list_table = new _WP_List_Table_Compat($screen);
+
+	$wp_list_table->print_column_headers($id);
+}
+
+/**
+ * Helper class to be used only by back compat functions
+ *
+ * @since 3.1.0
+ */
+class _WP_List_Table_Compat extends WP_List_Table {
+	var $_screen;
+	var $_columns;
+
+	function _WP_List_Table_Compat( $screen, $columns = array() ) {
+		if ( is_string( $screen ) )
+			$screen = convert_to_screen( $screen );
+
+		$this->_screen = $screen;
+
+		if ( !empty( $columns ) ) {
+			$this->_columns = $columns;
+			add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
+		}
+	}
+
+	function get_column_info() {
+		$columns = get_column_headers( $this->_screen );
+		$hidden = get_hidden_columns( $this->_screen );
+		$sortable = array();
+
+		return array( $columns, $hidden, $sortable );
+	}
+
+	function get_columns() {
+		return $this->_columns;
+	}
+}
+?>
Index: /tags/3.1/wp-admin/includes/manifest.php
===================================================================
--- /tags/3.1/wp-admin/includes/manifest.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/manifest.php	(revision 17487)
@@ -0,0 +1,203 @@
+<?php
+
+if ( !defined('ABSPATH') )
+	exit;
+
+require(ABSPATH . 'wp-includes/version.php');
+
+$man_version = md5( $tinymce_version . $manifest_version );
+$mce_ver = "ver=$tinymce_version";
+
+/**
+ * Retrieve list of all cacheable WP files
+ *
+ * Array format: file, version (optional), bool (whether to use src and set ignoreQuery, defaults to true)
+ */
+function &get_manifest() {
+	global $mce_ver;
+
+	$files = array(
+		array('images/align-center.png'),
+		array('images/align-left.png'),
+		array('images/align-none.png'),
+		array('images/align-right.png'),
+		array('images/archive-link.png'),
+		array('images/blue-grad.png'),
+		array('images/bubble_bg.gif'),
+		array('images/bubble_bg-rtl.gif'),
+		array('images/button-grad.png'),
+		array('images/button-grad-active.png'),
+		array('images/comment-grey-bubble.png'),
+		array('images/date-button.gif'),
+		array('images/ed-bg.gif'),
+		array('images/fade-butt.png'),
+		array('images/fav.png'),
+		array('images/fav-arrow.gif'),
+		array('images/fav-arrow-rtl.gif'),
+		array('images/generic.png'),
+		array('images/gray-grad.png'),
+		array('images/icons32.png'),
+		array('images/icons32-vs.png'),
+		array('images/list.png'),
+		array('images/wpspin_light.gif'),
+		array('images/wpspin_dark.gif'),
+		array('images/logo.gif'),
+		array('images/logo-ghost.png'),
+		array('images/logo-login.gif'),
+		array('images/media-button-image.gif'),
+		array('images/media-button-music.gif'),
+		array('images/media-button-other.gif'),
+		array('images/media-button-video.gif'),
+		array('images/menu.png'),
+		array('images/menu-vs.png'),
+		array('images/menu-arrows.gif'),
+		array('images/menu-bits.gif'),
+		array('images/menu-bits-rtl.gif'),
+		array('images/menu-dark.gif'),
+		array('images/menu-dark-rtl.gif'),
+		array('images/no.png'),
+		array('images/required.gif'),
+		array('images/resize.gif'),
+		array('images/screen-options-right.gif'),
+		array('images/screen-options-right-up.gif'),
+		array('images/se.png'),
+		array('images/star.gif'),
+		array('images/toggle-arrow.gif'),
+		array('images/toggle-arrow-rtl.gif'),
+		array('images/white-grad.png'),
+		array('images/white-grad-active.png'),
+		array('images/wordpress-logo.png'),
+		array('images/wp-logo.png'),
+		array('images/xit.gif'),
+		array('images/yes.png'),
+		array('../wp-includes/images/crystal/archive.png'),
+		array('../wp-includes/images/crystal/audio.png'),
+		array('../wp-includes/images/crystal/code.png'),
+		array('../wp-includes/images/crystal/default.png'),
+		array('../wp-includes/images/crystal/document.png'),
+		array('../wp-includes/images/crystal/interactive.png'),
+		array('../wp-includes/images/crystal/text.png'),
+		array('../wp-includes/images/crystal/video.png'),
+		array('../wp-includes/images/crystal/spreadsheet.png'),
+		array('../wp-includes/images/rss.png'),
+		array('../wp-includes/images/blank.gif'),
+		array('../wp-includes/images/upload.png'),
+		array('../wp-includes/js/thickbox/loadingAnimation.gif'),
+		array('../wp-includes/js/thickbox/tb-close.png'),
+	);
+
+	if ( @is_file('../wp-includes/js/tinymce/tiny_mce.js') ) :
+	$mce = array(
+		array('../wp-includes/js/tinymce/wp-tinymce.php', $mce_ver),
+
+		array('../wp-includes/js/tinymce/tiny_mce.js', $mce_ver),
+		array('../wp-includes/js/tinymce/langs/wp-langs-en.js', $mce_ver),
+		array('../wp-includes/js/tinymce/utils/mctabs.js', $mce_ver),
+		array('../wp-includes/js/tinymce/utils/validate.js', $mce_ver),
+		array('../wp-includes/js/tinymce/utils/form_utils.js', $mce_ver),
+		array('../wp-includes/js/tinymce/utils/editable_selects.js', $mce_ver),
+		array('../wp-includes/js/tinymce/tiny_mce_popup.js', $mce_ver),
+
+		array('../wp-includes/js/tinymce/themes/advanced/editor_template.js', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/source_editor.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/anchor.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/image.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/link.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/color_picker.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/charmap.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/js/color_picker.js', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/js/charmap.js', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/js/image.js', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/js/link.js', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/js/source_editor.js', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/js/anchor.js', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css', $mce_ver),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/template.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/media/editor_plugin.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/media/js/media.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/media/media.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/media/css/content.css', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/media/css/media.css', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/paste/editor_plugin.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/paste/js/pasteword.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/paste/js/pastetext.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/paste/pasteword.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/paste/blank.htm', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/paste/pastetext.htm', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/safari/editor_plugin.js', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/spellchecker/css/content.css', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/wordpress/css/content.css', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css', $mce_ver),
+		array('../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css', $mce_ver),
+
+		array('../wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js', $mce_ver),
+
+		array('../wp-includes/js/tinymce/themes/advanced/img/icons.gif'),
+		array('../wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg'),
+		array('../wp-includes/js/tinymce/themes/advanced/img/fm.gif'),
+		array('../wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png'),
+		array('../wp-includes/js/tinymce/themes/advanced/img/sflogo.png'),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png'),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png'),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif'),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif'),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif'),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif'),
+		array('../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/drag.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/button.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif'),
+		array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif'),
+		array('../wp-includes/js/tinymce/plugins/media/img/flash.gif'),
+		array('../wp-includes/js/tinymce/plugins/media/img/quicktime.gif'),
+		array('../wp-includes/js/tinymce/plugins/media/img/realmedia.gif'),
+		array('../wp-includes/js/tinymce/plugins/media/img/shockwave.gif'),
+		array('../wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif'),
+		array('../wp-includes/js/tinymce/plugins/media/img/trans.gif'),
+		array('../wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/more.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/page.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/help.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/image.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/media.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/video.gif'),
+		array('../wp-includes/js/tinymce/plugins/wordpress/img/audio.gif'),
+		array('../wp-includes/js/tinymce/plugins/wpeditimage/img/image.png'),
+		array('../wp-includes/js/tinymce/plugins/wpeditimage/img/delete.png'),
+		array('../wp-includes/js/tinymce/plugins/wpgallery/img/delete.png'),
+		array('../wp-includes/js/tinymce/plugins/wpgallery/img/edit.png'),
+		array('../wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png')
+	);
+	$files = array_merge($files, $mce);
+	endif;
+
+	return $files;
+}
Index: /tags/3.1/wp-admin/includes/media.php
===================================================================
--- /tags/3.1/wp-admin/includes/media.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/media.php	(revision 17487)
@@ -0,0 +1,2324 @@
+<?php
+/**
+ * WordPress Administration Media API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_tabs() {
+	$_default_tabs = array(
+		'type' => __('From Computer'), // handler action suffix => tab text
+		'type_url' => __('From URL'),
+		'gallery' => __('Gallery'),
+		'library' => __('Media Library')
+	);
+
+	return apply_filters('media_upload_tabs', $_default_tabs);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $tabs
+ * @return unknown
+ */
+function update_gallery_tab($tabs) {
+	global $wpdb;
+
+	if ( !isset($_REQUEST['post_id']) ) {
+		unset($tabs['gallery']);
+		return $tabs;
+	}
+
+	$post_id = intval($_REQUEST['post_id']);
+
+	if ( $post_id )
+		$attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) );
+
+	if ( empty($attachments) ) {
+		unset($tabs['gallery']);
+		return $tabs;
+	}
+
+	$tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>");
+
+	return $tabs;
+}
+add_filter('media_upload_tabs', 'update_gallery_tab');
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ */
+function the_media_upload_tabs() {
+	global $redir_tab;
+	$tabs = media_upload_tabs();
+
+	if ( !empty($tabs) ) {
+		echo "<ul id='sidemenu'>\n";
+		if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) )
+			$current = $redir_tab;
+		elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) )
+			$current = $_GET['tab'];
+		else
+			$current = apply_filters('media_upload_default_tab', 'type');
+
+		foreach ( $tabs as $callback => $text ) {
+			$class = '';
+			if ( $current == $callback )
+				$class = " class='current'";
+			$href = add_query_arg(array('tab'=>$callback, 's'=>false, 'paged'=>false, 'post_mime_type'=>false, 'm'=>false));
+			$link = "<a href='" . esc_url($href) . "'$class>$text</a>";
+			echo "\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n";
+		}
+		echo "</ul>\n";
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $id
+ * @param unknown_type $alt
+ * @param unknown_type $title
+ * @param unknown_type $align
+ * @param unknown_type $url
+ * @param unknown_type $rel
+ * @param unknown_type $size
+ * @return unknown
+ */
+function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = false, $size='medium', $alt = '') {
+
+	$html = get_image_tag($id, $alt, $title, $align, $size);
+
+	$rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : '';
+
+	if ( $url )
+		$html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>";
+
+	$html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt );
+
+	return $html;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.6.0
+ *
+ * @param unknown_type $html
+ * @param unknown_type $id
+ * @param unknown_type $alt
+ * @param unknown_type $title
+ * @param unknown_type $align
+ * @param unknown_type $url
+ * @param unknown_type $size
+ * @return unknown
+ */
+function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
+
+	if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
+		return $html;
+
+	$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
+
+	if ( ! preg_match( '/width="([0-9]+)/', $html, $matches ) )
+		return $html;
+
+	$width = $matches[1];
+
+	$caption = str_replace(	array( '>',    '<',    '"',      "'" ),
+							array( '&gt;', '&lt;', '&quot;', '&#039;' ),
+							$caption
+						  );
+
+	$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
+	if ( empty($align) )
+		$align = 'none';
+
+	$shcode = '[caption id="' . $id . '" align="align' . $align
+	. '" width="' . $width . '" caption="' . addslashes($caption) . '"]' . $html . '[/caption]';
+
+	return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
+}
+add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $html
+ */
+function media_send_to_editor($html) {
+?>
+<script type="text/javascript">
+/* <![CDATA[ */
+var win = window.dialogArguments || opener || parent || top;
+win.send_to_editor('<?php echo addslashes($html); ?>');
+/* ]]> */
+</script>
+<?php
+	exit;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * This handles the file upload POST itself, creating the attachment post.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file_id Index into the {@link $_FILES} array of the upload
+ * @param int $post_id The post ID the media is associated with
+ * @param array $post_data allows you to overwrite some of the attachment
+ * @param array $overrides allows you to override the {@link wp_handle_upload()} behavior
+ * @return int the ID of the attachment
+ */
+function media_handle_upload($file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false )) {
+
+	$time = current_time('mysql');
+	if ( $post = get_post($post_id) ) {
+		if ( substr( $post->post_date, 0, 4 ) > 0 )
+			$time = $post->post_date;
+	}
+
+	$name = $_FILES[$file_id]['name'];
+	$file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
+
+	if ( isset($file['error']) )
+		return new WP_Error( 'upload_error', $file['error'] );
+
+	$name_parts = pathinfo($name);
+	$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
+
+	$url = $file['url'];
+	$type = $file['type'];
+	$file = $file['file'];
+	$title = $name;
+	$content = '';
+
+	// use image exif/iptc data for title and caption defaults if possible
+	if ( $image_meta = @wp_read_image_metadata($file) ) {
+		if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
+			$title = $image_meta['title'];
+		if ( trim( $image_meta['caption'] ) )
+			$content = $image_meta['caption'];
+	}
+
+	// Construct the attachment array
+	$attachment = array_merge( array(
+		'post_mime_type' => $type,
+		'guid' => $url,
+		'post_parent' => $post_id,
+		'post_title' => $title,
+		'post_content' => $content,
+	), $post_data );
+
+	// Save the data
+	$id = wp_insert_attachment($attachment, $file, $post_id);
+	if ( !is_wp_error($id) ) {
+		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
+	}
+
+	return $id;
+
+}
+
+/**
+ * This handles a sideloaded file in the same way as an uploaded file is handled by {@link media_handle_upload()}
+ *
+ * @since 2.6.0
+ *
+ * @param array $file_array Array similar to a {@link $_FILES} upload array
+ * @param int $post_id The post ID the media is associated with
+ * @param string $desc Description of the sideloaded file
+ * @param array $post_data allows you to overwrite some of the attachment
+ * @return int|object The ID of the attachment or a WP_Error on failure
+ */
+function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
+	$overrides = array('test_form'=>false);
+
+	$file = wp_handle_sideload($file_array, $overrides);
+	if ( isset($file['error']) )
+		return new WP_Error( 'upload_error', $file['error'] );
+
+	$url = $file['url'];
+	$type = $file['type'];
+	$file = $file['file'];
+	$title = preg_replace('/\.[^.]+$/', '', basename($file));
+	$content = '';
+
+	// use image exif/iptc data for title and caption defaults if possible
+	if ( $image_meta = @wp_read_image_metadata($file) ) {
+		if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
+			$title = $image_meta['title'];
+		if ( trim( $image_meta['caption'] ) )
+			$content = $image_meta['caption'];
+	}
+
+	$title = isset($desc) ? $desc : '';
+
+	// Construct the attachment array
+	$attachment = array_merge( array(
+		'post_mime_type' => $type,
+		'guid' => $url,
+		'post_parent' => $post_id,
+		'post_title' => $title,
+		'post_content' => $content,
+	), $post_data );
+
+	// Save the attachment metadata
+	$id = wp_insert_attachment($attachment, $file, $post_id);
+	if ( !is_wp_error($id) )
+		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
+
+	return $id;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Wrap iframe content (produced by $content_func) in a doctype, html head/body
+ * etc any additional function args will be passed to content_func.
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $content_func
+ */
+function wp_iframe($content_func /* ... */) {
+?>
+<!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') ?> &rsaquo; <?php _e('Uploads'); ?> &#8212; <?php _e('WordPress'); ?></title>
+<?php
+wp_enqueue_style( 'global' );
+wp_enqueue_style( 'wp-admin' );
+wp_enqueue_style( 'colors' );
+// Check callback name for 'media'
+if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
+	|| ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) )
+	wp_enqueue_style( 'media' );
+wp_enqueue_style( 'ie' );
+?>
+<script type="text/javascript">
+//<![CDATA[
+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();}}};
+var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'};
+var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
+isRtl = <?php echo (int) is_rtl(); ?>;
+//]]>
+</script>
+<?php
+do_action('admin_enqueue_scripts', 'media-upload-popup');
+do_action('admin_print_styles-media-upload-popup');
+do_action('admin_print_styles');
+do_action('admin_print_scripts-media-upload-popup');
+do_action('admin_print_scripts');
+do_action('admin_head-media-upload-popup');
+do_action('admin_head');
+
+if ( is_string($content_func) )
+	do_action( "admin_head_{$content_func}" );
+?>
+</head>
+<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
+<?php
+	$args = func_get_args();
+	$args = array_slice($args, 1);
+	call_user_func_array($content_func, $args);
+
+	do_action('admin_print_footer_scripts');
+?>
+<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
+</body>
+</html>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ */
+function media_buttons() {
+	$do_image = $do_audio = $do_video = true;
+	if ( is_multisite() ) {
+		$media_buttons = get_site_option( 'mu_media_buttons' );
+		if ( empty($media_buttons['image']) )
+			$do_image = false;
+		if ( empty($media_buttons['audio']) )
+			$do_audio = false;
+		if ( empty($media_buttons['video']) )
+			$do_video = false;
+	}
+	$out = '';
+
+	if ( $do_image )
+		$out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image');
+	if ( $do_video )
+		$out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video');
+	if ( $do_audio )
+		$out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio');
+
+	$out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media');
+
+	$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
+
+	printf($context, $out);
+}
+add_action( 'media_buttons', 'media_buttons' );
+
+function _media_button($title, $icon, $type) {
+	return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='add_$type' class='thickbox' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' onclick='return false;' /></a>";
+}
+
+function get_upload_iframe_src($type) {
+	global $post_ID, $temp_ID;
+	$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
+	$upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
+
+	if ( 'media' != $type )
+		$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
+	$upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
+
+	return add_query_arg('TB_iframe', true, $upload_iframe_src);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_form_handler() {
+	check_admin_referer('media-form');
+
+	$errors = null;
+
+	if ( isset($_POST['send']) ) {
+		$keys = array_keys($_POST['send']);
+		$send_id = (int) array_shift($keys);
+	}
+
+	if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
+		$post = $_post = get_post($attachment_id, ARRAY_A);
+		if ( isset($attachment['post_content']) )
+			$post['post_content'] = $attachment['post_content'];
+		if ( isset($attachment['post_title']) )
+			$post['post_title'] = $attachment['post_title'];
+		if ( isset($attachment['post_excerpt']) )
+			$post['post_excerpt'] = $attachment['post_excerpt'];
+		if ( isset($attachment['menu_order']) )
+			$post['menu_order'] = $attachment['menu_order'];
+
+		if ( isset($send_id) && $attachment_id == $send_id ) {
+			if ( isset($attachment['post_parent']) )
+				$post['post_parent'] = $attachment['post_parent'];
+		}
+
+		$post = apply_filters('attachment_fields_to_save', $post, $attachment);
+
+		if ( isset($attachment['image_alt']) ) {
+			$image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
+			if ( $image_alt != stripslashes($attachment['image_alt']) ) {
+				$image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true );
+				// update_meta expects slashed
+				update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) );
+			}
+		}
+
+		if ( isset($post['errors']) ) {
+			$errors[$attachment_id] = $post['errors'];
+			unset($post['errors']);
+		}
+
+		if ( $post != $_post )
+			wp_update_post($post);
+
+		foreach ( get_attachment_taxonomies($post) as $t ) {
+			if ( isset($attachment[$t]) )
+				wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
+		}
+	}
+
+	if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
+		<script type="text/javascript">
+		/* <![CDATA[ */
+		var win = window.dialogArguments || opener || parent || top;
+		win.tb_remove();
+		/* ]]> */
+		</script>
+		<?php
+		exit;
+	}
+
+	if ( isset($send_id) ) {
+		$attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
+
+		$html = $attachment['post_title'];
+		if ( !empty($attachment['url']) ) {
+			$rel = '';
+			if ( strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'] )
+				$rel = " rel='attachment wp-att-" . esc_attr($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);
+	}
+
+	return $errors;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_image() {
+	$errors = array();
+	$id = 0;
+
+	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
+		// Upload File button was clicked
+		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
+		unset($_FILES);
+		if ( is_wp_error($id) ) {
+			$errors['upload_error'] = $id;
+			$id = false;
+		}
+	}
+
+	if ( !empty($_POST['insertonlybutton']) ) {
+		$alt = $align = '';
+
+		$src = $_POST['insertonly']['src'];
+		if ( !empty($src) && !strpos($src, '://') )
+			$src = "http://$src";
+		$alt = esc_attr($_POST['insertonly']['alt']);
+		if ( isset($_POST['insertonly']['align']) ) {
+			$align = esc_attr($_POST['insertonly']['align']);
+			$class = " class='align$align'";
+		}
+		if ( !empty($src) )
+			$html = "<img src='" . esc_url($src) . "' alt='$alt'$class />";
+
+		$html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);
+		return media_send_to_editor($html);
+	}
+
+	if ( !empty($_POST) ) {
+		$return = media_upload_form_handler();
+
+		if ( is_string($return) )
+			return $return;
+		if ( is_array($return) )
+			$errors = $return;
+	}
+
+	if ( isset($_POST['save']) ) {
+		$errors['upload_notice'] = __('Saved.');
+		return media_upload_gallery();
+	}
+
+	if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+		return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
+
+	return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
+}
+
+/**
+ * Download an image from the specified URL and attach it to a post.
+ *
+ * @since 2.6.0
+ *
+ * @param string $file The URL of the image to download
+ * @param int $post_id The post ID the media is to be associated with
+ * @param string $desc Optional. Description of the image
+ * @return string|WP_Error Populated HTML img tag on success
+ */
+function media_sideload_image($file, $post_id, $desc = null) {
+	if ( ! empty($file) ) {
+		// Download file to temp location
+		$tmp = download_url( $file );
+
+		// Set variables for storage
+		// fix file filename for query strings
+		preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
+		$file_array['name'] = basename($matches[0]);
+		$file_array['tmp_name'] = $tmp;
+
+		// If error storing temporarily, unlink
+		if ( is_wp_error( $tmp ) ) {
+			@unlink($file_array['tmp_name']);
+			$file_array['tmp_name'] = '';
+		}
+
+		// do the validation and storage stuff
+		$id = media_handle_sideload( $file_array, $post_id, $desc );
+		// If error storing permanently, unlink
+		if ( is_wp_error($id) ) {
+			@unlink($file_array['tmp_name']);
+			return $id;
+		}
+
+		$src = wp_get_attachment_url( $id );
+	}
+
+	// Finally check to make sure the file has been saved, then return the html
+	if ( ! empty($src) ) {
+		$alt = isset($desc) ? esc_attr($desc) : '';
+		$html = "<img src='$src' alt='$alt' />";
+		return $html;
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_audio() {
+	$errors = array();
+	$id = 0;
+
+	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
+		// Upload File button was clicked
+		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
+		unset($_FILES);
+		if ( is_wp_error($id) ) {
+			$errors['upload_error'] = $id;
+			$id = false;
+		}
+	}
+
+	if ( !empty($_POST['insertonlybutton']) ) {
+		$href = $_POST['insertonly']['href'];
+		if ( !empty($href) && !strpos($href, '://') )
+			$href = "http://$href";
+
+		$title = esc_attr($_POST['insertonly']['title']);
+		if ( empty($title) )
+            $title = esc_attr( basename($href) );
+
+		if ( !empty($title) && !empty($href) )
+            $html = "<a href='" . esc_url($href) . "' >$title</a>";
+
+		$html = apply_filters('audio_send_to_editor_url', $html, $href, $title);
+
+		return media_send_to_editor($html);
+	}
+
+	if ( !empty($_POST) ) {
+		$return = media_upload_form_handler();
+
+		if ( is_string($return) )
+			return $return;
+		if ( is_array($return) )
+			$errors = $return;
+	}
+
+	if ( isset($_POST['save']) ) {
+		$errors['upload_notice'] = __('Saved.');
+		return media_upload_gallery();
+	}
+
+	if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+		return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id );
+
+	return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_video() {
+	$errors = array();
+	$id = 0;
+
+	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
+		// Upload File button was clicked
+		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
+		unset($_FILES);
+		if ( is_wp_error($id) ) {
+			$errors['upload_error'] = $id;
+			$id = false;
+		}
+	}
+
+	if ( !empty($_POST['insertonlybutton']) ) {
+		$href = $_POST['insertonly']['href'];
+		if ( !empty($href) && !strpos($href, '://') )
+			$href = "http://$href";
+
+		$title = esc_attr($_POST['insertonly']['title']);
+        if ( empty($title) )
+            $title = esc_attr( basename($href) );
+
+		if ( !empty($title) && !empty($href) )
+            $html = "<a href='" . esc_url($href) . "' >$title</a>";
+
+		$html = apply_filters('video_send_to_editor_url', $html, $href, $title);
+
+		return media_send_to_editor($html);
+	}
+
+	if ( !empty($_POST) ) {
+		$return = media_upload_form_handler();
+
+		if ( is_string($return) )
+			return $return;
+		if ( is_array($return) )
+			$errors = $return;
+	}
+
+	if ( isset($_POST['save']) ) {
+		$errors['upload_notice'] = __('Saved.');
+		return media_upload_gallery();
+	}
+
+	if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+		return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id );
+
+	return wp_iframe( 'media_upload_type_form', 'video', $errors, $id );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_file() {
+	$errors = array();
+	$id = 0;
+
+	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
+		// Upload File button was clicked
+		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
+		unset($_FILES);
+		if ( is_wp_error($id) ) {
+			$errors['upload_error'] = $id;
+			$id = false;
+		}
+	}
+
+	if ( !empty($_POST['insertonlybutton']) ) {
+		$href = $_POST['insertonly']['href'];
+		if ( !empty($href) && !strpos($href, '://') )
+			$href = "http://$href";
+
+		$title = esc_attr($_POST['insertonly']['title']);
+		if ( empty($title) )
+			$title = basename($href);
+		if ( !empty($title) && !empty($href) )
+			$html = "<a href='" . esc_url($href) . "' >$title</a>";
+		$html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
+		return media_send_to_editor($html);
+	}
+
+	if ( !empty($_POST) ) {
+		$return = media_upload_form_handler();
+
+		if ( is_string($return) )
+			return $return;
+		if ( is_array($return) )
+			$errors = $return;
+	}
+
+	if ( isset($_POST['save']) ) {
+		$errors['upload_notice'] = __('Saved.');
+		return media_upload_gallery();
+	}
+
+	if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
+		return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id );
+
+	return wp_iframe( 'media_upload_type_form', 'file', $errors, $id );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_gallery() {
+	$errors = array();
+
+	if ( !empty($_POST) ) {
+		$return = media_upload_form_handler();
+
+		if ( is_string($return) )
+			return $return;
+		if ( is_array($return) )
+			$errors = $return;
+	}
+
+	wp_enqueue_script('admin-gallery');
+	return wp_iframe( 'media_upload_gallery_form', $errors );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+function media_upload_library() {
+	$errors = array();
+	if ( !empty($_POST) ) {
+		$return = media_upload_form_handler();
+
+		if ( is_string($return) )
+			return $return;
+		if ( is_array($return) )
+			$errors = $return;
+	}
+
+	return wp_iframe( 'media_upload_library_form', $errors );
+}
+
+/**
+ * Retrieve HTML for the image alignment radio buttons with the specified one checked.
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $post
+ * @param unknown_type $checked
+ * @return unknown
+ */
+function image_align_input_fields( $post, $checked = '' ) {
+
+	if ( empty($checked) )
+		$checked = get_user_setting('align', 'none');
+
+	$alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right'));
+	if ( !array_key_exists( (string) $checked, $alignments ) )
+		$checked = 'none';
+
+	$out = array();
+	foreach ( $alignments as $name => $label ) {
+		$name = esc_attr($name);
+		$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'".
+		 	( $checked == $name ? " checked='checked'" : "" ) .
+			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
+	}
+	return join("\n", $out);
+}
+
+/**
+ * Retrieve HTML for the size radio buttons with the specified one checked.
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $post
+ * @param unknown_type $check
+ * @return unknown
+ */
+function image_size_input_fields( $post, $check = '' ) {
+
+		// get a list of the actual pixel dimensions of each possible intermediate version of this image
+		$size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'));
+
+		if ( empty($check) )
+			$check = get_user_setting('imgsize', 'medium');
+
+		foreach ( $size_names as $size => $label ) {
+			$downsize = image_downsize($post->ID, $size);
+			$checked = '';
+
+			// is this size selectable?
+			$enabled = ( $downsize[3] || 'full' == $size );
+			$css_id = "image-size-{$size}-{$post->ID}";
+			// if this size is the default but that's not available, don't select it
+			if ( $size == $check ) {
+				if ( $enabled )
+					$checked = " checked='checked'";
+				else
+					$check = '';
+			} elseif ( !$check && $enabled && 'thumbnail' != $size ) {
+				// if $check is not enabled, default to the first available size that's bigger than a thumbnail
+				$check = $size;
+				$checked = " checked='checked'";
+			}
+
+			$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
+
+			$html .= "<label for='{$css_id}'>$label</label>";
+			// only show the dimensions if that choice is available
+			if ( $enabled )
+				$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d&nbsp;&times;&nbsp;%d)", $downsize[1], $downsize[2] ). "</label>";
+
+			$html .= '</div>';
+
+			$out[] = $html;
+		}
+
+		return array(
+			'label' => __('Size'),
+			'input' => 'html',
+			'html'  => join("\n", $out),
+		);
+}
+
+/**
+ * Retrieve HTML for the Link URL buttons with the default link type as specified.
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $post
+ * @param unknown_type $url_type
+ * @return unknown
+ */
+function image_link_input_fields($post, $url_type = '') {
+
+	$file = wp_get_attachment_url($post->ID);
+	$link = get_attachment_link($post->ID);
+
+	if ( empty($url_type) )
+		$url_type = get_user_setting('urlbutton', 'post');
+
+	$url = '';
+	if ( $url_type == 'file' )
+		$url = $file;
+	elseif ( $url_type == 'post' )
+		$url = $link;
+
+	return "
+	<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br />
+	<button type='button' class='button urlnone' title=''>" . __('None') . "</button>
+	<button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button>
+	<button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Post URL') . "</button>
+";
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $form_fields
+ * @param unknown_type $post
+ * @return unknown
+ */
+function image_attachment_fields_to_edit($form_fields, $post) {
+	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
+		$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
+		if ( empty($alt) )
+			$alt = '';
+
+		$form_fields['post_title']['required'] = true;
+
+		$form_fields['image_alt'] = array(
+			'value' => $alt,
+			'label' => __('Alternate Text'),
+			'helps' => __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;')
+		);
+
+		$form_fields['align'] = array(
+			'label' => __('Alignment'),
+			'input' => 'html',
+			'html'  => image_align_input_fields($post, get_option('image_default_align')),
+		);
+
+		$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') );
+
+	} else {
+		unset( $form_fields['image_alt'] );
+	}
+	return $form_fields;
+}
+
+add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $form_fields
+ * @param unknown_type $post
+ * @return unknown
+ */
+function media_single_attachment_fields_to_edit( $form_fields, $post ) {
+	unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']);
+	return $form_fields;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.8.0
+ *
+ * @param unknown_type $form_fields
+ * @param unknown_type $post
+ * @return unknown
+ */
+function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
+	unset($form_fields['image_url']);
+	return $form_fields;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $post
+ * @param unknown_type $attachment
+ * @return unknown
+ */
+function image_attachment_fields_to_save($post, $attachment) {
+	if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
+		if ( strlen(trim($post['post_title'])) == 0 ) {
+			$post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid']));
+			$post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.');
+		}
+	}
+
+	return $post;
+}
+
+add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2);
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $html
+ * @param unknown_type $attachment_id
+ * @param unknown_type $attachment
+ * @return unknown
+ */
+function image_media_send_to_editor($html, $attachment_id, $attachment) {
+	$post =& get_post($attachment_id);
+	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
+		$url = $attachment['url'];
+		$align = !empty($attachment['align']) ? $attachment['align'] : 'none';
+		$size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium';
+		$alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : '';
+		$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, $alt);
+	}
+
+	return $html;
+}
+
+add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $post
+ * @param unknown_type $errors
+ * @return unknown
+ */
+function get_attachment_fields_to_edit($post, $errors = null) {
+	if ( is_int($post) )
+		$post =& get_post($post);
+	if ( is_array($post) )
+		$post = (object) $post;
+
+	$image_url = wp_get_attachment_url($post->ID);
+
+	$edit_post = sanitize_post($post, 'edit');
+
+
+
+	$form_fields = array(
+		'post_title'   => array(
+			'label'      => __('Title'),
+			'value'      => $edit_post->post_title
+		),
+		'image_alt'   => array(),
+		'post_excerpt' => array(
+			'label'      => __('Caption'),
+			'value'      => $edit_post->post_excerpt
+		),
+		'post_content' => array(
+			'label'      => __('Description'),
+			'value'      => $edit_post->post_content,
+			'input'      => 'textarea'
+		),
+		'url'          => array(
+			'label'      => __('Link URL'),
+			'input'      => 'html',
+			'html'       => image_link_input_fields($post, get_option('image_default_link_type')),
+			'helps'      => __('Enter a link URL or click above for presets.')
+		),
+		'menu_order'   => array(
+			'label'      => __('Order'),
+			'value'      => $edit_post->menu_order
+		),
+		'image_url'	=> array(
+			'label'      => __('File URL'),
+			'input'      => 'html',
+			'html'       => "<input type='text' class='text urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />",
+			'value'      => wp_get_attachment_url($post->ID),
+			'helps'      => __('Location of the uploaded file.')
+		)
+	);
+
+	foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
+		$t = (array) get_taxonomy($taxonomy);
+		if ( ! $t['public'] )
+			continue;
+		if ( empty($t['label']) )
+			$t['label'] = $taxonomy;
+		if ( empty($t['args']) )
+			$t['args'] = array();
+
+		$terms = get_object_term_cache($post->ID, $taxonomy);
+		if ( empty($terms) )
+			$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
+
+		$values = array();
+
+		foreach ( $terms as $term )
+			$values[] = $term->name;
+		$t['value'] = join(', ', $values);
+
+		$form_fields[$taxonomy] = $t;
+	}
+
+	// Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
+	// The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
+	$form_fields = array_merge_recursive($form_fields, (array) $errors);
+
+	$form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
+
+	return $form_fields;
+}
+
+/**
+ * Retrieve HTML for media items of post gallery.
+ *
+ * The HTML markup retrieved will be created for the progress of SWF Upload
+ * component. Will also create link for showing and hiding the form to modify
+ * the image attachment.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param array $errors Errors for attachment, if any.
+ * @return string
+ */
+function get_media_items( $post_id, $errors ) {
+	$attachments = array();
+	if ( $post_id ) {
+		$post = get_post($post_id);
+		if ( $post && $post->post_type == 'attachment' )
+			$attachments = array($post->ID => $post);
+		else
+			$attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
+	} else {
+		if ( is_array($GLOBALS['wp_the_query']->posts) )
+			foreach ( $GLOBALS['wp_the_query']->posts as $attachment )
+				$attachments[$attachment->ID] = $attachment;
+	}
+
+	$output = '';
+	foreach ( (array) $attachments as $id => $attachment ) {
+		if ( $attachment->post_status == 'trash' )
+			continue;
+		if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
+			$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
+	}
+
+	return $output;
+}
+
+/**
+ * Retrieve HTML form for modifying the image attachment.
+ *
+ * @since 2.5.0
+ *
+ * @param int $attachment_id Attachment ID for modification.
+ * @param string|array $args Optional. Override defaults.
+ * @return string HTML form for attachment.
+ */
+function get_media_item( $attachment_id, $args = null ) {
+	global $redir_tab;
+
+	if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) )
+		$thumb_url = $thumb_url[0];
+	else
+		$thumb_url = false;
+
+	$post = get_post( $attachment_id );
+
+	$default_args = array( 'errors' => null, 'send' => $post->post_parent ? post_type_supports( get_post_type( $post->post_parent ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true );
+	$args = wp_parse_args( $args, $default_args );
+	$args = apply_filters( 'get_media_item_args', $args );
+	extract( $args, EXTR_SKIP );
+
+	$toggle_on  = __( 'Show' );
+	$toggle_off = __( 'Hide' );
+
+	$filename = basename( $post->guid );
+	$title = esc_attr( $post->post_title );
+
+	if ( $_tags = get_the_tags( $attachment_id ) ) {
+		foreach ( $_tags as $tag )
+			$tags[] = $tag->name;
+		$tags = esc_attr( join( ', ', $tags ) );
+	}
+
+	$post_mime_types = get_post_mime_types();
+	$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
+	$type = array_shift( $keys );
+	$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
+
+	$form_fields = get_attachment_fields_to_edit( $post, $errors );
+
+	if ( $toggle ) {
+		$class = empty( $errors ) ? 'startclosed' : 'startopen';
+		$toggle_links = "
+	<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
+	<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
+	} else {
+		$class = 'form-table';
+		$toggle_links = '';
+	}
+
+	$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
+	$display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';
+
+	$gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
+	$order = '';
+
+	foreach ( $form_fields as $key => $val ) {
+		if ( 'menu_order' == $key ) {
+			if ( $gallery )
+				$order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ). "' /></div>";
+			else
+				$order = "<input type='hidden' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' />";
+
+			unset( $form_fields['menu_order'] );
+			break;
+		}
+	}
+
+	$media_dims = '';
+	$meta = wp_get_attachment_metadata( $post->ID );
+	if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
+		$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
+	$media_dims = apply_filters( 'media_meta', $media_dims, $post );
+
+	$image_edit_button = '';
+	if ( gd_edit_image_support( $post->post_mime_type ) ) {
+		$nonce = wp_create_nonce( "image_editor-$post->ID" );
+		$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <img src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' class='imgedit-wait-spin' alt='' />";
+	}
+
+	$attachment_url = get_permalink( $attachment_id );
+
+	$item = "
+	$type_html
+	$toggle_links
+	$order
+	$display_title
+	<table class='slidetoggle describe $class'>
+		<thead class='media-item-info' id='media-head-$post->ID'>
+		<tr valign='top'>
+			<td class='A1B1' id='thumbnail-head-$post->ID'>
+			<p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' style='margin-top: 3px' /></a></p>
+			<p>$image_edit_button</p>
+			</td>
+			<td>
+			<p><strong>" . __('File name:') . "</strong> $filename</p>
+			<p><strong>" . __('File type:') . "</strong> $post->post_mime_type</p>
+			<p><strong>" . __('Upload date:') . "</strong> " . mysql2date( get_option('date_format'), $post->post_date ). '</p>';
+			if ( !empty( $media_dims ) )
+				$item .= "<p><strong>" . __('Dimensions:') . "</strong> $media_dims</p>\n";
+
+			$item .= "</td></tr>\n";
+
+
+
+	$item .= "
+		</thead>
+		<tbody>
+		<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr>
+		<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n";
+
+	$defaults = array(
+		'input'      => 'text',
+		'required'   => false,
+		'value'      => '',
+		'extra_rows' => array(),
+	);
+
+	if ( $send )
+		$send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false );
+	if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
+		if ( !EMPTY_TRASH_DAYS ) {
+			$delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>';
+		} elseif ( !MEDIA_TRASH ) {
+			$delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a>
+			 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "
+			 <a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a>
+			 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a>
+			 </div>";
+		} else {
+			$delete = "<a href='" . wp_nonce_url( "post.php?action=trash&amp;post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a>
+			<a href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>";
+		}
+	} else {
+		$delete = '';
+	}
+
+	$thumbnail = '';
+	$calling_post_id = 0;
+	if ( isset( $_GET['post_id'] ) )
+		$calling_post_id = absint( $_GET['post_id'] );
+	elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set
+		$calling_post_id = $post->post_parent;
+	if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
+		$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" );
+		$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>";
+	}
+
+	if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) )
+		$form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n" );
+
+	$hidden_fields = array();
+
+	foreach ( $form_fields as $id => $field ) {
+		if ( $id[0] == '_' )
+			continue;
+
+		if ( !empty( $field['tr'] ) ) {
+			$item .= $field['tr'];
+			continue;
+		}
+
+		$field = array_merge( $defaults, $field );
+		$name = "attachments[$attachment_id][$id]";
+
+		if ( $field['input'] == 'hidden' ) {
+			$hidden_fields[$name] = $field['value'];
+			continue;
+		}
+
+		$required      = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : '';
+		$aria_required = $field['required'] ? " aria-required='true' " : '';
+		$class  = $id;
+		$class .= $field['required'] ? ' form-required' : '';
+
+		$item .= "\t\t<tr class='$class'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}</span>$required<br class='clear' /></label></th>\n\t\t\t<td class='field'>";
+		if ( !empty( $field[ $field['input'] ] ) )
+			$item .= $field[ $field['input'] ];
+		elseif ( $field['input'] == 'textarea' ) {
+			if ( user_can_richedit() ) { // textarea_escaped when user_can_richedit() = false
+				$field['value'] = esc_textarea( $field['value'] );
+			}
+			$item .= "<textarea type='text' id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>';
+		} else {
+			$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />";
+		}
+		if ( !empty( $field['helps'] ) )
+			$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
+		$item .= "</td>\n\t\t</tr>\n";
+
+		$extra_rows = array();
+
+		if ( !empty( $field['errors'] ) )
+			foreach ( array_unique( (array) $field['errors'] ) as $error )
+				$extra_rows['error'][] = $error;
+
+		if ( !empty( $field['extra_rows'] ) )
+			foreach ( $field['extra_rows'] as $class => $rows )
+				foreach ( (array) $rows as $html )
+					$extra_rows[$class][] = $html;
+
+		foreach ( $extra_rows as $class => $rows )
+			foreach ( $rows as $html )
+				$item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
+	}
+
+	if ( !empty( $form_fields['_final'] ) )
+		$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
+	$item .= "\t</tbody>\n";
+	$item .= "\t</table>\n";
+
+	foreach ( $hidden_fields as $name => $value )
+		$item .= "\t<input type='hidden' name='$name' id='$name' value='" . esc_attr( $value ) . "' />\n";
+
+	if ( $post->post_parent < 1 && isset( $_REQUEST['post_id'] ) ) {
+		$parent = (int) $_REQUEST['post_id'];
+		$parent_name = "attachments[$attachment_id][post_parent]";
+		$item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='$parent' />\n";
+	}
+
+	return $item;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ */
+function media_upload_header() {
+	?>
+	<script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>
+	<div id="media-upload-header">
+	<?php the_media_upload_tabs(); ?>
+	</div>
+	<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $errors
+ */
+function media_upload_form( $errors = null ) {
+	global $type, $tab, $pagenow;
+
+	$flash_action_url = admin_url('async-upload.php');
+
+	// If Mac and mod_security, no Flash. :(
+	$flash = true;
+	if ( false !== stripos($_SERVER['HTTP_USER_AGENT'], 'mac') && apache_mod_loaded('mod_security') )
+		$flash = false;
+
+	$flash = apply_filters('flash_uploader', $flash);
+	$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
+
+	$upload_size_unit = $max_upload_size =  wp_max_upload_size();
+	$sizes = array( 'KB', 'MB', 'GB' );
+	for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ )
+		$upload_size_unit /= 1024;
+	if ( $u < 0 ) {
+		$upload_size_unit = 0;
+		$u = 0;
+	} else {
+		$upload_size_unit = (int) $upload_size_unit;
+	}
+?>
+<script type="text/javascript">
+//<![CDATA[
+var uploaderMode = 0;
+jQuery(document).ready(function($){
+	uploaderMode = getUserSetting('uploader');
+	$('.upload-html-bypass a').click(function(){deleteUserSetting('uploader');uploaderMode=0;swfuploadPreLoad();return false;});
+	$('.upload-flash-bypass a').click(function(){setUserSetting('uploader', '1');uploaderMode=1;swfuploadPreLoad();return false;});
+});
+//]]>
+</script>
+<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
+// Check quota for this blog if multisite
+if ( is_multisite() && !is_upload_space_available() ) {
+	echo '<p>' . sprintf( __( 'Sorry, you have filled your storage quota (%s MB).' ), get_space_allowed() ) . '</p>';
+	return;
+}
+
+do_action('pre-upload-ui');
+
+if ( $flash ) :
+
+// Set the post params, which SWFUpload will post back with the file, and pass
+// them through a filter.
+$post_params = array(
+		"post_id" => $post_id,
+		"auth_cookie" => (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]),
+		"logged_in_cookie" => $_COOKIE[LOGGED_IN_COOKIE],
+		"_wpnonce" => wp_create_nonce('media-form'),
+		"type" => $type,
+		"tab" => $tab,
+		"short" => "1",
+);
+$post_params = apply_filters( 'swfupload_post_params', $post_params );
+$p = array();
+foreach ( $post_params as $param => $val )
+	$p[] = "\t\t'$param' : '$val'";
+$post_params_str = implode( ", \n", $p );
+
+// #8545. wmode=transparent cannot be used with SWFUpload
+if ( 'media-new.php' == $pagenow ) {
+	$upload_image_path = get_user_option( 'admin_color' );
+	if ( 'classic' != $upload_image_path )
+		$upload_image_path = 'fresh';
+	$upload_image_path = admin_url( 'images/upload-' . $upload_image_path . '.png?ver=20101205' );
+} else {
+	$upload_image_path = includes_url( 'images/upload.png?ver=20100531' );
+}
+
+?>
+<script type="text/javascript">
+//<![CDATA[
+var swfu;
+SWFUpload.onload = function() {
+	var settings = {
+			button_text: '<span class="button"><?php _e('Select Files'); ?><\/span>',
+			button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 11px; text-shadow: 0 1px 0 #FFFFFF; color:#464646; }',
+			button_height: "23",
+			button_width: "132",
+			button_text_top_padding: 3,
+			button_image_url: '<?php echo $upload_image_path; ?>',
+			button_placeholder_id: "flash-browse-button",
+			upload_url : "<?php echo esc_attr( $flash_action_url ); ?>",
+			flash_url : "<?php echo includes_url('js/swfupload/swfupload.swf'); ?>",
+			file_post_name: "async-upload",
+			file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
+			post_params : {
+				<?php echo $post_params_str; ?>
+			},
+			file_size_limit : "<?php echo $max_upload_size; ?>b",
+			file_dialog_start_handler : fileDialogStart,
+			file_queued_handler : fileQueued,
+			upload_start_handler : uploadStart,
+			upload_progress_handler : uploadProgress,
+			upload_error_handler : uploadError,
+			upload_success_handler : <?php echo apply_filters( 'swfupload_success_handler', 'uploadSuccess' ); ?>,
+			upload_complete_handler : uploadComplete,
+			file_queue_error_handler : fileQueueError,
+			file_dialog_complete_handler : fileDialogComplete,
+			swfupload_pre_load_handler: swfuploadPreLoad,
+			swfupload_load_failed_handler: swfuploadLoadFailed,
+			custom_settings : {
+				degraded_element_id : "html-upload-ui", // id of the element displayed when swfupload is unavailable
+				swfupload_element_id : "flash-upload-ui" // id of the element displayed when swfupload is available
+			},
+			debug: false
+		};
+		swfu = new SWFUpload(settings);
+};
+//]]>
+</script>
+
+<div id="flash-upload-ui" class="hide-if-no-js">
+<?php do_action('pre-flash-upload-ui'); ?>
+
+	<div>
+	<?php _e( 'Choose files to upload' ); ?>
+	<div id="flash-browse-button"></div>
+	<span><input id="cancel-upload" disabled="disabled" onclick="cancelUpload()" type="button" value="<?php esc_attr_e('Cancel Upload'); ?>" class="button" /></span>
+	</div>
+	<p class="media-upload-size"><?php printf( __( 'Maximum upload file size: %d%s' ), $upload_size_unit, $sizes[$u] ); ?></p>
+<?php do_action('post-flash-upload-ui'); ?>
+	<p class="howto"><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p>
+</div>
+<?php endif; // $flash ?>
+
+<div id="html-upload-ui">
+<?php do_action('pre-html-upload-ui'); ?>
+	<p id="async-upload-wrap">
+		<label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label>
+		<input type="file" name="async-upload" id="async-upload" />
+		<?php submit_button( __( 'Upload' ), 'button', 'html-upload', false ); ?>
+		<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?></a>
+	</p>
+	<div class="clear"></div>
+	<p class="media-upload-size"><?php printf( __( 'Maximum upload file size: %d%s' ), $upload_size_unit, $sizes[$u] ); ?></p>
+	<?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 update to lighttpd 1.5.'); ?></p>
+	<?php endif;?>
+<?php do_action('post-html-upload-ui', $flash); ?>
+</div>
+<?php do_action('post-upload-ui'); ?>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $type
+ * @param unknown_type $errors
+ * @param unknown_type $id
+ */
+function media_upload_type_form($type = 'file', $errors = null, $id = null) {
+	media_upload_header();
+
+	$post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0;
+
+	$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
+?>
+
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form">
+<?php submit_button( '', 'hidden', 'save', false ); ?>
+<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+<?php wp_nonce_field('media-form'); ?>
+
+<h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3>
+
+<?php media_upload_form( $errors ); ?>
+
+<script type="text/javascript">
+//<![CDATA[
+jQuery(function($){
+	var preloaded = $(".media-item.preloaded");
+	if ( preloaded.length > 0 ) {
+		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+	}
+	updateMediaForm();
+});
+//]]>
+</script>
+<div id="media-items">
+<?php
+if ( $id ) {
+	if ( !is_wp_error($id) ) {
+		add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
+		echo get_media_items( $id, $errors );
+	} else {
+		echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div>';
+		exit;
+	}
+}
+?>
+</div>
+<p class="savebutton ml-submit">
+<?php submit_button( __( 'Save all changes' ), 'button', 'save', false ); ?>
+</p>
+</form>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $type
+ * @param unknown_type $errors
+ * @param unknown_type $id
+ */
+function media_upload_type_url_form($type = 'file', $errors = null, $id = null) {
+	media_upload_header();
+
+	$post_id = intval($_REQUEST['post_id']);
+
+	$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
+
+	$callback = "type_url_form_$type";
+?>
+
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($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 (int) $post_id; ?>" />
+<?php wp_nonce_field('media-form'); ?>
+
+<?php if ( is_callable($callback) ) { ?>
+
+<h3 class="media-title"><?php _e('Add media file from URL'); ?></h3>
+
+<script type="text/javascript">
+//<![CDATA[
+var addExtImage = {
+
+	width : '',
+	height : '',
+	align : 'alignnone',
+
+	insert : function() {
+		var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = '';
+
+		if ( '' == f.src.value || '' == t.width )
+			return false;
+
+		if ( f.title.value ) {
+			title = f.title.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+			title = ' title="'+title+'"';
+		}
+
+		if ( f.alt.value )
+			alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+
+<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
+		if ( f.caption.value )
+			caption = f.caption.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+<?php } ?>
+
+		cls = caption ? '' : ' class="'+t.align+'"';
+
+		html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />';
+
+		if ( f.url.value )
+			html = '<a href="'+f.url.value+'">'+html+'</a>';
+
+		if ( caption )
+			html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]';
+
+		var win = window.dialogArguments || opener || parent || top;
+		win.send_to_editor(html);
+		return false;
+	},
+
+	resetImageData : function() {
+		var t = addExtImage;
+
+		t.width = t.height = '';
+		document.getElementById('go_button').style.color = '#bbb';
+		if ( ! document.forms[0].src.value )
+			document.getElementById('status_img').innerHTML = '*';
+		else document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" alt="" />';
+	},
+
+	updateImageData : function() {
+		var t = addExtImage;
+
+		t.width = t.preloadImg.width;
+		t.height = t.preloadImg.height;
+		document.getElementById('go_button').style.color = '#333';
+		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" alt="" />';
+	},
+
+	getImageData : function() {
+		var t = addExtImage, src = document.forms[0].src.value;
+
+		if ( ! src ) {
+			t.resetImageData();
+			return false;
+		}
+		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />';
+		t.preloadImg = new Image();
+		t.preloadImg.onload = t.updateImageData;
+		t.preloadImg.onerror = t.resetImageData;
+		t.preloadImg.src = src;
+	}
+}
+//]]>
+</script>
+
+<div id="media-items">
+<div class="media-item media-blank">
+<?php echo apply_filters($callback, call_user_func($callback)); ?>
+</div>
+</div>
+</form>
+<?php
+	} else {
+		wp_die( __('Unknown action.') );
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $errors
+ */
+function media_upload_gallery_form($errors) {
+	global $redir_tab, $type;
+
+	$redir_tab = 'gallery';
+	media_upload_header();
+
+	$post_id = intval($_REQUEST['post_id']);
+	$form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id");
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
+?>
+
+<script type="text/javascript">
+<!--
+jQuery(function($){
+	var preloaded = $(".media-item.preloaded");
+	if ( preloaded.length > 0 ) {
+		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+		updateMediaForm();
+	}
+});
+-->
+</script>
+<div id="sort-buttons" class="hide-if-no-js">
+<span>
+<?php _e('All Tabs:'); ?>
+<a href="#" id="showall"><?php _e('Show'); ?></a>
+<a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a>
+</span>
+<?php _e('Sort Order:'); ?>
+<a href="#" id="asc"><?php _e('Ascending'); ?></a> |
+<a href="#" id="desc"><?php _e('Descending'); ?></a> |
+<a href="#" id="clear"><?php _ex('Clear', 'verb'); ?></a>
+</div>
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
+<?php wp_nonce_field('media-form'); ?>
+<?php //media_upload_form( $errors ); ?>
+<table class="widefat" cellspacing="0">
+<thead><tr>
+<th><?php _e('Media'); ?></th>
+<th class="order-head"><?php _e('Order'); ?></th>
+<th class="actions-head"><?php _e('Actions'); ?></th>
+</tr></thead>
+</table>
+<div id="media-items">
+<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
+<?php echo get_media_items($post_id, $errors); ?>
+</div>
+
+<p class="ml-submit">
+<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false, array( 'id' => 'save-all', 'style' => 'display: none;' ) ); ?>
+<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+<input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
+<input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />
+</p>
+
+<div id="gallery-settings" style="display:none;">
+<div class="title"><?php _e('Gallery Settings'); ?></div>
+<table id="basic" class="describe"><tbody>
+	<tr>
+	<th scope="row" class="label">
+		<label>
+		<span class="alignleft"><?php _e('Link thumbnails to:'); ?></span>
+		</label>
+	</th>
+	<td class="field">
+		<input type="radio" name="linkto" id="linkto-file" value="file" />
+		<label for="linkto-file" class="radio"><?php _e('Image File'); ?></label>
+
+		<input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
+		<label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label>
+	</td>
+	</tr>
+
+	<tr>
+	<th scope="row" class="label">
+		<label>
+		<span class="alignleft"><?php _e('Order images by:'); ?></span>
+		</label>
+	</th>
+	<td class="field">
+		<select id="orderby" name="orderby">
+			<option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option>
+			<option value="title"><?php _e('Title'); ?></option>
+			<option value="ID"><?php _e('Date/Time'); ?></option>
+			<option value="rand"><?php _e('Random'); ?></option>
+		</select>
+	</td>
+	</tr>
+
+	<tr>
+	<th scope="row" class="label">
+		<label>
+		<span class="alignleft"><?php _e('Order:'); ?></span>
+		</label>
+	</th>
+	<td class="field">
+		<input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
+		<label for="order-asc" class="radio"><?php _e('Ascending'); ?></label>
+
+		<input type="radio" name="order" id="order-desc" value="desc" />
+		<label for="order-desc" class="radio"><?php _e('Descending'); ?></label>
+	</td>
+	</tr>
+
+	<tr>
+	<th scope="row" class="label">
+		<label>
+		<span class="alignleft"><?php _e('Gallery columns:'); ?></span>
+		</label>
+	</th>
+	<td class="field">
+		<select id="columns" name="columns">
+			<option value="1">1</option>
+			<option value="2">2</option>
+			<option value="3" selected="selected">3</option>
+			<option value="4">4</option>
+			<option value="5">5</option>
+			<option value="6">6</option>
+			<option value="7">7</option>
+			<option value="8">8</option>
+			<option value="9">9</option>
+		</select>
+	</td>
+	</tr>
+</tbody></table>
+
+<p class="ml-submit">
+<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" />
+<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" />
+</p>
+</div>
+</form>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $errors
+ */
+function media_upload_library_form($errors) {
+	global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
+
+	media_upload_header();
+
+	$post_id = intval($_REQUEST['post_id']);
+
+	$form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id");
+	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
+
+	$_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
+	if ( $_GET['paged'] < 1 )
+		$_GET['paged'] = 1;
+	$start = ( $_GET['paged'] - 1 ) * 10;
+	if ( $start < 1 )
+		$start = 0;
+	add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) );
+
+	list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
+
+?>
+
+<form id="filter" action="" method="get">
+<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
+<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
+<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
+<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
+
+<p id="media-search" class="search-box">
+	<label class="screen-reader-text" for="media-search-input"><?php _e('Search Media');?>:</label>
+	<input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
+	<?php submit_button( __( 'Search Media' ), 'button', '', false ); ?>
+</p>
+
+<ul class="subsubsub">
+<?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 )
+		if ( isset($num_posts[$_type]) )
+			$num_posts[$_type] += $_num_posts[$real];
+		else
+			$num_posts[$_type] = $_num_posts[$real];
+// 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"';
+else
+	$class = '';
+$type_links[] = "<li><a href='" . esc_url(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 = '';
+
+	if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
+		continue;
+
+	if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
+		$class = ' class="current"';
+
+	$type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>';
+}
+echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
+unset($type_links);
+?>
+</ul>
+
+<div class="tablenav">
+
+<?php
+$page_links = paginate_links( array(
+	'base' => add_query_arg( 'paged', '%#%' ),
+	'format' => '',
+	'prev_text' => __('&laquo;'),
+	'next_text' => __('&raquo;'),
+	'total' => ceil($wp_query->found_posts / 10),
+	'current' => $_GET['paged']
+));
+
+if ( $page_links )
+	echo "<div class='tablenav-pages'>$page_links</div>";
+?>
+
+<div class="alignleft actions">
+<?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";
+
+$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 ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) )
+		$default = ' selected="selected"';
+	else
+		$default = '';
+
+	echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
+	echo esc_html( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" );
+	echo "</option>\n";
+}
+?>
+</select>
+<?php } ?>
+
+<?php submit_button( __( 'Filter &#187;' ), 'secondary', 'post-query-submit', false ); ?>
+
+</div>
+
+<br class="clear" />
+</div>
+</form>
+
+<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form validate" id="library-form">
+
+<?php wp_nonce_field('media-form'); ?>
+<?php //media_upload_form( $errors ); ?>
+
+<script type="text/javascript">
+<!--
+jQuery(function($){
+	var preloaded = $(".media-item.preloaded");
+	if ( preloaded.length > 0 ) {
+		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+		updateMediaForm();
+	}
+});
+-->
+</script>
+
+<div id="media-items">
+<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
+<?php echo get_media_items(null, $errors); ?>
+</div>
+<p class="ml-submit">
+<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false ); ?>
+<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
+</p>
+</form>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @return unknown
+ */
+function type_url_form_image() {
+	if ( !apply_filters( 'disable_captions', '' ) ) {
+		$caption = '
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="caption">' . __('Image Caption') . '</label></span>
+			</th>
+			<td class="field"><input id="caption" name="caption" value="" type="text" /></td>
+		</tr>
+';
+	} else {
+		$caption = '';
+	}
+
+	$default_align = get_option('image_default_align');
+	if ( empty($default_align) )
+		$default_align = 'none';
+
+	return '
+	<h4 class="media-sub-title">' . __('Insert an image from another web site') . '</h4>
+	<table class="describe"><tbody>
+		<tr>
+			<th valign="top" scope="row" class="label" style="width:130px;">
+				<span class="alignleft"><label for="src">' . __('Image URL') . '</label></span>
+				<span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="title">' . __('Image Title') . '</label></span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="title" name="title" value="" type="text" aria-required="true" /></td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span>
+			</th>
+			<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
+			<p class="help">' . __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;') . '</p></td>
+		</tr>
+		' . $caption . '
+		<tr class="align">
+			<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
+			<td class="field">
+				<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
+				<label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
+				<input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' />
+				<label for="align-left" class="align image-align-left-label">' . __('Left') . '</label>
+				<input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' />
+				<label for="align-center" class="align image-align-center-label">' . __('Center') . '</label>
+				<input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' />
+				<label for="align-right" class="align image-align-right-label">' . __('Right') . '</label>
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="url">' . __('Link Image To:') . '</label></span>
+			</th>
+			<td class="field"><input id="url" name="url" value="" type="text" /><br />
+
+			<button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None') . '</button>
+			<button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image') . '</button>
+			<p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td>
+		</tr>
+	' . _insert_into_post_button('image') . '
+	</tbody></table>
+';
+
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @return unknown
+ */
+function type_url_form_audio() {
+	return '
+	<table class="describe"><tbody>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="insertonly[href]">' . __('Audio File URL') . '</label></span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
+		</tr>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
+		</tr>
+		<tr><td></td><td class="help">' . __('Link text, e.g. &#8220;Still Alive by Jonathan Coulton&#8221;') . '</td></tr>
+	' . _insert_into_post_button('audio') . '
+	</tbody></table>
+';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @return unknown
+ */
+function type_url_form_video() {
+	return '
+	<table class="describe"><tbody>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="insertonly[href]">' . __('Video URL') . '</label></span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
+		</tr>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
+		</tr>
+		<tr><td></td><td class="help">' . __('Link text, e.g. &#8220;Lucy on YouTube&#8221;') . '</td></tr>
+	' . _insert_into_post_button('video') . '
+	</tbody></table>
+';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @return unknown
+ */
+function type_url_form_file() {
+	return '
+	<table class="describe"><tbody>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="insertonly[href]">' . __('URL') . '</label></span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
+		</tr>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+			</th>
+			<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
+		</tr>
+		<tr><td></td><td class="help">' . __('Link text, e.g. &#8220;Ransom Demands (PDF)&#8221;') . '</td></tr>
+	' . _insert_into_post_button('file') . '
+	</tbody></table>
+';
+}
+
+
+function _insert_into_post_button($type) {
+	if ( !post_type_supports(get_post_type($_GET['post_id']), 'editor') )
+		return '';
+
+	if ( 'image' == $type )
+	return '
+		<tr>
+			<td></td>
+			<td>
+				<input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" />
+			</td>
+		</tr>
+	';
+
+	return '
+		<tr>
+			<td></td>
+			<td>
+				' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . '
+			</td>
+		</tr>
+	';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Support a GET parameter for disabling the flash uploader.
+ *
+ * @since 2.6.0
+ *
+ * @param unknown_type $flash
+ * @return unknown
+ */
+function media_upload_use_flash($flash) {
+	if ( array_key_exists('flash', $_REQUEST) )
+		$flash = !empty($_REQUEST['flash']);
+	return $flash;
+}
+
+add_filter('flash_uploader', 'media_upload_use_flash');
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.6.0
+ */
+function media_upload_flash_bypass() {
+	echo '<p class="upload-flash-bypass">';
+	printf( __('You are using the Flash uploader.  Problems?  Try the <a href="%s">Browser uploader</a> instead.'), esc_url(add_query_arg('flash', 0)) );
+	echo '</p>';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.6.0
+ */
+function media_upload_html_bypass($flash = true) {
+	echo '<p class="upload-html-bypass hide-if-no-js">';
+	_e('You are using the Browser uploader.');
+	if ( $flash ) {
+		// the user manually selected the browser uploader, so let them switch back to Flash
+		echo ' ';
+		printf( __('Try the <a href="%s">Flash uploader</a> instead.'), esc_url(add_query_arg('flash', 1)) );
+	}
+	echo "</p>\n";
+}
+
+add_action('post-flash-upload-ui', 'media_upload_flash_bypass');
+add_action('post-html-upload-ui', 'media_upload_html_bypass');
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Make sure the GET parameter sticks when we submit a form.
+ *
+ * @since 2.6.0
+ *
+ * @param unknown_type $url
+ * @return unknown
+ */
+function media_upload_bypass_url($url) {
+	if ( array_key_exists('flash', $_REQUEST) )
+		$url = add_query_arg('flash', intval($_REQUEST['flash']));
+	return $url;
+}
+
+add_filter('media_upload_form_url', 'media_upload_bypass_url');
+
+add_filter('async_upload_image', 'get_media_item', 10, 2);
+add_filter('async_upload_audio', 'get_media_item', 10, 2);
+add_filter('async_upload_video', 'get_media_item', 10, 2);
+add_filter('async_upload_file', 'get_media_item', 10, 2);
+
+add_action('media_upload_image', 'media_upload_image');
+add_action('media_upload_audio', 'media_upload_audio');
+add_action('media_upload_video', 'media_upload_video');
+add_action('media_upload_file', 'media_upload_file');
+
+add_filter('media_upload_gallery', 'media_upload_gallery');
+
+add_filter('media_upload_library', 'media_upload_library');
Index: /tags/3.1/wp-admin/includes/menu.php
===================================================================
--- /tags/3.1/wp-admin/includes/menu.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/menu.php	(revision 17487)
@@ -0,0 +1,215 @@
+<?php
+
+/**
+ * Build Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+if ( is_network_admin() )
+	do_action('_network_admin_menu');
+elseif ( is_user_admin() )
+	do_action('_user_admin_menu');
+else
+	do_action('_admin_menu');
+
+// Create list of page plugin hook names.
+foreach ($menu as $menu_page) {
+	if ( false !== $pos = strpos($menu_page[2], '?') ) {
+		// Handle post_type=post|page|foo pages.
+		$hook_name = substr($menu_page[2], 0, $pos);
+		$hook_args = substr($menu_page[2], $pos + 1);
+		wp_parse_str($hook_args, $hook_args);
+		// Set the hook name to be the post type.
+		if ( isset($hook_args['post_type']) )
+			$hook_name = $hook_args['post_type'];
+		else
+			$hook_name = basename($hook_name, '.php');
+		unset($hook_args);
+	} else {
+		$hook_name = basename($menu_page[2], '.php');
+	}
+	$hook_name = sanitize_title($hook_name);
+
+	if ( isset($compat[$hook_name]) )
+		$hook_name = $compat[$hook_name];
+	elseif ( !$hook_name )
+		continue;
+
+	$admin_page_hooks[$menu_page[2]] = $hook_name;
+}
+unset($menu_page, $compat);
+
+$_wp_submenu_nopriv = array();
+$_wp_menu_nopriv = array();
+// Loop over submenus and remove pages for which the user does not have privs.
+foreach ( array( 'submenu' ) as $sub_loop ) {
+	foreach ($$sub_loop as $parent => $sub) {
+		foreach ($sub as $index => $data) {
+			if ( ! current_user_can($data[1]) ) {
+				unset(${$sub_loop}[$parent][$index]);
+				$_wp_submenu_nopriv[$parent][$data[2]] = true;
+			}
+		}
+		unset($index, $data);
+
+		if ( empty(${$sub_loop}[$parent]) )
+			unset(${$sub_loop}[$parent]);
+	}
+	unset($sub, $parent);
+}
+unset($sub_loop);
+
+// Loop over the top-level menu.
+// Menus for which the original parent is not accessible due to lack of privs will have the next
+// submenu in line be assigned as the new menu parent.
+foreach ( $menu as $id => $data ) {
+	if ( empty($submenu[$data[2]]) )
+		continue;
+	$subs = $submenu[$data[2]];
+	$first_sub = array_shift($subs);
+	$old_parent = $data[2];
+	$new_parent = $first_sub[2];
+	// If the first submenu is not the same as the assigned parent,
+	// make the first submenu the new parent.
+	if ( $new_parent != $old_parent ) {
+		$_wp_real_parent_file[$old_parent] = $new_parent;
+		$menu[$id][2] = $new_parent;
+
+		foreach ($submenu[$old_parent] as $index => $data) {
+			$submenu[$new_parent][$index] = $submenu[$old_parent][$index];
+			unset($submenu[$old_parent][$index]);
+		}
+		unset($submenu[$old_parent], $index);
+
+		if ( isset($_wp_submenu_nopriv[$old_parent]) )
+			$_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
+	}
+}
+unset($id, $data, $subs, $first_sub, $old_parent, $new_parent);
+
+if ( is_network_admin() )
+	do_action('network_admin_menu', '');
+elseif ( is_user_admin() )
+	do_action('user_admin_menu', '');
+else
+	do_action('admin_menu', '');
+
+// Remove menus that have no accessible submenus and require privs that the user does not have.
+// Run re-parent loop again.
+foreach ( $menu as $id => $data ) {
+	if ( ! current_user_can($data[1]) )
+		$_wp_menu_nopriv[$data[2]] = true;
+
+	// If submenu is empty...
+	if ( empty($submenu[$data[2]]) ) {
+		// And user doesn't have privs, remove menu.
+		if ( isset( $_wp_menu_nopriv[$data[2]] ) ) {
+			unset($menu[$id]);
+		}
+	}
+}
+unset($id, $data);
+
+// Remove any duplicated seperators
+$seperator_found = false;
+foreach ( $menu as $id => $data ) {
+	if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) {
+		if (false == $seperator_found) {
+			$seperator_found = true;
+		} else {
+			unset($menu[$id]);
+			$seperator_found = false;
+		}
+	} else {
+		$seperator_found = false;
+	}
+}
+unset($id, $data);
+
+function add_cssclass($add, $class) {
+	$class = empty($class) ? $add : $class .= ' ' . $add;
+	return $class;
+}
+
+function add_menu_classes($menu) {
+
+	$first = $lastorder = false;
+	$i = 0;
+	$mc = count($menu);
+	foreach ( $menu as $order => $top ) {
+		$i++;
+
+		if ( 0 == $order ) { // dashboard is always shown/single
+			$menu[0][4] = add_cssclass('menu-top-first', $top[4]);
+			$lastorder = 0;
+			continue;
+		}
+
+		if ( 0 === strpos($top[2], 'separator') ) { // if separator
+			$first = true;
+			$c = $menu[$lastorder][4];
+			$menu[$lastorder][4] = add_cssclass('menu-top-last', $c);
+			continue;
+		}
+
+		if ( $first ) {
+			$c = $menu[$order][4];
+			$menu[$order][4] = add_cssclass('menu-top-first', $c);
+			$first = false;
+		}
+
+		if ( $mc == $i ) { // last item
+			$c = $menu[$order][4];
+			$menu[$order][4] = add_cssclass('menu-top-last', $c);
+		}
+
+		$lastorder = $order;
+	}
+
+	return apply_filters( 'add_menu_classes', $menu );
+}
+
+uksort($menu, "strnatcasecmp"); // make it all pretty
+
+if ( apply_filters('custom_menu_order', false) ) {
+	$menu_order = array();
+	foreach ( $menu as $menu_item ) {
+		$menu_order[] = $menu_item[2];
+	}
+	unset($menu_item);
+	$default_menu_order = $menu_order;
+	$menu_order = apply_filters('menu_order', $menu_order);
+	$menu_order = array_flip($menu_order);
+	$default_menu_order = array_flip($default_menu_order);
+
+	function sort_menu($a, $b) {
+		global $menu_order, $default_menu_order;
+		$a = $a[2];
+		$b = $b[2];
+		if ( isset($menu_order[$a]) && !isset($menu_order[$b]) ) {
+			return -1;
+		} elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) {
+			return 1;
+		} elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) {
+			if ( $menu_order[$a] == $menu_order[$b] )
+				return 0;
+			return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1;
+		} else {
+			return ($default_menu_order[$a] <= $default_menu_order[$b]) ? -1 : 1;
+		}
+	}
+
+	usort($menu, 'sort_menu');
+	unset($menu_order, $default_menu_order);
+}
+
+if ( !user_can_access_admin_page() ) {
+	do_action('admin_page_access_denied');
+	wp_die( __('You do not have sufficient permissions to access this page.') );
+}
+
+$menu = add_menu_classes($menu);
+
+?>
Index: /tags/3.1/wp-admin/includes/meta-boxes.php
===================================================================
--- /tags/3.1/wp-admin/includes/meta-boxes.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/meta-boxes.php	(revision 17487)
@@ -0,0 +1,915 @@
+<?php
+
+// -- Post related Meta Boxes
+
+/**
+ * Display post submit form fields.
+ *
+ * @since 2.7.0
+ *
+ * @param object $post
+ */
+function post_submit_meta_box($post) {
+	global $action;
+
+	$post_type = $post->post_type;
+	$post_type_object = get_post_type_object($post_type);
+	$can_publish = current_user_can($post_type_object->cap->publish_posts);
+?>
+<div class="submitbox" id="submitpost">
+
+<div id="minor-publishing">
+
+<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
+<div style="display:none;">
+<?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
+</div>
+
+<div id="minor-publishing-actions">
+<div id="save-action">
+<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status )  { ?>
+<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" />
+<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
+<input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" />
+<?php } ?>
+<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="draft-ajax-loading" alt="" />
+</div>
+
+<div id="preview-action">
+<?php
+if ( 'publish' == $post->post_status ) {
+	$preview_link = esc_url( get_permalink( $post->ID ) );
+	$preview_button = __( 'Preview Changes' );
+} else {
+	$preview_link = get_permalink( $post->ID );
+	if ( is_ssl() )
+		$preview_link = str_replace( 'http://', 'https://', $preview_link );
+	$preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
+	$preview_button = __( 'Preview' );
+}
+?>
+<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a>
+<input type="hidden" name="wp-preview" id="wp-preview" value="" />
+</div>
+
+<div class="clear"></div>
+</div><?php // /minor-publishing-actions ?>
+
+<div id="misc-publishing-actions">
+
+<div class="misc-pub-section<?php if ( !$can_publish ) { echo ' misc-pub-section-last'; } ?>"><label for="post_status"><?php _e('Status:') ?></label>
+<span id="post-status-display">
+<?php
+switch ( $post->post_status ) {
+	case 'private':
+		_e('Privately Published');
+		break;
+	case 'publish':
+		_e('Published');
+		break;
+	case 'future':
+		_e('Scheduled');
+		break;
+	case 'pending':
+		_e('Pending Review');
+		break;
+	case 'draft':
+	case 'auto-draft':
+		_e('Draft');
+		break;
+}
+?>
+</span>
+<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
+<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
+
+<div id="post-status-select" class="hide-if-js">
+<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" />
+<select name='post_status' id='post_status' tabindex='4'>
+<?php if ( 'publish' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
+<?php elseif ( 'private' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
+<?php elseif ( 'future' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
+<?php endif; ?>
+<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
+<?php if ( 'auto-draft' == $post->post_status ) : ?>
+<option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option>
+<?php else : ?>
+<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
+<?php endif; ?>
+</select>
+ <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
+ <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
+</div>
+
+<?php } ?>
+</div><?php // /misc-pub-section ?>
+
+<div class="misc-pub-section " id="visibility">
+<?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
+
+if ( 'private' == $post->post_status ) {
+	$post->post_password = '';
+	$visibility = 'private';
+	$visibility_trans = __('Private');
+} elseif ( !empty( $post->post_password ) ) {
+	$visibility = 'password';
+	$visibility_trans = __('Password protected');
+} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
+	$visibility = 'public';
+	$visibility_trans = __('Public, Sticky');
+} else {
+	$visibility = 'public';
+	$visibility_trans = __('Public');
+}
+
+echo esc_html( $visibility_trans ); ?></span>
+<?php if ( $can_publish ) { ?>
+<a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
+
+<div id="post-visibility-select" class="hide-if-js">
+<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
+<?php if ($post_type == 'post'): ?>
+<input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
+<?php endif; ?>
+<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
+
+
+<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
+<?php if ($post_type == 'post'): ?>
+<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked(is_sticky($post->ID)); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e('Stick this post to the front page') ?></label><br /></span>
+<?php endif; ?>
+<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
+<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span>
+<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
+
+<p>
+ <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
+ <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
+</p>
+</div>
+<?php } ?>
+
+</div><?php // /misc-pub-section ?>
+
+<?php
+// translators: Publish box date formt, see http://php.net/date
+$datef = __( 'M j, Y @ G:i' );
+if ( 0 != $post->ID ) {
+	if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
+		$stamp = __('Scheduled for: <b>%1$s</b>');
+	} else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
+		$stamp = __('Published on: <b>%1$s</b>');
+	} else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
+		$stamp = __('Publish <b>immediately</b>');
+	} else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
+		$stamp = __('Schedule for: <b>%1$s</b>');
+	} else { // draft, 1 or more saves, date specified
+		$stamp = __('Publish on: <b>%1$s</b>');
+	}
+	$date = date_i18n( $datef, strtotime( $post->post_date ) );
+} else { // draft (no saves, and thus no date specified)
+	$stamp = __('Publish <b>immediately</b>');
+	$date = date_i18n( $datef, strtotime( current_time('mysql') ) );
+}
+
+if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
+<div class="misc-pub-section curtime misc-pub-section-last">
+	<span id="timestamp">
+	<?php printf($stamp, $date); ?></span>
+	<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
+	<div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
+</div><?php // /misc-pub-section ?>
+<?php endif; ?>
+
+<?php do_action('post_submitbox_misc_actions'); ?>
+</div>
+<div class="clear"></div>
+</div>
+
+<div id="major-publishing-actions">
+<?php do_action('post_submitbox_start'); ?>
+<div id="delete-action">
+<?php
+if ( current_user_can( "delete_post", $post->ID ) ) {
+	if ( !EMPTY_TRASH_DAYS )
+		$delete_text = __('Delete Permanently');
+	else
+		$delete_text = __('Move to Trash');
+	?>
+<a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
+} ?>
+</div>
+
+<div id="publishing-action">
+<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" />
+<?php
+if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
+	if ( $can_publish ) :
+		if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
+		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
+		<?php submit_button( __( 'Schedule' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?>
+<?php	else : ?>
+		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
+		<?php submit_button( __( 'Publish' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?>
+<?php	endif;
+	else : ?>
+		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
+		<?php submit_button( __( 'Submit for Review' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?>
+<?php
+	endif;
+} else { ?>
+		<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
+		<input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
+<?php
+} ?>
+</div>
+<div class="clear"></div>
+</div>
+</div>
+
+<?php
+}
+
+/**
+ * Display post format form elements.
+ *
+ * @since 3.1.0
+ *
+ * @param object $post
+ */
+function post_format_meta_box( $post, $box ) {
+	if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
+	$post_formats = get_theme_support( 'post-formats' );
+
+	if ( is_array( $post_formats[0] ) ) :
+		$post_format = get_post_format( $post->ID );
+		if ( !$post_format )
+			$post_format = '0';
+		$post_format_display = get_post_format_string( $post_format );
+		// Add in the current one if it isn't there yet, in case the current theme doesn't support it
+		if ( $post_format && !in_array( $post_format, $post_formats[0] ) )
+			$post_formats[0][] = $post_format;
+	?>
+	<div id="post-formats-select">
+		<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0"><?php _e('Standard'); ?></label>
+		<?php foreach ( $post_formats[0] as $format ) : ?>
+		<br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
+		<?php endforeach; ?><br />
+	</div>
+	<?php endif; endif;
+}
+
+
+/**
+ * Display post tags form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_tags_meta_box($post, $box) {
+	$defaults = array('taxonomy' => 'post_tag');
+	if ( !isset($box['args']) || !is_array($box['args']) )
+		$args = array();
+	else
+		$args = $box['args'];
+	extract( wp_parse_args($args, $defaults), EXTR_SKIP );
+	$tax_name = esc_attr($taxonomy);
+	$taxonomy = get_taxonomy($taxonomy);
+	$disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
+?>
+<div class="tagsdiv" id="<?php echo $tax_name; ?>">
+	<div class="jaxtag">
+	<div class="nojs-tags hide-if-js">
+	<p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
+	<textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo get_terms_to_edit( $post->ID, $tax_name ); // textarea_escaped by esc_attr() ?></textarea></div>
+ 	<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
+	<div class="ajaxtag hide-if-no-js">
+		<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
+		<div class="taghint"><?php echo $taxonomy->labels->add_new_item; ?></div>
+		<p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
+		<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /></p>
+	</div>
+	<p class="howto"><?php echo esc_attr( $taxonomy->labels->separate_items_with_commas ); ?></p>
+	<?php endif; ?>
+	</div>
+	<div class="tagchecklist"></div>
+</div>
+<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
+<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p>
+<?php endif; ?>
+<?php
+}
+
+
+/**
+ * Display post categories form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_categories_meta_box( $post, $box ) {
+	$defaults = array('taxonomy' => 'category');
+	if ( !isset($box['args']) || !is_array($box['args']) )
+		$args = array();
+	else
+		$args = $box['args'];
+	extract( wp_parse_args($args, $defaults), EXTR_SKIP );
+	$tax = get_taxonomy($taxonomy);
+
+	?>
+	<div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
+		<ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs">
+			<li class="tabs"><a href="#<?php echo $taxonomy; ?>-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
+			<li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?>-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
+		</ul>
+
+		<div id="<?php echo $taxonomy; ?>-pop" class="tabs-panel" style="display: none;">
+			<ul id="<?php echo $taxonomy; ?>checklist-pop" class="categorychecklist form-no-clear" >
+				<?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?>
+			</ul>
+		</div>
+
+		<div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
+			<?php
+            $name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy . ']';
+            echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
+            ?>
+			<ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear">
+				<?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
+			</ul>
+		</div>
+	<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
+			<div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
+				<h4>
+					<a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3">
+						<?php
+							/* translators: %s: add new taxonomy label */
+							printf( __( '+ %s' ), $tax->labels->add_new_item );
+						?>
+					</a>
+				</h4>
+				<p id="<?php echo $taxonomy; ?>-add" class="category-add wp-hidden-child">
+					<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>"><?php echo $tax->labels->add_new_item; ?></label>
+					<input type="text" name="new<?php echo $taxonomy; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
+					<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>_parent">
+						<?php echo $tax->labels->parent_item_colon; ?>
+					</label>
+					<?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3 ) ); ?>
+					<input type="button" id="<?php echo $taxonomy; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-sumbit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
+					<?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce-add-'.$taxonomy, false ); ?>
+					<span id="<?php echo $taxonomy; ?>-ajax-response"></span>
+				</p>
+			</div>
+		<?php endif; ?>
+	</div>
+	<?php
+}
+
+
+/**
+ * Display post excerpt form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_excerpt_meta_box($post) {
+?>
+<label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
+<p><?php _e('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>'); ?></p>
+<?php
+}
+
+
+/**
+ * Display trackback links form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_trackback_meta_box($post) {
+	$form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" tabindex="7" value="'. esc_attr( str_replace("\n", ' ', $post->to_ping) ) .'" />';
+	if ('' != $post->pinged) {
+		$pings = '<p>'. __('Already pinged:') . '</p><ul>';
+		$already_pinged = explode("\n", trim($post->pinged));
+		foreach ($already_pinged as $pinged_url) {
+			$pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>";
+		}
+		$pings .= '</ul>';
+	}
+
+?>
+<p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?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&#8217;ve linked to them. If you link other WordPress sites they&#8217;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;
+}
+
+
+/**
+ * Display custom fields form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_custom_meta_box($post) {
+?>
+<div id="postcustomstuff">
+<div id="ajax-response"></div>
+<?php
+$metadata = has_meta($post->ID);
+list_meta($metadata);
+meta_form(); ?>
+</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>
+<?php
+}
+
+
+/**
+ * Display comments status form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_comment_status_meta_box($post) {
+?>
+<input name="advanced_view" type="hidden" value="1" />
+<p class="meta-options">
+	<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><br />
+	<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php printf( __( 'Allow <a href="%s" target="_blank">trackbacks and pingbacks</a> on this page.' ), __( 'http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); ?></label>
+	<?php do_action('post_comment_status_meta_box-options', $post); ?>
+</p>
+<?php
+}
+
+/**
+ * Display comments for post table header
+ *
+ * @since 3.0.0
+ *
+ * @param array $result table header rows
+ * @return array
+ */
+function post_comment_meta_box_thead($result) {
+	unset($result['cb'], $result['response']);
+	return $result;
+}
+
+/**
+ * Display comments for post.
+ *
+ * @since 2.8.0
+ *
+ * @param object $post
+ */
+function post_comment_meta_box($post) {
+	global $wpdb, $post_ID;
+
+	$total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
+
+	if ( 1 > $total ) {
+		echo '<p>' . __('No comments yet.') . '</p>';
+		return;
+	}
+
+	wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
+
+	$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
+	$wp_list_table->display( true );
+?>
+<p class="hide-if-no-js"><a href="#commentstatusdiv" id="show-comments" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /></p>
+<?php
+	$hidden = get_hidden_meta_boxes('post');
+	if ( ! in_array('commentsdiv', $hidden) ) { ?>
+		<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
+<?php
+	}
+	wp_comment_trashnotice();
+}
+
+
+/**
+ * Display slug form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_slug_meta_box($post) {
+?>
+<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $post->post_name ); ?>" />
+<?php
+}
+
+
+/**
+ * Display form field with list of authors.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_author_meta_box($post) {
+	global $user_ID;
+?>
+<label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label>
+<?php
+	wp_dropdown_users( array(
+		'who' => 'authors',
+		'name' => 'post_author_override',
+		'selected' => empty($post->ID) ? $user_ID : $post->post_author,
+		'include_selected' => true
+	) );
+}
+
+
+/**
+ * Display list of revisions.
+ *
+ * @since 2.6.0
+ *
+ * @param object $post
+ */
+function post_revisions_meta_box($post) {
+	wp_list_post_revisions();
+}
+
+
+// -- Page related Meta Boxes
+
+/**
+ * Display page attributes form fields.
+ *
+ * @since 2.7.0
+ *
+ * @param object $post
+ */
+function page_attributes_meta_box($post) {
+	$post_type_object = get_post_type_object($post->post_type);
+	if ( $post_type_object->hierarchical ) {
+		$pages = wp_dropdown_pages(array('post_type' => $post->post_type, 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column'=> 'menu_order, post_title', 'echo' => 0));
+		if ( ! empty($pages) ) {
+?>
+<p><strong><?php _e('Parent') ?></strong></p>
+<label class="screen-reader-text" for="parent_id"><?php _e('Parent') ?></label>
+<?php echo $pages; ?>
+<?php
+		} // end empty pages check
+	} // end hierarchical check.
+	if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
+		$template = !empty($post->page_template) ? $post->page_template : false;
+		?>
+<p><strong><?php _e('Template') ?></strong></p>
+<label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
+<option value='default'><?php _e('Default Template'); ?></option>
+<?php page_template_dropdown($template); ?>
+</select>
+<?php
+	} ?>
+<p><strong><?php _e('Order') ?></strong></p>
+<p><label class="screen-reader-text" for="menu_order"><?php _e('Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p>
+<p><?php if ( 'page' == $post->post_type ) _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?></p>
+<?php
+}
+
+
+// -- Link related Meta Boxes
+
+/**
+ * Display link create form fields.
+ *
+ * @since 2.7.0
+ *
+ * @param object $link
+ */
+function link_submit_meta_box($link) {
+?>
+<div class="submitbox" id="submitlink">
+
+<div id="minor-publishing">
+
+<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
+<div style="display:none;">
+<?php submit_button( __( 'Save' ), 'button', 'save', false ); ?>
+</div>
+
+<div id="minor-publishing-actions">
+<div id="preview-action">
+<?php if ( !empty($link->link_id) ) { ?>
+	<a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank" tabindex="4"><?php _e('Visit Link'); ?></a>
+<?php } ?>
+</div>
+<div class="clear"></div>
+</div>
+
+<div id="misc-publishing-actions">
+<div class="misc-pub-section misc-pub-section-last">
+	<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>
+</div>
+</div>
+
+</div>
+
+<div id="major-publishing-actions">
+<?php do_action('post_submitbox_start'); ?>
+<div id="delete-action">
+<?php
+if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
+	<a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
+<?php } ?>
+</div>
+
+<div id="publishing-action">
+<?php if ( !empty($link->link_id) ) { ?>
+	<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" />
+<?php } else { ?>
+	<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />
+<?php } ?>
+</div>
+<div class="clear"></div>
+</div>
+<?php do_action('submitlink_box'); ?>
+<div class="clear"></div>
+</div>
+<?php
+}
+
+
+/**
+ * Display link categories form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
+function link_categories_meta_box($link) { ?>
+<ul id="category-tabs" class="category-tabs">
+	<li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
+	<li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
+</ul>
+
+<div id="categories-all" class="tabs-panel">
+	<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
+		<?php
+		if ( isset($link->link_id) )
+			wp_link_category_checklist($link->link_id);
+		else
+			wp_link_category_checklist();
+		?>
+	</ul>
+</div>
+
+<div id="categories-pop" class="tabs-panel" style="display: none;">
+	<ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
+		<?php wp_popular_terms_checklist('link_category'); ?>
+	</ul>
+</div>
+
+<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">
+		<label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
+		<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />
+		<input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php esc_attr_e( 'Add' ); ?>" />
+		<?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
+		<span id="category-ajax-response"></span>
+	</p>
+</div>
+<?php
+}
+
+
+/**
+ * Display form fields for changing link target.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
+function link_target_meta_box($link) { ?>
+<fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>
+<p><label for="link_target_blank" class="selectit">
+<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
+<?php _e('<code>_blank</code> &mdash; new window or tab.'); ?></label></p>
+<p><label for="link_target_top" class="selectit">
+<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
+<?php _e('<code>_top</code> &mdash; current window or tab, with no frames.'); ?></label></p>
+<p><label for="link_target_none" class="selectit">
+<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
+<?php _e('<code>_none</code> &mdash; same window or tab.'); ?></label></p>
+</fieldset>
+<p><?php _e('Choose the target frame for your link.'); ?></p>
+<?php
+}
+
+
+/**
+ * Display checked checkboxes attribute for xfn microformat options.
+ *
+ * @since 1.0.1
+ *
+ * @param string $class
+ * @param string $value
+ * @param mixed $deprecated Never used.
+ */
+function xfn_check( $class, $value = '', $deprecated = '' ) {
+	global $link;
+
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '0.0' ); // Never implemented
+
+	$link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
+	$rels = preg_split('/\s+/', $link_rel);
+
+	if ('' != $value && in_array($value, $rels) ) {
+		echo ' checked="checked"';
+	}
+
+	if ('' == $value) {
+		if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"';
+		if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
+		if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
+		if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
+	}
+}
+
+
+/**
+ * Display xfn form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
+function link_xfn_meta_box($link) {
+?>
+<table class="editform" style="width: 100%;" cellspacing="2" cellpadding="5">
+	<tr>
+		<th style="width: 20%;" scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
+		<td style="width: 80%;"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td>
+	</tr>
+	<tr>
+		<td colspan="2">
+			<table cellpadding="3" cellspacing="5" class="form-table">
+				<tr>
+					<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </th>
+					<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?> </span></legend>
+						<label for="me">
+						<input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
+						<?php _e('another web address of mine') ?></label>
+					</fieldset></td>
+				</tr>
+				<tr>
+					<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </th>
+					<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?> </span></legend>
+						<label for="contact">
+						<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('contact') ?></label>
+						<label for="acquaintance">
+						<input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance'); ?> />  <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('acquaintance') ?></label>
+						<label for="friend">
+						<input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friend') ?></label>
+						<label for="friendship">
+						<input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
+					</fieldset></td>
+				</tr>
+				<tr>
+					<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th>
+					<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </span></legend>
+						<label for="met">
+						<input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?></label>
+					</fieldset></td>
+				</tr>
+				<tr>
+					<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th>
+					<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </span></legend>
+						<label for="co-worker">
+						<input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?></label>
+						<label for="colleague">
+						<input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?></label>
+					</fieldset></td>
+				</tr>
+				<tr>
+					<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </th>
+					<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend>
+						<label for="co-resident">
+						<input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?></label>
+						<label for="neighbor">
+						<input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?></label>
+						<label for="geographical">
+						<input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
+					</fieldset></td>
+				</tr>
+				<tr>
+					<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </th>
+					<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend>
+						<label for="child">
+						<input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child'); ?>  />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?></label>
+						<label for="kin">
+						<input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin'); ?>  />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?></label>
+						<label for="parent">
+						<input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?></label>
+						<label for="sibling">
+						<input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?></label>
+						<label for="spouse">
+						<input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?></label>
+						<label for="family">
+						<input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?></label>
+					</fieldset></td>
+				</tr>
+				<tr>
+					<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </th>
+					<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend>
+						<label for="muse">
+						<input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?></label>
+						<label for="crush">
+						<input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?></label>
+						<label for="date">
+						<input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?></label>
+						<label for="romantic">
+						<input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
+						<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?></label>
+					</fieldset></td>
+				</tr>
+			</table>
+		</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>
+<?php
+}
+
+
+/**
+ * Display advanced link options form fields.
+ *
+ * @since 2.6.0
+ *
+ * @param object $link
+ */
+function link_advanced_meta_box($link) {
+?>
+<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" class="code" id="link_image" size="50" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" style="width: 95%" /></td>
+	</tr>
+	<tr class="form-field">
+		<th valign="top"  scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
+		<td><input name="link_rss" class="code" type="text" id="rss_uri" value="<?php echo  ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" size="50" style="width: 95%" /></td>
+	</tr>
+	<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 ( isset( $link->link_notes ) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td>
+	</tr>
+	<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="'. esc_attr($r) .'" ');
+				if ( isset($link->link_rating) && $link->link_rating == $r)
+					echo 'selected="selected"';
+				echo('>'.$r.'</option>');
+			}
+		?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
+		</td>
+	</tr>
+</table>
+<?php
+}
+
+/**
+ * Display post thumbnail meta box.
+ *
+ * @since 2.9.0
+ */
+function post_thumbnail_meta_box() {
+	global $post;
+	$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
+	echo _wp_post_thumbnail_html( $thumbnail_id );
+}
Index: /tags/3.1/wp-admin/includes/misc.php
===================================================================
--- /tags/3.1/wp-admin/includes/misc.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/misc.php	(revision 17487)
@@ -0,0 +1,596 @@
+<?php
+/**
+ * Misc WordPress Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @return unknown
+ */
+function got_mod_rewrite() {
+	$got_rewrite = apache_mod_loaded('mod_rewrite', true);
+	return apply_filters('got_rewrite', $got_rewrite);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $filename
+ * @param unknown_type $marker
+ * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
+ */
+function extract_from_markers( $filename, $marker ) {
+	$result = array ();
+
+	if (!file_exists( $filename ) ) {
+		return $result;
+	}
+
+	if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));
+	{
+		$state = false;
+		foreach ( $markerdata as $markerline ) {
+			if (strpos($markerline, '# END ' . $marker) !== false)
+				$state = false;
+			if ( $state )
+				$result[] = $markerline;
+			if (strpos($markerline, '# BEGIN ' . $marker) !== false)
+				$state = true;
+		}
+	}
+
+	return $result;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Inserts an array of strings into a file (.htaccess ), placing it between
+ * BEGIN and END markers. Replaces existing marked info. Retains surrounding
+ * data. Creates file if none exists.
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $filename
+ * @param unknown_type $marker
+ * @param unknown_type $insertion
+ * @return bool True on write success, false on failure.
+ */
+function insert_with_markers( $filename, $marker, $insertion ) {
+	if (!file_exists( $filename ) || is_writeable( $filename ) ) {
+		if (!file_exists( $filename ) ) {
+			$markerdata = '';
+		} else {
+			$markerdata = explode( "\n", implode( '', file( $filename ) ) );
+		}
+
+		if ( !$f = @fopen( $filename, 'w' ) )
+			return false;
+
+		$foundit = false;
+		if ( $markerdata ) {
+			$state = true;
+			foreach ( $markerdata as $n => $markerline ) {
+				if (strpos($markerline, '# BEGIN ' . $marker) !== false)
+					$state = false;
+				if ( $state ) {
+					if ( $n + 1 < count( $markerdata ) )
+						fwrite( $f, "{$markerline}\n" );
+					else
+						fwrite( $f, "{$markerline}" );
+				}
+				if (strpos($markerline, '# END ' . $marker) !== false) {
+					fwrite( $f, "# BEGIN {$marker}\n" );
+					if ( is_array( $insertion ))
+						foreach ( $insertion as $insertline )
+							fwrite( $f, "{$insertline}\n" );
+					fwrite( $f, "# END {$marker}\n" );
+					$state = true;
+					$foundit = true;
+				}
+			}
+		}
+		if (!$foundit) {
+			fwrite( $f, "\n# BEGIN {$marker}\n" );
+			foreach ( $insertion as $insertline )
+				fwrite( $f, "{$insertline}\n" );
+			fwrite( $f, "# END {$marker}\n" );
+		}
+		fclose( $f );
+		return true;
+	} else {
+		return false;
+	}
+}
+
+/**
+ * Updates the htaccess file with the current rules if it is writable.
+ *
+ * Always writes to the file if it exists and is writable to ensure that we
+ * blank out old rules.
+ *
+ * @since 1.5.0
+ */
+function save_mod_rewrite_rules() {
+	if ( is_multisite() )
+		return;
+
+	global $wp_rewrite;
+
+	$home_path = get_home_path();
+	$htaccess_file = $home_path.'.htaccess';
+
+	// If the file doesn't already exist check for write access to the directory and whether we have some rules.
+	// else check for write access to the file.
+	if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
+		if ( got_mod_rewrite() ) {
+			$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
+			return insert_with_markers( $htaccess_file, 'WordPress', $rules );
+		}
+	}
+
+	return false;
+}
+
+/**
+ * Updates the IIS web.config file with the current rules if it is writable.
+ * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file.
+ *
+ * @since 2.8.0
+ *
+ * @return bool True if web.config was updated successfully
+ */
+function iis7_save_url_rewrite_rules(){
+	if ( is_multisite() )
+		return;
+
+	global $wp_rewrite;
+
+	$home_path = get_home_path();
+	$web_config_file = $home_path . 'web.config';
+
+	// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
+	if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) {
+		$rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
+		if ( ! empty($rule) ) {
+			return iis7_add_rewrite_rule($web_config_file, $rule);
+		} else {
+			return iis7_delete_rewrite_rule($web_config_file);
+		}
+	}
+	return false;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $file
+ */
+function update_recently_edited( $file ) {
+	$oldfiles = (array ) get_option( 'recently_edited' );
+	if ( $oldfiles ) {
+		$oldfiles = array_reverse( $oldfiles );
+		$oldfiles[] = $file;
+		$oldfiles = array_reverse( $oldfiles );
+		$oldfiles = array_unique( $oldfiles );
+		if ( 5 < count( $oldfiles ))
+			array_pop( $oldfiles );
+	} else {
+		$oldfiles[] = $file;
+	}
+	update_option( 'recently_edited', $oldfiles );
+}
+
+/**
+ * If siteurl or home changed, flush rewrite rules.
+ *
+ * @since 2.1.0
+ *
+ * @param unknown_type $old_value
+ * @param unknown_type $value
+ */
+function update_home_siteurl( $old_value, $value ) {
+	global $wp_rewrite;
+
+	if ( defined( "WP_INSTALLING" ) )
+		return;
+
+	// If home changed, write rewrite rules to new location.
+	$wp_rewrite->flush_rules();
+}
+
+add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
+add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
+
+/**
+ * Shorten an URL, to be used as link text
+ *
+ * @since 1.2.1
+ *
+ * @param string $url
+ * @return string
+ */
+function url_shorten( $url ) {
+	$short_url = str_replace( 'http://', '', stripslashes( $url ));
+	$short_url = str_replace( 'www.', '', $short_url );
+	if ('/' == substr( $short_url, -1 ))
+		$short_url = substr( $short_url, 0, -1 );
+	if ( strlen( $short_url ) > 35 )
+		$short_url = substr( $short_url, 0, 32 ).'...';
+	return $short_url;
+}
+
+/**
+ * Resets global variables based on $_GET and $_POST
+ *
+ * This function resets global variables based on the names passed
+ * in the $vars array to the value of $_POST[$var] or $_GET[$var] or ''
+ * if neither is defined.
+ *
+ * @since 2.0.0
+ *
+ * @param array $vars An array of globals to reset.
+ */
+function wp_reset_vars( $vars ) {
+	for ( $i=0; $i<count( $vars ); $i += 1 ) {
+		$var = $vars[$i];
+		global $$var;
+
+		if ( empty( $_POST[$var] ) ) {
+			if ( empty( $_GET[$var] ) )
+				$$var = '';
+			else
+				$$var = $_GET[$var];
+		} else {
+			$$var = $_POST[$var];
+		}
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.1.0
+ *
+ * @param unknown_type $message
+ */
+function show_message($message) {
+	if ( is_wp_error($message) ){
+		if ( $message->get_error_data() )
+			$message = $message->get_error_message() . ': ' . $message->get_error_data();
+		else
+			$message = $message->get_error_message();
+	}
+	echo "<p>$message</p>\n";
+	wp_ob_end_flush_all();
+	flush();
+}
+
+function wp_doc_link_parse( $content ) {
+	if ( !is_string( $content ) || empty( $content ) )
+		return array();
+
+	if ( !function_exists('token_get_all') )
+		return array();
+
+	$tokens = token_get_all( $content );
+	$functions = array();
+	$ignore_functions = array();
+	for ( $t = 0, $count = count( $tokens ); $t < $count; $t++ ) {
+		if ( !is_array( $tokens[$t] ) ) continue;
+		if ( T_STRING == $tokens[$t][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
+			// If it's a function or class defined locally, there's not going to be any docs available
+			if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
+				$ignore_functions[] = $tokens[$t][1];
+			}
+			// Add this to our stack of unique references
+			$functions[] = $tokens[$t][1];
+		}
+	}
+
+	$functions = array_unique( $functions );
+	sort( $functions );
+	$ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
+	$ignore_functions = array_unique( $ignore_functions );
+
+	$out = array();
+	foreach ( $functions as $function ) {
+		if ( in_array( $function, $ignore_functions ) )
+			continue;
+		$out[] = $function;
+	}
+
+	return $out;
+}
+
+/**
+ * Saves option for number of rows when listing posts, pages, comments, etc.
+ *
+ * @since 2.8
+**/
+function set_screen_options() {
+
+	if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
+		check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
+
+		if ( !$user = wp_get_current_user() )
+			return;
+		$option = $_POST['wp_screen_options']['option'];
+		$value = $_POST['wp_screen_options']['value'];
+
+		if ( !preg_match( '/^[a-z_-]+$/', $option ) )
+			return;
+
+		$option = str_replace('-', '_', $option);
+
+		$map_option = $option;
+		$type = str_replace('edit_', '', $map_option);
+		$type = str_replace('_per_page', '', $type);
+		if ( in_array($type, get_post_types()) )
+			$map_option = 'edit_per_page';
+		if ( in_array( $type, get_taxonomies()) )
+			$map_option = 'edit_tags_per_page';
+
+
+		switch ( $map_option ) {
+			case 'edit_per_page':
+			case 'users_per_page':
+			case 'edit_comments_per_page':
+			case 'upload_per_page':
+			case 'edit_tags_per_page':
+			case 'plugins_per_page':
+			// Network admin
+			case 'sites_network_per_page':
+			case 'users_network_per_page':
+			case 'site_users_network_per_page':
+			case 'plugins_network_per_page':
+			case 'themes_network_per_page':
+			case 'site_themes_network_per_page':
+				$value = (int) $value;
+				if ( $value < 1 || $value > 999 )
+					return;
+				break;
+			default:
+				$value = apply_filters('set-screen-option', false, $option, $value);
+				if ( false === $value )
+					return;
+				break;
+		}
+
+		update_user_meta($user->ID, $option, $value);
+		wp_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
+		exit;
+	}
+}
+
+function wp_menu_unfold() {
+	if ( isset($_GET['unfoldmenu']) ) {
+		delete_user_setting('mfold');
+		wp_redirect( remove_query_arg( 'unfoldmenu', stripslashes($_SERVER['REQUEST_URI']) ) );
+	 	exit;
+	}
+}
+
+/**
+ * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file
+ *
+ * @since 2.8.0
+ *
+ * @return bool
+ * @param string $filename The file path to the configuration file
+ */
+function iis7_rewrite_rule_exists($filename) {
+	if ( ! file_exists($filename) )
+		return false;
+	if ( ! class_exists('DOMDocument') )
+		return false;
+
+	$doc = new DOMDocument();
+	if ( $doc->load($filename) === false )
+		return false;
+	$xpath = new DOMXPath($doc);
+	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
+	if ( $rules->length == 0 )
+		return false;
+	else
+		return true;
+}
+
+/**
+ * Delete WordPress rewrite rule from web.config file if it exists there
+ *
+ * @since 2.8.0
+ *
+ * @param string $filename Name of the configuration file
+ * @return bool
+ */
+function iis7_delete_rewrite_rule($filename) {
+	// If configuration file does not exist then rules also do not exist so there is nothing to delete
+	if ( ! file_exists($filename) )
+		return true;
+
+	if ( ! class_exists('DOMDocument') )
+		return false;
+
+	$doc = new DOMDocument();
+	$doc->preserveWhiteSpace = false;
+
+	if ( $doc -> load($filename) === false )
+		return false;
+	$xpath = new DOMXPath($doc);
+	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
+	if ( $rules->length > 0 ) {
+		$child = $rules->item(0);
+		$parent = $child->parentNode;
+		$parent->removeChild($child);
+		$doc->formatOutput = true;
+		saveDomDocument($doc, $filename);
+	}
+	return true;
+}
+
+/**
+ * Add WordPress rewrite rule to the IIS 7 configuration file.
+ *
+ * @since 2.8.0
+ *
+ * @param string $filename The file path to the configuration file
+ * @param string $rewrite_rule The XML fragment with URL Rewrite rule
+ * @return bool
+ */
+function iis7_add_rewrite_rule($filename, $rewrite_rule) {
+	if ( ! class_exists('DOMDocument') )
+		return false;
+
+	// If configuration file does not exist then we create one.
+	if ( ! file_exists($filename) ) {
+		$fp = fopen( $filename, 'w');
+		fwrite($fp, '<configuration/>');
+		fclose($fp);
+	}
+
+	$doc = new DOMDocument();
+	$doc->preserveWhiteSpace = false;
+
+	if ( $doc->load($filename) === false )
+		return false;
+
+	$xpath = new DOMXPath($doc);
+
+	// First check if the rule already exists as in that case there is no need to re-add it
+	$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
+	if ( $wordpress_rules->length > 0 )
+		return true;
+
+	// Check the XPath to the rewrite rule and create XML nodes if they do not exist
+	$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
+	if ( $xmlnodes->length > 0 ) {
+		$rules_node = $xmlnodes->item(0);
+	} else {
+		$rules_node = $doc->createElement('rules');
+
+		$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
+		if ( $xmlnodes->length > 0 ) {
+			$rewrite_node = $xmlnodes->item(0);
+			$rewrite_node->appendChild($rules_node);
+		} else {
+			$rewrite_node = $doc->createElement('rewrite');
+			$rewrite_node->appendChild($rules_node);
+
+			$xmlnodes = $xpath->query('/configuration/system.webServer');
+			if ( $xmlnodes->length > 0 ) {
+				$system_webServer_node = $xmlnodes->item(0);
+				$system_webServer_node->appendChild($rewrite_node);
+			} else {
+				$system_webServer_node = $doc->createElement('system.webServer');
+				$system_webServer_node->appendChild($rewrite_node);
+
+				$xmlnodes = $xpath->query('/configuration');
+				if ( $xmlnodes->length > 0 ) {
+					$config_node = $xmlnodes->item(0);
+					$config_node->appendChild($system_webServer_node);
+				} else {
+					$config_node = $doc->createElement('configuration');
+					$doc->appendChild($config_node);
+					$config_node->appendChild($system_webServer_node);
+				}
+			}
+		}
+	}
+
+	$rule_fragment = $doc->createDocumentFragment();
+	$rule_fragment->appendXML($rewrite_rule);
+	$rules_node->appendChild($rule_fragment);
+
+	$doc->encoding = "UTF-8";
+	$doc->formatOutput = true;
+	saveDomDocument($doc, $filename);
+
+	return true;
+}
+
+/**
+ * Saves the XML document into a file
+ *
+ * @since 2.8.0
+ *
+ * @param DOMDocument $doc
+ * @param string $filename
+ */
+function saveDomDocument($doc, $filename) {
+	$config = $doc->saveXML();
+	$config = preg_replace("/([^\r])\n/", "$1\r\n", $config);
+	$fp = fopen($filename, 'w');
+	fwrite($fp, $config);
+	fclose($fp);
+}
+
+/**
+ * Workaround for Windows bug in is_writable() function
+ *
+ * @since 2.8.0
+ *
+ * @param string $path
+ * @return bool
+ */
+function win_is_writable( $path ) {
+	/* will work in despite of Windows ACLs bug
+	 * NOTE: use a trailing slash for folders!!!
+	 * see http://bugs.php.net/bug.php?id=27609
+	 * see http://bugs.php.net/bug.php?id=30931
+	 */
+
+	if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path
+		return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
+	else if ( is_dir( $path ) )
+		return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
+	// check tmp file for read/write capabilities
+	$should_delete_tmp_file = !file_exists( $path );
+	$f = @fopen( $path, 'a' );
+	if ( $f === false )
+		return false;
+	fclose( $f );
+	if ( $should_delete_tmp_file )
+		unlink( $path );
+	return true;
+}
+
+/**
+ * Display the default admin color scheme picker (Used in user-edit.php)
+ *
+ * @since 3.0.0
+ */
+function admin_color_scheme_picker() {
+	global $_wp_admin_css_colors, $user_id; ?>
+<fieldset><legend class="screen-reader-text"><span><?php _e('Admin Color Scheme')?></span></legend>
+<?php
+$current_color = get_user_option('admin_color', $user_id);
+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 esc_attr($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 ?>">&nbsp;</td>
+	<?php endforeach; ?>
+	</tr>
+	</table>
+
+	<label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
+</div>
+	<?php endforeach; ?>
+</fieldset>
+<?php
+}
+?>
Index: /tags/3.1/wp-admin/includes/ms-deprecated.php
===================================================================
--- /tags/3.1/wp-admin/includes/ms-deprecated.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/ms-deprecated.php	(revision 17487)
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Deprecated multisite admin functions from past WordPress versions and WordPress MU.
+ * You shouldn't use these functions and look for the alternatives instead. The functions
+ * will be removed in a later version.
+ *
+ * @package WordPress
+ * @subpackage Deprecated
+ * @since 3.0.0
+ */
+
+/**
+ * @deprecated 3.0.0
+ */
+function wpmu_menu() {
+	_deprecated_function(__FUNCTION__, '3.0' );
+	// deprecated. See #11763
+}
+
+/**
+  * Determines if the available space defined by the admin has been exceeded by the user.
+  *
+  * @deprecated 3.0.0
+  * @see is_upload_space_available()
+ */
+function wpmu_checkAvailableSpace() {
+	_deprecated_function(__FUNCTION__, '3.0', 'is_upload_space_available()' );
+
+	if ( !is_upload_space_available() )
+		wp_die( __('Sorry, you must delete files before you can upload any more.') );
+}
+
+/**
+ * @deprecated 3.0.0
+ */
+function mu_options( $options ) {
+	_deprecated_function(__FUNCTION__, '3.0' );
+	return $options;
+}
+
+/**
+ * @deprecated 3.0.0
+ * @see activate_plugin()
+ */
+function activate_sitewide_plugin() {
+	_deprecated_function(__FUNCTION__, '3.0', 'activate_plugin()' );
+	return false;
+}
+
+/**
+ * @deprecated 3.0.0
+ * @see deactivate_sitewide_plugin()
+ */
+function deactivate_sitewide_plugin( $plugin = false ) {
+	_deprecated_function(__FUNCTION__, '3.0', 'deactivate_plugin()' );
+	return;
+}
+
+/**
+ * @deprecated 3.0.0
+ * @see is_network_only_plugin()
+ */
+function is_wpmu_sitewide_plugin( $file ) {
+	_deprecated_function(__FUNCTION__, '3.0', 'is_network_only_plugin()' );
+	return is_network_only_plugin( $file );
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/ms.php
===================================================================
--- /tags/3.1/wp-admin/includes/ms.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/ms.php	(revision 17487)
@@ -0,0 +1,763 @@
+<?php
+/**
+ * Multisite administration functions.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/**
+ * Determine if uploaded file exceeds space quota.
+ *
+ * @since 3.0.0
+ *
+ * @param array $file $_FILES array for a given file.
+ * @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise.
+ */
+function check_upload_size( $file ) {
+	if ( get_site_option( 'upload_space_check_disabled' ) )
+		return $file;
+
+	if ( $file['error'] != '0' ) // there's already an error
+		return $file;
+
+	if ( defined( 'WP_IMPORTING' ) )
+		return $file;
+
+	$space_allowed = 1048576 * get_space_allowed();
+	$space_used = get_dirsize( BLOGUPLOADDIR );
+	$space_left = $space_allowed - $space_used;
+	$file_size = filesize( $file['tmp_name'] );
+	if ( $space_left < $file_size )
+		$file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) );
+	if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
+		$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
+	if ( upload_is_user_over_quota( false ) ) {
+		$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
+	}
+	if ( $file['error'] != '0' && !isset($_POST['html-upload']) )
+		wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
+
+	return $file;
+}
+add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
+
+/**
+ * Delete a blog
+ *
+ * @since 3.0.0
+ *
+ * @param int $blog_id Blog ID
+ * @param bool $drop True if blog's table should be dropped.  Default is false.
+ * @return void
+ */
+function wpmu_delete_blog( $blog_id, $drop = false ) {
+	global $wpdb;
+
+	$switch = false;
+	if ( $blog_id != $wpdb->blogid ) {
+		$switch = true;
+		switch_to_blog( $blog_id );
+	}
+
+	$blog_prefix = $wpdb->get_blog_prefix( $blog_id );
+
+	do_action( 'delete_blog', $blog_id, $drop );
+
+	$users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
+
+	// Remove users from this blog.
+	if ( ! empty( $users ) ) {
+		foreach ( $users as $user_id ) {
+			remove_user_from_blog( $user_id, $blog_id) ;
+		}
+	}
+
+	update_blog_status( $blog_id, 'deleted', 1 );
+
+	if ( $drop ) {
+		if ( substr( $blog_prefix, -1 ) == '_' )
+			$blog_prefix =  substr( $blog_prefix, 0, -1 ) . '\_';
+
+		$drop_tables = $wpdb->get_results( "SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A );
+		$drop_tables = apply_filters( 'wpmu_drop_tables', $drop_tables );
+
+		reset( $drop_tables );
+		foreach ( (array) $drop_tables as $drop_table) {
+			$wpdb->query( "DROP TABLE IF EXISTS ". current( $drop_table ) ."" );
+		}
+		$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) );
+		$dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
+		$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
+		$top_dir = $dir;
+		$stack = array($dir);
+		$index = 0;
+
+		while ( $index < count( $stack ) ) {
+			# Get indexed directory from stack
+			$dir = $stack[$index];
+
+			$dh = @opendir( $dir );
+			if ( $dh ) {
+				while ( ( $file = @readdir( $dh ) ) !== false ) {
+					if ( $file == '.' || $file == '..' )
+						continue;
+
+					if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) )
+						$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
+					else if ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) )
+						@unlink( $dir . DIRECTORY_SEPARATOR . $file );
+				}
+			}
+			$index++;
+		}
+
+		$stack = array_reverse( $stack );  // Last added dirs are deepest
+		foreach( (array) $stack as $dir ) {
+			if ( $dir != $top_dir)
+			@rmdir( $dir );
+		}
+	}
+
+	$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'" );
+	$blogs = get_site_option( 'blog_list' );
+	if ( is_array( $blogs ) ) {
+		foreach ( $blogs as $n => $blog ) {
+			if ( $blog['blog_id'] == $blog_id )
+				unset( $blogs[$n] );
+		}
+		update_site_option( 'blog_list', $blogs );
+	}
+
+	if ( $switch === true )
+		restore_current_blog();
+}
+
+// @todo Merge with wp_delete_user() ?
+function wpmu_delete_user( $id ) {
+	global $wpdb;
+
+	$id = (int) $id;
+
+	do_action( 'wpmu_delete_user', $id );
+
+	$blogs = get_blogs_of_user( $id );
+
+	if ( ! empty( $blogs ) ) {
+		foreach ( $blogs as $blog ) {
+			switch_to_blog( $blog->userblog_id );
+			remove_user_from_blog( $id, $blog->userblog_id );
+
+			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
+			foreach ( (array) $post_ids as $post_id ) {
+				wp_delete_post( $post_id );
+			}
+
+			// Clean links
+			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
+
+			if ( $link_ids ) {
+				foreach ( $link_ids as $link_id )
+					wp_delete_link( $link_id );
+			}
+
+			restore_current_blog();
+		}
+	}
+
+	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id ) );
+	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
+
+	clean_user_cache( $id );
+
+	// allow for commit transaction
+	do_action( 'deleted_user', $id );
+
+	return true;
+}
+
+function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
+	$themes = get_themes();
+
+	if ( $blog_id != 0 )
+		switch_to_blog( $blog_id );
+
+	$blog_allowed_themes = get_option( 'allowedthemes' );
+	if ( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes
+		$blog_allowed_themes = get_option( 'allowed_themes' );
+
+		if ( is_array( $blog_allowed_themes ) ) {
+			foreach( (array) $themes as $key => $theme ) {
+				$theme_key = esc_html( $theme['Stylesheet'] );
+				if ( isset( $blog_allowed_themes[$key] ) == true ) {
+					$blog_allowedthemes[$theme_key] = 1;
+				}
+			}
+			$blog_allowed_themes = $blog_allowedthemes;
+			add_option( 'allowedthemes', $blog_allowed_themes );
+			delete_option( 'allowed_themes' );
+		}
+	}
+
+	if ( $blog_id != 0 )
+		restore_current_blog();
+
+	return $blog_allowed_themes;
+}
+
+function update_option_new_admin_email( $old_value, $value ) {
+	$email = get_option( 'admin_email' );
+	if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
+		return;
+
+	$hash = md5( $value. time() .mt_rand() );
+	$new_admin_email = array(
+		'hash' => $hash,
+		'newemail' => $value
+	);
+	update_option( 'adminhash', $new_admin_email );
+
+	$content = apply_filters( 'new_admin_email_content', __( "Dear user,
+
+You recently requested to have the administration email address on
+your site changed.
+If this is correct, please click on the following link to change it:
+###ADMIN_URL###
+
+You can safely ignore and delete this email if you do not want to
+take this action.
+
+This email has been sent to ###EMAIL###
+
+Regards,
+All at ###SITENAME###
+###SITEURL### "), $new_admin_email );
+
+	$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
+	$content = str_replace( '###EMAIL###', $value, $content );
+	$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
+	$content = str_replace( '###SITEURL###', network_home_url(), $content );
+
+	wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), get_option( 'blogname' ) ), $content );
+}
+add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
+add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
+
+function send_confirmation_on_profile_email() {
+	global $errors, $wpdb;
+	$current_user = wp_get_current_user();
+	if ( ! is_object($errors) )
+		$errors = new WP_Error();
+
+	if ( $current_user->id != $_POST['user_id'] )
+		return false;
+
+	if ( $current_user->user_email != $_POST['email'] ) {
+		if ( !is_email( $_POST['email'] ) ) {
+			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) );
+			return;
+		}
+
+		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
+			$errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address is already used." ), array( 'form-field' => 'email' ) );
+			delete_option( $current_user->ID . '_new_email' );
+			return;
+		}
+
+		$hash = md5( $_POST['email'] . time() . mt_rand() );
+		$new_user_email = array(
+				'hash' => $hash,
+				'newemail' => $_POST['email']
+				);
+		update_option( $current_user->ID . '_new_email', $new_user_email );
+
+		$content = apply_filters( 'new_user_email_content', __( "Dear user,
+
+You recently requested to have the email address on your account changed.
+If this is correct, please click on the following link to change it:
+###ADMIN_URL###
+
+You can safely ignore and delete this email if you do not want to
+take this action.
+
+This email has been sent to ###EMAIL###
+
+Regards,
+All at ###SITENAME###
+###SITEURL###" ), $new_user_email );
+
+		$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
+		$content = str_replace( '###EMAIL###', $_POST['email'], $content);
+		$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
+		$content = str_replace( '###SITEURL###', network_home_url(), $content );
+
+		wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), get_option( 'blogname' ) ), $content );
+		$_POST['email'] = $current_user->user_email;
+	}
+}
+add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
+
+function new_user_email_admin_notice() {
+	if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
+		echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
+}
+add_action( 'admin_notices', 'new_user_email_admin_notice' );
+
+function get_site_allowed_themes() {
+	$themes = get_themes();
+	$allowed_themes = get_site_option( 'allowedthemes' );
+	if ( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
+		$allowed_themes = get_site_option( 'allowed_themes' ); // convert old allowed_themes format
+		if ( !is_array( $allowed_themes ) ) {
+			$allowed_themes = array();
+		} else {
+			foreach( (array) $themes as $key => $theme ) {
+				$theme_key = esc_html( $theme['Stylesheet'] );
+				if ( isset( $allowed_themes[ $key ] ) == true ) {
+					$allowedthemes[ $theme_key ] = 1;
+				}
+			}
+			$allowed_themes = $allowedthemes;
+		}
+	}
+	return $allowed_themes;
+}
+
+/**
+ * Determines if there is any upload space left in the current blog's quota.
+ *
+ * @since 3.0.0
+ * @return bool True if space is available, false otherwise.
+ */
+function is_upload_space_available() {
+	if ( get_site_option( 'upload_space_check_disabled' ) )
+		return true;
+
+	if ( !( $space_allowed = get_upload_space_available() ) )
+		return false;
+
+	return true;
+}
+
+/**
+ * @since 3.0.0
+ *
+ * @return int of upload size limit in bytes
+ */
+function upload_size_limit_filter( $size ) {
+	$fileupload_maxk = 1024 * get_site_option( 'fileupload_maxk', 1500 );
+	if ( get_site_option( 'upload_space_check_disabled' ) )
+		return min( $size, $fileupload_maxk );
+
+	return min( $size, $fileupload_maxk, get_upload_space_available() );
+}
+/**
+ * Determines if there is any upload space left in the current blog's quota.
+ *
+ * @return int of upload space available in bytes
+ */
+function get_upload_space_available() {
+	$space_allowed = get_space_allowed() * 1024 * 1024;
+	if ( get_site_option( 'upload_space_check_disabled' ) )
+		return $space_allowed;
+
+	$dir_name = trailingslashit( BLOGUPLOADDIR );
+	if ( !( is_dir( $dir_name) && is_readable( $dir_name ) ) )
+		return $space_allowed;
+
+  	$dir = dir( $dir_name );
+   	$size = 0;
+
+	while ( $file = $dir->read() ) {
+		if ( $file != '.' && $file != '..' ) {
+			if ( is_dir( $dir_name . $file) ) {
+				$size += get_dirsize( $dir_name . $file );
+			} else {
+				$size += filesize( $dir_name . $file );
+			}
+		}
+	}
+	$dir->close();
+
+	if ( ( $space_allowed - $size ) <= 0 )
+		return 0;
+
+	return $space_allowed - $size;
+}
+
+/**
+ * Returns the upload quota for the current blog.
+ *
+ * @return int Quota
+ */
+function get_space_allowed() {
+	$space_allowed = get_option( 'blog_upload_space' );
+	if ( $space_allowed == false )
+		$space_allowed = get_site_option( 'blog_upload_space' );
+	if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) )
+		$space_allowed = 50;
+
+	return $space_allowed;
+}
+
+function display_space_usage() {
+	$space = get_space_allowed();
+	$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
+
+	$percentused = ( $used / $space ) * 100;
+
+	if ( $space > 1000 ) {
+		$space = number_format( $space / 1024 );
+		/* translators: Gigabytes */
+		$space .= __( 'GB' );
+	} else {
+		/* translators: Megabytes */
+		$space .= __( 'MB' );
+	}
+	?>
+	<strong><?php printf( __( 'Used: %1s%% of %2s' ), number_format( $percentused ), $space ); ?></strong>
+	<?php
+}
+
+// Edit blog upload space setting on Edit Blog page
+function upload_space_setting( $id ) {
+	$quota = get_blog_option( $id, 'blog_upload_space' );
+	if ( !$quota )
+		$quota = '';
+
+	?>
+	<tr>
+		<th><?php _e( 'Site Upload Space Quota '); ?></th>
+		<td><input type="text" size="3" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /> <?php _e( 'MB (Leave blank for network default)' ); ?></td>
+	</tr>
+	<?php
+}
+add_action( 'wpmueditblogaction', 'upload_space_setting' );
+
+function update_user_status( $id, $pref, $value, $deprecated = null ) {
+	global $wpdb;
+
+	if ( null !== $deprecated  )
+		_deprecated_argument( __FUNCTION__, '3.1' );
+
+	$wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) );
+
+	clean_user_cache( $id );
+
+	if ( $pref == 'spam' ) {
+		if ( $value == 1 )
+			do_action( 'make_spam_user', $id );
+		else
+			do_action( 'make_ham_user', $id );
+	}
+
+	return $value;
+}
+
+function refresh_user_details( $id ) {
+	$id = (int) $id;
+
+	if ( !$user = get_userdata( $id ) )
+		return false;
+
+	clean_user_cache( $id );
+
+	return $id;
+}
+
+function format_code_lang( $code = '' ) {
+	$code = strtolower( substr( $code, 0, 2 ) );
+	$lang_codes = array(
+		'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
+		'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
+		'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijjian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic',
+		'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue',
+		'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz',
+		'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam',
+		'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål',
+		'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian',
+		'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili',
+		'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek',
+		've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
+	$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
+	return strtr( $code, $lang_codes );
+}
+
+function sync_category_tag_slugs( $term, $taxonomy ) {
+	if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
+		if ( is_object( $term ) ) {
+			$term->slug = sanitize_title( $term->name );
+		} else {
+			$term['slug'] = sanitize_title( $term['name'] );
+		}
+	}
+	return $term;
+}
+add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
+
+function redirect_user_to_blog() {
+	$c = 0;
+	if ( isset( $_GET['c'] ) )
+		$c = (int) $_GET['c'];
+
+	if ( $c >= 5 ) {
+		wp_die( __( "You don&#8217;t have permission to view this site. Please contact the system administrator." ) );
+	}
+	$c ++;
+
+	$blog = get_active_blog_for_user( get_current_user_id() );
+
+	if ( is_object( $blog ) ) {
+		wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
+	} else {
+		wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case"
+	}
+	exit;
+}
+add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
+
+function check_import_new_users( $permission ) {
+	if ( !is_super_admin() )
+		return false;
+	return true;
+}
+add_filter( 'import_allow_create_users', 'check_import_new_users' );
+// See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
+
+function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
+	$flag = false;
+	$output = array();
+
+	foreach ( (array) $lang_files as $val ) {
+		$code_lang = basename( $val, '.mo' );
+
+		if ( $code_lang == 'en_US' ) { // American English
+			$flag = true;
+			$ae = __( 'American English' );
+			$output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
+		} elseif ( $code_lang == 'en_GB' ) { // British English
+			$flag = true;
+			$be = __( 'British English' );
+			$output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
+		} else {
+			$translated = format_code_lang( $code_lang );
+			$output[$translated] =  '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>';
+		}
+
+	}
+
+	if ( $flag === false ) // WordPress english
+		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
+
+	// Order by name
+	uksort( $output, 'strnatcasecmp' );
+
+	$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
+	echo implode( "\n\t", $output );
+}
+
+/* Warn the admin if SECRET SALT information is missing from wp-config.php */
+function secret_salt_warning() {
+	if ( !is_super_admin() )
+		return;
+	$secret_keys = array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' );
+	$out = '';
+	foreach( $secret_keys as $key ) {
+		if ( ! defined( $key ) )
+			$out .= "define( '$key', '" . esc_html( wp_generate_password( 64, true, true ) ) . "' );<br />";
+	}
+	if ( $out != '' ) {
+		$msg  = __( 'Warning! WordPress encrypts user cookies, but you must add the following lines to <strong>wp-config.php</strong> for it to be more secure.' );
+		$msg .= '<br/>' . __( "Before the line <code>/* That's all, stop editing! Happy blogging. */</code> please add this code:" );
+		$msg .= "<br/><br/><code>$out</code>";
+
+		echo "<div class='update-nag'>$msg</div>";
+	}
+}
+add_action( 'network_admin_notices', 'secret_salt_warning' );
+
+function site_admin_notice() {
+	global $wp_db_version;
+	if ( !is_super_admin() )
+		return false;
+	if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version )
+		echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Update Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
+}
+add_action( 'admin_notices', 'site_admin_notice' );
+add_action( 'network_admin_notices', 'site_admin_notice' );
+
+function avoid_blog_page_permalink_collision( $data, $postarr ) {
+	if ( is_subdomain_install() )
+		return $data;
+	if ( $data['post_type'] != 'page' )
+		return $data;
+	if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
+		return $data;
+	if ( !is_main_site() )
+		return $data;
+
+	$post_name = $data['post_name'];
+	$c = 0;
+	while( $c < 10 && get_id_from_blogname( $post_name ) ) {
+		$post_name .= mt_rand( 1, 10 );
+		$c ++;
+	}
+	if ( $post_name != $data['post_name'] ) {
+		$data['post_name'] = $post_name;
+	}
+	return $data;
+}
+add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
+
+function choose_primary_blog() {
+	?>
+	<table class="form-table">
+	<tr>
+	<?php /* translators: My sites label */ ?>
+		<th scope="row"><?php _e( 'Primary Site' ); ?></th>
+		<td>
+		<?php
+		$all_blogs = get_blogs_of_user( get_current_user_id() );
+		$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
+		if ( count( $all_blogs ) > 1 ) {
+			$found = false;
+			?>
+			<select name="primary_blog">
+				<?php foreach( (array) $all_blogs as $blog ) {
+					if ( $primary_blog == $blog->userblog_id )
+						$found = true;
+					?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog,  $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
+				} ?>
+			</select>
+			<?php
+			if ( !$found ) {
+				$blog = array_shift( $all_blogs );
+				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
+			}
+		} elseif ( count( $all_blogs ) == 1 ) {
+			$blog = array_shift( $all_blogs );
+			echo $blog->domain;
+			if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
+				update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
+		} else {
+			echo "N/A";
+		}
+		?>
+		</td>
+	</tr>
+	<?php if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) : ?>
+		<tr>
+			<th scope="row" colspan="2" class="th-full">
+				<a href="<?php echo apply_filters( 'wp_signup_location', network_home_url( 'wp-signup.php' ) ); ?>"><?php _e( 'Create a New Site' ); ?></a>
+			</th>
+		</tr>
+	<?php endif; ?>
+	</table>
+	<?php
+}
+
+function ms_deprecated_blogs_file() {
+	if ( ! is_super_admin() )
+		return;
+	if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )
+		return;
+	echo '<div class="update-nag">' . sprintf( __( 'The <code>%1$s</code> file is deprecated. Please remove it and update your server rewrite rules to use <code>%2$s</code> instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '</div>';
+}
+add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
+
+/**
+ * Grants super admin privileges.
+ *
+ * @since 3.0.0
+ * @param int $user_id
+ */
+function grant_super_admin( $user_id ) {
+	global $super_admins;
+
+	// If global super_admins override is defined, there is nothing to do here.
+	if ( isset($super_admins) )
+		return false;
+
+	do_action( 'grant_super_admin', $user_id );
+
+	// Directly fetch site_admins instead of using get_super_admins()
+	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
+
+	$user = new WP_User( $user_id );
+	if ( ! in_array( $user->user_login, $super_admins ) ) {
+		$super_admins[] = $user->user_login;
+		update_site_option( 'site_admins' , $super_admins );
+		do_action( 'granted_super_admin', $user_id );
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Revokes super admin privileges.
+ *
+ * @since 3.0.0
+ * @param int $user_id
+ */
+function revoke_super_admin( $user_id ) {
+	global $super_admins;
+
+	// If global super_admins override is defined, there is nothing to do here.
+	if ( isset($super_admins) )
+		return false;
+
+	do_action( 'revoke_super_admin', $user_id );
+
+	// Directly fetch site_admins instead of using get_super_admins()
+	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
+
+	$user = new WP_User( $user_id );
+	if ( $user->user_email != get_site_option( 'admin_email' ) ) {
+		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
+			unset( $super_admins[$key] );
+			update_site_option( 'site_admins', $super_admins );
+			do_action( 'revoked_super_admin', $user_id );
+			return true;
+		}
+	}
+	return false;
+}
+
+/**
+ * Whether or not we can edit this network from this page
+ *
+ * By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
+ *
+ * @since 3.1.0
+ * @param integer $site_id The network/site id to check.
+ */
+function can_edit_network( $site_id ) {
+	global $wpdb;
+
+	if ($site_id == $wpdb->siteid )
+		$result = true;
+	else
+		$result = false;
+
+	return apply_filters( 'can_edit_network', $result, $site_id );
+}
+
+/**
+ * Thickbox image paths for Network Admin.
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _thickbox_path_admin_subfolder() {
+?>
+<script type="text/javascript">
+//<![CDATA[
+var tb_pathToImage = "../../wp-includes/js/thickbox/loadingAnimation.gif";
+var tb_closeImage = "../../wp-includes/js/thickbox/tb-close.png";
+//]]>
+</script>
+<?php
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/nav-menu.php
===================================================================
--- /tags/3.1/wp-admin/includes/nav-menu.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/nav-menu.php	(revision 17487)
@@ -0,0 +1,1133 @@
+<?php
+
+/**
+ * Create HTML list of nav menu input items.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ * @uses Walker_Nav_Menu
+ */
+class Walker_Nav_Menu_Edit extends Walker_Nav_Menu  {
+	/**
+	 * @see Walker_Nav_Menu::start_lvl()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference.
+	 */
+	function start_lvl(&$output) {}
+
+	/**
+	 * @see Walker_Nav_Menu::end_lvl()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference.
+	 */
+	function end_lvl(&$output) {
+	}
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $item Menu item data object.
+	 * @param int $depth Depth of menu item. Used for padding.
+	 * @param object $args
+	 */
+	function start_el(&$output, $item, $depth, $args) {
+		global $_wp_nav_menu_max_depth;
+		$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
+
+		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
+
+		ob_start();
+		$item_id = esc_attr( $item->ID );
+		$removed_args = array(
+			'action',
+			'customlink-tab',
+			'edit-menu-item',
+			'menu-item',
+			'page-tab',
+			'_wpnonce',
+		);
+
+		$original_title = '';
+		if ( 'taxonomy' == $item->type ) {
+			$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
+		} elseif ( 'post_type' == $item->type ) {
+			$original_object = get_post( $item->object_id );
+			$original_title = $original_object->post_title;
+		}
+
+		$classes = array(
+			'menu-item menu-item-depth-' . $depth,
+			'menu-item-' . esc_attr( $item->object ),
+			'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
+		);
+
+		$title = $item->title;
+
+		if ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
+			$classes[] = 'pending';
+			/* translators: %s: title of menu item in draft status */
+			$title = sprintf( __('%s (Pending)'), $item->title );
+		}
+
+		$title = empty( $item->label ) ? $title : $item->label;
+
+		?>
+		<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
+			<dl class="menu-item-bar">
+				<dt class="menu-item-handle">
+					<span class="item-title"><?php echo esc_html( $title ); ?></span>
+					<span class="item-controls">
+						<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
+						<span class="item-order">
+							<a href="<?php
+								echo wp_nonce_url(
+									add_query_arg(
+										array(
+											'action' => 'move-up-menu-item',
+											'menu-item' => $item_id,
+										),
+										remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
+									),
+									'move-menu_item'
+								);
+							?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up'); ?>">&#8593;</abbr></a>
+							|
+							<a href="<?php
+								echo wp_nonce_url(
+									add_query_arg(
+										array(
+											'action' => 'move-down-menu-item',
+											'menu-item' => $item_id,
+										),
+										remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
+									),
+									'move-menu_item'
+								);
+							?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">&#8595;</abbr></a>
+						</span>
+						<a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php _e('Edit Menu Item'); ?>" href="<?php
+							echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
+						?>"><?php _e( 'Edit Menu Item' ); ?></a>
+					</span>
+				</dt>
+			</dl>
+
+			<div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
+				<?php if( 'custom' == $item->type ) : ?>
+					<p class="field-url description description-wide">
+						<label for="edit-menu-item-url-<?php echo $item_id; ?>">
+							<?php _e( 'URL' ); ?><br />
+							<input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
+						</label>
+					</p>
+				<?php endif; ?>
+				<p class="description description-thin">
+					<label for="edit-menu-item-title-<?php echo $item_id; ?>">
+						<?php _e( 'Navigation Label' ); ?><br />
+						<input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
+					</label>
+				</p>
+				<p class="description description-thin">
+					<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
+						<?php _e( 'Title Attribute' ); ?><br />
+						<input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
+					</label>
+				</p>
+				<p class="field-link-target description description-thin">
+					<label for="edit-menu-item-target-<?php echo $item_id; ?>">
+						<?php _e( 'Link Target' ); ?><br />
+						<select id="edit-menu-item-target-<?php echo $item_id; ?>" class="widefat edit-menu-item-target" name="menu-item-target[<?php echo $item_id; ?>]">
+							<option value="" <?php selected( $item->target, ''); ?>><?php _e('Same window or tab'); ?></option>
+							<option value="_blank" <?php selected( $item->target, '_blank'); ?>><?php _e('New window or tab'); ?></option>
+						</select>
+					</label>
+				</p>
+				<p class="field-css-classes description description-thin">
+					<label for="edit-menu-item-classes-<?php echo $item_id; ?>">
+						<?php _e( 'CSS Classes (optional)' ); ?><br />
+						<input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
+					</label>
+				</p>
+				<p class="field-xfn description description-thin">
+					<label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
+						<?php _e( 'Link Relationship (XFN)' ); ?><br />
+						<input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
+					</label>
+				</p>
+				<p class="field-description description description-wide">
+					<label for="edit-menu-item-description-<?php echo $item_id; ?>">
+						<?php _e( 'Description' ); ?><br />
+						<textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea>
+						<span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
+					</label>
+				</p>
+
+				<div class="menu-item-actions description-wide submitbox">
+					<?php if( 'custom' != $item->type ) : ?>
+						<p class="link-to-original">
+							<?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
+						</p>
+					<?php endif; ?>
+					<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
+					echo wp_nonce_url(
+						add_query_arg(
+							array(
+								'action' => 'delete-menu-item',
+								'menu-item' => $item_id,
+							),
+							remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
+						),
+						'delete-menu_item_' . $item_id
+					); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep"> | </span> <a class="item-cancel submitcancel" id="cancel-<?php echo $item_id; ?>" href="<?php	echo add_query_arg( array('edit-menu-item' => $item_id, 'cancel' => time()), remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) );
+						?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a>
+				</div>
+
+				<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
+				<input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
+				<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
+				<input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
+				<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
+				<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
+			</div><!-- .menu-item-settings-->
+			<ul class="menu-item-transport"></ul>
+		<?php
+		$output .= ob_get_clean();
+	}
+}
+
+/**
+ * Create HTML list of nav menu input items.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ * @uses Walker_Nav_Menu
+ */
+class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu  {
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $item Menu item data object.
+	 * @param int $depth Depth of menu item. Used for padding.
+	 * @param object $args
+	 */
+	function start_el(&$output, $item, $depth, $args) {
+		global $_nav_menu_placeholder;
+
+		$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
+		$possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
+		$possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
+
+		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
+
+		$output .= $indent . '<li>';
+		$output .= '<label class="menu-item-title">';
+		$output .= '<input type="checkbox" class="menu-item-checkbox';
+		if ( ! empty( $item->_add_to_top ) ) {
+			$output .= ' add-to-top';
+		}
+		$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> ';
+		$output .= empty( $item->label ) ? esc_html( $item->title ) : esc_html( $item->label );
+		$output .= '</label>';
+
+		// Menu item hidden fields
+		$output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
+		$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
+		$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
+	}
+}
+
+/**
+ * Prints the appropriate response to a menu quick search.
+ *
+ * @since 3.0.0
+ *
+ * @param array $request The unsanitized request values.
+ */
+function _wp_ajax_menu_quick_search( $request = array() ) {
+	$args = array();
+	$type = isset( $request['type'] ) ? $request['type'] : '';
+	$object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
+	$query = isset( $request['q'] ) ? $request['q'] : '';
+	$response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json';
+
+	if ( 'markup' == $response_format ) {
+		$args['walker'] = new Walker_Nav_Menu_Checklist;
+	}
+
+	if ( 'get-post-item' == $type ) {
+		if ( post_type_exists( $object_type ) ) {
+			if ( isset( $request['ID'] ) ) {
+				$object_id = (int) $request['ID'];
+				if ( 'markup' == $response_format ) {
+					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
+				} elseif ( 'json' == $response_format ) {
+					$post_obj = get_post( $object_id );
+					echo json_encode(
+						array(
+							'ID' => $object_id,
+							'post_title' => get_the_title( $object_id ),
+							'post_type' => get_post_type( $object_id ),
+						)
+					);
+					echo "\n";
+				}
+			}
+		} elseif ( taxonomy_exists( $object_type ) ) {
+			if ( isset( $request['ID'] ) ) {
+				$object_id = (int) $request['ID'];
+				if ( 'markup' == $response_format ) {
+					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
+				} elseif ( 'json' == $response_format ) {
+					$post_obj = get_term( $object_id, $object_type );
+					echo json_encode(
+						array(
+							'ID' => $object_id,
+							'post_title' => $post_obj->name,
+							'post_type' => $object_type,
+						)
+					);
+					echo "\n";
+				}
+			}
+
+		}
+
+
+	} elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {
+		if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
+			query_posts(array(
+				'posts_per_page' => 10,
+				'post_type' => $matches[2],
+				's' => $query,
+			));
+			if ( ! have_posts() )
+				return;
+			while ( have_posts() ) {
+				the_post();
+				if ( 'markup' == $response_format ) {
+					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref = get_the_ID() ) ) ), 0, (object) $args );
+				} elseif ( 'json' == $response_format ) {
+					echo json_encode(
+						array(
+							'ID' => get_the_ID(),
+							'post_title' => get_the_title(),
+							'post_type' => get_post_type(),
+						)
+					);
+					echo "\n";
+				}
+			}
+		} elseif ( 'taxonomy' == $matches[1] ) {
+			$terms = get_terms( $matches[2], array(
+				'name__like' => $query,
+				'number' => 10,
+			));
+			if ( empty( $terms ) || is_wp_error( $terms ) )
+				return;
+			foreach( (array) $terms as $term ) {
+				if ( 'markup' == $response_format ) {
+					echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
+				} elseif ( 'json' == $response_format ) {
+					echo json_encode(
+						array(
+							'ID' => $term->term_id,
+							'post_title' => $term->name,
+							'post_type' => $matches[2],
+						)
+					);
+					echo "\n";
+				}
+			}
+		}
+	}
+}
+
+/**
+ * Register nav menu metaboxes and advanced menu items
+ *
+ * @since 3.0.0
+ **/
+function wp_nav_menu_setup() {
+	// Register meta boxes
+	if ( wp_get_nav_menus() )
+		add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
+	add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
+	wp_nav_menu_post_type_meta_boxes();
+	wp_nav_menu_taxonomy_meta_boxes();
+
+	// Register advanced menu items (columns)
+	add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
+
+	// If first time editing, disable advanced items by default.
+	if( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
+		$user = wp_get_current_user();
+		update_user_option($user->ID, 'managenav-menuscolumnshidden',
+			array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', ),
+			true);
+	}
+}
+
+/**
+ * Limit the amount of meta boxes to just links, pages and cats for first time users.
+ *
+ * @since 3.0.0
+ **/
+function wp_initial_nav_menu_meta_boxes() {
+	global $wp_meta_boxes;
+
+	if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
+		return;
+
+	$initial_meta_boxes = array( 'nav-menu-theme-locations', 'add-custom-links', 'add-page', 'add-category' );
+	$hidden_meta_boxes = array();
+
+	foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
+		foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
+			foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
+				if ( in_array( $box['id'], $initial_meta_boxes ) ) {
+					unset( $box['id'] );
+				} else {
+					$hidden_meta_boxes[] = $box['id'];
+				}
+			}
+		}
+	}
+
+	$user = wp_get_current_user();
+	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
+}
+
+/**
+ * Creates metaboxes for any post type menu item.
+ *
+ * @since 3.0.0
+ */
+function wp_nav_menu_post_type_meta_boxes() {
+	$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
+
+	if ( ! $post_types )
+		return;
+
+	foreach ( $post_types as $post_type ) {
+		$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
+		if ( $post_type ) {
+			$id = $post_type->name;
+			add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
+		}
+	}
+}
+
+/**
+ * Creates metaboxes for any taxonomy menu item.
+ *
+ * @since 3.0.0
+ */
+function wp_nav_menu_taxonomy_meta_boxes() {
+	$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
+
+	if ( !$taxonomies )
+		return;
+
+	foreach ( $taxonomies as $tax ) {
+		$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
+		if ( $tax ) {
+			$id = $tax->name;
+			add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
+		}
+	}
+}
+
+/**
+ * Displays a metabox for the nav menu theme locations.
+ *
+ * @since 3.0.0
+ */
+function wp_nav_menu_locations_meta_box() {
+	global $nav_menu_selected_id;
+
+	if ( ! current_theme_supports( 'menus' ) ) {
+		// We must only support widgets. Leave a message and bail.
+		echo '<p class="howto">' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p>';
+		return;
+	}
+
+	$locations = get_registered_nav_menus();
+	$menus = wp_get_nav_menus();
+	$menu_locations = get_nav_menu_locations();
+	$num_locations = count( array_keys($locations) );
+
+	echo '<p class="howto">' . sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n($num_locations) ) . '</p>';
+
+	foreach ( $locations as $location => $description ) {
+		?>
+		<p>
+			<label class="howto" for="locations-<?php echo $location; ?>">
+				<span><?php echo $description; ?></span>
+				<select name="menu-locations[<?php echo $location; ?>]" id="locations-<?php echo $location; ?>">
+					<option value="0"></option>
+					<?php foreach ( $menus as $menu ) : ?>
+					<option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?>
+						value="<?php echo $menu->term_id; ?>"><?php
+						$truncated_name = wp_html_excerpt( $menu->name, 40 );
+						echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '&hellip;';
+					?></option>
+					<?php endforeach; ?>
+				</select>
+			</label>
+		</p>
+	<?php
+	}
+	?>
+	<p class="button-controls">
+		<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+		<?php submit_button( __( 'Save' ), 'primary', 'nav-menu-locations', false, disabled( $nav_menu_selected_id, 0, false ) ); ?>
+	</p>
+	<?php
+}
+
+/**
+ * Displays a metabox for the custom links menu item.
+ *
+ * @since 3.0.0
+ */
+function wp_nav_menu_item_link_meta_box() {
+	global $_nav_menu_placeholder, $nav_menu_selected_id;
+	$_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
+
+	$current_tab = 'create';
+	if ( isset( $_REQUEST['customlink-tab'] ) && in_array( $_REQUEST['customlink-tab'], array('create', 'all') ) ) {
+		$current_tab = $_REQUEST['customlink-tab'];
+	}
+
+	$removed_args = array(
+		'action',
+		'customlink-tab',
+		'edit-menu-item',
+		'menu-item',
+		'page-tab',
+		'_wpnonce',
+	);
+
+	?>
+	<div class="customlinkdiv" id="customlinkdiv">
+
+			<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
+			<p id="menu-item-url-wrap">
+				<label class="howto" for="custom-menu-item-url">
+					<span><?php _e('URL'); ?></span>
+					<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text" class="code menu-item-textbox" value="http://" />
+				</label>
+			</p>
+
+			<p id="menu-item-name-wrap">
+				<label class="howto" for="custom-menu-item-name">
+					<span><?php _e('Label'); ?></span>
+					<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Menu Item'); ?>" />
+				</label>
+			</p>
+
+		<p class="button-controls">
+			<span class="add-to-menu">
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+				<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
+			</span>
+		</p>
+
+	</div><!-- /.customlinkdiv -->
+	<?php
+}
+
+/**
+ * Displays a metabox for a post type menu item.
+ *
+ * @since 3.0.0
+ *
+ * @param string $object Not used.
+ * @param string $post_type The post type object.
+ */
+function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
+	global $_nav_menu_placeholder, $nav_menu_selected_id;
+
+	$post_type_name = $post_type['args']->name;
+
+	// paginate browsing for large numbers of post objects
+	$per_page = 50;
+	$pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
+	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
+
+	$args = array(
+		'offset' => $offset,
+		'order' => 'ASC',
+		'orderby' => 'title',
+		'posts_per_page' => $per_page,
+		'post_type' => $post_type_name,
+		'suppress_filters' => true,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false
+	);
+
+	if ( isset( $post_type['args']->_default_query ) )
+		$args = array_merge($args, (array) $post_type['args']->_default_query );
+
+	// @todo transient caching of these results with proper invalidation on updating of a post of this type
+	$get_posts = new WP_Query;
+	$posts = $get_posts->query( $args );
+	if ( ! $get_posts->post_count ) {
+		echo '<p>' . __( 'No items.' ) . '</p>';
+		return;
+	}
+
+	$post_type_object = get_post_type_object($post_type_name);
+
+	$num_pages = $get_posts->max_num_pages;
+
+	$page_links = paginate_links( array(
+		'base' => add_query_arg(
+			array(
+				$post_type_name . '-tab' => 'all',
+				'paged' => '%#%',
+				'item-type' => 'post_type',
+				'item-object' => $post_type_name,
+			)
+		),
+		'format' => '',
+		'prev_text' => __('&laquo;'),
+		'next_text' => __('&raquo;'),
+		'total' => $num_pages,
+		'current' => $pagenum
+	));
+
+	if ( !$posts )
+		$error = '<li id="error">'. $post_type['args']->labels->not_found .'</li>';
+
+	$walker = new Walker_Nav_Menu_Checklist;
+
+	$current_tab = 'most-recent';
+	if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
+		$current_tab = $_REQUEST[$post_type_name . '-tab'];
+	}
+
+	if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
+		$current_tab = 'search';
+	}
+
+	$removed_args = array(
+		'action',
+		'customlink-tab',
+		'edit-menu-item',
+		'menu-item',
+		'page-tab',
+		'_wpnonce',
+	);
+
+	?>
+	<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
+		<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
+			<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"><?php _e('Most Recent'); ?></a></li>
+			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li>
+			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"><?php _e('Search'); ?></a></li>
+		</ul>
+
+		<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php
+			echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
+		?>">
+			<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
+				<?php
+				$recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) );
+				$most_recent = $get_posts->query( $recent_args );
+				$args['walker'] = $walker;
+				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args );
+				?>
+			</ul>
+		</div><!-- /.tabs-panel -->
+
+		<div class="tabs-panel <?php
+			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
+		?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
+			<?php
+			if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
+				$searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] );
+				$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
+			} else {
+				$searched = '';
+				$search_results = array();
+			}
+			?>
+			<p class="quick-search-wrap">
+				<input type="text" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" />
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+				<?php submit_button( __( 'Search' ), 'quick-search-submit button-secondary hide-if-js', 'submit', false ); ?>
+			</p>
+
+			<ul id="<?php echo $post_type_name; ?>-search-checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear">
+			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
+				<?php
+				$args['walker'] = $walker;
+				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
+				?>
+			<?php elseif ( is_wp_error( $search_results ) ) : ?>
+				<li><?php echo $search_results->get_error_message(); ?></li>
+			<?php elseif ( ! empty( $searched ) ) : ?>
+				<li><?php _e('No results found.'); ?></li>
+			<?php endif; ?>
+			</ul>
+		</div><!-- /.tabs-panel -->
+
+
+		<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
+			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
+		?>">
+			<?php if ( ! empty( $page_links ) ) : ?>
+				<div class="add-menu-item-pagelinks">
+					<?php echo $page_links; ?>
+				</div>
+			<?php endif; ?>
+			<ul id="<?php echo $post_type_name; ?>checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear">
+				<?php
+				$args['walker'] = $walker;
+
+				// if we're dealing with pages, let's put a checkbox for the front page at the top of the list
+				if ( 'page' == $post_type_name ) {
+					$front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;
+					if ( ! empty( $front_page ) ) {
+						$front_page_obj = get_post( $front_page );
+						$front_page_obj->_add_to_top = true;
+						$front_page_obj->label = sprintf( _x('Home: %s', 'nav menu front page title'), $front_page_obj->post_title );
+						array_unshift( $posts, $front_page_obj );
+					} else {
+						$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
+						array_unshift( $posts, (object) array(
+							'_add_to_top' => true,
+							'ID' => 0,
+							'object_id' => $_nav_menu_placeholder,
+							'post_content' => '',
+							'post_excerpt' => '',
+							'post_title' => _x('Home', 'nav menu home label'),
+							'post_type' => 'nav_menu_item',
+							'type' => 'custom',
+							'url' => home_url('/'),
+						) );
+					}
+				}
+
+				$checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
+
+				if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
+					$checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);
+
+				}
+
+				echo $checkbox_items;
+				?>
+			</ul>
+			<?php if ( ! empty( $page_links ) ) : ?>
+				<div class="add-menu-item-pagelinks">
+					<?php echo $page_links; ?>
+				</div>
+			<?php endif; ?>
+		</div><!-- /.tabs-panel -->
+
+
+		<p class="button-controls">
+			<span class="list-controls">
+				<a href="<?php
+					echo esc_url(add_query_arg(
+						array(
+							$post_type_name . '-tab' => 'all',
+							'selectall' => 1,
+						),
+						remove_query_arg($removed_args)
+					));
+				?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
+			</span>
+
+			<span class="add-to-menu">
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+				<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="submit-posttype-<?php echo $post_type_name; ?>" />
+			</span>
+		</p>
+
+	</div><!-- /.posttypediv -->
+	<?php
+}
+
+/**
+ * Displays a metabox for a taxonomy menu item.
+ *
+ * @since 3.0.0
+ *
+ * @param string $object Not used.
+ * @param string $taxonomy The taxonomy object.
+ */
+function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
+	global $nav_menu_selected_id;
+	$taxonomy_name = $taxonomy['args']->name;
+
+	// paginate browsing for large numbers of objects
+	$per_page = 50;
+	$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
+	$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
+
+	$args = array(
+		'child_of' => 0,
+		'exclude' => '',
+		'hide_empty' => false,
+		'hierarchical' => 1,
+		'include' => '',
+		'include_last_update_time' => false,
+		'number' => $per_page,
+		'offset' => $offset,
+		'order' => 'ASC',
+		'orderby' => 'name',
+		'pad_counts' => false,
+	);
+
+	$terms = get_terms( $taxonomy_name, $args );
+
+	if ( ! $terms || is_wp_error($terms) ) {
+		echo '<p>' . __( 'No items.' ) . '</p>';
+		return;
+	}
+
+	$num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page );
+
+	$page_links = paginate_links( array(
+		'base' => add_query_arg(
+			array(
+				$taxonomy_name . '-tab' => 'all',
+				'paged' => '%#%',
+				'item-type' => 'taxonomy',
+				'item-object' => $taxonomy_name,
+			)
+		),
+		'format' => '',
+		'prev_text' => __('&laquo;'),
+		'next_text' => __('&raquo;'),
+		'total' => $num_pages,
+		'current' => $pagenum
+	));
+
+	$walker = new Walker_Nav_Menu_Checklist;
+
+	$current_tab = 'most-used';
+	if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {
+		$current_tab = $_REQUEST[$taxonomy_name . '-tab'];
+	}
+
+	if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
+		$current_tab = 'search';
+	}
+
+	$removed_args = array(
+		'action',
+		'customlink-tab',
+		'edit-menu-item',
+		'menu-item',
+		'page-tab',
+		'_wpnonce',
+	);
+
+	?>
+	<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
+		<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
+			<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"><?php _e('Most Used'); ?></a></li>
+			<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"><?php _e('View All'); ?></a></li>
+			<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"><?php _e('Search'); ?></a></li>
+		</ul>
+
+		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
+			echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
+		?>">
+			<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
+				<?php
+				$popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
+				$args['walker'] = $walker;
+				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );
+				?>
+			</ul>
+		</div><!-- /.tabs-panel -->
+
+		<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
+			echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
+		?>">
+			<?php if ( ! empty( $page_links ) ) : ?>
+				<div class="add-menu-item-pagelinks">
+					<?php echo $page_links; ?>
+				</div>
+			<?php endif; ?>
+			<ul id="<?php echo $taxonomy_name; ?>checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear">
+				<?php
+				$args['walker'] = $walker;
+				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args );
+				?>
+			</ul>
+			<?php if ( ! empty( $page_links ) ) : ?>
+				<div class="add-menu-item-pagelinks">
+					<?php echo $page_links; ?>
+				</div>
+			<?php endif; ?>
+		</div><!-- /.tabs-panel -->
+
+		<div class="tabs-panel <?php
+			echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
+		?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
+			<?php
+			if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
+				$searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] );
+				$search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
+			} else {
+				$searched = '';
+				$search_results = array();
+			}
+			?>
+			<p class="quick-search-wrap">
+				<input type="text" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" />
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+				<?php submit_button( __( 'Search' ), 'quick-search-submit button-secondary hide-if-js', 'submit', false ); ?>
+			</p>
+
+			<ul id="<?php echo $taxonomy_name; ?>-search-checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear">
+			<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
+				<?php
+				$args['walker'] = $walker;
+				echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
+				?>
+			<?php elseif ( is_wp_error( $search_results ) ) : ?>
+				<li><?php echo $search_results->get_error_message(); ?></li>
+			<?php elseif ( ! empty( $searched ) ) : ?>
+				<li><?php _e('No results found.'); ?></li>
+			<?php endif; ?>
+			</ul>
+		</div><!-- /.tabs-panel -->
+
+		<p class="button-controls">
+			<span class="list-controls">
+				<a href="<?php
+					echo esc_url(add_query_arg(
+						array(
+							$taxonomy_name . '-tab' => 'all',
+							'selectall' => 1,
+						),
+						remove_query_arg($removed_args)
+					));
+				?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
+			</span>
+
+			<span class="add-to-menu">
+				<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+				<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="submit-taxonomy-<?php echo $taxonomy_name; ?>" />
+			</span>
+		</p>
+
+	</div><!-- /.taxonomydiv -->
+	<?php
+}
+
+/**
+ * Save posted nav menu item data.
+ *
+ * @since 3.0.0
+ *
+ * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a draft, orphaned menu item.
+ * @param array $menu_data The unsanitized posted menu item data.
+ * @return array The database IDs of the items saved
+ */
+function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
+	$menu_id = (int) $menu_id;
+	$items_saved = array();
+
+	if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
+
+		// Loop through all the menu items' POST values
+		foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
+			if (
+				empty( $_item_object_data['menu-item-object-id'] ) && // checkbox is not checked
+				(
+					! isset( $_item_object_data['menu-item-type'] ) || // and item type either isn't set
+					in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || // or URL is the default
+					! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) ||  // or it's not a custom menu item (but not the custom home page)
+					! empty( $_item_object_data['menu-item-db-id'] ) // or it *is* a custom menu item that already exists
+				)
+			) {
+				continue; // then this potential menu item is not getting added to this menu
+			}
+
+			// if this possible menu item doesn't actually have a menu database ID yet
+			if (
+				empty( $_item_object_data['menu-item-db-id'] ) ||
+				( 0 > $_possible_db_id ) ||
+				$_possible_db_id != $_item_object_data['menu-item-db-id']
+			) {
+				$_actual_db_id = 0;
+			} else {
+				$_actual_db_id = (int) $_item_object_data['menu-item-db-id'];
+			}
+
+			$args = array(
+				'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
+				'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
+				'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
+				'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
+				'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
+				'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
+				'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
+				'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
+				'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
+				'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
+				'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
+				'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
+				'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
+			);
+
+			$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
+
+		}
+	}
+	return $items_saved;
+}
+
+/**
+ * Adds custom arguments to some of the meta box object types.
+ *
+ * @since 3.0.0
+ *
+ * @access private
+ *
+ * @param object $object The post type or taxonomy meta-object.
+ * @return object The post type of taxonomy object.
+ */
+function _wp_nav_menu_meta_box_object( $object = null ) {
+	if ( isset( $object->name ) ) {
+
+		if ( 'page' == $object->name ) {
+			$object->_default_query = array(
+				'orderby' => 'menu_order title',
+				'post_status' => 'publish',
+			);
+
+		// posts should show only published items
+		} elseif ( 'post' == $object->name ) {
+			$object->_default_query = array(
+				'post_status' => 'publish',
+			);
+
+		// cats should be in reverse chronological order
+		} elseif ( 'category' == $object->name ) {
+			$object->_default_query = array(
+				'orderby' => 'id',
+				'order' => 'DESC',
+			);
+
+		// custom post types should show only published items
+		} else {
+			$object->_default_query = array(
+				'post_status' => 'publish',
+			);
+		}
+	}
+
+	return $object;
+}
+
+/**
+ * Returns the menu formatted to edit.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu_id The ID of the menu to format.
+ * @return string|WP_Error $output The menu formatted to edit or error object on failure.
+ */
+function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
+	$menu = wp_get_nav_menu_object( $menu_id );
+
+	// If the menu exists, get its items.
+	if ( is_nav_menu( $menu ) ) {
+		$menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
+		$result = '<div id="menu-instructions" class="post-body-plain';
+		$result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';
+		$result .= '<p>' . __('Select menu items (pages, categories, links) from the boxes at left to begin building your custom menu.') . '</p>';
+		$result .= '</div>';
+
+		if( empty($menu_items) )
+			return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
+
+		$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
+
+		if ( class_exists( $walker_class_name ) )
+			$walker = new $walker_class_name;
+		else
+			return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );
+
+		$some_pending_menu_items = false;
+		foreach( (array) $menu_items as $menu_item ) {
+			if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
+				$some_pending_menu_items = true;
+		}
+
+		if ( $some_pending_menu_items )
+			$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
+
+		$result .= '<ul class="menu" id="menu-to-edit"> ';
+		$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
+		$result .= ' </ul> ';
+		return $result;
+	} elseif ( is_wp_error( $menu ) ) {
+		return $menu;
+	}
+
+
+}
+
+/**
+ * Returns the columns for the nav menus page.
+ *
+ * @since 3.0.0
+ *
+ * @return string|WP_Error $output The menu formatted to edit or error object on failure.
+ */
+function wp_nav_menu_manage_columns() {
+	return array(
+		'_title' => __('Show advanced menu properties'),
+		'cb' => '<input type="checkbox" />',
+		'link-target' => __('Link Target'),
+		'css-classes' => __('CSS Classes'),
+		'xfn' => __('Link Relationship (XFN)'),
+		'description' => __('Description'),
+	);
+}
+
+/**
+ * Deletes orphaned draft menu items
+ *
+ * @access private
+ * @since 3.0.0
+ *
+ */
+function _wp_delete_orphaned_draft_menu_items() {
+	global $wpdb;
+	$delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
+
+	// delete orphaned draft menu items
+	$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
+
+	foreach( (array) $menu_items_to_delete as $menu_item_id )
+		wp_delete_post( $menu_item_id, true );
+}
+
+add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items');
+
+?>
Index: /tags/3.1/wp-admin/includes/plugin-install.php
===================================================================
--- /tags/3.1/wp-admin/includes/plugin-install.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/plugin-install.php	(revision 17487)
@@ -0,0 +1,370 @@
+<?php
+/**
+ * WordPress Plugin Install Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Retrieve plugin installer pages from WordPress Plugins API.
+ *
+ * It is possible for a plugin to override the Plugin API result with three
+ * filters. Assume this is for plugins, which can extend on the Plugin Info to
+ * offer more choices. This is very powerful and must be used with care, when
+ * overridding the filters.
+ *
+ * The first filter, 'plugins_api_args', is for the args and gives the action as
+ * the second parameter. The hook for 'plugins_api_args' must ensure that an
+ * object is returned.
+ *
+ * The second filter, 'plugins_api', is the result that would be returned.
+ *
+ * @since 2.7.0
+ *
+ * @param string $action
+ * @param array|object $args Optional. Arguments to serialize for the Plugin Info API.
+ * @return object plugins_api response object on success, WP_Error on failure.
+ */
+function plugins_api($action, $args = null) {
+
+	if ( is_array($args) )
+		$args = (object)$args;
+
+	if ( !isset($args->per_page) )
+		$args->per_page = 24;
+
+	// Allows a plugin to override the WordPress.org API entirely.
+	// Use the filter 'plugins_api_result' to mearly add results.
+	// Please ensure that a object is returned from the following filters.
+	$args = apply_filters('plugins_api_args', $args, $action);
+	$res = apply_filters('plugins_api', false, $action, $args);
+
+	if ( false === $res ) {
+		$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))) );
+		if ( is_wp_error($request) ) {
+			$res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() );
+		} else {
+			$res = unserialize($request['body']);
+			if ( false === $res )
+				$res = new WP_Error('plugins_api_failed', __('An unknown error occurred.'), $request['body']);
+		}
+	} elseif ( !is_wp_error($res) ) {
+		$res->external = true;
+	}
+
+	return apply_filters('plugins_api_result', $res, $action, $args);
+}
+
+/**
+ * Retrieve popular WordPress plugin tags.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args
+ * @return array
+ */
+function install_popular_tags( $args = array() ) {
+	$key = md5(serialize($args));
+	if ( false !== ($tags = get_site_transient('poptags_' . $key) ) )
+		return $tags;
+
+	$tags = plugins_api('hot_tags', $args);
+
+	if ( is_wp_error($tags) )
+		return $tags;
+
+	set_site_transient('poptags_' . $key, $tags, 10800); // 3 * 60 * 60 = 10800
+
+	return $tags;
+}
+
+function install_dashboard() {
+	?>
+	<p><?php _e('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> or upload a plugin in .zip format via this page.') ?></p>
+
+	<h4><?php _e('Search') ?></h4>
+	<p class="install-help"><?php _e('Search for plugins by keyword, author, or tag.') ?></p>
+	<?php install_search_form(); ?>
+
+	<h4><?php _e('Popular tags') ?></h4>
+	<p class="install-help"><?php _e('You may also browse based on the most popular tags in the Plugin Directory:') ?></p>
+	<?php
+
+	$api_tags = install_popular_tags();
+
+	echo '<p class="popular-tags">';
+	if ( is_wp_error($api_tags) ) {
+		echo $api_tags->get_error_message();
+	} else {
+		//Set up the tags in a way which can be interprated by wp_generate_tag_cloud()
+		$tags = array();
+		foreach ( (array)$api_tags as $tag )
+			$tags[ $tag['name'] ] = (object) array(
+									'link' => esc_url( self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ),
+									'name' => $tag['name'],
+									'id' => sanitize_title_with_dashes($tag['name']),
+									'count' => $tag['count'] );
+		echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%d plugin'), 'multiple_text' => __('%d plugins') ) );
+	}
+	echo '</p><br class="clear" />';
+}
+add_action('install_plugins_dashboard', 'install_dashboard');
+
+/**
+ * Display search form for searching plugins.
+ *
+ * @since 2.7.0
+ */
+function install_search_form(){
+	$type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
+	$term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
+
+	?><form id="search-plugins" method="get" action="">
+		<input type="hidden" name="tab" value="search" />
+		<select name="type" id="typeselector">
+			<option value="term"<?php selected('term', $type) ?>><?php _e('Term'); ?></option>
+			<option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
+			<option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
+		</select>
+		<input type="text" name="s" value="<?php echo esc_attr($term) ?>" />
+		<label class="screen-reader-text" for="plugin-search-input"><?php _e('Search Plugins'); ?></label>
+		<?php submit_button( __( 'Search Plugins' ), 'button', 'plugin-search-input', false ); ?>
+	</form><?php
+}
+
+/**
+ * Upload from zip
+ * @since 2.8.0
+ *
+ * @param string $page
+ */
+function install_plugins_upload( $page = 1 ) {
+?>
+	<h4><?php _e('Install a plugin in .zip format') ?></h4>
+	<p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.') ?></p>
+	<form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-plugin') ?>">
+		<?php wp_nonce_field( 'plugin-upload') ?>
+		<label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label>
+		<input type="file" id="pluginzip" name="pluginzip" />
+		<input type="submit" class="button" value="<?php esc_attr_e('Install Now') ?>" />
+	</form>
+<?php
+}
+add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
+
+/**
+ * Display plugin content based on plugin list.
+ *
+ * @since 2.7.0
+ */
+function display_plugins_table() {
+	global $wp_list_table;
+
+	$wp_list_table->display();
+}
+add_action('install_plugins_search', 'display_plugins_table');
+add_action('install_plugins_featured', 'display_plugins_table');
+add_action('install_plugins_popular', 'display_plugins_table');
+add_action('install_plugins_new', 'display_plugins_table');
+add_action('install_plugins_updated', 'display_plugins_table');
+
+/**
+ * Determine the status we can perform on a plugin.
+ *
+ * @since 3.0.0
+ */
+function install_plugin_install_status($api, $loop = false) {
+	// this function is called recursivly, $loop prevents futhur loops.
+	if ( is_array($api) )
+		$api = (object) $api;
+
+	//Default to a "new" plugin
+	$status = 'install';
+	$url = false;
+
+	//Check to see if this plugin is known to be installed, and has an update awaiting it.
+	$update_plugins = get_site_transient('update_plugins');
+	if ( is_object( $update_plugins ) ) {
+		foreach ( (array)$update_plugins->response as $file => $plugin ) {
+			if ( $plugin->slug === $api->slug ) {
+				$status = 'update_available';
+				$update_file = $file;
+				$version = $plugin->new_version;
+				if ( current_user_can('update_plugins') )
+					$url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file);
+				break;
+			}
+		}
+	}
+
+	if ( 'install' == $status ) {
+		if ( is_dir( WP_PLUGIN_DIR  . '/' . $api->slug ) ) {
+			$installed_plugin = get_plugins('/' . $api->slug);
+			if ( empty($installed_plugin) ) {
+				if ( current_user_can('install_plugins') )
+					$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
+			} else {
+				$key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
+				if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
+					$status = 'latest_installed';
+				} elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
+					$status = 'newer_installed';
+					$version = $installed_plugin[ $key ]['Version'];
+				} else {
+					//If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
+					if ( ! $loop ) {
+						delete_site_transient('update_plugins');
+						wp_update_plugins();
+						return install_plugin_install_status($api, true);
+					}
+				}
+			}
+		} else {
+			// "install" & no directory with that slug
+			if ( current_user_can('install_plugins') )
+				$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
+		}
+	}
+	if ( isset($_GET['from']) )
+		$url .= '&amp;from=' . urlencode(stripslashes($_GET['from']));
+
+	return compact('status', 'url', 'version');
+}
+
+/**
+ * Display plugin information in dialog box form.
+ *
+ * @since 2.7.0
+ */
+function install_plugin_information() {
+	global $tab;
+
+	$api = plugins_api('plugin_information', array('slug' => stripslashes( $_REQUEST['plugin'] ) ));
+
+	if ( is_wp_error($api) )
+		wp_die($api);
+
+	$plugins_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
+								'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
+								'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
+								'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
+								'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
+								'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
+	//Sanitize HTML
+	foreach ( (array)$api->sections as $section_name => $content )
+		$api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
+	foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key )
+		$api->$key = wp_kses($api->$key, $plugins_allowedtags);
+
+	$section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
+	if ( empty($section) || ! isset($api->sections[ $section ]) )
+		$section = array_shift( $section_titles = array_keys((array)$api->sections) );
+
+	iframe_header( __('Plugin Install') );
+	echo "<div id='$tab-header'>\n";
+	echo "<ul id='sidemenu'>\n";
+	foreach ( (array)$api->sections as $section_name => $content ) {
+
+		$title = $section_name;
+		$title = ucwords(str_replace('_', ' ', $title));
+
+		$class = ( $section_name == $section ) ? ' class="current"' : '';
+		$href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
+		$href = esc_url($href);
+		$san_title = esc_attr(sanitize_title_with_dashes($title));
+		echo "\t<li><a name='$san_title' target='' href='$href'$class>$title</a></li>\n";
+	}
+	echo "</ul>\n";
+	echo "</div>\n";
+	?>
+	<div class="alignright fyi">
+		<?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?>
+		<p class="action-button">
+		<?php
+		$status = install_plugin_install_status($api);
+		switch ( $status['status'] ) {
+			case 'install':
+				if ( $status['url'] )
+					echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
+				break;
+			case 'update_available':
+				if ( $status['url'] )
+					echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>';
+				break;
+			case 'newer_installed':
+				echo '<a>' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
+				break;
+			case 'latest_installed':
+				echo '<a>' . __('Latest Version Installed') . '</a>';
+				break;
+		}
+		?>
+		</p>
+		<?php endif; ?>
+		<h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI') ?></h2>
+		<ul>
+<?php if ( ! empty($api->version) ) : ?>
+			<li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li>
+<?php endif; if ( ! empty($api->author) ) : ?>
+			<li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li>
+<?php endif; if ( ! empty($api->last_updated) ) : ?>
+			<li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
+							printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
+<?php endif; if ( ! empty($api->requires) ) : ?>
+			<li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li>
+<?php endif; if ( ! empty($api->tested) ) : ?>
+			<li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li>
+<?php endif; if ( ! empty($api->downloaded) ) : ?>
+			<li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li>
+<?php endif; if ( ! empty($api->slug) && empty($api->external) ) : ?>
+			<li><a target="_blank" href="http://wordpress.org/extend/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page &#187;') ?></a></li>
+<?php endif; if ( ! empty($api->homepage) ) : ?>
+			<li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage  &#187;') ?></a></li>
+<?php endif; ?>
+		</ul>
+		<?php if ( ! empty($api->rating) ) : ?>
+		<h2><?php _e('Average Rating') ?></h2>
+		<div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?>">
+			<div class="star star-rating" style="width: <?php echo esc_attr($api->rating) ?>px"></div>
+			<div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div>
+			<div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div>
+			<div class="star star3"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('3 stars') ?>" /></div>
+			<div class="star star2"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('2 stars') ?>" /></div>
+			<div class="star star1"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('1 star') ?>" /></div>
+		</div>
+		<small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>
+		<?php endif; ?>
+	</div>
+	<div id="section-holder" class="wrap">
+	<?php
+		if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )
+			echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
+
+		else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )
+			echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';
+
+		foreach ( (array)$api->sections as $section_name => $content ) {
+			$title = $section_name;
+			$title[0] = strtoupper($title[0]);
+			$title = str_replace('_', ' ', $title);
+
+			$content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/');
+			$content = links_add_target($content, '_blank');
+
+			$san_title = esc_attr(sanitize_title_with_dashes($title));
+
+			$display = ( $section_name == $section ) ? 'block' : 'none';
+
+			echo "\t<div id='section-{$san_title}' class='section' style='display: {$display};'>\n";
+			echo "\t\t<h2 class='long-header'>$title</h2>";
+			echo $content;
+			echo "\t</div>\n";
+		}
+	echo "</div>\n";
+
+	iframe_footer();
+	exit;
+}
+add_action('install_plugins_pre_plugin-information', 'install_plugin_information');
+
Index: /tags/3.1/wp-admin/includes/plugin.php
===================================================================
--- /tags/3.1/wp-admin/includes/plugin.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/plugin.php	(revision 17487)
@@ -0,0 +1,1729 @@
+<?php
+/**
+ * WordPress Plugin Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Parse the plugin contents to retrieve plugin's metadata.
+ *
+ * The metadata of the plugin's data searches for the following in the plugin's
+ * header. All plugin data must be on its own line. For plugin description, it
+ * must not have any newlines or only parts of the description will be displayed
+ * and the same goes for the plugin data. The below is formatted for printing.
+ *
+ * <code>
+ * /*
+ * Plugin Name: Name of Plugin
+ * Plugin URI: Link to plugin information
+ * Description: Plugin Description
+ * Author: Plugin author's name
+ * Author URI: Link to the author's web site
+ * Version: Must be set in the plugin for WordPress 2.3+
+ * Text Domain: Optional. Unique identifier, should be same as the one used in
+ *		plugin_text_domain()
+ * Domain Path: Optional. Only useful if the translations are located in a
+ *		folder above the plugin's base path. For example, if .mo files are
+ *		located in the locale folder then Domain Path will be "/locale/" and
+ *		must have the first slash. Defaults to the base folder the plugin is
+ *		located in.
+ * Network: Optional. Specify "Network: true" to require that a plugin is activated
+ *		across all sites in an installation. This will prevent a plugin from being
+ *		activated on a single site when Multisite is enabled.
+ *  * / # Remove the space to close comment
+ * </code>
+ *
+ * Plugin data returned array contains the following:
+ *		'Name' - Name of the plugin, must be unique.
+ *		'Title' - Title of the plugin and the link to the plugin's web site.
+ *		'Description' - Description of what the plugin does and/or notes
+ *		from the author.
+ *		'Author' - The author's name
+ *		'AuthorURI' - The authors web site address.
+ *		'Version' - The plugin version number.
+ *		'PluginURI' - Plugin web site address.
+ *		'TextDomain' - Plugin's text domain for localization.
+ *		'DomainPath' - Plugin's relative directory path to .mo files.
+ *		'Network' - Boolean. Whether the plugin can only be activated network wide.
+ *
+ * Some users have issues with opening large files and manipulating the contents
+ * for want is usually the first 1kiB or 2kiB. This function stops pulling in
+ * the plugin contents when it has all of the required plugin data.
+ *
+ * The first 8kiB of the file will be pulled in and if the plugin data is not
+ * within that first 8kiB, then the plugin author should correct their plugin
+ * and move the plugin data headers to the top.
+ *
+ * The plugin file is assumed to have permissions to allow for scripts to read
+ * the file. This is not checked however and the file is only opened for
+ * reading.
+ *
+ * @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
+ * @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
+ * @since 1.5.0
+ *
+ * @param string $plugin_file Path to the plugin file
+ * @param bool $markup If the returned data should have HTML markup applied
+ * @param bool $translate If the returned data should be translated
+ * @return array See above for description.
+ */
+function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
+
+	$default_headers = array(
+		'Name' => 'Plugin Name',
+		'PluginURI' => 'Plugin URI',
+		'Version' => 'Version',
+		'Description' => 'Description',
+		'Author' => 'Author',
+		'AuthorURI' => 'Author URI',
+		'TextDomain' => 'Text Domain',
+		'DomainPath' => 'Domain Path',
+		'Network' => 'Network',
+		// Site Wide Only is deprecated in favor of Network.
+		'_sitewide' => 'Site Wide Only',
+	);
+
+	$plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
+
+	// Site Wide Only is the old header for Network
+	if ( empty( $plugin_data['Network'] ) && ! empty( $plugin_data['_sitewide'] ) ) {
+		_deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) );
+		$plugin_data['Network'] = $plugin_data['_sitewide'];
+	}
+	$plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
+	unset( $plugin_data['_sitewide'] );
+
+	//For backward compatibility by default Title is the same as Name.
+	$plugin_data['Title'] = $plugin_data['Name'];
+
+	if ( $markup || $translate )
+		$plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
+	else
+		$plugin_data['AuthorName'] = $plugin_data['Author'];
+
+	return $plugin_data;
+}
+
+function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) {
+
+	//Translate fields
+	if ( $translate && ! empty($plugin_data['TextDomain']) ) {
+		if ( ! empty( $plugin_data['DomainPath'] ) )
+			load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file). $plugin_data['DomainPath']);
+		else
+			load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file));
+
+		foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field )
+			$plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']);
+	}
+
+	$plugins_allowedtags = array(
+		'a'       => array( 'href' => array(), 'title' => array() ),
+		'abbr'    => array( 'title' => array() ),
+		'acronym' => array( 'title' => array() ),
+		'code'    => array(),
+		'em'      => array(),
+		'strong'  => array(),
+	);
+
+	$plugin_data['AuthorName'] = $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags );
+
+	//Apply Markup
+	if ( $markup ) {
+		if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) )
+			$plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>';
+		else
+			$plugin_data['Title'] = $plugin_data['Name'];
+
+		if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']) )
+			$plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
+
+		$plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
+		if ( ! empty($plugin_data['Author']) )
+			$plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>';
+	}
+
+	// Sanitize all displayed data. Author and AuthorName sanitized above.
+	$plugin_data['Title']       = wp_kses( $plugin_data['Title'],       $plugins_allowedtags );
+	$plugin_data['Version']     = wp_kses( $plugin_data['Version'],     $plugins_allowedtags );
+	$plugin_data['Description'] = wp_kses( $plugin_data['Description'], $plugins_allowedtags );
+	$plugin_data['Name']        = wp_kses( $plugin_data['Name'],        $plugins_allowedtags );
+
+	return $plugin_data;
+}
+
+/**
+ * Get a list of a plugin's files.
+ *
+ * @since 2.8.0
+ *
+ * @param string $plugin Plugin ID
+ * @return array List of files relative to the plugin root.
+ */
+function get_plugin_files($plugin) {
+	$plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
+	$dir = dirname($plugin_file);
+	$plugin_files = array($plugin);
+	if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) {
+		$plugins_dir = @ opendir( $dir );
+		if ( $plugins_dir ) {
+			while (($file = readdir( $plugins_dir ) ) !== false ) {
+				if ( substr($file, 0, 1) == '.' )
+					continue;
+				if ( is_dir( $dir . '/' . $file ) ) {
+					$plugins_subdir = @ opendir( $dir . '/' . $file );
+					if ( $plugins_subdir ) {
+						while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
+							if ( substr($subfile, 0, 1) == '.' )
+								continue;
+							$plugin_files[] = plugin_basename("$dir/$file/$subfile");
+						}
+						@closedir( $plugins_subdir );
+					}
+				} else {
+					if ( plugin_basename("$dir/$file") != $plugin )
+						$plugin_files[] = plugin_basename("$dir/$file");
+				}
+			}
+			@closedir( $plugins_dir );
+		}
+	}
+
+	return $plugin_files;
+}
+
+/**
+ * Check the plugins directory and retrieve all plugin files with plugin data.
+ *
+ * WordPress only supports plugin files in the base plugins directory
+ * (wp-content/plugins) and in one directory above the plugins directory
+ * (wp-content/plugins/my-plugin). The file it looks for has the plugin data and
+ * must be found in those two locations. It is recommended that do keep your
+ * plugin files in directories.
+ *
+ * The file with the plugin data is the file that will be included and therefore
+ * needs to have the main execution for the plugin. This does not mean
+ * everything must be contained in the file and it is recommended that the file
+ * be split for maintainability. Keep everything in one file for extreme
+ * optimization purposes.
+ *
+ * @since 1.5.0
+ *
+ * @param string $plugin_folder Optional. Relative path to single plugin folder.
+ * @return array Key is the plugin file path and the value is an array of the plugin data.
+ */
+function get_plugins($plugin_folder = '') {
+
+	if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
+		$cache_plugins = array();
+
+	if ( isset($cache_plugins[ $plugin_folder ]) )
+		return $cache_plugins[ $plugin_folder ];
+
+	$wp_plugins = array ();
+	$plugin_root = WP_PLUGIN_DIR;
+	if ( !empty($plugin_folder) )
+		$plugin_root .= $plugin_folder;
+
+	// Files in wp-content/plugins directory
+	$plugins_dir = @ opendir( $plugin_root);
+	$plugin_files = array();
+	if ( $plugins_dir ) {
+		while (($file = readdir( $plugins_dir ) ) !== false ) {
+			if ( substr($file, 0, 1) == '.' )
+				continue;
+			if ( is_dir( $plugin_root.'/'.$file ) ) {
+				$plugins_subdir = @ opendir( $plugin_root.'/'.$file );
+				if ( $plugins_subdir ) {
+					while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
+						if ( substr($subfile, 0, 1) == '.' )
+							continue;
+						if ( substr($subfile, -4) == '.php' )
+							$plugin_files[] = "$file/$subfile";
+					}
+				}
+			} else {
+				if ( substr($file, -4) == '.php' )
+					$plugin_files[] = $file;
+			}
+		}
+	} else {
+		return $wp_plugins;
+	}
+
+	@closedir( $plugins_dir );
+	@closedir( $plugins_subdir );
+
+	if ( empty($plugin_files) )
+		return $wp_plugins;
+
+	foreach ( $plugin_files as $plugin_file ) {
+		if ( !is_readable( "$plugin_root/$plugin_file" ) )
+			continue;
+
+		$plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
+
+		if ( empty ( $plugin_data['Name'] ) )
+			continue;
+
+		$wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
+	}
+
+	uasort( $wp_plugins, '_sort_uname_callback' );
+
+	$cache_plugins[ $plugin_folder ] = $wp_plugins;
+	wp_cache_set('plugins', $cache_plugins, 'plugins');
+
+	return $wp_plugins;
+}
+
+/**
+ * Check the mu-plugins directory and retrieve all mu-plugin files with any plugin data.
+ *
+ * WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins).
+ *
+ * @since 3.0.0
+ * @return array Key is the mu-plugin file path and the value is an array of the mu-plugin data.
+ */
+function get_mu_plugins() {
+	$wp_plugins = array();
+	// Files in wp-content/mu-plugins directory
+	$plugin_files = array();
+
+	if ( ! is_dir( WPMU_PLUGIN_DIR ) )
+		return $wp_plugins;
+	if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) {
+		while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
+			if ( substr( $file, -4 ) == '.php' )
+				$plugin_files[] = $file;
+		}
+	} else {
+		return $wp_plugins;
+	}
+
+	@closedir( $plugins_dir );
+
+	if ( empty($plugin_files) )
+		return $wp_plugins;
+
+	foreach ( $plugin_files as $plugin_file ) {
+		if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) )
+			continue;
+
+		$plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
+
+		if ( empty ( $plugin_data['Name'] ) )
+			$plugin_data['Name'] = $plugin_file;
+
+		$wp_plugins[ $plugin_file ] = $plugin_data;
+	}
+
+	if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden
+		unset( $wp_plugins['index.php'] );
+
+	uasort( $wp_plugins, '_sort_uname_callback' );
+
+	return $wp_plugins;
+}
+
+/**
+ * Callback to sort array by a 'Name' key.
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _sort_uname_callback( $a, $b ) {
+	return strnatcasecmp( $a['Name'], $b['Name'] );
+}
+
+/**
+ * Check the wp-content directory and retrieve all drop-ins with any plugin data.
+ *
+ * @since 3.0.0
+ * @return array Key is the file path and the value is an array of the plugin data.
+ */
+function get_dropins() {
+	$dropins = array();
+	$plugin_files = array();
+
+	$_dropins = _get_dropins();
+
+	// These exist in the wp-content directory
+	if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) {
+		while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
+			if ( isset( $_dropins[ $file ] ) )
+				$plugin_files[] = $file;
+		}
+	} else {
+		return $dropins;
+	}
+
+	@closedir( $plugins_dir );
+
+	if ( empty($plugin_files) )
+		return $dropins;
+
+	foreach ( $plugin_files as $plugin_file ) {
+		if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) )
+			continue;
+		$plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
+		if ( empty( $plugin_data['Name'] ) )
+			$plugin_data['Name'] = $plugin_file;
+		$dropins[ $plugin_file ] = $plugin_data;
+	}
+
+	uksort( $dropins, 'strnatcasecmp' );
+
+	return $dropins;
+}
+
+/**
+ * Returns drop-ins that WordPress uses.
+ *
+ * Includes Multisite drop-ins only when is_multisite()
+ *
+ * @since 3.0.0
+ * @return array Key is file name. The value is an array, with the first value the
+ *	purpose of the drop-in and the second value the name of the constant that must be
+ *	true for the drop-in to be used, or true if no constant is required.
+ */
+function _get_dropins() {
+	$dropins = array(
+		'advanced-cache.php' => array( __( 'Advanced caching plugin.'       ), 'WP_CACHE' ), // WP_CACHE
+		'db.php'             => array( __( 'Custom database class.'         ), true ), // auto on load
+		'db-error.php'       => array( __( 'Custom database error message.' ), true ), // auto on error
+		'install.php'        => array( __( 'Custom install script.'         ), true ), // auto on install
+		'maintenance.php'    => array( __( 'Custom maintenance message.'    ), true ), // auto on maintenance
+		'object-cache.php'   => array( __( 'External object cache.'         ), true ), // auto on load
+	);
+
+	if ( is_multisite() ) {
+		$dropins['sunrise.php'       ] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
+		$dropins['blog-deleted.php'  ] = array( __( 'Custom site deleted message.'   ), true ); // auto on deleted blog
+		$dropins['blog-inactive.php' ] = array( __( 'Custom site inactive message.'  ), true ); // auto on inactive blog
+		$dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog
+	}
+
+	return $dropins;
+}
+
+/**
+ * Check whether the plugin is active by checking the active_plugins list.
+ *
+ * @since 2.5.0
+ *
+ * @param string $plugin Base plugin path from plugins directory.
+ * @return bool True, if in the active plugins list. False, not in the list.
+ */
+function is_plugin_active( $plugin ) {
+	return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin );
+}
+
+/**
+ * Check whether the plugin is inactive.
+ *
+ * Reverse of is_plugin_active(). Used as a callback.
+ *
+ * @since 3.1.0
+ * @see is_plugin_active()
+ *
+ * @param string $plugin Base plugin path from plugins directory.
+ * @return bool True if inactive. False if active.
+ */
+function is_plugin_inactive( $plugin ) {
+	return ! is_plugin_active( $plugin );
+}
+
+/**
+ * Check whether the plugin is active for the entire network.
+ *
+ * @since 3.0.0
+ *
+ * @param string $plugin Base plugin path from plugins directory.
+ * @return bool True, if active for the network, otherwise false.
+ */
+function is_plugin_active_for_network( $plugin ) {
+	if ( !is_multisite() )
+		return false;
+
+	$plugins = get_site_option( 'active_sitewide_plugins');
+	if ( isset($plugins[$plugin]) )
+		return true;
+
+	return false;
+}
+
+/**
+ * Checks for "Network: true" in the plugin header to see if this should
+ * be activated only as a network wide plugin. The plugin would also work
+ * when Multisite is not enabled.
+ *
+ * Checks for "Site Wide Only: true" for backwards compatibility.
+ *
+ * @since 3.0.0
+ *
+ * @param string $plugin Plugin to check
+ * @return bool True if plugin is network only, false otherwise.
+ */
+function is_network_only_plugin( $plugin ) {
+	$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
+	if ( $plugin_data )
+		return $plugin_data['Network'];
+	return false;
+}
+
+/**
+ * Attempts activation of plugin in a "sandbox" and redirects on success.
+ *
+ * A plugin that is already activated will not attempt to be activated again.
+ *
+ * The way it works is by setting the redirection to the error before trying to
+ * include the plugin file. If the plugin fails, then the redirection will not
+ * be overwritten with the success message. Also, the options will not be
+ * updated and the activation hook will not be called on plugin error.
+ *
+ * It should be noted that in no way the below code will actually prevent errors
+ * within the file. The code should not be used elsewhere to replicate the
+ * "sandbox", which uses redirection to work.
+ * {@source 13 1}
+ *
+ * If any errors are found or text is outputted, then it will be captured to
+ * ensure that the success redirection will update the error redirection.
+ *
+ * @since 2.5.0
+ *
+ * @param string $plugin Plugin path to main plugin file with plugin data.
+ * @param string $redirect Optional. URL to redirect to.
+ * @param bool $network_wide Whether to enable the plugin for all sites in the
+ *   network or just the current site. Multisite only. Default is false.
+ * @param bool $silent Prevent calling activation hooks. Optional, default is false.
+ * @return WP_Error|null WP_Error on invalid file or null on success.
+ */
+function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
+	$plugin = plugin_basename( trim( $plugin ) );
+
+	if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) {
+		$network_wide = true;
+		$current = get_site_option( 'active_sitewide_plugins', array() );
+	} else {
+		$current = get_option( 'active_plugins', array() );
+	}
+
+	$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_once(WP_PLUGIN_DIR . '/' . $plugin);
+
+		if ( ! $silent ) {
+			do_action( 'activate_plugin', $plugin, $network_wide );
+			do_action( 'activate_' . $plugin, $network_wide );
+		}
+
+		if ( $network_wide ) {
+			$current[$plugin] = time();
+			update_site_option( 'active_sitewide_plugins', $current );
+		} else {
+			$current[] = $plugin;
+			sort($current);
+			update_option('active_plugins', $current);
+		}
+
+		if ( ! $silent ) {
+			do_action( 'activated_plugin', $plugin, $network_wide );
+		}
+
+		if ( ob_get_length() > 0 ) {
+			$output = ob_get_clean();
+			return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
+		}
+		ob_end_clean();
+	}
+
+	return null;
+}
+
+/**
+ * Deactivate a single plugin or multiple plugins.
+ *
+ * The deactivation hook is disabled by the plugin upgrader by using the $silent
+ * parameter.
+ *
+ * @since 2.5.0
+ *
+ * @param string|array $plugins Single plugin or list of plugins to deactivate.
+ * @param bool $silent Prevent calling deactivation hooks. Default is false.
+ */
+function deactivate_plugins( $plugins, $silent = false ) {
+	if ( is_multisite() )
+		$network_current = get_site_option( 'active_sitewide_plugins', array() );
+	$current = get_option( 'active_plugins', array() );
+	$do_blog = $do_network = false;
+
+	foreach ( (array) $plugins as $plugin ) {
+		$plugin = plugin_basename( trim( $plugin ) );
+		if ( ! is_plugin_active($plugin) )
+			continue;
+
+		$network_wide = is_plugin_active_for_network( $plugin );
+
+		if ( ! $silent )
+			do_action( 'deactivate_plugin', $plugin, $network_wide );
+
+		if ( $network_wide ) {
+			$do_network = true;
+			unset( $network_current[ $plugin ] );
+		} else {
+			$key = array_search( $plugin, $current );
+			if ( false !== $key ) {
+				$do_blog = true;
+				array_splice( $current, $key, 1 );
+			}
+		}
+
+		if ( ! $silent ) {
+			do_action( 'deactivate_' . $plugin, $network_wide );
+			do_action( 'deactivated_plugin', $plugin, $network_wide );
+		}
+	}
+
+	if ( $do_blog )
+		update_option('active_plugins', $current);
+	if ( $do_network )
+		update_site_option( 'active_sitewide_plugins', $network_current );
+}
+
+/**
+ * Activate multiple plugins.
+ *
+ * When WP_Error is returned, it does not mean that one of the plugins had
+ * errors. It means that one or more of the plugins file path was invalid.
+ *
+ * The execution will be halted as soon as one of the plugins has an error.
+ *
+ * @since 2.6.0
+ *
+ * @param string|array $plugins
+ * @param string $redirect Redirect to page after successful activation.
+ * @param bool $network_wide Whether to enable the plugin for all sites in the network.
+ * @param bool $silent Prevent calling activation hooks. Default is false.
+ * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
+ */
+function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
+	if ( !is_array($plugins) )
+		$plugins = array($plugins);
+
+	$errors = array();
+	foreach ( $plugins as $plugin ) {
+		if ( !empty($redirect) )
+			$redirect = add_query_arg('plugin', $plugin, $redirect);
+		$result = activate_plugin($plugin, $redirect, $network_wide, $silent);
+		if ( is_wp_error($result) )
+			$errors[$plugin] = $result;
+	}
+
+	if ( !empty($errors) )
+		return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors);
+
+	return true;
+}
+
+/**
+ * Remove directory and files of a plugin for a single or list of plugin(s).
+ *
+ * If the plugins parameter list is empty, false will be returned. True when
+ * completed.
+ *
+ * @since 2.6.0
+ *
+ * @param array $plugins List of plugin
+ * @param string $redirect Redirect to page when complete.
+ * @return mixed
+ */
+function delete_plugins($plugins, $redirect = '' ) {
+	global $wp_filesystem;
+
+	if ( empty($plugins) )
+		return false;
+
+	$checked = array();
+	foreach( $plugins as $plugin )
+		$checked[] = 'checked[]=' . $plugin;
+
+	ob_start();
+	$url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins');
+	if ( false === ($credentials = request_filesystem_credentials($url)) ) {
+		$data = ob_get_contents();
+		ob_end_clean();
+		if ( ! empty($data) ){
+			include_once( ABSPATH . 'wp-admin/admin-header.php');
+			echo $data;
+			include( ABSPATH . 'wp-admin/admin-footer.php');
+			exit;
+		}
+		return;
+	}
+
+	if ( ! WP_Filesystem($credentials) ) {
+		request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
+		$data = ob_get_contents();
+		ob_end_clean();
+		if ( ! empty($data) ){
+			include_once( ABSPATH . 'wp-admin/admin-header.php');
+			echo $data;
+			include( ABSPATH . 'wp-admin/admin-footer.php');
+			exit;
+		}
+		return;
+	}
+
+	if ( ! is_object($wp_filesystem) )
+		return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
+
+	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
+		return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
+
+	//Get the base plugin folder
+	$plugins_dir = $wp_filesystem->wp_plugins_dir();
+	if ( empty($plugins_dir) )
+		return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
+
+	$plugins_dir = trailingslashit( $plugins_dir );
+
+	$errors = array();
+
+	foreach( $plugins as $plugin_file ) {
+		// Run Uninstall hook
+		if ( is_uninstallable_plugin( $plugin_file ) )
+			uninstall_plugin($plugin_file);
+
+		$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) );
+		// If plugin is in its own directory, recursively delete the directory.
+		if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory seperator AND that its not the root plugin folder
+			$deleted = $wp_filesystem->delete($this_plugin_dir, true);
+		else
+			$deleted = $wp_filesystem->delete($plugins_dir . $plugin_file);
+
+		if ( ! $deleted )
+			$errors[] = $plugin_file;
+	}
+
+	if ( ! empty($errors) )
+		return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors)) );
+
+	// Force refresh of plugin update information
+	if ( $current = get_site_transient('update_plugins') ) {
+		unset( $current->response[ $plugin_file ] );
+		set_site_transient('update_plugins', $current);
+	}
+
+	return true;
+}
+
+/**
+ * Validate active plugins
+ *
+ * Validate all active plugins, deactivates invalid and
+ * returns an array of deactivated ones.
+ *
+ * @since 2.5.0
+ * @return array invalid plugins, plugin as key, error as value
+ */
+function validate_active_plugins() {
+	$plugins = get_option( 'active_plugins', array() );
+	// validate vartype: array
+	if ( ! is_array( $plugins ) ) {
+		update_option( 'active_plugins', array() );
+		$plugins = array();
+	}
+
+	if ( is_multisite() && is_super_admin() ) {
+		$network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
+		$plugins = array_merge( $plugins, array_keys( $network_plugins ) );
+	}
+
+	if ( empty( $plugins ) )
+		return;
+
+	$invalid = array();
+
+	// invalid plugins get deactivated
+	foreach ( $plugins as $plugin ) {
+		$result = validate_plugin( $plugin );
+		if ( is_wp_error( $result ) ) {
+			$invalid[$plugin] = $result;
+			deactivate_plugins( $plugin, true );
+		}
+	}
+	return $invalid;
+}
+
+/**
+ * Validate the plugin path.
+ *
+ * Checks that the file exists and {@link validate_file() is valid file}.
+ *
+ * @since 2.5.0
+ *
+ * @param string $plugin Plugin Path
+ * @return WP_Error|int 0 on success, WP_Error on failure.
+ */
+function validate_plugin($plugin) {
+	if ( validate_file($plugin) )
+		return new WP_Error('plugin_invalid', __('Invalid plugin path.'));
+	if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
+		return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));
+
+	$installed_plugins = get_plugins();
+	if ( ! isset($installed_plugins[$plugin]) )
+		return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.'));
+	return 0;
+}
+
+/**
+ * Whether the plugin can be uninstalled.
+ *
+ * @since 2.7.0
+ *
+ * @param string $plugin Plugin path to check.
+ * @return bool Whether plugin can be uninstalled.
+ */
+function is_uninstallable_plugin($plugin) {
+	$file = plugin_basename($plugin);
+
+	$uninstallable_plugins = (array) get_option('uninstall_plugins');
+	if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) )
+		return true;
+
+	return false;
+}
+
+/**
+ * Uninstall a single plugin.
+ *
+ * Calls the uninstall hook, if it is available.
+ *
+ * @since 2.7.0
+ *
+ * @param string $plugin Relative plugin path from Plugin Directory.
+ */
+function uninstall_plugin($plugin) {
+	$file = plugin_basename($plugin);
+
+	$uninstallable_plugins = (array) get_option('uninstall_plugins');
+	if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) {
+		if ( isset( $uninstallable_plugins[$file] ) ) {
+			unset($uninstallable_plugins[$file]);
+			update_option('uninstall_plugins', $uninstallable_plugins);
+		}
+		unset($uninstallable_plugins);
+
+		define('WP_UNINSTALL_PLUGIN', $file);
+		include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php';
+
+		return true;
+	}
+
+	if ( isset( $uninstallable_plugins[$file] ) ) {
+		$callable = $uninstallable_plugins[$file];
+		unset($uninstallable_plugins[$file]);
+		update_option('uninstall_plugins', $uninstallable_plugins);
+		unset($uninstallable_plugins);
+
+		include WP_PLUGIN_DIR . '/' . $file;
+
+		add_action( 'uninstall_' . $file, $callable );
+		do_action( 'uninstall_' . $file );
+	}
+}
+
+//
+// Menu
+//
+
+/**
+ * Add a top level menu page
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ * @param string $icon_url The url to the icon to be used for this menu
+ * @param int $position The position in the menu order this one should appear
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = NULL ) {
+	global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
+
+	$menu_slug = plugin_basename( $menu_slug );
+
+	$admin_page_hooks[$menu_slug] = sanitize_title( $menu_title );
+
+	$hookname = get_plugin_page_hookname( $menu_slug, '' );
+
+	if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) )
+		add_action( $hookname, $function );
+
+	if ( empty($icon_url) )
+		$icon_url = esc_url( admin_url( 'images/generic.png' ) );
+	elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
+		$icon_url = 'https://' . substr($icon_url, 7);
+
+	$new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
+
+	if ( null === $position  )
+		$menu[] = $new_menu;
+	else
+		$menu[$position] = $new_menu;
+
+	$_registered_pages[$hookname] = true;
+
+	// No parent as top level
+	$_parent_pages[$menu_slug] = false;
+
+	return $hookname;
+}
+
+/**
+ * Add a top level menu page in the 'objects' section
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ * @param string $icon_url The url to the icon to be used for this menu
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
+	global $_wp_last_object_menu;
+
+	$_wp_last_object_menu++;
+
+	return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_object_menu);
+}
+
+/**
+ * Add a top level menu page in the 'utility' section
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ * @param string $icon_url The url to the icon to be used for this menu
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
+	global $_wp_last_utility_menu;
+
+	$_wp_last_utility_menu++;
+
+	return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_utility_menu);
+}
+
+/**
+ * Add a sub menu page
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	global $submenu;
+	global $menu;
+	global $_wp_real_parent_file;
+	global $_wp_submenu_nopriv;
+	global $_registered_pages;
+	global $_parent_pages;
+
+	$menu_slug = plugin_basename( $menu_slug );
+	$parent_slug = plugin_basename( $parent_slug);
+
+	if ( isset( $_wp_real_parent_file[$parent_slug] ) )
+		$parent_slug = $_wp_real_parent_file[$parent_slug];
+
+	if ( !current_user_can( $capability ) ) {
+		$_wp_submenu_nopriv[$parent_slug][$menu_slug] = true;
+		return false;
+	}
+
+	// If the parent doesn't already have a submenu, add a link to the parent
+	// as the first item in the submenu.  If the submenu file is the same as the
+	// parent file someone is trying to link back to the parent manually.  In
+	// this case, don't automatically add a link back to avoid duplication.
+	if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug  ) {
+		foreach ( (array)$menu as $parent_menu ) {
+			if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) )
+				$submenu[$parent_slug][] = $parent_menu;
+		}
+	}
+
+	$submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title );
+
+	$hookname = get_plugin_page_hookname( $menu_slug, $parent_slug);
+	if (!empty ( $function ) && !empty ( $hookname ))
+		add_action( $hookname, $function );
+
+	$_registered_pages[$hookname] = true;
+	// backwards-compatibility for plugins using add_management page.  See wp-admin/admin.php for redirect from edit.php to tools.php
+	if ( 'tools.php' == $parent_slug )
+		$_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true;
+
+	// No parent as top level
+	$_parent_pages[$menu_slug] = $parent_slug;
+
+	return $hookname;
+}
+
+/**
+ * Add sub menu page to the tools main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the options main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the themes main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the plugins main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the Users/Profile main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	if ( current_user_can('edit_users') )
+		$parent = 'users.php';
+	else
+		$parent = 'profile.php';
+	return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+/**
+ * Add sub menu page to the Dashboard main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the posts main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the media main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the links main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+ */
+function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the pages main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+*/
+function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+/**
+ * Add sub menu page to the comments main menu.
+ *
+ * This function takes a capability which will be used to determine whether
+ * or not a page is included in the menu.
+ *
+ * The function which is hooked in to handle the output of the page must check
+ * that the user has the required capability as well.
+ *
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
+ * @param string $menu_title The text to be used for the menu
+ * @param string $capability The capability required for this menu to be displayed to the user.
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param callback $function The function to be called to output the content for this page.
+ *
+ * @return string The resulting page's hook_suffix
+*/
+function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
+	return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
+}
+
+
+/**
+ * Remove a top level admin menu
+ *
+ * @since 3.1.0
+ *
+ * @param string $menu_slug The slug of the menu
+ * @return array|bool The removed menu on success, False if not found
+ */
+function remove_menu_page( $menu_slug ) {
+	global $menu;
+
+	foreach ( $menu as $i => $item ) {
+		if ( $menu_slug == $item[2] ) {
+			unset( $menu[$i] );
+			return $item;
+		}
+	}
+
+	return false;
+}
+
+/**
+ * Remove an admin submenu
+ *
+ * @since 3.1.0
+ *
+ * @param string $menu_slug The slug for the parent menu
+ * @param string $submenu_slug The slug of the submenu
+ * @return array|bool The removed submenu on success, False if not found
+ */
+function remove_submenu_page( $menu_slug, $submenu_slug ) {
+	global $submenu;
+
+	if ( !isset( $submenu[$menu_slug] ) )
+		return false;
+
+	foreach ( $submenu[$menu_slug] as $i => $item ) {
+		if ( $submenu_slug == $item[2] ) {
+			unset( $submenu[$menu_slug][$i] );
+			return $item;
+		}
+	}
+
+	return false;
+}
+
+/**
+ * Get the url to access a particular menu page based on the slug it was registered with.
+ *
+ * If the slug hasn't been registered properly no url will be returned
+ *
+ * @since 3.0
+ *
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
+ * @param bool $echo Whether or not to echo the url - default is true
+ * @return string the url
+ */
+function menu_page_url($menu_slug, $echo = true) {
+	global $_parent_pages;
+
+	if ( isset( $_parent_pages[$menu_slug] ) ) {
+		$parent_slug = $_parent_pages[$menu_slug];
+		if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) {
+			$url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) );
+		} else {
+			$url = admin_url( 'admin.php?page=' . $menu_slug );
+		}
+	} else {
+		$url = '';
+	}
+
+	$url = esc_url($url);
+
+	if ( $echo )
+		echo $url;
+
+	return $url;
+}
+
+//
+// Pluggable Menu Support -- Private
+//
+
+function get_admin_page_parent( $parent = '' ) {
+	global $parent_file;
+	global $menu;
+	global $submenu;
+	global $pagenow;
+	global $typenow;
+	global $plugin_page;
+	global $_wp_real_parent_file;
+	global $_wp_menu_nopriv;
+	global $_wp_submenu_nopriv;
+
+	if ( !empty ( $parent ) && 'admin.php' != $parent ) {
+		if ( isset( $_wp_real_parent_file[$parent] ) )
+			$parent = $_wp_real_parent_file[$parent];
+		return $parent;
+	}
+
+	/*
+	if ( !empty ( $parent_file ) ) {
+		if ( isset( $_wp_real_parent_file[$parent_file] ) )
+			$parent_file = $_wp_real_parent_file[$parent_file];
+
+		return $parent_file;
+	}
+	*/
+
+	if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
+		foreach ( (array)$menu as $parent_menu ) {
+			if ( $parent_menu[2] == $plugin_page ) {
+				$parent_file = $plugin_page;
+				if ( isset( $_wp_real_parent_file[$parent_file] ) )
+					$parent_file = $_wp_real_parent_file[$parent_file];
+				return $parent_file;
+			}
+		}
+		if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) {
+			$parent_file = $plugin_page;
+			if ( isset( $_wp_real_parent_file[$parent_file] ) )
+					$parent_file = $_wp_real_parent_file[$parent_file];
+			return $parent_file;
+		}
+	}
+
+	if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
+		$parent_file = $pagenow;
+		if ( isset( $_wp_real_parent_file[$parent_file] ) )
+			$parent_file = $_wp_real_parent_file[$parent_file];
+		return $parent_file;
+	}
+
+	foreach (array_keys( (array)$submenu ) as $parent) {
+		foreach ( $submenu[$parent] as $submenu_array ) {
+			if ( isset( $_wp_real_parent_file[$parent] ) )
+				$parent = $_wp_real_parent_file[$parent];
+			if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) {
+				$parent_file = $parent;
+				return $parent;
+			} elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
+				$parent_file = $parent;
+				return $parent;
+			} else
+				if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
+					$parent_file = $parent;
+					return $parent;
+				}
+		}
+	}
+
+	if ( empty($parent_file) )
+		$parent_file = '';
+	return '';
+}
+
+function get_admin_page_title() {
+	global $title;
+	global $menu;
+	global $submenu;
+	global $pagenow;
+	global $plugin_page;
+	global $typenow;
+
+	if ( ! empty ( $title ) )
+		return $title;
+
+	$hook = get_plugin_page_hook( $plugin_page, $pagenow );
+
+	$parent = $parent1 = get_admin_page_parent();
+
+	if ( empty ( $parent) ) {
+		foreach ( (array)$menu as $menu_array ) {
+			if ( isset( $menu_array[3] ) ) {
+				if ( $menu_array[2] == $pagenow ) {
+					$title = $menu_array[3];
+					return $menu_array[3];
+				} else
+					if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
+						$title = $menu_array[3];
+						return $menu_array[3];
+					}
+			} else {
+				$title = $menu_array[0];
+				return $title;
+			}
+		}
+	} else {
+		foreach ( array_keys( $submenu ) as $parent ) {
+			foreach ( $submenu[$parent] as $submenu_array ) {
+				if ( isset( $plugin_page ) &&
+					( $plugin_page == $submenu_array[2] ) &&
+					(
+						( $parent == $pagenow ) ||
+						( $parent == $plugin_page ) ||
+						( $plugin_page == $hook ) ||
+						( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) ||
+						( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow)
+					)
+					) {
+						$title = $submenu_array[3];
+						return $submenu_array[3];
+					}
+
+				if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page
+					continue;
+
+				if ( isset( $submenu_array[3] ) ) {
+					$title = $submenu_array[3];
+					return $submenu_array[3];
+				} else {
+					$title = $submenu_array[0];
+					return $title;
+				}
+			}
+		}
+		if ( empty ( $title ) ) {
+			foreach ( $menu as $menu_array ) {
+				if ( isset( $plugin_page ) &&
+					( $plugin_page == $menu_array[2] ) &&
+					( $pagenow == 'admin.php' ) &&
+					( $parent1 == $menu_array[2] ) )
+					{
+						$title = $menu_array[3];
+						return $menu_array[3];
+					}
+			}
+		}
+	}
+
+	return $title;
+}
+
+function get_plugin_page_hook( $plugin_page, $parent_page ) {
+	$hook = get_plugin_page_hookname( $plugin_page, $parent_page );
+	if ( has_action($hook) )
+		return $hook;
+	else
+		return null;
+}
+
+function get_plugin_page_hookname( $plugin_page, $parent_page ) {
+	global $admin_page_hooks;
+
+	$parent = get_admin_page_parent( $parent_page );
+
+	$page_type = 'admin';
+	if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) {
+		if ( isset( $admin_page_hooks[$plugin_page] ) )
+			$page_type = 'toplevel';
+		else
+			if ( isset( $admin_page_hooks[$parent] ))
+				$page_type = $admin_page_hooks[$parent];
+	} else if ( isset( $admin_page_hooks[$parent] ) ) {
+		$page_type = $admin_page_hooks[$parent];
+	}
+
+	$plugin_name = preg_replace( '!\.php!', '', $plugin_page );
+
+	return $page_type . '_page_' . $plugin_name;
+}
+
+function user_can_access_admin_page() {
+	global $pagenow;
+	global $menu;
+	global $submenu;
+	global $_wp_menu_nopriv;
+	global $_wp_submenu_nopriv;
+	global $plugin_page;
+	global $_registered_pages;
+
+	$parent = get_admin_page_parent();
+
+	if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
+		return false;
+
+	if ( isset( $plugin_page ) ) {
+		if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
+			return false;
+
+		$hookname = get_plugin_page_hookname($plugin_page, $parent);
+
+		if ( !isset($_registered_pages[$hookname]) )
+			return false;
+	}
+
+	if ( empty( $parent) ) {
+		if ( isset( $_wp_menu_nopriv[$pagenow] ) )
+			return false;
+		if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
+			return false;
+		if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
+			return false;
+		if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
+			return false;
+		foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
+			if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
+				return false;
+			if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
+			return false;
+		}
+		return true;
+	}
+
+	if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
+		return false;
+
+	if ( isset( $submenu[$parent] ) ) {
+		foreach ( $submenu[$parent] as $submenu_array ) {
+			if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
+				if ( current_user_can( $submenu_array[1] ))
+					return true;
+				else
+					return false;
+			} else if ( $submenu_array[2] == $pagenow ) {
+				if ( current_user_can( $submenu_array[1] ))
+					return true;
+				else
+					return false;
+			}
+		}
+	}
+
+	foreach ( $menu as $menu_array ) {
+		if ( $menu_array[2] == $parent) {
+			if ( current_user_can( $menu_array[1] ))
+				return true;
+			else
+				return false;
+		}
+	}
+
+	return true;
+}
+
+/* Whitelist functions */
+
+/**
+ * Register a setting and its sanitization callback
+ *
+ * @since 2.7.0
+ *
+ * @param string $option_group A settings group name.  Should correspond to a whitelisted option key name.
+ * 	Default whitelisted option key names include "general," "discussion," and "reading," among others.
+ * @param string $option_name The name of an option to sanitize and save.
+ * @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
+ * @return unknown
+ */
+function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
+	global $new_whitelist_options;
+
+	if ( 'misc' == $option_group ) {
+		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
+		$option_group = 'general';
+	}
+
+	$new_whitelist_options[ $option_group ][] = $option_name;
+	if ( $sanitize_callback != '' )
+		add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
+}
+
+/**
+ * Unregister a setting
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $option_group
+ * @param unknown_type $option_name
+ * @param unknown_type $sanitize_callback
+ * @return unknown
+ */
+function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) {
+	global $new_whitelist_options;
+
+	if ( 'misc' == $option_group ) {
+		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
+		$option_group = 'general';
+	}
+
+	$pos = array_search( $option_name, (array) $new_whitelist_options );
+	if ( $pos !== false )
+		unset( $new_whitelist_options[ $option_group ][ $pos ] );
+	if ( $sanitize_callback != '' )
+		remove_filter( "sanitize_option_{$option_name}", $sanitize_callback );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $options
+ * @return unknown
+ */
+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' );
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $new_options
+ * @param unknown_type $options
+ * @return unknown
+ */
+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 ) {
+			if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) {
+				$whitelist_options[ $page ] = array();
+				$whitelist_options[ $page ][] = $key;
+			} else {
+				$pos = array_search( $key, $whitelist_options[ $page ] );
+				if ( $pos === false )
+					$whitelist_options[ $page ][] = $key;
+			}
+		}
+	}
+
+	return $whitelist_options;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $del_options
+ * @param unknown_type $options
+ * @return unknown
+ */
+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 ) {
+			if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) {
+				$pos = array_search( $key, $whitelist_options[ $page ] );
+				if ( $pos !== false )
+					unset( $whitelist_options[ $page ][ $pos ] );
+			}
+		}
+	}
+
+	return $whitelist_options;
+}
+
+/**
+ * Output nonce, action, and option_page fields for a settings page.
+ *
+ * @since 2.7.0
+ *
+ * @param string $option_group A settings group name.  This should match the group name used in register_setting().
+ */
+function settings_fields($option_group) {
+	echo "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />";
+	echo '<input type="hidden" name="action" value="update" />';
+	wp_nonce_field("$option_group-options");
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/post.php
===================================================================
--- /tags/3.1/wp-admin/includes/post.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/post.php	(revision 17487)
@@ -0,0 +1,1703 @@
+<?php
+/**
+ * WordPress Post Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Rename $_POST data from form names to DB post columns.
+ *
+ * Manipulates $_POST directly.
+ *
+ * @package WordPress
+ * @since 2.6.0
+ *
+ * @param bool $update Are we updating a pre-existing post?
+ * @param array $post_data Array of post data. Defaults to the contents of $_POST.
+ * @return object|bool WP_Error on failure, true on success.
+ */
+function _wp_translate_postdata( $update = false, $post_data = null ) {
+
+	if ( empty($post_data) )
+		$post_data = &$_POST;
+
+	if ( $update )
+		$post_data['ID'] = (int) $post_data['post_ID'];
+	$post_data['post_content'] = isset($post_data['content']) ? $post_data['content'] : '';
+	$post_data['post_excerpt'] = isset($post_data['excerpt']) ? $post_data['excerpt'] : '';
+	$post_data['post_parent'] = isset($post_data['parent_id'])? $post_data['parent_id'] : '';
+	if ( isset($post_data['trackback_url']) )
+		$post_data['to_ping'] = $post_data['trackback_url'];
+
+	if ( !isset($post_data['user_ID']) )
+		$post_data['user_ID'] = $GLOBALS['user_ID'];
+
+	if (!empty ( $post_data['post_author_override'] ) ) {
+		$post_data['post_author'] = (int) $post_data['post_author_override'];
+	} else {
+		if (!empty ( $post_data['post_author'] ) ) {
+			$post_data['post_author'] = (int) $post_data['post_author'];
+		} else {
+			$post_data['post_author'] = (int) $post_data['user_ID'];
+		}
+	}
+
+	$ptype = get_post_type_object( $post_data['post_type'] );
+	if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
+		if ( !current_user_can( $ptype->cap->edit_others_posts ) ) {
+			if ( 'page' == $post_data['post_type'] ) {
+				return new WP_Error( 'edit_others_pages', $update ?
+					__( 'You are not allowed to edit pages as this user.' ) :
+					__( 'You are not allowed to create pages as this user.' )
+				);
+			} else {
+				return new WP_Error( 'edit_others_posts', $update ?
+					__( 'You are not allowed to edit posts as this user.' ) :
+					__( 'You are not allowed to post as this user.' )
+				);
+			}
+		}
+	}
+
+	// What to do based on which button they pressed
+	if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] )
+		$post_data['post_status'] = 'draft';
+	if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
+		$post_data['post_status'] = 'private';
+	if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) )
+		$post_data['post_status'] = 'publish';
+	if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
+		$post_data['post_status'] = 'draft';
+	if ( isset($post_data['pending']) && '' != $post_data['pending'] )
+		$post_data['post_status'] = 'pending';
+
+	if ( isset( $post_data['ID'] ) )
+		$post_id = $post_data['ID'];
+	else
+		$post_id = false;
+	$previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
+
+	// Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
+	// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
+	if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) )
+		if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) )
+			$post_data['post_status'] = 'pending';
+
+	if ( ! isset($post_data['post_status']) )
+		$post_data['post_status'] = $previous_status;
+
+	if (!isset( $post_data['comment_status'] ))
+		$post_data['comment_status'] = 'closed';
+
+	if (!isset( $post_data['ping_status'] ))
+		$post_data['ping_status'] = 'closed';
+
+	foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
+		if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
+			$post_data['edit_date'] = '1';
+			break;
+		}
+	}
+
+	if ( !empty( $post_data['edit_date'] ) ) {
+		$aa = $post_data['aa'];
+		$mm = $post_data['mm'];
+		$jj = $post_data['jj'];
+		$hh = $post_data['hh'];
+		$mn = $post_data['mn'];
+		$ss = $post_data['ss'];
+		$aa = ($aa <= 0 ) ? date('Y') : $aa;
+		$mm = ($mm <= 0 ) ? date('n') : $mm;
+		$jj = ($jj > 31 ) ? 31 : $jj;
+		$jj = ($jj <= 0 ) ? date('j') : $jj;
+		$hh = ($hh > 23 ) ? $hh -24 : $hh;
+		$mn = ($mn > 59 ) ? $mn -60 : $mn;
+		$ss = ($ss > 59 ) ? $ss -60 : $ss;
+		$post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
+		$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
+	}
+
+	return $post_data;
+}
+
+/**
+ * Update an existing post with values provided in $_POST.
+ *
+ * @since 1.5.0
+ *
+ * @param array $post_data Optional.
+ * @return int Post ID.
+ */
+function edit_post( $post_data = null ) {
+
+	if ( empty($post_data) )
+		$post_data = &$_POST;
+
+	$post_ID = (int) $post_data['post_ID'];
+	$post = get_post( $post_ID );
+	$post_data['post_type'] = $post->post_type;
+
+	$ptype = get_post_type_object($post_data['post_type']);
+	if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {
+		if ( 'page' == $post_data['post_type'] )
+			wp_die( __('You are not allowed to edit this page.' ));
+		else
+			wp_die( __('You are not allowed to edit this post.' ));
+	}
+
+	// Autosave shouldn't save too soon after a real save
+	if ( 'autosave' == $post_data['action'] ) {
+		$post =& get_post( $post_ID );
+		$now = time();
+		$then = strtotime($post->post_date_gmt . ' +0000');
+		$delta = AUTOSAVE_INTERVAL / 2;
+		if ( ($now - $then) < $delta )
+			return $post_ID;
+	}
+
+	$post_data = _wp_translate_postdata( true, $post_data );
+	if ( is_wp_error($post_data) )
+		wp_die( $post_data->get_error_message() );
+	if ( 'autosave' != $post_data['action']  && 'auto-draft' == $post_data['post_status'] )
+		$post_data['post_status'] = 'draft';
+
+	if ( isset($post_data['visibility']) ) {
+		switch ( $post_data['visibility'] ) {
+			case 'public' :
+				$post_data['post_password'] = '';
+				break;
+			case 'password' :
+				unset( $post_data['sticky'] );
+				break;
+			case 'private' :
+				$post_data['post_status'] = 'private';
+				$post_data['post_password'] = '';
+				unset( $post_data['sticky'] );
+				break;
+		}
+	}
+
+	// Post Formats
+	if ( current_theme_supports( 'post-formats' ) && isset( $post_data['post_format'] ) ) {
+		$formats = get_theme_support( 'post-formats' );
+		if ( is_array( $formats ) ) {
+			$formats = $formats[0];
+			if ( in_array( $post_data['post_format'], $formats ) ) {
+				set_post_format( $post_ID, $post_data['post_format'] );
+			} elseif ( '0' == $post_data['post_format'] ) {
+				set_post_format( $post_ID, false );
+			}
+		}
+	}
+
+	// Meta Stuff
+	if ( isset($post_data['meta']) && $post_data['meta'] ) {
+		foreach ( $post_data['meta'] as $key => $value ) {
+			if ( !$meta = get_post_meta_by_id( $key ) )
+				continue;
+			if ( $meta->post_id != $post_ID )
+				continue;
+			update_meta( $key, $value['key'], $value['value'] );
+		}
+	}
+
+	if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
+		foreach ( $post_data['deletemeta'] as $key => $value ) {
+			if ( !$meta = get_post_meta_by_id( $key ) )
+				continue;
+			if ( $meta->post_id != $post_ID )
+				continue;
+			delete_meta( $key );
+		}
+	}
+
+	add_meta( $post_ID );
+
+	update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
+
+	wp_update_post( $post_data );
+
+	// Reunite any orphaned attachments with their parent
+	if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+		$draft_ids = array();
+	if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
+		_relocate_children( $draft_temp_id, $post_ID );
+
+	// 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 );
+
+	if ( current_user_can( $ptype->cap->edit_others_posts ) ) {
+		if ( ! empty( $post_data['sticky'] ) )
+			stick_post( $post_ID );
+		else
+			unstick_post( $post_ID );
+	}
+
+	return $post_ID;
+}
+
+/**
+ * Process the post data for the bulk editing of posts.
+ *
+ * Updates all bulk edited posts/pages, adding (but not removing) tags and
+ * categories. Skips pages when they would be their own parent or child.
+ *
+ * @since 2.7.0
+ *
+ * @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal.
+ * @return array
+ */
+function bulk_edit_posts( $post_data = null ) {
+	global $wpdb;
+
+	if ( empty($post_data) )
+		$post_data = &$_POST;
+
+	if ( isset($post_data['post_type']) )
+		$ptype = get_post_type_object($post_data['post_type']);
+	else
+		$ptype = get_post_type_object('post');
+
+	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
+		if ( 'page' == $ptype->name )
+			wp_die( __('You are not allowed to edit pages.'));
+		else
+			wp_die( __('You are not allowed to edit posts.'));
+	}
+
+	if ( -1 == $post_data['_status'] ) {
+		$post_data['post_status'] = null;
+		unset($post_data['post_status']);
+	} else {
+		$post_data['post_status'] = $post_data['_status'];
+	}
+	unset($post_data['_status']);
+
+	$post_IDs = array_map( 'intval', (array) $post_data['post'] );
+
+	$reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky' );
+	foreach ( $reset as $field ) {
+		if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
+			unset($post_data[$field]);
+	}
+
+	if ( isset($post_data['post_category']) ) {
+		if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
+			$new_cats = array_map( 'absint', $post_data['post_category'] );
+		else
+			unset($post_data['post_category']);
+	}
+
+	$tax_input = array();
+	if ( isset($post_data['tax_input'])) {
+		foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
+			if ( empty($terms) )
+				continue;
+			if ( is_taxonomy_hierarchical( $tax_name ) )
+				$tax_input[$tax_name] = array_map( 'absint', $terms );
+			else {
+				$tax_input[$tax_name] = preg_replace( '/\s*,\s*/', ',', rtrim( trim($terms), ' ,' ) );
+				$tax_input[$tax_name] = explode(',', $tax_input[$tax_name]);
+			}
+		}
+	}
+
+	if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) {
+		$pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'");
+		$children = array();
+
+		for ( $i = 0; $i < 50 && $parent > 0; $i++ ) {
+			$children[] = $parent;
+
+			foreach ( $pages as $page ) {
+				if ( $page->ID == $parent ) {
+					$parent = $page->post_parent;
+					break;
+				}
+			}
+		}
+	}
+
+	$updated = $skipped = $locked = array();
+	foreach ( $post_IDs as $post_ID ) {
+		$post_type_object = get_post_type_object( get_post_type( $post_ID ) );
+
+		if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( $post_type_object->cap->edit_post, $post_ID ) ) {
+			$skipped[] = $post_ID;
+			continue;
+		}
+
+		if ( wp_check_post_lock( $post_ID ) ) {
+			$locked[] = $post_ID;
+			continue;
+		}
+
+		$tax_names = get_object_taxonomies( get_post($post_ID) );
+		foreach ( $tax_names as $tax_name ) {
+			$taxonomy_obj = get_taxonomy($tax_name);
+			if (  isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
+				$new_terms = $tax_input[$tax_name];
+			else
+				$new_terms = array();
+
+			if ( $taxonomy_obj->hierarchical )
+				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
+			else
+				$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
+
+			$post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
+		}
+
+		if ( isset($new_cats) && in_array( 'category', $tax_names ) ) {
+			$cats = (array) wp_get_post_categories($post_ID);
+			$post_data['post_category'] = array_unique( array_merge($cats, $new_cats) );
+			unset( $post_data['tax_input']['category'] );
+		}
+
+		$post_data['ID'] = $post_ID;
+		$updated[] = wp_update_post( $post_data );
+
+		if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
+			if ( 'sticky' == $post_data['sticky'] )
+				stick_post( $post_ID );
+			else
+				unstick_post( $post_ID );
+		}
+
+	}
+
+	return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
+}
+
+/**
+ * Default post information to use when populating the "Write Post" form.
+ *
+ * @since 2.0.0
+ *
+ * @param string $post_type A post type string, defaults to 'post'.
+ * @return object stdClass object containing all the default post data as attributes
+ */
+function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
+	global $wpdb;
+
+	$post_title = '';
+	if ( !empty( $_REQUEST['post_title'] ) )
+		$post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
+
+	$post_content = '';
+	if ( !empty( $_REQUEST['content'] ) )
+		$post_content = esc_html( stripslashes( $_REQUEST['content'] ));
+
+	$post_excerpt = '';
+	if ( !empty( $_REQUEST['excerpt'] ) )
+		$post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
+
+	if ( $create_in_db ) {
+		// Cleanup old auto-drafts more than 7 days old
+		$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
+		foreach ( (array) $old_posts as $delete )
+			wp_delete_post( $delete, true ); // Force delete
+		$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
+		$post = get_post( $post_id );
+		if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
+			set_post_format( $post, get_option( 'default_post_format' ) );
+	} else {
+		$post->ID = 0;
+		$post->post_author = '';
+		$post->post_date = '';
+		$post->post_date_gmt = '';
+		$post->post_password = '';
+		$post->post_type = $post_type;
+		$post->post_status = 'draft';
+		$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' );
+		$post->post_category = get_option( 'default_category' );
+		$post->page_template = 'default';
+		$post->post_parent = 0;
+		$post->menu_order = 0;
+	}
+
+	$post->post_content = apply_filters( 'default_content', $post_content, $post );
+	$post->post_title   = apply_filters( 'default_title',   $post_title, $post   );
+	$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
+	$post->post_name = '';
+
+	return $post;
+}
+
+/**
+ * Get the default page information to use.
+ *
+ * @since 2.5.0
+ *
+ * @return object stdClass object containing all the default post data as attributes
+ */
+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.
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
+function get_post_to_edit( $id ) {
+
+	$post = get_post( $id, OBJECT, 'edit' );
+
+	if ( $post->post_type == 'page' )
+		$post->page_template = get_post_meta( $id, '_wp_page_template', true );
+
+	return $post;
+}
+
+/**
+ * Determine if a post exists based on title, content, and date
+ *
+ * @since 2.0.0
+ *
+ * @param string $title Post title
+ * @param string $content Optional post content
+ * @param string $date Optional post date
+ * @return int Post ID if post exists, 0 otherwise.
+ */
+function post_exists($title, $content = '', $date = '') {
+	global $wpdb;
+
+	$post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
+	$post_content = stripslashes( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
+	$post_date = stripslashes( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
+
+	$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
+	$args = array();
+
+	if ( !empty ( $date ) ) {
+		$query .= ' AND post_date = %s';
+		$args[] = $post_date;
+	}
+
+	if ( !empty ( $title ) ) {
+		$query .= ' AND post_title = %s';
+		$args[] = $post_title;
+	}
+
+	if ( !empty ( $content ) ) {
+		$query .= 'AND post_content = %s';
+		$args[] = $post_content;
+	}
+
+	if ( !empty ( $args ) )
+		return $wpdb->get_var( $wpdb->prepare($query, $args) );
+
+	return 0;
+}
+
+/**
+ * Creates a new post from the "Write Post" form using $_POST information.
+ *
+ * @since 2.1.0
+ *
+ * @return unknown
+ */
+function wp_write_post() {
+	global $user_ID;
+
+
+	if ( isset($_POST['post_type']) )
+		$ptype = get_post_type_object($_POST['post_type']);
+	else
+		$ptype = get_post_type_object('post');
+
+	if ( !current_user_can( $ptype->cap->edit_posts ) ) {
+		if ( 'page' == $ptype->name )
+			return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
+		else
+			return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
+	}
+
+	// Check for autosave collisions
+	// Does this need to be updated? ~ Mark
+	$temp_id = false;
+	if ( isset($_POST['temp_ID']) ) {
+		$temp_id = (int) $_POST['temp_ID'];
+		if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+			$draft_ids = array();
+		foreach ( $draft_ids as $temp => $real )
+			if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then )
+				unset($draft_ids[$temp]);
+
+		if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
+			$_POST['post_ID'] = $draft_ids[$temp_id];
+			unset($_POST['temp_ID']);
+			update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
+			return edit_post();
+		}
+	}
+
+	$translated = _wp_translate_postdata( false );
+	if ( is_wp_error($translated) )
+		return $translated;
+
+	if ( isset($_POST['visibility']) ) {
+		switch ( $_POST['visibility'] ) {
+			case 'public' :
+				$_POST['post_password'] = '';
+				break;
+			case 'password' :
+				unset( $_POST['sticky'] );
+				break;
+			case 'private' :
+				$_POST['post_status'] = 'private';
+				$_POST['post_password'] = '';
+				unset( $_POST['sticky'] );
+				break;
+		}
+	}
+
+	// Create the post.
+	$post_ID = wp_insert_post( $_POST );
+	if ( is_wp_error( $post_ID ) )
+		return $post_ID;
+
+	if ( empty($post_ID) )
+		return 0;
+
+	add_meta( $post_ID );
+
+	add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
+
+	// Reunite any orphaned attachments with their parent
+	// Does this need to be udpated? ~ Mark
+	if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+		$draft_ids = array();
+	if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
+		_relocate_children( $draft_temp_id, $post_ID );
+	if ( $temp_id && $temp_id != $draft_temp_id )
+		_relocate_children( $temp_id, $post_ID );
+
+	// Update autosave collision detection
+	if ( $temp_id ) {
+		$draft_ids[$temp_id] = $post_ID;
+		update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
+	}
+
+	// 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;
+}
+
+/**
+ * Calls wp_write_post() and handles the errors.
+ *
+ * @since 2.0.0
+ *
+ * @return unknown
+ */
+function write_post() {
+	$result = wp_write_post();
+	if ( is_wp_error( $result ) )
+		wp_die( $result->get_error_message() );
+	else
+		return $result;
+}
+
+//
+// Post Meta
+//
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $post_ID
+ * @return unknown
+ */
+function add_meta( $post_ID ) {
+	global $wpdb;
+	$post_ID = (int) $post_ID;
+
+	$protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
+
+	$metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : '';
+	$metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : '';
+	$metavalue = isset($_POST['metavalue']) ? maybe_serialize( stripslashes_deep( $_POST['metavalue'] ) ) : '';
+	if ( is_string($metavalue) )
+		$metavalue = trim( $metavalue );
+
+	if ( ('0' === $metavalue || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {
+		// We have a key/value pair. If both the select and the
+		// input for the key have data, the input takes precedence:
+
+ 		if ('#NONE#' != $metakeyselect)
+			$metakey = $metakeyselect;
+
+		if ( $metakeyinput)
+			$metakey = $metakeyinput; // default
+
+		if ( in_array($metakey, $protected) )
+			return false;
+
+		wp_cache_delete($post_ID, 'post_meta');
+		$wpdb->insert( $wpdb->postmeta, array( 'post_id' => $post_ID, 'meta_key' => $metakey, 'meta_value' => $metavalue ) );
+		$meta_id = $wpdb->insert_id;
+		do_action( 'added_postmeta', $meta_id, $post_ID, $metakey, $metavalue );
+
+		return $meta_id;
+	}
+	return false;
+} // add_meta
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $mid
+ * @return unknown
+ */
+function delete_meta( $mid ) {
+	global $wpdb;
+	$mid = (int) $mid;
+
+	$post_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = %d", $mid) );
+
+	do_action( 'delete_postmeta', $mid );
+	wp_cache_delete($post_id, 'post_meta');
+	$rval = $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id = %d", $mid) );
+	do_action( 'deleted_postmeta', $mid );
+
+	return $rval;
+}
+
+/**
+ * Get a list of previously defined keys.
+ *
+ * @since 1.2.0
+ *
+ * @return unknown
+ */
+function get_meta_keys() {
+	global $wpdb;
+
+	$keys = $wpdb->get_col( "
+			SELECT meta_key
+			FROM $wpdb->postmeta
+			GROUP BY meta_key
+			ORDER BY meta_key" );
+
+	return $keys;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.1.0
+ *
+ * @param unknown_type $mid
+ * @return unknown
+ */
+function get_post_meta_by_id( $mid ) {
+	global $wpdb;
+	$mid = (int) $mid;
+
+	$meta = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_id = %d", $mid) );
+	if ( empty($meta) )
+		return false;
+	if ( is_serialized_string( $meta->meta_value ) )
+		$meta->meta_value = maybe_unserialize( $meta->meta_value );
+	return $meta;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * Some postmeta stuff.
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $postid
+ * @return unknown
+ */
+function has_meta( $postid ) {
+	global $wpdb;
+
+	return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id
+			FROM $wpdb->postmeta WHERE post_id = %d
+			ORDER BY meta_key,meta_id", $postid), ARRAY_A );
+
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $meta_id
+ * @param unknown_type $meta_key Expect Slashed
+ * @param unknown_type $meta_value Expect Slashed
+ * @return unknown
+ */
+function update_meta( $meta_id, $meta_key, $meta_value ) {
+	global $wpdb;
+
+	$protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
+
+	$meta_key = stripslashes($meta_key);
+
+	if ( in_array($meta_key, $protected) )
+		return false;
+
+	if ( '' === trim( $meta_value ) )
+		return false;
+
+	$post_id = $wpdb->get_var( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_id = %d", $meta_id) );
+
+	$meta_value = maybe_serialize( stripslashes_deep( $meta_value ) );
+	$meta_id = (int) $meta_id;
+
+	$data  = compact( 'meta_key', 'meta_value' );
+	$where = compact( 'meta_id' );
+
+	do_action( 'update_postmeta', $meta_id, $post_id, $meta_key, $meta_value );
+	$rval = $wpdb->update( $wpdb->postmeta, $data, $where );
+	wp_cache_delete($post_id, 'post_meta');
+	do_action( 'updated_postmeta', $meta_id, $post_id, $meta_key, $meta_value );
+
+	return $rval;
+}
+
+//
+// Private
+//
+
+/**
+ * Replace hrefs of attachment anchors with up-to-date permalinks.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param unknown_type $post_ID
+ * @return unknown
+ */
+function _fix_attachment_links( $post_ID ) {
+	global $_fix_attachment_link_id;
+
+	$post = & get_post( $post_ID, ARRAY_A );
+
+	$search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
+
+	// See if we have any rel="attachment" links
+	if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) )
+		return;
+
+	$i = 0;
+	$search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
+	foreach ( $anchor_matches[0] as $anchor ) {
+		if ( 0 == preg_match( $search, $anchor, $id_matches ) )
+			continue;
+
+		$id = (int) $id_matches[3];
+
+		// While we have the attachment ID, let's adopt any orphans.
+		$attachment = & get_post( $id, ARRAY_A );
+		if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) {
+			$attachment['post_parent'] = $post_ID;
+			// Escape data pulled from DB.
+			$attachment = add_magic_quotes( $attachment );
+			wp_update_post( $attachment );
+		}
+
+		$post_search[$i] = $anchor;
+		 $_fix_attachment_link_id = $id;
+		$post_replace[$i] = preg_replace_callback( "#href=(\"|')[^'\"]*\\1#", '_fix_attachment_links_replace_cb', $anchor );
+		++$i;
+	}
+
+	$post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] );
+
+	// Escape data pulled from DB.
+	$post = add_magic_quotes( $post);
+
+	return wp_update_post( $post);
+}
+
+function _fix_attachment_links_replace_cb($match) {
+        global $_fix_attachment_link_id;
+        return stripslashes( 'href='.$match[1] ).get_attachment_link( $_fix_attachment_link_id ).stripslashes( $match[1] );
+}
+
+/**
+ * Move child posts to a new parent.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param unknown_type $old_ID
+ * @param unknown_type $new_ID
+ * @return unknown
+ */
+function _relocate_children( $old_ID, $new_ID ) {
+	global $wpdb;
+	$old_ID = (int) $old_ID;
+	$new_ID = (int) $new_ID;
+
+	$children = $wpdb->get_col( $wpdb->prepare("
+		SELECT post_id
+		FROM $wpdb->postmeta
+		WHERE meta_key = '_wp_attachment_temp_parent'
+		AND meta_value = %d", $old_ID) );
+
+	foreach ( $children as $child_id ) {
+		$wpdb->update($wpdb->posts, array('post_parent' => $new_ID), array('ID' => $child_id) );
+		delete_post_meta($child_id, '_wp_attachment_temp_parent');
+	}
+}
+
+/**
+ * Get all the possible statuses for a post_type
+ *
+ * @since 2.5.0
+ *
+ * @param string $type The post_type you want the statuses for
+ * @return array As array of all the statuses for the supplied post type
+ */
+function get_available_post_statuses($type = 'post') {
+	$stati = wp_count_posts($type);
+
+	return array_keys(get_object_vars($stati));
+}
+
+/**
+ * Run the wp query to fetch the posts for listing on the edit posts page
+ *
+ * @since 2.5.0
+ *
+ * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
+ * @return array
+ */
+function wp_edit_posts_query( $q = false ) {
+	if ( false === $q )
+		$q = $_GET;
+	$q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
+	$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
+	$post_stati  = get_post_stati();
+
+	if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
+		$post_type = $q['post_type'];
+	else
+		$post_type = 'post';
+
+	$avail_post_stati = get_available_post_statuses($post_type);
+
+	if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) {
+		$post_status = $q['post_status'];
+		$perm = 'readable';
+	}
+
+	if ( isset($q['orderby']) )
+		$orderby = $q['orderby'];
+	elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )
+		$orderby = 'modified';
+
+	if ( isset($q['order']) )
+		$order = $q['order'];
+	elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] )
+		$order = 'ASC';
+
+	$per_page = 'edit_' . $post_type . '_per_page';
+	$posts_per_page = (int) get_user_option( $per_page );
+	if ( empty( $posts_per_page ) || $posts_per_page < 1 )
+		$posts_per_page = 20;
+
+	$posts_per_page = apply_filters( $per_page, $posts_per_page );
+	$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type );
+
+	$query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
+
+	// Hierarchical types require special args.
+	if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) {
+		$query['orderby'] = 'menu_order title';
+		$query['order'] = 'asc';
+		$query['posts_per_page'] = -1;
+		$query['posts_per_archive_page'] = -1;
+	}
+
+	if ( ! empty( $q['show_sticky'] ) )
+		$query['post__in'] = (array) get_option( 'sticky_posts' );
+
+	wp( $query );
+
+	return $avail_post_stati;
+}
+
+/**
+ * Get default post mime types
+ *
+ * @since 2.9.0
+ *
+ * @return array
+ */
+function get_post_mime_types() {
+	$post_mime_types = array(	//	array( adj, noun )
+		'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
+		'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')),
+		'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')),
+	);
+
+	return apply_filters('post_mime_types', $post_mime_types);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $type
+ * @return unknown
+ */
+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;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $q
+ * @return unknown
+ */
+function wp_edit_attachments_query( $q = false ) {
+	if ( false === $q )
+		$q = $_GET;
+
+	$q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0;
+	$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
+	$q['post_type'] = 'attachment';
+	$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit';
+	$media_per_page = (int) get_user_option( 'upload_per_page' );
+	if ( empty( $media_per_page ) || $media_per_page < 1 )
+		$media_per_page = 20;
+	$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
+
+	$post_mime_types = get_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']);
+
+	if ( isset($q['detached']) )
+		add_filter('posts_where', '_edit_attachments_query_helper');
+
+	wp( $q );
+
+	if ( isset($q['detached']) )
+		remove_filter('posts_where', '_edit_attachments_query_helper');
+
+	return array($post_mime_types, $avail_post_mime_types);
+}
+
+function _edit_attachments_query_helper($where) {
+	return $where .= ' AND post_parent < 1';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @uses get_user_option()
+ * @since 2.5.0
+ *
+ * @param unknown_type $id
+ * @param unknown_type $page
+ * @return unknown
+ */
+function postbox_classes( $id, $page ) {
+	if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id )
+		return '';
+
+	if ( $closed = get_user_option('closedpostboxes_'.$page ) ) {
+		if ( !is_array( $closed ) ) {
+			return '';
+		}
+		return in_array( $id, $closed )? 'closed' : '';
+	} else {
+		return '';
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param int|object $id    Post ID or post object.
+ * @param string $title (optional) Title
+ * @param string $name (optional) Name
+ * @return array With two entries of type string
+ */
+function get_sample_permalink($id, $title = null, $name = null) {
+	$post = &get_post($id);
+	if ( !$post->ID )
+		return array('', '');
+
+	$ptype = get_post_type_object($post->post_type);
+
+	$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_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);
+
+	$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
+
+	$post->filter = 'sample';
+
+	$permalink = get_permalink($post, true);
+
+	// Replace custom post_type Token with generic pagename token for ease of use.
+	$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
+
+	// Handle page hierarchy
+	if ( $ptype->hierarchical ) {
+		$uri = get_page_uri($post);
+		$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, apply_filters('editable_slug', $post->post_name));
+	$post->post_status = $original_status;
+	$post->post_date = $original_date;
+	$post->post_name = $original_name;
+	unset($post->filter);
+
+	return $permalink;
+}
+
+/**
+ * sample permalink html
+ *
+ * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
+ *
+ * @since 2.5.0
+ *
+ * @param int|object $id Post ID or post object.
+ * @param string $new_title (optional) New title
+ * @param string $new_slug (optional) New slug
+ * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
+ */
+function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
+	global $wpdb;
+	$post = &get_post($id);
+
+	list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
+
+	if ( 'publish' == $post->post_status ) {
+		$ptype = get_post_type_object($post->post_type);
+		$view_post = $ptype->labels->view_item;
+		$title = __('Click to edit this part of the permalink');
+	} else {
+		$title = __('Temporary permalink. Click to edit this part.');
+	}
+
+	if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
+		$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n";
+		if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) )
+			$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
+		if ( isset($view_post) )
+			$return .= "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n";
+
+		$return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
+
+		return $return;
+	}
+
+	if ( function_exists('mb_strlen') ) {
+		if ( mb_strlen($post_name) > 30 ) {
+			$post_name_abridged = mb_substr($post_name, 0, 14). '&hellip;' . mb_substr($post_name, -14);
+		} else {
+			$post_name_abridged = $post_name;
+		}
+	} else {
+		if ( strlen($post_name) > 30 ) {
+			$post_name_abridged = substr($post_name, 0, 14). '&hellip;' . substr($post_name, -14);
+		} else {
+			$post_name_abridged = $post_name;
+		}
+	}
+
+	$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
+	$display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
+	$view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
+	$return =  '<strong>' . __('Permalink:') . "</strong>\n";
+	$return .= '<span id="sample-permalink">' . $display_link . "</span>\n";
+	$return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
+	$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
+	$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
+	if ( isset($view_post) )
+		$return .= "<span id='view-post-btn'><a href='$view_link' class='button' target='_blank'>$view_post</a></span>\n";
+
+	$return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
+
+	return $return;
+}
+
+/**
+ * Output HTML for the post thumbnail meta-box.
+ *
+ * @since 2.9.0
+ *
+ * @param int $thumbnail_id ID of the attachment used for thumbnail
+ * @return string html
+ */
+function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {
+	global $content_width, $_wp_additional_image_sizes, $post_ID;
+	$set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="' . esc_url( get_upload_iframe_src('image') ) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';
+	$content = sprintf($set_thumbnail_link, esc_html__( 'Set featured image' ));
+
+	if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
+		$old_content_width = $content_width;
+		$content_width = 266;
+		if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
+			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
+		else
+			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
+		if ( !empty( $thumbnail_html ) ) {
+			$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_ID" );
+			$content = sprintf($set_thumbnail_link, $thumbnail_html);
+			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';
+		}
+		$content_width = $old_content_width;
+	}
+
+	return apply_filters( 'admin_post_thumbnail_html', $content );
+}
+
+/**
+ * Check to see if the post is currently being edited by another user.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id ID of the post to check for editing
+ * @return bool|int False: not locked or locked by current user. Int: user ID of user with lock.
+ */
+function wp_check_post_lock( $post_id ) {
+	if ( !$post = get_post( $post_id ) )
+		return false;
+
+	if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
+		return false;
+
+	$lock = explode( ':', $lock );
+	$time = $lock[0];
+	$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
+
+	$time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
+
+	if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
+		return $user;
+	return false;
+}
+
+/**
+ * Mark the post as currently being edited by the current user
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id ID of the post to being edited
+ * @return bool Returns false if the post doesn't exist of there is no current user
+ */
+function wp_set_post_lock( $post_id ) {
+	if ( !$post = get_post( $post_id ) )
+		return false;
+	if ( 0 == ($user_id = get_current_user_id()) )
+		return false;
+
+	$now = time();
+	$lock = "$now:$user_id";
+
+	update_post_meta( $post->ID, '_edit_lock', $lock );
+}
+
+/**
+ * Outputs the notice message to say that someone else is editing this post at the moment.
+ *
+ * @since 2.8.5
+ * @return none
+ */
+function _admin_notice_post_locked() {
+	global $post;
+
+	$lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
+	$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
+	$last_user = get_userdata( $user );
+	$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
+
+	switch ($post->post_type) {
+		case 'post':
+			$message = __( 'Warning: %s is currently editing this post' );
+			break;
+		case 'page':
+			$message = __( 'Warning: %s is currently editing this page' );
+			break;
+		default:
+			$message = __( 'Warning: %s is currently editing this.' );
+	}
+
+	$message = sprintf( $message, esc_html( $last_user_name ) );
+	echo "<div class='error'><p>$message</p></div>";
+}
+
+/**
+ * Creates autosave data for the specified post from $_POST data.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses _wp_translate_postdata()
+ * @uses _wp_post_revision_fields()
+ *
+ * @return unknown
+ */
+function wp_create_post_autosave( $post_id ) {
+	$translated = _wp_translate_postdata( true );
+	if ( is_wp_error( $translated ) )
+		return $translated;
+
+	// Only store one autosave.  If there is already an autosave, overwrite it.
+	if ( $old_autosave = wp_get_post_autosave( $post_id ) ) {
+		$new_autosave = _wp_post_revision_fields( $_POST, true );
+		$new_autosave['ID'] = $old_autosave->ID;
+		$new_autosave['post_author'] = get_current_user_id();
+		return wp_update_post( $new_autosave );
+	}
+
+	// _wp_put_post_revision() expects unescaped.
+	$_POST = stripslashes_deep($_POST);
+
+	// Otherwise create the new autosave as a special post revision
+	return _wp_put_post_revision( $_POST, true );
+}
+
+/**
+ * Save draft or manually autosave for showing preview.
+ *
+ * @package WordPress
+ * @since 2.7.0
+ *
+ * @uses wp_write_post()
+ * @uses edit_post()
+ * @uses get_post()
+ * @uses current_user_can()
+ * @uses wp_create_post_autosave()
+ *
+ * @return str URL to redirect to show the preview
+ */
+function post_preview() {
+
+	$post_ID = (int) $_POST['post_ID'];
+	$status = get_post_status( $post_ID );
+	if ( 'auto-draft' == $status )
+		wp_die( __('Preview not available. Please save as a draft first.') );
+
+	if ( isset($_POST['catslist']) )
+		$_POST['post_category'] = explode(",", $_POST['catslist']);
+
+	if ( isset($_POST['tags_input']) )
+		$_POST['tags_input'] = explode(",", $_POST['tags_input']);
+
+	if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
+		unset($_POST['post_category']);
+
+	$_POST['ID'] = $post_ID;
+	$post = get_post($post_ID);
+
+	if ( 'page' == $post->post_type ) {
+		if ( !current_user_can('edit_page', $post_ID) )
+			wp_die(__('You are not allowed to edit this page.'));
+	} else {
+		if ( !current_user_can('edit_post', $post_ID) )
+			wp_die(__('You are not allowed to edit this post.'));
+	}
+
+	if ( 'draft' == $post->post_status ) {
+		$id = edit_post();
+	} else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.
+		$id = wp_create_post_autosave( $post->ID );
+		if ( ! is_wp_error($id) )
+			$id = $post->ID;
+	}
+
+	if ( is_wp_error($id) )
+		wp_die( $id->get_error_message() );
+
+	if ( $_POST['post_status'] == 'draft'  ) {
+		$url = add_query_arg( 'preview', 'true', get_permalink($id) );
+	} else {
+		$nonce = wp_create_nonce('post_preview_' . $id);
+		$url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($id) );
+	}
+
+	return $url;
+}
+
+/**
+ * Adds the TinyMCE editor used on the Write and Edit screens.
+ *
+ * @package WordPress
+ * @since 2.7.0
+ *
+ * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated
+ * and optionaly pre-compressed version of the core and all default plugins. Additional plugins are loaded
+ * directly by TinyMCE using non-blocking method. Custom plugins can be refreshed by adding a query string
+ * to the URL when queueing them with the mce_external_plugins filter.
+ *
+ * @param bool $teeny optional Output a trimmed down version used in Press This.
+ * @param mixed $settings optional An array that can add to or overwrite the default TinyMCE settings.
+ */
+function wp_tiny_mce( $teeny = false, $settings = false ) {
+	global $concatenate_scripts, $compress_scripts, $tinymce_version, $editor_styles;
+
+	if ( ! user_can_richedit() )
+		return;
+
+	$baseurl = includes_url('js/tinymce');
+
+	$mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
+
+	/*
+	The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
+	By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
+	The + sign marks the default language. More information:
+	http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
+	*/
+	$mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
+
+	if ( $teeny ) {
+		$plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs') );
+		$ext_plugins = '';
+	} else {
+		$plugins = array( 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus', 'wplink', 'wpdialogs' );
+
+		/*
+		The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
+		It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin.
+		The url should be absolute and should include the js file name to be loaded. Example:
+		array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' )
+		If the plugin uses a button, it should be added with one of the "$mce_buttons" filters.
+		*/
+		$mce_external_plugins = apply_filters('mce_external_plugins', array());
+
+		$ext_plugins = '';
+		if ( ! empty($mce_external_plugins) ) {
+
+			/*
+			The following filter loads external language files for TinyMCE plugins.
+			It takes an associative array 'plugin_name' => 'path', where path is the
+			include path to the file. The language file should follow the same format as
+			/tinymce/langs/wp-langs.php and should define a variable $strings that
+			holds all translated strings.
+			When this filter is not used, the function will try to load {mce_locale}.js.
+			If that is not found, en.js will be tried next.
+			*/
+			$mce_external_languages = apply_filters('mce_external_languages', array());
+
+			$loaded_langs = array();
+			$strings = '';
+
+			if ( ! empty($mce_external_languages) ) {
+				foreach ( $mce_external_languages as $name => $path ) {
+					if ( @is_file($path) && @is_readable($path) ) {
+						include_once($path);
+						$ext_plugins .= $strings . "\n";
+						$loaded_langs[] = $name;
+					}
+				}
+			}
+
+			foreach ( $mce_external_plugins as $name => $url ) {
+
+				if ( is_ssl() ) $url = str_replace('http://', 'https://', $url);
+
+				$plugins[] = '-' . $name;
+
+				$plugurl = dirname($url);
+				$strings = $str1 = $str2 = '';
+				if ( ! in_array($name, $loaded_langs) ) {
+					$path = str_replace( WP_PLUGIN_URL, '', $plugurl );
+					$path = WP_PLUGIN_DIR . $path . '/langs/';
+
+					if ( function_exists('realpath') )
+						$path = trailingslashit( realpath($path) );
+
+					if ( @is_file($path . $mce_locale . '.js') )
+						$strings .= @file_get_contents($path . $mce_locale . '.js') . "\n";
+
+					if ( @is_file($path . $mce_locale . '_dlg.js') )
+						$strings .= @file_get_contents($path . $mce_locale . '_dlg.js') . "\n";
+
+					if ( 'en' != $mce_locale && empty($strings) ) {
+						if ( @is_file($path . 'en.js') ) {
+							$str1 = @file_get_contents($path . 'en.js');
+							$strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n";
+						}
+
+						if ( @is_file($path . 'en_dlg.js') ) {
+							$str2 = @file_get_contents($path . 'en_dlg.js');
+							$strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n";
+						}
+					}
+
+					if ( ! empty($strings) )
+						$ext_plugins .= "\n" . $strings . "\n";
+				}
+
+				$ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
+				$ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
+			}
+		}
+	}
+
+	if ( $teeny ) {
+		$mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') );
+		$mce_buttons = implode($mce_buttons, ',');
+		$mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = '';
+	} else {
+		$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
+		$mce_buttons = implode($mce_buttons, ',');
+
+		$mce_buttons_2 = array( 'formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' );
+		$mce_buttons_2 = apply_filters('mce_buttons_2', $mce_buttons_2);
+		$mce_buttons_2 = implode($mce_buttons_2, ',');
+
+		$mce_buttons_3 = apply_filters('mce_buttons_3', array());
+		$mce_buttons_3 = implode($mce_buttons_3, ',');
+
+		$mce_buttons_4 = apply_filters('mce_buttons_4', array());
+		$mce_buttons_4 = implode($mce_buttons_4, ',');
+	}
+	$no_captions = (bool) apply_filters( 'disable_captions', '' );
+
+	// TinyMCE init settings
+	$initArray = array (
+		'mode' => 'specific_textareas',
+		'editor_selector' => 'theEditor',
+		'width' => '100%',
+		'theme' => 'advanced',
+		'skin' => 'wp_theme',
+		'theme_advanced_buttons1' => $mce_buttons,
+		'theme_advanced_buttons2' => $mce_buttons_2,
+		'theme_advanced_buttons3' => $mce_buttons_3,
+		'theme_advanced_buttons4' => $mce_buttons_4,
+		'language' => $mce_locale,
+		'spellchecker_languages' => $mce_spellchecker_languages,
+		'theme_advanced_toolbar_location' => 'top',
+		'theme_advanced_toolbar_align' => 'left',
+		'theme_advanced_statusbar_location' => 'bottom',
+		'theme_advanced_resizing' => true,
+		'theme_advanced_resize_horizontal' => false,
+		'dialog_type' => 'modal',
+		'formats' => "{
+			alignleft : [
+				{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}},
+				{selector : 'img,table', classes : 'alignleft'}
+			],
+			aligncenter : [
+				{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}},
+				{selector : 'img,table', classes : 'aligncenter'}
+			],
+			alignright : [
+				{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}},
+				{selector : 'img,table', classes : 'alignright'}
+			],
+			strikethrough : {inline : 'del'}
+		}",
+		'relative_urls' => false,
+		'remove_script_host' => false,
+		'convert_urls' => false,
+		'apply_source_formatting' => false,
+		'remove_linebreaks' => true,
+		'gecko_spellcheck' => true,
+		'entities' => '38,amp,60,lt,62,gt',
+		'accessibility_focus' => true,
+		'tabfocus_elements' => 'major-publishing-actions',
+		'media_strict' => false,
+		'paste_remove_styles' => true,
+		'paste_remove_spans' => true,
+		'paste_strip_class_attributes' => 'all',
+		'paste_text_use_dialog' => true,
+		'wpeditimage_disable_captions' => $no_captions,
+		'plugins' => implode( ',', $plugins ),
+	);
+
+	if ( ! empty( $editor_styles ) && is_array( $editor_styles ) ) {
+		$mce_css = array();
+		$style_uri = get_stylesheet_directory_uri();
+		if ( ! is_child_theme() ) {
+			foreach ( $editor_styles as $file )
+				$mce_css[] = "$style_uri/$file";
+		} else {
+			$style_dir    = get_stylesheet_directory();
+			$template_uri = get_template_directory_uri();
+			$template_dir = get_template_directory();
+			foreach ( $editor_styles as $file ) {
+				if ( file_exists( "$template_dir/$file" ) )
+					$mce_css[] = "$template_uri/$file";
+				if ( file_exists( "$style_dir/$file" ) )
+					$mce_css[] = "$style_uri/$file";
+			}
+		}
+		$mce_css = implode( ',', $mce_css );
+	} else {
+		$mce_css = '';
+	}
+
+	$mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' );
+
+	if ( ! empty($mce_css) )
+		$initArray['content_css'] = $mce_css;
+
+	if ( is_array($settings) )
+		$initArray = array_merge($initArray, $settings);
+
+	// For people who really REALLY know what they're doing with TinyMCE
+	// You can modify initArray to add, remove, change elements of the config before tinyMCE.init
+	// Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
+	// Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
+	if ( $teeny ) {
+		$initArray = apply_filters('teeny_mce_before_init', $initArray);
+	} else {
+		$initArray = apply_filters('tiny_mce_before_init', $initArray);
+	}
+
+	if ( empty($initArray['theme_advanced_buttons3']) && !empty($initArray['theme_advanced_buttons4']) ) {
+		$initArray['theme_advanced_buttons3'] = $initArray['theme_advanced_buttons4'];
+		$initArray['theme_advanced_buttons4'] = '';
+	}
+
+	if ( ! isset($concatenate_scripts) )
+		script_concat_settings();
+
+	$language = $initArray['language'];
+
+	$compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING'])
+		&& false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip');
+
+	/**
+	 * Deprecated
+	 *
+	 * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
+	 * These plugins can be refreshed by appending query string to the URL passed to mce_external_plugins filter.
+	 * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
+	 */
+	$version = apply_filters('tiny_mce_version', '');
+	$version = 'ver=' . $tinymce_version . $version;
+
+	if ( 'en' != $language )
+		include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php');
+
+	$mce_options = '';
+	foreach ( $initArray as $k => $v ) {
+		if ( is_bool($v) ) {
+			$val = $v ? 'true' : 'false';
+			$mce_options .= $k . ':' . $val . ', ';
+			continue;
+		} elseif ( !empty($v) && is_string($v) && ( '{' == $v{0} || '[' == $v{0} ) ) {
+			$mce_options .= $k . ':' . $v . ', ';
+			continue;
+		}
+
+		$mce_options .= $k . ':"' . $v . '", ';
+	}
+
+	$mce_options = rtrim( trim($mce_options), '\n\r,' ); ?>
+
+<script type="text/javascript">
+/* <![CDATA[ */
+tinyMCEPreInit = {
+	base : "<?php echo $baseurl; ?>",
+	suffix : "",
+	query : "<?php echo $version; ?>",
+	mceInit : {<?php echo $mce_options; ?>},
+	load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
+};
+/* ]]> */
+</script>
+
+<?php
+	if ( $compressed )
+		echo "<script type='text/javascript' src='$baseurl/wp-tinymce.php?c=1&amp;$version'></script>\n";
+	else
+		echo "<script type='text/javascript' src='$baseurl/tiny_mce.js?$version'></script>\n";
+
+	if ( 'en' != $language && isset($lang) )
+		echo "<script type='text/javascript'>\n$lang\n</script>\n";
+	else
+		echo "<script type='text/javascript' src='$baseurl/langs/wp-langs-en.js?$version'></script>\n";
+?>
+
+<script type="text/javascript">
+/* <![CDATA[ */
+<?php
+	if ( $ext_plugins )
+		echo "$ext_plugins\n";
+
+	if ( ! $compressed ) {
+?>
+(function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.mceInit.language,th=t.mceInit.theme,pl=t.mceInit.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
+<?php } ?>
+tinyMCE.init(tinyMCEPreInit.mceInit);
+/* ]]> */
+</script>
+<?php
+
+	// Load additional inline scripts based on active plugins.
+	if ( in_array( 'wpdialogs', $plugins ) ) {
+		wp_print_scripts( array( 'wpdialogs-popup' ) );
+		wp_print_styles('wp-jquery-ui-dialog');
+	}
+	if ( in_array( 'wplink', $plugins ) ) {
+		require_once ABSPATH . 'wp-admin/includes/internal-linking.php';
+		add_action('tiny_mce_preload_dialogs', 'wp_link_dialog');
+		wp_print_scripts('wplink');
+		wp_print_styles('wplink');
+	}
+}
+function wp_tiny_mce_preload_dialogs() { ?>
+	<div id="preloaded-dialogs" style="display:none;">
+<?php 	do_action('tiny_mce_preload_dialogs'); ?>
+	</div>
+<?php }
Index: /tags/3.1/wp-admin/includes/schema.php
===================================================================
--- /tags/3.1/wp-admin/includes/schema.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/schema.php	(revision 17487)
@@ -0,0 +1,783 @@
+<?php
+/**
+ * WordPress Administration Scheme API
+ *
+ * Here we keep the DB structure and option values.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * The database character collate.
+ * @var string
+ * @global string
+ * @name $charset_collate
+ */
+$charset_collate = '';
+
+// Declare these as global in case schema.php is included from a function.
+global $wpdb, $wp_queries;
+
+if ( ! empty($wpdb->charset) )
+	$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
+if ( ! empty($wpdb->collate) )
+	$charset_collate .= " COLLATE $wpdb->collate";
+
+/** Create WordPress database tables SQL */
+$wp_queries = "CREATE TABLE $wpdb->terms (
+ term_id bigint(20) unsigned NOT NULL auto_increment,
+ name varchar(200) NOT NULL default '',
+ slug varchar(200) NOT NULL default '',
+ term_group bigint(10) NOT NULL default 0,
+ PRIMARY KEY  (term_id),
+ UNIQUE KEY slug (slug),
+ KEY name (name)
+) $charset_collate;
+CREATE TABLE $wpdb->term_taxonomy (
+ term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
+ term_id bigint(20) unsigned NOT NULL default 0,
+ taxonomy varchar(32) NOT NULL default '',
+ description longtext NOT NULL,
+ parent bigint(20) unsigned NOT NULL default 0,
+ count bigint(20) NOT NULL default 0,
+ PRIMARY KEY  (term_taxonomy_id),
+ UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
+ KEY taxonomy (taxonomy)
+) $charset_collate;
+CREATE TABLE $wpdb->term_relationships (
+ object_id bigint(20) unsigned NOT NULL default 0,
+ term_taxonomy_id bigint(20) unsigned 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;
+CREATE TABLE $wpdb->commentmeta (
+  meta_id bigint(20) unsigned NOT NULL auto_increment,
+  comment_id bigint(20) unsigned NOT NULL default '0',
+  meta_key varchar(255) default NULL,
+  meta_value longtext,
+  PRIMARY KEY  (meta_id),
+  KEY comment_id (comment_id),
+  KEY meta_key (meta_key)
+) $charset_collate;
+CREATE TABLE $wpdb->comments (
+  comment_ID bigint(20) unsigned NOT NULL auto_increment,
+  comment_post_ID bigint(20) unsigned NOT NULL default '0',
+  comment_author tinytext NOT NULL,
+  comment_author_email varchar(100) NOT NULL default '',
+  comment_author_url varchar(200) NOT NULL default '',
+  comment_author_IP varchar(100) NOT NULL default '',
+  comment_date datetime NOT NULL default '0000-00-00 00:00:00',
+  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 varchar(20) NOT NULL default '1',
+  comment_agent varchar(255) NOT NULL default '',
+  comment_type varchar(20) NOT NULL default '',
+  comment_parent bigint(20) unsigned NOT NULL default '0',
+  user_id bigint(20) unsigned NOT NULL default '0',
+  PRIMARY KEY  (comment_ID),
+  KEY comment_approved (comment_approved),
+  KEY comment_post_ID (comment_post_ID),
+  KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
+  KEY comment_date_gmt (comment_date_gmt),
+  KEY comment_parent (comment_parent)
+) $charset_collate;
+CREATE TABLE $wpdb->links (
+  link_id bigint(20) unsigned NOT NULL auto_increment,
+  link_url varchar(255) NOT NULL default '',
+  link_name varchar(255) NOT NULL default '',
+  link_image varchar(255) NOT NULL default '',
+  link_target varchar(25) NOT NULL default '',
+  link_description varchar(255) NOT NULL default '',
+  link_visible varchar(20) NOT NULL default 'Y',
+  link_owner bigint(20) unsigned NOT NULL default '1',
+  link_rating int(11) NOT NULL default '0',
+  link_updated datetime NOT NULL default '0000-00-00 00:00:00',
+  link_rel varchar(255) NOT NULL default '',
+  link_notes mediumtext NOT NULL,
+  link_rss varchar(255) NOT NULL default '',
+  PRIMARY KEY  (link_id),
+  KEY link_visible (link_visible)
+) $charset_collate;
+CREATE TABLE $wpdb->options (
+  option_id bigint(20) unsigned NOT NULL auto_increment,
+  blog_id int(11) NOT NULL default '0',
+  option_name varchar(64) NOT NULL default '',
+  option_value longtext NOT NULL,
+  autoload varchar(20) NOT NULL default 'yes',
+  PRIMARY KEY  (option_id),
+  UNIQUE KEY option_name (option_name)
+) $charset_collate;
+CREATE TABLE $wpdb->postmeta (
+  meta_id bigint(20) unsigned NOT NULL auto_increment,
+  post_id bigint(20) unsigned NOT NULL default '0',
+  meta_key varchar(255) default NULL,
+  meta_value longtext,
+  PRIMARY KEY  (meta_id),
+  KEY post_id (post_id),
+  KEY meta_key (meta_key)
+) $charset_collate;
+CREATE TABLE $wpdb->posts (
+  ID bigint(20) unsigned NOT NULL auto_increment,
+  post_author bigint(20) unsigned NOT NULL default '0',
+  post_date datetime NOT NULL default '0000-00-00 00:00:00',
+  post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+  post_content longtext NOT NULL,
+  post_title text NOT NULL,
+  post_excerpt text NOT NULL,
+  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,
+  pinged text NOT NULL,
+  post_modified datetime NOT NULL default '0000-00-00 00:00:00',
+  post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+  post_content_filtered text NOT NULL,
+  post_parent bigint(20) unsigned NOT NULL default '0',
+  guid varchar(255) NOT NULL default '',
+  menu_order int(11) NOT NULL default '0',
+  post_type varchar(20) NOT NULL default 'post',
+  post_mime_type varchar(100) NOT NULL default '',
+  comment_count bigint(20) NOT NULL default '0',
+  PRIMARY KEY  (ID),
+  KEY post_name (post_name),
+  KEY type_status_date (post_type,post_status,post_date,ID),
+  KEY post_parent (post_parent),
+  KEY post_author (post_author)
+) $charset_collate;
+CREATE TABLE $wpdb->users (
+  ID bigint(20) unsigned NOT NULL auto_increment,
+  user_login varchar(60) NOT NULL default '',
+  user_pass varchar(64) NOT NULL default '',
+  user_nicename varchar(50) NOT NULL default '',
+  user_email varchar(100) NOT NULL default '',
+  user_url varchar(100) NOT NULL default '',
+  user_registered datetime NOT NULL default '0000-00-00 00:00:00',
+  user_activation_key varchar(60) NOT NULL default '',
+  user_status int(11) NOT NULL default '0',
+  display_name varchar(250) NOT NULL default '',
+  PRIMARY KEY  (ID),
+  KEY user_login_key (user_login),
+  KEY user_nicename (user_nicename)
+) $charset_collate;
+CREATE TABLE $wpdb->usermeta (
+  umeta_id bigint(20) unsigned NOT NULL auto_increment,
+  user_id bigint(20) unsigned NOT NULL default '0',
+  meta_key varchar(255) default NULL,
+  meta_value longtext,
+  PRIMARY KEY  (umeta_id),
+  KEY user_id (user_id),
+  KEY meta_key (meta_key)
+) $charset_collate;";
+
+/**
+ * Create WordPress options and set the default values.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ * @uses $wp_db_version
+ */
+function populate_options() {
+	global $wpdb, $wp_db_version, $current_site;
+
+	$guessurl = wp_guess_url();
+
+	do_action('populate_options');
+
+	if ( ini_get('safe_mode') ) {
+		// Safe mode can break mkdir() so use a flat structure by default.
+		$uploads_use_yearmonth_folders = 0;
+	} else {
+		$uploads_use_yearmonth_folders = 1;
+	}
+
+	$options = array(
+	'siteurl' => $guessurl,
+	'blogname' => __('My Site'),
+	/* translators: blog tagline */
+	'blogdescription' => __('Just another WordPress site'),
+	'users_can_register' => 0,
+	'admin_email' => 'you@example.com',
+	'start_of_week' => 1,
+	'use_balanceTags' => 0,
+	'use_smilies' => 1,
+	'require_name_email' => 1,
+	'comments_notify' => 1,
+	'posts_per_rss' => 10,
+	'rss_use_excerpt' => 0,
+	'mailserver_url' => 'mail.example.com',
+	'mailserver_login' => 'login@example.com',
+	'mailserver_pass' => 'password',
+	'mailserver_port' => 110,
+	'default_category' => 1,
+	'default_comment_status' => 'open',
+	'default_ping_status' => 'open',
+	'default_pingback_flag' => 1,
+	'default_post_edit_rows' => 20,
+	'posts_per_page' => 10,
+	/* translators: default date format, see http://php.net/date */
+	'date_format' => __('F j, Y'),
+	/* translators: default time format, see http://php.net/date */
+	'time_format' => __('g:i a'),
+	/* translators: links last updated date format, see http://php.net/date */
+	'links_updated_date_format' => __('F j, Y g:i a'),
+	'links_recently_updated_prepend' => '<em>',
+	'links_recently_updated_append' => '</em>',
+	'links_recently_updated_time' => 120,
+	'comment_moderation' => 0,
+	'moderation_notify' => 1,
+	'permalink_structure' => '',
+	'gzipcompression' => 0,
+	'hack_file' => 0,
+	'blog_charset' => 'UTF-8',
+	'moderation_keys' => '',
+	'active_plugins' => array(),
+	'home' => $guessurl,
+	'category_base' => '',
+	'ping_sites' => 'http://rpc.pingomatic.com/',
+	'advanced_edit' => 0,
+	'comment_max_links' => 2,
+	'gmt_offset' => date('Z') / 3600,
+
+	// 1.5
+	'default_email_category' => 1,
+	'recently_edited' => '',
+	'template' => WP_DEFAULT_THEME,
+	'stylesheet' => WP_DEFAULT_THEME,
+	'comment_whitelist' => 1,
+	'blacklist_keys' => '',
+	'comment_registration' => 0,
+	'rss_language' => 'en',
+	'html_type' => 'text/html',
+
+	// 1.5.1
+	'use_trackback' => 0,
+
+	// 2.0
+	'default_role' => 'subscriber',
+	'db_version' => $wp_db_version,
+
+	// 2.0.1
+	'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
+	'upload_path' => '',
+
+	// 2.1
+	'blog_public' => '1',
+	'default_link_category' => 2,
+	'show_on_front' => 'posts',
+
+	// 2.2
+	'tag_base' => '',
+
+	// 2.5
+	'show_avatars' => '1',
+	'avatar_rating' => 'G',
+	'upload_url_path' => '',
+	'thumbnail_size_w' => 150,
+	'thumbnail_size_h' => 150,
+	'thumbnail_crop' => 1,
+	'medium_size_w' => 300,
+	'medium_size_h' => 300,
+
+	// 2.6
+	'avatar_default' => 'mystery',
+	'enable_app' => 0,
+	'enable_xmlrpc' => 0,
+
+	// 2.7
+	'large_size_w' => 1024,
+	'large_size_h' => 1024,
+	'image_default_link_type' => 'file',
+	'image_default_size' => '',
+	'image_default_align' => '',
+	'close_comments_for_old_posts' => 0,
+	'close_comments_days_old' => 14,
+	'thread_comments' => 1,
+	'thread_comments_depth' => 5,
+	'page_comments' => 0,
+	'comments_per_page' => 50,
+	'default_comments_page' => 'newest',
+	'comment_order' => 'asc',
+	'sticky_posts' => array(),
+	'widget_categories' => array(),
+	'widget_text' => array(),
+	'widget_rss' => array(),
+
+	// 2.8
+	'timezone_string' => '',
+
+	// 2.9
+	'embed_autourls' => 1,
+	'embed_size_w' => '',
+	'embed_size_h' => 600,
+
+	// 3.0
+	'page_for_posts' => 0,
+	'page_on_front' => 0,
+
+	// 3.1
+	'default_post_format' => 0,
+	);
+
+	// 3.0 multisite
+	if ( is_multisite() ) {
+		/* translators: blog tagline */
+		$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name );
+		$options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
+	}
+
+	// Set autoload to no for these options
+	$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
+
+	$existing_options = $wpdb->get_col("SELECT option_name FROM $wpdb->options");
+
+	$insert = '';
+	foreach ( $options as $option => $value ) {
+		if ( in_array($option, $existing_options) )
+			continue;
+		if ( in_array($option, $fat_options) )
+			$autoload = 'no';
+		else
+			$autoload = 'yes';
+
+		$option = $wpdb->escape($option);
+		if ( is_array($value) )
+			$value = serialize($value);
+		$value = $wpdb->escape($value);
+		if ( !empty($insert) )
+			$insert .= ', ';
+		$insert .= "('$option', '$value', '$autoload')";
+	}
+
+	if ( !empty($insert) )
+		$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert);
+
+	// in case it is set, but blank, update "home"
+	if ( !__get_option('home') ) update_option('home', $guessurl);
+
+	// 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', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show');
+	foreach ( $unusedoptions as $option )
+		delete_option($option);
+
+	// delete obsolete magpie stuff
+	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
+}
+
+/**
+ * Execute WordPress role creation for the various WordPress versions.
+ *
+ * @since 2.0.0
+ */
+function populate_roles() {
+	populate_roles_160();
+	populate_roles_210();
+	populate_roles_230();
+	populate_roles_250();
+	populate_roles_260();
+	populate_roles_270();
+	populate_roles_280();
+	populate_roles_300();
+}
+
+/**
+ * Create the roles for WordPress 2.0
+ *
+ * @since 2.0.0
+ */
+function populate_roles_160() {
+	// Add roles
+
+	// Dummy gettext calls to get strings in the catalog.
+	/* translators: user role */
+	_x('Administrator', 'User role');
+	/* translators: user role */
+	_x('Editor', 'User role');
+	/* translators: user role */
+	_x('Author', 'User role');
+	/* translators: user role */
+	_x('Contributor', 'User role');
+	/* translators: user role */
+	_x('Subscriber', 'User role');
+
+	add_role('administrator', 'Administrator');
+	add_role('editor', 'Editor');
+	add_role('author', 'Author');
+	add_role('contributor', 'Contributor');
+	add_role('subscriber', 'Subscriber');
+
+	// Add caps for Administrator role
+	$role =& get_role('administrator');
+	$role->add_cap('switch_themes');
+	$role->add_cap('edit_themes');
+	$role->add_cap('activate_plugins');
+	$role->add_cap('edit_plugins');
+	$role->add_cap('edit_users');
+	$role->add_cap('edit_files');
+	$role->add_cap('manage_options');
+	$role->add_cap('moderate_comments');
+	$role->add_cap('manage_categories');
+	$role->add_cap('manage_links');
+	$role->add_cap('upload_files');
+	$role->add_cap('import');
+	$role->add_cap('unfiltered_html');
+	$role->add_cap('edit_posts');
+	$role->add_cap('edit_others_posts');
+	$role->add_cap('edit_published_posts');
+	$role->add_cap('publish_posts');
+	$role->add_cap('edit_pages');
+	$role->add_cap('read');
+	$role->add_cap('level_10');
+	$role->add_cap('level_9');
+	$role->add_cap('level_8');
+	$role->add_cap('level_7');
+	$role->add_cap('level_6');
+	$role->add_cap('level_5');
+	$role->add_cap('level_4');
+	$role->add_cap('level_3');
+	$role->add_cap('level_2');
+	$role->add_cap('level_1');
+	$role->add_cap('level_0');
+
+	// Add caps for Editor role
+	$role =& get_role('editor');
+	$role->add_cap('moderate_comments');
+	$role->add_cap('manage_categories');
+	$role->add_cap('manage_links');
+	$role->add_cap('upload_files');
+	$role->add_cap('unfiltered_html');
+	$role->add_cap('edit_posts');
+	$role->add_cap('edit_others_posts');
+	$role->add_cap('edit_published_posts');
+	$role->add_cap('publish_posts');
+	$role->add_cap('edit_pages');
+	$role->add_cap('read');
+	$role->add_cap('level_7');
+	$role->add_cap('level_6');
+	$role->add_cap('level_5');
+	$role->add_cap('level_4');
+	$role->add_cap('level_3');
+	$role->add_cap('level_2');
+	$role->add_cap('level_1');
+	$role->add_cap('level_0');
+
+	// Add caps for Author role
+	$role =& get_role('author');
+	$role->add_cap('upload_files');
+	$role->add_cap('edit_posts');
+	$role->add_cap('edit_published_posts');
+	$role->add_cap('publish_posts');
+	$role->add_cap('read');
+	$role->add_cap('level_2');
+	$role->add_cap('level_1');
+	$role->add_cap('level_0');
+
+	// Add caps for Contributor role
+	$role =& get_role('contributor');
+	$role->add_cap('edit_posts');
+	$role->add_cap('read');
+	$role->add_cap('level_1');
+	$role->add_cap('level_0');
+
+	// Add caps for Subscriber role
+	$role =& get_role('subscriber');
+	$role->add_cap('read');
+	$role->add_cap('level_0');
+}
+
+/**
+ * Create and modify WordPress roles for WordPress 2.1.
+ *
+ * @since 2.1.0
+ */
+function populate_roles_210() {
+	$roles = array('administrator', 'editor');
+	foreach ($roles as $role) {
+		$role =& get_role($role);
+		if ( empty($role) )
+			continue;
+
+		$role->add_cap('edit_others_pages');
+		$role->add_cap('edit_published_pages');
+		$role->add_cap('publish_pages');
+		$role->add_cap('delete_pages');
+		$role->add_cap('delete_others_pages');
+		$role->add_cap('delete_published_pages');
+		$role->add_cap('delete_posts');
+		$role->add_cap('delete_others_posts');
+		$role->add_cap('delete_published_posts');
+		$role->add_cap('delete_private_posts');
+		$role->add_cap('edit_private_posts');
+		$role->add_cap('read_private_posts');
+		$role->add_cap('delete_private_pages');
+		$role->add_cap('edit_private_pages');
+		$role->add_cap('read_private_pages');
+	}
+
+	$role =& get_role('administrator');
+	if ( ! empty($role) ) {
+		$role->add_cap('delete_users');
+		$role->add_cap('create_users');
+	}
+
+	$role =& get_role('author');
+	if ( ! empty($role) ) {
+		$role->add_cap('delete_posts');
+		$role->add_cap('delete_published_posts');
+	}
+
+	$role =& get_role('contributor');
+	if ( ! empty($role) ) {
+		$role->add_cap('delete_posts');
+	}
+}
+
+/**
+ * Create and modify WordPress roles for WordPress 2.3.
+ *
+ * @since 2.3.0
+ */
+function populate_roles_230() {
+	$role =& get_role( 'administrator' );
+
+	if ( !empty( $role ) ) {
+		$role->add_cap( 'unfiltered_upload' );
+	}
+}
+
+/**
+ * Create and modify WordPress roles for WordPress 2.5.
+ *
+ * @since 2.5.0
+ */
+function populate_roles_250() {
+	$role =& get_role( 'administrator' );
+
+	if ( !empty( $role ) ) {
+		$role->add_cap( 'edit_dashboard' );
+	}
+}
+
+/**
+ * Create and modify WordPress roles for WordPress 2.6.
+ *
+ * @since 2.6.0
+ */
+function populate_roles_260() {
+	$role =& get_role( 'administrator' );
+
+	if ( !empty( $role ) ) {
+		$role->add_cap( 'update_plugins' );
+		$role->add_cap( 'delete_plugins' );
+	}
+}
+
+/**
+ * Create and modify WordPress roles for WordPress 2.7.
+ *
+ * @since 2.7.0
+ */
+function populate_roles_270() {
+	$role =& get_role( 'administrator' );
+
+	if ( !empty( $role ) ) {
+		$role->add_cap( 'install_plugins' );
+		$role->add_cap( 'update_themes' );
+	}
+}
+
+/**
+ * Create and modify WordPress roles for WordPress 2.8.
+ *
+ * @since 2.8.0
+ */
+function populate_roles_280() {
+	$role =& get_role( 'administrator' );
+
+	if ( !empty( $role ) ) {
+		$role->add_cap( 'install_themes' );
+	}
+}
+
+/**
+ * Create and modify WordPress roles for WordPress 3.0.
+ *
+ * @since 3.0.0
+ */
+function populate_roles_300() {
+	$role =& get_role( 'administrator' );
+
+	if ( !empty( $role ) ) {
+		$role->add_cap( 'update_core' );
+		$role->add_cap( 'list_users' );
+		$role->add_cap( 'remove_users' );
+		$role->add_cap( 'add_users' );
+		$role->add_cap( 'promote_users' );
+		$role->add_cap( 'edit_theme_options' );
+		$role->add_cap( 'delete_themes' );
+		$role->add_cap( 'export' );
+	}
+}
+
+/**
+ * populate network settings
+ *
+ * @since 3.0.0
+ *
+ * @param int $network_id id of network to populate
+ * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful,
+ * 	so the error code must be checked) or failure.
+ */
+function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
+	global $wpdb, $current_site, $wp_db_version, $wp_rewrite;
+
+	$errors = new WP_Error();
+	if ( '' == $domain )
+		$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
+	if ( '' == $site_name )
+		$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
+
+	// check for network collision
+	if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
+		$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
+
+	$site_user = get_user_by_email( $email );
+	if ( ! is_email( $email ) )
+		$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );
+
+	if ( $errors->get_error_code() )
+		return $errors;
+
+	// set up site tables
+	$template = get_option( 'template' );
+	$stylesheet = get_option( 'stylesheet' );
+	$allowed_themes = array( $stylesheet => true );
+	if ( $template != $stylesheet )
+		$allowed_themes[ $template ] = true;
+	if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template )
+		$allowed_themes[ WP_DEFAULT_THEME ] = true;
+
+	if ( 1 == $network_id ) {
+		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
+		$network_id = $wpdb->insert_id;
+	} else {
+		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
+	}
+
+	if ( !is_multisite() ) {
+		$site_admins = array( $site_user->user_login );
+		$users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) );
+		if ( $users ) {
+			foreach ( $users as $user ) {
+				if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
+					$site_admins[] = $user->user_login;
+			}
+		}
+	} else {
+		$site_admins = get_site_option( 'site_admins' );
+	}
+
+	$welcome_email = __( 'Dear User,
+
+Your new SITE_NAME site has been successfully set up at:
+BLOG_URL
+
+You can log in to the administrator account with the following information:
+Username: USERNAME
+Password: PASSWORD
+Login Here: BLOG_URLwp-login.php
+
+We hope you enjoy your new site.
+Thanks!
+
+--The Team @ SITE_NAME' );
+
+	$sitemeta = array(
+		'site_name' => $site_name,
+		'admin_email' => $site_user->user_email,
+		'admin_user_id' => $site_user->ID,
+		'registration' => 'none',
+		'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',
+		'blog_upload_space' => 10,
+		'fileupload_maxk' => 1500,
+		'site_admins' => $site_admins,
+		'allowedthemes' => $allowed_themes,
+		'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
+		'wpmu_upgrade_site' => $wp_db_version,
+		'welcome_email' => $welcome_email,
+		'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
+		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
+		'siteurl' => get_option( 'siteurl' ) . '/',
+		'add_new_users' => '0',
+		'upload_space_check_disabled' => '0',
+		'subdomain_install' => intval( $subdomain_install ),
+		'global_terms_enabled' => global_terms_enabled() ? '1' : '0'
+	);
+	if ( ! $subdomain_install )
+		$sitemeta['illegal_names'][] = 'blog';
+
+	$insert = '';
+	foreach ( $sitemeta as $meta_key => $meta_value ) {
+		$meta_key = $wpdb->escape( $meta_key );
+		if ( is_array( $meta_value ) )
+			$meta_value = serialize( $meta_value );
+		$meta_value = $wpdb->escape( $meta_value );
+		if ( !empty( $insert ) )
+			$insert .= ', ';
+		$insert .= "( $network_id, '$meta_key', '$meta_value')";
+	}
+	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
+
+	$current_site->domain = $domain;
+	$current_site->path = $path;
+	$current_site->site_name = ucfirst( $domain );
+
+	if ( !is_multisite() ) {
+		$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
+		$blog_id = $wpdb->insert_id;
+		update_user_meta( $site_user->ID, 'source_domain', $domain );
+		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
+		if ( !$upload_path = get_option( 'upload_path' ) ) {
+			$upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
+			update_option( 'upload_path', $upload_path );
+		}
+		update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
+	}
+
+	if ( $subdomain_install )
+		update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
+	else
+		update_option( 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/');
+
+	$wp_rewrite->flush_rules();
+
+	if ( $subdomain_install ) {
+		$vhost_ok = false;
+		$errstr = '';
+		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
+		$page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
+		if ( is_wp_error( $page ) )
+			$errstr = $page->get_error_message();
+		elseif ( 200 == $page['response']['code'] )
+				$vhost_ok = true;
+
+		if ( ! $vhost_ok ) {
+			$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';
+			$msg .= '<p>' . sprintf( __( 'The installer attempted to contact a random hostname (<code>%1$s</code>) on your domain.' ), $hostname );
+			if ( ! empty ( $errstr ) )
+				$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
+			$msg .= '</p>';
+			$msg .= '<p>' . __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a <code>*</code> hostname record pointing at your web server in your DNS configuration tool.' ) . '</p>';
+			$msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>';
+			return new WP_Error( 'no_wildcard_dns', $msg );
+		}
+	}
+
+	return true;
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/taxonomy.php
===================================================================
--- /tags/3.1/wp-admin/includes/taxonomy.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/taxonomy.php	(revision 17487)
@@ -0,0 +1,252 @@
+<?php
+/**
+ * WordPress Taxonomy Administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+//
+// Category
+//
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $cat_name
+ * @return unknown
+ */
+function category_exists($cat_name, $parent = 0) {
+	$id = term_exists($cat_name, 'category', $parent);
+	if ( is_array($id) )
+		$id = $id['term_id'];
+	return $id;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
+function get_category_to_edit( $id ) {
+	$category = get_category( $id, OBJECT, 'edit' );
+	return $category;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $cat_name
+ * @param unknown_type $parent
+ * @return unknown
+ */
+function wp_create_category( $cat_name, $parent = 0 ) {
+	if ( $id = category_exists($cat_name, $parent) )
+		return $id;
+
+	return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $categories
+ * @param unknown_type $post_id
+ * @return unknown
+ */
+function wp_create_categories($categories, $post_id = '') {
+	$cat_ids = array ();
+	foreach ($categories as $category) {
+		if ($id = category_exists($category))
+			$cat_ids[] = $id;
+		else
+			if ($id = wp_create_category($category))
+				$cat_ids[] = $id;
+	}
+
+	if ( $post_id )
+		wp_set_post_categories($post_id, $cat_ids);
+
+	return $cat_ids;
+}
+
+/**
+ * Updates an existing Category or creates a new Category.
+ *
+ * @since 2.0.0
+ *
+ * @param mixed $catarr See defaults below. Set 'cat_ID' to a non-zero value to update an existing category. The 'taxonomy' key was added in 3.0.0.
+ * @param bool $wp_error Optional, since 2.5.0. Set this to true if the caller handles WP_Error return values.
+ * @return int|object The ID number of the new or updated Category on success.  Zero or a WP_Error on failure, depending on param $wp_error.
+ */
+function wp_insert_category($catarr, $wp_error = false) {
+	$cat_defaults = array('cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
+	$catarr = wp_parse_args($catarr, $cat_defaults);
+	extract($catarr, EXTR_SKIP);
+
+	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;
+
+	// Are we updating or creating?
+	if ( !empty ($cat_ID) )
+		$update = true;
+	else
+		$update = false;
+
+	$name = $cat_name;
+	$description = $category_description;
+	$slug = $category_nicename;
+	$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;
+
+	$args = compact('name', 'slug', 'parent', 'description');
+
+	if ( $update )
+		$cat_ID = wp_update_term($cat_ID, $taxonomy, $args);
+	else
+		$cat_ID = wp_insert_term($cat_name, $taxonomy, $args);
+
+	if ( is_wp_error($cat_ID) ) {
+		if ( $wp_error )
+			return $cat_ID;
+		else
+			return 0;
+	}
+
+	return $cat_ID['term_id'];
+}
+
+/**
+ * Aliases wp_insert_category() with minimal args.
+ *
+ * If you want to update only some fields of an existing category, call this
+ * function with only the new values set inside $catarr.
+ *
+ * @since 2.0.0
+ *
+ * @param array $catarr The 'cat_ID' value is required.  All other keys are optional.
+ * @return int|bool The ID number of the new or updated Category on success. Zero or FALSE on failure.
+ */
+function wp_update_category($catarr) {
+	$cat_ID = (int) $catarr['cat_ID'];
+
+	if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) )
+		return false;
+
+	// First, get all of the original fields
+	$category = get_category($cat_ID, ARRAY_A);
+
+	// Escape data pulled from DB.
+	$category = add_magic_quotes($category);
+
+	// Merge old and new fields with new fields overwriting old ones.
+	$catarr = array_merge($category, $catarr);
+
+	return wp_insert_category($catarr);
+}
+
+//
+// Tags
+//
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param unknown_type $tag_name
+ * @return unknown
+ */
+function tag_exists($tag_name) {
+	return term_exists($tag_name, 'post_tag');
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param unknown_type $tag_name
+ * @return unknown
+ */
+function wp_create_tag($tag_name) {
+	return wp_create_term( $tag_name, 'post_tag');
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param unknown_type $post_id
+ * @return unknown
+ */
+function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
+	return get_terms_to_edit( $post_id, $taxonomy);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.8.0
+ *
+ * @param unknown_type $post_id
+ * @return unknown
+ */
+function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
+	$post_id = (int) $post_id;
+	if ( !$post_id )
+		return false;
+
+	$tags = wp_get_post_terms($post_id, $taxonomy, array());
+
+	if ( !$tags )
+		return false;
+
+	if ( is_wp_error($tags) )
+		return $tags;
+
+	foreach ( $tags as $tag )
+		$tag_names[] = $tag->name;
+	$tags_to_edit = join( ',', $tag_names );
+	$tags_to_edit = esc_attr( $tags_to_edit );
+	$tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );
+
+	return $tags_to_edit;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.8.0
+ *
+ * @param unknown_type $tag_name
+ * @return unknown
+ */
+function wp_create_term($tag_name, $taxonomy = 'post_tag') {
+	if ( $id = term_exists($tag_name, $taxonomy) )
+		return $id;
+
+	return wp_insert_term($tag_name, $taxonomy);
+}
Index: /tags/3.1/wp-admin/includes/template.php
===================================================================
--- /tags/3.1/wp-admin/includes/template.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/template.php	(revision 17487)
@@ -0,0 +1,2188 @@
+<?php
+/**
+ * Template WordPress Administration API.
+ *
+ * A Big Mess. Also some neat functions that are nicely written.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+
+//
+// Category Checklists
+//
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.1
+ */
+class Walker_Category_Checklist extends Walker {
+	var $tree_type = 'category';
+	var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
+
+	function start_lvl(&$output, $depth, $args) {
+		$indent = str_repeat("\t", $depth);
+		$output .= "$indent<ul class='children'>\n";
+	}
+
+	function end_lvl(&$output, $depth, $args) {
+		$indent = str_repeat("\t", $depth);
+		$output .= "$indent</ul>\n";
+	}
+
+	function start_el(&$output, $category, $depth, $args) {
+		extract($args);
+		if ( empty($taxonomy) )
+			$taxonomy = 'category';
+
+		if ( $taxonomy == 'category' )
+			$name = 'post_category';
+		else
+			$name = 'tax_input['.$taxonomy.']';
+
+		$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
+		$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
+	}
+
+	function end_el(&$output, $category, $depth, $args) {
+		$output .= "</li>\n";
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.1
+ *
+ * @param unknown_type $post_id
+ * @param unknown_type $descendants_and_self
+ * @param unknown_type $selected_cats
+ * @param unknown_type $popular_cats
+ */
+function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
+	wp_terms_checklist($post_id,
+	 	array(
+			'taxonomy' => 'category',
+			'descendants_and_self' => $descendants_and_self,
+			'selected_cats' => $selected_cats,
+			'popular_cats' => $popular_cats,
+			'walker' => $walker,
+			'checked_ontop' => $checked_ontop
+  ));
+}
+
+/**
+ * Taxonomy independent version of wp_category_checklist
+ *
+ * @since 3.0.0
+ *
+ * @param int $post_id
+ * @param array $args
+ */
+function wp_terms_checklist($post_id = 0, $args = array()) {
+ 	$defaults = array(
+		'descendants_and_self' => 0,
+		'selected_cats' => false,
+		'popular_cats' => false,
+		'walker' => null,
+		'taxonomy' => 'category',
+		'checked_ontop' => true
+	);
+	extract( wp_parse_args($args, $defaults), EXTR_SKIP );
+
+	if ( empty($walker) || !is_a($walker, 'Walker') )
+		$walker = new Walker_Category_Checklist;
+
+	$descendants_and_self = (int) $descendants_and_self;
+
+	$args = array('taxonomy' => $taxonomy);
+
+	$tax = get_taxonomy($taxonomy);
+	$args['disabled'] = !current_user_can($tax->cap->assign_terms);
+
+	if ( is_array( $selected_cats ) )
+		$args['selected_cats'] = $selected_cats;
+	elseif ( $post_id )
+		$args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
+	else
+		$args['selected_cats'] = array();
+
+	if ( is_array( $popular_cats ) )
+		$args['popular_cats'] = $popular_cats;
+	else
+		$args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
+
+	if ( $descendants_and_self ) {
+		$categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
+		$self = get_term( $descendants_and_self, $taxonomy );
+		array_unshift( $categories, $self );
+	} else {
+		$categories = (array) get_terms($taxonomy, array('get' => 'all'));
+	}
+
+	if ( $checked_ontop ) {
+		// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
+		$checked_categories = array();
+		$keys = array_keys( $categories );
+
+		foreach( $keys as $k ) {
+			if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
+				$checked_categories[] = $categories[$k];
+				unset( $categories[$k] );
+			}
+		}
+
+		// Put checked cats on top
+		echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
+	}
+	// Then the rest of them
+	echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $taxonomy
+ * @param unknown_type $default
+ * @param unknown_type $number
+ * @param unknown_type $echo
+ * @return unknown
+ */
+function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
+	global $post_ID;
+
+	if ( $post_ID )
+		$checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids'));
+	else
+		$checked_terms = array();
+
+	$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
+
+	$tax = get_taxonomy($taxonomy);
+	if ( ! current_user_can($tax->cap->assign_terms) )
+		$disabled = 'disabled="disabled"';
+	else
+		$disabled = '';
+
+	$popular_ids = array();
+	foreach ( (array) $terms as $term ) {
+		$popular_ids[] = $term->term_id;
+		if ( !$echo ) // hack for AJAX use
+			continue;
+		$id = "popular-$taxonomy-$term->term_id";
+		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
+		?>
+
+		<li id="<?php echo $id; ?>" class="popular-category">
+			<label class="selectit">
+			<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>
+				<?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
+			</label>
+		</li>
+
+		<?php
+	}
+	return $popular_ids;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.1
+ *
+ * @param unknown_type $link_id
+ */
+function wp_link_category_checklist( $link_id = 0 ) {
+	$default = 1;
+
+	if ( $link_id ) {
+		$checked_categories = wp_get_link_cats( $link_id );
+		// No selected categories, strange
+		if ( ! count( $checked_categories ) )
+			$checked_categories[] = $default;
+	} else {
+		$checked_categories[] = $default;
+	}
+
+	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
+
+	if ( empty( $categories ) )
+		return;
+
+	foreach ( $categories as $category ) {
+		$cat_id = $category->term_id;
+		$name = esc_html( apply_filters( 'the_category', $category->name ) );
+		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
+		echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";
+	}
+}
+
+/**
+ * Get the column headers for a screen
+ *
+ * @since 2.7.0
+ *
+ * @param string|object $screen The screen you want the headers for
+ * @return array Containing the headers in the format id => UI String
+ */
+function get_column_headers( $screen ) {
+	if ( is_string( $screen ) )
+		$screen = convert_to_screen( $screen );
+
+	global $_wp_column_headers;
+
+	if ( !isset( $_wp_column_headers[ $screen->id ] ) ) {
+		$_wp_column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() );
+	}
+
+	return $_wp_column_headers[ $screen->id ];
+}
+
+/**
+ * Get a list of hidden columns.
+ *
+ * @since 2.7.0
+ *
+ * @param string|object $screen The screen you want the hidden columns for
+ * @return array
+ */
+function get_hidden_columns( $screen ) {
+	if ( is_string( $screen ) )
+		$screen = convert_to_screen( $screen );
+
+	return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' );
+}
+
+// adds hidden fields with the data for use in the inline editor for posts and pages
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $post
+ */
+function get_inline_data($post) {
+	$post_type_object = get_post_type_object($post->post_type);
+	if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) )
+		return;
+
+	$title = esc_textarea( trim( $post->post_title ) );
+
+	echo '
+<div class="hidden" id="inline_' . $post->ID . '">
+	<div class="post_title">' . $title . '</div>
+	<div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div>
+	<div class="post_author">' . $post->post_author . '</div>
+	<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
+	<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
+	<div class="_status">' . esc_html( $post->post_status ) . '</div>
+	<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
+	<div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
+	<div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
+	<div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
+	<div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
+	<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
+	<div class="post_password">' . esc_html( $post->post_password ) . '</div>';
+
+	if ( $post_type_object->hierarchical )
+		echo '<div class="post_parent">' . $post->post_parent . '</div>';
+
+	if ( $post->post_type == 'page' )
+		echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
+
+	if ( $post_type_object->hierarchical )
+		echo '<div class="menu_order">' . $post->menu_order . '</div>';
+
+	$taxonomy_names = get_object_taxonomies( $post->post_type );
+	foreach ( $taxonomy_names as $taxonomy_name) {
+		$taxonomy = get_taxonomy( $taxonomy_name );
+
+		if ( $taxonomy->hierarchical && $taxonomy->show_ui )
+				echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">' . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array('fields'=>'ids')) ) . '</div>';
+		elseif ( $taxonomy->show_ui )
+			echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' . esc_html( str_replace( ',', ', ', get_terms_to_edit($post->ID, $taxonomy_name) ) ) . '</div>';
+	}
+
+	if ( !$post_type_object->hierarchical )
+		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
+
+	echo '</div>';
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $position
+ * @param unknown_type $checkbox
+ * @param unknown_type $mode
+ */
+function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
+	// allow plugin to replace the popup content
+	$content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
+
+	if ( ! empty($content) ) {
+		echo $content;
+		return;
+	}
+
+	if ( $mode == 'single' ) {
+		$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
+	} else {
+		$wp_list_table = _get_list_table('WP_Comments_List_Table');
+	}
+
+?>
+<form method="get" action="">
+<?php if ( $table_row ) : ?>
+<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
+<?php else : ?>
+<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
+<?php endif; ?>
+	<div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
+
+	<div id="edithead" style="display:none;">
+		<div class="inside">
+		<label for="author"><?php _e('Name') ?></label>
+		<input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
+		</div>
+
+		<div class="inside">
+		<label for="author-email"><?php _e('E-mail') ?></label>
+		<input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
+		</div>
+
+		<div class="inside">
+		<label for="author-url"><?php _e('URL') ?></label>
+		<input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
+		</div>
+		<div style="clear:both;"></div>
+	</div>
+
+	<div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
+
+	<p id="replysubmit" class="submit">
+	<a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
+	<a href="#comments-form" class="save button-primary alignright" tabindex="104">
+	<span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
+	<span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
+	<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+	<span class="error" style="display:none;"></span>
+	<br class="clear" />
+	</p>
+
+	<input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
+	<input type="hidden" name="action" id="action" value="" />
+	<input type="hidden" name="comment_ID" id="comment_ID" value="" />
+	<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
+	<input type="hidden" name="status" id="status" value="" />
+	<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
+	<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
+	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
+	<?php wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); ?>
+	<?php wp_comment_form_unfiltered_html_nonce(); ?>
+<?php if ( $table_row ) : ?>
+</td></tr></tbody></table>
+<?php else : ?>
+</div></div>
+<?php endif; ?>
+</form>
+<?php
+}
+
+/**
+ * Output 'undo move to trash' text for comments
+ *
+ * @since 2.9.0
+ */
+function wp_comment_trashnotice() {
+?>
+<div class="hidden" id="trash-undo-holder">
+	<div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>
+</div>
+<div class="hidden" id="spam-undo-holder">
+	<div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div>
+</div>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.2.0
+ *
+ * @param unknown_type $meta
+ */
+function list_meta( $meta ) {
+	// Exit if no meta
+	if ( ! $meta ) {
+		echo '
+<table id="list-table" style="display: none;">
+	<thead>
+	<tr>
+		<th class="left">' . __( 'Name' ) . '</th>
+		<th>' . __( 'Value' ) . '</th>
+	</tr>
+	</thead>
+	<tbody id="the-list" class="list:meta">
+	<tr><td></td></tr>
+	</tbody>
+</table>'; //TBODY needed for list-manipulation JS
+		return;
+	}
+	$count = 0;
+?>
+<table id="list-table">
+	<thead>
+	<tr>
+		<th class="left"><?php _e( 'Name' ) ?></th>
+		<th><?php _e( 'Value' ) ?></th>
+	</tr>
+	</thead>
+	<tbody id='the-list' class='list:meta'>
+<?php
+	foreach ( $meta as $entry )
+		echo _list_meta_row( $entry, $count );
+?>
+	</tbody>
+</table>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param unknown_type $entry
+ * @param unknown_type $count
+ * @return unknown
+ */
+function _list_meta_row( $entry, &$count ) {
+	static $update_nonce = false;
+	if ( !$update_nonce )
+		$update_nonce = wp_create_nonce( 'add-meta' );
+
+	$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;
+		}
+	}
+
+	$entry['meta_key'] = esc_attr($entry['meta_key']);
+	$entry['meta_value'] = esc_textarea( $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 class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
+
+	$r .= "\n\t\t<div class='submit'>";
+	$r .= get_submit_button( __( 'Delete' ), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta", "deletemeta[{$entry['meta_id']}]", false, array( 'tabindex' => '6' ) );
+	$r .= "\n\t\t";
+	$r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) );
+	$r .= "</div>";
+	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
+	$r .= "</td>";
+
+	$r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
+	return $r;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.2.0
+ */
+function meta_form() {
+	global $wpdb;
+	$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
+	$keys = $wpdb->get_col( "
+		SELECT meta_key
+		FROM $wpdb->postmeta
+		GROUP BY meta_key
+		HAVING meta_key NOT LIKE '\_%'
+		ORDER BY meta_key
+		LIMIT $limit" );
+	if ( $keys )
+		natcasesort($keys);
+?>
+<p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
+<table id="newmeta">
+<thead>
+<tr>
+<th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
+<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
+</tr>
+</thead>
+
+<tbody>
+<tr>
+<td id="newmetaleft" class="left">
+<?php if ( $keys ) { ?>
+<select id="metakeyselect" name="metakeyselect" tabindex="7">
+<option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option>
+<?php
+
+	foreach ( $keys as $key ) {
+		echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
+	}
+?>
+</select>
+<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
+<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
+<span id="enternew"><?php _e('Enter new'); ?></span>
+<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
+<?php } else { ?>
+<input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
+<?php } ?>
+</td>
+<td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
+</tr>
+
+<tr><td colspan="2" class="submit">
+<?php submit_button( __( 'Add Custom Field' ), 'add:the-list:newmeta', 'addmeta', false, array( 'id' => 'addmetasub', 'tabindex' => '9' ) ); ?>
+<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
+</td></tr>
+</tbody>
+</table>
+<?php
+
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 0.71
+ *
+ * @param unknown_type $edit
+ * @param unknown_type $for_post
+ * @param unknown_type $tab_index
+ * @param unknown_type $multi
+ */
+function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
+	global $wp_locale, $post, $comment;
+
+	if ( $for_post )
+		$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
+
+	$tab_index_attribute = '';
+	if ( (int) $tab_index > 0 )
+		$tab_index_attribute = " tabindex=\"$tab_index\"";
+
+	// 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 = current_time('timestamp');
+	$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
+	$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
+	$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
+	$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
+	$hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
+	$mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
+	$ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
+
+	$cur_jj = gmdate( 'd', $time_adj );
+	$cur_mm = gmdate( 'm', $time_adj );
+	$cur_aa = gmdate( 'Y', $time_adj );
+	$cur_hh = gmdate( 'H', $time_adj );
+	$cur_mn = gmdate( 'i', $time_adj );
+
+	$month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
+	for ( $i = 1; $i < 13; $i = $i +1 ) {
+		$month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
+		if ( $i == $mm )
+			$month .= ' selected="selected"';
+		$month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
+	}
+	$month .= '</select>';
+
+	$day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+	$year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
+	$hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+	$minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
+
+	echo '<div class="timestamp-wrap">';
+	/* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
+	printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
+
+	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
+
+	if ( $multi ) return;
+
+	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";
+		$cur_timeunit = 'cur_' . $timeunit;
+		echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
+	}
+?>
+
+<p>
+<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
+<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
+</p>
+<?php
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $default
+ */
+function page_template_dropdown( $default = '' ) {
+	$templates = get_page_templates();
+	ksort( $templates );
+	foreach (array_keys( $templates ) as $template )
+		: if ( $default == $templates[$template] )
+			$selected = " selected='selected'";
+		else
+			$selected = '';
+	echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
+	endforeach;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $default
+ * @param unknown_type $parent
+ * @param unknown_type $level
+ * @return unknown
+ */
+function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
+	global $wpdb, $post_ID;
+	$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
+
+	if ( $items ) {
+		foreach ( $items as $item ) {
+			// A page cannot be its own parent.
+			if (!empty ( $post_ID ) ) {
+				if ( $item->ID == $post_ID ) {
+					continue;
+				}
+			}
+			$pad = str_repeat( '&nbsp;', $level * 3 );
+			if ( $item->ID == $default)
+				$current = ' selected="selected"';
+			else
+				$current = '';
+
+			echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
+			parent_dropdown( $default, $item->ID, $level +1 );
+		}
+	} else {
+		return false;
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @param unknown_type $id
+ * @return unknown
+ */
+function the_attachment_links( $id = false ) {
+	$id = (int) $id;
+	$post = & get_post( $id );
+
+	if ( $post->post_type != 'attachment' )
+		return false;
+
+	$icon = wp_get_attachment_image( $post->ID, 'thumbnail', true );
+	$attachment_data = wp_get_attachment_metadata( $id );
+	$thumb = isset( $attachment_data['thumb'] );
+?>
+<form id="the-attachment-links">
+<table>
+	<col />
+	<col class="widefat" />
+	<tr>
+		<th scope="row"><?php _e( 'URL' ) ?></th>
+		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo esc_textarea( wp_get_attachment_url() ); ?></textarea></td>
+	</tr>
+<?php if ( $icon ) : ?>
+	<tr>
+		<th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
+		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>
+	</tr>
+	<tr>
+		<th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
+		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
+	</tr>
+<?php else : ?>
+	<tr>
+		<th scope="row"><?php _e( 'Link to file' ) ?></th>
+		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
+	</tr>
+	<tr>
+		<th scope="row"><?php _e( 'Link to page' ) ?></th>
+		<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
+	</tr>
+<?php endif; ?>
+</table>
+</form>
+<?php
+}
+
+
+/**
+ * Print out <option> html elements for role selectors
+ *
+ * @since 2.1.0
+ *
+ * @param string $selected slug for the role that should be already selected
+ */
+function wp_dropdown_roles( $selected = false ) {
+	$p = '';
+	$r = '';
+
+	$editable_roles = get_editable_roles();
+
+	foreach ( $editable_roles as $role => $details ) {
+		$name = translate_user_role($details['name'] );
+		if ( $selected == $role ) // preselect specified role
+			$p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
+		else
+			$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
+	}
+	echo $p . $r;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param unknown_type $size
+ * @return unknown
+ */
+function wp_convert_hr_to_bytes( $size ) {
+	$size = strtolower($size);
+	$bytes = (int) $size;
+	if ( strpos($size, 'k') !== false )
+		$bytes = intval($size) * 1024;
+	elseif ( strpos($size, 'm') !== false )
+		$bytes = intval($size) * 1024 * 1024;
+	elseif ( strpos($size, 'g') !== false )
+		$bytes = intval($size) * 1024 * 1024 * 1024;
+	return $bytes;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.3.0
+ *
+ * @param unknown_type $bytes
+ * @return unknown
+ */
+function wp_convert_bytes_to_hr( $bytes ) {
+	$units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
+	$log = log( $bytes, 1024 );
+	$power = (int) $log;
+	$size = pow(1024, $log - $power);
+	return $size . $units[$power];
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @return unknown
+ */
+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( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
+	return $bytes;
+}
+
+/**
+ * Outputs the form used by the importers to accept the data to be imported
+ *
+ * @since 2.0.0
+ *
+ * @param string $action The action attribute for the form.
+ */
+function wp_import_upload_form( $action ) {
+	$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
+	$size = wp_convert_bytes_to_hr( $bytes );
+	$upload_dir = wp_upload_dir();
+	if ( ! empty( $upload_dir['error'] ) ) :
+		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
+		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
+	else :
+?>
+<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
+<p>
+<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
+<input type="file" id="upload" name="import" size="25" />
+<input type="hidden" name="action" value="save" />
+<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
+</p>
+<?php submit_button( __('Upload file and import'), 'button' ); ?>
+</form>
+<?php
+	endif;
+}
+
+/**
+ * Add a meta box to an edit form.
+ *
+ * @since 2.5.0
+ *
+ * @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').
+ * @param string $priority The priority within the context where the boxes should show ('high', 'low').
+ */
+function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
+	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();
+
+	foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
+		foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
+			if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
+				continue;
+
+			// If a core box was previously added or removed by a plugin, don't add.
+			if ( 'core' == $priority ) {
+				// If core box previously deleted, don't add
+				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
+					return;
+				// If box was added with default priority, give it core priority to maintain sort order
+				if ( 'default' == $a_priority ) {
+					$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
+					unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
+				}
+				return;
+			}
+			// If no priority given and id already present, use existing priority
+			if ( empty($priority) ) {
+				$priority = $a_priority;
+			// else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
+			} elseif ( 'sorted' == $priority ) {
+				$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
+				$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
+				$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
+			}
+			// An id can be in only one priority and one context
+			if ( $priority != $a_priority || $context != $a_context )
+				unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
+		}
+	}
+
+	if ( empty($priority) )
+		$priority = 'low';
+
+	if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
+		$wp_meta_boxes[$page][$context][$priority] = array();
+
+	$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
+}
+
+/**
+ * Meta-Box template function
+ *
+ * @since 2.5.0
+ *
+ * @param string $page page identifier, also known as screen identifier
+ * @param string $context box context
+ * @param mixed $object gets passed to the box callback function as first parameter
+ * @return int number of meta_boxes
+ */
+function do_meta_boxes($page, $context, $object) {
+	global $wp_meta_boxes;
+	static $already_sorted = false;
+
+	$hidden = get_hidden_meta_boxes($page);
+
+	printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
+
+	$i = 0;
+	do {
+		// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
+		if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
+			foreach ( $sorted as $box_context => $ids )
+				foreach ( explode(',', $ids) as $id )
+					if ( $id )
+						add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
+		}
+		$already_sorted = true;
+
+		if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
+			break;
+
+		foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
+			if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
+				foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
+					if ( false == $box || ! $box['title'] )
+						continue;
+					$i++;
+					$style = '';
+					$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
+					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
+					echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>';
+					echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
+					echo '<div class="inside">' . "\n";
+					call_user_func($box['callback'], $object, $box);
+					echo "</div>\n";
+					echo "</div>\n";
+				}
+			}
+		}
+	} while(0);
+
+	echo "</div>";
+
+	return $i;
+
+}
+
+/**
+ * Remove a meta box from an edit form.
+ *
+ * @since 2.6.0
+ *
+ * @param string $id String for use in the 'id' attribute of tags.
+ * @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 remove_meta_box($id, $page, $context) {
+	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();
+
+	foreach ( array('high', 'core', 'default', 'low') as $priority )
+		$wp_meta_boxes[$page][$context][$priority][$id] = false;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $screen
+ */
+function meta_box_prefs($screen) {
+	global $wp_meta_boxes;
+
+	if ( is_string($screen) )
+		$screen = convert_to_screen($screen);
+
+	if ( empty($wp_meta_boxes[$screen->id]) )
+		return;
+
+	$hidden = get_hidden_meta_boxes($screen);
+
+	foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
+		foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
+			foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
+				if ( false == $box || ! $box['title'] )
+					continue;
+				// Submit box cannot be hidden
+				if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
+					continue;
+				$box_id = $box['id'];
+				echo '<label for="' . $box_id . '-hide">';
+				echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
+				echo "{$box['title']}</label>\n";
+			}
+		}
+	}
+}
+
+/**
+ * Get Hidden Meta Boxes
+ *
+ * @since 2.7.0
+ *
+ * @param string|object $screen Screen identifier
+ * @return array Hidden Meta Boxes
+ */
+function get_hidden_meta_boxes( $screen ) {
+	if ( is_string( $screen ) )
+		$screen = convert_to_screen( $screen );
+
+	$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
+
+	// Hide slug boxes by default
+	if ( !is_array( $hidden ) ) {
+		if ( 'post' == $screen->base || 'page' == $screen->base )
+			$hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
+		else
+			$hidden = array( 'slugdiv' );
+		$hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen);
+	}
+
+	return $hidden;
+}
+
+/**
+ * Add a new section to a settings page.
+ *
+ * Part of the Settings API. Use this to define new settings sections for an admin page.
+ * Show settings sections in your admin page callback function with do_settings_sections().
+ * Add settings fields to your section with add_settings_field()
+ *
+ * The $callback argument should be the name of a function that echoes out any
+ * content you want to show at the top of the settings section before the actual
+ * fields. It can output nothing if you want.
+ *
+ * @since 2.7.0
+ *
+ * @global $wp_settings_sections Storage array of all settings sections added to admin pages
+ *
+ * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
+ * @param string $title Formatted title of the section. Shown as the heading for the section.
+ * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
+ * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
+ */
+function add_settings_section($id, $title, $callback, $page) {
+	global $wp_settings_sections;
+
+	if ( 'misc' == $page ) {
+		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
+		$page = 'general';
+	}
+
+	if ( !isset($wp_settings_sections) )
+		$wp_settings_sections = array();
+	if ( !isset($wp_settings_sections[$page]) )
+		$wp_settings_sections[$page] = array();
+	if ( !isset($wp_settings_sections[$page][$id]) )
+		$wp_settings_sections[$page][$id] = array();
+
+	$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
+}
+
+/**
+ * Add a new field to a section of a settings page
+ *
+ * Part of the Settings API. Use this to define a settings field that will show
+ * as part of a settings section inside a settings page. The fields are shown using
+ * do_settings_fields() in do_settings-sections()
+ *
+ * The $callback argument should be the name of a function that echoes out the
+ * html input tags for this setting field. Use get_option() to retrive existing
+ * values to show.
+ *
+ * @since 2.7.0
+ *
+ * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
+ *
+ * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
+ * @param string $title Formatted title of the field. Shown as the label for the field during output.
+ * @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
+ * @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
+ * @param string $section The slug-name of the section of the settingss page in which to show the box (default, ...).
+ * @param array $args Additional arguments
+ */
+function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
+	global $wp_settings_fields;
+
+	if ( 'misc' == $page ) {
+		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
+		$page = 'general';
+	}
+
+	if ( !isset($wp_settings_fields) )
+		$wp_settings_fields = array();
+	if ( !isset($wp_settings_fields[$page]) )
+		$wp_settings_fields[$page] = array();
+	if ( !isset($wp_settings_fields[$page][$section]) )
+		$wp_settings_fields[$page][$section] = array();
+
+	$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
+}
+
+/**
+ * Prints out all settings sections added to a particular settings page
+ *
+ * Part of the Settings API. Use this in a settings page callback function
+ * to output all the sections and fields that were added to that $page with
+ * add_settings_section() and add_settings_field()
+ *
+ * @global $wp_settings_sections Storage array of all settings sections added to admin pages
+ * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
+ * @since 2.7.0
+ *
+ * @param string $page The slug name of the page whos settings sections you want to output
+ */
+function do_settings_sections($page) {
+	global $wp_settings_sections, $wp_settings_fields;
+
+	if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
+		return;
+
+	foreach ( (array) $wp_settings_sections[$page] as $section ) {
+		echo "<h3>{$section['title']}</h3>\n";
+		call_user_func($section['callback'], $section);
+		if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
+			continue;
+		echo '<table class="form-table">';
+		do_settings_fields($page, $section['id']);
+		echo '</table>';
+	}
+}
+
+/**
+ * Print out the settings fields for a particular settings section
+ *
+ * Part of the Settings API. Use this in a settings page to output
+ * a specific section. Should normally be called by do_settings_sections()
+ * rather than directly.
+ *
+ * @global $wp_settings_fields Storage array of settings fields and their pages/sections
+ *
+ * @since 2.7.0
+ *
+ * @param string $page Slug title of the admin page who's settings fields you want to show.
+ * @param section $section Slug title of the settings section who's fields you want to show.
+ */
+function do_settings_fields($page, $section) {
+	global $wp_settings_fields;
+
+	if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
+		return;
+
+	foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
+		echo '<tr valign="top">';
+		if ( !empty($field['args']['label_for']) )
+			echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
+		else
+			echo '<th scope="row">' . $field['title'] . '</th>';
+		echo '<td>';
+		call_user_func($field['callback'], $field['args']);
+		echo '</td>';
+		echo '</tr>';
+	}
+}
+
+/**
+ * Register a settings error to be displayed to the user
+ *
+ * Part of the Settings API. Use this to show messages to users about settings validation
+ * problems, missing settings or anything else.
+ *
+ * Settings errors should be added inside the $sanitize_callback function defined in
+ * register_setting() for a given setting to give feedback about the submission.
+ *
+ * By default messages will show immediately after the submission that generated the error.
+ * Additional calls to settings_errors() can be used to show errors even when the settings
+ * page is first accessed.
+ *
+ * @since 3.0.0
+ *
+ * @global array $wp_settings_errors Storage array of errors registered during this pageload
+ *
+ * @param string $setting Slug title of the setting to which this error applies
+ * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
+ * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
+ * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
+ */
+function add_settings_error( $setting, $code, $message, $type = 'error' ) {
+	global $wp_settings_errors;
+
+	if ( !isset($wp_settings_errors) )
+		$wp_settings_errors = array();
+
+	$new_error = array(
+		'setting' => $setting,
+		'code' => $code,
+		'message' => $message,
+		'type' => $type
+	);
+	$wp_settings_errors[] = $new_error;
+}
+
+/**
+ * Fetch settings errors registered by add_settings_error()
+ *
+ * Checks the $wp_settings_errors array for any errors declared during the current
+ * pageload and returns them.
+ *
+ * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved
+ * to the 'settings_errors' transient then those errors will be returned instead. This
+ * is used to pass errors back across pageloads.
+ *
+ * Use the $sanitize argument to manually re-sanitize the option before returning errors.
+ * This is useful if you have errors or notices you want to show even when the user
+ * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
+ *
+ * @since 3.0.0
+ *
+ * @global array $wp_settings_errors Storage array of errors registered during this pageload
+ *
+ * @param string $setting Optional slug title of a specific setting who's errors you want.
+ * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
+ * @return array Array of settings errors
+ */
+function get_settings_errors( $setting = '', $sanitize = FALSE ) {
+	global $wp_settings_errors;
+
+	// If $sanitize is true, manually re-run the sanitizisation for this option
+	// This allows the $sanitize_callback from register_setting() to run, adding
+	// any settings errors you want to show by default.
+	if ( $sanitize )
+		sanitize_option( $setting, get_option($setting));
+
+	// If settings were passed back from options.php then use them
+	// Ignore transients if $sanitize is true, we dont' want the old values anyway
+	if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) {
+		$settings_errors = get_transient('settings_errors');
+		delete_transient('settings_errors');
+	// Otherwise check global in case validation has been run on this pageload
+	} elseif ( count( $wp_settings_errors ) ) {
+		$settings_errors = $wp_settings_errors;
+	} else {
+		return;
+	}
+
+	// Filter the results to those of a specific setting if one was set
+	if ( $setting ) {
+		foreach ( (array) $settings_errors as $key => $details )
+			if ( $setting != $details['setting'] )
+				unset( $settings_errors[$key] );
+	}
+	return $settings_errors;
+}
+
+/**
+ * Display settings errors registered by add_settings_error()
+ *
+ * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
+ *
+ * This is called automatically after a settings page based on the Settings API is submitted.
+ * Errors should be added during the validation callback function for a setting defined in register_setting()
+ *
+ * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
+ * on its current value.
+ *
+ * The $hide_on_update option will cause errors to only show when the settings page is first loaded.
+ * if the user has already saved new values it will be hidden to avoid repeating messages already
+ * shown in the default error reporting after submission. This is useful to show general errors like missing
+ * settings when the user arrives at the settings page.
+ *
+ * @since 3.0.0
+ *
+ * @param string $setting Optional slug title of a specific setting who's errors you want.
+ * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
+ * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
+ */
+function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {
+
+	if ($hide_on_update AND $_GET['settings-updated']) return;
+
+	$settings_errors = get_settings_errors( $setting, $sanitize );
+
+	if ( !is_array($settings_errors) ) return;
+
+	$output = '';
+	foreach ( $settings_errors as $key => $details ) {
+		$css_id = 'setting-error-' . $details['code'];
+		$css_class = $details['type'] . ' settings-error';
+		$output .= "<div id='$css_id' class='$css_class'> \n";
+		$output .= "<p><strong>{$details['message']}</strong></p>";
+		$output .= "</div> \n";
+	}
+	echo $output;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ *
+ * @param unknown_type $found_action
+ */
+function find_posts_div($found_action = '') {
+?>
+	<div id="find-posts" class="find-box" style="display:none;">
+		<div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
+		<div class="find-box-inside">
+			<div class="find-box-search">
+				<?php if ( $found_action ) { ?>
+					<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
+				<?php } ?>
+
+				<input type="hidden" name="affected" id="affected" value="" />
+				<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
+				<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
+				<input type="text" id="find-posts-input" name="ps" value="" />
+				<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
+
+				<?php
+				$post_types = get_post_types( array('public' => true), 'objects' );
+				foreach ( $post_types as $post ) {
+					if ( 'attachment' == $post->name )
+						continue;
+				?>
+				<input type="radio" name="find-posts-what" id="find-posts-<?php echo esc_attr($post->name); ?>" value="<?php echo esc_attr($post->name); ?>" <?php checked($post->name,  'post'); ?> />
+				<label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label>
+				<?php
+				} ?>
+			</div>
+			<div id="find-posts-response"></div>
+		</div>
+		<div class="find-box-buttons">
+			<input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" />
+			<?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
+		</div>
+	</div>
+<?php
+}
+
+/**
+ * Display the post password.
+ *
+ * The password is passed through {@link esc_attr()} to ensure that it
+ * is safe for placing in an html attribute.
+ *
+ * @uses attr
+ * @since 2.7.0
+ */
+function the_post_password() {
+	global $post;
+	if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.7.0
+ */
+function favorite_actions( $screen = null ) {
+	$default_action = false;
+
+	if ( is_string($screen) )
+		$screen = convert_to_screen($screen);
+
+	if ( $screen->is_user )
+		return;
+
+	if ( isset($screen->post_type) ) {
+		$post_type_object = get_post_type_object($screen->post_type);
+		if ( 'add' != $screen->action )
+			$default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));
+		else
+			$default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));
+	}
+
+	if ( !$default_action ) {
+		if ( $screen->is_network ) {
+			$default_action = array('sites.php' => array( __('Sites'), 'manage_sites'));
+		} else {
+			switch ( $screen->id ) {
+				case 'upload':
+					$default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
+					break;
+				case 'media':
+					$default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
+					break;
+				case 'link-manager':
+				case 'link':
+					if ( 'add' != $screen->action )
+						$default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
+					else
+						$default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
+					break;
+				case 'users':
+					$default_action = array('user-new.php' => array(__('New User'), 'create_users'));
+					break;
+				case 'user':
+					$default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
+					break;
+				case 'plugins':
+					$default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
+					break;
+				case 'plugin-install':
+					$default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
+					break;
+				case 'themes':
+					$default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
+					break;
+				case 'theme-install':
+					$default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
+					break;
+				default:
+					$default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
+					break;
+			}
+		}
+	}
+
+	if ( !$screen->is_network ) {
+		$actions = array(
+			'post-new.php' => array(__('New Post'), 'edit_posts'),
+			'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
+			'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),
+			'media-new.php' => array(__('Upload'), 'upload_files'),
+			'edit-comments.php' => array(__('Comments'), 'moderate_comments')
+			);
+	} else {
+		$actions = array(
+			'sites.php' => array( __('Sites'), 'manage_sites'),
+			'users.php' => array( __('Users'), 'manage_network_users')
+		);
+	}
+
+	$default_key = array_keys($default_action);
+	$default_key = $default_key[0];
+	if ( isset($actions[$default_key]) )
+		unset($actions[$default_key]);
+	$actions = array_merge($default_action, $actions);
+	$actions = apply_filters( 'favorite_actions', $actions, $screen );
+
+	$allowed_actions = array();
+	foreach ( $actions as $action => $data ) {
+		if ( current_user_can($data[1]) )
+			$allowed_actions[$action] = $data[0];
+	}
+
+	if ( empty($allowed_actions) )
+		return;
+
+	$first = array_keys($allowed_actions);
+	$first = $first[0];
+	echo '<div id="favorite-actions">';
+	echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
+	echo '<div id="favorite-inside">';
+
+	array_shift($allowed_actions);
+
+	foreach ( $allowed_actions as $action => $label) {
+		echo "<div class='favorite-action'><a href='$action'>";
+		echo $label;
+		echo "</a></div>\n";
+	}
+	echo "</div></div>\n";
+}
+
+/**
+ * Get the post title.
+ *
+ * The post title is fetched and if it is blank then a default string is
+ * returned.
+ *
+ * @since 2.7.0
+ * @param int $post_id The post id. If not supplied the global $post is used.
+ * @return string The post title if set
+ */
+function _draft_or_post_title( $post_id = 0 ) {
+	$title = get_the_title($post_id);
+	if ( empty($title) )
+		$title = __('(no title)');
+	return $title;
+}
+
+/**
+ * Display the search query.
+ *
+ * A simple wrapper to display the "s" parameter in a GET URI. This function
+ * should only be used when {@link the_search_query()} cannot.
+ *
+ * @uses attr
+ * @since 2.7.0
+ *
+ */
+function _admin_search_query() {
+	echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
+}
+
+/**
+ * Generic Iframe header for use with Thickbox
+ *
+ * @since 2.7.0
+ * @param string $title Title of the Iframe page.
+ * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
+ *
+ */
+function iframe_header( $title = '', $limit_styles = false ) {
+	show_admin_bar( false );
+	global $hook_suffix, $current_screen, $current_user, $admin_body_class, $wp_locale;
+	$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
+	$admin_body_class .= ' iframe';
+
+?><!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') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
+<?php
+wp_enqueue_style( 'global' );
+if ( ! $limit_styles )
+	wp_enqueue_style( 'wp-admin' );
+wp_enqueue_style( 'colors' );
+?>
+<script type="text/javascript">
+//<![CDATA[
+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();}}};
+function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
+var userSettings = {
+		'url': '<?php echo SITECOOKIEPATH; ?>',
+		'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
+		'time':'<?php echo time() ?>'
+	},
+	ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
+	pagenow = '<?php echo $current_screen->id; ?>',
+	typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
+	adminpage = '<?php echo $admin_body_class; ?>',
+	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
+	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
+	isRtl = <?php echo (int) is_rtl(); ?>;
+//]]>
+</script>
+<?php
+do_action('admin_enqueue_scripts', $hook_suffix);
+do_action("admin_print_styles-$hook_suffix");
+do_action('admin_print_styles');
+do_action("admin_print_scripts-$hook_suffix");
+do_action('admin_print_scripts');
+do_action("admin_head-$hook_suffix");
+do_action('admin_head');
+?>
+</head>
+<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>  class="no-js <?php echo $admin_body_class; ?>">
+<script type="text/javascript">
+//<![CDATA[
+(function(){
+var c = document.body.className;
+c = c.replace(/no-js/, 'js');
+document.body.className = c;
+})();
+//]]>
+</script>
+<?php
+}
+
+/**
+ * Generic Iframe footer for use with Thickbox
+ *
+ * @since 2.7.0
+ *
+ */
+function iframe_footer() {
+	//We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
+	<div class="hidden">
+<?php
+	do_action('admin_footer', '');
+	do_action('admin_print_footer_scripts'); ?>
+	</div>
+<script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
+</body>
+</html>
+<?php
+}
+
+function _post_states($post) {
+	$post_states = array();
+	if ( isset($_GET['post_status']) )
+		$post_status = $_GET['post_status'];
+	else
+		$post_status = '';
+
+	if ( !empty($post->post_password) )
+		$post_states[] = __('Password protected');
+	if ( 'private' == $post->post_status && 'private' != $post_status )
+		$post_states[] = __('Private');
+	if ( 'draft' == $post->post_status && 'draft' != $post_status )
+		$post_states[] = __('Draft');
+	if ( 'pending' == $post->post_status && 'pending' != $post_status )
+		/* translators: post state */
+		$post_states[] = _x('Pending', 'post state');
+	if ( is_sticky($post->ID) )
+		$post_states[] = __('Sticky');
+
+	$post_states = apply_filters( 'display_post_states', $post_states );
+
+	if ( ! empty($post_states) ) {
+		$state_count = count($post_states);
+		$i = 0;
+		echo ' - ';
+		foreach ( $post_states as $state ) {
+			++$i;
+			( $i == $state_count ) ? $sep = '' : $sep = ', ';
+			echo "<span class='post-state'>$state$sep</span>";
+		}
+	}
+
+	if ( get_post_format( $post->ID ) )
+		echo ' - <span class="post-state-format">' . get_post_format_string( get_post_format( $post->ID ) ) . '</span>';
+}
+
+/**
+ * Convert a screen string to a screen object
+ *
+ * @since 3.0.0
+ *
+ * @param string $screen The name of the screen
+ * @return object An object containing the safe screen name and id
+ */
+function convert_to_screen( $screen ) {
+	$screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen);
+
+	if ( is_network_admin() )
+		$screen .= '-network';
+	elseif ( is_user_admin() )
+		$screen .= '-user';
+
+	$screen = (string) apply_filters( 'screen_meta_screen', $screen );
+	$screen = (object) array('id' => $screen, 'base' => $screen);
+	return $screen;
+}
+
+function screen_meta($screen) {
+	global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options;
+
+	if ( is_string($screen) )
+		$screen = convert_to_screen($screen);
+
+	$columns = get_column_headers( $screen );
+	$hidden = get_hidden_columns( $screen );
+
+	$meta_screens = array('index' => 'dashboard');
+
+	if ( isset($meta_screens[$screen->id]) ) {
+		$screen->id = $meta_screens[$screen->id];
+		$screen->base = $screen->id;
+	}
+
+	$show_screen = false;
+	if ( !empty($wp_meta_boxes[$screen->id]) || !empty($columns) )
+		$show_screen = true;
+
+	$screen_options = screen_options($screen);
+	if ( $screen_options )
+		$show_screen = true;
+
+	if ( !isset($_wp_contextual_help) )
+		$_wp_contextual_help = array();
+
+	$settings = apply_filters('screen_settings', '', $screen);
+
+	switch ( $screen->id ) {
+		case 'widgets':
+			$settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
+			$show_screen = true;
+			break;
+	}
+	if ( ! empty( $settings ) )
+		$show_screen = true;
+
+	if ( !empty($wp_current_screen_options) )
+		$show_screen = true;
+
+?>
+<div id="screen-meta">
+<?php if ( $show_screen ) : ?>
+<div id="screen-options-wrap" class="hidden">
+	<form id="adv-settings" action="" method="post">
+	<?php if ( isset($wp_meta_boxes[$screen->id]) ) : ?>
+		<h5><?php _ex('Show on screen', 'Metaboxes') ?></h5>
+		<div class="metabox-prefs">
+			<?php meta_box_prefs($screen); ?>
+			<br class="clear" />
+		</div>
+		<?php endif;
+		if ( ! empty($columns) ) : ?>
+		<h5><?php echo ( isset( $columns['_title'] ) ?  $columns['_title'] :  _x('Show on screen', 'Columns') ) ?></h5>
+		<div class="metabox-prefs">
+<?php
+	$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
+
+	foreach ( $columns as $column => $title ) {
+		// Can't hide these for they are special
+		if ( in_array( $column, $special ) )
+			continue;
+		if ( empty( $title ) )
+			continue;
+
+		if ( 'comments' == $column )
+			$title = __( 'Comments' );
+		$id = "$column-hide";
+		echo '<label for="' . $id . '">';
+		echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';
+		echo "$title</label>\n";
+	}
+?>
+			<br class="clear" />
+		</div>
+	<?php endif;
+	echo screen_layout($screen);
+
+	if ( !empty( $screen_options ) ) {
+		?>
+		<h5><?php _ex('Show on screen', 'Screen Options') ?></h5>
+		<?php
+	}
+
+	echo $screen_options;
+	echo $settings; ?>
+<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
+</form>
+</div>
+
+<?php endif; // $show_screen
+
+	$_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
+	?>
+	<div id="contextual-help-wrap" class="hidden">
+	<?php
+	$contextual_help = '';
+	if ( isset($_wp_contextual_help[$screen->id]) ) {
+		$contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n";
+	} else {
+		$contextual_help .= '<div class="metabox-prefs">';
+		$default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
+		$default_help .= '<br />';
+		$default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
+		$contextual_help .= apply_filters('default_contextual_help', $default_help);
+		$contextual_help .= "</div>\n";
+	}
+
+	echo apply_filters('contextual_help', $contextual_help, $screen->id, $screen);
+	?>
+	</div>
+
+<div id="screen-meta-links">
+<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
+<a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
+</div>
+<?php if ( $show_screen ) { ?>
+<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
+<a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
+</div>
+<?php } ?>
+</div>
+</div>
+<?php
+}
+
+/**
+ * Add contextual help text for a page
+ *
+ * @since 2.7.0
+ *
+ * @param string $screen The handle for the screen to add help to.  This is usually the hook name returned by the add_*_page() functions.
+ * @param string $help Arbitrary help text
+ */
+function add_contextual_help($screen, $help) {
+	global $_wp_contextual_help;
+
+	if ( is_string($screen) )
+		$screen = convert_to_screen($screen);
+
+	if ( !isset($_wp_contextual_help) )
+		$_wp_contextual_help = array();
+
+	$_wp_contextual_help[$screen->id] = $help;
+}
+
+function screen_layout($screen) {
+	global $screen_layout_columns, $wp_current_screen_options;
+
+	if ( is_string($screen) )
+		$screen = convert_to_screen($screen);
+
+	// Back compat for plugins using the filter instead of add_screen_option()
+	$columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen);
+	if ( !empty($columns) && isset($columns[$screen->id]) )
+		add_screen_option('layout_columns', array('max' => $columns[$screen->id]) );
+
+	if ( !isset($wp_current_screen_options['layout_columns']) ) {
+		$screen_layout_columns = 0;
+		return '';
+	}
+
+	$screen_layout_columns = get_user_option("screen_layout_$screen->id");
+	$num = $wp_current_screen_options['layout_columns']['max'];
+
+	if ( ! $screen_layout_columns ) {
+		if ( isset($wp_current_screen_options['layout_columns']['default']) )
+			$screen_layout_columns = $wp_current_screen_options['layout_columns']['default'];
+		else
+			$screen_layout_columns = 2;
+	}
+
+	$i = 1;
+	$return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n";
+	while ( $i <= $num ) {
+		$return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n";
+		++$i;
+	}
+	$return .= "</div>\n";
+	return $return;
+}
+
+/**
+ * Register and configure an admin screen option
+ *
+ * @since 3.1.0
+ *
+ * @param string $option An option name.
+ * @param mixed $args Option dependent arguments
+ * @return void
+ */
+function add_screen_option( $option, $args = array() ) {
+	global $wp_current_screen_options;
+
+	if ( !isset($wp_current_screen_options) )
+		$wp_current_screen_options = array();
+
+	$wp_current_screen_options[$option] = $args;
+}
+
+function screen_options($screen) {
+	global $wp_current_screen_options;
+
+	if ( is_string($screen) )
+		$screen = convert_to_screen($screen);
+
+	if ( !isset($wp_current_screen_options['per_page']) )
+		return '';
+
+	$per_page_label = $wp_current_screen_options['per_page']['label'];
+
+	if ( empty($wp_current_screen_options['per_page']['option']) ) {
+		$option = str_replace( '-', '_', "{$screen->id}_per_page" );
+	} else {
+		$option = $wp_current_screen_options['per_page']['option'];
+	}
+
+	$per_page = (int) get_user_option( $option );
+	if ( empty( $per_page ) || $per_page < 1 ) {
+		if ( isset($wp_current_screen_options['per_page']['default']) )
+			$per_page = $wp_current_screen_options['per_page']['default'];
+		else
+			$per_page = 20;
+	}
+
+	if ( 'edit_comments_per_page' == $option )
+		$per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
+	elseif ( 'categories_per_page' == $option )
+		$per_page = apply_filters( 'edit_categories_per_page', $per_page );
+	else
+		$per_page = apply_filters( $option, $per_page );
+
+	// Back compat
+	if ( isset( $screen->post_type ) )
+		$per_page = apply_filters( 'edit_posts_per_page', $per_page, $screen->post_type );
+
+	$return = "<div class='screen-options'>\n";
+	if ( !empty($per_page_label) )
+		$return .= "<input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' /> <label for='$option'>$per_page_label</label>\n";
+	$return .= get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false );
+	$return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />";
+	$return .= "</div>\n";
+	return $return;
+}
+
+function screen_icon($screen = '') {
+	global $current_screen, $typenow;
+
+	if ( empty($screen) )
+		$screen = $current_screen;
+	elseif ( is_string($screen) )
+		$name = $screen;
+
+	$class = 'icon32';
+
+	if ( empty($name) ) {
+		if ( !empty($screen->parent_base) )
+			$name = $screen->parent_base;
+		else
+			$name = $screen->base;
+
+		if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type )
+			$name = 'edit-pages';
+
+		$post_type = '';
+		if ( isset( $screen->post_type ) )
+			$post_type = $screen->post_type;
+		elseif ( $current_screen == $screen )
+			$post_type = $typenow;
+		if ( $post_type )
+			$class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type );
+	}
+
+?>
+	<div id="icon-<?php echo $name; ?>" class="<?php echo $class; ?>"><br /></div>
+<?php
+}
+
+/**
+ * Test support for compressing JavaScript from PHP
+ *
+ * Outputs JavaScript that tests if compression from PHP works as expected
+ * and sets an option with the result. Has no effect when the current user
+ * is not an administrator. To run the test again the option 'can_compress_scripts'
+ * has to be deleted.
+ *
+ * @since 2.8.0
+ */
+function compression_test() {
+?>
+	<script type="text/javascript">
+	/* <![CDATA[ */
+	var testCompression = {
+		get : function(test) {
+			var x;
+			if ( window.XMLHttpRequest ) {
+				x = new XMLHttpRequest();
+			} else {
+				try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
+			}
+
+			if (x) {
+				x.onreadystatechange = function() {
+					var r, h;
+					if ( x.readyState == 4 ) {
+						r = x.responseText.substr(0, 18);
+						h = x.getResponseHeader('Content-Encoding');
+						testCompression.check(r, h, test);
+					}
+				}
+
+				x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
+				x.send('');
+			}
+		},
+
+		check : function(r, h, test) {
+			if ( ! r && ! test )
+				this.get(1);
+
+			if ( 1 == test ) {
+				if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
+					this.get('no');
+				else
+					this.get(2);
+
+				return;
+			}
+
+			if ( 2 == test ) {
+				if ( '"wpCompressionTest' == r )
+					this.get('yes');
+				else
+					this.get('no');
+			}
+		}
+	};
+	testCompression.check();
+	/* ]]> */
+	</script>
+<?php
+}
+
+/**
+ *  Get the current screen object
+ *
+ *  @since 3.1.0
+ *
+ * @return object Current screen object
+ */
+function get_current_screen() {
+	global $current_screen;
+
+	if ( !isset($current_screen) )
+		return null;
+
+	return $current_screen;
+}
+
+/**
+ * Set the current screen object
+ *
+ * @since 3.0.0
+ *
+ * @uses $current_screen
+ *
+ * @param string $id Screen id, optional.
+ */
+function set_current_screen( $id =  '' ) {
+	global $current_screen, $hook_suffix, $typenow, $taxnow;
+
+	$action = '';
+
+	if ( empty($id) ) {
+		$current_screen = $hook_suffix;
+		$current_screen = str_replace('.php', '', $current_screen);
+		if ( preg_match('/-add|-new$/', $current_screen) )
+			$action = 'add';
+		$current_screen = str_replace('-new', '', $current_screen);
+		$current_screen = str_replace('-add', '', $current_screen);
+		$current_screen = array('id' => $current_screen, 'base' => $current_screen);
+	} else {
+		$id = sanitize_key($id);
+		if ( false !== strpos($id, '-') ) {
+			list( $id, $typenow ) = explode('-', $id, 2);
+			if ( taxonomy_exists( $typenow ) ) {
+				$id = 'edit-tags';
+				$taxnow = $typenow;
+				$typenow = '';
+			}
+		}
+		$current_screen = array('id' => $id, 'base' => $id);
+	}
+
+	$current_screen = (object) $current_screen;
+
+	$current_screen->action = $action;
+
+	// Map index to dashboard
+	if ( 'index' == $current_screen->base )
+		$current_screen->base = 'dashboard';
+	if ( 'index' == $current_screen->id )
+		$current_screen->id = 'dashboard';
+
+	if ( 'edit' == $current_screen->id ) {
+		if ( empty($typenow) )
+			$typenow = 'post';
+		$current_screen->id .= '-' . $typenow;
+		$current_screen->post_type = $typenow;
+	} elseif ( 'post' == $current_screen->id ) {
+		if ( empty($typenow) )
+			$typenow = 'post';
+		$current_screen->id = $typenow;
+		$current_screen->post_type = $typenow;
+	} elseif ( 'edit-tags' == $current_screen->id ) {
+		if ( empty($taxnow) )
+			$taxnow = 'post_tag';
+		$current_screen->id = 'edit-' . $taxnow;
+		$current_screen->taxonomy = $taxnow;
+	}
+
+	$current_screen->is_network = is_network_admin();
+	$current_screen->is_user = is_user_admin();
+
+	if ( $current_screen->is_network ) {
+		$current_screen->base .= '-network';
+		$current_screen->id .= '-network';
+	} elseif ( $current_screen->is_user ) {
+		$current_screen->base .= '-user';
+		$current_screen->id .= '-user';
+	}
+
+	$current_screen = apply_filters('current_screen', $current_screen);
+}
+
+/**
+ * Echos a submit button, with provided text and appropriate class
+ *
+ * @since 3.1.0
+ *
+ * @param string $text The text of the button (defaults to 'Save Changes')
+ * @param string $type The type of button. One of: primary, secondary, delete
+ * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
+ *               is given in $other_attributes below, $name will be used as the button's id.
+ * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
+ * 			   false otherwise. Defaults to true
+ * @param array|string $other_attributes Other attributes that should be output with the button,
+ *                     mapping attributes to their values, such as array( 'tabindex' => '1' ).
+ *                     These attributes will be ouput as attribute="value", such as tabindex="1".
+ *                     Defaults to no other attributes. Other attributes can also be provided as a
+ *                     string such as 'tabindex="1"', though the array format is typically cleaner.
+ */
+function submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {
+	echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
+}
+
+/**
+ * Returns a submit button, with provided text and appropriate class
+ *
+ * @since 3.1.0
+ *
+ * @param string $text The text of the button (defaults to 'Save Changes')
+ * @param string $type The type of button. One of: primary, secondary, delete
+ * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
+ *               is given in $other_attributes below, $name will be used as the button's id.
+ * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
+ * 			   false otherwise. Defaults to true
+ * @param array|string $other_attributes Other attributes that should be output with the button,
+ *                     mapping attributes to their values, such as array( 'tabindex' => '1' ).
+ *                     These attributes will be ouput as attribute="value", such as tabindex="1".
+ *                     Defaults to no other attributes. Other attributes can also be provided as a
+ *                     string such as 'tabindex="1"', though the array format is typically cleaner.
+ */
+function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {
+	switch ( $type ) :
+		case 'primary' :
+		case 'secondary' :
+			$class = 'button-' . $type;
+			break;
+		case 'delete' :
+			$class = 'button-secondary delete';
+			break;
+		default :
+			$class = $type; // Custom cases can just pass in the classes they want to be used
+	endswitch;
+	$text = ( NULL == $text ) ? __( 'Save Changes' ) : $text;
+
+	// Default the id attribute to $name unless an id was specifically provided in $other_attributes
+	$id = $name;
+	if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
+		$id = $other_attributes['id'];
+		unset( $other_attributes['id'] );
+	}
+
+	$attributes = '';
+	if ( is_array( $other_attributes ) ) {
+		foreach ( $other_attributes as $attribute => $value ) {
+			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
+		}
+	} else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
+		$attributes = $other_attributes;
+	}
+
+	$button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class );
+	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
+
+	if ( $wrap ) {
+		$button = '<p class="submit">' . $button . '</p>';
+	}
+
+	return $button;
+}
+
Index: /tags/3.1/wp-admin/includes/theme-install.php
===================================================================
--- /tags/3.1/wp-admin/includes/theme-install.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/theme-install.php	(revision 17487)
@@ -0,0 +1,323 @@
+<?php
+/**
+ * WordPress Theme Install Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+$themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
+	'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
+	'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
+	'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
+	'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
+	'img' => array('src' => array(), 'class' => array(), 'alt' => array())
+);
+
+$theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
+	'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
+	'tags' => true, 'num_ratings' => true
+);
+
+/**
+ * Retrieve list of WordPress theme features (aka theme tags)
+ *
+ * @since 2.8.0
+ *
+ * @deprecated since 3.1.0  Use get_theme_feature_list() instead.
+ *
+ * @return array
+ */
+function install_themes_feature_list( ) {
+	if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
+		set_transient( 'wporg_theme_feature_list', array( ),  10800);
+
+	if ( $cache  )
+		return $cache;
+
+	$feature_list = themes_api( 'feature_list', array( ) );
+	if ( is_wp_error( $feature_list ) )
+		return $features;
+
+	set_transient( 'wporg_theme_feature_list', $feature_list, 10800 );
+
+	return $feature_list;
+}
+
+/**
+ * Display search form for searching themes.
+ *
+ * @since 2.8.0
+ */
+function install_theme_search_form() {
+	$type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
+	$term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
+	?>
+<p class="install-help"><?php _e('Search for themes by keyword, author, or tag.') ?></p>
+
+<form id="search-themes" method="get" action="">
+	<input type="hidden" name="tab" value="search" />
+	<select	name="type" id="typeselector">
+	<option value="term" <?php selected('term', $type) ?>><?php _e('Term'); ?></option>
+	<option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
+	<option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
+	</select>
+	<input type="text" name="s" size="30" value="<?php echo esc_attr($term) ?>" />
+	<?php submit_button( __( 'Search' ), 'button', 'search', false ); ?>
+</form>
+<?php
+}
+
+/**
+ * Display tags filter for themes.
+ *
+ * @since 2.8.0
+ */
+function install_themes_dashboard() {
+	install_theme_search_form();
+?>
+<h4><?php _e('Feature Filter') ?></h4>
+<form method="post" action="<?php echo self_admin_url( 'theme-install.php?tab=search' ); ?>">
+<p class="install-help"><?php _e('Find a theme based on specific features') ?></p>
+	<?php
+	$feature_list = get_theme_feature_list( );
+	echo '<div class="feature-filter">';
+
+	foreach ( (array) $feature_list as $feature_name => $features ) {
+		$feature_name = esc_html( $feature_name );
+		echo '<div class="feature-name">' . $feature_name . '</div>';
+
+		echo '<ol class="feature-group">';
+		foreach ( $features as $feature => $feature_name ) {
+			$feature_name = esc_html( $feature_name );
+			$feature = esc_attr($feature);
+?>
+
+<li>
+	<input type="checkbox" name="features[<?php echo $feature; ?>]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" />
+	<label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label>
+</li>
+
+<?php	} ?>
+</ol>
+<br class="clear" />
+<?php
+	} ?>
+
+</div>
+<br class="clear" />
+<?php submit_button( __( 'Find Themes' ), 'button', 'search' ); ?>
+</form>
+<?php
+}
+add_action('install_themes_dashboard', 'install_themes_dashboard');
+
+function install_themes_upload($page = 1) {
+?>
+<h4><?php _e('Install a theme in .zip format') ?></h4>
+<p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.') ?></p>
+<form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-theme') ?>">
+	<?php wp_nonce_field( 'theme-upload') ?>
+	<input type="file" name="themezip" />
+	<?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?>
+</form>
+	<?php
+}
+add_action('install_themes_upload', 'install_themes_upload', 10, 1);
+
+function display_theme($theme, $actions = null, $show_details = true) {
+	global $themes_allowedtags;
+
+	if ( empty($theme) )
+		return;
+
+	$name = wp_kses($theme->name, $themes_allowedtags);
+	$desc = wp_kses($theme->description, $themes_allowedtags);
+	//if ( strlen($desc) > 30 )
+	//	$desc =  substr($desc, 0, 15) . '<span class="dots">...</span><span>' . substr($desc, -15) . '</span>';
+
+	$preview_link = $theme->preview_url . '?TB_iframe=true&amp;width=600&amp;height=400';
+	if ( !is_array($actions) ) {
+		$actions = array();
+		$actions[] = '<a href="' . self_admin_url('theme-install.php?tab=theme-information&amp;theme=' . $theme->slug .
+										'&amp;TB_iframe=true&amp;tbWidth=500&amp;tbHeight=385') . '" class="thickbox thickbox-preview onclick" title="' . esc_attr(sprintf(__('Install &#8220;%s&#8221;'), $name)) . '">' . __('Install') . '</a>';
+		if ( !is_network_admin() )
+			$actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview onclick previewlink" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)) . '">' . __('Preview') . '</a>';
+		$actions = apply_filters('theme_install_action_links', $actions, $theme);
+	}
+
+	$actions = implode ( ' | ', $actions );
+	?>
+<a class='thickbox thickbox-preview screenshot'
+	href='<?php echo esc_url($preview_link); ?>'
+	title='<?php echo esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $name)); ?>'>
+<img src='<?php echo esc_url($theme->screenshot_url); ?>' width='150' />
+</a>
+<h3><?php echo $name ?></h3>
+<span class='action-links'><?php echo $actions ?></span>
+<p><?php echo $desc ?></p>
+<?php if ( $show_details ) { ?>
+<a href="#theme_detail" class="theme-detail hide-if-no-js" tabindex='4'><?php _e('Details') ?></a>
+<div class="themedetaildiv hide-if-js">
+<p><strong><?php _e('Version:') ?></strong> <?php echo wp_kses($theme->version, $themes_allowedtags) ?></p>
+<p><strong><?php _e('Author:') ?></strong> <?php echo wp_kses($theme->author, $themes_allowedtags) ?></p>
+<?php if ( ! empty($theme->last_updated) ) : ?>
+<p><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $theme->last_updated ?>"><?php printf( __('%s ago'), human_time_diff(strtotime($theme->last_updated)) ) ?></span></p>
+<?php endif; if ( ! empty($theme->requires) ) : ?>
+<p><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $theme->requires) ?></p>
+<?php endif; if ( ! empty($theme->tested) ) : ?>
+<p><strong><?php _e('Compatible up to:') ?></strong> <?php echo $theme->tested ?></p>
+<?php endif; if ( !empty($theme->downloaded) ) : ?>
+<p><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $theme->downloaded), number_format_i18n($theme->downloaded)) ?></p>
+<?php endif; ?>
+<div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $theme->num_ratings), number_format_i18n($theme->num_ratings)) ?>">
+	<div class="star star-rating" style="width: <?php echo esc_attr($theme->rating) ?>px"></div>
+	<div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div>
+	<div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div>
+	<div class="star star3"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('3 stars') ?>" /></div>
+	<div class="star star2"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('2 stars') ?>" /></div>
+	<div class="star star1"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('1 star') ?>" /></div>
+</div>
+</div>
+<?php }
+	/*
+	 object(stdClass)[59]
+	 public 'name' => string 'Magazine Basic' (length=14)
+	 public 'slug' => string 'magazine-basic' (length=14)
+	 public 'version' => string '1.1' (length=3)
+	 public 'author' => string 'tinkerpriest' (length=12)
+	 public 'preview_url' => string 'http://wp-themes.com/?magazine-basic' (length=36)
+	 public 'screenshot_url' => string 'http://wp-themes.com/wp-content/themes/magazine-basic/screenshot.png' (length=68)
+	 public 'rating' => float 80
+	 public 'num_ratings' => int 1
+	 public 'homepage' => string 'http://wordpress.org/extend/themes/magazine-basic' (length=49)
+	 public 'description' => string 'A basic magazine style layout with a fully customizable layout through a backend interface. Designed by <a href="http://bavotasan.com">c.bavota</a> of <a href="http://tinkerpriestmedia.com">Tinker Priest Media</a>.' (length=214)
+	 public 'download_link' => string 'http://wordpress.org/extend/themes/download/magazine-basic.1.1.zip' (length=66)
+	 */
+}
+
+/**
+ * Display theme content based on theme list.
+ *
+ * @since 2.8.0
+ */
+function display_themes() {
+	global $wp_list_table;
+
+	$wp_list_table->display();
+}
+add_action('install_themes_search', 'display_themes');
+add_action('install_themes_featured', 'display_themes');
+add_action('install_themes_new', 'display_themes');
+add_action('install_themes_updated', 'display_themes');
+
+/**
+ * Display theme information in dialog box form.
+ *
+ * @since 2.8.0
+ */
+function install_theme_information() {
+	//TODO: This function needs a LOT of UI work :)
+	global $tab, $themes_allowedtags;
+
+	$api = themes_api('theme_information', array('slug' => stripslashes( $_REQUEST['theme'] ) ));
+
+	if ( is_wp_error($api) )
+		wp_die($api);
+
+	// Sanitize HTML
+	foreach ( (array)$api->sections as $section_name => $content )
+		$api->sections[$section_name] = wp_kses($content, $themes_allowedtags);
+
+	foreach ( array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key ) {
+		if ( isset($api->$key) )
+			$api->$key = wp_kses($api->$key, $themes_allowedtags);
+	}
+
+	iframe_header( __('Theme Install') );
+
+	if ( empty($api->download_link) ) {
+		echo '<div id="message" class="error"><p>' . __('<strong>Error:</strong> This theme is currently not available. Please try again later.') . '</p></div>';
+		iframe_footer();
+		exit;
+	}
+
+	if ( !empty($api->tested) && version_compare($GLOBALS['wp_version'], $api->tested, '>') )
+		echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This theme has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
+	else if ( !empty($api->requires) && version_compare($GLOBALS['wp_version'], $api->requires, '<') )
+		echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This theme has not been marked as <strong>compatible</strong> with your version of WordPress.') . '</p></div>';
+
+	// Default to a "new" theme
+	$type = 'install';
+	// Check to see if this theme is known to be installed, and has an update awaiting it.
+	$update_themes = get_site_transient('update_themes');
+	if ( is_object($update_themes) && isset($update_themes->response) ) {
+		foreach ( (array)$update_themes->response as $theme_slug => $theme_info ) {
+			if ( $theme_slug === $api->slug ) {
+				$type = 'update_available';
+				$update_file = $theme_slug;
+				break;
+			}
+		}
+	}
+
+	$themes = get_themes();
+	foreach ( $themes as $this_theme ) {
+		if ( is_array($this_theme) && $this_theme['Stylesheet'] == $api->slug ) {
+			if ( $this_theme['Version'] == $api->version ) {
+				$type = 'latest_installed';
+			} elseif ( $this_theme['Version'] > $api->version ) {
+				$type = 'newer_installed';
+				$newer_version = $this_theme['Version'];
+			}
+			break;
+		}
+	}
+?>
+
+<div class='available-theme'>
+<img src='<?php echo esc_url($api->screenshot_url) ?>' width='300' class="theme-preview-img" />
+<h3><?php echo $api->name; ?></h3>
+<p><?php printf(__('by %s'), $api->author); ?></p>
+<p><?php printf(__('Version: %s'), $api->version); ?></p>
+
+<?php
+$buttons = '<a class="button" id="cancel" href="#" onclick="tb_close();return false;">' . __('Cancel') . '</a> ';
+
+switch ( $type ) {
+default:
+case 'install':
+	if ( current_user_can('install_themes') ) :
+	$buttons .= '<a class="button-primary" id="install" href="' . wp_nonce_url(self_admin_url('update.php?action=install-theme&theme=' . $api->slug), 'install-theme_' . $api->slug) . '" target="_parent">' . __('Install Now') . '</a>';
+	endif;
+	break;
+case 'update_available':
+	if ( current_user_can('update_themes') ) :
+	$buttons .= '<a class="button-primary" id="install"	href="' . wp_nonce_url(self_admin_url('update.php?action=upgrade-theme&theme=' . $update_file), 'upgrade-theme_' . $update_file) . '" target="_parent">' . __('Install Update Now') . '</a>';
+	endif;
+	break;
+case 'newer_installed':
+	if ( current_user_can('install_themes') || current_user_can('update_themes') ) :
+	?><p><?php printf(__('Newer version (%s) is installed.'), $newer_version); ?></p><?php
+	endif;
+	break;
+case 'latest_installed':
+	if ( current_user_can('install_themes') || current_user_can('update_themes') ) :
+	?><p><?php _e('This version is already installed.'); ?></p><?php
+	endif;
+	break;
+} ?>
+<br class="clear" />
+</div>
+
+<p class="action-button">
+<?php echo $buttons; ?>
+<br class="clear" />
+</p>
+
+<?php
+	iframe_footer();
+	exit;
+}
+add_action('install_themes_pre_theme-information', 'install_theme_information');
+
Index: /tags/3.1/wp-admin/includes/theme.php
===================================================================
--- /tags/3.1/wp-admin/includes/theme.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/theme.php	(revision 17487)
@@ -0,0 +1,405 @@
+<?php
+/**
+ * WordPress Theme Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.0.0
+ *
+ * @return unknown
+ */
+function current_theme_info() {
+	$themes = get_themes();
+	$current_theme = get_current_theme();
+	if ( ! isset( $themes[$current_theme] ) ) {
+		delete_option( 'current_theme' );
+		$current_theme = get_current_theme();
+	}
+	$ct->name = $current_theme;
+	$ct->title = $themes[$current_theme]['Title'];
+	$ct->version = $themes[$current_theme]['Version'];
+	$ct->parent_theme = $themes[$current_theme]['Parent Theme'];
+	$ct->template_dir = $themes[$current_theme]['Template Dir'];
+	$ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
+	$ct->template = $themes[$current_theme]['Template'];
+	$ct->stylesheet = $themes[$current_theme]['Stylesheet'];
+	$ct->screenshot = $themes[$current_theme]['Screenshot'];
+	$ct->description = $themes[$current_theme]['Description'];
+	$ct->author = $themes[$current_theme]['Author'];
+	$ct->tags = $themes[$current_theme]['Tags'];
+	$ct->theme_root = $themes[$current_theme]['Theme Root'];
+	$ct->theme_root_uri = $themes[$current_theme]['Theme Root URI'];
+	return $ct;
+}
+
+/**
+ * Remove a theme
+ *
+ * @since 2.8.0
+ *
+ * @param string $template Template directory of the theme to delete
+ * @param string $redirect Redirect to page when complete.
+ * @return mixed
+ */
+function delete_theme($template, $redirect = '') {
+	global $wp_filesystem;
+
+	if ( empty($template) )
+		return false;
+
+	ob_start();
+	if ( empty( $redirect ) )
+		$redirect = wp_nonce_url('themes.php?action=delete&template=' . $template, 'delete-theme_' . $template);
+	if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
+		$data = ob_get_contents();
+		ob_end_clean();
+		if ( ! empty($data) ){
+			include_once( ABSPATH . 'wp-admin/admin-header.php');
+			echo $data;
+			include( ABSPATH . 'wp-admin/admin-footer.php');
+			exit;
+		}
+		return;
+	}
+
+	if ( ! WP_Filesystem($credentials) ) {
+		request_filesystem_credentials($url, '', true); // Failed to connect, Error and request again
+		$data = ob_get_contents();
+		ob_end_clean();
+		if ( ! empty($data) ) {
+			include_once( ABSPATH . 'wp-admin/admin-header.php');
+			echo $data;
+			include( ABSPATH . 'wp-admin/admin-footer.php');
+			exit;
+		}
+		return;
+	}
+
+
+	if ( ! is_object($wp_filesystem) )
+		return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
+
+	if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
+		return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
+
+	//Get the base plugin folder
+	$themes_dir = $wp_filesystem->wp_themes_dir();
+	if ( empty($themes_dir) )
+		return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.'));
+
+	$themes_dir = trailingslashit( $themes_dir );
+	$theme_dir = trailingslashit($themes_dir . $template);
+	$deleted = $wp_filesystem->delete($theme_dir, true);
+
+	if ( ! $deleted )
+		return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $template) );
+
+	// Force refresh of theme update information
+	delete_site_transient('update_themes');
+
+	return true;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 1.5.0
+ *
+ * @return unknown
+ */
+function get_broken_themes() {
+	global $wp_broken_themes;
+
+	get_themes();
+	return $wp_broken_themes;
+}
+
+/**
+ * Get the allowed themes for the current blog.
+ *
+ * @since 3.0.0
+ *
+ * @uses get_themes()
+ * @uses current_theme_info()
+ * @uses get_site_allowed_themes()
+ * @uses wpmu_get_blog_allowedthemes
+ *
+ * @return array $themes Array of allowed themes.
+ */
+function get_allowed_themes() {
+	if ( !is_multisite() )
+		return get_themes();
+
+	$themes = get_themes();
+	$ct = current_theme_info();
+	$allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes() );
+	if ( $allowed_themes == false )
+		$allowed_themes = array();
+
+	$blog_allowed_themes = wpmu_get_blog_allowedthemes();
+	if ( is_array( $blog_allowed_themes ) )
+		$allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes );
+
+	if ( isset( $allowed_themes[ esc_html( $ct->stylesheet ) ] ) == false )
+		$allowed_themes[ esc_html( $ct->stylesheet ) ] = true;
+
+	reset( $themes );
+	foreach ( $themes as $key => $theme ) {
+		if ( isset( $allowed_themes[ esc_html( $theme[ 'Stylesheet' ] ) ] ) == false )
+			unset( $themes[ $key ] );
+	}
+	reset( $themes );
+
+	return $themes;
+}
+
+/**
+ * Get the Page Templates available in this theme
+ *
+ * @since 1.5.0
+ *
+ * @return array Key is template name, Value is template name
+ */
+function get_page_templates() {
+	$themes = get_themes();
+	$theme = get_current_theme();
+	$templates = $themes[$theme]['Template Files'];
+	$page_templates = array();
+
+	if ( is_array( $templates ) ) {
+		$base = array( trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()) );
+
+		foreach ( $templates as $template ) {
+			$basename = str_replace($base, '', $template);
+
+			// don't allow template files in subdirectories
+			if ( false !== strpos($basename, '/') )
+				continue;
+
+			$template_data = implode( '', file( $template ));
+
+			$name = '';
+			if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
+				$name = _cleanup_header_comment($name[1]);
+
+			if ( !empty( $name ) ) {
+				$page_templates[trim( $name )] = $basename;
+			}
+		}
+	}
+
+	return $page_templates;
+}
+
+/**
+ * Tidies a filename for url display by the theme editor.
+ *
+ * @since 2.9.0
+ * @access private
+ *
+ * @param string $fullpath Full path to the theme file
+ * @param string $containingfolder Path of the theme parent folder
+ * @return string
+ */
+function _get_template_edit_filename($fullpath, $containingfolder) {
+	return str_replace(dirname(dirname( $containingfolder )) , '', $fullpath);
+}
+
+/**
+ * Check if there is an update for a theme available.
+ *
+ * Will display link, if there is an update available.
+ *
+ * @since 2.7.0
+ *
+ * @param object $theme Theme data object.
+ * @return bool False if no valid info was passed.
+ */
+function theme_update_available( $theme ) {
+	static $themes_update;
+
+	if ( !current_user_can('update_themes' ) )
+		return;
+
+	if ( !isset($themes_update) )
+		$themes_update = get_site_transient('update_themes');
+
+	if ( is_object($theme) && isset($theme->stylesheet) )
+		$stylesheet = $theme->stylesheet;
+	elseif ( is_array($theme) && isset($theme['Stylesheet']) )
+		$stylesheet = $theme['Stylesheet'];
+	else
+		return false; //No valid info passed.
+
+	if ( isset($themes_update->response[ $stylesheet ]) ) {
+		$update = $themes_update->response[ $stylesheet ];
+		$theme_name = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : '');
+		$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
+		$update_url = wp_nonce_url('update.php?action=upgrade-theme&amp;theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
+		$update_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Updating this theme will lose any customizations you have made.  'Cancel' to stop, 'OK' to update.") ) . '\') ) {return true;}return false;"';
+
+		if ( !is_multisite() ) {
+			if ( ! current_user_can('update_themes') )
+				printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version']);
+			else if ( empty($update['package']) )
+				printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>. <em>Automatic update is unavailable for this theme.</em>') . '</strong></p>', $theme_name, $details_url, $update['new_version']);
+			else
+				printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a> or <a href="%4$s" %5$s>update automatically</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick );
+		}
+	}
+}
+
+/**
+ * Retrieve list of WordPress theme features (aka theme tags)
+ *
+ * @since 3.1.0
+ *
+ * @return array  Array of features keyed by category with translations keyed by slug.
+ */
+function get_theme_feature_list() {
+	// Hard-coded list is used if api not accessible.
+	$features = array(
+			__('Colors') => array(
+				'black'   => __( 'Black' ),
+				'blue'    => __( 'Blue' ),
+				'brown'   => __( 'Brown' ),
+				'green'   => __( 'Green' ),
+				'orange'  => __( 'Orange' ),
+				'pink'    => __( 'Pink' ),
+				'purple'  => __( 'Purple' ),
+				'red'     => __( 'Red' ),
+				'silver'  => __( 'Silver' ),
+				'tan'     => __( 'Tan' ),
+				'white'   => __( 'White' ),
+				'yellow'  => __( 'Yellow' ),
+				'dark'    => __( 'Dark' ),
+				'light'   => __( 'Light ')
+			),
+
+		__('Columns') => array(
+			'one-column'    => __( 'One Column' ),
+			'two-columns'   => __( 'Two Columns' ),
+			'three-columns' => __( 'Three Columns' ),
+			'four-columns'  => __( 'Four Columns' ),
+			'left-sidebar'  => __( 'Left Sidebar' ),
+			'right-sidebar' => __( 'Right Sidebar' )
+		),
+
+		__('Width') => array(
+			'fixed-width'    => __( 'Fixed Width' ),
+			'flexible-width' => __( 'Flexible Width' )
+		),
+
+		__( 'Features' ) => array(
+			'blavatar'             => __( 'Blavatar' ),
+			'buddypress'           => __( 'BuddyPress' ),
+			'custom-background'    => __( 'Custom Background' ),
+			'custom-colors'        => __( 'Custom Colors' ),
+			'custom-header'        => __( 'Custom Header' ),
+			'custom-menu'          => __( 'Custom Menu' ),
+			'editor-style'         => __( 'Editor Style' ),
+			'front-page-post-form' => __( 'Front Page Posting' ),
+			'microformats'         => __( 'Microformats' ),
+			'sticky-post'          => __( 'Sticky Post' ),
+			'theme-options'        => __( 'Theme Options' ),
+			'threaded-comments'    => __( 'Threaded Comments' ),
+			'translation-ready'    => __( 'Translation Ready' ),
+			'rtl-language-support' => __( 'RTL Language Support' )
+		),
+
+		__( 'Subject' )  => array(
+			'holiday' => __( 'Holiday' ),
+			'photoblogging' => __( 'Photoblogging' ),
+			'seasonal' => __( 'Seasonal' )
+		)
+	);
+
+	if ( !current_user_can('install_themes') )
+		return $features;
+
+	if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) )
+		set_site_transient( 'wporg_theme_feature_list', array( ),  10800);
+
+	if ( !$feature_list ) {
+		$feature_list = themes_api( 'feature_list', array( ) );
+		if ( is_wp_error( $feature_list ) )
+			return $features;
+	}
+
+	if ( !$feature_list )
+		return $features;
+
+	set_site_transient( 'wporg_theme_feature_list', $feature_list, 10800 );
+
+	$category_translations = array( 'Colors' => __('Colors'), 'Columns' => __('Columns'), 'Width' => __('Width'),
+								   'Features' => __('Features'), 'Subject' => __('Subject') );
+
+	// Loop over the wporg canonical list and apply translations
+	$wporg_features = array();
+	foreach ( (array) $feature_list as $feature_category => $feature_items ) {
+		if ( isset($category_translations[$feature_category]) )
+			$feature_category = $category_translations[$feature_category];
+		$wporg_features[$feature_category] = array();
+
+		foreach ( $feature_items as $feature ) {
+			if ( isset($features[$feature_category][$feature]) )
+				$wporg_features[$feature_category][$feature] = $features[$feature_category][$feature];
+			else
+				$wporg_features[$feature_category][$feature] = $feature;
+		}
+	}
+
+	return $wporg_features;
+}
+
+/**
+ * Retrieve theme installer pages from WordPress Themes API.
+ *
+ * It is possible for a theme to override the Themes API result with three
+ * filters. Assume this is for themes, which can extend on the Theme Info to
+ * offer more choices. This is very powerful and must be used with care, when
+ * overridding the filters.
+ *
+ * The first filter, 'themes_api_args', is for the args and gives the action as
+ * the second parameter. The hook for 'themes_api_args' must ensure that an
+ * object is returned.
+ *
+ * The second filter, 'themes_api', is the result that would be returned.
+ *
+ * @since 2.8.0
+ *
+ * @param string $action
+ * @param array|object $args Optional. Arguments to serialize for the Theme Info API.
+ * @return mixed
+ */
+function themes_api($action, $args = null) {
+
+	if ( is_array($args) )
+		$args = (object)$args;
+
+	if ( !isset($args->per_page) )
+		$args->per_page = 24;
+
+	$args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.
+	$res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API.
+
+	if ( ! $res ) {
+		$request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );
+		if ( is_wp_error($request) ) {
+			$res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() );
+		} else {
+			$res = unserialize($request['body']);
+			if ( ! $res )
+			$res = new WP_Error('themes_api_failed', __('An unknown error occurred.'), $request['body']);
+		}
+	}
+	//var_dump(array($args, $res));
+	return apply_filters('themes_api_result', $res, $action, $args);
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/update-core.php
===================================================================
--- /tags/3.1/wp-admin/includes/update-core.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/update-core.php	(revision 17487)
@@ -0,0 +1,369 @@
+<?php
+/**
+ * WordPress core upgrade functionality.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 2.7.0
+ */
+
+/**
+ * Stores files to be deleted.
+ *
+ * @since 2.7.0
+ * @global array $_old_files
+ * @var array
+ * @name $_old_files
+ */
+global $_old_files;
+
+$_old_files = array(
+'wp-admin/bookmarklet.php',
+'wp-admin/css/upload.css',
+'wp-admin/css/upload-rtl.css',
+'wp-admin/css/press-this-ie.css',
+'wp-admin/css/press-this-ie-rtl.css',
+'wp-admin/edit-form.php',
+'wp-admin/link-import.php',
+'wp-admin/images/box-bg-left.gif',
+'wp-admin/images/box-bg-right.gif',
+'wp-admin/images/box-bg.gif',
+'wp-admin/images/box-butt-left.gif',
+'wp-admin/images/box-butt-right.gif',
+'wp-admin/images/box-butt.gif',
+'wp-admin/images/box-head-left.gif',
+'wp-admin/images/box-head-right.gif',
+'wp-admin/images/box-head.gif',
+'wp-admin/images/heading-bg.gif',
+'wp-admin/images/login-bkg-bottom.gif',
+'wp-admin/images/login-bkg-tile.gif',
+'wp-admin/images/notice.gif',
+'wp-admin/images/toggle.gif',
+'wp-admin/images/comment-stalk-classic.gif',
+'wp-admin/images/comment-stalk-fresh.gif',
+'wp-admin/images/comment-stalk-rtl.gif',
+'wp-admin/images/comment-pill.gif',
+'wp-admin/images/del.png',
+'wp-admin/images/media-button-gallery.gif',
+'wp-admin/images/media-buttons.gif',
+'wp-admin/images/tail.gif',
+'wp-admin/images/gear.png',
+'wp-admin/images/tab.png',
+'wp-admin/images/postbox-bg.gif',
+'wp-admin/includes/upload.php',
+'wp-admin/js/dbx-admin-key.js',
+'wp-admin/js/link-cat.js',
+'wp-admin/js/forms.js',
+'wp-admin/js/upload.js',
+'wp-admin/js/set-post-thumbnail-handler.js',
+'wp-admin/js/set-post-thumbnail-handler.dev.js',
+'wp-admin/js/page.js',
+'wp-admin/js/page.dev.js',
+'wp-admin/js/slug.js',
+'wp-admin/js/slug.dev.js',
+'wp-admin/profile-update.php',
+'wp-admin/templates.php',
+'wp-includes/images/audio.png',
+'wp-includes/images/css.png',
+'wp-includes/images/default.png',
+'wp-includes/images/doc.png',
+'wp-includes/images/exe.png',
+'wp-includes/images/html.png',
+'wp-includes/images/js.png',
+'wp-includes/images/pdf.png',
+'wp-includes/images/swf.png',
+'wp-includes/images/tar.png',
+'wp-includes/images/text.png',
+'wp-includes/images/video.png',
+'wp-includes/images/zip.png',
+'wp-includes/js/dbx.js',
+'wp-includes/js/fat.js',
+'wp-includes/js/list-manipulation.js',
+'wp-includes/js/jquery/jquery.dimensions.min.js',
+'wp-includes/js/tinymce/langs/en.js',
+'wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js',
+'wp-includes/js/tinymce/plugins/autosave/langs',
+'wp-includes/js/tinymce/plugins/directionality/images',
+'wp-includes/js/tinymce/plugins/directionality/langs',
+'wp-includes/js/tinymce/plugins/inlinepopups/css',
+'wp-includes/js/tinymce/plugins/inlinepopups/images',
+'wp-includes/js/tinymce/plugins/inlinepopups/jscripts',
+'wp-includes/js/tinymce/plugins/paste/images',
+'wp-includes/js/tinymce/plugins/paste/jscripts',
+'wp-includes/js/tinymce/plugins/paste/langs',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php',
+'wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css',
+'wp-includes/js/tinymce/plugins/spellchecker/images',
+'wp-includes/js/tinymce/plugins/spellchecker/langs',
+'wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php',
+'wp-includes/js/tinymce/plugins/wordpress/images',
+'wp-includes/js/tinymce/plugins/wordpress/langs',
+'wp-includes/js/tinymce/plugins/wordpress/popups.css',
+'wp-includes/js/tinymce/plugins/wordpress/wordpress.css',
+'wp-includes/js/tinymce/plugins/wphelp',
+'wp-includes/js/tinymce/themes/advanced/css',
+'wp-includes/js/tinymce/themes/advanced/images',
+'wp-includes/js/tinymce/themes/advanced/jscripts',
+'wp-includes/js/tinymce/themes/advanced/langs',
+'wp-includes/js/tinymce/tiny_mce_gzip.php',
+'wp-includes/js/wp-ajax.js',
+'wp-admin/admin-db.php',
+'wp-admin/cat.js',
+'wp-admin/categories.js',
+'wp-admin/custom-fields.js',
+'wp-admin/dbx-admin-key.js',
+'wp-admin/edit-comments.js',
+'wp-admin/install-rtl.css',
+'wp-admin/install.css',
+'wp-admin/upgrade-schema.php',
+'wp-admin/upload-functions.php',
+'wp-admin/upload-rtl.css',
+'wp-admin/upload.css',
+'wp-admin/upload.js',
+'wp-admin/users.js',
+'wp-admin/widgets-rtl.css',
+'wp-admin/widgets.css',
+'wp-admin/xfn.js',
+'wp-includes/js/tinymce/license.html',
+'wp-admin/cat-js.php',
+'wp-admin/edit-form-ajax-cat.php',
+'wp-admin/execute-pings.php',
+'wp-admin/import/b2.php',
+'wp-admin/import/btt.php',
+'wp-admin/import/jkw.php',
+'wp-admin/inline-uploading.php',
+'wp-admin/link-categories.php',
+'wp-admin/list-manipulation.js',
+'wp-admin/list-manipulation.php',
+'wp-includes/comment-functions.php',
+'wp-includes/feed-functions.php',
+'wp-includes/functions-compat.php',
+'wp-includes/functions-formatting.php',
+'wp-includes/functions-post.php',
+'wp-includes/js/dbx-key.js',
+'wp-includes/js/tinymce/plugins/autosave/langs/cs.js',
+'wp-includes/js/tinymce/plugins/autosave/langs/sv.js',
+'wp-includes/js/tinymce/themes/advanced/editor_template_src.js',
+'wp-includes/links.php',
+'wp-includes/pluggable-functions.php',
+'wp-includes/template-functions-author.php',
+'wp-includes/template-functions-category.php',
+'wp-includes/template-functions-general.php',
+'wp-includes/template-functions-links.php',
+'wp-includes/template-functions-post.php',
+'wp-includes/wp-l10n.php',
+'wp-admin/import-b2.php',
+'wp-admin/import-blogger.php',
+'wp-admin/import-greymatter.php',
+'wp-admin/import-livejournal.php',
+'wp-admin/import-mt.php',
+'wp-admin/import-rss.php',
+'wp-admin/import-textpattern.php',
+'wp-admin/quicktags.js',
+'wp-images/fade-butt.png',
+'wp-images/get-firefox.png',
+'wp-images/header-shadow.png',
+'wp-images/smilies',
+'wp-images/wp-small.png',
+'wp-images/wpminilogo.png',
+'wp.php',
+'wp-includes/gettext.php',
+'wp-includes/streams.php',
+// MU
+'wp-admin/wpmu-admin.php',
+'wp-admin/wpmu-blogs.php',
+'wp-admin/wpmu-edit.php',
+'wp-admin/wpmu-options.php',
+'wp-admin/wpmu-themes.php',
+'wp-admin/wpmu-upgrade-site.php',
+'wp-admin/wpmu-users.php',
+'wp-includes/wpmu-default-filters.php',
+'wp-includes/wpmu-functions.php',
+'wpmu-settings.php',
+'index-install.php',
+'README.txt',
+'htaccess.dist',
+'wp-admin/css/mu-rtl.css',
+'wp-admin/css/mu.css',
+'wp-admin/images/site-admin.png',
+'wp-admin/includes/mu.php',
+'wp-includes/images/wordpress-mu.png',
+// 3.0
+'wp-admin/categories.php',
+'wp-admin/edit-category-form.php',
+'wp-admin/edit-page-form.php',
+'wp-admin/edit-pages.php',
+'wp-admin/images/wp-logo.gif',
+'wp-admin/js/wp-gears.dev.js',
+'wp-admin/js/wp-gears.js',
+'wp-admin/options-misc.php',
+'wp-admin/page-new.php',
+'wp-admin/page.php',
+'wp-admin/rtl.css',
+'wp-admin/rtl.dev.css',
+'wp-admin/update-links.php',
+'wp-admin/wp-admin.css',
+'wp-admin/wp-admin.dev.css',
+'wp-includes/js/codepress',
+'wp-includes/js/jquery/autocomplete.dev.js',
+'wp-includes/js/jquery/interface.js',
+'wp-includes/js/jquery/autocomplete.js',
+'wp-includes/js/scriptaculous/prototype.js',
+'wp-includes/js/tinymce/wp-tinymce.js',
+'wp-admin/import',
+'wp-admin/images/ico-edit.png',
+'wp-admin/images/fav-top.png',
+'wp-admin/images/ico-close.png',
+'wp-admin/images/admin-header-footer.png',
+'wp-admin/images/screen-options-left.gif',
+'wp-admin/images/ico-add.png',
+'wp-admin/images/browse-happy.gif',
+'wp-admin/images/ico-viewpage.png',
+// 3.1
+'wp-includes/js/tinymce/blank.htm',
+'wp-includes/js/tinymce/plugins/safari',
+'wp-includes/js/tinymce/plugins/media',
+'wp-admin/edit-link-categories.php',
+'wp-admin/edit-post-rows.php',
+'wp-admin/edit-attachment-rows.php',
+'wp-admin/link-category.php',
+'wp-admin/edit-link-category-form.php',
+'wp-admin/sidebar.php',
+'wp-admin/images/list-vs.png',
+'wp-admin/images/button-grad-vs.png',
+'wp-admin/images/button-grad-active-vs.png',
+'wp-admin/images/fav-arrow-vs.gif',
+'wp-admin/images/fav-arrow-vs-rtl.gif',
+'wp-admin/images/fav-top-vs.gif',
+'wp-admin/images/screen-options-right.gif',
+'wp-admin/images/screen-options-right-up.gif',
+'wp-admin/images/visit-site-button-grad-vs.gif',
+'wp-admin/images/visit-site-button-grad.gif',
+'wp-includes/classes.php',
+);
+
+/**
+ * Upgrade the core of WordPress.
+ *
+ * This will create a .maintenance file at the base of the WordPress directory
+ * to ensure that people can not access the web site, when the files are being
+ * copied to their locations.
+ *
+ * The files in the {@link $_old_files} list will be removed and the new files
+ * copied from the zip file after the database is upgraded.
+ *
+ * The steps for the upgrader for after the new release is downloaded and
+ * unzipped is:
+ *   1. Test unzipped location for select files to ensure that unzipped worked.
+ *   2. Create the .maintenance file in current WordPress base.
+ *   3. Copy new WordPress directory over old WordPress files.
+ *   4. Upgrade WordPress to new version.
+ *   5. Delete new WordPress directory path.
+ *   6. Delete .maintenance file.
+ *   7. Remove old files.
+ *   8. Delete 'update_core' option.
+ *
+ * There are several areas of failure. For instance if PHP times out before step
+ * 6, then you will not be able to access any portion of your site. Also, since
+ * the upgrade will not continue where it left off, you will not be able to
+ * automatically remove old files and remove the 'update_core' option. This
+ * isn't that bad.
+ *
+ * If the copy of the new WordPress over the old fails, then the worse is that
+ * the new WordPress directory will remain.
+ *
+ * If it is assumed that every file will be copied over, including plugins and
+ * themes, then if you edit the default theme, you should rename it, so that
+ * your changes remain.
+ *
+ * @since 2.7.0
+ *
+ * @param string $from New release unzipped path.
+ * @param string $to Path to old WordPress installation.
+ * @return WP_Error|null WP_Error on failure, null on success.
+ */
+function update_core($from, $to) {
+	global $wp_filesystem, $_old_files, $wpdb;
+
+	@set_time_limit( 300 );
+
+	$php_version    = phpversion();
+	$mysql_version  = $wpdb->db_version();
+	$required_php_version = '4.3';
+	$required_mysql_version = '4.1.2';
+	$wp_version = '3.1';
+	$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
+	$mysql_compat   = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
+
+	if ( !$mysql_compat || !$php_compat )
+		$wp_filesystem->delete($from, true);
+
+	if ( !$mysql_compat && !$php_compat )
+		return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) );
+	elseif ( !$php_compat )
+		return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) );
+	elseif ( !$mysql_compat )
+		return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) );
+
+	// Sanity check the unzipped distribution
+	apply_filters('update_feedback', __('Verifying the unpacked files&#8230;'));
+	$distro = '';
+	$roots = array( '/wordpress', '/wordpress-mu' );
+	foreach( $roots as $root ) {
+		if ( $wp_filesystem->exists($from . $root . '/wp-settings.php') && $wp_filesystem->exists($from . $root . '/wp-admin/admin.php') &&
+			$wp_filesystem->exists($from . $root . '/wp-includes/functions.php') ) {
+			$distro = $root;
+			break;
+		}
+	}
+	if ( !$distro ) {
+		$wp_filesystem->delete($from, true);
+		return new WP_Error('insane_distro', __('The update could not be unpacked') );
+	}
+
+	apply_filters('update_feedback', __('Installing the latest version&#8230;'));
+
+	// Create maintenance file to signal that we are upgrading
+	$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
+	$maintenance_file = $to . '.maintenance';
+	$wp_filesystem->delete($maintenance_file);
+	$wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
+
+	// Copy new versions of WP files into place.
+	$result = copy_dir($from . $distro, $to);
+	if ( is_wp_error($result) ) {
+		$wp_filesystem->delete($maintenance_file);
+		$wp_filesystem->delete($from, true);
+		return $result;
+	}
+
+	// Remove old files
+	foreach ( $_old_files as $old_file ) {
+		$old_file = $to . $old_file;
+		if ( !$wp_filesystem->exists($old_file) )
+			continue;
+		$wp_filesystem->delete($old_file, true);
+	}
+
+	// Upgrade DB with separate request
+	apply_filters('update_feedback', __('Upgrading database&#8230;'));
+	$db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');
+	wp_remote_post($db_upgrade_url, array('timeout' => 60));
+
+	// Remove working directory
+	$wp_filesystem->delete($from, true);
+
+	// Force refresh of update information
+	if ( function_exists('delete_site_transient') )
+		delete_site_transient('update_core');
+	else
+		delete_option('update_core');
+
+	// Remove maintenance file, we're done.
+	$wp_filesystem->delete($maintenance_file);
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/update.php
===================================================================
--- /tags/3.1/wp-admin/includes/update.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/update.php	(revision 17487)
@@ -0,0 +1,312 @@
+<?php
+/**
+ * WordPress Administration Update API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+// The admin side of our 1.1 update system
+
+/**
+ * Selects the first update version from the update_core option
+ *
+ * @return object the response from the API
+ */
+function get_preferred_from_update_core() {
+	$updates = get_core_updates();
+	if ( !is_array( $updates ) )
+		return false;
+	if ( empty( $updates ) )
+		return (object)array('response' => 'latest');
+	return $updates[0];
+}
+
+/**
+ * Get available core updates
+ *
+ * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too,
+ * 	set $options['available'] to false to skip not-dimissed updates.
+ * @return array Array of the update objects
+ */
+function get_core_updates( $options = array() ) {
+	$options = array_merge( array('available' => true, 'dismissed' => false ), $options );
+	$dismissed = get_site_option( 'dismissed_update_core' );
+	if ( !is_array( $dismissed ) ) $dismissed = array();
+	$from_api = get_site_transient( 'update_core' );
+	if ( empty($from_api) )
+		return false;
+	if ( !isset( $from_api->updates ) || !is_array( $from_api->updates ) ) return false;
+	$updates = $from_api->updates;
+	if ( !is_array( $updates ) ) return false;
+	$result = array();
+	foreach($updates as $update) {
+		if ( array_key_exists( $update->current.'|'.$update->locale, $dismissed ) ) {
+			if ( $options['dismissed'] ) {
+				$update->dismissed = true;
+				$result[]= $update;
+			}
+		} else {
+			if ( $options['available'] ) {
+				$update->dismissed = false;
+				$result[]= $update;
+			}
+		}
+	}
+	return $result;
+}
+
+function dismiss_core_update( $update ) {
+	$dismissed = get_site_option( 'dismissed_update_core' );
+	$dismissed[ $update->current.'|'.$update->locale ] = true;
+	return update_site_option( 'dismissed_update_core', $dismissed );
+}
+
+function undismiss_core_update( $version, $locale ) {
+	$dismissed = get_site_option( 'dismissed_update_core' );
+	$key = $version.'|'.$locale;
+	if ( !isset( $dismissed[$key] ) ) return false;
+	unset( $dismissed[$key] );
+	return update_site_option( 'dismissed_update_core', $dismissed );
+}
+
+function find_core_update( $version, $locale ) {
+	$from_api = get_site_transient( 'update_core' );
+	if ( !is_array( $from_api->updates ) ) return false;
+	$updates = $from_api->updates;
+	foreach($updates as $update) {
+		if ( $update->current == $version && $update->locale == $locale )
+			return $update;
+	}
+	return false;
+}
+
+function core_update_footer( $msg = '' ) {
+	if ( is_multisite() && !current_user_can('update_core') )
+		return false;
+
+	if ( !current_user_can('update_core') )
+		return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );
+
+	$cur = get_preferred_from_update_core();
+	if ( ! isset( $cur->current ) )
+		$cur->current = '';
+
+	if ( ! isset( $cur->url ) )
+		$cur->url = '';
+
+	if ( ! isset( $cur->response ) )
+		$cur->response = '';
+
+	switch ( $cur->response ) {
+	case 'development' :
+		return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), $GLOBALS['wp_version'], network_admin_url( 'update-core.php' ) );
+	break;
+
+	case 'upgrade' :
+		return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current);
+	break;
+
+	case 'latest' :
+	default :
+		return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );
+	break;
+	}
+}
+add_filter( 'update_footer', 'core_update_footer' );
+
+function update_nag() {
+	if ( is_multisite() && !current_user_can('update_core') )
+		return false;
+
+	global $pagenow;
+
+	if ( 'update-core.php' == $pagenow )
+		return;
+
+	$cur = get_preferred_from_update_core();
+
+	if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
+		return false;
+
+	if ( current_user_can('update_core') ) {
+		$msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) );
+	} else {
+		$msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current );
+	}
+	echo "<div class='update-nag'>$msg</div>";
+}
+add_action( 'admin_notices', 'update_nag', 3 );
+
+// Called directly from dashboard
+function update_right_now_message() {
+	if ( is_multisite() && !current_user_can('update_core') )
+		return false;
+
+	$cur = get_preferred_from_update_core();
+
+	$msg = sprintf( __('You are using <span class="b">WordPress %s</span>.'), $GLOBALS['wp_version'] );
+
+	if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('update_core') ) {
+		$msg .= " <a href='" . network_admin_url( 'update-core.php' ) . "' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
+	}
+
+	echo "<span id='wp-version-message'>$msg</span>";
+}
+
+function get_plugin_updates() {
+	$all_plugins = get_plugins();
+	$upgrade_plugins = array();
+	$current = get_site_transient( 'update_plugins' );
+	foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
+		if ( isset( $current->response[ $plugin_file ] ) ) {
+			$upgrade_plugins[ $plugin_file ] = (object) $plugin_data;
+			$upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ];
+		}
+	}
+
+	return $upgrade_plugins;
+}
+
+function wp_plugin_update_rows() {
+	if ( !current_user_can('update_plugins' ) )
+		return;
+
+	$plugins = get_site_transient( 'update_plugins' );
+	if ( isset($plugins->response) && is_array($plugins->response) ) {
+		$plugins = array_keys( $plugins->response );
+		foreach( $plugins as $plugin_file ) {
+			add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 );
+		}
+	}
+}
+add_action( 'admin_init', 'wp_plugin_update_rows' );
+
+function wp_plugin_update_row( $file, $plugin_data ) {
+	$current = get_site_transient( 'update_plugins' );
+	if ( !isset( $current->response[ $file ] ) )
+		return false;
+
+	$r = $current->response[ $file ];
+
+	$plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
+	$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
+
+	$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '&TB_iframe=true&width=600&height=800');
+
+	$wp_list_table = _get_list_table('WP_Plugins_List_Table');
+
+	if ( is_network_admin() || !is_multisite() ) {
+		echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
+		if ( ! current_user_can('update_plugins') )
+			printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
+		else if ( empty($r->package) )
+			printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
+		else
+			printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update automatically</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) );
+	}
+
+	do_action( "in_plugin_update_message-$file", $plugin_data, $r );
+
+	echo '</div></td></tr>';
+}
+
+function wp_update_plugin($plugin, $feedback = '') {
+	if ( !empty($feedback) )
+		add_filter('update_feedback', $feedback);
+
+	include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+	$upgrader = new Plugin_Upgrader();
+	return $upgrader->upgrade($plugin);
+}
+
+function get_theme_updates() {
+	$themes = get_themes();
+	$current = get_site_transient('update_themes');
+	$update_themes = array();
+
+	foreach ( $themes as $theme ) {
+		$theme = (object) $theme;
+		if ( isset($current->response[ $theme->Stylesheet ]) ) {
+			$update_themes[$theme->Stylesheet] = $theme;
+			$update_themes[$theme->Stylesheet]->update = $current->response[ $theme->Stylesheet ];
+		}
+	}
+
+	return $update_themes;
+}
+
+function wp_update_theme($theme, $feedback = '') {
+	if ( !empty($feedback) )
+		add_filter('update_feedback', $feedback);
+
+	include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+	$upgrader = new Theme_Upgrader();
+	return $upgrader->upgrade($theme);
+}
+
+function wp_theme_update_rows() {
+	if ( !current_user_can('update_themes' ) )
+		return;
+
+	$themes = get_site_transient( 'update_themes' );
+	if ( isset($themes->response) && is_array($themes->response) ) {
+		$themes = array_keys( $themes->response );
+
+		foreach( $themes as $theme ) {
+			add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 );
+		}
+	}
+}
+add_action( 'admin_init', 'wp_theme_update_rows' );
+
+function wp_theme_update_row( $theme_key, $theme ) {
+	$current = get_site_transient( 'update_themes' );
+	if ( !isset( $current->response[ $theme_key ] ) )
+		return false;
+	$r = $current->response[ $theme_key ];
+	$themes_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
+	$theme_name = wp_kses( $theme['Name'], $themes_allowedtags );
+
+	$details_url = self_admin_url("theme-install.php?tab=theme-information&theme=$theme_key&TB_iframe=true&width=600&height=400");
+
+	$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
+
+	echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
+	if ( ! current_user_can('update_themes') )
+		printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version );
+	else if ( empty( $r['package'] ) )
+		printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] );
+	else
+		printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update automatically</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) );
+
+	do_action( "in_theme_update_message-$theme_key", $theme, $r );
+
+	echo '</div></td></tr>';
+}
+
+function wp_update_core($current, $feedback = '') {
+	if ( !empty($feedback) )
+		add_filter('update_feedback', $feedback);
+
+	include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+	$upgrader = new Core_Upgrader();
+	return $upgrader->upgrade($current);
+
+}
+
+function maintenance_nag() {
+	global $upgrading;
+	if ( ! isset( $upgrading ) )
+		return false;
+
+	if ( current_user_can('update_core') )
+		$msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
+	else
+		$msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
+
+	echo "<div class='update-nag'>$msg</div>";
+}
+add_action( 'admin_notices', 'maintenance_nag' );
+
+?>
Index: /tags/3.1/wp-admin/includes/upgrade.php
===================================================================
--- /tags/3.1/wp-admin/includes/upgrade.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/upgrade.php	(revision 17487)
@@ -0,0 +1,2001 @@
+<?php
+/**
+ * WordPress Upgrade API
+ *
+ * Most of the functions are pluggable and can be overwritten
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Include user install customize script. */
+if ( file_exists(WP_CONTENT_DIR . '/install.php') )
+	require (WP_CONTENT_DIR . '/install.php');
+
+/** WordPress Administration API */
+require_once(ABSPATH . 'wp-admin/includes/admin.php');
+
+/** WordPress Schema API */
+require_once(ABSPATH . 'wp-admin/includes/schema.php');
+
+if ( !function_exists('wp_install') ) :
+/**
+ * Installs the blog
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.1.0
+ *
+ * @param string $blog_title Blog title.
+ * @param string $user_name User's username.
+ * @param string $user_email User's email.
+ * @param bool $public Whether blog is public.
+ * @param null $deprecated Optional. Not used.
+ * @param string $user_password Optional. User's chosen password. Will default to a random password.
+ * @return array Array keys 'url', 'user_id', 'password', 'password_message'.
+ */
+function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '' ) {
+	global $wp_rewrite;
+
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.6' );
+
+	wp_check_mysql_version();
+	wp_cache_flush();
+	make_db_current_silent();
+	populate_options();
+	populate_roles();
+
+	update_option('blogname', $blog_title);
+	update_option('admin_email', $user_email);
+	update_option('blog_public', $public);
+
+	$guessurl = wp_guess_url();
+
+	update_option('siteurl', $guessurl);
+
+	// If not a public blog, don't ping.
+	if ( ! $public )
+		update_option('default_pingback_flag', 0);
+
+	// Create default user.  If the user already exists, the user tables are
+	// being shared among blogs.  Just set the role in that case.
+	$user_id = username_exists($user_name);
+	$user_password = trim($user_password);
+	$email_password = false;
+	if ( !$user_id && empty($user_password) ) {
+		$user_password = wp_generate_password( 12, false );
+		$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
+		$user_id = wp_create_user($user_name, $user_password, $user_email);
+		update_user_option($user_id, 'default_password_nag', true, true);
+		$email_password = true;
+	} else if ( !$user_id ) {
+		// Password has been provided
+		$message = '<em>'.__('Your chosen password.').'</em>';
+		$user_id = wp_create_user($user_name, $user_password, $user_email);
+	} else {
+		$message =  __('User already exists. Password inherited.');
+	}
+
+	$user = new WP_User($user_id);
+	$user->set_role('administrator');
+
+	wp_install_defaults($user_id);
+
+	$wp_rewrite->flush_rules();
+
+	wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
+
+	wp_cache_flush();
+
+	return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
+}
+endif;
+
+if ( !function_exists('wp_install_defaults') ) :
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.1.0
+ *
+ * @param int $user_id User ID.
+ */
+function wp_install_defaults($user_id) {
+	global $wpdb, $wp_rewrite, $current_site, $table_prefix;
+
+	// Default category
+	$cat_name = __('Uncategorized');
+	/* translators: Default category slug */
+	$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
+
+	if ( global_terms_enabled() ) {
+		$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
+		if ( $cat_id == null ) {
+			$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
+			$cat_id = $wpdb->insert_id;
+		}
+		update_option('default_category', $cat_id);
+	} else {
+		$cat_id = 1;
+	}
+
+	$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
+	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
+	$cat_tt_id = $wpdb->insert_id;
+
+	// Default link category
+	$cat_name = __('Blogroll');
+	/* translators: Default link category slug */
+	$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
+
+	if ( global_terms_enabled() ) {
+		$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
+		if ( $blogroll_id == null ) {
+			$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
+			$blogroll_id = $wpdb->insert_id;
+		}
+		update_option('default_link_category', $blogroll_id);
+	} else {
+		$blogroll_id = 2;
+	}
+
+	$wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
+	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
+	$blogroll_tt_id = $wpdb->insert_id;
+
+	// Now drop in some default links
+	$default_links = array();
+	$default_links[] = array(	'link_url' => 'http://codex.wordpress.org/',
+								'link_name' => 'Documentation',
+								'link_rss' => '',
+								'link_notes' => '');
+
+	$default_links[] = array(	'link_url' => 'http://wordpress.org/news/',
+								'link_name' => 'WordPress Blog',
+								'link_rss' => 'http://wordpress.org/news/feed/',
+								'link_notes' => '');
+
+	$default_links[] = array(	'link_url' => 'http://wordpress.org/extend/ideas/',
+								'link_name' => 'Suggest Ideas',
+								'link_rss' => '',
+								'link_notes' =>'');
+
+	$default_links[] = array(	'link_url' => 'http://wordpress.org/support/',
+								'link_name' => 'Support Forum',
+								'link_rss' => '',
+								'link_notes' =>'');
+
+	$default_links[] = array(	'link_url' => 'http://wordpress.org/extend/plugins/',
+								'link_name' => 'Plugins',
+								'link_rss' => '',
+								'link_notes' =>'');
+
+	$default_links[] = array(	'link_url' => 'http://wordpress.org/extend/themes/',
+								'link_name' => 'Themes',
+								'link_rss' => '',
+								'link_notes' =>'');
+
+	$default_links[] = array(	'link_url' => 'http://planet.wordpress.org/',
+								'link_name' => 'WordPress Planet',
+								'link_rss' => '',
+								'link_notes' =>'');
+
+	foreach ( $default_links as $link ) {
+		$wpdb->insert( $wpdb->links, $link);
+		$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id) );
+	}
+
+	// First post
+	$now = date('Y-m-d H:i:s');
+	$now_gmt = gmdate('Y-m-d H:i:s');
+	$first_post_guid = get_option('home') . '/?p=1';
+
+	if ( is_multisite() ) {
+		$first_post = get_site_option( 'first_post' );
+
+		if ( empty($first_post) )
+			$first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
+
+		$first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post );
+		$first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
+	} else {
+		$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
+	}
+
+	$wpdb->insert( $wpdb->posts, array(
+								'post_author' => $user_id,
+								'post_date' => $now,
+								'post_date_gmt' => $now_gmt,
+								'post_content' => $first_post,
+								'post_excerpt' => '',
+								'post_title' => __('Hello world!'),
+								/* translators: Default post slug */
+								'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ),
+								'post_modified' => $now,
+								'post_modified_gmt' => $now_gmt,
+								'guid' => $first_post_guid,
+								'comment_count' => 1,
+								'to_ping' => '',
+								'pinged' => '',
+								'post_content_filtered' => ''
+								));
+	$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
+
+	// Default comment
+	$first_comment_author = __('Mr WordPress');
+	$first_comment_url = 'http://wordpress.org/';
+	$first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
+	if ( is_multisite() ) {
+		$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
+		$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
+		$first_comment = get_site_option( 'first_comment', $first_comment );
+	}
+	$wpdb->insert( $wpdb->comments, array(
+								'comment_post_ID' => 1,
+								'comment_author' => $first_comment_author,
+								'comment_author_email' => '',
+								'comment_author_url' => $first_comment_url,
+								'comment_date' => $now,
+								'comment_date_gmt' => $now_gmt,
+								'comment_content' => $first_comment
+								));
+
+	// First Page
+	$first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
+
+<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
+
+...or something like this:
+
+<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
+
+As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
+	if ( is_multisite() )
+		$first_page = get_site_option( 'first_page', $first_page );
+	$first_post_guid = get_option('home') . '/?page_id=2';
+	$wpdb->insert( $wpdb->posts, array(
+								'post_author' => $user_id,
+								'post_date' => $now,
+								'post_date_gmt' => $now_gmt,
+								'post_content' => $first_page,
+								'post_excerpt' => '',
+								'post_title' => __( 'Sample Page' ),
+								/* translators: Default page slug */
+								'post_name' => __( 'sample-page' ),
+								'post_modified' => $now,
+								'post_modified_gmt' => $now_gmt,
+								'guid' => $first_post_guid,
+								'post_type' => 'page',
+								'to_ping' => '',
+								'pinged' => '',
+								'post_content_filtered' => ''
+								));
+	$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
+
+	// Set up default widgets for default theme.
+	update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
+	update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
+	update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
+	update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
+	update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
+	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
+	update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array ( ), 'primary-widget-area' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'secondary-widget-area' => array ( ), 'first-footer-widget-area' => array ( ), 'second-footer-widget-area' => array ( ), 'third-footer-widget-area' => array ( ), 'fourth-footer-widget-area' => array ( ), 'array_version' => 3 ) );
+
+	if ( is_multisite() ) {
+		// Flush rules to pick up the new page.
+		$wp_rewrite->init();
+		$wp_rewrite->flush_rules();
+
+		$user = new WP_User($user_id);
+		$wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
+
+		// Remove all perms except for the login user.
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
+
+		// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
+		if ( !is_super_admin( $user_id ) && $user_id != 1 )
+			$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );
+	}
+}
+endif;
+
+if ( !function_exists('wp_new_blog_notification') ) :
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.1.0
+ *
+ * @param string $blog_title Blog title.
+ * @param string $blog_url Blog url.
+ * @param int $user_id User ID.
+ * @param string $password User's Password.
+ */
+function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
+	$user = new WP_User($user_id);
+	$email = $user->user_email;
+	$name = $user->user_login;
+	$message = sprintf(__("Your new WordPress site has been successfully set up at:
+
+%1\$s
+
+You can log in to the administrator account with the following information:
+
+Username: %2\$s
+Password: %3\$s
+
+We hope you enjoy your new site. Thanks!
+
+--The WordPress Team
+http://wordpress.org/
+"), $blog_url, $name, $password);
+
+	@wp_mail($email, __('New WordPress Site'), $message);
+}
+endif;
+
+if ( !function_exists('wp_upgrade') ) :
+/**
+ * Run WordPress Upgrade functions.
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.1.0
+ *
+ * @return null
+ */
+function wp_upgrade() {
+	global $wp_current_db_version, $wp_db_version, $wpdb;
+
+	$wp_current_db_version = __get_option('db_version');
+
+	// We are up-to-date.  Nothing to do.
+	if ( $wp_db_version == $wp_current_db_version )
+		return;
+
+	if ( ! is_blog_installed() )
+		return;
+
+	wp_check_mysql_version();
+	wp_cache_flush();
+	pre_schema_upgrade();
+	make_db_current_silent();
+	upgrade_all();
+	if ( is_multisite() && is_main_site() )
+		upgrade_network();
+	wp_cache_flush();
+
+	if ( is_multisite() ) {
+		if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
+			$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
+		else
+			$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
+	}
+}
+endif;
+
+/**
+ * Functions to be called in install and upgrade scripts.
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.0.1
+ */
+function upgrade_all() {
+	global $wp_current_db_version, $wp_db_version, $wp_rewrite;
+	$wp_current_db_version = __get_option('db_version');
+
+	// We are up-to-date.  Nothing to do.
+	if ( $wp_db_version == $wp_current_db_version )
+		return;
+
+	// If the version is not set in the DB, try to guess the version.
+	if ( empty($wp_current_db_version) ) {
+		$wp_current_db_version = 0;
+
+		// If the template option exists, we have 1.5.
+		$template = __get_option('template');
+		if ( !empty($template) )
+			$wp_current_db_version = 2541;
+	}
+
+	if ( $wp_current_db_version < 6039 )
+		upgrade_230_options_table();
+
+	populate_options();
+
+	if ( $wp_current_db_version < 2541 ) {
+		upgrade_100();
+		upgrade_101();
+		upgrade_110();
+		upgrade_130();
+	}
+
+	if ( $wp_current_db_version < 3308 )
+		upgrade_160();
+
+	if ( $wp_current_db_version < 4772 )
+		upgrade_210();
+
+	if ( $wp_current_db_version < 4351 )
+		upgrade_old_slugs();
+
+	if ( $wp_current_db_version < 5539 )
+		upgrade_230();
+
+	if ( $wp_current_db_version < 6124 )
+		upgrade_230_old_tables();
+
+	if ( $wp_current_db_version < 7499 )
+		upgrade_250();
+
+	if ( $wp_current_db_version < 7935 )
+		upgrade_252();
+
+	if ( $wp_current_db_version < 8201 )
+		upgrade_260();
+
+	if ( $wp_current_db_version < 8989 )
+		upgrade_270();
+
+	if ( $wp_current_db_version < 10360 )
+		upgrade_280();
+
+	if ( $wp_current_db_version < 11958 )
+		upgrade_290();
+
+	if ( $wp_current_db_version < 15260 )
+		upgrade_300();
+
+	maybe_disable_automattic_widgets();
+
+	update_option( 'db_version', $wp_db_version );
+	update_option( 'db_upgraded', true );
+}
+
+/**
+ * Execute changes made in WordPress 1.0.
+ *
+ * @since 1.0.0
+ */
+function upgrade_100() {
+	global $wpdb;
+
+	// Get the title and ID of every post, post_name to check if it already has a value
+	$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
+	if ($posts) {
+		foreach($posts as $post) {
+			if ('' == $post->post_name) {
+				$newtitle = sanitize_title($post->post_title);
+				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) );
+			}
+		}
+	}
+
+	$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
+	foreach ($categories as $category) {
+		if ('' == $category->category_nicename) {
+			$newtitle = sanitize_title($category->cat_name);
+			$wpdb>update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) );
+		}
+	}
+
+	$wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
+	WHERE option_name LIKE 'links_rating_image%'
+	AND option_value LIKE 'wp-links/links-images/%'");
+
+	$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
+	if ($done_ids) :
+		foreach ($done_ids as $done_id) :
+			$done_posts[] = $done_id->post_id;
+		endforeach;
+		$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
+	else:
+		$catwhere = '';
+	endif;
+
+	$allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
+	if ($allposts) :
+		foreach ($allposts as $post) {
+			// Check to see if it's already been imported
+			$cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) );
+			if (!$cat && 0 != $post->post_category) { // If there's no result
+				$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );
+			}
+		}
+	endif;
+}
+
+/**
+ * Execute changes made in WordPress 1.0.1.
+ *
+ * @since 1.0.1
+ */
+function upgrade_101() {
+	global $wpdb;
+
+	// Clean up indices, add a few
+	add_clean_index($wpdb->posts, 'post_name');
+	add_clean_index($wpdb->posts, 'post_status');
+	add_clean_index($wpdb->categories, 'category_nicename');
+	add_clean_index($wpdb->comments, 'comment_approved');
+	add_clean_index($wpdb->comments, 'comment_post_ID');
+	add_clean_index($wpdb->links , 'link_category');
+	add_clean_index($wpdb->links , 'link_visible');
+}
+
+/**
+ * Execute changes made in WordPress 1.2.
+ *
+ * @since 1.2.0
+ */
+function upgrade_110() {
+	global $wpdb;
+
+	// Set user_nicename.
+	$users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
+	foreach ($users as $user) {
+		if ('' == $user->user_nicename) {
+			$newname = sanitize_title($user->user_nickname);
+			$wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) );
+		}
+	}
+
+	$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
+	foreach ($users as $row) {
+		if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
+			$wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) );
+		}
+	}
+
+	// Get the GMT offset, we'll use that later on
+	$all_options = get_alloptions_110();
+
+	$time_difference = $all_options->time_difference;
+
+	$server_time = time()+date('Z');
+	$weblogger_time = $server_time + $time_difference*3600;
+	$gmt_time = time();
+
+	$diff_gmt_server = ($gmt_time - $server_time) / 3600;
+	$diff_weblogger_server = ($weblogger_time - $server_time) / 3600;
+	$diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
+	$gmt_offset = -$diff_gmt_weblogger;
+
+	// Add a gmt_offset option, with value $gmt_offset
+	add_option('gmt_offset', $gmt_offset);
+
+	// Check if we already set the GMT fields (if we did, then
+	// MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
+	// <michel_v> I just slapped myself silly for not thinking about it earlier
+	$got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00');
+
+	if (!$got_gmt_fields) {
+
+		// Add or substract time to all dates, to get GMT dates
+		$add_hours = intval($diff_gmt_weblogger);
+		$add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours));
+		$wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+		$wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date");
+		$wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
+		$wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+		$wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+	}
+
+}
+
+/**
+ * Execute changes made in WordPress 1.5.
+ *
+ * @since 1.5.0
+ */
+function upgrade_130() {
+	global $wpdb;
+
+	// Remove extraneous backslashes.
+	$posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
+	if ($posts) {
+		foreach($posts as $post) {
+			$post_content = addslashes(deslash($post->post_content));
+			$post_title = addslashes(deslash($post->post_title));
+			$post_excerpt = addslashes(deslash($post->post_excerpt));
+			if ( empty($post->guid) )
+				$guid = get_permalink($post->ID);
+			else
+				$guid = $post->guid;
+
+			$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
+
+		}
+	}
+
+	// Remove extraneous backslashes.
+	$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
+	if ($comments) {
+		foreach($comments as $comment) {
+			$comment_content = deslash($comment->comment_content);
+			$comment_author = deslash($comment->comment_author);
+
+			$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) );
+		}
+	}
+
+	// Remove extraneous backslashes.
+	$links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
+	if ($links) {
+		foreach($links as $link) {
+			$link_name = deslash($link->link_name);
+			$link_description = deslash($link->link_description);
+
+			$wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) );
+		}
+	}
+
+	$active_plugins = __get_option('active_plugins');
+
+	// If plugins are not stored in an array, they're stored in the old
+	// newline separated format.  Convert to new format.
+	if ( !is_array( $active_plugins ) ) {
+		$active_plugins = explode("\n", trim($active_plugins));
+		update_option('active_plugins', $active_plugins);
+	}
+
+	// Obsolete tables
+	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
+	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
+	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
+	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
+
+	// Update comments table to use comment_type
+	$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
+	$wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
+
+	// Some versions have multiple duplicate option_name rows with the same values
+	$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
+	foreach ( $options as $option ) {
+		if ( 1 != $option->dupes ) { // Could this be done in the query?
+			$limit = $option->dupes - 1;
+			$dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) );
+			if ( $dupe_ids ) {
+				$dupe_ids = join($dupe_ids, ',');
+				$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
+			}
+		}
+	}
+
+	make_site_theme();
+}
+
+/**
+ * Execute changes made in WordPress 2.0.
+ *
+ * @since 2.0.0
+ */
+function upgrade_160() {
+	global $wpdb, $wp_current_db_version;
+
+	populate_roles_160();
+
+	$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
+	foreach ( $users as $user ) :
+		if ( !empty( $user->user_firstname ) )
+			update_user_meta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
+		if ( !empty( $user->user_lastname ) )
+			update_user_meta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
+		if ( !empty( $user->user_nickname ) )
+			update_user_meta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
+		if ( !empty( $user->user_level ) )
+			update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
+		if ( !empty( $user->user_icq ) )
+			update_user_meta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
+		if ( !empty( $user->user_aim ) )
+			update_user_meta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
+		if ( !empty( $user->user_msn ) )
+			update_user_meta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
+		if ( !empty( $user->user_yim ) )
+			update_user_meta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
+		if ( !empty( $user->user_description ) )
+			update_user_meta( $user->ID, 'description', $wpdb->escape($user->user_description) );
+
+		if ( isset( $user->user_idmode ) ):
+			$idmode = $user->user_idmode;
+			if ($idmode == 'nickname') $id = $user->user_nickname;
+			if ($idmode == 'login') $id = $user->user_login;
+			if ($idmode == 'firstname') $id = $user->user_firstname;
+			if ($idmode == 'lastname') $id = $user->user_lastname;
+			if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
+			if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
+			if (!$idmode) $id = $user->user_nickname;
+			$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
+		endif;
+
+		// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
+		$caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities');
+		if ( empty($caps) || defined('RESET_CAPS') ) {
+			$level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true);
+			$role = translate_level_to_role($level);
+			update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
+		}
+
+	endforeach;
+	$old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
+	$wpdb->hide_errors();
+	foreach ( $old_user_fields as $old )
+		$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
+	$wpdb->show_errors();
+
+	// populate comment_count field of posts table
+	$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
+	if ( is_array( $comments ) )
+		foreach ($comments as $comment)
+			$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
+
+	// Some alpha versions used a post status of object instead of attachment and put
+	// the mime type in post_type instead of post_mime_type.
+	if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
+		$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
+		foreach ($objects as $object) {
+			$wpdb->update( $wpdb->posts, array(	'post_status' => 'attachment',
+												'post_mime_type' => $object->post_type,
+												'post_type' => ''),
+										 array( 'ID' => $object->ID ) );
+
+			$meta = get_post_meta($object->ID, 'imagedata', true);
+			if ( ! empty($meta['file']) )
+				update_attached_file( $object->ID, $meta['file'] );
+		}
+	}
+}
+
+/**
+ * Execute changes made in WordPress 2.1.
+ *
+ * @since 2.1.0
+ */
+function upgrade_210() {
+	global $wpdb, $wp_current_db_version;
+
+	if ( $wp_current_db_version < 3506 ) {
+		// Update status and type.
+		$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
+
+		if ( ! empty($posts) ) foreach ($posts as $post) {
+			$status = $post->post_status;
+			$type = 'post';
+
+			if ( 'static' == $status ) {
+				$status = 'publish';
+				$type = 'page';
+			} else if ( 'attachment' == $status ) {
+				$status = 'inherit';
+				$type = 'attachment';
+			}
+
+			$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
+		}
+	}
+
+	if ( $wp_current_db_version < 3845 ) {
+		populate_roles_210();
+	}
+
+	if ( $wp_current_db_version < 3531 ) {
+		// Give future posts a post_status of future.
+		$now = gmdate('Y-m-d H:i:59');
+		$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
+
+		$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
+		if ( !empty($posts) )
+			foreach ( $posts as $post )
+				wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
+	}
+}
+
+/**
+ * Execute changes made in WordPress 2.3.
+ *
+ * @since 2.3.0
+ */
+function upgrade_230() {
+	global $wp_current_db_version, $wpdb;
+
+	if ( $wp_current_db_version < 5200 ) {
+		populate_roles_230();
+	}
+
+	// Convert categories to terms.
+	$tt_ids = array();
+	$have_tags = false;
+	$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_ID");
+	foreach ($categories as $category) {
+		$term_id = (int) $category->cat_ID;
+		$name = $category->cat_name;
+		$description = $category->category_description;
+		$slug = $category->category_nicename;
+		$parent = $category->category_parent;
+		$term_group = 0;
+
+		// Associate terms with the same slug in a term group and make slugs unique.
+		if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
+			$term_group = $exists[0]->term_group;
+			$id = $exists[0]->term_id;
+			$num = 2;
+			do {
+				$alt_slug = $slug . "-$num";
+				$num++;
+				$slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) );
+			} while ( $slug_check );
+
+			$slug = $alt_slug;
+
+			if ( empty( $term_group ) ) {
+				$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
+				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) );
+			}
+		}
+
+		$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
+		(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );
+
+		$count = 0;
+		if ( !empty($category->category_count) ) {
+			$count = (int) $category->category_count;
+			$taxonomy = 'category';
+			$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
+			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+		}
+
+		if ( !empty($category->link_count) ) {
+			$count = (int) $category->link_count;
+			$taxonomy = 'link_category';
+			$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
+			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+		}
+
+		if ( !empty($category->tag_count) ) {
+			$have_tags = true;
+			$count = (int) $category->tag_count;
+			$taxonomy = 'post_tag';
+			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
+			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+		}
+
+		if ( empty($count) ) {
+			$count = 0;
+			$taxonomy = 'category';
+			$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
+			$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+		}
+	}
+
+	$select = 'post_id, category_id';
+	if ( $have_tags )
+		$select .= ', rel_type';
+
+	$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
+	foreach ( $posts as $post ) {
+		$post_id = (int) $post->post_id;
+		$term_id = (int) $post->category_id;
+		$taxonomy = 'category';
+		if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
+			$taxonomy = 'tag';
+		$tt_id = $tt_ids[$term_id][$taxonomy];
+		if ( empty($tt_id) )
+			continue;
+
+		$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
+	}
+
+	// < 3570 we used linkcategories.  >= 3570 we used categories and link2cat.
+	if ( $wp_current_db_version < 3570 ) {
+		// Create link_category terms for link categories.  Create a map of link cat IDs
+		// to link_category terms.
+		$link_cat_id_map = array();
+		$default_link_cat = 0;
+		$tt_ids = array();
+		$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
+		foreach ( $link_cats as $category) {
+			$cat_id = (int) $category->cat_id;
+			$term_id = 0;
+			$name = $wpdb->escape($category->cat_name);
+			$slug = sanitize_title($name);
+			$term_group = 0;
+
+			// Associate terms with the same slug in a term group and make slugs unique.
+			if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
+				$term_group = $exists[0]->term_group;
+				$term_id = $exists[0]->term_id;
+			}
+
+			if ( empty($term_id) ) {
+				$wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') );
+				$term_id = (int) $wpdb->insert_id;
+			}
+
+			$link_cat_id_map[$cat_id] = $term_id;
+			$default_link_cat = $term_id;
+
+			$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) );
+			$tt_ids[$term_id] = (int) $wpdb->insert_id;
+		}
+
+		// Associate links to cats.
+		$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
+		if ( !empty($links) ) foreach ( $links as $link ) {
+			if ( 0 == $link->link_category )
+				continue;
+			if ( ! isset($link_cat_id_map[$link->link_category]) )
+				continue;
+			$term_id = $link_cat_id_map[$link->link_category];
+			$tt_id = $tt_ids[$term_id];
+			if ( empty($tt_id) )
+				continue;
+
+			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
+		}
+
+		// Set default to the last category we grabbed during the upgrade loop.
+		update_option('default_link_category', $default_link_cat);
+	} else {
+		$links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id");
+		foreach ( $links as $link ) {
+			$link_id = (int) $link->link_id;
+			$term_id = (int) $link->category_id;
+			$taxonomy = 'link_category';
+			$tt_id = $tt_ids[$term_id][$taxonomy];
+			if ( empty($tt_id) )
+				continue;
+			$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
+		}
+	}
+
+	if ( $wp_current_db_version < 4772 ) {
+		// Obsolete linkcategories table
+		$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
+	}
+
+	// Recalculate all counts
+	$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
+	foreach ( (array) $terms as $term ) {
+		if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
+			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
+		else
+			$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
+		$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
+	}
+}
+
+/**
+ * Remove old options from the database.
+ *
+ * @since 2.3.0
+ */
+function upgrade_230_options_table() {
+	global $wpdb;
+	$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
+	$wpdb->hide_errors();
+	foreach ( $old_options_fields as $old )
+		$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
+	$wpdb->show_errors();
+}
+
+/**
+ * Remove old categories, link2cat, and post2cat database tables.
+ *
+ * @since 2.3.0
+ */
+function upgrade_230_old_tables() {
+	global $wpdb;
+	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
+	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat');
+	$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
+}
+
+/**
+ * Upgrade old slugs made in version 2.2.
+ *
+ * @since 2.2.0
+ */
+function upgrade_old_slugs() {
+	// upgrade people who were using the Redirect Old Slugs plugin
+	global $wpdb;
+	$wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");
+}
+
+/**
+ * Execute changes made in WordPress 2.5.0.
+ *
+ * @since 2.5.0
+ */
+function upgrade_250() {
+	global $wp_current_db_version;
+
+	if ( $wp_current_db_version < 6689 ) {
+		populate_roles_250();
+	}
+
+}
+
+/**
+ * Execute changes made in WordPress 2.5.2.
+ *
+ * @since 2.5.2
+ */
+function upgrade_252() {
+	global $wpdb;
+
+	$wpdb->query("UPDATE $wpdb->users SET user_activation_key = ''");
+}
+
+/**
+ * Execute changes made in WordPress 2.6.
+ *
+ * @since 2.6.0
+ */
+function upgrade_260() {
+	global $wp_current_db_version;
+
+	if ( $wp_current_db_version < 8000 )
+		populate_roles_260();
+
+	if ( $wp_current_db_version < 8201 ) {
+		update_option('enable_app', 1);
+		update_option('enable_xmlrpc', 1);
+	}
+}
+
+/**
+ * Execute changes made in WordPress 2.7.
+ *
+ * @since 2.7.0
+ */
+function upgrade_270() {
+	global $wpdb, $wp_current_db_version;
+
+	if ( $wp_current_db_version < 8980 )
+		populate_roles_270();
+
+	// Update post_date for unpublished posts with empty timestamp
+	if ( $wp_current_db_version < 8921 )
+		$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
+}
+
+/**
+ * Execute changes made in WordPress 2.8.
+ *
+ * @since 2.8.0
+ */
+function upgrade_280() {
+	global $wp_current_db_version, $wpdb;
+
+	if ( $wp_current_db_version < 10360 )
+		populate_roles_280();
+	if ( is_multisite() ) {
+		$start = 0;
+		while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
+			foreach( $rows as $row ) {
+				$value = $row->option_value;
+				if ( !@unserialize( $value ) )
+					$value = stripslashes( $value );
+				if ( $value !== $row->option_value ) {
+					update_option( $row->option_name, $value );
+				}
+			}
+			$start += 20;
+		}
+		refresh_blog_details( $wpdb->blogid );
+	}
+}
+
+/**
+ * Execute changes made in WordPress 2.9.
+ *
+ * @since 2.9.0
+ */
+function upgrade_290() {
+	global $wp_current_db_version;
+
+	if ( $wp_current_db_version < 11958 ) {
+		// Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion
+		if ( get_option( 'thread_comments_depth' ) == '1' ) {
+			update_option( 'thread_comments_depth', 2 );
+			update_option( 'thread_comments', 0 );
+		}
+	}
+}
+
+/**
+ * Execute changes made in WordPress 3.0.
+ *
+ * @since 3.0.0
+ */
+function upgrade_300() {
+	global $wp_current_db_version, $wpdb;
+
+	if ( $wp_current_db_version < 15093 )
+		populate_roles_300();
+
+	if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
+		add_site_option( 'siteurl', '' );
+
+	// 3.0-alpha nav menu postmeta changes. can be removed before release. // r13802
+	if ( $wp_current_db_version >= 13226 && $wp_current_db_version < 13974 )
+		$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key IN( 'menu_type', 'object_id', 'menu_new_window', 'menu_link', '_menu_item_append', 'menu_item_append', 'menu_item_type', 'menu_item_object_id', 'menu_item_target', 'menu_item_classes', 'menu_item_xfn', 'menu_item_url' )" );
+
+	// 3.0-beta1 remove_user primitive->meta cap. can be removed before release. r13956
+	if ( $wp_current_db_version >= 12751 && $wp_current_db_version < 13974 ) {
+		$role =& get_role( 'administrator' );
+		if ( ! empty( $role ) )
+			$role->remove_cap( 'remove_user' );
+	}
+
+	// 3.0-beta1 nav menu postmeta changes. can be removed before release. r13974
+	if ( $wp_current_db_version >= 13802 && $wp_current_db_version < 13974 )
+		$wpdb->update( $wpdb->postmeta, array( 'meta_value' => '' ), array( 'meta_key' => '_menu_item_target', 'meta_value' => '_self' ) );
+
+	// 3.0 screen options key name changes.
+	if ( is_main_site() && !defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
+		$prefix = like_escape($wpdb->base_prefix);
+		$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '{$prefix}%meta-box-hidden%' OR meta_key LIKE '{$prefix}%closedpostboxes%' OR meta_key LIKE '{$prefix}%manage-%-columns-hidden%' OR meta_key LIKE '{$prefix}%meta-box-order%' OR meta_key LIKE '{$prefix}%metaboxorder%' OR meta_key LIKE '{$prefix}%screen_layout%'
+					 OR meta_key = 'manageedittagscolumnshidden' OR meta_key='managecategoriescolumnshidden' OR meta_key = 'manageedit-tagscolumnshidden' OR meta_key = 'manageeditcolumnshidden' OR meta_key = 'categories_per_page' OR meta_key = 'edit_tags_per_page'" );
+	}
+
+}
+
+/**
+ * Execute network level changes
+ *
+ * @since 3.0.0
+ */
+function upgrade_network() {
+	global $wp_current_db_version, $wpdb;
+	// 2.8
+	if ( $wp_current_db_version < 11549 ) {
+		$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
+		$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
+		if ( $wpmu_sitewide_plugins ) {
+			if ( !$active_sitewide_plugins )
+				$sitewide_plugins = (array) $wpmu_sitewide_plugins;
+			else
+				$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
+
+			update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
+		}
+		delete_site_option( 'wpmu_sitewide_plugins' );
+		delete_site_option( 'deactivated_sitewide_plugins' );
+
+		$start = 0;
+		while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
+			foreach( $rows as $row ) {
+				$value = $row->meta_value;
+				if ( !@unserialize( $value ) )
+					$value = stripslashes( $value );
+				if ( $value !== $row->meta_value ) {
+					update_site_option( $row->meta_key, $value );
+				}
+			}
+			$start += 20;
+		}
+	}
+	// 3.0
+	if ( $wp_current_db_version < 13576 )
+		update_site_option( 'global_terms_enabled', '1' );
+}
+
+// The functions we use to actually do stuff
+
+// General
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.0.0
+ *
+ * @param string $table_name Database table name to create.
+ * @param string $create_ddl SQL statement to create table.
+ * @return bool If table already exists or was created by function.
+ */
+function maybe_create_table($table_name, $create_ddl) {
+	global $wpdb;
+	if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
+		return true;
+	//didn't find it try to create it.
+	$q = $wpdb->query($create_ddl);
+	// we cannot directly tell that whether this succeeded!
+	if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
+		return true;
+	return false;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.0.1
+ *
+ * @param string $table Database table name.
+ * @param string $index Index name to drop.
+ * @return bool True, when finished.
+ */
+function drop_index($table, $index) {
+	global $wpdb;
+	$wpdb->hide_errors();
+	$wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`");
+	// Now we need to take out all the extra ones we may have created
+	for ($i = 0; $i < 25; $i++) {
+		$wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`");
+	}
+	$wpdb->show_errors();
+	return true;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.0.1
+ *
+ * @param string $table Database table name.
+ * @param string $index Database table index column.
+ * @return bool True, when done with execution.
+ */
+function add_clean_index($table, $index) {
+	global $wpdb;
+	drop_index($table, $index);
+	$wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )");
+	return true;
+}
+
+/**
+ ** maybe_add_column()
+ ** Add column to db table if it doesn't exist.
+ ** Returns:  true if already exists or on successful completion
+ **           false on error
+ */
+function maybe_add_column($table_name, $column_name, $create_ddl) {
+	global $wpdb, $debug;
+	foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+		if ($debug) echo("checking $column == $column_name<br />");
+		if ($column == $column_name) {
+			return true;
+		}
+	}
+	//didn't find it try to create it.
+	$q = $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) {
+			return true;
+		}
+	}
+	return false;
+}
+
+/**
+ * Retrieve all options as it was for 1.2.
+ *
+ * @since 1.2.0
+ *
+ * @return array List of options.
+ */
+function get_alloptions_110() {
+	global $wpdb;
+	if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
+		foreach ($options as $option) {
+			// "When trying to design a foolproof system,
+			//  never underestimate the ingenuity of the fools :)" -- Dougal
+			if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+			if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+			if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+			$all_options->{$option->option_name} = stripslashes($option->option_value);
+		}
+	}
+	return $all_options;
+}
+
+/**
+ * Version of get_option that is private to install/upgrade.
+ *
+ * @since 1.5.1
+ * @access private
+ *
+ * @param string $setting Option name.
+ * @return mixed
+ */
+function __get_option($setting) {
+	global $wpdb;
+
+	if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
+		return preg_replace( '|/+$|', '', WP_HOME );
+	}
+
+	if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
+		return preg_replace( '|/+$|', '', WP_SITEURL );
+	}
+
+	$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting) );
+
+	if ( 'home' == $setting && '' == $option )
+		return __get_option('siteurl');
+
+	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
+		$option = preg_replace('|/+$|', '', $option);
+
+	@ $kellogs = unserialize($option);
+	if ($kellogs !== FALSE)
+		return $kellogs;
+	else
+		return $option;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param string $content
+ * @return string
+ */
+function deslash($content) {
+	// Note: \\\ inside a regex denotes a single backslash.
+
+	// Replace one or more backslashes followed by a single quote with
+	// a single quote.
+	$content = preg_replace("/\\\+'/", "'", $content);
+
+	// Replace one or more backslashes followed by a double quote with
+	// a double quote.
+	$content = preg_replace('/\\\+"/', '"', $content);
+
+	// Replace one or more backslashes with one backslash.
+	$content = preg_replace("/\\\+/", "\\", $content);
+
+	return $content;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $queries
+ * @param unknown_type $execute
+ * @return unknown
+ */
+function dbDelta($queries, $execute = true) {
+	global $wpdb;
+
+	// Separate individual queries into an array
+	if ( !is_array($queries) ) {
+		$queries = explode( ';', $queries );
+		if ('' == $queries[count($queries) - 1]) array_pop($queries);
+	}
+
+	$cqueries = array(); // Creation Queries
+	$iqueries = array(); // Insertion Queries
+	$for_update = array();
+
+	// Create a tablename index for an array ($cqueries) of queries
+	foreach($queries as $qry) {
+		if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
+			$cqueries[trim( strtolower($matches[1]), '`' )] = $qry;
+			$for_update[$matches[1]] = 'Created table '.$matches[1];
+		} else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
+			array_unshift($cqueries, $qry);
+		} else if (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
+			$iqueries[] = $qry;
+		} else if (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
+			$iqueries[] = $qry;
+		} else {
+			// Unrecognized query type
+		}
+	}
+
+	// Check to see which tables and fields exist
+	if ($tables = $wpdb->get_col('SHOW TABLES;')) {
+		// For every table in the database
+		foreach ($tables as $table) {
+			// Upgrade global tables only for the main site. Don't upgrade at all if DO_NOT_UPGRADE_GLOBAL_TABLES is defined.
+			if ( in_array($table, $wpdb->tables('global')) && ( !is_main_site() || defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) )
+				continue;
+
+			// If a table query exists for the database table...
+			if ( array_key_exists(strtolower($table), $cqueries) ) {
+				// Clear the field and index arrays
+				$cfields = $indices = array();
+				// Get all of the field names in the query from between the parens
+				preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2);
+				$qryline = trim($match2[1]);
+
+				// Separate field lines into an array
+				$flds = explode("\n", $qryline);
+
+				//echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
+
+				// For every field line specified in the query
+				foreach ($flds as $fld) {
+					// Extract the field name
+					preg_match("|^([^ ]*)|", trim($fld), $fvals);
+					$fieldname = trim( $fvals[1], '`' );
+
+					// Verify the found field name
+					$validfield = true;
+					switch (strtolower($fieldname)) {
+					case '':
+					case 'primary':
+					case 'index':
+					case 'fulltext':
+					case 'unique':
+					case 'key':
+						$validfield = false;
+						$indices[] = trim(trim($fld), ", \n");
+						break;
+					}
+					$fld = trim($fld);
+
+					// If it's a valid field, add it to the field array
+					if ($validfield) {
+						$cfields[strtolower($fieldname)] = trim($fld, ", \n");
+					}
+				}
+
+				// Fetch the table column structure from the database
+				$tablefields = $wpdb->get_results("DESCRIBE {$table};");
+
+				// For every field in the table
+				foreach ($tablefields as $tablefield) {
+					// If the table field exists in the field array...
+					if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
+						// Get the field type from the query
+						preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
+						$fieldtype = $matches[1];
+
+						// Is actual field type different from the field type in query?
+						if ($tablefield->Type != $fieldtype) {
+							// Add a query to change the column type
+							$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
+							$for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
+						}
+
+						// Get the default value from the array
+							//echo "{$cfields[strtolower($tablefield->Field)]}<br>";
+						if (preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
+							$default_value = $matches[1];
+							if ($tablefield->Default != $default_value) {
+								// Add a query to change the column's default value
+								$cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
+								$for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
+							}
+						}
+
+						// Remove the field from the array (so it's not added)
+						unset($cfields[strtolower($tablefield->Field)]);
+					} else {
+						// This field exists in the table, but not in the creation queries?
+					}
+				}
+
+				// For every remaining field specified for the table
+				foreach ($cfields as $fieldname => $fielddef) {
+					// Push a query line into $cqueries that adds the field to that table
+					$cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
+					$for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
+				}
+
+				// Index stuff goes here
+				// Fetch the table index structure from the database
+				$tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
+
+				if ($tableindices) {
+					// Clear the index array
+					unset($index_ary);
+
+					// For every index in the table
+					foreach ($tableindices as $tableindex) {
+						// Add the index to the index data array
+						$keyname = $tableindex->Key_name;
+						$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
+						$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
+					}
+
+					// For each actual index in the index array
+					foreach ($index_ary as $index_name => $index_data) {
+						// Build a create string to compare to the query
+						$index_string = '';
+						if ($index_name == 'PRIMARY') {
+							$index_string .= 'PRIMARY ';
+						} else if($index_data['unique']) {
+							$index_string .= 'UNIQUE ';
+						}
+						$index_string .= 'KEY ';
+						if ($index_name != 'PRIMARY') {
+							$index_string .= $index_name;
+						}
+						$index_columns = '';
+						// For each column in the index
+						foreach ($index_data['columns'] as $column_data) {
+							if ($index_columns != '') $index_columns .= ',';
+							// Add the field to the column list string
+							$index_columns .= $column_data['fieldname'];
+							if ($column_data['subpart'] != '') {
+								$index_columns .= '('.$column_data['subpart'].')';
+							}
+						}
+						// Add the column list to the index create string
+						$index_string .= ' ('.$index_columns.')';
+						if (!(($aindex = array_search($index_string, $indices)) === false)) {
+							unset($indices[$aindex]);
+							//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
+						}
+						//else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
+					}
+				}
+
+				// For every remaining index specified for the table
+				foreach ( (array) $indices as $index ) {
+					// Push a query line into $cqueries that adds the index to that table
+					$cqueries[] = "ALTER TABLE {$table} ADD $index";
+					$for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
+				}
+
+				// Remove the original table creation query from processing
+				unset($cqueries[strtolower($table)]);
+				unset($for_update[strtolower($table)]);
+			} else {
+				// This table exists in the database, but not in the creation queries?
+			}
+		}
+	}
+
+	$allqueries = array_merge($cqueries, $iqueries);
+	if ($execute) {
+		foreach ($allqueries as $query) {
+			//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
+			$wpdb->query($query);
+		}
+	}
+
+	return $for_update;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ */
+function make_db_current() {
+	global $wp_queries;
+
+	$alterations = dbDelta($wp_queries);
+	echo "<ol>\n";
+	foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
+	echo "</ol>\n";
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ */
+function make_db_current_silent() {
+	global $wp_queries;
+
+	$alterations = dbDelta($wp_queries);
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $theme_name
+ * @param unknown_type $template
+ * @return unknown
+ */
+function make_site_theme_from_oldschool($theme_name, $template) {
+	$home_path = get_home_path();
+	$site_dir = WP_CONTENT_DIR . "/themes/$template";
+
+	if (! file_exists("$home_path/index.php"))
+		return false;
+
+	// Copy files from the old locations to the site theme.
+	// TODO: This does not copy arbitarary include dependencies.  Only the
+	// standard WP files are copied.
+	$files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
+
+	foreach ($files as $oldfile => $newfile) {
+		if ($oldfile == 'index.php')
+			$oldpath = $home_path;
+		else
+			$oldpath = ABSPATH;
+
+		if ($oldfile == 'index.php') { // Check to make sure it's not a new index
+			$index = implode('', file("$oldpath/$oldfile"));
+			if (strpos($index, 'WP_USE_THEMES') !== false) {
+				if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
+					return false;
+				continue; // Don't copy anything
+				}
+		}
+
+		if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
+			return false;
+
+		chmod("$site_dir/$newfile", 0777);
+
+		// Update the blog header include in each file.
+		$lines = explode("\n", implode('', file("$site_dir/$newfile")));
+		if ($lines) {
+			$f = fopen("$site_dir/$newfile", 'w');
+
+			foreach ($lines as $line) {
+				if (preg_match('/require.*wp-blog-header/', $line))
+					$line = '//' . $line;
+
+				// Update stylesheet references.
+				$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
+
+				// Update comments template inclusion.
+				$line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", "<?php comments_template(); ?>", $line);
+
+				fwrite($f, "{$line}\n");
+			}
+			fclose($f);
+		}
+	}
+
+	// Add a theme header.
+	$header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
+
+	$stylelines = file_get_contents("$site_dir/style.css");
+	if ($stylelines) {
+		$f = fopen("$site_dir/style.css", 'w');
+
+		fwrite($f, $header);
+		fwrite($f, $stylelines);
+		fclose($f);
+	}
+
+	return true;
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @param unknown_type $theme_name
+ * @param unknown_type $template
+ * @return unknown
+ */
+function make_site_theme_from_default($theme_name, $template) {
+	$site_dir = WP_CONTENT_DIR . "/themes/$template";
+	$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
+
+	// Copy files from the default theme to the site theme.
+	//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
+
+	$theme_dir = @ opendir($default_dir);
+	if ($theme_dir) {
+		while(($theme_file = readdir( $theme_dir )) !== false) {
+			if (is_dir("$default_dir/$theme_file"))
+				continue;
+			if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
+				return;
+			chmod("$site_dir/$theme_file", 0777);
+		}
+	}
+	@closedir($theme_dir);
+
+	// Rewrite the theme header.
+	$stylelines = explode("\n", implode('', file("$site_dir/style.css")));
+	if ($stylelines) {
+		$f = fopen("$site_dir/style.css", 'w');
+
+		foreach ($stylelines as $line) {
+			if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
+			elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
+			elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
+			elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
+			elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
+			fwrite($f, $line . "\n");
+		}
+		fclose($f);
+	}
+
+	// Copy the images.
+	umask(0);
+	if (! mkdir("$site_dir/images", 0777)) {
+		return false;
+	}
+
+	$images_dir = @ opendir("$default_dir/images");
+	if ($images_dir) {
+		while(($image = readdir($images_dir)) !== false) {
+			if (is_dir("$default_dir/images/$image"))
+				continue;
+			if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
+				return;
+			chmod("$site_dir/images/$image", 0777);
+		}
+	}
+	@closedir($images_dir);
+}
+
+// Create a site theme from the default theme.
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 1.5.0
+ *
+ * @return unknown
+ */
+function make_site_theme() {
+	// Name the theme after the blog.
+	$theme_name = __get_option('blogname');
+	$template = sanitize_title($theme_name);
+	$site_dir = WP_CONTENT_DIR . "/themes/$template";
+
+	// If the theme already exists, nothing to do.
+	if ( is_dir($site_dir)) {
+		return false;
+	}
+
+	// We must be able to write to the themes dir.
+	if (! is_writable(WP_CONTENT_DIR . "/themes")) {
+		return false;
+	}
+
+	umask(0);
+	if (! mkdir($site_dir, 0777)) {
+		return false;
+	}
+
+	if (file_exists(ABSPATH . 'wp-layout.css')) {
+		if (! make_site_theme_from_oldschool($theme_name, $template)) {
+			// TODO:  rm -rf the site theme directory.
+			return false;
+		}
+	} else {
+		if (! make_site_theme_from_default($theme_name, $template))
+			// TODO:  rm -rf the site theme directory.
+			return false;
+	}
+
+	// Make the new site theme active.
+	$current_template = __get_option('template');
+	if ($current_template == WP_DEFAULT_THEME) {
+		update_option('template', $template);
+		update_option('stylesheet', $template);
+	}
+	return $template;
+}
+
+/**
+ * Translate user level to user role name.
+ *
+ * @since 2.0.0
+ *
+ * @param int $level User level.
+ * @return string User role name.
+ */
+function translate_level_to_role($level) {
+	switch ($level) {
+	case 10:
+	case 9:
+	case 8:
+		return 'administrator';
+	case 7:
+	case 6:
+	case 5:
+		return 'editor';
+	case 4:
+	case 3:
+	case 2:
+		return 'author';
+	case 1:
+		return 'contributor';
+	case 0:
+		return 'subscriber';
+	}
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.1.0
+ */
+function wp_check_mysql_version() {
+	global $wpdb;
+	$result = $wpdb->check_database_version();
+	if ( is_wp_error( $result ) )
+		die( $result->get_error_message() );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @since 2.2.0
+ */
+function maybe_disable_automattic_widgets() {
+	$plugins = __get_option( 'active_plugins' );
+
+	foreach ( (array) $plugins as $plugin ) {
+		if ( basename( $plugin ) == 'widgets.php' ) {
+			array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
+			update_option( 'active_plugins', $plugins );
+			break;
+		}
+	}
+}
+
+/**
+ * Runs before the schema is upgraded.
+ *
+ * @since 2.9.0
+ */
+function pre_schema_upgrade() {
+	global $wp_current_db_version, $wp_db_version, $wpdb;
+
+	// Upgrade versions prior to 2.9
+	if ( $wp_current_db_version < 11557 ) {
+		// Delete duplicate options.  Keep the option with the highest option_id.
+		$wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
+
+		// Drop the old primary key and add the new.
+		$wpdb->query("ALTER TABLE $wpdb->options DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)");
+
+		// Drop the old option_name index. dbDelta() doesn't do the drop.
+		$wpdb->query("ALTER TABLE $wpdb->options DROP INDEX option_name");
+	}
+
+}
+
+/**
+ * Install Network.
+ *
+ * @since 3.0.0
+ *
+ */
+if ( !function_exists( 'install_network' ) ) :
+function install_network() {
+	global $wpdb, $charset_collate;
+	$ms_queries = "
+CREATE TABLE $wpdb->users (
+  ID bigint(20) unsigned NOT NULL auto_increment,
+  user_login varchar(60) NOT NULL default '',
+  user_pass varchar(64) NOT NULL default '',
+  user_nicename varchar(50) NOT NULL default '',
+  user_email varchar(100) NOT NULL default '',
+  user_url varchar(100) NOT NULL default '',
+  user_registered datetime NOT NULL default '0000-00-00 00:00:00',
+  user_activation_key varchar(60) NOT NULL default '',
+  user_status int(11) NOT NULL default '0',
+  display_name varchar(250) NOT NULL default '',
+  spam tinyint(2) NOT NULL default '0',
+  deleted tinyint(2) NOT NULL default '0',
+  PRIMARY KEY  (ID),
+  KEY user_login_key (user_login),
+  KEY user_nicename (user_nicename)
+) $charset_collate;
+CREATE TABLE $wpdb->blogs (
+  blog_id bigint(20) NOT NULL auto_increment,
+  site_id bigint(20) NOT NULL default '0',
+  domain varchar(200) NOT NULL default '',
+  path varchar(100) NOT NULL default '',
+  registered datetime NOT NULL default '0000-00-00 00:00:00',
+  last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+  public tinyint(2) NOT NULL default '1',
+  archived enum('0','1') NOT NULL default '0',
+  mature tinyint(2) NOT NULL default '0',
+  spam tinyint(2) NOT NULL default '0',
+  deleted tinyint(2) NOT NULL default '0',
+  lang_id int(11) NOT NULL default '0',
+  PRIMARY KEY  (blog_id),
+  KEY domain (domain(50),path(5)),
+  KEY lang_id (lang_id)
+) $charset_collate;
+CREATE TABLE $wpdb->blog_versions (
+  blog_id bigint(20) NOT NULL default '0',
+  db_version varchar(20) NOT NULL default '',
+  last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+  PRIMARY KEY  (blog_id),
+  KEY db_version (db_version)
+) $charset_collate;
+CREATE TABLE $wpdb->registration_log (
+  ID bigint(20) NOT NULL auto_increment,
+  email varchar(255) NOT NULL default '',
+  IP varchar(30) NOT NULL default '',
+  blog_id bigint(20) NOT NULL default '0',
+  date_registered datetime NOT NULL default '0000-00-00 00:00:00',
+  PRIMARY KEY  (ID),
+  KEY IP (IP)
+) $charset_collate;
+CREATE TABLE $wpdb->site (
+  id bigint(20) NOT NULL auto_increment,
+  domain varchar(200) NOT NULL default '',
+  path varchar(100) NOT NULL default '',
+  PRIMARY KEY  (id),
+  KEY domain (domain,path)
+) $charset_collate;
+CREATE TABLE $wpdb->sitemeta (
+  meta_id bigint(20) NOT NULL auto_increment,
+  site_id bigint(20) NOT NULL default '0',
+  meta_key varchar(255) default NULL,
+  meta_value longtext,
+  PRIMARY KEY  (meta_id),
+  KEY meta_key (meta_key),
+  KEY site_id (site_id)
+) $charset_collate;
+CREATE TABLE $wpdb->signups (
+  domain varchar(200) NOT NULL default '',
+  path varchar(100) NOT NULL default '',
+  title longtext NOT NULL,
+  user_login varchar(60) NOT NULL default '',
+  user_email varchar(100) NOT NULL default '',
+  registered datetime NOT NULL default '0000-00-00 00:00:00',
+  activated datetime NOT NULL default '0000-00-00 00:00:00',
+  active tinyint(1) NOT NULL default '0',
+  activation_key varchar(50) NOT NULL default '',
+  meta longtext,
+  KEY activation_key (activation_key),
+  KEY domain (domain)
+) $charset_collate;
+";
+// now create tables
+	dbDelta( $ms_queries );
+}
+endif;
+
+/**
+ * Install global terms.
+ *
+ * @since 3.0.0
+ *
+ */
+if ( !function_exists( 'install_global_terms' ) ) :
+function install_global_terms() {
+	global $wpdb, $charset_collate;
+	$ms_queries = "
+CREATE TABLE $wpdb->sitecategories (
+  cat_ID bigint(20) NOT NULL auto_increment,
+  cat_name varchar(55) NOT NULL default '',
+  category_nicename varchar(200) NOT NULL default '',
+  last_updated timestamp NOT NULL,
+  PRIMARY KEY  (cat_ID),
+  KEY category_nicename (category_nicename),
+  KEY last_updated (last_updated)
+) $charset_collate;
+";
+// now create tables
+	dbDelta( $ms_queries );
+}
+endif;
+?>
Index: /tags/3.1/wp-admin/includes/user.php
===================================================================
--- /tags/3.1/wp-admin/includes/user.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/user.php	(revision 17487)
@@ -0,0 +1,383 @@
+<?php
+/**
+ * WordPress user administration API.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Creates a new user from the "Users" form using $_POST information.
+ *
+ * It seems that the first half is for backwards compatibility, but only
+ * has the ability to alter the user's role. WordPress core seems to
+ * use this function only in the second way, running edit_user() with
+ * no id so as to create a new user.
+ *
+ * @since 2.0
+ *
+ * @param int $user_id Optional. User ID.
+ * @return null|WP_Error|int Null when adding user, WP_Error or User ID integer when no parameters.
+ */
+function add_user() {
+	if ( func_num_args() ) { // The hackiest hack that ever did hack
+		global $wp_roles;
+		$user_id = (int) func_get_arg( 0 );
+
+		if ( isset( $_POST['role'] ) ) {
+			$new_role = sanitize_text_field( $_POST['role'] );
+			// Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
+			if ( $user_id != get_current_user_id() || $wp_roles->role_objects[$new_role]->has_cap( 'edit_users' ) ) {
+				// If the new role isn't editable by the logged-in user die with error
+				$editable_roles = get_editable_roles();
+				if ( empty( $editable_roles[$new_role] ) )
+					wp_die(__('You can&#8217;t give users that role.'));
+
+				$user = new WP_User( $user_id );
+				$user->set_role( $new_role );
+			}
+		}
+	} else {
+		add_action( 'user_register', 'add_user' ); // See above
+		return edit_user();
+	}
+}
+
+/**
+ * Edit user settings based on contents of $_POST
+ *
+ * Used on user-edit.php and profile.php to manage and process user options, passwords etc.
+ *
+ * @since 2.0
+ *
+ * @param int $user_id Optional. User ID.
+ * @return int user id of the updated user
+ */
+function edit_user( $user_id = 0 ) {
+	global $wp_roles, $wpdb;
+	$user = new stdClass;
+	if ( $user_id ) {
+		$update = true;
+		$user->ID = (int) $user_id;
+		$userdata = get_userdata( $user_id );
+		$user->user_login = $wpdb->escape( $userdata->user_login );
+	} else {
+		$update = false;
+	}
+
+	if ( !$update && isset( $_POST['user_login'] ) )
+		$user->user_login = sanitize_user($_POST['user_login'], true);
+
+	$pass1 = $pass2 = '';
+	if ( isset( $_POST['pass1'] ))
+		$pass1 = $_POST['pass1'];
+	if ( isset( $_POST['pass2'] ))
+		$pass2 = $_POST['pass2'];
+
+	if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) {
+		$new_role = sanitize_text_field( $_POST['role'] );
+		$potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false;
+		// Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
+		// Multisite super admins can freely edit their blog roles -- they possess all caps.
+		if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) )
+			$user->role = $new_role;
+
+		// If the new role isn't editable by the logged-in user die with error
+		$editable_roles = get_editable_roles();
+		if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) )
+			wp_die(__('You can&#8217;t give users that role.'));
+	}
+
+	if ( isset( $_POST['email'] ))
+		$user->user_email = sanitize_text_field( $_POST['email'] );
+	if ( isset( $_POST['url'] ) ) {
+		if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) {
+			$user->user_url = '';
+		} else {
+			$user->user_url = esc_url_raw( $_POST['url'] );
+			$user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
+		}
+	}
+	if ( isset( $_POST['first_name'] ) )
+		$user->first_name = sanitize_text_field( $_POST['first_name'] );
+	if ( isset( $_POST['last_name'] ) )
+		$user->last_name = sanitize_text_field( $_POST['last_name'] );
+	if ( isset( $_POST['nickname'] ) )
+		$user->nickname = sanitize_text_field( $_POST['nickname'] );
+	if ( isset( $_POST['display_name'] ) )
+		$user->display_name = sanitize_text_field( $_POST['display_name'] );
+
+	if ( isset( $_POST['description'] ) )
+		$user->description = trim( $_POST['description'] );
+
+	foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
+		if ( isset( $_POST[$method] ))
+			$user->$method = sanitize_text_field( $_POST[$method] );
+	}
+
+	if ( $update ) {
+		$user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
+		$user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
+		$user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
+		$user->show_admin_bar_admin = isset( $_POST['admin_bar_admin'] ) ? 'true' : 'false';
+	}
+
+	$user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
+
+	$user->use_ssl = 0;
+	if ( !empty($_POST['use_ssl']) )
+		$user->use_ssl = 1;
+
+	$errors = new WP_Error();
+
+	/* checking that username has been typed */
+	if ( $user->user_login == '' )
+		$errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ));
+
+	/* checking the password has been typed twice */
+	do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 ));
+
+	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) )
+			$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 ( false !== strpos( stripslashes($pass1), "\\" ) )
+		$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 enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) );
+
+	if ( !empty( $pass1 ) )
+		$user->user_pass = $pass1;
+
+	if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) )
+		$errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. 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.' ));
+
+	/* checking e-mail address */
+	if ( empty( $user->user_email ) ) {
+		$errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) );
+	} elseif ( !is_email( $user->user_email ) ) {
+		$errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The e-mail address isn&#8217;t correct.' ), array( 'form-field' => 'email' ) );
+	} elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) {
+		$errors->add( 'email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) );
+	}
+
+	// Allow plugins to return their own errors.
+	do_action_ref_array('user_profile_update_errors', array ( &$errors, $update, &$user ) );
+
+	if ( $errors->get_error_codes() )
+		return $errors;
+
+	if ( $update ) {
+		$user_id = wp_update_user( get_object_vars( $user ) );
+	} else {
+		$user_id = wp_insert_user( get_object_vars( $user ) );
+		wp_new_user_notification( $user_id, isset($_POST['send_password']) ? $pass1 : '' );
+	}
+	return $user_id;
+}
+
+/**
+ * Fetch a filtered list of user roles that the current user is
+ * allowed to edit.
+ *
+ * Simple function who's main purpose is to allow filtering of the
+ * list of roles in the $wp_roles object so that plugins can remove
+ * innappropriate ones depending on the situation or user making edits.
+ * Specifically because without filtering anyone with the edit_users
+ * capability can edit others to be administrators, even if they are
+ * only editors or authors. This filter allows admins to delegate
+ * user management.
+ *
+ * @since 2.8
+ *
+ * @return unknown
+ */
+function get_editable_roles() {
+	global $wp_roles;
+
+	$all_roles = $wp_roles->roles;
+	$editable_roles = apply_filters('editable_roles', $all_roles);
+
+	return $editable_roles;
+}
+
+/**
+ * Retrieve user data and filter it.
+ *
+ * @since 2.0.5
+ *
+ * @param int $user_id User ID.
+ * @return object WP_User object with user data.
+ */
+function get_user_to_edit( $user_id ) {
+	$user = new WP_User( $user_id );
+
+	$user_contactmethods = _wp_get_user_contactmethods( $user );
+	foreach ($user_contactmethods as $method => $name) {
+		if ( empty( $user->{$method} ) )
+			$user->{$method} = '';
+	}
+
+	if ( empty($user->description) )
+		$user->description = '';
+
+	$user = sanitize_user_object($user, 'edit');
+
+	return $user;
+}
+
+/**
+ * Retrieve the user's drafts.
+ *
+ * @since 2.0.0
+ *
+ * @param int $user_id User ID.
+ * @return array
+ */
+function get_users_drafts( $user_id ) {
+	global $wpdb;
+	$query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id);
+	$query = apply_filters('get_users_drafts', $query);
+	return $wpdb->get_results( $query );
+}
+
+/**
+ * Remove user and optionally reassign posts and links to another user.
+ *
+ * If the $reassign parameter is not assigned to an User ID, then all posts will
+ * be deleted of that user. The action 'delete_user' that is passed the User ID
+ * being deleted will be run after the posts are either reassigned or deleted.
+ * The user meta will also be deleted that are for that User ID.
+ *
+ * @since 2.0.0
+ *
+ * @param int $id User ID.
+ * @param int $reassign Optional. Reassign posts and links to new User ID.
+ * @return bool True when finished.
+ */
+function wp_delete_user( $id, $reassign = 'novalue' ) {
+	global $wpdb;
+
+	$id = (int) $id;
+
+	// allow for transaction statement
+	do_action('delete_user', $id);
+
+	if ( 'novalue' === $reassign || null === $reassign ) {
+		$post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) );
+
+		if ( $post_ids ) {
+			foreach ( $post_ids as $post_id )
+				wp_delete_post($post_id);
+		}
+
+		// Clean links
+		$link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) );
+
+		if ( $link_ids ) {
+			foreach ( $link_ids as $link_id )
+				wp_delete_link($link_id);
+		}
+	} else {
+		$reassign = (int) $reassign;
+		$wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) );
+		$wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) );
+	}
+
+	clean_user_cache($id);
+
+	// FINALLY, delete user
+	if ( !is_multisite() ) {
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
+	} else {
+		$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
+		$wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$level_key}'");
+	}
+
+	// allow for commit transaction
+	do_action('deleted_user', $id);
+
+	return true;
+}
+
+/**
+ * Remove all capabilities from user.
+ *
+ * @since 2.1.0
+ *
+ * @param int $id User ID.
+ */
+function wp_revoke_user($id) {
+	$id = (int) $id;
+
+	$user = new WP_User($id);
+	$user->remove_all_caps();
+}
+
+add_action('admin_init', 'default_password_nag_handler');
+/**
+ * @since 2.8.0
+ */
+function default_password_nag_handler($errors = false) {
+	global $user_ID;
+	if ( ! get_user_option('default_password_nag') ) //Short circuit it.
+		return;
+
+	//get_user_setting = JS saved UI setting. else no-js-falback code.
+	if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) {
+		delete_user_setting('default_password_nag');
+		update_user_option($user_ID, 'default_password_nag', false, true);
+	}
+}
+
+add_action('profile_update', 'default_password_nag_edit_user', 10, 2);
+/**
+ * @since 2.8.0
+ */
+function default_password_nag_edit_user($user_ID, $old_data) {
+	if ( ! get_user_option('default_password_nag', $user_ID) ) //Short circuit it.
+		return;
+
+	$new_data = get_userdata($user_ID);
+
+	if ( $new_data->user_pass != $old_data->user_pass ) { //Remove the nag if the password has been changed.
+		delete_user_setting('default_password_nag', $user_ID);
+		update_user_option($user_ID, 'default_password_nag', false, true);
+	}
+}
+
+add_action('admin_notices', 'default_password_nag');
+/**
+ * @since 2.8.0
+ */
+function default_password_nag() {
+	global $pagenow;
+	if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) //Short circuit it.
+		return;
+
+	echo '<div class="error default-password-nag">';
+	echo '<p>';
+	echo '<strong>' . __('Notice:') . '</strong> ';
+	_e('You&rsquo;re using the auto-generated password for your account. Would you like to change it to something easier to remember?');
+	echo '</p><p>';
+	printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', admin_url('profile.php') . '#password' );
+	printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
+	echo '</p></div>';
+}
+
+?>
Index: /tags/3.1/wp-admin/includes/widgets.php
===================================================================
--- /tags/3.1/wp-admin/includes/widgets.php	(revision 17487)
+++ /tags/3.1/wp-admin/includes/widgets.php	(revision 17487)
@@ -0,0 +1,225 @@
+<?php
+/**
+ * WordPress Widgets Administration API
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Display list of the available widgets.
+ *
+ * @since 2.5.0
+ */
+function wp_list_widgets() {
+	global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
+
+	$sort = $wp_registered_widgets;
+	usort( $sort, '_sort_name_callback' );
+	$done = array();
+
+	foreach ( $sort as $widget ) {
+		if ( in_array( $widget['callback'], $done, true ) ) // We already showed this multi-widget
+			continue;
+
+		$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
+		$done[] = $widget['callback'];
+
+		if ( ! isset( $widget['params'][0] ) )
+			$widget['params'][0] = array();
+
+		$args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
+
+		if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) {
+			$id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
+			$args['_temp_id'] = "$id_base-__i__";
+			$args['_multi_num'] = next_widget_id_number($id_base);
+			$args['_add'] = 'multi';
+		} else {
+			$args['_add'] = 'single';
+			if ( $sidebar )
+				$args['_hide'] = '1';
+		}
+
+		$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
+		call_user_func_array( 'wp_widget_control', $args );
+	}
+}
+
+/**
+ * Callback to sort array by a 'name' key.
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _sort_name_callback( $a, $b ) {
+	return strnatcasecmp( $a['name'], $b['name'] );
+}
+
+/**
+ * Show the widgets and their settings for a sidebar.
+ * Used in the the admin widget config screen.
+ *
+ * @since 2.5.0
+ *
+ * @param string $sidebar id slug of the sidebar
+ */
+function wp_list_widget_controls( $sidebar ) {
+	add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' );
+
+	echo "<div id='$sidebar' class='widgets-sortables'>\n";
+
+	$description = wp_sidebar_description( $sidebar );
+
+	if ( !empty( $description ) ) {
+		echo "<div class='sidebar-description'>\n";
+		echo "\t<p class='description'>$description</p>";
+		echo "</div>\n";
+	}
+
+	dynamic_sidebar( $sidebar );
+	echo "</div>\n";
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.5.0
+ *
+ * @param array $params
+ * @return array
+ */
+function wp_list_widget_controls_dynamic_sidebar( $params ) {
+	global $wp_registered_widgets;
+	static $i = 0;
+	$i++;
+
+	$widget_id = $params[0]['widget_id'];
+	$id = isset($params[0]['_temp_id']) ? $params[0]['_temp_id'] : $widget_id;
+	$hidden = isset($params[0]['_hide']) ? ' style="display:none;"' : '';
+
+	$params[0]['before_widget'] = "<div id='widget-{$i}_{$id}' class='widget'$hidden>";
+	$params[0]['after_widget'] = "</div>";
+	$params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated
+	$params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated
+	if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) {
+		$wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback'];
+		$wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control';
+	}
+
+	return $params;
+}
+
+function next_widget_id_number($id_base) {
+	global $wp_registered_widgets;
+	$number = 1;
+
+	foreach ( $wp_registered_widgets as $widget_id => $widget ) {
+		if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) )
+			$number = max($number, $matches[1]);
+	}
+	$number++;
+
+	return $number;
+}
+
+/**
+ * Meta widget used to display the control form for a widget.
+ *
+ * Called from dynamic_sidebar().
+ *
+ * @since 2.5.0
+ *
+ * @param array $sidebar_args
+ * @return array
+ */
+function wp_widget_control( $sidebar_args ) {
+	global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets;
+
+	$widget_id = $sidebar_args['widget_id'];
+	$sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false;
+	$key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : '-1'; // position of widget in sidebar
+	$control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : array();
+	$widget = $wp_registered_widgets[$widget_id];
+
+	$id_format = $widget['id'];
+	$widget_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
+	$id_base = isset($control['id_base']) ? $control['id_base'] : $widget_id;
+	$multi_number = isset($sidebar_args['_multi_num']) ? $sidebar_args['_multi_num'] : '';
+	$add_new = isset($sidebar_args['_add']) ? $sidebar_args['_add'] : '';
+
+	$query_arg = array( 'editwidget' => $widget['id'] );
+	if ( $add_new ) {
+		$query_arg['addnew'] = 1;
+		if ( $multi_number ) {
+			$query_arg['num'] = $multi_number;
+			$query_arg['base'] = $id_base;
+		}
+	} else {
+		$query_arg['sidebar'] = $sidebar_id;
+		$query_arg['key'] = $key;
+	}
+
+	// We aren't showing a widget control, we're outputing a template for a mult-widget control
+	if ( isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number ) {
+		// number == -1 implies a template where id numbers are replaced by a generic '__i__'
+		$control['params'][0]['number'] = -1;
+		// with id_base widget id's are constructed like {$id_base}-{$id_number}
+		if ( isset($control['id_base']) )
+			$id_format = $control['id_base'] . '-__i__';
+	}
+
+	$wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback'];
+	unset($wp_registered_widgets[$widget_id]['_callback']);
+
+	$widget_title = esc_html( strip_tags( $sidebar_args['widget_name'] ) );
+	$has_form = 'noform';
+
+	echo $sidebar_args['before_widget']; ?>
+	<div class="widget-top">
+	<div class="widget-title-action">
+		<a class="widget-action hide-if-no-js" href="#available-widgets"></a>
+		<a class="widget-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>"><span class="edit"><?php _e('Edit'); ?></span><span class="add"><?php _e('Add'); ?></span></a>
+	</div>
+	<div class="widget-title"><h4><?php echo $widget_title ?><span class="in-widget-title"></span></h4></div>
+	</div>
+
+	<div class="widget-inside">
+	<form action="" method="post">
+	<div class="widget-content">
+<?php
+	if ( isset($control['callback']) )
+		$has_form = call_user_func_array( $control['callback'], $control['params'] );
+	else
+		echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?>
+	</div>
+	<input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($id_format); ?>" />
+	<input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
+	<input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) echo esc_attr($control['width']); ?>" />
+	<input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) echo esc_attr($control['height']); ?>" />
+	<input type="hidden" name="widget_number" class="widget_number" value="<?php echo esc_attr($widget_number); ?>" />
+	<input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
+	<input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" />
+
+	<div class="widget-control-actions">
+		<div class="alignleft">
+		<a class="widget-control-remove" href="#remove"><?php _e('Delete'); ?></a> |
+		<a class="widget-control-close" href="#close"><?php _e('Close'); ?></a>
+		</div>
+		<div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>">
+		<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback " title="" alt="" />
+		<?php submit_button( __( 'Save' ), 'button-primary widget-control-save', 'savewidget', false ); ?>
+		</div>
+		<br class="clear" />
+	</div>
+	</form>
+	</div>
+
+	<div class="widget-description">
+<?php echo ( $widget_description = wp_widget_description($widget_id) ) ? "$widget_description\n" : "$widget_title\n"; ?>
+	</div>
+<?php
+	echo $sidebar_args['after_widget'];
+	return $sidebar_args;
+}
+
Index: /tags/3.1/wp-admin/index-extra.php
===================================================================
--- /tags/3.1/wp-admin/index-extra.php	(revision 17487)
+++ /tags/3.1/wp-admin/index-extra.php	(revision 17487)
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Handle default dashboard widgets options AJAX.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
+require_once( './admin.php' );
+
+/** Load WordPress Administration Dashboard API */
+require(ABSPATH . 'wp-admin/includes/dashboard.php' );
+
+@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
+send_nosniff_header();
+
+switch ( $_GET['jax'] ) {
+
+case 'dashboard_incoming_links' :
+	wp_dashboard_incoming_links_output();
+	break;
+
+case 'dashboard_primary' :
+	wp_dashboard_rss_output( 'dashboard_primary' );
+	break;
+
+case 'dashboard_secondary' :
+	wp_dashboard_secondary_output();
+	break;
+
+case 'dashboard_plugins' :
+	wp_dashboard_plugins_output();
+	break;
+
+case 'dashboard_quick_press' :
+	wp_dashboard_quick_press_output();
+	break;
+
+}
+
+?>
Index: /tags/3.1/wp-admin/index.php
===================================================================
--- /tags/3.1/wp-admin/index.php	(revision 17487)
+++ /tags/3.1/wp-admin/index.php	(revision 17487)
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Dashboard Administration Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Bootstrap */
+require_once('./admin.php');
+
+/** Load WordPress dashboard API */
+require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
+
+wp_dashboard_setup();
+
+wp_enqueue_script( 'dashboard' );
+wp_enqueue_script( 'plugin-install' );
+wp_enqueue_script( 'media-upload' );
+wp_admin_css( 'dashboard' );
+wp_admin_css( 'plugin-install' );
+add_thickbox();
+
+$title = __('Dashboard');
+$parent_file = 'index.php';
+
+if ( is_user_admin() )
+	add_screen_option('layout_columns', array('max' => 4, 'default' => 1) );
+else
+	add_screen_option('layout_columns', array('max' => 4, 'default' => 2) );
+
+add_contextual_help($current_screen,
+
+	'<p>' . __( 'Welcome to your WordPress Dashboard! You will find helpful tips in the Help tab of each screen to assist you as you get to know the application.' ) . '</p>' .
+	'<p>' . __( 'The Admin Bar at the top, new in 3.1, provides quick access to common tasks when you are viewing your site.' ) . '</p>' .
+	'<p>' . __( 'The left-hand navigation menu provides links to the administration screens in your WordPress application. You can expand or collapse navigation sections by clicking on the arrow that appears on the right side of each navigation item when you hover over it. You can also minimize the navigation menu to a narrow icon strip by clicking on the faint separator lines between the Dashboard and Posts sections, or between Comments and Appearance; when minimized, the submenu items will be displayed on hover.' ) . '</p>' .
+	'<p>' . __( 'You can configure your dashboard by choosing which boxes, or modules, to display in the work area, how many columns to display them in, and where each box should be placed. You can hide/show boxes and select the number of columns in the Screen Options tab. To rearrange the boxes, drag and drop by clicking on the title bar of the selected box and releasing when you see a gray dotted-line rectangle appear in the location you want to place the box. You can also expand or collapse each box by clicking once on the title bar of the box. In addition, some boxes are configurable, and will show a &#8220;Configure&#8221; link in the title bar when you hover over it.' ) . '</p>' .
+	'<p>' . __( 'The boxes on your Dashboard screen are:' ) . '</p>' .
+	'<p>' . __( '<strong>Right Now</strong> - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.' ) . '</p>' .
+	'<p>' . __( '<strong>Recent Comments</strong> - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.' ) . '</p>' .
+	'<p>' . __( '<strong>Incoming Links</strong> - Shows links to your site found by Google Blog Search.' ) . '</p>' .
+	'<p>' . __( '<strong>QuickPress</strong> - Allows you to create a new post and either publish it or save it as a draft.' ) . '</p>' .
+	'<p>' . __( '<strong>Recent Drafts</strong> - Displays links to the 5 most recent draft posts you&#8217;ve started.' ) . '</p>' .
+	'<p>' . __( '<strong>WordPress Development Blog</strong> - Come here for the latest scoop.' ) . '</p>' .
+	'<p>' . __( '<strong>Other WordPress News</strong> - Shows the feed from <a href="http://planet.wordpress.org" target="_blank">WordPress Planet</a>. You can configure it to show a different feed of your choosing.' ) . '</p>' .
+	'<p>' . __( '<strong>Plugins</strong> - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.' ) . '</p>' .
+	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+	'<p>' . __( '<a href="http://codex.wordpress.org/Dashboard_SubPanel" target="_blank">Documentation on Dashboard</a>' ) . '</p>' .
+	'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
+);
+
+include (ABSPATH . 'wp-admin/admin-header.php');
+
+$today = current_time('mysql', 1);
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<div id="dashboard-widgets-wrap">
+
+<?php wp_dashboard(); ?>
+
+<div class="clear"></div>
+</div><!-- dashboard-widgets-wrap -->
+
+</div><!-- wrap -->
+
+<?php require(ABSPATH . 'wp-admin/admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/install-helper.php
===================================================================
--- /tags/3.1/wp-admin/install-helper.php	(revision 17487)
+++ /tags/3.1/wp-admin/install-helper.php	(revision 17487)
@@ -0,0 +1,217 @@
+<?php
+/**
+ * Plugins may load this file to gain access to special helper functions for
+ * plugin installation. This file is not included by WordPress and it is
+ * recommended, to prevent fatal errors, that this file is included using
+ * require_once().
+ *
+ * These functions are not optimized for speed, but they should only be used
+ * once in a while, so speed shouldn't be a concern. If it is and you are
+ * needing to use these functions a lot, you might experience time outs. If you
+ * do, then it is advised to just write the SQL code yourself.
+ *
+ * You can turn debugging on, by setting $debug to 1 after you include this
+ * file.
+ *
+ * <code>
+ * check_column('wp_links', 'link_description', 'mediumtext');
+ * if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
+ *     echo "ok\n";
+ *
+ * $error_count = 0;
+ * $tablename = $wpdb->links;
+ * // check the column
+ * if (!check_column($wpdb->links, 'link_description', 'varchar(255)')) {
+ *     $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
+ *     $q = $wpdb->query($ddl);
+ * }
+ *
+ * if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
+ *     $res .= $tablename . ' - ok <br />';
+ * } else {
+ *     $res .= 'There was a problem with ' . $tablename . '<br />';
+ *     ++$error_count;
+ * }
+ * </code>
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ */
+
+/** Load WordPress Bootstrap */
+require_once(dirname(dirname(__FILE__)).'/wp-load.php');
+
+/**
+ * Turn debugging on or off.
+ * @global bool|int $debug
+ * @name $debug
+ * @var bool|int
+ * @since 1.0.0
+ */
+$debug = 0;
+
+if ( ! function_exists('maybe_create_table') ) :
+/**
+ * Create database table, if it doesn't already exist.
+ *
+ * @since 1.0.0
+ * @package WordPress
+ * @subpackage Plugin
+ * @uses $wpdb
+ *
+ * @param string $table_name Database table name.
+ * @param string $create_ddl Create database table SQL.
+ * @return bool False on error, true if already exists or success.
+ */
+function maybe_create_table($table_name, $create_ddl) {
+	global $wpdb;
+	foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+		if ($table == $table_name) {
+			return true;
+		}
+	}
+	//didn't find it try to create it.
+	$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) {
+			return true;
+		}
+	}
+	return false;
+}
+endif;
+
+if ( ! function_exists('maybe_add_column') ) :
+/**
+ * Add column to database table, if column doesn't already exist in table.
+ *
+ * @since 1.0.0
+ * @package WordPress
+ * @subpackage Plugin
+ * @uses $wpdb
+ * @uses $debug
+ *
+ * @param string $table_name Database table name
+ * @param string $column_name Table column name
+ * @param string $create_ddl SQL to add column to table.
+ * @return bool False on failure. True, if already exists or was successful.
+ */
+function maybe_add_column($table_name, $column_name, $create_ddl) {
+	global $wpdb, $debug;
+	foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+		if ($debug) echo("checking $column == $column_name<br />");
+
+		if ($column == $column_name) {
+			return true;
+		}
+	}
+	//didn't find it try to create it.
+	$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) {
+			return true;
+		}
+	}
+	return false;
+}
+endif;
+
+/**
+ * Drop column from database table, if it exists.
+ *
+ * @since 1.0.0
+ * @package WordPress
+ * @subpackage Plugin
+ * @uses $wpdb
+ *
+ * @param string $table_name Table name
+ * @param string $column_name Column name
+ * @param string $drop_ddl SQL statement to drop column.
+ * @return bool False on failure, true on success or doesn't exist.
+ */
+function maybe_drop_column($table_name, $column_name, $drop_ddl) {
+	global $wpdb;
+	foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
+		if ($column == $column_name) {
+			//found it try to drop it.
+			$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) {
+					return false;
+				}
+			}
+		}
+	}
+	// else didn't find it
+	return true;
+}
+
+/**
+ * Check column matches criteria.
+ *
+ * Uses the SQL DESC for retrieving the table info for the column. It will help
+ * understand the parameters, if you do more research on what column information
+ * is returned by the SQL statement. Pass in null to skip checking that
+ * criteria.
+ *
+ * Column names returned from DESC table are case sensitive and are listed:
+ *      Field
+ *      Type
+ *      Null
+ *      Key
+ *      Default
+ *      Extra
+ *
+ * @since 1.0.0
+ * @package WordPress
+ * @subpackage Plugin
+ *
+ * @param string $table_name Table name
+ * @param string $col_name Column name
+ * @param string $col_type Column type
+ * @param bool $is_null Optional. Check is null.
+ * @param mixed $key Optional. Key info.
+ * @param mixed $default Optional. Default value.
+ * @param mixed $extra Optional. Extra value.
+ * @return bool True, if matches. False, if not matching.
+ */
+function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) {
+	global $wpdb, $debug;
+	$diffs = 0;
+	$results = $wpdb->get_results("DESC $table_name");
+
+	foreach ($results as $row ) {
+		if ($debug > 1) print_r($row);
+
+		if ($row->Field == $col_name) {
+			// got our column, check the params
+			if ($debug) echo ("checking $row->Type against $col_type\n");
+			if (($col_type != null) && ($row->Type != $col_type)) {
+				++$diffs;
+			}
+			if (($is_null != null) && ($row->Null != $is_null)) {
+				++$diffs;
+			}
+			if (($key != null) && ($row->Key  != $key)) {
+				++$diffs;
+			}
+			if (($default != null) && ($row->Default != $default)) {
+				++$diffs;
+			}
+			if (($extra != null) && ($row->Extra != $extra)) {
+				++$diffs;
+			}
+			if ($diffs > 0) {
+				if ($debug) echo ("diffs = $diffs returning false\n");
+				return false;
+			}
+			return true;
+		} // end if found our column
+	}
+	return false;
+}
+
+?>
Index: /tags/3.1/wp-admin/install.php
===================================================================
--- /tags/3.1/wp-admin/install.php	(revision 17487)
+++ /tags/3.1/wp-admin/install.php	(revision 17487)
@@ -0,0 +1,264 @@
+<?php
+/**
+ * WordPress Installer
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+// Sanity check.
+if ( false ) {
+?>
+<!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>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<title>Error: PHP is not running</title>
+</head>
+<body>
+	<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
+	<h2>Error: PHP is not running</h2>
+	<p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p>
+</body>
+</html>
+<?php
+}
+
+/**
+ * We are installing WordPress.
+ *
+ * @since 1.5.1
+ * @var bool
+ */
+define( 'WP_INSTALLING', true );
+
+/** Load WordPress Bootstrap */
+require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
+
+/** Load WordPress Administration Upgrade API */
+require_once( dirname( __FILE__ ) . '/includes/upgrade.php' );
+
+/** Load wpdb */
+require_once(dirname(dirname(__FILE__)) . '/wp-includes/wp-db.php');
+
+$step = isset( $_GET['step'] ) ? $_GET['step'] : 0;
+
+/**
+ * Display install header.
+ *
+ * @since 2.5.0
+ * @package WordPress
+ * @subpackage Installer
+ */
+function display_header() {
+	header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!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 language_attributes(); ?>>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<title><?php _e( 'WordPress &rsaquo; Installation' ); ?></title>
+	<?php wp_admin_css( 'install', true ); ?>
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
+
+<?php
+} // end display_header()
+
+/**
+ * Display installer setup form.
+ *
+ * @since 2.8.0
+ * @package WordPress
+ * @subpackage Installer
+ */
+function display_setup_form( $error = null ) {
+	global $wpdb;
+	$user_table = ( $wpdb->get_var("SHOW TABLES LIKE '$wpdb->users'") != null );
+
+	// Ensure that Blogs appear in search engines by default
+	$blog_public = 1;
+	if ( ! empty( $_POST ) )
+		$blog_public = isset( $_POST['blog_public'] );
+
+	$weblog_title = isset( $_POST['weblog_title'] ) ? trim( stripslashes( $_POST['weblog_title'] ) ) : '';
+	$user_name = isset($_POST['user_name']) ? trim( stripslashes( $_POST['user_name'] ) ) : 'admin';
+	$admin_password = isset($_POST['admin_password']) ? trim( stripslashes( $_POST['admin_password'] ) ) : '';
+	$admin_email  = isset( $_POST['admin_email']  ) ? trim( stripslashes( $_POST['admin_email'] ) ) : '';
+
+	if ( ! is_null( $error ) ) {
+?>
+<p class="message"><?php printf( __( '<strong>ERROR</strong>: %s' ), $error ); ?></p>
+<?php } ?>
+<form id="setup" method="post" action="install.php?step=2">
+	<table class="form-table">
+		<tr>
+			<th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th>
+			<td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td>
+		</tr>
+		<tr>
+			<th scope="row"><label for="user_name"><?php _e('Username'); ?></label></th>
+			<td>
+			<?php
+			if ( $user_table ) {
+				_e('User(s) already exists.');
+			} else {
+				?><input name="user_name" type="text" id="user_login" size="25" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" />
+				<p><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods and the @ symbol.' ); ?></p>
+			<?php
+			} ?>
+			</td>
+		</tr>
+		<?php if ( ! $user_table ) : ?>
+		<tr>
+			<th scope="row">
+				<label for="admin_password"><?php _e('Password, twice'); ?></label>
+				<p><?php _e('A password will be automatically generated for you if you leave this blank.'); ?></p>
+			</th>
+			<td>
+				<input name="admin_password" type="password" id="pass1" size="25" value="" />
+				<p><input name="admin_password2" type="password" id="pass2" size="25" value="" /></p>
+				<div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
+				<p><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
+			</td>
+		</tr>
+		<?php endif; ?>
+		<tr>
+			<th scope="row"><label for="admin_email"><?php _e( 'Your E-mail' ); ?></label></th>
+			<td><input name="admin_email" type="text" id="admin_email" size="25" value="<?php echo esc_attr( $admin_email ); ?>" />
+			<p><?php _e( 'Double-check your email address before continuing.' ); ?></p></td>
+		</tr>
+		<tr>
+			<td colspan="2"><label><input type="checkbox" name="blog_public" value="1" <?php checked( $blog_public ); ?> /> <?php _e( 'Allow my site to appear in search engines like Google and Technorati.' ); ?></label></td>
+		</tr>
+	</table>
+	<p class="step"><input type="submit" name="Submit" value="<?php esc_attr_e( 'Install WordPress' ); ?>" class="button" /></p>
+</form>
+<?php
+} // end display_setup_form()
+
+// Let's check to make sure WP isn't already installed.
+if ( is_blog_installed() ) {
+	display_header();
+	die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p><p class="step"><a href="../wp-login.php" class="button">' . __('Log In') . '</a></p></body></html>' );
+}
+
+$php_version    = phpversion();
+$mysql_version  = $wpdb->db_version();
+$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
+$mysql_compat   = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
+
+if ( !$mysql_compat && !$php_compat )
+	$compat = sprintf( __('You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
+elseif ( !$php_compat )
+	$compat = sprintf( __('You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version );
+elseif ( !$mysql_compat )
+	$compat = sprintf( __('You cannot install because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version );
+
+if ( !$mysql_compat || !$php_compat ) {
+	display_header();
+	die('<h1>' . __('Insufficient Requirements') . '</h1><p>' . $compat . '</p></body></html>');
+}
+
+switch($step) {
+	case 0: // Step 1
+	case 1: // Step 1, direct link.
+	  display_header();
+?>
+<h1><?php _e( 'Welcome' ); ?></h1>
+<p><?php printf( __( 'Welcome to the famous five minute WordPress installation process! You may want to browse the <a href="%s">ReadMe documentation</a> at your leisure. Otherwise, just fill in the information below and you&#8217;ll be on your way to using the most extendable and powerful personal publishing platform in the world.' ), '../readme.html' ); ?></p>
+
+<h1><?php _e( 'Information needed' ); ?></h1>
+<p><?php _e( 'Please provide the following information. Don&#8217;t worry, you can always change these settings later.' ); ?></p>
+
+<?php
+		display_setup_form();
+		break;
+	case 2:
+		if ( ! empty( $wpdb->error ) )
+			wp_die( $wpdb->error->get_error_message() );
+
+		display_header();
+		// Fill in the data we gathered
+		$weblog_title = isset( $_POST['weblog_title'] ) ? trim( stripslashes( $_POST['weblog_title'] ) ) : '';
+		$user_name = isset($_POST['user_name']) ? trim( stripslashes( $_POST['user_name'] ) ) : 'admin';
+		$admin_password = isset($_POST['admin_password']) ? $_POST['admin_password'] : '';
+		$admin_password_check = isset($_POST['admin_password2']) ? $_POST['admin_password2'] : '';
+		$admin_email  = isset( $_POST['admin_email']  ) ?trim( stripslashes( $_POST['admin_email'] ) ) : '';
+		$public       = isset( $_POST['blog_public']  ) ? (int) $_POST['blog_public'] : 0;
+		// check e-mail address
+		$error = false;
+		if ( empty( $user_name ) ) {
+			// TODO: poka-yoke
+			display_setup_form( __('you must provide a valid username.') );
+			$error = true;
+		} elseif ( $user_name != sanitize_user( $user_name, true ) ) {
+			display_setup_form( __('the username you provided has invalid characters.') );
+			$error = true;
+		} elseif ( $admin_password != $admin_password_check ) {
+			// TODO: poka-yoke
+			display_setup_form( __( 'your passwords do not match. Please try again' ) );
+			$error = true;
+		} else if ( empty( $admin_email ) ) {
+			// TODO: poka-yoke
+			display_setup_form( __( 'you must provide an e-mail address.' ) );
+			$error = true;
+		} elseif ( ! is_email( $admin_email ) ) {
+			// TODO: poka-yoke
+			display_setup_form( __( 'that isn&#8217;t a valid e-mail address.  E-mail addresses look like: <code>username@example.com</code>' ) );
+			$error = true;
+		}
+
+		if ( $error === false ) {
+			$wpdb->show_errors();
+			$result = wp_install($weblog_title, $user_name, $admin_email, $public, '', $admin_password);
+			extract( $result, EXTR_SKIP );
+?>
+
+<h1><?php _e( 'Success!' ); ?></h1>
+
+<p><?php _e( 'WordPress has been installed. Were you expecting more steps? Sorry to disappoint.' ); ?></p>
+
+<table class="form-table">
+	<tr>
+		<th><?php _e( 'Username' ); ?></th>
+		<td><code><?php echo esc_html( sanitize_user( $user_name, true ) ); ?></code></td>
+	</tr>
+	<tr>
+		<th><?php _e( 'Password' ); ?></th>
+		<td><?php
+		if ( ! empty( $password ) && empty($admin_password_check) )
+			echo '<code>'. esc_html($password) .'</code><br />';
+		echo "<p>$password_message</p>"; ?>
+		</td>
+	</tr>
+</table>
+
+<p class="step"><a href="../wp-login.php" class="button"><?php _e( 'Log In' ); ?></a></p>
+
+<?php
+		}
+		break;
+}
+?>
+<script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
+<script type="text/javascript" src="../wp-includes/js/jquery/jquery.js"></script>
+<script type="text/javascript" src="js/password-strength-meter.js"></script>
+<script type="text/javascript" src="js/user-profile.js"></script>
+<script type="text/javascript" src="../wp-includes/js/l10n.js"></script>
+<script type='text/javascript'>
+/* <![CDATA[ */
+var pwsL10n = {
+ empty: "<?php echo esc_js( __( 'Strength indicator' ) ); ?>",
+ short: "<?php echo esc_js( __( 'Very weak' ) ); ?>",
+ bad: "<?php echo esc_js( __( 'Weak' ) ); ?>",
+ good: "<?php echo esc_js( _x( 'Medium', 'password strength' ) ); ?>",
+ strong: "<?php echo esc_js( __( 'Strong' ) ); ?>",
+ mismatch: "<?php echo esc_js( __( 'Mismatch' ) ); ?>"
+};
+try{convertEntities(pwsL10n);}catch(e){};
+/* ]]> */
+</script>
+</body>
+</html>
Index: /tags/3.1/wp-admin/js/cat.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/cat.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/cat.dev.js	(revision 17487)
@@ -0,0 +1,5 @@
+jQuery(document).ready( 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 } );
+} );
Index: /tags/3.1/wp-admin/js/cat.js
===================================================================
--- /tags/3.1/wp-admin/js/cat.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/cat.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(b){var a=function(){return""!==b("#newcat").val()};b("#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>');b("#categorychecklist").wpList({alt:"",response:"cat-ajax-response",confirm:a})});
Index: /tags/3.1/wp-admin/js/categories.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/categories.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/categories.dev.js	(revision 17487)
@@ -0,0 +1,34 @@
+jQuery(document).ready(function($) {
+	var options = false, addAfter, delBefore, delAfter;
+	if ( document.forms['addcat'].category_parent )
+		options = document.forms['addcat'].category_parent.options;
+
+	addAfter = function( r, settings ) {
+		var name, id;
+
+		name = $("<span>" + $('name', r).text() + "</span>").text();
+		id = $('cat', r).attr('id');
+		options[options.length] = new Option(name, id);
+	}
+
+	delAfter = function( r, settings ) {
+		var id = $('cat', r).attr('id'), o;
+		for ( o = 0; o < options.length; o++ )
+			if ( id == options[o].value )
+				options[o] = null;
+	}
+
+	delBefore = function(s) {
+		if ( 'undefined' != showNotice )
+			return showNotice.warn() ? s : false;
+
+		return s;
+	}
+
+	if ( options )
+		$('#the-list').wpList( { addAfter: addAfter, delBefore: delBefore, delAfter: delAfter } );
+	else
+		$('#the-list').wpList({ delBefore: delBefore });
+
+	$('.delete a[class^="delete"]').live('click', function(){return false;});
+});
Index: /tags/3.1/wp-admin/js/categories.js
===================================================================
--- /tags/3.1/wp-admin/js/categories.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/categories.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(d){var b=false,e,c,a;if(document.forms.addcat.category_parent){b=document.forms.addcat.category_parent.options}e=function(h,g){var f,i;f=d("<span>"+d("name",h).text()+"</span>").text();i=d("cat",h).attr("id");b[b.length]=new Option(f,i)};a=function(g,f){var i=d("cat",g).attr("id"),h;for(h=0;h<b.length;h++){if(i==b[h].value){b[h]=null}}};c=function(f){if("undefined"!=showNotice){return showNotice.warn()?f:false}return f};if(b){d("#the-list").wpList({addAfter:e,delBefore:c,delAfter:a})}else{d("#the-list").wpList({delBefore:c})}d('.delete a[class^="delete"]').live("click",function(){return false})});
Index: /tags/3.1/wp-admin/js/comment.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/comment.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/comment.dev.js	(revision 17487)
@@ -0,0 +1,47 @@
+jQuery(document).ready( function($) {
+
+	var stamp = $('#timestamp').html();
+	$('.edit-timestamp').click(function () {
+		if ($('#timestampdiv').is(":hidden")) {
+			$('#timestampdiv').slideDown("normal");
+			$('.edit-timestamp').hide();
+		}
+		return false;
+	});
+
+	$('.cancel-timestamp').click(function() {
+		$('#timestampdiv').slideUp("normal");
+		$('#mm').val($('#hidden_mm').val());
+		$('#jj').val($('#hidden_jj').val());
+		$('#aa').val($('#hidden_aa').val());
+		$('#hh').val($('#hidden_hh').val());
+		$('#mn').val($('#hidden_mn').val());
+		$('#timestamp').html(stamp);
+		$('.edit-timestamp').show();
+		return false;
+	});
+
+	$('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
+		var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
+			newD = new Date( aa, mm - 1, jj, hh, mn );
+
+		if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) {
+			$('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
+			return false;
+		} else {
+			$('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
+		}
+
+		$('#timestampdiv').slideUp("normal");
+		$('.edit-timestamp').show();
+		$('#timestamp').html(
+			commentL10n.submittedOn + ' <b>' +
+			$( '#mm option[value=' + mm + ']' ).text() + ' ' +
+			jj + ', ' +
+			aa + ' @ ' +
+			hh + ':' +
+			mn + '</b> '
+		);
+		return false;
+	});
+});
Index: /tags/3.1/wp-admin/js/comment.js
===================================================================
--- /tags/3.1/wp-admin/js/comment.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/comment.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(b){var a=b("#timestamp").html();b(".edit-timestamp").click(function(){if(b("#timestampdiv").is(":hidden")){b("#timestampdiv").slideDown("normal");b(".edit-timestamp").hide()}return false});b(".cancel-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b("#mm").val(b("#hidden_mm").val());b("#jj").val(b("#hidden_jj").val());b("#aa").val(b("#hidden_aa").val());b("#hh").val(b("#hidden_hh").val());b("#mn").val(b("#hidden_mn").val());b("#timestamp").html(a);b(".edit-timestamp").show();return false});b(".save-timestamp").click(function(){var g=b("#aa").val(),h=b("#mm").val(),d=b("#jj").val(),c=b("#hh").val(),f=b("#mn").val(),e=new Date(g,h-1,d,c,f);if(e.getFullYear()!=g||(1+e.getMonth())!=h||e.getDate()!=d||e.getMinutes()!=f){b(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{b(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" <b>"+b("#mm option[value="+h+"]").text()+" "+d+", "+g+" @ "+c+":"+f+"</b> ");return false})});
Index: /tags/3.1/wp-admin/js/common.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/common.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/common.dev.js	(revision 17487)
@@ -0,0 +1,334 @@
+var showNotice, adminMenu, columns, validateForm;
+(function($){
+// sidebar admin menu
+adminMenu = {
+	init : function() {
+		var menu = $('#adminmenu');
+
+		$('.wp-menu-toggle', menu).each( function() {
+			var t = $(this), sub = t.siblings('.wp-submenu');
+			if ( sub.length )
+				t.click(function(){ adminMenu.toggle( sub ); });
+			else
+				t.hide();
+		});
+
+		this.favorites();
+
+		$('.separator', menu).click(function(){
+			if ( $('body').hasClass('folded') ) {
+				adminMenu.fold(1);
+				deleteUserSetting( 'mfold' );
+			} else {
+				adminMenu.fold();
+				setUserSetting( 'mfold', 'f' );
+			}
+			return false;
+		});
+
+		if ( $('body').hasClass('folded') )
+			this.fold();
+
+		this.restoreMenuState();
+	},
+
+	restoreMenuState : function() {
+		$('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
+			var v = getUserSetting( 'm'+i );
+			if ( $(e).hasClass('wp-has-current-submenu') )
+				return true; // leave the current parent open
+
+			if ( 'o' == v )
+				$(e).addClass('wp-menu-open');
+			else if ( 'c' == v )
+				$(e).removeClass('wp-menu-open');
+		});
+	},
+
+	toggle : function(el) {
+		el.slideToggle(150, function() {
+			var id = el.parent().toggleClass( 'wp-menu-open' ).attr('id');
+			if ( id ) {
+				$('li.wp-has-submenu', '#adminmenu').each(function(i, e) {
+					if ( id == e.id ) {
+						var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c';
+						setUserSetting( 'm'+i, v );
+					}
+				});
+			}
+		});
+
+		return false;
+	},
+
+	fold : function(off) {
+		if (off) {
+			$('body').removeClass('folded');
+			$('#adminmenu li.wp-has-submenu').unbind();
+		} else {
+			$('body').addClass('folded');
+			$('#adminmenu li.wp-has-submenu').hoverIntent({
+				over: function(e){
+					var m, b, h, o, f;
+					m = $(this).find('.wp-submenu');
+					b = $(this).offset().top + m.height() + 1; // Bottom offset of the menu
+					h = $('#wpwrap').height(); // Height of the entire page
+					o = 60 + b - h;
+					f = $(window).height() + $(window).scrollTop() - 15; // The fold
+					if ( f < (b - o) ) {
+						o = b - f;
+					}
+					if ( o > 1 ) {
+						m.css({'marginTop':'-'+o+'px'});
+					} else if ( m.css('marginTop') ) {
+						m.css({'marginTop':''});
+					}
+					m.addClass('sub-open');
+				},
+				out: function(){ $(this).find('.wp-submenu').removeClass('sub-open').css({'marginTop':''}); },
+				timeout: 220,
+				sensitivity: 8,
+				interval: 100
+			});
+
+		}
+	},
+
+	favorites : function() {
+		$('#favorite-inside').width( $('#favorite-actions').width() - 4 );
+		$('#favorite-toggle, #favorite-inside').bind('mouseenter', function() {
+			$('#favorite-inside').removeClass('slideUp').addClass('slideDown');
+			setTimeout(function() {
+				if ( $('#favorite-inside').hasClass('slideDown') ) {
+					$('#favorite-inside').slideDown(100);
+					$('#favorite-first').addClass('slide-down');
+				}
+			}, 200);
+		}).bind('mouseleave', function() {
+			$('#favorite-inside').removeClass('slideDown').addClass('slideUp');
+			setTimeout(function() {
+				if ( $('#favorite-inside').hasClass('slideUp') ) {
+					$('#favorite-inside').slideUp(100, function() {
+						$('#favorite-first').removeClass('slide-down');
+					});
+				}
+			}, 300);
+		});
+	}
+};
+
+$(document).ready(function(){ adminMenu.init(); });
+
+// show/hide/save table columns
+columns = {
+	init : function() {
+		var that = this;
+		$('.hide-column-tog', '#adv-settings').click( function() {
+			var $t = $(this), column = $t.val();
+			if ( $t.attr('checked') )
+				that.checked(column);
+			else
+				that.unchecked(column);
+
+			columns.saveManageColumnsState();
+		});
+	},
+
+	saveManageColumnsState : function() {
+		var hidden = this.hidden();
+		$.post(ajaxurl, {
+			action: 'hidden-columns',
+			hidden: hidden,
+			screenoptionnonce: $('#screenoptionnonce').val(),
+			page: pagenow
+		});
+	},
+
+	checked : function(column) {
+		$('.column-' + column).show();
+		this.colSpanChange(+1);
+	},
+
+	unchecked : function(column) {
+		$('.column-' + column).hide();
+		this.colSpanChange(-1);
+	},
+
+	hidden : function() {
+		return $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
+	},
+
+	useCheckboxesForHidden : function() {
+		this.hidden = function(){
+			return $('.hide-column-tog').not(':checked').map(function() {
+				var id = this.id;
+				return id.substring( id, id.length - 5 );
+			}).get().join(',');
+		};
+	},
+
+	colSpanChange : function(diff) {
+		var $t = $('table').find('.colspanchange'), n;
+		if ( !$t.length )
+			return;
+		n = parseInt( $t.attr('colspan'), 10 ) + diff;
+		$t.attr('colspan', n.toString());
+	}
+}
+
+$(document).ready(function(){columns.init();});
+
+validateForm = function( form ) {
+	return !$( form ).find('.form-required').filter( function() { return $('input:visible', this).val() == ''; } ).addClass( 'form-invalid' ).find('input:visible').change( function() { $(this).closest('.form-invalid').removeClass( 'form-invalid' ); } ).size();
+}
+
+})(jQuery);
+
+// stub for doing better warnings
+showNotice = {
+	warn : function() {
+		var msg = commonL10n.warnDelete || '';
+		if ( confirm(msg) ) {
+			return true;
+		}
+
+		return false;
+	},
+
+	note : function(text) {
+		alert(text);
+	}
+};
+
+jQuery(document).ready( function($) {
+	var lastClicked = false, checks, first, last, checked, bgx = ( isRtl ? 'left' : 'right' );
+
+	// Move .updated and .error alert boxes. Don't move boxes designed to be inline.
+	$('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2');
+	$('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );
+
+	// screen settings tab
+	$('#show-settings-link').click(function () {
+		if ( ! $('#screen-options-wrap').hasClass('screen-options-open') )
+			$('#contextual-help-link-wrap').css('visibility', 'hidden');
+
+		$('#screen-options-wrap').slideToggle('fast', function(){
+			if ( $(this).hasClass('screen-options-open') ) {
+				$('#show-settings-link').css({'backgroundPosition':'top '+bgx});
+				$('#contextual-help-link-wrap').css('visibility', '');
+				$(this).removeClass('screen-options-open');
+			} else {
+				$('#show-settings-link').css({'backgroundPosition':'bottom '+bgx});
+				$(this).addClass('screen-options-open');
+			}
+		});
+		return false;
+	});
+
+	// help tab
+	$('#contextual-help-link').click(function () {
+		if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') )
+			$('#screen-options-link-wrap').css('visibility', 'hidden');
+
+		$('#contextual-help-wrap').slideToggle('fast', function() {
+			if ( $(this).hasClass('contextual-help-open') ) {
+				$('#contextual-help-link').css({'backgroundPosition':'top '+bgx});
+				$('#screen-options-link-wrap').css('visibility', '');
+				$(this).removeClass('contextual-help-open');
+			} else {
+				$('#contextual-help-link').css({'backgroundPosition':'bottom '+bgx});
+				$(this).addClass('contextual-help-open');
+			}
+		});
+		return false;
+	});
+
+	// check all checkboxes
+	$('tbody').children().children('.check-column').find(':checkbox').click( function(e) {
+		if ( 'undefined' == e.shiftKey ) { return true; }
+		if ( e.shiftKey ) {
+			if ( !lastClicked ) { return true; }
+			checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' );
+			first = checks.index( lastClicked );
+			last = checks.index( this );
+			checked = $(this).attr('checked');
+			if ( 0 < first && 0 < last && first != last ) {
+				checks.slice( first, last ).attr( 'checked', function(){
+					if ( $(this).closest('tr').is(':visible') )
+						return checked ? 'checked' : '';
+
+					return '';
+				});
+			}
+		}
+		lastClicked = this;
+		return true;
+	});
+
+	$('thead, tfoot').find('.check-column :checkbox').click( function(e) {
+		var c = $(this).attr('checked'),
+			kbtoggle = 'undefined' == typeof toggleWithKeyboard ? false : toggleWithKeyboard,
+			toggle = e.shiftKey || kbtoggle;
+
+		$(this).closest( 'table' ).children( 'tbody' ).filter(':visible')
+		.children().children('.check-column').find(':checkbox')
+		.attr('checked', function() {
+			if ( $(this).closest('tr').is(':hidden') )
+				return '';
+			if ( toggle )
+				return $(this).attr( 'checked' ) ? '' : 'checked';
+			else if (c)
+				return 'checked';
+			return '';
+		});
+
+		$(this).closest('table').children('thead,  tfoot').filter(':visible')
+		.children().children('.check-column').find(':checkbox')
+		.attr('checked', function() {
+			if ( toggle )
+				return '';
+			else if (c)
+				return 'checked';
+			return '';
+		});
+	});
+
+	$('#default-password-nag-no').click( function() {
+		setUserSetting('default_password_nag', 'hide');
+		$('div.default-password-nag').hide();
+		return false;
+	});
+
+	// tab in textareas
+	$('#newcontent').keydown(function(e) {
+		if ( e.keyCode != 9 )
+			return true;
+
+		var el = e.target, selStart = el.selectionStart, selEnd = el.selectionEnd, val = el.value, scroll, sel;
+
+		try {
+			this.lastKey = 9; // not a standard DOM property, lastKey is to help stop Opera tab event.  See blur handler below.
+		} catch(err) {}
+
+		if ( document.selection ) {
+			el.focus();
+			sel = document.selection.createRange();
+			sel.text = '\t';
+		} else if ( selStart >= 0 ) {
+			scroll = this.scrollTop;
+			el.value = val.substring(0, selStart).concat('\t', val.substring(selEnd) );
+			el.selectionStart = el.selectionEnd = selStart + 1;
+			this.scrollTop = scroll;
+		}
+
+		if ( e.stopPropagation )
+			e.stopPropagation();
+		if ( e.preventDefault )
+			e.preventDefault();
+	});
+
+	$('#newcontent').blur(function(e) {
+		if ( this.lastKey && 9 == this.lastKey )
+			this.focus();
+	});
+});
Index: /tags/3.1/wp-admin/js/common.js
===================================================================
--- /tags/3.1/wp-admin/js/common.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/common.js	(revision 17487)
@@ -0,0 +1,1 @@
+var showNotice,adminMenu,columns,validateForm;(function(a){adminMenu={init:function(){var b=a("#adminmenu");a(".wp-menu-toggle",b).each(function(){var c=a(this),d=c.siblings(".wp-submenu");if(d.length){c.click(function(){adminMenu.toggle(d)})}else{c.hide()}});this.favorites();a(".separator",b).click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("li.wp-has-submenu","#adminmenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){var c=b.parent().toggleClass("wp-menu-open").attr("id");if(c){a("li.wp-has-submenu","#adminmenu").each(function(f,g){if(c==g.id){var d=a(g).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+f,d)}})}});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=a(this).offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a(window).scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)}).bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){var b=this;a(".hide-column-tog","#adv-settings").click(function(){var d=a(this),c=d.val();if(d.attr("checked")){b.checked(c)}else{b.unchecked(c)}columns.saveManageColumnsState()})},saveManageColumnsState:function(){var b=this.hidden();a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})},checked:function(b){a(".column-"+b).show();this.colSpanChange(+1)},unchecked:function(b){a(".column-"+b).hide();this.colSpanChange(-1)},hidden:function(){return a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",")},useCheckboxesForHidden:function(){this.hidden=function(){return a(".hide-column-tog").not(":checked").map(function(){var b=this.id;return b.substring(b,b.length-5)}).get().join(",")}},colSpanChange:function(b){var d=a("table").find(".colspanchange"),c;if(!d.length){return}c=parseInt(d.attr("colspan"),10)+b;d.attr("colspan",c.toString())}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").find("input:visible").change(function(){a(this).closest(".form-invalid").removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(e){var g=false,b,f,d,c,a=(isRtl?"left":"right");e("div.wrap h2:first").nextAll("div.updated, div.error").addClass("below-h2");e("div.updated, div.error").not(".below-h2, .inline").insertAfter(e("div.wrap h2:first"));e("#show-settings-link").click(function(){if(!e("#screen-options-wrap").hasClass("screen-options-open")){e("#contextual-help-link-wrap").css("visibility","hidden")}e("#screen-options-wrap").slideToggle("fast",function(){if(e(this).hasClass("screen-options-open")){e("#show-settings-link").css({backgroundPosition:"top "+a});e("#contextual-help-link-wrap").css("visibility","");e(this).removeClass("screen-options-open")}else{e("#show-settings-link").css({backgroundPosition:"bottom "+a});e(this).addClass("screen-options-open")}});return false});e("#contextual-help-link").click(function(){if(!e("#contextual-help-wrap").hasClass("contextual-help-open")){e("#screen-options-link-wrap").css("visibility","hidden")}e("#contextual-help-wrap").slideToggle("fast",function(){if(e(this).hasClass("contextual-help-open")){e("#contextual-help-link").css({backgroundPosition:"top "+a});e("#screen-options-link-wrap").css("visibility","");e(this).removeClass("contextual-help-open")}else{e("#contextual-help-link").css({backgroundPosition:"bottom "+a});e(this).addClass("contextual-help-open")}});return false});e("tbody").children().children(".check-column").find(":checkbox").click(function(h){if("undefined"==h.shiftKey){return true}if(h.shiftKey){if(!g){return true}b=e(g).closest("form").find(":checkbox");f=b.index(g);d=b.index(this);c=e(this).attr("checked");if(0<f&&0<d&&f!=d){b.slice(f,d).attr("checked",function(){if(e(this).closest("tr").is(":visible")){return c?"checked":""}return""})}}g=this;return true});e("thead, tfoot").find(".check-column :checkbox").click(function(j){var k=e(this).attr("checked"),i="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,h=j.shiftKey||i;e(this).closest("table").children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").attr("checked",function(){if(e(this).closest("tr").is(":hidden")){return""}if(h){return e(this).attr("checked")?"":"checked"}else{if(k){return"checked"}}return""});e(this).closest("table").children("thead,  tfoot").filter(":visible").children().children(".check-column").find(":checkbox").attr("checked",function(){if(h){return""}else{if(k){return"checked"}}return""})});e("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");e("div.default-password-nag").hide();return false});e("#newcontent").keydown(function(m){if(m.keyCode!=9){return true}var j=m.target,o=j.selectionStart,i=j.selectionEnd,n=j.value,h,l;try{this.lastKey=9}catch(k){}if(document.selection){j.focus();l=document.selection.createRange();l.text="\t"}else{if(o>=0){h=this.scrollTop;j.value=n.substring(0,o).concat("\t",n.substring(i));j.selectionStart=j.selectionEnd=o+1;this.scrollTop=h}}if(m.stopPropagation){m.stopPropagation()}if(m.preventDefault){m.preventDefault()}});e("#newcontent").blur(function(h){if(this.lastKey&&9==this.lastKey){this.focus()}})});
Index: /tags/3.1/wp-admin/js/custom-background.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/custom-background.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/custom-background.dev.js	(revision 17487)
@@ -0,0 +1,46 @@
+var farbtastic;
+
+function pickColor(color) {
+	farbtastic.setColor(color);
+	jQuery('#background-color').val(color);
+	jQuery('#custom-background-image').css('background-color', color);
+}
+
+jQuery(document).ready(function() {
+	jQuery('#pickcolor').click(function() {
+		jQuery('#colorPickerDiv').show();
+		return false;
+	});
+
+	jQuery('#background-color').keyup(function() {
+		var _hex = jQuery('#background-color').val(), hex = _hex;
+		if ( hex.charAt(0) != '#' )
+			hex = '#' + hex;
+		hex = hex.replace(/[^#a-fA-F0-9]+/, '');
+		if ( hex != _hex )
+			jQuery('#background-color').val(hex);
+		if ( hex.length == 4 || hex.length == 7 )
+			pickColor( hex );
+	});
+
+	jQuery('input[name="background-position-x"]').change(function() {
+		jQuery('#custom-background-image').css('background-position', jQuery(this).val() + ' top');
+	});
+
+	jQuery('input[name="background-repeat"]').change(function() {
+		jQuery('#custom-background-image').css('background-repeat', jQuery(this).val());
+	});
+
+	farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) {
+		pickColor(color);
+	});
+	pickColor(jQuery('#background-color').val());
+
+	jQuery(document).mousedown(function(){
+		jQuery('#colorPickerDiv').each(function(){
+			var display = jQuery(this).css('display');
+			if ( display == 'block' )
+				jQuery(this).fadeOut(2);
+		});
+	});
+});
Index: /tags/3.1/wp-admin/js/custom-background.js
===================================================================
--- /tags/3.1/wp-admin/js/custom-background.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/custom-background.js	(revision 17487)
@@ -0,0 +1,1 @@
+var farbtastic;function pickColor(a){farbtastic.setColor(a);jQuery("#background-color").val(a);jQuery("#custom-background-image").css("background-color",a)}jQuery(document).ready(function(){jQuery("#pickcolor").click(function(){jQuery("#colorPickerDiv").show();return false});jQuery("#background-color").keyup(function(){var b=jQuery("#background-color").val(),a=b;if(a.charAt(0)!="#"){a="#"+a}a=a.replace(/[^#a-fA-F0-9]+/,"");if(a!=b){jQuery("#background-color").val(a)}if(a.length==4||a.length==7){pickColor(a)}});jQuery('input[name="background-position-x"]').change(function(){jQuery("#custom-background-image").css("background-position",jQuery(this).val()+" top")});jQuery('input[name="background-repeat"]').change(function(){jQuery("#custom-background-image").css("background-repeat",jQuery(this).val())});farbtastic=jQuery.farbtastic("#colorPickerDiv",function(a){pickColor(a)});pickColor(jQuery("#background-color").val());jQuery(document).mousedown(function(){jQuery("#colorPickerDiv").each(function(){var a=jQuery(this).css("display");if(a=="block"){jQuery(this).fadeOut(2)}})})});
Index: /tags/3.1/wp-admin/js/custom-fields.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/custom-fields.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/custom-fields.dev.js	(revision 17487)
@@ -0,0 +1,34 @@
+jQuery(document).ready( function($) {
+	var before, addBefore, addAfter, delBefore;
+
+	before = function() {
+		var nonce = $('#newmeta [name=_ajax_nonce]').val(), postId = $('#post_ID').val();
+		if ( !nonce || !postId ) { return false; }
+		return [nonce,postId];
+	}
+
+	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;
+	};
+
+	addAfter = function( r, s ) {
+		var postId = $('postid', r).text(), h;
+		if ( !postId ) { return; }
+		$('#post_ID').attr( 'name', 'post_ID' ).val( postId );
+		h = $('#hiddenaction');
+		if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); }
+	};
+
+	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' );
+} );
Index: /tags/3.1/wp-admin/js/custom-fields.js
===================================================================
--- /tags/3.1/wp-admin/js/custom-fields.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/custom-fields.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(d){var c,b,e,a;c=function(){var g=d("#newmeta [name=_ajax_nonce]").val(),f=d("#post_ID").val();if(!g||!f){return false}return[g,f]};b=function(g){var f=c();if(!f){return false}g.data=g.data.replace(/_ajax_nonce=[a-f0-9]+/,"_ajax_nonce="+f[0])+"&post_id="+f[1];return g};e=function(j,i){var f=d("postid",j).text(),g;if(!f){return}d("#post_ID").attr("name","post_ID").val(f);g=d("#hiddenaction");if("post"==g.val()){g.val("postajaxpost")}};a=function(g){var f=c();if(!f){return false}g.data._ajax_nonce=f[0];g.data.post_id=f[1];return g};d("#the-list").wpList({addBefore:b,addAfter:e,delBefore:a}).find(".updatemeta, .deletemeta").attr("type","button")});
Index: /tags/3.1/wp-admin/js/dashboard.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/dashboard.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/dashboard.dev.js	(revision 17487)
@@ -0,0 +1,70 @@
+var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
+
+jQuery(document).ready( function($) {
+	// These widgets are sometimes populated via ajax
+	ajaxWidgets = [
+		'dashboard_incoming_links',
+		'dashboard_primary',
+		'dashboard_secondary',
+		'dashboard_plugins',
+		'dashboard_quick_press'
+	];
+
+	ajaxPopulateWidgets = function(el) {
+		show = function(id, i) {
+			var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
+			if ( e.length ) {
+				p = e.parent();
+				setTimeout( function(){
+					p.load( ajaxurl.replace( '/admin-ajax.php', '' ) + '/index-extra.php?jax=' + id, '', function() {
+						p.hide().slideDown('normal', function(){
+							$(this).css('display', '');
+							if ( 'dashboard_quick_press' == id )
+								quickPressLoad();
+						});
+					});
+				}, i * 500 );
+			}
+		}
+		if ( el ) {
+			el = el.toString();
+			if ( $.inArray(el, ajaxWidgets) != -1 )
+				show(el, 0);
+		} else {
+			$.each( ajaxWidgets, function(i) {
+				show(this, i);
+			});
+		}
+	};
+	ajaxPopulateWidgets();
+
+	postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
+
+	/* QuickPress */
+	quickPressLoad = function() {
+		var act = $('#quickpost-action'), t;
+		t = $('#quick-press').submit( function() {
+			$('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'visible');
+			$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','disabled');
+
+			if ( 'post' == act.val() ) {
+				act.val( 'post-quickpress-publish' );
+			}
+
+			$('#dashboard_quick_press div.inside').load( t.attr( 'action' ), t.serializeArray(), function() {
+				$('#dashboard_quick_press #publishing-action img.waiting').css('visibility', 'hidden');
+				$('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr('disabled','');
+				$('#dashboard_quick_press ul').next('p').remove();
+				$('#dashboard_quick_press ul').find('li').each( function() {
+					$('#dashboard_recent_drafts ul').prepend( this );
+				} ).end().remove();
+				quickPressLoad();
+			} );
+			return false;
+		} );
+
+		$('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
+
+	};
+
+} );
Index: /tags/3.1/wp-admin/js/dashboard.js
===================================================================
--- /tags/3.1/wp-admin/js/dashboard.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/dashboard.js	(revision 17487)
@@ -0,0 +1,1 @@
+var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins","dashboard_quick_press"];ajaxPopulateWidgets=function(b){show=function(g,c){var f,d=a("#"+g+" div.inside:visible").find(".widget-loading");if(d.length){f=d.parent();setTimeout(function(){f.load(ajaxurl.replace("/admin-ajax.php","")+"/index-extra.php?jax="+g,"",function(){f.hide().slideDown("normal",function(){a(this).css("display","");if("dashboard_quick_press"==g){quickPressLoad()}})})},c*500)}};if(b){b=b.toString();if(a.inArray(b,ajaxWidgets)!=-1){show(b,0)}}else{a.each(ajaxWidgets,function(c){show(this,c)})}};ajaxPopulateWidgets();postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var b=a("#quickpost-action"),c;c=a("#quick-press").submit(function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","visible");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==b.val()){b.val("post-quickpress-publish")}a("#dashboard_quick_press div.inside").load(c.attr("action"),c.serializeArray(),function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","hidden");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");a("#dashboard_quick_press ul").next("p").remove();a("#dashboard_quick_press ul").find("li").each(function(){a("#dashboard_recent_drafts ul").prepend(this)}).end().remove();quickPressLoad()});return false});a("#publish").click(function(){b.val("post-quickpress-publish")})}});
Index: /tags/3.1/wp-admin/js/edit-comments.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/edit-comments.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/edit-comments.dev.js	(revision 17487)
@@ -0,0 +1,555 @@
+var theList, theExtraList, toggleWithKeyboard = false;
+(function($) {
+
+setCommentsList = function() {
+	var totalInput, perPageInput, pageInput, lastConfidentTime = 0, dimAfter, delBefore, updateTotalCount, delAfter;
+
+	totalInput = $('input[name="_total"]', '#comments-form');
+	perPageInput = $('input[name="_per_page"]', '#comments-form');
+	pageInput = $('input[name="_page"]', '#comments-form');
+
+	dimAfter = function( r, settings ) {
+		var c = $('#' + settings.element);
+
+		if ( c.is('.unapproved') )
+			c.find('div.comment_status').html('0')
+		else
+			c.find('div.comment_status').html('1')
+
+		$('span.pending-count').each( function() {
+			var a = $(this), n, dif;
+			n = a.html().replace(/[^0-9]+/g, '');
+			n = parseInt(n,10);
+			if ( isNaN(n) ) return;
+			dif = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
+			n = n + dif;
+			if ( n < 0 ) { n = 0; }
+			a.closest('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
+			updateCount(a, n);
+			dashboardTotals();
+		});
+	};
+
+	// Send current total, page, per_page and url
+	delBefore = function( settings, list ) {
+		var cl = $(settings.target).attr('className'), id, el, n, h, a, author, action = false;
+
+		settings.data._total = totalInput.val() || 0;
+		settings.data._per_page = perPageInput.val() || 0;
+		settings.data._page = pageInput.val() || 0;
+		settings.data._url = document.location.href;
+		settings.data.comment_status = $('input[name=comment_status]', '#comments-form').val();
+
+		if ( cl.indexOf(':trash=1') != -1 )
+			action = 'trash';
+		else if ( cl.indexOf(':spam=1') != -1 )
+			action = 'spam';
+
+		if ( action ) {
+			id = cl.replace(/.*?comment-([0-9]+).*/, '$1');
+			el = $('#comment-' + id);
+			note = $('#' + action + '-undo-holder').html();
+
+			el.find('.check-column :checkbox').attr('checked', ''); // Uncheck the row so as not to be affected by Bulk Edits.
+
+			if ( el.siblings('#replyrow').length && commentReply.cid == id )
+				commentReply.close();
+
+			if ( el.is('tr') ) {
+				n = el.children(':visible').length;
+				author = $('.author strong', el).text();
+				h = $('<tr id="undo-' + id + '" class="undo un' + action + '" style="display:none;"><td colspan="' + n + '">' + note + '</td></tr>');
+			} else {
+				author = $('.comment-author', el).text();
+				h = $('<div id="undo-' + id + '" style="display:none;" class="undo un' + action + '">' + note + '</div>');
+			}
+
+			el.before(h);
+
+			$('strong', '#undo-' + id).text(author + ' ');
+			a = $('.undo a', '#undo-' + id);
+			a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce);
+			a.attr('className', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1 vim-z vim-destructive');
+			$('.avatar', el).clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
+
+			a.click(function(){
+				list.wpList.del(this);
+				$('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
+					$(this).remove();
+					$('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show() });
+				});
+				return false;
+			});
+		}
+
+		return settings;
+	};
+
+	// Updates the current total (as displayed visibly)
+	updateTotalCount = function( total, time, setConfidentTime ) {
+		if ( time < lastConfidentTime )
+			return;
+
+		if ( setConfidentTime )
+			lastConfidentTime = time;
+
+		totalInput.val( total.toString() );
+		$('span.total-type-count').each( function() {
+			updateCount( $(this), total );
+		});
+	};
+
+	function dashboardTotals(n) {
+		var dash = $('#dashboard_right_now'), total, appr, totalN, apprN;
+
+		n = n || 0;
+		if ( isNaN(n) || !dash.length )
+			return;
+
+		total = $('span.total-count', dash);
+		appr = $('span.approved-count', dash);
+		totalN = getCount(total);
+
+		totalN = totalN + n;
+		apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
+		updateCount(total, totalN);
+		updateCount(appr, apprN);
+
+	}
+
+	function getCount(el) {
+		var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
+		if ( isNaN(n) )
+			return 0;
+		return n;
+	}
+
+	function updateCount(el, n) {
+		var n1 = '';
+		if ( isNaN(n) )
+			return;
+		n = n < 1 ? '0' : n.toString();
+		if ( n.length > 3 ) {
+			while ( n.length > 3 ) {
+				n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
+				n = n.substr(0, n.length - 3);
+			}
+			n = n + n1;
+		}
+		el.html(n);
+	}
+
+	// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
+	delAfter = function( r, settings ) {
+		var total, pageLinks, N, untrash = $(settings.target).parent().is('span.untrash'), unspam = $(settings.target).parent().is('span.unspam'), spam, trash;
+
+		function getUpdate(s) {
+			if ( $(settings.target).parent().is('span.' + s) )
+				return 1;
+			else if ( $('#' + settings.element).is('.' + s) )
+				return -1;
+
+			return 0;
+		}
+		spam = getUpdate('spam');
+		trash = getUpdate('trash');
+
+		if ( untrash )
+			trash = -1;
+		if ( unspam )
+			spam = -1;
+
+		$('span.pending-count').each( function() {
+			var a = $(this), n = getCount(a), unapproved = $('#' + settings.element).is('.unapproved');
+
+			if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
+				n = n + 1;
+			} else if ( unapproved ) { // we deleted a formerly unapproved comment
+				n = n - 1;
+			}
+			if ( n < 0 ) { n = 0; }
+			a.closest('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
+			updateCount(a, n);
+			dashboardTotals();
+		});
+
+		$('span.spam-count').each( function() {
+			var a = $(this), n = getCount(a) + spam;
+			updateCount(a, n);
+		});
+
+		$('span.trash-count').each( function() {
+			var a = $(this), n = getCount(a) + trash;
+			updateCount(a, n);
+		});
+
+		if ( $('#dashboard_right_now').length ) {
+			N = trash ? -1 * trash : 0;
+			dashboardTotals(N);
+		} else {
+			total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0;
+			total = total - spam - trash;
+			if ( total < 0 )
+				total = 0;
+
+			if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
+				total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || '';
+				if ( total_items_i18n ) {
+					$('.displaying-num').text( total_items_i18n );
+					$('.total-pages').text( settings.parsed.responses[0].supplemental.total_pages_i18n );
+					$('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', settings.parsed.responses[0].supplemental.total_pages == $('.current-page').val());
+				}
+				updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );
+			} else {
+				updateTotalCount( total, r, false );
+			}
+		}
+
+
+		if ( ! theExtraList || theExtraList.size() == 0 || theExtraList.children().size() == 0 || untrash || unspam ) {
+			return;
+		}
+
+		theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
+
+		refillTheExtraList();
+	};
+
+	var refillTheExtraList = function(ev) {
+		// var args = $.query.get(), total_pages = listTable.get_total_pages(), per_page = $('input[name=_per_page]', '#comments-form').val(), r;
+		var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name=_per_page]', '#comments-form').val(), r;
+
+		if (! args.paged)
+			args.paged = 1;
+
+		if (args.paged > total_pages) {
+			return;
+		}
+
+		if (ev) {
+			theExtraList.empty();
+			args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php
+		} else {
+			args.number = 1;
+			args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list
+		}
+
+		args.no_placeholder = true;
+
+		args.paged ++;
+
+		// $.query.get() needs some correction to be sent into an ajax request
+		if ( true === args.comment_type )
+			args.comment_type = '';
+
+		args = $.extend(args, {
+			'action': 'fetch-list',
+			'list_args': list_args,
+			'_ajax_fetch_list_nonce': $('#_ajax_fetch_list_nonce').val()
+		});
+
+		$.ajax({
+			url: ajaxurl,
+			global: false,
+			dataType: 'json',
+			data: args,
+			success: function(response) {
+				theExtraList.get(0).wpList.add( response.rows );
+			}
+		});
+	};
+
+	theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
+	theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )
+		.bind('wpListDelEnd', function(e, s){
+			var id = s.element.replace(/[^0-9]+/g, '');
+
+			if ( s.target.className.indexOf(':trash=1') != -1 || s.target.className.indexOf(':spam=1') != -1 )
+				$('#undo-' + id).fadeIn(300, function(){ $(this).show() });
+		});
+	// $(listTable).bind('changePage', refillTheExtraList);
+};
+
+commentReply = {
+	cid : '',
+	act : '',
+
+	init : function() {
+		var row = $('#replyrow');
+
+		$('a.cancel', row).click(function() { return commentReply.revert(); });
+		$('a.save', row).click(function() { return commentReply.send(); });
+		$('input#author, input#author-email, input#author-url', row).keypress(function(e){
+			if ( e.which == 13 ) {
+				commentReply.send();
+				e.preventDefault();
+				return false;
+			}
+		});
+
+		// add events
+		$('#the-comment-list .column-comment > p').dblclick(function(){
+			commentReply.toggle($(this).parent());
+		});
+
+		$('#doaction, #doaction2, #post-query-submit').click(function(e){
+			if ( $('#the-comment-list #replyrow').length > 0 )
+				commentReply.close();
+		});
+
+		this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || '';
+
+		/* $(listTable).bind('beforeChangePage', function(){
+			commentReply.close();
+		}); */
+	},
+
+	addEvents : function(r) {
+		r.each(function() {
+			$(this).find('.column-comment > p').dblclick(function(){
+				commentReply.toggle($(this).parent());
+			});
+		});
+	},
+
+	toggle : function(el) {
+		if ( $(el).css('display') != 'none' )
+			$(el).find('a.vim-q').click();
+	},
+
+	revert : function() {
+
+		if ( $('#the-comment-list #replyrow').length < 1 )
+			return false;
+
+		$('#replyrow').fadeOut('fast', function(){
+			commentReply.close();
+		});
+
+		return false;
+	},
+
+	close : function() {
+		var c;
+
+		if ( this.cid ) {
+			c = $('#comment-' + this.cid);
+
+			if ( this.act == 'edit-comment' )
+				c.fadeIn(300, function(){ c.show() }).css('backgroundColor', '');
+
+			$('#replyrow').hide();
+			$('#com-reply').append( $('#replyrow') );
+			$('#replycontent').val('');
+			$('input', '#edithead').val('');
+			$('.error', '#replysubmit').html('').hide();
+			$('.waiting', '#replysubmit').hide();
+
+			if ( $.browser.msie )
+				$('#replycontainer, #replycontent').css('height', '120px');
+			else
+				$('#replycontainer').resizable('destroy').css('height', '120px');
+
+			this.cid = '';
+		}
+	},
+
+	open : function(id, p, a) {
+		var t = this, editRow, rowData, act, h, c = $('#comment-' + id);
+		t.close();
+		t.cid = id;
+
+		editRow = $('#replyrow');
+		rowData = $('#inline-'+id);
+		act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment';
+
+		$('#action', editRow).val(act);
+		$('#comment_post_ID', editRow).val(p);
+		$('#comment_ID', editRow).val(id);
+
+		if ( a == 'edit' ) {
+			$('#author', editRow).val( $('div.author', rowData).text() );
+			$('#author-email', editRow).val( $('div.author-email', rowData).text() );
+			$('#author-url', editRow).val( $('div.author-url', rowData).text() );
+			$('#status', editRow).val( $('div.comment_status', rowData).text() );
+			$('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
+			$('#edithead, #savebtn', editRow).show();
+			$('#replyhead, #replybtn', editRow).hide();
+
+			h = c.height();
+			if ( h > 220 )
+				if ( $.browser.msie )
+					$('#replycontainer, #replycontent', editRow).height(h-105);
+				else
+					$('#replycontainer', editRow).height(h-105);
+
+			c.after( editRow ).fadeOut('fast', function(){
+				$('#replyrow').fadeIn(300, function(){ $(this).show() });
+			});
+		} else {
+			$('#edithead, #savebtn', editRow).hide();
+			$('#replyhead, #replybtn', editRow).show();
+			c.after(editRow);
+			$('#replyrow').fadeIn(300, function(){ $(this).show() });
+		}
+
+		if ( ! $.browser.msie )
+			$('#replycontainer').resizable({
+				handles : 's',
+				axis : 'y',
+				minHeight : 80,
+				stop : function() {
+					$('#replycontainer').width('auto');
+				}
+			});
+
+		setTimeout(function() {
+			var rtop, rbottom, scrollTop, vp, scrollBottom;
+
+			rtop = $('#replyrow').offset().top;
+			rbottom = rtop + $('#replyrow').height();
+			scrollTop = window.pageYOffset || document.documentElement.scrollTop;
+			vp = document.documentElement.clientHeight || self.innerHeight || 0;
+			scrollBottom = scrollTop + vp;
+
+			if ( scrollBottom - 20 < rbottom )
+				window.scroll(0, rbottom - vp + 35);
+			else if ( rtop - 20 < scrollTop )
+				window.scroll(0, rtop - 35);
+
+			$('#replycontent').focus().keyup(function(e){
+				if ( e.which == 27 )
+					commentReply.revert(); // close on Escape
+			});
+		}, 600);
+
+		return false;
+	},
+
+	send : function() {
+		var post = {};
+
+		$('#replysubmit .error').hide();
+		$('#replysubmit .waiting').show();
+
+		$('#replyrow input').each(function() {
+			post[ $(this).attr('name') ] = $(this).val();
+		});
+
+		post.content = $('#replycontent').val();
+		post.id = post.comment_post_ID;
+		post.comments_listing = this.comments_listing;
+		post.p = $('[name=p]').val();
+
+		$.ajax({
+			type : 'POST',
+			url : ajaxurl,
+			data : post,
+			success : function(x) { commentReply.show(x); },
+			error : function(r) { commentReply.error(r); }
+		});
+
+		return false;
+	},
+
+	show : function(xml) {
+		var r, c, id, bg;
+
+		if ( typeof(xml) == 'string' ) {
+			this.error({'responseText': xml});
+			return false;
+		}
+
+		r = wpAjax.parseAjaxResponse(xml);
+		if ( r.errors ) {
+			this.error({'responseText': wpAjax.broken});
+			return false;
+		}
+
+		r = r.responses[0];
+		c = r.data;
+		id = '#comment-' + r.id;
+		if ( 'edit-comment' == this.act )
+			$(id).remove();
+
+		$(c).hide()
+		$('#replyrow').after(c);
+
+		this.revert();
+		this.addEvents($(id));
+		bg = $(id).hasClass('unapproved') ? '#ffffe0' : '#fff';
+
+		$(id)
+			.animate( { 'backgroundColor':'#CCEEBB' }, 600 )
+			.animate( { 'backgroundColor': bg }, 600 );
+
+		// $.fn.wpList.process($(id));
+	},
+
+	error : function(r) {
+		var er = r.statusText;
+
+		$('#replysubmit .waiting').hide();
+
+		if ( r.responseText )
+			er = r.responseText.replace( /<.[^<>]*?>/g, '' );
+
+		if ( er )
+			$('#replysubmit .error').html(er).show();
+
+	}
+};
+
+$(document).ready(function(){
+	var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk;
+
+	setCommentsList();
+	commentReply.init();
+	$(document).delegate('span.delete a.delete', 'click', function(){return false;});
+
+	if ( typeof QTags != 'undefined' )
+		ed_reply = new QTags('ed_reply', 'replycontent', 'replycontainer', 'more');
+
+	if ( typeof $.table_hotkeys != 'undefined' ) {
+		make_hotkeys_redirect = function(which) {
+			return function() {
+				var first_last, l;
+
+				first_last = 'next' == which? 'first' : 'last';
+				l = $('.tablenav-pages .'+which+'-page:not(.disabled)');
+				if (l.length)
+					window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
+			}
+		};
+
+		edit_comment = function(event, current_row) {
+			window.location = $('span.edit a', current_row).attr('href');
+		};
+
+		toggle_all = function() {
+			toggleWithKeyboard = true;
+			$('input:checkbox', '#cb').click().attr('checked', '');
+			toggleWithKeyboard = false;
+		};
+
+		make_bulk = function(value) {
+			return function() {
+				var scope = $('select[name="action"]');
+				$('option[value='+value+']', scope).attr('selected', 'selected');
+				$('#doaction').click();
+			}
+		};
+
+		$.table_hotkeys(
+			$('table.widefat'),
+			['a', 'u', 's', 'd', 'r', 'q', 'z', ['e', edit_comment], ['shift+x', toggle_all],
+			['shift+a', make_bulk('approve')], ['shift+s', make_bulk('spam')],
+			['shift+d', make_bulk('delete')], ['shift+t', make_bulk('trash')],
+			['shift+z', make_bulk('untrash')], ['shift+u', make_bulk('unapprove')]],
+			{ highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
+			prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next') }
+		);
+	}
+});
+
+})(jQuery);
Index: /tags/3.1/wp-admin/js/edit-comments.js
===================================================================
--- /tags/3.1/wp-admin/js/edit-comments.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/edit-comments.js	(revision 17487)
@@ -0,0 +1,1 @@
+var theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var d,f,i,m=0,h,j,e,l;d=a('input[name="_total"]',"#comments-form");f=a('input[name="_per_page"]',"#comments-form");i=a('input[name="_page"]',"#comments-form");h=function(o,n){var p=a("#"+n.element);if(p.is(".unapproved")){p.find("div.comment_status").html("0")}else{p.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var q=a(this),s,r;s=q.html().replace(/[^0-9]+/g,"");s=parseInt(s,10);if(isNaN(s)){return}r=a("#"+n.element).is("."+n.dimClass)?1:-1;s=s+r;if(s<0){s=0}q.closest("#awaiting-mod")[0==s?"addClass":"removeClass"]("count-0");g(q,s);k()})};j=function(r,v){var x=a(r.target).attr("className"),o,p,q,u,w,t,s=false;r.data._total=d.val()||0;r.data._per_page=f.val()||0;r.data._page=i.val()||0;r.data._url=document.location.href;r.data.comment_status=a("input[name=comment_status]","#comments-form").val();if(x.indexOf(":trash=1")!=-1){s="trash"}else{if(x.indexOf(":spam=1")!=-1){s="spam"}}if(s){o=x.replace(/.*?comment-([0-9]+).*/,"$1");p=a("#comment-"+o);note=a("#"+s+"-undo-holder").html();p.find(".check-column :checkbox").attr("checked","");if(p.siblings("#replyrow").length&&commentReply.cid==o){commentReply.close()}if(p.is("tr")){q=p.children(":visible").length;t=a(".author strong",p).text();u=a('<tr id="undo-'+o+'" class="undo un'+s+'" style="display:none;"><td colspan="'+q+'">'+note+"</td></tr>")}else{t=a(".comment-author",p).text();u=a('<div id="undo-'+o+'" style="display:none;" class="undo un'+s+'">'+note+"</div>")}p.before(u);a("strong","#undo-"+o).text(t+" ");w=a(".undo a","#undo-"+o);w.attr("href","comment.php?action=un"+s+"comment&c="+o+"&_wpnonce="+r.data._ajax_nonce);w.attr("className","delete:the-comment-list:comment-"+o+"::un"+s+"=1 vim-z vim-destructive");a(".avatar",p).clone().prependTo("#undo-"+o+" ."+s+"-undo-inside");w.click(function(){v.wpList.del(this);a("#undo-"+o).css({backgroundColor:"#ceb"}).fadeOut(350,function(){a(this).remove();a("#comment-"+o).css("backgroundColor","").fadeIn(300,function(){a(this).show()})});return false})}return r};e=function(n,o,p){if(o<m){return}if(p){m=o}d.val(n.toString());a("span.total-type-count").each(function(){g(a(this),n)})};function k(t){var s=a("#dashboard_right_now"),p,r,q,o;t=t||0;if(isNaN(t)||!s.length){return}p=a("span.total-count",s);r=a("span.approved-count",s);q=c(p);q=q+t;o=q-c(a("span.pending-count",s))-c(a("span.spam-count",s));g(p,q);g(r,o)}function c(o){var p=parseInt(o.html().replace(/[^0-9]+/g,""),10);if(isNaN(p)){return 0}return p}function g(p,q){var o="";if(isNaN(q)){return}q=q<1?"0":q.toString();if(q.length>3){while(q.length>3){o=thousandsSeparator+q.substr(q.length-3)+o;q=q.substr(0,q.length-3)}q=q+o}p.html(q)}l=function(n,p){var u,q,s,w=a(p.target).parent().is("span.untrash"),o=a(p.target).parent().is("span.unspam"),v,t;function x(r){if(a(p.target).parent().is("span."+r)){return 1}else{if(a("#"+p.element).is("."+r)){return -1}}return 0}v=x("spam");t=x("trash");if(w){t=-1}if(o){v=-1}a("span.pending-count").each(function(){var r=a(this),z=c(r),y=a("#"+p.element).is(".unapproved");if(a(p.target).parent().is("span.unapprove")||((w||o)&&y)){z=z+1}else{if(y){z=z-1}}if(z<0){z=0}r.closest("#awaiting-mod")[0==z?"addClass":"removeClass"]("count-0");g(r,z);k()});a("span.spam-count").each(function(){var r=a(this),y=c(r)+v;g(r,y)});a("span.trash-count").each(function(){var r=a(this),y=c(r)+t;g(r,y)});if(a("#dashboard_right_now").length){s=t?-1*t:0;k(s)}else{u=d.val()?parseInt(d.val(),10):0;u=u-v-t;if(u<0){u=0}if(("object"==typeof n)&&m<p.parsed.responses[0].supplemental.time){total_items_i18n=p.parsed.responses[0].supplemental.total_items_i18n||"";if(total_items_i18n){a(".displaying-num").text(total_items_i18n);a(".total-pages").text(p.parsed.responses[0].supplemental.total_pages_i18n);a(".tablenav-pages").find(".next-page, .last-page").toggleClass("disabled",p.parsed.responses[0].supplemental.total_pages==a(".current-page").val())}e(u,p.parsed.responses[0].supplemental.time,true)}else{e(u,n,false)}}if(!theExtraList||theExtraList.size()==0||theExtraList.children().size()==0||w||o){return}theList.get(0).wpList.add(theExtraList.children(":eq(0)").remove().clone());b()};var b=function(s){var o=a.query.get(),n=a(".total-pages").text(),p=a("input[name=_per_page]","#comments-form").val(),q;if(!o.paged){o.paged=1}if(o.paged>n){return}if(s){theExtraList.empty();o.number=Math.min(8,p)}else{o.number=1;o.offset=Math.min(8,p)-1}o.no_placeholder=true;o.paged++;if(true===o.comment_type){o.comment_type=""}o=a.extend(o,{action:"fetch-list",list_args:list_args,_ajax_fetch_list_nonce:a("#_ajax_fetch_list_nonce").val()});a.ajax({url:ajaxurl,global:false,dataType:"json",data:o,success:function(r){theExtraList.get(0).wpList.add(r.rows)}})};theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"});theList=a("#the-comment-list").wpList({alt:"",delBefore:j,dimAfter:h,delAfter:l,addColor:"none"}).bind("wpListDelEnd",function(o,n){var p=n.element.replace(/[^0-9]+/g,"");if(n.target.className.indexOf(":trash=1")!=-1||n.target.className.indexOf(":spam=1")!=-1){a("#undo-"+p).fadeIn(300,function(){a(this).show()})}})};commentReply={cid:"",act:"",init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()});a("a.save",b).click(function(){return commentReply.send()});a("input#author, input#author-email, input#author-url",b).keypress(function(c){if(c.which==13){commentReply.send();c.preventDefault();return false}});a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){var b;if(this.cid){b=a("#comment-"+this.cid);if(this.act=="edit-comment"){b.fadeIn(300,function(){b.show()}).css("backgroundColor","")}a("#replyrow").hide();a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("input","#edithead").val("");a(".error","#replysubmit").html("").hide();a(".waiting","#replysubmit").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}this.cid=""}},open:function(b,d,k){var l=this,e,f,i,g,j=a("#comment-"+b);l.close();l.cid=b;e=a("#replyrow");f=a("#inline-"+b);i=l.act=(k=="edit")?"edit-comment":"replyto-comment";a("#action",e).val(i);a("#comment_post_ID",e).val(d);a("#comment_ID",e).val(b);if(k=="edit"){a("#author",e).val(a("div.author",f).text());a("#author-email",e).val(a("div.author-email",f).text());a("#author-url",e).val(a("div.author-url",f).text());a("#status",e).val(a("div.comment_status",f).text());a("#replycontent",e).val(a("textarea.comment",f).val());a("#edithead, #savebtn",e).show();a("#replyhead, #replybtn",e).hide();g=j.height();if(g>220){if(a.browser.msie){a("#replycontainer, #replycontent",e).height(g-105)}else{a("#replycontainer",e).height(g-105)}}j.after(e).fadeOut("fast",function(){a("#replyrow").fadeIn(300,function(){a(this).show()})})}else{a("#edithead, #savebtn",e).hide();a("#replyhead, #replybtn",e).show();j.after(e);a("#replyrow").fadeIn(300,function(){a(this).show()})}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var n,h,o,c,m;n=a("#replyrow").offset().top;h=n+a("#replyrow").height();o=window.pageYOffset||document.documentElement.scrollTop;c=document.documentElement.clientHeight||self.innerHeight||0;m=o+c;if(m-20<h){window.scroll(0,h-c+35)}else{if(n-20<o){window.scroll(0,n-35)}}a("#replycontent").focus().keyup(function(p){if(p.which==27){commentReply.revert()}})},600);return false},send:function(){var b={};a("#replysubmit .error").hide();a("#replysubmit .waiting").show();a("#replyrow input").each(function(){b[a(this).attr("name")]=a(this).val()});b.content=a("#replycontent").val();b.id=b.comment_post_ID;b.comments_listing=this.comments_listing;b.p=a("[name=p]").val();a.ajax({type:"POST",url:ajaxurl,data:b,success:function(c){commentReply.show(c)},error:function(c){commentReply.error(c)}});return false},show:function(b){var e,g,f,d;if(typeof(b)=="string"){this.error({responseText:b});return false}e=wpAjax.parseAjaxResponse(b);if(e.errors){this.error({responseText:wpAjax.broken});return false}e=e.responses[0];g=e.data;f="#comment-"+e.id;if("edit-comment"==this.act){a(f).remove()}a(g).hide();a("#replyrow").after(g);this.revert();this.addEvents(a(f));d=a(f).hasClass("unapproved")?"#ffffe0":"#fff";a(f).animate({backgroundColor:"#CCEEBB"},600).animate({backgroundColor:d},600)},error:function(b){var c=b.statusText;a("#replysubmit .waiting").hide();if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a(document).delegate("span.delete a.delete","click",function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a(".tablenav-pages ."+f+"-page:not(.disabled)");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("input:checkbox","#cb").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(){var g=a('select[name="action"]');a("option[value="+f+"]",g).attr("selected","selected");a("#doaction").click()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q","z",["e",b],["shift+x",c],["shift+a",d("approve")],["shift+s",d("spam")],["shift+d",d("delete")],["shift+t",d("trash")],["shift+z",d("untrash")],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery);
Index: /tags/3.1/wp-admin/js/editor.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/editor.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/editor.dev.js	(revision 17487)
@@ -0,0 +1,207 @@
+
+jQuery(document).ready(function($){
+	var h = wpCookies.getHash('TinyMCE_content_size');
+
+	if ( getUserSetting( 'editor' ) == 'html' ) {
+		if ( h )
+			$('#content').css('height', h.ch - 15 + 'px');
+	} else {
+		if ( typeof tinyMCE != 'object' ) {
+			$('#content').css('color', '#000');
+		} else {
+			$('#quicktags').hide();
+		}
+	}
+});
+
+var switchEditors = {
+
+	mode : '',
+
+	I : function(e) {
+		return document.getElementById(e);
+	},
+
+	_wp_Nop : function(content) {
+		var blocklist1, blocklist2;
+
+		// Protect pre|script tags
+		if ( content.indexOf('<pre') != -1 || content.indexOf('<script') != -1 ) {
+			content = content.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
+				a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp_temp>');
+				return a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp_temp>');
+			});
+		}
+
+		// Pretty it up for the source editor
+		blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset';
+		content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'g'), '</$1>\n');
+		content = content.replace(new RegExp('\\s*<((?:'+blocklist1+')(?: [^>]*)?)>', 'g'), '\n<$1>');
+
+		// Mark </p> if it has any attributes.
+		content = content.replace(/(<p [^>]+>.*?)<\/p>/g, '$1</p#>');
+
+		// Sepatate <div> containing <p>
+		content = content.replace(/<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n');
+
+		// Remove <p> and <br />
+		content = content.replace(/\s*<p>/gi, '');
+		content = content.replace(/\s*<\/p>\s*/gi, '\n\n');
+		content = content.replace(/\n[\s\u00a0]+\n/g, '\n\n');
+		content = content.replace(/\s*<br ?\/?>\s*/gi, '\n');
+
+		// Fix some block element newline issues
+		content = content.replace(/\s*<div/g, '\n<div');
+		content = content.replace(/<\/div>\s*/g, '</div>\n');
+		content = content.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n');
+		content = content.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption');
+
+		blocklist2 = 'blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset';
+		content = content.replace(new RegExp('\\s*<((?:'+blocklist2+')(?: [^>]*)?)\\s*>', 'g'), '\n<$1>');
+		content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'g'), '</$1>\n');
+		content = content.replace(/<li([^>]*)>/g, '\t<li$1>');
+
+		if ( content.indexOf('<hr') != -1 ) {
+			content = content.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
+		}
+
+		if ( content.indexOf('<object') != -1 ) {
+			content = content.replace(/<object[\s\S]+?<\/object>/g, function(a){
+				return a.replace(/[\r\n]+/g, '');
+			});
+		}
+
+		// Unmark special paragraph closing tags
+		content = content.replace(/<\/p#>/g, '</p>\n');
+		content = content.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1');
+
+		// Trim whitespace
+		content = content.replace(/^\s+/, '');
+		content = content.replace(/[\s\u00a0]+$/, '');
+
+		// put back the line breaks in pre|script
+		content = content.replace(/<wp_temp>/g, '\n');
+
+		return content;
+	},
+
+	go : function(id, mode) {
+		id = id || 'content';
+		mode = mode || this.mode || '';
+
+		var ed, qt = this.I('quicktags'), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'), ta = this.I(id);
+
+		try { ed = tinyMCE.get(id); }
+		catch(e) { ed = false; }
+
+		if ( 'tinymce' == mode ) {
+			if ( ed && ! ed.isHidden() )
+				return false;
+
+			setUserSetting( 'editor', 'tinymce' );
+			this.mode = 'html';
+
+			P.className = 'active';
+			H.className = '';
+			edCloseAllTags(); // :-(
+			qt.style.display = 'none';
+
+			ta.style.color = '#FFF';
+			ta.value = this.wpautop(ta.value);
+
+			try {
+				if ( ed )
+					ed.show();
+				else
+					tinyMCE.execCommand("mceAddControl", false, id);
+			} catch(e) {}
+
+			ta.style.color = '#000';
+		} else {
+			setUserSetting( 'editor', 'html' );
+			ta.style.color = '#000';
+			this.mode = 'tinymce';
+			H.className = 'active';
+			P.className = '';
+
+			if ( ed && !ed.isHidden() ) {
+				ta.style.height = ed.getContentAreaContainer().offsetHeight + 24 + 'px';
+				ed.hide();
+			}
+
+			qt.style.display = 'block';
+		}
+		return false;
+	},
+
+	_wp_Autop : function(pee) {
+		var blocklist = 'table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|fieldset|legend|hr';
+
+		if ( pee.indexOf('<object') != -1 ) {
+			pee = pee.replace(/<object[\s\S]+?<\/object>/g, function(a){
+				return a.replace(/[\r\n]+/g, '');
+			});
+		}
+
+		pee = pee.replace(/<[^<>]+>/g, function(a){
+			return a.replace(/[\r\n]+/g, ' ');
+		});
+
+		// Protect pre|script tags
+		if ( pee.indexOf('<pre') != -1 || pee.indexOf('<script') != -1 ) {
+			pee = pee.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g, function(a) {
+				return a.replace(/(\r\n|\n)/g, '<wp_temp_br>');
+			});
+		}
+
+		pee = pee + '\n\n';
+		pee = pee.replace(/<br \/>\s*<br \/>/gi, '\n\n');
+		pee = pee.replace(new RegExp('(<(?:'+blocklist+')(?: [^>]*)?>)', 'gi'), '\n$1');
+		pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), '$1\n\n');
+		pee = pee.replace(/<hr( [^>]*)?>/gi, '<hr$1>\n\n'); // hr is self closing block element
+		pee = pee.replace(/\r\n|\r/g, '\n');
+		pee = pee.replace(/\n\s*\n+/g, '\n\n');
+		pee = pee.replace(/([\s\S]+?)\n\n/g, '<p>$1</p>\n');
+		pee = pee.replace(/<p>\s*?<\/p>/gi, '');
+		pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')(?: [^>]*)?>)\\s*</p>', 'gi'), "$1");
+		pee = pee.replace(/<p>(<li.+?)<\/p>/gi, '$1');
+		pee = pee.replace(/<p>\s*<blockquote([^>]*)>/gi, '<blockquote$1><p>');
+		pee = pee.replace(/<\/blockquote>\s*<\/p>/gi, '</p></blockquote>');
+		pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')(?: [^>]*)?>)', 'gi'), "$1");
+		pee = pee.replace(new RegExp('(</?(?:'+blocklist+')(?: [^>]*)?>)\\s*</p>', 'gi'), "$1");
+		pee = pee.replace(/\s*\n/gi, '<br />\n');
+		pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1");
+		pee = pee.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi, '$1');
+		pee = pee.replace(/(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi, '[caption$1[/caption]');
+
+		pee = pee.replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g, function(a, b, c) {
+			if ( c.match(/<p( [^>]*)?>/) )
+				return a;
+
+			return b + '<p>' + c + '</p>';
+		});
+
+		// put back the line breaks in pre|script
+		pee = pee.replace(/<wp_temp_br>/g, '\n');
+
+		return pee;
+	},
+
+	pre_wpautop : function(content) {
+		var t = this, o = { o: t, data: content, unfiltered: content };
+
+		jQuery('body').trigger('beforePreWpautop', [o]);
+		o.data = t._wp_Nop(o.data);
+		jQuery('body').trigger('afterPreWpautop', [o]);
+		return o.data;
+	},
+
+	wpautop : function(pee) {
+		var t = this, o = { o: t, data: pee, unfiltered: pee };
+
+		jQuery('body').trigger('beforeWpautop', [o]);
+		o.data = t._wp_Autop(o.data);
+		jQuery('body').trigger('afterWpautop', [o]);
+		return o.data;
+	}
+};
Index: /tags/3.1/wp-admin/js/editor.js
===================================================================
--- /tags/3.1/wp-admin/js/editor.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/editor.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(b){var a=wpCookies.getHash("TinyMCE_content_size");if(getUserSetting("editor")=="html"){if(a){b("#content").css("height",a.ch-15+"px")}}else{if(typeof tinyMCE!="object"){b("#content").css("color","#000")}else{b("#quicktags").hide()}}});var switchEditors={mode:"",I:function(a){return document.getElementById(a)},_wp_Nop:function(b){var c,a;if(b.indexOf("<pre")!=-1||b.indexOf("<script")!=-1){b=b.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(d){d=d.replace(/<br ?\/?>(\r\n|\n)?/g,"<wp_temp>");return d.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"<wp_temp>")})}c="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|div|h[1-6]|p|fieldset";b=b.replace(new RegExp("\\s*</("+c+")>\\s*","g"),"</$1>\n");b=b.replace(new RegExp("\\s*<((?:"+c+")(?: [^>]*)?)>","g"),"\n<$1>");b=b.replace(/(<p [^>]+>.*?)<\/p>/g,"$1</p#>");b=b.replace(/<div( [^>]*)?>\s*<p>/gi,"<div$1>\n\n");b=b.replace(/\s*<p>/gi,"");b=b.replace(/\s*<\/p>\s*/gi,"\n\n");b=b.replace(/\n[\s\u00a0]+\n/g,"\n\n");b=b.replace(/\s*<br ?\/?>\s*/gi,"\n");b=b.replace(/\s*<div/g,"\n<div");b=b.replace(/<\/div>\s*/g,"</div>\n");b=b.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,"\n\n[caption$1[/caption]\n\n");b=b.replace(/caption\]\n\n+\[caption/g,"caption]\n\n[caption");a="blockquote|ul|ol|li|table|thead|tbody|tfoot|tr|th|td|h[1-6]|pre|fieldset";b=b.replace(new RegExp("\\s*<((?:"+a+")(?: [^>]*)?)\\s*>","g"),"\n<$1>");b=b.replace(new RegExp("\\s*</("+a+")>\\s*","g"),"</$1>\n");b=b.replace(/<li([^>]*)>/g,"\t<li$1>");if(b.indexOf("<hr")!=-1){b=b.replace(/\s*<hr( [^>]*)?>\s*/g,"\n\n<hr$1>\n\n")}if(b.indexOf("<object")!=-1){b=b.replace(/<object[\s\S]+?<\/object>/g,function(d){return d.replace(/[\r\n]+/g,"")})}b=b.replace(/<\/p#>/g,"</p>\n");b=b.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g,"\n$1");b=b.replace(/^\s+/,"");b=b.replace(/[\s\u00a0]+$/,"");b=b.replace(/<wp_temp>/g,"\n");return b},go:function(i,g){i=i||"content";g=g||this.mode||"";var b,h=this.I("quicktags"),c=this.I("edButtonHTML"),d=this.I("edButtonPreview"),a=this.I(i);try{b=tinyMCE.get(i)}catch(f){b=false}if("tinymce"==g){if(b&&!b.isHidden()){return false}setUserSetting("editor","tinymce");this.mode="html";d.className="active";c.className="";edCloseAllTags();h.style.display="none";a.style.color="#FFF";a.value=this.wpautop(a.value);try{if(b){b.show()}else{tinyMCE.execCommand("mceAddControl",false,i)}}catch(f){}a.style.color="#000"}else{setUserSetting("editor","html");a.style.color="#000";this.mode="tinymce";c.className="active";d.className="";if(b&&!b.isHidden()){a.style.height=b.getContentAreaContainer().offsetHeight+24+"px";b.hide()}h.style.display="block"}return false},_wp_Autop:function(a){var b="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|fieldset|legend|hr";if(a.indexOf("<object")!=-1){a=a.replace(/<object[\s\S]+?<\/object>/g,function(c){return c.replace(/[\r\n]+/g,"")})}a=a.replace(/<[^<>]+>/g,function(c){return c.replace(/[\r\n]+/g," ")});if(a.indexOf("<pre")!=-1||a.indexOf("<script")!=-1){a=a.replace(/<(pre|script)[^>]*>[\s\S]+?<\/\1>/g,function(c){return c.replace(/(\r\n|\n)/g,"<wp_temp_br>")})}a=a+"\n\n";a=a.replace(/<br \/>\s*<br \/>/gi,"\n\n");a=a.replace(new RegExp("(<(?:"+b+")(?: [^>]*)?>)","gi"),"\n$1");a=a.replace(new RegExp("(</(?:"+b+")>)","gi"),"$1\n\n");a=a.replace(/<hr( [^>]*)?>/gi,"<hr$1>\n\n");a=a.replace(/\r\n|\r/g,"\n");a=a.replace(/\n\s*\n+/g,"\n\n");a=a.replace(/([\s\S]+?)\n\n/g,"<p>$1</p>\n");a=a.replace(/<p>\s*?<\/p>/gi,"");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/<p>(<li.+?)<\/p>/gi,"$1");a=a.replace(/<p>\s*<blockquote([^>]*)>/gi,"<blockquote$1><p>");a=a.replace(/<\/blockquote>\s*<\/p>/gi,"</p></blockquote>");a=a.replace(new RegExp("<p>\\s*(</?(?:"+b+")(?: [^>]*)?>)","gi"),"$1");a=a.replace(new RegExp("(</?(?:"+b+")(?: [^>]*)?>)\\s*</p>","gi"),"$1");a=a.replace(/\s*\n/gi,"<br />\n");a=a.replace(new RegExp("(</?(?:"+b+")[^>]*>)\\s*<br />","gi"),"$1");a=a.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)/gi,"$1");a=a.replace(/(?:<p>|<br ?\/?>)*\s*\[caption([^\[]+)\[\/caption\]\s*(?:<\/p>|<br ?\/?>)*/gi,"[caption$1[/caption]");a=a.replace(/(<(?:div|th|td|form|fieldset|dd)[^>]*>)(.*?)<\/p>/g,function(e,d,f){if(f.match(/<p( [^>]*)?>/)){return e}return d+"<p>"+f+"</p>"});a=a.replace(/<wp_temp_br>/g,"\n");return a},pre_wpautop:function(b){var a=this,c={o:a,data:b,unfiltered:b};jQuery("body").trigger("beforePreWpautop",[c]);c.data=a._wp_Nop(c.data);jQuery("body").trigger("afterPreWpautop",[c]);return c.data},wpautop:function(b){var a=this,c={o:a,data:b,unfiltered:b};jQuery("body").trigger("beforeWpautop",[c]);c.data=a._wp_Autop(c.data);jQuery("body").trigger("afterWpautop",[c]);return c.data}};
Index: /tags/3.1/wp-admin/js/farbtastic.js
===================================================================
--- /tags/3.1/wp-admin/js/farbtastic.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/farbtastic.js	(revision 17487)
@@ -0,0 +1,276 @@
+/*!
+ * Farbtastic: jQuery color picker plug-in v1.3u
+ *
+ * Licensed under the GPL license:
+ *   http://www.gnu.org/licenses/gpl.html
+ */
+(function($) {
+
+$.fn.farbtastic = function (options) {
+  $.farbtastic(this, options);
+  return this;
+};
+
+$.farbtastic = function (container, callback) {
+  var container = $(container).get(0);
+  return container.farbtastic || (container.farbtastic = new $._farbtastic(container, callback));
+};
+
+$._farbtastic = function (container, callback) {
+  // Store farbtastic object
+  var fb = this;
+
+  // Insert markup
+  $(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
+  var e = $('.farbtastic', container);
+  fb.wheel = $('.wheel', container).get(0);
+  // Dimensions
+  fb.radius = 84;
+  fb.square = 100;
+  fb.width = 194;
+
+  // Fix background PNGs in IE6
+  if (navigator.appVersion.match(/MSIE [0-6]\./)) {
+    $('*', e).each(function () {
+      if (this.currentStyle.backgroundImage != 'none') {
+        var image = this.currentStyle.backgroundImage;
+        image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
+        $(this).css({
+          'backgroundImage': 'none',
+          'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
+        });
+      }
+    });
+  }
+
+  /**
+   * Link to the given element(s) or callback.
+   */
+  fb.linkTo = function (callback) {
+    // Unbind previous nodes
+    if (typeof fb.callback == 'object') {
+      $(fb.callback).unbind('keyup', fb.updateValue);
+    }
+
+    // Reset color
+    fb.color = null;
+
+    // Bind callback or elements
+    if (typeof callback == 'function') {
+      fb.callback = callback;
+    }
+    else if (typeof callback == 'object' || typeof callback == 'string') {
+      fb.callback = $(callback);
+      fb.callback.bind('keyup', fb.updateValue);
+      if (fb.callback.get(0).value) {
+        fb.setColor(fb.callback.get(0).value);
+      }
+    }
+    return this;
+  };
+  fb.updateValue = function (event) {
+    if (this.value && this.value != fb.color) {
+      fb.setColor(this.value);
+    }
+  };
+
+  /**
+   * Change color with HTML syntax #123456
+   */
+  fb.setColor = function (color) {
+    var unpack = fb.unpack(color);
+    if (fb.color != color && unpack) {
+      fb.color = color;
+      fb.rgb = unpack;
+      fb.hsl = fb.RGBToHSL(fb.rgb);
+      fb.updateDisplay();
+    }
+    return this;
+  };
+
+  /**
+   * Change color with HSL triplet [0..1, 0..1, 0..1]
+   */
+  fb.setHSL = function (hsl) {
+    fb.hsl = hsl;
+    fb.rgb = fb.HSLToRGB(hsl);
+    fb.color = fb.pack(fb.rgb);
+    fb.updateDisplay();
+    return this;
+  };
+
+  /////////////////////////////////////////////////////
+
+  /**
+   * Retrieve the coordinates of the given event relative to the center
+   * of the widget.
+   */
+  fb.widgetCoords = function (event) {
+    var offset = $(fb.wheel).offset();
+    return { x: (event.pageX - offset.left) - fb.width / 2, y: (event.pageY - offset.top) - fb.width / 2 };
+  };
+
+  /**
+   * Mousedown handler
+   */
+  fb.mousedown = function (event) {
+    // Capture mouse
+    if (!document.dragging) {
+      $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
+      document.dragging = true;
+    }
+
+    // Check which area is being dragged
+    var pos = fb.widgetCoords(event);
+    fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
+
+    // Process
+    fb.mousemove(event);
+    return false;
+  };
+
+  /**
+   * Mousemove handler
+   */
+  fb.mousemove = function (event) {
+    // Get coordinates relative to color picker center
+    var pos = fb.widgetCoords(event);
+
+    // Set new HSL parameters
+    if (fb.circleDrag) {
+      var hue = Math.atan2(pos.x, -pos.y) / 6.28;
+      if (hue < 0) hue += 1;
+      fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
+    }
+    else {
+      var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
+      var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
+      fb.setHSL([fb.hsl[0], sat, lum]);
+    }
+    return false;
+  };
+
+  /**
+   * Mouseup handler
+   */
+  fb.mouseup = function () {
+    // Uncapture mouse
+    $(document).unbind('mousemove', fb.mousemove);
+    $(document).unbind('mouseup', fb.mouseup);
+    document.dragging = false;
+  };
+
+  /**
+   * Update the markers and styles
+   */
+  fb.updateDisplay = function () {
+    // Markers
+    var angle = fb.hsl[0] * 6.28;
+    $('.h-marker', e).css({
+      left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
+      top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
+    });
+
+    $('.sl-marker', e).css({
+      left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
+      top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
+    });
+
+    // Saturation/Luminance gradient
+    $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
+
+    // Linked elements or callback
+    if (typeof fb.callback == 'object') {
+      // Set background/foreground color
+      $(fb.callback).css({
+        backgroundColor: fb.color,
+        color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
+      });
+
+      // Change linked value
+      $(fb.callback).each(function() {
+        if (this.value && this.value != fb.color) {
+          this.value = fb.color;
+        }
+      });
+    }
+    else if (typeof fb.callback == 'function') {
+      fb.callback.call(fb, fb.color);
+    }
+  };
+
+  /* Various color utility functions */
+  fb.pack = function (rgb) {
+    var r = Math.round(rgb[0] * 255);
+    var g = Math.round(rgb[1] * 255);
+    var b = Math.round(rgb[2] * 255);
+    return '#' + (r < 16 ? '0' : '') + r.toString(16) +
+           (g < 16 ? '0' : '') + g.toString(16) +
+           (b < 16 ? '0' : '') + b.toString(16);
+  };
+
+  fb.unpack = function (color) {
+    if (color.length == 7) {
+      return [parseInt('0x' + color.substring(1, 3)) / 255,
+        parseInt('0x' + color.substring(3, 5)) / 255,
+        parseInt('0x' + color.substring(5, 7)) / 255];
+    }
+    else if (color.length == 4) {
+      return [parseInt('0x' + color.substring(1, 2)) / 15,
+        parseInt('0x' + color.substring(2, 3)) / 15,
+        parseInt('0x' + color.substring(3, 4)) / 15];
+    }
+  };
+
+  fb.HSLToRGB = function (hsl) {
+    var m1, m2, r, g, b;
+    var h = hsl[0], s = hsl[1], l = hsl[2];
+    m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
+    m1 = l * 2 - m2;
+    return [this.hueToRGB(m1, m2, h+0.33333),
+        this.hueToRGB(m1, m2, h),
+        this.hueToRGB(m1, m2, h-0.33333)];
+  };
+
+  fb.hueToRGB = function (m1, m2, h) {
+    h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
+    if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
+    if (h * 2 < 1) return m2;
+    if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
+    return m1;
+  };
+
+  fb.RGBToHSL = function (rgb) {
+    var min, max, delta, h, s, l;
+    var r = rgb[0], g = rgb[1], b = rgb[2];
+    min = Math.min(r, Math.min(g, b));
+    max = Math.max(r, Math.max(g, b));
+    delta = max - min;
+    l = (min + max) / 2;
+    s = 0;
+    if (l > 0 && l < 1) {
+      s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
+    }
+    h = 0;
+    if (delta > 0) {
+      if (max == r && max != g) h += (g - b) / delta;
+      if (max == g && max != b) h += (2 + (b - r) / delta);
+      if (max == b && max != r) h += (4 + (r - g) / delta);
+      h /= 6;
+    }
+    return [h, s, l];
+  };
+
+  // Install mousedown handler (the others are set on the document on-demand)
+  $('*', e).mousedown(fb.mousedown);
+
+    // Init color
+  fb.setColor('#000000');
+
+  // Set linked elements/callback
+  if (callback) {
+    fb.linkTo(callback);
+  }
+};
+
+})(jQuery);
Index: /tags/3.1/wp-admin/js/gallery.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/gallery.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/gallery.dev.js	(revision 17487)
@@ -0,0 +1,205 @@
+jQuery(document).ready(function($) {
+	var gallerySortable, gallerySortableInit, w, desc = false;
+
+	gallerySortableInit = function() {
+		gallerySortable = $('#media-items').sortable( {
+			items: 'div.media-item',
+			placeholder: 'sorthelper',
+			axis: 'y',
+			distance: 2,
+			handle: 'div.filename',
+			stop: function(e, ui) {
+				// When an update has occurred, adjust the order for each item
+				var all = $('#media-items').sortable('toArray'), len = all.length;
+				$.each(all, function(i, id) {
+					var order = desc ? (len - i) : (1 + i);
+					$('#' + id + ' .menu_order input').val(order);
+				});
+			}
+		} );
+	}
+
+	sortIt = function() {
+		var all = $('.menu_order_input'), len = all.length;
+		all.each(function(i){
+			var order = desc ? (len - i) : (1 + i);
+			$(this).val(order);
+		});
+	}
+
+	clearAll = function(c) {
+		c = c || 0;
+		$('.menu_order_input').each(function(){
+			if ( this.value == '0' || c ) this.value = '';
+		});
+	}
+
+	$('#asc').click(function(){desc = false; sortIt(); return false;});
+	$('#desc').click(function(){desc = true; sortIt(); return false;});
+	$('#clear').click(function(){clearAll(1); return false;});
+	$('#showall').click(function(){
+		$('#sort-buttons span a').toggle();
+		$('a.describe-toggle-on').hide();
+		$('a.describe-toggle-off, table.slidetoggle').show();
+		return false;
+	});
+	$('#hideall').click(function(){
+		$('#sort-buttons span a').toggle();
+		$('a.describe-toggle-on').show();
+		$('a.describe-toggle-off, table.slidetoggle').hide();
+		return false;
+	});
+
+	// initialize sortable
+	gallerySortableInit();
+	clearAll();
+
+	if ( $('#media-items>*').length > 1 ) {
+		w = wpgallery.getWin();
+
+		$('#save-all, #gallery-settings').show();
+		if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
+			wpgallery.mcemode = true;
+			wpgallery.init();
+		} else {
+			$('#insert-gallery').show();
+		}
+	}
+});
+
+jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup
+
+/* gallery settings */
+var tinymce = null, tinyMCE, wpgallery;
+
+wpgallery = {
+	mcemode : false,
+	editor : {},
+	dom : {},
+	is_update : false,
+	el : {},
+
+	I : function(e) {
+		return document.getElementById(e);
+	},
+
+	init: function() {
+		var t = this, li, q, i, it, w = t.getWin();
+
+		if ( ! t.mcemode ) return;
+
+		li = ('' + document.location.search).replace(/^\?/, '').split('&');
+		q = {};
+		for (i=0; i<li.length; i++) {
+			it = li[i].split('=');
+			q[unescape(it[0])] = unescape(it[1]);
+		}
+
+		if (q.mce_rdomain)
+			document.domain = q.mce_rdomain;
+
+		// Find window & API
+		tinymce = w.tinymce;
+		tinyMCE = w.tinyMCE;
+		t.editor = tinymce.EditorManager.activeEditor;
+
+		t.setup();
+	},
+
+	getWin : function() {
+		return window.dialogArguments || opener || parent || top;
+	},
+
+	restoreSelection : function() {
+		var t = this;
+
+		if (tinymce.isIE)
+			t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
+	},
+
+	setup : function() {
+		var t = this, a, ed = t.editor, g, columns, link, order, orderby;
+		if ( ! t.mcemode ) return;
+
+		t.restoreSelection();
+		t.el = ed.selection.getNode();
+
+		if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
+			if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
+				t.el = g[0];
+			} else {
+				if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
+				if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
+				if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
+				if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
+				jQuery('#insert-gallery').show();
+				return;
+			}
+		}
+
+		a = ed.dom.getAttrib(t.el, 'title');
+		a = ed.dom.decode(a);
+
+		if ( a ) {
+			jQuery('#update-gallery').show();
+			t.is_update = true;
+
+			columns = a.match(/columns=['"]([0-9]+)['"]/);
+			link = a.match(/link=['"]([^'"]+)['"]/i);
+			order = a.match(/order=['"]([^'"]+)['"]/i);
+			orderby = a.match(/orderby=['"]([^'"]+)['"]/i);
+
+			if ( link && link[1] ) t.I('linkto-file').checked = "checked";
+			if ( order && order[1] ) t.I('order-desc').checked = "checked";
+			if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
+			if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
+		} else {
+			jQuery('#insert-gallery').show();
+		}
+	},
+
+	update : function() {
+		var t = this, ed = t.editor, all = '', s;
+
+		if ( ! t.mcemode || ! t.is_update ) {
+			s = '[gallery'+t.getSettings()+']';
+			t.getWin().send_to_editor(s);
+			return;
+		}
+
+		if (t.el.nodeName != 'IMG') return;
+
+		all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
+		all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
+		all += t.getSettings();
+
+		ed.dom.setAttrib(t.el, 'title', all);
+		t.getWin().tb_remove();
+	},
+
+	getSettings : function() {
+		var I = this.I, s = '';
+
+		if ( I('linkto-file').checked ) {
+			s += ' link="file"';
+			setUserSetting('galfile', '1');
+		}
+
+		if ( I('order-desc').checked ) {
+			s += ' order="DESC"';
+			setUserSetting('galdesc', '1');
+		}
+
+		if ( I('columns').value != 3 ) {
+			s += ' columns="'+I('columns').value+'"';
+			setUserSetting('galcols', I('columns').value);
+		}
+
+		if ( I('orderby').value != 'menu_order' ) {
+			s += ' orderby="'+I('orderby').value+'"';
+			setUserSetting('galord', I('orderby').value);
+		}
+
+		return s;
+	}
+};
Index: /tags/3.1/wp-admin/js/gallery.js
===================================================================
--- /tags/3.1/wp-admin/js/gallery.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/gallery.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(c){var b,e,a,d=false;e=function(){b=c("#media-items").sortable({items:"div.media-item",placeholder:"sorthelper",axis:"y",distance:2,handle:"div.filename",stop:function(i,h){var g=c("#media-items").sortable("toArray"),f=g.length;c.each(g,function(k,l){var j=d?(f-k):(1+k);c("#"+l+" .menu_order input").val(j)})}})};sortIt=function(){var g=c(".menu_order_input"),f=g.length;g.each(function(j){var h=d?(f-j):(1+j);c(this).val(h)})};clearAll=function(f){f=f||0;c(".menu_order_input").each(function(){if(this.value=="0"||f){this.value=""}})};c("#asc").click(function(){d=false;sortIt();return false});c("#desc").click(function(){d=true;sortIt();return false});c("#clear").click(function(){clearAll(1);return false});c("#showall").click(function(){c("#sort-buttons span a").toggle();c("a.describe-toggle-on").hide();c("a.describe-toggle-off, table.slidetoggle").show();return false});c("#hideall").click(function(){c("#sort-buttons span a").toggle();c("a.describe-toggle-on").show();c("a.describe-toggle-off, table.slidetoggle").hide();return false});e();clearAll();if(c("#media-items>*").length>1){a=wpgallery.getWin();c("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{c("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.setup()},getWin:function(){return window.dialogArguments||opener||parent||top},restoreSelection:function(){var a=this;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},setup:function(){var f=this,c,d=f.editor,i,e,h,b,j;if(!f.mcemode){return}f.restoreSelection();f.el=d.selection.getNode();if(f.el.nodeName!="IMG"||!d.dom.hasClass(f.el,"wpGallery")){if((i=d.dom.select("img.wpGallery"))&&i[0]){f.el=i[0]}else{if(getUserSetting("galfile")=="1"){f.I("linkto-file").checked="checked"}if(getUserSetting("galdesc")=="1"){f.I("order-desc").checked="checked"}if(getUserSetting("galcols")){f.I("columns").value=getUserSetting("galcols")}if(getUserSetting("galord")){f.I("orderby").value=getUserSetting("galord")}jQuery("#insert-gallery").show();return}}c=d.dom.getAttrib(f.el,"title");c=d.dom.decode(c);if(c){jQuery("#update-gallery").show();f.is_update=true;e=c.match(/columns=['"]([0-9]+)['"]/);h=c.match(/link=['"]([^'"]+)['"]/i);b=c.match(/order=['"]([^'"]+)['"]/i);j=c.match(/orderby=['"]([^'"]+)['"]/i);if(h&&h[1]){f.I("linkto-file").checked="checked"}if(b&&b[1]){f.I("order-desc").checked="checked"}if(e&&e[1]){f.I("columns").value=""+e[1]}if(j&&j[1]){f.I("orderby").value=j[1]}}else{jQuery("#insert-gallery").show()}},update:function(){var b=this,a=b.editor,d="",c;if(!b.mcemode||!b.is_update){c="[gallery"+b.getSettings()+"]";b.getWin().send_to_editor(c);return}if(b.el.nodeName!="IMG"){return}d=a.dom.decode(a.dom.getAttrib(b.el,"title"));d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,"");d+=b.getSettings();a.dom.setAttrib(b.el,"title",d);b.getWin().tb_remove()},getSettings:function(){var a=this.I,b="";if(a("linkto-file").checked){b+=' link="file"';setUserSetting("galfile","1")}if(a("order-desc").checked){b+=' order="DESC"';setUserSetting("galdesc","1")}if(a("columns").value!=3){b+=' columns="'+a("columns").value+'"';setUserSetting("galcols",a("columns").value)}if(a("orderby").value!="menu_order"){b+=' orderby="'+a("orderby").value+'"';setUserSetting("galord",a("orderby").value)}return b}};
Index: /tags/3.1/wp-admin/js/image-edit.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/image-edit.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/image-edit.dev.js	(revision 17487)
@@ -0,0 +1,569 @@
+var imageEdit;
+
+(function($) {
+imageEdit = {
+	iasapi : {},
+	hold : {},
+	postid : '',
+
+	intval : function(f) {
+		return f | 0;
+	},
+
+	setDisabled : function(el, s) {
+		if ( s ) {
+			el.removeClass('disabled');
+			$('input', el).removeAttr('disabled');
+		} else {
+			el.addClass('disabled');
+			$('input', el).attr('disabled', 'disabled');
+		}
+	},
+
+	init : function(postid, nonce) {
+		var t = this, old = $('#image-editor-' + t.postid),
+			x = t.intval( $('#imgedit-x-' + postid).val() ),
+			y = t.intval( $('#imgedit-y-' + postid).val() );
+
+		if ( t.postid != postid && old.length )
+			t.close(t.postid);
+
+		t.hold['w'] = t.hold['ow'] = x;
+		t.hold['h'] = t.hold['oh'] = y;
+		t.hold['xy_ratio'] = x / y;
+		t.hold['sizer'] = parseFloat( $('#imgedit-sizer-' + postid).val() );
+		t.postid = postid;
+		$('#imgedit-response-' + postid).empty();
+
+		$('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) {
+			var k = e.keyCode;
+
+			if ( 36 < k && k < 41 )
+				$(this).blur()
+
+			if ( 13 == k ) {
+				e.preventDefault();
+				e.stopPropagation();
+				return false;
+			}
+		});
+	},
+
+	toggleEditor : function(postid, toggle) {
+		var wait = $('#imgedit-wait-' + postid);
+
+		if ( toggle )
+			wait.height( $('#imgedit-panel-' + postid).height() ).fadeIn('fast');
+		else
+			wait.fadeOut('fast');
+	},
+
+	toggleHelp : function(el) {
+		$(el).siblings('.imgedit-help').slideToggle('fast');
+		return false;
+	},
+
+	getTarget : function(postid) {
+		return $('input[name=imgedit-target-' + postid + ']:checked', '#imgedit-save-target-' + postid).val() || 'full';
+	},
+
+	scaleChanged : function(postid, x) {
+		var w = $('#imgedit-scale-width-' + postid), h = $('#imgedit-scale-height-' + postid),
+		warn = $('#imgedit-scale-warn-' + postid), w1 = '', h1 = '';
+
+		if ( x ) {
+			h1 = (w.val() != '') ? this.intval( w.val() / this.hold['xy_ratio'] ) : '';
+			h.val( h1 );
+		} else {
+			w1 = (h.val() != '') ? this.intval( h.val() * this.hold['xy_ratio'] ) : '';
+			w.val( w1 );
+		}
+
+		if ( ( h1 && h1 > this.hold['oh'] ) || ( w1 && w1 > this.hold['ow'] ) )
+			warn.css('visibility', 'visible');
+		else
+			warn.css('visibility', 'hidden');
+	},
+
+	getSelRatio : function(postid) {
+		var x = this.hold['w'], y = this.hold['h'],
+			X = this.intval( $('#imgedit-crop-width-' + postid).val() ),
+			Y = this.intval( $('#imgedit-crop-height-' + postid).val() );
+
+		if ( X && Y )
+			return X + ':' + Y;
+
+		if ( x && y )
+			return x + ':' + y;
+
+		return '1:1';
+	},
+
+	filterHistory : function(postid, setSize) {
+		// apply undo state to history
+		var history = $('#imgedit-history-' + postid).val(), pop, n, o, i, op = [];
+
+		if ( history != '' ) {
+			history = JSON.parse(history);
+			pop = this.intval( $('#imgedit-undone-' + postid).val() );
+			if ( pop > 0 ) {
+				while ( pop > 0 ) {
+					history.pop();
+					pop--;
+				}
+			}
+
+			if ( setSize ) {
+				if ( !history.length ) {
+					this.hold['w'] = this.hold['ow'];
+					this.hold['h'] = this.hold['oh'];
+					return '';
+				}
+
+				// restore
+				o = history[history.length - 1];
+				o = o.c || o.r || o.f || false;
+
+				if ( o ) {
+					this.hold['w'] = o.fw;
+					this.hold['h'] = o.fh;
+				}
+			}
+
+			// filter the values
+			for ( n in history ) {
+				i = history[n];
+				if ( i.hasOwnProperty('c') ) {
+					op[n] = { 'c': { 'x': i.c.x, 'y': i.c.y, 'w': i.c.w, 'h': i.c.h } };
+				} else if ( i.hasOwnProperty('r') ) {
+					op[n] = { 'r': i.r.r };
+				} else if ( i.hasOwnProperty('f') ) {
+					op[n] = { 'f': i.f.f };
+				}
+			}
+			return JSON.stringify(op);
+		}
+		return '';
+	},
+
+	refreshEditor : function(postid, nonce, callback) {
+		var t = this, data, img;
+
+		t.toggleEditor(postid, 1);
+		data = {
+			'action': 'imgedit-preview',
+			'_ajax_nonce': nonce,
+			'postid': postid,
+			'history': t.filterHistory(postid, 1),
+			'rand': t.intval(Math.random() * 1000000)
+		};
+
+		img = $('<img id="image-preview-' + postid + '" />');
+		img.load( function() {
+			var max1, max2, parent = $('#imgedit-crop-' + postid), t = imageEdit;
+
+			parent.empty().append(img);
+
+			// w, h are the new full size dims
+			max1 = Math.max( t.hold.w, t.hold.h );
+			max2 = Math.max( $(img).width(), $(img).height() );
+			t.hold['sizer'] = max1 > max2 ? max2 / max1 : 1;
+
+			t.initCrop(postid, img, parent);
+			t.setCropSelection(postid, 0);
+
+			if ( (typeof callback != "unknown") && callback != null )
+				callback();
+
+			if ( $('#imgedit-history-' + postid).val() && $('#imgedit-undone-' + postid).val() == 0 )
+				$('input.imgedit-submit-btn', '#imgedit-panel-' + postid).removeAttr('disabled');
+			else
+				$('input.imgedit-submit-btn', '#imgedit-panel-' + postid).attr('disabled', 'disabled');
+
+			t.toggleEditor(postid, 0);
+		}).attr('src', ajaxurl + '?' + $.param(data));
+	},
+
+	action : function(postid, nonce, action) {
+		var t = this, data, w, h, fw, fh;
+
+		if ( t.notsaved(postid) )
+			return false;
+
+		data = {
+			'action': 'image-editor',
+			'_ajax_nonce': nonce,
+			'postid': postid
+		};
+
+		if ( 'scale' == action ) {
+			w = $('#imgedit-scale-width-' + postid),
+			h = $('#imgedit-scale-height-' + postid),
+			fw = t.intval(w.val()),
+			fh = t.intval(h.val());
+
+			if ( fw < 1 ) {
+				w.focus();
+				return false;
+			} else if ( fh < 1 ) {
+				h.focus();
+				return false;
+			}
+
+			if ( fw == t.hold.ow || fh == t.hold.oh )
+				return false;
+
+			data['do'] = 'scale';
+			data['fwidth'] = fw;
+			data['fheight'] = fh;
+		} else if ( 'restore' == action ) {
+			data['do'] = 'restore';
+		} else {
+			return false;
+		}
+
+		t.toggleEditor(postid, 1);
+		$.post(ajaxurl, data, function(r) {
+			$('#image-editor-' + postid).empty().append(r);
+			t.toggleEditor(postid, 0);
+		});
+	},
+
+	save : function(postid, nonce) {
+		var data, target = this.getTarget(postid), history = this.filterHistory(postid, 0);
+
+		if ( '' == history )
+			return false;
+
+		this.toggleEditor(postid, 1);
+		data = {
+			'action': 'image-editor',
+			'_ajax_nonce': nonce,
+			'postid': postid,
+			'history': history,
+			'target': target,
+			'do': 'save'
+		};
+
+		$.post(ajaxurl, data, function(r) {
+			var ret = JSON.parse(r);
+
+			if ( ret.error ) {
+				$('#imgedit-response-' + postid).html('<div class="error"><p>' + ret.error + '</p><div>');
+				imageEdit.close(postid);
+				return;
+			}
+
+			if ( ret.fw && ret.fh )
+				$('#media-dims-' + postid).html( ret.fw + ' &times; ' + ret.fh );
+
+			if ( ret.thumbnail )
+				$('.thumbnail', '#thumbnail-head-' + postid).attr('src', ''+ret.thumbnail);
+
+			if ( ret.msg )
+				$('#imgedit-response-' + postid).html('<div class="updated"><p>' + ret.msg + '</p></div>');
+
+			imageEdit.close(postid);
+		});
+	},
+
+	open : function(postid, nonce) {
+		var data, elem = $('#image-editor-' + postid), head = $('#media-head-' + postid),
+			btn = $('#imgedit-open-btn-' + postid), spin = btn.siblings('img');
+
+		btn.attr('disabled', 'disabled');
+		spin.css('visibility', 'visible');
+
+		data = {
+			'action': 'image-editor',
+			'_ajax_nonce': nonce,
+			'postid': postid,
+			'do': 'open'
+		};
+
+		elem.load(ajaxurl, data, function() {
+			elem.fadeIn('fast');
+			head.fadeOut('fast', function(){
+				btn.removeAttr('disabled');
+				spin.css('visibility', 'hidden');
+			});
+		});
+	},
+
+	imgLoaded : function(postid) {
+		var img = $('#image-preview-' + postid), parent = $('#imgedit-crop-' + postid);
+
+		this.initCrop(postid, img, parent);
+		this.setCropSelection(postid, 0);
+		this.toggleEditor(postid, 0);
+	},
+
+	initCrop : function(postid, image, parent) {
+		var t = this, selW = $('#imgedit-sel-width-' + postid),
+			selH = $('#imgedit-sel-height-' + postid);
+
+		t.iasapi = $(image).imgAreaSelect({
+			parent: parent,
+			instance: true,
+			handles: true,
+			keys: true,
+			minWidth: 3,
+			minHeight: 3,
+
+			onInit: function(img, c) {
+				parent.children().mousedown(function(e){
+					var ratio = false, sel, defRatio;
+
+					if ( e.shiftKey ) {
+						sel = t.iasapi.getSelection();
+						defRatio = t.getSelRatio(postid);
+						ratio = ( sel && sel.width && sel.height ) ? sel.width + ':' + sel.height : defRatio;
+					}
+
+					t.iasapi.setOptions({
+						aspectRatio: ratio
+					});
+				});
+			},
+
+			onSelectStart: function(img, c) {
+				imageEdit.setDisabled($('#imgedit-crop-sel-' + postid), 1);
+			},
+
+			onSelectEnd: function(img, c) {
+				imageEdit.setCropSelection(postid, c);
+			},
+
+			onSelectChange: function(img, c) {
+				var sizer = imageEdit.hold.sizer;
+				selW.val( imageEdit.round(c.width / sizer) );
+				selH.val( imageEdit.round(c.height / sizer) );
+			}
+		});
+	},
+
+	setCropSelection : function(postid, c) {
+		var sel, min = $('#imgedit-minthumb-' + postid).val() || '128:128',
+			sizer = this.hold['sizer'];
+			min = min.split(':');
+			c = c || 0;
+
+		if ( !c || ( c.width < 3 && c.height < 3 ) ) {
+			this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
+			this.setDisabled($('#imgedit-crop-sel-' + postid), 0);
+			$('#imgedit-sel-width-' + postid).val('');
+			$('#imgedit-sel-height-' + postid).val('');
+			$('#imgedit-selection-' + postid).val('');
+			return false;
+		}
+
+		if ( c.width < (min[0] * sizer) && c.height < (min[1] * sizer) ) {
+			this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
+			$('#imgedit-selection-' + postid).val('');
+			return false;
+		}
+
+		sel = { 'x': c.x1, 'y': c.y1, 'w': c.width, 'h': c.height };
+		this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 1);
+		$('#imgedit-selection-' + postid).val( JSON.stringify(sel) );
+	},
+
+	close : function(postid, warn) {
+		warn = warn || false;
+
+		if ( warn && this.notsaved(postid) )
+			return false;
+
+		this.iasapi = {};
+		this.hold = {};
+		$('#image-editor-' + postid).fadeOut('fast', function() {
+			$('#media-head-' + postid).fadeIn('fast');
+			$(this).empty();
+		});
+	},
+
+	notsaved : function(postid) {
+		var h = $('#imgedit-history-' + postid).val(),
+			history = (h != '') ? JSON.parse(h) : new Array(),
+			pop = this.intval( $('#imgedit-undone-' + postid).val() );
+
+		if ( pop < history.length ) {
+			if ( confirm( $('#imgedit-leaving-' + postid).html() ) )
+				return false;
+			return true;
+		}
+		return false;
+	},
+
+	addStep : function(op, postid, nonce) {
+		var t = this, elem = $('#imgedit-history-' + postid),
+		history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array(),
+		undone = $('#imgedit-undone-' + postid),
+		pop = t.intval(undone.val());
+
+		while ( pop > 0 ) {
+			history.pop();
+			pop--;
+		}
+		undone.val(0); // reset
+
+		history.push(op);
+		elem.val( JSON.stringify(history) );
+
+		t.refreshEditor(postid, nonce, function() {
+			t.setDisabled($('#image-undo-' + postid), true);
+			t.setDisabled($('#image-redo-' + postid), false);
+		});
+	},
+
+	rotate : function(angle, postid, nonce, t) {
+		if ( $(t).hasClass('disabled') )
+			return false;
+
+		this.addStep({ 'r': { 'r': angle, 'fw': this.hold['h'], 'fh': this.hold['w'] }}, postid, nonce);
+	},
+
+	flip : function (axis, postid, nonce, t) {
+		if ( $(t).hasClass('disabled') )
+			return false;
+
+		this.addStep({ 'f': { 'f': axis, 'fw': this.hold['w'], 'fh': this.hold['h'] }}, postid, nonce);
+	},
+
+	crop : function (postid, nonce, t) {
+		var sel = $('#imgedit-selection-' + postid).val(),
+			w = this.intval( $('#imgedit-sel-width-' + postid).val() ),
+			h = this.intval( $('#imgedit-sel-height-' + postid).val() );
+
+		if ( $(t).hasClass('disabled') || sel == '' )
+			return false;
+
+		sel = JSON.parse(sel);
+		if ( sel.w > 0 && sel.h > 0 && w > 0 && h > 0 ) {
+			sel['fw'] = w;
+			sel['fh'] = h;
+			this.addStep({ 'c': sel }, postid, nonce);
+		}
+	},
+
+	undo : function (postid, nonce) {
+		var t = this, button = $('#image-undo-' + postid), elem = $('#imgedit-undone-' + postid),
+			pop = t.intval( elem.val() ) + 1;
+
+		if ( button.hasClass('disabled') )
+			return;
+
+		elem.val(pop);
+		t.refreshEditor(postid, nonce, function() {
+			var elem = $('#imgedit-history-' + postid),
+			history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array();
+
+			t.setDisabled($('#image-redo-' + postid), true);
+			t.setDisabled(button, pop < history.length);
+		});
+	},
+
+	redo : function(postid, nonce) {
+		var t = this, button = $('#image-redo-' + postid), elem = $('#imgedit-undone-' + postid),
+			pop = t.intval( elem.val() ) - 1;
+
+		if ( button.hasClass('disabled') )
+			return;
+
+		elem.val(pop);
+		t.refreshEditor(postid, nonce, function() {
+			t.setDisabled($('#image-undo-' + postid), true);
+			t.setDisabled(button, pop > 0);
+		});
+	},
+
+	setNumSelection : function(postid) {
+		var sel, elX = $('#imgedit-sel-width-' + postid), elY = $('#imgedit-sel-height-' + postid),
+			x = this.intval( elX.val() ), y = this.intval( elY.val() ),
+			img = $('#image-preview-' + postid), imgh = img.height(), imgw = img.width(),
+			sizer = this.hold['sizer'], x1, y1, x2, y2, ias = this.iasapi;
+
+		if ( x < 1 ) {
+			elX.val('');
+			return false;
+		}
+
+		if ( y < 1 ) {
+			elY.val('');
+			return false;
+		}
+
+		if ( x && y && ( sel = ias.getSelection() ) ) {
+			x2 = sel.x1 + Math.round( x * sizer );
+			y2 = sel.y1 + Math.round( y * sizer );
+			x1 = sel.x1;
+			y1 = sel.y1;
+
+			if ( x2 > imgw ) {
+				x1 = 0;
+				x2 = imgw;
+				elX.val( Math.round( x2 / sizer ) );
+			}
+
+			if ( y2 > imgh ) {
+				y1 = 0;
+				y2 = imgh;
+				elY.val( Math.round( y2 / sizer ) );
+			}
+
+			ias.setSelection( x1, y1, x2, y2 );
+			ias.update();
+			this.setCropSelection(postid, ias.getSelection());
+		}
+	},
+
+	round : function(num) {
+		var s;
+		num = Math.round(num);
+
+		if ( this.hold.sizer > 0.6 )
+			return num;
+
+		s = num.toString().slice(-1);
+
+		if ( '1' == s )
+			return num - 1;
+		else if ( '9' == s )
+			return num + 1;
+
+		return num;
+	},
+
+	setRatioSelection : function(postid, n, el) {
+		var sel, r, x = this.intval( $('#imgedit-crop-width-' + postid).val() ),
+			y = this.intval( $('#imgedit-crop-height-' + postid).val() ),
+			h = $('#image-preview-' + postid).height();
+
+		if ( !this.intval( $(el).val() ) ) {
+			$(el).val('');
+			return;
+		}
+
+		if ( x && y ) {
+			this.iasapi.setOptions({
+				aspectRatio: x + ':' + y
+			});
+
+			if ( sel = this.iasapi.getSelection(true) ) {
+				r = Math.ceil( sel.y1 + ((sel.x2 - sel.x1) / (x / y)) );
+
+				if ( r > h ) {
+					r = h;
+					if ( n )
+						$('#imgedit-crop-height-' + postid).val('');
+					else
+						$('#imgedit-crop-width-' + postid).val('');
+				}
+
+				this.iasapi.setSelection( sel.x1, sel.y1, sel.x2, r );
+				this.iasapi.update();
+			}
+		}
+	}
+}
+})(jQuery);
Index: /tags/3.1/wp-admin/js/image-edit.js
===================================================================
--- /tags/3.1/wp-admin/js/image-edit.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/image-edit.js	(revision 17487)
@@ -0,0 +1,1 @@
+var imageEdit;(function(a){imageEdit={iasapi:{},hold:{},postid:"",intval:function(b){return b|0},setDisabled:function(c,b){if(b){c.removeClass("disabled");a("input",c).removeAttr("disabled")}else{c.addClass("disabled");a("input",c).attr("disabled","disabled")}},init:function(g,e){var d=this,c=a("#image-editor-"+d.postid),b=d.intval(a("#imgedit-x-"+g).val()),f=d.intval(a("#imgedit-y-"+g).val());if(d.postid!=g&&c.length){d.close(d.postid)}d.hold.w=d.hold.ow=b;d.hold.h=d.hold.oh=f;d.hold.xy_ratio=b/f;d.hold.sizer=parseFloat(a("#imgedit-sizer-"+g).val());d.postid=g;a("#imgedit-response-"+g).empty();a('input[type="text"]',"#imgedit-panel-"+g).keypress(function(i){var h=i.keyCode;if(36<h&&h<41){a(this).blur()}if(13==h){i.preventDefault();i.stopPropagation();return false}})},toggleEditor:function(d,b){var c=a("#imgedit-wait-"+d);if(b){c.height(a("#imgedit-panel-"+d).height()).fadeIn("fast")}else{c.fadeOut("fast")}},toggleHelp:function(b){a(b).siblings(".imgedit-help").slideToggle("fast");return false},getTarget:function(b){return a("input[name=imgedit-target-"+b+"]:checked","#imgedit-save-target-"+b).val()||"full"},scaleChanged:function(i,b){var d=a("#imgedit-scale-width-"+i),f=a("#imgedit-scale-height-"+i),g=a("#imgedit-scale-warn-"+i),c="",e="";if(b){e=(d.val()!="")?this.intval(d.val()/this.hold.xy_ratio):"";f.val(e)}else{c=(f.val()!="")?this.intval(f.val()*this.hold.xy_ratio):"";d.val(c)}if((e&&e>this.hold.oh)||(c&&c>this.hold.ow)){g.css("visibility","visible")}else{g.css("visibility","hidden")}},getSelRatio:function(f){var b=this.hold.w,e=this.hold.h,d=this.intval(a("#imgedit-crop-width-"+f).val()),c=this.intval(a("#imgedit-crop-height-"+f).val());if(d&&c){return d+":"+c}if(b&&e){return b+":"+e}return"1:1"},filterHistory:function(j,f){var d=a("#imgedit-history-"+j).val(),b,h,e,c,g=[];if(d!=""){d=JSON.parse(d);b=this.intval(a("#imgedit-undone-"+j).val());if(b>0){while(b>0){d.pop();b--}}if(f){if(!d.length){this.hold.w=this.hold.ow;this.hold.h=this.hold.oh;return""}e=d[d.length-1];e=e.c||e.r||e.f||false;if(e){this.hold.w=e.fw;this.hold.h=e.fh}}for(h in d){c=d[h];if(c.hasOwnProperty("c")){g[h]={c:{x:c.c.x,y:c.c.y,w:c.c.w,h:c.c.h}}}else{if(c.hasOwnProperty("r")){g[h]={r:c.r.r}}else{if(c.hasOwnProperty("f")){g[h]={f:c.f.f}}}}}return JSON.stringify(g)}return""},refreshEditor:function(g,d,f){var c=this,e,b;c.toggleEditor(g,1);e={action:"imgedit-preview",_ajax_nonce:d,postid:g,history:c.filterHistory(g,1),rand:c.intval(Math.random()*1000000)};b=a('<img id="image-preview-'+g+'" />');b.load(function(){var i,h,k=a("#imgedit-crop-"+g),j=imageEdit;k.empty().append(b);i=Math.max(j.hold.w,j.hold.h);h=Math.max(a(b).width(),a(b).height());j.hold.sizer=i>h?h/i:1;j.initCrop(g,b,k);j.setCropSelection(g,0);if((typeof f!="unknown")&&f!=null){f()}if(a("#imgedit-history-"+g).val()&&a("#imgedit-undone-"+g).val()==0){a("input.imgedit-submit-btn","#imgedit-panel-"+g).removeAttr("disabled")}else{a("input.imgedit-submit-btn","#imgedit-panel-"+g).attr("disabled","disabled")}j.toggleEditor(g,0)}).attr("src",ajaxurl+"?"+a.param(e))},action:function(b,g,c){var j=this,e,i,f,d,k;if(j.notsaved(b)){return false}e={action:"image-editor",_ajax_nonce:g,postid:b};if("scale"==c){i=a("#imgedit-scale-width-"+b),f=a("#imgedit-scale-height-"+b),d=j.intval(i.val()),k=j.intval(f.val());if(d<1){i.focus();return false}else{if(k<1){f.focus();return false}}if(d==j.hold.ow||k==j.hold.oh){return false}e["do"]="scale";e.fwidth=d;e.fheight=k}else{if("restore"==c){e["do"]="restore"}else{return false}}j.toggleEditor(b,1);a.post(ajaxurl,e,function(h){a("#image-editor-"+b).empty().append(h);j.toggleEditor(b,0)})},save:function(f,b){var c,e=this.getTarget(f),d=this.filterHistory(f,0);if(""==d){return false}this.toggleEditor(f,1);c={action:"image-editor",_ajax_nonce:b,postid:f,history:d,target:e,"do":"save"};a.post(ajaxurl,c,function(h){var g=JSON.parse(h);if(g.error){a("#imgedit-response-"+f).html('<div class="error"><p>'+g.error+"</p><div>");imageEdit.close(f);return}if(g.fw&&g.fh){a("#media-dims-"+f).html(g.fw+" &times; "+g.fh)}if(g.thumbnail){a(".thumbnail","#thumbnail-head-"+f).attr("src",""+g.thumbnail)}if(g.msg){a("#imgedit-response-"+f).html('<div class="updated"><p>'+g.msg+"</p></div>")}imageEdit.close(f)})},open:function(h,d){var f,e=a("#image-editor-"+h),c=a("#media-head-"+h),b=a("#imgedit-open-btn-"+h),g=b.siblings("img");b.attr("disabled","disabled");g.css("visibility","visible");f={action:"image-editor",_ajax_nonce:d,postid:h,"do":"open"};e.load(ajaxurl,f,function(){e.fadeIn("fast");c.fadeOut("fast",function(){b.removeAttr("disabled");g.css("visibility","hidden")})})},imgLoaded:function(d){var b=a("#image-preview-"+d),c=a("#imgedit-crop-"+d);this.initCrop(d,b,c);this.setCropSelection(d,0);this.toggleEditor(d,0)},initCrop:function(g,e,c){var b=this,d=a("#imgedit-sel-width-"+g),f=a("#imgedit-sel-height-"+g);b.iasapi=a(e).imgAreaSelect({parent:c,instance:true,handles:true,keys:true,minWidth:3,minHeight:3,onInit:function(h,i){c.children().mousedown(function(m){var k=false,l,j;if(m.shiftKey){l=b.iasapi.getSelection();j=b.getSelRatio(g);k=(l&&l.width&&l.height)?l.width+":"+l.height:j}b.iasapi.setOptions({aspectRatio:k})})},onSelectStart:function(h,i){imageEdit.setDisabled(a("#imgedit-crop-sel-"+g),1)},onSelectEnd:function(h,i){imageEdit.setCropSelection(g,i)},onSelectChange:function(h,j){var i=imageEdit.hold.sizer;d.val(imageEdit.round(j.width/i));f.val(imageEdit.round(j.height/i))}})},setCropSelection:function(g,f){var e,b=a("#imgedit-minthumb-"+g).val()||"128:128",d=this.hold.sizer;b=b.split(":");f=f||0;if(!f||(f.width<3&&f.height<3)){this.setDisabled(a(".imgedit-crop","#imgedit-panel-"+g),0);this.setDisabled(a("#imgedit-crop-sel-"+g),0);a("#imgedit-sel-width-"+g).val("");a("#imgedit-sel-height-"+g).val("");a("#imgedit-selection-"+g).val("");return false}if(f.width<(b[0]*d)&&f.height<(b[1]*d)){this.setDisabled(a(".imgedit-crop","#imgedit-panel-"+g),0);a("#imgedit-selection-"+g).val("");return false}e={x:f.x1,y:f.y1,w:f.width,h:f.height};this.setDisabled(a(".imgedit-crop","#imgedit-panel-"+g),1);a("#imgedit-selection-"+g).val(JSON.stringify(e))},close:function(c,b){b=b||false;if(b&&this.notsaved(c)){return false}this.iasapi={};this.hold={};a("#image-editor-"+c).fadeOut("fast",function(){a("#media-head-"+c).fadeIn("fast");a(this).empty()})},notsaved:function(e){var c=a("#imgedit-history-"+e).val(),d=(c!="")?JSON.parse(c):new Array(),b=this.intval(a("#imgedit-undone-"+e).val());if(b<d.length){if(confirm(a("#imgedit-leaving-"+e).html())){return false}return true}return false},addStep:function(i,h,d){var c=this,e=a("#imgedit-history-"+h),g=(e.val()!="")?JSON.parse(e.val()):new Array(),f=a("#imgedit-undone-"+h),b=c.intval(f.val());while(b>0){g.pop();b--}f.val(0);g.push(i);e.val(JSON.stringify(g));c.refreshEditor(h,d,function(){c.setDisabled(a("#image-undo-"+h),true);c.setDisabled(a("#image-redo-"+h),false)})},rotate:function(d,e,c,b){if(a(b).hasClass("disabled")){return false}this.addStep({r:{r:d,fw:this.hold.h,fh:this.hold.w}},e,c)},flip:function(d,e,c,b){if(a(b).hasClass("disabled")){return false}this.addStep({f:{f:d,fw:this.hold.w,fh:this.hold.h}},e,c)},crop:function(g,e,c){var f=a("#imgedit-selection-"+g).val(),b=this.intval(a("#imgedit-sel-width-"+g).val()),d=this.intval(a("#imgedit-sel-height-"+g).val());if(a(c).hasClass("disabled")||f==""){return false}f=JSON.parse(f);if(f.w>0&&f.h>0&&b>0&&d>0){f.fw=b;f.fh=d;this.addStep({c:f},g,e)}},undo:function(g,e){var d=this,c=a("#image-undo-"+g),f=a("#imgedit-undone-"+g),b=d.intval(f.val())+1;if(c.hasClass("disabled")){return}f.val(b);d.refreshEditor(g,e,function(){var h=a("#imgedit-history-"+g),i=(h.val()!="")?JSON.parse(h.val()):new Array();d.setDisabled(a("#image-redo-"+g),true);d.setDisabled(c,b<i.length)})},redo:function(g,e){var d=this,c=a("#image-redo-"+g),f=a("#imgedit-undone-"+g),b=d.intval(f.val())-1;if(c.hasClass("disabled")){return}f.val(b);d.refreshEditor(g,e,function(){d.setDisabled(a("#image-undo-"+g),true);d.setDisabled(c,b>0)})},setNumSelection:function(c){var g,k=a("#imgedit-sel-width-"+c),j=a("#imgedit-sel-height-"+c),o=this.intval(k.val()),m=this.intval(j.val()),i=a("#image-preview-"+c),p=i.height(),h=i.width(),b=this.hold.sizer,f,n,e,l,d=this.iasapi;if(o<1){k.val("");return false}if(m<1){j.val("");return false}if(o&&m&&(g=d.getSelection())){e=g.x1+Math.round(o*b);l=g.y1+Math.round(m*b);f=g.x1;n=g.y1;if(e>h){f=0;e=h;k.val(Math.round(e/b))}if(l>p){n=0;l=p;j.val(Math.round(l/b))}d.setSelection(f,n,e,l);d.update();this.setCropSelection(c,d.getSelection())}},round:function(b){var c;b=Math.round(b);if(this.hold.sizer>0.6){return b}c=b.toString().slice(-1);if("1"==c){return b-1}else{if("9"==c){return b+1}}return b},setRatioSelection:function(j,i,d){var f,e,b=this.intval(a("#imgedit-crop-width-"+j).val()),g=this.intval(a("#imgedit-crop-height-"+j).val()),c=a("#image-preview-"+j).height();if(!this.intval(a(d).val())){a(d).val("");return}if(b&&g){this.iasapi.setOptions({aspectRatio:b+":"+g});if(f=this.iasapi.getSelection(true)){e=Math.ceil(f.y1+((f.x2-f.x1)/(b/g)));if(e>c){e=c;if(i){a("#imgedit-crop-height-"+j).val("")}else{a("#imgedit-crop-width-"+j).val("")}}this.iasapi.setSelection(f.x1,f.y1,f.x2,e);this.iasapi.update()}}}}})(jQuery);
Index: /tags/3.1/wp-admin/js/inline-edit-post.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/inline-edit-post.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/inline-edit-post.dev.js	(revision 17487)
@@ -0,0 +1,289 @@
+(function($) {
+inlineEditPost = {
+
+	init : function(){
+		var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
+
+		t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
+		t.what = '#post-';
+
+		// prepare the edit rows
+		qeRow.keyup(function(e){
+			if (e.which == 27)
+				return inlineEditPost.revert();
+		});
+		bulkRow.keyup(function(e){
+			if (e.which == 27)
+				return inlineEditPost.revert();
+		});
+
+		$('a.cancel', qeRow).click(function(){
+			return inlineEditPost.revert();
+		});
+		$('a.save', qeRow).click(function(){
+			return inlineEditPost.save(this);
+		});
+		$('td', qeRow).keydown(function(e){
+			if ( e.which == 13 )
+				return inlineEditPost.save(this);
+		});
+
+		$('a.cancel', bulkRow).click(function(){
+			return inlineEditPost.revert();
+		});
+
+		$('#inline-edit .inline-edit-private input[value=private]').click( function(){
+			var pw = $('input.inline-edit-password-input');
+			if ( $(this).attr('checked') ) {
+				pw.val('').attr('disabled', 'disabled');
+			} else {
+				pw.attr('disabled', '');
+			}
+		});
+
+		// add events
+		$('a.editinline').live('click', function(){
+			inlineEditPost.edit(this);
+			return false;
+		});
+
+		$('#bulk-title-div').parents('fieldset').after(
+			$('#inline-edit fieldset.inline-edit-categories').clone()
+		).siblings( 'fieldset:last' ).prepend(
+			$('#inline-edit label.inline-edit-tags').clone()
+		);
+
+		// hiearchical taxonomies expandable?
+		$('span.catshow').click(function(){
+			$(this).hide().next().show().parent().next().addClass("cat-hover");
+		});
+
+		$('span.cathide').click(function(){
+			$(this).hide().prev().show().parent().next().removeClass("cat-hover");
+		});
+
+		$('select[name="_status"] option[value="future"]', bulkRow).remove();
+
+		$('#doaction, #doaction2').click(function(e){
+			var n = $(this).attr('id').substr(2);
+			if ( $('select[name="'+n+'"]').val() == 'edit' ) {
+				e.preventDefault();
+				t.setBulk();
+			} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
+				t.revert();
+			}
+		});
+
+		$('#post-query-submit').click(function(e){
+			if ( $('form#posts-filter tr.inline-editor').length > 0 )
+				t.revert();
+		});
+	},
+
+	toggle : function(el){
+		var t = this;
+		$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
+	},
+
+	setBulk : function(){
+		var te = '', type = this.type, tax, c = true;
+		this.revert();
+
+		$('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length);
+		$('table.widefat tbody').prepend( $('#bulk-edit') );
+		$('#bulk-edit').addClass('inline-editor').show();
+
+		$('tbody th.check-column input[type="checkbox"]').each(function(i){
+			if ( $(this).attr('checked') ) {
+				c = false;
+				var id = $(this).val(), theTitle;
+				theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle;
+				te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
+			}
+		});
+
+		if ( c )
+			return this.revert();
+
+		$('#bulk-titles').html(te);
+		$('#bulk-titles a').click(function(){
+			var id = $(this).attr('id').substr(1);
+
+			$('table.widefat input[value="'+id+'"]').attr('checked', '');
+			$('#ttle'+id).remove();
+		});
+
+		// enable autocomplete for tags
+		if ( 'post' == type ) {
+			// support multi taxonomies?
+			tax = 'post_tag';
+			$('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
+		}
+	},
+
+	edit : function(id) {
+		var t = this, fields, editRow, rowData, cats, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, tax;
+		t.revert();
+
+		if ( typeof(id) == 'object' )
+			id = t.getId(id);
+
+		fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];
+		if ( t.type == 'page' )
+			fields.push('post_parent', 'menu_order', 'page_template');
+
+		// add the new blank row
+		editRow = $('#inline-edit').clone(true);
+		$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
+
+		if ( $(t.what+id).hasClass('alternate') )
+			$(editRow).addClass('alternate');
+		$(t.what+id).hide().after(editRow);
+
+		// populate the data
+		rowData = $('#inline_'+id);
+		if ( !$(':input[name="post_author"] option[value=' + $('.post_author', rowData).text() + ']', editRow).val() ) {
+			// author no longer has edit caps, so we need to add them to the list of authors
+			$(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>');
+		}
+		if ( $(':input[name="post_author"] option', editRow).length == 1 ) {
+			$('label.inline-edit-author', editRow).hide();
+		}
+
+		for ( var f = 0; f < fields.length; f++ ) {
+			$(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() );
+		}
+
+		if ( $('.comment_status', rowData).text() == 'open' )
+			$('input[name="comment_status"]', editRow).attr("checked", "checked");
+		if ( $('.ping_status', rowData).text() == 'open' )
+			$('input[name="ping_status"]', editRow).attr("checked", "checked");
+		if ( $('.sticky', rowData).text() == 'sticky' )
+			$('input[name="sticky"]', editRow).attr("checked", "checked");
+
+		// hierarchical taxonomies
+		$('.post_category', rowData).each(function(){
+			var term_ids = $(this).text();
+
+			if ( term_ids ) {
+				taxname = $(this).attr('id').replace('_'+id, '');
+				$('ul.'+taxname+'-checklist :checkbox', editRow).val(term_ids.split(','));
+			}
+		});
+		//flat taxonomies
+		$('.tags_input', rowData).each(function(){
+			var terms = $(this).text();
+
+			if ( terms ) {
+				taxname = $(this).attr('id').replace('_'+id, '');
+				$('textarea.tax_input_'+taxname, editRow).val(terms);
+				$('textarea.tax_input_'+taxname, editRow).suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
+			}
+		});
+
+
+		// handle the post status
+		status = $('._status', rowData).text();
+		if ( 'future' != status )
+			$('select[name="_status"] option[value="future"]', editRow).remove();
+
+		if ( 'private' == status ) {
+			$('input[name="keep_private"]', editRow).attr("checked", "checked");
+			$('input.inline-edit-password-input').val('').attr('disabled', 'disabled');
+		}
+
+		// remove the current page and children from the parent dropdown
+		pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow);
+		if ( pageOpt.length > 0 ) {
+			pageLevel = pageOpt[0].className.split('-')[1];
+			nextPage = pageOpt;
+			while ( pageLoop ) {
+				nextPage = nextPage.next('option');
+				if (nextPage.length == 0) break;
+				nextLevel = nextPage[0].className.split('-')[1];
+				if ( nextLevel <= pageLevel ) {
+					pageLoop = false;
+				} else {
+					nextPage.remove();
+					nextPage = pageOpt;
+				}
+			}
+			pageOpt.remove();
+		}
+
+		$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
+		$('.ptitle', editRow).focus();
+
+		return false;
+	},
+
+	save : function(id) {
+		var params, fields, page = $('.post_status_page').val() || '';
+
+		if ( typeof(id) == 'object' )
+			id = this.getId(id);
+
+		$('table.widefat .inline-edit-save .waiting').show();
+
+		params = {
+			action: 'inline-save',
+			post_type: typenow,
+			post_ID: id,
+			edit_date: 'true',
+			post_status: page
+		};
+
+		fields = $('#edit-'+id+' :input').serialize();
+		params = fields + '&' + $.param(params);
+
+		// make ajax request
+		$.post('admin-ajax.php', params,
+			function(r) {
+				$('table.widefat .inline-edit-save .waiting').hide();
+
+				if (r) {
+					if ( -1 != r.indexOf('<tr') ) {
+						$(inlineEditPost.what+id).remove();
+						$('#edit-'+id).before(r).remove();
+						$(inlineEditPost.what+id).hide().fadeIn();
+					} else {
+						r = r.replace( /<.[^<>]*?>/g, '' );
+						$('#edit-'+id+' .inline-edit-save').append('<span class="error">'+r+'</span>');
+					}
+				} else {
+					$('#edit-'+id+' .inline-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>');
+				}
+			}
+		, 'html');
+		return false;
+	},
+
+	revert : function(){
+		var id = $('table.widefat tr.inline-editor').attr('id');
+
+		if ( id ) {
+			$('table.widefat .inline-edit-save .waiting').hide();
+
+			if ( 'bulk-edit' == id ) {
+				$('table.widefat #bulk-edit').removeClass('inline-editor').hide();
+				$('#bulk-titles').html('');
+				$('#inlineedit').append( $('#bulk-edit') );
+			} else {
+				$('#'+id).remove();
+				id = id.substr( id.lastIndexOf('-') + 1 );
+				$(this.what+id).show();
+			}
+		}
+
+		return false;
+	},
+
+	getId : function(o) {
+		var id = $(o).closest('tr').attr('id'),
+			parts = id.split('-');
+		return parts[parts.length - 1];
+	}
+};
+
+$(document).ready(function(){inlineEditPost.init();});
+})(jQuery);
Index: /tags/3.1/wp-admin/js/inline-edit-post.js
===================================================================
--- /tags/3.1/wp-admin/js/inline-edit-post.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/inline-edit-post.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){inlineEditPost={init:function(){var c=this,d=a("#inline-edit"),b=a("#bulk-edit");c.type=a("table.widefat").hasClass("pages")?"page":"post";c.what="#post-";d.keyup(function(f){if(f.which==27){return inlineEditPost.revert()}});b.keyup(function(f){if(f.which==27){return inlineEditPost.revert()}});a("a.cancel",d).click(function(){return inlineEditPost.revert()});a("a.save",d).click(function(){return inlineEditPost.save(this)});a("td",d).keydown(function(f){if(f.which==13){return inlineEditPost.save(this)}});a("a.cancel",b).click(function(){return inlineEditPost.revert()});a("#inline-edit .inline-edit-private input[value=private]").click(function(){var e=a("input.inline-edit-password-input");if(a(this).attr("checked")){e.val("").attr("disabled","disabled")}else{e.attr("disabled","")}});a("a.editinline").live("click",function(){inlineEditPost.edit(this);return false});a("#bulk-title-div").parents("fieldset").after(a("#inline-edit fieldset.inline-edit-categories").clone()).siblings("fieldset:last").prepend(a("#inline-edit label.inline-edit-tags").clone());a("span.catshow").click(function(){a(this).hide().next().show().parent().next().addClass("cat-hover")});a("span.cathide").click(function(){a(this).hide().prev().show().parent().next().removeClass("cat-hover")});a('select[name="_status"] option[value="future"]',b).remove();a("#doaction, #doaction2").click(function(f){var g=a(this).attr("id").substr(2);if(a('select[name="'+g+'"]').val()=="edit"){f.preventDefault();c.setBulk()}else{if(a("form#posts-filter tr.inline-editor").length>0){c.revert()}}});a("#post-query-submit").click(function(f){if(a("form#posts-filter tr.inline-editor").length>0){c.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},setBulk:function(){var e="",d=this.type,b,f=true;this.revert();a("#bulk-edit td").attr("colspan",a(".widefat:first thead th:visible").length);a("table.widefat tbody").prepend(a("#bulk-edit"));a("#bulk-edit").addClass("inline-editor").show();a('tbody th.check-column input[type="checkbox"]').each(function(g){if(a(this).attr("checked")){f=false;var h=a(this).val(),c;c=a("#inline_"+h+" .post_title").text()||inlineEditL10n.notitle;e+='<div id="ttle'+h+'"><a id="_'+h+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+c+"</div>"}});if(f){return this.revert()}a("#bulk-titles").html(e);a("#bulk-titles a").click(function(){var c=a(this).attr("id").substr(1);a('table.widefat input[value="'+c+'"]').attr("checked","");a("#ttle"+c).remove()});if("post"==d){b="post_tag";a('tr.inline-editor textarea[name="tags_input"]').suggest("admin-ajax.php?action=ajax-tag-search&tax="+b,{delay:500,minchars:2,multiple:true,multipleSep:", "})}},edit:function(b){var o=this,j,d,g,n,i,h,m,l,c=true,p,e;o.revert();if(typeof(b)=="object"){b=o.getId(b)}j=["post_title","post_name","post_author","_status","jj","mm","aa","hh","mn","ss","post_password"];if(o.type=="page"){j.push("post_parent","menu_order","page_template")}d=a("#inline-edit").clone(true);a("td",d).attr("colspan",a(".widefat:first thead th:visible").length);if(a(o.what+b).hasClass("alternate")){a(d).addClass("alternate")}a(o.what+b).hide().after(d);g=a("#inline_"+b);if(!a(':input[name="post_author"] option[value='+a(".post_author",g).text()+"]",d).val()){a(':input[name="post_author"]',d).prepend('<option value="'+a(".post_author",g).text()+'">'+a("#"+o.type+"-"+b+" .author").text()+"</option>")}if(a(':input[name="post_author"] option',d).length==1){a("label.inline-edit-author",d).hide()}for(var k=0;k<j.length;k++){a(':input[name="'+j[k]+'"]',d).val(a("."+j[k],g).text())}if(a(".comment_status",g).text()=="open"){a('input[name="comment_status"]',d).attr("checked","checked")}if(a(".ping_status",g).text()=="open"){a('input[name="ping_status"]',d).attr("checked","checked")}if(a(".sticky",g).text()=="sticky"){a('input[name="sticky"]',d).attr("checked","checked")}a(".post_category",g).each(function(){var f=a(this).text();if(f){taxname=a(this).attr("id").replace("_"+b,"");a("ul."+taxname+"-checklist :checkbox",d).val(f.split(","))}});a(".tags_input",g).each(function(){var f=a(this).text();if(f){taxname=a(this).attr("id").replace("_"+b,"");a("textarea.tax_input_"+taxname,d).val(f);a("textarea.tax_input_"+taxname,d).suggest("admin-ajax.php?action=ajax-tag-search&tax="+taxname,{delay:500,minchars:2,multiple:true,multipleSep:", "})}});i=a("._status",g).text();if("future"!=i){a('select[name="_status"] option[value="future"]',d).remove()}if("private"==i){a('input[name="keep_private"]',d).attr("checked","checked");a("input.inline-edit-password-input").val("").attr("disabled","disabled")}h=a('select[name="post_parent"] option[value="'+b+'"]',d);if(h.length>0){m=h[0].className.split("-")[1];l=h;while(c){l=l.next("option");if(l.length==0){break}p=l[0].className.split("-")[1];if(p<=m){c=false}else{l.remove();l=h}}h.remove()}a(d).attr("id","edit-"+b).addClass("inline-editor").show();a(".ptitle",d).focus();return false},save:function(e){var d,b,c=a(".post_status_page").val()||"";if(typeof(e)=="object"){e=this.getId(e)}a("table.widefat .inline-edit-save .waiting").show();d={action:"inline-save",post_type:typenow,post_ID:e,edit_date:"true",post_status:c};b=a("#edit-"+e+" :input").serialize();d=b+"&"+a.param(d);a.post("admin-ajax.php",d,function(f){a("table.widefat .inline-edit-save .waiting").hide();if(f){if(-1!=f.indexOf("<tr")){a(inlineEditPost.what+e).remove();a("#edit-"+e).before(f).remove();a(inlineEditPost.what+e).hide().fadeIn()}else{f=f.replace(/<.[^<>]*?>/g,"");a("#edit-"+e+" .inline-edit-save").append('<span class="error">'+f+"</span>")}}else{a("#edit-"+e+" .inline-edit-save").append('<span class="error">'+inlineEditL10n.error+"</span>")}},"html");return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .inline-edit-save .waiting").hide();if("bulk-edit"==b){a("table.widefat #bulk-edit").removeClass("inline-editor").hide();a("#bulk-titles").html("");a("#inlineedit").append(a("#bulk-edit"))}else{a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}}return false},getId:function(c){var d=a(c).closest("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditPost.init()})})(jQuery);
Index: /tags/3.1/wp-admin/js/inline-edit-tax.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/inline-edit-tax.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/inline-edit-tax.dev.js	(revision 17487)
@@ -0,0 +1,119 @@
+
+(function($) {
+inlineEditTax = {
+
+	init : function() {
+		var t = this, row = $('#inline-edit');
+
+		t.type = $('#the-list').attr('className').substr(5);
+		t.what = '#'+t.type+'-';
+
+		$('.editinline').live('click', function(){
+			inlineEditTax.edit(this);
+			return false;
+		});
+
+		// prepare the edit row
+		row.keyup(function(e) { if(e.which == 27) return inlineEditTax.revert(); });
+
+		$('a.cancel', row).click(function() { return inlineEditTax.revert(); });
+		$('a.save', row).click(function() { return inlineEditTax.save(this); });
+		$('input, select', row).keydown(function(e) { if(e.which == 13) return inlineEditTax.save(this); });
+
+		$('#posts-filter input[type="submit"]').click(function(e){
+			if ( $('form#posts-filter tr.inline-editor').length > 0 )
+				t.revert();
+		});
+	},
+
+	toggle : function(el) {
+		var t = this;
+		$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
+	},
+
+	edit : function(id) {
+		var t = this, editRow;
+		t.revert();
+
+		if ( typeof(id) == 'object' )
+			id = t.getId(id);
+
+		editRow = $('#inline-edit').clone(true), rowData = $('#inline_'+id);
+		$('td', editRow).attr('colspan', $('.widefat:first thead th:visible').length);
+
+		if ( $(t.what+id).hasClass('alternate') )
+			$(editRow).addClass('alternate');
+
+		$(t.what+id).hide().after(editRow);
+
+		$(':input[name="name"]', editRow).val( $('.name', rowData).text() );
+		$(':input[name="slug"]', editRow).val( $('.slug', rowData).text() );
+
+		$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
+		$('.ptitle', editRow).eq(0).focus();
+
+		return false;
+	},
+
+	save : function(id) {
+		var params, fields, tax = $('input[name="taxonomy"]').val() || '';
+
+		if( typeof(id) == 'object' )
+			id = this.getId(id);
+
+		$('table.widefat .inline-edit-save .waiting').show();
+
+		params = {
+			action: 'inline-save-tax',
+			tax_type: this.type,
+			tax_ID: id,
+			taxonomy: tax
+		};
+
+		fields = $('#edit-'+id+' :input').serialize();
+		params = fields + '&' + $.param(params);
+
+		// make ajax request
+		$.post('admin-ajax.php', params,
+			function(r) {
+				var row, new_id;
+				$('table.widefat .inline-edit-save .waiting').hide();
+
+				if (r) {
+					if ( -1 != r.indexOf('<tr') ) {
+						$(inlineEditTax.what+id).remove();
+						new_id = $(r).attr('id');
+
+						$('#edit-'+id).before(r).remove();
+						row = new_id ? $('#'+new_id) : $(inlineEditTax.what+id);
+						row.hide().fadeIn();
+					} else
+						$('#edit-'+id+' .inline-edit-save .error').html(r).show();
+				} else
+					$('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();
+			}
+		);
+		return false;
+	},
+
+	revert : function() {
+		var id = $('table.widefat tr.inline-editor').attr('id');
+
+		if ( id ) {
+			$('table.widefat .inline-edit-save .waiting').hide();
+			$('#'+id).remove();
+			id = id.substr( id.lastIndexOf('-') + 1 );
+			$(this.what+id).show();
+		}
+
+		return false;
+	},
+
+	getId : function(o) {
+		var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
+		return parts[parts.length - 1];
+	}
+};
+
+$(document).ready(function(){inlineEditTax.init();});
+})(jQuery);
Index: /tags/3.1/wp-admin/js/inline-edit-tax.js
===================================================================
--- /tags/3.1/wp-admin/js/inline-edit-tax.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/inline-edit-tax.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){inlineEditTax={init:function(){var b=this,c=a("#inline-edit");b.type=a("#the-list").attr("className").substr(5);b.what="#"+b.type+"-";a(".editinline").live("click",function(){inlineEditTax.edit(this);return false});c.keyup(function(d){if(d.which==27){return inlineEditTax.revert()}});a("a.cancel",c).click(function(){return inlineEditTax.revert()});a("a.save",c).click(function(){return inlineEditTax.save(this)});a("input, select",c).keydown(function(d){if(d.which==13){return inlineEditTax.save(this)}});a('#posts-filter input[type="submit"]').click(function(d){if(a("form#posts-filter tr.inline-editor").length>0){b.revert()}})},toggle:function(c){var b=this;a(b.what+b.getId(c)).css("display")=="none"?b.revert():b.edit(c)},edit:function(d){var c=this,b;c.revert();if(typeof(d)=="object"){d=c.getId(d)}b=a("#inline-edit").clone(true),rowData=a("#inline_"+d);a("td",b).attr("colspan",a(".widefat:first thead th:visible").length);if(a(c.what+d).hasClass("alternate")){a(b).addClass("alternate")}a(c.what+d).hide().after(b);a(':input[name="name"]',b).val(a(".name",rowData).text());a(':input[name="slug"]',b).val(a(".slug",rowData).text());a(b).attr("id","edit-"+d).addClass("inline-editor").show();a(".ptitle",b).eq(0).focus();return false},save:function(e){var d,b,c=a('input[name="taxonomy"]').val()||"";if(typeof(e)=="object"){e=this.getId(e)}a("table.widefat .inline-edit-save .waiting").show();d={action:"inline-save-tax",tax_type:this.type,tax_ID:e,taxonomy:c};b=a("#edit-"+e+" :input").serialize();d=b+"&"+a.param(d);a.post("admin-ajax.php",d,function(g){var h,f;a("table.widefat .inline-edit-save .waiting").hide();if(g){if(-1!=g.indexOf("<tr")){a(inlineEditTax.what+e).remove();f=a(g).attr("id");a("#edit-"+e).before(g).remove();h=f?a("#"+f):a(inlineEditTax.what+e);h.hide().fadeIn()}else{a("#edit-"+e+" .inline-edit-save .error").html(g).show()}}else{a("#edit-"+e+" .inline-edit-save .error").html(inlineEditL10n.error).show()}});return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .inline-edit-save .waiting").hide();a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}return false},getId:function(c){var d=c.tagName=="TR"?c.id:a(c).parents("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){inlineEditTax.init()})})(jQuery);
Index: /tags/3.1/wp-admin/js/link.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/link.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/link.dev.js	(revision 17487)
@@ -0,0 +1,67 @@
+jQuery(document).ready( function($) {
+
+	var newCat, noSyncChecks = false, syncChecks, catAddAfter;
+
+	$('#link_name').focus();
+	// postboxes
+	postboxes.add_postbox_toggles('link');
+
+	// category tabs
+	$('#category-tabs a').click(function(){
+		var t = $(this).attr('href');
+		$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
+		$('.tabs-panel').hide();
+		$(t).show();
+		if ( '#categories-all' == t )
+			deleteUserSetting('cats');
+		else
+			setUserSetting('cats','pop');
+		return false;
+	});
+	if ( getUserSetting('cats') )
+		$('#category-tabs a[href="#categories-pop"]').click();
+
+	// Ajax Cat
+	newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
+	$('#category-add-submit').click( function() { newCat.focus(); } );
+	syncChecks = function() {
+		if ( noSyncChecks )
+			return;
+		noSyncChecks = true;
+		var th = $(this), c = th.is(':checked'), id = th.val().toString();
+		$('#in-link-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
+		noSyncChecks = false;
+	};
+
+	catAddAfter = function( r, s ) {
+		$(s.what + ' response_data', r).each( function() {
+			var t = $($(this).text());
+			t.find( 'label' ).each( function() {
+				var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
+				$('#' + id).change( syncChecks );
+				o = $( '<option value="' +  parseInt( val, 10 ) + '"></option>' ).text( name );
+			} );
+		} );
+	};
+
+	$('#categorychecklist').wpList( {
+		alt: '',
+		what: 'link-category',
+		response: 'category-ajax-response',
+		addAfter: catAddAfter
+	} );
+
+	$('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
+	$('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
+	if ( 'pop' == getUserSetting('cats') )
+		$('a[href="#categories-pop"]').click();
+
+	$('#category-add-toggle').click( function() {
+		$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
+		$('#category-tabs a[href="#categories-all"]').click();
+		$('#newcategory').focus();
+		return false;
+	} );
+
+	$('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
+});
Index: /tags/3.1/wp-admin/js/link.js
===================================================================
--- /tags/3.1/wp-admin/js/link.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/link.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(c){var b,a=false,d,e;c("#link_name").focus();postboxes.add_postbox_toggles("link");c("#category-tabs a").click(function(){var f=c(this).attr("href");c(this).parent().addClass("tabs").siblings("li").removeClass("tabs");c(".tabs-panel").hide();c(f).show();if("#categories-all"==f){deleteUserSetting("cats")}else{setUserSetting("cats","pop")}return false});if(getUserSetting("cats")){c('#category-tabs a[href="#categories-pop"]').click()}b=c("#newcat").one("focus",function(){c(this).val("").removeClass("form-input-tip")});c("#category-add-submit").click(function(){b.focus()});d=function(){if(a){return}a=true;var f=c(this),h=f.is(":checked"),g=f.val().toString();c("#in-link-category-"+g+", #in-popular-category-"+g).attr("checked",h);a=false};e=function(g,f){c(f.what+" response_data",g).each(function(){var h=c(c(this).text());h.find("label").each(function(){var j=c(this),l=j.find("input").val(),m=j.find("input")[0].id,i=c.trim(j.text()),k;c("#"+m).change(d);k=c('<option value="'+parseInt(l,10)+'"></option>').text(i)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:e});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");c('#category-tabs a[href="#categories-all"]').click();c("#newcategory").focus();return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});
Index: /tags/3.1/wp-admin/js/list-table.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/list-table.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/list-table.dev.js	(revision 17487)
@@ -0,0 +1,337 @@
+jQuery(document).ready(function($) {
+
+window.listTable = {
+
+	init: function() {
+		this.loading = false;
+
+		this.reset( '.tablenav, .search-box, .wp-list-table' );
+
+		if ( '' == $.query.GET('paged') )
+			$.query.SET('paged', 1);
+		this.set_total_pages();
+
+		this.$tbody = $('#the-list, #the-comment-list');
+	},
+
+	/**
+	 * Simulates form.reset() for all input, select, and textarea elements
+	 * within a provided context.
+	 */
+	reset: function( context ) {
+		context = $(context);
+
+		$('input', context).each( function(){
+			this.value = this.defaultValue;
+			this.checked = this.defaultChecked;
+		});
+
+		$('select', context).each( function(){
+			var options = $('option', this),
+				anySelected = false;
+
+			options.each( function(){
+				this.selected = this.defaultSelected;
+				anySelected = anySelected || this.defaultSelected;
+			});
+
+			// If no options are selected within a single-select dropdown,
+			// select the first element by default.
+			if ( ! this.multiple && ! anySelected )
+				options[0].selected = true;
+		});
+
+		$('textarea', context).each( function(){
+			this.value = this.defaultValue;
+		});
+	},
+
+	// paging
+	set_total_pages: function(num) {
+		var last_page_url = $('.last-page').attr('href');
+
+		if ( last_page_url )
+			this.total_pages = num || $.query.load( last_page_url ).get('paged');
+	},
+
+	get_total_pages: function() {
+		return this.total_pages;
+	},
+
+	htmlencode: function(value) {
+		return $('<div/>').text(value).html();
+	},
+
+	update_rows: function(args, reset_paging, callback) {
+		if ( this.loading )
+			return false;
+
+		var different = false, data = {};
+
+		$.each(args, function(key, val) {
+			if ( val != $.query.GET(key) ) {
+				$.query.SET(key, val);
+				different = true;
+			}
+		});
+
+		if ( !different )
+			return false;
+
+		this.start_loading();
+
+		if ( reset_paging )
+			$.query.SET('paged', 1);
+
+		$.each( $.query.get(), function(key, value) {
+			if ( true === value )
+				data[key] = '';
+			else
+				data[key] = value;
+		});
+
+		this._callback = callback;
+
+		this.fetch_list(
+			data,
+			$.proxy(this, 'handle_success'),
+			$.proxy(this, 'handle_error')
+		);
+
+		return true;
+	},
+
+	fetch_list: function(data, success_callback, error_callback) {
+		data = $.extend(data, {
+			'action': 'fetch-list',
+			'list_args': list_args,
+			'_ajax_fetch_list_nonce': $('#_ajax_fetch_list_nonce').val()
+		});
+
+		$.ajax({
+			url: ajaxurl,
+			global: false,
+			dataType: 'json',
+			data: data,
+			success: success_callback,
+			error: error_callback
+		});
+	},
+
+	handle_success: function(response) {
+		if ( 'object' != typeof response ) {
+			this.handle_error();
+		} else {
+			var tablenav = $('.tablenav-pages');
+
+			this.stop_loading();
+
+			$('div.updated, div.error').not('.persistent, .inline').remove();
+
+			this.$tbody.html(response.rows);
+
+			$('.displaying-num').html(response.total_items_i18n);
+			$('.total-pages').html(response.total_pages_i18n);
+
+			this.set_total_pages(response.total_pages);
+
+			if ( response.total_pages > 1 )
+				tablenav.removeClass('one-page');
+
+			$('.current-page').val($.query.GET('paged'));
+
+			// Disable buttons that should noop.
+			tablenav.find('.first-page, .prev-page').toggleClass('disabled', 1 == $.query.GET('paged'));
+			tablenav.find('.next-page, .last-page').toggleClass('disabled', response.total_pages == $.query.GET('paged'));
+
+			$('th.column-cb :input').attr('checked', false);
+
+			if ( history.replaceState ) {
+				history.replaceState({}, '', location.pathname + $.query);
+			}
+
+			if ( this._callback )
+				this._callback();
+		}
+	},
+
+	handle_error: function() {
+		this.stop_loading();
+
+		$('h2').after('<div class="error ajax below-h2"><p>' + listTableL10n.error + '</p></div>');
+	},
+
+	start_loading: function() {
+		this.loading = true;
+
+		$('.error.ajax').remove();
+
+		$('.list-ajax-loading').css('visibility', 'visible');
+	},
+
+	stop_loading: function() {
+		this.loading = false;
+
+		$('.list-ajax-loading').css('visibility', 'hidden');
+	}
+}
+
+listTable.init();
+
+// Ajaxify various UI elements
+
+	function change_page(paged, $el) {
+		if ( paged < 1 )
+			paged = 1;
+
+		if ( paged > listTable.get_total_pages() )
+			paged = listTable.get_total_pages();
+
+		$(listTable).trigger('beforeChangePage');
+		listTable.update_rows({'paged': paged}, false, function() {
+			if ( $el.parents('.tablenav.bottom').length )
+				scrollTo(0, 0);
+
+			$(listTable).trigger('changePage');
+		});
+	}
+
+	// pagination
+	$('.tablenav-pages a').click(function() {
+		var $el = $(this),
+			paged = $.query.GET('paged');
+
+		switch ( $el.attr('class') ) {
+			case 'first-page':
+				paged = 1;
+				break;
+			case 'prev-page':
+				paged -= 1;
+				break;
+			case 'next-page':
+				paged += 1;
+				break;
+			case 'last-page':
+				paged = listTable.get_total_pages();
+				break;
+		}
+
+		change_page(paged, $el);
+
+		return false;
+	});
+
+	$('.current-page').keypress(function(e) {
+		if ( 13 != e.keyCode )
+			return;
+
+		var $el = $(this);
+
+		change_page(parseInt($el.val()) || 1, $el);
+
+		return false;
+	});
+
+	// sortable columns
+	$('th.sortable a, th.sorted a').click(function() {
+
+		function get_initial_order($el) {
+			return $.query.load( $el.find('a').attr('href') ).get('order');
+		}
+
+		var $link = $(this),
+			$th = $link.parent('th'),
+			thIndex = $th.index(),
+			orderby = $.query.load( $link.attr('href') ).get('orderby'),
+			order;
+
+		// th should include both headers in thead and tfoot
+		$th = $th.closest('table').find('thead th:eq(' + thIndex + '), tfoot th:eq(' + thIndex + ')');
+
+		if ( orderby == $.query.get('orderby') ) {
+			// changing the direction
+			order = ( 'asc' == $.query.get('order') ) ? 'desc' : 'asc';
+		} else {
+			// changing the parameter
+			order = get_initial_order($th);
+
+			var $old_th = $('th.sorted');
+			if ( $old_th.length ) {
+				$old_th.removeClass('sorted').addClass('sortable');
+				$old_th.removeClass('desc').removeClass('asc').addClass(
+					'asc' == get_initial_order( $old_th ) ? 'desc' : 'asc'
+				);
+			}
+
+			$th.removeClass('sortable').addClass('sorted');
+		}
+
+		$th.removeClass('desc').removeClass('asc').addClass(order);
+
+		listTable.update_rows({'orderby': orderby, 'order': order}, true);
+
+		return false;
+	});
+
+	// searchbox
+	function change_search(ev) {
+		if ( 'keypress' == ev.type && 13 != ev.keyCode )
+			return;
+
+		ev.preventDefault();
+		ev.stopImmediatePropagation();
+
+		var data = $(this).parent('.search-box').find(':input').serializeObject();
+
+		listTable.update_rows(data, true, function() {
+			if ( $('h2.nav-tab-wrapper').length )
+				return;
+
+			if ( 'site-users-network' == pagenow || 'site-themes-network' == pagenow ) {
+				$('h4.search-text').remove();
+
+				if ( data.s )
+					$('ul.subsubsub').after($('<h4 class="clear search-text">').html(
+						listTableL10n.search.replace('%s', this.htmlencode(data.s))
+					));
+			} else {
+				$('h2 .subtitle').remove();
+
+				if ( data.s )
+					$('h2').append($('<span class="subtitle">').html(
+						listTableL10n.search.replace('%s', this.htmlencode(data.s))
+					));
+			}
+		});
+	}
+	$('.search-box :submit').click(change_search);
+	$('.search-box :text').keypress(change_search);
+
+	// tablenav dropdowns
+	$('#post-query-submit').click(function() {
+		var args = {};
+
+		$(this).parents('.actions').find('select[name!="action"]').each(function() {
+			var $el = $(this);
+
+			args[$el.attr('name')] = $el.val();
+		});
+
+		listTable.update_rows(args, true);
+
+		return false;
+	});
+
+	// view switch
+	$('.view-switch a').click(function() {
+		var $this = $(this);
+
+		listTable.update_rows({'mode': $.query.load($this.attr('href')).get('mode')}, false, function() {
+			$('.view-switch .current').removeClass('current');
+			$this.addClass('current');
+		});
+
+		return false;
+	});
+});
+
Index: /tags/3.1/wp-admin/js/list-table.js
===================================================================
--- /tags/3.1/wp-admin/js/list-table.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/list-table.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(a){window.listTable={init:function(){this.loading=false;this.reset(".tablenav, .search-box, .wp-list-table");if(""==a.query.GET("paged")){a.query.SET("paged",1)}this.set_total_pages();this.$tbody=a("#the-list, #the-comment-list")},reset:function(d){d=a(d);a("input",d).each(function(){this.value=this.defaultValue;this.checked=this.defaultChecked});a("select",d).each(function(){var e=a("option",this),f=false;e.each(function(){this.selected=this.defaultSelected;f=f||this.defaultSelected});if(!this.multiple&&!f){e[0].selected=true}});a("textarea",d).each(function(){this.value=this.defaultValue})},set_total_pages:function(e){var d=a(".last-page").attr("href");if(d){this.total_pages=e||a.query.load(d).get("paged")}},get_total_pages:function(){return this.total_pages},htmlencode:function(d){return a("<div/>").text(d).html()},update_rows:function(e,d,h){if(this.loading){return false}var g=false,f={};a.each(e,function(i,j){if(j!=a.query.GET(i)){a.query.SET(i,j);g=true}});if(!g){return false}this.start_loading();if(d){a.query.SET("paged",1)}a.each(a.query.get(),function(i,j){if(true===j){f[i]=""}else{f[i]=j}});this._callback=h;this.fetch_list(f,a.proxy(this,"handle_success"),a.proxy(this,"handle_error"));return true},fetch_list:function(e,f,d){e=a.extend(e,{action:"fetch-list",list_args:list_args,_ajax_fetch_list_nonce:a("#_ajax_fetch_list_nonce").val()});a.ajax({url:ajaxurl,global:false,dataType:"json",data:e,success:f,error:d})},handle_success:function(d){if("object"!=typeof d){this.handle_error()}else{var e=a(".tablenav-pages");this.stop_loading();a("div.updated, div.error").not(".persistent, .inline").remove();this.$tbody.html(d.rows);a(".displaying-num").html(d.total_items_i18n);a(".total-pages").html(d.total_pages_i18n);this.set_total_pages(d.total_pages);if(d.total_pages>1){e.removeClass("one-page")}a(".current-page").val(a.query.GET("paged"));e.find(".first-page, .prev-page").toggleClass("disabled",1==a.query.GET("paged"));e.find(".next-page, .last-page").toggleClass("disabled",d.total_pages==a.query.GET("paged"));a("th.column-cb :input").attr("checked",false);if(history.replaceState){history.replaceState({},"",location.pathname+a.query)}if(this._callback){this._callback()}}},handle_error:function(){this.stop_loading();a("h2").after('<div class="error ajax below-h2"><p>'+listTableL10n.error+"</p></div>")},start_loading:function(){this.loading=true;a(".error.ajax").remove();a(".list-ajax-loading").css("visibility","visible")},stop_loading:function(){this.loading=false;a(".list-ajax-loading").css("visibility","hidden")}};listTable.init();function b(e,d){if(e<1){e=1}if(e>listTable.get_total_pages()){e=listTable.get_total_pages()}a(listTable).trigger("beforeChangePage");listTable.update_rows({paged:e},false,function(){if(d.parents(".tablenav.bottom").length){scrollTo(0,0)}a(listTable).trigger("changePage")})}a(".tablenav-pages a").click(function(){var e=a(this),d=a.query.GET("paged");switch(e.attr("class")){case"first-page":d=1;break;case"prev-page":d-=1;break;case"next-page":d+=1;break;case"last-page":d=listTable.get_total_pages();break}b(d,e);return false});a(".current-page").keypress(function(f){if(13!=f.keyCode){return}var d=a(this);b(parseInt(d.val())||1,d);return false});a("th.sortable a, th.sorted a").click(function(){function i(k){return a.query.load(k.find("a").attr("href")).get("order")}var f=a(this),h=f.parent("th"),g=h.index(),j=a.query.load(f.attr("href")).get("orderby"),e;h=h.closest("table").find("thead th:eq("+g+"), tfoot th:eq("+g+")");if(j==a.query.get("orderby")){e=("asc"==a.query.get("order"))?"desc":"asc"}else{e=i(h);var d=a("th.sorted");if(d.length){d.removeClass("sorted").addClass("sortable");d.removeClass("desc").removeClass("asc").addClass("asc"==i(d)?"desc":"asc")}h.removeClass("sortable").addClass("sorted")}h.removeClass("desc").removeClass("asc").addClass(e);listTable.update_rows({orderby:j,order:e},true);return false});function c(d){if("keypress"==d.type&&13!=d.keyCode){return}d.preventDefault();d.stopImmediatePropagation();var e=a(this).parent(".search-box").find(":input").serializeObject();listTable.update_rows(e,true,function(){if(a("h2.nav-tab-wrapper").length){return}if("site-users-network"==pagenow||"site-themes-network"==pagenow){a("h4.search-text").remove();if(e.s){a("ul.subsubsub").after(a('<h4 class="clear search-text">').html(listTableL10n.search.replace("%s",this.htmlencode(e.s))))}}else{a("h2 .subtitle").remove();if(e.s){a("h2").append(a('<span class="subtitle">').html(listTableL10n.search.replace("%s",this.htmlencode(e.s))))}}})}a(".search-box :submit").click(c);a(".search-box :text").keypress(c);a("#post-query-submit").click(function(){var d={};a(this).parents(".actions").find('select[name!="action"]').each(function(){var e=a(this);d[e.attr("name")]=e.val()});listTable.update_rows(d,true);return false});a(".view-switch a").click(function(){var d=a(this);listTable.update_rows({mode:a.query.load(d.attr("href")).get("mode")},false,function(){a(".view-switch .current").removeClass("current");d.addClass("current")});return false})});
Index: /tags/3.1/wp-admin/js/media-upload.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/media-upload.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/media-upload.dev.js	(revision 17487)
@@ -0,0 +1,69 @@
+// send html to the post editor
+function send_to_editor(h) {
+	var ed;
+
+	if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
+		ed.focus();
+		if ( tinymce.isIE )
+			ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
+
+		if ( h.indexOf('[caption') === 0 ) {
+			if ( ed.plugins.wpeditimage )
+				h = ed.plugins.wpeditimage._do_shcode(h);
+		} else if ( h.indexOf('[gallery') === 0 ) {
+			if ( ed.plugins.wpgallery )
+				h = ed.plugins.wpgallery._do_gallery(h);
+		} else if ( h.indexOf('[embed') === 0 ) {
+			if ( ed.plugins.wordpress )
+				h = ed.plugins.wordpress._setEmbed(h);
+		}
+
+		ed.execCommand('mceInsertContent', false, h);
+
+	} else if ( typeof edInsertContent == 'function' ) {
+		edInsertContent(edCanvas, h);
+	} else {
+		jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
+	}
+
+	tb_remove();
+}
+
+// thickbox settings
+var tb_position;
+(function($) {
+	tb_position = function() {
+		var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width, adminbar_height = 0;
+
+		if ( $('body.admin-bar').length )
+			adminbar_height = 28;
+
+		if ( tbWindow.size() ) {
+			tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
+			$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
+			tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
+			if ( typeof document.body.style.maxWidth != 'undefined' )
+				tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
+		};
+
+		return $('a.thickbox').each( function() {
+			var href = $(this).attr('href');
+			if ( ! href ) return;
+			href = href.replace(/&width=[0-9]+/g, '');
+			href = href.replace(/&height=[0-9]+/g, '');
+			$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
+		});
+	};
+
+	$(window).resize(function(){ tb_position(); });
+
+})(jQuery);
+
+jQuery(document).ready(function($){
+	$('a.thickbox').click(function(){
+		if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) {
+			tinyMCE.get('content').focus();
+			tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple');
+		}
+	});
+});
Index: /tags/3.1/wp-admin/js/media-upload.js
===================================================================
--- /tags/3.1/wp-admin/js/media-upload.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/media-upload.js	(revision 17487)
@@ -0,0 +1,1 @@
+function send_to_editor(b){var a;if(typeof tinyMCE!="undefined"&&(a=tinyMCE.activeEditor)&&!a.isHidden()){a.focus();if(tinymce.isIE){a.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark)}if(b.indexOf("[caption")===0){if(a.plugins.wpeditimage){b=a.plugins.wpeditimage._do_shcode(b)}}else{if(b.indexOf("[gallery")===0){if(a.plugins.wpgallery){b=a.plugins.wpgallery._do_gallery(b)}}else{if(b.indexOf("[embed")===0){if(a.plugins.wordpress){b=a.plugins.wordpress._setEmbed(b)}}}}a.execCommand("mceInsertContent",false,b)}else{if(typeof edInsertContent=="function"){edInsertContent(edCanvas,b)}else{jQuery(edCanvas).val(jQuery(edCanvas).val()+b)}}tb_remove()}var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()})})(jQuery);jQuery(document).ready(function(a){a("a.thickbox").click(function(){if(typeof tinyMCE!="undefined"&&tinyMCE.activeEditor){tinyMCE.get("content").focus();tinyMCE.activeEditor.windowManager.bookmark=tinyMCE.activeEditor.selection.getBookmark("simple")}})});
Index: /tags/3.1/wp-admin/js/media.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/media.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/media.dev.js	(revision 17487)
@@ -0,0 +1,97 @@
+
+var findPosts;
+(function($){
+	findPosts = {
+		open : function(af_name, af_val) {
+			var st = document.documentElement.scrollTop || $(document).scrollTop();
+
+			if ( af_name && af_val ) {
+				$('#affected').attr('name', af_name).val(af_val);
+			}
+			$('#find-posts').show().draggable({
+				handle: '#find-posts-head'
+			}).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-250px'});
+
+			$('#find-posts-input').focus().keyup(function(e){
+				if (e.which == 27) { findPosts.close(); } // close on Escape
+			});
+
+			return false;
+		},
+
+		close : function() {
+			$('#find-posts-response').html('');
+			$('#find-posts').draggable('destroy').hide();
+		},
+
+		send : function() {
+			var post = {
+				ps: $('#find-posts-input').val(),
+				action: 'find_posts',
+				_ajax_nonce: $('#_ajax_nonce').val()
+			};
+
+			var selectedItem;
+			$("input[@name='itemSelect[]']:checked").each(function() { selectedItem = $(this).val() });
+			post['post_type'] = selectedItem;
+
+			$.ajax({
+				type : 'POST',
+				url : ajaxurl,
+				data : post,
+				success : function(x) { findPosts.show(x); },
+				error : function(r) { findPosts.error(r); }
+			});
+		},
+
+		show : function(x) {
+
+			if ( typeof(x) == 'string' ) {
+				this.error({'responseText': x});
+				return;
+			}
+
+			var r = wpAjax.parseAjaxResponse(x);
+
+			if ( r.errors ) {
+				this.error({'responseText': wpAjax.broken});
+			}
+			r = r.responses[0];
+			$('#find-posts-response').html(r.data);
+		},
+
+		error : function(r) {
+			var er = r.statusText;
+
+			if ( r.responseText ) {
+				er = r.responseText.replace( /<.[^<>]*?>/g, '' );
+			}
+			if ( er ) {
+				$('#find-posts-response').html(er);
+			}
+		}
+	};
+
+	$(document).ready(function() {
+		$('#find-posts-submit').click(function(e) {
+			if ( '' == $('#find-posts-response').html() )
+				e.preventDefault();
+		});
+		$( '#find-posts .find-box-search :input' ).keypress( function( event ) {
+			if ( 13 == event.which ) {
+				findPosts.send();
+				return false;
+			}
+		} );
+		$( '#find-posts-search' ).click( findPosts.send );
+		$( '#find-posts-close' ).click( findPosts.close );
+		$('#doaction, #doaction2').click(function(e){
+			$('select[name^="action"]').each(function(){
+				if ( $(this).val() == 'attach' ) {
+					e.preventDefault();
+					findPosts.open();
+				}
+			});
+		});
+	});
+})(jQuery);
Index: /tags/3.1/wp-admin/js/media.js
===================================================================
--- /tags/3.1/wp-admin/js/media.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/media.js	(revision 17487)
@@ -0,0 +1,1 @@
+var findPosts;(function(a){findPosts={open:function(d,c){var b=document.documentElement.scrollTop||a(document).scrollTop();if(d&&c){a("#affected").attr("name",d).val(c)}a("#find-posts").show().draggable({handle:"#find-posts-head"}).css({top:b+50+"px",left:"50%",marginLeft:"-250px"});a("#find-posts-input").focus().keyup(function(f){if(f.which==27){findPosts.close()}});return false},close:function(){a("#find-posts-response").html("");a("#find-posts").draggable("destroy").hide()},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()};var c;a("input[@name='itemSelect[]']:checked").each(function(){c=a(this).val()});b.post_type=c;a.ajax({type:"POST",url:ajaxurl,data:b,success:function(d){findPosts.show(d)},error:function(d){findPosts.error(d)}})},show:function(b){if(typeof(b)=="string"){this.error({responseText:b});return}var c=wpAjax.parseAjaxResponse(b);if(c.errors){this.error({responseText:wpAjax.broken})}c=c.responses[0];a("#find-posts-response").html(c.data)},error:function(b){var c=b.statusText;if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#find-posts-response").html(c)}}};a(document).ready(function(){a("#find-posts-submit").click(function(b){if(""==a("#find-posts-response").html()){b.preventDefault()}});a("#find-posts .find-box-search :input").keypress(function(b){if(13==b.which){findPosts.send();return false}});a("#find-posts-search").click(findPosts.send);a("#find-posts-close").click(findPosts.close);a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){if(a(this).val()=="attach"){b.preventDefault();findPosts.open()}})})})})(jQuery);
Index: /tags/3.1/wp-admin/js/nav-menu.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/nav-menu.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/nav-menu.dev.js	(revision 17487)
@@ -0,0 +1,959 @@
+/**
+ * WordPress Administration Navigation Menu
+ * Interface JS functions
+ *
+ * @version 2.0.0
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+var wpNavMenu;
+
+(function($) {
+
+	var api = wpNavMenu = {
+
+		options : {
+			menuItemDepthPerLevel : 30, // Do not use directly. Use depthToPx and pxToDepth instead.
+			globalMaxDepth : 11
+		},
+
+		menuList : undefined,	// Set in init.
+		targetList : undefined, // Set in init.
+		menusChanged : false,
+		isRTL: !! ( 'undefined' != typeof isRtl && isRtl ),
+		negateIfRTL: ( 'undefined' != typeof isRtl && isRtl ) ? -1 : 1,
+
+		// Functions that run on init.
+		init : function() {
+			api.menuList = $('#menu-to-edit');
+			api.targetList = api.menuList;
+
+			this.jQueryExtensions();
+
+			this.attachMenuEditListeners();
+
+			this.setupInputWithDefaultTitle();
+			this.attachQuickSearchListeners();
+			this.attachThemeLocationsListeners();
+
+			this.attachTabsPanelListeners();
+
+			this.attachUnsavedChangesListener();
+
+			if( api.menuList.length ) // If no menu, we're in the + tab.
+				this.initSortables();
+
+			this.initToggles();
+
+			this.initTabManager();
+		},
+
+		jQueryExtensions : function() {
+			// jQuery extensions
+			$.fn.extend({
+				menuItemDepth : function() {
+					var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left');
+					return api.pxToDepth( margin && -1 != margin.indexOf('px') ? margin.slice(0, -2) : 0 );
+				},
+				updateDepthClass : function(current, prev) {
+					return this.each(function(){
+						var t = $(this);
+						prev = prev || t.menuItemDepth();
+						$(this).removeClass('menu-item-depth-'+ prev )
+							.addClass('menu-item-depth-'+ current );
+					});
+				},
+				shiftDepthClass : function(change) {
+					return this.each(function(){
+						var t = $(this),
+							depth = t.menuItemDepth();
+						$(this).removeClass('menu-item-depth-'+ depth )
+							.addClass('menu-item-depth-'+ (depth + change) );
+					});
+				},
+				childMenuItems : function() {
+					var result = $();
+					this.each(function(){
+						var t = $(this), depth = t.menuItemDepth(), next = t.next();
+						while( next.length && next.menuItemDepth() > depth ) {
+							result = result.add( next );
+							next = next.next();
+						}
+					});
+					return result;
+				},
+				updateParentMenuItemDBId : function() {
+					return this.each(function(){
+						var item = $(this),
+							input = item.find('.menu-item-data-parent-id'),
+							depth = item.menuItemDepth(),
+							parent = item.prev();
+
+						if( depth == 0 ) { // Item is on the top level, has no parent
+							input.val(0);
+						} else { // Find the parent item, and retrieve its object id.
+							while( ! parent[0] || ! parent[0].className || -1 == parent[0].className.indexOf('menu-item') || ( parent.menuItemDepth() != depth - 1 ) )
+								parent = parent.prev();
+							input.val( parent.find('.menu-item-data-db-id').val() );
+						}
+					});
+				},
+				hideAdvancedMenuItemFields : function() {
+					return this.each(function(){
+						var that = $(this);
+						$('.hide-column-tog').not(':checked').each(function(){
+							that.find('.field-' + $(this).val() ).addClass('hidden-field');
+						});
+					});
+				},
+				/**
+				 * Adds selected menu items to the menu.
+				 *
+				 * @param jQuery metabox The metabox jQuery object.
+				 */
+				addSelectedToMenu : function(processMethod) {
+					if ( 0 == $('#menu-to-edit').length ) {
+						return false;
+					}
+
+					return this.each(function() {
+						var t = $(this), menuItems = {},
+							checkboxes = t.find('.tabs-panel-active .categorychecklist li input:checked'),
+							re = new RegExp('menu-item\\[(\[^\\]\]*)');
+
+						processMethod = processMethod || api.addMenuItemToBottom;
+
+						// If no items are checked, bail.
+						if ( !checkboxes.length )
+							return false;
+
+						// Show the ajax spinner
+						t.find('img.waiting').show();
+
+						// Retrieve menu item data
+						$(checkboxes).each(function(){
+							var t = $(this),
+								listItemDBIDMatch = re.exec( t.attr('name') ),
+								listItemDBID = 'undefined' == typeof listItemDBIDMatch[1] ? 0 : parseInt(listItemDBIDMatch[1], 10);
+							if ( this.className && -1 != this.className.indexOf('add-to-top') )
+								processMethod = api.addMenuItemToTop;
+							menuItems[listItemDBID] = t.closest('li').getItemData( 'add-menu-item', listItemDBID );
+						});
+
+						// Add the items
+						api.addItemToMenu(menuItems, processMethod, function(){
+							// Deselect the items and hide the ajax spinner
+							checkboxes.removeAttr('checked');
+							t.find('img.waiting').hide();
+						});
+					});
+				},
+				getItemData : function( itemType, id ) {
+					itemType = itemType || 'menu-item';
+
+					var itemData = {}, i,
+					fields = [
+						'menu-item-db-id',
+						'menu-item-object-id',
+						'menu-item-object',
+						'menu-item-parent-id',
+						'menu-item-position',
+						'menu-item-type',
+						'menu-item-title',
+						'menu-item-url',
+						'menu-item-description',
+						'menu-item-attr-title',
+						'menu-item-target',
+						'menu-item-classes',
+						'menu-item-xfn'
+					];
+
+					if( !id && itemType == 'menu-item' ) {
+						id = this.find('.menu-item-data-db-id').val();
+					}
+
+					if( !id ) return itemData;
+
+					this.find('input').each(function() {
+						var field;
+						i = fields.length;
+						while ( i-- ) {
+							if( itemType == 'menu-item' )
+								field = fields[i] + '[' + id + ']';
+							else if( itemType == 'add-menu-item' )
+								field = 'menu-item[' + id + '][' + fields[i] + ']';
+
+							if (
+								this.name &&
+								field == this.name
+							) {
+								itemData[fields[i]] = this.value;
+							}
+						}
+					});
+
+					return itemData;
+				},
+				setItemData : function( itemData, itemType, id ) { // Can take a type, such as 'menu-item', or an id.
+					itemType = itemType || 'menu-item';
+
+					if( !id && itemType == 'menu-item' ) {
+						id = $('.menu-item-data-db-id', this).val();
+					}
+
+					if( !id ) return this;
+
+					this.find('input').each(function() {
+						var t = $(this), field;
+						$.each( itemData, function( attr, val ) {
+							if( itemType == 'menu-item' )
+								field = attr + '[' + id + ']';
+							else if( itemType == 'add-menu-item' )
+								field = 'menu-item[' + id + '][' + attr + ']';
+
+							if ( field == t.attr('name') ) {
+								t.val( val );
+							}
+						});
+					});
+					return this;
+				}
+			});
+		},
+
+		initToggles : function() {
+			// init postboxes
+			postboxes.add_postbox_toggles('nav-menus');
+
+			// adjust columns functions for menus UI
+			columns.useCheckboxesForHidden();
+			columns.checked = function(field) {
+				$('.field-' + field).removeClass('hidden-field');
+			}
+			columns.unchecked = function(field) {
+				$('.field-' + field).addClass('hidden-field');
+			}
+			// hide fields
+			api.menuList.hideAdvancedMenuItemFields();
+		},
+
+		initSortables : function() {
+			var currentDepth = 0, originalDepth, minDepth, maxDepth,
+				prev, next, prevBottom, nextThreshold, helperHeight, transport,
+				menuEdge = api.menuList.offset().left,
+				body = $('body'), maxChildDepth,
+				menuMaxDepth = initialMenuMaxDepth();
+
+			// Use the right edge if RTL.
+			menuEdge += api.isRTL ? api.menuList.width() : 0;
+
+			api.menuList.sortable({
+				handle: '.menu-item-handle',
+				placeholder: 'sortable-placeholder',
+				start: function(e, ui) {
+					var height, width, parent, children, tempHolder;
+
+					// handle placement for rtl orientation
+					if ( api.isRTL )
+						ui.item[0].style.right = 'auto';
+
+					transport = ui.item.children('.menu-item-transport');
+
+					// Set depths. currentDepth must be set before children are located.
+					originalDepth = ui.item.menuItemDepth();
+					updateCurrentDepth(ui, originalDepth);
+
+					// Attach child elements to parent
+					// Skip the placeholder
+					parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item;
+					children = parent.childMenuItems();
+					transport.append( children );
+
+					// Update the height of the placeholder to match the moving item.
+					height = transport.outerHeight();
+					// If there are children, account for distance between top of children and parent
+					height += ( height > 0 ) ? (ui.placeholder.css('margin-top').slice(0, -2) * 1) : 0;
+					height += ui.helper.outerHeight();
+					helperHeight = height;
+					height -= 2; // Subtract 2 for borders
+					ui.placeholder.height(height);
+
+					// Update the width of the placeholder to match the moving item.
+					maxChildDepth = originalDepth;
+					children.each(function(){
+						var depth = $(this).menuItemDepth();
+						maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth;
+					});
+					width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width
+					width += api.depthToPx(maxChildDepth - originalDepth); // Account for children
+					width -= 2; // Subtract 2 for borders
+					ui.placeholder.width(width);
+
+					// Update the list of menu items.
+					tempHolder = ui.placeholder.next();
+					tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder
+					ui.placeholder.detach(); // detach or jQuery UI will think the placeholder is a menu item
+					$(this).sortable( "refresh" ); // The children aren't sortable. We should let jQ UI know.
+					ui.item.after( ui.placeholder ); // reattach the placeholder.
+					tempHolder.css('margin-top', 0); // reset the margin
+
+					// Now that the element is complete, we can update...
+					updateSharedVars(ui);
+				},
+				stop: function(e, ui) {
+					var children, depthChange = currentDepth - originalDepth;
+
+					// Return child elements to the list
+					children = transport.children().insertAfter(ui.item);
+
+					// Update depth classes
+					if( depthChange != 0 ) {
+						ui.item.updateDepthClass( currentDepth );
+						children.shiftDepthClass( depthChange );
+						updateMenuMaxDepth( depthChange );
+					}
+					// Register a change
+					api.registerChange();
+					// Update the item data.
+					ui.item.updateParentMenuItemDBId();
+
+					// address sortable's incorrectly-calculated top in opera
+					ui.item[0].style.top = 0;
+
+					// handle drop placement for rtl orientation
+					if ( api.isRTL ) {
+						ui.item[0].style.left = 'auto';
+						ui.item[0].style.right = 0;
+					}
+
+					// The width of the tab bar might have changed. Just in case.
+					api.refreshMenuTabs( true );
+				},
+				change: function(e, ui) {
+					// Make sure the placeholder is inside the menu.
+					// Otherwise fix it, or we're in trouble.
+					if( ! ui.placeholder.parent().hasClass('menu') )
+						(prev.length) ? prev.after( ui.placeholder ) : api.menuList.prepend( ui.placeholder );
+
+					updateSharedVars(ui);
+				},
+				sort: function(e, ui) {
+					var offset = ui.helper.offset(),
+						edge = api.isRTL ? offset.left + ui.helper.width() : offset.left,
+						depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge );
+					// Check and correct if depth is not within range.
+					// Also, if the dragged element is dragged upwards over
+					// an item, shift the placeholder to a child position.
+					if ( depth > maxDepth || offset.top < prevBottom ) depth = maxDepth;
+					else if ( depth < minDepth ) depth = minDepth;
+
+					if( depth != currentDepth )
+						updateCurrentDepth(ui, depth);
+
+					// If we overlap the next element, manually shift downwards
+					if( nextThreshold && offset.top + helperHeight > nextThreshold ) {
+						next.after( ui.placeholder );
+						updateSharedVars( ui );
+						$(this).sortable( "refreshPositions" );
+					}
+				}
+			});
+
+			function updateSharedVars(ui) {
+				var depth;
+
+				prev = ui.placeholder.prev();
+				next = ui.placeholder.next();
+
+				// Make sure we don't select the moving item.
+				if( prev[0] == ui.item[0] ) prev = prev.prev();
+				if( next[0] == ui.item[0] ) next = next.next();
+
+				prevBottom = (prev.length) ? prev.offset().top + prev.height() : 0;
+				nextThreshold = (next.length) ? next.offset().top + next.height() / 3 : 0;
+				minDepth = (next.length) ? next.menuItemDepth() : 0;
+
+				if( prev.length )
+					maxDepth = ( (depth = prev.menuItemDepth() + 1) > api.options.globalMaxDepth ) ? api.options.globalMaxDepth : depth;
+				else
+					maxDepth = 0;
+			}
+
+			function updateCurrentDepth(ui, depth) {
+				ui.placeholder.updateDepthClass( depth, currentDepth );
+				currentDepth = depth;
+			}
+
+			function initialMenuMaxDepth() {
+				if( ! body[0].className ) return 0;
+				var match = body[0].className.match(/menu-max-depth-(\d+)/);
+				return match && match[1] ? parseInt(match[1]) : 0;
+			}
+
+			function updateMenuMaxDepth( depthChange ) {
+				var depth, newDepth = menuMaxDepth;
+				if ( depthChange === 0 ) {
+					return;
+				} else if ( depthChange > 0 ) {
+					depth = maxChildDepth + depthChange;
+					if( depth > menuMaxDepth )
+						newDepth = depth;
+				} else if ( depthChange < 0 && maxChildDepth == menuMaxDepth ) {
+					while( ! $('.menu-item-depth-' + newDepth, api.menuList).length && newDepth > 0 )
+						newDepth--;
+				}
+				// Update the depth class.
+				body.removeClass( 'menu-max-depth-' + menuMaxDepth ).addClass( 'menu-max-depth-' + newDepth );
+				menuMaxDepth = newDepth;
+			}
+		},
+
+		attachMenuEditListeners : function() {
+			var that = this;
+			$('#update-nav-menu').bind('click', function(e) {
+				if ( e.target && e.target.className ) {
+					if ( -1 != e.target.className.indexOf('item-edit') ) {
+						return that.eventOnClickEditLink(e.target);
+					} else if ( -1 != e.target.className.indexOf('menu-save') ) {
+						return that.eventOnClickMenuSave(e.target);
+					} else if ( -1 != e.target.className.indexOf('menu-delete') ) {
+						return that.eventOnClickMenuDelete(e.target);
+					} else if ( -1 != e.target.className.indexOf('item-delete') ) {
+						return that.eventOnClickMenuItemDelete(e.target);
+					} else if ( -1 != e.target.className.indexOf('item-cancel') ) {
+						return that.eventOnClickCancelLink(e.target);
+					}
+				}
+			});
+		},
+
+		/**
+		 * An interface for managing default values for input elements
+		 * that is both JS and accessibility-friendly.
+		 *
+		 * Input elements that add the class 'input-with-default-title'
+		 * will have their values set to the provided HTML title when empty.
+		 */
+		setupInputWithDefaultTitle : function() {
+			var name = 'input-with-default-title';
+
+			$('.' + name).each( function(){
+				var $t = $(this), title = $t.attr('title'), val = $t.val();
+				$t.data( name, title );
+
+				if( '' == val ) $t.val( title );
+				else if ( title == val ) return;
+				else $t.removeClass( name );
+			}).focus( function(){
+				var $t = $(this);
+				if( $t.val() == $t.data(name) )
+					$t.val('').removeClass( name );
+			}).blur( function(){
+				var $t = $(this);
+				if( '' == $t.val() )
+					$t.addClass( name ).val( $t.data(name) );
+			});
+		},
+
+		attachThemeLocationsListeners : function() {
+			var loc = $('#nav-menu-theme-locations'), params = {};
+			params['action'] = 'menu-locations-save';
+			params['menu-settings-column-nonce'] = $('#menu-settings-column-nonce').val();
+			loc.find('input[type=submit]').click(function() {
+				loc.find('select').each(function() {
+					params[this.name] = $(this).val();
+				});
+				loc.find('.waiting').show();
+				$.post( ajaxurl, params, function(r) {
+					loc.find('.waiting').hide();
+				});
+				return false;
+			});
+		},
+
+		attachQuickSearchListeners : function() {
+			var searchTimer;
+
+			$('.quick-search').keypress(function(e){
+				var t = $(this);
+
+				if( 13 == e.which ) {
+					api.updateQuickSearchResults( t );
+					return false;
+				}
+
+				if( searchTimer ) clearTimeout(searchTimer);
+
+				searchTimer = setTimeout(function(){
+					api.updateQuickSearchResults( t );
+				}, 400);
+			}).attr('autocomplete','off');
+		},
+
+		updateQuickSearchResults : function(input) {
+			var panel, params,
+			minSearchLength = 2,
+			q = input.val();
+
+			if( q.length < minSearchLength ) return;
+
+			panel = input.parents('.tabs-panel');
+			params = {
+				'action': 'menu-quick-search',
+				'response-format': 'markup',
+				'menu': $('#menu').val(),
+				'menu-settings-column-nonce': $('#menu-settings-column-nonce').val(),
+				'q': q,
+				'type': input.attr('name')
+			};
+
+			$('img.waiting', panel).show();
+
+			$.post( ajaxurl, params, function(menuMarkup) {
+				api.processQuickSearchQueryResponse(menuMarkup, params, panel);
+			});
+		},
+
+		addCustomLink : function( processMethod ) {
+			var url = $('#custom-menu-item-url').val(),
+				label = $('#custom-menu-item-name').val();
+
+			processMethod = processMethod || api.addMenuItemToBottom;
+
+			if ( '' == url || 'http://' == url )
+				return false;
+
+			// Show the ajax spinner
+			$('.customlinkdiv img.waiting').show();
+			this.addLinkToMenu( url, label, processMethod, function() {
+				// Remove the ajax spinner
+				$('.customlinkdiv img.waiting').hide();
+				// Set custom link form back to defaults
+				$('#custom-menu-item-name').val('').blur();
+				$('#custom-menu-item-url').val('http://');
+			});
+		},
+
+		addLinkToMenu : function(url, label, processMethod, callback) {
+			processMethod = processMethod || api.addMenuItemToBottom;
+			callback = callback || function(){};
+
+			api.addItemToMenu({
+				'-1': {
+					'menu-item-type': 'custom',
+					'menu-item-url': url,
+					'menu-item-title': label
+				}
+			}, processMethod, callback);
+		},
+
+		addItemToMenu : function(menuItem, processMethod, callback) {
+			var menu = $('#menu').val(),
+				nonce = $('#menu-settings-column-nonce').val();
+
+			processMethod = processMethod || function(){};
+			callback = callback || function(){};
+
+			params = {
+				'action': 'add-menu-item',
+				'menu': menu,
+				'menu-settings-column-nonce': nonce,
+				'menu-item': menuItem
+			};
+
+			$.post( ajaxurl, params, function(menuMarkup) {
+				var ins = $('#menu-instructions');
+				processMethod(menuMarkup, params);
+				if( ! ins.hasClass('menu-instructions-inactive') && ins.siblings().length )
+					ins.addClass('menu-instructions-inactive');
+				callback();
+			});
+		},
+
+		/**
+		 * Process the add menu item request response into menu list item.
+		 *
+		 * @param string menuMarkup The text server response of menu item markup.
+		 * @param object req The request arguments.
+		 */
+		addMenuItemToBottom : function( menuMarkup, req ) {
+			$(menuMarkup).hideAdvancedMenuItemFields().appendTo( api.targetList );
+		},
+
+		addMenuItemToTop : function( menuMarkup, req ) {
+			$(menuMarkup).hideAdvancedMenuItemFields().prependTo( api.targetList );
+		},
+
+		attachUnsavedChangesListener : function() {
+			$('#menu-management input, #menu-management select, #menu-management, #menu-management textarea').change(function(){
+				api.registerChange();
+			});
+
+			if ( 0 != $('#menu-to-edit').length ) {
+				window.onbeforeunload = function(){
+					if ( api.menusChanged )
+						return navMenuL10n.saveAlert;
+				};
+			} else {
+				// Make the post boxes read-only, as they can't be used yet
+				$('#menu-settings-column').find('input,select').attr('disabled', 'disabled').end().find('a').attr('href', '#').unbind('click');
+			}
+		},
+
+		registerChange : function() {
+			api.menusChanged = true;
+		},
+
+		attachTabsPanelListeners : function() {
+			$('#menu-settings-column').bind('click', function(e) {
+				var selectAreaMatch, panelId, wrapper, items,
+					target = $(e.target);
+
+				if ( target.hasClass('nav-tab-link') ) {
+					panelId = /#(.*)$/.exec(e.target.href);
+					if ( panelId && panelId[1] )
+						panelId = panelId[1]
+					else
+						return false;
+
+					wrapper = target.parents('.inside').first();
+
+					// upon changing tabs, we want to uncheck all checkboxes
+					$('input', wrapper).removeAttr('checked');
+
+					$('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive');
+					$('#' + panelId, wrapper).removeClass('tabs-panel-inactive').addClass('tabs-panel-active');
+
+					$('.tabs', wrapper).removeClass('tabs');
+					target.parent().addClass('tabs');
+
+					// select the search bar
+					$('.quick-search', wrapper).focus();
+
+					return false;
+				} else if ( target.hasClass('select-all') ) {
+					selectAreaMatch = /#(.*)$/.exec(e.target.href);
+					if ( selectAreaMatch && selectAreaMatch[1] ) {
+						items = $('#' + selectAreaMatch[1] + ' .tabs-panel-active .menu-item-title input');
+						if( items.length === items.filter(':checked').length )
+							items.removeAttr('checked');
+						else
+							items.attr('checked', 'checked');
+						return false;
+					}
+				} else if ( target.hasClass('submit-add-to-menu') ) {
+					api.registerChange();
+
+					if ( e.target.id && 'submit-customlinkdiv' == e.target.id )
+						api.addCustomLink( api.addMenuItemToBottom );
+					else if ( e.target.id && -1 != e.target.id.indexOf('submit-') )
+						$('#' + e.target.id.replace(/submit-/, '')).addSelectedToMenu( api.addMenuItemToBottom );
+					return false;
+				} else if ( target.hasClass('page-numbers') ) {
+					$.post( ajaxurl, e.target.href.replace(/.*\?/, '').replace(/action=([^&]*)/, '') + '&action=menu-get-metabox',
+						function( resp ) {
+							if ( -1 == resp.indexOf('replace-id') )
+								return;
+
+							var metaBoxData = $.parseJSON(resp),
+							toReplace = document.getElementById(metaBoxData['replace-id']),
+							placeholder = document.createElement('div'),
+							wrap = document.createElement('div');
+
+							if ( ! metaBoxData['markup'] || ! toReplace )
+								return;
+
+							wrap.innerHTML = metaBoxData['markup'] ? metaBoxData['markup'] : '';
+
+							toReplace.parentNode.insertBefore( placeholder, toReplace );
+							placeholder.parentNode.removeChild( toReplace );
+
+							placeholder.parentNode.insertBefore( wrap, placeholder );
+
+							placeholder.parentNode.removeChild( placeholder );
+
+						}
+					);
+
+					return false;
+				}
+			});
+		},
+
+		initTabManager : function() {
+			var fixed = $('.nav-tabs-wrapper'),
+				fluid = fixed.children('.nav-tabs'),
+				active = fluid.children('.nav-tab-active'),
+				tabs = fluid.children('.nav-tab'),
+				tabsWidth = 0,
+				fixedRight, fixedLeft,
+				arrowLeft, arrowRight, resizeTimer, css = {},
+				marginFluid = api.isRTL ? 'margin-right' : 'margin-left',
+				marginFixed = api.isRTL ? 'margin-left' : 'margin-right',
+				msPerPx = 2;
+
+			/**
+			 * Refreshes the menu tabs.
+			 * Will show and hide arrows where necessary.
+			 * Scrolls to the active tab by default.
+			 *
+			 * @param savePosition {boolean} Optional. Prevents scrolling so
+			 * 		  that the current position is maintained. Default false.
+			 **/
+			api.refreshMenuTabs = function( savePosition ) {
+				var fixedWidth = fixed.width(),
+					margin = 0, css = {};
+				fixedLeft = fixed.offset().left;
+				fixedRight = fixedLeft + fixedWidth;
+
+				if( !savePosition )
+					active.makeTabVisible();
+
+				// Prevent space from building up next to the last tab if there's more to show
+				if( tabs.last().isTabVisible() ) {
+					margin = fixed.width() - tabsWidth;
+					margin = margin > 0 ? 0 : margin;
+					css[marginFluid] = margin + 'px';
+					fluid.animate( css, 100, "linear" );
+				}
+
+				// Show the arrows only when necessary
+				if( fixedWidth > tabsWidth )
+					arrowLeft.add( arrowRight ).hide();
+				else
+					arrowLeft.add( arrowRight ).show();
+			}
+
+			$.fn.extend({
+				makeTabVisible : function() {
+					var t = this.eq(0), left, right, css = {}, shift = 0;
+
+					if( ! t.length ) return this;
+
+					left = t.offset().left;
+					right = left + t.outerWidth();
+
+					if( right > fixedRight )
+						shift = fixedRight - right;
+					else if ( left < fixedLeft )
+						shift = fixedLeft - left;
+
+					if( ! shift ) return this;
+
+					css[marginFluid] = "+=" + api.negateIfRTL * shift + 'px';
+					fluid.animate( css, Math.abs( shift ) * msPerPx, "linear" );
+					return this;
+				},
+				isTabVisible : function() {
+					var t = this.eq(0),
+						left = t.offset().left,
+						right = left + t.outerWidth();
+					return ( right <= fixedRight && left >= fixedLeft ) ? true : false;
+				}
+			});
+
+			// Find the width of all tabs
+			tabs.each(function(){
+				tabsWidth += $(this).outerWidth(true);
+			});
+
+			// Set up fixed margin for overflow, unset padding
+			css['padding'] = 0;
+			css[marginFixed] = (-1 * tabsWidth) + 'px';
+			fluid.css( css );
+
+			// Build tab navigation
+			arrowLeft = $('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>&laquo;</a></div>');
+			arrowRight = $('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>&raquo;</a></div>');
+			// Attach to the document
+			fixed.wrap('<div class="nav-tabs-nav"/>').parent().prepend( arrowLeft ).append( arrowRight );
+
+			// Set the menu tabs
+			api.refreshMenuTabs();
+			// Make sure the tabs reset on resize
+			$(window).resize(function() {
+				if( resizeTimer ) clearTimeout(resizeTimer);
+				resizeTimer = setTimeout( api.refreshMenuTabs, 200);
+			});
+
+			// Build arrow functions
+			$.each([{
+					arrow : arrowLeft,
+					next : "next",
+					last : "first",
+					operator : "+="
+				},{
+					arrow : arrowRight,
+					next : "prev",
+					last : "last",
+					operator : "-="
+				}], function(){
+				var that = this;
+				this.arrow.mousedown(function(){
+					var marginFluidVal = Math.abs( parseInt( fluid.css(marginFluid) ) ),
+						shift = marginFluidVal,
+						css = {};
+
+					if( "-=" == that.operator )
+						shift = Math.abs( tabsWidth - fixed.width() ) - marginFluidVal;
+
+					if( ! shift ) return;
+
+					css[marginFluid] = that.operator + shift + 'px';
+					fluid.animate( css, shift * msPerPx, "linear" );
+				}).mouseup(function(){
+					var tab, next;
+					fluid.stop(true);
+					tab = tabs[that.last]();
+					while( (next = tab[that.next]()) && next.length && ! next.isTabVisible() ) {
+						tab = next;
+					}
+					tab.makeTabVisible();
+				});
+			});
+		},
+
+		eventOnClickEditLink : function(clickedEl) {
+			var settings, item,
+			matchedSection = /#(.*)$/.exec(clickedEl.href);
+			if ( matchedSection && matchedSection[1] ) {
+				settings = $('#'+matchedSection[1]);
+				item = settings.parent();
+				if( 0 != item.length ) {
+					if( item.hasClass('menu-item-edit-inactive') ) {
+						if( ! settings.data('menu-item-data') ) {
+							settings.data( 'menu-item-data', settings.getItemData() );
+						}
+						settings.slideDown('fast');
+						item.removeClass('menu-item-edit-inactive')
+							.addClass('menu-item-edit-active');
+					} else {
+						settings.slideUp('fast');
+						item.removeClass('menu-item-edit-active')
+							.addClass('menu-item-edit-inactive');
+					}
+					return false;
+				}
+			}
+		},
+
+		eventOnClickCancelLink : function(clickedEl) {
+			var settings = $(clickedEl).closest('.menu-item-settings');
+			settings.setItemData( settings.data('menu-item-data') );
+			return false;
+		},
+
+		eventOnClickMenuSave : function(clickedEl) {
+			var locs = '',
+			menuName = $('#menu-name'),
+			menuNameVal = menuName.val();
+			// Cancel and warn if invalid menu name
+			if( !menuNameVal || menuNameVal == menuName.attr('title') || !menuNameVal.replace(/\s+/, '') ) {
+				menuName.parent().addClass('form-invalid');
+				return false;
+			}
+			// Copy menu theme locations
+			$('#nav-menu-theme-locations select').each(function() {
+				locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />';
+			});
+			$('#update-nav-menu').append( locs );
+			// Update menu item position data
+			api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
+			window.onbeforeunload = null;
+
+			return true;
+		},
+
+		eventOnClickMenuDelete : function(clickedEl) {
+			// Delete warning AYS
+			if ( confirm( navMenuL10n.warnDeleteMenu ) ) {
+				window.onbeforeunload = null;
+				return true;
+			}
+			return false;
+		},
+
+		eventOnClickMenuItemDelete : function(clickedEl) {
+			var itemID = parseInt(clickedEl.id.replace('delete-', ''), 10);
+			api.removeMenuItem( $('#menu-item-' + itemID) );
+			api.registerChange();
+			return false;
+		},
+
+		/**
+		 * Process the quick search response into a search result
+		 *
+		 * @param string resp The server response to the query.
+		 * @param object req The request arguments.
+		 * @param jQuery panel The tabs panel we're searching in.
+		 */
+		processQuickSearchQueryResponse : function(resp, req, panel) {
+			var matched, newID,
+			takenIDs = {},
+			form = document.getElementById('nav-menu-meta'),
+			pattern = new RegExp('menu-item\\[(\[^\\]\]*)', 'g'),
+			$items = $('<div>').html(resp).find('li'),
+			$item;
+
+			if( ! $items.length ) {
+				$('.categorychecklist', panel).html( '<li><p>' + navMenuL10n.noResultsFound + '</p></li>' );
+				$('img.waiting', panel).hide();
+				return;
+			}
+
+			$items.each(function(){
+				$item = $(this);
+
+				// make a unique DB ID number
+				matched = pattern.exec($item.html());
+
+				if ( matched && matched[1] ) {
+					newID = matched[1];
+					while( form.elements['menu-item[' + newID + '][menu-item-type]'] || takenIDs[ newID ] ) {
+						newID--;
+					}
+
+					takenIDs[newID] = true;
+					if ( newID != matched[1] ) {
+						$item.html( $item.html().replace(new RegExp(
+							'menu-item\\[' + matched[1] + '\\]', 'g'),
+							'menu-item[' + newID + ']'
+						) );
+					}
+				}
+			});
+
+			$('.categorychecklist', panel).html( $items );
+			$('img.waiting', panel).hide();
+		},
+
+		removeMenuItem : function(el) {
+			var children = el.childMenuItems();
+
+			el.addClass('deleting').animate({
+					opacity : 0,
+					height: 0
+				}, 350, function() {
+					var ins = $('#menu-instructions');
+					el.remove();
+					children.shiftDepthClass(-1).updateParentMenuItemDBId();
+					if( ! ins.siblings().length )
+						ins.removeClass('menu-instructions-inactive');
+				});
+		},
+
+		depthToPx : function(depth) {
+			return depth * api.options.menuItemDepthPerLevel;
+		},
+
+		pxToDepth : function(px) {
+			return Math.floor(px / api.options.menuItemDepthPerLevel);
+		}
+
+	};
+
+	$(document).ready(function(){ wpNavMenu.init(); });
+
+})(jQuery);
Index: /tags/3.1/wp-admin/js/nav-menu.js
===================================================================
--- /tags/3.1/wp-admin/js/nav-menu.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/nav-menu.js	(revision 17487)
@@ -0,0 +1,1 @@
+var wpNavMenu;(function(b){var a=wpNavMenu={options:{menuItemDepthPerLevel:30,globalMaxDepth:11},menuList:undefined,targetList:undefined,menusChanged:false,isRTL:!!("undefined"!=typeof isRtl&&isRtl),negateIfRTL:("undefined"!=typeof isRtl&&isRtl)?-1:1,init:function(){a.menuList=b("#menu-to-edit");a.targetList=a.menuList;this.jQueryExtensions();this.attachMenuEditListeners();this.setupInputWithDefaultTitle();this.attachQuickSearchListeners();this.attachThemeLocationsListeners();this.attachTabsPanelListeners();this.attachUnsavedChangesListener();if(a.menuList.length){this.initSortables()}this.initToggles();this.initTabManager()},jQueryExtensions:function(){b.fn.extend({menuItemDepth:function(){var c=a.isRTL?this.eq(0).css("margin-right"):this.eq(0).css("margin-left");return a.pxToDepth(c&&-1!=c.indexOf("px")?c.slice(0,-2):0)},updateDepthClass:function(d,c){return this.each(function(){var e=b(this);c=c||e.menuItemDepth();b(this).removeClass("menu-item-depth-"+c).addClass("menu-item-depth-"+d)})},shiftDepthClass:function(c){return this.each(function(){var d=b(this),e=d.menuItemDepth();b(this).removeClass("menu-item-depth-"+e).addClass("menu-item-depth-"+(e+c))})},childMenuItems:function(){var c=b();this.each(function(){var d=b(this),f=d.menuItemDepth(),e=d.next();while(e.length&&e.menuItemDepth()>f){c=c.add(e);e=e.next()}});return c},updateParentMenuItemDBId:function(){return this.each(function(){var e=b(this),c=e.find(".menu-item-data-parent-id"),f=e.menuItemDepth(),d=e.prev();if(f==0){c.val(0)}else{while(!d[0]||!d[0].className||-1==d[0].className.indexOf("menu-item")||(d.menuItemDepth()!=f-1)){d=d.prev()}c.val(d.find(".menu-item-data-db-id").val())}})},hideAdvancedMenuItemFields:function(){return this.each(function(){var c=b(this);b(".hide-column-tog").not(":checked").each(function(){c.find(".field-"+b(this).val()).addClass("hidden-field")})})},addSelectedToMenu:function(c){if(0==b("#menu-to-edit").length){return false}return this.each(function(){var e=b(this),d={},g=e.find(".tabs-panel-active .categorychecklist li input:checked"),f=new RegExp("menu-item\\[([^\\]]*)");c=c||a.addMenuItemToBottom;if(!g.length){return false}e.find("img.waiting").show();b(g).each(function(){var i=b(this),h=f.exec(i.attr("name")),j="undefined"==typeof h[1]?0:parseInt(h[1],10);if(this.className&&-1!=this.className.indexOf("add-to-top")){c=a.addMenuItemToTop}d[j]=i.closest("li").getItemData("add-menu-item",j)});a.addItemToMenu(d,c,function(){g.removeAttr("checked");e.find("img.waiting").hide()})})},getItemData:function(f,g){f=f||"menu-item";var d={},e,c=["menu-item-db-id","menu-item-object-id","menu-item-object","menu-item-parent-id","menu-item-position","menu-item-type","menu-item-title","menu-item-url","menu-item-description","menu-item-attr-title","menu-item-target","menu-item-classes","menu-item-xfn"];if(!g&&f=="menu-item"){g=this.find(".menu-item-data-db-id").val()}if(!g){return d}this.find("input").each(function(){var h;e=c.length;while(e--){if(f=="menu-item"){h=c[e]+"["+g+"]"}else{if(f=="add-menu-item"){h="menu-item["+g+"]["+c[e]+"]"}}if(this.name&&h==this.name){d[c[e]]=this.value}}});return d},setItemData:function(c,d,e){d=d||"menu-item";if(!e&&d=="menu-item"){e=b(".menu-item-data-db-id",this).val()}if(!e){return this}this.find("input").each(function(){var f=b(this),g;b.each(c,function(h,i){if(d=="menu-item"){g=h+"["+e+"]"}else{if(d=="add-menu-item"){g="menu-item["+e+"]["+h+"]"}}if(g==f.attr("name")){f.val(i)}})});return this}})},initToggles:function(){postboxes.add_postbox_toggles("nav-menus");columns.useCheckboxesForHidden();columns.checked=function(c){b(".field-"+c).removeClass("hidden-field")};columns.unchecked=function(c){b(".field-"+c).addClass("hidden-field")};a.menuList.hideAdvancedMenuItemFields()},initSortables:function(){var p=0,e,t,d,l,o,f,c,i,s,m=a.menuList.offset().left,h=b("body"),q,n=r();m+=a.isRTL?a.menuList.width():0;a.menuList.sortable({handle:".menu-item-handle",placeholder:"sortable-placeholder",start:function(A,z){var u,x,w,v,y;if(a.isRTL){z.item[0].style.right="auto"}s=z.item.children(".menu-item-transport");e=z.item.menuItemDepth();j(z,e);w=(z.item.next()[0]==z.placeholder[0])?z.item.next():z.item;v=w.childMenuItems();s.append(v);u=s.outerHeight();u+=(u>0)?(z.placeholder.css("margin-top").slice(0,-2)*1):0;u+=z.helper.outerHeight();i=u;u-=2;z.placeholder.height(u);q=e;v.each(function(){var B=b(this).menuItemDepth();q=(B>q)?B:q});x=z.helper.find(".menu-item-handle").outerWidth();x+=a.depthToPx(q-e);x-=2;z.placeholder.width(x);y=z.placeholder.next();y.css("margin-top",i+"px");z.placeholder.detach();b(this).sortable("refresh");z.item.after(z.placeholder);y.css("margin-top",0);k(z)},stop:function(x,w){var v,u=p-e;v=s.children().insertAfter(w.item);if(u!=0){w.item.updateDepthClass(p);v.shiftDepthClass(u);g(u)}a.registerChange();w.item.updateParentMenuItemDBId();w.item[0].style.top=0;if(a.isRTL){w.item[0].style.left="auto";w.item[0].style.right=0}a.refreshMenuTabs(true)},change:function(v,u){if(!u.placeholder.parent().hasClass("menu")){(l.length)?l.after(u.placeholder):a.menuList.prepend(u.placeholder)}k(u)},sort:function(w,v){var y=v.helper.offset(),u=a.isRTL?y.left+v.helper.width():y.left,x=a.negateIfRTL*a.pxToDepth(u-m);if(x>d||y.top<f){x=d}else{if(x<t){x=t}}if(x!=p){j(v,x)}if(c&&y.top+i>c){o.after(v.placeholder);k(v);b(this).sortable("refreshPositions")}}});function k(u){var v;l=u.placeholder.prev();o=u.placeholder.next();if(l[0]==u.item[0]){l=l.prev()}if(o[0]==u.item[0]){o=o.next()}f=(l.length)?l.offset().top+l.height():0;c=(o.length)?o.offset().top+o.height()/3:0;t=(o.length)?o.menuItemDepth():0;if(l.length){d=((v=l.menuItemDepth()+1)>a.options.globalMaxDepth)?a.options.globalMaxDepth:v}else{d=0}}function j(u,v){u.placeholder.updateDepthClass(v,p);p=v}function r(){if(!h[0].className){return 0}var u=h[0].className.match(/menu-max-depth-(\d+)/);return u&&u[1]?parseInt(u[1]):0}function g(u){var v,w=n;if(u===0){return}else{if(u>0){v=q+u;if(v>n){w=v}}else{if(u<0&&q==n){while(!b(".menu-item-depth-"+w,a.menuList).length&&w>0){w--}}}}h.removeClass("menu-max-depth-"+n).addClass("menu-max-depth-"+w);n=w}},attachMenuEditListeners:function(){var c=this;b("#update-nav-menu").bind("click",function(d){if(d.target&&d.target.className){if(-1!=d.target.className.indexOf("item-edit")){return c.eventOnClickEditLink(d.target)}else{if(-1!=d.target.className.indexOf("menu-save")){return c.eventOnClickMenuSave(d.target)}else{if(-1!=d.target.className.indexOf("menu-delete")){return c.eventOnClickMenuDelete(d.target)}else{if(-1!=d.target.className.indexOf("item-delete")){return c.eventOnClickMenuItemDelete(d.target)}else{if(-1!=d.target.className.indexOf("item-cancel")){return c.eventOnClickCancelLink(d.target)}}}}}}})},setupInputWithDefaultTitle:function(){var c="input-with-default-title";b("."+c).each(function(){var f=b(this),e=f.attr("title"),d=f.val();f.data(c,e);if(""==d){f.val(e)}else{if(e==d){return}else{f.removeClass(c)}}}).focus(function(){var d=b(this);if(d.val()==d.data(c)){d.val("").removeClass(c)}}).blur(function(){var d=b(this);if(""==d.val()){d.addClass(c).val(d.data(c))}})},attachThemeLocationsListeners:function(){var d=b("#nav-menu-theme-locations"),c={};c.action="menu-locations-save";c["menu-settings-column-nonce"]=b("#menu-settings-column-nonce").val();d.find("input[type=submit]").click(function(){d.find("select").each(function(){c[this.name]=b(this).val()});d.find(".waiting").show();b.post(ajaxurl,c,function(e){d.find(".waiting").hide()});return false})},attachQuickSearchListeners:function(){var c;b(".quick-search").keypress(function(f){var d=b(this);if(13==f.which){a.updateQuickSearchResults(d);return false}if(c){clearTimeout(c)}c=setTimeout(function(){a.updateQuickSearchResults(d)},400)}).attr("autocomplete","off")},updateQuickSearchResults:function(d){var c,g,e=2,f=d.val();if(f.length<e){return}c=d.parents(".tabs-panel");g={action:"menu-quick-search","response-format":"markup",menu:b("#menu").val(),"menu-settings-column-nonce":b("#menu-settings-column-nonce").val(),q:f,type:d.attr("name")};b("img.waiting",c).show();b.post(ajaxurl,g,function(h){a.processQuickSearchQueryResponse(h,g,c)})},addCustomLink:function(c){var e=b("#custom-menu-item-url").val(),d=b("#custom-menu-item-name").val();c=c||a.addMenuItemToBottom;if(""==e||"http://"==e){return false}b(".customlinkdiv img.waiting").show();this.addLinkToMenu(e,d,c,function(){b(".customlinkdiv img.waiting").hide();b("#custom-menu-item-name").val("").blur();b("#custom-menu-item-url").val("http://")})},addLinkToMenu:function(e,d,c,f){c=c||a.addMenuItemToBottom;f=f||function(){};a.addItemToMenu({"-1":{"menu-item-type":"custom","menu-item-url":e,"menu-item-title":d}},c,f)},addItemToMenu:function(e,c,g){var f=b("#menu").val(),d=b("#menu-settings-column-nonce").val();c=c||function(){};g=g||function(){};params={action:"add-menu-item",menu:f,"menu-settings-column-nonce":d,"menu-item":e};b.post(ajaxurl,params,function(h){var i=b("#menu-instructions");c(h,params);if(!i.hasClass("menu-instructions-inactive")&&i.siblings().length){i.addClass("menu-instructions-inactive")}g()})},addMenuItemToBottom:function(c,d){b(c).hideAdvancedMenuItemFields().appendTo(a.targetList)},addMenuItemToTop:function(c,d){b(c).hideAdvancedMenuItemFields().prependTo(a.targetList)},attachUnsavedChangesListener:function(){b("#menu-management input, #menu-management select, #menu-management, #menu-management textarea").change(function(){a.registerChange()});if(0!=b("#menu-to-edit").length){window.onbeforeunload=function(){if(a.menusChanged){return navMenuL10n.saveAlert}}}else{b("#menu-settings-column").find("input,select").attr("disabled","disabled").end().find("a").attr("href","#").unbind("click")}},registerChange:function(){a.menusChanged=true},attachTabsPanelListeners:function(){b("#menu-settings-column").bind("click",function(h){var f,d,i,c,g=b(h.target);if(g.hasClass("nav-tab-link")){d=/#(.*)$/.exec(h.target.href);if(d&&d[1]){d=d[1]}else{return false}i=g.parents(".inside").first();b("input",i).removeAttr("checked");b(".tabs-panel-active",i).removeClass("tabs-panel-active").addClass("tabs-panel-inactive");b("#"+d,i).removeClass("tabs-panel-inactive").addClass("tabs-panel-active");b(".tabs",i).removeClass("tabs");g.parent().addClass("tabs");b(".quick-search",i).focus();return false}else{if(g.hasClass("select-all")){f=/#(.*)$/.exec(h.target.href);if(f&&f[1]){c=b("#"+f[1]+" .tabs-panel-active .menu-item-title input");if(c.length===c.filter(":checked").length){c.removeAttr("checked")}else{c.attr("checked","checked")}return false}}else{if(g.hasClass("submit-add-to-menu")){a.registerChange();if(h.target.id&&"submit-customlinkdiv"==h.target.id){a.addCustomLink(a.addMenuItemToBottom)}else{if(h.target.id&&-1!=h.target.id.indexOf("submit-")){b("#"+h.target.id.replace(/submit-/,"")).addSelectedToMenu(a.addMenuItemToBottom)}}return false}else{if(g.hasClass("page-numbers")){b.post(ajaxurl,h.target.href.replace(/.*\?/,"").replace(/action=([^&]*)/,"")+"&action=menu-get-metabox",function(m){if(-1==m.indexOf("replace-id")){return}var l=b.parseJSON(m),e=document.getElementById(l["replace-id"]),k=document.createElement("div"),j=document.createElement("div");if(!l.markup||!e){return}j.innerHTML=l.markup?l.markup:"";e.parentNode.insertBefore(k,e);k.parentNode.removeChild(e);k.parentNode.insertBefore(j,k);k.parentNode.removeChild(k)});return false}}}}})},initTabManager:function(){var h=b(".nav-tabs-wrapper"),j=h.children(".nav-tabs"),g=j.children(".nav-tab-active"),m=j.children(".nav-tab"),e=0,o,f,l,d,k,i={},c=a.isRTL?"margin-right":"margin-left",p=a.isRTL?"margin-left":"margin-right",n=2;a.refreshMenuTabs=function(q){var t=h.width(),s=0,r={};f=h.offset().left;o=f+t;if(!q){g.makeTabVisible()}if(m.last().isTabVisible()){s=h.width()-e;s=s>0?0:s;r[c]=s+"px";j.animate(r,100,"linear")}if(t>e){l.add(d).hide()}else{l.add(d).show()}};b.fn.extend({makeTabVisible:function(){var u=this.eq(0),v,s,r={},q=0;if(!u.length){return this}v=u.offset().left;s=v+u.outerWidth();if(s>o){q=o-s}else{if(v<f){q=f-v}}if(!q){return this}r[c]="+="+a.negateIfRTL*q+"px";j.animate(r,Math.abs(q)*n,"linear");return this},isTabVisible:function(){var r=this.eq(0),s=r.offset().left,q=s+r.outerWidth();return(q<=o&&s>=f)?true:false}});m.each(function(){e+=b(this).outerWidth(true)});i.padding=0;i[p]=(-1*e)+"px";j.css(i);l=b('<div class="nav-tabs-arrow nav-tabs-arrow-left"><a>&laquo;</a></div>');d=b('<div class="nav-tabs-arrow nav-tabs-arrow-right"><a>&raquo;</a></div>');h.wrap('<div class="nav-tabs-nav"/>').parent().prepend(l).append(d);a.refreshMenuTabs();b(window).resize(function(){if(k){clearTimeout(k)}k=setTimeout(a.refreshMenuTabs,200)});b.each([{arrow:l,next:"next",last:"first",operator:"+="},{arrow:d,next:"prev",last:"last",operator:"-="}],function(){var q=this;this.arrow.mousedown(function(){var t=Math.abs(parseInt(j.css(c))),r=t,s={};if("-="==q.operator){r=Math.abs(e-h.width())-t}if(!r){return}s[c]=q.operator+r+"px";j.animate(s,r*n,"linear")}).mouseup(function(){var s,r;j.stop(true);s=m[q.last]();while((r=s[q.next]())&&r.length&&!r.isTabVisible()){s=r}s.makeTabVisible()})})},eventOnClickEditLink:function(d){var c,e,f=/#(.*)$/.exec(d.href);if(f&&f[1]){c=b("#"+f[1]);e=c.parent();if(0!=e.length){if(e.hasClass("menu-item-edit-inactive")){if(!c.data("menu-item-data")){c.data("menu-item-data",c.getItemData())}c.slideDown("fast");e.removeClass("menu-item-edit-inactive").addClass("menu-item-edit-active")}else{c.slideUp("fast");e.removeClass("menu-item-edit-active").addClass("menu-item-edit-inactive")}return false}}},eventOnClickCancelLink:function(d){var c=b(d).closest(".menu-item-settings");c.setItemData(c.data("menu-item-data"));return false},eventOnClickMenuSave:function(e){var f="",c=b("#menu-name"),d=c.val();if(!d||d==c.attr("title")||!d.replace(/\s+/,"")){c.parent().addClass("form-invalid");return false}b("#nav-menu-theme-locations select").each(function(){f+='<input type="hidden" name="'+this.name+'" value="'+b(this).val()+'" />'});b("#update-nav-menu").append(f);a.menuList.find(".menu-item-data-position").val(function(g){return g+1});window.onbeforeunload=null;return true},eventOnClickMenuDelete:function(c){if(confirm(navMenuL10n.warnDeleteMenu)){window.onbeforeunload=null;return true}return false},eventOnClickMenuItemDelete:function(c){var d=parseInt(c.id.replace("delete-",""),10);a.removeMenuItem(b("#menu-item-"+d));a.registerChange();return false},processQuickSearchQueryResponse:function(g,k,c){var e,i,f={},d=document.getElementById("nav-menu-meta"),j=new RegExp("menu-item\\[([^\\]]*)","g"),h=b("<div>").html(g).find("li"),l;if(!h.length){b(".categorychecklist",c).html("<li><p>"+navMenuL10n.noResultsFound+"</p></li>");b("img.waiting",c).hide();return}h.each(function(){l=b(this);e=j.exec(l.html());if(e&&e[1]){i=e[1];while(d.elements["menu-item["+i+"][menu-item-type]"]||f[i]){i--}f[i]=true;if(i!=e[1]){l.html(l.html().replace(new RegExp("menu-item\\["+e[1]+"\\]","g"),"menu-item["+i+"]"))}}});b(".categorychecklist",c).html(h);b("img.waiting",c).hide()},removeMenuItem:function(d){var c=d.childMenuItems();d.addClass("deleting").animate({opacity:0,height:0},350,function(){var e=b("#menu-instructions");d.remove();c.shiftDepthClass(-1).updateParentMenuItemDBId();if(!e.siblings().length){e.removeClass("menu-instructions-inactive")}})},depthToPx:function(c){return c*a.options.menuItemDepthPerLevel},pxToDepth:function(c){return Math.floor(c/a.options.menuItemDepthPerLevel)}};b(document).ready(function(){wpNavMenu.init()})})(jQuery);
Index: /tags/3.1/wp-admin/js/password-strength-meter.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/password-strength-meter.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/password-strength-meter.dev.js	(revision 17487)
@@ -0,0 +1,36 @@
+// Password strength meter
+function passwordStrength(password1, username, password2) {
+	var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
+
+	// password 1 != password 2
+	if ( (password1 != password2) && password2.length > 0)
+		return mismatch
+
+	//password < 4
+	if ( password1.length < 4 )
+		return shortPass
+
+	//password1 == username
+	if ( password1.toLowerCase() == username.toLowerCase() )
+		return badPass;
+
+	if ( password1.match(/[0-9]/) )
+		symbolSize +=10;
+	if ( password1.match(/[a-z]/) )
+		symbolSize +=26;
+	if ( password1.match(/[A-Z]/) )
+		symbolSize +=26;
+	if ( password1.match(/[^a-zA-Z0-9]/) )
+		symbolSize +=31;
+
+	natLog = Math.log( Math.pow(symbolSize, password1.length) );
+	score = natLog / Math.LN2;
+
+	if (score < 40 )
+		return badPass
+
+	if (score < 56 )
+		return goodPass
+
+    return strongPass;
+}
Index: /tags/3.1/wp-admin/js/password-strength-meter.js
===================================================================
--- /tags/3.1/wp-admin/js/password-strength-meter.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/password-strength-meter.js	(revision 17487)
@@ -0,0 +1,1 @@
+function passwordStrength(f,i,d){var k=1,h=2,b=3,a=4,c=5,g=0,j,e;if((f!=d)&&d.length>0){return c}if(f.length<4){return k}if(f.toLowerCase()==i.toLowerCase()){return h}if(f.match(/[0-9]/)){g+=10}if(f.match(/[a-z]/)){g+=26}if(f.match(/[A-Z]/)){g+=26}if(f.match(/[^a-zA-Z0-9]/)){g+=31}j=Math.log(Math.pow(g,f.length));e=j/Math.LN2;if(e<40){return h}if(e<56){return b}return a};
Index: /tags/3.1/wp-admin/js/plugin-install.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/plugin-install.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/plugin-install.dev.js	(revision 17487)
@@ -0,0 +1,53 @@
+/* Plugin Browser Thickbox related JS*/
+var tb_position;
+jQuery(document).ready(function($) {
+	tb_position = function() {
+		var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width, adminbar_height = 0;
+
+		if ( $('body.admin-bar').length )
+			adminbar_height = 28;
+
+		if ( tbWindow.size() ) {
+			tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
+			$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
+			tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
+			if ( typeof document.body.style.maxWidth != 'undefined' )
+				tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
+		};
+
+		return $('a.thickbox').each( function() {
+			var href = $(this).attr('href');
+			if ( ! href )
+				return;
+			href = href.replace(/&width=[0-9]+/g, '');
+			href = href.replace(/&height=[0-9]+/g, '');
+			$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
+		});
+	};
+
+	$(window).resize(function(){ tb_position(); });
+
+	 $('#dashboard_plugins a.thickbox, .plugins a.thickbox').click( function() {
+		tb_click.call(this);
+
+		$('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
+		$('#TB_ajaxWindowTitle').html('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).attr('title') );
+		return false;
+	});
+
+	/* Plugin install related JS*/
+	$('#plugin-information #sidemenu a').click( function() {
+		var tab = $(this).attr('name');
+		//Flip the tab
+		$('#plugin-information-header a.current').removeClass('current');
+		$(this).addClass('current');
+		//Flip the content.
+		$('#section-holder div.section').hide(); //Hide 'em all
+		$('#section-' + tab).show();
+		return false;
+	});
+
+	$('a.install-now').click( function() {
+		return confirm( plugininstallL10n.ays );
+	});
+});
Index: /tags/3.1/wp-admin/js/plugin-install.js
===================================================================
--- /tags/3.1/wp-admin/js/plugin-install.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/plugin-install.js	(revision 17487)
@@ -0,0 +1,1 @@
+var tb_position;jQuery(document).ready(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a("#dashboard_plugins a.thickbox, .plugins a.thickbox").click(function(){tb_click.call(this);a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});a("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+a(this).attr("title"));return false});a("#plugin-information #sidemenu a").click(function(){var b=a(this).attr("name");a("#plugin-information-header a.current").removeClass("current");a(this).addClass("current");a("#section-holder div.section").hide();a("#section-"+b).show();return false});a("a.install-now").click(function(){return confirm(plugininstallL10n.ays)})});
Index: /tags/3.1/wp-admin/js/post.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/post.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/post.dev.js	(revision 17487)
@@ -0,0 +1,617 @@
+var tagBox, commentsBox, editPermalink, makeSlugeditClickable, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail;
+
+// return an array with any duplicate, whitespace or values removed
+function array_unique_noempty(a) {
+	var out = [];
+	jQuery.each( a, function(key, val) {
+		val = jQuery.trim(val);
+		if ( val && jQuery.inArray(val, out) == -1 )
+			out.push(val);
+		} );
+	return out;
+}
+
+(function($){
+
+tagBox = {
+	clean : function(tags) {
+		return tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
+	},
+
+	parseTags : function(el) {
+		var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.tagsdiv'), thetags = taxbox.find('.the-tags'), current_tags = thetags.val().split(','), new_tags = [];
+		delete current_tags[num];
+
+		$.each( current_tags, function(key, val) {
+			val = $.trim(val);
+			if ( val ) {
+				new_tags.push(val);
+			}
+		});
+
+		thetags.val( this.clean( new_tags.join(',') ) );
+
+		this.quickClicks(taxbox);
+		return false;
+	},
+
+	quickClicks : function(el) {
+		var thetags = $('.the-tags', el),
+			tagchecklist = $('.tagchecklist', el),
+			id = $(el).attr('id'),
+			current_tags, disabled;
+
+		if ( !thetags.length )
+			return;
+
+		disabled = thetags.attr('disabled');
+
+		current_tags = thetags.val().split(',');
+		tagchecklist.empty();
+
+		$.each( current_tags, function( key, val ) {
+			var span, xbutton;
+
+			val = $.trim( val );
+
+			if ( ! val )
+				return;
+
+			// Create a new span, and ensure the text is properly escaped.
+			span = $('<span />').text( val );
+
+			// If tags editing isn't disabled, create the X button.
+			if ( ! disabled ) {
+				xbutton = $( '<a id="' + id + '-check-num-' + key + '" class="ntdelbutton">X</a>' );
+				xbutton.click( function(){ tagBox.parseTags(this); });
+				span.prepend('&nbsp;').prepend( xbutton );
+			}
+
+			// Append the span to the tag list.
+			tagchecklist.append( span );
+		});
+	},
+
+	flushTags : function(el, a, f) {
+		a = a || false;
+		var text, tags = $('.the-tags', el), newtag = $('input.newtag', el), newtags;
+
+		text = a ? $(a).text() : newtag.val();
+		tagsval = tags.val();
+		newtags = tagsval ? tagsval + ',' + text : text;
+
+		newtags = this.clean( newtags );
+		newtags = array_unique_noempty( newtags.split(',') ).join(',');
+		tags.val(newtags);
+		this.quickClicks(el);
+
+		if ( !a )
+			newtag.val('');
+		if ( 'undefined' == typeof(f) )
+			newtag.focus();
+
+		return false;
+	},
+
+	get : function(id) {
+		var tax = id.substr(id.indexOf('-')+1);
+
+		$.post(ajaxurl, {'action':'get-tagcloud','tax':tax}, function(r, stat) {
+			if ( 0 == r || 'success' != stat )
+				r = wpAjax.broken;
+
+			r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>');
+			$('a', r).click(function(){
+				tagBox.flushTags( $(this).closest('.inside').children('.tagsdiv'), this);
+				return false;
+			});
+
+			$('#'+id).after(r);
+		});
+	},
+
+	init : function() {
+		var t = this, ajaxtag = $('div.ajaxtag');
+
+	    $('.tagsdiv').each( function() {
+	        tagBox.quickClicks(this);
+	    });
+
+		$('input.tagadd', ajaxtag).click(function(){
+			t.flushTags( $(this).closest('.tagsdiv') );
+		});
+
+		$('div.taghint', ajaxtag).click(function(){
+			$(this).css('visibility', 'hidden').parent().siblings('.newtag').focus();
+		});
+
+		$('input.newtag', ajaxtag).blur(function() {
+			if ( this.value == '' )
+	            $(this).parent().siblings('.taghint').css('visibility', '');
+	    }).focus(function(){
+			$(this).parent().siblings('.taghint').css('visibility', 'hidden');
+		}).keyup(function(e){
+			if ( 13 == e.which ) {
+				tagBox.flushTags( $(this).closest('.tagsdiv') );
+				return false;
+			}
+		}).keypress(function(e){
+			if ( 13 == e.which ) {
+				e.preventDefault();
+				return false;
+			}
+		}).each(function(){
+			var tax = $(this).closest('div.tagsdiv').attr('id');
+			$(this).suggest( ajaxurl + '?action=ajax-tag-search&tax=' + tax, { delay: 500, minchars: 2, multiple: true, multipleSep: "," } );
+		});
+
+	    // save tags on post save/publish
+	    $('#post').submit(function(){
+			$('div.tagsdiv').each( function() {
+	        	tagBox.flushTags(this, false, 1);
+			});
+		});
+
+		// tag cloud
+		$('a.tagcloud-link').click(function(){
+			tagBox.get( $(this).attr('id') );
+			$(this).unbind().click(function(){
+				$(this).siblings('.the-tagcloud').toggle();
+				return false;
+			});
+			return false;
+		});
+	}
+};
+
+commentsBox = {
+	st : 0,
+
+	get : function(total, num) {
+		var st = this.st, data;
+		if ( ! num )
+			num = 20;
+
+		this.st += num;
+		this.total = total;
+		$('#commentsdiv img.waiting').show();
+
+		data = {
+			'action' : 'get-comments',
+			'mode' : 'single',
+			'_ajax_nonce' : $('#add_comment_nonce').val(),
+			'p' : $('#post_ID').val(),
+			'start' : st,
+			'number' : num
+		};
+
+		$.post(ajaxurl, data,
+			function(r) {
+				r = wpAjax.parseAjaxResponse(r);
+				$('#commentsdiv .widefat').show();
+				$('#commentsdiv img.waiting').hide();
+
+				if ( 'object' == typeof r && r.responses[0] ) {
+					$('#the-comment-list').append( r.responses[0].data );
+
+					theList = theExtraList = null;
+					$("a[className*=':']").unbind();
+
+					if ( commentsBox.st > commentsBox.total )
+						$('#show-comments').hide();
+					else
+						$('#show-comments').html(postL10n.showcomm);
+					return;
+				} else if ( 1 == r ) {
+					$('#show-comments').parent().html(postL10n.endcomm);
+					return;
+				}
+
+				$('#the-comment-list').append('<tr><td colspan="2">'+wpAjax.broken+'</td></tr>');
+			}
+		);
+
+		return false;
+	}
+};
+
+WPSetThumbnailHTML = function(html){
+	$('.inside', '#postimagediv').html(html);
+};
+
+WPSetThumbnailID = function(id){
+	var field = $('input[value=_thumbnail_id]', '#list-table');
+	if ( field.size() > 0 ) {
+		$('#meta\\[' + field.attr('id').match(/[0-9]+/) + '\\]\\[value\\]').text(id);
+	}
+};
+
+WPRemoveThumbnail = function(nonce){
+	$.post(ajaxurl, {
+		action:"set-post-thumbnail", post_id: $('#post_ID').val(), thumbnail_id: -1, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
+	}, function(str){
+		if ( str == '0' ) {
+			alert( setPostThumbnailL10n.error );
+		} else {
+			WPSetThumbnailHTML(str);
+		}
+	}
+	);
+};
+
+})(jQuery);
+
+jQuery(document).ready( function($) {
+	var stamp, visibility, sticky = '';
+
+	postboxes.add_postbox_toggles(pagenow);
+
+	// multi-taxonomies
+	if ( $('#tagsdiv-post_tag').length ) {
+		tagBox.init();
+	} else {
+		$('#side-sortables, #normal-sortables, #advanced-sortables').children('div.postbox').each(function(){
+			if ( this.id.indexOf('tagsdiv-') === 0 ) {
+				tagBox.init();
+				return false;
+			}
+		});
+	}
+
+	// categories
+	$('.categorydiv').each( function(){
+		var this_id = $(this).attr('id'), noSyncChecks = false, syncChecks, catAddAfter, taxonomyParts, taxonomy, settingName;
+
+		taxonomyParts = this_id.split('-');
+		taxonomyParts.shift();
+		taxonomy = taxonomyParts.join('-');
+ 		settingName = taxonomy + '_tab';
+ 		if ( taxonomy == 'category' )
+ 			settingName = 'cats';
+
+		// TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.dev.js
+		$('a', '#' + taxonomy + '-tabs').click( function(){
+			var t = $(this).attr('href');
+			$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
+			$('#' + taxonomy + '-tabs').siblings('.tabs-panel').hide();
+			$(t).show();
+			if ( '#' + taxonomy + '-all' == t )
+				deleteUserSetting(settingName);
+			else
+				setUserSetting(settingName, 'pop');
+			return false;
+		});
+
+		if ( getUserSetting(settingName) )
+			$('a[href="#' + taxonomy + '-pop"]', '#' + taxonomy + '-tabs').click();
+
+		// Ajax Cat
+		$('#new' + taxonomy).one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ) } );
+		$('#' + taxonomy + '-add-submit').click( function(){ $('#new' + taxonomy).focus(); });
+
+		syncChecks = function() {
+			if ( noSyncChecks )
+				return;
+			noSyncChecks = true;
+			var th = jQuery(this), c = th.is(':checked'), id = th.val().toString();
+			$('#in-' + taxonomy + '-' + id + ', #in-' + taxonomy + '-category-' + id).attr( 'checked', c );
+			noSyncChecks = false;
+		};
+
+		catAddBefore = function( s ) {
+			if ( !$('#new'+taxonomy).val() )
+				return false;
+			s.data += '&' + $( ':checked', '#'+taxonomy+'checklist' ).serialize();
+			return s;
+		};
+
+		catAddAfter = function( r, s ) {
+			var sup, drop = $('#new'+taxonomy+'_parent');
+
+			if ( 'undefined' != s.parsed.responses[0] && (sup = s.parsed.responses[0].supplemental.newcat_parent) ) {
+				drop.before(sup);
+				drop.remove();
+			}
+		};
+
+		$('#' + taxonomy + 'checklist').wpList({
+			alt: '',
+			response: taxonomy + '-ajax-response',
+			addBefore: catAddBefore,
+			addAfter: catAddAfter
+		});
+
+		$('#' + taxonomy + '-add-toggle').click( function() {
+			$('#' + taxonomy + '-adder').toggleClass( 'wp-hidden-children' );
+			$('a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs').click();
+			$('#new'+taxonomy).focus();
+			return false;
+		});
+
+		$('#' + taxonomy + 'checklist li.popular-category :checkbox, #' + taxonomy + 'checklist-pop :checkbox').live( 'click', function(){
+			var t = $(this), c = t.is(':checked'), id = t.val();
+			if ( id && t.parents('#taxonomy-'+taxonomy).length )
+				$('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).attr( 'checked', c );
+		});
+
+	}); // end cats
+
+	// Custom Fields
+	if ( $('#postcustom').length ) {
+		$('#the-list').wpList( { addAfter: function( xml, s ) {
+			$('table#list-table').show();
+		}, addBefore: function( s ) {
+			s.data += '&post_id=' + $('#post_ID').val();
+			return s;
+		}
+		});
+	}
+
+	// submitdiv
+	if ( $('#submitdiv').length ) {
+		stamp = $('#timestamp').html();
+		visibility = $('#post-visibility-display').html();
+
+		function updateVisibility() {
+			var pvSelect = $('#post-visibility-select');
+			if ( $('input:radio:checked', pvSelect).val() != 'public' ) {
+				$('#sticky').attr('checked', false);
+				$('#sticky-span').hide();
+			} else {
+				$('#sticky-span').show();
+			}
+			if ( $('input:radio:checked', pvSelect).val() != 'password' ) {
+				$('#password-span').hide();
+			} else {
+				$('#password-span').show();
+			}
+		}
+
+		function updateText() {
+			var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'),
+				optPublish = $('option[value=publish]', postStatus), aa = $('#aa').val(),
+				mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val();
+
+			attemptedDate = new Date( aa, mm - 1, jj, hh, mn );
+			originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val() );
+			currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
+
+			if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) {
+				$('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
+				return false;
+			} else {
+				$('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
+			}
+
+			if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
+				publishOn = postL10n.publishOnFuture;
+				$('#publish').val( postL10n.schedule );
+			} else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
+				publishOn = postL10n.publishOn;
+				$('#publish').val( postL10n.publish );
+			} else {
+				publishOn = postL10n.publishOnPast;
+				$('#publish').val( postL10n.update );
+			}
+			if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
+				$('#timestamp').html(stamp);
+			} else {
+				$('#timestamp').html(
+					publishOn + ' <b>' +
+					$('option[value=' + $('#mm').val() + ']', '#mm').text() + ' ' +
+					jj + ', ' +
+					aa + ' @ ' +
+					hh + ':' +
+					mn + '</b> '
+				);
+			}
+
+			if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) {
+				$('#publish').val( postL10n.update );
+				if ( optPublish.length == 0 ) {
+					postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
+				} else {
+					optPublish.html( postL10n.privatelyPublished );
+				}
+				$('option[value=publish]', postStatus).attr('selected', true);
+				$('.edit-post-status', '#misc-publishing-actions').hide();
+			} else {
+				if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
+					if ( optPublish.length ) {
+						optPublish.remove();
+						postStatus.val($('#hidden_post_status').val());
+					}
+				} else {
+					optPublish.html( postL10n.published );
+				}
+				if ( postStatus.is(':hidden') )
+					$('.edit-post-status', '#misc-publishing-actions').show();
+			}
+			$('#post-status-display').html($('option:selected', postStatus).text());
+			if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) {
+				$('#save-post').hide();
+			} else {
+				$('#save-post').show();
+				if ( $('option:selected', postStatus).val() == 'pending' ) {
+					$('#save-post').show().val( postL10n.savePending );
+				} else {
+					$('#save-post').show().val( postL10n.saveDraft );
+				}
+			}
+			return true;
+		}
+
+		$('.edit-visibility', '#visibility').click(function () {
+			if ($('#post-visibility-select').is(":hidden")) {
+				updateVisibility();
+				$('#post-visibility-select').slideDown("normal");
+				$(this).hide();
+			}
+			return false;
+		});
+
+		$('.cancel-post-visibility', '#post-visibility-select').click(function () {
+			$('#post-visibility-select').slideUp("normal");
+			$('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true);
+			$('#post_password').val($('#hidden_post_password').val());
+			$('#sticky').attr('checked', $('#hidden-post-sticky').attr('checked'));
+			$('#post-visibility-display').html(visibility);
+			$('.edit-visibility', '#visibility').show();
+			updateText();
+			return false;
+		});
+
+		$('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels
+			var pvSelect = $('#post-visibility-select');
+
+			pvSelect.slideUp("normal");
+			$('.edit-visibility', '#visibility').show();
+			updateText();
+
+			if ( $('input:radio:checked', pvSelect).val() != 'public' ) {
+				$('#sticky').attr('checked', false);
+			} // WEAPON LOCKED
+
+			if ( true == $('#sticky').attr('checked') ) {
+				sticky = 'Sticky';
+			} else {
+				sticky = '';
+			}
+
+			$('#post-visibility-display').html(	postL10n[$('input:radio:checked', pvSelect).val() + sticky]	);
+			return false;
+		});
+
+		$('input:radio', '#post-visibility-select').change(function() {
+			updateVisibility();
+		});
+
+		$('#timestampdiv').siblings('a.edit-timestamp').click(function() {
+			if ($('#timestampdiv').is(":hidden")) {
+				$('#timestampdiv').slideDown("normal");
+				$(this).hide();
+			}
+			return false;
+		});
+
+		$('.cancel-timestamp', '#timestampdiv').click(function() {
+			$('#timestampdiv').slideUp("normal");
+			$('#mm').val($('#hidden_mm').val());
+			$('#jj').val($('#hidden_jj').val());
+			$('#aa').val($('#hidden_aa').val());
+			$('#hh').val($('#hidden_hh').val());
+			$('#mn').val($('#hidden_mn').val());
+			$('#timestampdiv').siblings('a.edit-timestamp').show();
+			updateText();
+			return false;
+		});
+
+		$('.save-timestamp', '#timestampdiv').click(function () { // crazyhorse - multiple ok cancels
+			if ( updateText() ) {
+				$('#timestampdiv').slideUp("normal");
+				$('#timestampdiv').siblings('a.edit-timestamp').show();
+			}
+			return false;
+		});
+
+		$('#post-status-select').siblings('a.edit-post-status').click(function() {
+			if ($('#post-status-select').is(":hidden")) {
+				$('#post-status-select').slideDown("normal");
+				$(this).hide();
+			}
+			return false;
+		});
+
+		$('.save-post-status', '#post-status-select').click(function() {
+			$('#post-status-select').slideUp("normal");
+			$('#post-status-select').siblings('a.edit-post-status').show();
+			updateText();
+			return false;
+		});
+
+		$('.cancel-post-status', '#post-status-select').click(function() {
+			$('#post-status-select').slideUp("normal");
+			$('#post_status').val($('#hidden_post_status').val());
+			$('#post-status-select').siblings('a.edit-post-status').show();
+			updateText();
+			return false;
+		});
+	} // end submitdiv
+
+	// permalink
+	if ( $('#edit-slug-box').length ) {
+		editPermalink = function(post_id) {
+			var i, c = 0, e = $('#editable-post-name'), revert_e = e.html(), real_slug = $('#post_name'), revert_slug = real_slug.val(), b = $('#edit-slug-buttons'), revert_b = b.html(), full = $('#editable-post-name-full').html();
+
+			$('#view-post-btn').hide();
+			b.html('<a href="#" class="save button">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+'</a>');
+			b.children('.save').click(function() {
+				var new_slug = e.children('input').val();
+				$.post(ajaxurl, {
+					action: 'sample-permalink',
+					post_id: post_id,
+					new_slug: new_slug,
+					new_title: $('#title').val(),
+					samplepermalinknonce: $('#samplepermalinknonce').val()
+				}, function(data) {
+					$('#edit-slug-box').html(data);
+					b.html(revert_b);
+					real_slug.attr('value', new_slug);
+					makeSlugeditClickable();
+					$('#view-post-btn').show();
+				});
+				return false;
+			});
+
+			$('.cancel', '#edit-slug-buttons').click(function() {
+				$('#view-post-btn').show();
+				e.html(revert_e);
+				b.html(revert_b);
+				real_slug.attr('value', revert_slug);
+				return false;
+			});
+
+			for ( i = 0; i < full.length; ++i ) {
+				if ( '%' == full.charAt(i) )
+					c++;
+			}
+
+			slug_value = ( c > full.length / 4 ) ? '' : full;
+			e.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children('input').keypress(function(e){
+				var key = e.keyCode || 0;
+				// on enter, just save the new slug, don't save the post
+				if ( 13 == key ) {
+					b.children('.save').click();
+					return false;
+				}
+				if ( 27 == key ) {
+					b.children('.cancel').click();
+					return false;
+				}
+				real_slug.attr('value', this.value);
+			}).focus();
+		}
+
+		makeSlugeditClickable = function() {
+			$('#editable-post-name').click(function() {
+				$('#edit-slug-buttons').children('.edit-slug').click();
+			});
+		}
+		makeSlugeditClickable();
+	}
+
+	if ( $('#title').val() == '' )
+		$('#title').siblings('#title-prompt-text').css('visibility', '');
+	$('#title-prompt-text').click(function(){
+		$(this).css('visibility', 'hidden').siblings('#title').focus();
+	});
+	$('#title').blur(function(){
+		if (this.value == '')
+			$(this).siblings('#title-prompt-text').css('visibility', '');
+	}).focus(function(){
+		$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
+	}).keydown(function(e){
+		$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
+		$(this).unbind(e);
+	});
+});
Index: /tags/3.1/wp-admin/js/post.js
===================================================================
--- /tags/3.1/wp-admin/js/post.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/post.js	(revision 17487)
@@ -0,0 +1,1 @@
+var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail;function array_unique_noempty(b){var c=[];jQuery.each(b,function(a,d){d=jQuery.trim(d);if(d&&jQuery.inArray(d,c)==-1){c.push(d)}});return c}(function(a){tagBox={clean:function(b){return b.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(e){var h=e.id,b=h.split("-check-num-")[1],d=a(e).closest(".tagsdiv"),g=d.find(".the-tags"),c=g.val().split(","),f=[];delete c[b];a.each(c,function(i,j){j=a.trim(j);if(j){f.push(j)}});g.val(this.clean(f.join(",")));this.quickClicks(d);return false},quickClicks:function(d){var g=a(".the-tags",d),e=a(".tagchecklist",d),f=a(d).attr("id"),b,c;if(!g.length){return}c=g.attr("disabled");b=g.val().split(",");e.empty();a.each(b,function(i,k){var j,h;k=a.trim(k);if(!k){return}j=a("<span />").text(k);if(!c){h=a('<a id="'+f+"-check-num-"+i+'" class="ntdelbutton">X</a>');h.click(function(){tagBox.parseTags(this)});j.prepend("&nbsp;").prepend(h)}e.append(j)})},flushTags:function(e,b,g){b=b||false;var i,c=a(".the-tags",e),h=a("input.newtag",e),d;i=b?a(b).text():h.val();tagsval=c.val();d=tagsval?tagsval+","+i:i;d=this.clean(d);d=array_unique_noempty(d.split(",")).join(",");c.val(d);this.quickClicks(e);if(!b){h.val("")}if("undefined"==typeof(g)){h.focus()}return false},get:function(c){var b=c.substr(c.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('<p id="tagcloud-'+b+'" class="the-tagcloud">'+e+"</p>");a("a",e).click(function(){tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this);return false});a("#"+c).after(e)})},init:function(){var b=this,c=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)});a("input.tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))});a("div.taghint",c).click(function(){a(this).css("visibility","hidden").parent().siblings(".newtag").focus()});a("input.newtag",c).blur(function(){if(this.value==""){a(this).parent().siblings(".taghint").css("visibility","")}}).focus(function(){a(this).parent().siblings(".taghint").css("visibility","hidden")}).keyup(function(d){if(13==d.which){tagBox.flushTags(a(this).closest(".tagsdiv"));return false}}).keypress(function(d){if(13==d.which){d.preventDefault();return false}}).each(function(){var d=a(this).closest("div.tagsdiv").attr("id");a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+d,{delay:500,minchars:2,multiple:true,multipleSep:","})});a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,false,1)})});a("a.tagcloud-link").click(function(){tagBox.get(a(this).attr("id"));a(this).unbind().click(function(){a(this).siblings(".the-tagcloud").toggle();return false});return false})}};commentsBox={st:0,get:function(d,c){var b=this.st,e;if(!c){c=20}this.st+=c;this.total=d;a("#commentsdiv img.waiting").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),p:a("#post_ID").val(),start:b,number:c};a.post(ajaxurl,e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentsdiv .widefat").show();a("#commentsdiv img.waiting").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").parent().html(postL10n.endcomm);return}}a("#the-comment-list").append('<tr><td colspan="2">'+wpAjax.broken+"</td></tr>")});return false}};WPSetThumbnailHTML=function(b){a(".inside","#postimagediv").html(b)};WPSetThumbnailID=function(c){var b=a("input[value=_thumbnail_id]","#list-table");if(b.size()>0){a("#meta\\["+b.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(c)}};WPRemoveThumbnail=function(b){a.post(ajaxurl,{action:"set-post-thumbnail",post_id:a("#post_ID").val(),thumbnail_id:-1,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(c){if(c=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(c)}})}})(jQuery);jQuery(document).ready(function(e){var b,a,f="";postboxes.add_postbox_toggles(pagenow);if(e("#tagsdiv-post_tag").length){tagBox.init()}else{e("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}e(".categorydiv").each(function(){var l=e(this).attr("id"),h=false,k,m,j,g,i;j=l.split("-");j.shift();g=j.join("-");i=g+"_tab";if(g=="category"){i="cats"}e("a","#"+g+"-tabs").click(function(){var n=e(this).attr("href");e(this).parent().addClass("tabs").siblings("li").removeClass("tabs");e("#"+g+"-tabs").siblings(".tabs-panel").hide();e(n).show();if("#"+g+"-all"==n){deleteUserSetting(i)}else{setUserSetting(i,"pop")}return false});if(getUserSetting(i)){e('a[href="#'+g+'-pop"]',"#"+g+"-tabs").click()}e("#new"+g).one("focus",function(){e(this).val("").removeClass("form-input-tip")});e("#"+g+"-add-submit").click(function(){e("#new"+g).focus()});k=function(){if(h){return}h=true;var n=jQuery(this),p=n.is(":checked"),o=n.val().toString();e("#in-"+g+"-"+o+", #in-"+g+"-category-"+o).attr("checked",p);h=false};catAddBefore=function(n){if(!e("#new"+g).val()){return false}n.data+="&"+e(":checked","#"+g+"checklist").serialize();return n};m=function(q,p){var o,n=e("#new"+g+"_parent");if("undefined"!=p.parsed.responses[0]&&(o=p.parsed.responses[0].supplemental.newcat_parent)){n.before(o);n.remove()}};e("#"+g+"checklist").wpList({alt:"",response:g+"-ajax-response",addBefore:catAddBefore,addAfter:m});e("#"+g+"-add-toggle").click(function(){e("#"+g+"-adder").toggleClass("wp-hidden-children");e('a[href="#'+g+'-all"]',"#"+g+"-tabs").click();e("#new"+g).focus();return false});e("#"+g+"checklist li.popular-category :checkbox, #"+g+"checklist-pop :checkbox").live("click",function(){var n=e(this),p=n.is(":checked"),o=n.val();if(o&&n.parents("#taxonomy-"+g).length){e("#in-"+g+"-"+o+", #in-popular-"+g+"-"+o).attr("checked",p)}})});if(e("#postcustom").length){e("#the-list").wpList({addAfter:function(g,h){e("table#list-table").show()},addBefore:function(g){g.data+="&post_id="+e("#post_ID").val();return g}})}if(e("#submitdiv").length){b=e("#timestamp").html();a=e("#post-visibility-display").html();function d(){var g=e("#post-visibility-select");if(e("input:radio:checked",g).val()!="public"){e("#sticky").attr("checked",false);e("#sticky-span").hide()}else{e("#sticky-span").show()}if(e("input:radio:checked",g).val()!="password"){e("#password-span").hide()}else{e("#password-span").show()}}function c(){var n,o,h,q,p=e("#post_status"),i=e("option[value=publish]",p),g=e("#aa").val(),l=e("#mm").val(),m=e("#jj").val(),k=e("#hh").val(),j=e("#mn").val();n=new Date(g,l-1,m,k,j);o=new Date(e("#hidden_aa").val(),e("#hidden_mm").val()-1,e("#hidden_jj").val(),e("#hidden_hh").val(),e("#hidden_mn").val());h=new Date(e("#cur_aa").val(),e("#cur_mm").val()-1,e("#cur_jj").val(),e("#cur_hh").val(),e("#cur_mn").val());if(n.getFullYear()!=g||(1+n.getMonth())!=l||n.getDate()!=m||n.getMinutes()!=j){e(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{e(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(n>h&&e("#original_post_status").val()!="future"){q=postL10n.publishOnFuture;e("#publish").val(postL10n.schedule)}else{if(n<=h&&e("#original_post_status").val()!="publish"){q=postL10n.publishOn;e("#publish").val(postL10n.publish)}else{q=postL10n.publishOnPast;e("#publish").val(postL10n.update)}}if(o.toUTCString()==n.toUTCString()){e("#timestamp").html(b)}else{e("#timestamp").html(q+" <b>"+e("option[value="+e("#mm").val()+"]","#mm").text()+" "+m+", "+g+" @ "+k+":"+j+"</b> ")}if(e("input:radio:checked","#post-visibility-select").val()=="private"){e("#publish").val(postL10n.update);if(i.length==0){p.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{i.html(postL10n.privatelyPublished)}e("option[value=publish]",p).attr("selected",true);e(".edit-post-status","#misc-publishing-actions").hide()}else{if(e("#original_post_status").val()=="future"||e("#original_post_status").val()=="draft"){if(i.length){i.remove();p.val(e("#hidden_post_status").val())}}else{i.html(postL10n.published)}if(p.is(":hidden")){e(".edit-post-status","#misc-publishing-actions").show()}}e("#post-status-display").html(e("option:selected",p).text());if(e("option:selected",p).val()=="private"||e("option:selected",p).val()=="publish"){e("#save-post").hide()}else{e("#save-post").show();if(e("option:selected",p).val()=="pending"){e("#save-post").show().val(postL10n.savePending)}else{e("#save-post").show().val(postL10n.saveDraft)}}return true}e(".edit-visibility","#visibility").click(function(){if(e("#post-visibility-select").is(":hidden")){d();e("#post-visibility-select").slideDown("normal");e(this).hide()}return false});e(".cancel-post-visibility","#post-visibility-select").click(function(){e("#post-visibility-select").slideUp("normal");e("#visibility-radio-"+e("#hidden-post-visibility").val()).attr("checked",true);e("#post_password").val(e("#hidden_post_password").val());e("#sticky").attr("checked",e("#hidden-post-sticky").attr("checked"));e("#post-visibility-display").html(a);e(".edit-visibility","#visibility").show();c();return false});e(".save-post-visibility","#post-visibility-select").click(function(){var g=e("#post-visibility-select");g.slideUp("normal");e(".edit-visibility","#visibility").show();c();if(e("input:radio:checked",g).val()!="public"){e("#sticky").attr("checked",false)}if(true==e("#sticky").attr("checked")){f="Sticky"}else{f=""}e("#post-visibility-display").html(postL10n[e("input:radio:checked",g).val()+f]);return false});e("input:radio","#post-visibility-select").change(function(){d()});e("#timestampdiv").siblings("a.edit-timestamp").click(function(){if(e("#timestampdiv").is(":hidden")){e("#timestampdiv").slideDown("normal");e(this).hide()}return false});e(".cancel-timestamp","#timestampdiv").click(function(){e("#timestampdiv").slideUp("normal");e("#mm").val(e("#hidden_mm").val());e("#jj").val(e("#hidden_jj").val());e("#aa").val(e("#hidden_aa").val());e("#hh").val(e("#hidden_hh").val());e("#mn").val(e("#hidden_mn").val());e("#timestampdiv").siblings("a.edit-timestamp").show();c();return false});e(".save-timestamp","#timestampdiv").click(function(){if(c()){e("#timestampdiv").slideUp("normal");e("#timestampdiv").siblings("a.edit-timestamp").show()}return false});e("#post-status-select").siblings("a.edit-post-status").click(function(){if(e("#post-status-select").is(":hidden")){e("#post-status-select").slideDown("normal");e(this).hide()}return false});e(".save-post-status","#post-status-select").click(function(){e("#post-status-select").slideUp("normal");e("#post-status-select").siblings("a.edit-post-status").show();c();return false});e(".cancel-post-status","#post-status-select").click(function(){e("#post-status-select").slideUp("normal");e("#post_status").val(e("#hidden_post_status").val());e("#post-status-select").siblings("a.edit-post-status").show();c();return false})}if(e("#edit-slug-box").length){editPermalink=function(g){var h,l=0,k=e("#editable-post-name"),m=k.html(),p=e("#post_name"),q=p.val(),n=e("#edit-slug-buttons"),o=n.html(),j=e("#editable-post-name-full").html();e("#view-post-btn").hide();n.html('<a href="#" class="save button">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>");n.children(".save").click(function(){var i=k.children("input").val();e.post(ajaxurl,{action:"sample-permalink",post_id:g,new_slug:i,new_title:e("#title").val(),samplepermalinknonce:e("#samplepermalinknonce").val()},function(r){e("#edit-slug-box").html(r);n.html(o);p.attr("value",i);makeSlugeditClickable();e("#view-post-btn").show()});return false});e(".cancel","#edit-slug-buttons").click(function(){e("#view-post-btn").show();k.html(m);n.html(o);p.attr("value",q);return false});for(h=0;h<j.length;++h){if("%"==j.charAt(h)){l++}}slug_value=(l>j.length/4)?"":j;k.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(r){var i=r.keyCode||0;if(13==i){n.children(".save").click();return false}if(27==i){n.children(".cancel").click();return false}p.attr("value",this.value)}).focus()};makeSlugeditClickable=function(){e("#editable-post-name").click(function(){e("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}if(e("#title").val()==""){e("#title").siblings("#title-prompt-text").css("visibility","")}e("#title-prompt-text").click(function(){e(this).css("visibility","hidden").siblings("#title").focus()});e("#title").blur(function(){if(this.value==""){e(this).siblings("#title-prompt-text").css("visibility","")}}).focus(function(){e(this).siblings("#title-prompt-text").css("visibility","hidden")}).keydown(function(g){e(this).siblings("#title-prompt-text").css("visibility","hidden");e(this).unbind(g)})});
Index: /tags/3.1/wp-admin/js/postbox.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/postbox.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/postbox.dev.js	(revision 17487)
@@ -0,0 +1,152 @@
+var postboxes;
+(function($) {
+	postboxes = {
+		add_postbox_toggles : function(page,args) {
+			this.init(page,args);
+			$('.postbox h3, .postbox .handlediv').click( function() {
+				var p = $(this).parent('.postbox'), id = p.attr('id');
+
+				p.toggleClass('closed');
+				postboxes.save_state(page);
+				if ( id ) {
+					if ( !p.hasClass('closed') && $.isFunction(postboxes.pbshow) )
+						postboxes.pbshow(id);
+					else if ( p.hasClass('closed') && $.isFunction(postboxes.pbhide) )
+						postboxes.pbhide(id);
+				}
+			} );
+			$('.postbox h3 a').click( function(e) {
+				e.stopPropagation();
+			} );
+			$('.hide-postbox-tog').click( function() {
+				var box = $(this).val();
+
+				if ( $(this).attr('checked') ) {
+					$('#' + box).show();
+					if ( $.isFunction( postboxes.pbshow ) )
+						postboxes.pbshow( box );
+				} else {
+					$('#' + box).hide();
+					if ( $.isFunction( postboxes.pbhide ) )
+						postboxes.pbhide( box );
+				}
+				postboxes.save_state(page);
+			} );
+			$('.columns-prefs input[type="radio"]').click(function(){
+				var num = $(this).val(), i, el, p = $('#poststuff');
+
+				if ( p.length ) { // write pages
+					if ( num == 2 ) {
+						p.addClass('has-right-sidebar');
+						$('#side-sortables').addClass('temp-border');
+					} else if ( num == 1 ) {
+						p.removeClass('has-right-sidebar');
+						$('#normal-sortables').append($('#side-sortables').children('.postbox'));
+					}
+				} else { // dashboard
+					for ( i = 4; ( i > num && i > 1 ); i-- ) {
+						el = $('#' + colname(i) + '-sortables');
+						$('#' + colname(i-1) + '-sortables').append(el.children('.postbox'));
+						el.parent().hide();
+					}
+					for ( i = 1; i <= num; i++ ) {
+						el = $('#' + colname(i) + '-sortables');
+						if ( el.parent().is(':hidden') )
+							el.addClass('temp-border').parent().show();
+					}
+					$('.postbox-container:visible').css('width', 98/num + '%');
+				}
+				postboxes.save_order(page);
+			});
+
+			function colname(n) {
+				switch (n) {
+					case 1:
+						return 'normal';
+						break
+					case 2:
+						return 'side';
+						break
+					case 3:
+						return 'column3';
+						break
+					case 4:
+						return 'column4';
+						break
+					default:
+						return '';
+				}
+			}
+		},
+
+		init : function(page, args) {
+			$.extend( this, args || {} );
+			$('#wpbody-content').css('overflow','hidden');
+			$('.meta-box-sortables').sortable({
+				placeholder: 'sortable-placeholder',
+				connectWith: '.meta-box-sortables',
+				items: '.postbox',
+				handle: '.hndle',
+				cursor: 'move',
+				distance: 2,
+				tolerance: 'pointer',
+				forcePlaceholderSize: true,
+				helper: 'clone',
+				opacity: 0.65,
+				start: function(e,ui) {
+					$('body').css({
+						WebkitUserSelect: 'none',
+						KhtmlUserSelect: 'none'
+					});
+					/*
+					if ( $.browser.msie )
+						return;
+					ui.item.addClass('noclick');
+					*/
+				},
+				stop: function(e,ui) {
+					postboxes.save_order(page);
+					ui.item.parent().removeClass('temp-border');
+					$('body').css({
+						WebkitUserSelect: '',
+						KhtmlUserSelect: ''
+					});
+				}
+			});
+		},
+
+		save_state : function(page) {
+			var closed = $('.postbox').filter('.closed').map(function() { return this.id; }).get().join(','),
+				hidden = $('.postbox').filter(':hidden').map(function() { return this.id; }).get().join(',');
+
+			$.post(ajaxurl, {
+				action: 'closed-postboxes',
+				closed: closed,
+				hidden: hidden,
+				closedpostboxesnonce: jQuery('#closedpostboxesnonce').val(),
+				page: page
+			});
+		},
+
+		save_order : function(page) {
+			var postVars, page_columns = $('.columns-prefs input:checked').val() || 0;
+
+			postVars = {
+				action: 'meta-box-order',
+				_ajax_nonce: $('#meta-box-order-nonce').val(),
+				page_columns: page_columns,
+				page: page
+			}
+			$('.meta-box-sortables').each( function() {
+				postVars["order[" + this.id.split('-')[0] + "]"] = $(this).sortable( 'toArray' ).join(',');
+			} );
+			$.post( ajaxurl, postVars );
+		},
+
+		/* Callbacks */
+		pbshow : false,
+
+		pbhide : false
+	};
+
+}(jQuery));
Index: /tags/3.1/wp-admin/js/postbox.js
===================================================================
--- /tags/3.1/wp-admin/js/postbox.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/postbox.js	(revision 17487)
@@ -0,0 +1,1 @@
+var postboxes;(function(a){postboxes={add_postbox_toggles:function(c,b){this.init(c,b);a(".postbox h3, .postbox .handlediv").click(function(){var e=a(this).parent(".postbox"),f=e.attr("id");e.toggleClass("closed");postboxes.save_state(c);if(f){if(!e.hasClass("closed")&&a.isFunction(postboxes.pbshow)){postboxes.pbshow(f)}else{if(e.hasClass("closed")&&a.isFunction(postboxes.pbhide)){postboxes.pbhide(f)}}}});a(".postbox h3 a").click(function(f){f.stopPropagation()});a(".hide-postbox-tog").click(function(){var e=a(this).val();if(a(this).attr("checked")){a("#"+e).show();if(a.isFunction(postboxes.pbshow)){postboxes.pbshow(e)}}else{a("#"+e).hide();if(a.isFunction(postboxes.pbhide)){postboxes.pbhide(e)}}postboxes.save_state(c)});a('.columns-prefs input[type="radio"]').click(function(){var e=a(this).val(),f,g,h=a("#poststuff");if(h.length){if(e==2){h.addClass("has-right-sidebar");a("#side-sortables").addClass("temp-border")}else{if(e==1){h.removeClass("has-right-sidebar");a("#normal-sortables").append(a("#side-sortables").children(".postbox"))}}}else{for(f=4;(f>e&&f>1);f--){g=a("#"+d(f)+"-sortables");a("#"+d(f-1)+"-sortables").append(g.children(".postbox"));g.parent().hide()}for(f=1;f<=e;f++){g=a("#"+d(f)+"-sortables");if(g.parent().is(":hidden")){g.addClass("temp-border").parent().show()}}a(".postbox-container:visible").css("width",98/e+"%")}postboxes.save_order(c)});function d(e){switch(e){case 1:return"normal";break;case 2:return"side";break;case 3:return"column3";break;case 4:return"column4";break;default:return""}}},init:function(c,b){a.extend(this,b||{});a("#wpbody-content").css("overflow","hidden");a(".meta-box-sortables").sortable({placeholder:"sortable-placeholder",connectWith:".meta-box-sortables",items:".postbox",handle:".hndle",cursor:"move",distance:2,tolerance:"pointer",forcePlaceholderSize:true,helper:"clone",opacity:0.65,start:function(f,d){a("body").css({WebkitUserSelect:"none",KhtmlUserSelect:"none"})},stop:function(f,d){postboxes.save_order(c);d.item.parent().removeClass("temp-border");a("body").css({WebkitUserSelect:"",KhtmlUserSelect:""})}})},save_state:function(d){var b=a(".postbox").filter(".closed").map(function(){return this.id}).get().join(","),c=a(".postbox").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"closed-postboxes",closed:b,hidden:c,closedpostboxesnonce:jQuery("#closedpostboxesnonce").val(),page:d})},save_order:function(c){var b,d=a(".columns-prefs input:checked").val()||0;b={action:"meta-box-order",_ajax_nonce:a("#meta-box-order-nonce").val(),page_columns:d,page:c};a(".meta-box-sortables").each(function(){b["order["+this.id.split("-")[0]+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b)},pbshow:false,pbhide:false}}(jQuery));
Index: /tags/3.1/wp-admin/js/revisions-js.php
===================================================================
--- /tags/3.1/wp-admin/js/revisions-js.php	(revision 17487)
+++ /tags/3.1/wp-admin/js/revisions-js.php	(revision 17487)
@@ -0,0 +1,39 @@
+<?php
+
+// The JS here is purposefully obfuscated to preserve mystery and romance.
+// If you want to see behind the curtain, visit http://core.trac.wordpress.org/ticket/15262
+
+if ( !defined( 'ABSPATH' ) )
+	exit;
+
+/** @ignore */
+function dvortr( $str ) {
+	return strtr(
+		$str,
+		'\',.pyfgcrl/=\\aoeuidhtns-;qjkxbmwvz"<>PYFGCRL?+|AOEUIDHTNS_:QJKXBMWVZ[]',
+		'qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?-='
+	);
+}
+
+$j = esc_url( site_url( '/wp-includes/js/jquery/jquery.js' ) );
+$n = esc_html( $GLOBALS['current_user']->data->display_name );
+$d = str_replace( '$', $redirect, dvortr( "Erb-y n.y ydco dall.b aiacbv Wa ce]-irxajt- dp.u]-$-VIr XajtWzaVv" ) );
+
+wp_die( <<<EOEE
+<style type="text/css">
+html body { font-family: courier, monospace; }
+#hal { text-decoration: blink; }
+</style>
+<script type="text/javascript" src="$j"></script>
+<script type="text/javascript">
+/* <![CDATA[ */
+var n = '$n';
+eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('6(4(){2 e=6(\\'#Q\\').v();2 i=\\'\\\\\\',.R/=\\\\\\\\S-;T"<>U?+|V:W[]X{}\\'.u(\\'\\');2 o=\\'Y[]\\\\\\\\Z;\\\\\\'10,./11{}|12:"13<>?-=14+\\'.u(\\'\\');2 5=4(s){r=\\'\\';6.15(s.u(\\'\\'),4(){2 t=16.D();2 c=6.17(t,i);r+=\\'\$\\'==t?n:(-1==c?t:o[c])});j r};2 a=[\\'O.E[18 e.y.19.1a\\',\\'1b 1c. 1d .1e.,1f 1g\\',\\'O.E e.1h 1i 8\\',\\'9\\',\\'0\\'];2 b=[\\'<1j. 1k \$1l\\',\\'1m. 1n 1o 1p\\',\\'1q, 1r. ,1s. 1t\\'];2 w=[];2 h=6(5(\\'#1u\\'));6(5(\\'1v\\')).1w(4(e){7(1x!==e.1y){j}7(x&&x.F){x.F();j G}1z.1A=6(5(\\'#1B\\')).1C(\\'1D\\');j G});2 k=4(){2 l=a.H();7(\\'I\\'==J l){7(m){2 c={};c[5(\\'1E\\')]=5(\\'1F\\');c[5(\\'1G\\')]=5(\\'1H..b\\');6(5(\\'1I 1J\\')).1K(c);p();h.v().1L({1M:1},z,\\'1N\\',4(){h.K()});d(m,L)}j}w=5(l).u(\\'\\');A()};2 A=4(){B=w.H();7(\\'I\\'==J B){7(m){h.M(5(\\'1O 1P\\'));d(k,C)}N{7(a.P){d(p,C);d(k,z)}N{d(4(){p();h.v()},C);d(4(){e.K()},L)}}j}h.M(B.D());d(A,1Q)};2 m=4(){a=b;m=1R;k()};p=4(){2 f=6(\\'p\\').1S(0);2 g=6.1T(f.q).1U();1V(2 g=f.q.P;g>0;g--){7(3==f.q[g-1].1W||\\'1X\\'==f.q[g-1].1Y.1Z()){f.20(f.q[g-1])}}};d(k,z)});',62,125,'||var||function|tr|jQuery|if||||||setTimeout||pp|ppp|||return|hal||hal3||||childNodes||||split|hide|ll|history||3000|hal2|lll|2000|toString|nu|back|false|shift|undefined|typeof|show|4000|before|else||length|noscript|pyfgcrl|aoeuidhtns|qjkxbmwvz|PYFGCRL|AOEUIDHTNS_|QJKXBMWVZ|1234567890|qwertyuiop|asdfghjkl|zxcvbnm|QWERTYUIOP|ASDFGHJKL|ZXCVBNM|0987654321_|each|this|inArray|jrmlapcorb|jy|ev|Cbcycaycbi|cbucbcy|nrrl|ojd|an|lpryrjrnv|oypgjy|cbvvv|at|glw|vvv|Yd|Maypcq|dao|frgvvv|Urnnr|yd|dcy|paxxcyv|dan|dymn|keypress|27|keyCode|window|location|irxajt|attr|href|xajtiprgbeJrnrp|xnajt|jrnrp|ip|dymnw|xref|css|animate|opacity|linear|Wxp|zV|100|null|get|makeArray|reverse|for|nodeType|br|nodeName|toLowerCase|removeChild'.split('|'),0,{}))
+/* ]]> */
+</script>
+<span id="noscript">$d</span>
+<blink id="hal">&#x258c;</blink>
+EOEE
+,
+dvortr( 'Eabi.p!' )
+);
Index: /tags/3.1/wp-admin/js/set-post-thumbnail.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/set-post-thumbnail.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/set-post-thumbnail.dev.js	(revision 17487)
@@ -0,0 +1,21 @@
+function WPSetAsThumbnail(id, nonce){
+	var $link = jQuery('a#wp-post-thumbnail-' + id);
+
+	$link.text( setPostThumbnailL10n.saving );
+	jQuery.post(ajaxurl, {
+		action:"set-post-thumbnail", post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
+	}, function(str){
+		var win = window.dialogArguments || opener || parent || top;
+		$link.text( setPostThumbnailL10n.setThumbnail );
+		if ( str == '0' ) {
+			alert( setPostThumbnailL10n.error );
+		} else {
+			jQuery('a.wp-post-thumbnail').show();
+			$link.text( setPostThumbnailL10n.done );
+			$link.fadeOut( 2000 );
+			win.WPSetThumbnailID(id);
+			win.WPSetThumbnailHTML(str);
+		}
+	}
+	);
+}
Index: /tags/3.1/wp-admin/js/set-post-thumbnail.js
===================================================================
--- /tags/3.1/wp-admin/js/set-post-thumbnail.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/set-post-thumbnail.js	(revision 17487)
@@ -0,0 +1,1 @@
+function WPSetAsThumbnail(c,b){var a=jQuery("a#wp-post-thumbnail-"+c);a.text(setPostThumbnailL10n.saving);jQuery.post(ajaxurl,{action:"set-post-thumbnail",post_id:post_id,thumbnail_id:c,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(e){var d=window.dialogArguments||opener||parent||top;a.text(setPostThumbnailL10n.setThumbnail);if(e=="0"){alert(setPostThumbnailL10n.error)}else{jQuery("a.wp-post-thumbnail").show();a.text(setPostThumbnailL10n.done);a.fadeOut(2000);d.WPSetThumbnailID(c);d.WPSetThumbnailHTML(e)}})};
Index: /tags/3.1/wp-admin/js/tags.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/tags.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/tags.dev.js	(revision 17487)
@@ -0,0 +1,68 @@
+jQuery(document).ready(function($) {
+
+	$('.delete-tag').live('click', function(e){
+		var t = $(this), tr = t.parents('tr'), r = true, data;
+		if ( 'undefined' != showNotice )
+			r = showNotice.warn();
+		if ( r ) {
+			data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag');
+			$.post(ajaxurl, data, function(r){
+				if ( '1' == r ) {
+					$('#ajax-response').empty();
+					tr.fadeOut('normal', function(){ tr.remove(); });
+					// Remove the term from the parent box and tag cloud
+					$('select#parent option[value=' + data.match(/tag_ID=(\d+)/)[1] + ']').remove();
+					$('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove();
+				} else if ( '-1' == r ) {
+					$('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>');
+					tr.children().css('backgroundColor', '');
+				} else {
+					$('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.broken + '</p></div>');
+					tr.children().css('backgroundColor', '');
+				}
+			});
+			tr.children().css('backgroundColor', '#f33');
+		}
+		return false;
+	});
+
+	$('#submit').click(function(){
+		var form = $(this).parents('form');
+
+		if ( !validateForm( form ) )
+			return false;
+
+		$.post(ajaxurl, $('#addtag').serialize(), function(r){
+		   $('#ajax-response').empty();
+			var res = wpAjax.parseAjaxResponse(r, 'ajax-response');
+			if ( ! res )
+				return;
+
+			var parent = form.find('select#parent').val();
+
+			if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list.
+				$('.tags #tag-' + parent).after( res.responses[0].supplemental['noparents'] ); // As the parent exists, Insert the version with - - - prefixed
+			else
+				$('.tags').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
+
+			$('.tags .no-items').remove();
+
+			if ( form.find('select#parent') ) {
+				// Parents field exists, Add new term to the list.
+				var term = res.responses[1].supplemental;
+
+				// Create an indent for the Parent field
+				var indent = '';
+				for ( var i = 0; i < res.responses[1].position; i++ )
+					indent += '&nbsp;&nbsp;&nbsp;';
+
+				form.find('select#parent option:selected').after('<option value="' + term['term_id'] + '">' + indent + term['name'] + '</option>');
+			}
+
+			$('input[type="text"]:visible, textarea:visible', form).val('');
+		});
+
+		return false;
+	});
+
+});
Index: /tags/3.1/wp-admin/js/tags.js
===================================================================
--- /tags/3.1/wp-admin/js/tags.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/tags.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(a){a(".delete-tag").live("click",function(g){var b=a(this),f=b.parents("tr"),c=true,d;if("undefined"!=showNotice){c=showNotice.warn()}if(c){d=b.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag");a.post(ajaxurl,d,function(e){if("1"==e){a("#ajax-response").empty();f.fadeOut("normal",function(){f.remove()});a("select#parent option[value="+d.match(/tag_ID=(\d+)/)[1]+"]").remove();a("a.tag-link-"+d.match(/tag_ID=(\d+)/)[1]).remove()}else{if("-1"==e){a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>");f.children().css("backgroundColor","")}else{a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>");f.children().css("backgroundColor","")}}});f.children().css("backgroundColor","#f33")}return false});a("#submit").click(function(){var b=a(this).parents("form");if(!validateForm(b)){return false}a.post(ajaxurl,a("#addtag").serialize(),function(h){a("#ajax-response").empty();var f=wpAjax.parseAjaxResponse(h,"ajax-response");if(!f){return}var g=b.find("select#parent").val();if(g>0&&a("#tag-"+g).length>0){a(".tags #tag-"+g).after(f.responses[0].supplemental.noparents)}else{a(".tags").prepend(f.responses[0].supplemental.parents)}a(".tags .no-items").remove();if(b.find("select#parent")){var e=f.responses[1].supplemental;var c="";for(var d=0;d<f.responses[1].position;d++){c+="&nbsp;&nbsp;&nbsp;"}b.find("select#parent option:selected").after('<option value="'+e.term_id+'">'+c+e.name+"</option>")}a('input[type="text"]:visible, textarea:visible',b).val("")});return false})});
Index: /tags/3.1/wp-admin/js/theme-preview.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/theme-preview.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/theme-preview.dev.js	(revision 17487)
@@ -0,0 +1,64 @@
+
+var thickDims, tbWidth, tbHeight;
+jQuery(document).ready(function($) {
+
+	thickDims = function() {
+		var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h;
+
+		w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 90;
+		h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 60;
+
+		if ( tbWindow.size() ) {
+			tbWindow.width(w).height(h);
+			$('#TB_iframeContent').width(w).height(h - 27);
+			tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'});
+			if ( typeof document.body.style.maxWidth != 'undefined' )
+				tbWindow.css({'top':'30px','margin-top':'0'});
+		}
+	};
+
+	thickDims();
+	$(window).resize( function() { thickDims() } );
+
+	$('a.thickbox-preview').click( function() {
+		tb_click.call(this);
+
+		var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text;
+
+		if ( tbWidth = href.match(/&tbWidth=[0-9]+/) )
+			tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10);
+		else
+			tbWidth = $(window).width() - 90;
+
+		if ( tbHeight = href.match(/&tbHeight=[0-9]+/) )
+			tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10);
+		else
+			tbHeight = $(window).height() - 60;
+
+		if ( alink.length ) {
+			url = alink.attr('href') || '';
+			text = alink.attr('title') || '';
+			link = '&nbsp; <a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>';
+		} else {
+			text = $(this).attr('title') || '';
+			link = '&nbsp; <span class="tb-theme-preview-link">' + text + '</span>';
+		}
+
+		$('#TB_title').css({'background-color':'#222','color':'#dfdfdf'});
+		$('#TB_closeAjaxWindow').css({'float':'left'});
+		$('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);
+
+		$('#TB_iframeContent').width('100%');
+		thickDims();
+
+		return false;
+	} );
+
+	// Theme details
+	$('.theme-detail').click(function () {
+		$(this).siblings('.themedetaildiv').toggle();
+		return false;
+	});
+
+});
+
Index: /tags/3.1/wp-admin/js/theme-preview.js
===================================================================
--- /tags/3.1/wp-admin/js/theme-preview.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/theme-preview.js	(revision 17487)
@@ -0,0 +1,1 @@
+var thickDims,tbWidth,tbHeight;jQuery(document).ready(function(a){thickDims=function(){var f=a("#TB_window"),d=a(window).height(),b=a(window).width(),c,e;c=(tbWidth&&tbWidth<b-90)?tbWidth:b-90;e=(tbHeight&&tbHeight<d-60)?tbHeight:d-60;if(f.size()){f.width(c).height(e);a("#TB_iframeContent").width(c).height(e-27);f.css({"margin-left":"-"+parseInt((c/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:"30px","margin-top":"0"})}}};thickDims();a(window).resize(function(){thickDims()});a("a.thickbox-preview").click(function(){tb_click.call(this);var d=a(this).parents(".available-theme").find(".activatelink"),e="",b=a(this).attr("href"),c,f;if(tbWidth=b.match(/&tbWidth=[0-9]+/)){tbWidth=parseInt(tbWidth[0].replace(/[^0-9]+/g,""),10)}else{tbWidth=a(window).width()-90}if(tbHeight=b.match(/&tbHeight=[0-9]+/)){tbHeight=parseInt(tbHeight[0].replace(/[^0-9]+/g,""),10)}else{tbHeight=a(window).height()-60}if(d.length){c=d.attr("href")||"";f=d.attr("title")||"";e='&nbsp; <a href="'+c+'" target="_top" class="tb-theme-preview-link">'+f+"</a>"}else{f=a(this).attr("title")||"";e='&nbsp; <span class="tb-theme-preview-link">'+f+"</span>"}a("#TB_title").css({"background-color":"#222",color:"#dfdfdf"});a("#TB_closeAjaxWindow").css({"float":"left"});a("#TB_ajaxWindowTitle").css({"float":"right"}).html(e);a("#TB_iframeContent").width("100%");thickDims();return false});a(".theme-detail").click(function(){a(this).siblings(".themedetaildiv").toggle();return false})});
Index: /tags/3.1/wp-admin/js/theme.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/theme.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/theme.dev.js	(revision 17487)
@@ -0,0 +1,55 @@
+var ThemeViewer;
+
+(function($){
+	ThemeViewer = function( args ) {
+
+		function init() {
+			$( '#filter-click, #mini-filter-click' ).unbind( 'click' ).click( function() {
+				$( '#filter-click' ).toggleClass( 'current' );
+				$( '#filter-box' ).slideToggle();
+				$( '#current-theme' ).slideToggle( 300 );
+				return false;
+			});
+
+			$( '#filter-box :checkbox' ).unbind( 'click' ).click( function() {
+				var count = $( '#filter-box :checked' ).length,
+					text  = $( '#filter-click' ).text();
+
+				if ( text.indexOf( '(' ) != -1 )
+					text = text.substr( 0, text.indexOf( '(' ) );
+
+				if ( count == 0 )
+					$( '#filter-click' ).text( text );
+				else
+					$( '#filter-click' ).text( text + ' (' + count + ')' );
+			});
+
+			/* $('#filter-box :submit').unbind( 'click' ).click(function() {
+				var features = [];
+				$('#filter-box :checked').each(function() {
+					features.push($(this).val());
+				});
+
+				listTable.update_rows({'features': features}, true, function() {
+					$( '#filter-click' ).toggleClass( 'current' );
+					$( '#filter-box' ).slideToggle();
+					$( '#current-theme' ).slideToggle( 300 );
+				});
+
+				return false;
+			}); */
+		}
+
+		// These are the functions we expose
+		var api = {
+			init: init
+		};
+
+  	return api;
+	}
+})(jQuery);
+
+jQuery( document ).ready( function($) {
+	theme_viewer = new ThemeViewer();
+	theme_viewer.init();
+});
Index: /tags/3.1/wp-admin/js/theme.js
===================================================================
--- /tags/3.1/wp-admin/js/theme.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/theme.js	(revision 17487)
@@ -0,0 +1,1 @@
+var ThemeViewer;(function(a){ThemeViewer=function(b){function d(){a("#filter-click, #mini-filter-click").unbind("click").click(function(){a("#filter-click").toggleClass("current");a("#filter-box").slideToggle();a("#current-theme").slideToggle(300);return false});a("#filter-box :checkbox").unbind("click").click(function(){var e=a("#filter-box :checked").length,f=a("#filter-click").text();if(f.indexOf("(")!=-1){f=f.substr(0,f.indexOf("("))}if(e==0){a("#filter-click").text(f)}else{a("#filter-click").text(f+" ("+e+")")}})}var c={init:d};return c}})(jQuery);jQuery(document).ready(function(a){theme_viewer=new ThemeViewer();theme_viewer.init()});
Index: /tags/3.1/wp-admin/js/user-profile.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/user-profile.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/user-profile.dev.js	(revision 17487)
@@ -0,0 +1,65 @@
+(function($){
+
+	function check_pass_strength() {
+		var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
+
+		$('#pass-strength-result').removeClass('short bad good strong');
+		if ( ! pass1 ) {
+			$('#pass-strength-result').html( pwsL10n.empty );
+			return;
+		}
+
+		strength = passwordStrength(pass1, user, pass2);
+
+		switch ( strength ) {
+			case 2:
+				$('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
+				break;
+			case 3:
+				$('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
+				break;
+			case 4:
+				$('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
+				break;
+			case 5:
+				$('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
+				break;
+			default:
+				$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
+		}
+	}
+
+	$(document).ready( function() {
+		$('#pass1').val('').keyup( check_pass_strength );
+		$('#pass2').val('').keyup( check_pass_strength );
+		$('#pass-strength-result').show();
+		$('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
+		$('#nickname').blur(function(){
+			var str = $(this).val() || $('#user_login').val();
+			var select = $('#display_name');
+			var sel = select.children('option:selected').attr('id');
+			select.children('#display_nickname').remove();
+			if ( ! select.children('option[value=' + str + ']').length )
+				select.append('<option id="display_nickname" value="' + str + '">' + str + '</option>');
+			$('#'+sel).attr('selected', 'selected');
+		});
+		$('#first_name, #last_name').blur(function(){
+			var select = $('#display_name');
+			var first = $('#first_name').val(), last = $('#last_name').val();
+			var sel = select.children('option:selected').attr('id');
+			$('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
+			if ( first && ! select.children('option[value=' + first + ']').length )
+				select.append('<option id="display_firstname" value="' + first + '">' + first + '</option>');
+			if ( last && ! select.children('option[value=' + last + ']').length )
+				select.append('<option id="display_lastname" value="' + last + '">' + last + '</option>');
+			if ( first && last ) {
+				if ( ! select.children('option[value=' + first + ' ' + last + ']').length )
+					select.append('<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>');
+				if ( ! select.children('option[value=' + last + ' ' + first + ']').length )
+					select.append('<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>');
+			}
+			$('#'+sel).attr('selected', 'selected');
+		});
+    });
+
+})(jQuery);
Index: /tags/3.1/wp-admin/js/user-profile.js
===================================================================
--- /tags/3.1/wp-admin/js/user-profile.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/user-profile.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var e=a(this).val()||a("#user_login").val();var c=a("#display_name");var d=c.children("option:selected").attr("id");c.children("#display_nickname").remove();if(!c.children("option[value="+e+"]").length){c.append('<option id="display_nickname" value="'+e+'">'+e+"</option>")}a("#"+d).attr("selected","selected")});a("#first_name, #last_name").blur(function(){var c=a("#display_name");var f=a("#first_name").val(),d=a("#last_name").val();var e=c.children("option:selected").attr("id");a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(f&&!c.children("option[value="+f+"]").length){c.append('<option id="display_firstname" value="'+f+'">'+f+"</option>")}if(d&&!c.children("option[value="+d+"]").length){c.append('<option id="display_lastname" value="'+d+'">'+d+"</option>")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('<option id="display_firstlast" value="'+f+" "+d+'">'+f+" "+d+"</option>")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('<option id="display_lastfirst" value="'+d+" "+f+'">'+d+" "+f+"</option>")}}a("#"+e).attr("selected","selected")})})})(jQuery);
Index: /tags/3.1/wp-admin/js/utils.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/utils.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/utils.dev.js	(revision 17487)
@@ -0,0 +1,144 @@
+// utility functions
+
+var wpCookies = {
+// The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
+
+	each : function(o, cb, s) {
+		var n, l;
+
+		if (!o)
+			return 0;
+
+		s = s || o;
+
+		if (typeof(o.length) != 'undefined') {
+			for (n=0, l = o.length; n<l; n++) {
+				if (cb.call(s, o[n], n, o) === false)
+					return 0;
+			}
+		} else {
+			for (n in o) {
+				if (o.hasOwnProperty(n)) {
+					if (cb.call(s, o[n], n, o) === false) {
+						return 0;
+					}
+				}
+			}
+		}
+		return 1;
+	},
+
+	getHash : function(n) {
+		var v = this.get(n), h;
+
+		if (v) {
+			this.each(v.split('&'), function(v) {
+				v = v.split('=');
+				h = h || {};
+				h[v[0]] = v[1];
+			});
+		}
+		return h;
+	},
+
+	setHash : function(n, v, e, p, d, s) {
+		var o = '';
+
+		this.each(v, function(v, k) {
+			o += (!o ? '' : '&') + k + '=' + v;
+		});
+
+		this.set(n, o, e, p, d, s);
+	},
+
+	get : function(n) {
+		var c = document.cookie, e, p = n + "=", b;
+
+		if (!c)
+			return;
+
+		b = c.indexOf("; " + p);
+
+		if (b == -1) {
+			b = c.indexOf(p);
+
+			if (b != 0)
+				return null;
+
+		} else {
+			b += 2;
+		}
+
+		e = c.indexOf(";", b);
+
+		if (e == -1)
+			e = c.length;
+
+		return decodeURIComponent(c.substring(b + p.length, e));
+	},
+
+	set : function(n, v, e, p, d, s) {
+		document.cookie = n + "=" + encodeURIComponent(v) +
+			((e) ? "; expires=" + e.toGMTString() : "") +
+			((p) ? "; path=" + p : "") +
+			((d) ? "; domain=" + d : "") +
+			((s) ? "; secure" : "");
+	},
+
+	remove : function(n, p) {
+		var d = new Date();
+
+		d.setTime(d.getTime() - 1000);
+
+		this.set(n, '', d, p, d);
+	}
+};
+
+// Returns the value as string. Second arg or empty string is returned when value is not set.
+function getUserSetting( name, def ) {
+	var o = getAllUserSettings();
+
+	if ( o.hasOwnProperty(name) )
+		return o[name];
+
+	if ( typeof def != 'undefined' )
+		return def;
+
+	return '';
+}
+
+// Both name and value must be only ASCII letters, numbers or underscore
+// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
+function setUserSetting( name, value, del ) {
+	if ( 'object' !== typeof userSettings )
+		return false;
+
+	var c = 'wp-settings-' + userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date(), p,
+	n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
+
+	if ( del ) {
+		delete o[n];
+	} else {
+		o[n] = v;
+	}
+
+	d.setTime( d.getTime() + 31536000000 );
+	p = userSettings.url;
+
+	wpCookies.setHash(c, o, d, p);
+	wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p);
+
+	return name;
+}
+
+function deleteUserSetting( name ) {
+	return setUserSetting( name, '', 1 );
+}
+
+// Returns all settings as js object.
+function getAllUserSettings() {
+	if ( 'object' !== typeof userSettings )
+		return {};
+
+	return wpCookies.getHash('wp-settings-' + userSettings.uid) || {};
+}
Index: /tags/3.1/wp-admin/js/utils.js
===================================================================
--- /tags/3.1/wp-admin/js/utils.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/utils.js	(revision 17487)
@@ -0,0 +1,1 @@
+var wpCookies={each:function(d,a,c){var e,b;if(!d){return 0}c=c||d;if(typeof(d.length)!="undefined"){for(e=0,b=d.length;e<b;e++){if(a.call(c,d[e],e,d)===false){return 0}}}else{for(e in d){if(d.hasOwnProperty(e)){if(a.call(c,d[e],e,d)===false){return 0}}}}return 1},getHash:function(c){var a=this.get(c),b;if(a){this.each(a.split("&"),function(d){d=d.split("=");b=b||{};b[d[0]]=d[1]})}return b},setHash:function(i,a,f,c,h,b){var g="";this.each(a,function(e,d){g+=(!g?"":"&")+d+"="+e});this.set(i,g,f,c,h,b)},get:function(h){var g=document.cookie,f,d=h+"=",a;if(!g){return}a=g.indexOf("; "+d);if(a==-1){a=g.indexOf(d);if(a!=0){return null}}else{a+=2}f=g.indexOf(";",a);if(f==-1){f=g.length}return decodeURIComponent(g.substring(a+d.length,f))},set:function(h,a,f,c,g,b){document.cookie=h+"="+encodeURIComponent(a)+((f)?"; expires="+f.toGMTString():"")+((c)?"; path="+c:"")+((g)?"; domain="+g:"")+((b)?"; secure":"")},remove:function(c,a){var b=new Date();b.setTime(b.getTime()-1000);this.set(c,"",b,a,b)}};function getUserSetting(a,b){var c=getAllUserSettings();if(c.hasOwnProperty(a)){return c[a]}if(typeof b!="undefined"){return b}return""}function setUserSetting(a,i,k){if("object"!==typeof userSettings){return false}var h="wp-settings-"+userSettings.uid,e=wpCookies.getHash(h)||{},g=new Date(),b,f=a.toString().replace(/[^A-Za-z0-9_]/,""),j=i.toString().replace(/[^A-Za-z0-9_]/,"");if(k){delete e[f]}else{e[f]=j}g.setTime(g.getTime()+31536000000);b=userSettings.url;wpCookies.setHash(h,e,g,b);wpCookies.set("wp-settings-time-"+userSettings.uid,userSettings.time,g,b);return a}function deleteUserSetting(a){return setUserSetting(a,"",1)}function getAllUserSettings(){if("object"!==typeof userSettings){return{}}return wpCookies.getHash("wp-settings-"+userSettings.uid)||{}};
Index: /tags/3.1/wp-admin/js/widgets.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/widgets.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/widgets.dev.js	(revision 17487)
@@ -0,0 +1,281 @@
+var wpWidgets;
+(function($) {
+
+wpWidgets = {
+
+	init : function() {
+		var rem, sidebars = $('div.widgets-sortables');
+
+		$('#widgets-right').children('.widgets-holder-wrap').children('.sidebar-name').click(function(){
+			var c = $(this).siblings('.widgets-sortables'), p = $(this).parent();
+			if ( !p.hasClass('closed') ) {
+				c.sortable('disable');
+				p.addClass('closed');
+			} else {
+				p.removeClass('closed');
+				c.sortable('enable').sortable('refresh');
+			}
+		});
+
+		$('#widgets-left').children('.widgets-holder-wrap').children('.sidebar-name').click(function() {
+			$(this).siblings('.widget-holder').parent().toggleClass('closed');
+		});
+
+		sidebars.not('#wp_inactive_widgets').each(function(){
+			var h = 50, H = $(this).children('.widget').length;
+			h = h + parseInt(H * 48, 10);
+			$(this).css( 'minHeight', h + 'px' );
+		});
+
+		$('a.widget-action').live('click', function(){
+			var css = {}, widget = $(this).closest('div.widget'), inside = widget.children('.widget-inside'), w = parseInt( widget.find('input.widget-width').val(), 10 );
+
+			if ( inside.is(':hidden') ) {
+				if ( w > 250 && inside.closest('div.widgets-sortables').length ) {
+					css['width'] = w + 30 + 'px';
+					if ( inside.closest('div.widget-liquid-right').length )
+						css['marginLeft'] = 235 - w + 'px';
+					widget.css(css);
+				}
+				wpWidgets.fixLabels(widget);
+				inside.slideDown('fast');
+			} else {
+				inside.slideUp('fast', function() {
+					widget.css({'width':'','marginLeft':''});
+				});
+			}
+			return false;
+		});
+
+		$('input.widget-control-save').live('click', function(){
+			wpWidgets.save( $(this).closest('div.widget'), 0, 1, 0 );
+			return false;
+		});
+
+		$('a.widget-control-remove').live('click', function(){
+			wpWidgets.save( $(this).closest('div.widget'), 1, 1, 0 );
+			return false;
+		});
+
+		$('a.widget-control-close').live('click', function(){
+			wpWidgets.close( $(this).closest('div.widget') );
+			return false;
+		});
+
+		sidebars.children('.widget').each(function() {
+			wpWidgets.appendTitle(this);
+			if ( $('p.widget-error', this).length )
+				$('a.widget-action', this).click();
+		});
+
+		$('#widget-list').children('.widget').draggable({
+			connectToSortable: 'div.widgets-sortables',
+			handle: '> .widget-top > .widget-title',
+			distance: 2,
+			helper: 'clone',
+			zIndex: 5,
+			containment: 'document',
+			start: function(e,ui) {
+				wpWidgets.fixWebkit(1);
+				ui.helper.find('div.widget-description').hide();
+			},
+			stop: function(e,ui) {
+				if ( rem )
+					$(rem).hide();
+				rem = '';
+				wpWidgets.fixWebkit();
+			}
+		});
+
+		sidebars.sortable({
+			placeholder: 'widget-placeholder',
+			items: '> .widget',
+			handle: '> .widget-top > .widget-title',
+			cursor: 'move',
+			distance: 2,
+			containment: 'document',
+			start: function(e,ui) {
+				wpWidgets.fixWebkit(1);
+				ui.item.children('.widget-inside').hide();
+				ui.item.css({'marginLeft':'','width':''});
+			},
+			stop: function(e,ui) {
+				if ( ui.item.hasClass('ui-draggable') && ui.item.data('draggable') )
+					ui.item.draggable('destroy');
+
+				if ( ui.item.hasClass('deleting') ) {
+					wpWidgets.save( ui.item, 1, 0, 1 ); // delete widget
+					ui.item.remove();
+					return;
+				}
+
+				var add = ui.item.find('input.add_new').val(),
+					n = ui.item.find('input.multi_number').val(),
+					id = ui.item.attr('id'),
+					sb = $(this).attr('id');
+
+				ui.item.css({'marginLeft':'','width':''});
+				wpWidgets.fixWebkit();
+				if ( add ) {
+					if ( 'multi' == add ) {
+						ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) );
+						ui.item.attr( 'id', id.replace(/__i__|%i%/g, n) );
+						n++;
+						$('div#' + id).find('input.multi_number').val(n);
+					} else if ( 'single' == add ) {
+						ui.item.attr( 'id', 'new-' + id );
+						rem = 'div#' + id;
+					}
+					wpWidgets.save( ui.item, 0, 0, 1 );
+					ui.item.find('input.add_new').val('');
+					ui.item.find('a.widget-action').click();
+					return;
+				}
+				wpWidgets.saveOrder(sb);
+			},
+			receive: function(e,ui) {
+				if ( !$(this).is(':visible') )
+					$(this).sortable('cancel');
+			}
+		}).sortable('option', 'connectWith', 'div.widgets-sortables').parent().filter('.closed').children('.widgets-sortables').sortable('disable');
+
+		$('#available-widgets').droppable({
+			tolerance: 'pointer',
+			accept: function(o){
+				return $(o).parent().attr('id') != 'widget-list';
+			},
+			drop: function(e,ui) {
+				ui.draggable.addClass('deleting');
+				$('#removing-widget').hide().children('span').html('');
+			},
+			over: function(e,ui) {
+				ui.draggable.addClass('deleting');
+				$('div.widget-placeholder').hide();
+
+				if ( ui.draggable.hasClass('ui-sortable-helper') )
+					$('#removing-widget').show().children('span')
+					.html( ui.draggable.find('div.widget-title').children('h4').html() );
+			},
+			out: function(e,ui) {
+				ui.draggable.removeClass('deleting');
+				$('div.widget-placeholder').show();
+				$('#removing-widget').hide().children('span').html('');
+			}
+		});
+	},
+
+	saveOrder : function(sb) {
+		if ( sb )
+			$('#' + sb).closest('div.widgets-holder-wrap').find('img.ajax-feedback').css('visibility', 'visible');
+
+		var a = {
+			action: 'widgets-order',
+			savewidgets: $('#_wpnonce_widgets').val(),
+			sidebars: []
+		};
+
+		$('div.widgets-sortables').each( function() {
+			a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(',');
+		});
+
+		$.post( ajaxurl, a, function() {
+			$('img.ajax-feedback').css('visibility', 'hidden');
+		});
+
+		this.resize();
+	},
+
+	save : function(widget, del, animate, order) {
+		var sb = widget.closest('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a;
+		widget = $(widget);
+		$('.ajax-feedback', widget).css('visibility', 'visible');
+
+		a = {
+			action: 'save-widget',
+			savewidgets: $('#_wpnonce_widgets').val(),
+			sidebar: sb
+		};
+
+		if ( del )
+			a['delete_widget'] = 1;
+
+		data += '&' + $.param(a);
+
+		$.post( ajaxurl, data, function(r){
+			var id;
+
+			if ( del ) {
+				if ( !$('input.widget_number', widget).val() ) {
+					id = $('input.widget-id', widget).val();
+					$('#available-widgets').find('input.widget-id').each(function(){
+						if ( $(this).val() == id )
+							$(this).closest('div.widget').show();
+					});
+				}
+
+				if ( animate ) {
+					order = 0;
+					widget.slideUp('fast', function(){
+						$(this).remove();
+						wpWidgets.saveOrder();
+					});
+				} else {
+					widget.remove();
+					wpWidgets.resize();
+				}
+			} else {
+				$('.ajax-feedback').css('visibility', 'hidden');
+				if ( r && r.length > 2 ) {
+					$('div.widget-content', widget).html(r);
+					wpWidgets.appendTitle(widget);
+					wpWidgets.fixLabels(widget);
+				}
+			}
+			if ( order )
+				wpWidgets.saveOrder();
+		});
+	},
+
+	appendTitle : function(widget) {
+		var title = $('input[id*="-title"]', widget);
+		if ( title = title.val() ) {
+			title = title.replace(/<[^<>]+>/g, '').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+			$(widget).children('.widget-top').children('.widget-title').children()
+				.children('.in-widget-title').html(': ' + title);
+		}
+	},
+
+	resize : function() {
+		$('div.widgets-sortables').not('#wp_inactive_widgets').each(function(){
+			var h = 50, H = $(this).children('.widget').length;
+			h = h + parseInt(H * 48, 10);
+			$(this).css( 'minHeight', h + 'px' );
+		});
+	},
+
+    fixWebkit : function(n) {
+        n = n ? 'none' : '';
+        $('body').css({
+			WebkitUserSelect: n,
+			KhtmlUserSelect: n
+		});
+    },
+
+    fixLabels : function(widget) {
+		widget.children('.widget-inside').find('label').each(function(){
+			var f = $(this).attr('for');
+			if ( f && f == $('input', this).attr('id') )
+				$(this).removeAttr('for');
+		});
+	},
+
+    close : function(widget) {
+		widget.children('.widget-inside').slideUp('fast', function(){
+			widget.css({'width':'','marginLeft':''});
+		});
+	}
+};
+
+$(document).ready(function($){ wpWidgets.init(); });
+
+})(jQuery);
Index: /tags/3.1/wp-admin/js/widgets.js
===================================================================
--- /tags/3.1/wp-admin/js/widgets.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/widgets.js	(revision 17487)
@@ -0,0 +1,1 @@
+var wpWidgets;(function(a){wpWidgets={init:function(){var c,b=a("div.widgets-sortables");a("#widgets-right").children(".widgets-holder-wrap").children(".sidebar-name").click(function(){var e=a(this).siblings(".widgets-sortables"),d=a(this).parent();if(!d.hasClass("closed")){e.sortable("disable");d.addClass("closed")}else{d.removeClass("closed");e.sortable("enable").sortable("refresh")}});a("#widgets-left").children(".widgets-holder-wrap").children(".sidebar-name").click(function(){a(this).siblings(".widget-holder").parent().toggleClass("closed")});b.not("#wp_inactive_widgets").each(function(){var e=50,d=a(this).children(".widget").length;e=e+parseInt(d*48,10);a(this).css("minHeight",e+"px")});a("a.widget-action").live("click",function(){var f={},g=a(this).closest("div.widget"),d=g.children(".widget-inside"),e=parseInt(g.find("input.widget-width").val(),10);if(d.is(":hidden")){if(e>250&&d.closest("div.widgets-sortables").length){f.width=e+30+"px";if(d.closest("div.widget-liquid-right").length){f.marginLeft=235-e+"px"}g.css(f)}wpWidgets.fixLabels(g);d.slideDown("fast")}else{d.slideUp("fast",function(){g.css({width:"",marginLeft:""})})}return false});a("input.widget-control-save").live("click",function(){wpWidgets.save(a(this).closest("div.widget"),0,1,0);return false});a("a.widget-control-remove").live("click",function(){wpWidgets.save(a(this).closest("div.widget"),1,1,0);return false});a("a.widget-control-close").live("click",function(){wpWidgets.close(a(this).closest("div.widget"));return false});b.children(".widget").each(function(){wpWidgets.appendTitle(this);if(a("p.widget-error",this).length){a("a.widget-action",this).click()}});a("#widget-list").children(".widget").draggable({connectToSortable:"div.widgets-sortables",handle:"> .widget-top > .widget-title",distance:2,helper:"clone",zIndex:5,containment:"document",start:function(f,d){wpWidgets.fixWebkit(1);d.helper.find("div.widget-description").hide()},stop:function(f,d){if(c){a(c).hide()}c="";wpWidgets.fixWebkit()}});b.sortable({placeholder:"widget-placeholder",items:"> .widget",handle:"> .widget-top > .widget-title",cursor:"move",distance:2,containment:"document",start:function(f,d){wpWidgets.fixWebkit(1);d.item.children(".widget-inside").hide();d.item.css({marginLeft:"",width:""})},stop:function(g,d){if(d.item.hasClass("ui-draggable")&&d.item.data("draggable")){d.item.draggable("destroy")}if(d.item.hasClass("deleting")){wpWidgets.save(d.item,1,0,1);d.item.remove();return}var f=d.item.find("input.add_new").val(),j=d.item.find("input.multi_number").val(),i=d.item.attr("id"),h=a(this).attr("id");d.item.css({marginLeft:"",width:""});wpWidgets.fixWebkit();if(f){if("multi"==f){d.item.html(d.item.html().replace(/<[^<>]+>/g,function(e){return e.replace(/__i__|%i%/g,j)}));d.item.attr("id",i.replace(/__i__|%i%/g,j));j++;a("div#"+i).find("input.multi_number").val(j)}else{if("single"==f){d.item.attr("id","new-"+i);c="div#"+i}}wpWidgets.save(d.item,0,0,1);d.item.find("input.add_new").val("");d.item.find("a.widget-action").click();return}wpWidgets.saveOrder(h)},receive:function(f,d){if(!a(this).is(":visible")){a(this).sortable("cancel")}}}).sortable("option","connectWith","div.widgets-sortables").parent().filter(".closed").children(".widgets-sortables").sortable("disable");a("#available-widgets").droppable({tolerance:"pointer",accept:function(d){return a(d).parent().attr("id")!="widget-list"},drop:function(f,d){d.draggable.addClass("deleting");a("#removing-widget").hide().children("span").html("")},over:function(f,d){d.draggable.addClass("deleting");a("div.widget-placeholder").hide();if(d.draggable.hasClass("ui-sortable-helper")){a("#removing-widget").show().children("span").html(d.draggable.find("div.widget-title").children("h4").html())}},out:function(f,d){d.draggable.removeClass("deleting");a("div.widget-placeholder").show();a("#removing-widget").hide().children("span").html("")}})},saveOrder:function(c){if(c){a("#"+c).closest("div.widgets-holder-wrap").find("img.ajax-feedback").css("visibility","visible")}var b={action:"widgets-order",savewidgets:a("#_wpnonce_widgets").val(),sidebars:[]};a("div.widgets-sortables").each(function(){b["sidebars["+a(this).attr("id")+"]"]=a(this).sortable("toArray").join(",")});a.post(ajaxurl,b,function(){a("img.ajax-feedback").css("visibility","hidden")});this.resize()},save:function(g,d,e,b){var h=g.closest("div.widgets-sortables").attr("id"),f=g.find("form").serialize(),c;g=a(g);a(".ajax-feedback",g).css("visibility","visible");c={action:"save-widget",savewidgets:a("#_wpnonce_widgets").val(),sidebar:h};if(d){c.delete_widget=1}f+="&"+a.param(c);a.post(ajaxurl,f,function(i){var j;if(d){if(!a("input.widget_number",g).val()){j=a("input.widget-id",g).val();a("#available-widgets").find("input.widget-id").each(function(){if(a(this).val()==j){a(this).closest("div.widget").show()}})}if(e){b=0;g.slideUp("fast",function(){a(this).remove();wpWidgets.saveOrder()})}else{g.remove();wpWidgets.resize()}}else{a(".ajax-feedback").css("visibility","hidden");if(i&&i.length>2){a("div.widget-content",g).html(i);wpWidgets.appendTitle(g);wpWidgets.fixLabels(g)}}if(b){wpWidgets.saveOrder()}})},appendTitle:function(b){var c=a('input[id*="-title"]',b);if(c=c.val()){c=c.replace(/<[^<>]+>/g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;");a(b).children(".widget-top").children(".widget-title").children().children(".in-widget-title").html(": "+c)}},resize:function(){a("div.widgets-sortables").not("#wp_inactive_widgets").each(function(){var c=50,b=a(this).children(".widget").length;c=c+parseInt(b*48,10);a(this).css("minHeight",c+"px")})},fixWebkit:function(b){b=b?"none":"";a("body").css({WebkitUserSelect:b,KhtmlUserSelect:b})},fixLabels:function(b){b.children(".widget-inside").find("label").each(function(){var c=a(this).attr("for");if(c&&c==a("input",this).attr("id")){a(this).removeAttr("for")}})},close:function(b){b.children(".widget-inside").slideUp("fast",function(){b.css({width:"",marginLeft:""})})}};a(document).ready(function(b){wpWidgets.init()})})(jQuery);
Index: /tags/3.1/wp-admin/js/word-count.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/word-count.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/word-count.dev.js	(revision 17487)
@@ -0,0 +1,39 @@
+// Word count
+(function($) {
+	wpWordCount = {
+
+		init : function() {
+			var t = this, last = 0, co = $('#content');
+
+			$('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) );
+			t.block = 0;
+			t.wc(co.val());
+			co.keyup( function(e) {
+				if ( e.keyCode == last ) return true;
+				if ( 13 == e.keyCode || 8 == last || 46 == last ) t.wc(co.val());
+				last = e.keyCode;
+				return true;
+			});
+		},
+
+		wc : function(tx) {
+			var t = this, w = $('#word-count'), tc = 0;
+
+			if ( t.block ) return;
+			t.block = 1;
+
+			setTimeout( function() {
+				if ( tx ) {
+					tx = tx.replace( /<.[^<>]*?>/g, ' ' ).replace( /&nbsp;|&#160;/gi, ' ' );
+					tx = tx.replace( /[0-9.(),;:!?%#$¿'"_+=\\/-]*/g, '' );
+					tx.replace( /\S\s+/g, function(){tc++;} );
+				}
+				w.html(tc.toString());
+
+				setTimeout( function() { t.block = 0; }, 2000 );
+			}, 1 );
+		}
+	}
+
+	$(document).ready( function(){ wpWordCount.init(); } );
+}(jQuery));
Index: /tags/3.1/wp-admin/js/word-count.js
===================================================================
--- /tags/3.1/wp-admin/js/word-count.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/word-count.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span id="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;|&#160;/gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));
Index: /tags/3.1/wp-admin/js/xfn.dev.js
===================================================================
--- /tags/3.1/wp-admin/js/xfn.dev.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/xfn.dev.js	(revision 17487)
@@ -0,0 +1,16 @@
+jQuery(document).ready( function($) {
+	$('#link_rel').attr('readonly', 'readonly');
+	$('#linkxfndiv input').bind('click keyup', function() {
+		var isMe = $('#me').is(':checked'), inputs = '';
+		$('input.valinp').each( function() {
+			if (isMe) {
+				$(this).attr('disabled', 'disabled').parent().addClass('disabled');
+			} else {
+				$(this).removeAttr('disabled').parent().removeClass('disabled');
+				if ( $(this).is(':checked') && $(this).val() != '')
+					inputs += $(this).val() + ' ';
+			}
+		});
+		$('#link_rel').val( (isMe) ? 'me' : inputs.substr(0,inputs.length - 1) );
+	});
+});
Index: /tags/3.1/wp-admin/js/xfn.js
===================================================================
--- /tags/3.1/wp-admin/js/xfn.js	(revision 17487)
+++ /tags/3.1/wp-admin/js/xfn.js	(revision 17487)
@@ -0,0 +1,1 @@
+jQuery(document).ready(function(a){a("#link_rel").attr("readonly","readonly");a("#linkxfndiv input").bind("click keyup",function(){var c=a("#me").is(":checked"),b="";a("input.valinp").each(function(){if(c){a(this).attr("disabled","disabled").parent().addClass("disabled")}else{a(this).removeAttr("disabled").parent().removeClass("disabled");if(a(this).is(":checked")&&a(this).val()!=""){b+=a(this).val()+" "}}});a("#link_rel").val((c)?"me":b.substr(0,b.length-1))})});
Index: /tags/3.1/wp-admin/link-add.php
===================================================================
--- /tags/3.1/wp-admin/link-add.php	(revision 17487)
+++ /tags/3.1/wp-admin/link-add.php	(revision 17487)
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Add Link Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can('manage_links') )
+	wp_die(__('You do not have sufficient permissions to add links to this site.'));
+
+$title = __('Add New Link');
+$parent_file = 'link-manager.php';
+
+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[]'));
+
+wp_enqueue_script('link');
+wp_enqueue_script('xfn');
+
+$link = get_default_link_to_edit();
+include('./edit-link-form.php');
+
+require('./admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/link-manager.php
===================================================================
--- /tags/3.1/wp-admin/link-manager.php	(revision 17487)
+++ /tags/3.1/wp-admin/link-manager.php	(revision 17487)
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Link Management Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once ('admin.php');
+if ( ! current_user_can( 'manage_links' ) )
+	wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );
+
+$wp_list_table = _get_list_table('WP_Links_List_Table');
+
+// Handle bulk deletes
+$doaction = $wp_list_table->current_action();
+
+if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {
+	check_admin_referer( 'bulk-bookmarks' );
+
+	if ( 'delete' == $doaction ) {
+		$bulklinks = (array) $_REQUEST['linkcheck'];
+		foreach ( $bulklinks as $link_id ) {
+			$link_id = (int) $link_id;
+
+			wp_delete_link( $link_id );
+		}
+
+		wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) );
+		exit;
+	}
+} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
+	 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
+	 exit;
+}
+
+$wp_list_table->prepare_items();
+
+$title = __('Links');
+$this_file = $parent_file = 'link-manager.php';
+
+add_contextual_help( $current_screen,
+	'<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '</p>' .
+    '<p>' . __('Links may be separated into categories; these are different than the categories used on your posts.') . '</p>' .
+    '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>' .
+    '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Links_Links_SubPanel" target="_blank">Documentation on Managing Links</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include_once ('./admin-header.php');
+
+if ( ! current_user_can('manage_links') )
+	wp_die(__("You do not have sufficient permissions to edit the links for this site."));
+
+?>
+
+<div class="wrap nosubsub">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php
+if ( !empty($_REQUEST['s']) )
+	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
+</h2>
+
+<?php
+if ( isset($_REQUEST['deleted']) ) {
+	echo '<div id="message" class="updated"><p>';
+	$deleted = (int) $_REQUEST['deleted'];
+	printf(_n('%s link deleted.', '%s links deleted', $deleted), $deleted);
+	echo '</p></div>';
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
+}
+?>
+
+<form id="posts-filter" action="" method="get">
+
+<?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?>
+
+<?php $wp_list_table->display(); ?>
+
+<div id="ajax-response"></div>
+</form>
+
+</div>
+
+<?php
+include('./admin-footer.php');
Index: /tags/3.1/wp-admin/link-parse-opml.php
===================================================================
--- /tags/3.1/wp-admin/link-parse-opml.php	(revision 17487)
+++ /tags/3.1/wp-admin/link-parse-opml.php	(revision 17487)
@@ -0,0 +1,97 @@
+<?php
+/**
+ * Parse OPML XML files and store in globals.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+if ( ! defined('ABSPATH') )
+	die();
+
+global $opml, $map;
+
+// columns we wish to find are:  link_url, link_name, link_target, link_description
+// we need to map XML attribute names to our columns
+$opml_map = array('URL'         => 'link_url',
+	'HTMLURL'     => 'link_url',
+	'TEXT'        => 'link_name',
+	'TITLE'       => 'link_name',
+	'TARGET'      => 'link_target',
+	'DESCRIPTION' => 'link_description',
+	'XMLURL'      => 'link_rss'
+);
+
+$map = $opml_map;
+
+/**
+ * XML callback function for the start of a new XML tag.
+ *
+ * @since 0.71
+ * @access private
+ *
+ * @uses $updated_timestamp Not used inside function.
+ * @uses $all_links Not used inside function.
+ * @uses $map Stores names of attributes to use.
+ * @global array $names
+ * @global array $urls
+ * @global array $targets
+ * @global array $descriptions
+ * @global array $feeds
+ *
+ * @param mixed $parser XML Parser resource.
+ * @param string $tagName XML element name.
+ * @param array $attrs XML element attributes.
+ */
+function startElement($parser, $tagName, $attrs) {
+	global $updated_timestamp, $all_links, $map;
+	global $names, $urls, $targets, $descriptions, $feeds;
+
+	if ($tagName == 'OUTLINE') {
+		foreach (array_keys($map) as $key) {
+			if (isset($attrs[$key])) {
+				$$map[$key] = $attrs[$key];
+			}
+		}
+
+		//echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
+
+		// save the data away.
+		$names[] = $link_name;
+		$urls[] = $link_url;
+		$targets[] = $link_target;
+		$feeds[] = $link_rss;
+		$descriptions[] = $link_description;
+	} // end if outline
+}
+
+/**
+ * XML callback function that is called at the end of a XML tag.
+ *
+ * @since 0.71
+ * @access private
+ * @package WordPress
+ * @subpackage Dummy
+ *
+ * @param mixed $parser XML Parser resource.
+ * @param string $tagName XML tag name.
+ */
+function endElement($parser, $tagName) {
+	// nothing to do.
+}
+
+// Create an XML parser
+$xml_parser = xml_parser_create();
+
+// Set the functions to handle opening and closing tags
+xml_set_element_handler($xml_parser, "startElement", "endElement");
+
+if (!xml_parse($xml_parser, $opml, true)) {
+	echo(sprintf(__('XML error: %1$s at line %2$s'),
+	xml_error_string(xml_get_error_code($xml_parser)),
+	xml_get_current_line_number($xml_parser)));
+}
+
+// Free up memory used by the XML parser
+xml_parser_free($xml_parser);
+?>
Index: /tags/3.1/wp-admin/link.php
===================================================================
--- /tags/3.1/wp-admin/link.php	(revision 17487)
+++ /tags/3.1/wp-admin/link.php	(revision 17487)
@@ -0,0 +1,118 @@
+<?php
+/**
+ * Manage link administration actions.
+ *
+ * This page is accessed by the link management pages and handles the forms and
+ * AJAX processes for link actions.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once ('admin.php');
+
+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[]'));
+
+if ( ! current_user_can('manage_links') )
+	wp_die( __('You do not have sufficient permissions to edit the links for this site.') );
+
+if ( !empty($_POST['deletebookmarks']) )
+	$action = 'deletebookmarks';
+if ( !empty($_POST['move']) )
+	$action = 'move';
+if ( !empty($_POST['linkcheck']) )
+	$linkcheck = $_POST['linkcheck'];
+
+$this_file = admin_url('link-manager.php');
+
+switch ($action) {
+	case 'deletebookmarks' :
+		check_admin_referer('bulk-bookmarks');
+
+		//for each link id (in $linkcheck[]) change category to selected value
+		if (count($linkcheck) == 0) {
+			wp_redirect($this_file);
+			exit;
+		}
+
+		$deleted = 0;
+		foreach ($linkcheck as $link_id) {
+			$link_id = (int) $link_id;
+
+			if ( wp_delete_link($link_id) )
+				$deleted++;
+		}
+
+		wp_redirect("$this_file?deleted=$deleted");
+		exit;
+		break;
+
+	case 'move' :
+		check_admin_referer('bulk-bookmarks');
+
+		//for each link id (in $linkcheck[]) change category to selected value
+		if (count($linkcheck) == 0) {
+			wp_redirect($this_file);
+			exit;
+		}
+		$all_links = join(',', $linkcheck);
+		// should now have an array of links we can change
+		//$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
+
+		wp_redirect($this_file);
+		exit;
+		break;
+
+	case 'add' :
+		check_admin_referer('add-bookmark');
+
+		$redir = wp_get_referer();
+		if ( add_link() )
+			$redir = add_query_arg( 'added', 'true', $redir );
+
+		wp_redirect( $redir );
+		exit;
+		break;
+
+	case 'save' :
+		$link_id = (int) $_POST['link_id'];
+		check_admin_referer('update-bookmark_' . $link_id);
+
+		edit_link($link_id);
+
+		wp_redirect($this_file);
+		exit;
+		break;
+
+	case 'delete' :
+		$link_id = (int) $_GET['link_id'];
+		check_admin_referer('delete-bookmark_' . $link_id);
+
+		wp_delete_link($link_id);
+
+		wp_redirect($this_file);
+		exit;
+		break;
+
+	case 'edit' :
+		wp_enqueue_script('link');
+		wp_enqueue_script('xfn');
+
+		$parent_file = 'link-manager.php';
+		$submenu_file = 'link-manager.php';
+		$title = __('Edit Link');
+
+		$link_id = (int) $_GET['link_id'];
+
+		if (!$link = get_link_to_edit($link_id))
+			wp_die(__('Link not found.'));
+
+		include ('edit-link-form.php');
+		include ('admin-footer.php');
+		break;
+
+	default :
+		break;
+}
+?>
Index: /tags/3.1/wp-admin/load-scripts.php
===================================================================
--- /tags/3.1/wp-admin/load-scripts.php	(revision 17487)
+++ /tags/3.1/wp-admin/load-scripts.php	(revision 17487)
@@ -0,0 +1,142 @@
+<?php
+
+/**
+ * Disable error reporting
+ *
+ * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
+ */
+error_reporting(0);
+
+/** Set ABSPATH for execution */
+define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
+define( 'WPINC', 'wp-includes' );
+
+/**
+ * @ignore
+ */
+function __() {}
+
+/**
+ * @ignore
+ */
+function _x() {}
+
+
+/**
+ * @ignore
+ */
+function add_filter() {}
+
+/**
+ * @ignore
+ */
+function esc_attr() {}
+
+/**
+ * @ignore
+ */
+function apply_filters() {}
+
+/**
+ * @ignore
+ */
+function get_option() {}
+
+/**
+ * @ignore
+ */
+function is_lighttpd_before_150() {}
+
+/**
+ * @ignore
+ */
+function add_action() {}
+
+/**
+ * @ignore
+ */
+function do_action_ref_array() {}
+
+/**
+ * @ignore
+ */
+function get_bloginfo() {}
+
+/**
+ * @ignore
+ */
+function is_admin() {return true;}
+
+/**
+ * @ignore
+ */
+function site_url() {}
+
+/**
+ * @ignore
+ */
+function admin_url() {}
+
+/**
+ * @ignore
+ */
+function home_url() {}
+
+/**
+ * @ignore
+ */
+function wp_guess_url() {}
+
+function get_file($path) {
+
+	if ( function_exists('realpath') )
+		$path = realpath($path);
+
+	if ( ! $path || ! @is_file($path) )
+		return '';
+
+	return @file_get_contents($path);
+}
+
+$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
+$load = explode(',', $load);
+
+if ( empty($load) )
+	exit;
+
+require(ABSPATH . WPINC . '/script-loader.php');
+require(ABSPATH . WPINC . '/version.php');
+
+$compress = ( isset($_GET['c']) && $_GET['c'] );
+$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
+$expires_offset = 31536000;
+$out = '';
+
+$wp_scripts = new WP_Scripts();
+wp_default_scripts($wp_scripts);
+
+foreach( $load as $handle ) {
+	if ( !array_key_exists($handle, $wp_scripts->registered) )
+		continue;
+
+	$path = ABSPATH . $wp_scripts->registered[$handle]->src;
+	$out .= get_file($path) . "\n";
+}
+
+header('Content-Type: application/x-javascript; charset=UTF-8');
+header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
+header("Cache-Control: public, max-age=$expires_offset");
+
+if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
+	header('Vary: Accept-Encoding'); // Handle proxies
+	if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
+		header('Content-Encoding: deflate');
+		$out = gzdeflate( $out, 3 );
+	} elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
+		header('Content-Encoding: gzip');
+		$out = gzencode( $out, 3 );
+	}
+}
+
+echo $out;
+exit;
Index: /tags/3.1/wp-admin/load-styles.php
===================================================================
--- /tags/3.1/wp-admin/load-styles.php	(revision 17487)
+++ /tags/3.1/wp-admin/load-styles.php	(revision 17487)
@@ -0,0 +1,147 @@
+<?php
+
+/**
+ * Disable error reporting
+ *
+ * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
+ */
+error_reporting(0);
+
+/** Set ABSPATH for execution */
+define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
+define( 'WPINC', 'wp-includes' );
+
+/**
+ * @ignore
+ */
+function __() {}
+
+/**
+ * @ignore
+ */
+function _x() {}
+
+
+/**
+ * @ignore
+ */
+function add_filter() {}
+
+/**
+ * @ignore
+ */
+function esc_attr() {}
+
+/**
+ * @ignore
+ */
+function apply_filters() {}
+
+/**
+ * @ignore
+ */
+function get_option() {}
+
+/**
+ * @ignore
+ */
+function is_lighttpd_before_150() {}
+
+/**
+ * @ignore
+ */
+function add_action() {}
+
+/**
+ * @ignore
+ */
+function do_action_ref_array() {}
+
+/**
+ * @ignore
+ */
+function get_bloginfo() {}
+
+/**
+ * @ignore
+ */
+function is_admin() {return true;}
+
+/**
+ * @ignore
+ */
+function site_url() {}
+
+/**
+ * @ignore
+ */
+function admin_url() {}
+
+/**
+ * @ignore
+ */
+function wp_guess_url() {}
+
+function get_file($path) {
+
+	if ( function_exists('realpath') )
+		$path = realpath($path);
+
+	if ( ! $path || ! @is_file($path) )
+		return '';
+
+	return @file_get_contents($path);
+}
+
+require(ABSPATH . '/wp-includes/script-loader.php');
+require(ABSPATH . '/wp-includes/version.php');
+
+$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] );
+$load = explode(',', $load);
+
+if ( empty($load) )
+	exit;
+
+$compress = ( isset($_GET['c']) && $_GET['c'] );
+$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
+$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
+$expires_offset = 31536000;
+$out = '';
+
+$wp_styles = new WP_Styles();
+wp_default_styles($wp_styles);
+
+foreach( $load as $handle ) {
+	if ( !array_key_exists($handle, $wp_styles->registered) )
+		continue;
+
+	$style = $wp_styles->registered[$handle];
+	$path = ABSPATH . $style->src;
+
+	$content = get_file($path) . "\n";
+
+	if ( $rtl && isset($style->extra['rtl']) && $style->extra['rtl'] ) {
+		$rtl_path = is_bool($style->extra['rtl']) ? str_replace( '.css', '-rtl.css', $path ) : ABSPATH . $style->extra['rtl'];
+		$content .= get_file($rtl_path) . "\n";
+	}
+
+	$out .= str_replace( '../images/', 'images/', $content );
+}
+
+header('Content-Type: text/css');
+header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
+header("Cache-Control: public, max-age=$expires_offset");
+
+if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
+	header('Vary: Accept-Encoding'); // Handle proxies
+	if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
+		header('Content-Encoding: deflate');
+		$out = gzdeflate( $out, 3 );
+	} elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
+		header('Content-Encoding: gzip');
+		$out = gzencode( $out, 3 );
+	}
+}
+
+echo $out;
+exit;
Index: /tags/3.1/wp-admin/maint/repair.php
===================================================================
--- /tags/3.1/wp-admin/maint/repair.php	(revision 17487)
+++ /tags/3.1/wp-admin/maint/repair.php	(revision 17487)
@@ -0,0 +1,92 @@
+<?php
+
+define('WP_REPAIRING', true);
+
+require_once('../../wp-load.php');
+
+header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!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 language_attributes(); ?>>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<title><?php _e('WordPress &rsaquo; Database Repair'); ?></title>
+	<?php wp_admin_css( 'install', true ); ?>
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="../images/wordpress-logo.png" /></h1>
+
+<?php
+
+if ( !defined('WP_ALLOW_REPAIR') ) {
+	echo '<p>'.__('To allow use of this page to automatically repair database problems, please add the following line to your wp-config.php file.  Once this line is added to your config, reload this page.')."</p><code>define('WP_ALLOW_REPAIR', true);</code>";
+} elseif ( isset($_GET['repair']) ) {
+	$problems = array();
+	check_admin_referer('repair_db');
+
+	if ( 2 == $_GET['repair'] )
+		$optimize = true;
+	else
+		$optimize = false;
+
+	$okay = true;
+
+	$tables = $wpdb->tables();
+	// Sitecategories may not exist if global terms are disabled.
+	if ( is_multisite() && ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->sitecategories'" ) )
+		unset( $tables['sitecategories'] );
+	$tables = array_merge( $tables, (array) apply_filters( 'tables_to_repair', array() ) ); // Return tables with table prefixes.
+	// Loop over the tables, checking and repairing as needed.
+	foreach ( $tables as $table ) {
+		$check = $wpdb->get_row("CHECK TABLE $table");
+		if ( 'OK' == $check->Msg_text ) {
+			echo "<p>The $table table is okay.";
+		} else {
+			echo "<p>The $table table is not okay. It is reporting the following error: <code>$check->Msg_text</code>.  WordPress will attempt to repair this table&hellip;";
+			$repair = $wpdb->get_row("REPAIR TABLE $table");
+			if ( 'OK' == $check->Msg_text ) {
+				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully repaired the $table table.";
+			} else {
+				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to repair the $table table. Error: $check->Msg_text<br />";
+				$problems["$table"] = $check->Msg_text;
+				$okay = false;
+			}
+		}
+		if ( $okay && $optimize ) {
+			$check = $wpdb->get_row("ANALYZE TABLE $table");
+			if ( 'Table is already up to date' == $check->Msg_text )  {
+				echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;The $table table is already optimized.";
+			} else {
+				$check = $wpdb->get_row("OPTIMIZE TABLE $table");
+				if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text )
+					echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Successfully optimized the $table table.";
+				else
+					echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;Failed to optimize the $table table. Error: $check->Msg_text";
+			}
+		}
+		echo '</p>';
+	}
+
+	if ( !empty($problems) ) {
+		printf('<p>'.__('Some database problems could not be repaired. Please copy-and-paste the following list of errors to the <a href="%s">WordPress support forums</a> to get additional assistance.').'</p>', 'http://wordpress.org/support/forum/3');
+		$problem_output = array();
+		foreach ( $problems as $table => $problem )
+			$problem_output[] = "$table: $problem";
+		echo '<textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( implode("\n", $problem_output) ) . '</textarea>';
+	} else {
+		echo '<p>'.__('Repairs complete.  Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.')."</p><code>define('WP_ALLOW_REPAIR', true);</code>";
+	}
+} else {
+	if ( isset($_GET['referrer']) && 'is_blog_installed' == $_GET['referrer'] )
+		_e('One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the &#8220;Repair Database&#8221; button. Repairing can take a while, so please be patient.');
+	else
+		_e('WordPress can automatically look for some common database problems and repair them.  Repairing can take a while, so please be patient.')
+?>
+	<p class="step"><a class="button" href="<?php echo wp_nonce_url('repair.php?repair=1', 'repair_db') ?>"><?php _e( 'Repair Database' ); ?></a></p>
+	<?php _e('WordPress can also attempt to optimize the database.  This improves performance in some situations.  Repairing and optimizing the database can take a long time and the database will be locked while optimizing.'); ?>
+	<p class="step"><a class="button" href="<?php echo wp_nonce_url('repair.php?repair=2', 'repair_db') ?>"><?php _e( 'Repair and Optimize Database' ); ?></a></p>
+<?php
+}
+?>
+</body>
+</html>
Index: /tags/3.1/wp-admin/media-new.php
===================================================================
--- /tags/3.1/wp-admin/media-new.php	(revision 17487)
+++ /tags/3.1/wp-admin/media-new.php	(revision 17487)
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Upload new media Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+$_GET['inline'] = 'true';
+/** Administration bootstrap */
+require_once('./admin.php');
+require_once('./media-upload.php');
+
+?>
Index: /tags/3.1/wp-admin/media-upload.php
===================================================================
--- /tags/3.1/wp-admin/media-upload.php	(revision 17487)
+++ /tags/3.1/wp-admin/media-upload.php	(revision 17487)
@@ -0,0 +1,124 @@
+<?php
+/**
+ * Manage media uploaded file.
+ *
+ * There are many filters in here for media. Plugins can extend functionality
+ * by hooking into the filters.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+if ( ! isset( $_GET['inline'] ) )
+	define( 'IFRAME_REQUEST' , true );
+
+/** Load WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if (!current_user_can('upload_files'))
+	wp_die(__('You do not have permission to upload files.'));
+
+wp_enqueue_script('swfupload-all');
+wp_enqueue_script('swfupload-handlers');
+wp_enqueue_script('image-edit');
+wp_enqueue_script('set-post-thumbnail' );
+wp_enqueue_style('imgareaselect');
+
+@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+
+// IDs should be integers
+$ID = isset($ID) ? (int) $ID : 0;
+$post_id = isset($post_id)? (int) $post_id : 0;
+
+// Require an ID for the edit screen
+if ( isset($action) && $action == 'edit' && !$ID )
+	wp_die(__("You are not allowed to be here"));
+
+if ( isset($_GET['inline']) ) {
+	$errors = array();
+
+	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
+		// Upload File button was clicked
+		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
+		unset($_FILES);
+		if ( is_wp_error($id) ) {
+			$errors['upload_error'] = $id;
+			$id = false;
+		}
+	}
+
+	if ( isset($_GET['upload-page-form']) ) {
+		$errors = array_merge($errors, (array) media_upload_form_handler());
+
+		$location = 'upload.php';
+		if ( $errors )
+			$location .= '?message=3';
+
+		wp_redirect( admin_url($location) );
+		exit;
+	}
+
+	$title = __('Upload New Media');
+	$parent_file = 'upload.php';
+
+	add_contextual_help( $current_screen,
+'<p>' . __('You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share.') . '</p>' .
+		'<p>' . __('There are two options for uploading files: <em>Select Files</em> will open the Flash-based uploader (multiple file upload allowed), or you can use the <em>Browser Uploader</em>. Clicking <em>Select Files</em> opens a navigation window showing you files in your operating system. Selecting <em>Open</em> after clicking on the file you want activates a progress bar on the uploader screen. Basic image editing is available after upload is complete. Make sure you click <em>Save</em> before leaving this screen.') . '</p>' .
+		'<p><strong>' . __('For more information:') . '</strong></p>' .
+		'<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_SubPanel" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
+		'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+	);
+
+	require_once('./admin-header.php'); ?>
+	<div class="wrap">
+	<?php screen_icon(); ?>
+	<h2><?php echo esc_html( $title ); ?></h2>
+
+	<form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-upload.php?inline=&amp;upload-page-form='); ?>" class="media-upload-form type-form validate" id="file-form">
+
+	<?php media_upload_form(); ?>
+
+	<script type="text/javascript">
+	jQuery(function($){
+		var preloaded = $(".media-item.preloaded");
+		if ( preloaded.length > 0 ) {
+			preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
+		}
+		updateMediaForm();
+		post_id = 0;
+		shortform = 1;
+	});
+	</script>
+	<input type="hidden" name="post_id" id="post_id" value="0" />
+	<?php wp_nonce_field('media-form'); ?>
+	<div id="media-items" class="hide-if-no-js"> </div>
+	<?php submit_button( __( 'Save all changes' ), 'button savebutton hide-if-no-js', 'save' ); ?>
+	</form>
+	</div>
+
+<?php
+	include('./admin-footer.php');
+
+} else {
+
+	// upload type: image, video, file, ..?
+	if ( isset($_GET['type']) )
+		$type = strval($_GET['type']);
+	else
+		$type = apply_filters('media_upload_default_type', 'file');
+
+	// tab: gallery, library, or type-specific
+	if ( isset($_GET['tab']) )
+		$tab = strval($_GET['tab']);
+	else
+		$tab = apply_filters('media_upload_default_tab', 'type');
+
+	$body_id = 'media-upload';
+
+	// let the action code decide how to handle the request
+	if ( $tab == 'type' || $tab == 'type_url' )
+		do_action("media_upload_$type");
+	else
+		do_action("media_upload_$tab");
+}
+?>
Index: /tags/3.1/wp-admin/media.php
===================================================================
--- /tags/3.1/wp-admin/media.php	(revision 17487)
+++ /tags/3.1/wp-admin/media.php	(revision 17487)
@@ -0,0 +1,137 @@
+<?php
+/**
+ * Media management action handler.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+$parent_file = 'upload.php';
+$submenu_file = 'upload.php';
+
+wp_reset_vars(array('action'));
+
+switch( $action ) :
+case 'editattachment' :
+	$attachment_id = (int) $_POST['attachment_id'];
+	check_admin_referer('media-form');
+
+	if ( !current_user_can('edit_post', $attachment_id) )
+		wp_die ( __('You are not allowed to edit this attachment.') );
+
+	$errors = media_upload_form_handler();
+
+	if ( empty($errors) ) {
+		$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;
+	}
+
+	// no break
+case 'edit' :
+	$title = __('Edit Media');
+
+	if ( empty($errors) )
+		$errors = null;
+
+	if ( empty( $_GET['attachment_id'] ) ) {
+		wp_redirect( admin_url('upload.php') );
+		exit();
+	}
+	$att_id = (int) $_GET['attachment_id'];
+
+	if ( !current_user_can('edit_post', $att_id) )
+		wp_die ( __('You are not allowed to edit this attachment.') );
+
+	$att = get_post($att_id);
+
+	if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn&#8217;t exist. Perhaps it was deleted?') );
+	if ( $att->post_status == 'trash' ) wp_die( __('You can&#8217;t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.') );
+
+	add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
+
+	wp_enqueue_script( 'wp-ajax-response' );
+	wp_enqueue_script('image-edit');
+	wp_enqueue_style('imgareaselect');
+
+	add_contextual_help( $current_screen,
+	'<p>' . __('This screen allows you to edit five fields for metadata in a file within the media library.') . '</p>' .
+	'<p>' . __('For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.') . '</p>' .
+	'<p>' . __('Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.') . '</p>' .
+	'<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_SubPanel#Edit_Media" target="_blank">Documentation on Edit Media</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+	require( './admin-header.php' );
+
+	$parent_file = 'upload.php';
+	$message = '';
+	$class = '';
+	if ( isset($_GET['message']) ) {
+		switch ( $_GET['message'] ) :
+		case 'updated' :
+			$message = __('Media attachment updated.');
+			$class = 'updated';
+			break;
+		endswitch;
+	}
+	if ( $message )
+		echo "<div id='message' class='$class'><p>$message</p></div>\n";
+
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php _e( 'Edit Media' ); ?></h2>
+
+<form method="post" action="" class="media-upload-form" id="media-single-form">
+<p class="submit" style="padding-bottom: 0;">
+<?php submit_button( __( 'Update Media' ), 'primary', 'save', false ); ?>
+</p>
+
+<div class="media-single">
+<div id='media-item-<?php echo $att_id; ?>' class='media-item'>
+<?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'show_title' => false, 'errors' => !empty($errors[$att_id]) ? $errors[$att_id] : null ) ); ?>
+</div>
+</div>
+
+<?php submit_button( __( 'Update Media' ), 'primary', 'save' ); ?>
+<input type="hidden" name="post_id" id="post_id" value="<?php echo isset($post_id) ? esc_attr($post_id) : ''; ?>" />
+<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($att_id); ?>" />
+<input type="hidden" name="action" value="editattachment" />
+<?php wp_original_referer_field(true, 'previous'); ?>
+<?php wp_nonce_field('media-form'); ?>
+
+</form>
+
+</div>
+
+<?php
+
+	require( './admin-footer.php' );
+
+	exit;
+
+default:
+	wp_redirect( admin_url('upload.php') );
+	exit;
+
+endswitch;
+
+
+?>
Index: /tags/3.1/wp-admin/menu-header.php
===================================================================
--- /tags/3.1/wp-admin/menu-header.php	(revision 17487)
+++ /tags/3.1/wp-admin/menu-header.php	(revision 17487)
@@ -0,0 +1,174 @@
+<?php
+/**
+ * Displays Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * The current page.
+ *
+ * @global string $self
+ * @name $self
+ * @var string
+ */
+$self = preg_replace('|^.*/wp-admin/network/|i', '', $_SERVER['PHP_SELF']);
+$self = preg_replace('|^.*/wp-admin/|i', '', $self);
+$self = preg_replace('|^.*/plugins/|i', '', $self);
+$self = preg_replace('|^.*/mu-plugins/|i', '', $self);
+
+global $menu, $submenu, $parent_file; //For when admin-header is included from within a function.
+$parent_file = apply_filters("parent_file", $parent_file); // For plugins to move submenu tabs around.
+
+get_admin_page_parent();
+
+/**
+ * Display menu.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @param array $menu
+ * @param array $submenu
+ * @param bool $submenu_as_parent
+ */
+function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
+	global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow;
+
+	$first = true;
+	// 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src
+	foreach ( $menu as $key => $item ) {
+		$admin_is_parent = false;
+		$class = array();
+		if ( $first ) {
+			$class[] = 'wp-first-item';
+			$first = false;
+		}
+		if ( !empty($submenu[$item[2]]) )
+			$class[] = 'wp-has-submenu';
+
+		if ( ( $parent_file && $item[2] == $parent_file ) || ( empty($typenow) && $self == $item[2] ) ) {
+			if ( !empty($submenu[$item[2]]) )
+				$class[] = 'wp-has-current-submenu wp-menu-open';
+			else
+				$class[] = 'current';
+		}
+
+		if ( ! empty($item[4]) )
+			$class[] = $item[4];
+
+		$class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
+		$tabindex = ' tabindex="1"';
+		$id = ! empty($item[5]) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : '';
+		$img = '';
+		if ( ! empty($item[6]) ) {
+			if ( 'div' === $item[6] )
+				$img = '<br />';
+			else
+				$img = '<img src="' . $item[6] . '" alt="" />';
+		}
+		$toggle = '<div class="wp-menu-toggle"><br /></div>';
+
+		$title = wptexturize($item[0]);
+
+		echo "\n\t<li$class$id>";
+
+		if ( false !== strpos($class, 'wp-menu-separator') ) {
+			echo '<a class="separator" href="?unfoldmenu=1"><br /></a>';
+		} elseif ( $submenu_as_parent && !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]);
+			$menu_file = $submenu[$item[2]][0][2];
+			if ( false !== $pos = strpos($menu_file, '?') )
+				$menu_file = substr($menu_file, 0, $pos);
+			if ( ( ('index.php' != $submenu[$item[2]][0][2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") ) || !empty($menu_hook)) {
+				$admin_is_parent = true;
+				echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class$tabindex>$title</a>";
+			} else {
+				echo "\n\t<div class='wp-menu-image'><a href='{$submenu[$item[2]][0][2]}'>$img</a></div>$toggle<a href='{$submenu[$item[2]][0][2]}'$class$tabindex>$title</a>";
+			}
+		} else if ( current_user_can($item[1]) ) {
+			$menu_hook = get_plugin_page_hook($item[2], 'admin.php');
+			$menu_file = $item[2];
+			if ( false !== $pos = strpos($menu_file, '?') )
+				$menu_file = substr($menu_file, 0, $pos);
+			if ( ('index.php' != $item[2]) && file_exists(WP_PLUGIN_DIR . "/$menu_file") || !empty($menu_hook) ) {
+				$admin_is_parent = true;
+				echo "\n\t<div class='wp-menu-image'><a href='admin.php?page={$item[2]}'>$img</a></div>$toggle<a href='admin.php?page={$item[2]}'$class$tabindex>{$item[0]}</a>";
+			} else {
+				echo "\n\t<div class='wp-menu-image'><a href='{$item[2]}'>$img</a></div>$toggle<a href='{$item[2]}'$class$tabindex>{$item[0]}</a>";
+			}
+		}
+
+		if ( !empty($submenu[$item[2]]) ) {
+			echo "\n\t<div class='wp-submenu'><div class='wp-submenu-head'>{$item[0]}</div><ul>";
+			$first = true;
+			foreach ( $submenu[$item[2]] as $sub_key => $sub_item ) {
+				if ( !current_user_can($sub_item[1]) )
+					continue;
+
+				$class = array();
+				if ( $first ) {
+					$class[] = 'wp-first-item';
+					$first = false;
+				}
+
+				$menu_file = $item[2];
+
+				if ( false !== $pos = strpos($menu_file, '?') )
+					$menu_file = substr($menu_file, 0, $pos);
+
+				// Handle current for post_type=post|page|foo pages, which won't match $self.
+				if ( !empty($typenow) )
+					$self_type = $self . '?post_type=' . $typenow;
+				else
+					$self_type = 'nothing';
+
+				if ( isset($submenu_file) ) {
+					if ( $submenu_file == $sub_item[2] )
+						$class[] = 'current';
+				// If plugin_page is set the parent must either match the current page or not physically exist.
+				// This allows plugin pages with the same hook to exist under different parents.
+				} else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self) || ($item[2] == $self_type))) || (!isset($plugin_page) && $self == $sub_item[2]) ) {
+					$class[] = 'current';
+				}
+
+				$class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
+
+				$menu_hook = get_plugin_page_hook($sub_item[2], $item[2]);
+				$sub_file = $sub_item[2];
+				if ( false !== $pos = strpos($sub_file, '?') )
+					$sub_file = substr($sub_file, 0, $pos);
+
+				$title = wptexturize($sub_item[0]);
+
+				if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) {
+					// If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
+					if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) )
+						$sub_item_url = add_query_arg( array('page' => $sub_item[2]), $item[2] );
+					else
+						$sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' );
+					$sub_item_url = esc_url($sub_item_url);
+					echo "<li$class><a href='$sub_item_url'$class$tabindex>$title</a></li>";
+				} else {
+					echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>$title</a></li>";
+				}
+			}
+			echo "</ul></div>";
+		}
+		echo "</li>";
+	}
+}
+
+?>
+
+<ul id="adminmenu">
+
+<?php
+
+_wp_menu_output( $menu, $submenu );
+do_action( 'adminmenu' );
+
+?>
+</ul>
Index: /tags/3.1/wp-admin/menu.php
===================================================================
--- /tags/3.1/wp-admin/menu.php	(revision 17487)
+++ /tags/3.1/wp-admin/menu.php	(revision 17487)
@@ -0,0 +1,255 @@
+<?php
+/**
+ * Build Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * Constructs the admin menu bar.
+ *
+ * The elements in the array are :
+ *     0: Menu item name
+ *     1: Minimum level or capability required.
+ *     2: The URL of the item's file
+ *     3: Class
+ *     4: ID
+ *     5: Icon for top level menu
+ *
+ * @global array $menu
+ * @name $menu
+ * @var array
+ */
+
+$menu[2] = array( __('Dashboard'), 'read', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'div' );
+
+$submenu[ 'index.php' ][0] = array( __('Dashboard'), 'read', 'index.php' );
+
+if ( is_multisite() ) {
+	$submenu[ 'index.php' ][5] = array( __('My Sites'), 'read', 'my-sites.php' );
+}
+
+if ( ! is_multisite() || is_super_admin() ) {
+	$plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
+	$update_plugins = get_site_transient( 'update_plugins' );
+	if ( !empty($update_plugins->response) )
+		$plugin_update_count = count( $update_plugins->response );
+	$update_themes = get_site_transient( 'update_themes' );
+	if ( !empty($update_themes->response) )
+		$theme_update_count = count( $update_themes->response );
+	$update_wordpress = get_core_updates( array('dismissed' => false) );
+	if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
+		$wordpress_update_count = 1;
+
+	$total_update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
+	$update_title = array();
+	if ( $wordpress_update_count )
+		$update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);
+	if ( $plugin_update_count )
+		$update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);
+	if ( $theme_update_count )
+		$update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count);
+
+	$update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';
+}
+
+if ( ! is_multisite() ) {
+	$submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-$total_update_count' title='$update_title'><span class='update-count'>" . number_format_i18n($total_update_count) . "</span></span>" ), 'update_core',  'update-core.php');
+}
+
+unset($plugin_update_count, $theme_update_count, $wordpress_update_count, $update_themes, $update_plugins, $update_wordpress);
+
+$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
+
+$menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' );
+	$submenu['edit.php'][5]  = array( __('Posts'), 'edit_posts', 'edit.php' );
+	/* translators: add new post */
+	$submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' );
+
+	$i = 15;
+	foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
+		if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
+			continue;
+
+		$submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
+	}
+	unset($tax);
+
+$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' );
+	$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
+	/* translators: add new file */
+	$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
+
+$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );
+	$submenu['link-manager.php'][5] = array( __('Links'), 'manage_links', 'link-manager.php' );
+	/* translators: add new links */
+	$submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' );
+	$submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );
+
+$menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' );
+	$submenu['edit.php?post_type=page'][5] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page' );
+	/* translators: add new page */
+	$submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );
+	$i = 15;
+	foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
+		if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) )
+			continue;
+
+		$submenu['edit.php?post_type=page'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&amp;post_type=page' );
+	}
+	unset($tax);
+
+$awaiting_mod = wp_count_comments();
+$awaiting_mod = $awaiting_mod->moderated;
+$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top menu-icon-comments', 'menu-comments', 'div' );
+unset($awaiting_mod);
+
+$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
+
+foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) as $ptype ) {
+	$ptype_obj = get_post_type_object( $ptype );
+	// Check if it should be a submenu.
+	if ( $ptype_obj->show_in_menu !== true )
+		continue;
+	$ptype_menu_position = is_int( $ptype_obj->menu_position ) ? $ptype_obj->menu_position : ++$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first.
+	$ptype_for_id = sanitize_html_class( $ptype );
+	if ( is_string( $ptype_obj->menu_icon ) ) {
+		$menu_icon   = esc_url( $ptype_obj->menu_icon );
+		$ptype_class = $ptype_for_id;
+	} else {
+		$menu_icon   = 'div';
+		$ptype_class = 'post';
+	}
+
+	// if $ptype_menu_position is already populated or will be populated by a hard-coded value below, increment the position.
+	$core_menu_positions = array(59, 60, 65, 70, 75, 80, 85, 99);
+	while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) )
+		$ptype_menu_position++;
+
+	$menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon );
+	$submenu["edit.php?post_type=$ptype"][5]  = array( $ptype_obj->labels->menu_name, $ptype_obj->cap->edit_posts,  "edit.php?post_type=$ptype");
+	$submenu["edit.php?post_type=$ptype"][10]  = array( $ptype_obj->labels->add_new, $ptype_obj->cap->edit_posts, "post-new.php?post_type=$ptype" );
+
+	$i = 15;
+	foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
+		if ( ! $tax->show_ui || ! in_array($ptype, (array) $tax->object_type, true) )
+			continue;
+
+		$submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
+	}
+}
+unset($ptype, $ptype_obj, $ptype_class, $ptype_for_id, $ptype_menu_position, $menu_icon, $i, $tax);
+
+$menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' );
+
+if ( current_user_can( 'switch_themes') ) {
+	$menu[60] = array( __('Appearance'), 'switch_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
+		$submenu['themes.php'][5]  = array(__('Themes'), 'switch_themes', 'themes.php');
+		if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
+			$submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php');
+} else {
+	$menu[60] = array( __('Appearance'), 'edit_theme_options', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div' );
+		$submenu['themes.php'][5]  = array(__('Themes'), 'edit_theme_options', 'themes.php');
+		if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
+			$submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php' );
+}
+
+// Add 'Editor' to the bottom of the Appearence menu.
+if ( ! is_multisite() )
+	add_action('admin_menu', '_add_themes_utility_last', 101);
+function _add_themes_utility_last() {
+	// Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook
+	add_submenu_page('themes.php', _x('Editor', 'theme editor'), _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php');
+}
+
+$update_plugins = get_site_transient( 'update_plugins' );
+$update_count = 0;
+if ( !empty($update_plugins->response) )
+	$update_count = count( $update_plugins->response );
+
+$menu_perms = get_site_option('menu_items', array());
+if ( ! is_multisite() || is_super_admin() || ! empty( $menu_perms['plugins'] ) ) {
+	$count = "<span class='update-plugins count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>";
+	if ( is_multisite() )
+		$count = '';
+	$menu[65] = array( sprintf( __('Plugins %s'), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div' );
+		if ( ! is_multisite() ) {
+			/* translators: add new plugin */
+			$submenu['plugins.php'][5]  = array( __('Plugins'), 'activate_plugins', 'plugins.php' );
+			$submenu['plugins.php'][10] = array( _x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php' );
+			$submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' );
+		}
+}
+unset($menu_perms, $update_plugins, $update_count);
+
+if ( current_user_can('list_users') )
+	$menu[70] = array( __('Users'), 'list_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' );
+else
+	$menu[70] = array( __('Profile'), 'read', 'profile.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' );
+
+if ( current_user_can('list_users') ) {
+	$_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
+	$submenu['users.php'][5] = array(__('Users'), 'list_users', 'users.php');
+	if ( current_user_can('create_users') )
+		$submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php');
+	else
+		$submenu['users.php'][10] = array(_x('Add New', 'user'), 'promote_users', 'user-new.php');
+
+	$submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
+} else {
+	$_wp_real_parent_file['users.php'] = 'profile.php';
+	$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
+	if ( current_user_can('create_users') )
+		$submenu['profile.php'][10] = array(__('Add New User'), 'create_users', 'user-new.php');
+	else
+		$submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php');
+}
+
+$menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'div' );
+	$submenu['tools.php'][5] = array( __('Tools'), 'edit_posts', 'tools.php' );
+	$submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' );
+	$submenu['tools.php'][15] = array( __('Export'), 'import', 'export.php' );
+	if ( is_multisite() && !is_main_site() )
+		$submenu['tools.php'][25] = array( __('Delete Site'), 'manage_options', 'ms-delete-site.php' );
+	if ( ! is_multisite() && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE )
+		$submenu['tools.php'][50] = array(__('Network'), 'manage_options', 'network.php');
+
+$menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'div' );
+	$submenu['options-general.php'][10] = array(_x('General', 'settings screen'), 'manage_options', 'options-general.php');
+	$submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
+	$submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
+	$submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
+	$submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php');
+	$submenu['options-general.php'][35] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
+	$submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
+
+$_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group
+
+$menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator-last' );
+
+// Back-compat for old top-levels
+$_wp_real_parent_file['post.php'] = 'edit.php';
+$_wp_real_parent_file['post-new.php'] = 'edit.php';
+$_wp_real_parent_file['edit-pages.php'] = 'edit.php?post_type=page';
+$_wp_real_parent_file['page-new.php'] = 'edit.php?post_type=page';
+$_wp_real_parent_file['wpmu-admin.php'] = 'tools.php';
+$_wp_real_parent_file['ms-admin.php'] = 'tools.php';
+
+// ensure we're backwards compatible
+$compat = array(
+	'index' => 'dashboard',
+	'edit' => 'posts',
+	'post' => 'posts',
+	'upload' => 'media',
+	'link-manager' => 'links',
+	'edit-pages' => 'pages',
+	'page' => 'pages',
+	'edit-comments' => 'comments',
+	'options-general' => 'settings',
+	'themes' => 'appearance',
+	);
+
+require_once(ABSPATH . 'wp-admin/includes/menu.php');
+
+?>
Index: /tags/3.1/wp-admin/moderation.php
===================================================================
--- /tags/3.1/wp-admin/moderation.php	(revision 17487)
+++ /tags/3.1/wp-admin/moderation.php	(revision 17487)
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Comment Moderation Administration Panel.
+ *
+ * Redirects to edit-comments.php?comment_status=moderated.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+require_once('../wp-load.php');
+wp_redirect( admin_url('edit-comments.php?comment_status=moderated') );
+exit;
+?>
Index: /tags/3.1/wp-admin/ms-admin.php
===================================================================
--- /tags/3.1/wp-admin/ms-admin.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-admin.php	(revision 17487)
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Multisite administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+wp_redirect( network_admin_url() );
+exit;
+?>
Index: /tags/3.1/wp-admin/ms-delete-site.php
===================================================================
--- /tags/3.1/wp-admin/ms-delete-site.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-delete-site.php	(revision 17487)
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Multisite delete site panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+if ( !is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+// @todo Create a delete blog cap.
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die(__( 'You do not have sufficient permissions to delete this site.'));
+
+if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' ) != false ) {
+	if ( get_option( 'delete_blog_hash' ) == $_GET['h'] ) {
+		wpmu_delete_blog( $wpdb->blogid );
+		wp_die( sprintf( __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ), $current_site->site_name ) );
+	} else {
+		wp_die( __( "I'm sorry, the link you clicked is stale. Please select another option." ) );
+	}
+}
+
+$title = __( 'Delete Site' );
+$parent_file = 'tools.php';
+require_once( './admin-header.php' );
+
+echo '<div class="wrap">';
+screen_icon();
+echo '<h2>' . esc_html( $title ) . '</h2>';
+
+if ( isset( $_POST['action'] ) && $_POST['action'] == 'deleteblog' && isset( $_POST['confirmdelete'] ) && $_POST['confirmdelete'] == '1' ) {
+	$hash = wp_generate_password( 20, false );
+	update_option( 'delete_blog_hash', $hash );
+
+	$url_delete = esc_url( admin_url( 'ms-delete-site.php?h=' . $hash ) );
+
+	$content = apply_filters( 'delete_site_email_content', __( "Dear User,
+You recently clicked the 'Delete Site' link on your site and filled in a
+form on that page.
+If you really want to delete your site, click the link below. You will not
+be asked to confirm again so only click this link if you are absolutely certain:
+###URL_DELETE###
+
+If you delete your site, please consider opening a new site here
+some time in the future! (But remember your current site and username
+are gone forever.)
+
+Thanks for using the site,
+Webmaster
+###SITE_NAME###" ) );
+
+	$content = str_replace( '###URL_DELETE###', $url_delete, $content );
+	$content = str_replace( '###SITE_NAME###', $current_site->site_name, $content );
+
+	wp_mail( get_option( 'admin_email' ), "[ " . get_option( 'blogname' ) . " ] ".__( 'Delete My Site' ), $content );
+	?>
+
+	<p><?php _e( 'Thank you. Please check your email for a link to confirm your action. Your site will not be deleted until this link is clicked. ') ?></p>
+
+<?php } else {
+	?>
+	<p><?php printf( __( 'If you do not want to use your %s site any more, you can delete it using the form below. When you click <strong>Delete My Site Permanently</strong> you will be sent an email with a link in it. Click on this link to delete your site.'), $current_site->site_name); ?></p>
+	<p><?php _e( 'Remember, once deleted your site cannot be restored.' ) ?></p>
+
+	<form method="post" name="deletedirect">
+		<input type="hidden" name="action" value="deleteblog" />
+		<p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $current_blog->domain : $current_blog->domain . $current_blog->path ); ?></strong></label></p>
+		<?php submit_button( __( 'Delete My Site Permanently' ) ); ?>
+	</form>
+	<?php
+}
+echo '</div>';
+
+include( './admin-footer.php' );
+?>
Index: /tags/3.1/wp-admin/ms-edit.php
===================================================================
--- /tags/3.1/wp-admin/ms-edit.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-edit.php	(revision 17487)
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Action handler for Multisite administration panels.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+wp_redirect( network_admin_url() );
+exit;
+?>
Index: /tags/3.1/wp-admin/ms-options.php
===================================================================
--- /tags/3.1/wp-admin/ms-options.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-options.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Multisite network settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+wp_redirect( network_admin_url('settings.php') );
Index: /tags/3.1/wp-admin/ms-sites.php
===================================================================
--- /tags/3.1/wp-admin/ms-sites.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-sites.php	(revision 17487)
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Multisite sites administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+wp_redirect( network_admin_url('sites.php') );
+exit;
+
+?>
Index: /tags/3.1/wp-admin/ms-themes.php
===================================================================
--- /tags/3.1/wp-admin/ms-themes.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-themes.php	(revision 17487)
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Multisite themes administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+wp_redirect( network_admin_url('themes.php') );
+exit;
+?>
Index: /tags/3.1/wp-admin/ms-upgrade-network.php
===================================================================
--- /tags/3.1/wp-admin/ms-upgrade-network.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-upgrade-network.php	(revision 17487)
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Multisite upgrade administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once('admin.php');
+
+wp_redirect( network_admin_url('upgrade.php') );
+exit;
+
+?>
Index: /tags/3.1/wp-admin/ms-users.php
===================================================================
--- /tags/3.1/wp-admin/ms-users.php	(revision 17487)
+++ /tags/3.1/wp-admin/ms-users.php	(revision 17487)
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Multisite users administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+wp_redirect( network_admin_url('users.php') );
+exit;
+?>
Index: /tags/3.1/wp-admin/my-sites.php
===================================================================
--- /tags/3.1/wp-admin/my-sites.php	(revision 17487)
+++ /tags/3.1/wp-admin/my-sites.php	(revision 17487)
@@ -0,0 +1,110 @@
+<?php
+/**
+ * My Sites dashboard.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+require_once( './admin.php' );
+
+if ( !is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can('read') )
+	wp_die( __( 'You do not have sufficient permissions to view this page.' ) );
+
+$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
+
+$blogs = get_blogs_of_user( $current_user->id );
+
+if ( empty( $blogs ) )
+	wp_die( __( 'You must be a member of at least one site to use this page.' ) );
+
+$updated = false;
+if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
+	check_admin_referer( 'update-my-sites' );
+
+	$blog = get_blog_details( (int) $_POST['primary_blog'] );
+	if ( $blog && isset( $blog->domain ) ) {
+		update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true );
+		$updated = true;
+	} else {
+		wp_die( __( 'The primary site you chose does not exist.' ) );
+	}
+}
+
+$title = __( 'My Sites' );
+$parent_file = 'index.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. He or she can use the links under each site to visit either the frontend or the dashboard for that site.') . '</p>' .
+	'<p>' . __('Up until WordPress version 3.0, what is now called a Multi-site Network had to be installed separately as WordPress MU (multi-user).') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Dashboard_My_Sites_SubPanel" target="_blank">Documentation on My Sites</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+require_once( './admin-header.php' );
+
+if ( $updated ) { ?>
+	<div id="message" class="updated"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
+<?php } ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+<form id="myblogs" action="" method="post">
+	<?php
+	choose_primary_blog();
+	do_action( 'myblogs_allblogs_options' );
+	?>
+	<br clear="all" />
+	<table class="widefat fixed">
+	<?php
+	$settings_html = apply_filters( 'myblogs_options', '', 'global' );
+	if ( $settings_html != '' ) {
+		echo '<tr><td valign="top"><h3>' . __( 'Global Settings' ) . '</h3></td><td>';
+		echo $settings_html;
+		echo '</td></tr>';
+	}
+	reset( $blogs );
+	$num = count( $blogs );
+	$cols = 1;
+	if ( $num >= 20 )
+		$cols = 4;
+	elseif ( $num >= 10 )
+		$cols = 2;
+	$num_rows = ceil( $num / $cols );
+	$split = 0;
+	for ( $i = 1; $i <= $num_rows; $i++ ) {
+		$rows[] = array_slice( $blogs, $split, $cols );
+		$split = $split + $cols;
+	}
+
+	$c = '';
+	foreach ( $rows as $row ) {
+		$c = $c == 'alternate' ? '' : 'alternate';
+		echo "<tr class='$c'>";
+		$i = 0;
+		foreach ( $row as $user_blog ) {
+			$s = $i == 3 ? '' : 'border-right: 1px solid #ccc;';
+			echo "<td valign='top' style='$s'>";
+			echo "<h3>{$user_blog->blogname}</h3>";
+			echo "<p>" . apply_filters( 'myblogs_blog_actions', "<a href='" . esc_url( get_home_url( $user_blog->userblog_id ) ). "'>" . __( 'Visit' ) . "</a> | <a href='" . esc_url( get_admin_url( $user_blog->userblog_id ) ) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
+			echo apply_filters( 'myblogs_options', '', $user_blog );
+			echo "</td>";
+			$i++;
+		}
+		echo "</tr>";
+	}?>
+	</table>
+	<input type="hidden" name="action" value="updateblogsettings" />
+	<?php wp_nonce_field( 'update-my-sites' ); ?>
+	<?php submit_button(); ?>
+	</form>
+	</div>
+<?php
+include( './admin-footer.php' );
+?>
Index: /tags/3.1/wp-admin/nav-menus.php
===================================================================
--- /tags/3.1/wp-admin/nav-menus.php	(revision 17487)
+++ /tags/3.1/wp-admin/nav-menus.php	(revision 17487)
@@ -0,0 +1,608 @@
+<?php
+/**
+ * WordPress Administration for Navigation Menus
+ * Interface functions
+ *
+ * @version 2.0.0
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+// Load all the nav menu interface functions
+require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
+
+if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' ) )
+	wp_die( __( 'Your theme does not support navigation menus or widgets.' ) );
+
+// Permissions Check
+if ( ! current_user_can('edit_theme_options') )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+// Nav Menu CSS
+wp_admin_css( 'nav-menu' );
+
+// jQuery
+wp_enqueue_script( 'jquery' );
+wp_enqueue_script( 'jquery-ui-draggable' );
+wp_enqueue_script( 'jquery-ui-droppable' );
+wp_enqueue_script( 'jquery-ui-sortable' );
+
+// Nav Menu functions
+wp_enqueue_script( 'nav-menu' );
+
+// Metaboxes
+wp_enqueue_script( 'common' );
+wp_enqueue_script( 'wp-lists' );
+wp_enqueue_script( 'postbox' );
+
+// Container for any messages displayed to the user
+$messages = array();
+
+// Container that stores the name of the active menu
+$nav_menu_selected_title = '';
+
+// The menu id of the current menu being edited
+$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
+
+// Allowed actions: add, update, delete
+$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit';
+
+switch ( $action ) {
+	case 'add-menu-item':
+		check_admin_referer( 'add-menu_item', 'menu-settings-column-nonce' );
+		if ( isset( $_REQUEST['nav-menu-locations'] ) )
+			set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_REQUEST['menu-locations'] ) );
+		elseif ( isset( $_REQUEST['menu-item'] ) )
+			wp_save_nav_menu_items( $nav_menu_selected_id, $_REQUEST['menu-item'] );
+		break;
+	case 'move-down-menu-item' :
+		// moving down a menu item is the same as moving up the next in order
+		check_admin_referer( 'move-menu_item' );
+		$menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0;
+		if ( is_nav_menu_item( $menu_item_id ) ) {
+			$menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) );
+			if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) {
+				$menu_id = (int) $menus[0];
+				$ordered_menu_items = wp_get_nav_menu_items( $menu_id );
+				$menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
+
+				// set up the data we need in one pass through the array of menu items
+				$dbids_to_orders = array();
+				$orders_to_dbids = array();
+				foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) {
+					if ( isset( $ordered_menu_item_object->ID ) ) {
+						if ( isset( $ordered_menu_item_object->menu_order ) ) {
+							$dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order;
+							$orders_to_dbids[$ordered_menu_item_object->menu_order] = $ordered_menu_item_object->ID;
+						}
+					}
+				}
+
+				// get next in order
+				if (
+					isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1] )
+				) {
+					$next_item_id = $orders_to_dbids[$dbids_to_orders[$menu_item_id] + 1];
+					$next_item_data = (array) wp_setup_nav_menu_item( get_post( $next_item_id ) );
+
+					// if not siblings of same parent, bubble menu item up but keep order
+					if (
+						! empty( $menu_item_data['menu_item_parent'] ) &&
+						(
+							empty( $next_item_data['menu_item_parent'] ) ||
+							$next_item_data['menu_item_parent'] != $menu_item_data['menu_item_parent']
+						)
+					) {
+
+						$parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0;
+
+						$parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) );
+
+						if ( ! is_wp_error( $parent_object ) ) {
+							$parent_data = (array) $parent_object;
+							$menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
+							update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
+
+						}
+
+					// make menu item a child of its next sibling
+					} else {
+						$next_item_data['menu_order'] = $next_item_data['menu_order'] - 1;
+						$menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1;
+
+						$menu_item_data['menu_item_parent'] = $next_item_data['ID'];
+						update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
+
+						wp_update_post($menu_item_data);
+						wp_update_post($next_item_data);
+					}
+
+
+				// the item is last but still has a parent, so bubble up
+				} elseif (
+					! empty( $menu_item_data['menu_item_parent'] ) &&
+					in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids )
+				) {
+					$menu_item_data['menu_item_parent'] = (int) get_post_meta( $menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true);
+					update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
+				}
+			}
+		}
+
+		break;
+	case 'move-up-menu-item' :
+		check_admin_referer( 'move-menu_item' );
+		$menu_item_id = isset( $_REQUEST['menu-item'] ) ? (int) $_REQUEST['menu-item'] : 0;
+		if ( is_nav_menu_item( $menu_item_id ) ) {
+			$menus = isset( $_REQUEST['menu'] ) ? array( (int) $_REQUEST['menu'] ) : wp_get_object_terms( $menu_item_id, 'nav_menu', array( 'fields' => 'ids' ) );
+			if ( ! is_wp_error( $menus ) && ! empty( $menus[0] ) ) {
+				$menu_id = (int) $menus[0];
+				$ordered_menu_items = wp_get_nav_menu_items( $menu_id );
+				$menu_item_data = (array) wp_setup_nav_menu_item( get_post( $menu_item_id ) );
+
+				// set up the data we need in one pass through the array of menu items
+				$dbids_to_orders = array();
+				$orders_to_dbids = array();
+				foreach( (array) $ordered_menu_items as $ordered_menu_item_object ) {
+					if ( isset( $ordered_menu_item_object->ID ) ) {
+						if ( isset( $ordered_menu_item_object->menu_order ) ) {
+							$dbids_to_orders[$ordered_menu_item_object->ID] = $ordered_menu_item_object->menu_order;
+							$orders_to_dbids[$ordered_menu_item_object->menu_order] = $ordered_menu_item_object->ID;
+						}
+					}
+				}
+
+
+				// if this menu item is not first
+				if ( ! empty( $dbids_to_orders[$menu_item_id] ) && ! empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ) {
+
+					// if this menu item is a child of the previous
+					if (
+						! empty( $menu_item_data['menu_item_parent'] ) &&
+						in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) &&
+						isset( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) &&
+						( $menu_item_data['menu_item_parent'] == $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] )
+					) {
+						$parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0;
+						$parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) );
+
+						if ( ! is_wp_error( $parent_object ) ) {
+							$parent_data = (array) $parent_object;
+
+							// if there is something before the parent and parent a child of it, make menu item a child also of it
+							if (
+								! empty( $dbids_to_orders[$parent_db_id] ) &&
+								! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] ) &&
+								! empty( $parent_data['menu_item_parent'] )
+							) {
+								$menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
+
+							// else if there is something before parent and parent not a child of it, make menu item a child of that something's parent
+							} elseif (
+								! empty( $dbids_to_orders[$parent_db_id] ) &&
+								! empty( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1] )
+							) {
+								$_possible_parent_id = (int) get_post_meta( $orders_to_dbids[$dbids_to_orders[$parent_db_id] - 1], '_menu_item_menu_item_parent', true);
+								if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ) ) )
+									$menu_item_data['menu_item_parent'] = $_possible_parent_id;
+								else
+									$menu_item_data['menu_item_parent'] = 0;
+
+							// else there isn't something before the parent
+							} else {
+								$menu_item_data['menu_item_parent'] = 0;
+							}
+
+							// set former parent's [menu_order] to that of menu-item's
+							$parent_data['menu_order'] = $parent_data['menu_order'] + 1;
+
+							// set menu-item's [menu_order] to that of former parent
+							$menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1;
+
+							// save changes
+							update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
+							wp_update_post($menu_item_data);
+							wp_update_post($parent_data);
+						}
+
+					// else this menu item is not a child of the previous
+					} elseif (
+						empty( $menu_item_data['menu_order'] ) ||
+						empty( $menu_item_data['menu_item_parent'] ) ||
+						! in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) ||
+						empty( $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] ) ||
+						$orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1] != $menu_item_data['menu_item_parent']
+					) {
+						// just make it a child of the previous; keep the order
+						$menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1];
+						update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
+						wp_update_post($menu_item_data);
+					}
+				}
+			}
+		}
+		break;
+
+	case 'delete-menu-item':
+		$menu_item_id = (int) $_REQUEST['menu-item'];
+
+		check_admin_referer( 'delete-menu_item_' . $menu_item_id );
+
+
+		if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) )
+			$messages[] = '<div id="message" class="updated"><p>' . __('The menu item has been successfully deleted.') . '</p></div>';
+		break;
+	case 'delete':
+		check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );
+
+		if ( is_nav_menu( $nav_menu_selected_id ) ) {
+			$deleted_nav_menu = wp_get_nav_menu_object( $nav_menu_selected_id );
+			$delete_nav_menu = wp_delete_nav_menu( $nav_menu_selected_id );
+
+			if ( is_wp_error($delete_nav_menu) ) {
+				$messages[] = '<div id="message" class="error"><p>' . $delete_nav_menu->get_error_message() . '</p></div>';
+			} else {
+				// Remove this menu from any locations.
+				$locations = get_theme_mod( 'nav_menu_locations' );
+				foreach ( (array) $locations as $location => $menu_id ) {
+					if ( $menu_id == $nav_menu_selected_id )
+						$locations[ $location ] = 0;
+				}
+				set_theme_mod( 'nav_menu_locations', $locations );
+				$messages[] = '<div id="message" class="updated"><p>' . __('The menu has been successfully deleted.') . '</p></div>';
+				// Select the next available menu
+				$nav_menu_selected_id = 0;
+				$_nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
+				foreach( $_nav_menus as $index => $_nav_menu ) {
+					if ( strcmp( $_nav_menu->name, $deleted_nav_menu->name ) >= 0
+					 || $index == count( $_nav_menus ) - 1 ) {
+						$nav_menu_selected_id = $_nav_menu->term_id;
+						break;
+					}
+				}
+			}
+			unset( $delete_nav_menu, $deleted_nav_menu, $_nav_menus );
+		} else {
+			// Reset the selected menu
+			$nav_menu_selected_id = 0;
+			unset( $_REQUEST['menu'] );
+		}
+		break;
+
+	case 'update':
+		check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
+
+		// Update menu theme locations
+		if ( isset( $_POST['menu-locations'] ) )
+			set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
+
+		// Add Menu
+		if ( 0 == $nav_menu_selected_id ) {
+			$new_menu_title = trim( esc_html( $_POST['menu-name'] ) );
+
+			if ( $new_menu_title ) {
+				$_nav_menu_selected_id = wp_update_nav_menu_object( 0, array('menu-name' => $new_menu_title) );
+
+				if ( is_wp_error( $_nav_menu_selected_id ) ) {
+					$messages[] = '<div id="message" class="error"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
+				} else {
+					$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
+					$nav_menu_selected_id = $_nav_menu_selected_id;
+					$nav_menu_selected_title = $_menu_object->name;
+					$messages[] = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been successfully created.'), $nav_menu_selected_title ) . '</p></div>';
+				}
+			} else {
+				$messages[] = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';
+			}
+
+		// update existing menu
+		} else {
+
+			$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
+
+			$menu_title = trim( esc_html( $_POST['menu-name'] ) );
+			if ( ! $menu_title ) {
+				$messages[] = '<div id="message" class="error"><p>' . __('Please enter a valid menu name.') . '</p></div>';
+				$menu_title = $_menu_object->name;
+			}
+
+			if ( ! is_wp_error( $_menu_object ) ) {
+				$_nav_menu_selected_id = wp_update_nav_menu_object( $nav_menu_selected_id, array( 'menu-name' => $menu_title ) );
+				if ( is_wp_error( $_nav_menu_selected_id ) ) {
+					$_menu_object = $_nav_menu_selected_id;
+					$messages[] = '<div id="message" class="error"><p>' . $_nav_menu_selected_id->get_error_message() . '</p></div>';
+				} else {
+					$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
+					$nav_menu_selected_title = $_menu_object->name;
+				}
+			}
+
+			// Update menu items
+
+			if ( ! is_wp_error( $_menu_object ) ) {
+				$unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish') );
+				$menu_items = array();
+				// Index menu items by db ID
+				foreach( $unsorted_menu_items as $_item )
+					$menu_items[$_item->db_id] = $_item;
+
+				$post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' );
+				wp_defer_term_counting(true);
+				// Loop through all the menu items' POST variables
+				if ( ! empty( $_POST['menu-item-db-id'] ) ) {
+					foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
+
+						// Menu item title can't be blank
+						if ( empty( $_POST['menu-item-title'][$_key] ) )
+							continue;
+
+						$args = array();
+						foreach ( $post_fields as $field )
+							$args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : '';
+
+						$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args );
+
+						if ( is_wp_error( $menu_item_db_id ) )
+							$messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
+						elseif ( isset( $menu_items[$menu_item_db_id] ) )
+							unset( $menu_items[$menu_item_db_id] );
+					}
+				}
+
+				// Remove menu items from the menu that weren't in $_POST
+				if ( ! empty( $menu_items ) ) {
+					foreach ( array_keys( $menu_items ) as $menu_item_id ) {
+						if ( is_nav_menu_item( $menu_item_id ) ) {
+							wp_delete_post( $menu_item_id );
+						}
+					}
+				}
+
+				// Store 'auto-add' pages.
+				$auto_add = ! empty( $_POST['auto-add-pages'] );
+				$nav_menu_option = (array) get_option( 'nav_menu_options' );
+				if ( ! isset( $nav_menu_option['auto_add'] ) )
+					$nav_menu_option['auto_add'] = array();
+				if ( $auto_add ) {
+					if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
+						$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
+				} else {
+					if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
+						unset( $nav_menu_option['auto_add'][$key] );
+				}
+				// Remove nonexistent/deleted menus
+				$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
+				update_option( 'nav_menu_options', $nav_menu_option );
+
+				wp_defer_term_counting(false);
+
+				do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
+
+				$messages[] = '<div id="message" class="updated"><p>' . sprintf( __('The <strong>%s</strong> menu has been updated.'), $nav_menu_selected_title ) . '</p></div>';
+				unset( $menu_items, $unsorted_menu_items );
+			}
+		}
+		break;
+}
+
+// Get all nav menus
+$nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
+
+// Get recently edited nav menu
+$recently_edited = (int) get_user_option( 'nav_menu_recently_edited' );
+
+// If there was no recently edited menu, and $nav_menu_selected_id is a nav menu, update recently edited menu.
+if ( !$recently_edited && is_nav_menu( $nav_menu_selected_id ) ) {
+	$recently_edited = $nav_menu_selected_id;
+
+// Else if $nav_menu_selected_id is not a menu and not requesting that we create a new menu, but $recently_edited is a menu, grab that one.
+} elseif ( 0 == $nav_menu_selected_id && ! isset( $_REQUEST['menu'] ) && is_nav_menu( $recently_edited ) ) {
+	$nav_menu_selected_id = $recently_edited;
+
+// Else try to grab the first menu from the menus list
+} elseif ( 0 == $nav_menu_selected_id && ! isset( $_REQUEST['menu'] ) && ! empty($nav_menus) ) {
+	$nav_menu_selected_id = $nav_menus[0]->term_id;
+}
+
+// Update the user's setting
+if ( $nav_menu_selected_id != $recently_edited && is_nav_menu( $nav_menu_selected_id ) )
+	update_user_meta( $current_user->ID, 'nav_menu_recently_edited', $nav_menu_selected_id );
+
+// If there's a menu, get its name.
+if ( ! $nav_menu_selected_title && is_nav_menu( $nav_menu_selected_id ) ) {
+	$_menu_object = wp_get_nav_menu_object( $nav_menu_selected_id );
+	$nav_menu_selected_title = ! is_wp_error( $_menu_object ) ? $_menu_object->name : '';
+}
+
+// Generate truncated menu names
+foreach( (array) $nav_menus as $key => $_nav_menu ) {
+	$_nav_menu->truncated_name = trim( wp_html_excerpt( $_nav_menu->name, 40 ) );
+	if ( $_nav_menu->truncated_name != $_nav_menu->name )
+		$_nav_menu->truncated_name .= '&hellip;';
+
+	$nav_menus[$key]->truncated_name = $_nav_menu->truncated_name;
+}
+
+// Ensure the user will be able to scroll horizontally
+// by adding a class for the max menu depth.
+global $_wp_nav_menu_max_depth;
+$_wp_nav_menu_max_depth = 0;
+
+// Calling wp_get_nav_menu_to_edit generates $_wp_nav_menu_max_depth
+if ( is_nav_menu( $nav_menu_selected_id ) )
+	$edit_markup = wp_get_nav_menu_to_edit( $nav_menu_selected_id  );
+
+function wp_nav_menu_max_depth() {
+	global $_wp_nav_menu_max_depth;
+	return "menu-max-depth-$_wp_nav_menu_max_depth";
+}
+
+add_action('admin_body_class','wp_nav_menu_max_depth');
+
+wp_nav_menu_setup();
+wp_initial_nav_menu_meta_boxes();
+
+if ( ! current_theme_supports( 'menus' ) && ! wp_get_nav_menus() )
+	$messages[] = '<div id="message" class="updated"><p>' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p></div>';
+
+$help =  '<p>' . __('This feature, introduced in version 3.0, allows you to use a custom menu in place of your theme&#8217;s default menus. If your theme does not support the custom menus feature yet (the default theme, Twenty Ten, does), you can learn about adding this support by following the Documentation link in this tab. You can still use the &#8220;Custom Menu&#8221; widget to add menus to a sidebar.') . '</p>';
+$help .= '<p>' . __('You can create custom menus for your site. These menus may contain links to pages, categories, custom links or other content types (use the Screen Options tab to decide which ones to show on the screen). You can specify a different navigation label for a menu item as well as other attributes. You can create multiple menus. If your theme includes more than one menu, you can choose which custom menu to associate with each. You can also use custom menus in conjunction with the Custom Menus widget.') . '</p>';
+$help .= '<p>' . __('To create a new custom menu, click on the + tab, give the menu a name, and click Create Menu. Next, add menu items from the appropriate boxes. You&#8217;ll be able to edit the information for each menu item, and can drag and drop to put them in order. You can also drag a menu item a little to the right to make it a submenu, to create menus with hierarchy. Drop the item into its new nested placement when the dotted rectangle target shifts over, also a little to the right. Don&#8217;t forget to click Save when you&#8217;re finished.') . '</p>';
+$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Menus_SubPanel" target="_blank">Documentation on Menus</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
+
+add_contextual_help($current_screen, $help);
+
+// Get the admin header
+require_once( './admin-header.php' );
+?>
+<div class="wrap">
+	<?php screen_icon(); ?>
+	<h2><?php esc_html_e('Menus'); ?></h2>
+	<?php
+	foreach( $messages as $message ) :
+		echo $message . "\n";
+	endforeach;
+	?>
+	<div id="nav-menus-frame">
+	<div id="menu-settings-column" class="metabox-holder<?php if ( !$nav_menu_selected_id ) { echo ' metabox-holder-disabled'; } ?>">
+
+		<form id="nav-menu-meta" action="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-menu-meta" method="post" enctype="multipart/form-data">
+			<input type="hidden" name="menu" id="nav-menu-meta-object-id" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
+			<input type="hidden" name="action" value="add-menu-item" />
+			<?php wp_nonce_field( 'add-menu_item', 'menu-settings-column-nonce' ); ?>
+			<?php do_meta_boxes( 'nav-menus', 'side', null ); ?>
+		</form>
+
+	</div><!-- /#menu-settings-column -->
+	<div id="menu-management-liquid">
+		<div id="menu-management">
+			<div id="select-nav-menu-container" class="hide-if-js">
+				<form id="select-nav-menu" action="">
+					<strong><label for="select-nav-menu"><?php esc_html_e( 'Select Menu:' ); ?></label></strong>
+					<select class="select-nav-menu" name="menu">
+						<?php foreach( (array) $nav_menus as $_nav_menu ) : ?>
+							<option value="<?php echo esc_attr($_nav_menu->term_id) ?>" <?php selected($nav_menu_selected_id, $_nav_menu->term_id); ?>>
+								<?php echo esc_html( $_nav_menu->truncated_name ); ?>
+							</option>
+						<?php endforeach; ?>
+						<option value="0"><?php esc_html_e('Add New Menu'); ?></option>
+					</select>
+					<input type="hidden" name="action" value="edit" />
+					<?php submit_button( __( 'Select' ), 'secondary', 'select_menu', false ); ?>
+				</form>
+			</div>
+			<div class="nav-tabs-wrapper">
+			<div class="nav-tabs">
+				<?php
+				foreach( (array) $nav_menus as $_nav_menu ) :
+					if ( $nav_menu_selected_id == $_nav_menu->term_id ) : ?><span class="nav-tab nav-tab-active">
+							<?php echo esc_html( $_nav_menu->truncated_name ); ?>
+						</span><?php else : ?><a href="<?php
+							echo esc_url(add_query_arg(
+								array(
+									'action' => 'edit',
+									'menu' => $_nav_menu->term_id,
+								),
+								admin_url( 'nav-menus.php' )
+							));
+						?>" class="nav-tab hide-if-no-js">
+							<?php echo esc_html( $_nav_menu->truncated_name ); ?>
+						</a><?php endif;
+				endforeach;
+				if ( 0 == $nav_menu_selected_id ) : ?><span class="nav-tab menu-add-new nav-tab-active">
+					<?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>
+				</span><?php else : ?><a href="<?php
+					echo esc_url(add_query_arg(
+						array(
+							'action' => 'edit',
+							'menu' => 0,
+						),
+						admin_url( 'nav-menus.php' )
+					));
+				?>" class="nav-tab menu-add-new">
+					<?php printf( '<abbr title="%s">+</abbr>', esc_html__( 'Add menu' ) ); ?>
+				</a><?php endif; ?>
+			</div>
+			</div>
+			<div class="menu-edit">
+				<form id="update-nav-menu" action="<?php echo admin_url( 'nav-menus.php' ); ?>" method="post" enctype="multipart/form-data">
+					<div id="nav-menu-header">
+						<div id="submitpost" class="submitbox">
+							<div class="major-publishing-actions">
+								<label class="menu-name-label howto open-label" for="menu-name">
+									<span><?php _e('Menu Name'); ?></span>
+									<input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Enter menu name here'); ?>" value="<?php echo esc_attr( $nav_menu_selected_title  ); ?>" />
+								</label>
+								<?php if ( !empty( $nav_menu_selected_id ) ) :
+									if ( ! isset( $auto_add ) ) {
+										$auto_add = get_option( 'nav_menu_options' );
+										if ( ! isset( $auto_add['auto_add'] ) )
+											$auto_add = false;
+										elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) )
+											$auto_add = true;
+										else
+											$auto_add = false;
+									}
+								?>
+								<div class="auto-add-pages">
+									<label class="howto"><input type="checkbox"<?php checked( $auto_add ); ?> name="auto-add-pages" value="1" /> <?php printf( __('Automatically add new top-level pages' ), esc_url( admin_url( 'edit.php?post_type=page' ) ) ); ?></label>
+								</div>
+								<?php endif; ?>
+								<br class="clear" />
+								<div class="publishing-action">
+									<?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false ); ?>
+								</div><!-- END .publishing-action -->
+
+								<?php if ( ! empty( $nav_menu_selected_id ) ) : ?>
+								<div class="delete-action">
+									<a class="submitdelete deletion menu-delete" href="<?php echo esc_url( wp_nonce_url( admin_url('nav-menus.php?action=delete&amp;menu=' . $nav_menu_selected_id), 'delete-nav_menu-' . $nav_menu_selected_id ) ); ?>"><?php _e('Delete Menu'); ?></a>
+								</div><!-- END .delete-action -->
+								<?php endif; ?>
+							</div><!-- END .major-publishing-actions -->
+						</div><!-- END #submitpost .submitbox -->
+						<?php
+						wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
+						wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
+						wp_nonce_field( 'update-nav_menu', 'update-nav-menu-nonce' );
+						?>
+						<input type="hidden" name="action" value="update" />
+						<input type="hidden" name="menu" id="menu" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />
+					</div><!-- END #nav-menu-header -->
+					<div id="post-body">
+						<div id="post-body-content">
+							<?php
+							if ( isset( $edit_markup ) ) {
+								if ( ! is_wp_error( $edit_markup ) )
+									echo $edit_markup;
+							} else if ( empty( $nav_menu_selected_id ) ) {
+								echo '<div class="post-body-plain">';
+								echo '<p>' . __('To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu.') . '</p>';
+								echo '<p>' . __('After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options.') . '</p>';
+								echo '<p>' . __('When you have finished building your custom menu, make sure you click the Save Menu button.') . '</p>';
+								echo '</div>';
+							}
+							?>
+						</div><!-- /#post-body-content -->
+					</div><!-- /#post-body -->
+					<div id="nav-menu-footer">
+						<div class="major-publishing-actions">
+						<div class="publishing-action">
+							<?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'button-primary menu-save', 'save_menu', false ); ?>
+						</div>
+						</div>
+					</div><!-- /#nav-menu-footer -->
+				</form><!-- /#update-nav-menu -->
+			</div><!-- /.menu-edit -->
+		</div><!-- /#menu-management -->
+	</div><!-- /#menu-management-liquid -->
+	</div><!-- /#nav-menus-frame -->
+</div><!-- /.wrap-->
+
+
+<?php include( './admin-footer.php' ); ?>
Index: /tags/3.1/wp-admin/network.php
===================================================================
--- /tags/3.1/wp-admin/network.php	(revision 17487)
+++ /tags/3.1/wp-admin/network.php	(revision 17487)
@@ -0,0 +1,548 @@
+<?php
+/**
+ * Network installation administration panel.
+ *
+ * A multi-step process allowing the user to enable a network of WordPress sites.
+ *
+ * @since 3.0.0
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+define( 'WP_NETWORK_ADMIN_PAGE', true );
+
+/** WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_super_admin() )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+if ( is_multisite() ) {
+	if ( ! is_network_admin() ) {
+		wp_redirect( network_admin_url( 'setup.php' ) );
+		exit;
+	}
+	if ( ! defined( 'MULTISITE' ) )
+		wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
+}
+
+// We need to create references to ms global tables to enable Network.
+foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table )
+	$wpdb->$table = $prefixed_table;
+
+/**
+ * Check for an existing network.
+ *
+ * @since 3.0.0
+ * @return Whether a network exists.
+ */
+function network_domain_check() {
+	global $wpdb;
+	if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
+		return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
+	return false;
+}
+
+/**
+ * Allow subdomain install
+ *
+ * @since 3.0.0
+ * @return bool Whether subdomain install is allowed
+ */
+function allow_subdomain_install() {
+	$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'siteurl' ) );
+	if( false !== strpos( $domain, '/' ) || 'localhost' == $domain || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $domain ) )
+		return false;
+
+	return true;
+}
+/**
+ * Allow subdirectory install
+ *
+ * @since 3.0.0
+ * @return bool Whether subdirectory install is allowed
+ */
+function allow_subdirectory_install() {
+	global $wpdb;
+	if ( apply_filters( 'allow_subdirectory_install', false ) )
+		return true;
+
+	if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL )
+		return true;
+
+	$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
+	if ( empty( $post ) )
+		return true;
+
+	return false;
+}
+/**
+ * Get base domain of network.
+ *
+ * @since 3.0.0
+ * @return string Base domain.
+ */
+function get_clean_basedomain() {
+	if ( $existing_domain = network_domain_check() )
+		return $existing_domain;
+	$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
+	if ( $slash = strpos( $domain, '/' ) )
+		$domain = substr( $domain, 0, $slash );
+	return $domain;
+}
+
+if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) )
+	wp_die( __( 'You must define the <code>WP_ALLOW_MULTISITE</code> constant as true in your wp-config.php file to allow creation of a Network.' ) );
+
+if ( is_network_admin() ) {
+	$title = __( 'Network Setup' );
+	$parent_file = 'settings.php';
+} else {
+	$title = __( 'Create a Network of WordPress Sites' );
+	$parent_file = 'tools.php';
+}
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen allows you to configure a network as having subdomains (<code>site1.example.com</code>) or subdirectories (<code>example.com/site1</code>). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' .
+	'<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' .
+	'<p>' . __('The next screen for Network will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' .
+	'<p>' . __('Add a <code>blogs.dir</code> directory under <code>/wp-content</code> and add the designated lines of code to wp-config.php (just before <code>/*...stop editing...*/</code>) and <code>.htaccess</code> (replacing the existing WordPress rules).') . '</p>' .
+	'<p>' . __('Refreshing your browser will take you to a screen with an archive of those added lines of code. A set of six links under Super Admin will appear at the top of the main left navigation menu. The multisite network is now enabled.') . '</p>' .
+	'<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with &#8220;/blog/&#8221; from the main site. This disabling will be addressed soon in a future version.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Create_A_Network" target="_blank">Documentation on Creating a Network</a>') . '</p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Tools_Network_SubPanel" target="_blank">Documentation on the Network Screen</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include( ABSPATH . 'wp-admin/admin-header.php' );
+?>
+<div class="wrap">
+<?php screen_icon('tools'); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<?php
+/**
+ * Prints step 1 for Network installation process.
+ *
+ * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
+ * 	should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
+ *
+ * @since 3.0.0
+ */
+function network_step1( $errors = false ) {
+	global $is_apache;
+
+	if ( get_option( 'siteurl' ) != get_option( 'home' ) ) {
+		echo '<div class="error"><p><strong>' . __('Error:') . '</strong> ' . sprintf( __( 'Your <strong>WordPress address</strong> must match your <strong>Site address</strong> before creating a Network. See <a href="%s">General Settings</a>.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '</p></div>';
+		echo '</div>';
+		include ( ABSPATH . 'wp-admin/admin-footer.php' );
+		die();
+	}
+
+	if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
+		echo '<div class="error"><p><strong>' . __('Error:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>';
+		echo '</div>';
+		include ( ABSPATH . 'wp-admin/admin-footer.php' );
+		die();
+	}
+
+	$active_plugins = get_option( 'active_plugins' );
+	if ( ! empty( $active_plugins ) ) {
+		echo '<div class="updated"><p><strong>' . __('Warning:') . '</strong> ' . sprintf( __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '</p></div><p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
+		echo '</div>';
+		include( ABSPATH . 'wp-admin/admin-footer.php' );
+		die();
+	}
+
+	$hostname = get_clean_basedomain();
+	$has_ports = strstr( $hostname, ':' );
+	if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
+		echo '<div class="error"><p><strong>' . __( 'Error:') . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
+		echo '<p>' . sprintf( __( 'You cannot use port numbers such as <code>%s</code>.' ), $has_ports ) . '</p>';
+		echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Return to Dashboard' ) . '</a>';
+		echo '</div>';
+		include( ABSPATH . 'wp-admin/admin-footer.php' );
+		die();
+	}
+
+	echo '<form method="post" action="">';
+
+	wp_nonce_field( 'install-network-1' );
+
+	$error_codes = array();
+	if ( is_wp_error( $errors ) ) {
+		echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
+		foreach ( $errors->get_error_messages() as $error )
+			echo "<p>$error</p>";
+		echo '</div>';
+		$error_codes = $errors->get_error_codes();
+	}
+
+	if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
+		echo '<div class="error"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
+
+	$site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
+	$admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
+	?>
+	<p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
+	<p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
+	<?php
+
+	if ( isset( $_POST['subdomain_install'] ) ) {
+		$subdomain_install = (bool) $_POST['subdomain_install'];
+	} elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
+		$subdomain_install = true;
+	} elseif ( !allow_subdirectory_install() ) {
+		$subdomain_install = true;
+	} else {
+		$subdomain_install = false;
+		if ( $got_mod_rewrite = got_mod_rewrite() ) // dangerous assumptions
+			echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ' . __( 'Please make sure the Apache <code>mod_rewrite</code> module is installed as it will be used at the end of this installation.' ) . '</p>';
+		elseif ( $is_apache )
+			echo '<div class="error inline"><p><strong>' . __( 'Warning!' ) . '</strong> ' . __( 'It looks like the Apache <code>mod_rewrite</code> module is not installed.' ) . '</p>';
+		if ( $got_mod_rewrite || $is_apache ) // Protect against mod_rewrite mimicry (but ! Apache)
+			echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled, ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p></div>';
+	}
+
+	if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
+		<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
+		<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
+		<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
+		<?php // @todo: Link to an MS readme? ?>
+		<table class="form-table">
+			<tr>
+				<th><label><input type='radio' name='subdomain_install' value='1'<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
+				<td><?php printf( _x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ), $hostname ); ?></td>
+			</tr>
+			<tr>
+				<th><label><input type='radio' name='subdomain_install' value='0'<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
+				<td><?php printf( _x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ), $hostname ); ?></td>
+			</tr>
+		</table>
+
+<?php
+	endif;
+
+		$is_www = ( 0 === strpos( $hostname, 'www.' ) );
+		if ( $is_www ) :
+		?>
+		<h3><?php esc_html_e( 'Server Address' ); ?></h3>
+		<p><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the <code>www</code> prefix with an address like <code>%2$s</code> but any links will not have the <code>www</code> prefix.' ), substr( $hostname, 4 ), $hostname ); ?></h3>
+		<table class="form-table">
+			<tr>
+				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
+				<td>
+					<?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
+				</td>
+			</tr>
+		</table>
+		<?php endif; ?>
+
+		<h3><?php esc_html_e( 'Network Details' ); ?></h3>
+		<table class="form-table">
+		<?php if ( 'localhost' == $hostname ) : ?>
+			<tr>
+				<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
+				<td><?php
+					_e( 'Because you are using <code>localhost</code>, the sites in your WordPress network must use sub-directories. Consider using <code>localhost.localdomain</code> if you wish to use sub-domains.' );
+					// Uh oh:
+					if ( !allow_subdirectory_install() )
+						echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
+				?></td>
+			</tr>
+		<?php elseif ( !allow_subdomain_install() ) : ?>
+			<tr>
+				<th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
+				<td><?php
+					_e( 'Because your install is in a directory, the sites in your WordPress network must use sub-directories.' );
+					// Uh oh:
+					if ( !allow_subdirectory_install() )
+						echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
+				?></td>
+			</tr>
+		<?php elseif ( !allow_subdirectory_install() ) : ?>
+			<tr>
+				<th scope="row"><?php esc_html_e( 'Sub-domain Install' ); ?></th>
+				<td><?php _e( 'Because your install is not new, the sites in your WordPress network must use sub-domains.' );
+					echo ' <strong>' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
+				?></td>
+			</tr>
+		<?php endif; ?>
+		<?php if ( ! $is_www ) : ?>
+			<tr>
+				<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
+				<td>
+					<?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
+				</td>
+			</tr>
+		<?php endif; ?>
+			<tr>
+				<th scope='row'><?php esc_html_e( 'Network Title' ); ?></th>
+				<td>
+					<input name='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
+					<br /><?php _e( 'What would you like to call your network?' ); ?>
+				</td>
+			</tr>
+			<tr>
+				<th scope='row'><?php esc_html_e( 'Admin E-mail Address' ); ?></th>
+				<td>
+					<input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
+					<br /><?php _e( 'Your email address.' ); ?>
+				</td>
+			</tr>
+		</table>
+		<?php submit_button( __( 'Install' ), 'primary', 'submit' ); ?>
+	</form>
+	<?php
+}
+
+/**
+ * Prints step 2 for Network installation process.
+ *
+ * @since 3.0.0
+ */
+function network_step2( $errors = false ) {
+	global $base, $wpdb;
+	$hostname = get_clean_basedomain();
+
+	if ( ! isset( $base ) )
+		$base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
+
+	// Wildcard DNS message.
+	if ( is_wp_error( $errors ) )
+		echo '<div class="error">' . $errors->get_error_message() . '</div>';
+
+	if ( $_POST ) {
+		if ( allow_subdomain_install() )
+			$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
+		else
+			$subdomain_install = false;
+	} else {
+		if ( is_multisite() ) {
+			$subdomain_install = is_subdomain_install();
+?>
+	<p><?php _e( 'The original configuration steps are shown here for reference.' ); ?></p>
+<?php
+		} else {
+			$subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
+?>
+	<div class="error"><p><strong><?php _e('Warning:'); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
+	<p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
+<?php
+		}
+	}
+
+	if ( $_POST || ! is_multisite() ) {
+?>
+		<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
+		<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
+		<div class="updated inline"><p><?php
+			if ( file_exists( ABSPATH . '.htaccess' ) )
+				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), '.htaccess' );
+			elseif ( file_exists( ABSPATH . 'web.config' ) )
+				printf( __( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>%s</code> files.' ), 'web.config' );
+			else
+				_e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' );
+		?></p></div>
+<?php
+	}
+?>
+		<ol>
+			<li><p><?php
+				printf( __( 'Create a <code>blogs.dir</code> directory at <code>%s/blogs.dir</code>. This directory is used to store uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
+				if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
+					echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong';
+			?></p></li>
+			<li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p>
+				<textarea class="code" readonly="readonly" cols="100" rows="7">
+define( 'MULTISITE', true );
+define( 'SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?> );
+$base = '<?php echo $base; ?>';
+define( 'DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>' );
+define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
+define( 'SITE_ID_CURRENT_SITE', 1 );
+define( 'BLOG_ID_CURRENT_SITE', 1 );</textarea>
+<?php
+	$keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
+	foreach ( $keys_salts as $c => $v ) {
+		if ( defined( $c ) )
+			unset( $keys_salts[ $c ] );
+	}
+	if ( ! empty( $keys_salts ) ) {
+		$keys_salts_str = '';
+		$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
+		if ( is_wp_error( $from_api ) ) {
+			foreach ( $keys_salts as $c => $v ) {
+				$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
+			}
+		} else {
+			$from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
+			foreach ( $keys_salts as $c => $v ) {
+				$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
+			}
+		}
+		$num_keys_salts = count( $keys_salts );
+?>
+	<p><?php
+		echo _n( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts ); ?> <?php _e( 'To make your installation more secure, you should also add:' ) ?></p>
+	<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
+<?php
+	}
+?>
+</li>
+<?php
+	if ( iis7_supports_permalinks() ) :
+
+			if ( $subdomain_install ) {
+				$web_config_file =
+'<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <system.webServer>
+        <rewrite>
+            <rules>
+                <rule name="WordPress Rule 1" stopProcessing="true">
+                    <match url="^index\.php$" ignoreCase="false" />
+                    <action type="None" />
+                </rule>
+                <rule name="WordPress Rule 2" stopProcessing="true">
+                    <match url="^files/(.+)" ignoreCase="false" />
+                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
+                </rule>
+                <rule name="WordPress Rule 3" stopProcessing="true">
+                    <match url="^" ignoreCase="false" />
+                    <conditions logicalGrouping="MatchAny">
+                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
+                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
+                    </conditions>
+                    <action type="None" />
+                </rule>
+                <rule name="WordPress Rule 4" stopProcessing="true">
+                    <match url="." ignoreCase="false" />
+                    <action type="Rewrite" url="index.php" />
+                </rule>
+            </rules>
+        </rewrite>
+    </system.webServer>
+</configuration>';
+			} else {
+				$web_config_file =
+'<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <system.webServer>
+        <rewrite>
+            <rules>
+                <rule name="WordPress Rule 1" stopProcessing="true">
+                    <match url="^index\.php$" ignoreCase="false" />
+                    <action type="None" />
+                </rule>
+                <rule name="WordPress Rule 2" stopProcessing="true">
+                    <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
+                    <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
+                </rule>
+                <rule name="WordPress Rule 3" stopProcessing="true">
+                    <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
+                    <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
+                </rule>
+                <rule name="WordPress Rule 4" stopProcessing="true">
+                    <match url="^" ignoreCase="false" />
+                    <conditions logicalGrouping="MatchAny">
+                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
+                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
+                    </conditions>
+                    <action type="None" />
+                </rule>
+                <rule name="WordPress Rule 5" stopProcessing="true">
+                    <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" />
+                    <action type="Rewrite" url="{R:2}" />
+                </rule>
+                <rule name="WordPress Rule 6" stopProcessing="true">
+                    <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
+                    <action type="Rewrite" url="{R:2}" />
+                </rule>
+                <rule name="WordPress Rule 7" stopProcessing="true">
+                    <match url="." ignoreCase="false" />
+                    <action type="Rewrite" url="index.php" />
+                </rule>
+            </rules>
+        </rewrite>
+    </system.webServer>
+</configuration>';
+			}
+	?>
+		<li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
+		<textarea class="code" readonly="readonly" cols="100" rows="20">
+		<?php echo esc_textarea( $web_config_file ); ?>
+		</textarea></li>
+		</ol>
+
+	<?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
+
+		$htaccess_file = 'RewriteEngine On
+RewriteBase ' . $base . '
+RewriteRule ^index\.php$ - [L]
+
+# uploaded files
+RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
+
+		if ( ! $subdomain_install )
+			$htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
+
+		$htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
+RewriteCond %{REQUEST_FILENAME} -d
+RewriteRule ^ - [L]';
+
+		// @todo custom content dir.
+		if ( ! $subdomain_install )
+			$htaccess_file .= "\nRewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]\nRewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]";
+
+		$htaccess_file .= "\nRewriteRule . index.php [L]";
+
+		?>
+		<li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
+		<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
+<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
+		</ol>
+
+	<?php endif; // end IIS/Apache code branches.
+
+	if ( !is_multisite() ) { ?>
+		<p><?php printf( __( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.') ); ?> <a href="<?php echo esc_url( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p>
+<?php
+	}
+}
+
+if ( $_POST ) {
+
+	$base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
+
+	check_admin_referer( 'install-network-1' );
+
+	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+	// create network tables
+	install_network();
+	$hostname = get_clean_basedomain();
+	$subdomain_install = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
+	if ( ! network_domain_check() ) {
+		$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install );
+		if ( is_wp_error( $result ) ) {
+			if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() )
+				network_step2( $result );
+			else
+				network_step1( $result );
+		} else {
+			network_step2();
+		}
+	} else {
+		network_step2();
+	}
+} elseif ( is_multisite() || network_domain_check() ) {
+	network_step2();
+} else {
+	network_step1();
+}
+?>
+</div>
+
+<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
Index: /tags/3.1/wp-admin/network/admin.php
===================================================================
--- /tags/3.1/wp-admin/network/admin.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/admin.php	(revision 17487)
@@ -0,0 +1,22 @@
+<?php
+/**
+ * WordPress Network Administration Bootstrap
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+define( 'WP_NETWORK_ADMIN', TRUE );
+
+/** Load WordPress Administration Bootstrap */
+require_once( dirname( dirname( __FILE__ ) ) . '/admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! is_main_site() ) {
+	wp_redirect( network_admin_url() );
+	exit;
+}
+?>
Index: /tags/3.1/wp-admin/network/edit.php
===================================================================
--- /tags/3.1/wp-admin/network/edit.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/edit.php	(revision 17487)
@@ -0,0 +1,482 @@
+<?php
+/**
+ * Action handler for Multisite administration panels.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( empty( $_GET['action'] ) ) {
+	wp_redirect( admin_url( 'index.php' ) );
+	exit;
+}
+
+function confirm_delete_users( $users ) {
+	$current_user = wp_get_current_user();
+	if ( !is_array( $users ) )
+		return false;
+
+	screen_icon();
+	?>
+	<h2><?php esc_html_e( 'Users' ); ?></h2>
+	<p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
+	<form action="edit.php?action=dodelete" method="post">
+	<input type="hidden" name="dodelete" />
+	<?php
+	wp_nonce_field( 'ms-users-delete' );
+	$site_admins = get_super_admins();
+	$admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>";
+
+	foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) {
+		if ( $val != '' && $val != '0' ) {
+			$delete_user = new WP_User( $val );
+
+			if ( ! current_user_can( 'delete_user', $delete_user->ID ) )
+				wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) );
+
+			if ( in_array( $delete_user->user_login, $site_admins ) )
+				wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network admnistrator.' ), $delete_user->user_login ) );
+
+			echo "<input type='hidden' name='user[]' value='{$val}'/>\n";
+			$blogs = get_blogs_of_user( $val, true );
+
+			if ( !empty( $blogs ) ) {
+				?>
+				<br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
+				<?php
+				foreach ( (array) $blogs as $key => $details ) {
+					$blog_users = get_users( array( 'blog_id' => $details->userblog_id ) );
+					if ( is_array( $blog_users ) && !empty( $blog_users ) ) {
+						$user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
+						$user_dropdown = "<select name='blog[$val][{$key}]'>";
+						$user_list = '';
+						foreach ( $blog_users as $user ) {
+							if ( ! in_array( $user->ID, $allusers ) )
+								$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
+						}
+						if ( '' == $user_list )
+							$user_list = $admin_out;
+						$user_dropdown .= $user_list;
+						$user_dropdown .= "</select>\n";
+						?>
+						<ul style="list-style:none;">
+							<li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
+							<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
+							<?php _e( 'Delete all posts and links.' ); ?></label></li>
+							<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
+							<?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
+						</ul>
+						<?php
+					}
+				}
+				echo "</fieldset>";
+			}
+		}
+	}
+
+	submit_button( __('Confirm Deletion'), 'delete' );
+	?>
+	</form>
+    <?php
+	return true;
+}
+
+do_action( 'wpmuadminedit' , '');
+
+if ( isset( $_GET['id' ]) )
+	$id = intval( $_GET['id'] );
+elseif ( isset( $_POST['id'] ) )
+	$id = intval( $_POST['id'] );
+
+switch ( $_GET['action'] ) {
+	case 'siteoptions':
+		check_admin_referer( 'siteoptions' );
+		if ( ! current_user_can( 'manage_network_options' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		if ( empty( $_POST ) )
+			wp_die( sprintf( __( 'You probably need to go back to the <a href="%s">options page</a>.' ), esc_url( admin_url( 'settings.php' ) ) ) );
+
+		if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array( $_POST['WPLANG'], get_available_languages() ) ) )
+			update_site_option( 'WPLANG', $_POST['WPLANG'] );
+
+		if ( is_email( $_POST['admin_email'] ) )
+			update_site_option( 'admin_email', $_POST['admin_email'] );
+
+		$illegal_names = split( ' ', $_POST['illegal_names'] );
+		foreach ( (array) $illegal_names as $name ) {
+			$name = trim( $name );
+			if ( $name != '' )
+				$names[] = trim( $name );
+		}
+		update_site_option( 'illegal_names', $names );
+
+		if ( $_POST['limited_email_domains'] != '' ) {
+			$limited_email_domains = str_replace( ' ', "\n", $_POST['limited_email_domains'] );
+			$limited_email_domains = split( "\n", stripslashes( $limited_email_domains ) );
+			$limited_email = array();
+			foreach ( (array) $limited_email_domains as $domain ) {
+					$domain = trim( $domain );
+				if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
+					$limited_email[] = trim( $domain );
+			}
+			update_site_option( 'limited_email_domains', $limited_email );
+		} else {
+			update_site_option( 'limited_email_domains', '' );
+		}
+
+		if ( $_POST['banned_email_domains'] != '' ) {
+			$banned_email_domains = split( "\n", stripslashes( $_POST['banned_email_domains'] ) );
+			$banned = array();
+			foreach ( (array) $banned_email_domains as $domain ) {
+				$domain = trim( $domain );
+				if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) )
+					$banned[] = trim( $domain );
+			}
+			update_site_option( 'banned_email_domains', $banned );
+		} else {
+			update_site_option( 'banned_email_domains', '' );
+		}
+
+		$options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled' );
+		$checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 );
+		foreach ( $checked_options as $option_name => $option_unchecked_value ) {
+			if ( ! isset( $_POST[$option_name] ) )
+				$_POST[$option_name] = $option_unchecked_value;
+		}
+		foreach ( $options as $option_name ) {
+			if ( ! isset($_POST[$option_name]) )
+				continue;
+			$value = stripslashes_deep( $_POST[$option_name] );
+			update_site_option( $option_name, $value );
+		}
+
+		// Update more options here
+		do_action( 'update_wpmu_options' );
+
+		wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
+		exit();
+	break;
+
+	case 'updateblog':
+		// No longer used.
+	break;
+
+	case 'deleteblog':
+		check_admin_referer('deleteblog');
+		if ( ! ( current_user_can( 'manage_sites' ) && current_user_can( 'delete_sites' ) ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
+			wpmu_delete_blog( $id, true );
+			wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'delete' ), wp_get_referer() ) );
+		} else {
+			wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'not_deleted' ), wp_get_referer() ) );
+		}
+
+		exit();
+	break;
+
+	case 'allblogs':
+		if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
+			check_admin_referer( 'bulk-sites' );
+
+			if ( ! current_user_can( 'manage_sites' ) )
+				wp_die( __( 'You do not have permission to access this page.' ) );
+
+			if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
+				$doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
+
+			$blogfunction = '';
+
+			foreach ( (array) $_POST['allblogs'] as $key => $val ) {
+				if ( $val != '0' && $val != $current_site->blog_id ) {
+					switch ( $doaction ) {
+						case 'delete':
+							if ( ! current_user_can( 'delete_site', $val ) )
+								wp_die( __( 'You are not allowed to delete the site.' ) );
+							$blogfunction = 'all_delete';
+							wpmu_delete_blog( $val, true );
+						break;
+
+						case 'spam':
+							$blogfunction = 'all_spam';
+							update_blog_status( $val, 'spam', '1' );
+							set_time_limit( 60 );
+						break;
+
+						case 'notspam':
+							$blogfunction = 'all_notspam';
+							update_blog_status( $val, 'spam', '0' );
+							set_time_limit( 60 );
+						break;
+					}
+				} else {
+					wp_die( __( 'You are not allowed to change the current site.' ) );
+				}
+			}
+
+			wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $blogfunction ), wp_get_referer() ) );
+		} else {
+			wp_redirect( network_admin_url( 'sites.php' ) );
+		}
+		exit();
+	break;
+
+	case 'archiveblog':
+		check_admin_referer( 'archiveblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		update_blog_status( $id, 'archived', '1' );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'archive' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	case 'unarchiveblog':
+		check_admin_referer( 'unarchiveblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		update_blog_status( $id, 'archived', '0' );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unarchive' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	case 'activateblog':
+		check_admin_referer( 'activateblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		update_blog_status( $id, 'deleted', '0' );
+		do_action( 'activate_blog', $id );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'activate' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	case 'deactivateblog':
+		check_admin_referer( 'deactivateblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		do_action( 'deactivate_blog', $id );
+		update_blog_status( $id, 'deleted', '1' );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'deactivate' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	case 'unspamblog':
+		check_admin_referer( 'unspamblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		update_blog_status( $id, 'spam', '0' );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unspam' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	case 'spamblog':
+		check_admin_referer( 'spamblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		update_blog_status( $id, 'spam', '1' );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'spam' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	case 'unmatureblog':
+		check_admin_referer( 'unmatureblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		update_blog_status( $id, 'mature', '0' );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'unmature' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	case 'matureblog':
+		check_admin_referer( 'matureblog' );
+		if ( ! current_user_can( 'manage_sites' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		update_blog_status( $id, 'mature', '1' );
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'mature' ), wp_get_referer() ) );
+		exit();
+	break;
+
+	// Common
+	case 'confirm':
+		check_admin_referer( 'confirm' );
+		if ( !headers_sent() ) {
+			nocache_headers();
+			header( 'Content-Type: text/html; charset=utf-8' );
+		}
+		if ( $current_site->blog_id == $id )
+			wp_die( __( 'You are not allowed to change the current site.' ) );
+		?>
+		<!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 if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
+			<head>
+				<title><?php _e( 'WordPress &rsaquo; Confirm your action' ); ?></title>
+
+				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+				<?php
+				wp_admin_css( 'install', true );
+				wp_admin_css( 'ie', true );
+				?>
+			</head>
+			<body>
+				<h1 id="logo"><img alt="WordPress" src="<?php echo esc_attr( admin_url( 'images/wordpress-logo.png' ) ); ?>" /></h1>
+				<form action="edit.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
+					<input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
+					<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
+					<input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
+					<?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
+					<p><?php echo esc_html( stripslashes( $_GET['msg'] ) ); ?></p>
+					<?php submit_button( __('Confirm'), 'button' ); ?>
+				</form>
+			</body>
+		</html>
+		<?php
+		exit();
+	break;
+
+	// Users
+	case 'deleteuser':
+		if ( ! current_user_can( 'manage_network_users' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		check_admin_referer( 'deleteuser' );
+
+		if ( $id != '0' && $id != '1' ) {
+			$_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
+			$title = __( 'Users' );
+			$parent_file = 'users.php';
+			require_once( '../admin-header.php' );
+			echo '<div class="wrap">';
+			confirm_delete_users( $_POST['allusers'] );
+			echo '</div>';
+            require_once( '../admin-footer.php' );
+  		} else {
+			wp_redirect( network_admin_url( 'users.php' ) );
+		}
+		exit();
+	break;
+
+	case 'allusers':
+		if ( !current_user_can( 'manage_network_users' ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
+			check_admin_referer( 'bulk-users-network' );
+
+			if ( $_GET['action'] != -1 || $_POST['action2'] != -1 )
+				$doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
+
+			$userfunction = '';
+
+			foreach ( (array) $_POST['allusers'] as $key => $val ) {
+				if ( !empty( $val ) ) {
+					switch ( $doaction ) {
+						case 'delete':
+							if ( ! current_user_can( 'delete_users' ) )
+								wp_die( __( 'You do not have permission to access this page.' ) );
+							$title = __( 'Users' );
+							$parent_file = 'users.php';
+							require_once( '../admin-header.php' );
+							echo '<div class="wrap">';
+							confirm_delete_users( $_POST['allusers'] );
+							echo '</div>';
+				            require_once( '../admin-footer.php' );
+				            exit();
+       					break;
+
+						case 'spam':
+							$user = new WP_User( $val );
+							if ( in_array( $user->user_login, get_super_admins() ) )
+								wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
+
+							$userfunction = 'all_spam';
+							$blogs = get_blogs_of_user( $val, true );
+							foreach ( (array) $blogs as $key => $details ) {
+								if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
+									update_blog_status( $details->userblog_id, 'spam', '1' );
+							}
+							update_user_status( $val, 'spam', '1' );
+						break;
+
+						case 'notspam':
+							$userfunction = 'all_notspam';
+							$blogs = get_blogs_of_user( $val, true );
+							foreach ( (array) $blogs as $key => $details )
+								update_blog_status( $details->userblog_id, 'spam', '0' );
+
+							update_user_status( $val, 'spam', '0' );
+						break;
+					}
+				}
+			}
+
+			wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
+		} else {
+			$location = network_admin_url( 'users.php' );
+
+			if ( ! empty( $_REQUEST['paged'] ) )
+				$location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
+			wp_redirect( $location );
+		}
+		exit();
+	break;
+
+	case 'dodelete':
+		check_admin_referer( 'ms-users-delete' );
+		if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) )
+			wp_die( __( 'You do not have permission to access this page.' ) );
+
+		if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
+			foreach ( $_POST['blog'] as $id => $users ) {
+				foreach ( $users as $blogid => $user_id ) {
+					if ( ! current_user_can( 'delete_user', $id ) )
+						continue;
+
+					if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
+						remove_user_from_blog( $id, $blogid, $user_id );
+					else
+						remove_user_from_blog( $id, $blogid );
+				}
+			}
+		}
+		$i = 0;
+		if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
+			foreach( $_POST['user'] as $id ) {
+				if ( ! current_user_can( 'delete_user', $id ) )
+					continue;
+				wpmu_delete_user( $id );
+				$i++;
+			}
+
+		if ( $i == 1 )
+			$deletefunction = 'delete';
+		else
+			$deletefunction = 'all_delete';
+
+		wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
+		exit();
+	break;
+
+	default:
+		// Let plugins use us as a post handler easily
+		do_action( 'network_admin_edit_' . $_GET['action'] );
+		wp_redirect( network_admin_url( 'index.php' ) );
+		exit();
+	break;
+}
+?>
Index: /tags/3.1/wp-admin/network/index-extra.php
===================================================================
--- /tags/3.1/wp-admin/network/index-extra.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/index-extra.php	(revision 17487)
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Handle default network dashboard widgets options AJAX.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+require( '../index-extra.php' );
Index: /tags/3.1/wp-admin/network/index.php
===================================================================
--- /tags/3.1/wp-admin/network/index.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/index.php	(revision 17487)
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Multisite administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+/** Load WordPress dashboard API */
+require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
+
+if ( !is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can( 'manage_network' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$title = __( 'Dashboard' );
+$parent_file = 'index.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('Until WordPress 3.0, running multiple sites required using WordPress MU instead of regular WordPress. In version 3.0, these applications have merged. If you are a former MU user, you should be aware of the following changes:') . '</p>' .
+	'<ul><li>' . __('Site Admin is now Super Admin (we highly encourage you to get yourself a cape!).') . '</li>' .
+	'<li>' . __('Blogs are now called Sites; Site is now called Network.') . '</li></ul>' .
+	'<p>' . __('This screen provides the network administrator with links to the screens for Sites and Users to either create a new site or user, or to search existing users and sites, as well as Dashboard widgets. Those screens are also accessible through the left-hand navigation in the Network Admin section.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin" target="_blank">Documentation on the Network Admin</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+wp_dashboard_setup();
+
+wp_enqueue_script( 'dashboard' );
+wp_enqueue_script( 'plugin-install' );
+wp_admin_css( 'dashboard' );
+wp_admin_css( 'plugin-install' );
+add_thickbox();
+
+add_screen_option('layout_columns', array('max' => 4, 'default' => 2) );
+
+require_once( '../admin-header.php' );
+
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<div id="dashboard-widgets-wrap">
+
+<?php wp_dashboard(); ?>
+
+<div class="clear"></div>
+</div><!-- dashboard-widgets-wrap -->
+
+</div><!-- wrap -->
+
+<?php include( '../admin-footer.php' ); ?>
Index: /tags/3.1/wp-admin/network/menu.php
===================================================================
--- /tags/3.1/wp-admin/network/menu.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/menu.php	(revision 17487)
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Build Network Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/* translators: Network menu item */
+$menu[0] = array(__('Dashboard'), 'manage_network', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'div');
+
+$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
+
+/* translators: Sites menu item */
+$menu[5] = array(__('Sites'), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'div');
+$submenu['sites.php'][5]  = array( __('Sites'), 'manage_sites', 'sites.php' );
+$submenu['sites.php'][10]  = array( _x('Add New', 'site'), 'create_sites', 'site-new.php' );
+
+$menu[10] = array(__('Users'), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'div');
+$submenu['users.php'][5]  = array( __('Users'), 'manage_network_users', 'users.php' );
+$submenu['users.php'][10]  = array( _x('Add New', 'user'), 'create_users', 'user-new.php' );
+
+$plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
+$update_themes = get_site_transient( 'update_themes' );
+if ( !empty($update_themes->response) )
+	$theme_update_count = count( $update_themes->response );
+$menu[15] = array(sprintf(__('Themes %s'), "<span class='update-plugins count-$theme_update_count'><span class='theme-count'>" . number_format_i18n($theme_update_count) . "</span></span>" ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'div');
+$submenu['themes.php'][5]  = array( __('Themes'), 'manage_network_themes', 'themes.php' );
+$submenu['themes.php'][10] = array( _x('Add New', 'theme'), 'install_themes', 'theme-install.php' );
+$submenu['themes.php'][15] = array( _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php' );
+
+$update_plugins = get_site_transient( 'update_plugins' );
+if ( !empty($update_plugins->response) )
+	$plugin_update_count = count( $update_plugins->response );
+$menu[20] = array(sprintf( __('Plugins %s'), "<span class='update-plugins count-$plugin_update_count'><span class='plugin-count'>" . number_format_i18n($plugin_update_count) . "</span></span>" ), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'div');
+$submenu['plugins.php'][5]  = array( __('Plugins'), 'manage_network_plugins', 'plugins.php' );
+$submenu['plugins.php'][10] = array( _x('Add New', 'plugin editor'), 'install_plugins', 'plugin-install.php' );
+$submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' );
+
+
+$menu[25] = array(__('Settings'), 'manage_network_options', 'settings.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'div');
+if ( defined( 'MULTISITE' ) && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) {
+	$submenu['settings.php'][5]  = array( __('Settings'), 'manage_network_options', 'settings.php' );
+	$submenu['settings.php'][10] = array( __('Network Setup'), 'manage_network_options', 'setup.php' );
+}
+
+$update_wordpress = get_core_updates( array('dismissed' => false) );
+if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
+	$wordpress_update_count = 1;
+
+$update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
+$update_title = array();
+if ( $wordpress_update_count )
+	$update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);
+if ( $plugin_update_count )
+	$update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);
+if ( $theme_update_count )
+	$update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count);
+
+$update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';
+
+$menu[30] = array(sprintf( __('Updates %s'), "<span class='update-plugins count-$update_count' title='$update_title'><span class='update-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'manage_network', 'upgrade.php', '', 'menu-top menu-icon-tools', 'menu-update', 'div');
+$submenu[ 'upgrade.php' ][10] = array( __( 'Updates' ), 'update_core',  'update-core.php' );
+$submenu[ 'upgrade.php' ][15] = array( __( 'Update Network' ), 'manage_network', 'upgrade.php' );
+unset($plugin_update_count, $theme_update_count, $wordpress_update_count, $update_count, $update_title, $update_themes, $update_plugins, $update_wordpress);
+
+
+$menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator-last' );
+
+require_once(ABSPATH . 'wp-admin/includes/menu.php');
+
+?>
Index: /tags/3.1/wp-admin/network/plugin-editor.php
===================================================================
--- /tags/3.1/wp-admin/network/plugin-editor.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/plugin-editor.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Plugin editor network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../plugin-editor.php' );
Index: /tags/3.1/wp-admin/network/plugin-install.php
===================================================================
--- /tags/3.1/wp-admin/network/plugin-install.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/plugin-install.php	(revision 17487)
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Install plugin network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+if ( isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) )
+	define( 'IFRAME_REQUEST', true );
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../plugin-install.php' );
Index: /tags/3.1/wp-admin/network/plugins.php
===================================================================
--- /tags/3.1/wp-admin/network/plugins.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/plugins.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Network Plugins administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../plugins.php' );
Index: /tags/3.1/wp-admin/network/profile.php
===================================================================
--- /tags/3.1/wp-admin/network/profile.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/profile.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * User profile network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../profile.php' );
Index: /tags/3.1/wp-admin/network/settings.php
===================================================================
--- /tags/3.1/wp-admin/network/settings.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/settings.php	(revision 17487)
@@ -0,0 +1,277 @@
+<?php
+/**
+ * Multisite network settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can( 'manage_network_options' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$title = __( 'Settings' );
+$parent_file = 'settings.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen sets and changes options for the network as a whole. The first site is the main site in the network and network options are pulled from that original site&#8217;s options.') . '</p>' .
+	'<p>' . __('Operational settings has fields for the network&#8217;s name and admin email.') . '</p>' .
+	'<p>' . __('Dashboard Site is an option to give a site to users who do not have a site on the system. Their default role is Subscriber, but that default can be changed. The Admin Notice Feed can provide a notice on all dashboards of the latest post via RSS or Atom, or provide no such notice if left blank.') . '</p>' .
+	'<p>' . __('Registration settings can disable/enable public signups. If you let others sign up for a site, install spam plugins. Spaces, not commas, should separate names banned as sites for this network.') . '</p>' .
+	'<p>' . __('New site settings are defaults applied when a new site is created in the network. These include welcome email for when a new site or user account is registered, and what&#8127;s put in the first post, page, comment, comment author, and comment URL.') . '</p>' .
+	'<p>' . __('Upload settings control the size of the uploaded files and the amount of available upload space for each site. You can change the default value for specific sites when you edit a particular site. Allowed file types are also listed (space separated only).') . '</p>' .
+	'<p>' . __('Checkboxes for media upload buttons set which are shown in the visual editor. If unchecked, a generic upload button is still visible; other media types can still be uploaded if on the allowed file types list.') . '</p>' .
+	'<p>' . __('Menu setting enables/disables the plugin menus from appearing for non super admins, so that only super admins, not site admins, have access to activate plugins.') . '</p>' .
+	'<p>' . __('Super admins can no longer be added on the Options screen. You must now go to the list of existing users on Super Admin > Users and click on Username or the Edit action link below that name. This goes to an Edit User page where you can check a box to grant super admin privileges.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Settings_Screen" target="_blank">Documentation on Network Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include( '../admin-header.php' );
+
+if (isset($_GET['updated'])) {
+	?>
+	<div id="message" class="updated"><p><?php _e( 'Options saved.' ) ?></p></div>
+	<?php
+}
+?>
+
+<div class="wrap">
+	<?php screen_icon('options-general'); ?>
+	<h2><?php _e( 'Settings' ) ?></h2>
+	<form method="post" action="edit.php?action=siteoptions">
+		<?php wp_nonce_field( 'siteoptions' ); ?>
+		<h3><?php _e( 'Operational Settings' ); ?></h3>
+		<table class="form-table">
+			<tr valign="top">
+				<th scope="row"><label for="site_name"><?php _e( 'Network Name' ) ?></label></th>
+				<td>
+					<input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( $current_site->site_name ) ?>" />
+					<br />
+					<?php _e( 'What you would like to call this website.' ) ?>
+				</td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ) ?></label></th>
+				<td>
+					<input name="admin_email" type="text" id="admin_email" class="regular-text" value="<?php echo esc_attr( get_site_option('admin_email') ) ?>" />
+					<br />
+					<?php printf( __( 'Registration and support emails will come from this address. An address such as <code>support@%s</code> is recommended.' ), $current_site->domain ); ?>
+				</td>
+			</tr>
+		</table>
+		<h3><?php _e( 'Registration Settings' ); ?></h3>
+		<table class="form-table">
+			<tr valign="top">
+				<th scope="row"><?php _e( 'Allow new registrations' ) ?></th>
+				<?php
+				if ( !get_site_option( 'registration' ) )
+					update_site_option( 'registration', 'none' );
+				$reg = get_site_option( 'registration' );
+				?>
+				<td>
+					<label><input name="registration" type="radio" id="registration1" value="none"<?php checked( $reg, 'none') ?> /> <?php _e( 'Registration is disabled.' ); ?></label><br />
+					<label><input name="registration" type="radio" id="registration2" value="user"<?php checked( $reg, 'user') ?> /> <?php _e( 'User accounts may be registered.' ); ?></label><br />
+					<label><input name="registration" type="radio" id="registration3" value="blog"<?php checked( $reg, 'blog') ?> /> <?php _e( 'Logged in users may register new sites.' ); ?></label><br />
+					<label><input name="registration" type="radio" id="registration4" value="all"<?php checked( $reg, 'all') ?> /> <?php _e( 'Both sites and user accounts can be registered.' ); ?></label><br />
+					<?php if ( is_subdomain_install() )
+						_e( 'If registration is disabled, please set <code>NOBLOGREDIRECT</code> in <code>wp-config.php</code> to a URL you will redirect visitors to if they visit a non-existent site.' );
+					?>
+				</td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><?php _e( 'Registration notification' ) ?></th>
+				<?php
+				if ( !get_site_option( 'registrationnotification' ) )
+					update_site_option( 'registrationnotification', 'yes' );
+				?>
+				<td>
+					<label><input name="registrationnotification" type="checkbox" id="registrationnotification" value="yes"<?php checked( get_site_option( 'registrationnotification' ), 'yes' ) ?> /> <?php _e( 'Send the network admin an email notification every time someone registers a site or user account.' ) ?></label>
+				</td>
+			</tr>
+
+			<tr valign="top" id="addnewusers">
+				<th scope="row"><?php _e( 'Add New Users' ) ?></th>
+				<td>
+					<label><input name="add_new_users" type="checkbox" id="add_new_users" value="1"<?php checked( get_site_option( 'add_new_users' ) ) ?> /> <?php _e( 'Allow site administrators to add new users to their site via the "Users &rarr; Add New" page.' ); ?></label>
+				</td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><label for="illegal_names"><?php _e( 'Banned Names' ) ?></label></th>
+				<td>
+					<input name="illegal_names" type="text" id="illegal_names" class="large-text" value="<?php echo esc_attr( implode( " ", (array) get_site_option( 'illegal_names' ) ) ); ?>" size="45" />
+					<br />
+					<?php _e( 'Users are not allowed to register these sites. Separate names by spaces.' ) ?>
+				</td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><label for="limited_email_domains"><?php _e( 'Limited Email Registrations' ) ?></label></th>
+				<td>
+					<?php $limited_email_domains = get_site_option( 'limited_email_domains' );
+					$limited_email_domains = str_replace( ' ', "\n", $limited_email_domains ); ?>
+					<textarea name="limited_email_domains" id="limited_email_domains" cols="45" rows="5">
+<?php echo esc_textarea( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea>
+					<br />
+					<?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ) ?>
+				</td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><label for="banned_email_domains"><?php _e('Banned Email Domains') ?></label></th>
+				<td>
+					<textarea name="banned_email_domains" id="banned_email_domains" cols="45" rows="5">
+<?php echo esc_textarea( get_site_option( 'banned_email_domains' ) == '' ? '' : implode( "\n", (array) get_site_option( 'banned_email_domains' ) ) ); ?></textarea>
+					<br />
+					<?php _e( 'If you want to ban domains from site registrations. One domain per line.' ) ?>
+				</td>
+			</tr>
+
+		</table>
+		<h3><?php _e('New Site Settings'); ?></h3>
+		<table class="form-table">
+
+			<tr valign="top">
+				<th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ) ?></label></th>
+				<td>
+					<textarea name="welcome_email" id="welcome_email" rows="5" cols="45" class="large-text">
+<?php echo esc_textarea( stripslashes( get_site_option( 'welcome_email' ) ) ) ?></textarea>
+					<br />
+					<?php _e( 'The welcome email sent to new site owners.' ) ?>
+				</td>
+			</tr>
+			<tr valign="top">
+				<th scope="row"><label for="welcome_user_email"><?php _e( 'Welcome User Email' ) ?></label></th>
+				<td>
+					<textarea name="welcome_user_email" id="welcome_user_email" rows="5" cols="45" class="large-text">
+<?php echo esc_textarea( stripslashes( get_site_option( 'welcome_user_email' ) ) ) ?></textarea>
+					<br />
+					<?php _e( 'The welcome email sent to new users.' ) ?>
+				</td>
+			</tr>
+			<tr valign="top">
+				<th scope="row"><label for="first_post"><?php _e( 'First Post' ) ?></label></th>
+				<td>
+					<textarea name="first_post" id="first_post" rows="5" cols="45" class="large-text">
+<?php echo esc_textarea( stripslashes( get_site_option( 'first_post' ) ) ) ?></textarea>
+					<br />
+					<?php _e( 'The first post on a new site.' ) ?>
+				</td>
+			</tr>
+			<tr valign="top">
+				<th scope="row"><label for="first_page"><?php _e( 'First Page' ) ?></label></th>
+				<td>
+					<textarea name="first_page" id="first_page" rows="5" cols="45" class="large-text">
+<?php echo esc_textarea( stripslashes( get_site_option('first_page') ) ) ?></textarea>
+					<br />
+					<?php _e( 'The first page on a new site.' ) ?>
+				</td>
+			</tr>
+			<tr valign="top">
+				<th scope="row"><label for="first_comment"><?php _e( 'First Comment' ) ?></label></th>
+				<td>
+					<textarea name="first_comment" id="first_comment" rows="5" cols="45" class="large-text">
+<?php echo esc_textarea( stripslashes( get_site_option('first_comment') ) ) ?></textarea>
+					<br />
+					<?php _e( 'The first comment on a new site.' ) ?>
+				</td>
+			</tr>
+			<tr valign="top">
+				<th scope="row"><label for="first_comment_author"><?php _e( 'First Comment Author' ) ?></label></th>
+				<td>
+					<input type="text" size="40" name="first_comment_author" id="first_comment_author" value="<?php echo get_site_option('first_comment_author') ?>" />
+					<br />
+					<?php _e( 'The author of the first comment on a new site.' ) ?>
+				</td>
+			</tr>
+			<tr valign="top">
+				<th scope="row"><label for="first_comment_url"><?php _e( 'First Comment URL' ) ?></label></th>
+				<td>
+					<input type="text" size="40" name="first_comment_url" id="first_comment_url" value="<?php echo esc_attr( get_site_option( 'first_comment_url' ) ) ?>" />
+					<br />
+					<?php _e( 'The URL for the first comment on a new site.' ) ?>
+				</td>
+			</tr>
+		</table>
+		<h3><?php _e( 'Upload Settings' ); ?></h3>
+		<table class="form-table">
+			<tr valign="top">
+				<th scope="row"><?php _e( 'Media upload buttons' ) ?></th>
+				<?php $mu_media_buttons = get_site_option( 'mu_media_buttons', array() ); ?>
+				<td><label><input type="checkbox" id="mu_media_buttons_image" name="mu_media_buttons[image]" value="1"<?php checked( ! empty( $mu_media_buttons['image'] ) ) ?>/> <?php _e( 'Images' ); ?></label><br />
+				<label><input type="checkbox" id="mu_media_buttons_video" name="mu_media_buttons[video]" value="1"<?php checked( ! empty( $mu_media_buttons['video'] ) ) ?>/> <?php _e( 'Videos' ); ?></label><br />
+				<label><input type="checkbox" id="mu_media_buttons_audio" name="mu_media_buttons[audio]" value="1"<?php checked( ! empty( $mu_media_buttons['audio'] ) ) ?>/> <?php _e( 'Music' ); ?></label><br />
+				<?php _e( 'The media upload buttons to display on the &#8220;Write Post&#8221; page. Make sure you update the allowed upload file types below as well.' ); ?></td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><?php _e( 'Site upload space' ) ?></th>
+				<td>
+				<label><input type="checkbox" id="upload_space_check_disabled" name="upload_space_check_disabled" value="0"<?php checked( get_site_option( 'upload_space_check_disabled' ), 0 ) ?>/> <?php printf( __( 'Limit total size of files uploaded to %s MB' ), '</label><label><input name="blog_upload_space" type="text" id="blog_upload_space" value="' . esc_attr( get_site_option('blog_upload_space', 10) ) . '" size="3" />' ); ?></label><br />
+				</td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><label for="upload_filetypes"><?php _e( 'Upload file types' ) ?></label></th>
+				<td><input name="upload_filetypes" type="text" id="upload_filetypes" class="large-text" value="<?php echo esc_attr( get_site_option('upload_filetypes', 'jpg jpeg png gif') ) ?>" size="45" /></td>
+			</tr>
+
+			<tr valign="top">
+				<th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ) ?></label></th>
+				<td><?php printf( _x( '%s KB', 'File size in kilobytes' ), '<input name="fileupload_maxk" type="text" id="fileupload_maxk" value="' . esc_attr( get_site_option( 'fileupload_maxk', 300 ) ) . '" size="5" />' ); ?></td>
+			</tr>
+		</table>
+
+<?php
+		$languages = get_available_languages();
+		if ( ! empty( $languages ) ) {
+			$lang = get_site_option( 'WPLANG' );
+?>
+		<h3><?php _e( 'Language Settings' ); ?></h3>
+		<table class="form-table">
+				<tr valign="top">
+					<th><label for="WPLANG"><?php _e( 'Default Language' ); ?></label></th>
+					<td>
+						<select name="WPLANG" id="WPLANG">
+							<?php mu_dropdown_languages( $languages, get_site_option( 'WPLANG' ) ); ?>
+						</select>
+					</td>
+				</tr>
+		</table>
+<?php
+		} // languages
+?>
+
+		<h3><?php _e( 'Menu Settings' ); ?></h3>
+		<table id="menu" class="form-table">
+			<tr valign="top">
+				<th scope="row"><?php _e( 'Enable administration menus' ); ?></th>
+				<td>
+			<?php
+			$menu_perms = get_site_option( 'menu_items' );
+			$menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
+			foreach ( (array) $menu_items as $key => $val ) {
+				echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" .  ( isset( $menu_perms[$key] ) ? checked( $menu_perms[$key], '1', false ) : '' ) . " /> " . esc_html( $val ) . "</label><br/>";
+			}
+			?>
+				</td>
+			</tr>
+		</table>
+
+		<?php do_action( 'wpmu_options' ); // Add more options here ?>
+
+		<?php submit_button(); ?>
+	</form>
+</div>
+
+<?php include( '../admin-footer.php' ); ?>
Index: /tags/3.1/wp-admin/network/setup.php
===================================================================
--- /tags/3.1/wp-admin/network/setup.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/setup.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Network Setup administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../network.php' );
Index: /tags/3.1/wp-admin/network/site-info.php
===================================================================
--- /tags/3.1/wp-admin/network/site-info.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/site-info.php	(revision 17487)
@@ -0,0 +1,166 @@
+<?php
+/**
+ * Edit Site Info Administration Screen
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can( 'manage_sites' ) )
+	wp_die( __( 'You do not have sufficient permissions to edit this site.' ) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
+	'<p>' . __('<strong>Info</strong> - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
+	'<p>' . __('<strong>Users</strong> - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
+	'<p>' . sprintf( __('<strong>Themes</strong> - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
+	'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screens" target="_blank">Documentation on Site Management</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
+
+if ( ! $id )
+	wp_die( __('Invalid site ID.') );
+
+$details = get_blog_details( $id );
+if ( !can_edit_network( $details->site_id ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$is_main_site = is_main_site( $id );
+
+if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) {
+	check_admin_referer( 'edit-site' );
+
+	switch_to_blog( $id );
+
+	if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) {
+		$blog_address = get_blogaddress_by_domain( $_POST['blog']['domain'], $_POST['blog']['path'] );
+		if ( get_option( 'siteurl' ) != $blog_address )
+			update_option( 'siteurl', $blog_address );
+
+		if ( get_option( 'home' ) != $blog_address )
+			update_option( 'home', $blog_address );
+	}
+
+	// rewrite rules can't be flushed during switch to blog
+	delete_option( 'rewrite_rules' );
+
+	// update blogs table
+	$blog_data = stripslashes_deep( $_POST['blog'] );
+	$existing_details = get_blog_details( $id, false );
+	$blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
+	foreach ( $blog_data_checkboxes as $c ) {
+		if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) )
+			$blog_data[ $c ] = $existing_details->$c;
+		else
+			$blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
+	}
+	update_blog_details( $id, $blog_data );
+
+	restore_current_blog();
+	wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php') );
+	exit;
+}
+
+if ( isset($_GET['update']) ) {
+	$messages = array();
+	if ( 'updated' == $_GET['update'] )
+		$messages[] = __('Site info updated.');
+}
+
+$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id));
+$parent_file = 'sites.php';
+$submenu_file = 'sites.php';
+
+require('../admin-header.php');
+
+?>
+
+<div class="wrap">
+<?php screen_icon('ms-admin'); ?>
+<h2 id="edit-site"><?php echo $title ?></h2>
+<h3 class="nav-tab-wrapper">
+<?php
+$tabs = array(
+	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
+	'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
+	'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
+	'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
+);
+foreach ( $tabs as $tab_id => $tab ) {
+	$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
+	echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' .  esc_html( $tab['label'] ) . '</a>';
+}
+?>
+</h3>
+<?php
+if ( ! empty( $messages ) ) {
+	foreach ( $messages as $msg )
+		echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
+} ?>
+<form method="post" action="site-info.php?action=update-site">
+	<?php wp_nonce_field( 'edit-site' ); ?>
+	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+	<table class="form-table">
+		<tr class="form-field form-required">
+			<th scope="row"><?php _e( 'Domain' ) ?></th>
+			<?php
+			$protocol = is_ssl() ? 'https://' : 'http://';
+			if ( $is_main_site ) { ?>
+			<td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td>
+			<?php } else { ?>
+			<td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td>
+			<?php } ?>
+		</tr>
+		<tr class="form-field form-required">
+			<th scope="row"><?php _e( 'Path' ) ?></th>
+			<?php if ( $is_main_site ) { ?>
+			<td><code><?php echo esc_attr( $details->path ) ?></code></td>
+			<?php } else { ?>
+			<td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' />
+			<br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td>
+			<?php } ?>
+		</tr>
+		<tr class="form-field">
+			<th scope="row"><?php _ex( 'Registered', 'site' ) ?></th>
+			<td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td>
+		</tr>
+		<tr class="form-field">
+			<th scope="row"><?php _e( 'Last Updated' ); ?></th>
+			<td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td>
+		</tr>
+		<?php
+		$attribute_fields = array( 'public' => __( 'Public' ) );
+		if ( ! $is_main_site ) {
+			$attribute_fields['archived'] = __( 'Archived' );
+			$attribute_fields['spam']     = _x( 'Spam', 'site' );
+			$attribute_fields['deleted']  = __( 'Deleted' );
+		}
+		$attribute_fields['mature'] = __( 'Mature' );
+		?>
+		<tr>
+			<th scope="row"><?php _e( 'Attributes' ); ?></th>
+			<td>
+			<?php foreach ( $attribute_fields as $field_key => $field_label ) : ?>
+				<label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); disabled( ! in_array( $details->$field_key, array( 0, 1 ) ) ); ?> />
+				<?php echo $field_label; ?></label><br/>
+			<?php endforeach; ?>
+			</td>
+		</tr>
+	</table>
+	<?php submit_button(); ?>
+</form>
+
+</div>
+<?php
+require('../admin-footer.php');
Index: /tags/3.1/wp-admin/network/site-new.php
===================================================================
--- /tags/3.1/wp-admin/network/site-new.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/site-new.php	(revision 17487)
@@ -0,0 +1,145 @@
+<?php
+/**
+ * Add Site Administration Screen
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can( 'manage_sites' ) )
+	wp_die( __( 'You do not have sufficient permissions to add sites to this network.' ) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.') . '</p>' .
+	'<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screens" target="_blank">Documentation on Site Management</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) {
+	check_admin_referer( 'add-blog', '_wpnonce_add-blog' );
+
+	if ( ! current_user_can( 'manage_sites' ) )
+		wp_die( __( 'You do not have permission to access this page.' ) );
+
+	if ( ! is_array( $_POST['blog'] ) )
+		wp_die( __( 'Can&#8217;t create an empty site.' ) );
+	$blog = $_POST['blog'];
+	$domain = '';
+	if ( ! preg_match( '/(--)/', $blog['domain'] ) && preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) )
+		$domain = strtolower( $blog['domain'] );
+
+	// If not a subdomain install, make sure the domain isn't a reserved word
+	if ( ! is_subdomain_install() ) {
+		$subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) );
+		if ( in_array( $domain, $subdirectory_reserved_names ) )
+			wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) );
+	}
+
+	$email = sanitize_email( $blog['email'] );
+	$title = $blog['title'];
+
+	if ( empty( $domain ) )
+		wp_die( __( 'Missing or invalid site address.' ) );
+	if ( empty( $email ) )
+		wp_die( __( 'Missing email address.' ) );
+	if ( !is_email( $email ) )
+		wp_die( __( 'Invalid email address.' ) );
+
+	if ( is_subdomain_install() ) {
+		$newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain );
+		$path = $base;
+	} else {
+		$newdomain = $current_site->domain;
+		$path = $base . $domain . '/';
+	}
+
+	$password = 'N/A';
+	$user_id = email_exists($email);
+	if ( !$user_id ) { // Create a new user with a random password
+		$password = wp_generate_password( 12, false );
+		$user_id = wpmu_create_user( $domain, $password, $email );
+		if ( false == $user_id )
+			wp_die( __( 'There was an error creating the user.' ) );
+		else
+			wp_new_user_notification( $user_id, $password );
+	}
+
+	$wpdb->hide_errors();
+	$id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
+	$wpdb->show_errors();
+	if ( !is_wp_error( $id ) ) {
+		if ( !is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) )
+			update_user_option( $user_id, 'primary_blog', $id, true );
+		$content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) );
+		wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
+		wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );
+		wp_redirect( add_query_arg( array('update' => 'added'), 'site-new.php' ) );
+		exit;
+	} else {
+		wp_die( $id->get_error_message() );
+	}
+}
+
+if ( isset($_GET['update']) ) {
+	$messages = array();
+	if ( 'added' == $_GET['update'] )
+		$messages[] = __('Site added.');
+}
+
+$title = __('Add New Site');
+$parent_file = 'sites.php';
+
+require('../admin-header.php');
+
+?>
+
+<div class="wrap">
+<?php screen_icon('ms-admin'); ?>
+<h2 id="add-new-site"><?php _e('Add New Site') ?></h2>
+<?php
+if ( ! empty( $messages ) ) {
+	foreach ( $messages as $msg )
+		echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
+} ?>
+<form method="post" action="<?php echo network_admin_url('site-new.php?action=add-site'); ?>">
+<?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?>
+	<table class="form-table">
+		<tr class="form-field form-required">
+			<th scope="row"><?php _e( 'Site Address' ) ?></th>
+			<td>
+			<?php if ( is_subdomain_install() ) { ?>
+				<input name="blog[domain]" type="text" class="regular-text" title="<?php _e( 'Domain' ) ?>"/>.<?php echo preg_replace( '|^www\.|', '', $current_site->domain );?>
+			<?php } else {
+				echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e( 'Domain' ) ?>"/>
+			<?php }
+			echo '<p>' . __( 'Only the characters a-z and 0-9 recommended.' ) . '</p>';
+			?>
+			</td>
+		</tr>
+		<tr class="form-field form-required">
+			<th scope="row"><?php _e( 'Site Title' ) ?></th>
+			<td><input name="blog[title]" type="text" class="regular-text" title="<?php _e( 'Title' ) ?>"/></td>
+		</tr>
+		<tr class="form-field form-required">
+			<th scope="row"><?php _e( 'Admin Email' ) ?></th>
+			<td><input name="blog[email]" type="text" class="regular-text" title="<?php _e( 'Email' ) ?>"/></td>
+		</tr>
+		<tr class="form-field">
+			<td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>
+		</tr>
+	</table>
+	<?php submit_button( __('Add Site'), 'primary', 'add-site' ); ?>
+	</form>
+</div>
+<?php
+require('../admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/network/site-settings.php
===================================================================
--- /tags/3.1/wp-admin/network/site-settings.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/site-settings.php	(revision 17487)
@@ -0,0 +1,150 @@
+<?php
+/**
+ * Edit Site Settings Administration Screen
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can( 'manage_sites' ) )
+	wp_die( __( 'You do not have sufficient permissions to edit this site.' ) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
+	'<p>' . __('<strong>Info</strong> - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
+	'<p>' . __('<strong>Users</strong> - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
+	'<p>' . sprintf( __('<strong>Themes</strong> - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
+	'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screens" target="_blank">Documentation on Site Management</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
+
+if ( ! $id )
+	wp_die( __('Invalid site ID.') );
+
+$details = get_blog_details( $id );
+if ( !can_edit_network( $details->site_id ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$is_main_site = is_main_site( $id );
+
+if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
+	check_admin_referer( 'edit-site' );
+
+	switch_to_blog( $id );
+
+	$c = 1;
+	$count = count( $_POST['option'] );
+	$skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
+	foreach ( (array) $_POST['option'] as $key => $val ) {
+		if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) )
+			continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options
+		if ( $c == $count )
+			update_option( $key, stripslashes( $val ) );
+		else
+			update_option( $key, stripslashes( $val ), false ); // no need to refresh blog details yet
+		$c++;
+	}
+
+	do_action( 'wpmu_update_blog_options' );
+	restore_current_blog();
+	wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') );
+	exit;
+}
+
+if ( isset($_GET['update']) ) {
+	$messages = array();
+	if ( 'updated' == $_GET['update'] )
+		$messages[] = __('Site options updated.');
+}
+
+$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id));
+$parent_file = 'sites.php';
+$submenu_file = 'sites.php';
+
+require('../admin-header.php');
+
+?>
+
+<div class="wrap">
+<?php screen_icon('ms-admin'); ?>
+<h2 id="edit-site"><?php echo $title ?></h2>
+<h3 class="nav-tab-wrapper">
+<?php
+$tabs = array(
+	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
+	'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
+	'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
+	'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
+);
+foreach ( $tabs as $tab_id => $tab ) {
+	$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
+	echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' .  esc_html( $tab['label'] ) . '</a>';
+}
+?>
+</h3>
+<?php
+if ( ! empty( $messages ) ) {
+	foreach ( $messages as $msg )
+		echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
+} ?>
+<form method="post" action="site-settings.php?action=update-site">
+	<?php wp_nonce_field( 'edit-site' ); ?>
+	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+	<table class="form-table">
+		<?php
+		$blog_prefix = $wpdb->get_blog_prefix( $id );
+		$options = $wpdb->get_results( "SELECT * FROM {$blog_prefix}options WHERE option_name NOT LIKE '\_%' AND option_name NOT LIKE '%user_roles'" );
+		foreach ( $options as $option ) {
+			if ( $option->option_name == 'default_role' )
+				$editblog_default_role = $option->option_value;
+			$disabled = false;
+			$class = 'all-options';
+			if ( is_serialized( $option->option_value ) ) {
+				if ( is_serialized_string( $option->option_value ) ) {
+					$option->option_value = esc_html( maybe_unserialize( $option->option_value ), 'single' );
+				} else {
+					$option->option_value = 'SERIALIZED DATA';
+					$disabled = true;
+					$class = 'all-options disabled';
+				}
+			}
+			if ( strpos( $option->option_value, "\n" ) !== false ) {
+			?>
+				<tr class="form-field">
+					<th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
+					<td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ) ?>]" id="<?php echo esc_attr( $option->option_name ) ?>"<?php disabled( $disabled ) ?>><?php echo esc_textarea( $option->option_value ) ?></textarea></td>
+				</tr>
+			<?php
+			} else {
+			?>
+				<tr class="form-field">
+					<th scope="row"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></th>
+					<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
+					<td><code><?php echo esc_html( $option->option_value ) ?></code></td>
+					<?php } else { ?>
+					<td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ) ?>]" type="text" id="<?php echo esc_attr( $option->option_name ) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
+					<?php } ?>
+				</tr>
+			<?php
+			}
+		} // End foreach
+		do_action( 'wpmueditblogaction', $id );
+		?>
+	</table>
+	<?php submit_button(); ?>
+</form>
+
+</div>
+<?php
+require('../admin-footer.php');
Index: /tags/3.1/wp-admin/network/site-themes.php
===================================================================
--- /tags/3.1/wp-admin/network/site-themes.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/site-themes.php	(revision 17487)
@@ -0,0 +1,179 @@
+<?php
+/**
+ * Edit Site Themes Administration Screen
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+$menu_perms = get_site_option( 'menu_items', array() );
+
+if ( empty( $menu_perms['themes'] ) && ! is_super_admin() )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+if ( ! current_user_can( 'manage_sites' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
+	'<p>' . __('<strong>Info</strong> - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
+	'<p>' . __('<strong>Users</strong> - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
+	'<p>' . sprintf( __('<strong>Themes</strong> - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
+	'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screens" target="_blank">Documentation on Site Management</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
+
+$action = $wp_list_table->current_action();
+
+$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
+
+// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
+$temp_args = array( 'enabled', 'disabled', 'error' ); 
+$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] ); 
+$referer = remove_query_arg( $temp_args, wp_get_referer() );
+
+$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
+
+if ( ! $id )
+	wp_die( __('Invalid site ID.') );
+
+$wp_list_table->prepare_items();
+
+$details = get_blog_details( $id );
+if ( !can_edit_network( $details->site_id ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$is_main_site = is_main_site( $id );
+
+if ( $action ) {
+	switch_to_blog( $id );
+	$allowed_themes = get_option( 'allowedthemes' );
+
+	switch ( $action ) {
+		case 'enable':
+			check_admin_referer( 'enable-theme_' . $_GET['theme'] );
+			$theme = $_GET['theme'];
+			$action = 'enabled';
+			$n = 1;
+			if ( !$allowed_themes )
+				$allowed_themes = array( $theme => true );
+			else
+				$allowed_themes[$theme] = true;
+			break;
+		case 'disable':
+			check_admin_referer( 'disable-theme_' . $_GET['theme'] );
+			$theme = $_GET['theme'];
+			$action = 'disabled';
+			$n = 1;			
+			if ( !$allowed_themes )
+				$allowed_themes = array();
+			else
+				unset( $allowed_themes[$theme] );
+			break;
+		case 'enable-selected':
+			check_admin_referer( 'bulk-themes' );
+			if ( isset( $_POST['checked'] ) ) {
+				$themes = (array) $_POST['checked'];
+				$action = 'enabled';
+				$n = count( $themes );
+				foreach( (array) $themes as $theme )
+					$allowed_themes[ $theme ] = true;
+			} else {
+				$action = 'error';
+				$n = 'none';
+			}
+			break;
+		case 'disable-selected':
+			check_admin_referer( 'bulk-themes' );
+			if ( isset( $_POST['checked'] ) ) {
+				$themes = (array) $_POST['checked'];
+				$action = 'disabled';
+				$n = count( $themes );
+				foreach( (array) $themes as $theme )
+					unset( $allowed_themes[ $theme ] );
+			} else {
+				$action = 'error';
+				$n = 'none';
+			}
+			break;
+	}
+	
+	update_option( 'allowedthemes', $allowed_themes );
+	restore_current_blog();
+	
+	wp_redirect( add_query_arg( $action, $n, $referer ) );
+	exit;	
+}
+
+if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
+	wp_redirect( $referer );
+	exit();
+}
+
+add_thickbox();
+add_screen_option( 'per_page', array( 'label' => _x( 'Themes', 'themes per page (screen options)' ) ) );
+
+$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id));
+$parent_file = 'sites.php';
+$submenu_file = 'sites.php';
+
+require('../admin-header.php'); ?>
+
+<div class="wrap">
+<?php screen_icon('ms-admin'); ?>
+<h2 id="edit-site"><?php echo $title ?></h2>
+<h3 class="nav-tab-wrapper">
+<?php
+$tabs = array(
+	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
+	'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
+	'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
+	'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
+);
+foreach ( $tabs as $tab_id => $tab ) {
+	$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
+	echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' .  esc_html( $tab['label'] ) . '</a>';
+}
+?>
+</h3><?php
+
+if ( isset( $_GET['enabled'] ) ) {
+	$_GET['enabled'] = absint( $_GET['enabled'] ); 
+	echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>'; 
+} elseif ( isset( $_GET['disabled'] ) ) { 
+	$_GET['disabled'] = absint( $_GET['disabled'] ); 
+	echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>'; 
+} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { 
+	echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>'; 
+} ?>
+
+<p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p>
+
+<form method="get" action="">
+<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
+<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+</form>
+
+<?php $wp_list_table->views(); ?>
+
+<form method="post" action="site-themes.php?action=update-site">
+	<?php wp_nonce_field( 'edit-site' ); ?>
+	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+
+<?php $wp_list_table->display(); ?>
+
+</form>
+
+</div>
+<?php include(ABSPATH . 'wp-admin/admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/network/site-users.php
===================================================================
--- /tags/3.1/wp-admin/network/site-users.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/site-users.php	(revision 17487)
@@ -0,0 +1,308 @@
+<?php
+/**
+ * Edit Site Users Administration Screen
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can('manage_sites') )
+	wp_die(__('You do not have sufficient permissions to edit this site.'));
+
+$wp_list_table = _get_list_table('WP_Users_List_Table');
+$wp_list_table->prepare_items();
+
+$action = $wp_list_table->current_action();
+
+add_contextual_help($current_screen,
+	'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
+	'<p>' . __('<strong>Info</strong> - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
+	'<p>' . __('<strong>Users</strong> - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
+	'<p>' . sprintf( __('<strong>Themes</strong> - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
+	'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screens" target="_blank">Documentation on Site Management</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
+
+if ( ! $id )
+	wp_die( __('Invalid site ID.') );
+
+$details = get_blog_details( $id );
+if ( !can_edit_network( $details->site_id ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$is_main_site = is_main_site( $id );
+
+// get blog prefix
+$blog_prefix = $wpdb->get_blog_prefix( $id );
+
+// @todo This is a hack. Eventually, add API to WP_Roles allowing retrieval of roles for a particular blog.
+if ( ! empty($wp_roles->use_db) ) {
+	$editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
+} else {
+	// Roles are stored in memory, not the DB.
+	$editblog_roles = $wp_roles->roles;
+}
+$default_role = get_blog_option( $id, 'default_role' );
+
+$action = $wp_list_table->current_action();
+
+if ( $action ) {
+	switch_to_blog( $id );
+	
+	switch ( $action ) {
+		case 'newuser':
+			check_admin_referer( 'add-user', '_wpnonce_add-new-user' );
+			$user = $_POST['user'];
+			if ( !is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) {
+				$update = 'err_new';
+			} else {
+				$password = wp_generate_password( 12, false);
+				$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
+
+				if ( false == $user_id ) {
+		 			$update = 'err_new_dup';
+				} else {
+					wp_new_user_notification( $user_id, $password );
+					add_user_to_blog( $id, $user_id, $_POST['new_role'] );
+					$update = 'newuser';
+				}
+			}
+			break;
+
+		case 'adduser':
+			check_admin_referer( 'add-user', '_wpnonce_add-user' );
+			if ( !empty( $_POST['newuser'] ) ) {
+				$update = 'adduser';
+				$newuser = $_POST['newuser'];				
+				$userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) );
+				if ( $userid ) {
+					$user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" );
+					if ( $user == false )
+						add_user_to_blog( $id, $userid, $_POST['new_role'] );
+					else
+						$update = 'err_add_member';
+				} else {
+					$update = 'err_add_notfound';
+				}
+			} else {
+				$update = 'err_add_notfound';
+			}
+			break;
+		
+		case 'remove':
+			if ( !current_user_can('remove_users')  )
+				die(__('You can&#8217;t remove users.'));
+			check_admin_referer( 'bulk-users' );
+			
+			$update = 'remove';
+			if ( isset( $_REQUEST['users'] ) ) {
+				$userids = $_REQUEST['users'];
+
+				foreach ( $userids as $user_id ) {
+					$user_id = (int) $user_id;
+					remove_user_from_blog( $user_id, $id );
+				}
+			} elseif ( isset( $_GET['user'] ) ) {
+				remove_user_from_blog( $_GET['user'] );
+			} else {
+				$update = 'err_remove';
+			}
+			break;
+
+		case 'promote':
+			check_admin_referer( 'bulk-users' );
+			$editable_roles = get_editable_roles();
+			if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
+				wp_die(__('You can&#8217;t give users that role.'));
+
+			if ( isset( $_REQUEST['users'] ) ) {
+				$userids = $_REQUEST['users'];
+				$update = 'promote';
+				foreach ( $userids as $user_id ) {
+					$user_id = (int) $user_id;
+
+					// If the user doesn't already belong to the blog, bail.
+					if ( !is_user_member_of_blog( $user_id ) )
+						wp_die(__('Cheatin&#8217; uh?'));
+
+					$user = new WP_User( $user_id );
+					$user->set_role( $_REQUEST['new_role'] );
+				}
+			} else {
+				$update = 'err_promote';
+			}
+			break;
+	}
+	
+	restore_current_blog();
+	wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) );
+	exit();
+}
+
+if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
+	wp_redirect( wp_get_referer() );
+	exit();
+}
+
+add_screen_option( 'per_page', array( 'label' => _x( 'Users', 'users per page (screen options)' ) ) );
+
+$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id));
+$parent_file = 'sites.php';
+$submenu_file = 'sites.php';
+
+require('../admin-header.php'); ?>
+
+<div class="wrap">
+<?php screen_icon('ms-admin'); ?>
+<h2 id="edit-site"><?php echo $title ?></h2>
+<h3 class="nav-tab-wrapper">
+<?php
+$tabs = array(
+	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
+	'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
+	'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
+	'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
+);
+foreach ( $tabs as $tab_id => $tab ) {
+	$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
+	echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' .  esc_html( $tab['label'] ) . '</a>';
+}
+?>
+</h3><?php
+
+if ( isset($_GET['update']) ) :
+	switch($_GET['update']) {
+	case 'adduser':
+		echo '<div id="message" class="updated"><p>' . __( 'User added.' ) . '</p></div>';
+		break;
+	case 'err_add_member':
+		echo '<div id="message" class="error"><p>' . __( 'User is already a member of this site.' ) . '</p></div>';
+		break;
+	case 'err_add_notfound':
+		echo '<div id="message" class="error"><p>' . __( 'Enter the username of an existing user.' ) . '</p></div>';
+		break;
+	case 'promote':
+		echo '<div id="message" class="updated"><p>' . __( 'Changed roles.' ) . '</p></div>';
+		break;
+	case 'err_promote':
+		echo '<div id="message" class="error"><p>' . __( 'Select a user to change role.' ) . '</p></div>';
+		break;
+	case 'remove':
+		echo '<div id="message" class="updated"><p>' . __( 'User removed from this site.' ) . '</p></div>';
+		break;
+	case 'err_remove':
+		echo '<div id="message" class="error"><p>' . __( 'Select a user to remove.' ) . '</p></div>';
+		break;
+	case 'newuser':
+		echo '<div id="message" class="updated"><p>' . __( 'User created.' ) . '</p></div>';
+		break;
+	case 'err_new':
+		echo '<div id="message" class="error"><p>' . __( 'Enter the username and email.' ) . '</p></div>';
+		break;
+	case 'err_new_dup':
+		echo '<div id="message" class="error"><p>' . __( 'Duplicated username or email address.' ) . '</p></div>';
+		break;
+	}
+endif; ?>
+
+<form class="search-form" action="" method="get">
+<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
+<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+</form>
+
+<?php $wp_list_table->views(); ?>
+
+<form method="post" action="site-users.php?action=update-site">
+	<?php wp_nonce_field( 'edit-site' ); ?>
+	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+
+<?php $wp_list_table->display(); ?>
+
+</form>
+
+<?php do_action( 'network_site_users_after_list_table', '' );?>
+
+<?php if ( current_user_can( 'promote_users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) : ?>
+<h4 id="add-user"><?php _e('Add User to This Site') ?></h4>
+	<?php if ( current_user_can( 'create_users' ) && apply_filters( 'show_network_site_users_add_new_form', true ) ) : ?>
+<p><?php _e( 'You may add from existing network users, or set up a new user to add to this site.' ); ?></p>
+	<?php else : ?>
+<p><?php _e( 'You may add from existing network users to this site.' ); ?></p>
+	<?php endif; ?>
+<h5 id="add-existing-user"><?php _e('Add Existing User') ?></h5>
+<form action="site-users.php?action=adduser" id="adduser" method="post">
+	<?php wp_nonce_field( 'edit-site' ); ?>
+	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+	<table class="form-table">
+		<tr>
+			<th scope="row"><?php _e( 'Username' ); ?></th>
+			<td><input type="text" class="regular-text" name="newuser" id="newuser" /></td>
+		</tr>
+		<tr>
+			<th scope="row"><?php _e( 'Role'); ?></th>
+			<td><select name="new_role" id="new_role_0">
+			<?php
+			reset( $editblog_roles );
+			foreach ( $editblog_roles as $role => $role_assoc ){
+				$name = translate_user_role( $role_assoc['name'] );
+				$selected = ( $role == $default_role ) ? 'selected="selected"' : '';
+				echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
+			}
+			?>
+			</select></td>
+		</tr>
+	</table>
+	<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
+	<?php submit_button( __('Add User'), 'primary', 'add-user' ); ?>
+</form>
+<?php endif; ?>
+
+<?php if ( current_user_can( 'create_users' ) && apply_filters( 'show_network_site_users_add_new_form', true ) ) : ?>
+<h5 id="add-new-user"><?php _e('Add New User') ?></h5>
+<form action="<?php echo network_admin_url('site-users.php?action=newuser'); ?>" id="newuser" method="post">
+	<?php wp_nonce_field( 'edit-site' ); ?>
+	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
+	<table class="form-table">
+		<tr>
+			<th scope="row"><?php _e( 'Username' ) ?></th>
+			<td><input type="text" class="regular-text" name="user[username]" /></td>
+		</tr>
+		<tr>
+			<th scope="row"><?php _e( 'Email' ) ?></th>
+			<td><input type="text" class="regular-text" name="user[email]" /></td>
+		</tr>
+		<tr>
+			<th scope="row"><?php _e( 'Role'); ?></th>
+			<td><select name="new_role" id="new_role_0">
+			<?php
+			reset( $editblog_roles );
+			foreach ( $editblog_roles as $role => $role_assoc ){
+				$name = translate_user_role( $role_assoc['name'] );
+				$selected = ( $role == $default_role ) ? 'selected="selected"' : '';
+				echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
+			}
+			?>
+			</select></td>
+		</tr>
+		<tr class="form-field">
+			<td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
+		</tr>
+	</table>
+	<?php wp_nonce_field( 'add-user', '_wpnonce_add-new-user' ) ?>
+	<?php submit_button( __('Add New User'), 'primary', 'add-user' ); ?>
+</form>
+<?php endif; ?>
+</div>
+<?php
+require('../admin-footer.php');
Index: /tags/3.1/wp-admin/network/sites.php
===================================================================
--- /tags/3.1/wp-admin/network/sites.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/sites.php	(revision 17487)
@@ -0,0 +1,124 @@
+<?php
+/**
+ * Multisite sites administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can( 'manage_sites' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$wp_list_table = _get_list_table('WP_MS_Sites_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+
+$title = __( 'Sites' );
+$parent_file = 'sites.php';
+
+add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' .
+	'<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' .
+	'<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' .
+	'<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' .
+	'<li>' . __('Dashboard leads to the Dashboard for that site.') . '</li>' .
+	'<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' .
+	'<li>' . __('Delete which is a permanent action after the confirmation screens.') . '</li>' .
+	'<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' .
+	'<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' .
+	'<p>' . __('Clicking on bold settings can re-sort this table. The upper right icons switch between list and excerpt views.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screens" target="_blank">Documentation on Site Management</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
+
+$msg = '';
+if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
+	switch ( $_REQUEST['action'] ) {
+		case 'all_notspam':
+			$msg = __( 'Sites removed from spam.' );
+		break;
+		case 'all_spam':
+			$msg = __( 'Sites marked as spam.' );
+		break;
+		case 'all_delete':
+			$msg = __( 'Sites deleted.' );
+		break;
+		case 'delete':
+			$msg = __( 'Site deleted.' );
+		break;
+		case 'not_deleted':
+			$msg = __( 'You do not have permission to delete that site.' );
+		break;
+		case 'archive':
+			$msg = __( 'Site archived.' );
+		break;
+		case 'unarchive':
+			$msg = __( 'Site unarchived.' );
+		break;
+		case 'activate':
+			$msg = __( 'Site activated.' );
+		break;
+		case 'deactivate':
+			$msg = __( 'Site deactivated.' );
+		break;
+		case 'unspam':
+			$msg = __( 'Site removed from spam.' );
+		break;
+		case 'spam':
+			$msg = __( 'Site marked as spam.' );
+		break;
+		default:
+			$msg = apply_filters( 'network_sites_updated_message_' . $_REQUEST['action'] , __( 'Settings saved.' ) );
+		break;
+	}
+	if ( $msg )
+		$msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
+}
+
+$wp_list_table->prepare_items();
+
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+require_once( '../admin-header.php' );
+?>
+
+<div class="wrap">
+<?php screen_icon('ms-admin'); ?>
+<h2><?php _e('Sites') ?>
+<?php echo $msg; ?>
+<?php if ( current_user_can( 'create_sites') ) : ?>
+        <a href="<?php echo network_admin_url('site-new.php'); ?>" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
+<?php endif; ?>
+
+<?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
+	printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
+} ?>
+</h2>
+
+<form action="" method="get" id="ms-search">
+<?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
+<input type="hidden" name="action" value="blogs" />
+</form>
+
+<form id="form-site-list" action="edit.php?action=allblogs" method="post">
+	<?php $wp_list_table->display(); ?>
+</form>
+</div>
+<?php
+
+require_once( '../admin-footer.php' ); ?>
Index: /tags/3.1/wp-admin/network/theme-editor.php
===================================================================
--- /tags/3.1/wp-admin/network/theme-editor.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/theme-editor.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Theme editor network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../theme-editor.php' );
Index: /tags/3.1/wp-admin/network/theme-install.php
===================================================================
--- /tags/3.1/wp-admin/network/theme-install.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/theme-install.php	(revision 17487)
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Install theme network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+if ( isset( $_GET['tab'] ) && ( 'theme-information' == $_GET['tab'] ) )
+	define( 'IFRAME_REQUEST', true );
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../theme-install.php' );
Index: /tags/3.1/wp-admin/network/themes.php
===================================================================
--- /tags/3.1/wp-admin/network/themes.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/themes.php	(revision 17487)
@@ -0,0 +1,241 @@
+<?php
+/**
+ * Multisite themes administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+$menu_perms = get_site_option( 'menu_items', array() );
+
+if ( empty( $menu_perms['themes'] ) && ! is_super_admin() )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+if ( !current_user_can('manage_network_themes') )
+	wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) );
+
+$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+
+$action = $wp_list_table->current_action();
+
+$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
+
+// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
+$temp_args = array( 'enabled', 'disabled', 'deleted', 'error' );
+$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
+$referer = remove_query_arg( $temp_args, wp_get_referer() );
+
+if ( $action ) {
+	$allowed_themes = get_site_option( 'allowedthemes' );	
+	switch ( $action ) {
+		case 'enable':
+			check_admin_referer('enable-theme_' . $_GET['theme']);
+			$allowed_themes[ $_GET['theme'] ] = true;
+			update_site_option( 'allowedthemes', $allowed_themes );
+			wp_redirect( add_query_arg( 'enabled', '1', $referer ) );
+			exit;
+			break;
+		case 'disable':
+			check_admin_referer('disable-theme_' . $_GET['theme']);
+			unset( $allowed_themes[ $_GET['theme'] ] );
+			update_site_option( 'allowedthemes', $allowed_themes );
+			wp_redirect( add_query_arg( 'disabled', '1', $referer ) );
+			exit;
+			break;
+		case 'enable-selected':
+			check_admin_referer('bulk-themes');
+			$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
+			if ( empty($themes) ) {
+				wp_redirect( add_query_arg( 'error', 'none', $referer ) );
+				exit;
+			}
+			foreach( (array) $themes as $theme )
+				$allowed_themes[ $theme ] = true;
+			update_site_option( 'allowedthemes', $allowed_themes );
+			wp_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
+			exit;
+			break;
+		case 'disable-selected':
+			check_admin_referer('bulk-themes');
+			$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
+			if ( empty($themes) ) {
+				wp_redirect( add_query_arg( 'error', 'none', $referer ) );
+				exit;
+			}
+			foreach( (array) $themes as $theme )
+				unset( $allowed_themes[ $theme ] );
+			update_site_option( 'allowedthemes', $allowed_themes );
+			wp_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
+			exit;
+			break;
+		case 'delete-selected':
+			if ( ! current_user_can( 'delete_themes' ) )
+				wp_die( __('You do not have sufficient permissions to delete themes for this site.') );
+			check_admin_referer( 'bulk-themes' );
+
+			$themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
+
+			if ( isset( $themes[ get_option( 'template' ) ] ) )
+				unset( $themes[ get_option( 'template' ) ] );
+			if ( isset( $themes[ get_option( 'stylesheet' ) ] ) )
+				unset( $themes[ get_option( 'stylesheet' ) ] );
+
+			if ( empty( $themes ) ) {
+				wp_redirect( add_query_arg( 'error', 'none', $referer ) );
+				exit;
+			}
+
+			$main_theme = get_current_theme();
+			$files_to_delete = $theme_info = array();
+			foreach ( $themes as $key => $theme ) {
+				$data = get_theme_data( WP_CONTENT_DIR . '/themes/' . $theme . '/style.css' );
+				if ( $data['Name'] == $main_theme ) {
+					unset( $themes[$key] );
+				} else {
+					$files_to_delete = array_merge( $files_to_delete, list_files( WP_CONTENT_DIR . "/themes/$theme" ) );					
+					$theme_info[ $theme ] = $data;
+				}
+			}
+			
+			if ( empty( $themes ) ) {
+				wp_redirect( add_query_arg( 'error', 'main', $referer ) );
+				exit;
+			}
+
+			include(ABSPATH . 'wp-admin/update.php');
+
+			$parent_file = 'themes.php';
+
+			if ( ! isset( $_REQUEST['verify-delete'] ) ) {
+				wp_enqueue_script( 'jquery' );
+				require_once( ABSPATH . 'wp-admin/admin-header.php' );
+				?>
+			<div class="wrap">
+				<?php
+					$themes_to_delete = count( $themes );
+					screen_icon();
+					echo '<h2>' . _n( 'Delete Theme', 'Delete Themes', $themes_to_delete ) . '</h2>';
+				?>
+				<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This theme may be active on other sites in the network.', 'These themes may be active on other sites in the network.', $themes_to_delete ); ?></p></div>
+				<p><?php echo _n( 'You are about to remove the following theme:', 'You are about to remove the following themes:', $themes_to_delete ); ?></p>
+					<ul class="ul-disc">
+						<?php foreach ( $theme_info as $theme )
+							echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html( $theme['Name'] ), esc_html( $theme['AuthorName'] ) ), '</li>'; /* translators: 1: theme name, 2: theme author */ ?>
+					</ul>
+				<p><?php _e('Are you sure you wish to delete these themes?'); ?></p>
+				<form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
+					<input type="hidden" name="verify-delete" value="1" />
+					<input type="hidden" name="action" value="delete-selected" />
+					<?php
+						foreach ( (array) $themes as $theme )
+							echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />';
+					?>
+					<?php wp_nonce_field('bulk-themes') ?>
+					<?php submit_button( _n( 'Yes, Delete this theme', 'Yes, Delete these themes', $themes_to_delete ), 'button', 'submit', false ); ?>
+				</form>
+				<form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
+					<?php submit_button( __( 'No, Return me to the theme list' ), 'button', 'submit', false ); ?>
+				</form>
+
+				<p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
+				<div id="files-list" style="display:none;">
+					<ul class="code">
+					<?php
+						foreach ( (array) $files_to_delete as $file )
+							echo '<li>' . esc_html( str_replace( WP_CONTENT_DIR . "/themes", '', $file) ) . '</li>';
+					?>
+					</ul>
+				</div>
+			</div>
+				<?php
+				require_once(ABSPATH . 'wp-admin/admin-footer.php');
+				exit;
+			} // Endif verify-delete
+
+			foreach ( $themes as $theme )
+				$delete_result = delete_theme( $theme, esc_url( add_query_arg( array('verify-delete' => 1), $_SERVER['REQUEST_URI'] ) ) );
+			$paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1; 
+			wp_redirect( network_admin_url( "themes.php?deleted=".count( $themes )."&paged=$paged&s=$s" ) );
+			exit;
+			break;
+	}
+}
+
+$wp_list_table->prepare_items();
+
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+add_thickbox();
+
+add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' )) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.') . '</p>' .
+	'<p>' . __('If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site&#8217;s Appearance > Themes screen.') . '</p>' .
+	'<p>' . __('Themes can be enabled on a site by site basis by the network admin on the Edit Site screen you go to via the Edit action link on the Sites screen. Only network admins are able to install or edit themes.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Themes_Screen" target="_blank">Documentation on Network Themes</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$title = __('Themes');
+$parent_file = 'themes.php';
+
+require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+?>
+
+<div class="wrap">
+<?php screen_icon('themes'); ?>
+<h2><?php echo esc_html( $title ); if ( current_user_can('install_themes') ) { ?> <a href="theme-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'theme'); ?></a><?php }
+if ( $s ) 
+	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?> 
+</h2>
+
+<?php
+if ( isset( $_GET['enabled'] ) ) {
+	$_GET['enabled'] = absint( $_GET['enabled'] );
+	echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>';
+} elseif ( isset( $_GET['disabled'] ) ) {
+	$_GET['disabled'] = absint( $_GET['disabled'] );
+	echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>';
+} elseif ( isset( $_GET['deleted'] ) ) {
+	$_GET['deleted'] = absint( $_GET['deleted'] );
+	echo '<div id="message" class="updated"><p>' . sprintf( _nx( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'], 'network' ), number_format_i18n( $_GET['deleted'] ) ) . '</p></div>';
+} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
+	echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>';
+} elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {
+	echo '<div class="error"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
+}
+
+?>
+
+<form method="get" action="">
+<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
+</form>
+
+<?php $wp_list_table->views(); ?>
+
+<form method="post" action="">
+<input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" />
+<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
+
+<?php $wp_list_table->display(); ?>
+</form>
+
+</div>
+
+<?php
+include(ABSPATH . 'wp-admin/admin-footer.php');
Index: /tags/3.1/wp-admin/network/update-core.php
===================================================================
--- /tags/3.1/wp-admin/network/update-core.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/update-core.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Updates network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../update-core.php' );
Index: /tags/3.1/wp-admin/network/update.php
===================================================================
--- /tags/3.1/wp-admin/network/update.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/update.php	(revision 17487)
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Update/Install Plugin/Theme network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
+	define( 'IFRAME_REQUEST', true );
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../update.php' );
Index: /tags/3.1/wp-admin/network/upgrade.php
===================================================================
--- /tags/3.1/wp-admin/network/upgrade.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/upgrade.php	(revision 17487)
@@ -0,0 +1,86 @@
+<?php
+/**
+ * Multisite upgrade administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require_once( ABSPATH . WPINC . '/http.php' );
+
+$title = __( 'Update Network' );
+$parent_file = 'upgrade.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('Only use this screen once you have updated to a new version of WordPress through Dashboard > Updates. Clicking the Update Network button will step through each site in the network, five at a time, and make sure any database updates are applied.') . '</p>' .
+	'<p>' . __('If a version update to core has not happened, clicking this button won&#8217;t affect anything.') . '</p>' .
+	'<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Updates_Screen" target="_blank">Documentation on Update Network</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+require_once('../admin-header.php');
+
+if ( ! current_user_can( 'manage_network' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+echo '<div class="wrap">';
+screen_icon('tools');
+echo '<h2>' . __( 'Update Network' ) . '</h2>';
+
+$action = isset($_GET['action']) ? $_GET['action'] : 'show';
+
+switch ( $action ) {
+	case "upgrade":
+		$n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;
+
+		if ( $n < 5 ) {
+			global $wp_db_version;
+			update_site_option( 'wpmu_upgrade_site', $wp_db_version );
+		}
+
+		$blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A );
+		if ( empty( $blogs ) ) {
+			echo '<p>' . __( 'All done!' ) . '</p>';
+			break;
+		}
+		echo "<ul>";
+		foreach ( (array) $blogs as $details ) {
+			$siteurl = get_blog_option( $details['blog_id'], 'siteurl' );
+			echo "<li>$siteurl</li>";
+			$response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=upgrade_db", array( 'timeout' => 120, 'httpversion' => '1.1' ) );
+			if ( is_wp_error( $response ) )
+				wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>' ), $siteurl, $response->get_error_message() ) );
+			do_action( 'after_mu_upgrade', $response );
+			do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] );
+		}
+		echo "</ul>";
+		?><p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p>
+		<script type='text/javascript'>
+		<!--
+		function nextpage() {
+			location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>";
+		}
+		setTimeout( "nextpage()", 250 );
+		//-->
+		</script><?php
+	break;
+	case 'show':
+	default:
+		?><p><?php _e( 'You can update all the sites on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.' ); ?></p>
+		<p><a class="button" href="upgrade.php?action=upgrade"><?php _e("Update Network"); ?></a></p><?php
+		do_action( 'wpmu_upgrade_page' );
+	break;
+}
+?>
+</div>
+
+<?php include('../admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/network/user-edit.php
===================================================================
--- /tags/3.1/wp-admin/network/user-edit.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/user-edit.php	(revision 17487)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Edit user network administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+require( '../user-edit.php' );
Index: /tags/3.1/wp-admin/network/user-new.php
===================================================================
--- /tags/3.1/wp-admin/network/user-new.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/user-new.php	(revision 17487)
@@ -0,0 +1,94 @@
+<?php
+/**
+ * Add Site Administration Screen
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.1.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can('create_users') )
+	wp_die(__('You do not have sufficient permissions to add users to this network.'));
+
+
+add_contextual_help($current_screen,
+	'<p>' . __('Add User will set up a new user account on the network and send them an email with their username and password.') . '</p>' .
+	'<p>' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+if ( isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action'] ) {
+	check_admin_referer( 'add-user', '_wpnonce_add-user' );
+	if ( ! current_user_can( 'manage_network_users' ) )
+		wp_die( __( 'You do not have permission to access this page.' ) );
+
+	if ( is_array( $_POST['user'] ) == false )
+		wp_die( __( 'Cannot create an empty user.' ) );
+	$user = $_POST['user'];
+	if ( empty($user['username']) && empty($user['email']) )
+		wp_die( __( 'Missing username and email.' ) );
+	elseif ( empty($user['username']) )
+		wp_die( __( 'Missing username.' ) );
+	elseif ( empty($user['email']) )
+		wp_die( __( 'Missing email.' ) );
+
+	$password = wp_generate_password( 12, false);
+	$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
+
+	if ( false == $user_id )
+ 		wp_die( __( 'Duplicated username or email address.' ) );
+	else
+		wp_new_user_notification( $user_id, $password );
+		
+	wp_redirect( add_query_arg( array('update' => 'added'), 'user-new.php' ) );
+	exit;
+}
+
+if ( isset($_GET['update']) ) {
+	$messages = array();
+	if ( 'added' == $_GET['update'] )
+		$messages[] = __('User added.');
+}
+
+$title = __('Add New User');
+$parent_file = 'users.php';
+
+require('../admin-header.php'); ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
+<?php
+if ( ! empty( $messages ) ) {
+	foreach ( $messages as $msg )
+		echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
+} ?>
+	<form action="<?php echo network_admin_url('user-new.php?action=add-user'); ?>" id="adduser" method="post">	
+	<table class="form-table">
+		<tr class="form-field form-required">
+			<th scope="row"><?php _e( 'Username' ) ?></th>
+			<td><input type="text" class="regular-text" name="user[username]" /></td>
+		</tr>
+		<tr class="form-field form-required">
+			<th scope="row"><?php _e( 'Email' ) ?></th>
+			<td><input type="text" class="regular-text" name="user[email]" /></td>
+		</tr>
+		<tr class="form-field">
+			<td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
+		</tr>
+	</table>
+	<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
+	<?php submit_button( __('Add User'), 'primary', 'add-user' ); ?>
+	</form>
+</div>
+<?php
+require('../admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/network/users.php
===================================================================
--- /tags/3.1/wp-admin/network/users.php	(revision 17487)
+++ /tags/3.1/wp-admin/network/users.php	(revision 17487)
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Multisite users administration panel.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! is_multisite() )
+	wp_die( __( 'Multisite support is not enabled.' ) );
+
+if ( ! current_user_can( 'manage_network_users' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
+
+$wp_list_table = _get_list_table('WP_MS_Users_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+$wp_list_table->prepare_items();
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+$title = __( 'Users' );
+$parent_file = 'users.php';
+
+add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' .
+	'<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' .
+	'<p>' . __('You can also go to the user&#8217;s profile page by clicking on the individual username.') . '</p>' .
+	'<p>' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '</p>' .
+	'<p>' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '</p>' .
+	'<p>' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+require_once( '../admin-header.php' );
+
+if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
+	?>
+	<div id="message" class="updated"><p>
+		<?php
+		switch ( $_REQUEST['action'] ) {
+			case 'delete':
+				_e( 'User deleted.' );
+			break;
+			case 'all_spam':
+				_e( 'Users marked as spam.' );
+			break;
+			case 'all_notspam':
+				_e( 'Users removed from spam.' );
+			break;
+			case 'all_delete':
+				_e( 'Users deleted.' );
+			break;
+			case 'add':
+				_e( 'User added.' );
+			break;
+		}
+		?>
+	</p></div>
+	<?php
+}
+	?>
+<div class="wrap">
+	<?php screen_icon(); ?>
+	<h2><?php esc_html_e( 'Users' );
+	if ( current_user_can( 'create_users') ) : ?>
+		<a href="<?php echo network_admin_url('user-new.php'); ?>" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php
+	endif;
+	
+	if ( !empty( $usersearch ) )
+	printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $usersearch ) );
+	?>
+	</h2>
+
+	<?php $wp_list_table->views(); ?>
+
+	<form action="" method="get" class="search-form">
+		<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
+	</form>
+
+	<form id="form-user-list" action='edit.php?action=allusers' method='post'>
+		<?php $wp_list_table->display(); ?>
+	</form>
+</div>
+
+<?php require_once( '../admin-footer.php' ); ?>
Index: /tags/3.1/wp-admin/options-discussion.php
===================================================================
--- /tags/3.1/wp-admin/options-discussion.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-discussion.php	(revision 17487)
@@ -0,0 +1,248 @@
+<?php
+/**
+ * Discussion settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+$title = __('Discussion Settings');
+$parent_file = 'options-general.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won&#8217;t all fit here! :) Use the documentation link below to get information on what each discussion setting does.') . '</p>' .
+	'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Discussion_SubPanel" target="_blank">Documentation on Discussion Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include('./admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form method="post" action="options.php">
+<?php settings_fields('discussion'); ?>
+
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><?php _e('Default article settings') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Default article settings') ?></span></legend>
+<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.') ?></label>
+<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>
+<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 new articles') ?></label>
+<br />
+<small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Other comment settings') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Other comment settings') ?></span></legend>
+<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_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') ?>
+<?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?>
+</label>
+<br />
+
+<label for="close_comments_for_old_posts">
+<input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> />
+<?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . esc_attr(get_option('close_comments_days_old')) . '" class="small-text" />') ?>
+<br />
+<label for="thread_comments">
+<input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
+<?php
+
+$maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
+
+$thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">';
+for ( $i = 2; $i <= $maxdeep; $i++ ) {
+	$thread_comments_depth .= "<option value='" . esc_attr($i) . "'";
+	if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
+	$thread_comments_depth .= ">$i</option>";
+}
+$thread_comments_depth .= '</select>';
+
+printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
+
+?><br />
+<label for="page_comments">
+<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> />
+<?php
+
+$default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
+if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
+$default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
+if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
+$default_comments_page .= '>' . __('first') . '</option></select>';
+
+printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page );
+
+?></label>
+<br />
+<label for="comment_order"><?php
+
+$comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
+if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
+$comment_order .= '>' . __('older') . '</option><option value="desc"';
+if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
+$comment_order .= '>' . __('newer') . '</option></select>';
+
+printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order );
+
+?></label>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('E-mail me whenever') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever') ?></span></legend>
+<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>
+<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>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Before a comment appears') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears') ?></span></legend>
+<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>
+<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>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Comment Moderation') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation') ?></span></legend>
+<p><label for="comment_max_links"><?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" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ) ?></label></p>
+
+<p><label for="moderation_keys"><?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 &#8220;press&#8221; will match &#8220;WordPress&#8221;.') ?></label></p>
+<p>
+<textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea>
+</p>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Comment Blacklist') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist') ?></span></legend>
+<p><label for="blacklist_keys"><?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 &#8220;press&#8221; will match &#8220;WordPress&#8221;.') ?></label></p>
+<p>
+<textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
+</p>
+</fieldset></td>
+</tr>
+<?php do_settings_fields('discussion', 'default'); ?>
+</table>
+
+<h3><?php _e('Avatars') ?></h3>
+
+<p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites.  Here you can enable the display of avatars for people who comment on your site.'); ?></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><fieldset><legend class="screen-reader-text"><span><?php _e('Avatar Display') ?></span></legend>
+<?php
+	$yesorno = array( 0 => __( 'Don&#8217;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='" . esc_attr($key) . "' $selected/> $value</label><br />";
+	}
+?>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Maximum Rating') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating') ?></span></legend>
+
+<?php
+$ratings = array(
+	/* translators: Content suitability rating: http://bit.ly/89QxZA */
+	'G' => __('G &#8212; Suitable for all audiences'),
+	/* translators: Content suitability rating: http://bit.ly/89QxZA */
+	'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'),
+	/* translators: Content suitability rating: http://bit.ly/89QxZA */
+	'R' => __('R &#8212; Intended for adult audiences above 17'),
+	/* translators: Content suitability rating: http://bit.ly/89QxZA */
+	'X' => __('X &#8212; 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='" . esc_attr($key) . "' $selected/> $rating</label><br />";
+endforeach;
+?>
+
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Default Avatar') ?></th>
+<td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar') ?></span></legend>
+
+<?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
+
+<?php
+$avatar_defaults = array(
+	'mystery' => __('Mystery Man'),
+	'blank' => __('Blank'),
+	'gravatar_default' => __('Gravatar Logo'),
+	'identicon' => __('Identicon (Generated)'),
+	'wavatar' => __('Wavatar (Generated)'),
+	'monsterid' => __('MonsterID (Generated)'),
+	'retro' => __('Retro (Generated)')
+);
+$avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults);
+$default = get_option('avatar_default');
+if ( empty($default) )
+	$default = 'mystery';
+$size = 32;
+$avatar_list = '';
+foreach ( $avatar_defaults as $default_key => $default_name ) {
+	$selected = ($default == $default_key) ? 'checked="checked" ' : '';
+	$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key)  . "' {$selected}/> ";
+
+	$avatar = get_avatar( $user_email, $size, $default_key );
+	$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&amp;forcedefault=1'", $avatar);
+
+	$avatar_list .= ' ' . $default_name . '</label>';
+	$avatar_list .= '<br />';
+}
+echo apply_filters('default_avatar_select', $avatar_list);
+?>
+
+</fieldset></td>
+</tr>
+<?php do_settings_fields('discussion', 'avatars'); ?>
+</table>
+
+<?php do_settings_sections('discussion'); ?>
+
+<?php submit_button(); ?>
+</form>
+</div>
+
+<?php include('./admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/options-general.php
===================================================================
--- /tags/3.1/wp-admin/options-general.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-general.php	(revision 17487)
@@ -0,0 +1,355 @@
+<?php
+/**
+ * General settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+$title = __('General Settings');
+$parent_file = 'options-general.php';
+/* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */
+$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
+
+/**
+ * Display JavaScript on the page.
+ *
+ * @package WordPress
+ * @subpackage General_Settings_Screen
+ */
+function add_js() {
+?>
+<script type="text/javascript">
+//<![CDATA[
+	jQuery(document).ready(function($){
+		$("input[name='date_format']").click(function(){
+			if ( "date_format_custom_radio" != $(this).attr("id") )
+				$("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
+		});
+		$("input[name='date_format_custom']").focus(function(){
+			$("#date_format_custom_radio").attr("checked", "checked");
+		});
+
+		$("input[name='time_format']").click(function(){
+			if ( "time_format_custom_radio" != $(this).attr("id") )
+				$("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
+		});
+		$("input[name='time_format_custom']").focus(function(){
+			$("#time_format_custom_radio").attr("checked", "checked");
+		});
+		$("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
+			var format = $(this);
+			format.siblings('img').css('visibility','visible');
+			$.post(ajaxurl, {
+					action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
+					date : format.val()
+				}, function(d) { format.siblings('img').css('visibility','hidden'); format.siblings('.example').text(d); } );
+		});
+	});
+//]]>
+</script>
+<?php
+}
+add_action('admin_head', 'add_js');
+
+add_contextual_help($current_screen,
+	'<p>' . __('The fields on this screen determine some of the basics of your site setup.') . '</p>' .
+	'<p>' . __('Most themes display the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. The tagline is also displayed by many themes.') . '</p>' .
+	'<p>' . __('The WordPress URL and the Site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.') . '</p>' .
+	'<p>' . __('If you want site visitors to be able to register themselves, as opposed to being registered by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site administrator.') . '</p>' .
+	'<p>' . __('UTC means Coordinated Universal Time.') . '</p>' .
+	'<p>' . __('Remember to click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">Documentation on General Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include('./admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form method="post" action="options.php">
+<?php settings_fields('general'); ?>
+
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><label for="blogname"><?php _e('Site Title') ?></label></th>
+<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" class="regular-text" /></td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="blogdescription"><?php _e('Tagline') ?></label></th>
+<td><input name="blogdescription" type="text" id="blogdescription"  value="<?php form_option('blogdescription'); ?>" class="regular-text" />
+<span class="description"><?php _e('In a few words, explain what this site is about.') ?></span></td>
+</tr>
+<?php if ( !is_multisite() ) { ?>
+<tr valign="top">
+<th scope="row"><label for="siteurl"><?php _e('WordPress address (URL)') ?></label></th>
+<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) echo ' disabled' ?>" /></td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="home"><?php _e('Site address (URL)') ?></label></th>
+<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) echo ' disabled' ?>" />
+<span class="description"><?php _e('Enter the address here if you want your site homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></span></td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="admin_email"><?php _e('E-mail address') ?> </label></th>
+<td><input name="admin_email" type="text" id="admin_email" value="<?php form_option('admin_email'); ?>" class="regular-text" />
+<span class="description"><?php _e('This address is used for admin purposes, like new user notification.') ?></span></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Membership') ?></th>
+<td> <fieldset><legend class="screen-reader-text"><span><?php _e('Membership') ?></span></legend><label for="users_can_register">
+<input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_option('users_can_register')); ?> />
+<?php _e('Anyone can register') ?></label>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="default_role"><?php _e('New User Default Role') ?></label></th>
+<td>
+<select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select>
+</td>
+</tr>
+<?php } else { ?>
+<tr valign="top">
+<th scope="row"><label for="new_admin_email"><?php _e('E-mail address') ?> </label></th>
+<td><input name="new_admin_email" type="text" id="new_admin_email" value="<?php form_option('admin_email'); ?>" class="regular-text code" />
+<span class="description"><?php _e('This address is used for admin purposes. If you change this we will send you an e-mail at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>') ?></span>
+<?php
+$new_admin_email = get_option( 'new_admin_email' );
+if ( $new_admin_email && $new_admin_email != get_option('admin_email') ) : ?>
+<div class="updated inline">
+<p><?php printf( __('There is a pending change of the admin e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_admin_email, esc_url( admin_url( 'options.php?dismiss=new_admin_email' ) ) ); ?></p>
+</div>
+<?php endif; ?>
+</td>
+</tr>
+<?php } ?>
+<tr>
+<?php
+if ( !wp_timezone_supported() ) : // no magic timezone support here
+?>
+<th scope="row"><label for="gmt_offset"><?php _e('Timezone') ?> </label></th>
+<td>
+<select name="gmt_offset" id="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=\"" . esc_attr($offset) . "\"$selected>" . sprintf(__('UTC %s'), $offset_name) . '</option>';
+}
+?>
+</select>
+<?php _e('hours'); ?>
+<span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n( $time_format, false, 'gmt')); ?></span>
+<?php if ($current_offset) : ?>
+	<span id="local-time"><?php printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, date_i18n($time_format)); ?></span>
+<?php endif; ?>
+<br />
+<span class="description"><?php _e('Unfortunately, you have to manually update this for daylight saving time. The PHP Date/Time library is not supported by your web host.'); ?></span>
+</td>
+<?php
+else: // looks like we can do nice timezone selection!
+$current_offset = get_option('gmt_offset');
+$tzstring = get_option('timezone_string');
+
+$check_zone_info = true;
+
+// Remove old Etc mappings.  Fallback to gmt_offset.
+if ( false !== strpos($tzstring,'Etc/GMT') )
+	$tzstring = '';
+
+if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
+	$check_zone_info = false;
+	if ( 0 == $current_offset )
+		$tzstring = 'UTC+0';
+	elseif ($current_offset < 0)
+		$tzstring = 'UTC' . $current_offset;
+	else
+		$tzstring = 'UTC+' . $current_offset;
+}
+
+?>
+<th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
+<td>
+
+<select id="timezone_string" name="timezone_string">
+<?php echo wp_timezone_choice($tzstring); ?>
+</select>
+
+    <span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n($timezone_format, false, 'gmt')); ?></span>
+<?php if ( get_option('timezone_string') || !empty($current_offset) ) : ?>
+	<span id="local-time"><?php printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format)); ?></span>
+<?php endif; ?>
+<br />
+<span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
+<?php if ($check_zone_info && $tzstring) : ?>
+<br />
+<span>
+	<?php
+	// Set TZ so localtime works.
+	date_default_timezone_set($tzstring);
+	$now = localtime(time(), true);
+	if ( $now['tm_isdst'] )
+		_e('This timezone is currently in daylight saving time.');
+	else
+		_e('This timezone is currently in standard time.');
+	?>
+	<br />
+	<?php
+	if ( function_exists('timezone_transitions_get') ) {
+		$found = false;
+		$date_time_zone_selected = new DateTimeZone($tzstring);
+		$tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
+		$right_now = time();
+		foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) {
+			if ( $tr['ts'] > $right_now ) {
+			    $found = true;
+				break;
+			}
+		}
+
+		if ( $found ) {
+			echo ' ';
+			$message = $tr['isdst'] ?
+				__('Daylight saving time begins on: <code>%s</code>.') :
+				__('Standard time begins  on: <code>%s</code>.');
+			// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
+			printf( $message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts'] + ($tz_offset - $tr['offset']) ) );
+		} else {
+			_e('This timezone does not observe daylight saving time.');
+		}
+	}
+	// Set back to UTC.
+	date_default_timezone_set('UTC');
+	?>
+	</span>
+<?php endif; ?>
+</td>
+
+<?php endif; ?>
+</tr>
+<tr>
+<th scope="row"><?php _e('Date Format') ?></th>
+<td>
+	<fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend>
+<?php
+
+	$date_formats = apply_filters( 'date_formats', array(
+		__('F j, Y'),
+		'Y/m/d',
+		'm/d/Y',
+		'd/m/Y',
+	) );
+
+	$custom = true;
+
+	foreach ( $date_formats as $format ) {
+		echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='date_format' value='" . esc_attr($format) . "'";
+		if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "==="
+			echo " checked='checked'";
+			$custom = false;
+		}
+		echo ' /> <span>' . date_i18n( $format ) . "</span></label><br />\n";
+	}
+
+	echo '	<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
+	checked( $custom );
+	echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . esc_attr( get_option('date_format') ) . '" class="small-text" /> <span class="example"> ' . date_i18n( get_option('date_format') ) . "</span> <img class='ajax-loading' src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' />\n";
+
+	echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.') . "</p>\n";
+?>
+	</fieldset>
+</td>
+</tr>
+<tr>
+<th scope="row"><?php _e('Time Format') ?></th>
+<td>
+	<fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend>
+<?php
+
+	$time_formats = apply_filters( 'time_formats', array(
+		__('g:i a'),
+		'g:i A',
+		'H:i',
+	) );
+
+	$custom = true;
+
+	foreach ( $time_formats as $format ) {
+		echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='time_format' value='" . esc_attr($format) . "'";
+		if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "==="
+			echo " checked='checked'";
+			$custom = false;
+		}
+		echo ' /> <span>' . date_i18n( $format ) . "</span></label><br />\n";
+	}
+
+	echo '	<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
+	checked( $custom );
+	echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . esc_attr( get_option('time_format') ) . '" class="small-text" /> <span class="example"> ' . date_i18n( get_option('time_format') ) . "</span> <img class='ajax-loading' src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' />\n";
+	;
+?>
+	</fieldset>
+</td>
+</tr>
+<tr>
+<th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></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='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
+endfor;
+?>
+</select></td>
+</tr>
+<?php do_settings_fields('general', 'default'); ?>
+<?php
+	$languages = get_available_languages();
+	if ( is_multisite() && !empty( $languages ) ):
+?>
+	<tr valign="top">
+		<th width="33%" scope="row"><?php _e('Site language:') ?></th>
+		<td>
+			<select name="WPLANG" id="WPLANG">
+				<?php mu_dropdown_languages( $languages, get_option('WPLANG') ); ?>
+			</select>
+		</td>
+	</tr>
+<?php
+	endif;
+?>
+</table>
+
+<?php do_settings_sections('general'); ?>
+
+<?php submit_button(); ?>
+</form>
+
+</div>
+
+<?php include('./admin-footer.php') ?>
Index: /tags/3.1/wp-admin/options-head.php
===================================================================
--- /tags/3.1/wp-admin/options-head.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-head.php	(revision 17487)
@@ -0,0 +1,21 @@
+<?php
+/**
+ * WordPress Options Header.
+ *
+ * Resets variables: 'action', 'standalone', and 'option_group_id'. Displays
+ * updated message, if updated variable is part of the URL query.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+wp_reset_vars(array('action', 'standalone', 'option_group_id'));
+
+if ( isset( $_GET['updated'] ) && isset( $_GET['page'] ) ) {
+	// For backwards compat with plugins that don't use the Settings API and just set updated=1 in the redirect
+	add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
+}
+
+settings_errors();
+
+?>
Index: /tags/3.1/wp-admin/options-media.php
===================================================================
--- /tags/3.1/wp-admin/options-media.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-media.php	(revision 17487)
@@ -0,0 +1,141 @@
+<?php
+/**
+ * Media settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+$title = __('Media Settings');
+$parent_file = 'options-general.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '</p>' .
+	'<p>' . __('The Embed option allows you embed a video, image, or other media content into your content automatically by typing the URL (of the web page where the file lives) on its own line when you create your content.') . '</p>' .
+	( is_multisite() ? '' : '<p>' . __('Uploading Options gives you folder and path choices for storing your files in your installation&#8217;s directory.') . '</p>' ) .
+	'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Media_SubPanel" target="_blank">Documentation on Media Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include('./admin-header.php');
+
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form action="options.php" method="post">
+<?php settings_fields('media'); ?>
+
+<h3><?php _e('Image sizes') ?></h3>
+<p><?php _e('The sizes listed below determine the maximum dimensions in pixels 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('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'); ?>" class="small-text" />
+<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'); ?>" class="small-text" /><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 valign="top">
+<th scope="row"><?php _e('Medium size') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Medium size'); ?></span></legend>
+<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'); ?>" class="small-text" />
+<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'); ?>" class="small-text" />
+</fieldset></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e('Large size') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Large size'); ?></span></legend>
+<label for="large_size_w"><?php _e('Max Width'); ?></label>
+<input name="large_size_w" type="text" id="large_size_w" value="<?php form_option('large_size_w'); ?>" class="small-text" />
+<label for="large_size_h"><?php _e('Max Height'); ?></label>
+<input name="large_size_h" type="text" id="large_size_h" value="<?php form_option('large_size_h'); ?>" class="small-text" />
+</fieldset></td>
+</tr>
+
+<?php do_settings_fields('media', 'default'); ?>
+</table>
+
+<h3><?php _e('Embeds') ?></h3>
+
+<table class="form-table">
+
+<tr valign="top">
+<th scope="row"><?php _e('Auto-embeds'); ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('When possible, embed the media content from a URL directly onto the page. For example: links to Flickr and YouTube.'); ?></span></legend>
+<label for="embed_autourls"><input name="embed_autourls" type="checkbox" id="embed_autourls" value="1" <?php checked( '1', get_option('embed_autourls') ); ?>/> <?php _e('When possible, embed the media content from a URL directly onto the page. For example: links to Flickr and YouTube.'); ?></label>
+</fieldset></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><?php _e('Maximum embed size') ?></th>
+<td>
+<label for="embed_size_w"><?php _e('Width'); ?></label>
+<input name="embed_size_w" type="text" id="embed_size_w" value="<?php form_option('embed_size_w'); ?>" class="small-text" />
+<label for="embed_size_h"><?php _e('Height'); ?></label>
+<input name="embed_size_h" type="text" id="embed_size_h" value="<?php form_option('embed_size_h'); ?>" class="small-text" />
+<?php if ( !empty($content_width) ) echo '<br />' . __("If the width value is left blank, embeds will default to the max width of your theme."); ?>
+</td>
+</tr>
+
+<?php do_settings_fields('media', 'embeds'); ?>
+</table>
+
+<?php if ( !is_multisite() ) : ?>
+<h3><?php _e('Uploading Files'); ?></h3>
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
+<td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" />
+<span class="description"><?php _e('Default is <code>wp-content/uploads</code>'); ?></span>
+</td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><label for="upload_url_path"><?php _e('Full URL path to files'); ?></label></th>
+<td><input name="upload_url_path" type="text" id="upload_url_path" value="<?php echo esc_attr( get_option('upload_url_path')); ?>" class="regular-text code" />
+<span class="description"><?php _e('Configuring this is optional. By default, it should be blank.'); ?></span>
+</td>
+</tr>
+
+<tr>
+<th scope="row" colspan="2" class="th-full">
+<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>
+</th>
+</tr>
+
+<?php do_settings_fields('media', 'uploads'); ?>
+</table>
+<?php endif; ?>
+
+<?php do_settings_sections('media'); ?>
+
+<?php submit_button(); ?>
+
+</form>
+
+</div>
+
+<?php include('./admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/options-permalink.php
===================================================================
--- /tags/3.1/wp-admin/options-permalink.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-permalink.php	(revision 17487)
@@ -0,0 +1,260 @@
+<?php
+/**
+ * Permalink settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+$title = __('Permalink Settings');
+$parent_file = 'options-general.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen provides some common options for your default permalinks URL structure.') . '</p>' .
+	'<p>' . __('If you pick an option other than Default, your general URL path with structure tags, terms surrounded by <code>%</code>, will also appear in the custom structure field and your path can be further modified there.') . '</p>' .
+	'<p>' . __('When you assign multiple categories or tags to a post, only one can show up in the permalink: the lowest numbered category. This applies if your custom structure includes <code>%category%</code> or <code>%tag%</code>.') . '</p>' .
+	'<p>' . __('Note that permalinks beginning with the category, tag, author or postname structure tags require more advanced server resources. Double-check your hosting details to make sure those are in place or start your permalinks with other structure tags.') . '</p>' .
+	'<p>' . __('The Optional fields let you customize the &#8220;category&#8221; and &#8220;tag&#8221; base names that will appear in archive URLs. For example, the page listing all posts in the &#8220;Uncategorized&#8221; category could be <code>/topics/uncategorized</code> instead of <code>/category/uncategorized</code>.') . '</p>' .
+	'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Permalinks_SubPanel" target="_blank">Documentation on Permalinks Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Using_Permalinks" target="_blank">Documentation on Using Permalinks</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+/**
+ * Display JavaScript on the page.
+ *
+ * @package WordPress
+ * @subpackage Permalink_Settings_Panel
+ */
+function add_js() {
+	?>
+<script type="text/javascript">
+//<![CDATA[
+jQuery(document).ready(function() {
+	jQuery('input:radio.tog').change(function() {
+		if ( 'custom' == this.value )
+			return;
+		jQuery('#permalink_structure').val( this.value );
+	});
+	jQuery('#permalink_structure').focus(function() {
+		jQuery("#custom_selection").attr('checked', 'checked');
+	});
+});
+//]]>
+</script>
+<?php
+}
+add_filter('admin_head', 'add_js');
+
+include('./admin-header.php');
+
+$home_path = get_home_path();
+$iis7_permalinks = iis7_supports_permalinks();
+
+$prefix = $blog_prefix = '';
+if ( ! got_mod_rewrite() && ! $iis7_permalinks )
+	$prefix = '/index.php';
+if ( is_multisite() && !is_subdomain_install() && is_main_site() )
+	$blog_prefix = '/blog';
+
+if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
+	check_admin_referer('update-permalink');
+
+	if ( isset( $_POST['permalink_structure'] ) ) {
+		if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] )
+			$permalink_structure = $_POST['selection'];
+		else
+			$permalink_structure = $_POST['permalink_structure'];
+
+		if ( ! empty( $permalink_structure ) ) {
+			$permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
+			if ( $prefix && $blog_prefix )
+				$permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
+			else
+				$permalink_structure = $blog_prefix . $permalink_structure;
+		}
+		$wp_rewrite->set_permalink_structure( $permalink_structure );
+	}
+
+	if ( isset( $_POST['category_base'] ) ) {
+		$category_base = $_POST['category_base'];
+		if ( ! empty( $category_base ) )
+			$category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
+		$wp_rewrite->set_category_base( $category_base );
+	}
+
+	if ( isset( $_POST['tag_base'] ) ) {
+		$tag_base = $_POST['tag_base'];
+		if ( ! empty( $tag_base ) )
+			$tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
+		$wp_rewrite->set_tag_base( $tag_base );
+	}
+
+	create_initial_taxonomies();
+}
+
+$permalink_structure = get_option('permalink_structure');
+$category_base = get_option('category_base');
+$tag_base = get_option( 'tag_base' );
+
+if ( $iis7_permalinks ) {
+	if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
+		$writable = true;
+	else
+		$writable = false;
+} else {
+	if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') )
+		$writable = true;
+	else
+		$writable = false;
+}
+
+if ( $wp_rewrite->using_index_permalinks() )
+	$usingpi = true;
+else
+	$usingpi = false;
+
+$wp_rewrite->flush_rules();
+
+
+if (isset($_POST['submit'])) : ?>
+<div id="message" class="updated"><p><?php
+if ( ! is_multisite() ) {
+	if ( $iis7_permalinks ) {
+		if ( $permalink_structure && ! $usingpi && ! $writable )
+			_e('You should update your web.config now');
+		else if ( $permalink_structure && ! $usingpi && $writable )
+			_e('Permalink structure updated. Remove write access on web.config file now!');
+		else
+			_e('Permalink structure updated');
+	} else {
+		if ( $permalink_structure && ! $usingpi && ! $writable )
+			_e('You should update your .htaccess now.');
+		else
+			_e('Permalink structure updated.');
+	}
+} else {
+	_e('Permalink structure updated.');
+}
+?>
+</p></div>
+<?php endif; ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form name="form" action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
+
+  <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
+if ( is_multisite() && !is_subdomain_install() && is_main_site() ) {
+	$permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
+	$category_base = preg_replace( '|^/?blog|', '', $category_base );
+	$tag_base = preg_replace( '|^/?blog|', '', $tag_base );
+}
+
+$structures = array(
+	'',
+	$prefix . '/%year%/%monthnum%/%day%/%postname%/',
+	$prefix . '/%year%/%monthnum%/%postname%/',
+	$prefix . '/archives/%post_id%'
+	);
+?>
+<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 esc_attr($structures[1]); ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> /> <?php _e('Day and name'); ?></label></th>
+		<td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></td>
+	</tr>
+	<tr>
+		<th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[2]); ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> /> <?php _e('Month and name'); ?></label></th>
+		<td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . date('Y') . '/' . date('m') . '/sample-post/'; ?></code></td>
+	</tr>
+	<tr>
+		<th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[3]); ?>" class="tog" <?php checked($structures[3], $permalink_structure); ?> /> <?php _e('Numeric'); ?></label></th>
+		<td><code><?php echo get_option('home') . $blog_prefix . $prefix; ?>/archives/123</code></td>
+	</tr>
+	<tr>
+		<th>
+			<label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" <?php checked( !in_array($permalink_structure, $structures) ); ?> />
+			<?php _e('Custom Structure'); ?>
+			</label>
+		</th>
+		<td>
+			<?php echo $blog_prefix; ?>
+			<input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
+		</td>
+	</tr>
+</table>
+
+<h3><?php _e('Optional'); ?></h3>
+<?php if ( $is_apache || $iis7_permalinks ) : ?>
+	<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 <kbd>topics</kbd> 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 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; ?>
+
+<table class="form-table">
+	<tr>
+		<th><label for="category_base"><?php /* translators: prefix for category permalinks */ _e('Category base'); ?></label></th>
+		<td><?php echo $blog_prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td>
+	</tr>
+	<tr>
+		<th><label for="tag_base"><?php _e('Tag base'); ?></label></th>
+		<td><?php echo $blog_prefix; ?> <input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr($tag_base); ?>" class="regular-text code" /></td>
+	</tr>
+	<?php do_settings_fields('permalink', 'optional'); ?>
+</table>
+
+<?php do_settings_sections('permalink'); ?>
+
+<?php submit_button(); ?>
+  </form>
+<?php if ( !is_multisite() ) { ?>
+<?php if ( $iis7_permalinks ) :
+	if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) :
+		if ( file_exists($home_path . 'web.config') ) : ?>
+<p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.') ?></p>
+<form action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
+	<p><textarea rows="9" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea></p>
+</form>
+<p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.')  ?></p>
+		<?php else : ?>
+<p><?php _e('If the root directory of your site were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so this is the url rewrite rule you should have in your <code>web.config</code> file. Create a new file, called <code>web.config</code> in the root directory of your site. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this code into the <code>web.config</code> file.') ?></p>
+<form action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
+	<p><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules(true) ); ?></textarea></p>
+</form>
+<p><?php _e('If you temporarily make your site&#8217;s root directory writable for us to generate the <code>web.config</code> file automatically, do not forget to revert the permissions after the file has been created.')  ?></p>
+		<?php endif; ?>
+	<?php endif; ?>
+<?php else :
+	if ( $permalink_structure && ! $usingpi && ! $writable ) : ?>
+<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&#8217;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="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea></p>
+</form>
+	<?php endif; ?>
+<?php endif; ?>
+<?php } // multisite ?>
+
+</div>
+
+<?php require('./admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/options-privacy.php
===================================================================
--- /tags/3.1/wp-admin/options-privacy.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-privacy.php	(revision 17487)
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Privacy Options Settings Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+$title = __('Privacy Settings');
+$parent_file = 'options-general.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('You can choose whether or not your site will be crawled by robots, ping services, and spiders. If you want those services to ignore your site, click the second option here. Note that your privacy is not complete; your site is still visible on the web.') . '</p>' .
+	'<p>' . __('When this setting is in effect a reminder is shown in the header of these administration screens that says, &#8220;Search Engines Blocked,&#8221; to remind you that your site is not being crawled.') . '</p>' .
+	'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Privacy_SubPanel" target="_blank">Documentation on Privacy Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include('./admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form method="post" action="options.php">
+<?php settings_fields('privacy'); ?>
+
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><?php _e('Site Visibility') ?> </th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Site Visibility') ?> </span></legend>
+<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 site to be visible to everyone, including search engines (like Google, Bing, Technorati) and archivers');?></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>
+<?php do_action('blog_privacy_selector'); ?>
+</fieldset></td>
+</tr>
+<?php do_settings_fields('privacy', 'default'); ?>
+</table>
+
+<?php do_settings_sections('privacy'); ?>
+
+<?php submit_button(); ?>
+</form>
+
+</div>
+
+<?php include('./admin-footer.php') ?>
Index: /tags/3.1/wp-admin/options-reading.php
===================================================================
--- /tags/3.1/wp-admin/options-reading.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-reading.php	(revision 17487)
@@ -0,0 +1,131 @@
+<?php
+/**
+ * Reading settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+$title = __( 'Reading Settings' );
+$parent_file = 'options-general.php';
+
+/**
+ * Display JavaScript on the page.
+ *
+ * @package WordPress
+ * @subpackage Reading_Settings_Screen
+ */
+function add_js() {
+?>
+<script type="text/javascript">
+//<![CDATA[
+	jQuery(document).ready(function($){
+		var section = $('#front-static-pages'),
+			staticPage = section.find('input:radio[value="page"]'),
+			selects = section.find('select'),
+			check_disabled = function(){
+				selects.attr('disabled', staticPage.is(':checked') ? '' : 'disabled');
+			};
+		check_disabled();
+ 		section.find('input:radio').change(check_disabled);
+	});
+//]]>
+</script>
+<?php
+}
+add_action('admin_head', 'add_js');
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen contains the settings that affect the display of your content.') . '</p>' .
+	'<p>' . sprintf(__('You can choose what&#8217;s displayed on the front page of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static home page, you first need to create two <a href="%s">Pages</a>. One will become the front page, and the other will be where your posts are displayed.'), 'post-new.php?post_type=page') . '</p>' .
+	'<p>' . __('You can also control the display of your content in RSS feeds, including the maximum numbers of posts to display, whether to show full text or a summary, and the character set encoding.') . '</p>' .
+	'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Reading_SubPanel" target="_blank">Documentation on Reading Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include( './admin-header.php' );
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form name="form1" method="post" action="options.php">
+<?php settings_fields( 'reading' ); ?>
+
+<?php if ( ! get_pages() ) : ?>
+<input name="show_on_front" type="hidden" value="posts" />
+<table class="form-table">
+<?php
+	if ( 'posts' != get_option( 'show_on_front' ) ) :
+		update_option( 'show_on_front', 'posts' );
+	endif;
+
+else :
+	if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) )
+		update_option( 'show_on_front', 'posts' );
+?>
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><?php _e( 'Front page displays' ); ?></th>
+<td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Front page displays' ); ?></span></legend>
+	<p><label>
+		<input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
+		<?php _e( 'Your latest posts' ); ?>
+	</label>
+	</p>
+	<p><label>
+		<input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
+		<?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
+	</label>
+	</p>
+<ul>
+	<li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>
+	<li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li>
+</ul>
+<?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
+<div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
+<?php endif; ?>
+</fieldset></td>
+</tr>
+<?php endif; ?>
+<tr valign="top">
+<th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
+<td>
+<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option( 'posts_per_page' ); ?>" class="small-text" /> <?php _e( 'posts' ); ?>
+</td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
+<td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option( 'posts_per_rss' ); ?>" class="small-text" /> <?php _e( 'items' ); ?></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e( 'For each article in a feed, show' ); ?> </th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'For each article in a feed, show' ); ?> </span></legend>
+<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>
+</fieldset></td>
+</tr>
+
+<tr valign="top">
+<th scope="row"><label for="blog_charset"><?php _e( 'Encoding for pages and feeds' ); ?></label></th>
+<td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option( 'blog_charset' ); ?>" class="regular-text" />
+<span class="description"><?php _e( 'The <a href="http://codex.wordpress.org/Glossary#Character_set">character encoding</a> of your site (UTF-8 is recommended, if you are adventurous there are some <a href="http://en.wikipedia.org/wiki/Character_set">other encodings</a>)' ); ?></span></td>
+</tr>
+<?php do_settings_fields( 'reading', 'default' ); ?>
+</table>
+
+<?php do_settings_sections( 'reading' ); ?>
+
+<?php submit_button(); ?>
+</form>
+</div>
+<?php include( './admin-footer.php' ); ?>
Index: /tags/3.1/wp-admin/options-writing.php
===================================================================
--- /tags/3.1/wp-admin/options-writing.php	(revision 17487)
+++ /tags/3.1/wp-admin/options-writing.php	(revision 17487)
@@ -0,0 +1,172 @@
+<?php
+/**
+ * Writing settings administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can( 'manage_options' ) )
+	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
+
+$title = __('Writing Settings');
+$parent_file = 'options-general.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('You can submit content in several different ways; this screen holds the settings for all of them. The top section controls the editor within these administration screens, while the rest control external publishing methods. For more information on any of these methods, use the documentation links below.') . '</p>' .
+	'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Settings_Writing_SubPanel" target="_blank">Documentation on Writing Settings</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include('./admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form method="post" action="options.php">
+<?php settings_fields('writing'); ?>
+
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><label for="default_post_edit_rows"> <?php _e('Size of the post box') ?></label></th>
+<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" class="small-text" />
+<?php _e('lines') ?></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Formatting') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Formatting') ?></span></legend>
+<label for="use_smilies">
+<input name="use_smilies" type="checkbox" id="use_smilies" value="1" <?php checked('1', get_option('use_smilies')); ?> />
+<?php _e('Convert emoticons like <code>:-)</code> and <code>:-P</code> to graphics on display') ?></label><br />
+<label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked('1', get_option('use_balanceTags')); ?> /> <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label>
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="default_category"><?php _e('Default Post Category') ?></label></th>
+<td>
+<?php
+wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_category', 'orderby' => 'name', 'selected' => get_option('default_category'), 'hierarchical' => true));
+?>
+</td>
+</tr>
+<?php
+if ( current_theme_supports( 'post-formats' ) ) :
+	$post_formats = get_theme_support( 'post-formats' );
+	if ( is_array( $post_formats[0] ) ) :
+?>
+<tr valign="top">
+<th scope="row"><label for="default_post_format"><?php _e('Default Post Format') ?></label></th>
+<td>
+	<select name="default_post_format" id="default_post_format">
+		<option value="0"><?php _e('Standard'); ?></option>
+<?php foreach ( $post_formats[0] as $format ): ?>
+		<option<?php selected( get_option('default_post_format'), $format ); ?> value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
+<?php endforeach; ?>
+	</select></label>
+</td>
+</tr>
+<?php endif; endif; ?>
+<tr valign="top">
+<th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th>
+<td>
+<?php
+wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_link_category', 'orderby' => 'name', 'selected' => get_option('default_link_category'), 'hierarchical' => true, 'taxonomy' => 'link_category'));
+?>
+</td>
+</tr>
+<?php do_settings_fields('writing', 'default'); ?>
+</table>
+
+
+<h3 class="title"><?php _e('Press This') ?></h3>
+<p><?php _e('Press This is a bookmarklet: a little app that runs in your browser and lets you grab bits of the web.');?></p>
+<p><?php _e('Use Press This to clip text, images and videos from any web page. Then edit and add more straight from Press This before you save or publish it in a post on your site.'); ?></p>
+<p><?php _e('Drag-and-drop the following link to your bookmarks bar or right click it and add it to your favorites for a posting shortcut.') ?></p>
+<p class="pressthis"><a href="<?php echo htmlspecialchars( get_shortcut_link() ); ?>" title="<?php echo esc_attr(__('Press This')) ?>"><?php _e('Press This') ?></a></p>
+
+<?php if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { ?>
+<h3><?php _e('Post via e-mail') ?></h3>
+<p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it&#8217;s a good idea to keep this address very secret. Here are three random strings you could use: <kbd>%s</kbd>, <kbd>%s</kbd>, <kbd>%s</kbd>.'), wp_generate_password(8, false), wp_generate_password(8, false), wp_generate_password(8, false)) ?></p>
+
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><label for="mailserver_url"><?php _e('Mail Server') ?></label></th>
+<td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option('mailserver_url'); ?>" class="regular-text code" />
+<label for="mailserver_port"><?php _e('Port') ?></label>
+<input name="mailserver_port" type="text" id="mailserver_port" value="<?php form_option('mailserver_port'); ?>" class="small-text" />
+</td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="mailserver_login"><?php _e('Login Name') ?></label></th>
+<td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option('mailserver_login'); ?>" class="regular-text" /></td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="mailserver_pass"><?php _e('Password') ?></label></th>
+<td>
+<input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option('mailserver_pass'); ?>" class="regular-text" />
+</td>
+</tr>
+<tr valign="top">
+<th scope="row"><label for="default_email_category"><?php _e('Default Mail Category') ?></label></th>
+<td>
+<?php
+wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_category', 'orderby' => 'name', 'selected' => get_option('default_email_category'), 'hierarchical' => true));
+?>
+</td>
+</tr>
+<?php do_settings_fields('writing', 'post_via_email'); ?>
+</table>
+<?php } ?>
+
+<h3><?php _e('Remote Publishing') ?></h3>
+<p><?php printf(__('To post to WordPress from a desktop blogging client or remote website that uses the Atom Publishing Protocol or one of the XML-RPC publishing interfaces you must enable them below.')) ?></p>
+<table class="form-table">
+<tr valign="top">
+<th scope="row"><?php _e('Atom Publishing Protocol') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Atom Publishing Protocol') ?></span></legend>
+<label for="enable_app">
+<input name="enable_app" type="checkbox" id="enable_app" value="1" <?php checked('1', get_option('enable_app')); ?> />
+<?php _e('Enable the Atom Publishing Protocol.') ?></label><br />
+</fieldset></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('XML-RPC') ?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('XML-RPC') ?></span></legend>
+<label for="enable_xmlrpc">
+<input name="enable_xmlrpc" type="checkbox" id="enable_xmlrpc" value="1" <?php checked('1', get_option('enable_xmlrpc')); ?> />
+<?php _e('Enable the WordPress, Movable Type, MetaWeblog and Blogger XML-RPC publishing protocols.') ?></label><br />
+</fieldset></td>
+</tr>
+<?php do_settings_fields('writing', 'remote_publishing'); ?>
+</table>
+
+<?php if ( apply_filters( 'enable_update_services_configuration', true ) ) { ?>
+<h3><?php _e('Update Services') ?></h3>
+
+<?php if ( get_option('blog_public') ) : ?>
+
+<p><label for="ping_sites"><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service <abbr title="Universal Resource Locator">URL</abbr>s with line breaks.') ?></label></p>
+
+<textarea name="ping_sites" id="ping_sites" class="large-text code" rows="3"><?php echo esc_textarea( get_option('ping_sites') ); ?></textarea>
+
+<?php else : ?>
+
+	<p><?php printf(__('WordPress is not notifying any <a href="http://codex.wordpress.org/Update_Services">Update Services</a> because of your site&#8217;s <a href="%s">privacy settings</a>.'), 'options-privacy.php'); ?></p>
+
+<?php endif; ?>
+<?php } // multisite ?>
+
+<?php do_settings_sections('writing'); ?>
+
+<?php submit_button(); ?>
+</form>
+</div>
+
+<?php include('./admin-footer.php') ?>
Index: /tags/3.1/wp-admin/options.php
===================================================================
--- /tags/3.1/wp-admin/options.php	(revision 17487)
+++ /tags/3.1/wp-admin/options.php	(revision 17487)
@@ -0,0 +1,223 @@
+<?php
+/**
+ * Options Management Administration Panel.
+ *
+ * If accessed directly in a browser this page shows a list of all saved options
+ * along with editable fields for their values. Serialized data is not supported
+ * and there is no way to remove options via this page. It is not linked to from
+ * anywhere else in the admin.
+ *
+ * This file is also the target of the forms in core and custom options pages
+ * that use the Settings API. In this case it saves the new option values
+ * and returns the user to their page of origin.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+$title = __('Settings');
+$this_file = 'options.php';
+$parent_file = 'options-general.php';
+
+wp_reset_vars(array('action', 'option_page'));
+
+if ( empty($option_page) ) // This is for back compat and will eventually be removed.
+	$option_page = 'options';
+
+if ( !current_user_can('manage_options') )
+	wp_die(__('Cheatin&#8217; uh?'));
+
+// Handle admin email change requests
+if ( is_multisite() ) {
+	if ( ! empty($_GET[ 'adminhash' ] ) ) {
+		$new_admin_details = get_option( 'adminhash' );
+		$redirect = 'options-general.php?updated=false';
+		if ( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && !empty($new_admin_details[ 'newemail' ]) ) {
+			update_option( 'admin_email', $new_admin_details[ 'newemail' ] );
+			delete_option( 'adminhash' );
+			delete_option( 'new_admin_email' );
+			$redirect = 'options-general.php?updated=true';
+		}
+		wp_redirect( admin_url( $redirect ) );
+		exit;
+	} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) {
+		delete_option( 'adminhash' );
+		delete_option( 'new_admin_email' );
+		wp_redirect( admin_url( 'options-general.php?updated=true' ) );
+		exit;
+	}
+}
+
+if ( is_multisite() && !is_super_admin() && 'update' != $action )
+	wp_die(__('Cheatin&#8217; uh?'));
+
+$whitelist_options = array(
+	'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
+	'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', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
+	'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ),
+	'privacy' => array( 'blog_public' ),
+	'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
+	'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ),
+	'options' => array( '' ) );
+
+$mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
+$uploads_options = array('uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path');
+
+if ( !is_multisite() ) {
+	if ( !defined( 'WP_SITEURL' ) )
+		$whitelist_options['general'][] = 'siteurl';
+	if ( !defined( 'WP_HOME' ) )
+		$whitelist_options['general'][] = 'home';
+
+	$whitelist_options['general'][] = 'admin_email';
+	$whitelist_options['general'][] = 'users_can_register';
+	$whitelist_options['general'][] = 'default_role';
+
+	$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
+	$whitelist_options['writing'][] = 'ping_sites';
+
+	$whitelist_options['media'] = array_merge($whitelist_options['media'], $uploads_options);
+} else {
+	$whitelist_options['general'][] = 'new_admin_email';
+	$whitelist_options['general'][] = 'WPLANG';
+	$whitelist_options['general'][] = 'language';
+
+	if ( apply_filters( 'enable_post_by_email_configuration', true ) )
+		$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
+
+	$whitelist_options[ 'misc' ] = array();
+}
+
+$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
+
+/*
+ * If $_GET['action'] == 'update' we are saving settings sent from a settings page
+ */
+if ( 'update' == $action ) {
+	if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed.
+		$unregistered = true;
+		check_admin_referer( 'update-options' );
+	} else {
+		$unregistered = false;
+		check_admin_referer( $option_page . '-options' );
+	}
+
+	if ( !isset( $whitelist_options[ $option_page ] ) )
+		wp_die( __( 'Error: options page not found.' ) );
+
+	if ( 'options' == $option_page ) {
+		if ( is_multisite() && ! is_super_admin() )
+			wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) );
+		$options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) );
+	} else {
+		$options = $whitelist_options[ $option_page ];
+	}
+
+	// Handle custom date/time formats
+	if ( 'general' == $option_page ) {
+		if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
+			$_POST['date_format'] = $_POST['date_format_custom'];
+		if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
+			$_POST['time_format'] = $_POST['time_format_custom'];
+		// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
+		if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
+			$_POST['gmt_offset'] = $_POST['timezone_string'];
+			$_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
+			$_POST['timezone_string'] = '';
+		}
+	}
+
+	if ( $options ) {
+		foreach ( $options as $option ) {
+			if ( $unregistered )
+				_deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) );
+
+			$option = trim($option);
+			$value = null;
+			if ( isset($_POST[$option]) )
+				$value = $_POST[$option];
+			if ( !is_array($value) )
+				$value = trim($value);
+			$value = stripslashes_deep($value);
+			update_option($option, $value);
+		}
+	}
+
+	/**
+	 *  Handle settings errors and return to options page
+	 */
+	// If no settings errors were registered add a general 'updated' message.
+	if ( !count( get_settings_errors() ) )
+		add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
+	set_transient('settings_errors', get_settings_errors(), 30);
+
+	/**
+	 * Redirect back to the settings page that was submitted
+	 */
+	$goback = add_query_arg( 'settings-updated', 'true',  wp_get_referer() );
+	wp_redirect( $goback );
+	exit;
+}
+
+include('./admin-header.php'); ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+  <h2><?php esc_html_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' />
+  <table class="form-table">
+<?php
+$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
+
+foreach ( (array) $options as $option ) :
+	$disabled = false;
+	if ( $option->option_name == '' )
+		continue;
+	if ( is_serialized( $option->option_value ) ) {
+		if ( is_serialized_string( $option->option_value ) ) {
+			// this is a serialized string, so we should display it
+			$value = maybe_unserialize( $option->option_value );
+			$options_to_update[] = $option->option_name;
+			$class = 'all-options';
+		} else {
+			$value = 'SERIALIZED DATA';
+			$disabled = true;
+			$class = 'all-options disabled';
+		}
+	} else {
+		$value = $option->option_value;
+		$options_to_update[] = $option->option_name;
+		$class = 'all-options';
+	}
+	$name = esc_attr( $option->option_name );
+	echo "
+<tr>
+	<th scope='row'><label for='$name'>" . esc_html( $option->option_name ) . "</label></th>
+<td>";
+	if ( strpos( $value, "\n" ) !== false )
+		echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . esc_textarea( $value ) . "</textarea>";
+	else
+		echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />";
+	echo "</td>
+</tr>";
+endforeach;
+?>
+  </table>
+
+<input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" />
+
+<?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?>
+
+  </form>
+</div>
+
+
+<?php
+include('./admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/plugin-editor.php
===================================================================
--- /tags/3.1/wp-admin/plugin-editor.php	(revision 17487)
+++ /tags/3.1/wp-admin/plugin-editor.php	(revision 17487)
@@ -0,0 +1,264 @@
+<?php
+/**
+ * Edit plugin editor administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( is_multisite() && ! is_network_admin() ) {
+	wp_redirect( network_admin_url( 'plugin-editor.php' ) );
+	exit();
+}
+
+if ( !current_user_can('edit_plugins') )
+	wp_die( __('You do not have sufficient permissions to edit plugins for this site.') );
+
+$title = __("Edit Plugins");
+$parent_file = 'plugins.php';
+
+wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'plugin'));
+
+wp_admin_css( 'theme-editor' );
+
+$plugins = get_plugins();
+
+if ( empty($plugins) )
+	wp_die( __('There are no plugins installed on this site.') );
+
+if ( isset($_REQUEST['file']) )
+	$plugin = stripslashes($_REQUEST['file']);
+
+if ( empty($plugin) ) {
+	$plugin = array_keys($plugins);
+	$plugin = $plugin[0];
+}
+
+$plugin_files = get_plugin_files($plugin);
+
+if ( empty($file) )
+	$file = $plugin_files[0];
+else
+	$file = stripslashes($file);
+
+$file = validate_file_to_edit($file, $plugin_files);
+$real_file = WP_PLUGIN_DIR . '/' . $file;
+$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0;
+
+switch ( $action ) {
+
+case 'update':
+
+	check_admin_referer('edit-plugin_' . $file);
+
+	$newcontent = stripslashes($_POST['newcontent']);
+	if ( is_writeable($real_file) ) {
+		$f = fopen($real_file, 'w+');
+		fwrite($f, $newcontent);
+		fclose($f);
+
+		$network_wide = is_plugin_active_for_network( $file );
+
+		// Deactivate so we can test it.
+		if ( is_plugin_active($file) || isset($_POST['phperror']) ) {
+			if ( is_plugin_active($file) )
+				deactivate_plugins($file, true);
+
+			update_option('recently_activated', array($file => time()) + (array)get_option('recently_activated'));
+
+			wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
+			exit;
+		}
+		wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
+	} else {
+		wp_redirect( self_admin_url("plugin-editor.php?file=$file&scrollto=$scrollto") );
+	}
+	exit;
+
+break;
+
+default:
+
+	if ( isset($_GET['liveupdate']) ) {
+		check_admin_referer('edit-plugin-test_' . $file);
+
+		$error = validate_plugin($file);
+		if ( is_wp_error($error) )
+			wp_die( $error );
+
+		if ( ( ! empty( $_GET['networkwide'] ) && ! is_plugin_active_for_network($file) ) || ! is_plugin_active($file) )
+			activate_plugin($file, "plugin-editor.php?file=$file&phperror=1", ! empty( $_GET['networkwide'] ) ); // we'll override this later if the plugin can be included without fatal error
+
+		wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
+		exit;
+	}
+
+	// List of allowable extensions
+	$editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
+	$editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions);
+
+	if ( ! is_file($real_file) ) {
+		wp_die(sprintf('<p>%s</p>', __('No such file exists! Double check the name and try again.')));
+	} else {
+		// Get the extension of the file
+		if ( preg_match('/\.([^.]+)$/', $real_file, $matches) ) {
+			$ext = strtolower($matches[1]);
+			// If extension is not in the acceptable list, skip it
+			if ( !in_array( $ext, $editable_extensions) )
+				wp_die(sprintf('<p>%s</p>', __('Files of this type are not editable.')));
+		}
+	}
+
+	add_contextual_help($current_screen,
+		'<p>' . __('You can use the editor to make changes to any of your plugins&#8217; individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.') . '</p>' .
+		'<p>' . __('Choose a plugin to edit from the menu in the upper right and click the Select button. Click once on any file name to load it in the editor, and make your changes. Don&#8217;t forget to save your changes (Update File) when you&#8217;re finished.') . '</p>' .
+		'<p>' . __('The Documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Lookup takes you to a web page about that particular function.') . '</p>' .
+		'<p>' . __('If you want to make changes but don&#8217;t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.') . '</p>' .
+		( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' ) .
+		'<p><strong>' . __('For more information:') . '</strong></p>' .
+		'<p>' . __('<a href="http://codex.wordpress.org/Plugins_Editor_SubPanel" target="_blank">Documentation on Editing Plugins</a>') . '</p>' .
+		'<p>' . __('<a href="http://codex.wordpress.org/Writing_a_Plugin" target="_blank">Documentation on Writing Plugins</a>') . '</p>' .
+		'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+	);
+
+	require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+	update_recently_edited(WP_PLUGIN_DIR . '/' . $file);
+
+	$content = file_get_contents( $real_file );
+
+	if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) {
+		$functions = wp_doc_link_parse( $content );
+
+		if ( !empty($functions) ) {
+			$docs_select = '<select name="docs-list" id="docs-list">';
+			$docs_select .= '<option value="">' . __( 'Function Name&hellip;' ) . '</option>';
+			foreach ( $functions as $function) {
+				$docs_select .= '<option value="' . esc_attr( $function ) . '">' . esc_html( $function ) . '()</option>';
+			}
+			$docs_select .= '</select>';
+		}
+	}
+
+	$content = esc_textarea( $content );
+	?>
+<?php if (isset($_GET['a'])) : ?>
+ <div id="message" class="updated"><p><?php _e('File edited successfully.') ?></p></div>
+<?php elseif (isset($_GET['phperror'])) : ?>
+ <div id="message" class="updated"><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&amp;plugin=<?php echo esc_attr($file); ?>&amp;_wpnonce=<?php echo esc_attr($_GET['_error_nonce']); ?>"></iframe>
+	<?php } ?>
+</div>
+<?php endif; ?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<div class="fileedit-sub">
+<div class="alignleft">
+<big><?php
+	if ( is_plugin_active($plugin) ) {
+		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 sprintf(__('Editing <strong>%s</strong> (inactive)'), $file);
+		else
+			echo sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file);
+	}
+	?></big>
+</div>
+<div class="alignright">
+	<form action="plugin-editor.php" method="post">
+		<strong><label for="plugin"><?php _e('Select plugin to edit:'); ?> </label></strong>
+		<select name="plugin" id="plugin">
+<?php
+	foreach ( $plugins as $plugin_key => $a_plugin ) {
+		$plugin_name = $a_plugin['Name'];
+		if ( $plugin_key == $plugin )
+			$selected = " selected='selected'";
+		else
+			$selected = '';
+		$plugin_name = esc_attr($plugin_name);
+		$plugin_key = esc_attr($plugin_key);
+		echo "\n\t<option value=\"$plugin_key\" $selected>$plugin_name</option>";
+	}
+?>
+		</select>
+		<?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
+	</form>
+</div>
+<br class="clear" />
+</div>
+
+<div id="templateside">
+	<h3><?php _e('Plugin Files'); ?></h3>
+
+	<ul>
+<?php
+foreach ( $plugin_files as $plugin_file ) :
+	// Get the extension of the file
+	if ( preg_match('/\.([^.]+)$/', $plugin_file, $matches) ) {
+		$ext = strtolower($matches[1]);
+		// If extension is not in the acceptable list, skip it
+		if ( !in_array( $ext, $editable_extensions ) )
+			continue;
+	} else {
+		// No extension found
+		continue;
+	}
+?>
+		<li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>&amp;plugin=<?php echo $plugin; ?>"><?php echo $plugin_file ?></a></li>
+<?php endforeach; ?>
+	</ul>
+</div>
+<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>
+		<input type="hidden" name="action" value="update" />
+		<input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" />
+		<input type="hidden" name="plugin" value="<?php echo esc_attr($plugin) ?>" />
+		<input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" />
+		</div>
+		<?php if ( !empty( $docs_select ) ) : ?>
+		<div id="documentation" class="hide-if-no-js"><label for="docs-list"><?php _e('Documentation:') ?></label> <?php echo $docs_select ?> <input type="button" class="button" value="<?php esc_attr_e( 'Lookup' ) ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" /></div>
+		<?php endif; ?>
+<?php if ( is_writeable($real_file) ) : ?>
+	<?php if ( in_array( $file, (array) get_option( 'active_plugins', array() ) ) ) { ?>
+		<p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended.  If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p>
+	<?php } ?>
+	<p class="submit">
+	<?php
+		if ( isset($_GET['phperror']) ) {
+			echo "<input type='hidden' name='phperror' value='1' />";
+			submit_button( __( 'Update File and Attempt to Reactivate' ), 'primary', 'submit', false, array( 'tabindex' => '2' ) );
+		} else {
+			submit_button( __( 'Update File' ), 'primary', 'submit', false, array( 'tabindex' => '2' ) );
+		}
+	?>
+	</p>
+<?php else : ?>
+	<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>
+<br class="clear" />
+</div>
+<script type="text/javascript">
+/* <![CDATA[ */
+jQuery(document).ready(function($){
+	$('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
+	$('#newcontent').scrollTop( $('#scrollto').val() );
+});
+/* ]]> */
+</script>
+<?php
+	break;
+}
+include(ABSPATH . "wp-admin/admin-footer.php");
Index: /tags/3.1/wp-admin/plugin-install.php
===================================================================
--- /tags/3.1/wp-admin/plugin-install.php	(revision 17487)
+++ /tags/3.1/wp-admin/plugin-install.php	(revision 17487)
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Install plugin administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+// TODO route this pages via a specific iframe handler instead of the do_action below
+if ( !defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) )
+	define( 'IFRAME_REQUEST', true );
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can('install_plugins') )
+	wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
+
+if ( is_multisite() && ! is_network_admin() ) {
+	wp_redirect( network_admin_url( 'plugin-install.php' ) );
+	exit();
+}
+
+$wp_list_table = _get_list_table('WP_Plugin_Install_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+$wp_list_table->prepare_items();
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+$title = __('Install Plugins');
+$parent_file = 'plugins.php';
+
+wp_enqueue_style( 'plugin-install' );
+wp_enqueue_script( 'plugin-install' );
+if ( 'plugin-information' != $tab )
+	add_thickbox();
+
+$body_id = $tab;
+
+do_action('install_plugins_pre_' . $tab); //Used to override the general interface, Eg, install or plugin information.
+
+add_contextual_help($current_screen,
+	'<p>' . sprintf(__('Plugins hook into WordPress to extend its functionality with custom features. Plugins are developed independently from WordPress core by thousands of developers all over the world. All plugins in the official <a href="%s" target="_blank">WordPress.org Plugin Directory</a> are compatible with the WordPress GPL v2 license. You can find new plugins to install by searching or browsing the Directory right here in your own Plugins section.'), 'http://wordpress.org/extend/plugins/') . '</p>' .
+	'<p>' . __('If you know what you&#8217;re looking for, Search is your best bet. The Search screen has options to search the WordPress.org Plugin Directory for a particular Term, Author, or Tag. You can also search the directory by selecting a popular tags. Tags in larger type mean more plugins have been labeled with that tag.') . '</p>' .
+	'<p>' . __('If you just want to get an idea of what&#8217;s available, you can browse Featured, Popular, Newest, and Recently Updated plugins by using the links in the upper left of the screen. These sections rotate regularly.') . '</p>' .
+	'<p>' . __('If you want to install a plugin that you&#8217;ve downloaded elsewhere, click Upload in the upper left. You will be prompted to upload the .zip package, and once uploaded, you can activate the new plugin.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Plugins_Add_New_SubPanel" target="_blank">Documentation on Installing Plugins</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+include(ABSPATH . 'wp-admin/admin-header.php');
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<?php $wp_list_table->views(); ?>
+
+<br class="clear" />
+<?php do_action('install_plugins_' . $tab, $paged); ?>
+</div>
+<?php
+include(ABSPATH . 'wp-admin/admin-footer.php');
+
Index: /tags/3.1/wp-admin/plugins.php
===================================================================
--- /tags/3.1/wp-admin/plugins.php	(revision 17487)
+++ /tags/3.1/wp-admin/plugins.php	(revision 17487)
@@ -0,0 +1,423 @@
+<?php
+/**
+ * Plugins administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( is_multisite() ) {
+	$menu_perms = get_site_option( 'menu_items', array() );
+
+	if ( empty( $menu_perms['plugins'] ) && ! is_super_admin() )
+		wp_die( __( 'Cheatin&#8217; uh?' ) );
+}
+
+if ( !current_user_can('activate_plugins') )
+	wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) );
+
+$wp_list_table = _get_list_table('WP_Plugins_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+
+$action = $wp_list_table->current_action();
+
+$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
+$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : '';
+
+// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
+$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
+
+if ( $action ) {
+	$network_wide = false;
+	if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )
+		$network_wide = true;
+
+	switch ( $action ) {
+		case 'activate':
+			if ( ! current_user_can('activate_plugins') )
+				wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
+
+			check_admin_referer('activate-plugin_' . $plugin);
+
+			$result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), $network_wide);
+			if ( is_wp_error( $result ) ) {
+				if ( 'unexpected_output' == $result->get_error_code() ) {
+					$redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin . "&plugin_status=$status&paged=$page&s=$s");
+					wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
+					exit;
+				} else {
+					wp_die($result);
+				}
+			}
+
+			$recent = (array)get_option('recently_activated');
+			if ( isset($recent[ $plugin ]) ) {
+				unset($recent[ $plugin ]);
+				update_option('recently_activated', $recent);
+			}
+			if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
+				wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix
+			} else {
+				wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
+			}
+			exit;
+			break;
+		case 'activate-selected':
+		case 'network-activate-selected':
+			if ( ! current_user_can('activate_plugins') )
+				wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
+
+			check_admin_referer('bulk-plugins');
+
+			$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
+
+			// Only activate plugins which are not already active.
+			$check = $network_wide ? 'is_plugin_active_for_network' : 'is_plugin_active';
+			foreach ( $plugins as $i => $plugin )
+				if ( $check( $plugin ) )
+					unset( $plugins[ $i ] );
+
+			if ( empty($plugins) ) {
+				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
+				exit;
+			}
+
+			activate_plugins($plugins, self_admin_url('plugins.php?error=true'), $network_wide);
+
+			$recent = (array)get_option('recently_activated');
+			foreach ( $plugins as $plugin => $time)
+				if ( isset($recent[ $plugin ]) )
+					unset($recent[ $plugin ]);
+
+			update_option('recently_activated', $recent);
+
+			wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
+			exit;
+			break;
+		case 'update-selected' :
+
+			check_admin_referer( 'bulk-plugins' );
+
+			if ( isset( $_GET['plugins'] ) )
+				$plugins = explode( ',', $_GET['plugins'] );
+			elseif ( isset( $_POST['checked'] ) )
+				$plugins = (array) $_POST['checked'];
+			else
+				$plugins = array();
+
+			$title = __( 'Update Plugins' );
+			$parent_file = 'plugins.php';
+
+			require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+			echo '<div class="wrap">';
+			screen_icon();
+			echo '<h2>' . esc_html( $title ) . '</h2>';
+
+
+			$url = self_admin_url('update.php?action=update-selected&amp;plugins=' . urlencode( join(',', $plugins) ));
+			$url = wp_nonce_url($url, 'bulk-update-plugins');
+
+			echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
+			echo '</div>';
+			require_once(ABSPATH . 'wp-admin/admin-footer.php');
+			exit;
+			break;
+		case 'error_scrape':
+			if ( ! current_user_can('activate_plugins') )
+				wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
+
+			check_admin_referer('plugin-activation-error_' . $plugin);
+
+			$valid = validate_plugin($plugin);
+			if ( is_wp_error($valid) )
+				wp_die($valid);
+
+			if ( ! WP_DEBUG ) {
+				if ( defined('E_RECOVERABLE_ERROR') )
+					error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
+				else
+					error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
+			}
+
+			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
+			// Go back to "sandbox" scope so we get the same errors as before
+			function plugin_sandbox_scrape( $plugin ) {
+				include( WP_PLUGIN_DIR . '/' . $plugin );
+			}
+			plugin_sandbox_scrape( $plugin );
+			do_action('activate_' . $plugin);
+			exit;
+			break;
+		case 'deactivate':
+			if ( ! current_user_can('activate_plugins') )
+				wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
+
+			check_admin_referer('deactivate-plugin_' . $plugin);
+			deactivate_plugins($plugin);
+			update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
+			if ( headers_sent() )
+				echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
+			else
+				wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") );
+			exit;
+			break;
+		case 'deactivate-selected':
+			if ( ! current_user_can('activate_plugins') )
+				wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
+
+			check_admin_referer('bulk-plugins');
+
+			$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
+			$plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
+			if ( empty($plugins) ) {
+				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
+				exit;
+			}
+
+			deactivate_plugins($plugins);
+
+			$deactivated = array();
+			foreach ( $plugins as $plugin )
+				$deactivated[ $plugin ] = time();
+
+			update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
+			wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
+			exit;
+			break;
+		case 'delete-selected':
+			if ( ! current_user_can('delete_plugins') )
+				wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
+
+			check_admin_referer('bulk-plugins');
+
+			//$_POST = from the plugin form; $_GET = from the FTP details screen.
+			$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
+			if ( empty( $plugins ) ) {
+				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
+				exit;
+			}
+
+			$plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
+			if ( empty( $plugins ) ) {
+				wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
+				exit;
+			}
+
+			include(ABSPATH . 'wp-admin/update.php');
+
+			$parent_file = 'plugins.php';
+
+			if ( ! isset($_REQUEST['verify-delete']) ) {
+				wp_enqueue_script('jquery');
+				require_once(ABSPATH . 'wp-admin/admin-header.php');
+				?>
+			<div class="wrap">
+				<?php
+					$files_to_delete = $plugin_info = array();
+					$have_non_network_plugins = false;
+					foreach ( (array) $plugins as $plugin ) {
+						if ( '.' == dirname($plugin) ) {
+							$files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
+							if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) {
+								$plugin_info[ $plugin ] = $data;
+								$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
+								if ( ! $plugin_info[ $plugin ]['Network'] )
+									$have_non_network_plugins = true;
+							}
+						} else {
+							// Locate all the files in that folder
+							$files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) );
+							if ( $files ) {
+								$files_to_delete = array_merge($files_to_delete, $files);
+							}
+							// Get plugins list from that folder
+							if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
+								foreach( $folder_plugins as $plugin_file => $data ) {
+									$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
+									$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
+									if ( ! $plugin_info[ $plugin_file ]['Network'] )
+										$have_non_network_plugins = true;
+								}
+							}
+						}
+					}
+					screen_icon();
+					$plugins_to_delete = count( $plugin_info );
+					echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>';
+				?>
+				<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
+				<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This plugin may be active on other sites in the network.', 'These plugins may be active on other sites in the network.', $plugins_to_delete ); ?></p></div>
+				<?php endif; ?>
+				<p><?php echo _n( 'You are about to remove the following plugin:', 'You are about to remove the following plugins:', $plugins_to_delete ); ?></p>
+					<ul class="ul-disc">
+						<?php
+						$data_to_delete = false;
+						foreach ( $plugin_info as $plugin ) {
+							if ( $plugin['is_uninstallable'] ) {
+								/* translators: 1: plugin name, 2: plugin author */
+								echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '</li>';
+								$data_to_delete = true;
+							} else {
+								/* translators: 1: plugin name, 2: plugin author */
+								echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '</li>';
+							}
+						}
+						?>
+					</ul>
+				<p><?php
+				if ( $data_to_delete )
+					_e('Are you sure you wish to delete these files and data?');
+				else
+					_e('Are you sure you wish to delete these files?');
+				?></p>
+				<form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
+					<input type="hidden" name="verify-delete" value="1" />
+					<input type="hidden" name="action" value="delete-selected" />
+					<?php
+						foreach ( (array) $plugins as $plugin )
+							echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
+					?>
+					<?php wp_nonce_field('bulk-plugins') ?>
+					<?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>
+				</form>
+				<form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
+					<?php submit_button( __( 'No, Return me to the plugin list' ), 'button', 'submit', false ); ?>
+				</form>
+
+				<p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
+				<div id="files-list" style="display:none;">
+					<ul class="code">
+					<?php
+						foreach ( (array)$files_to_delete as $file )
+							echo '<li>' . esc_html(str_replace(WP_PLUGIN_DIR, '', $file)) . '</li>';
+					?>
+					</ul>
+				</div>
+			</div>
+				<?php
+				require_once(ABSPATH . 'wp-admin/admin-footer.php');
+				exit;
+			} //Endif verify-delete
+			$delete_result = delete_plugins($plugins);
+
+			set_transient('plugins_delete_result_' . $user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
+			wp_redirect( self_admin_url("plugins.php?deleted=true&plugin_status=$status&paged=$page&s=$s") );
+			exit;
+			break;
+		case 'clear-recent-list':
+			update_option('recently_activated', array());
+			break;
+	}
+}
+
+$wp_list_table->prepare_items();
+
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+wp_enqueue_script('plugin-install');
+add_thickbox();
+
+add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' )) );
+
+add_contextual_help($current_screen,
+	'<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
+	'<p>' . sprintf(__('You can find additional plugins for your site by using the <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="%2$s" target="_blank">WordPress Plugin Directory</a> directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your <code>/wp-content/plugins</code> directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/extend/plugins/') . '</p>' .
+	'<p>' . __('Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin&#8217;s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.') . '</p>' .
+	'<p>' . sprintf( __('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR) . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Managing_Plugins#Plugin_Management" target="_blank">Documentation on Managing Plugins</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+$title = __('Plugins');
+$parent_file = 'plugins.php';
+
+require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+$invalid = validate_active_plugins();
+if ( !empty($invalid) )
+	foreach ( $invalid as $plugin_file => $error )
+		echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>';
+?>
+
+<?php if ( isset($_GET['error']) ) :
+
+	if ( isset( $_GET['main'] ) )
+		$errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
+	elseif ( isset($_GET['charsout']) )
+		$errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation.  If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
+	else
+		$errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
+	?>
+	<div id="message" class="updated"><p><?php echo $errmsg; ?></p>
+	<?php
+		if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
+	<iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&amp;plugin=' . esc_attr($plugin) . '&amp;_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>
+	<?php
+		}
+	?>
+	</div>
+<?php elseif ( isset($_GET['deleted']) ) :
+		$delete_result = get_transient('plugins_delete_result_'.$user_ID);
+		delete_transient('plugins_delete_result'); //Delete it once we're done.
+
+		if ( is_wp_error($delete_result) ) : ?>
+		<div id="message" class="updated"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
+		<?php else : ?>
+		<div id="message" class="updated"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div>
+		<?php endif; ?>
+<?php elseif ( isset($_GET['activate']) ) : ?>
+	<div id="message" class="updated"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
+<?php elseif (isset($_GET['activate-multi'])) : ?>
+	<div id="message" class="updated"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
+<?php elseif ( isset($_GET['deactivate']) ) : ?>
+	<div id="message" class="updated"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
+<?php elseif (isset($_GET['deactivate-multi'])) : ?>
+	<div id="message" class="updated"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
+<?php elseif ( 'update-selected' == $action ) : ?>
+	<div id="message" class="updated"><p><?php _e('No out of date plugins were selected.'); ?></p></div>
+<?php endif; ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title );
+if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
+<a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a>
+<?php }
+if ( $s )
+	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) ); ?>
+</h2>
+
+<?php do_action( 'pre_current_active_plugins', $plugins['all'] ) ?>
+
+<?php $wp_list_table->views(); ?>
+
+<form method="post" action="">
+
+<?php $wp_list_table->search_box( __( 'Search Plugins' ), 'plugin' ); ?>
+
+<input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
+<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
+
+<?php
+if ( 'mustuse' == $status )
+	echo '<br class="clear" /><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>';
+elseif ( 'dropins' == $status )
+	echo '<br class="clear" /><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>';
+?>
+
+<?php $wp_list_table->display(); ?>
+</form>
+
+</div>
+
+<?php
+include(ABSPATH . 'wp-admin/admin-footer.php');
Index: /tags/3.1/wp-admin/post-new.php
===================================================================
--- /tags/3.1/wp-admin/post-new.php	(revision 17487)
+++ /tags/3.1/wp-admin/post-new.php	(revision 17487)
@@ -0,0 +1,43 @@
+<?php
+/**
+ * New Post Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** Load WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( !isset($_GET['post_type']) )
+	$post_type = 'post';
+elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
+	$post_type = $_GET['post_type'];
+else
+	wp_die( __('Invalid post type') );
+
+if ( 'post' != $post_type ) {
+	$parent_file = "edit.php?post_type=$post_type";
+	$submenu_file = "post-new.php?post_type=$post_type";
+} else {
+	$parent_file = 'edit.php';
+	$submenu_file = 'post-new.php';
+}
+
+$post_type_object = get_post_type_object($post_type);
+
+$title = $post_type_object->labels->add_new_item;
+
+$editing = true;
+
+if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+wp_enqueue_script('autosave');
+
+// Show post form.
+$post = get_default_post_to_edit( $post_type, true );
+$post_ID = $post->ID;
+include('edit-form-advanced.php');
+include('./admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/post.php
===================================================================
--- /tags/3.1/wp-admin/post.php	(revision 17487)
+++ /tags/3.1/wp-admin/post.php	(revision 17487)
@@ -0,0 +1,277 @@
+<?php
+/**
+ * Edit post administration panel.
+ *
+ * Manage Post actions: post, edit, delete, etc.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+$parent_file = 'edit.php';
+$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'));
+
+if ( isset($_GET['post']) )
+	$post_id = (int) $_GET['post'];
+elseif ( isset($_POST['post_ID']) )
+	$post_id = (int) $_POST['post_ID'];
+else
+	$post_id = 0;
+$post_ID = $post_id;
+$post = null;
+$post_type_object = null;
+$post_type = null;
+if ( $post_id ) {
+	$post = get_post($post_id);
+	if ( $post ) {
+		$post_type_object = get_post_type_object($post->post_type);
+		if ( $post_type_object ) {
+			$post_type = $post->post_type;
+			$current_screen->post_type = $post->post_type;
+			$current_screen->id = $current_screen->post_type;
+		}
+	}
+} elseif ( isset($_POST['post_type']) ) {
+	$post_type_object = get_post_type_object($_POST['post_type']);
+	if ( $post_type_object ) {
+		$post_type = $post_type_object->name;
+		$current_screen->post_type = $post_type;
+		$current_screen->id = $current_screen->post_type;
+	}
+}
+
+/**
+ * Redirect to previous page.
+ *
+ * @param int $post_id Optional. Post ID.
+ */
+function redirect_post($post_id = '') {
+	if ( isset($_POST['save']) || isset($_POST['publish']) ) {
+		$status = get_post_status( $post_id );
+
+		if ( isset( $_POST['publish'] ) ) {
+			switch ( $status ) {
+				case 'pending':
+					$message = 8;
+					break;
+				case 'future':
+					$message = 9;
+					break;
+				default:
+					$message = 6;
+			}
+		} else {
+				$message = 'draft' == $status ? 10 : 1;
+		}
+
+		$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
+	} 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 ( 'post-quickpress-save-cont' == $_POST['action'] ) {
+		$location = "post.php?action=edit&post=$post_id&message=7";
+	} else {
+		$location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
+	}
+
+	wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
+	exit;
+}
+
+if ( isset( $_POST['deletepost'] ) )
+	$action = 'delete';
+elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
+	$action = 'preview';
+
+$sendback = wp_get_referer();
+if ( strpos($sendback, 'post.php') !== false || strpos($sendback, 'post-new.php') !== false ) {
+	$sendback = admin_url('edit.php');
+	$sendback .= ( !empty( $post_type ) ) ? '?post_type=' . $post_type : '';
+} else {
+	$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
+}
+
+switch($action) {
+case 'postajaxpost':
+case 'post':
+case 'post-quickpress-publish':
+case 'post-quickpress-save':
+	check_admin_referer('add-' . $post_type);
+
+	if ( 'post-quickpress-publish' == $action )
+		$_POST['publish'] = 'publish'; // tell write_post() to publish
+
+	if ( 'post-quickpress-publish' == $action || 'post-quickpress-save' == $action ) {
+		$_POST['comment_status'] = get_option('default_comment_status');
+		$_POST['ping_status'] = get_option('default_ping_status');
+	}
+
+	if ( !empty( $_POST['quickpress_post_ID'] ) ) {
+		$_POST['post_ID'] = (int) $_POST['quickpress_post_ID'];
+		$post_id = edit_post();
+	} else {
+		$post_id = 'postajaxpost' == $action ? edit_post() : write_post();
+	}
+
+	if ( 0 === strpos( $action, 'post-quickpress' ) ) {
+		$_POST['post_ID'] = $post_id;
+		// output the quickpress dashboard widget
+		require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
+		wp_dashboard_quick_press_output();
+		exit;
+	}
+
+	redirect_post($post_id);
+	exit();
+	break;
+
+case 'edit':
+	$editing = true;
+
+	if ( empty( $post_id ) ) {
+		wp_redirect( admin_url('post.php') );
+		exit();
+	}
+
+	$p = $post_id;
+
+	if ( empty($post->ID) )
+		wp_die( __('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?') );
+
+	if ( !current_user_can($post_type_object->cap->edit_post, $post_id) )
+		wp_die( __('You are not allowed to edit this item.') );
+
+	if ( 'trash' == $post->post_status )
+		wp_die( __('You can&#8217;t edit this item because it is in the Trash. Please restore it and try again.') );
+
+	if ( null == $post_type_object )
+		wp_die( __('Unknown post type.') );
+
+	$post_type = $post->post_type;
+	if ( 'post' == $post_type ) {
+		$parent_file = "edit.php";
+		$submenu_file = "edit.php";
+	} else {
+		if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true )
+			$parent_file = $post_type_object->show_in_menu;
+		else
+			$parent_file = "edit.php?post_type=$post_type";
+		$submenu_file = "edit.php?post_type=$post_type";
+	}
+
+	if ( $last = wp_check_post_lock( $post->ID ) ) {
+		add_action('admin_notices', '_admin_notice_post_locked' );
+	} else {
+		wp_set_post_lock( $post->ID );
+		wp_enqueue_script('autosave');
+	}
+
+	$title = $post_type_object->labels->edit_item;
+	$post = get_post_to_edit($post_id);
+
+	if ( post_type_supports($post_type, 'comments') ) {
+		wp_enqueue_script('admin-comments');
+		enqueue_comment_hotkeys_js();
+	}
+
+	include('./edit-form-advanced.php');
+
+	break;
+
+case 'editattachment':
+	check_admin_referer('update-attachment_' . $post_id);
+
+	// Don't let these be changed
+	unset($_POST['guid']);
+	$_POST['post_type'] = 'attachment';
+
+	// Update the thumbnail filename
+	$newmeta = wp_get_attachment_metadata( $post_id, true );
+	$newmeta['thumb'] = $_POST['thumb'];
+
+	wp_update_attachment_metadata( $post_id, $newmeta );
+
+case 'editpost':
+	check_admin_referer('update-' . $post_type . '_' . $post_id);
+
+	$post_id = edit_post();
+
+	redirect_post($post_id); // Send user on their way while we keep working
+
+	exit();
+	break;
+
+case 'trash':
+	check_admin_referer('trash-' . $post_type . '_' . $post_id);
+
+	$post = & get_post($post_id);
+
+	if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+		wp_die( __('You are not allowed to move this item to the Trash.') );
+
+	if ( ! wp_trash_post($post_id) )
+		wp_die( __('Error in moving to Trash.') );
+
+	wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) );
+	exit();
+	break;
+
+case 'untrash':
+	check_admin_referer('untrash-' . $post_type . '_' . $post_id);
+
+	if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+		wp_die( __('You are not allowed to move this item out of the Trash.') );
+
+	if ( ! wp_untrash_post($post_id) )
+		wp_die( __('Error in restoring from Trash.') );
+
+	wp_redirect( add_query_arg('untrashed', 1, $sendback) );
+	exit();
+	break;
+
+case 'delete':
+	check_admin_referer('delete-' . $post_type . '_' . $post_id);
+
+	if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
+		wp_die( __('You are not allowed to delete this item.') );
+
+	$force = !EMPTY_TRASH_DAYS;
+	if ( $post->post_type == 'attachment' ) {
+		$force = ( $force || !MEDIA_TRASH );
+		if ( ! wp_delete_attachment($post_id, $force) )
+			wp_die( __('Error in deleting.') );
+	} else {
+		if ( !wp_delete_post($post_id, $force) )
+			wp_die( __('Error in deleting.') );
+	}
+
+	wp_redirect( add_query_arg('deleted', 1, $sendback) );
+	exit();
+	break;
+
+case 'preview':
+	check_admin_referer( 'autosave', 'autosavenonce' );
+
+	$url = post_preview();
+
+	wp_redirect($url);
+	exit();
+	break;
+
+default:
+	wp_redirect( admin_url('edit.php') );
+	exit();
+	break;
+} // end switch
+include('./admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/press-this.php
===================================================================
--- /tags/3.1/wp-admin/press-this.php	(revision 17487)
+++ /tags/3.1/wp-admin/press-this.php	(revision 17487)
@@ -0,0 +1,641 @@
+<?php
+/**
+ * Press This Display and Handler.
+ *
+ * @package WordPress
+ * @subpackage Press_This
+ */
+
+define('IFRAME_REQUEST' , true);
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+
+if ( ! current_user_can('edit_posts') )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+/**
+ * Press It form handler.
+ *
+ * @package WordPress
+ * @subpackage Press_This
+ * @since 2.6.0
+ *
+ * @return int Post ID
+ */
+function press_it() {
+	// define some basic variables
+	$quick = array();
+	$quick['post_status'] = 'draft'; // set as draft first
+	$quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
+	$quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null;
+	$quick['post_title'] = ( trim($_POST['title']) != '' ) ? $_POST['title'] : '  ';
+	$quick['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : '';
+
+	// insert the post with nothing in it, to get an ID
+	$post_ID = wp_insert_post($quick, true);
+	if ( is_wp_error($post_ID) )
+		wp_die($post_ID);
+
+	$content = isset($_POST['content']) ? $_POST['content'] : '';
+
+	$upload = false;
+	if ( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
+		foreach( (array) $_POST['photo_src'] as $key => $image) {
+			// see if files exist in content - we don't want to upload non-used selected files.
+			if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
+				$desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
+				$upload = media_sideload_image($image, $post_ID, $desc);
+
+				// Replace the POSTED content <img> with correct uploaded ones. Regex contains fix for Magic Quotes
+				if ( !is_wp_error($upload) )
+					$content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
+			}
+		}
+	}
+	// set the post_content and status
+	$quick['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft';
+	$quick['post_content'] = $content;
+	// error handling for media_sideload
+	if ( is_wp_error($upload) ) {
+		wp_delete_post($post_ID);
+		wp_die($upload);
+	} else {
+		// Post formats
+		if ( current_theme_supports( 'post-formats' ) && isset( $_POST['post_format'] ) ) {
+			$post_formats = get_theme_support( 'post-formats' );
+			if ( is_array( $post_formats ) ) {
+				$post_formats = $post_formats[0];
+				if ( in_array( $_POST['post_format'], $post_formats ) )
+					set_post_format( $post_ID, $_POST['post_format'] );
+				elseif ( '0' == $_POST['post_format'] )
+					set_post_format( $post_ID, false );
+			}
+		}
+
+		$quick['ID'] = $post_ID;
+		wp_update_post($quick);
+	}
+	return $post_ID;
+}
+
+// For submitted posts.
+if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
+	check_admin_referer('press-this');
+	$post_ID = press_it();
+	$posted =  $post_ID;
+} else {
+	$post_ID = 0;
+}
+
+// Set Variables
+$title = isset( $_GET['t'] ) ? trim( strip_tags( html_entity_decode( stripslashes( $_GET['t'] ) , ENT_QUOTES) ) ) : '';
+
+$selection = '';
+if ( !empty($_GET['s']) ) {
+	$selection = str_replace('&apos;', "'", stripslashes($_GET['s']));
+	$selection = trim( htmlspecialchars( html_entity_decode($selection, ENT_QUOTES) ) );
+}
+
+if ( ! empty($selection) ) {
+	$selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
+	$selection = '<p>' . str_replace('<p></p>', '', $selection) . '</p>';
+}
+
+$url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
+$image = isset($_GET['i']) ? $_GET['i'] : '';
+
+if ( !empty($_REQUEST['ajax']) ) {
+	switch ($_REQUEST['ajax']) {
+		case 'video': ?>
+			<script type="text/javascript" charset="utf-8">
+			/* <![CDATA[ */
+				jQuery('.select').click(function() {
+					append_editor(jQuery('#embed-code').val());
+					jQuery('#extra-fields').hide();
+					jQuery('#extra-fields').html('');
+				});
+				jQuery('.close').click(function() {
+					jQuery('#extra-fields').hide();
+					jQuery('#extra-fields').html('');
+				});
+			/* ]]> */
+			</script>
+			<div class="postbox">
+				<h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
+				<div class="inside">
+					<textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo esc_textarea( $selection ); ?></textarea>
+					<p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
+				</div>
+			</div>
+			<?php break;
+
+		case 'photo_thickbox': ?>
+			<script type="text/javascript" charset="utf-8">
+				/* <![CDATA[ */
+				jQuery('.cancel').click(function() {
+					tb_remove();
+				});
+				jQuery('.select').click(function() {
+					image_selector();
+				});
+				/* ]]> */
+			</script>
+			<h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
+			<div class="titlediv">
+				<div class="titlewrap">
+					<input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
+				</div>
+			</div>
+
+			<p class="centered">
+				<input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="this_photo" />
+				<a href="#" class="select">
+					<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
+				</a>
+			</p>
+
+			<p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
+			<?php break;
+
+		case 'photo_thickbox_url': ?>
+			<script type="text/javascript" charset="utf-8">
+				/* <![CDATA[ */
+				jQuery('.cancel').click(function() {
+					tb_remove();
+				});
+
+				jQuery('.select').click(function() {
+					image_selector();
+				});
+				/* ]]> */
+			</script>
+			<h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>
+			<div class="titlediv">
+				<div class="titlewrap">
+					<input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />
+				</div>
+			</div>
+			<h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>
+			<div id="titlediv">
+				<div class="titlewrap">
+					<input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
+				</div>
+			</div>
+
+			<p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
+			<?php break;
+	case 'photo_images':
+		/**
+		 * Retrieve all image URLs from given URI.
+		 *
+		 * @package WordPress
+		 * @subpackage Press_This
+		 * @since 2.6.0
+		 *
+		 * @param string $uri
+		 * @return string
+		 */
+		function get_images_from_uri($uri) {
+			$uri = preg_replace('/\/#.+?$/','', $uri);
+			if ( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
+				return "'" . esc_attr( html_entity_decode($uri) ) . "'";
+			$content = wp_remote_fopen($uri);
+			if ( false === $content )
+				return '';
+			$host = parse_url($uri);
+			$pattern = '/<img ([^>]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/i';
+			$content = str_replace(array("\n","\t","\r"), '', $content);
+			preg_match_all($pattern, $content, $matches);
+			if ( empty($matches[0]) )
+				return '';
+			$sources = array();
+			foreach ($matches[3] as $src) {
+				// if no http in url
+				if (strpos($src, 'http') === false)
+					// if it doesn't have a relative uri
+					if ( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
+						$src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
+					else
+						$src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
+				$sources[] = esc_attr($src);
+			}
+			return "'" . implode("','", $sources) . "'";
+		}
+		$url = wp_kses(urldecode($url), null);
+		echo 'new Array('.get_images_from_uri($url).')';
+		break;
+
+	case 'photo_js': ?>
+		// gather images and load some default JS
+		var last = null
+		var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
+		if(photostorage == false) {
+		var my_src = eval(
+			jQuery.ajax({
+		   		type: "GET",
+		   		url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
+				cache : false,
+				async : false,
+		   		data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
+				dataType : "script"
+			}).responseText
+		);
+		if(my_src.length == 0) {
+			var my_src = eval(
+				jQuery.ajax({
+		   			type: "GET",
+		   			url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
+					cache : false,
+					async : false,
+		   			data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
+					dataType : "script"
+				}).responseText
+			);
+			if(my_src.length == 0) {
+				strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
+			}
+		}
+		}
+		for (i = 0; i < my_src.length; i++) {
+			img = new Image();
+			img.src = my_src[i];
+			img_attr = 'id="img' + i + '"';
+			skip = false;
+
+			maybeappend = '<a href="?ajax=photo_thickbox&amp;i=' + encodeURIComponent(img.src) + '&amp;u=<?php echo urlencode($url); ?>&amp;height=400&amp;width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
+
+			if (img.width && img.height) {
+				if (img.width >= 30 && img.height >= 30) {
+					aspect = img.width / img.height;
+					scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
+
+					w = img.width;
+					h = img.height;
+
+					if (scale < 1) {
+						w = parseInt(img.width * scale);
+						h = parseInt(img.height * scale);
+					}
+					img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
+					strtoappend += maybeappend;
+				}
+			} else {
+				strtoappend += maybeappend;
+			}
+		}
+
+		function pick(img, desc) {
+			if (img) {
+				if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
+				if(length == 0) length = 1;
+				jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
+				jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
+				insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
+			}
+			return false;
+		}
+
+		function image_selector() {
+			tb_remove();
+			desc = jQuery('#this_photo_description').val();
+			src = jQuery('#this_photo').val();
+			pick(src, desc);
+			jQuery('#extra-fields').hide();
+			jQuery('#extra-fields').html('');
+			return false;
+		}
+			jQuery('#extra-fields').html('<div class="postbox"><h2>Add Photos <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
+			jQuery('#img_container').html(strtoappend);
+		<?php break;
+}
+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 _e('Press This') ?></title>
+
+<?php
+	add_thickbox();
+	wp_enqueue_style( 'press-this' );
+	wp_enqueue_style( 'press-this-ie');
+	wp_enqueue_style( 'colors' );
+	wp_enqueue_script( 'post' );
+	wp_enqueue_script( 'editor' );
+?>
+<script type="text/javascript">
+//<![CDATA[
+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();}}};
+var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
+var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
+var photostorage = false;
+//]]>
+</script>
+
+<?php
+	do_action('admin_print_styles');
+	do_action('admin_print_scripts');
+	do_action('admin_head');
+
+	if ( user_can_richedit() ) {
+		wp_tiny_mce( true, array( 'height' => '370' ) );
+		add_action( 'admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30 );
+	}
+?>
+	<script type="text/javascript">
+	function insert_plain_editor(text) {
+		edCanvas = document.getElementById('content');
+		edInsertContent(edCanvas, text);
+	}
+	function set_editor(text) {
+		if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
+		if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
+	}
+	function insert_editor(text) {
+		if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
+			tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
+		} else {
+			insert_plain_editor(decodeURI(text));
+		}
+	}
+	function append_editor(text) {
+		if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
+			tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
+			tinyMCE.execCommand('mceCleanup');
+		} else {
+			insert_plain_editor(text);
+		}
+	}
+
+	function show(tab_name) {
+		jQuery('#extra-fields').html('');
+		switch(tab_name) {
+			case 'video' :
+				jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
+					<?php
+					$content = '';
+					if ( preg_match("/youtube\.com\/watch/i", $url) ) {
+						list($domain, $video_id) = split("v=", $url);
+						$video_id = esc_attr($video_id);
+						$content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
+
+					} elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
+						list($domain, $video_id) = split(".com/", $url);
+						$video_id = esc_attr($video_id);
+						$content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" />	<embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&amp;server=www.vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
+
+						if ( trim($selection) == '' )
+							$selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>';
+
+					} elseif ( strpos( $selection, '<object' ) !== false ) {
+						$content = $selection;
+					}
+					?>
+					jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
+				});
+				jQuery('#extra-fields').show();
+				return false;
+				break;
+			case 'photo' :
+				function setup_photo_actions() {
+					jQuery('.close').click(function() {
+						jQuery('#extra-fields').hide();
+						jQuery('#extra-fields').html('');
+					});
+					jQuery('.refresh').click(function() {
+						photostorage = false;
+						show('photo');
+					});
+					jQuery('#photo-add-url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
+					tb_init('#extra-fields .thickbox');
+					jQuery('#waiting').hide();
+					jQuery('#extra-fields').show();
+				}
+				jQuery('#extra-fields').before('<div id="waiting"><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></div>');
+
+				if(photostorage == false) {
+					jQuery.ajax({
+						type: "GET",
+						cache : false,
+						url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
+						data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
+						dataType : "script",
+						success : function(data) {
+							eval(data);
+							photostorage = jQuery('#extra-fields').html();
+							setup_photo_actions();
+						}
+					});
+				} else {
+					jQuery('#extra-fields').html(photostorage);
+					setup_photo_actions();
+				}
+				return false;
+				break;
+		}
+	}
+	jQuery(document).ready(function($) {
+		//resize screen
+		window.resizeTo(720,540);
+		// set button actions
+    	jQuery('#photo_button').click(function() { show('photo'); return false; });
+		jQuery('#video_button').click(function() { show('video'); return false; });
+		// auto select
+		<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
+			show('video');
+		<?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
+			show('video');
+		<?php  } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
+			show('photo');
+		<?php } ?>
+		jQuery('#title').unbind();
+		jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
+
+		$('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
+			$(this).siblings('.inside').toggle();
+		});
+	});
+</script>
+</head>
+<body class="press-this wp-admin">
+<div id="wphead"></div>
+<form action="press-this.php?action=post" method="post">
+<div id="poststuff" class="metabox-holder">
+	<div id="side-info-column">
+		<div class="sleeve">
+			<h1 id="viewsite"><a href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>
+
+			<?php wp_nonce_field('press-this') ?>
+			<input type="hidden" name="post_type" id="post_type" value="text"/>
+			<input type="hidden" name="autosave" id="autosave" />
+			<input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
+			<input type="hidden" id="prev_status" name="prev_status" value="draft" />
+
+			<!-- This div holds the photo metadata -->
+			<div class="photolist"></div>
+
+			<div id="submitdiv" class="stuffbox">
+				<div class="inside">
+					<p>
+					<?php
+						submit_button( __( 'Save Draft' ), 'button', 'draft', false, array( 'id' => 'save' ) );
+						if ( current_user_can('publish_posts') ) {
+							submit_button( __( 'Publish' ), 'primary', 'publish', false );
+						} else {
+							echo '<br /><br />';
+							submit_button( __( 'Submit for Review' ), 'primary', 'review', false );
+						} ?>
+						<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="saving" style="display:none;" />
+					</p>
+					<?php if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) :
+							$post_formats = get_theme_support( 'post-formats' );
+							if ( is_array( $post_formats[0] ) ) :
+								$default_format = get_option( 'default_post_format', '0' );
+						?>
+					<p>
+						<label for="post_format"><?php _e( 'Post Format:' ); ?>
+						<select name="post_format" id="post_format">
+							<option value="0"><?php _e( 'Standard' ); ?></option>
+						<?php foreach ( $post_formats[0] as $format ): ?>
+							<option<?php selected( $default_format, $format ); ?> value="<?php echo esc_attr( $format ); ?>"> <?php echo esc_html( get_post_format_string( $format ) ); ?></option>
+						<?php endforeach; ?>
+						</select></label>
+					</p>
+					<?php endif; endif; ?>
+				</div>
+			</div>
+
+			<?php $tax = get_taxonomy( 'category' ); ?>
+			<div id="categorydiv" class="postbox">
+				<div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>"><br /></div>
+				<h3 class="hndle"><?php _e('Categories') ?></h3>
+				<div class="inside">
+				<div id="taxonomy-category" class="categorydiv">
+
+					<ul id="category-tabs" class="category-tabs">
+						<li class="tabs"><a href="#category-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
+						<li class="hide-if-no-js"><a href="#category-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
+					</ul>
+
+					<div id="category-pop" class="tabs-panel" style="display: none;">
+						<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
+							<?php $popular_ids = wp_popular_terms_checklist( 'category' ); ?>
+						</ul>
+					</div>
+
+					<div id="category-all" class="tabs-panel">
+						<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
+							<?php wp_terms_checklist($post_ID, array( 'taxonomy' => 'category', 'popular_cats' => $popular_ids ) ) ?>
+						</ul>
+					</div>
+
+					<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
+					<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
+					<?php endif; ?>
+					<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
+						<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 printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>
+								</a>
+							</h4>
+							<p id="category-add" class="category-add wp-hidden-child">
+								<label class="screen-reader-text" for="newcategory"><?php echo $tax->labels->add_new_item; ?></label>
+								<input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
+								<label class="screen-reader-text" for="newcategory_parent">
+									<?php echo $tax->labels->parent_item_colon; ?>
+								</label>
+								<?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3 ) ); ?>
+								<input type="button" id="category-add-submit" class="add:categorychecklist:category-add button category-add-sumbit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
+								<?php wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); ?>
+								<span id="category-ajax-response"></span>
+							</p>
+						</div>
+					<?php endif; ?>
+				</div>
+				</div>
+			</div>
+
+			<div id="tagsdiv-post_tag" class="stuffbox" >
+				<div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
+					<br/>
+				</div>
+				<h3><span><?php _e('Post Tags'); ?></span></h3>
+				<div class="inside">
+					<div class="tagsdiv" id="post_tag">
+						<p class="jaxtag">
+							<label class="screen-reader-text" for="newtag"><?php _e('Post Tags'); ?></label>
+							<input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
+							<div class="ajaxtag">
+								<input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
+								<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
+							</div>
+						</p>
+						<div class="tagchecklist"></div>
+					</div>
+					<p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags in Post Tags'); ?></a></p>
+				</div>
+			</div>
+		</div>
+	</div>
+	<div class="posting">
+		<?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
+		<div id="message" class="updated"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit Post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
+		<?php } ?>
+
+		<div id="titlediv">
+			<div class="titlewrap">
+				<input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
+			</div>
+		</div>
+
+		<div id="extra-fields" style="display: none"></div>
+
+		<div class="postdivrich">
+			<ul id="actions" class="actions">
+
+				<li id="photo_button">
+					Add: <?php if ( current_user_can('upload_files') ) { ?><a title="<?php _e('Insert an Image'); ?>" href="#">
+<img alt="<?php _e('Insert an Image'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-image.gif?ver=20100531' ) ); ?>"/></a>
+					<?php } ?>
+				</li>
+				<li id="video_button">
+					<a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-video.gif?ver=20100531' ) ); ?>"/></a>
+				</li>
+				<?php if ( user_can_richedit() ) { ?>
+				<li id="switcher">
+					<?php wp_print_scripts( 'quicktags' ); ?>
+					<?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
+					<a id="edButtonHTML" onclick="switchEditors.go('content', 'html');"><?php _e('HTML'); ?></a>
+					<a id="edButtonPreview" class="active" onclick="switchEditors.go('content', 'tinymce');"><?php _e('Visual'); ?></a>
+					<div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('content')" /></div>
+				</li>
+				<?php } ?>
+			</ul>
+			<div id="quicktags"></div>
+			<div class="editor-container">
+				<textarea name="content" id="content" style="width:100%;" class="theEditor" rows="15"><?php
+					if ( $selection )
+						echo wp_richedit_pre($selection);
+					if ( $url ) {
+						echo '<p>';
+						if ( $selection )
+							_e('via ');
+						printf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) );
+					}
+				?></textarea>
+			</div>
+		</div>
+	</div>
+</div>
+</form>
+<?php do_action('admin_print_footer_scripts'); ?>
+<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
+</body>
+</html>
Index: /tags/3.1/wp-admin/profile.php
===================================================================
--- /tags/3.1/wp-admin/profile.php	(revision 17487)
+++ /tags/3.1/wp-admin/profile.php	(revision 17487)
@@ -0,0 +1,19 @@
+<?php
+/**
+ * User Profile Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * This is a profile page.
+ *
+ * @since 2.5.0
+ * @var bool
+ */
+define('IS_PROFILE_PAGE', true);
+
+/** Load User Editing Page */
+require_once('./user-edit.php');
+?>
Index: /tags/3.1/wp-admin/revision.php
===================================================================
--- /tags/3.1/wp-admin/revision.php	(revision 17487)
+++ /tags/3.1/wp-admin/revision.php	(revision 17487)
@@ -0,0 +1,223 @@
+<?php
+/**
+ * Revisions administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+wp_enqueue_script('list-revisions');
+
+wp_reset_vars(array('revision', 'left', 'right', 'action'));
+
+$revision_id = absint($revision);
+$left        = absint($left);
+$right       = absint($right);
+
+$redirect = 'edit.php';
+
+switch ( $action ) :
+case 'restore' :
+	if ( !$revision = wp_get_post_revision( $revision_id ) )
+		break;
+	if ( !current_user_can( 'edit_post', $revision->post_parent ) )
+		break;
+	if ( !$post = get_post( $revision->post_parent ) )
+		break;
+
+	// Revisions disabled and we're not looking at an autosave
+	if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) {
+		$redirect = 'edit.php?post_type=' . $post->post_type;
+		break;
+	}
+
+	check_admin_referer( "restore-post_$post->ID|$revision->ID" );
+
+	wp_restore_post_revision( $revision->ID );
+	$redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) );
+	break;
+case 'diff' :
+	if ( !$left_revision  = get_post( $left ) )
+		break;
+	if ( !$right_revision = get_post( $right ) )
+		break;
+
+	if ( !current_user_can( 'read_post', $left_revision->ID ) || !current_user_can( 'read_post', $right_revision->ID ) )
+		break;
+
+	// If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post
+	if ( $left_revision->ID == $right_revision->ID ) {
+		$redirect = get_edit_post_link( $left_revision->ID );
+		include( './js/revisions-js.php' );
+		break;
+	}
+
+	// Don't allow reverse diffs?
+	if ( strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt) ) {
+		$redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
+		break;
+	}
+
+	if ( $left_revision->ID == $right_revision->post_parent ) // right is a revision of left
+		$post =& $left_revision;
+	elseif ( $left_revision->post_parent == $right_revision->ID ) // left is a revision of right
+		$post =& $right_revision;
+	elseif ( $left_revision->post_parent == $right_revision->post_parent ) // both are revisions of common parent
+		$post = get_post( $left_revision->post_parent );
+	else
+		break; // Don't diff two unrelated revisions
+
+	if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled
+		if (
+			// we're not looking at an autosave
+			( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )
+		||
+			// we're not comparing an autosave to the current post
+			( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID )
+		) {
+			$redirect = 'edit.php?post_type=' . $post->post_type;
+			break;
+		}
+	}
+
+	if (
+		// They're the same
+		$left_revision->ID == $right_revision->ID
+	||
+		// Neither is a revision
+		( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )
+	)
+		break;
+
+	$post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
+	$h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
+	$title = __( 'Revisions' );
+
+	$left  = $left_revision->ID;
+	$right = $right_revision->ID;
+
+	$redirect = false;
+	break;
+case 'view' :
+default :
+	if ( !$revision = wp_get_post_revision( $revision_id ) )
+		break;
+	if ( !$post = get_post( $revision->post_parent ) )
+		break;
+
+	if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )
+		break;
+
+	// Revisions disabled and we're not looking at an autosave
+	if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) {
+		$redirect = 'edit.php?post_type=' . $post->post_type;
+		break;
+	}
+
+	$post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
+	$revision_title = wp_post_revision_title( $revision, false );
+	$h2 = sprintf( __( 'Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
+	$title = __( 'Revisions' );
+
+	// Sets up the diff radio buttons
+	$left  = $revision->ID;
+	$right = $post->ID;
+
+	$redirect = false;
+	break;
+endswitch;
+
+// Empty post_type means either malformed object found, or no valid parent was found.
+if ( !$redirect && empty($post->post_type) )
+	$redirect = 'edit.php';
+
+if ( !empty($redirect) ) {
+	wp_redirect( $redirect );
+	exit;
+}
+
+// This is so that the correct "Edit" menu item is selected.
+if ( !empty($post->post_type) && 'post' != $post->post_type )
+	$parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type;
+else
+	$parent_file = $submenu_file = 'edit.php';
+
+require_once( './admin-header.php' );
+
+?>
+
+<div class="wrap">
+
+<h2 class="long-header"><?php echo $h2; ?></h2>
+
+<table class="form-table ie-fixed">
+	<col class="th" />
+<?php if ( 'diff' == $action ) : ?>
+<tr id="revision">
+	<th scope="row"></th>
+	<th scope="col" class="th-full">
+		<span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?></span>
+		<span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?></span>
+	</th>
+</tr>
+<?php endif;
+
+// use get_post_to_edit filters?
+$identical = true;
+foreach ( _wp_post_revision_fields() as $field => $field_title ) :
+	if ( 'diff' == $action ) {
+		$left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field );
+		$right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field );
+		if ( !$content = wp_text_diff( $left_content, $right_content ) )
+			continue; // There is no difference between left and right
+		$identical = false;
+	} else {
+		add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' );
+		$content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field );
+	}
+	?>
+
+	<tr id="revision-field-<?php echo $field; ?>">
+		<th scope="row"><?php echo esc_html( $field_title ); ?></th>
+		<td><div class="pre"><?php echo $content; ?></div></td>
+	</tr>
+
+	<?php
+
+endforeach;
+
+if ( 'diff' == $action && $identical ) :
+
+	?>
+
+	<tr><td colspan="2"><div class="updated"><p><?php _e( 'These revisions are identical.' ); ?></p></div></td></tr>
+
+	<?php
+
+endif;
+
+?>
+
+</table>
+
+<br class="clear" />
+
+<h3><?php echo $title; ?></h3>
+
+<?php
+
+$args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left );
+if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') )
+	$args['type'] = 'autosave';
+
+wp_list_post_revisions( $post, $args );
+
+?>
+
+</div>
+
+<?php
+require_once( './admin-footer.php' );
Index: /tags/3.1/wp-admin/setup-config.php
===================================================================
--- /tags/3.1/wp-admin/setup-config.php	(revision 17487)
+++ /tags/3.1/wp-admin/setup-config.php	(revision 17487)
@@ -0,0 +1,277 @@
+<?php
+/**
+ * Retrieves and creates the wp-config.php file.
+ *
+ * The permissions for the base directory must allow for writing files in order
+ * for the wp-config.php to be created using this page.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * We are installing.
+ *
+ * @package WordPress
+ */
+define('WP_INSTALLING', true);
+
+/**
+ * We are blissfully unaware of anything.
+ */
+define('WP_SETUP_CONFIG', true);
+
+/**
+ * Disable error reporting
+ *
+ * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
+ */
+error_reporting(0);
+
+/**#@+
+ * These three defines are required to allow us to use require_wp_db() to load
+ * the database class while being wp-content/db.php aware.
+ * @ignore
+ */
+define('ABSPATH', dirname(dirname(__FILE__)).'/');
+define('WPINC', 'wp-includes');
+define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
+define('WP_DEBUG', false);
+/**#@-*/
+
+require_once(ABSPATH . WPINC . '/load.php');
+require_once(ABSPATH . WPINC . '/compat.php');
+require_once(ABSPATH . WPINC . '/functions.php');
+require_once(ABSPATH . WPINC . '/class-wp-error.php');
+require_once(ABSPATH . WPINC . '/version.php');
+
+if (!file_exists(ABSPATH . 'wp-config-sample.php'))
+	wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
+
+$configFile = file(ABSPATH . 'wp-config-sample.php');
+
+// Check if wp-config.php has been created
+if (file_exists(ABSPATH . 'wp-config.php'))
+	wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
+
+// Check if wp-config.php exists above the root directory but is not part of another install
+if (file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-settings.php'))
+	wp_die("<p>The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
+
+if ( version_compare( $required_php_version, phpversion(), '>' ) )
+	wp_die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %1$s but WordPress requires at least %2$s.'/*/WP_I18N_OLD_PHP*/, phpversion(), $required_php_version ) );
+
+if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') )
+	wp_die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
+
+if (isset($_GET['step']))
+	$step = $_GET['step'];
+else
+	$step = 0;
+
+/**
+ * Display setup wp-config.php file header.
+ *
+ * @ignore
+ * @since 2.3.0
+ * @package WordPress
+ * @subpackage Installer_WP_Config
+ */
+function display_header() {
+	header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!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>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>WordPress &rsaquo; Setup Configuration File</title>
+<link rel="stylesheet" href="css/install.css" type="text/css" />
+
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
+<?php
+}//end function display_header();
+
+switch($step) {
+	case 0:
+		display_header();
+?>
+
+<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
+<ol>
+	<li>Database name</li>
+	<li>Database username</li>
+	<li>Database password</li>
+	<li>Database host</li>
+	<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 Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;</p>
+
+<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button">Let&#8217;s go!</a></p>
+<?php
+	break;
+
+	case 1:
+		display_header();
+	?>
+<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 class="form-table">
+		<tr>
+			<th scope="row"><label for="dbname">Database Name</label></th>
+			<td><input name="dbname" id="dbname" type="text" size="25" value="wordpress" /></td>
+			<td>The name of the database you want to run WP in. </td>
+		</tr>
+		<tr>
+			<th scope="row"><label for="uname">User Name</label></th>
+			<td><input name="uname" id="uname" type="text" size="25" value="username" /></td>
+			<td>Your MySQL username</td>
+		</tr>
+		<tr>
+			<th scope="row"><label for="pwd">Password</label></th>
+			<td><input name="pwd" id="pwd" type="text" size="25" value="password" /></td>
+			<td>...and MySQL password.</td>
+		</tr>
+		<tr>
+			<th scope="row"><label for="dbhost">Database Host</label></th>
+			<td><input name="dbhost" id="dbhost" type="text" size="25" value="localhost" /></td>
+			<td>You should be able to get this info from your web host, if <code>localhost</code> does not work.</td>
+		</tr>
+		<tr>
+			<th scope="row"><label for="prefix">Table Prefix</label></th>
+			<td><input name="prefix" id="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
+			<td>If you want to run multiple WordPress installations in a single database, change this.</td>
+		</tr>
+	</table>
+	<?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="true" /><?php } ?>
+	<p class="step"><input name="submit" type="submit" value="Submit" class="button" /></p>
+</form>
+<?php
+	break;
+
+	case 2:
+	$dbname  = trim($_POST['dbname']);
+	$uname   = trim($_POST['uname']);
+	$passwrd = trim($_POST['pwd']);
+	$dbhost  = trim($_POST['dbhost']);
+	$prefix  = trim($_POST['prefix']);
+	if ( empty($prefix) )
+		$prefix = 'wp_';
+
+	// Validate $prefix: it can only contain letters, numbers and underscores
+	if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
+		wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ );
+
+	// Test the db connection.
+	/**#@+
+	 * @ignore
+	 */
+	define('DB_NAME', $dbname);
+	define('DB_USER', $uname);
+	define('DB_PASSWORD', $passwrd);
+	define('DB_HOST', $dbhost);
+	/**#@-*/
+
+	// We'll fail here if the values are no good.
+	require_wp_db();
+	if ( ! empty( $wpdb->error ) ) {
+		$back = '<p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">Try Again</a></p>';
+		wp_die( $wpdb->error->get_error_message() . $back );
+	}
+
+	// Fetch or generate keys and salts.
+	$no_api = isset( $_POST['noapi'] );
+	require_once( ABSPATH . WPINC . '/plugin.php' );
+	require_once( ABSPATH . WPINC . '/l10n.php' );
+	require_once( ABSPATH . WPINC . '/pomo/translations.php' );
+	if ( ! $no_api ) {
+		require_once( ABSPATH . WPINC . '/class-http.php' );
+		require_once( ABSPATH . WPINC . '/http.php' );
+		wp_fix_server_vars();
+		/**#@+
+		 * @ignore
+		 */
+		function get_bloginfo() {
+			return ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . str_replace( $_SERVER['PHP_SELF'], '/wp-admin/setup-config.php', '' ) );
+		}
+		/**#@-*/
+		$secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
+	}
+
+	if ( $no_api || is_wp_error( $secret_keys ) ) {
+		$secret_keys = array();
+		require_once( ABSPATH . WPINC . '/pluggable.php' );
+		for ( $i = 0; $i < 8; $i++ ) {
+			$secret_keys[] = wp_generate_password( 64, true, true );
+		}
+	} else {
+		$secret_keys = explode( "\n", wp_remote_retrieve_body( $secret_keys ) );
+		foreach ( $secret_keys as $k => $v ) {
+			$secret_keys[$k] = substr( $v, 28, 64 );
+		}
+	}
+	$key = 0;
+
+	foreach ($configFile as $line_num => $line) {
+		switch (substr($line,0,16)) {
+			case "define('DB_NAME'":
+				$configFile[$line_num] = str_replace("database_name_here", $dbname, $line);
+				break;
+			case "define('DB_USER'":
+				$configFile[$line_num] = str_replace("'username_here'", "'$uname'", $line);
+				break;
+			case "define('DB_PASSW":
+				$configFile[$line_num] = str_replace("'password_here'", "'$passwrd'", $line);
+				break;
+			case "define('DB_HOST'":
+				$configFile[$line_num] = str_replace("localhost", $dbhost, $line);
+				break;
+			case '$table_prefix  =':
+				$configFile[$line_num] = str_replace('wp_', $prefix, $line);
+				break;
+			case "define('AUTH_KEY":
+			case "define('SECURE_A":
+			case "define('LOGGED_I":
+			case "define('NONCE_KE":
+			case "define('AUTH_SAL":
+			case "define('SECURE_A":
+			case "define('LOGGED_I":
+			case "define('NONCE_SA":
+				$configFile[$line_num] = str_replace('put your unique phrase here', $secret_keys[$key++], $line );
+				break;
+		}
+	}
+	if ( ! is_writable(ABSPATH) ) :
+		display_header();
+?>
+<p>Sorry, but I can't write the <code>wp-config.php</code> file.</p>
+<p>You can create the <code>wp-config.php</code> manually and paste the following text into it.</p>
+<textarea cols="98" rows="15" class="code"><?php
+		foreach( $configFile as $line ) {
+			echo htmlentities($line, ENT_COMPAT, 'UTF-8');
+		}
+?></textarea>
+<p>After you've done that, click "Run the install."</p>
+<p class="step"><a href="install.php" class="button">Run the install</a></p>
+<?php
+	else :
+		$handle = fopen(ABSPATH . 'wp-config.php', 'w');
+		foreach( $configFile as $line ) {
+			fwrite($handle, $line);
+		}
+		fclose($handle);
+		chmod(ABSPATH . '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&hellip;</p>
+
+<p class="step"><a href="install.php" class="button">Run the install</a></p>
+<?php
+	endif;
+	break;
+}
+?>
+</body>
+</html>
Index: /tags/3.1/wp-admin/theme-editor.php
===================================================================
--- /tags/3.1/wp-admin/theme-editor.php	(revision 17487)
+++ /tags/3.1/wp-admin/theme-editor.php	(revision 17487)
@@ -0,0 +1,271 @@
+<?php
+/**
+ * Theme editor administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( is_multisite() && ! is_network_admin() ) {
+	wp_redirect( network_admin_url( 'theme-editor.php' ) );
+	exit();
+}
+
+if ( !current_user_can('edit_themes') )
+	wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
+
+$title = __("Edit Themes");
+$parent_file = 'themes.php';
+
+$help = '<p>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.') . '</p>';
+$help .= '<p>' . __('Begin by choosing a theme to edit from the dropdown menu and clicking Select. A list then appears of all the template files. Clicking once on any file name causes the file to appear in the large Editor box.') . '</p>';
+$help .= '<p>' . __('For PHP files, you can use the Documentation dropdown to select from functions recognized in that file. Lookup takes you to a web page with reference material about that particular function.') . '</p>';
+$help .= '<p>' . __('After typing in your edits, click Update File.') . '</p>';
+$help .= '<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>';
+$help .= '<p>' . __('Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="http://codex.wordpress.org/Child_Themes" target="_blank">child theme</a> instead.') . '</p>';
+if ( is_network_admin() )
+	$help .= '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>';
+$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Editing_Files" target="_blank">Documentation on Editing Files</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Template_Tags" target="_blank">Documentation on Template Tags</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
+add_contextual_help($current_screen, $help);
+
+wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme', 'dir'));
+
+wp_admin_css( 'theme-editor' );
+
+$themes = get_themes();
+
+if (empty($theme)) {
+	$theme = get_current_theme();
+} else {
+	$theme = stripslashes($theme);
+}
+
+if ( ! isset($themes[$theme]) )
+	wp_die(__('The requested theme does not exist.'));
+
+$allowed_files = array_merge( $themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files'] );
+
+if ( empty( $file ) ) {
+	if ( false !== array_search( $themes[$theme]['Stylesheet Dir'] . '/style.css', $allowed_files ) )
+		$file = $themes[$theme]['Stylesheet Dir'] . '/style.css';
+	else
+		$file = $allowed_files[0];
+} else {
+	$file = stripslashes($file);
+	if ( 'theme' == $dir ) {
+		$file = dirname(dirname($themes[$theme]['Template Dir'])) . $file ;
+	} else if ( 'style' == $dir) {
+		$file = dirname(dirname($themes[$theme]['Stylesheet Dir'])) . $file ;
+	}
+}
+
+validate_file_to_edit($file, $allowed_files);
+$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0;
+$file_show = basename( $file );
+
+switch($action) {
+
+case 'update':
+
+	check_admin_referer('edit-theme_' . $file . $theme);
+
+	$newcontent = stripslashes($_POST['newcontent']);
+	$theme = urlencode($theme);
+	if (is_writeable($file)) {
+		//is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
+		$f = fopen($file, 'w+');
+		if ($f !== FALSE) {
+			fwrite($f, $newcontent);
+			fclose($f);
+			$location = "theme-editor.php?file=$file&theme=$theme&a=te&scrollto=$scrollto";
+		} else {
+			$location = "theme-editor.php?file=$file&theme=$theme&scrollto=$scrollto";
+		}
+	} else {
+		$location = "theme-editor.php?file=$file&theme=$theme&scrollto=$scrollto";
+	}
+
+	$location = wp_kses_no_null($location);
+	$strip = array('%0d', '%0a', '%0D', '%0A');
+	$location = _deep_replace($strip, $location);
+	header("Location: $location");
+	exit();
+
+break;
+
+default:
+
+	require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+	update_recently_edited($file);
+
+	if ( !is_file($file) )
+		$error = 1;
+
+	$content = '';
+	if ( !$error && filesize($file) > 0 ) {
+		$f = fopen($file, 'r');
+		$content = fread($f, filesize($file));
+
+		if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) {
+			$functions = wp_doc_link_parse( $content );
+
+			$docs_select = '<select name="docs-list" id="docs-list">';
+			$docs_select .= '<option value="">' . esc_attr__( 'Function Name...' ) . '</option>';
+			foreach ( $functions as $function ) {
+				$docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>';
+			}
+			$docs_select .= '</select>';
+		}
+
+		$content = esc_textarea( $content );
+	}
+
+	?>
+<?php if (isset($_GET['a'])) : ?>
+ <div id="message" class="updated"><p><?php _e('File edited successfully.') ?></p></div>
+<?php endif;
+
+$description = get_file_description($file);
+$desc_header = ( $description != $file_show ) ? "$description <span>($file_show)</span>" : $file_show;
+
+$is_child_theme = $themes[$theme]['Template'] != $themes[$theme]['Stylesheet'];
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<div class="fileedit-sub">
+<div class="alignleft">
+<h3><?php echo $themes[$theme]['Name'] . ': ' . $desc_header; ?></h3>
+</div>
+<div class="alignright">
+	<form action="theme-editor.php" method="post">
+		<strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong>
+		<select name="theme" id="theme">
+<?php
+	foreach ($themes as $a_theme) {
+	$theme_name = $a_theme['Name'];
+	if ($theme_name == $theme) $selected = " selected='selected'";
+	else $selected = '';
+	$theme_name = esc_attr($theme_name);
+	echo "\n\t<option value=\"$theme_name\" $selected>$theme_name</option>";
+}
+?>
+		</select>
+		<?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
+	</form>
+</div>
+<br class="clear" />
+</div>
+	<div id="templateside">
+<?php
+if ($allowed_files) :
+?>
+	<h3><?php _e('Templates'); ?></h3>
+	<?php if ( $is_child_theme ) : ?>
+	<p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), $themes[$theme]['Parent Theme'] ); ?></p>
+	<?php endif; ?>
+	<ul>
+<?php
+	$template_mapping = array();
+	$template_dir = $themes[$theme]['Template Dir'];
+	foreach ( $themes[$theme]['Template Files'] as $template_file ) {
+		// Don't show parent templates.
+		if ( $is_child_theme && strpos( $template_file, trailingslashit( $template_dir ) ) === 0 )
+			continue;
+
+		$description = trim( get_file_description($template_file) );
+		$template_show = basename($template_file);
+		$filedesc = ( $description != $template_file ) ? "$description<br /><span class='nonessential'>($template_show)</span>" : "$description";
+		$filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($template_show)</span></span>" : $filedesc;
+		$template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
+	}
+	ksort( $template_mapping );
+	while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :
+	?>
+		<li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>&amp;dir=theme"><?php echo $filedesc ?></a></li>
+<?php endwhile; ?>
+	</ul>
+	<h3><?php /* translators: Theme stylesheets in theme editor */ _ex('Styles', 'Theme stylesheets in theme editor'); ?></h3>
+	<ul>
+<?php
+	$template_mapping = array();
+	$stylesheet_dir = $themes[$theme]['Stylesheet Dir'];
+	foreach ( $themes[$theme]['Stylesheet Files'] as $style_file ) {
+		// Don't show parent styles.
+		if ( $is_child_theme && strpos( $style_file, trailingslashit( $template_dir ) ) === 0 )
+			continue;
+
+		$description = trim( get_file_description($style_file) );
+		$style_show = basename($style_file);
+		$filedesc = ( $description != $style_file ) ? "$description<br /><span class='nonessential'>($style_show)</span>" : "$description";
+		$filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($style_show)</span></span>" : $filedesc;
+		$template_mapping[ $description ] = array( _get_template_edit_filename($style_file, $stylesheet_dir), $filedesc );
+	}
+	ksort( $template_mapping );
+	while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) :
+		?>
+		<li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>&amp;dir=style"><?php echo $filedesc ?></a></li>
+<?php endwhile; ?>
+	</ul>
+<?php endif; ?>
+</div>
+<?php if (!$error) { ?>
+	<form name="template" id="template" action="theme-editor.php" method="post">
+	<?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
+		 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
+		 <input type="hidden" name="action" value="update" />
+		 <input type="hidden" name="file" value="<?php echo esc_attr($file) ?>" />
+		 <input type="hidden" name="theme" value="<?php echo esc_attr($theme) ?>" />
+		 <input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" />
+		 </div>
+	<?php if ( isset($functions ) && count($functions) ) { ?>
+		<div id="documentation" class="hide-if-no-js">
+		<label for="docs-list"><?php _e('Documentation:') ?></label>
+		<?php echo $docs_select; ?>
+		<input type="button" class="button" value=" <?php esc_attr_e( 'Lookup' ); ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&amp;locale=<?php echo urlencode( get_locale() ) ?>&amp;version=<?php echo urlencode( $wp_version ) ?>&amp;redirect=true'); }" />
+		</div>
+	<?php } ?>
+
+		<div>
+		<?php if ( is_child_theme() && ! $is_child_theme && $themes[$theme]['Template'] == get_option('template') ) : ?>
+			<p><?php if ( is_writeable( $file ) ) { ?><strong><?php _e( 'Caution:' ); ?></strong><?php } ?>
+			<?php _e( 'This is a file in your current parent theme.' ); ?></p>
+		<?php endif; ?>
+<?php
+	if ( is_writeable( $file ) ) :
+		submit_button( __( 'Update File' ), 'primary', 'submit', true, array( 'tabindex' => '2' ) );
+	else : ?>
+<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; ?>
+		</div>
+	</form>
+<?php
+	} else {
+		echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
+	}
+?>
+<br class="clear" />
+</div>
+<script type="text/javascript">
+/* <![CDATA[ */
+jQuery(document).ready(function($){
+	$('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
+	$('#newcontent').scrollTop( $('#scrollto').val() );
+});
+/* ]]> */
+</script>
+<?php
+break;
+}
+
+include(ABSPATH . "wp-admin/admin-footer.php");
Index: /tags/3.1/wp-admin/theme-install.php
===================================================================
--- /tags/3.1/wp-admin/theme-install.php	(revision 17487)
+++ /tags/3.1/wp-admin/theme-install.php	(revision 17487)
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Install theme administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+if ( !defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'theme-information' == $_GET['tab'] ) )
+	define( 'IFRAME_REQUEST', true );
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( ! current_user_can('install_themes') )
+	wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
+
+if ( is_multisite() && ! is_network_admin() ) {
+	wp_redirect( network_admin_url( 'theme-install.php' ) );
+	exit();
+}
+
+$wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+$wp_list_table->prepare_items();
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+$title = __('Install Themes');
+$parent_file = 'themes.php';
+if ( !is_network_admin() )
+	$submenu_file = 'themes.php';
+
+wp_enqueue_style( 'theme-install' );
+wp_enqueue_script( 'theme-install' );
+
+add_thickbox();
+wp_enqueue_script( 'theme-preview' );
+
+$body_id = $tab;
+
+do_action('install_themes_pre_' . $tab); //Used to override the general interface, Eg, install or theme information.
+
+$help = '<p>' . sprintf(__('You can find additional themes for your site by using the Theme Browser/Installer on this screen, which will display themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. These themes are designed and developed by third parties, are available free of charge, and are licensed under the GNU General Public License, version 2, just like WordPress.'), 'http://wordpress.org/extend/themes/') . '</p>';
+$help .= '<p>' . __('You can Search for themes by keyword, author, or tag, or can get more specific and search by criteria listed in the feature filter. Alternately, you can browse the themes that are Featured, Newest, or Recently Updated. When you find a theme you like, you can preview it or install it.') . '</p>';
+$help .= '<p>' . __('You can Upload a theme manually if you have already downloaded its ZIP archive onto your computer (make sure it is from a trusted and original source). You can also do it the old-fashioned way and copy a downloaded theme&#8217;s folder via FTP into your <code>/wp-content/themes</code> directory.') . '</p>';
+$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes#Adding_New_Themes" target="_blank">Documentation on Adding New Themes</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
+add_contextual_help($current_screen, $help);
+
+include(ABSPATH . 'wp-admin/admin-header.php');
+?>
+<div class="wrap">
+<?php
+screen_icon();
+
+if ( is_network_admin() ) : ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+<?php else : ?>
+<h2 class="nav-tab-wrapper"><a href="themes.php" class="nav-tab"><?php echo esc_html_x('Manage Themes', 'theme'); ?></a><a href="theme-install.php" class="nav-tab nav-tab-active"><?php echo esc_html( $title ); ?></a></h2>
+
+<?php
+endif;
+
+$wp_list_table->views(); ?>
+
+<br class="clear" />
+<?php do_action('install_themes_' . $tab, $paged); ?>
+</div>
+<?php
+include(ABSPATH . 'wp-admin/admin-footer.php');
+
Index: /tags/3.1/wp-admin/themes.php
===================================================================
--- /tags/3.1/wp-admin/themes.php	(revision 17487)
+++ /tags/3.1/wp-admin/themes.php	(revision 17487)
@@ -0,0 +1,243 @@
+<?php
+/**
+ * Themes administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+$wp_list_table = _get_list_table('WP_Themes_List_Table');
+
+if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
+	if ( 'activate' == $_GET['action'] ) {
+		check_admin_referer('switch-theme_' . $_GET['template']);
+		switch_theme($_GET['template'], $_GET['stylesheet']);
+		wp_redirect( admin_url('themes.php?activated=true') );
+		exit;
+	} elseif ( 'delete' == $_GET['action'] ) {
+		check_admin_referer('delete-theme_' . $_GET['template']);
+		if ( !current_user_can('delete_themes') )
+			wp_die( __( 'Cheatin&#8217; uh?' ) );
+		delete_theme($_GET['template']);
+		wp_redirect( admin_url('themes.php?deleted=true') );
+		exit;
+	}
+}
+
+$wp_list_table->prepare_items();
+
+$title = __('Manage Themes');
+$parent_file = 'themes.php';
+
+if ( current_user_can( 'switch_themes' ) ) :
+
+$help = '<p>' . __('Aside from the default theme included with your WordPress installation, themes are designed and developed by third parties.') . '</p>';
+$help .= '<p>' . __('You can see your active theme at the top of the screen. Below are the other themes you have installed that are not currently in use. You can see what your site would look like with one of these themes by clicking the Preview link. To change themes, click the Activate link.') . '</p>';
+if ( current_user_can('install_themes') )
+	$help .= '<p>' . sprintf(__('If you would like to see more themes to choose from, click on the &#8220;Install Themes&#8221; tab and you will be able to browse or search for additional themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. Themes in the WordPress.org Theme Directory are designed and developed by third parties, and are licensed under the GNU General Public License, version 2, just like WordPress. Oh, and they&#8217;re free!'), 'http://wordpress.org/extend/themes/') . '</p>';
+
+$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
+add_contextual_help($current_screen, $help);
+
+add_thickbox();
+wp_enqueue_script( 'theme-preview' );
+wp_enqueue_script( 'theme' );
+wp_enqueue_style( 'theme-install' );
+
+endif;
+
+require_once('./admin-header.php');
+?>
+
+<?php if ( ! validate_current_theme() ) : ?>
+<div id="message1" class="updated"><p><?php _e('The active theme is broken.  Reverting to the default theme.'); ?></p></div>
+<?php elseif ( isset($_GET['activated']) ) :
+		if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) && current_user_can('edit_theme_options') ) { ?>
+<div id="message2" class="updated"><p><?php printf( __('New theme activated. This theme supports widgets, please visit the <a href="%s">widgets settings</a> screen to configure them.'), admin_url( 'widgets.php' ) ); ?></p></div><?php
+		} else { ?>
+<div id="message2" class="updated"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php
+		}
+	elseif ( isset($_GET['deleted']) ) : ?>
+<div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div>
+<?php endif; ?>
+
+<div class="wrap"><?php
+screen_icon();
+if ( !is_multisite() ) : ?>
+<h2 class="nav-tab-wrapper">
+<a href="themes.php" class="nav-tab nav-tab-active"><?php echo esc_html( $title ); ?></a>
+	<?php if ( current_user_can('install_themes') ) : ?>
+<a href="<?php echo admin_url( 'theme-install.php'); ?>" class="nav-tab"><?php echo esc_html_x('Install Themes', 'theme'); ?></a>
+	<?php endif;
+else : ?>
+<h2>
+<?php echo esc_html( $title ); ?>
+<?php endif; ?>
+</h2>
+
+<h3><?php _e('Current Theme'); ?></h3>
+<div id="current-theme">
+<?php if ( $ct->screenshot ) : ?>
+<img src="<?php echo $ct->theme_root_uri . '/' . $ct->stylesheet . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
+<?php endif; ?>
+<h4><?php
+	/* translators: 1: theme title, 2: theme version, 3: theme author */
+	printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h4>
+<p class="theme-description"><?php echo $ct->description; ?></p>
+<div class="theme-options">
+	<span><?php _e( 'Options:' )?></span>
+	<?php
+	// Pretend you didn't see this.
+	$options = array();
+	if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
+		foreach ( (array) $submenu['themes.php'] as $item) {
+			$class = '';
+			if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] )
+				continue;
+			// 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]}") || !empty($menu_hook))
+					$options[] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
+				else
+					$options[] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
+			} else if ( current_user_can($item[1]) ) {
+				if ( file_exists(ABSPATH . 'wp-admin/' . $item[2]) ) {
+					$options[] = "<a href='{$item[2]}'$class>{$item[0]}</a>";
+				} else {
+					$options[] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>";
+				}
+			}
+		}
+	}
+	echo implode ( ' | ', $options );
+
+	if ( $ct->tags ) : ?>
+	<p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
+	<?php endif; ?>
+</div>
+<?php theme_update_available($ct); ?>
+
+</div>
+
+<br class="clear" />
+<?php
+if ( ! current_user_can( 'switch_themes' ) ) {
+	echo '</div>';
+	require( './admin-footer.php' );
+	exit;
+}
+?>
+
+<h3><?php _e('Available Themes'); ?></h3>
+
+<?php if ( !empty( $_REQUEST['s'] ) || !empty( $_REQUEST['filter'] ) || $wp_list_table->has_items() ) : ?>
+
+<form class="search-form filter-form" action="" method="get">
+
+<p class="search-box">
+	<label class="screen-reader-text" for="theme-search-input"><?php _e('Search Themes'); ?>:</label>
+	<input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
+	<?php submit_button( __( 'Search Themes' ), 'button', 'submit', false ); ?>
+	<a id="filter-click" href="?filter=1"><?php _e( 'Feature Filter' ); ?></a>
+</p>
+
+<br class="clear"/>
+
+<div id="filter-box" style="<?php if ( empty($_REQUEST['filter']) ) echo 'display: none;'; ?>">
+<?php $feature_list = get_theme_feature_list(); ?>
+	<div class="feature-filter">
+		<p class="install-help"><?php _e('Theme filters') ?></p>
+	<?php if ( !empty( $_REQUEST['filter'] ) ) : ?>
+		<input type="hidden" name="filter" value="1" />
+	<?php endif; ?>
+	<?php foreach ( $feature_list as $feature_name => $features ) :
+			$feature_name = esc_html( $feature_name ); ?>
+
+		<div class="feature-container">
+			<div class="feature-name"><?php echo $feature_name ?></div>
+
+			<ol class="feature-group">
+				<?php foreach ( $features as $key => $feature ) :
+						$feature_name = $feature;
+						$feature_name = esc_html( $feature_name );
+						$feature = esc_attr( $feature );
+						?>
+				<li>
+					<input type="checkbox" name="features[]" id="feature-id-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( in_array( $key, $wp_list_table->features ) ); ?>/>
+					<label for="feature-id-<?php echo $key; ?>"><?php echo $feature_name; ?></label>
+				</li>
+				<?php endforeach; ?>
+			</ol>
+		</div>
+	<?php endforeach; ?>
+
+	<div class="feature-container">
+		<?php submit_button( __( 'Apply Filters' ), 'button-secondary submitter', 'submit', false, array( 'style' => 'margin-left: 120px' ) ); ?>
+		&nbsp;
+		<small><a id="mini-filter-click" href="<?php echo esc_url( remove_query_arg( array('filter', 'features', 'submit') ) ); ?>"><?php _e( 'Close filters' )?></a></small>
+	</div>
+	<br/>
+	</div>
+	<br class="clear"/>
+</div>
+
+<br class="clear" />
+
+<?php endif; ?>
+
+<?php $wp_list_table->display(); ?>
+
+</form>
+<br class="clear" />
+
+<?php
+// List broken themes, if any.
+$broken_themes = get_broken_themes();
+if ( current_user_can('edit_themes') && count( $broken_themes ) ) {
+?>
+
+<h3><?php _e('Broken Themes'); ?></h3>
+<p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
+
+<table id="broken-themes">
+	<tr>
+		<th><?php _e('Name'); ?></th>
+		<th><?php _e('Description'); ?></th>
+	</tr>
+<?php
+	$theme = '';
+
+	$theme_names = array_keys($broken_themes);
+	natcasesort($theme_names);
+
+	foreach ($theme_names as $theme_name) {
+		$title = $broken_themes[$theme_name]['Title'];
+		$description = $broken_themes[$theme_name]['Description'];
+
+		$theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
+		echo "
+		<tr $theme>
+			 <td>$title</td>
+			 <td>$description</td>
+		</tr>";
+	}
+?>
+</table>
+<?php
+}
+?>
+</div>
+
+<?php require('./admin-footer.php'); ?>
Index: /tags/3.1/wp-admin/tools.php
===================================================================
--- /tags/3.1/wp-admin/tools.php	(revision 17487)
+++ /tags/3.1/wp-admin/tools.php	(revision 17487)
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Tools Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+$title = __('Tools');
+
+add_contextual_help($current_screen,
+	'<p>' . __('Press This is a bookmarklet that makes it easy to blog about something you come across on the web. You can use it to just grab a link, or to post an excerpt. Press This will even allow you to choose from images included on the page and use them in your post. Just drag the Press This link on this screen to your bookmarks bar in your browser, and you&#8217;ll be on your way to easier content creation. Clicking on it while on another website opens a popup window with all these options.') . '</p>' .
+	'<p>' . __('The Use This link for the Categories and Tags Converter will take you to the Import page, where that Converter is one of the plugins you can download. Once installed, the link on this page takes you to a screen where you can choose conversion either way.') . '</p>' .
+	'<p>' . __('Note: Turbo/Gears is no longer promoted on this screen as it was in previous versions due to the fact that Google has discontinued support for it.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Tools_Tools_SubPanel" target="_blank">Documentation on Tools</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+require_once('./admin-header.php');
+
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<?php if ( current_user_can('edit_posts') ) : ?>
+<div class="tool-box">
+	<h3 class="title"><?php _e('Press This') ?></h3>
+	<p><?php _e('Press This is a bookmarklet: a little app that runs in your browser and lets you grab bits of the web.');?></p>
+
+	<p><?php _e('Use Press This to clip text, images and videos from any web page. Then edit and add more straight from Press This before you save or publish it in a post on your site.'); ?></p>
+	<p><?php _e('Drag-and-drop the following link to your bookmarks bar or right click it and add it to your favorites for a posting shortcut.') ?></p>
+	<p class="pressthis"><a href="<?php echo htmlspecialchars( get_shortcut_link() ); ?>" title="<?php echo esc_attr(__('Press This')) ?>"><?php _e('Press This') ?></a></p>
+</div>
+<?php
+endif;
+
+if ( current_user_can( 'import' ) ) :
+$cats = get_taxonomy('category');
+$tags = get_taxonomy('post_tag');
+if ( current_user_can($cats->cap->manage_terms) || current_user_can($tags->cap->manage_terms) ) : ?>
+<div class="tool-box">
+    <h3 class="title"><?php _e( 'Categories and Tags Converter' ) ?></h3>
+    <p><?php printf( __('<a href="%s">Use this</a> to convert categories to tags or tags to categories.'), 'import.php' ); ?></p>
+</div>
+<?php
+endif;
+endif;
+
+do_action( 'tool_box' );
+?>
+</div>
+<?php
+include('./admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/update-core.php
===================================================================
--- /tags/3.1/wp-admin/update-core.php	(revision 17487)
+++ /tags/3.1/wp-admin/update-core.php	(revision 17487)
@@ -0,0 +1,492 @@
+<?php
+/**
+ * Update Core administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( is_multisite() && ! is_network_admin() ) {
+	wp_redirect( network_admin_url( 'update-core.php' ) );
+	exit();
+}
+
+if ( ! current_user_can( 'update_core' ) )
+	wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
+
+function list_core_update( $update ) {
+	global $wp_local_package, $wpdb;
+	$version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
+			$update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
+	$current = false;
+	if ( !isset($update->response) || 'latest' == $update->response )
+		$current = true;
+	$submit = __('Update Automatically');
+	$form_action = 'update-core.php?action=do-core-upgrade';
+	$php_version    = phpversion();
+	$mysql_version  = $wpdb->db_version();
+	$show_buttons = true;
+	if ( 'development' == $update->response ) {
+		$message = __('You are using a development version of WordPress.  You can update to the latest nightly build automatically or download the nightly build and install it manually:');
+		$download = __('Download nightly build');
+	} else {
+		if ( $current ) {
+			$message = sprintf(__('You have the latest version of WordPress. You do not need to update. However, if you want to re-install version %s, you can do so automatically or download the package and re-install manually:'), $version_string);
+			$submit = __('Re-install Automatically');
+			$form_action = 'update-core.php?action=do-core-reinstall';
+		} else {
+			$php_compat     = version_compare( $php_version, $update->php_version, '>=' );
+			$mysql_compat   = version_compare( $mysql_version, $update->mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
+			if ( !$mysql_compat && !$php_compat )
+				$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version );
+			elseif ( !$php_compat )
+				$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version );
+			elseif ( !$mysql_compat )
+				$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version );
+			else
+				$message = 	sprintf(__('You can update to <a href="http://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically or download the package and install it manually:'), $update->current, $version_string);
+			if ( !$mysql_compat || !$php_compat )
+				$show_buttons = false;
+		}
+		$download = sprintf(__('Download %s'), $version_string);
+	}
+
+	echo '<p>';
+	echo $message;
+	echo '</p>';
+	echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
+	wp_nonce_field('upgrade-core');
+	echo '<p>';
+	echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
+	echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
+	if ( $show_buttons ) {
+		submit_button( $submit, 'button', 'upgrade', false );
+		echo '&nbsp;<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
+	}
+	if ( 'en_US' != $update->locale )
+		if ( !isset( $update->dismissed ) || !$update->dismissed )
+			submit_button( __('Hide this update'), 'button', 'dismiss', false );
+		else
+			submit_button( __('Bring back this update'), 'button', 'undismiss', false );
+	echo '</p>';
+	if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
+	    echo '<p class="hint">'.__('This localized version contains both the translation and various other localization fixes. You can skip upgrading if you want to keep your current translation.').'</p>';
+	else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) {
+	    echo '<p class="hint">'.sprintf( __('You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.'), $update->current ).'</p>';
+	}
+	echo '</form>';
+
+}
+
+function dismissed_updates() {
+	$dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
+	if ( $dismissed ) {
+
+		$show_text = esc_js(__('Show hidden updates'));
+		$hide_text = esc_js(__('Hide hidden updates'));
+	?>
+	<script type="text/javascript">
+
+		jQuery(function($) {
+			$('dismissed-updates').show();
+			$('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
+			$('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
+		});
+	</script>
+	<?php
+		echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
+		echo '<ul id="dismissed-updates" class="core-updates dismissed">';
+		foreach( (array) $dismissed as $update) {
+			echo '<li>';
+			list_core_update( $update );
+			echo '</li>';
+		}
+		echo '</ul>';
+	}
+}
+
+/**
+ * Display upgrade WordPress for downloading latest or upgrading automatically form.
+ *
+ * @since 2.7
+ *
+ * @return null
+ */
+function core_upgrade_preamble() {
+	global $upgrade_error;
+
+	$updates = get_core_updates();
+?>
+	<div class="wrap">
+	<?php screen_icon('tools'); ?>
+	<h2><?php _e('WordPress Updates'); ?></h2>
+<?php
+	if ( $upgrade_error ) {
+		echo '<div class="error"><p>';
+		if ( $upgrade_error == 'themes' )
+			_e('Please select one or more themes to update.');
+		else
+			_e('Please select one or more plugins to update.');
+		echo '</p></div>';
+	}
+
+	echo '<p>';
+	/* translators: %1 date, %2 time. */
+	printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
+	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
+	echo '</p>';
+
+	if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
+		echo '<h3>';
+		_e('You have the latest version of WordPress.');
+		echo '</h3>';
+	} else {
+		echo '<div class="updated inline"><p>';
+		_e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
+		echo '</p></div>';
+
+		echo '<h3 class="response">';
+		_e( 'An updated version of WordPress is available.' );
+		echo '</h3>';
+	}
+
+	echo '<ul class="core-updates">';
+	$alternate = true;
+	foreach( (array) $updates as $update ) {
+		echo '<li>';
+		list_core_update( $update );
+		echo '</li>';
+	}
+	echo '</ul>';
+	echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.' ) . '</p>';
+	dismissed_updates();
+
+	if ( current_user_can( 'update_plugins' ) )
+		list_plugin_updates();
+	if ( current_user_can( 'update_themes' ) )
+		list_theme_updates();
+	do_action('core_upgrade_preamble');
+	echo '</div>';
+}
+
+function list_plugin_updates() {
+	global $wp_version;
+
+	$cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
+
+	require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
+	$plugins = get_plugin_updates();
+	if ( empty( $plugins ) ) {
+		echo '<h3>' . __( 'Plugins' ) . '</h3>';
+		echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
+		return;
+	}
+	$form_action = 'update-core.php?action=do-plugin-upgrade';
+
+	$core_updates = get_core_updates();
+	if ( !isset($core_updates[0]->response) || 'latest' == $core_updates[0]->response || 'development' == $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=') )
+		$core_update_version = false;
+	else
+		$core_update_version = $core_updates[0]->current;
+	?>
+<h3><?php _e( 'Plugins' ); ?></h3>
+<p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
+<form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade">
+<?php wp_nonce_field('upgrade-core'); ?>
+<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
+<table class="widefat" cellspacing="0" id="update-plugins-table">
+	<thead>
+	<tr>
+		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
+		<th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
+	</tr>
+	</thead>
+
+	<tfoot>
+	<tr>
+		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
+		<th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th>
+	</tr>
+	</tfoot>
+	<tbody class="plugins">
+<?php
+	foreach ( (array) $plugins as $plugin_file => $plugin_data) {
+		$info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
+		// Get plugin compat for running version of WordPress.
+		if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
+			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
+		} elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
+			$compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
+			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat[0], $compat[2], $compat[1]);
+		} else {
+			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
+		}
+		// Get plugin compat for updated version of WordPress.
+		if ( $core_update_version ) {
+			if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
+				$update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
+				$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat[0], $update_compat[2], $update_compat[1]);
+			} else {
+				$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
+			}
+		}
+		// Get the upgrade notice for the new plugin version.
+		if ( isset($plugin_data->update->upgrade_notice) ) {
+			$upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
+		} else {
+			$upgrade_notice = '';
+		}
+		echo "
+	<tr class='active'>
+		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
+		<td><strong>{$plugin_data->Name}</strong><br />" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . $compat . $upgrade_notice . "</td>
+	</tr>";
+	}
+?>
+	</tbody>
+</table>
+<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
+</form>
+<?php
+}
+
+function list_theme_updates() {
+	$themes = get_theme_updates();
+	if ( empty( $themes ) ) {
+		echo '<h3>' . __( 'Themes' ) . '</h3>';
+		echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
+		return;
+	}
+
+	$form_action = 'update-core.php?action=do-theme-upgrade';
+
+?>
+<h3><?php _e( 'Themes' ); ?></h3>
+<p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.' ); ?></p>
+<p><?php printf( __('<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), _x('http://codex.wordpress.org/Child_Themes', 'Link used in suggestion to use child themes in GUU') ); ?></p>
+<form method="post" action="<?php echo $form_action; ?>" name="upgrade-themes" class="upgrade">
+<?php wp_nonce_field('upgrade-core'); ?>
+<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
+<table class="widefat" cellspacing="0" id="update-themes-table">
+	<thead>
+	<tr>
+		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
+		<th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
+	</tr>
+	</thead>
+
+	<tfoot>
+	<tr>
+		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
+		<th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th>
+	</tr>
+	</tfoot>
+	<tbody class="plugins">
+<?php
+	foreach ( (array) $themes as $stylesheet => $theme_data) {
+		$screenshot = $theme_data->{'Theme Root URI'} . '/' . $stylesheet . '/' . $theme_data->Screenshot;
+
+		echo "
+	<tr class='active'>
+		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>
+		<td class='plugin-title'><img src='$screenshot' width='64' height='64' style='float:left; padding: 5px' /><strong>{$theme_data->Name}</strong>" .  sprintf(__('You have version %1$s installed. Update to %2$s.'), $theme_data->Version, $theme_data->update['new_version']) . "</td>
+	</tr>";
+	}
+?>
+	</tbody>
+</table>
+<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
+</form>
+<?php
+}
+
+/**
+ * Upgrade WordPress core display.
+ *
+ * @since 2.7
+ *
+ * @return null
+ */
+function do_core_upgrade( $reinstall = false ) {
+	global $wp_filesystem;
+
+	if ( $reinstall )
+		$url = 'update-core.php?action=do-core-reinstall';
+	else
+		$url = 'update-core.php?action=do-core-upgrade';
+	$url = wp_nonce_url($url, 'upgrade-core');
+	if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )
+		return;
+
+	$version = isset( $_POST['version'] )? $_POST['version'] : false;
+	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
+	$update = find_core_update( $version, $locale );
+	if ( !$update )
+		return;
+
+
+	if ( ! WP_Filesystem($credentials, ABSPATH) ) {
+		request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again
+		return;
+	}
+?>
+	<div class="wrap">
+	<?php screen_icon('tools'); ?>
+	<h2><?php _e('Update WordPress'); ?></h2>
+<?php
+	if ( $wp_filesystem->errors->get_error_code() ) {
+		foreach ( $wp_filesystem->errors->get_error_messages() as $message )
+			show_message($message);
+		echo '</div>';
+		return;
+	}
+
+	if ( $reinstall )
+		$update->response = 'reinstall';
+
+	$result = wp_update_core($update, 'show_message');
+
+	if ( is_wp_error($result) ) {
+		show_message($result);
+		if ('up_to_date' != $result->get_error_code() )
+			show_message( __('Installation Failed') );
+	} else {
+		show_message( __('WordPress updated successfully') );
+		show_message( '<a href="' . esc_url( self_admin_url() ) . '">' . __('Go to Dashboard') . '</a>' );
+	}
+	echo '</div>';
+}
+
+function do_dismiss_core_update() {
+	$version = isset( $_POST['version'] )? $_POST['version'] : false;
+	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
+	$update = find_core_update( $version, $locale );
+	if ( !$update )
+		return;
+	dismiss_core_update( $update );
+	wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
+	exit;
+}
+
+function do_undismiss_core_update() {
+	$version = isset( $_POST['version'] )? $_POST['version'] : false;
+	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
+	$update = find_core_update( $version, $locale );
+	if ( !$update )
+		return;
+	undismiss_core_update( $version, $locale );
+	wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
+	exit;
+}
+
+function no_update_actions($actions) {
+	return '';
+}
+
+$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
+
+$upgrade_error = false;
+if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
+	&& ! isset( $_POST['checked'] ) ) {
+	$upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
+	$action = 'upgrade-core';
+}
+
+$title = __('WordPress Updates');
+$parent_file = 'tools.php';
+
+add_contextual_help($current_screen,
+	'<p>' . __('This screen lets you update to the latest version of WordPress as well as update your themes and plugins from the WordPress.org repository. When updates are available, the number of available updates will appear in a bubble on the left hand menu as a notification. It is very important to keep your WordPress installation up to date for security reasons, so when you see a number appear, make sure you take the time to update, which is an easy process.') . '</p>' .
+	'<p>' . __('Updating your WordPress installation is a simple one-click procedure; just click on the Update button when it says a new version is available.') . '</p>' .
+	'<p>' . __('To update themes or plugins from this screen, use the checkboxes to make your selection and click on the appropriate Update button. Check the box at the top of the Themes or Plugins section to select all and update them all at once.') . '</p>' .
+	'<p><strong>' . __('For more information:') . '</strong></p>' .
+	'<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_SubPanel" target="_blank">Documentation on Updating WordPress</a>') . '</p>' .
+	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+if ( 'upgrade-core' == $action ) {
+
+	wp_version_check();
+	require_once(ABSPATH . 'wp-admin/admin-header.php');
+	core_upgrade_preamble();
+
+} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
+	check_admin_referer('upgrade-core');
+
+	// do the (un)dismiss actions before headers,
+	// so that they can redirect
+	if ( isset( $_POST['dismiss'] ) )
+		do_dismiss_core_update();
+	elseif ( isset( $_POST['undismiss'] ) )
+		do_undismiss_core_update();
+
+	require_once(ABSPATH . 'wp-admin/admin-header.php');
+	if ( 'do-core-reinstall' == $action )
+		$reinstall = true;
+	else
+		$reinstall = false;
+
+	if ( isset( $_POST['upgrade'] ) )
+		do_core_upgrade($reinstall);
+
+} elseif ( 'do-plugin-upgrade' == $action ) {
+
+	if ( ! current_user_can( 'update_plugins' ) )
+		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
+
+	check_admin_referer('upgrade-core');
+
+	if ( isset( $_GET['plugins'] ) ) {
+		$plugins = explode( ',', $_GET['plugins'] );
+	} elseif ( isset( $_POST['checked'] ) ) {
+		$plugins = (array) $_POST['checked'];
+	} else {
+		wp_redirect( admin_url('update-core.php') );
+		exit;
+	}
+
+	$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
+	$url = wp_nonce_url($url, 'bulk-update-plugins');
+
+	$title = __('Update Plugins');
+
+	require_once(ABSPATH . 'wp-admin/admin-header.php');
+	echo '<div class="wrap">';
+	screen_icon('plugins');
+	echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
+	echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
+	echo '</div>';
+
+} elseif ( 'do-theme-upgrade' == $action ) {
+
+	if ( ! current_user_can( 'update_themes' ) )
+		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
+
+	check_admin_referer('upgrade-core');
+
+	if ( isset( $_GET['themes'] ) ) {
+		$themes = explode( ',', $_GET['themes'] );
+	} elseif ( isset( $_POST['checked'] ) ) {
+		$themes = (array) $_POST['checked'];
+	} else {
+		wp_redirect( admin_url('update-core.php') );
+		exit;
+	}
+
+	$url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
+	$url = wp_nonce_url($url, 'bulk-update-themes');
+
+	$title = __('Update Themes');
+
+	require_once(ABSPATH . 'wp-admin/admin-header.php');
+	echo '<div class="wrap">';
+	screen_icon('themes');
+	echo '<h2>' . esc_html__('Update Themes') . '</h2>';
+	echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
+	echo '</div>';
+}
+
+include(ABSPATH . 'wp-admin/admin-footer.php');
Index: /tags/3.1/wp-admin/update.php
===================================================================
--- /tags/3.1/wp-admin/update.php	(revision 17487)
+++ /tags/3.1/wp-admin/update.php	(revision 17487)
@@ -0,0 +1,254 @@
+<?php
+/**
+ * Update/Install Plugin/Theme administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) )
+	define( 'IFRAME_REQUEST', true );
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+
+if ( isset($_GET['action']) ) {
+	$plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
+	$theme = isset($_REQUEST['theme']) ? urldecode($_REQUEST['theme']) : '';
+	$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
+
+	if ( 'update-selected' == $action ) {
+		if ( ! current_user_can( 'update_plugins' ) )
+			wp_die( __( 'You do not have sufficient permissions to update plugins for this site.' ) );
+
+		check_admin_referer( 'bulk-update-plugins' );
+
+		if ( isset( $_GET['plugins'] ) )
+			$plugins = explode( ',', stripslashes($_GET['plugins']) );
+		elseif ( isset( $_POST['checked'] ) )
+			$plugins = (array) $_POST['checked'];
+		else
+			$plugins = array();
+
+		$plugins = array_map('urldecode', $plugins);
+
+		$url = 'update.php?action=update-selected&amp;plugins=' . urlencode(implode(',', $plugins));
+		$nonce = 'bulk-update-plugins';
+
+		wp_enqueue_script('jquery');
+		iframe_header();
+
+		$upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
+		$upgrader->bulk_upgrade( $plugins );
+
+		iframe_footer();
+
+	} elseif ( 'upgrade-plugin' == $action ) {
+		if ( ! current_user_can('update_plugins') )
+			wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
+
+		check_admin_referer('upgrade-plugin_' . $plugin);
+
+		$title = __('Update Plugin');
+		$parent_file = 'plugins.php';
+		$submenu_file = 'plugins.php';
+		require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		$nonce = 'upgrade-plugin_' . $plugin;
+		$url = 'update.php?action=upgrade-plugin&plugin=' . $plugin;
+
+		$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
+		$upgrader->upgrade($plugin);
+
+		include(ABSPATH . 'wp-admin/admin-footer.php');
+
+	} elseif ('activate-plugin' == $action ) {
+		if ( ! current_user_can('update_plugins') )
+			wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
+
+		check_admin_referer('activate-plugin_' . $plugin);
+		if ( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
+			wp_redirect( admin_url('update.php?action=activate-plugin&failure=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
+			activate_plugin( $plugin, '', ! empty( $_GET['networkwide'] ), true );
+			wp_redirect( admin_url('update.php?action=activate-plugin&success=true&plugin=' . $plugin . '&_wpnonce=' . $_GET['_wpnonce']) );
+			die();
+		}
+		iframe_header( __('Plugin Reactivation'), true );
+		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>';
+
+			if ( defined('E_RECOVERABLE_ERROR') )
+				error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
+			else
+				error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
+
+			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
+			include(WP_PLUGIN_DIR . '/' . $plugin);
+		}
+		iframe_footer();
+	} elseif ( 'install-plugin' == $action ) {
+
+		if ( ! current_user_can('install_plugins') )
+			wp_die(__('You do not have sufficient permissions to install plugins for this site.'));
+
+		include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api..
+
+		check_admin_referer('install-plugin_' . $plugin);
+		$api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
+
+		if ( is_wp_error($api) )
+	 		wp_die($api);
+
+		$title = __('Plugin Install');
+		$parent_file = 'plugins.php';
+		$submenu_file = 'plugin-install.php';
+		require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		$title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
+		$nonce = 'install-plugin_' . $plugin;
+		$url = 'update.php?action=install-plugin&plugin=' . $plugin;
+		if ( isset($_GET['from']) )
+			$url .= '&from=' . urlencode(stripslashes($_GET['from']));
+
+		$type = 'web'; //Install plugin type, From Web or an Upload.
+
+		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
+		$upgrader->install($api->download_link);
+
+		include(ABSPATH . 'wp-admin/admin-footer.php');
+
+	} elseif ( 'upload-plugin' == $action ) {
+
+		if ( ! current_user_can('install_plugins') )
+			wp_die(__('You do not have sufficient permissions to install plugins for this site.'));
+
+		check_admin_referer('plugin-upload');
+
+		$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
+
+		$title = __('Upload Plugin');
+		$parent_file = 'plugins.php';
+		$submenu_file = 'plugin-install.php';
+		require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		$title = sprintf( __('Installing Plugin from uploaded file: %s'), basename( $file_upload->filename ) );
+		$nonce = 'plugin-upload';
+		$url = add_query_arg(array('package' => $file_upload->filename ), 'update.php?action=upload-plugin');
+		$type = 'upload'; //Install plugin type, From Web or an Upload.
+
+		$upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
+		$upgrader->install( $file_upload->package );
+
+		include(ABSPATH . 'wp-admin/admin-footer.php');
+
+	} elseif ( 'upgrade-theme' == $action ) {
+
+		if ( ! current_user_can('update_themes') )
+			wp_die(__('You do not have sufficient permissions to update themes for this site.'));
+
+		check_admin_referer('upgrade-theme_' . $theme);
+
+		add_thickbox();
+		wp_enqueue_script('theme-preview');
+		$title = __('Update Theme');
+		$parent_file = 'themes.php';
+		$submenu_file = 'themes.php';
+		require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		$nonce = 'upgrade-theme_' . $theme;
+		$url = 'update.php?action=upgrade-theme&theme=' . $theme;
+
+		$upgrader = new Theme_Upgrader( new Theme_Upgrader_Skin( compact('title', 'nonce', 'url', 'theme') ) );
+		$upgrader->upgrade($theme);
+
+		include(ABSPATH . 'wp-admin/admin-footer.php');
+	} elseif ( 'update-selected-themes' == $action ) {
+		if ( ! current_user_can( 'update_themes' ) )
+			wp_die( __( 'You do not have sufficient permissions to update themes for this site.' ) );
+
+		check_admin_referer( 'bulk-update-themes' );
+
+		if ( isset( $_GET['themes'] ) )
+			$themes = explode( ',', stripslashes($_GET['themes']) );
+		elseif ( isset( $_POST['checked'] ) )
+			$themes = (array) $_POST['checked'];
+		else
+			$themes = array();
+
+		$themes = array_map('urldecode', $themes);
+
+		$url = 'update.php?action=update-selected-themes&amp;themes=' . urlencode(implode(',', $themes));
+		$nonce = 'bulk-update-themes';
+
+		wp_enqueue_script('jquery');
+		iframe_header();
+
+		$upgrader = new Theme_Upgrader( new Bulk_Theme_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
+		$upgrader->bulk_upgrade( $themes );
+
+		iframe_footer();
+	} elseif ( 'install-theme' == $action ) {
+
+		if ( ! current_user_can('install_themes') )
+			wp_die(__('You do not have sufficient permissions to install themes for this site.'));
+
+		include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api..
+
+		check_admin_referer('install-theme_' . $theme);
+		$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
+
+		if ( is_wp_error($api) )
+	 		wp_die($api);
+
+		add_thickbox();
+		wp_enqueue_script('theme-preview');
+		$title = __('Install Themes');
+		$parent_file = 'themes.php';
+		$submenu_file = 'themes.php';
+		require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		$title = sprintf( __('Installing Theme: %s'), $api->name . ' ' . $api->version );
+		$nonce = 'install-theme_' . $theme;
+		$url = 'update.php?action=install-theme&theme=' . $theme;
+		$type = 'web'; //Install theme type, From Web or an Upload.
+
+		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('title', 'url', 'nonce', 'plugin', 'api') ) );
+		$upgrader->install($api->download_link);
+
+		include(ABSPATH . 'wp-admin/admin-footer.php');
+
+	} elseif ( 'upload-theme' == $action ) {
+
+		if ( ! current_user_can('install_themes') )
+			wp_die(__('You do not have sufficient permissions to install themes for this site.'));
+
+		check_admin_referer('theme-upload');
+
+		$file_upload = new File_Upload_Upgrader('themezip', 'package');
+
+		$title = __('Upload Theme');
+		$parent_file = 'themes.php';
+		$submenu_file = 'theme-install.php';
+		add_thickbox();
+		wp_enqueue_script('theme-preview');
+		require_once(ABSPATH . 'wp-admin/admin-header.php');
+
+		$title = sprintf( __('Installing Theme from uploaded file: %s'), basename( $file_upload->filename ) );
+		$nonce = 'theme-upload';
+		$url = add_query_arg(array('package' => $file_upload->filename), 'update.php?action=upload-theme');
+		$type = 'upload'; //Install plugin type, From Web or an Upload.
+
+		$upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact('type', 'title', 'nonce', 'url') ) );
+		$upgrader->install( $file_upload->package );
+
+		include(ABSPATH . 'wp-admin/admin-footer.php');
+
+	} else {
+		do_action('update-custom_' . $action);
+	}
+}
Index: /tags/3.1/wp-admin/upgrade-functions.php
===================================================================
--- /tags/3.1/wp-admin/upgrade-functions.php	(revision 17487)
+++ /tags/3.1/wp-admin/upgrade-functions.php	(revision 17487)
@@ -0,0 +1,13 @@
+<?php
+/**
+ * WordPress Upgrade Functions. Old file, must not be used. Include
+ * wp-admin/includes/upgrade.php instead.
+ *
+ * @deprecated 2.5
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/upgrade.php' );
+require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
+?>
Index: /tags/3.1/wp-admin/upgrade.php
===================================================================
--- /tags/3.1/wp-admin/upgrade.php	(revision 17487)
+++ /tags/3.1/wp-admin/upgrade.php	(revision 17487)
@@ -0,0 +1,110 @@
+<?php
+/**
+ * Upgrade WordPress Page.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/**
+ * We are upgrading WordPress.
+ *
+ * @since 1.5.1
+ * @var bool
+ */
+define( 'WP_INSTALLING', true );
+
+/** Load WordPress Bootstrap */
+require( '../wp-load.php' );
+
+timer_start();
+require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+
+delete_site_transient('update_core');
+
+if ( isset( $_GET['step'] ) )
+	$step = $_GET['step'];
+else
+	$step = 0;
+
+// Do it.  No output.
+if ( 'upgrade_db' === $step ) {
+	wp_upgrade();
+	die( '0' );
+}
+
+$step = (int) $step;
+
+$php_version    = phpversion();
+$mysql_version  = $wpdb->db_version();
+$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
+$mysql_compat   = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
+
+@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
+?>
+<!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 language_attributes(); ?>>
+<head>
+	<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
+	<title><?php _e( 'WordPress &rsaquo; Update' ); ?></title>
+	<?php
+	wp_admin_css( 'install', true );
+	wp_admin_css( 'ie', true );
+	?>
+</head>
+<body>
+<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
+
+<?php if ( get_option( 'db_version' ) == $wp_db_version || !is_blog_installed() ) : ?>
+
+<h2><?php _e( 'No Update Required' ); ?></h2>
+<p><?php _e( 'Your WordPress database is already up-to-date!' ); ?></p>
+<p class="step"><a class="button" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
+
+<?php elseif ( !$php_compat || !$mysql_compat ) :
+	if ( !$mysql_compat && !$php_compat )
+		printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
+	elseif ( !$php_compat )
+		printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version );
+	elseif ( !$mysql_compat )
+		printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version );
+?>
+<?php else :
+switch ( $step ) :
+	case 0:
+		$goback = stripslashes( wp_get_referer() );
+		$goback = esc_url_raw( $goback );
+		$goback = urlencode( $goback );
+?>
+<h2><?php _e( 'Database Update Required' ); ?></h2>
+<p><?php _e( 'WordPress has been updated! Before we send you on your way, we have to update your database to the newest version.' ); ?></p>
+<p><?php _e( 'The update process may take a little while, so please be patient.' ); ?></p>
+<p class="step"><a class="button" href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p>
+<?php
+		break;
+	case 1:
+		wp_upgrade();
+
+			$backto = !empty($_GET['backto']) ? stripslashes( urldecode( $_GET['backto'] ) ) :  __get_option( 'home' ) . '/';
+			$backto = esc_url_raw( $backto );
+			$backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
+?>
+<h2><?php _e( 'Update Complete' ); ?></h2>
+	<p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
+	<p class="step"><a class="button" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
+
+<!--
+<pre>
+<?php printf( __( '%s queries' ), $wpdb->num_queries ); ?>
+
+<?php printf( __( '%s seconds' ), timer_stop( 0 ) ); ?>
+</pre>
+-->
+
+<?php
+		break;
+endswitch;
+endif;
+?>
+</body>
+</html>
Index: /tags/3.1/wp-admin/upload.php
===================================================================
--- /tags/3.1/wp-admin/upload.php	(revision 17487)
+++ /tags/3.1/wp-admin/upload.php	(revision 17487)
@@ -0,0 +1,228 @@
+<?php
+/**
+ * Media Library administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( !current_user_can('upload_files') )
+	wp_die( __( 'You do not have permission to upload files.' ) );
+
+$wp_list_table = _get_list_table('WP_Media_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+
+// Handle bulk actions
+$doaction = $wp_list_table->current_action();
+
+if ( $doaction ) {
+	check_admin_referer('bulk-media');
+
+	if ( 'delete_all' == $doaction ) {
+		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
+		$doaction = 'delete';
+	} elseif ( isset( $_REQUEST['media'] ) ) {
+		$post_ids = $_REQUEST['media'];
+	} elseif ( isset( $_REQUEST['ids'] ) ) {
+		$post_ids = explode( ',', $_REQUEST['ids'] );
+	}
+
+	$location = 'upload.php';
+	if ( $referer = wp_get_referer() ) {
+		if ( false !== strpos( $referer, 'upload.php' ) )
+			$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
+	}
+
+	switch ( $doaction ) {
+		case 'find_detached':
+			if ( !current_user_can('edit_posts') )
+				wp_die( __('You are not allowed to scan for lost attachments.') );
+
+			$lost = $wpdb->get_col( "
+				SELECT ID FROM $wpdb->posts
+				WHERE post_type = 'attachment' AND post_parent > '0'
+				AND post_parent NOT IN (
+					SELECT ID FROM $wpdb->posts
+					WHERE post_type NOT IN ( 'attachment', '" . join( "', '", get_post_types( array( 'public' => false ) ) ) . "' )
+				)
+			" );
+
+			$_REQUEST['detached'] = 1;
+			break;
+		case 'attach':
+			$parent_id = (int) $_REQUEST['found_post_id'];
+			if ( !$parent_id )
+				return;
+
+			$parent = &get_post( $parent_id );
+			if ( !current_user_can( 'edit_post', $parent_id ) )
+				wp_die( __( 'You are not allowed to edit this post.' ) );
+
+			$attach = array();
+			foreach ( (array) $_REQUEST['media'] as $att_id ) {
+				$att_id = (int) $att_id;
+
+				if ( !current_user_can( 'edit_post', $att_id ) )
+					continue;
+
+				$attach[] = $att_id;
+				clean_attachment_cache( $att_id );
+			}
+
+			if ( ! empty( $attach ) ) {
+				$attach = implode( ',', $attach );
+				$attached = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $attach )", $parent_id ) );
+			}
+
+			if ( isset( $attached ) ) {
+				$location = 'upload.php';
+				if ( $referer = wp_get_referer() ) {
+					if ( false !== strpos( $referer, 'upload.php' ) )
+						$location = $referer;
+				}
+
+				$location = add_query_arg( array( 'attached' => $attached ) , $location );
+				wp_redirect( $location );
+				exit;
+			}
+			break;
+		case 'trash':
+			foreach ( (array) $post_ids as $post_id ) {
+				if ( !current_user_can( 'delete_post', $post_id ) )
+					wp_die( __( 'You are not allowed to move this post to the trash.' ) );
+
+				if ( !wp_trash_post( $post_id ) )
+					wp_die( __( 'Error in moving to trash...' ) );
+			}
+			$location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location );
+			break;
+		case 'untrash':
+			foreach ( (array) $post_ids as $post_id ) {
+				if ( !current_user_can( 'delete_post', $post_id ) )
+					wp_die( __( 'You are not allowed to move this post out of the trash.' ) );
+
+				if ( !wp_untrash_post( $post_id ) )
+					wp_die( __( 'Error in restoring from trash...' ) );
+			}
+			$location = add_query_arg( 'untrashed', count( $post_ids ), $location );
+			break;
+		case 'delete':
+			foreach ( (array) $post_ids as $post_id_del ) {
+				if ( !current_user_can( 'delete_post', $post_id_del ) )
+					wp_die( __( 'You are not allowed to delete this post.' ) );
+
+				if ( !wp_delete_attachment( $post_id_del ) )
+					wp_die( __( 'Error in deleting...' ) );
+			}
+			$location = add_query_arg( 'deleted', count( $post_ids ), $location );
+			break;
+	}
+
+	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;
+}
+
+$wp_list_table->prepare_items();
+
+$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+if ( $pagenum > $total_pages && $total_pages > 0 ) {
+	wp_redirect( add_query_arg( 'paged', $total_pages ) );
+	exit;
+}
+
+$title = __('Media Library');
+$parent_file = 'upload.php';
+
+wp_enqueue_script( 'wp-ajax-response' );
+wp_enqueue_script( 'jquery-ui-draggable' );
+wp_enqueue_script( 'media' );
+
+add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
+
+add_contextual_help( $current_screen,
+	'<p>' . __( 'All the files you&#8217;ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the <em>Screen Options</em> tab to customize the display of this screen.' ) . '</p>' .
+	'<p>' . __( 'You can narrow the list by file type/status using the text link filters at the top of the screen. You also can refine the list by date using the dropdown menu above the media table.' ) . '</p>' .
+	'<p>' . __( 'Hovering over a row reveals action links: <em>Edit</em>, <em>Delete Permanently</em>, and <em>View</em>. Clicking <em>Edit</em> or on the media file&#8217;s name displays a simple screen to edit that individual file&#8217;s metadata. Clicking <em>Delete Permanently</em> will delete the file from the media library (as well as from any posts to which it is currently attached). <em>View</em> will take you to the display page for that file.' ) . '</p>' .
+	'<p>' . __( 'If a media file has not been attached to any post, you will see that in the <em>Attached To</em> column, and can click on <em>Attach File</em> to launch a small popup that will allow you to search for a post and attach the file.' ) . '</p>' .
+	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
+	'<p>' . __( '<a href="http://codex.wordpress.org/Media_Library_SubPanel" target="_blank">Documentation on Media Library</a>' ) . '</p>' .
+	'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
+);
+
+require_once('./admin-header.php');
+?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?> <a href="media-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a> <?php
+if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
+	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
+</h2>
+
+<?php
+$message = '';
+if ( isset($_GET['posted']) && (int) $_GET['posted'] ) {
+	$message = __('Media attachment updated.');
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
+}
+
+if ( isset($_GET['attached']) && (int) $_GET['attached'] ) {
+	$attached = (int) $_GET['attached'];
+	$message = sprintf( _n('Reattached %d attachment.', 'Reattached %d attachments.', $attached), $attached );
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']);
+}
+
+if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
+	$message = sprintf( _n( 'Media attachment permanently deleted.', '%d media attachments permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
+}
+
+if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
+	$message = sprintf( _n( 'Media attachment moved to the trash.', '%d media attachments moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
+	$message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']);
+}
+
+if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
+	$message = sprintf( _n( 'Media attachment restored from the trash.', '%d media attachments restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']);
+}
+
+$messages[1] = __('Media attachment updated.');
+$messages[2] = __('Media permanently deleted.');
+$messages[3] = __('Error saving media attachment.');
+$messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
+$messages[5] = __('Media restored from the trash.');
+
+if ( isset($_GET['message']) && (int) $_GET['message'] ) {
+	$message = $messages[$_GET['message']];
+	$_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
+}
+
+if ( !empty($message) ) { ?>
+<div id="message" class="updated"><p><?php echo $message; ?></p></div>
+<?php } ?>
+
+<?php $wp_list_table->views(); ?>
+
+<form id="posts-filter" action="" method="get">
+
+<?php $wp_list_table->search_box( __( 'Search Media' ), 'media' ); ?>
+
+<?php $wp_list_table->display(); ?>
+
+<div id="ajax-response"></div>
+<?php find_posts_div(); ?>
+<br class="clear" />
+
+</form>
+</div>
+
+<?php
+include('./admin-footer.php');
Index: /tags/3.1/wp-admin/user-edit.php
===================================================================
--- /tags/3.1/wp-admin/user-edit.php	(revision 17487)
+++ /tags/3.1/wp-admin/user-edit.php	(revision 17487)
@@ -0,0 +1,414 @@
+<?php
+/**
+ * Edit user administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
+
+$user_id = (int) $user_id;
+$current_user = wp_get_current_user();
+if ( ! defined( 'IS_PROFILE_PAGE' ) )
+	define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) );
+
+if ( ! $user_id && IS_PROFILE_PAGE )
+	$user_id = $current_user->ID;
+elseif ( ! $user_id && ! IS_PROFILE_PAGE )
+	wp_die(__( 'Invalid user ID.' ) );
+elseif ( ! get_userdata( $user_id ) )
+	wp_die( __('Invalid user ID.') );
+
+wp_enqueue_script('user-profile');
+
+$title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
+if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
+	$submenu_file = 'users.php';
+else
+	$submenu_file = 'profile.php';
+
+if ( current_user_can('edit_users') && !is_user_admin() )
+	$parent_file = 'users.php';
+else
+	$parent_file = 'profile.php';
+
+// contextual help - choose Help on the top right of admin panel to preview this.
+add_contextual_help($current_screen,
+    '<p>' . __('Your profile contains information about you (your &#8220;account&#8221;) as well as some personal options related to using WordPress.') . '</p>' .
+    '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things.') . '</p>' .
+    '<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' .
+    '<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' .
+    '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>' .
+    '<p><strong>' . __('For more information:') . '</strong></p>' .
+    '<p>' . __('<a href="http://codex.wordpress.org/Users_Your_Profile_SubPanel" target="_blank">Documentation on User Profiles</a>') . '</p>' .
+    '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+
+$wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
+
+$all_post_caps = array('posts', 'pages');
+$user_can_edit = false;
+foreach ( $all_post_caps as $post_cap )
+	$user_can_edit |= current_user_can("edit_$post_cap");
+
+/**
+ * Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
+ *
+ * @since 2.7.0
+ *
+ * @param object $user User data object
+ */
+function use_ssl_preference($user) {
+?>
+	<tr>
+		<th scope="row"><?php _e('Use https')?></th>
+		<td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked('1', $user->use_ssl); ?> /> <?php _e('Always use https when visiting the admin'); ?></label></td>
+	</tr>
+<?php
+}
+
+
+// Only allow super admins on multisite to edit every user.
+if ( is_multisite() && ! current_user_can( 'manage_network_users' ) && $user_id != $current_user->ID && ! apply_filters( 'enable_edit_any_user_configuration', true ) )
+	wp_die( __( 'You do not have permission to edit this user.' ) );
+
+// Execute confirmed email change. See send_confirmation_on_profile_email().
+if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
+	$new_email = get_option( $current_user->ID . '_new_email' );
+	if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
+		$user->ID = $current_user->ID;
+		$user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
+		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
+			$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
+		wp_update_user( get_object_vars( $user ) );
+		delete_option( $current_user->ID . '_new_email' );
+		wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
+		die();
+	}
+} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
+	delete_option( $current_user->ID . '_new_email' );
+	wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
+	die();
+}
+
+switch ($action) {
+case 'update':
+
+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', $user_id);
+else
+	do_action('edit_user_profile_update', $user_id);
+
+if ( !is_multisite() ) {
+	$errors = edit_user($user_id);
+} else {
+	$user = get_userdata( $user_id );
+
+	// Update the email address in signups, if present.
+	if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) )
+		$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) );
+
+	// WPMU must delete the user from the current blog if WP added him after editing.
+	$delete_role = false;
+	$blog_prefix = $wpdb->get_blog_prefix();
+	if ( $user_id != $current_user->ID ) {
+		$cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$user_id}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
+		if ( !is_network_admin() && null == $cap && $_POST[ 'role' ] == '' ) {
+			$_POST[ 'role' ] = 'contributor';
+			$delete_role = true;
+		}
+	}
+	if ( !isset( $errors ) || ( isset( $errors ) && is_object( $errors ) && false == $errors->get_error_codes() ) )
+		$errors = edit_user($user_id);
+	if ( $delete_role ) // stops users being added to current blog when they are edited
+		delete_user_meta( $user_id, $blog_prefix . 'capabilities' );
+
+	if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
+		empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
+}
+
+if ( !is_wp_error( $errors ) ) {
+	$redirect = (IS_PROFILE_PAGE ? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
+	if ( $wp_http_referer )
+		$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
+	wp_redirect($redirect);
+	exit;
+}
+
+default:
+$profileuser = get_user_to_edit($user_id);
+
+if ( !current_user_can('edit_user', $user_id) )
+	wp_die(__('You do not have permission to edit this user.'));
+
+include (ABSPATH . 'wp-admin/admin-header.php');
+?>
+
+<?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
+	<div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div>
+<?php } ?>
+<?php if ( isset($_GET['updated']) ) : ?>
+<div id="message" class="updated">
+	<p><strong><?php _e('User updated.') ?></strong></p>
+	<?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?>
+	<p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('&larr; Back to Authors and Users'); ?></a></p>
+	<?php endif; ?>
+</div>
+<?php endif; ?>
+<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
+<div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
+<?php endif; ?>
+
+<div class="wrap" id="profile-page">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post"<?php do_action('user_edit_form_tag'); ?>>
+<?php wp_nonce_field('update-user_' . $user_id) ?>
+<?php if ( $wp_http_referer ) : ?>
+	<input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
+<?php endif; ?>
+<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>
+
+<table class="form-table">
+<?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // 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="false" <?php checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td>
+	</tr>
+<?php endif; ?>
+<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
+<tr>
+<th scope="row"><?php _e('Admin Color Scheme')?></th>
+<td><?php do_action( 'admin_color_scheme_picker' ); ?></td>
+</tr>
+<?php
+endif; // $_wp_admin_css_colors
+if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
+<tr>
+<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
+<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td>
+</tr>
+<?php endif; ?>
+<tr class="show-admin-bar">
+<th scope="row"><?php _e('Show Admin Bar')?></th>
+<td><fieldset><legend class="screen-reader-text"><span><?php _e('Show Admin Bar') ?></span></legend>
+<label for="admin_bar_front">
+<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1" <?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
+<?php /* translators: Show admin bar when viewing site */ _e( 'when viewing site' ); ?></label><br />
+<label for="admin_bar_admin">
+<input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" <?php checked( _get_admin_bar_pref( 'admin', $profileuser->ID ) ); ?> />
+<?php /* translators: Show admin bar in dashboard */ _e( 'in dashboard' ); ?></label>
+</td>
+</tr>
+<?php do_action('personal_options', $profileuser); ?>
+</table>
+<?php
+	if ( IS_PROFILE_PAGE )
+		do_action('profile_personal_options', $profileuser);
+?>
+
+<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 esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>
+	</tr>
+
+<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
+<tr><th><label for="role"><?php _e('Role:') ?></label></th>
+<td><select name="role" id="role">
+<?php
+// Get the highest/primary role for this user
+// TODO: create a function that does this: wp_get_user_role()
+$user_roles = $profileuser->roles;
+$user_role = array_shift($user_roles);
+
+// print the full list of roles with the primary one selected.
+wp_dropdown_roles($user_role);
+
+// print the 'no role' option. Make it selected if the user has no role yet.
+if ( $user_role )
+	echo '<option value="">' . __('&mdash; No role for this site &mdash;') . '</option>';
+else
+	echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>';
+?>
+</select>
+<?php endif; //!IS_PROFILE_PAGE
+
+if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
+<tr><th><label for="role"><?php _e('Super Admin'); ?></label></th>
+<td>
+<?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) ) : ?>
+<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
+<?php else : ?>
+<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
+<?php endif; ?>
+</td></tr>
+<?php } ?>
+
+<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 esc_attr($profileuser->first_name) ?>" class="regular-text" /></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 esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
+</tr>
+
+<tr>
+	<th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
+	<td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></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['display_username']  = $profileuser->user_login;
+			$public_display['display_nickname']  = $profileuser->nickname;
+			if ( !empty($profileuser->first_name) )
+				$public_display['display_firstname'] = $profileuser->first_name;
+			if ( !empty($profileuser->last_name) )
+				$public_display['display_lastname'] = $profileuser->last_name;
+			if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
+				$public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
+				$public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
+			}
+			if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere
+				$public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
+			$public_display = array_map( 'trim', $public_display );
+			$public_display = array_unique( $public_display );
+			foreach ( $public_display as $id => $item ) {
+		?>
+			<option id="<?php echo $id; ?>" value="<?php echo esc_attr($item); ?>"<?php selected( $profileuser->display_name, $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'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
+	<td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" />
+	<?php
+	$new_email = get_option( $current_user->ID . '_new_email' );
+	if ( $new_email && $new_email != $current_user->user_email ) : ?>
+	<div class="updated inline">
+	<p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>
+	</div>
+	<?php endif; ?>
+	</td>
+</tr>
+
+<tr>
+	<th><label for="url"><?php _e('Website') ?></label></th>
+	<td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
+</tr>
+
+<?php
+	foreach (_wp_get_user_contactmethods( $profileuser ) as $name => $desc) {
+?>
+<tr>
+	<th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
+	<td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
+</tr>
+<?php
+	}
+?>
+</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_escaped ?></textarea><br />
+	<span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
+</tr>
+
+<?php
+$show_password_fields = apply_filters('show_password_fields', true, $profileuser);
+if ( $show_password_fields ) :
+?>
+<tr id="password">
+	<th><label for="pass1"><?php _e('New Password'); ?></label></th>
+	<td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?></span><br />
+		<input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br />
+		<div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
+		<p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
+	</td>
+</tr>
+<?php endif; ?>
+</table>
+
+<?php
+	if ( IS_PROFILE_PAGE )
+		do_action( 'show_user_profile', $profileuser );
+	else
+		do_action( 'edit_user_profile', $profileuser );
+?>
+
+<?php if ( count($profileuser->caps) > count($profileuser->roles) && apply_filters('additional_capabilities_display', true, $profileuser) ) { ?>
+<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
+			$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>
+	</table>
+<?php } ?>
+
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" />
+
+<?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?>
+
+</form>
+</div>
+<?php
+break;
+}
+?>
+<script type="text/javascript" charset="utf-8">
+	if (window.location.hash == '#password') {
+		document.getElementById('pass1').focus();
+	}
+</script>
+<?php
+include( ABSPATH . 'wp-admin/admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/user-new.php
===================================================================
--- /tags/3.1/wp-admin/user-new.php	(revision 17487)
+++ /tags/3.1/wp-admin/user-new.php	(revision 17487)
@@ -0,0 +1,350 @@
+<?php
+/**
+ * New User Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once('./admin.php');
+
+if ( is_multisite() ) {
+	if ( ! current_user_can( 'create_users' ) && ! current_user_can( 'promote_users' ) )
+		wp_die( __( 'Cheatin&#8217; uh?' ) );
+} elseif ( ! current_user_can( 'create_users' ) ) {
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+}
+
+if ( is_multisite() ) {
+	function admin_created_user_email( $text ) {
+		/* translators: 1: Site name, 2: site URL, 3: role */
+		return sprintf( __( 'Hi,
+You\'ve been invited to join \'%1$s\' at
+%2$s as a %3$s.
+If you do not want to join this site please ignore
+this email. This invitation will expire in a few days.
+
+Please click the following link to activate your user account:
+%%s' ), get_bloginfo('name'), site_url(), esc_html( $_REQUEST[ 'role' ] ) );
+	}
+	add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' );
+
+	function admin_created_user_subject( $text ) {
+		return "[" . get_bloginfo('name') . "] Your site invite";
+	}
+}
+
+if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) {
+	check_admin_referer( 'add-user', '_wpnonce_add-user' );
+
+	$user_details = null;
+	if ( false !== strpos($_REQUEST[ 'email' ], '@') ) {
+		$user_details = get_user_by('email', $_REQUEST[ 'email' ]);
+	} else {
+		if ( is_super_admin() ) {
+			$user_details = get_user_by('login', $_REQUEST[ 'email' ]);
+		} else {
+			wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) );
+			die();
+		}
+	}
+
+	if ( !$user_details ) {
+		wp_redirect( add_query_arg( array('update' => 'does_not_exist'), 'user-new.php' ) );
+		die();
+	}
+
+	if ( ! current_user_can('promote_user', $user_details->ID) )
+		wp_die(__('Cheatin&#8217; uh?'));
+
+	// Adding an existing user to this blog
+	$new_user_email = esc_html(trim($_REQUEST['email']));
+	$redirect = 'user-new.php';
+	$username = $user_details->user_login;
+	$user_id = $user_details->ID;
+	if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) {
+		$redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' );
+	} else {
+		if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
+			add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) );
+			$redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' );
+		} else {
+			$newuser_key = substr( md5( $user_id ), 0, 5 );
+			add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) );
+			$message = __("Hi,\n\nYou have been invited to join '%s' at\n%s as a %s.\nPlease click the following link to confirm the invite:\n%s\n");
+			wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ),  sprintf($message, get_option('blogname'), site_url(), $_REQUEST[ 'role' ], site_url("/newbloguser/$newuser_key/")));
+			$redirect = add_query_arg( array('update' => 'add'), 'user-new.php' );
+		}
+	}
+	wp_redirect( $redirect );
+	die();
+} elseif ( isset($_REQUEST['action']) && 'createuser' == $_REQUEST['action'] ) {
+	check_admin_referer( 'create-user', '_wpnonce_create-user' );
+
+	if ( ! current_user_can('create_users') )
+		wp_die(__('Cheatin&#8217; uh?'));
+
+	if ( !is_multisite() ) {
+		$user_id = add_user();
+
+		if ( is_wp_error( $user_id ) ) {
+			$add_user_errors = $user_id;
+		} else {
+			if ( current_user_can('edit_users') ) {
+				$new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
+				$redirect = 'users.php?usersearch='. urlencode($new_user_login) . '&update=add' . '#user-' . $user_id;
+			} else {
+				$redirect = add_query_arg( 'update', 'add', 'user-new.php' );
+			}
+			wp_redirect( $redirect );
+			die();
+		}
+	} else {
+		// Adding a new user to this blog
+		$user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $_REQUEST[ 'email' ] );
+		unset( $user_details[ 'errors' ]->errors[ 'user_email_used' ] );
+		if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) {
+			$add_user_errors = $user_details[ 'errors' ];
+		} else {
+			$new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_REQUEST['user_login']), true));
+			if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
+				add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
+			}
+			wpmu_signup_user( $new_user_login, $_REQUEST[ 'email' ], array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) );
+			if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
+				$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST[ 'email' ] ) );
+				wpmu_activate_signup( $key );
+				$redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' );
+			} else {
+				$redirect = add_query_arg( array('update' => 'newuserconfimation'), 'user-new.php' );
+			}
+			wp_redirect( $redirect );
+			die();
+		}
+	}
+}
+
+
+$title = __('Add New User');
+$parent_file = 'users.php';
+
+$do_both = false;
+if ( is_multisite() && current_user_can('promote_users') && current_user_can('create_users') )
+	$do_both = true;
+
+add_contextual_help($current_screen,
+    '<p>' . __('To add a new user to your site, fill in the form on this screen. If you&#8217;re not sure which role to assign, you can use the link below to review the different roles and their capabilities. Here is a basic overview of roles:') . '</p>' .
+    '<ul>' .
+        '<li>' . __('Administrators have access to all the administration features.') . '</li>' .
+        '<li>' . __('Editors can publish posts, manage posts as well as manage other people&#8217;s posts, etc.')  . '</li>' .
+        '<li>' . __('Authors can publish and manage their own posts.') . '</li>' .
+        '<li>' . __('Contributors can write and manage their posts but not publish posts or upload media files.') . '</li>' .
+        '<li>' . __('Subscribers can read comments/comment/receive newsletters, etc.') . '</li>' .
+    '</ul>' .
+    '<p>' . __('You must assign a password to the new user, but don&#8217;t worry; when they log in for the first time they will be prompted to change it. The username, however, cannot be changed.') . '</p>' .
+    '<p>' . __('New users will receive an email letting them know they&#8217;ve been added as a user for your site. By default, this email will also contain their password. Uncheck the box if you don&#8217;t want the password to be included in the welcome email.') . '</p>' .
+    '<p>' . __('Remember to click the Add User button at the bottom of this screen when you are finished.') . '</p>' .
+    '<p><strong>' . __('For more information:') . '</strong></p>' .
+    '<p>' . __('<a href="http://codex.wordpress.org/Users_Add_New_SubPanel" target="_blank">Documentation on Adding New Users</a>') . '</p>' .
+    '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+wp_enqueue_script('wp-ajax-response');
+wp_enqueue_script('user-profile');
+
+require_once ('admin-header.php');
+
+if ( isset($_GET['update']) ) {
+	$messages = array();
+	if ( is_multisite() ) {
+		switch ( $_GET['update'] ) {
+			case "newuserconfimation":
+				$messages[] = __('Invitation email sent to new user. A confirmation link must be clicked before their account is created.');
+				break;
+			case "add":
+				$messages[] = __('Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.');
+				break;
+			case "addnoconfirmation":
+				$messages[] = __('User has been added to your site.');
+				break;
+			case "addexisting":
+				$messages[] = __('That user is already a member of this site.');
+				break;
+			case "does_not_exist":
+				$messages[] = __('The requested user does not exist.');
+				break;
+			case "does_not_exist":
+				$messages[] = __('Please enter a valid email address.');
+				break;
+		}
+	} else {
+		if ( 'add' == $_GET['update'] )
+			$messages[] = __('User added.');
+	}
+}
+?>
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2 id="add-new-user"> <?php
+if ( current_user_can( 'create_users' ) ) {
+	echo _x( 'Add New User', 'user' );
+} elseif ( current_user_can( 'promote_users' ) ) {
+	echo _x( 'Add Existing User', 'user' );
+} ?>
+</h2>
+
+<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
+	<div class="error">
+		<ul>
+		<?php
+			foreach ( $errors->get_error_messages() as $err )
+				echo "<li>$err</li>\n";
+		?>
+		</ul>
+	</div>
+<?php endif;
+
+if ( ! empty( $messages ) ) {
+	foreach ( $messages as $msg )
+		echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
+} ?>
+
+<?php if ( isset($add_user_errors) && is_wp_error( $add_user_errors ) ) : ?>
+	<div class="error">
+		<?php
+			foreach ( $add_user_errors->get_error_messages() as $message )
+				echo "<p>$message</p>";
+		?>
+	</div>
+<?php endif; ?>
+<div id="ajax-response"></div>
+
+<?php
+if ( is_multisite() ) {
+	if ( $do_both )
+		echo '<h3 id="add-existing-user">' . __('Add Existing User') . '</h3>';
+	if ( !is_super_admin() ) {
+		_e( 'Enter the email address of an existing user on this network to invite them to this site.  That person will be sent an email asking them to confirm the invite.' );
+		$label = __('E-mail');
+	} else {
+		_e( 'Enter the email address or username of an existing user on this network to invite them to this site.  That person will be sent an email asking them to confirm the invite.' );
+		$label = __('E-mail or Username');
+	}
+?>
+<form action="" method="post" name="adduser" id="adduser" class="add:users: validate"<?php do_action('user_new_form_tag');?>>
+<input name="action" type="hidden" value="adduser" />
+<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
+
+<table class="form-table">
+	<tr class="form-field form-required">
+		<th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th>
+		<td><input name="email" type="text" id="adduser-email" value="" /></td>
+	</tr>
+	<tr class="form-field">
+		<th scope="row"><label for="adduser-role"><?php _e('Role'); ?></label></th>
+		<td><select name="role" id="adduser-role">
+			<?php wp_dropdown_roles( get_option('default_role') ); ?>
+			</select>
+		</td>
+	</tr>
+<?php if ( is_super_admin() ) { ?>
+	<tr>
+		<th scope="row"><label for="adduser-noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th>
+		<td><label for="adduser-noconfirmation"><input type="checkbox" name="noconfirmation" id="adduser-noconfirmation" value="1" /> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td>
+	</tr>
+<?php } ?>
+</table>
+<?php submit_button( __( 'Add Existing User '), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?>
+</form>
+<?php
+} // is_multisite()
+
+if ( current_user_can( 'create_users') ) {
+	if ( $do_both )
+		echo '<h3 id="create-new-user">' . __( 'Add New User' ) . '</h3>';
+?>
+<p><?php _e('Create a brand new user and add it to this site.'); ?></p>
+<form action="" method="post" name="createuser" id="createuser" class="add:users: validate"<?php do_action('user_new_form_tag');?>>
+<input name="action" type="hidden" value="createuser" />
+<?php wp_nonce_field( 'create-user', '_wpnonce_create-user' ) ?>
+<?php
+// Load up the passed data, else set to a default.
+foreach ( array( 'user_login' => 'login', 'first_name' => 'firstname', 'last_name' => 'lastname',
+				'email' => 'email', 'url' => 'uri', 'role' => 'role', 'send_password' => 'send_password', 'noconfirmation' => 'ignore_pass' ) as $post_field => $var ) {
+	$var = "new_user_$var";
+	if( isset( $_POST['createuser'] ) ) {
+		if ( ! isset($$var) )
+			$$var = isset( $_POST[$post_field] ) ? stripslashes( $_POST[$post_field] ) : '';
+	} else {
+		$$var = false;
+	}
+}
+
+?>
+<table class="form-table">
+	<tr class="form-field form-required">
+		<th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
+		<td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr($new_user_login); ?>" aria-required="true" /></td>
+	</tr>
+	<tr class="form-field form-required">
+		<th scope="row"><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
+		<td><input name="email" type="text" id="email" value="<?php echo esc_attr($new_user_email); ?>" /></td>
+	</tr>
+<?php if ( !is_multisite() ) { ?>
+	<tr class="form-field">
+		<th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
+		<td><input name="first_name" type="text" id="first_name" value="<?php echo esc_attr($new_user_firstname); ?>" /></td>
+	</tr>
+	<tr class="form-field">
+		<th scope="row"><label for="last_name"><?php _e('Last Name') ?> </label></th>
+		<td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr($new_user_lastname); ?>" /></td>
+	</tr>
+	<tr class="form-field">
+		<th scope="row"><label for="url"><?php _e('Website') ?></label></th>
+		<td><input name="url" type="text" id="url" class="code" value="<?php echo esc_attr($new_user_uri); ?>" /></td>
+	</tr>
+<?php if ( apply_filters('show_password_fields', true) ) : ?>
+	<tr class="form-field form-required">
+		<th scope="row"><label for="pass1"><?php _e('Password'); ?> <span class="description"><?php /* translators: password input field */_e('(twice, required)'); ?></span></label></th>
+		<td><input name="pass1" type="password" id="pass1" autocomplete="off" />
+		<br />
+		<input name="pass2" type="password" id="pass2" autocomplete="off" />
+		<br />
+		<div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
+		<p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
+		</td>
+	</tr>
+	<tr>
+		<th scope="row"><label for="send_password"><?php _e('Send Password?') ?></label></th>
+		<td><label for="send_password"><input type="checkbox" name="send_password" id="send_password" <?php checked( $new_user_send_password ); ?> /> <?php _e('Send this password to the new user by email.'); ?></label></td>
+	</tr>
+<?php endif; ?>
+<?php } // !is_multisite ?>
+	<tr class="form-field">
+		<th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
+		<td><select name="role" id="role">
+			<?php
+			if ( !$new_user_role )
+				$new_user_role = !empty($current_role) ? $current_role : get_option('default_role');
+			wp_dropdown_roles($new_user_role);
+			?>
+			</select>
+		</td>
+	</tr>
+	<?php if ( is_multisite() && is_super_admin() ) { ?>
+	<tr>
+		<th scope="row"><label for="noconfirmation"><?php _e('Skip Confirmation Email') ?></label></th>
+		<td><label for="noconfirmation"><input type="checkbox" name="noconfirmation" id="noconfirmation" value="1"  <?php checked( $new_user_ignore_pass ); ?> /> <?php _e( 'Add the user without sending them a confirmation email.' ); ?></label></td>
+	</tr>
+	<?php } ?>
+</table>
+
+<?php submit_button( __( 'Add New User '), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?>
+
+</form>
+<?php } // current_user_can('create_users') ?>
+</div>
+<?php
+include('./admin-footer.php');
+?>
Index: /tags/3.1/wp-admin/user/admin.php
===================================================================
--- /tags/3.1/wp-admin/user/admin.php	(revision 17487)
+++ /tags/3.1/wp-admin/user/admin.php	(revision 17487)
@@ -0,0 +1,23 @@
+<?php
+/**
+ * WordPress User Administration Bootstrap
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 3.1.0
+ */
+
+define('WP_USER_ADMIN', TRUE);
+
+require_once( dirname(dirname(__FILE__)) . '/admin.php');
+
+if ( ! is_multisite() ) {
+	wp_redirect( admin_url() );
+	exit;
+}
+
+if ( ! is_main_site() ) {
+	wp_redirect( user_admin_url() );
+	exit;
+}
+?>
Index: /tags/3.1/wp-admin/user/index-extra.php
===================================================================
--- /tags/3.1/wp-admin/user/index-extra.php	(revision 17487)
+++ /tags/3.1/wp-admin/user/index-extra.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Handle default dashboard widgets options AJAX.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 3.1.0
+ */
+
+require_once( './admin.php' );
+
+require( '../index-extra.php' );
Index: /tags/3.1/wp-admin/user/index.php
===================================================================
--- /tags/3.1/wp-admin/user/index.php	(revision 17487)
+++ /tags/3.1/wp-admin/user/index.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * User Dashboard Administration Panel
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 3.1.0
+ */
+
+require_once( './admin.php' );
+
+require( '../index.php' );
Index: /tags/3.1/wp-admin/user/menu.php
===================================================================
--- /tags/3.1/wp-admin/user/menu.php	(revision 17487)
+++ /tags/3.1/wp-admin/user/menu.php	(revision 17487)
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Build User Administration Menu.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 3.1.0
+ */
+
+$menu[0] = array(__('Dashboard'), 'exist', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'div');
+
+$menu[4] = array( '', 'exist', 'separator1', '', 'wp-menu-separator' );
+
+$menu[70] = array( __('Profile'), 'exist', 'profile.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' );
+
+$menu[99] = array( '', 'exist', 'separator-last', '', 'wp-menu-separator-last' );
+
+$_wp_real_parent_file['users.php'] = 'profile.php';
+$compat = array();
+$submenu = array();
+
+require_once(ABSPATH . 'wp-admin/includes/menu.php');
+
+?>
Index: /tags/3.1/wp-admin/user/profile.php
===================================================================
--- /tags/3.1/wp-admin/user/profile.php	(revision 17487)
+++ /tags/3.1/wp-admin/user/profile.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * User Profile Administration Panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 3.1.0
+ */
+
+require_once( './admin.php' );
+
+require( '../profile.php' );
Index: /tags/3.1/wp-admin/user/user-edit.php
===================================================================
--- /tags/3.1/wp-admin/user/user-edit.php	(revision 17487)
+++ /tags/3.1/wp-admin/user/user-edit.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Edit user administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ * @since 3.1.0
+ */
+
+require_once( './admin.php' );
+
+require( '../user-edit.php' );
Index: /tags/3.1/wp-admin/users.php
===================================================================
--- /tags/3.1/wp-admin/users.php	(revision 17487)
+++ /tags/3.1/wp-admin/users.php	(revision 17487)
@@ -0,0 +1,398 @@
+<?php
+/**
+ * Users administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+if ( ! current_user_can( 'list_users' ) )
+	wp_die( __( 'Cheatin&#8217; uh?' ) );
+
+$wp_list_table = _get_list_table('WP_Users_List_Table');
+$pagenum = $wp_list_table->get_pagenum();
+$title = __('Users');
+$parent_file = 'users.php';
+
+add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
+
+// contextual help - choose Help on the top right of admin panel to preview this.
+add_contextual_help($current_screen,
+    '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '</p>' .
+    '<p>' . __('You can customize the display of information on this screen as you can on other screens, by using the Screen Options tab and the on-screen filters.') . '</p>' .
+    '<p>' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '</p>' .
+    '<p><strong>' . __('For more information:') . '</strong></p>' .
+    '<p>' . __('<a href="http://codex.wordpress.org/Users_Users_SubPanel" target="_blank">Documentation on Managing Users</a>') . '</p>' .
+    '<p>' . __('<a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>') . '</p>' .
+    '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
+);
+
+if ( empty($_REQUEST) ) {
+	$referer = '<input type="hidden" name="wp_http_referer" value="'. esc_attr(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
+} 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="' . esc_attr($redirect) . '" />';
+} else {
+	$redirect = 'users.php';
+	$referer = '';
+}
+
+$update = '';
+
+switch ( $wp_list_table->current_action() ) {
+
+/* Bulk Dropdown menu Role changes */
+case 'promote':
+	check_admin_referer('bulk-users');
+
+	if ( ! current_user_can( 'promote_users' ) )
+		wp_die( __( 'You can&#8217;t edit that user.' ) );
+
+	if ( empty($_REQUEST['users']) ) {
+		wp_redirect($redirect);
+		exit();
+	}
+
+	$editable_roles = get_editable_roles();
+	if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
+		wp_die(__('You can&#8217;t give users that role.'));
+
+	$userids = $_REQUEST['users'];
+	$update = 'promote';
+	foreach ( $userids as $id ) {
+		$id = (int) $id;
+
+		if ( ! current_user_can('promote_user', $id) )
+			wp_die(__('You can&#8217;t edit that user.'));
+		// The new role of the current user must also have promote_users caps
+		if ( $id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('promote_users') ) {
+			$update = 'err_admin_role';
+			continue;
+		}
+
+		// If the user doesn't already belong to the blog, bail.
+		if ( is_multisite() && !is_user_member_of_blog( $id ) )
+			wp_die(__('Cheatin&#8217; uh?'));
+
+		$user = new WP_User($id);
+		$user->set_role($_REQUEST['new_role']);
+	}
+
+	wp_redirect(add_query_arg('update', $update, $redirect));
+	exit();
+
+break;
+
+case 'dodelete':
+	if ( is_multisite() )
+		wp_die( __('User deletion is not allowed from this screen.') );
+
+	check_admin_referer('delete-users');
+
+	if ( empty($_REQUEST['users']) ) {
+		wp_redirect($redirect);
+		exit();
+	}
+
+	if ( ! current_user_can( 'delete_users' ) )
+		wp_die(__('You can&#8217;t delete users.'));
+
+	$userids = $_REQUEST['users'];
+	$update = 'del';
+	$delete_count = 0;
+
+	foreach ( (array) $userids as $id) {
+		$id = (int) $id;
+
+		if ( ! current_user_can( 'delete_user', $id ) )
+			wp_die(__( 'You can&#8217;t delete that user.' ) );
+
+		if ( $id == $current_user->ID ) {
+			$update = 'err_admin_del';
+			continue;
+		}
+		switch ( $_REQUEST['delete_option'] ) {
+		case 'delete':
+			if ( current_user_can('delete_user', $id) )
+				wp_delete_user($id);
+			break;
+		case 'reassign':
+			if ( current_user_can('delete_user', $id) )
+				wp_delete_user($id, $_REQUEST['reassign_user']);
+			break;
+		}
+		++$delete_count;
+	}
+
+	$redirect = add_query_arg( array('delete_count' => $delete_count, 'update' => $update), $redirect);
+	wp_redirect($redirect);
+	exit();
+
+break;
+
+case 'delete':
+	if ( is_multisite() )
+		wp_die( __('User deletion is not allowed from this screen.') );
+
+	check_admin_referer('bulk-users');
+
+	if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
+		wp_redirect($redirect);
+		exit();
+	}
+
+	if ( ! current_user_can( 'delete_users' ) )
+		$errors = new WP_Error( 'edit_users', __( 'You can&#8217;t delete users.' ) );
+
+	if ( empty($_REQUEST['users']) )
+		$userids = array(intval($_REQUEST['user']));
+	else
+		$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">
+<?php screen_icon(); ?>
+<h2><?php _e('Delete Users'); ?></h2>
+<p><?php _e('You have specified these users for deletion:'); ?></p>
+<ul>
+<?php
+	$go_delete = false;
+	foreach ( (array) $userids as $id ) {
+		$id = (int) $id;
+		$user = new WP_User($id);
+		if ( $id == $current_user->ID ) {
+			echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
+		} else {
+			echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
+			$go_delete = true;
+		}
+	}
+	?>
+	</ul>
+<?php if ( $go_delete ) : ?>
+	<fieldset><p><legend><?php _e('What should be done with posts and links owned by this user?'); ?></legend></p>
+	<ul style="list-style:none;">
+		<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
+		<?php _e('Delete all posts and links.'); ?></label></li>
+		<li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
+		<?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>';
+		wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
+	</ul></fieldset>
+	<input type="hidden" name="action" value="dodelete" />
+	<?php submit_button( __('Confirm Deletion'), 'secondary' ); ?>
+<?php else : ?>
+	<p><?php _e('There are no valid users selected for deletion.'); ?></p>
+<?php endif; ?>
+</div>
+</form>
+<?php
+
+break;
+
+case 'doremove':
+	check_admin_referer('remove-users');
+
+	if ( ! is_multisite() )
+		wp_die( __( 'You can&#8217;t remove users.' ) );
+
+	if ( empty($_REQUEST['users']) ) {
+		wp_redirect($redirect);
+		exit;
+	}
+
+	if ( ! current_user_can( 'remove_users' ) )
+		wp_die( __( 'You can&#8217;t remove users.' ) );
+
+	$userids = $_REQUEST['users'];
+
+	$update = 'remove';
+ 	foreach ( $userids as $id ) {
+		$id = (int) $id;
+		if ( $id == $current_user->id && !is_super_admin() ) {
+			$update = 'err_admin_remove';
+			continue;
+		}
+		if ( !current_user_can('remove_user', $id) ) {
+			$update = 'err_admin_remove';
+			continue;
+		}
+		remove_user_from_blog($id, $blog_id);
+	}
+
+	$redirect = add_query_arg( array('update' => $update), $redirect);
+	wp_redirect($redirect);
+	exit;
+
+break;
+
+case 'remove':
+
+	check_admin_referer('bulk-users');
+
+	if ( ! is_multisite() )
+		wp_die( __( 'You can&#8217;t remove users.' ) );
+
+	if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
+		wp_redirect($redirect);
+		exit();
+	}
+
+	if ( !current_user_can('remove_users') )
+		$error = new WP_Error('edit_users', __('You can&#8217;t remove users.'));
+
+	if ( empty($_REQUEST['users']) )
+		$userids = array(intval($_REQUEST['user']));
+	else
+		$userids = $_REQUEST['users'];
+
+	include ('admin-header.php');
+?>
+<form action="" method="post" name="updateusers" id="updateusers">
+<?php wp_nonce_field('remove-users') ?>
+<?php echo $referer; ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php _e('Remove Users from Site'); ?></h2>
+<p><?php _e('You have specified these users for removal:'); ?></p>
+<ul>
+<?php
+	$go_remove = false;
+ 	foreach ( $userids as $id ) {
+		$id = (int) $id;
+ 		$user = new WP_User($id);
+		if ( $id == $current_user->id && !is_super_admin() ) {
+			echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n";
+		} elseif ( !current_user_can('remove_user', $id) ) {
+			echo "<li>" . sprintf(__('ID #%1s: %2s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n";
+		} else {
+			echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
+			$go_remove = true;
+		}
+ 	}
+ 	?>
+<?php if ( $go_remove ) : ?>
+		<input type="hidden" name="action" value="doremove" />
+		<?php submit_button( __('Confirm Removal'), 'secondary' ); ?>
+<?php else : ?>
+	<p><?php _e('There are no valid users selected for removal.'); ?></p>
+<?php endif; ?>
+</div>
+</form>
+<?php
+
+break;
+
+default:
+
+	if ( !empty($_GET['_wp_http_referer']) ) {
+		wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
+		exit;
+	}
+
+	$wp_list_table->prepare_items();
+	$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
+	if ( $pagenum > $total_pages && $total_pages > 0 ) {
+		wp_redirect( add_query_arg( 'paged', $total_pages ) );
+		exit;
+	}
+	include('./admin-header.php');
+
+	$messages = array();
+	if ( isset($_GET['update']) ) :
+		switch($_GET['update']) {
+		case 'del':
+		case 'del_many':
+			$delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0;
+			$messages[] = '<div id="message" class="updated"><p>' . sprintf(_n('%s user deleted', '%s users deleted', $delete_count), $delete_count) . '</p></div>';
+			break;
+		case 'add':
+			$messages[] = '<div id="message" class="updated"><p>' . __('New user created.') . '</p></div>';
+			break;
+		case 'promote':
+			$messages[] = '<div id="message" class="updated"><p>' . __('Changed roles.') . '</p></div>';
+			break;
+		case 'err_admin_role':
+			$messages[] = '<div id="message" class="error"><p>' . __('The current user&#8217;s role must have user editing capabilities.') . '</p></div>';
+			$messages[] = '<div id="message" class="updated"><p>' . __('Other user roles have been changed.') . '</p></div>';
+			break;
+		case 'err_admin_del':
+			$messages[] = '<div id="message" class="error"><p>' . __('You can&#8217;t delete the current user.') . '</p></div>';
+			$messages[] = '<div id="message" class="updated"><p>' . __('Other users have been deleted.') . '</p></div>';
+			break;
+		case 'remove':
+			$messages[] = '<div id="message" class="updated fade"><p>' . __('User removed from this site.') . '</p></div>';
+			break;
+		case 'err_admin_remove':
+			$messages[] = '<div id="message" class="error"><p>' . __("You can't remove the current user.") . '</p></div>';
+			$messages[] = '<div id="message" class="updated fade"><p>' . __('Other users have been removed.') . '</p></div>';
+			break;
+		}
+	endif; ?>
+
+<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
+	<div class="error">
+		<ul>
+		<?php
+			foreach ( $errors->get_error_messages() as $err )
+				echo "<li>$err</li>\n";
+		?>
+		</ul>
+	</div>
+<?php endif;
+
+if ( ! empty($messages) ) {
+	foreach ( $messages as $msg )
+		echo $msg;
+} ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2>
+<?php
+echo esc_html( $title );
+if ( current_user_can( 'create_users' ) ) { ?>
+	<a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
+<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
+	<a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
+<?php }
+
+if ( $usersearch )
+	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $usersearch ) ); ?>
+</h2>
+
+<?php $wp_list_table->views(); ?>
+
+<form action="" method="get">
+
+<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
+
+<?php $wp_list_table->display(); ?>
+</form>
+
+<?php
+if ( is_multisite() ) {
+	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 = isset($_REQUEST[$formpost]) ? esc_attr(stripslashes($_REQUEST[$formpost])) : '';
+	}
+	unset($name);
+}
+?>
+
+<br class="clear" />
+</div>
+<?php
+break;
+
+} // end of the $doaction switch
+
+include('./admin-footer.php');
Index: /tags/3.1/wp-admin/widgets.php
===================================================================
--- /tags/3.1/wp-admin/widgets.php	(revision 17487)
+++ /tags/3.1/wp-admin/widgets.php	(revision 17487)
@@ -0,0 +1,413 @@
+<?php
+/**
+ * Widgets administration panel.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** WordPress Administration Bootstrap */
+require_once( './admin.php' );
+
+/** WordPress Administration Widgets API */
+require_once(ABSPATH . 'wp-admin/includes/widgets.php');
+
+if ( ! current_user_can('edit_theme_options') )
+	wp_die( __( 'Cheatin&#8217; uh?' ));
+
+wp_admin_css( 'widgets' );
+
+$widgets_access = get_user_setting( 'widgets_access' );
+if ( isset($_GET['widgets-access']) ) {
+	$widgets_access = 'on' == $_GET['widgets-access'] ? 'on' : 'off';
+	set_user_setting( 'widgets_access', $widgets_access );
+}
+
+if ( 'on' == $widgets_access )
+	add_filter( 'admin_body_class', create_function('', '{return " widgets_access ";}') );
+else
+	wp_enqueue_script('admin-widgets');
+
+do_action( 'sidebar_admin_setup' );
+
+$title = __( 'Widgets' );
+$parent_file = 'themes.php';
+
+$help = '
+	<p>' . __('Widgets are independent sections of content that can be placed into any widgetized area provided by your theme (commonly called sidebars). To populate your sidebars/widget areas with individual widgets, drag and drop the title bars into the desired area. By default, only the first widget area is expanded. To populate additional widget areas, click on their title bars to expand them.') . '</p>
+	<p>' . __('The Available Widgets section contains all the widgets you can choose from. Once you drag a widget into a sidebar, it will open to allow you to configure its settings. When you are happy with the widget settings, click the Save button and the widget will go live on your site. If you click Delete, it will remove the widget.') . '</p>
+	<p>' . __('If you want to remove the widget but save its setting for possible future use, just drag it into the Inactive Widgets area. You can add them back anytime from there. This is especially helpful when you switch to a theme with fewer or different widget areas.') . '</p>
+	<p>' . __('Widgets may be used multiple times. You can give each widget a title, to display on your site, but it&#8217;s not required.') . '</p>
+	<p>' . __('Enabling Accessibility Mode, via Screen Options, allows you to use Add and Edit buttons instead of using drag and drop.') . '</p>
+	<p>' . __('Many themes show some sidebar widgets by default until you edit your sidebars, but they are not automatically displayed in your sidebar management tool. After you make your first widget change, you can re-add the default widgets by adding them from the Available Widgets area.') . '</p>
+';
+$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
+$help .= '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Widgets_SubPanel" target="_blank">Documentation on Widgets</a>') . '</p>';
+$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
+add_contextual_help($current_screen, $help);
+
+// register the inactive_widgets area as sidebar
+register_sidebar(array(
+	'name' => __('Inactive Widgets'),
+	'id' => 'wp_inactive_widgets',
+	'description' => '',
+	'before_widget' => '',
+	'after_widget' => '',
+	'before_title' => '',
+	'after_title' => '',
+));
+
+// These are the widgets grouped by sidebar
+$sidebars_widgets = wp_get_sidebars_widgets();
+if ( empty( $sidebars_widgets ) )
+	$sidebars_widgets = wp_get_widget_defaults();
+
+// look for "lost" widgets, this has to run at least on each theme change
+function retrieve_widgets() {
+	global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
+
+	$_sidebars_widgets = array();
+	$sidebars = array_keys($wp_registered_sidebars);
+
+	unset( $sidebars_widgets['array_version'] );
+
+	$old = array_keys($sidebars_widgets);
+	sort($old);
+	sort($sidebars);
+
+	if ( $old == $sidebars )
+		return;
+
+	// Move the known-good ones first
+	foreach ( $sidebars as $id ) {
+		if ( array_key_exists( $id, $sidebars_widgets ) ) {
+			$_sidebars_widgets[$id] = $sidebars_widgets[$id];
+			unset($sidebars_widgets[$id], $sidebars[$id]);
+		}
+	}
+
+	// if new theme has less sidebars than the old theme
+	if ( !empty($sidebars_widgets) ) {
+		foreach ( $sidebars_widgets as $lost => $val ) {
+			if ( is_array($val) )
+				$_sidebars_widgets['wp_inactive_widgets'] = array_merge( (array) $_sidebars_widgets['wp_inactive_widgets'], $val );
+		}
+	}
+
+	// discard invalid, theme-specific widgets from sidebars
+	$shown_widgets = array();
+	foreach ( $_sidebars_widgets as $sidebar => $widgets ) {
+		if ( !is_array($widgets) )
+			continue;
+
+		$_widgets = array();
+		foreach ( $widgets as $widget ) {
+			if ( isset($wp_registered_widgets[$widget]) )
+				$_widgets[] = $widget;
+		}
+		$_sidebars_widgets[$sidebar] = $_widgets;
+		$shown_widgets = array_merge($shown_widgets, $_widgets);
+	}
+
+	$sidebars_widgets = $_sidebars_widgets;
+	unset($_sidebars_widgets, $_widgets);
+
+	// find hidden/lost multi-widget instances
+	$lost_widgets = array();
+	foreach ( $wp_registered_widgets as $key => $val ) {
+		if ( in_array($key, $shown_widgets, true) )
+			continue;
+
+		$number = preg_replace('/.+?-([0-9]+)$/', '$1', $key);
+
+		if ( 2 > (int) $number )
+			continue;
+
+		$lost_widgets[] = $key;
+	}
+
+	$sidebars_widgets['wp_inactive_widgets'] = array_merge($lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets']);
+	wp_set_sidebars_widgets($sidebars_widgets);
+}
+retrieve_widgets();
+
+if ( count($wp_registered_sidebars) == 1 ) {
+	// If only "wp_inactive_widgets" is defined the theme has no sidebars, die.
+	require_once( './admin-header.php' );
+?>
+
+	<div class="wrap">
+	<?php screen_icon(); ?>
+	<h2><?php echo esc_html( $title ); ?></h2>
+		<div class="error">
+			<p><?php _e( 'No Sidebars Defined' ); ?></p>
+		</div>
+		<p><?php _e( 'The theme you are currently using isn&#8217;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://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.' ); ?></p>
+	</div>
+
+<?php
+	require_once( './admin-footer.php' );
+	exit;
+}
+
+// We're saving a widget without js
+if ( isset($_POST['savewidget']) || isset($_POST['removewidget']) ) {
+	$widget_id = $_POST['widget-id'];
+	check_admin_referer("save-delete-widget-$widget_id");
+
+	$number = isset($_POST['multi_number']) ? (int) $_POST['multi_number'] : '';
+	if ( $number ) {
+		foreach ( $_POST as $key => $val ) {
+			if ( is_array($val) && preg_match('/__i__|%i%/', key($val)) ) {
+				$_POST[$key] = array( $number => array_shift($val) );
+				break;
+			}
+		}
+	}
+
+	$sidebar_id = $_POST['sidebar'];
+	$position = isset($_POST[$sidebar_id . '_position']) ? (int) $_POST[$sidebar_id . '_position'] - 1 : 0;
+
+	$id_base = $_POST['id_base'];
+	$sidebar = isset($sidebars_widgets[$sidebar_id]) ? $sidebars_widgets[$sidebar_id] : array();
+
+	// delete
+	if ( isset($_POST['removewidget']) && $_POST['removewidget'] ) {
+
+		if ( !in_array($widget_id, $sidebar, true) ) {
+			wp_redirect( admin_url('widgets.php?error=0') );
+			exit;
+		}
+
+		$sidebar = array_diff( $sidebar, array($widget_id) );
+		$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
+	}
+
+	$_POST['widget-id'] = $sidebar;
+
+	foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
+		if ( $name != $id_base || !is_callable($control['callback']) )
+			continue;
+
+		ob_start();
+			call_user_func_array( $control['callback'], $control['params'] );
+		ob_end_clean();
+
+		break;
+	}
+
+	$sidebars_widgets[$sidebar_id] = $sidebar;
+
+	// remove old position
+	if ( !isset($_POST['delete_widget']) ) {
+		foreach ( $sidebars_widgets as $key => $sb ) {
+			if ( is_array($sb) )
+				$sidebars_widgets[$key] = array_diff( $sb, array($widget_id) );
+		}
+		array_splice( $sidebars_widgets[$sidebar_id], $position, 0, $widget_id );
+	}
+
+	wp_set_sidebars_widgets($sidebars_widgets);
+	wp_redirect( admin_url('widgets.php?message=0') );
+	exit;
+}
+
+// Output the widget form without js
+if ( isset($_GET['editwidget']) && $_GET['editwidget'] ) {
+	$widget_id = $_GET['editwidget'];
+
+	if ( isset($_GET['addnew']) ) {
+		// Default to the first sidebar
+		$sidebar = array_shift( $keys = array_keys($wp_registered_sidebars) );
+
+		if ( isset($_GET['base']) && isset($_GET['num']) ) { // multi-widget
+			// 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'];
+					$multi_number = (int) $_GET['num'];
+					$control['params'][0]['number'] = -1;
+					$widget_id = $control['id'] = $control['id_base'] . '-' . $multi_number;
+					$wp_registered_widget_controls[$control['id']] = $control;
+					break;
+				}
+			}
+		}
+	}
+
+	if ( isset($wp_registered_widget_controls[$widget_id]) && !isset($control) ) {
+		$control = $wp_registered_widget_controls[$widget_id];
+		$control_callback = $control['callback'];
+	} elseif ( !isset($wp_registered_widget_controls[$widget_id]) && isset($wp_registered_widgets[$widget_id]) ) {
+		$name = esc_html( strip_tags($wp_registered_widgets[$widget_id]['name']) );
+	}
+
+	if ( !isset($name) )
+		$name = esc_html( strip_tags($control['name']) );
+
+	if ( !isset($sidebar) )
+		$sidebar = isset($_GET['sidebar']) ? $_GET['sidebar'] : 'wp_inactive_widgets';
+
+	if ( !isset($multi_number) )
+		$multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
+
+	$id_base = isset($control['id_base']) ? $control['id_base'] : $control['id'];
+
+	// show the widget form
+	$width = ' style="width:' . max($control['width'], 350) . 'px"';
+	$key = isset($_GET['key']) ? (int) $_GET['key'] : 0;
+
+	require_once( './admin-header.php' ); ?>
+	<div class="wrap">
+	<?php screen_icon(); ?>
+	<h2><?php echo esc_html( $title ); ?></h2>
+	<div class="editwidget"<?php echo $width; ?>>
+	<h3><?php printf( __( 'Widget %s' ), $name ); ?></h3>
+
+	<form action="widgets.php" method="post">
+	<div class="widget-inside">
+<?php
+	if ( is_callable( $control_callback ) )
+		call_user_func_array( $control_callback, $control['params'] );
+	else
+		echo '<p>' . __('There are no options for this widget.') . "</p>\n"; ?>
+	</div>
+
+	<p class="describe"><?php _e('Select both the sidebar for this widget and the position of the widget in that sidebar.'); ?></p>
+	<div class="widget-position">
+	<table class="widefat"><thead><tr><th><?php _e('Sidebar'); ?></th><th><?php _e('Position'); ?></th></tr></thead><tbody>
+<?php
+	foreach ( $wp_registered_sidebars as $sbname => $sbvalue ) {
+		echo "\t\t<tr><td><label><input type='radio' name='sidebar' value='" . esc_attr($sbname) . "'" . checked( $sbname, $sidebar, false ) . " /> $sbvalue[name]</label></td><td>";
+		if ( 'wp_inactive_widgets' == $sbname ) {
+			echo '&nbsp;';
+		} else {
+			if ( !isset($sidebars_widgets[$sbname]) || !is_array($sidebars_widgets[$sbname]) ) {
+				$j = 1;
+				$sidebars_widgets[$sbname] = array();
+			} else {
+				$j = count($sidebars_widgets[$sbname]);
+				if ( isset($_GET['addnew']) || !in_array($widget_id, $sidebars_widgets[$sbname], true) )
+					$j++;
+			}
+			$selected = '';
+			echo "\t\t<select name='{$sbname}_position'>\n";
+			echo "\t\t<option value=''>" . __('&mdash; Select &mdash;') . "</option>\n";
+			for ( $i = 1; $i <= $j; $i++ ) {
+				if ( in_array($widget_id, $sidebars_widgets[$sbname], true) )
+					$selected = selected( $i, $key + 1, false );
+				echo "\t\t<option value='$i'$selected> $i </option>\n";
+			}
+			echo "\t\t</select>\n";
+		}
+		echo "</td></tr>\n";
+	} ?>
+	</tbody></table>
+	</div>
+
+	<div class="widget-control-actions">
+<?php
+	if ( isset($_GET['addnew']) ) { ?>
+	<a href="widgets.php" class="button alignleft"><?php _e('Cancel'); ?></a>
+<?php
+	} else {
+		submit_button( __( 'Delete' ), 'button alignleft', 'removewidget', false );
+	}
+	submit_button( __( 'Save Widget' ), 'button-primary alignright', 'savewidget', false ); ?>
+	<input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($widget_id); ?>" />
+	<input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
+	<input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
+<?php	wp_nonce_field("save-delete-widget-$widget_id"); ?>
+	<br class="clear" />
+	</div>
+	</form>
+	</div>
+	</div>
+<?php
+	require_once( './admin-footer.php' );
+	exit;
+}
+
+$messages = array(
+	__('Changes saved.')
+);
+
+$errors = array(
+	__('Error while saving.'),
+	__('Error in displaying the widget settings form.')
+);
+
+require_once( './admin-header.php' ); ?>
+
+<div class="wrap">
+<?php screen_icon(); ?>
+<h2><?php echo esc_html( $title ); ?></h2>
+
+<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
+<div id="message" class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php } ?>
+<?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
+<div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>
+<?php } ?>
+
+<?php do_action( 'widgets_admin_page' ); ?>
+
+<div class="widget-liquid-left">
+<div id="widgets-left">
+	<div id="available-widgets" class="widgets-holder-wrap">
+		<div class="sidebar-name">
+		<div class="sidebar-name-arrow"><br /></div>
+		<h3><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _e('Deactivate'); ?> <span></span></span></h3></div>
+		<div class="widget-holder">
+		<p class="description"><?php _e('Drag widgets from here to a sidebar on the right to activate them. Drag widgets back here to deactivate them and delete their settings.'); ?></p>
+		<div id="widget-list">
+		<?php wp_list_widgets(); ?>
+		</div>
+		<br class='clear' />
+		</div>
+		<br class="clear" />
+	</div>
+
+	<div class="widgets-holder-wrap">
+		<div class="sidebar-name">
+		<div class="sidebar-name-arrow"><br /></div>
+		<h3><?php _e('Inactive Widgets'); ?>
+		<span><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /></span></h3></div>
+		<div class="widget-holder inactive">
+		<p class="description"><?php _e('Drag widgets here to remove them from the sidebar but keep their settings.'); ?></p>
+		<?php wp_list_widget_controls('wp_inactive_widgets'); ?>
+		<br class="clear" />
+		</div>
+	</div>
+</div>
+</div>
+
+<div class="widget-liquid-right">
+<div id="widgets-right">
+<?php
+$i = 0;
+foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
+	if ( 'wp_inactive_widgets' == $sidebar )
+		continue;
+	$closed = $i ? ' closed' : ''; ?>
+	<div class="widgets-holder-wrap<?php echo $closed; ?>">
+	<div class="sidebar-name">
+	<div class="sidebar-name-arrow"><br /></div>
+	<h3><?php echo esc_html( $registered_sidebar['name'] ); ?>
+	<span><img src="<?php echo esc_url( admin_url( 'images/wpspin_dark.gif' ) ); ?>" class="ajax-feedback" title="" alt="" /></span></h3></div>
+	<?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?>
+	</div>
+<?php
+	$i++;
+} ?>
+</div>
+</div>
+<form action="" method="post">
+<?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?>
+</form>
+<br class="clear" />
+</div>
+
+<?php
+do_action( 'sidebar_admin_page' );
+require_once( './admin-footer.php' );
Index: /tags/3.1/wp-app.php
===================================================================
--- /tags/3.1/wp-app.php	(revision 17487)
+++ /tags/3.1/wp-app.php	(revision 17487)
@@ -0,0 +1,1611 @@
+<?php
+/**
+ * Atom Publishing Protocol support for WordPress
+ *
+ * @version 1.0.5-dc
+ */
+
+/**
+ * WordPress is handling an Atom Publishing Protocol request.
+ *
+ * @var bool
+ */
+define('APP_REQUEST', true);
+
+/** Set up WordPress environment */
+require_once('./wp-load.php');
+
+/** Atom Publishing Protocol Class */
+require_once(ABSPATH . WPINC . '/atomlib.php');
+
+/** Admin Image API for metadata updating */
+require_once(ABSPATH . '/wp-admin/includes/image.php');
+
+$_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] );
+
+/**
+ * Whether to enable Atom Publishing Protocol Logging.
+ *
+ * @name app_logging
+ * @var int|bool
+ */
+$app_logging = 0;
+
+/**
+ * Whether to always authenticate user. Permanently set to true.
+ *
+ * @name always_authenticate
+ * @var int|bool
+ * @todo Should be an option somewhere
+ */
+$always_authenticate = 1;
+
+/**
+ * Writes logging info to a file.
+ *
+ * @since 2.2.0
+ * @uses $app_logging
+ * @package WordPress
+ * @subpackage Logging
+ *
+ * @param string $label Type of logging
+ * @param string $msg Information describing logging reason.
+ */
+function log_app($label,$msg) {
+	global $app_logging;
+	if ($app_logging) {
+		$fp = fopen( 'wp-app.log', 'a+');
+		$date = gmdate( 'Y-m-d H:i:s' );
+		fwrite($fp, "\n\n$date - $label\n$msg\n");
+		fclose($fp);
+	}
+}
+
+/**
+ * Filter to add more post statuses.
+ *
+ * @since 2.2.0
+ *
+ * @param string $where SQL statement to filter.
+ * @return string Filtered SQL statement with added post_status for where clause.
+ */
+function wa_posts_where_include_drafts_filter($where) {
+	$where = str_replace("post_status = 'publish'","post_status = 'publish' OR post_status = 'future' OR post_status = 'draft' OR post_status = 'inherit'", $where);
+	return $where;
+
+}
+add_filter('posts_where', 'wa_posts_where_include_drafts_filter');
+
+/**
+ * WordPress AtomPub API implementation.
+ *
+ * @package WordPress
+ * @subpackage Publishing
+ * @since 2.2.0
+ */
+class AtomServer {
+
+	/**
+	 * ATOM content type.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $ATOM_CONTENT_TYPE = 'application/atom+xml';
+
+	/**
+	 * Categories ATOM content type.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $CATEGORIES_CONTENT_TYPE = 'application/atomcat+xml';
+
+	/**
+	 * Service ATOM content type.
+	 *
+	 * @since 2.3.0
+	 * @var string
+	 */
+	var $SERVICE_CONTENT_TYPE = 'application/atomsvc+xml';
+
+	/**
+	 * ATOM XML namespace.
+	 *
+	 * @since 2.3.0
+	 * @var string
+	 */
+	var $ATOM_NS = 'http://www.w3.org/2005/Atom';
+
+	/**
+	 * ATOMPUB XML namespace.
+	 *
+	 * @since 2.3.0
+	 * @var string
+	 */
+	var $ATOMPUB_NS = 'http://www.w3.org/2007/app';
+
+	/**
+	 * Entries path.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $ENTRIES_PATH = "posts";
+
+	/**
+	 * Categories path.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $CATEGORIES_PATH = "categories";
+
+	/**
+	 * Media path.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $MEDIA_PATH = "attachments";
+
+	/**
+	 * Entry path.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $ENTRY_PATH = "post";
+
+	/**
+	 * Service path.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $SERVICE_PATH = "service";
+
+	/**
+	 * Media single path.
+	 *
+	 * @since 2.2.0
+	 * @var string
+	 */
+	var $MEDIA_SINGLE_PATH = "attachment";
+
+	/**
+	 * ATOMPUB parameters.
+	 *
+	 * @since 2.2.0
+	 * @var array
+	 */
+	var $params = array();
+
+	/**
+	 * Supported ATOMPUB media types.
+	 *
+	 * @since 2.3.0
+	 * @var array
+	 */
+	var $media_content_types = array('image/*','audio/*','video/*');
+
+	/**
+	 * ATOMPUB content type(s).
+	 *
+	 * @since 2.2.0
+	 * @var array
+	 */
+	var $atom_content_types = array('application/atom+xml');
+
+	/**
+	 * ATOMPUB methods.
+	 *
+	 * @since 2.2.0
+	 * @var unknown_type
+	 */
+	var $selectors = array();
+
+	/**
+	 * Whether to do output.
+	 *
+	 * Support for head.
+	 *
+	 * @since 2.2.0
+	 * @var bool
+	 */
+	var $do_output = true;
+
+	/**
+	 * PHP4 constructor - Sets up object properties.
+	 *
+	 * @since 2.2.0
+	 * @return AtomServer
+	 */
+	function AtomServer() {
+
+		$this->script_name = array_pop( $var_by_ref = explode( '/', $_SERVER['SCRIPT_NAME'] ) );
+		$this->app_base = site_url( $this->script_name . '/' );
+
+		$this->selectors = array(
+			'@/service$@' =>
+				array('GET' => 'get_service'),
+			'@/categories$@' =>
+				array('GET' => 'get_categories_xml'),
+			'@/post/(\d+)$@' =>
+				array('GET' => 'get_post',
+						'PUT' => 'put_post',
+						'DELETE' => 'delete_post'),
+			'@/posts/?(\d+)?$@' =>
+				array('GET' => 'get_posts',
+						'POST' => 'create_post'),
+			'@/attachments/?(\d+)?$@' =>
+				array('GET' => 'get_attachment',
+						'POST' => 'create_attachment'),
+			'@/attachment/file/(\d+)$@' =>
+				array('GET' => 'get_file',
+						'PUT' => 'put_file',
+						'DELETE' => 'delete_file'),
+			'@/attachment/(\d+)$@' =>
+				array('GET' => 'get_attachment',
+						'PUT' => 'put_attachment',
+						'DELETE' => 'delete_attachment'),
+		);
+	}
+
+	/**
+	 * Handle ATOMPUB request.
+	 *
+	 * @since 2.2.0
+	 */
+	function handle_request() {
+		global $always_authenticate;
+
+		if ( !empty( $_SERVER['ORIG_PATH_INFO'] ) )
+			$path = $_SERVER['ORIG_PATH_INFO'];
+		else
+			$path = $_SERVER['PATH_INFO'];
+
+		$method = $_SERVER['REQUEST_METHOD'];
+
+		log_app('REQUEST',"$method $path\n================");
+
+		$this->process_conditionals();
+		//$this->process_conditionals();
+
+		// exception case for HEAD (treat exactly as GET, but don't output)
+		if ($method == 'HEAD') {
+			$this->do_output = false;
+			$method = 'GET';
+		}
+
+		// redirect to /service in case no path is found.
+		if (strlen($path) == 0 || $path == '/')
+			$this->redirect($this->get_service_url());
+
+		// check to see if AtomPub is enabled
+		if ( !get_option( 'enable_app' ) )
+			$this->forbidden( sprintf( __( 'AtomPub services are disabled on this site.  An admin user can enable them at %s' ), admin_url('options-writing.php') ) );
+
+		// dispatch
+		foreach ( $this->selectors as $regex => $funcs ) {
+			if ( preg_match($regex, $path, $matches) ) {
+				if ( isset($funcs[$method]) ) {
+
+					// authenticate regardless of the operation and set the current
+					// user. each handler will decide if auth is required or not.
+					if ( !$this->authenticate() ) {
+						if ( $always_authenticate )
+							$this->auth_required('Credentials required.');
+					}
+
+					array_shift($matches);
+					call_user_func_array(array(&$this,$funcs[$method]), $matches);
+					exit();
+				} else {
+					// only allow what we have handlers for...
+					$this->not_allowed(array_keys($funcs));
+				}
+			}
+		}
+
+		// oops, nothing found
+		$this->not_found();
+	}
+
+	/**
+	 * Retrieve XML for ATOMPUB service.
+	 *
+	 * @since 2.2.0
+	 */
+	function get_service() {
+		log_app('function','get_service()');
+
+		if ( !current_user_can( 'edit_posts' ) )
+			$this->auth_required( __( 'Sorry, you do not have the right to access this site.' ) );
+
+		$entries_url = esc_attr($this->get_entries_url());
+		$categories_url = esc_attr($this->get_categories_url());
+		$media_url = esc_attr($this->get_attachments_url());
+		$accepted_media_types = '';
+		foreach ($this->media_content_types as $med) {
+			$accepted_media_types = $accepted_media_types . "<accept>" . $med . "</accept>";
+		}
+		$atom_prefix="atom";
+		$atom_blogname = get_bloginfo('name');
+		$service_doc = <<<EOD
+<service xmlns="$this->ATOMPUB_NS" xmlns:$atom_prefix="$this->ATOM_NS">
+  <workspace>
+    <$atom_prefix:title>$atom_blogname Workspace</$atom_prefix:title>
+    <collection href="$entries_url">
+      <$atom_prefix:title>$atom_blogname Posts</$atom_prefix:title>
+      <accept>$this->ATOM_CONTENT_TYPE;type=entry</accept>
+      <categories href="$categories_url" />
+    </collection>
+    <collection href="$media_url">
+      <$atom_prefix:title>$atom_blogname Media</$atom_prefix:title>
+      $accepted_media_types
+    </collection>
+  </workspace>
+</service>
+
+EOD;
+
+		$this->output($service_doc, $this->SERVICE_CONTENT_TYPE);
+	}
+
+	/**
+	 * Retrieve categories list in XML format.
+	 *
+	 * @since 2.2.0
+	 */
+	function get_categories_xml() {
+		log_app('function','get_categories_xml()');
+
+		if ( !current_user_can( 'edit_posts' ) )
+			$this->auth_required( __( 'Sorry, you do not have the right to access this site.' ) );
+
+		$home = esc_attr(get_bloginfo_rss('url'));
+
+		$categories = "";
+		$cats = get_categories(array('hierarchical' => 0, 'hide_empty' => 0));
+		foreach ( (array) $cats as $cat ) {
+			$categories .= "    <category term=\"" . esc_attr($cat->name) .  "\" />\n";
+		}
+		$output = <<<EOD
+<app:categories xmlns:app="$this->ATOMPUB_NS"
+	xmlns="$this->ATOM_NS"
+	fixed="yes" scheme="$home">
+	$categories
+</app:categories>
+EOD;
+		$this->output($output, $this->CATEGORIES_CONTENT_TYPE);
+	}
+
+	/**
+	 * Create new post.
+	 *
+	 * @since 2.2.0
+	 */
+	function create_post() {
+		global $user_ID;
+		$this->get_accepted_content_type($this->atom_content_types);
+
+		$parser = new AtomParser();
+		if ( !$parser->parse() )
+			$this->client_error();
+
+		$entry = array_pop($parser->feed->entries);
+
+		log_app('Received entry:', print_r($entry,true));
+
+		$catnames = array();
+		foreach ( $entry->categories as $cat ) {
+			array_push($catnames, $cat["term"]);
+		}
+
+		$wp_cats = get_categories(array('hide_empty' => false));
+
+		$post_category = array();
+
+		foreach ( $wp_cats as $cat ) {
+			if ( in_array($cat->name, $catnames) )
+				array_push($post_category, $cat->term_id);
+		}
+
+		$publish = ! ( isset( $entry->draft ) && 'yes' == trim( $entry->draft ) );
+
+		$cap = ($publish) ? 'publish_posts' : 'edit_posts';
+
+		if ( !current_user_can($cap) )
+			$this->auth_required(__('Sorry, you do not have the right to edit/publish new posts.'));
+
+		$blog_ID = get_current_blog_id();
+		$post_status = ($publish) ? 'publish' : 'draft';
+		$post_author = (int) $user_ID;
+		$post_title = $entry->title[1];
+		$post_content = $entry->content[1];
+		$post_excerpt = $entry->summary[1];
+		$pubtimes = $this->get_publish_time($entry->published);
+		$post_date = $pubtimes[0];
+		$post_date_gmt = $pubtimes[1];
+
+		if ( isset( $_SERVER['HTTP_SLUG'] ) )
+			$post_name = $_SERVER['HTTP_SLUG'];
+
+		$post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_name');
+
+		$this->escape($post_data);
+		log_app('Inserting Post. Data:', print_r($post_data,true));
+
+		$postID = wp_insert_post($post_data);
+		if ( is_wp_error( $postID ) )
+			$this->internal_error($postID->get_error_message());
+
+		if ( !$postID )
+			$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
+
+		// getting warning here about unable to set headers
+		// because something in the cache is printing to the buffer
+		// could we clean up wp_set_post_categories or cache to not print
+		// this could affect our ability to send back the right headers
+		@wp_set_post_categories($postID, $post_category);
+
+		do_action( 'atompub_create_post', $postID, $entry );
+
+		$output = $this->get_entry($postID);
+
+		log_app('function',"create_post($postID)");
+		$this->created($postID, $output);
+	}
+
+	/**
+	 * Retrieve post.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function get_post($postID) {
+		global $entry;
+
+		if ( !current_user_can( 'edit_post', $postID ) )
+			$this->auth_required( __( 'Sorry, you do not have the right to access this post.' ) );
+
+		$this->set_current_entry($postID);
+		$output = $this->get_entry($postID);
+		log_app('function',"get_post($postID)");
+		$this->output($output);
+
+	}
+
+	/**
+	 * Update post.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function put_post($postID) {
+		// checked for valid content-types (atom+xml)
+		// quick check and exit
+		$this->get_accepted_content_type($this->atom_content_types);
+
+		$parser = new AtomParser();
+		if ( !$parser->parse() )
+			$this->bad_request();
+
+		$parsed = array_pop($parser->feed->entries);
+
+		log_app('Received UPDATED entry:', print_r($parsed,true));
+
+		// check for not found
+		global $entry;
+		$this->set_current_entry($postID);
+
+		if ( !current_user_can('edit_post', $entry['ID']) )
+			$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
+
+		$publish = ! ( isset($parsed->draft) && 'yes' == trim($parsed->draft) );
+		$post_status = ($publish) ? 'publish' : 'draft';
+
+		extract($entry);
+
+		$post_title = $parsed->title[1];
+		$post_content = $parsed->content[1];
+		$post_excerpt = $parsed->summary[1];
+		$pubtimes = $this->get_publish_time($entry->published);
+		$post_date = $pubtimes[0];
+		$post_date_gmt = $pubtimes[1];
+		$pubtimes = $this->get_publish_time($parsed->updated);
+		$post_modified = $pubtimes[0];
+		$post_modified_gmt = $pubtimes[1];
+
+		$postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt');
+		$this->escape($postdata);
+
+		$result = wp_update_post($postdata);
+
+		if ( !$result )
+			$this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
+
+		do_action( 'atompub_put_post', $ID, $parsed );
+
+		log_app('function',"put_post($postID)");
+		$this->ok();
+	}
+
+	/**
+	 * Remove post.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function delete_post($postID) {
+
+		// check for not found
+		global $entry;
+		$this->set_current_entry($postID);
+
+		if ( !current_user_can('edit_post', $postID) )
+			$this->auth_required(__('Sorry, you do not have the right to delete this post.'));
+
+		if ( $entry['post_type'] == 'attachment' ) {
+			$this->delete_attachment($postID);
+		} else {
+			$result = wp_delete_post($postID);
+
+			if ( !$result ) {
+				$this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
+			}
+
+			log_app('function',"delete_post($postID)");
+			$this->ok();
+		}
+
+	}
+
+	/**
+	 * Retrieve attachment.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Optional. Post ID.
+	 */
+	function get_attachment($postID = null) {
+		if ( !current_user_can( 'upload_files' ) )
+			$this->auth_required( __( 'Sorry, you do not have permission to upload files.' ) );
+
+		if ( !isset($postID) ) {
+			$this->get_attachments();
+		} else {
+			$this->set_current_entry($postID);
+			$output = $this->get_entry($postID, 'attachment');
+			log_app('function',"get_attachment($postID)");
+			$this->output($output);
+		}
+	}
+
+	/**
+	 * Create new attachment.
+	 *
+	 * @since 2.2.0
+	 */
+	function create_attachment() {
+
+		$type = $this->get_accepted_content_type();
+
+		if ( !current_user_can('upload_files') )
+			$this->auth_required(__('You do not have permission to upload files.'));
+
+		$fp = fopen("php://input", "rb");
+		$bits = null;
+		while ( !feof($fp) ) {
+			$bits .= fread($fp, 4096);
+		}
+		fclose($fp);
+
+		$slug = '';
+		if ( isset( $_SERVER['HTTP_SLUG'] ) )
+			$slug = sanitize_file_name( $_SERVER['HTTP_SLUG'] );
+		elseif ( isset( $_SERVER['HTTP_TITLE'] ) )
+			$slug = sanitize_file_name( $_SERVER['HTTP_TITLE'] );
+		elseif ( empty( $slug ) ) // just make a random name
+			$slug = substr( md5( uniqid( microtime() ) ), 0, 7);
+		$ext = preg_replace( '|.*/([a-z0-9]+)|', '$1', $_SERVER['CONTENT_TYPE'] );
+		$slug = "$slug.$ext";
+		$file = wp_upload_bits( $slug, NULL, $bits);
+
+		log_app('wp_upload_bits returns:',print_r($file,true));
+
+		$url = $file['url'];
+		$file = $file['file'];
+
+		do_action('wp_create_file_in_uploads', $file); // replicate
+
+		// Construct the attachment array
+		$attachment = array(
+			'post_title' => $slug,
+			'post_content' => $slug,
+			'post_status' => 'attachment',
+			'post_parent' => 0,
+			'post_mime_type' => $type,
+			'guid' => $url
+			);
+
+		// Save the data
+		$postID = wp_insert_attachment($attachment, $file);
+
+		if (!$postID)
+			$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
+
+		$output = $this->get_entry($postID, 'attachment');
+
+		$this->created($postID, $output, 'attachment');
+		log_app('function',"create_attachment($postID)");
+	}
+
+	/**
+	 * Update attachment.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function put_attachment($postID) {
+		// checked for valid content-types (atom+xml)
+		// quick check and exit
+		$this->get_accepted_content_type($this->atom_content_types);
+
+		$parser = new AtomParser();
+		if (!$parser->parse()) {
+			$this->bad_request();
+		}
+
+		$parsed = array_pop($parser->feed->entries);
+
+		// check for not found
+		global $entry;
+		$this->set_current_entry($postID);
+
+		if ( !current_user_can('edit_post', $entry['ID']) )
+			$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
+
+		extract($entry);
+
+		$post_title = $parsed->title[1];
+		$post_content = $parsed->summary[1];
+		$pubtimes = $this->get_publish_time($parsed->updated);
+		$post_modified = $pubtimes[0];
+		$post_modified_gmt = $pubtimes[1];
+
+		$postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'post_modified', 'post_modified_gmt');
+		$this->escape($postdata);
+
+		$result = wp_update_post($postdata);
+
+		if ( !$result )
+			$this->internal_error(__('For some strange yet very annoying reason, this post could not be edited.'));
+
+		log_app('function',"put_attachment($postID)");
+		$this->ok();
+	}
+
+	/**
+	 * Remove attachment.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function delete_attachment($postID) {
+		log_app('function',"delete_attachment($postID). File '$location' deleted.");
+
+		// check for not found
+		global $entry;
+		$this->set_current_entry($postID);
+
+		if ( !current_user_can('edit_post', $postID) )
+			$this->auth_required(__('Sorry, you do not have the right to delete this post.'));
+
+		$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
+		$filetype = wp_check_filetype($location);
+
+		if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
+			$this->internal_error(__('Error occurred while accessing post metadata for file location.'));
+
+		// delete file
+		@unlink($location);
+
+		// delete attachment
+		$result = wp_delete_post($postID);
+
+		if ( !$result )
+			$this->internal_error(__('For some strange yet very annoying reason, this post could not be deleted.'));
+
+		log_app('function',"delete_attachment($postID). File '$location' deleted.");
+		$this->ok();
+	}
+
+	/**
+	 * Retrieve attachment from post.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function get_file($postID) {
+
+		// check for not found
+		global $entry;
+		$this->set_current_entry($postID);
+
+		// then whether user can edit the specific post
+		if ( !current_user_can('edit_post', $postID) )
+			$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
+
+		$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
+		$location = get_option ('upload_path') . '/' . $location;
+		$filetype = wp_check_filetype($location);
+
+		if ( !isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']) )
+			$this->internal_error(__('Error occurred while accessing post metadata for file location.'));
+
+		status_header('200');
+		header('Content-Type: ' . $entry['post_mime_type']);
+		header('Connection: close');
+
+		if ( $fp = fopen($location, "rb") ) {
+			status_header('200');
+			header('Content-Type: ' . $entry['post_mime_type']);
+			header('Connection: close');
+
+			while ( !feof($fp) ) {
+				echo fread($fp, 4096);
+			}
+
+			fclose($fp);
+		} else {
+			status_header ('404');
+		}
+
+		log_app('function',"get_file($postID)");
+		exit;
+	}
+
+	/**
+	 * Upload file to blog and add attachment to post.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function put_file($postID) {
+
+		// first check if user can upload
+		if ( !current_user_can('upload_files') )
+			$this->auth_required(__('You do not have permission to upload files.'));
+
+		// check for not found
+		global $entry;
+		$this->set_current_entry($postID);
+
+		// then whether user can edit the specific post
+		if ( !current_user_can('edit_post', $postID) )
+			$this->auth_required(__('Sorry, you do not have the right to edit this post.'));
+
+		$upload_dir = wp_upload_dir( );
+		$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
+		$filetype = wp_check_filetype($location);
+
+		$location = "{$upload_dir['basedir']}/{$location}";
+
+		if (!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
+			$this->internal_error(__('Error occurred while accessing post metadata for file location.'));
+
+		$fp = fopen("php://input", "rb");
+		$localfp = fopen($location, "w+");
+		while ( !feof($fp) ) {
+			fwrite($localfp,fread($fp, 4096));
+		}
+		fclose($fp);
+		fclose($localfp);
+
+		$ID = $entry['ID'];
+		$pubtimes = $this->get_publish_time($entry->published);
+		$post_date = $pubtimes[0];
+		$post_date_gmt = $pubtimes[1];
+		$pubtimes = $this->get_publish_time($parsed->updated);
+		$post_modified = $pubtimes[0];
+		$post_modified_gmt = $pubtimes[1];
+
+		$post_data = compact('ID', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt');
+		$result = wp_update_post($post_data);
+
+		if ( !$result )
+			$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
+
+		wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $location ) );
+
+		log_app('function',"put_file($postID)");
+		$this->ok();
+	}
+
+	/**
+	 * Retrieve entries URL.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $page Page ID.
+	 * @return string
+	 */
+	function get_entries_url($page = null) {
+		if ( isset($GLOBALS['post_type']) && ( $GLOBALS['post_type'] == 'attachment' ) )
+			$path = $this->MEDIA_PATH;
+		else
+			$path = $this->ENTRIES_PATH;
+		$url = $this->app_base . $path;
+		if ( isset($page) && is_int($page) )
+			$url .= "/$page";
+		return $url;
+	}
+
+	/**
+	 * Display entries URL.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $page Page ID.
+	 */
+	function the_entries_url($page = null) {
+		echo $this->get_entries_url($page);
+	}
+
+	/**
+	 * Retrieve categories URL.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param mixed $deprecated Not used.
+	 * @return string
+	 */
+	function get_categories_url($deprecated = '') {
+		if ( !empty( $deprecated ) )
+			_deprecated_argument( __FUNCTION__, '2.5' );
+		return $this->app_base . $this->CATEGORIES_PATH;
+	}
+
+	/**
+	 * Display category URL.
+	 *
+	 * @since 2.2.0
+	 */
+	function the_categories_url() {
+		echo $this->get_categories_url();
+	}
+
+	/**
+	 * Retrieve attachment URL.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $page Page ID.
+	 * @return string
+	 */
+	function get_attachments_url($page = null) {
+		$url = $this->app_base . $this->MEDIA_PATH;
+		if (isset($page) && is_int($page)) {
+			$url .= "/$page";
+		}
+		return $url;
+	}
+
+	/**
+	 * Display attachment URL.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $page Page ID.
+	 */
+	function the_attachments_url($page = null) {
+		echo $this->get_attachments_url($page);
+	}
+
+	/**
+	 * Retrieve service URL.
+	 *
+	 * @since 2.3.0
+	 *
+	 * @return string
+	 */
+	function get_service_url() {
+		return $this->app_base . $this->SERVICE_PATH;
+	}
+
+	/**
+	 * Retrieve entry URL.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param int $postID Post ID.
+	 * @return string
+	 */
+	function get_entry_url($postID = null) {
+		if (!isset($postID)) {
+			global $post;
+			$postID = (int) $post->ID;
+		}
+
+		$url = $this->app_base . $this->ENTRY_PATH . "/$postID";
+
+		log_app('function',"get_entry_url() = $url");
+		return $url;
+	}
+
+	/**
+	 * Display entry URL.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function the_entry_url($postID = null) {
+		echo $this->get_entry_url($postID);
+	}
+
+	/**
+	 * Retrieve media URL.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 * @return string
+	 */
+	function get_media_url($postID = null) {
+		if (!isset($postID)) {
+			global $post;
+			$postID = (int) $post->ID;
+		}
+
+		$url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID";
+
+		log_app('function',"get_media_url() = $url");
+		return $url;
+	}
+
+	/**
+	 * Display the media URL.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function the_media_url($postID = null) {
+		echo $this->get_media_url($postID);
+	}
+
+	/**
+	 * Set the current entry to post ID.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 */
+	function set_current_entry($postID) {
+		global $entry;
+		log_app('function',"set_current_entry($postID)");
+
+		if (!isset($postID)) {
+			// $this->bad_request();
+			$this->not_found();
+		}
+
+		$entry = wp_get_single_post($postID,ARRAY_A);
+
+		if (!isset($entry) || !isset($entry['ID']))
+			$this->not_found();
+
+		return;
+	}
+
+	/**
+	 * Display posts XML.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $page Optional. Page ID.
+	 * @param string $post_type Optional, default is 'post'. Post Type.
+	 */
+	function get_posts($page = 1, $post_type = 'post') {
+			log_app('function',"get_posts($page, '$post_type')");
+			$feed = $this->get_feed($page, $post_type);
+			$this->output($feed);
+	}
+
+	/**
+	 * Display attachment XML.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $page Page ID.
+	 * @param string $post_type Optional, default is 'attachment'. Post type.
+	 */
+	function get_attachments($page = 1, $post_type = 'attachment') {
+		log_app('function',"get_attachments($page, '$post_type')");
+		$GLOBALS['post_type'] = $post_type;
+		$feed = $this->get_feed($page, $post_type);
+		$this->output($feed);
+	}
+
+	/**
+	 * Retrieve feed XML.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $page Page ID.
+	 * @param string $post_type Optional, default is post. Post type.
+	 * @return string
+	 */
+	function get_feed($page = 1, $post_type = 'post') {
+		global $post, $wp, $wp_query, $posts, $wpdb, $blog_id;
+		log_app('function',"get_feed($page, '$post_type')");
+		ob_start();
+
+		$this->ENTRY_PATH = $post_type;
+
+		if (!isset($page)) {
+			$page = 1;
+		}
+		$page = (int) $page;
+
+		$count = get_option('posts_per_rss');
+
+		wp('posts_per_page=' . $count . '&offset=' . ($count * ($page-1) . '&orderby=modified'));
+
+		$post = $GLOBALS['post'];
+		$posts = $GLOBALS['posts'];
+		$wp = $GLOBALS['wp'];
+		$wp_query = $GLOBALS['wp_query'];
+		$wpdb = $GLOBALS['wpdb'];
+		$blog_id = (int) $GLOBALS['blog_id'];
+		log_app('function',"query_posts(# " . print_r($wp_query, true) . "#)");
+
+		log_app('function',"total_count(# $wp_query->max_num_pages #)");
+		$last_page = $wp_query->max_num_pages;
+		$next_page = (($page + 1) > $last_page) ? NULL : $page + 1;
+		$prev_page = ($page - 1) < 1 ? NULL : $page - 1;
+		$last_page = ((int)$last_page == 1 || (int)$last_page == 0) ? NULL : (int) $last_page;
+		$self_page = $page > 1 ? $page : NULL;
+?><feed xmlns="<?php echo $this->ATOM_NS ?>" xmlns:app="<?php echo $this->ATOMPUB_NS ?>" xml:lang="<?php echo get_option('rss_language'); ?>" <?php do_action('app_ns'); ?> >
+<id><?php $this->the_entries_url() ?></id>
+<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
+<title type="text"><?php bloginfo_rss('name') ?></title>
+<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
+<link rel="first" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url() ?>" />
+<?php if (isset($prev_page)): ?>
+<link rel="previous" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($prev_page) ?>" />
+<?php endif; ?>
+<?php if (isset($next_page)): ?>
+<link rel="next" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($next_page) ?>" />
+<?php endif; ?>
+<link rel="last" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($last_page) ?>" />
+<link rel="self" type="<?php echo $this->ATOM_CONTENT_TYPE ?>" href="<?php $this->the_entries_url($self_page) ?>" />
+<rights type="text">Copyright <?php echo date('Y'); ?></rights>
+<?php do_action('app_head'); ?>
+<?php if ( have_posts() ) {
+			while ( have_posts() ) {
+				the_post();
+				$this->echo_entry();
+			}
+		}
+?></feed>
+<?php
+		$feed = ob_get_contents();
+		ob_end_clean();
+		return $feed;
+	}
+
+	/**
+	 * Display entry XML.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param int $postID Post ID.
+	 * @param string $post_type Optional, default is post. Post type.
+	 * @return string.
+	 */
+	function get_entry($postID, $post_type = 'post') {
+		log_app('function',"get_entry($postID, '$post_type')");
+		ob_start();
+		switch($post_type) {
+			case 'post':
+				$varname = 'p';
+				break;
+			case 'attachment':
+				$this->ENTRY_PATH = 'attachment';
+				$varname = 'attachment_id';
+				break;
+		}
+		query_posts($varname . '=' . $postID);
+		if ( have_posts() ) {
+			while ( have_posts() ) {
+				the_post();
+				$this->echo_entry();
+				log_app('$post',print_r($GLOBALS['post'],true));
+				$entry = ob_get_contents();
+				break;
+			}
+		}
+		ob_end_clean();
+
+		log_app('get_entry returning:',$entry);
+		return $entry;
+	}
+
+	/**
+	 * Display post content XML.
+	 *
+	 * @since 2.3.0
+	 */
+	function echo_entry() { ?>
+<entry xmlns="<?php echo $this->ATOM_NS ?>"
+       xmlns:app="<?php echo $this->ATOMPUB_NS ?>" xml:lang="<?php echo get_option('rss_language'); ?>">
+	<id><?php the_guid( $GLOBALS['post']->ID ); ?></id>
+<?php list($content_type, $content) = prep_atom_text_construct(get_the_title()); ?>
+	<title type="<?php echo $content_type ?>"><?php echo $content ?></title>
+	<updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated>
+	<published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
+	<app:edited><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></app:edited>
+	<app:control>
+		<app:draft><?php echo ($GLOBALS['post']->post_status == 'draft' ? 'yes' : 'no') ?></app:draft>
+	</app:control>
+	<author>
+		<name><?php the_author()?></name>
+<?php if ( get_the_author_meta('url') && get_the_author_meta('url') != 'http://' ) { ?>
+		<uri><?php the_author_meta('url') ?></uri>
+<?php } ?>
+	</author>
+<?php if ($GLOBALS['post']->post_type == 'attachment') { ?>
+	<link rel="edit-media" href="<?php $this->the_media_url() ?>" />
+	<content type="<?php echo $GLOBALS['post']->post_mime_type ?>" src="<?php the_guid() ; ?>"/>
+<?php } else { ?>
+	<link href="<?php the_permalink_rss() ?>" />
+<?php if ( strlen( $GLOBALS['post']->post_content ) ) :
+list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?>
+	<content type="<?php echo $content_type ?>"><?php echo $content ?></content>
+<?php endif; ?>
+<?php } ?>
+	<link rel="edit" href="<?php $this->the_entry_url() ?>" />
+	<?php the_category_rss( 'atom' ); ?>
+<?php list($content_type, $content) = prep_atom_text_construct(get_the_excerpt()); ?>
+	<summary type="<?php echo $content_type ?>"><?php echo $content ?></summary>
+	<?php do_action('app_entry'); ?>
+</entry>
+<?php }
+
+	/**
+	 * Set 'OK' (200) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function ok() {
+		log_app('Status','200: OK');
+		header('Content-Type: text/plain');
+		status_header('200');
+		exit;
+	}
+
+	/**
+	 * Set 'No Content' (204) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function no_content() {
+		log_app('Status','204: No Content');
+		header('Content-Type: text/plain');
+		status_header('204');
+		echo "Moved to Trash.";
+		exit;
+	}
+
+	/**
+	 * Display 'Internal Server Error' (500) status header.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param string $msg Optional. Status string.
+	 */
+	function internal_error($msg = 'Internal Server Error') {
+		log_app('Status','500: Server Error');
+		header('Content-Type: text/plain');
+		status_header('500');
+		echo $msg;
+		exit;
+	}
+
+	/**
+	 * Set 'Bad Request' (400) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function bad_request() {
+		log_app('Status','400: Bad Request');
+		header('Content-Type: text/plain');
+		status_header('400');
+		exit;
+	}
+
+	/**
+	 * Set 'Length Required' (411) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function length_required() {
+		log_app('Status','411: Length Required');
+		header("HTTP/1.1 411 Length Required");
+		header('Content-Type: text/plain');
+		status_header('411');
+		exit;
+	}
+
+	/**
+	 * Set 'Unsupported Media Type' (415) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function invalid_media() {
+		log_app('Status','415: Unsupported Media Type');
+		header("HTTP/1.1 415 Unsupported Media Type");
+		header('Content-Type: text/plain');
+		exit;
+	}
+
+	/**
+	 * Set 'Forbidden' (403) status header.
+	 *
+	 * @since 2.6.0
+	 */
+	function forbidden($reason='') {
+		log_app('Status','403: Forbidden');
+		header('Content-Type: text/plain');
+		status_header('403');
+		echo $reason;
+		exit;
+	}
+
+	/**
+	 * Set 'Not Found' (404) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function not_found() {
+		log_app('Status','404: Not Found');
+		header('Content-Type: text/plain');
+		status_header('404');
+		exit;
+	}
+
+	/**
+	 * Set 'Not Allowed' (405) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function not_allowed($allow) {
+		log_app('Status','405: Not Allowed');
+		header('Allow: ' . join(',', $allow));
+		status_header('405');
+		exit;
+	}
+
+	/**
+	 * Display Redirect (302) content and set status headers.
+	 *
+	 * @since 2.3.0
+	 */
+	function redirect($url) {
+
+		log_app('Status','302: Redirect');
+		$escaped_url = esc_attr($url);
+		$content = <<<EOD
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html>
+  <head>
+    <title>302 Found</title>
+  </head>
+<body>
+  <h1>Found</h1>
+  <p>The document has moved <a href="$escaped_url">here</a>.</p>
+  </body>
+</html>
+
+EOD;
+		header('HTTP/1.1 302 Moved');
+		header('Content-Type: text/html');
+		header('Location: ' . $url);
+		echo $content;
+		exit;
+
+	}
+
+	/**
+	 * Set 'Client Error' (400) status header.
+	 *
+	 * @since 2.2.0
+	 */
+	function client_error($msg = 'Client Error') {
+		log_app('Status','400: Client Error');
+		header('Content-Type: text/plain');
+		status_header('400');
+		exit;
+	}
+
+	/**
+	 * Set created status headers (201).
+	 *
+	 * Sets the 'content-type', 'content-location', and 'location'.
+	 *
+	 * @since 2.2.0
+	 */
+	function created($post_ID, $content, $post_type = 'post') {
+		log_app('created()::$post_ID',"$post_ID, $post_type");
+		$edit = $this->get_entry_url($post_ID);
+		switch($post_type) {
+			case 'post':
+				$ctloc = $this->get_entry_url($post_ID);
+				break;
+			case 'attachment':
+				$edit = $this->app_base . "attachments/$post_ID";
+				break;
+		}
+		header("Content-Type: $this->ATOM_CONTENT_TYPE");
+		if (isset($ctloc))
+			header('Content-Location: ' . $ctloc);
+		header('Location: ' . $edit);
+		status_header('201');
+		echo $content;
+		exit;
+	}
+
+	/**
+	 * Set 'Auth Required' (401) headers.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param string $msg Status header content and HTML content.
+	 */
+	function auth_required($msg) {
+		log_app('Status','401: Auth Required');
+		nocache_headers();
+		header('WWW-Authenticate: Basic realm="WordPress Atom Protocol"');
+		header("HTTP/1.1 401 $msg");
+		header('Status: 401 ' . $msg);
+		header('Content-Type: text/html');
+		$content = <<<EOD
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html>
+  <head>
+    <title>401 Unauthorized</title>
+  </head>
+<body>
+    <h1>401 Unauthorized</h1>
+    <p>$msg</p>
+  </body>
+</html>
+
+EOD;
+		echo $content;
+		exit;
+	}
+
+	/**
+	 * Display XML and set headers with content type.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param string $xml Display feed content.
+	 * @param string $ctype Optional, default is 'atom+xml'. Feed content type.
+	 */
+	function output($xml, $ctype = 'application/atom+xml') {
+			status_header('200');
+			$xml = '<?xml version="1.0" encoding="' . strtolower(get_option('blog_charset')) . '"?>'."\n".$xml;
+			header('Connection: close');
+			header('Content-Length: '. strlen($xml));
+			header('Content-Type: ' . $ctype);
+			header('Content-Disposition: attachment; filename=atom.xml');
+			header('Date: '. date('r'));
+			if ($this->do_output)
+				echo $xml;
+			log_app('function', "output:\n$xml");
+			exit;
+	}
+
+	/**
+	 * Sanitize content for database usage.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $array Sanitize array and multi-dimension array.
+	 */
+	function escape(&$array) {
+		global $wpdb;
+
+		foreach ($array as $k => $v) {
+				if (is_array($v)) {
+						$this->escape($array[$k]);
+				} else if (is_object($v)) {
+						//skip
+				} else {
+						$array[$k] = $wpdb->escape($v);
+				}
+		}
+	}
+
+	/**
+	 * Access credential through various methods and perform login.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @return bool
+	 */
+	function authenticate() {
+		log_app("authenticate()",print_r($_ENV, true));
+
+		// if using mod_rewrite/ENV hack
+		// http://www.besthostratings.com/articles/http-auth-php-cgi.html
+		if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
+			list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
+				explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
+		} else if (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
+			// Workaround for setups that do not forward HTTP_AUTHORIZATION
+			// See http://trac.wordpress.org/ticket/7361
+			list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
+				explode(':', base64_decode(substr($_SERVER['REDIRECT_REMOTE_USER'], 6)));
+		}
+
+		// If Basic Auth is working...
+		if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
+			log_app("Basic Auth",$_SERVER['PHP_AUTH_USER']);
+
+			$user = wp_authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
+			if ( $user && !is_wp_error($user) ) {
+				wp_set_current_user($user->ID);
+				log_app("authenticate()", $user->user_login);
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * Retrieve accepted content types.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $types Optional. Content Types.
+	 * @return string
+	 */
+	function get_accepted_content_type($types = null) {
+
+		if (!isset($types)) {
+			$types = $this->media_content_types;
+		}
+
+		if (!isset($_SERVER['CONTENT_LENGTH']) || !isset($_SERVER['CONTENT_TYPE'])) {
+			$this->length_required();
+		}
+
+		$type = $_SERVER['CONTENT_TYPE'];
+		list($type,$subtype) = explode('/',$type);
+		list($subtype) = explode(";",$subtype); // strip MIME parameters
+		log_app("get_accepted_content_type", "type=$type, subtype=$subtype");
+
+		foreach($types as $t) {
+			list($acceptedType,$acceptedSubtype) = explode('/',$t);
+			if ($acceptedType == '*' || $acceptedType == $type) {
+				if ($acceptedSubtype == '*' || $acceptedSubtype == $subtype)
+					return $type . "/" . $subtype;
+			}
+		}
+
+		$this->invalid_media();
+	}
+
+	/**
+	 * Process conditionals for posts.
+	 *
+	 * @since 2.2.0
+	 */
+	function process_conditionals() {
+
+		if (empty($this->params)) return;
+		if ($_SERVER['REQUEST_METHOD'] == 'DELETE') return;
+
+		switch($this->params[0]) {
+			case $this->ENTRY_PATH:
+				global $post;
+				$post = wp_get_single_post($this->params[1]);
+				$wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true);
+				$post = NULL;
+				break;
+			case $this->ENTRIES_PATH:
+				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
+				break;
+			default:
+				return;
+		}
+		$wp_etag = md5($wp_last_modified);
+		@header("Last-Modified: $wp_last_modified");
+		@header("ETag: $wp_etag");
+
+		// Support for Conditional GET
+		if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
+			$client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
+		else
+			$client_etag = false;
+
+		$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']);
+		// If string is empty, return 0. If not, attempt to parse into a timestamp
+		$client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
+
+		// Make a timestamp for our most recent modification...
+		$wp_modified_timestamp = strtotime($wp_last_modified);
+
+		if ( ($client_last_modified && $client_etag) ?
+		(($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
+		(($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
+			status_header( 304 );
+			exit;
+		}
+	}
+
+	/**
+	 * Convert RFC3339 time string to timestamp.
+	 *
+	 * @since 2.3.0
+	 *
+	 * @param string $str String to time.
+	 * @return bool|int false if format is incorrect.
+	 */
+	function rfc3339_str2time($str) {
+
+		$match = false;
+		if (!preg_match("/(\d{4}-\d{2}-\d{2})T(\d{2}\:\d{2}\:\d{2})\.?\d{0,3}(Z|[+-]+\d{2}\:\d{2})/", $str, $match))
+			return false;
+
+		if ($match[3] == 'Z')
+			$match[3] = '+0000';
+
+		return strtotime($match[1] . " " . $match[2] . " " . $match[3]);
+	}
+
+	/**
+	 * Retrieve published time to display in XML.
+	 *
+	 * @since 2.3.0
+	 *
+	 * @param string $published Time string.
+	 * @return string
+	 */
+	function get_publish_time($published) {
+
+		$pubtime = $this->rfc3339_str2time($published);
+
+		if (!$pubtime) {
+			return array(current_time('mysql'),current_time('mysql',1));
+		} else {
+			return array(date("Y-m-d H:i:s", $pubtime), gmdate("Y-m-d H:i:s", $pubtime));
+		}
+	}
+
+}
+
+/**
+ * AtomServer
+ * @var AtomServer
+ * @global object $server
+ */
+$server = new AtomServer();
+$server->handle_request();
+
+?>
Index: /tags/3.1/wp-atom.php
===================================================================
--- /tags/3.1/wp-atom.php	(revision 17487)
+++ /tags/3.1/wp-atom.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Redirects to the Atom feed
+ * This file is deprecated and only exists for backwards compatibility
+ *
+ * @package WordPress
+ */
+
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'atom_url' ), 301 );
+exit;
+?>
Index: /tags/3.1/wp-blog-header.php
===================================================================
--- /tags/3.1/wp-blog-header.php	(revision 17487)
+++ /tags/3.1/wp-blog-header.php	(revision 17487)
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Loads the WordPress environment and template.
+ *
+ * @package WordPress
+ */
+
+if ( !isset($wp_did_header) ) {
+
+	$wp_did_header = true;
+
+	require_once( dirname(__FILE__) . '/wp-load.php' );
+
+	wp();
+
+	require_once( ABSPATH . WPINC . '/template-loader.php' );
+
+}
+
+?>
Index: /tags/3.1/wp-comments-post.php
===================================================================
--- /tags/3.1/wp-comments-post.php	(revision 17487)
+++ /tags/3.1/wp-comments-post.php	(revision 17487)
@@ -0,0 +1,105 @@
+<?php
+/**
+ * Handles Comment Post to WordPress and prevents duplicate comment posting.
+ *
+ * @package WordPress
+ */
+
+if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
+	header('Allow: POST');
+	header('HTTP/1.1 405 Method Not Allowed');
+	header('Content-Type: text/plain');
+	exit;
+}
+
+/** Sets up the WordPress Environment. */
+require( dirname(__FILE__) . '/wp-load.php' );
+
+nocache_headers();
+
+$comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
+
+$post = get_post($comment_post_ID);
+
+if ( empty($post->comment_status) ) {
+	do_action('comment_id_not_found', $comment_post_ID);
+	exit;
+}
+
+// get_post_status() will get the parent status for attachments.
+$status = get_post_status($post);
+
+$status_obj = get_post_status_object($status);
+
+if ( !comments_open($comment_post_ID) ) {
+	do_action('comment_closed', $comment_post_ID);
+	wp_die( __('Sorry, comments are closed for this item.') );
+} elseif ( 'trash' == $status ) {
+	do_action('comment_on_trash', $comment_post_ID);
+	exit;
+} elseif ( !$status_obj->public && !$status_obj->private ) {
+	do_action('comment_on_draft', $comment_post_ID);
+	exit;
+} elseif ( post_password_required($comment_post_ID) ) {
+	do_action('comment_on_password_protected', $comment_post_ID);
+	exit;
+} else {
+	do_action('pre_comment_on_post', $comment_post_ID);
+}
+
+$comment_author       = ( isset($_POST['author']) )  ? trim(strip_tags($_POST['author'])) : null;
+$comment_author_email = ( isset($_POST['email']) )   ? trim($_POST['email']) : null;
+$comment_author_url   = ( isset($_POST['url']) )     ? trim($_POST['url']) : null;
+$comment_content      = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
+
+// If the user is logged in
+$user = wp_get_current_user();
+if ( $user->ID ) {
+	if ( empty( $user->display_name ) )
+		$user->display_name=$user->user_login;
+	$comment_author       = $wpdb->escape($user->display_name);
+	$comment_author_email = $wpdb->escape($user->user_email);
+	$comment_author_url   = $wpdb->escape($user->user_url);
+	if ( current_user_can('unfiltered_html') ) {
+		if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) {
+			kses_remove_filters(); // start with a clean slate
+			kses_init_filters(); // set up the filters
+		}
+	}
+} else {
+	if ( get_option('comment_registration') || 'private' == $status )
+		wp_die( __('Sorry, you must be logged in to post a comment.') );
+}
+
+$comment_type = '';
+
+if ( get_option('require_name_email') && !$user->ID ) {
+	if ( 6 > strlen($comment_author_email) || '' == $comment_author )
+		wp_die( __('Error: please fill the required fields (name, email).') );
+	elseif ( !is_email($comment_author_email))
+		wp_die( __('Error: please enter a valid email address.') );
+}
+
+if ( '' == $comment_content )
+	wp_die( __('Error: please type a comment.') );
+
+$comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
+
+$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
+
+$comment_id = wp_new_comment( $commentdata );
+
+$comment = get_comment($comment_id);
+if ( !$user->ID ) {
+	$comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000);
+	setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
+	setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
+	setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
+}
+
+$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
+$location = apply_filters('comment_post_redirect', $location, $comment);
+
+wp_redirect($location);
+exit;
+?>
Index: /tags/3.1/wp-commentsrss2.php
===================================================================
--- /tags/3.1/wp-commentsrss2.php	(revision 17487)
+++ /tags/3.1/wp-commentsrss2.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Redirects to the Comments RSS2 feed
+ * This file is deprecated and only exists for backwards compatibility
+ *
+ * @package WordPress
+ */
+
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'comments_rss2_url' ), 301 );
+exit;
+?>
Index: /tags/3.1/wp-config-sample.php
===================================================================
--- /tags/3.1/wp-config-sample.php	(revision 17487)
+++ /tags/3.1/wp-config-sample.php	(revision 17487)
@@ -0,0 +1,90 @@
+<?php
+/**
+ * The base configurations of the WordPress.
+ *
+ * This file has the following configurations: MySQL settings, Table Prefix,
+ * Secret Keys, WordPress Language, and ABSPATH. You can find more information
+ * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
+ * wp-config.php} Codex page. You can get the MySQL settings from your web host.
+ *
+ * This file is used by the wp-config.php creation script during the
+ * installation. You don't have to use the web site, you can just copy this file
+ * to "wp-config.php" and fill in the values.
+ *
+ * @package WordPress
+ */
+
+// ** MySQL settings - You can get this info from your web host ** //
+/** The name of the database for WordPress */
+define('DB_NAME', 'database_name_here');
+
+/** MySQL database username */
+define('DB_USER', 'username_here');
+
+/** MySQL database password */
+define('DB_PASSWORD', 'password_here');
+
+/** MySQL hostname */
+define('DB_HOST', 'localhost');
+
+/** Database Charset to use in creating database tables. */
+define('DB_CHARSET', 'utf8');
+
+/** The Database Collate type. Don't change this if in doubt. */
+define('DB_COLLATE', '');
+
+/**#@+
+ * Authentication Unique Keys and Salts.
+ *
+ * Change these to different unique phrases!
+ * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
+ * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
+ *
+ * @since 2.6.0
+ */
+define('AUTH_KEY',         'put your unique phrase here');
+define('SECURE_AUTH_KEY',  'put your unique phrase here');
+define('LOGGED_IN_KEY',    'put your unique phrase here');
+define('NONCE_KEY',        'put your unique phrase here');
+define('AUTH_SALT',        'put your unique phrase here');
+define('SECURE_AUTH_SALT', 'put your unique phrase here');
+define('LOGGED_IN_SALT',   'put your unique phrase here');
+define('NONCE_SALT',       'put your unique phrase here');
+
+/**#@-*/
+
+/**
+ * WordPress Database Table prefix.
+ *
+ * You can have multiple installations in one database if you give each a unique
+ * prefix. Only numbers, letters, and underscores please!
+ */
+$table_prefix  = 'wp_';
+
+/**
+ * WordPress Localized Language, defaults to English.
+ *
+ * Change this to localize WordPress. A corresponding MO file for the chosen
+ * language must be installed to wp-content/languages. For example, install
+ * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
+ * language support.
+ */
+define('WPLANG', '');
+
+/**
+ * For developers: WordPress debugging mode.
+ *
+ * Change this to true to enable the display of notices during development.
+ * It is strongly recommended that plugin and theme developers use WP_DEBUG
+ * in their development environments.
+ */
+define('WP_DEBUG', false);
+
+/* That's all, stop editing! Happy blogging. */
+
+/** Absolute path to the WordPress directory. */
+if ( !defined('ABSPATH') )
+	define('ABSPATH', dirname(__FILE__) . '/');
+
+/** Sets up WordPress vars and included files. */
+require_once(ABSPATH . 'wp-settings.php');
Index: /tags/3.1/wp-content/index.php
===================================================================
--- /tags/3.1/wp-content/index.php	(revision 17487)
+++ /tags/3.1/wp-content/index.php	(revision 17487)
@@ -0,0 +1,3 @@
+<?php
+// Silence is golden.
+?>
Index: /tags/3.1/wp-content/plugins/hello.php
===================================================================
--- /tags/3.1/wp-content/plugins/hello.php	(revision 17487)
+++ /tags/3.1/wp-content/plugins/hello.php	(revision 17487)
@@ -0,0 +1,82 @@
+<?php
+/**
+ * @package Hello_Dolly
+ * @version 1.6
+ */
+/*
+Plugin Name: Hello Dolly
+Plugin URI: http://wordpress.org/extend/plugins/hello-dolly/
+Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
+Author: Matt Mullenweg
+Version: 1.6
+Author URI: http://ma.tt/
+*/
+
+function hello_dolly_get_lyric() {
+	/** These are the lyrics to Hello Dolly */
+	$lyrics = "Hello, Dolly
+Well, hello, Dolly
+It's so nice to have you back where you belong
+You're lookin' swell, Dolly
+I can tell, Dolly
+You're still glowin', you're still crowin'
+You're still goin' strong
+We feel the room swayin'
+While the band's playin'
+One of your old favourite songs from way back when
+So, take her wrap, fellas
+Find her an empty lap, fellas
+Dolly'll never go away again
+Hello, Dolly
+Well, hello, Dolly
+It's so nice to have you back where you belong
+You're lookin' swell, Dolly
+I can tell, Dolly
+You're still glowin', you're still crowin'
+You're still goin' strong
+We feel the room swayin'
+While the band's playin'
+One of your old favourite songs from way back when
+Golly, gee, fellas
+Find her a vacant knee, fellas
+Dolly'll never go away
+Dolly'll never go away
+Dolly'll never go away again";
+
+	// Here we split it into lines
+	$lyrics = explode( "\n", $lyrics );
+
+	// And then randomly choose a line
+	return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
+}
+
+// This just echoes the chosen line, we'll position it later
+function hello_dolly() {
+	$chosen = hello_dolly_get_lyric();
+	echo "<p id='dolly'>$chosen</p>";
+}
+
+// Now we set that function up to execute when the admin_notices action is called
+add_action( 'admin_notices', 'hello_dolly' );
+
+// We need some CSS to position the paragraph
+function dolly_css() {
+	// This makes sure that the positioning is also good for right-to-left languages
+	$x = is_rtl() ? 'left' : 'right';
+
+	echo "
+	<style type='text/css'>
+	#dolly {
+		float: $x;
+		padding-$x: 15px;
+		padding-top: 5px;		
+		margin: 0;
+		font-size: 11px;
+	}
+	</style>
+	";
+}
+
+add_action( 'admin_head', 'dolly_css' );
+
+?>
Index: /tags/3.1/wp-content/plugins/index.php
===================================================================
--- /tags/3.1/wp-content/plugins/index.php	(revision 17487)
+++ /tags/3.1/wp-content/plugins/index.php	(revision 17487)
@@ -0,0 +1,3 @@
+<?php
+// Silence is golden.
+?>
Index: /tags/3.1/wp-content/themes/index.php
===================================================================
--- /tags/3.1/wp-content/themes/index.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/index.php	(revision 17487)
@@ -0,0 +1,3 @@
+<?php
+// Silence is golden.
+?>
Index: /tags/3.1/wp-content/themes/twentyten/404.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/404.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/404.php	(revision 17487)
@@ -0,0 +1,30 @@
+<?php
+/**
+ * The template for displaying 404 pages (Not Found).
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+	<div id="container">
+		<div id="content" role="main">
+
+			<div id="post-0" class="post error404 not-found">
+				<h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
+				<div class="entry-content">
+					<p><?php _e( 'Apologies, but the page you requested could not be found. Perhaps searching will help.', 'twentyten' ); ?></p>
+					<?php get_search_form(); ?>
+				</div><!-- .entry-content -->
+			</div><!-- #post-0 -->
+
+		</div><!-- #content -->
+	</div><!-- #container -->
+	<script type="text/javascript">
+		// focus on search field after it has loaded
+		document.getElementById('s') && document.getElementById('s').focus();
+	</script>
+
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/archive.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/archive.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/archive.php	(revision 17487)
@@ -0,0 +1,61 @@
+<?php
+/**
+ * The template for displaying Archive pages.
+ *
+ * Used to display archive-type pages if nothing more specific matches a query.
+ * For example, puts together date-based pages if no date.php file exists.
+ *
+ * Learn more: http://codex.wordpress.org/Template_Hierarchy
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+<?php
+	/* Queue the first post, that way we know
+	 * what date we're dealing with (if that is the case).
+	 *
+	 * We reset this later so we can run the loop
+	 * properly with a call to rewind_posts().
+	 */
+	if ( have_posts() )
+		the_post();
+?>
+
+			<h1 class="page-title">
+<?php if ( is_day() ) : ?>
+				<?php printf( __( 'Daily Archives: <span>%s</span>', 'twentyten' ), get_the_date() ); ?>
+<?php elseif ( is_month() ) : ?>
+				<?php printf( __( 'Monthly Archives: <span>%s</span>', 'twentyten' ), get_the_date( 'F Y' ) ); ?>
+<?php elseif ( is_year() ) : ?>
+				<?php printf( __( 'Yearly Archives: <span>%s</span>', 'twentyten' ), get_the_date( 'Y' ) ); ?>
+<?php else : ?>
+				<?php _e( 'Blog Archives', 'twentyten' ); ?>
+<?php endif; ?>
+			</h1>
+
+<?php
+	/* Since we called the_post() above, we need to
+	 * rewind the loop back to the beginning that way
+	 * we can run the loop properly, in full.
+	 */
+	rewind_posts();
+
+	/* Run the loop for the archives page to output the posts.
+	 * If you want to overload this in a child theme then include a file
+	 * called loop-archive.php and that will be used instead.
+	 */
+	 get_template_part( 'loop', 'archive' );
+?>
+
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/attachment.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/attachment.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/attachment.php	(revision 17487)
@@ -0,0 +1,26 @@
+<?php
+/**
+ * The template for displaying attachments.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container" class="single-attachment">
+			<div id="content" role="main">
+
+			<?php
+			/* Run the loop to output the attachment.
+			 * If you want to overload this in a child theme then include a file
+			 * called loop-attachment.php and that will be used instead.
+			 */
+			get_template_part( 'loop', 'attachment' );
+			?>
+
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/author.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/author.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/author.php	(revision 17487)
@@ -0,0 +1,60 @@
+<?php
+/**
+ * The template for displaying Author Archive pages.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+<?php
+	/* Queue the first post, that way we know who
+	 * the author is when we try to get their name,
+	 * URL, description, avatar, etc.
+	 *
+	 * We reset this later so we can run the loop
+	 * properly with a call to rewind_posts().
+	 */
+	if ( have_posts() )
+		the_post();
+?>
+
+				<h1 class="page-title author"><?php printf( __( 'Author Archives: %s', 'twentyten' ), "<span class='vcard'><a class='url fn n' href='" . get_author_posts_url( get_the_author_meta( 'ID' ) ) . "' title='" . esc_attr( get_the_author() ) . "' rel='me'>" . get_the_author() . "</a></span>" ); ?></h1>
+
+<?php
+// If a user has filled out their description, show a bio on their entries.
+if ( get_the_author_meta( 'description' ) ) : ?>
+					<div id="entry-author-info">
+						<div id="author-avatar">
+							<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyten_author_bio_avatar_size', 60 ) ); ?>
+						</div><!-- #author-avatar -->
+						<div id="author-description">
+							<h2><?php printf( __( 'About %s', 'twentyten' ), get_the_author() ); ?></h2>
+							<?php the_author_meta( 'description' ); ?>
+						</div><!-- #author-description	-->
+					</div><!-- #entry-author-info -->
+<?php endif; ?>
+
+<?php
+	/* Since we called the_post() above, we need to
+	 * rewind the loop back to the beginning that way
+	 * we can run the loop properly, in full.
+	 */
+	rewind_posts();
+
+	/* Run the loop for the author archive page to output the authors posts
+	 * If you want to overload this in a child theme then include a file
+	 * called loop-author.php and that will be used instead.
+	 */
+	 get_template_part( 'loop', 'author' );
+?>
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/category.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/category.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/category.php	(revision 17487)
@@ -0,0 +1,34 @@
+<?php
+/**
+ * The template for displaying Category Archive pages.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+				<h1 class="page-title"><?php
+					printf( __( 'Category Archives: %s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' );
+				?></h1>
+				<?php
+					$category_description = category_description();
+					if ( ! empty( $category_description ) )
+						echo '<div class="archive-meta">' . $category_description . '</div>';
+
+				/* Run the loop for the category page to output the posts.
+				 * If you want to overload this in a child theme then include a file
+				 * called loop-category.php and that will be used instead.
+				 */
+				get_template_part( 'loop', 'category' );
+				?>
+
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/comments.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/comments.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/comments.php	(revision 17487)
@@ -0,0 +1,79 @@
+<?php
+/**
+ * The template for displaying Comments.
+ *
+ * The area of the page that contains both current comments
+ * and the comment form.  The actual display of comments is
+ * handled by a callback to twentyten_comment which is
+ * located in the functions.php file.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+?>
+
+			<div id="comments">
+<?php if ( post_password_required() ) : ?>
+				<p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'twentyten' ); ?></p>
+			</div><!-- #comments -->
+<?php
+		/* Stop the rest of comments.php from being processed,
+		 * but don't kill the script entirely -- we still have
+		 * to fully load the template.
+		 */
+		return;
+	endif;
+?>
+
+<?php
+	// You can start editing here -- including this comment!
+?>
+
+<?php if ( have_comments() ) : ?>
+			<h3 id="comments-title"><?php
+			printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentyten' ),
+			number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' );
+			?></h3>
+
+<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
+			<div class="navigation">
+				<div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'twentyten' ) ); ?></div>
+				<div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
+			</div> <!-- .navigation -->
+<?php endif; // check for comment navigation ?>
+
+			<ol class="commentlist">
+				<?php
+					/* Loop through and list the comments. Tell wp_list_comments()
+					 * to use twentyten_comment() to format the comments.
+					 * If you want to overload this in a child theme then you can
+					 * define twentyten_comment() and that will be used instead.
+					 * See twentyten_comment() in twentyten/functions.php for more.
+					 */
+					wp_list_comments( array( 'callback' => 'twentyten_comment' ) );
+				?>
+			</ol>
+
+<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
+			<div class="navigation">
+				<div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Older Comments', 'twentyten' ) ); ?></div>
+				<div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
+			</div><!-- .navigation -->
+<?php endif; // check for comment navigation ?>
+
+<?php else : // or, if we don't have comments:
+
+	/* If there are no comments and comments are closed,
+	 * let's leave a little note, shall we?
+	 */
+	if ( ! comments_open() ) :
+?>
+	<p class="nocomments"><?php _e( 'Comments are closed.', 'twentyten' ); ?></p>
+<?php endif; // end ! comments_open() ?>
+
+<?php endif; // end have_comments() ?>
+
+<?php comment_form(); ?>
+
+</div><!-- #comments -->
Index: /tags/3.1/wp-content/themes/twentyten/editor-style-rtl.css
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/editor-style-rtl.css	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/editor-style-rtl.css	(revision 17487)
@@ -0,0 +1,56 @@
+/*
+Theme Name: Twenty Ten
+*/
+/*
+Used to style the TinyMCE editor.
+*/
+html .mceContentBody{
+	direction:rtl;
+	unicode-bidi:embed;
+	float:right;
+}
+* {
+	font-family: Arial, Tahoma, sans-serif;
+}
+/* Text elements */
+ul {
+	margin: 0 -18px 18px 0;
+}
+ol {
+	margin: 0 -18px 18px 0;
+}
+dd {
+	margin-right: 0;
+}
+blockquote {
+	font-style: normal;
+}
+table {
+	text-align: right;
+	margin: 0 0 24px -1px;
+}
+html .mceContentBody{
+	direction:rtl;
+	unicode-bidi:embed;
+	float:right;
+}
+* {
+	font-family: Arial, Tahoma, sans-serif;
+}
+/* Text elements */
+ul {
+	margin: 0 -18px 18px 0;
+}
+ol {
+	margin: 0 -18px 18px 0;
+}
+dd {
+	margin-right: 0;
+}
+blockquote {
+	font-style: normal;
+}
+table {
+	text-align: right;
+	margin: 0 0 24px -1px;
+}
Index: /tags/3.1/wp-content/themes/twentyten/editor-style.css
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/editor-style.css	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/editor-style.css	(revision 17487)
@@ -0,0 +1,292 @@
+/*
+Theme Name: Twenty Ten
+Description: Used to style the TinyMCE editor.
+*/
+html .mceContentBody {
+	max-width: 640px;
+}
+* {
+	color: #444;
+	font-family: Georgia, "Bitstream Charter", serif;
+	line-height: 1.5;
+}
+p,
+dl,
+td,
+th,
+ul,
+ol,
+blockquote {
+	font-size: 16px;
+}
+tr th,
+thead th,
+label,
+tr th,
+thead th {
+	font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
+}
+pre {
+	font-family: "Courier 10 Pitch", Courier, monospace;
+}
+code, code var {
+	font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
+}
+body, input, textarea {
+	font-size: 12px;
+	line-height: 18px;
+}
+hr {
+	background-color: #e7e7e7;
+	border: 0;
+	clear: both;
+	height: 1px;
+	margin-bottom: 18px;
+}
+/* Text elements */
+p {
+	margin-bottom: 18px;
+}
+ul {
+	list-style: square;
+	margin: 0 0 18px 1.5em;
+}
+ol {
+	list-style: decimal;
+	margin: 0 0 18px 1.5em;
+}
+ol ol {
+	list-style: upper-alpha;
+}
+ol ol ol {
+	list-style: lower-roman;
+}
+ol ol ol ol {
+	list-style: lower-alpha;
+}
+ul ul,
+ol ol,
+ul ol,
+ol ul {
+	margin-bottom: 0;
+}
+dl {
+	margin: 0 0 24px 0;
+}
+dt {
+	font-weight: bold;
+}
+dd {
+	margin-bottom: 18px;
+}
+strong {
+	color: #000;
+	font-weight: bold;
+}
+cite,
+em,
+i {
+	border: none;
+	font-style: italic;
+}
+big {
+	font-size: 131.25%;
+}
+ins {
+	background: #ffc;
+	border: none;
+	color: #333;
+}
+del {
+	text-decoration: line-through;
+	color: #555;
+}
+blockquote {
+	font-style: italic;
+	padding: 0 3em;
+}
+blockquote cite,
+blockquote em,
+blockquote i {
+	font-style: normal;
+}
+pre {
+	background: #f7f7f7;
+	color: #222;
+	line-height: 18px;
+	margin-bottom: 18px;
+	padding: 1.5em;
+}
+abbr,
+acronym {
+	border-bottom: 1px dotted #666;
+	cursor: help;
+}
+ins {
+	text-decoration: none;
+}
+sup,
+sub {
+	font-size: 10px;
+	height: 0;
+	line-height: 1;
+	position: relative;
+	vertical-align: baseline;
+}
+sup {
+	bottom: 1ex;
+}
+sub {
+	top: .5ex;
+}
+a:link {
+	color: #06c;
+}
+a:visited {
+	color: #743399;
+}
+a:active,
+a:hover {
+	color: #ff4b33;
+}
+p,
+ul,
+ol,
+dd,
+pre,
+hr {
+	margin-bottom: 24px;
+}
+ul ul,
+ol ol,
+ul ol,
+ol ul {
+	margin-bottom: 0;
+}
+pre,
+kbd,
+tt,
+var {
+	font-size: 15px;
+	line-height: 21px;
+}
+code {
+	font-size: 13px;
+}
+strong,
+b,
+dt,
+th {
+	color: #000;
+}
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+	color: #000;
+	font-weight: normal;
+	line-height: 1.5em;
+	margin: 0 0 20px 0;
+}
+h1 {
+	font-size: 2.4em;
+}
+h2 {
+	font-size: 1.8em;
+}
+h3 {
+	font-size: 1.4em;
+}
+h4 {
+	font-size: 1.2em;
+}
+h5 {
+	font-size: 1em;
+}
+h6 {
+	font-size: 0.9em;
+}
+table {
+	border: 1px solid #e7e7e7 !important;
+	border-collapse: collapse;
+	border-spacing: 0;
+	margin: 0 -1px 24px 0;
+	text-align: left;
+	width: 100%;
+}
+tr th,
+thead th {
+	border: none !important;
+	color: #888;
+	font-size: 12px;
+	font-weight: bold;
+	line-height: 18px;
+	padding: 9px 24px;
+}
+tr td {
+	border: none !important;
+	border-top: 1px solid #e7e7e7 !important;
+	padding: 6px 24px;
+}
+img {
+	margin: 0;
+}
+img.size-auto,
+img.size-large,
+img.size-full,
+img.size-medium {
+	max-width: 100%;
+	height: auto;
+}
+.alignleft,
+img.alignleft {
+	display: inline;
+	float: left;
+	margin-right: 24px;
+	margin-top: 4px;
+}
+.alignright,
+img.alignright {
+	display: inline;
+	float: right;
+	margin-left: 24px;
+	margin-top: 4px;
+}
+.aligncenter,
+img.aligncenter {
+	clear: both;
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+}
+img.alignleft,
+img.alignright,
+img.aligncenter {
+	margin-bottom: 12px;
+}
+.wp-caption {
+	background: #f1f1f1;
+	border: none;
+	-khtml-border-radius: 0;
+	-moz-border-radius: 0;
+	-webkit-border-radius: 0;
+	border-radius: 0;
+	color: #888;
+	font-size: 12px;
+	line-height: 18px;
+	margin-bottom: 20px;
+	max-width: 632px !important; /* prevent too-wide images from breaking layout */
+	padding: 4px;
+	text-align: center;
+}
+.wp-caption img {
+	margin: 5px;
+}
+.wp-caption p.wp-caption-text {
+	margin: 0 0 4px;
+}
+.wp-smiley {
+	margin: 0;
+}
Index: /tags/3.1/wp-content/themes/twentyten/footer.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/footer.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/footer.php	(revision 17487)
@@ -0,0 +1,50 @@
+<?php
+/**
+ * The template for displaying the footer.
+ *
+ * Contains the closing of the id=main div and all content
+ * after.  Calls sidebar-footer.php for bottom widgets.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+?>
+	</div><!-- #main -->
+
+	<div id="footer" role="contentinfo">
+		<div id="colophon">
+
+<?php
+	/* A sidebar in the footer? Yep. You can can customize
+	 * your footer with four columns of widgets.
+	 */
+	get_sidebar( 'footer' );
+?>
+
+			<div id="site-info">
+				<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
+					<?php bloginfo( 'name' ); ?>
+				</a>
+			</div><!-- #site-info -->
+
+			<div id="site-generator">
+				<?php do_action( 'twentyten_credits' ); ?>
+				<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyten' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentyten' ); ?>" rel="generator"><?php printf( __( 'Proudly powered by %s.', 'twentyten' ), 'WordPress' ); ?></a>
+			</div><!-- #site-generator -->
+
+		</div><!-- #colophon -->
+	</div><!-- #footer -->
+
+</div><!-- #wrapper -->
+
+<?php
+	/* Always have wp_footer() just before the closing </body>
+	 * tag of your theme, or you will break many plugins, which
+	 * generally use this hook to reference JavaScript files.
+	 */
+
+	wp_footer();
+?>
+</body>
+</html>
Index: /tags/3.1/wp-content/themes/twentyten/functions.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/functions.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/functions.php	(revision 17487)
@@ -0,0 +1,508 @@
+<?php
+/**
+ * TwentyTen functions and definitions
+ *
+ * Sets up the theme and provides some helper functions. Some helper functions
+ * are used in the theme as custom template tags. Others are attached to action and
+ * filter hooks in WordPress to change core functionality.
+ *
+ * The first function, twentyten_setup(), sets up the theme by registering support
+ * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
+ *
+ * When using a child theme (see http://codex.wordpress.org/Theme_Development and
+ * http://codex.wordpress.org/Child_Themes), you can override certain functions
+ * (those wrapped in a function_exists() call) by defining them first in your child theme's
+ * functions.php file. The child theme's functions.php file is included before the parent
+ * theme's file, so the child theme functions would be used.
+ *
+ * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
+ * to a filter or action hook. The hook can be removed by using remove_action() or
+ * remove_filter() and you can attach your own function to the hook.
+ *
+ * We can remove the parent theme's hook only after it is attached, which means we need to
+ * wait until setting up the child theme:
+ *
+ * <code>
+ * add_action( 'after_setup_theme', 'my_child_theme_setup' );
+ * function my_child_theme_setup() {
+ *     // We are providing our own filter for excerpt_length (or using the unfiltered value)
+ *     remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
+ *     ...
+ * }
+ * </code>
+ *
+ * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+/**
+ * Set the content width based on the theme's design and stylesheet.
+ *
+ * Used to set the width of images and content. Should be equal to the width the theme
+ * is designed for, generally via the style.css stylesheet.
+ */
+if ( ! isset( $content_width ) )
+	$content_width = 640;
+
+/** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
+add_action( 'after_setup_theme', 'twentyten_setup' );
+
+if ( ! function_exists( 'twentyten_setup' ) ):
+/**
+ * Sets up theme defaults and registers support for various WordPress features.
+ *
+ * Note that this function is hooked into the after_setup_theme hook, which runs
+ * before the init hook. The init hook is too late for some features, such as indicating
+ * support post thumbnails.
+ *
+ * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
+ * functions.php file.
+ *
+ * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
+ * @uses register_nav_menus() To add support for navigation menus.
+ * @uses add_custom_background() To add support for a custom background.
+ * @uses add_editor_style() To style the visual editor.
+ * @uses load_theme_textdomain() For translation/localization support.
+ * @uses add_custom_image_header() To add support for a custom header.
+ * @uses register_default_headers() To register the default custom header images provided with the theme.
+ * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
+ *
+ * @since Twenty Ten 1.0
+ */
+function twentyten_setup() {
+
+	// This theme styles the visual editor with editor-style.css to match the theme style.
+	add_editor_style();
+
+	// Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
+	add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
+
+	// This theme uses post thumbnails
+	add_theme_support( 'post-thumbnails' );
+
+	// Add default posts and comments RSS feed links to head
+	add_theme_support( 'automatic-feed-links' );
+
+	// Make theme available for translation
+	// Translations can be filed in the /languages/ directory
+	load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
+
+	$locale = get_locale();
+	$locale_file = TEMPLATEPATH . "/languages/$locale.php";
+	if ( is_readable( $locale_file ) )
+		require_once( $locale_file );
+
+	// This theme uses wp_nav_menu() in one location.
+	register_nav_menus( array(
+		'primary' => __( 'Primary Navigation', 'twentyten' ),
+	) );
+
+	// This theme allows users to set a custom background
+	add_custom_background();
+
+	// Your changeable header business starts here
+	if ( ! defined( 'HEADER_TEXTCOLOR' ) )
+		define( 'HEADER_TEXTCOLOR', '' );
+
+	// No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
+	if ( ! defined( 'HEADER_IMAGE' ) )
+		define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
+
+	// The height and width of your custom header. You can hook into the theme's own filters to change these values.
+	// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
+	define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
+	define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
+
+	// We'll be using post thumbnails for custom header images on posts and pages.
+	// We want them to be 940 pixels wide by 198 pixels tall.
+	// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
+	set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
+
+	// Don't support text inside the header image.
+	if ( ! defined( 'NO_HEADER_TEXT' ) )
+		define( 'NO_HEADER_TEXT', true );
+
+	// Add a way for the custom header to be styled in the admin panel that controls
+	// custom headers. See twentyten_admin_header_style(), below.
+	add_custom_image_header( '', 'twentyten_admin_header_style' );
+
+	// ... and thus ends the changeable header business.
+
+	// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
+	register_default_headers( array(
+		'berries' => array(
+			'url' => '%s/images/headers/berries.jpg',
+			'thumbnail_url' => '%s/images/headers/berries-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Berries', 'twentyten' )
+		),
+		'cherryblossom' => array(
+			'url' => '%s/images/headers/cherryblossoms.jpg',
+			'thumbnail_url' => '%s/images/headers/cherryblossoms-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Cherry Blossoms', 'twentyten' )
+		),
+		'concave' => array(
+			'url' => '%s/images/headers/concave.jpg',
+			'thumbnail_url' => '%s/images/headers/concave-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Concave', 'twentyten' )
+		),
+		'fern' => array(
+			'url' => '%s/images/headers/fern.jpg',
+			'thumbnail_url' => '%s/images/headers/fern-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Fern', 'twentyten' )
+		),
+		'forestfloor' => array(
+			'url' => '%s/images/headers/forestfloor.jpg',
+			'thumbnail_url' => '%s/images/headers/forestfloor-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Forest Floor', 'twentyten' )
+		),
+		'inkwell' => array(
+			'url' => '%s/images/headers/inkwell.jpg',
+			'thumbnail_url' => '%s/images/headers/inkwell-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Inkwell', 'twentyten' )
+		),
+		'path' => array(
+			'url' => '%s/images/headers/path.jpg',
+			'thumbnail_url' => '%s/images/headers/path-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Path', 'twentyten' )
+		),
+		'sunset' => array(
+			'url' => '%s/images/headers/sunset.jpg',
+			'thumbnail_url' => '%s/images/headers/sunset-thumbnail.jpg',
+			/* translators: header image description */
+			'description' => __( 'Sunset', 'twentyten' )
+		)
+	) );
+}
+endif;
+
+if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
+/**
+ * Styles the header image displayed on the Appearance > Header admin panel.
+ *
+ * Referenced via add_custom_image_header() in twentyten_setup().
+ *
+ * @since Twenty Ten 1.0
+ */
+function twentyten_admin_header_style() {
+?>
+<style type="text/css">
+/* Shows the same border as on front end */
+#headimg {
+	border-bottom: 1px solid #000;
+	border-top: 4px solid #000;
+}
+/* If NO_HEADER_TEXT is false, you would style the text with these selectors:
+	#headimg #name { }
+	#headimg #desc { }
+*/
+</style>
+<?php
+}
+endif;
+
+/**
+ * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
+ *
+ * To override this in a child theme, remove the filter and optionally add
+ * your own function tied to the wp_page_menu_args filter hook.
+ *
+ * @since Twenty Ten 1.0
+ */
+function twentyten_page_menu_args( $args ) {
+	$args['show_home'] = true;
+	return $args;
+}
+add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
+
+/**
+ * Sets the post excerpt length to 40 characters.
+ *
+ * To override this length in a child theme, remove the filter and add your own
+ * function tied to the excerpt_length filter hook.
+ *
+ * @since Twenty Ten 1.0
+ * @return int
+ */
+function twentyten_excerpt_length( $length ) {
+	return 40;
+}
+add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
+
+/**
+ * Returns a "Continue Reading" link for excerpts
+ *
+ * @since Twenty Ten 1.0
+ * @return string "Continue Reading" link
+ */
+function twentyten_continue_reading_link() {
+	return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
+}
+
+/**
+ * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
+ *
+ * To override this in a child theme, remove the filter and add your own
+ * function tied to the excerpt_more filter hook.
+ *
+ * @since Twenty Ten 1.0
+ * @return string An ellipsis
+ */
+function twentyten_auto_excerpt_more( $more ) {
+	return ' &hellip;' . twentyten_continue_reading_link();
+}
+add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
+
+/**
+ * Adds a pretty "Continue Reading" link to custom post excerpts.
+ *
+ * To override this link in a child theme, remove the filter and add your own
+ * function tied to the get_the_excerpt filter hook.
+ *
+ * @since Twenty Ten 1.0
+ * @return string Excerpt with a pretty "Continue Reading" link
+ */
+function twentyten_custom_excerpt_more( $output ) {
+	if ( has_excerpt() && ! is_attachment() ) {
+		$output .= twentyten_continue_reading_link();
+	}
+	return $output;
+}
+add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
+
+/**
+ * Remove inline styles printed when the gallery shortcode is used.
+ *
+ * Galleries are styled by the theme in Twenty Ten's style.css. This is just
+ * a simple filter call that tells WordPress to not use the default styles.
+ *
+ * @since Twenty Ten 1.2
+ */
+add_filter( 'use_default_gallery_style', '__return_false' );
+
+/**
+ * Deprecated way to remove inline styles printed when the gallery shortcode is used.
+ *
+ * This function is no longer needed or used. Use the use_default_gallery_style
+ * filter instead, as seen above.
+ *
+ * @since Twenty Ten 1.0
+ * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
+ *
+ * @return string The gallery style filter, with the styles themselves removed.
+ */
+function twentyten_remove_gallery_css( $css ) {
+	return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
+}
+// Backwards compatibility with WordPress 3.0.
+if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
+	add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
+
+if ( ! function_exists( 'twentyten_comment' ) ) :
+/**
+ * Template for comments and pingbacks.
+ *
+ * To override this walker in a child theme without modifying the comments template
+ * simply create your own twentyten_comment(), and that function will be used instead.
+ *
+ * Used as a callback by wp_list_comments() for displaying the comments.
+ *
+ * @since Twenty Ten 1.0
+ */
+function twentyten_comment( $comment, $args, $depth ) {
+	$GLOBALS['comment'] = $comment;
+	switch ( $comment->comment_type ) :
+		case '' :
+	?>
+	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
+		<div id="comment-<?php comment_ID(); ?>">
+		<div class="comment-author vcard">
+			<?php echo get_avatar( $comment, 40 ); ?>
+			<?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
+		</div><!-- .comment-author .vcard -->
+		<?php if ( $comment->comment_approved == '0' ) : ?>
+			<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
+			<br />
+		<?php endif; ?>
+
+		<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
+			<?php
+				/* translators: 1: date, 2: time */
+				printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
+			?>
+		</div><!-- .comment-meta .commentmetadata -->
+
+		<div class="comment-body"><?php comment_text(); ?></div>
+
+		<div class="reply">
+			<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
+		</div><!-- .reply -->
+	</div><!-- #comment-##  -->
+
+	<?php
+			break;
+		case 'pingback'  :
+		case 'trackback' :
+	?>
+	<li class="post pingback">
+		<p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
+	<?php
+			break;
+	endswitch;
+}
+endif;
+
+/**
+ * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
+ *
+ * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
+ * function tied to the init hook.
+ *
+ * @since Twenty Ten 1.0
+ * @uses register_sidebar
+ */
+function twentyten_widgets_init() {
+	// Area 1, located at the top of the sidebar.
+	register_sidebar( array(
+		'name' => __( 'Primary Widget Area', 'twentyten' ),
+		'id' => 'primary-widget-area',
+		'description' => __( 'The primary widget area', 'twentyten' ),
+		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+		'after_widget' => '</li>',
+		'before_title' => '<h3 class="widget-title">',
+		'after_title' => '</h3>',
+	) );
+
+	// Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
+	register_sidebar( array(
+		'name' => __( 'Secondary Widget Area', 'twentyten' ),
+		'id' => 'secondary-widget-area',
+		'description' => __( 'The secondary widget area', 'twentyten' ),
+		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+		'after_widget' => '</li>',
+		'before_title' => '<h3 class="widget-title">',
+		'after_title' => '</h3>',
+	) );
+
+	// Area 3, located in the footer. Empty by default.
+	register_sidebar( array(
+		'name' => __( 'First Footer Widget Area', 'twentyten' ),
+		'id' => 'first-footer-widget-area',
+		'description' => __( 'The first footer widget area', 'twentyten' ),
+		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+		'after_widget' => '</li>',
+		'before_title' => '<h3 class="widget-title">',
+		'after_title' => '</h3>',
+	) );
+
+	// Area 4, located in the footer. Empty by default.
+	register_sidebar( array(
+		'name' => __( 'Second Footer Widget Area', 'twentyten' ),
+		'id' => 'second-footer-widget-area',
+		'description' => __( 'The second footer widget area', 'twentyten' ),
+		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+		'after_widget' => '</li>',
+		'before_title' => '<h3 class="widget-title">',
+		'after_title' => '</h3>',
+	) );
+
+	// Area 5, located in the footer. Empty by default.
+	register_sidebar( array(
+		'name' => __( 'Third Footer Widget Area', 'twentyten' ),
+		'id' => 'third-footer-widget-area',
+		'description' => __( 'The third footer widget area', 'twentyten' ),
+		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+		'after_widget' => '</li>',
+		'before_title' => '<h3 class="widget-title">',
+		'after_title' => '</h3>',
+	) );
+
+	// Area 6, located in the footer. Empty by default.
+	register_sidebar( array(
+		'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
+		'id' => 'fourth-footer-widget-area',
+		'description' => __( 'The fourth footer widget area', 'twentyten' ),
+		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
+		'after_widget' => '</li>',
+		'before_title' => '<h3 class="widget-title">',
+		'after_title' => '</h3>',
+	) );
+}
+/** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
+add_action( 'widgets_init', 'twentyten_widgets_init' );
+
+/**
+ * Removes the default styles that are packaged with the Recent Comments widget.
+ *
+ * To override this in a child theme, remove the filter and optionally add your own
+ * function tied to the widgets_init action hook.
+ *
+ * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
+ * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
+ * but they won't have any effect on the widget in default Twenty Ten styling.
+ *
+ * @since Twenty Ten 1.0
+ */
+function twentyten_remove_recent_comments_style() {
+	add_filter( 'show_recent_comments_widget_style', '__return_false' );
+}
+add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
+
+if ( ! function_exists( 'twentyten_posted_on' ) ) :
+/**
+ * Prints HTML with meta information for the current post-date/time and author.
+ *
+ * @since Twenty Ten 1.0
+ */
+function twentyten_posted_on() {
+	printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
+		'meta-prep meta-prep-author',
+		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
+			get_permalink(),
+			esc_attr( get_the_time() ),
+			get_the_date()
+		),
+		sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
+			get_author_posts_url( get_the_author_meta( 'ID' ) ),
+			sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
+			get_the_author()
+		)
+	);
+}
+endif;
+
+if ( ! function_exists( 'twentyten_posted_in' ) ) :
+/**
+ * Prints HTML with meta information for the current post (category, tags and permalink).
+ *
+ * @since Twenty Ten 1.0
+ */
+function twentyten_posted_in() {
+	// Retrieves tag list of current post, separated by commas.
+	$tag_list = get_the_tag_list( '', ', ' );
+	if ( $tag_list ) {
+		$posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
+	} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
+		$posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
+	} else {
+		$posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
+	}
+	// Prints the string, replacing the placeholders.
+	printf(
+		$posted_in,
+		get_the_category_list( ', ' ),
+		$tag_list,
+		get_permalink(),
+		the_title_attribute( 'echo=0' )
+	);
+}
+endif;
Index: /tags/3.1/wp-content/themes/twentyten/header.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/header.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/header.php	(revision 17487)
@@ -0,0 +1,90 @@
+<?php
+/**
+ * The Header for our theme.
+ *
+ * Displays all of the <head> section and everything up till <div id="main">
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+?><!DOCTYPE html>
+<html <?php language_attributes(); ?>>
+<head>
+<meta charset="<?php bloginfo( 'charset' ); ?>" />
+<title><?php
+	/*
+	 * Print the <title> tag based on what is being viewed.
+	 */
+	global $page, $paged;
+
+	wp_title( '|', true, 'right' );
+
+	// Add the blog name.
+	bloginfo( 'name' );
+
+	// Add the blog description for the home/front page.
+	$site_description = get_bloginfo( 'description', 'display' );
+	if ( $site_description && ( is_home() || is_front_page() ) )
+		echo " | $site_description";
+
+	// Add a page number if necessary:
+	if ( $paged >= 2 || $page >= 2 )
+		echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
+
+	?></title>
+<link rel="profile" href="http://gmpg.org/xfn/11" />
+<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
+<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
+<?php
+	/* We add some JavaScript to pages with the comment form
+	 * to support sites with threaded comments (when in use).
+	 */
+	if ( is_singular() && get_option( 'thread_comments' ) )
+		wp_enqueue_script( 'comment-reply' );
+
+	/* Always have wp_head() just before the closing </head>
+	 * tag of your theme, or you will break many plugins, which
+	 * generally use this hook to add elements to <head> such
+	 * as styles, scripts, and meta tags.
+	 */
+	wp_head();
+?>
+</head>
+
+<body <?php body_class(); ?>>
+<div id="wrapper" class="hfeed">
+	<div id="header">
+		<div id="masthead">
+			<div id="branding" role="banner">
+				<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
+				<<?php echo $heading_tag; ?> id="site-title">
+					<span>
+						<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
+					</span>
+				</<?php echo $heading_tag; ?>>
+				<div id="site-description"><?php bloginfo( 'description' ); ?></div>
+
+				<?php
+					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
+					if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
+							has_post_thumbnail( $post->ID ) &&
+							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
+							$image[1] >= HEADER_IMAGE_WIDTH ) :
+						// Houston, we have a new header image!
+						echo get_the_post_thumbnail( $post->ID );
+					elseif ( get_header_image() ) : ?>
+						<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
+					<?php endif; ?>
+			</div><!-- #branding -->
+
+			<div id="access" role="navigation">
+			  <?php /*  Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
+				<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
+				<?php /* Our navigation menu.  If one isn't filled out, wp_nav_menu falls back to wp_page_menu.  The menu assiged to the primary position is the one used.  If none is assigned, the menu with the lowest ID is used.  */ ?>
+				<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
+			</div><!-- #access -->
+		</div><!-- #masthead -->
+	</div><!-- #header -->
+
+	<div id="main">
Index: /tags/3.1/wp-content/themes/twentyten/index.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/index.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/index.php	(revision 17487)
@@ -0,0 +1,32 @@
+<?php
+/**
+ * The main template file.
+ *
+ * This is the most generic template file in a WordPress theme
+ * and one of the two required files for a theme (the other being style.css).
+ * It is used to display a page when nothing more specific matches a query.
+ * E.g., it puts together the home page when no home.php file exists.
+ * Learn more: http://codex.wordpress.org/Template_Hierarchy
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+			<?php
+			/* Run the loop to output the posts.
+			 * If you want to overload this in a child theme then include a file
+			 * called loop-index.php and that will be used instead.
+			 */
+			 get_template_part( 'loop', 'index' );
+			?>
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/languages/twentyten.pot
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/languages/twentyten.pot	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/languages/twentyten.pot	(revision 17487)
@@ -0,0 +1,398 @@
+# Copyright (C) 2010 Twenty Ten
+# This file is distributed under the same license as the Twenty Ten package.
+msgid ""
+msgstr ""
+"Project-Id-Version: Twenty Ten 1.2\n"
+"Report-Msgid-Bugs-To: http://wordpress.org/tag/twentyten\n"
+"POT-Creation-Date: 2011-02-22 08:27:25+00:00\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+
+#: loop-attachment.php:21
+msgid "Return to %s"
+msgstr ""
+
+#: loop-attachment.php:23
+msgid "<span class=\"meta-nav\">&larr;</span> %s"
+msgstr ""
+
+#: loop-attachment.php:32
+msgid "<span class=\"%1$s\">By</span> %2$s"
+msgstr ""
+
+#: loop-attachment.php:36 functions.php:476
+msgid "View all posts by %s"
+msgstr ""
+
+#: loop-attachment.php:43
+msgid "<span class=\"%1$s\">Published</span> %2$s"
+msgstr ""
+
+#: loop-attachment.php:53
+msgid "Full size is %s pixels"
+msgstr ""
+
+#: loop-attachment.php:56
+msgid "Link to full-size image"
+msgstr ""
+
+#: loop-attachment.php:63 loop-attachment.php:111 loop.php:100 loop.php:123
+#: loop.php:165 loop-page.php:30 loop-single.php:56
+msgid "Edit"
+msgstr ""
+
+#: loop-attachment.php:104 loop.php:115 loop.php:143 functions.php:248
+msgid "Continue reading <span class=\"meta-nav\">&rarr;</span>"
+msgstr ""
+
+#: loop-attachment.php:105 loop.php:144 loop-page.php:29 loop-single.php:34
+msgid "Pages:"
+msgstr ""
+
+#. #-#-#-#-#  twentyten.pot (Twenty Ten 1.2)  #-#-#-#-#
+#. Theme URI of the plugin/theme
+#: footer.php:33
+msgid "http://wordpress.org/"
+msgstr ""
+
+#: footer.php:33
+msgid "Semantic Personal Publishing Platform"
+msgstr ""
+
+#: footer.php:33
+msgid "Proudly powered by %s."
+msgstr ""
+
+#: category.php:16
+msgid "Category Archives: %s"
+msgstr ""
+
+#: sidebar.php:27
+msgid "Archives"
+msgstr ""
+
+#: sidebar.php:34
+msgid "Meta"
+msgstr ""
+
+#: tag.php:16
+msgid "Tag Archives: %s"
+msgstr ""
+
+#: comments.php:18
+msgid ""
+"This post is password protected. Enter the password to view any comments."
+msgstr ""
+
+#: comments.php:35
+msgid "One Response to %2$s"
+msgid_plural "%1$s Responses to %2$s"
+msgstr[0] ""
+msgstr[1] ""
+
+#: comments.php:41 comments.php:60
+msgid "<span class=\"meta-nav\">&larr;</span> Older Comments"
+msgstr ""
+
+#: comments.php:42 comments.php:61
+msgid "Newer Comments <span class=\"meta-nav\">&rarr;</span>"
+msgstr ""
+
+#: comments.php:72
+msgid "Comments are closed."
+msgstr ""
+
+#: 404.php:16 loop.php:33
+msgid "Not Found"
+msgstr ""
+
+#: 404.php:18
+msgid ""
+"Apologies, but the page you requested could not be found. Perhaps searching "
+"will help."
+msgstr ""
+
+#: loop.php:25 loop.php:178
+msgid "<span class=\"meta-nav\">&larr;</span> Older posts"
+msgstr ""
+
+#: loop.php:26 loop.php:179
+msgid "Newer posts <span class=\"meta-nav\">&rarr;</span>"
+msgstr ""
+
+#: loop.php:35
+msgid ""
+"Apologies, but no results were found for the requested archive. Perhaps "
+"searching will help find a related post."
+msgstr ""
+
+#: loop.php:60 loop.php:95 loop.php:96
+msgctxt "gallery category slug"
+msgid "gallery"
+msgstr ""
+
+#: loop.php:62 loop.php:83 loop.php:131
+msgid "Permalink to %s"
+msgstr ""
+
+#: loop.php:82
+msgid "This gallery contains <a %1$s>%2$s photo</a>."
+msgid_plural "This gallery contains <a %1$s>%2$s photos</a>."
+msgstr[0] ""
+msgstr[1] ""
+
+#: loop.php:93
+msgid "View Galleries"
+msgstr ""
+
+#: loop.php:93 loop.php:96
+msgid "More Galleries"
+msgstr ""
+
+#: loop.php:96
+msgid "View posts in the Gallery category"
+msgstr ""
+
+#: loop.php:99 loop.php:122 loop.php:164
+msgid "Leave a comment"
+msgstr ""
+
+#: loop.php:99 loop.php:122 loop.php:164
+msgid "1 Comment"
+msgstr ""
+
+#: loop.php:99 loop.php:122 loop.php:164
+msgid "% Comments"
+msgstr ""
+
+#: loop.php:106
+msgctxt "asides category slug"
+msgid "asides"
+msgstr ""
+
+#: loop.php:151
+msgid "<span class=\"%1$s\">Posted in</span> %2$s"
+msgstr ""
+
+#: loop.php:160
+msgid "<span class=\"%1$s\">Tagged</span> %2$s"
+msgstr ""
+
+#: functions.php:100
+msgid "Primary Navigation"
+msgstr ""
+
+#: functions.php:140
+msgid "Berries"
+msgstr ""
+
+#: functions.php:146
+msgid "Cherry Blossoms"
+msgstr ""
+
+#: functions.php:152
+msgid "Concave"
+msgstr ""
+
+#: functions.php:158
+msgid "Fern"
+msgstr ""
+
+#: functions.php:164
+msgid "Forest Floor"
+msgstr ""
+
+#: functions.php:170
+msgid "Inkwell"
+msgstr ""
+
+#: functions.php:176
+msgid "Path"
+msgstr ""
+
+#: functions.php:182
+msgid "Sunset"
+msgstr ""
+
+#: functions.php:330
+msgid "%s <span class=\"says\">says:</span>"
+msgstr ""
+
+#: functions.php:333
+msgid "Your comment is awaiting moderation."
+msgstr ""
+
+#: functions.php:340
+msgid "%1$s at %2$s"
+msgstr ""
+
+#: functions.php:340 functions.php:357
+msgid "(Edit)"
+msgstr ""
+
+#: functions.php:357
+msgid "Pingback:"
+msgstr ""
+
+#: functions.php:376
+msgid "Primary Widget Area"
+msgstr ""
+
+#: functions.php:378
+msgid "The primary widget area"
+msgstr ""
+
+#: functions.php:387
+msgid "Secondary Widget Area"
+msgstr ""
+
+#: functions.php:389
+msgid "The secondary widget area"
+msgstr ""
+
+#: functions.php:398
+msgid "First Footer Widget Area"
+msgstr ""
+
+#: functions.php:400
+msgid "The first footer widget area"
+msgstr ""
+
+#: functions.php:409
+msgid "Second Footer Widget Area"
+msgstr ""
+
+#: functions.php:411
+msgid "The second footer widget area"
+msgstr ""
+
+#: functions.php:420
+msgid "Third Footer Widget Area"
+msgstr ""
+
+#: functions.php:422
+msgid "The third footer widget area"
+msgstr ""
+
+#: functions.php:431
+msgid "Fourth Footer Widget Area"
+msgstr ""
+
+#: functions.php:433
+msgid "The fourth footer widget area"
+msgstr ""
+
+#: functions.php:467
+msgid ""
+"<span class=\"%1$s\">Posted on</span> %2$s <span class=\"meta-sep\">by</"
+"span> %3$s"
+msgstr ""
+
+#: functions.php:493
+msgid ""
+"This entry was posted in %1$s and tagged %2$s. Bookmark the <a href=\"%3$s\" "
+"title=\"Permalink to %4$s\" rel=\"bookmark\">permalink</a>."
+msgstr ""
+
+#: functions.php:495
+msgid ""
+"This entry was posted in %1$s. Bookmark the <a href=\"%3$s\" title="
+"\"Permalink to %4$s\" rel=\"bookmark\">permalink</a>."
+msgstr ""
+
+#: functions.php:497
+msgid ""
+"Bookmark the <a href=\"%3$s\" title=\"Permalink to %4$s\" rel=\"bookmark"
+"\">permalink</a>."
+msgstr ""
+
+#: header.php:33
+msgid "Page %s"
+msgstr ""
+
+#: header.php:83
+msgid "Skip to content"
+msgstr ""
+
+#: author.php:27
+msgid "Author Archives: %s"
+msgstr ""
+
+#: author.php:37 loop-single.php:43
+msgid "About %s"
+msgstr ""
+
+#: search.php:16
+msgid "Search Results for: %s"
+msgstr ""
+
+#: search.php:26
+msgid "Nothing Found"
+msgstr ""
+
+#: search.php:28
+msgid ""
+"Sorry, but nothing matched your search criteria. Please try again with some "
+"different keywords."
+msgstr ""
+
+#: loop-single.php:21 loop-single.php:61
+msgctxt "Previous post link"
+msgid "&larr;"
+msgstr ""
+
+#: loop-single.php:22 loop-single.php:62
+msgctxt "Next post link"
+msgid "&rarr;"
+msgstr ""
+
+#: loop-single.php:47
+msgid "View all posts by %s <span class=\"meta-nav\">&rarr;</span>"
+msgstr ""
+
+#: archive.php:33
+msgid "Daily Archives: <span>%s</span>"
+msgstr ""
+
+#: archive.php:35
+msgid "Monthly Archives: <span>%s</span>"
+msgstr ""
+
+#: archive.php:37
+msgid "Yearly Archives: <span>%s</span>"
+msgstr ""
+
+#: archive.php:39
+msgid "Blog Archives"
+msgstr ""
+
+#. Theme Name of the plugin/theme
+msgid "Twenty Ten"
+msgstr ""
+
+#. Description of the plugin/theme
+msgid ""
+"The 2010 theme for WordPress is stylish, customizable, simple, and readable "
+"-- make it yours with a custom menu, header image, and background. Twenty "
+"Ten supports six widgetized areas (two in the sidebar, four in the footer) "
+"and featured images (thumbnails for gallery posts and custom header images "
+"for posts and pages). It includes stylesheets for print and the admin Visual "
+"Editor, special styles for posts in the \"Asides\" and \"Gallery\" "
+"categories, and has an optional one-column page template that removes the "
+"sidebar."
+msgstr ""
+
+#. Author of the plugin/theme
+msgid "the WordPress team"
+msgstr ""
+
+#. Tags of the plugin/theme
+msgid ""
+"black, blue, white, two-columns, fixed-width, custom-header, custom-"
+"background, threaded-comments, sticky-post, translation-ready, microformats, "
+"rtl-language-support, editor-style, custom-menu"
+msgstr ""
Index: /tags/3.1/wp-content/themes/twentyten/license.txt
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/license.txt	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/license.txt	(revision 17487)
@@ -0,0 +1,281 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc. 
+              51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
Index: /tags/3.1/wp-content/themes/twentyten/loop-attachment.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/loop-attachment.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/loop-attachment.php	(revision 17487)
@@ -0,0 +1,117 @@
+<?php
+/**
+ * The loop that displays an attachment.
+ *
+ * The loop displays the posts and the post content.  See
+ * http://codex.wordpress.org/The_Loop to understand it and
+ * http://codex.wordpress.org/Template_Tags to understand
+ * the tags used in it.
+ *
+ * This can be overridden in child themes with loop-attachment.php.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.2
+ */
+?>
+
+<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
+
+				<?php if ( ! empty( $post->post_parent ) ) : ?>
+					<p class="page-title"><a href="<?php echo get_permalink( $post->post_parent ); ?>" title="<?php esc_attr( printf( __( 'Return to %s', 'twentyten' ), get_the_title( $post->post_parent ) ) ); ?>" rel="gallery"><?php
+						/* translators: %s - title of parent post */
+						printf( __( '<span class="meta-nav">&larr;</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) );
+					?></a></p>
+				<?php endif; ?>
+
+				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+					<h2 class="entry-title"><?php the_title(); ?></h2>
+
+					<div class="entry-meta">
+						<?php
+							printf( __( '<span class="%1$s">By</span> %2$s', 'twentyten' ),
+								'meta-prep meta-prep-author',
+								sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
+									get_author_posts_url( get_the_author_meta( 'ID' ) ),
+									sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
+									get_the_author()
+								)
+							);
+						?>
+						<span class="meta-sep">|</span>
+						<?php
+							printf( __( '<span class="%1$s">Published</span> %2$s', 'twentyten' ),
+								'meta-prep meta-prep-entry-date',
+								sprintf( '<span class="entry-date"><abbr class="published" title="%1$s">%2$s</abbr></span>',
+									esc_attr( get_the_time() ),
+									get_the_date()
+								)
+							);
+							if ( wp_attachment_is_image() ) {
+								echo ' <span class="meta-sep">|</span> ';
+								$metadata = wp_get_attachment_metadata();
+								printf( __( 'Full size is %s pixels', 'twentyten' ),
+									sprintf( '<a href="%1$s" title="%2$s">%3$s &times; %4$s</a>',
+										wp_get_attachment_url(),
+										esc_attr( __( 'Link to full-size image', 'twentyten' ) ),
+										$metadata['width'],
+										$metadata['height']
+									)
+								);
+							}
+						?>
+						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
+					</div><!-- .entry-meta -->
+
+					<div class="entry-content">
+						<div class="entry-attachment">
+<?php if ( wp_attachment_is_image() ) :
+	$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
+	foreach ( $attachments as $k => $attachment ) {
+		if ( $attachment->ID == $post->ID )
+			break;
+	}
+	$k++;
+	// If there is more than 1 image attachment in a gallery
+	if ( count( $attachments ) > 1 ) {
+		if ( isset( $attachments[ $k ] ) )
+			// get the URL of the next image attachment
+			$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
+		else
+			// or get the URL of the first image attachment
+			$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
+	} else {
+		// or, if there's only 1 image attachment, get the URL of the image
+		$next_attachment_url = wp_get_attachment_url();
+	}
+?>
+						<p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
+							$attachment_width  = apply_filters( 'twentyten_attachment_size', 900 );
+							$attachment_height = apply_filters( 'twentyten_attachment_height', 900 );
+							echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height.
+						?></a></p>
+
+						<div id="nav-below" class="navigation">
+							<div class="nav-previous"><?php previous_image_link( false ); ?></div>
+							<div class="nav-next"><?php next_image_link( false ); ?></div>
+						</div><!-- #nav-below -->
+<?php else : ?>
+						<a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo basename( get_permalink() ); ?></a>
+<?php endif; ?>
+						</div><!-- .entry-attachment -->
+						<div class="entry-caption"><?php if ( !empty( $post->post_excerpt ) ) the_excerpt(); ?></div>
+
+<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
+<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
+
+					</div><!-- .entry-content -->
+
+					<div class="entry-utility">
+						<?php twentyten_posted_in(); ?>
+						<?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?>
+					</div><!-- .entry-utility -->
+				</div><!-- #post-## -->
+
+<?php comments_template(); ?>
+
+<?php endwhile; // end of the loop. ?>
Index: /tags/3.1/wp-content/themes/twentyten/loop-page.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/loop-page.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/loop-page.php	(revision 17487)
@@ -0,0 +1,36 @@
+<?php
+/**
+ * The loop that displays a page.
+ *
+ * The loop displays the posts and the post content.  See
+ * http://codex.wordpress.org/The_Loop to understand it and
+ * http://codex.wordpress.org/Template_Tags to understand
+ * the tags used in it.
+ *
+ * This can be overridden in child themes with loop-page.php.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.2
+ */
+?>
+
+<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
+
+				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+					<?php if ( is_front_page() ) { ?>
+						<h2 class="entry-title"><?php the_title(); ?></h2>
+					<?php } else { ?>
+						<h1 class="entry-title"><?php the_title(); ?></h1>
+					<?php } ?>
+
+					<div class="entry-content">
+						<?php the_content(); ?>
+						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
+						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
+					</div><!-- .entry-content -->
+				</div><!-- #post-## -->
+
+				<?php comments_template( '', true ); ?>
+
+<?php endwhile; // end of the loop. ?>
Index: /tags/3.1/wp-content/themes/twentyten/loop-single.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/loop-single.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/loop-single.php	(revision 17487)
@@ -0,0 +1,67 @@
+<?php
+/**
+ * The loop that displays a single post.
+ *
+ * The loop displays the posts and the post content.  See
+ * http://codex.wordpress.org/The_Loop to understand it and
+ * http://codex.wordpress.org/Template_Tags to understand
+ * the tags used in it.
+ *
+ * This can be overridden in child themes with loop-single.php.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.2
+ */
+?>
+
+<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
+
+				<div id="nav-above" class="navigation">
+					<div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'twentyten' ) . '</span> %title' ); ?></div>
+					<div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'twentyten' ) . '</span>' ); ?></div>
+				</div><!-- #nav-above -->
+
+				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+					<h1 class="entry-title"><?php the_title(); ?></h1>
+
+					<div class="entry-meta">
+						<?php twentyten_posted_on(); ?>
+					</div><!-- .entry-meta -->
+
+					<div class="entry-content">
+						<?php the_content(); ?>
+						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
+					</div><!-- .entry-content -->
+
+<?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries  ?>
+					<div id="entry-author-info">
+						<div id="author-avatar">
+							<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyten_author_bio_avatar_size', 60 ) ); ?>
+						</div><!-- #author-avatar -->
+						<div id="author-description">
+							<h2><?php printf( esc_attr__( 'About %s', 'twentyten' ), get_the_author() ); ?></h2>
+							<?php the_author_meta( 'description' ); ?>
+							<div id="author-link">
+								<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
+									<?php printf( __( 'View all posts by %s <span class="meta-nav">&rarr;</span>', 'twentyten' ), get_the_author() ); ?>
+								</a>
+							</div><!-- #author-link	-->
+						</div><!-- #author-description -->
+					</div><!-- #entry-author-info -->
+<?php endif; ?>
+
+					<div class="entry-utility">
+						<?php twentyten_posted_in(); ?>
+						<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
+					</div><!-- .entry-utility -->
+				</div><!-- #post-## -->
+
+				<div id="nav-below" class="navigation">
+					<div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'twentyten' ) . '</span> %title' ); ?></div>
+					<div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'twentyten' ) . '</span>' ); ?></div>
+				</div><!-- #nav-below -->
+
+				<?php comments_template( '', true ); ?>
+
+<?php endwhile; // end of the loop. ?>
Index: /tags/3.1/wp-content/themes/twentyten/loop.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/loop.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/loop.php	(revision 17487)
@@ -0,0 +1,181 @@
+<?php
+/**
+ * The loop that displays posts.
+ *
+ * The loop displays the posts and the post content.  See
+ * http://codex.wordpress.org/The_Loop to understand it and
+ * http://codex.wordpress.org/Template_Tags to understand
+ * the tags used in it.
+ *
+ * This can be overridden in child themes with loop.php or
+ * loop-template.php, where 'template' is the loop context
+ * requested by a template. For example, loop-index.php would
+ * be used if it exists and we ask for the loop with:
+ * <code>get_template_part( 'loop', 'index' );</code>
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+?>
+
+<?php /* Display navigation to next/previous pages when applicable */ ?>
+<?php if ( $wp_query->max_num_pages > 1 ) : ?>
+	<div id="nav-above" class="navigation">
+		<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
+		<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
+	</div><!-- #nav-above -->
+<?php endif; ?>
+
+<?php /* If there are no posts to display, such as an empty archive page */ ?>
+<?php if ( ! have_posts() ) : ?>
+	<div id="post-0" class="post error404 not-found">
+		<h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
+		<div class="entry-content">
+			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
+			<?php get_search_form(); ?>
+		</div><!-- .entry-content -->
+	</div><!-- #post-0 -->
+<?php endif; ?>
+
+<?php
+	/* Start the Loop.
+	 *
+	 * In Twenty Ten we use the same loop in multiple contexts.
+	 * It is broken into three main parts: when we're displaying
+	 * posts that are in the gallery category, when we're displaying
+	 * posts in the asides category, and finally all other posts.
+	 *
+	 * Additionally, we sometimes check for whether we are on an
+	 * archive page, a search page, etc., allowing for small differences
+	 * in the loop on each template without actually duplicating
+	 * the rest of the loop that is shared.
+	 *
+	 * Without further ado, the loop:
+	 */ ?>
+<?php while ( have_posts() ) : the_post(); ?>
+
+<?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?>
+
+	<?php if ( ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) || in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
+		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
+
+			<div class="entry-meta">
+				<?php twentyten_posted_on(); ?>
+			</div><!-- .entry-meta -->
+
+			<div class="entry-content">
+<?php if ( post_password_required() ) : ?>
+				<?php the_content(); ?>
+<?php else : ?>
+				<?php
+					$images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
+					if ( $images ) :
+						$total_images = count( $images );
+						$image = array_shift( $images );
+						$image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
+				?>
+						<div class="gallery-thumb">
+							<a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
+						</div><!-- .gallery-thumb -->
+						<p><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo</a>.', 'This gallery contains <a %1$s>%2$s photos</a>.', $total_images, 'twentyten' ),
+								'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
+								number_format_i18n( $total_images )
+							); ?></em></p>
+				<?php endif; ?>
+						<?php the_excerpt(); ?>
+<?php endif; ?>
+			</div><!-- .entry-content -->
+
+			<div class="entry-utility">
+			<?php if ( function_exists( 'get_post_format' ) && 'gallery' == get_post_format( $post->ID ) ) : ?>
+				<a href="<?php echo get_post_format_link( 'gallery' ); ?>" title="<?php esc_attr_e( 'View Galleries', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
+				<span class="meta-sep">|</span>
+			<?php elseif ( in_category( _x( 'gallery', 'gallery category slug', 'twentyten' ) ) ) : ?>
+				<a href="<?php echo get_term_link( _x( 'gallery', 'gallery category slug', 'twentyten' ), 'category' ); ?>" title="<?php esc_attr_e( 'View posts in the Gallery category', 'twentyten' ); ?>"><?php _e( 'More Galleries', 'twentyten' ); ?></a>
+				<span class="meta-sep">|</span>
+			<?php endif; ?>
+				<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
+				<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
+			</div><!-- .entry-utility -->
+		</div><!-- #post-## -->
+
+<?php /* How to display posts of the Aside format. The asides category is the old way. */ ?>
+
+	<?php elseif ( ( function_exists( 'get_post_format' ) && 'aside' == get_post_format( $post->ID ) ) || in_category( _x( 'asides', 'asides category slug', 'twentyten' ) )  ) : ?>
+		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+
+		<?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
+			<div class="entry-summary">
+				<?php the_excerpt(); ?>
+			</div><!-- .entry-summary -->
+		<?php else : ?>
+			<div class="entry-content">
+				<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
+			</div><!-- .entry-content -->
+		<?php endif; ?>
+
+			<div class="entry-utility">
+				<?php twentyten_posted_on(); ?>
+				<span class="meta-sep">|</span>
+				<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
+				<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
+			</div><!-- .entry-utility -->
+		</div><!-- #post-## -->
+
+<?php /* How to display all other posts. */ ?>
+
+	<?php else : ?>
+		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
+			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
+
+			<div class="entry-meta">
+				<?php twentyten_posted_on(); ?>
+			</div><!-- .entry-meta -->
+
+	<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
+			<div class="entry-summary">
+				<?php the_excerpt(); ?>
+			</div><!-- .entry-summary -->
+	<?php else : ?>
+			<div class="entry-content">
+				<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
+				<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
+			</div><!-- .entry-content -->
+	<?php endif; ?>
+
+			<div class="entry-utility">
+				<?php if ( count( get_the_category() ) ) : ?>
+					<span class="cat-links">
+						<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
+					</span>
+					<span class="meta-sep">|</span>
+				<?php endif; ?>
+				<?php
+					$tags_list = get_the_tag_list( '', ', ' );
+					if ( $tags_list ):
+				?>
+					<span class="tag-links">
+						<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
+					</span>
+					<span class="meta-sep">|</span>
+				<?php endif; ?>
+				<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
+				<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
+			</div><!-- .entry-utility -->
+		</div><!-- #post-## -->
+
+		<?php comments_template( '', true ); ?>
+
+	<?php endif; // This was the if statement that broke the loop into three parts based on categories. ?>
+
+<?php endwhile; // End the loop. Whew. ?>
+
+<?php /* Display navigation to next/previous pages when applicable */ ?>
+<?php if (  $wp_query->max_num_pages > 1 ) : ?>
+				<div id="nav-below" class="navigation">
+					<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
+					<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
+				</div><!-- #nav-below -->
+<?php endif; ?>
Index: /tags/3.1/wp-content/themes/twentyten/onecolumn-page.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/onecolumn-page.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/onecolumn-page.php	(revision 17487)
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Template Name: One column, no sidebar
+ *
+ * A custom page template without sidebar.
+ *
+ * The "Template Name:" bit above allows this to be selectable
+ * from a dropdown menu on the edit page screen.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container" class="one-column">
+			<div id="content" role="main">
+
+			<?php
+			/* Run the loop to output the page.
+			 * If you want to overload this in a child theme then include a file
+			 * called loop-page.php and that will be used instead.
+			 */
+			 get_template_part( 'loop', 'page' );
+			?>
+
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/page.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/page.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/page.php	(revision 17487)
@@ -0,0 +1,32 @@
+<?php
+/**
+ * The template for displaying all pages.
+ *
+ * This is the template that displays all pages by default.
+ * Please note that this is the WordPress construct of pages
+ * and that other 'pages' on your WordPress site will use a
+ * different template.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+			<?php
+			/* Run the loop to output the page.
+			 * If you want to overload this in a child theme then include a file
+			 * called loop-page.php and that will be used instead.
+			 */
+			get_template_part( 'loop', 'page' );
+			?>
+
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/rtl.css
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/rtl.css	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/rtl.css	(revision 17487)
@@ -0,0 +1,285 @@
+/*
+Theme Name: Twenty Ten
+*/
+
+
+/*
+RTL Basics
+*/
+
+
+body {
+	direction:rtl;
+	unicode-bidi:embed;
+}
+
+
+/*
+LAYOUT: Two-Column (Right)
+DESCRIPTION: Two-column fixed layout with one sidebar right of content
+*/
+
+#container {
+	float: right;
+	margin: 0 0 0 -240px;
+}
+#content {
+	margin: 0 20px 36px 280px;
+}
+#primary,
+#secondary {
+	float: left;
+}
+#secondary {
+	clear: left;
+}
+
+
+/* =Fonts
+-------------------------------------------------------------- */
+body,
+input,
+textarea,
+.page-title span,
+.pingback a.url,
+h3#comments-title,
+h3#reply-title,
+#access .menu,
+#access div.menu ul,
+#cancel-comment-reply-link,
+.form-allowed-tags,
+#site-info,
+#site-title,
+#wp-calendar,
+.comment-meta,
+.comment-body tr th,
+.comment-body thead th,
+.entry-content label,
+.entry-content tr th,
+.entry-content thead th,
+.entry-meta,
+.entry-title,
+.entry-utility,
+#respond label,
+.navigation,
+.page-title,
+.pingback p,
+.reply,
+.widget-title,
+input[type=submit] {
+	font-family: Arial, Tahoma, sans-serif;
+}
+
+/* =Structure
+-------------------------------------------------------------- */
+
+/* The main theme structure */
+#footer-widget-area .widget-area {
+	float: right;
+	margin-left: 20px;
+	margin-right: 0;
+}
+#footer-widget-area #fourth {
+	margin-left: 0;
+}
+#site-info {
+	float: right;
+}
+#site-generator {
+	float: left;
+}
+
+
+/* =Global Elements
+-------------------------------------------------------------- */
+
+/* Text elements */
+ul, ol {
+	margin: 0 1.5em 18px 0;
+}
+blockquote {
+	font-style: normal;
+}
+
+/* Text meant only for screen readers */
+.screen-reader-text {
+	left: auto;
+	text-indent:-9000px;
+	overflow:hidden;
+}
+
+
+/* =Header
+-------------------------------------------------------------- */
+
+#site-title {
+	float: right;
+}
+#site-description {
+	clear: left;
+	float: left;
+	font-style: normal;
+}
+#branding img {
+	float: right;
+}
+
+/* =Menu
+-------------------------------------------------------------- */
+
+#access {
+	float:right;
+}
+
+#access .menu-header,
+div.menu {
+    margin-right: 12px;
+    margin-left: 0;
+}
+
+#access .menu-header li,
+div.menu li{
+	float:right;
+}
+
+#access ul ul {
+	left:auto;
+	right:0;
+	float:right;
+}
+#access ul ul ul {
+	left:auto;
+	right:100%;
+}
+
+/* =Content
+-------------------------------------------------------------- */
+
+#content table {
+	text-align: right;
+	margin: 0 0 24px -1px;
+}
+.page-title span {
+	font-style:normal;
+}
+.entry-title,
+.entry-meta {
+	clear: right;
+	float: right;
+	margin-left: 68px;
+	margin-right: 0;
+}
+
+.entry-content input.file,
+.entry-content input.button {
+	margin-left: 24px;
+	margin-right:0;
+}
+.entry-content blockquote.left {
+	float: right;
+	margin-right: 0;
+	margin-left: 24px;
+	text-align: left;
+}
+.entry-content blockquote.right {
+	float: left;
+	margin-right: 24px;
+	margin-left: 0;
+	text-align: right;
+}
+#entry-author-info #author-avatar {
+	float: right;
+	margin: 0 0 0 -104px;
+}
+#entry-author-info #author-description {
+	float: right;
+	margin: 0 104px 0 0;
+}
+
+/* Gallery listing
+-------------------------------------------------------------- */
+
+.category-gallery .gallery-thumb {
+	float: right;
+ 	margin-left:20px;
+	margin-right:0;
+}
+
+
+/* Images
+-------------------------------------------------------------- */
+
+#content .gallery .gallery-caption {
+	margin-right: 0;
+}
+
+#content .gallery .gallery-item {
+	float: right;
+}
+
+/* =Navigation
+-------------------------------------------------------------- */
+.nav-previous {
+	float: right;
+}
+.nav-next {
+	float: left;
+	text-align:left;
+}
+
+/* =Comments
+-------------------------------------------------------------- */
+
+.commentlist li.comment {
+	padding: 0 56px 0 0;
+}
+.commentlist .avatar {
+	right: 0;
+	left: auto;
+}
+.comment-author .says, #comments .pingback .url  {
+	font-style: normal;
+}
+
+/* Comments form */
+.children #respond {
+	margin: 0 0 0 48px;
+}
+
+/* =Widget Areas
+-------------------------------------------------------------- */
+
+.widget-area ul {
+	margin-right: 0;
+}
+.widget-area ul ul {
+	margin-right: 1.3em;
+	margin-left: 0;
+}
+#wp-calendar caption {
+	text-align: right;
+}
+#wp-calendar tfoot #next {
+	text-align: left;
+}
+
+/* Main sidebars */
+#main .widget-area ul {
+	margin-right: 0;
+	padding: 0 0 0 20px;
+}
+#main .widget-area ul ul {
+	margin-right: 1.3em;
+	margin-left: 0;
+}
+
+/* =Footer
+-------------------------------------------------------------- */
+#site-generator {
+	font-style:normal;
+}
+#site-generator a {
+	background-position: right center;
+	padding-right: 20px;
+	padding-left: 0;
+}
Index: /tags/3.1/wp-content/themes/twentyten/search.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/search.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/search.php	(revision 17487)
@@ -0,0 +1,37 @@
+<?php
+/**
+ * The template for displaying Search Results pages.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+<?php if ( have_posts() ) : ?>
+				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyten' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
+				<?php
+				/* Run the loop for the search to output the results.
+				 * If you want to overload this in a child theme then include a file
+				 * called loop-search.php and that will be used instead.
+				 */
+				 get_template_part( 'loop', 'search' );
+				?>
+<?php else : ?>
+				<div id="post-0" class="post no-results not-found">
+					<h2 class="entry-title"><?php _e( 'Nothing Found', 'twentyten' ); ?></h2>
+					<div class="entry-content">
+						<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'twentyten' ); ?></p>
+						<?php get_search_form(); ?>
+					</div><!-- .entry-content -->
+				</div><!-- #post-0 -->
+<?php endif; ?>
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/sidebar-footer.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/sidebar-footer.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/sidebar-footer.php	(revision 17487)
@@ -0,0 +1,60 @@
+<?php
+/**
+ * The Footer widget areas.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+?>
+
+<?php
+	/* The footer widget area is triggered if any of the areas
+	 * have widgets. So let's check that first.
+	 *
+	 * If none of the sidebars have widgets, then let's bail early.
+	 */
+	if (   ! is_active_sidebar( 'first-footer-widget-area'  )
+		&& ! is_active_sidebar( 'second-footer-widget-area' )
+		&& ! is_active_sidebar( 'third-footer-widget-area'  )
+		&& ! is_active_sidebar( 'fourth-footer-widget-area' )
+	)
+		return;
+	// If we get this far, we have widgets. Let do this.
+?>
+
+			<div id="footer-widget-area" role="complementary">
+
+<?php if ( is_active_sidebar( 'first-footer-widget-area' ) ) : ?>
+				<div id="first" class="widget-area">
+					<ul class="xoxo">
+						<?php dynamic_sidebar( 'first-footer-widget-area' ); ?>
+					</ul>
+				</div><!-- #first .widget-area -->
+<?php endif; ?>
+
+<?php if ( is_active_sidebar( 'second-footer-widget-area' ) ) : ?>
+				<div id="second" class="widget-area">
+					<ul class="xoxo">
+						<?php dynamic_sidebar( 'second-footer-widget-area' ); ?>
+					</ul>
+				</div><!-- #second .widget-area -->
+<?php endif; ?>
+
+<?php if ( is_active_sidebar( 'third-footer-widget-area' ) ) : ?>
+				<div id="third" class="widget-area">
+					<ul class="xoxo">
+						<?php dynamic_sidebar( 'third-footer-widget-area' ); ?>
+					</ul>
+				</div><!-- #third .widget-area -->
+<?php endif; ?>
+
+<?php if ( is_active_sidebar( 'fourth-footer-widget-area' ) ) : ?>
+				<div id="fourth" class="widget-area">
+					<ul class="xoxo">
+						<?php dynamic_sidebar( 'fourth-footer-widget-area' ); ?>
+					</ul>
+				</div><!-- #fourth .widget-area -->
+<?php endif; ?>
+
+			</div><!-- #footer-widget-area -->
Index: /tags/3.1/wp-content/themes/twentyten/sidebar.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/sidebar.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/sidebar.php	(revision 17487)
@@ -0,0 +1,56 @@
+<?php
+/**
+ * The Sidebar containing the primary and secondary widget areas.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+?>
+
+		<div id="primary" class="widget-area" role="complementary">
+			<ul class="xoxo">
+
+<?php
+	/* When we call the dynamic_sidebar() function, it'll spit out
+	 * the widgets for that widget area. If it instead returns false,
+	 * then the sidebar simply doesn't exist, so we'll hard-code in
+	 * some default sidebar stuff just in case.
+	 */
+	if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : ?>
+
+			<li id="search" class="widget-container widget_search">
+				<?php get_search_form(); ?>
+			</li>
+
+			<li id="archives" class="widget-container">
+				<h3 class="widget-title"><?php _e( 'Archives', 'twentyten' ); ?></h3>
+				<ul>
+					<?php wp_get_archives( 'type=monthly' ); ?>
+				</ul>
+			</li>
+
+			<li id="meta" class="widget-container">
+				<h3 class="widget-title"><?php _e( 'Meta', 'twentyten' ); ?></h3>
+				<ul>
+					<?php wp_register(); ?>
+					<li><?php wp_loginout(); ?></li>
+					<?php wp_meta(); ?>
+				</ul>
+			</li>
+
+		<?php endif; // end primary widget area ?>
+			</ul>
+		</div><!-- #primary .widget-area -->
+
+<?php
+	// A second sidebar for widgets, just because.
+	if ( is_active_sidebar( 'secondary-widget-area' ) ) : ?>
+
+		<div id="secondary" class="widget-area" role="complementary">
+			<ul class="xoxo">
+				<?php dynamic_sidebar( 'secondary-widget-area' ); ?>
+			</ul>
+		</div><!-- #secondary .widget-area -->
+
+<?php endif; ?>
Index: /tags/3.1/wp-content/themes/twentyten/single.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/single.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/single.php	(revision 17487)
@@ -0,0 +1,27 @@
+<?php
+/**
+ * The Template for displaying all single posts.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+			<?php
+			/* Run the loop to output the post.
+			 * If you want to overload this in a child theme then include a file
+			 * called loop-single.php and that will be used instead.
+			 */
+			get_template_part( 'loop', 'single' );
+			?>
+
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-content/themes/twentyten/style.css
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/style.css	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/style.css	(revision 17487)
@@ -0,0 +1,1357 @@
+/*
+Theme Name: Twenty Ten
+Theme URI: http://wordpress.org/
+Description: The 2010 theme for WordPress is stylish, customizable, simple, and readable -- make it yours with a custom menu, header image, and background. Twenty Ten supports six widgetized areas (two in the sidebar, four in the footer) and featured images (thumbnails for gallery posts and custom header images for posts and pages). It includes stylesheets for print and the admin Visual Editor, special styles for posts in the "Asides" and "Gallery" categories, and has an optional one-column page template that removes the sidebar.
+Author: the WordPress team
+Version: 1.2
+License: GNU General Public License
+License URI: license.txt
+Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu
+*/
+
+
+/* =Reset default browser CSS. Based on work by Eric Meyer: http://meyerweb.com/eric/tools/css/reset/index.html
+-------------------------------------------------------------- */
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td {
+	background: transparent;
+	border: 0;
+	margin: 0;
+	padding: 0;
+	vertical-align: baseline;
+}
+body {
+	line-height: 1;
+}
+h1, h2, h3, h4, h5, h6 {
+	clear: both;
+	font-weight: normal;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote {
+	quotes: none;
+}
+blockquote:before, blockquote:after {
+	content: '';
+	content: none;
+}
+del {
+	text-decoration: line-through;
+}
+/* tables still need 'cellspacing="0"' in the markup */
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}
+a img {
+	border: none;
+}
+
+/* =Layout
+-------------------------------------------------------------- */
+
+/*
+LAYOUT: Two columns
+DESCRIPTION: Two-column fixed layout with one sidebar right of content
+*/
+
+#container {
+	float: left;
+	margin: 0 -240px 0 0;
+	width: 100%;
+}
+#content {
+	margin: 0 280px 0 20px;
+}
+#primary,
+#secondary {
+	float: right;
+	overflow: hidden;
+	width: 220px;
+}
+#secondary {
+	clear: right;
+}
+#footer {
+	clear: both;
+	width: 100%;
+}
+
+/*
+LAYOUT: One column, no sidebar
+DESCRIPTION: One centered column with no sidebar
+*/
+
+.one-column #content {
+	margin: 0 auto;
+	width: 640px;
+}
+
+/*
+LAYOUT: Full width, no sidebar
+DESCRIPTION: Full width content with no sidebar; used for attachment pages
+*/
+
+.single-attachment #content {
+	margin: 0 auto;
+	width: 900px;
+}
+
+
+/* =Fonts
+-------------------------------------------------------------- */
+body,
+input,
+textarea,
+.page-title span,
+.pingback a.url {
+	font-family: Georgia, "Bitstream Charter", serif;
+}
+h3#comments-title,
+h3#reply-title,
+#access .menu,
+#access div.menu ul,
+#cancel-comment-reply-link,
+.form-allowed-tags,
+#site-info,
+#site-title,
+#wp-calendar,
+.comment-meta,
+.comment-body tr th,
+.comment-body thead th,
+.entry-content label,
+.entry-content tr th,
+.entry-content thead th,
+.entry-meta,
+.entry-title,
+.entry-utility,
+#respond label,
+.navigation,
+.page-title,
+.pingback p,
+.reply,
+.widget-title,
+.wp-caption-text {
+	font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
+}
+input[type=submit] {
+	font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
+}
+pre {
+	font-family: "Courier 10 Pitch", Courier, monospace;
+}
+code {
+	font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
+}
+
+
+/* =Structure
+-------------------------------------------------------------- */
+
+/* The main theme structure */
+#access .menu-header,
+div.menu,
+#colophon,
+#branding,
+#main,
+#wrapper {
+	margin: 0 auto;
+	width: 940px;
+}
+#wrapper {
+	background: #fff;
+	margin-top: 20px;
+	padding: 0 20px;
+}
+
+/* Structure the footer area */
+#footer-widget-area {
+	overflow: hidden;
+}
+#footer-widget-area .widget-area {
+	float: left;
+	margin-right: 20px;
+	width: 220px;
+}
+#footer-widget-area #fourth {
+	margin-right: 0;
+}
+#site-info {
+	float: left;
+	font-size: 14px;
+	font-weight: bold;
+	width: 700px;
+}
+#site-generator {
+	float: right;
+	width: 220px;
+}
+
+
+/* =Global Elements
+-------------------------------------------------------------- */
+
+/* Main global 'theme' and typographic styles */
+body {
+	background: #f1f1f1;
+}
+body,
+input,
+textarea {
+	color: #666;
+	font-size: 12px;
+	line-height: 18px;
+}
+hr {
+	background-color: #e7e7e7;
+	border: 0;
+	clear: both;
+	height: 1px;
+	margin-bottom: 18px;
+}
+
+/* Text elements */
+p {
+	margin-bottom: 18px;
+}
+ul {
+	list-style: square;
+	margin: 0 0 18px 1.5em;
+}
+ol {
+	list-style: decimal;
+	margin: 0 0 18px 1.5em;
+}
+ol ol {
+	list-style: upper-alpha;
+}
+ol ol ol {
+	list-style: lower-roman;
+}
+ol ol ol ol {
+	list-style: lower-alpha;
+}
+ul ul,
+ol ol,
+ul ol,
+ol ul {
+	margin-bottom: 0;
+}
+dl {
+	margin: 0 0 24px 0;
+}
+dt {
+	font-weight: bold;
+}
+dd {
+	margin-bottom: 18px;
+}
+strong {
+	font-weight: bold;
+}
+cite,
+em,
+i {
+	font-style: italic;
+}
+big {
+	font-size: 131.25%;
+}
+ins {
+	background: #ffc;
+	text-decoration: none;
+}
+blockquote {
+	font-style: italic;
+	padding: 0 3em;
+}
+blockquote cite,
+blockquote em,
+blockquote i {
+	font-style: normal;
+}
+pre {
+	background: #f7f7f7;
+	color: #222;
+	line-height: 18px;
+	margin-bottom: 18px;
+	padding: 1.5em;
+}
+abbr,
+acronym {
+	border-bottom: 1px dotted #666;
+	cursor: help;
+}
+sup,
+sub {
+	height: 0;
+	line-height: 1;
+	position: relative;
+	vertical-align: baseline;
+}
+sup {
+	bottom: 1ex;
+}
+sub {
+	top: .5ex;
+}
+input[type="text"],
+textarea {
+	background: #f9f9f9;
+	border: 1px solid #ccc;
+	box-shadow: inset 1px 1px 1px rgba(0,0,0,0.1);
+	-moz-box-shadow: inset 1px 1px 1px rgba(0,0,0,0.1);
+	-webkit-box-shadow: inset 1px 1px 1px rgba(0,0,0,0.1);
+	padding: 2px;
+}
+a:link {
+	color: #0066cc;
+}
+a:visited {
+	color: #743399;
+}
+a:active,
+a:hover {
+	color: #ff4b33;
+}
+
+/* Text meant only for screen readers */
+.screen-reader-text {
+	position: absolute;
+	left: -9000px;
+}
+
+
+/* =Header
+-------------------------------------------------------------- */
+
+#header {
+	padding: 30px 0 0 0;
+}
+#site-title {
+	float: left;
+	font-size: 30px;
+	line-height: 36px;
+	margin: 0 0 18px 0;
+	width: 700px;
+}
+#site-title a {
+	color: #000;
+	font-weight: bold;
+	text-decoration: none;
+}
+#site-description {
+	clear: right;
+	float: right;
+	font-style: italic;
+	margin: 15px 0 18px 0;
+	width: 220px;
+}
+
+/* This is the custom header image */
+#branding img {
+	border-top: 4px solid #000;
+	border-bottom: 1px solid #000;
+	display: block;
+	float: left;
+}
+
+
+/* =Menu
+-------------------------------------------------------------- */
+
+#access {
+	background: #000;
+	display: block;
+	float: left;
+	margin: 0 auto;
+	width: 940px;
+}
+#access .menu-header,
+div.menu {
+	font-size: 13px;
+	margin-left: 12px;
+	width: 928px;
+}
+#access .menu-header ul,
+div.menu ul {
+	list-style: none;
+	margin: 0;
+}
+#access .menu-header li,
+div.menu li {
+	float: left;
+	position: relative;
+}
+#access a {
+	color: #aaa;
+	display: block;
+	line-height: 38px;
+	padding: 0 10px;
+	text-decoration: none;
+}
+#access ul ul {
+	box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
+	-moz-box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
+	-webkit-box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
+	display: none;
+	position: absolute;
+	top: 38px;
+	left: 0;
+	float: left;
+	width: 180px;
+	z-index: 99999;
+}
+#access ul ul li {
+	min-width: 180px;
+}
+#access ul ul ul {
+	left: 100%;
+	top: 0;
+}
+#access ul ul a {
+	background: #333;
+	line-height: 1em;
+	padding: 10px;
+	width: 160px;
+	height: auto;
+}
+#access li:hover > a,
+#access ul ul :hover > a {
+	background: #333;
+	color: #fff;
+}
+#access ul li:hover > ul {
+	display: block;
+}
+#access ul li.current_page_item > a,
+#access ul li.current-menu-ancestor > a,
+#access ul li.current-menu-item > a,
+#access ul li.current-menu-parent > a {
+	color: #fff;
+}
+* html #access ul li.current_page_item a,
+* html #access ul li.current-menu-ancestor a,
+* html #access ul li.current-menu-item a,
+* html #access ul li.current-menu-parent a,
+* html #access ul li a:hover {
+	color: #fff;
+}
+
+
+/* =Content
+-------------------------------------------------------------- */
+
+#main {
+	clear: both;
+	overflow: hidden;
+	padding: 40px 0 0 0;
+}
+#content {
+	margin-bottom: 36px;
+}
+#content,
+#content input,
+#content textarea {
+	color: #333;
+	font-size: 16px;
+	line-height: 24px;
+}
+#content p,
+#content ul,
+#content ol,
+#content dd,
+#content pre,
+#content hr {
+	margin-bottom: 24px;
+}
+#content ul ul,
+#content ol ol,
+#content ul ol,
+#content ol ul {
+	margin-bottom: 0;
+}
+#content pre,
+#content kbd,
+#content tt,
+#content var {
+	font-size: 15px;
+	line-height: 21px;
+}
+#content code {
+	font-size: 13px;
+}
+#content dt,
+#content th {
+	color: #000;
+}
+#content h1,
+#content h2,
+#content h3,
+#content h4,
+#content h5,
+#content h6 {
+	color: #000;
+	line-height: 1.5em;
+	margin: 0 0 20px 0;
+}
+#content table {
+	border: 1px solid #e7e7e7;
+	margin: 0 -1px 24px 0;
+	text-align: left;
+	width: 100%;
+}
+#content tr th,
+#content thead th {
+	color: #888;
+	font-size: 12px;
+	font-weight: bold;
+	line-height: 18px;
+	padding: 9px 24px;
+}
+#content tr td {
+	border-top: 1px solid #e7e7e7;
+	padding: 6px 24px;
+}
+#content tr.odd td {
+	background: #f2f7fc;
+}
+.hentry {
+	margin: 0 0 48px 0;
+}
+.home .sticky {
+	background: #f2f7fc;
+	border-top: 4px solid #000;
+	margin-left: -20px;
+	margin-right: -20px;
+	padding: 18px 20px;
+}
+.single .hentry {
+	margin: 0 0 36px 0;
+}
+.page-title {
+	color: #000;
+	font-size: 14px;
+	font-weight: bold;
+	margin: 0 0 36px 0;
+}
+.page-title span {
+	color: #333;
+	font-size: 16px;
+	font-style: italic;
+	font-weight: normal;
+}
+.page-title a:link,
+.page-title a:visited {
+	color: #888;
+	text-decoration: none;
+}
+.page-title a:active,
+.page-title a:hover {
+	color: #ff4b33;
+}
+#content .entry-title {
+	color: #000;
+	font-size: 21px;
+	font-weight: bold;
+	line-height: 1.3em;
+	margin-bottom: 0;
+}
+.entry-title a:link,
+.entry-title a:visited {
+	color: #000;
+	text-decoration: none;
+}
+.entry-title a:active,
+.entry-title a:hover {
+	color: #ff4b33;
+}
+.entry-meta {
+	color: #888;
+	font-size: 12px;
+}
+.entry-meta abbr,
+.entry-utility abbr {
+	border: none;
+}
+.entry-meta abbr:hover,
+.entry-utility abbr:hover {
+	border-bottom: 1px dotted #666;
+}
+.entry-content,
+.entry-summary {
+	clear: both;
+	padding: 12px 0 0 0;
+}
+#content .entry-summary p:last-child {
+	margin-bottom: 12px;
+}
+.entry-content fieldset {
+	border: 1px solid #e7e7e7;
+	margin: 0 0 24px 0;
+	padding: 24px;
+}
+.entry-content fieldset legend {
+	background: #fff;
+	color: #000;
+	font-weight: bold;
+	padding: 0 24px;
+}
+.entry-content input {
+	margin: 0 0 24px 0;
+}
+.entry-content input.file,
+.entry-content input.button {
+	margin-right: 24px;
+}
+.entry-content label {
+	color: #888;
+	font-size: 12px;
+}
+.entry-content select {
+	margin: 0 0 24px 0;
+}
+.entry-content sup,
+.entry-content sub {
+	font-size: 10px;
+}
+.entry-content blockquote.left {
+	float: left;
+	margin-left: 0;
+	margin-right: 24px;
+	text-align: right;
+	width: 33%;
+}
+.entry-content blockquote.right {
+	float: right;
+	margin-left: 24px;
+	margin-right: 0;
+	text-align: left;
+	width: 33%;
+}
+.page-link {
+	clear: both;
+	color: #000;
+	font-weight: bold;
+	margin: 0 0 22px 0;
+	word-spacing: 0.5em;
+}
+.page-link a:link,
+.page-link a:visited {
+	background: #f1f1f1;
+	color: #333;
+	font-weight: normal;
+	padding: 0.5em 0.75em;
+	text-decoration: none;
+}
+.home .sticky .page-link a {
+	background: #d9e8f7;
+}
+.page-link a:active,
+.page-link a:hover {
+	color: #ff4b33;
+}
+body.page .edit-link {
+	clear: both;
+	display: block;
+}
+#entry-author-info {
+	background: #f2f7fc;
+	border-top: 4px solid #000;
+	clear: both;
+	font-size: 14px;
+	line-height: 20px;
+	margin: 24px 0;
+	overflow: hidden;
+	padding: 18px 20px;
+}
+#entry-author-info #author-avatar {
+	background: #fff;
+	border: 1px solid #e7e7e7;
+	float: left;
+	height: 60px;
+	margin: 0 -104px 0 0;
+	padding: 11px;
+}
+#entry-author-info #author-description {
+	float: left;
+	margin: 0 0 0 104px;
+}
+#entry-author-info h2 {
+	color: #000;
+	font-size: 100%;
+	font-weight: bold;
+	margin-bottom: 0;
+}
+.entry-utility {
+	clear: both;
+	color: #888;
+	font-size: 12px;
+	line-height: 18px;
+}
+.entry-meta a,
+.entry-utility a {
+	color: #888;
+}
+.entry-meta a:hover,
+.entry-utility a:hover {
+	color: #ff4b33;
+}
+#content .video-player {
+	padding: 0;
+}
+
+
+/* =Asides
+-------------------------------------------------------------- */
+
+.home #content .format-aside p,
+.home #content .category-asides p {
+	font-size: 14px;
+	line-height: 20px;
+	margin-bottom: 10px;
+	margin-top: 0;
+}
+.home .hentry.format-aside,
+.home .hentry.category-asides {
+	padding: 0;
+}
+.home #content .format-aside .entry-content,
+.home #content .category-asides .entry-content {
+	padding-top: 0;
+}
+
+
+/* =Gallery listing
+-------------------------------------------------------------- */
+
+.format-gallery .size-thumbnail img,
+.category-gallery .size-thumbnail img {
+	border: 10px solid #f1f1f1;
+	margin-bottom: 0;
+}
+.format-gallery .gallery-thumb,
+.category-gallery .gallery-thumb {
+	float: left;
+	margin-right: 20px;
+	margin-top: -4px;
+}
+.home #content .format-gallery .entry-utility,
+.home #content .category-gallery .entry-utility {
+	padding-top: 4px;
+}
+
+
+/* =Attachment pages
+-------------------------------------------------------------- */
+
+.attachment .entry-content .entry-caption {
+	font-size: 140%;
+	margin-top: 24px;
+}
+.attachment .entry-content .nav-previous a:before {
+	content: '\2190\00a0';
+}
+.attachment .entry-content .nav-next a:after {
+	content: '\00a0\2192';
+}
+
+
+/* =Images
+-------------------------------------------------------------- */
+
+/*
+Resize images to fit the main content area.
+- Applies only to images uploaded via WordPress by targeting size-* classes.
+- Other images will be left alone. Use "size-auto" class to apply to other images.
+*/
+img.size-auto,
+img.size-full,
+img.size-large,
+img.size-medium,
+.attachment img {
+	max-width: 100%; /* When images are too wide for containing element, force them to fit. */
+	height: auto; /* Override height to match resized width for correct aspect ratio. */
+}
+.alignleft,
+img.alignleft {
+	display: inline;
+	float: left;
+	margin-right: 24px;
+	margin-top: 4px;
+}
+.alignright,
+img.alignright {
+	display: inline;
+	float: right;
+	margin-left: 24px;
+	margin-top: 4px;
+}
+.aligncenter,
+img.aligncenter {
+	clear: both;
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+}
+img.alignleft,
+img.alignright,
+img.aligncenter {
+	margin-bottom: 12px;
+}
+.wp-caption {
+	background: #f1f1f1;
+	line-height: 18px;
+	margin-bottom: 20px;
+	max-width: 632px !important; /* prevent too-wide images from breaking layout */
+	padding: 4px;
+	text-align: center;
+}
+.wp-caption img {
+	margin: 5px 5px 0;
+}
+.wp-caption p.wp-caption-text {
+	color: #888;
+	font-size: 12px;
+	margin: 5px;
+}
+.wp-smiley {
+	margin: 0;
+}
+.gallery {
+	margin: 0 auto 18px;
+}
+.gallery .gallery-item {
+	float: left;
+	margin-top: 0;
+	text-align: center;
+	width: 33%;
+}
+.gallery-columns-2 .gallery-item {
+	width: 50%;
+}
+.gallery-columns-4 .gallery-item {
+	width: 25%;
+}
+.gallery img {
+	border: 2px solid #cfcfcf;
+}
+.gallery-columns-2 .attachment-medium {
+	max-width: 92%;
+	height: auto;
+}
+.gallery-columns-4 .attachment-thumbnail {
+	max-width: 84%;
+	height: auto;
+}
+.gallery .gallery-caption {
+	color: #888;
+	font-size: 12px;
+	margin: 0 0 12px;
+}
+.gallery dl {
+	margin: 0;
+}
+.gallery img {
+	border: 10px solid #f1f1f1;
+}
+.gallery br+br {
+	display: none;
+}
+#content .attachment img {/* single attachment images should be centered */
+	display: block;
+	margin: 0 auto;
+}
+
+
+/* =Navigation
+-------------------------------------------------------------- */
+
+.navigation {
+	color: #888;
+	font-size: 12px;
+	line-height: 18px;
+	overflow: hidden;
+}
+.navigation a:link,
+.navigation a:visited {
+	color: #888;
+	text-decoration: none;
+}
+.navigation a:active,
+.navigation a:hover {
+	color: #ff4b33;
+}
+.nav-previous {
+	float: left;
+	width: 50%;
+}
+.nav-next {
+	float: right;
+	text-align: right;
+	width: 50%;
+}
+#nav-above {
+	margin: 0 0 18px 0;
+}
+#nav-above {
+	display: none;
+}
+.paged #nav-above,
+.single #nav-above {
+	display: block;
+}
+#nav-below {
+	margin: -18px 0 0 0;
+}
+
+
+/* =Comments
+-------------------------------------------------------------- */
+#comments {
+	clear: both;
+}
+#comments .navigation {
+	padding: 0 0 18px 0;
+}
+h3#comments-title,
+h3#reply-title {
+	color: #000;
+	font-size: 20px;
+	font-weight: bold;
+	margin-bottom: 0;
+}
+h3#comments-title {
+	padding: 24px 0;
+}
+.commentlist {
+	list-style: none;
+	margin: 0;
+}
+.commentlist li.comment {
+	border-bottom: 1px solid #e7e7e7;
+	line-height: 24px;
+	margin: 0 0 24px 0;
+	padding: 0 0 0 56px;
+	position: relative;
+}
+.commentlist li:last-child {
+	border-bottom: none;
+	margin-bottom: 0;
+}
+#comments .comment-body ul,
+#comments .comment-body ol {
+	margin-bottom: 18px;
+}
+#comments .comment-body p:last-child {
+	margin-bottom: 6px;
+}
+#comments .comment-body blockquote p:last-child {
+	margin-bottom: 24px;
+}
+.commentlist ol {
+	list-style: decimal;
+}
+.commentlist .avatar {
+	position: absolute;
+	top: 4px;
+	left: 0;
+}
+.comment-author {
+}
+.comment-author cite {
+	color: #000;
+	font-style: normal;
+	font-weight: bold;
+}
+.comment-author .says {
+	font-style: italic;
+}
+.comment-meta {
+	font-size: 12px;
+	margin: 0 0 18px 0;
+}
+.comment-meta a:link,
+.comment-meta a:visited {
+	color: #888;
+	text-decoration: none;
+}
+.comment-meta a:active,
+.comment-meta a:hover {
+	color: #ff4b33;
+}
+.commentlist .even {
+}
+.commentlist .bypostauthor {
+}
+.reply {
+	font-size: 12px;
+	padding: 0 0 24px 0;
+}
+.reply a,
+a.comment-edit-link {
+	color: #888;
+}
+.reply a:hover,
+a.comment-edit-link:hover {
+	color: #ff4b33;
+}
+.commentlist .children {
+	list-style: none;
+	margin: 0;
+}
+.commentlist .children li {
+	border: none;
+	margin: 0;
+}
+.nopassword,
+.nocomments {
+	display: none;
+}
+#comments .pingback {
+	border-bottom: 1px solid #e7e7e7;
+	margin-bottom: 18px;
+	padding-bottom: 18px;
+}
+.commentlist li.comment+li.pingback {
+	margin-top: -6px;
+}
+#comments .pingback p {
+	color: #888;
+	display: block;
+	font-size: 12px;
+	line-height: 18px;
+	margin: 0;
+}
+#comments .pingback .url {
+	font-size: 13px;
+	font-style: italic;
+}
+
+/* Comments form */
+input[type=submit] {
+	color: #333;
+}
+#respond {
+	border-top: 1px solid #e7e7e7;
+	margin: 24px 0;
+	overflow: hidden;
+	position: relative;
+}
+#respond p {
+	margin: 0;
+}
+#respond .comment-notes {
+	margin-bottom: 1em;
+}
+.form-allowed-tags {
+	line-height: 1em;
+}
+.children #respond {
+	margin: 0 48px 0 0;
+}
+h3#reply-title {
+	margin: 18px 0;
+}
+#comments-list #respond {
+	margin: 0 0 18px 0;
+}
+#comments-list ul #respond {
+	margin: 0;
+}
+#cancel-comment-reply-link {
+	font-size: 12px;
+	font-weight: normal;
+	line-height: 18px;
+}
+#respond .required {
+	color: #ff4b33;
+	font-weight: bold;
+}
+#respond label {
+	color: #888;
+	font-size: 12px;
+}
+#respond input {
+	margin: 0 0 9px;
+	width: 98%;
+}
+#respond textarea {
+	width: 98%;
+}
+#respond .form-allowed-tags {
+	color: #888;
+	font-size: 12px;
+	line-height: 18px;
+}
+#respond .form-allowed-tags code {
+	font-size: 11px;
+}
+#respond .form-submit {
+	margin: 12px 0;
+}
+#respond .form-submit input {
+	font-size: 14px;
+	width: auto;
+}
+
+
+/* =Widget Areas
+-------------------------------------------------------------- */
+
+.widget-area ul {
+	list-style: none;
+	margin-left: 0;
+}
+.widget-area ul ul {
+	list-style: square;
+	margin-left: 1.3em;
+}
+.widget-area select {
+	max-width: 100%;
+}
+.widget_search #s {/* This keeps the search inputs in line */
+	width: 60%;
+}
+.widget_search label {
+	display: none;
+}
+.widget-container {
+	margin: 0 0 18px 0;
+}
+.widget-title {
+	color: #222;
+	font-weight: bold;
+}
+.widget-area a:link,
+.widget-area a:visited {
+	text-decoration: none;
+}
+.widget-area a:active,
+.widget-area a:hover {
+	text-decoration: underline;
+}
+.widget-area .entry-meta {
+	font-size: 11px;
+}
+#wp_tag_cloud div {
+	line-height: 1.6em;
+}
+#wp-calendar {
+	width: 100%;
+}
+#wp-calendar caption {
+	color: #222;
+	font-size: 14px;
+	font-weight: bold;
+	padding-bottom: 4px;
+	text-align: left;
+}
+#wp-calendar thead {
+	font-size: 11px;
+}
+#wp-calendar thead th {
+}
+#wp-calendar tbody {
+	color: #aaa;
+}
+#wp-calendar tbody td {
+	background: #f5f5f5;
+	border: 1px solid #fff;
+	padding: 3px 0 2px;
+	text-align: center;
+}
+#wp-calendar tbody .pad {
+	background: none;
+}
+#wp-calendar tfoot #next {
+	text-align: right;
+}
+.widget_rss a.rsswidget {
+	color: #000;
+}
+.widget_rss a.rsswidget:hover {
+	color: #ff4b33;
+}
+.widget_rss .widget-title img {
+	width: 11px;
+	height: 11px;
+}
+
+/* Main sidebars */
+#main .widget-area ul {
+	margin-left: 0;
+	padding: 0 20px 0 0;
+}
+#main .widget-area ul ul {
+	border: none;
+	margin-left: 1.3em;
+	padding: 0;
+}
+#primary {
+}
+#secondary {
+}
+
+/* Footer widget areas */
+#footer-widget-area {
+}
+
+
+/* =Footer
+-------------------------------------------------------------- */
+
+#footer {
+	margin-bottom: 20px;
+}
+#colophon {
+	border-top: 4px solid #000;
+	margin-top: -4px;
+	overflow: hidden;
+	padding: 18px 0;
+}
+#site-info {
+	font-weight: bold;
+}
+#site-info a {
+	color: #000;
+	text-decoration: none;
+}
+#site-generator {
+	font-style: italic;
+	position: relative;
+}
+#site-generator a {
+	background: url(images/wordpress.png) center left no-repeat;
+	color: #666;
+	display: inline-block;
+	line-height: 16px;
+	padding-left: 20px;
+	text-decoration: none;
+}
+#site-generator a:hover {
+	text-decoration: underline;
+}
+img#wpstats {
+	display: block;
+	margin: 0 auto 10px;
+}
+
+
+/* =Mobile Safari ( iPad, iPhone and iPod Touch )
+-------------------------------------------------------------- */
+
+pre {
+	-webkit-text-size-adjust: 140%;
+}
+code {
+	-webkit-text-size-adjust: 160%;
+}
+#access,
+.entry-meta,
+.entry-utility,
+.navigation,
+.widget-area {
+	-webkit-text-size-adjust: 120%;
+}
+#site-description {
+	-webkit-text-size-adjust: none;
+}
+
+
+/* =Print Style
+-------------------------------------------------------------- */
+
+@media print {
+	body {
+		background: none !important;
+	}
+	#wrapper {
+		clear: both !important;
+		display: block !important;
+		float: none !important;
+		position: relative !important;
+	}
+	#header {
+		border-bottom: 2pt solid #000;
+		padding-bottom: 18pt;
+	}
+	#colophon {
+		border-top: 2pt solid #000;
+	}
+	#site-title,
+	#site-description {
+		float: none;
+		line-height: 1.4em;
+		margin: 0;
+		padding: 0;
+	}
+	#site-title {
+		font-size: 13pt;
+	}
+	.entry-content {
+		font-size: 14pt;
+		line-height: 1.6em;
+	}
+	.entry-title {
+		font-size: 21pt;
+	}
+	#access,
+	#branding img,
+	#respond,
+	.comment-edit-link,
+	.edit-link,
+	.navigation,
+	.page-link,
+	.widget-area {
+		display: none !important;
+	}
+	#container,
+	#header,
+	#footer {
+		margin: 0;
+		width: 100%;
+	}
+	#content,
+	.one-column #content {
+		margin: 24pt 0 0;
+		width: 100%;
+	}
+	.wp-caption p {
+		font-size: 11pt;
+	}
+	#site-info,
+	#site-generator {
+		float: none;
+		width: auto;
+	}
+	#colophon {
+		width: auto;
+	}
+	img#wpstats {
+		display: none;
+	}
+	#site-generator a {
+		margin: 0;
+		padding: 0;
+	}
+	#entry-author-info {
+		border: 1px solid #e7e7e7;
+	}
+	#main {
+		display: inline;
+	}
+	.home .sticky {
+		border: none;
+	}
+}
Index: /tags/3.1/wp-content/themes/twentyten/tag.php
===================================================================
--- /tags/3.1/wp-content/themes/twentyten/tag.php	(revision 17487)
+++ /tags/3.1/wp-content/themes/twentyten/tag.php	(revision 17487)
@@ -0,0 +1,30 @@
+<?php
+/**
+ * The template for displaying Tag Archive pages.
+ *
+ * @package WordPress
+ * @subpackage Twenty_Ten
+ * @since Twenty Ten 1.0
+ */
+
+get_header(); ?>
+
+		<div id="container">
+			<div id="content" role="main">
+
+				<h1 class="page-title"><?php
+					printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>' . single_tag_title( '', false ) . '</span>' );
+				?></h1>
+
+<?php
+/* Run the loop for the tag archive to output the posts
+ * If you want to overload this in a child theme then include a file
+ * called loop-tag.php and that will be used instead.
+ */
+ get_template_part( 'loop', 'tag' );
+?>
+			</div><!-- #content -->
+		</div><!-- #container -->
+
+<?php get_sidebar(); ?>
+<?php get_footer(); ?>
Index: /tags/3.1/wp-cron.php
===================================================================
--- /tags/3.1/wp-cron.php	(revision 17487)
+++ /tags/3.1/wp-cron.php	(revision 17487)
@@ -0,0 +1,60 @@
+<?php
+/**
+ * WordPress Cron Implementation for hosts, which do not offer CRON or for which
+ * the user has not set up a CRON job pointing to this file.
+ *
+ * The HTTP request to this file will not slow down the visitor who happens to
+ * visit when the cron job is needed to run.
+ *
+ * @package WordPress
+ */
+
+ignore_user_abort(true);
+
+if ( !empty($_POST) || defined('DOING_AJAX') || defined('DOING_CRON') )
+	die();
+
+/**
+ * Tell WordPress we are doing the CRON task.
+ *
+ * @var bool
+ */
+define('DOING_CRON', true);
+
+if ( !defined('ABSPATH') ) {
+	/** Set up WordPress environment */
+	require_once('./wp-load.php');
+}
+
+if ( false === $crons = _get_cron_array() )
+	die();
+
+$keys = array_keys( $crons );
+$local_time = time();
+
+if ( isset($keys[0]) && $keys[0] > $local_time )
+	die();
+
+foreach ($crons as $timestamp => $cronhooks) {
+	if ( $timestamp > $local_time )
+		break;
+
+	foreach ($cronhooks as $hook => $keys) {
+
+		foreach ($keys as $k => $v) {
+
+			$schedule = $v['schedule'];
+
+			if ($schedule != false) {
+				$new_args = array($timestamp, $schedule, $hook, $v['args']);
+				call_user_func_array('wp_reschedule_event', $new_args);
+			}
+
+			wp_unschedule_event($timestamp, $hook, $v['args']);
+
+ 			do_action_ref_array($hook, $v['args']);
+		}
+	}
+}
+
+die();
Index: /tags/3.1/wp-feed.php
===================================================================
--- /tags/3.1/wp-feed.php	(revision 17487)
+++ /tags/3.1/wp-feed.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Redirects to the default feed
+ * This file is deprecated and only exists for backwards compatibility
+ *
+ * @package WordPress
+ */
+
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( get_default_feed() . '_url' ), 301 );
+exit;
+?>
Index: /tags/3.1/wp-includes/Text/Diff.php
===================================================================
--- /tags/3.1/wp-includes/Text/Diff.php	(revision 17487)
+++ /tags/3.1/wp-includes/Text/Diff.php	(revision 17487)
@@ -0,0 +1,450 @@
+<?php
+/**
+ * General API for generating and formatting diffs - the differences between
+ * two sequences of strings.
+ *
+ * The original PHP version of this code was written by Geoffrey T. Dairiki
+ * <dairiki@dairiki.org>, and is used/adapted with his permission.
+ *
+ * Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org>
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did
+ * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
+ *
+ * @package Text_Diff
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ */
+class Text_Diff {
+
+    /**
+     * Array of changes.
+     *
+     * @var array
+     */
+    var $_edits;
+
+    /**
+     * Computes diffs between sequences of strings.
+     *
+     * @param string $engine     Name of the diffing engine to use.  'auto'
+     *                           will automatically select the best.
+     * @param array $params      Parameters to pass to the diffing engine.
+     *                           Normally an array of two arrays, each
+     *                           containing the lines from a file.
+     */
+    function Text_Diff($engine, $params)
+    {
+        // Backward compatibility workaround.
+        if (!is_string($engine)) {
+            $params = array($engine, $params);
+            $engine = 'auto';
+        }
+
+        if ($engine == 'auto') {
+            $engine = extension_loaded('xdiff') ? 'xdiff' : 'native';
+        } else {
+            $engine = basename($engine);
+        }
+
+        // WP #7391
+        require_once dirname(__FILE__).'/Diff/Engine/' . $engine . '.php';
+        $class = 'Text_Diff_Engine_' . $engine;
+        $diff_engine = new $class();
+
+        $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
+    }
+
+    /**
+     * Returns the array of differences.
+     */
+    function getDiff()
+    {
+        return $this->_edits;
+    }
+
+    /**
+     * returns the number of new (added) lines in a given diff.
+     *
+     * @since Text_Diff 1.1.0
+     *
+     * @return integer The number of new lines
+     */
+    function countAddedLines()
+    {
+        $count = 0;
+        foreach ($this->_edits as $edit) {
+            if (is_a($edit, 'Text_Diff_Op_add') ||
+                is_a($edit, 'Text_Diff_Op_change')) {
+                $count += $edit->nfinal();
+            }
+        }
+        return $count;
+    }
+
+    /**
+     * Returns the number of deleted (removed) lines in a given diff.
+     *
+     * @since Text_Diff 1.1.0
+     *
+     * @return integer The number of deleted lines
+     */
+    function countDeletedLines()
+    {
+        $count = 0;
+        foreach ($this->_edits as $edit) {
+            if (is_a($edit, 'Text_Diff_Op_delete') ||
+                is_a($edit, 'Text_Diff_Op_change')) {
+                $count += $edit->norig();
+            }
+        }
+        return $count;
+    }
+
+    /**
+     * Computes a reversed diff.
+     *
+     * Example:
+     * <code>
+     * $diff = new Text_Diff($lines1, $lines2);
+     * $rev = $diff->reverse();
+     * </code>
+     *
+     * @return Text_Diff  A Diff object representing the inverse of the
+     *                    original diff.  Note that we purposely don't return a
+     *                    reference here, since this essentially is a clone()
+     *                    method.
+     */
+    function reverse()
+    {
+        if (version_compare(zend_version(), '2', '>')) {
+            $rev = clone($this);
+        } else {
+            $rev = $this;
+        }
+        $rev->_edits = array();
+        foreach ($this->_edits as $edit) {
+            $rev->_edits[] = $edit->reverse();
+        }
+        return $rev;
+    }
+
+    /**
+     * Checks for an empty diff.
+     *
+     * @return boolean  True if two sequences were identical.
+     */
+    function isEmpty()
+    {
+        foreach ($this->_edits as $edit) {
+            if (!is_a($edit, 'Text_Diff_Op_copy')) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Computes the length of the Longest Common Subsequence (LCS).
+     *
+     * This is mostly for diagnostic purposes.
+     *
+     * @return integer  The length of the LCS.
+     */
+    function lcs()
+    {
+        $lcs = 0;
+        foreach ($this->_edits as $edit) {
+            if (is_a($edit, 'Text_Diff_Op_copy')) {
+                $lcs += count($edit->orig);
+            }
+        }
+        return $lcs;
+    }
+
+    /**
+     * Gets the original set of lines.
+     *
+     * This reconstructs the $from_lines parameter passed to the constructor.
+     *
+     * @return array  The original sequence of strings.
+     */
+    function getOriginal()
+    {
+        $lines = array();
+        foreach ($this->_edits as $edit) {
+            if ($edit->orig) {
+                array_splice($lines, count($lines), 0, $edit->orig);
+            }
+        }
+        return $lines;
+    }
+
+    /**
+     * Gets the final set of lines.
+     *
+     * This reconstructs the $to_lines parameter passed to the constructor.
+     *
+     * @return array  The sequence of strings.
+     */
+    function getFinal()
+    {
+        $lines = array();
+        foreach ($this->_edits as $edit) {
+            if ($edit->final) {
+                array_splice($lines, count($lines), 0, $edit->final);
+            }
+        }
+        return $lines;
+    }
+
+    /**
+     * Removes trailing newlines from a line of text. This is meant to be used
+     * with array_walk().
+     *
+     * @param string $line  The line to trim.
+     * @param integer $key  The index of the line in the array. Not used.
+     */
+    function trimNewlines(&$line, $key)
+    {
+        $line = str_replace(array("\n", "\r"), '', $line);
+    }
+
+    /**
+     * Determines the location of the system temporary directory.
+     *
+     * @static
+     *
+     * @access protected
+     *
+     * @return string  A directory name which can be used for temp files.
+     *                 Returns false if one could not be found.
+     */
+    function _getTempDir()
+    {
+        $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp',
+                               'c:\windows\temp', 'c:\winnt\temp');
+
+        /* Try PHP's upload_tmp_dir directive. */
+        $tmp = ini_get('upload_tmp_dir');
+
+        /* Otherwise, try to determine the TMPDIR environment variable. */
+        if (!strlen($tmp)) {
+            $tmp = getenv('TMPDIR');
+        }
+
+        /* If we still cannot determine a value, then cycle through a list of
+         * preset possibilities. */
+        while (!strlen($tmp) && count($tmp_locations)) {
+            $tmp_check = array_shift($tmp_locations);
+            if (@is_dir($tmp_check)) {
+                $tmp = $tmp_check;
+            }
+        }
+
+        /* If it is still empty, we have failed, so return false; otherwise
+         * return the directory determined. */
+        return strlen($tmp) ? $tmp : false;
+    }
+
+    /**
+     * Checks a diff for validity.
+     *
+     * This is here only for debugging purposes.
+     */
+    function _check($from_lines, $to_lines)
+    {
+        if (serialize($from_lines) != serialize($this->getOriginal())) {
+            trigger_error("Reconstructed original doesn't match", E_USER_ERROR);
+        }
+        if (serialize($to_lines) != serialize($this->getFinal())) {
+            trigger_error("Reconstructed final doesn't match", E_USER_ERROR);
+        }
+
+        $rev = $this->reverse();
+        if (serialize($to_lines) != serialize($rev->getOriginal())) {
+            trigger_error("Reversed original doesn't match", E_USER_ERROR);
+        }
+        if (serialize($from_lines) != serialize($rev->getFinal())) {
+            trigger_error("Reversed final doesn't match", E_USER_ERROR);
+        }
+
+        $prevtype = null;
+        foreach ($this->_edits as $edit) {
+            if ($prevtype == get_class($edit)) {
+                trigger_error("Edit sequence is non-optimal", E_USER_ERROR);
+            }
+            $prevtype = get_class($edit);
+        }
+
+        return true;
+    }
+
+}
+
+/**
+ * @package Text_Diff
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ */
+class Text_MappedDiff extends Text_Diff {
+
+    /**
+     * Computes a diff between sequences of strings.
+     *
+     * This can be used to compute things like case-insensitve diffs, or diffs
+     * which ignore changes in white-space.
+     *
+     * @param array $from_lines         An array of strings.
+     * @param array $to_lines           An array of strings.
+     * @param array $mapped_from_lines  This array should have the same size
+     *                                  number of elements as $from_lines.  The
+     *                                  elements in $mapped_from_lines and
+     *                                  $mapped_to_lines are what is actually
+     *                                  compared when computing the diff.
+     * @param array $mapped_to_lines    This array should have the same number
+     *                                  of elements as $to_lines.
+     */
+    function Text_MappedDiff($from_lines, $to_lines,
+                             $mapped_from_lines, $mapped_to_lines)
+    {
+        assert(count($from_lines) == count($mapped_from_lines));
+        assert(count($to_lines) == count($mapped_to_lines));
+
+        parent::Text_Diff($mapped_from_lines, $mapped_to_lines);
+
+        $xi = $yi = 0;
+        for ($i = 0; $i < count($this->_edits); $i++) {
+            $orig = &$this->_edits[$i]->orig;
+            if (is_array($orig)) {
+                $orig = array_slice($from_lines, $xi, count($orig));
+                $xi += count($orig);
+            }
+
+            $final = &$this->_edits[$i]->final;
+            if (is_array($final)) {
+                $final = array_slice($to_lines, $yi, count($final));
+                $yi += count($final);
+            }
+        }
+    }
+
+}
+
+/**
+ * @package Text_Diff
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ *
+ * @access private
+ */
+class Text_Diff_Op {
+
+    var $orig;
+    var $final;
+
+    function &reverse()
+    {
+        trigger_error('Abstract method', E_USER_ERROR);
+    }
+
+    function norig()
+    {
+        return $this->orig ? count($this->orig) : 0;
+    }
+
+    function nfinal()
+    {
+        return $this->final ? count($this->final) : 0;
+    }
+
+}
+
+/**
+ * @package Text_Diff
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ *
+ * @access private
+ */
+class Text_Diff_Op_copy extends Text_Diff_Op {
+
+    function Text_Diff_Op_copy($orig, $final = false)
+    {
+        if (!is_array($final)) {
+            $final = $orig;
+        }
+        $this->orig = $orig;
+        $this->final = $final;
+    }
+
+    function &reverse()
+    {
+        $reverse = &new Text_Diff_Op_copy($this->final, $this->orig);
+        return $reverse;
+    }
+
+}
+
+/**
+ * @package Text_Diff
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ *
+ * @access private
+ */
+class Text_Diff_Op_delete extends Text_Diff_Op {
+
+    function Text_Diff_Op_delete($lines)
+    {
+        $this->orig = $lines;
+        $this->final = false;
+    }
+
+    function &reverse()
+    {
+        $reverse = &new Text_Diff_Op_add($this->orig);
+        return $reverse;
+    }
+
+}
+
+/**
+ * @package Text_Diff
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ *
+ * @access private
+ */
+class Text_Diff_Op_add extends Text_Diff_Op {
+
+    function Text_Diff_Op_add($lines)
+    {
+        $this->final = $lines;
+        $this->orig = false;
+    }
+
+    function &reverse()
+    {
+        $reverse = &new Text_Diff_Op_delete($this->final);
+        return $reverse;
+    }
+
+}
+
+/**
+ * @package Text_Diff
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ *
+ * @access private
+ */
+class Text_Diff_Op_change extends Text_Diff_Op {
+
+    function Text_Diff_Op_change($orig, $final)
+    {
+        $this->orig = $orig;
+        $this->final = $final;
+    }
+
+    function &reverse()
+    {
+        $reverse = &new Text_Diff_Op_change($this->final, $this->orig);
+        return $reverse;
+    }
+
+}
Index: /tags/3.1/wp-includes/Text/Diff/Engine/native.php
===================================================================
--- /tags/3.1/wp-includes/Text/Diff/Engine/native.php	(revision 17487)
+++ /tags/3.1/wp-includes/Text/Diff/Engine/native.php	(revision 17487)
@@ -0,0 +1,436 @@
+<?php
+/**
+ * Class used internally by Text_Diff to actually compute the diffs.
+ *
+ * This class is implemented using native PHP code.
+ *
+ * The algorithm used here is mostly lifted from the perl module
+ * Algorithm::Diff (version 1.06) by Ned Konz, which is available at:
+ * http://www.perl.com/CPAN/authors/id/N/NE/NEDKONZ/Algorithm-Diff-1.06.zip
+ *
+ * More ideas are taken from: http://www.ics.uci.edu/~eppstein/161/960229.html
+ *
+ * Some ideas (and a bit of code) are taken from analyze.c, of GNU
+ * diffutils-2.7, which can be found at:
+ * ftp://gnudist.gnu.org/pub/gnu/diffutils/diffutils-2.7.tar.gz
+ *
+ * Some ideas (subdivision by NCHUNKS > 2, and some optimizations) are from
+ * Geoffrey T. Dairiki <dairiki@dairiki.org>. The original PHP version of this
+ * code was written by him, and is used/adapted with his permission.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did
+ * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
+ *
+ * @author  Geoffrey T. Dairiki <dairiki@dairiki.org>
+ * @package Text_Diff
+ */
+class Text_Diff_Engine_native {
+
+    function diff($from_lines, $to_lines)
+    {
+        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
+        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
+
+        $n_from = count($from_lines);
+        $n_to = count($to_lines);
+
+        $this->xchanged = $this->ychanged = array();
+        $this->xv = $this->yv = array();
+        $this->xind = $this->yind = array();
+        unset($this->seq);
+        unset($this->in_seq);
+        unset($this->lcs);
+
+        // Skip leading common lines.
+        for ($skip = 0; $skip < $n_from && $skip < $n_to; $skip++) {
+            if ($from_lines[$skip] !== $to_lines[$skip]) {
+                break;
+            }
+            $this->xchanged[$skip] = $this->ychanged[$skip] = false;
+        }
+
+        // Skip trailing common lines.
+        $xi = $n_from; $yi = $n_to;
+        for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {
+            if ($from_lines[$xi] !== $to_lines[$yi]) {
+                break;
+            }
+            $this->xchanged[$xi] = $this->ychanged[$yi] = false;
+        }
+
+        // Ignore lines which do not exist in both files.
+        for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
+            $xhash[$from_lines[$xi]] = 1;
+        }
+        for ($yi = $skip; $yi < $n_to - $endskip; $yi++) {
+            $line = $to_lines[$yi];
+            if (($this->ychanged[$yi] = empty($xhash[$line]))) {
+                continue;
+            }
+            $yhash[$line] = 1;
+            $this->yv[] = $line;
+            $this->yind[] = $yi;
+        }
+        for ($xi = $skip; $xi < $n_from - $endskip; $xi++) {
+            $line = $from_lines[$xi];
+            if (($this->xchanged[$xi] = empty($yhash[$line]))) {
+                continue;
+            }
+            $this->xv[] = $line;
+            $this->xind[] = $xi;
+        }
+
+        // Find the LCS.
+        $this->_compareseq(0, count($this->xv), 0, count($this->yv));
+
+        // Merge edits when possible.
+        $this->_shiftBoundaries($from_lines, $this->xchanged, $this->ychanged);
+        $this->_shiftBoundaries($to_lines, $this->ychanged, $this->xchanged);
+
+        // Compute the edit operations.
+        $edits = array();
+        $xi = $yi = 0;
+        while ($xi < $n_from || $yi < $n_to) {
+            assert($yi < $n_to || $this->xchanged[$xi]);
+            assert($xi < $n_from || $this->ychanged[$yi]);
+
+            // Skip matching "snake".
+            $copy = array();
+            while ($xi < $n_from && $yi < $n_to
+                   && !$this->xchanged[$xi] && !$this->ychanged[$yi]) {
+                $copy[] = $from_lines[$xi++];
+                ++$yi;
+            }
+            if ($copy) {
+                $edits[] = &new Text_Diff_Op_copy($copy);
+            }
+
+            // Find deletes & adds.
+            $delete = array();
+            while ($xi < $n_from && $this->xchanged[$xi]) {
+                $delete[] = $from_lines[$xi++];
+            }
+
+            $add = array();
+            while ($yi < $n_to && $this->ychanged[$yi]) {
+                $add[] = $to_lines[$yi++];
+            }
+
+            if ($delete && $add) {
+                $edits[] = &new Text_Diff_Op_change($delete, $add);
+            } elseif ($delete) {
+                $edits[] = &new Text_Diff_Op_delete($delete);
+            } elseif ($add) {
+                $edits[] = &new Text_Diff_Op_add($add);
+            }
+        }
+
+        return $edits;
+    }
+
+    /**
+     * Divides the Largest Common Subsequence (LCS) of the sequences (XOFF,
+     * XLIM) and (YOFF, YLIM) into NCHUNKS approximately equally sized
+     * segments.
+     *
+     * Returns (LCS, PTS).  LCS is the length of the LCS. PTS is an array of
+     * NCHUNKS+1 (X, Y) indexes giving the diving points between sub
+     * sequences.  The first sub-sequence is contained in (X0, X1), (Y0, Y1),
+     * the second in (X1, X2), (Y1, Y2) and so on.  Note that (X0, Y0) ==
+     * (XOFF, YOFF) and (X[NCHUNKS], Y[NCHUNKS]) == (XLIM, YLIM).
+     *
+     * This function assumes that the first lines of the specified portions of
+     * the two files do not match, and likewise that the last lines do not
+     * match.  The caller must trim matching lines from the beginning and end
+     * of the portions it is going to specify.
+     */
+    function _diag ($xoff, $xlim, $yoff, $ylim, $nchunks)
+    {
+        $flip = false;
+
+        if ($xlim - $xoff > $ylim - $yoff) {
+            /* Things seems faster (I'm not sure I understand why) when the
+             * shortest sequence is in X. */
+            $flip = true;
+            list ($xoff, $xlim, $yoff, $ylim)
+                = array($yoff, $ylim, $xoff, $xlim);
+        }
+
+        if ($flip) {
+            for ($i = $ylim - 1; $i >= $yoff; $i--) {
+                $ymatches[$this->xv[$i]][] = $i;
+            }
+        } else {
+            for ($i = $ylim - 1; $i >= $yoff; $i--) {
+                $ymatches[$this->yv[$i]][] = $i;
+            }
+        }
+
+        $this->lcs = 0;
+        $this->seq[0]= $yoff - 1;
+        $this->in_seq = array();
+        $ymids[0] = array();
+
+        $numer = $xlim - $xoff + $nchunks - 1;
+        $x = $xoff;
+        for ($chunk = 0; $chunk < $nchunks; $chunk++) {
+            if ($chunk > 0) {
+                for ($i = 0; $i <= $this->lcs; $i++) {
+                    $ymids[$i][$chunk - 1] = $this->seq[$i];
+                }
+            }
+
+            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);
+            for (; $x < $x1; $x++) {
+                $line = $flip ? $this->yv[$x] : $this->xv[$x];
+                if (empty($ymatches[$line])) {
+                    continue;
+                }
+                $matches = $ymatches[$line];
+                reset($matches);
+                while (list(, $y) = each($matches)) {
+                    if (empty($this->in_seq[$y])) {
+                        $k = $this->_lcsPos($y);
+                        assert($k > 0);
+                        $ymids[$k] = $ymids[$k - 1];
+                        break;
+                    }
+                }
+                while (list(, $y) = each($matches)) {
+                    if ($y > $this->seq[$k - 1]) {
+                        assert($y <= $this->seq[$k]);
+                        /* Optimization: this is a common case: next match is
+                         * just replacing previous match. */
+                        $this->in_seq[$this->seq[$k]] = false;
+                        $this->seq[$k] = $y;
+                        $this->in_seq[$y] = 1;
+                    } elseif (empty($this->in_seq[$y])) {
+                        $k = $this->_lcsPos($y);
+                        assert($k > 0);
+                        $ymids[$k] = $ymids[$k - 1];
+                    }
+                }
+            }
+        }
+
+        $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff);
+        $ymid = $ymids[$this->lcs];
+        for ($n = 0; $n < $nchunks - 1; $n++) {
+            $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks);
+            $y1 = $ymid[$n] + 1;
+            $seps[] = $flip ? array($y1, $x1) : array($x1, $y1);
+        }
+        $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim);
+
+        return array($this->lcs, $seps);
+    }
+
+    function _lcsPos($ypos)
+    {
+        $end = $this->lcs;
+        if ($end == 0 || $ypos > $this->seq[$end]) {
+            $this->seq[++$this->lcs] = $ypos;
+            $this->in_seq[$ypos] = 1;
+            return $this->lcs;
+        }
+
+        $beg = 1;
+        while ($beg < $end) {
+            $mid = (int)(($beg + $end) / 2);
+            if ($ypos > $this->seq[$mid]) {
+                $beg = $mid + 1;
+            } else {
+                $end = $mid;
+            }
+        }
+
+        assert($ypos != $this->seq[$end]);
+
+        $this->in_seq[$this->seq[$end]] = false;
+        $this->seq[$end] = $ypos;
+        $this->in_seq[$ypos] = 1;
+        return $end;
+    }
+
+    /**
+     * Finds LCS of two sequences.
+     *
+     * The results are recorded in the vectors $this->{x,y}changed[], by
+     * storing a 1 in the element for each line that is an insertion or
+     * deletion (ie. is not in the LCS).
+     *
+     * The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1.
+     *
+     * Note that XLIM, YLIM are exclusive bounds.  All line numbers are
+     * origin-0 and discarded lines are not counted.
+     */
+    function _compareseq ($xoff, $xlim, $yoff, $ylim)
+    {
+        /* Slide down the bottom initial diagonal. */
+        while ($xoff < $xlim && $yoff < $ylim
+               && $this->xv[$xoff] == $this->yv[$yoff]) {
+            ++$xoff;
+            ++$yoff;
+        }
+
+        /* Slide up the top initial diagonal. */
+        while ($xlim > $xoff && $ylim > $yoff
+               && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) {
+            --$xlim;
+            --$ylim;
+        }
+
+        if ($xoff == $xlim || $yoff == $ylim) {
+            $lcs = 0;
+        } else {
+            /* This is ad hoc but seems to work well.  $nchunks =
+             * sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); $nchunks =
+             * max(2,min(8,(int)$nchunks)); */
+            $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1;
+            list($lcs, $seps)
+                = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks);
+        }
+
+        if ($lcs == 0) {
+            /* X and Y sequences have no common subsequence: mark all
+             * changed. */
+            while ($yoff < $ylim) {
+                $this->ychanged[$this->yind[$yoff++]] = 1;
+            }
+            while ($xoff < $xlim) {
+                $this->xchanged[$this->xind[$xoff++]] = 1;
+            }
+        } else {
+            /* Use the partitions to split this problem into subproblems. */
+            reset($seps);
+            $pt1 = $seps[0];
+            while ($pt2 = next($seps)) {
+                $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]);
+                $pt1 = $pt2;
+            }
+        }
+    }
+
+    /**
+     * Adjusts inserts/deletes of identical lines to join changes as much as
+     * possible.
+     *
+     * We do something when a run of changed lines include a line at one end
+     * and has an excluded, identical line at the other.  We are free to
+     * choose which identical line is included.  `compareseq' usually chooses
+     * the one at the beginning, but usually it is cleaner to consider the
+     * following identical line to be the "change".
+     *
+     * This is extracted verbatim from analyze.c (GNU diffutils-2.7).
+     */
+    function _shiftBoundaries($lines, &$changed, $other_changed)
+    {
+        $i = 0;
+        $j = 0;
+
+        assert('count($lines) == count($changed)');
+        $len = count($lines);
+        $other_len = count($other_changed);
+
+        while (1) {
+            /* Scan forward to find the beginning of another run of
+             * changes. Also keep track of the corresponding point in the
+             * other file.
+             *
+             * Throughout this code, $i and $j are adjusted together so that
+             * the first $i elements of $changed and the first $j elements of
+             * $other_changed both contain the same number of zeros (unchanged
+             * lines).
+             *
+             * Furthermore, $j is always kept so that $j == $other_len or
+             * $other_changed[$j] == false. */
+            while ($j < $other_len && $other_changed[$j]) {
+                $j++;
+            }
+
+            while ($i < $len && ! $changed[$i]) {
+                assert('$j < $other_len && ! $other_changed[$j]');
+                $i++; $j++;
+                while ($j < $other_len && $other_changed[$j]) {
+                    $j++;
+                }
+            }
+
+            if ($i == $len) {
+                break;
+            }
+
+            $start = $i;
+
+            /* Find the end of this run of changes. */
+            while (++$i < $len && $changed[$i]) {
+                continue;
+            }
+
+            do {
+                /* Record the length of this run of changes, so that we can
+                 * later determine whether the run has grown. */
+                $runlength = $i - $start;
+
+                /* Move the changed region back, so long as the previous
+                 * unchanged line matches the last changed one.  This merges
+                 * with previous changed regions. */
+                while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) {
+                    $changed[--$start] = 1;
+                    $changed[--$i] = false;
+                    while ($start > 0 && $changed[$start - 1]) {
+                        $start--;
+                    }
+                    assert('$j > 0');
+                    while ($other_changed[--$j]) {
+                        continue;
+                    }
+                    assert('$j >= 0 && !$other_changed[$j]');
+                }
+
+                /* Set CORRESPONDING to the end of the changed run, at the
+                 * last point where it corresponds to a changed run in the
+                 * other file. CORRESPONDING == LEN means no such point has
+                 * been found. */
+                $corresponding = $j < $other_len ? $i : $len;
+
+                /* Move the changed region forward, so long as the first
+                 * changed line matches the following unchanged one.  This
+                 * merges with following changed regions.  Do this second, so
+                 * that if there are no merges, the changed region is moved
+                 * forward as far as possible. */
+                while ($i < $len && $lines[$start] == $lines[$i]) {
+                    $changed[$start++] = false;
+                    $changed[$i++] = 1;
+                    while ($i < $len && $changed[$i]) {
+                        $i++;
+                    }
+
+                    assert('$j < $other_len && ! $other_changed[$j]');
+                    $j++;
+                    if ($j < $other_len && $other_changed[$j]) {
+                        $corresponding = $i;
+                        while ($j < $other_len && $other_changed[$j]) {
+                            $j++;
+                        }
+                    }
+                }
+            } while ($runlength != $i - $start);
+
+            /* If possible, move the fully-merged run of changes back to a
+             * corresponding run in the other file. */
+            while ($corresponding < $i) {
+                $changed[--$start] = 1;
+                $changed[--$i] = 0;
+                assert('$j > 0');
+                while ($other_changed[--$j]) {
+                    continue;
+                }
+                assert('$j >= 0 && !$other_changed[$j]');
+            }
+        }
+    }
+
+}
Index: /tags/3.1/wp-includes/Text/Diff/Engine/shell.php
===================================================================
--- /tags/3.1/wp-includes/Text/Diff/Engine/shell.php	(revision 17487)
+++ /tags/3.1/wp-includes/Text/Diff/Engine/shell.php	(revision 17487)
@@ -0,0 +1,162 @@
+<?php
+/**
+ * Class used internally by Diff to actually compute the diffs.
+ *
+ * This class uses the Unix `diff` program via shell_exec to compute the
+ * differences between the two input arrays.
+ *
+ * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did
+ * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
+ *
+ * @author  Milian Wolff <mail@milianw.de>
+ * @package Text_Diff
+ * @since   0.3.0
+ */
+class Text_Diff_Engine_shell {
+
+    /**
+     * Path to the diff executable
+     *
+     * @var string
+     */
+    var $_diffCommand = 'diff';
+
+    /**
+     * Returns the array of differences.
+     *
+     * @param array $from_lines lines of text from old file
+     * @param array $to_lines   lines of text from new file
+     *
+     * @return array all changes made (array with Text_Diff_Op_* objects)
+     */
+    function diff($from_lines, $to_lines)
+    {
+        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
+        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
+
+        $temp_dir = Text_Diff::_getTempDir();
+
+        // Execute gnu diff or similar to get a standard diff file.
+        $from_file = tempnam($temp_dir, 'Text_Diff');
+        $to_file = tempnam($temp_dir, 'Text_Diff');
+        $fp = fopen($from_file, 'w');
+        fwrite($fp, implode("\n", $from_lines));
+        fclose($fp);
+        $fp = fopen($to_file, 'w');
+        fwrite($fp, implode("\n", $to_lines));
+        fclose($fp);
+        $diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file);
+        unlink($from_file);
+        unlink($to_file);
+
+        if (is_null($diff)) {
+            // No changes were made
+            return array(new Text_Diff_Op_copy($from_lines));
+        }
+
+        $from_line_no = 1;
+        $to_line_no = 1;
+        $edits = array();
+
+        // Get changed lines by parsing something like:
+        // 0a1,2
+        // 1,2c4,6
+        // 1,5d6
+        preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff,
+            $matches, PREG_SET_ORDER);
+
+        foreach ($matches as $match) {
+            if (!isset($match[5])) {
+                // This paren is not set every time (see regex).
+                $match[5] = false;
+            }
+
+            if ($match[3] == 'a') {
+                $from_line_no--;
+            }
+
+            if ($match[3] == 'd') {
+                $to_line_no--;
+            }
+
+            if ($from_line_no < $match[1] || $to_line_no < $match[4]) {
+                // copied lines
+                assert('$match[1] - $from_line_no == $match[4] - $to_line_no');
+                array_push($edits,
+                    new Text_Diff_Op_copy(
+                        $this->_getLines($from_lines, $from_line_no, $match[1] - 1),
+                        $this->_getLines($to_lines, $to_line_no, $match[4] - 1)));
+            }
+
+            switch ($match[3]) {
+            case 'd':
+                // deleted lines
+                array_push($edits,
+                    new Text_Diff_Op_delete(
+                        $this->_getLines($from_lines, $from_line_no, $match[2])));
+                $to_line_no++;
+                break;
+
+            case 'c':
+                // changed lines
+                array_push($edits,
+                    new Text_Diff_Op_change(
+                        $this->_getLines($from_lines, $from_line_no, $match[2]),
+                        $this->_getLines($to_lines, $to_line_no, $match[5])));
+                break;
+
+            case 'a':
+                // added lines
+                array_push($edits,
+                    new Text_Diff_Op_add(
+                        $this->_getLines($to_lines, $to_line_no, $match[5])));
+                $from_line_no++;
+                break;
+            }
+        }
+
+        if (!empty($from_lines)) {
+            // Some lines might still be pending. Add them as copied
+            array_push($edits,
+                new Text_Diff_Op_copy(
+                    $this->_getLines($from_lines, $from_line_no,
+                                     $from_line_no + count($from_lines) - 1),
+                    $this->_getLines($to_lines, $to_line_no,
+                                     $to_line_no + count($to_lines) - 1)));
+        }
+
+        return $edits;
+    }
+
+    /**
+     * Get lines from either the old or new text
+     *
+     * @access private
+     *
+     * @param array &$text_lines Either $from_lines or $to_lines
+     * @param int   &$line_no    Current line number
+     * @param int   $end         Optional end line, when we want to chop more
+     *                           than one line.
+     *
+     * @return array The chopped lines
+     */
+    function _getLines(&$text_lines, &$line_no, $end = false)
+    {
+        if (!empty($end)) {
+            $lines = array();
+            // We can shift even more
+            while ($line_no <= $end) {
+                array_push($lines, array_shift($text_lines));
+                $line_no++;
+            }
+        } else {
+            $lines = array(array_shift($text_lines));
+            $line_no++;
+        }
+
+        return $lines;
+    }
+
+}
Index: /tags/3.1/wp-includes/Text/Diff/Engine/string.php
===================================================================
--- /tags/3.1/wp-includes/Text/Diff/Engine/string.php	(revision 17487)
+++ /tags/3.1/wp-includes/Text/Diff/Engine/string.php	(revision 17487)
@@ -0,0 +1,248 @@
+<?php
+/**
+ * Parses unified or context diffs output from eg. the diff utility.
+ *
+ * Example:
+ * <code>
+ * $patch = file_get_contents('example.patch');
+ * $diff = new Text_Diff('string', array($patch));
+ * $renderer = new Text_Diff_Renderer_inline();
+ * echo $renderer->render($diff);
+ * </code>
+ *
+ * Copyright 2005 Örjan Persson <o@42mm.org>
+ * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did
+ * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
+ *
+ * @author  Örjan Persson <o@42mm.org>
+ * @package Text_Diff
+ * @since   0.2.0
+ */
+class Text_Diff_Engine_string {
+
+    /**
+     * Parses a unified or context diff.
+     *
+     * First param contains the whole diff and the second can be used to force
+     * a specific diff type. If the second parameter is 'autodetect', the
+     * diff will be examined to find out which type of diff this is.
+     *
+     * @param string $diff  The diff content.
+     * @param string $mode  The diff mode of the content in $diff. One of
+     *                      'context', 'unified', or 'autodetect'.
+     *
+     * @return array  List of all diff operations.
+     */
+    function diff($diff, $mode = 'autodetect')
+    {
+        // Detect line breaks.
+        $lnbr = "\n";
+        if (strpos($diff, "\r\n") !== false) {
+            $lnbr = "\r\n";
+        } elseif (strpos($diff, "\r") !== false) {
+            $lnbr = "\r";
+        }
+
+        // Make sure we have a line break at the EOF.
+        if (substr($diff, -strlen($lnbr)) != $lnbr) {
+            $diff .= $lnbr;
+        }
+
+        if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') {
+            return PEAR::raiseError('Type of diff is unsupported');
+        }
+
+        if ($mode == 'autodetect') {
+            $context = strpos($diff, '***');
+            $unified = strpos($diff, '---');
+            if ($context === $unified) {
+                return PEAR::raiseError('Type of diff could not be detected');
+            } elseif ($context === false || $unified === false) {
+                $mode = $context !== false ? 'context' : 'unified';
+            } else {
+                $mode = $context < $unified ? 'context' : 'unified';
+            }
+        }
+
+        // Split by new line and remove the diff header, if there is one.
+        $diff = explode($lnbr, $diff);
+        if (($mode == 'context' && strpos($diff[0], '***') === 0) ||
+            ($mode == 'unified' && strpos($diff[0], '---') === 0)) {
+            array_shift($diff);
+            array_shift($diff);
+        }
+
+        if ($mode == 'context') {
+            return $this->parseContextDiff($diff);
+        } else {
+            return $this->parseUnifiedDiff($diff);
+        }
+    }
+
+    /**
+     * Parses an array containing the unified diff.
+     *
+     * @param array $diff  Array of lines.
+     *
+     * @return array  List of all diff operations.
+     */
+    function parseUnifiedDiff($diff)
+    {
+        $edits = array();
+        $end = count($diff) - 1;
+        for ($i = 0; $i < $end;) {
+            $diff1 = array();
+            switch (substr($diff[$i], 0, 1)) {
+            case ' ':
+                do {
+                    $diff1[] = substr($diff[$i], 1);
+                } while (++$i < $end && substr($diff[$i], 0, 1) == ' ');
+                $edits[] = &new Text_Diff_Op_copy($diff1);
+                break;
+
+            case '+':
+                // get all new lines
+                do {
+                    $diff1[] = substr($diff[$i], 1);
+                } while (++$i < $end && substr($diff[$i], 0, 1) == '+');
+                $edits[] = &new Text_Diff_Op_add($diff1);
+                break;
+
+            case '-':
+                // get changed or removed lines
+                $diff2 = array();
+                do {
+                    $diff1[] = substr($diff[$i], 1);
+                } while (++$i < $end && substr($diff[$i], 0, 1) == '-');
+
+                while ($i < $end && substr($diff[$i], 0, 1) == '+') {
+                    $diff2[] = substr($diff[$i++], 1);
+                }
+                if (count($diff2) == 0) {
+                    $edits[] = &new Text_Diff_Op_delete($diff1);
+                } else {
+                    $edits[] = &new Text_Diff_Op_change($diff1, $diff2);
+                }
+                break;
+
+            default:
+                $i++;
+                break;
+            }
+        }
+
+        return $edits;
+    }
+
+    /**
+     * Parses an array containing the context diff.
+     *
+     * @param array $diff  Array of lines.
+     *
+     * @return array  List of all diff operations.
+     */
+    function parseContextDiff(&$diff)
+    {
+        $edits = array();
+        $i = $max_i = $j = $max_j = 0;
+        $end = count($diff) - 1;
+        while ($i < $end && $j < $end) {
+            while ($i >= $max_i && $j >= $max_j) {
+                // Find the boundaries of the diff output of the two files
+                for ($i = $j;
+                     $i < $end && substr($diff[$i], 0, 3) == '***';
+                     $i++);
+                for ($max_i = $i;
+                     $max_i < $end && substr($diff[$max_i], 0, 3) != '---';
+                     $max_i++);
+                for ($j = $max_i;
+                     $j < $end && substr($diff[$j], 0, 3) == '---';
+                     $j++);
+                for ($max_j = $j;
+                     $max_j < $end && substr($diff[$max_j], 0, 3) != '***';
+                     $max_j++);
+            }
+
+            // find what hasn't been changed
+            $array = array();
+            while ($i < $max_i &&
+                   $j < $max_j &&
+                   strcmp($diff[$i], $diff[$j]) == 0) {
+                $array[] = substr($diff[$i], 2);
+                $i++;
+                $j++;
+            }
+
+            while ($i < $max_i && ($max_j-$j) <= 1) {
+                if ($diff[$i] != '' && substr($diff[$i], 0, 1) != ' ') {
+                    break;
+                }
+                $array[] = substr($diff[$i++], 2);
+            }
+
+            while ($j < $max_j && ($max_i-$i) <= 1) {
+                if ($diff[$j] != '' && substr($diff[$j], 0, 1) != ' ') {
+                    break;
+                }
+                $array[] = substr($diff[$j++], 2);
+            }
+            if (count($array) > 0) {
+                $edits[] = &new Text_Diff_Op_copy($array);
+            }
+
+            if ($i < $max_i) {
+                $diff1 = array();
+                switch (substr($diff[$i], 0, 1)) {
+                case '!':
+                    $diff2 = array();
+                    do {
+                        $diff1[] = substr($diff[$i], 2);
+                        if ($j < $max_j && substr($diff[$j], 0, 1) == '!') {
+                            $diff2[] = substr($diff[$j++], 2);
+                        }
+                    } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!');
+                    $edits[] = &new Text_Diff_Op_change($diff1, $diff2);
+                    break;
+
+                case '+':
+                    do {
+                        $diff1[] = substr($diff[$i], 2);
+                    } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+');
+                    $edits[] = &new Text_Diff_Op_add($diff1);
+                    break;
+
+                case '-':
+                    do {
+                        $diff1[] = substr($diff[$i], 2);
+                    } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-');
+                    $edits[] = &new Text_Diff_Op_delete($diff1);
+                    break;
+                }
+            }
+
+            if ($j < $max_j) {
+                $diff2 = array();
+                switch (substr($diff[$j], 0, 1)) {
+                case '+':
+                    do {
+                        $diff2[] = substr($diff[$j++], 2);
+                    } while ($j < $max_j && substr($diff[$j], 0, 1) == '+');
+                    $edits[] = &new Text_Diff_Op_add($diff2);
+                    break;
+
+                case '-':
+                    do {
+                        $diff2[] = substr($diff[$j++], 2);
+                    } while ($j < $max_j && substr($diff[$j], 0, 1) == '-');
+                    $edits[] = &new Text_Diff_Op_delete($diff2);
+                    break;
+                }
+            }
+        }
+
+        return $edits;
+    }
+
+}
Index: /tags/3.1/wp-includes/Text/Diff/Engine/xdiff.php
===================================================================
--- /tags/3.1/wp-includes/Text/Diff/Engine/xdiff.php	(revision 17487)
+++ /tags/3.1/wp-includes/Text/Diff/Engine/xdiff.php	(revision 17487)
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Class used internally by Diff to actually compute the diffs.
+ *
+ * This class uses the xdiff PECL package (http://pecl.php.net/package/xdiff)
+ * to compute the differences between the two input arrays.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did
+ * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
+ *
+ * @author  Jon Parise <jon@horde.org>
+ * @package Text_Diff
+ */
+class Text_Diff_Engine_xdiff {
+
+    /**
+     */
+    function diff($from_lines, $to_lines)
+    {
+        array_walk($from_lines, array('Text_Diff', 'trimNewlines'));
+        array_walk($to_lines, array('Text_Diff', 'trimNewlines'));
+
+        /* Convert the two input arrays into strings for xdiff processing. */
+        $from_string = implode("\n", $from_lines);
+        $to_string = implode("\n", $to_lines);
+
+        /* Diff the two strings and convert the result to an array. */
+        $diff = xdiff_string_diff($from_string, $to_string, count($to_lines));
+        $diff = explode("\n", $diff);
+
+        /* Walk through the diff one line at a time.  We build the $edits
+         * array of diff operations by reading the first character of the
+         * xdiff output (which is in the "unified diff" format).
+         *
+         * Note that we don't have enough information to detect "changed"
+         * lines using this approach, so we can't add Text_Diff_Op_changed
+         * instances to the $edits array.  The result is still perfectly
+         * valid, albeit a little less descriptive and efficient. */
+        $edits = array();
+        foreach ($diff as $line) {
+            if (!strlen($line)) {
+                continue;
+            }
+            switch ($line[0]) {
+            case ' ':
+                $edits[] = &new Text_Diff_Op_copy(array(substr($line, 1)));
+                break;
+
+            case '+':
+                $edits[] = &new Text_Diff_Op_add(array(substr($line, 1)));
+                break;
+
+            case '-':
+                $edits[] = &new Text_Diff_Op_delete(array(substr($line, 1)));
+                break;
+            }
+        }
+
+        return $edits;
+    }
+
+}
Index: /tags/3.1/wp-includes/Text/Diff/Renderer.php
===================================================================
--- /tags/3.1/wp-includes/Text/Diff/Renderer.php	(revision 17487)
+++ /tags/3.1/wp-includes/Text/Diff/Renderer.php	(revision 17487)
@@ -0,0 +1,235 @@
+<?php
+/**
+ * A class to render Diffs in different formats.
+ *
+ * This class renders the diff in classic diff format. It is intended that
+ * this class be customized via inheritance, to obtain fancier outputs.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did
+ * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
+ *
+ * @package Text_Diff
+ */
+class Text_Diff_Renderer {
+
+    /**
+     * Number of leading context "lines" to preserve.
+     *
+     * This should be left at zero for this class, but subclasses may want to
+     * set this to other values.
+     */
+    var $_leading_context_lines = 0;
+
+    /**
+     * Number of trailing context "lines" to preserve.
+     *
+     * This should be left at zero for this class, but subclasses may want to
+     * set this to other values.
+     */
+    var $_trailing_context_lines = 0;
+
+    /**
+     * Constructor.
+     */
+    function Text_Diff_Renderer($params = array())
+    {
+        foreach ($params as $param => $value) {
+            $v = '_' . $param;
+            if (isset($this->$v)) {
+                $this->$v = $value;
+            }
+        }
+    }
+
+    /**
+     * Get any renderer parameters.
+     *
+     * @return array  All parameters of this renderer object.
+     */
+    function getParams()
+    {
+        $params = array();
+        foreach (get_object_vars($this) as $k => $v) {
+            if ($k[0] == '_') {
+                $params[substr($k, 1)] = $v;
+            }
+        }
+
+        return $params;
+    }
+
+    /**
+     * Renders a diff.
+     *
+     * @param Text_Diff $diff  A Text_Diff object.
+     *
+     * @return string  The formatted output.
+     */
+    function render($diff)
+    {
+        $xi = $yi = 1;
+        $block = false;
+        $context = array();
+
+        $nlead = $this->_leading_context_lines;
+        $ntrail = $this->_trailing_context_lines;
+
+        $output = $this->_startDiff();
+
+        $diffs = $diff->getDiff();
+        foreach ($diffs as $i => $edit) {
+            /* If these are unchanged (copied) lines, and we want to keep
+             * leading or trailing context lines, extract them from the copy
+             * block. */
+            if (is_a($edit, 'Text_Diff_Op_copy')) {
+                /* Do we have any diff blocks yet? */
+                if (is_array($block)) {
+                    /* How many lines to keep as context from the copy
+                     * block. */
+                    $keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail;
+                    if (count($edit->orig) <= $keep) {
+                        /* We have less lines in the block than we want for
+                         * context => keep the whole block. */
+                        $block[] = $edit;
+                    } else {
+                        if ($ntrail) {
+                            /* Create a new block with as many lines as we need
+                             * for the trailing context. */
+                            $context = array_slice($edit->orig, 0, $ntrail);
+                            $block[] = &new Text_Diff_Op_copy($context);
+                        }
+                        /* @todo */
+                        $output .= $this->_block($x0, $ntrail + $xi - $x0,
+                                                 $y0, $ntrail + $yi - $y0,
+                                                 $block);
+                        $block = false;
+                    }
+                }
+                /* Keep the copy block as the context for the next block. */
+                $context = $edit->orig;
+            } else {
+                /* Don't we have any diff blocks yet? */
+                if (!is_array($block)) {
+                    /* Extract context lines from the preceding copy block. */
+                    $context = array_slice($context, count($context) - $nlead);
+                    $x0 = $xi - count($context);
+                    $y0 = $yi - count($context);
+                    $block = array();
+                    if ($context) {
+                        $block[] = &new Text_Diff_Op_copy($context);
+                    }
+                }
+                $block[] = $edit;
+            }
+
+            if ($edit->orig) {
+                $xi += count($edit->orig);
+            }
+            if ($edit->final) {
+                $yi += count($edit->final);
+            }
+        }
+
+        if (is_array($block)) {
+            $output .= $this->_block($x0, $xi - $x0,
+                                     $y0, $yi - $y0,
+                                     $block);
+        }
+
+        return $output . $this->_endDiff();
+    }
+
+    function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)
+    {
+        $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));
+
+        foreach ($edits as $edit) {
+            switch (strtolower(get_class($edit))) {
+            case 'text_diff_op_copy':
+                $output .= $this->_context($edit->orig);
+                break;
+
+            case 'text_diff_op_add':
+                $output .= $this->_added($edit->final);
+                break;
+
+            case 'text_diff_op_delete':
+                $output .= $this->_deleted($edit->orig);
+                break;
+
+            case 'text_diff_op_change':
+                $output .= $this->_changed($edit->orig, $edit->final);
+                break;
+            }
+        }
+
+        return $output . $this->_endBlock();
+    }
+
+    function _startDiff()
+    {
+        return '';
+    }
+
+    function _endDiff()
+    {
+        return '';
+    }
+
+    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
+    {
+        if ($xlen > 1) {
+            $xbeg .= ',' . ($xbeg + $xlen - 1);
+        }
+        if ($ylen > 1) {
+            $ybeg .= ',' . ($ybeg + $ylen - 1);
+        }
+
+        // this matches the GNU Diff behaviour
+        if ($xlen && !$ylen) {
+            $ybeg--;
+        } elseif (!$xlen) {
+            $xbeg--;
+        }
+
+        return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;
+    }
+
+    function _startBlock($header)
+    {
+        return $header . "\n";
+    }
+
+    function _endBlock()
+    {
+        return '';
+    }
+
+    function _lines($lines, $prefix = ' ')
+    {
+        return $prefix . implode("\n$prefix", $lines) . "\n";
+    }
+
+    function _context($lines)
+    {
+        return $this->_lines($lines, '  ');
+    }
+
+    function _added($lines)
+    {
+        return $this->_lines($lines, '> ');
+    }
+
+    function _deleted($lines)
+    {
+        return $this->_lines($lines, '< ');
+    }
+
+    function _changed($orig, $final)
+    {
+        return $this->_deleted($orig) . "---\n" . $this->_added($final);
+    }
+
+}
Index: /tags/3.1/wp-includes/Text/Diff/Renderer/inline.php
===================================================================
--- /tags/3.1/wp-includes/Text/Diff/Renderer/inline.php	(revision 17487)
+++ /tags/3.1/wp-includes/Text/Diff/Renderer/inline.php	(revision 17487)
@@ -0,0 +1,206 @@
+<?php
+/**
+ * "Inline" diff renderer.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you did
+ * not receive this file, see http://opensource.org/licenses/lgpl-license.php.
+ *
+ * @author  Ciprian Popovici
+ * @package Text_Diff
+ */
+
+/** Text_Diff_Renderer */
+
+// WP #7391
+require_once dirname(dirname(__FILE__)) . '/Renderer.php';
+
+/**
+ * "Inline" diff renderer.
+ *
+ * This class renders diffs in the Wiki-style "inline" format.
+ *
+ * @author  Ciprian Popovici
+ * @package Text_Diff
+ */
+class Text_Diff_Renderer_inline extends Text_Diff_Renderer {
+
+    /**
+     * Number of leading context "lines" to preserve.
+     *
+     * @var integer
+     */
+    var $_leading_context_lines = 10000;
+
+    /**
+     * Number of trailing context "lines" to preserve.
+     *
+     * @var integer
+     */
+    var $_trailing_context_lines = 10000;
+
+    /**
+     * Prefix for inserted text.
+     *
+     * @var string
+     */
+    var $_ins_prefix = '<ins>';
+
+    /**
+     * Suffix for inserted text.
+     *
+     * @var string
+     */
+    var $_ins_suffix = '</ins>';
+
+    /**
+     * Prefix for deleted text.
+     *
+     * @var string
+     */
+    var $_del_prefix = '<del>';
+
+    /**
+     * Suffix for deleted text.
+     *
+     * @var string
+     */
+    var $_del_suffix = '</del>';
+
+    /**
+     * Header for each change block.
+     *
+     * @var string
+     */
+    var $_block_header = '';
+
+    /**
+     * Whether to split down to character-level.
+     *
+     * @var boolean
+     */
+    var $_split_characters = false;
+
+    /**
+     * What are we currently splitting on? Used to recurse to show word-level
+     * or character-level changes.
+     *
+     * @var string
+     */
+    var $_split_level = 'lines';
+
+    function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
+    {
+        return $this->_block_header;
+    }
+
+    function _startBlock($header)
+    {
+        return $header;
+    }
+
+    function _lines($lines, $prefix = ' ', $encode = true)
+    {
+        if ($encode) {
+            array_walk($lines, array(&$this, '_encode'));
+        }
+
+        if ($this->_split_level == 'lines') {
+            return implode("\n", $lines) . "\n";
+        } else {
+            return implode('', $lines);
+        }
+    }
+
+    function _added($lines)
+    {
+        array_walk($lines, array(&$this, '_encode'));
+        $lines[0] = $this->_ins_prefix . $lines[0];
+        $lines[count($lines) - 1] .= $this->_ins_suffix;
+        return $this->_lines($lines, ' ', false);
+    }
+
+    function _deleted($lines, $words = false)
+    {
+        array_walk($lines, array(&$this, '_encode'));
+        $lines[0] = $this->_del_prefix . $lines[0];
+        $lines[count($lines) - 1] .= $this->_del_suffix;
+        return $this->_lines($lines, ' ', false);
+    }
+
+    function _changed($orig, $final)
+    {
+        /* If we've already split on characters, just display. */
+        if ($this->_split_level == 'characters') {
+            return $this->_deleted($orig)
+                . $this->_added($final);
+        }
+
+        /* If we've already split on words, just display. */
+        if ($this->_split_level == 'words') {
+            $prefix = '';
+            while ($orig[0] !== false && $final[0] !== false &&
+                   substr($orig[0], 0, 1) == ' ' &&
+                   substr($final[0], 0, 1) == ' ') {
+                $prefix .= substr($orig[0], 0, 1);
+                $orig[0] = substr($orig[0], 1);
+                $final[0] = substr($final[0], 1);
+            }
+            return $prefix . $this->_deleted($orig) . $this->_added($final);
+        }
+
+        $text1 = implode("\n", $orig);
+        $text2 = implode("\n", $final);
+
+        /* Non-printing newline marker. */
+        $nl = "\0";
+
+        if ($this->_split_characters) {
+            $diff = new Text_Diff('native',
+                                  array(preg_split('//', $text1),
+                                        preg_split('//', $text2)));
+        } else {
+            /* We want to split on word boundaries, but we need to preserve
+             * whitespace as well. Therefore we split on words, but include
+             * all blocks of whitespace in the wordlist. */
+            $diff = new Text_Diff('native',
+                                  array($this->_splitOnWords($text1, $nl),
+                                        $this->_splitOnWords($text2, $nl)));
+        }
+
+        /* Get the diff in inline format. */
+        $renderer = new Text_Diff_Renderer_inline
+            (array_merge($this->getParams(),
+                         array('split_level' => $this->_split_characters ? 'characters' : 'words')));
+
+        /* Run the diff and get the output. */
+        return str_replace($nl, "\n", $renderer->render($diff)) . "\n";
+    }
+
+    function _splitOnWords($string, $newlineEscape = "\n")
+    {
+        // Ignore \0; otherwise the while loop will never finish.
+        $string = str_replace("\0", '', $string);
+
+        $words = array();
+        $length = strlen($string);
+        $pos = 0;
+
+        while ($pos < $length) {
+            // Eat a word with any preceding whitespace.
+            $spaces = strspn(substr($string, $pos), " \n");
+            $nextpos = strcspn(substr($string, $pos + $spaces), " \n");
+            $words[] = str_replace("\n", $newlineEscape, substr($string, $pos, $spaces + $nextpos));
+            $pos += $spaces + $nextpos;
+        }
+
+        return $words;
+    }
+
+    function _encode(&$string)
+    {
+        $string = htmlspecialchars($string);
+    }
+
+}
Index: /tags/3.1/wp-includes/admin-bar.php
===================================================================
--- /tags/3.1/wp-includes/admin-bar.php	(revision 17487)
+++ /tags/3.1/wp-includes/admin-bar.php	(revision 17487)
@@ -0,0 +1,378 @@
+<?php
+/**
+ * Admin Bar
+ *
+ * This code handles the building and rendering of the press bar.
+ */
+
+/**
+ * Instantiate the admin bar object and set it up as a global for access elsewhere.
+ *
+ * To hide the admin bar, you're looking in the wrong place. Unhooking this function will not
+ * properly remove the admin bar. For that, use show_admin_bar(false) or the show_admin_bar filter.
+ *
+ * @since 3.1.0
+ * @access private
+ * @return bool Whether the admin bar was successfully initialized.
+ */
+function _wp_admin_bar_init() {
+	global $wp_admin_bar;
+
+	if ( ! is_admin_bar_showing() )
+		return false;
+
+	/* Load the admin bar class code ready for instantiation */
+	require( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
+
+	/* Instantiate the admin bar */
+	$admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
+	if ( class_exists( $admin_bar_class ) )
+		$wp_admin_bar = new $admin_bar_class;
+	else
+		return false;
+
+	$wp_admin_bar->initialize();
+	$wp_admin_bar->add_menus();
+
+	return true;
+}
+add_action( 'init', '_wp_admin_bar_init' ); // Don't remove. Wrong way to disable.
+
+/**
+ * Render the admin bar to the page based on the $wp_admin_bar->menu member var.
+ * This is called very late on the footer actions so that it will render after anything else being
+ * added to the footer.
+ *
+ * It includes the action "admin_bar_menu" which should be used to hook in and
+ * add new menus to the admin bar. That way you can be sure that you are adding at most optimal point,
+ * right before the admin bar is rendered. This also gives you access to the $post global, among others.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_render() {
+	global $wp_admin_bar;
+
+	if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) )
+		return false;
+
+	$wp_admin_bar->load_user_locale_translations();
+
+	do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) );
+
+	do_action( 'wp_before_admin_bar_render' );
+
+	$wp_admin_bar->render();
+
+	do_action( 'wp_after_admin_bar_render' );
+
+	$wp_admin_bar->unload_user_locale_translations();
+}
+add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
+add_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
+
+/**
+ * Add the "My Account" menu and all submenus.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_my_account_menu() {
+	global $wp_admin_bar, $user_identity;
+
+	$user_id = get_current_user_id();
+
+	if ( 0 != $user_id ) {
+		/* Add the 'My Account' menu */
+		$avatar = get_avatar( get_current_user_id(), 16 );
+		$id = ( ! empty( $avatar ) ) ? 'my-account-with-avatar' : 'my-account';
+
+		$wp_admin_bar->add_menu( array( 'id' => $id, 'title' => $avatar . $user_identity,  'href' => get_edit_profile_url( $user_id ) ) );
+
+		/* Add the "My Account" sub menus */
+		$wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Edit My Profile' ), 'href' => get_edit_profile_url( $user_id ) ) );
+		if ( is_multisite() )
+			$wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) );
+		else
+			$wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Dashboard' ), 'href' => admin_url() ) );
+		$wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) );
+	}
+}
+
+/**
+ * Add the "My Sites/[Site Name]" menu and all submenus.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_my_sites_menu() {
+	global $wpdb, $wp_admin_bar;
+
+	/* Add the 'My Sites' menu if the user has more than one site. */
+	if ( count( $wp_admin_bar->user->blogs ) <= 1 )
+		return;
+
+	$wp_admin_bar->add_menu( array(  'id' => 'my-blogs', 'title' => __( 'My Sites' ),  'href' => admin_url( 'my-sites.php' ) ) );
+
+	$default = includes_url('images/wpmini-blue.png');
+
+	foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
+		// @todo Replace with some favicon lookup.
+		//$blavatar = '<img src="' . esc_url( blavatar_url( blavatar_domain( $blog->siteurl ), 'img', 16, $default ) ) . '" alt="Blavatar" width="16" height="16" />';
+		$blavatar = '<img src="' . esc_url($default) . '" alt="' . esc_attr__( 'Blavatar' ) . '" width="16" height="16" class="blavatar"/>';
+
+		$blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname;
+
+		$wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname,  'href' => get_admin_url($blog->userblog_id) ) );
+		$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => get_admin_url($blog->userblog_id) ) );
+
+		if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) ) {
+			$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => get_admin_url($blog->userblog_id, 'post-new.php') ) );
+			$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url($blog->userblog_id, 'edit-comments.php') ) );
+		}
+
+		$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Visit Site' ), 'href' => get_home_url($blog->userblog_id) ) );
+	}
+}
+
+/**
+ * Provide a shortlink.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_shortlink_menu() {
+	global $wp_admin_bar;
+
+	$short = wp_get_shortlink( 0, 'query' );
+	$id = 'get-shortlink';
+
+	if ( empty( $short ) )
+		return;
+
+	$html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />';
+
+	$wp_admin_bar->add_menu( array(
+		'id' => $id,
+		'title' => __( 'Shortlink' ),
+		'href' => $short,
+		'meta' => array( 'html' => $html ),
+	) );
+}
+
+/**
+ * Provide an edit link for posts and terms.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_edit_menu () {
+	global $wp_admin_bar;
+
+	$current_object = get_queried_object();
+
+	if ( empty($current_object) )
+		return;
+
+	if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) && $post_type_object->show_ui ) {
+		$wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $post_type_object->labels->edit_item,  'href' => get_edit_post_link( $current_object->ID ) ) );
+	} elseif ( ! empty( $current_object->taxonomy ) &&  ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) && $tax->show_ui ) {
+		$wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => $tax->labels->edit_item, 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) );
+	}
+}
+
+/**
+ * Add "Add New" menu.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_new_content_menu() {
+	global $wp_admin_bar;
+
+	$actions = array();
+	foreach ( (array) get_post_types( array( 'show_ui' => true ), 'objects' ) as $ptype_obj ) {
+		if ( true !== $ptype_obj->show_in_menu || ! current_user_can( $ptype_obj->cap->edit_posts ) )
+			continue;
+
+		$actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name );
+	}
+
+	if ( empty( $actions ) )
+		return;
+
+	$wp_admin_bar->add_menu( array( 'id' => 'new-content', 'title' => _x( 'Add New', 'admin bar menu group label' ), 'href' => admin_url( array_shift( array_keys( $actions ) ) ) ) );
+
+	foreach ( $actions as $link => $action ) {
+		$wp_admin_bar->add_menu( array( 'parent' => 'new-content', 'id' => $action[2], 'title' => $action[0], 'href' => admin_url($link) ) );
+	}
+}
+
+/**
+ * Add edit comments link with awaiting moderation count bubble.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_comments_menu() {
+	global $wp_admin_bar;
+
+	if ( !current_user_can('edit_posts') )
+		return;
+
+	$awaiting_mod = wp_count_comments();
+	$awaiting_mod = $awaiting_mod->moderated;
+
+	$awaiting_mod = $awaiting_mod ? "<span id='ab-awaiting-mod' class='pending-count'>" . number_format_i18n( $awaiting_mod ) . "</span>" : '';
+	$wp_admin_bar->add_menu( array( 'id' => 'comments', 'title' => sprintf( __('Comments %s'), $awaiting_mod ), 'href' => admin_url('edit-comments.php') ) );
+}
+
+/**
+ * Add "Appearance" menu with widget and nav menu submenu.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_appearance_menu() {
+	global $wp_admin_bar;
+
+	if ( !current_user_can('switch_themes') )
+		return;
+
+	$wp_admin_bar->add_menu( array( 'id' => 'appearance', 'title' => __('Appearance'), 'href' => admin_url('themes.php') ) );
+
+	if ( !current_user_can('edit_theme_options') )
+		return;
+
+	if ( current_theme_supports( 'widgets' )  )
+		$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __('Widgets'), 'href' => admin_url('widgets.php') ) );
+
+	 if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
+		$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) );
+}
+
+/**
+ * Provide an update link if theme/plugin/core updates are available.
+ *
+ * @since 3.1.0
+ */
+function wp_admin_bar_updates_menu() {
+	global $wp_admin_bar;
+
+	if ( !current_user_can('install_plugins') )
+		return;
+
+	$plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
+	$update_plugins = get_site_transient( 'update_plugins' );
+	if ( !empty($update_plugins->response) )
+		$plugin_update_count = count( $update_plugins->response );
+	$update_themes = get_site_transient( 'update_themes' );
+	if ( !empty($update_themes->response) )
+		$theme_update_count = count( $update_themes->response );
+	/* @todo get_core_updates() is only available on admin page loads
+	$update_wordpress = get_core_updates( array('dismissed' => false) );
+	if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
+		$wordpress_update_count = 1;
+	*/
+
+	$update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
+
+	if ( !$update_count )
+		return;
+
+	$update_title = array();
+	if ( $wordpress_update_count )
+		$update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);
+	if ( $plugin_update_count )
+		$update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);
+	if ( $theme_update_count )
+		$update_title[] = sprintf(_n('%d Theme Update', '%d Themes Updates', $theme_update_count), $theme_update_count);
+
+	$update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';
+
+	$update_title = "<span title='$update_title'>";
+	$update_title .= sprintf( __('Updates %s'), "<span id='ab-updates' class='update-count'>" . number_format_i18n($update_count) . '</span>' );
+	$update_title .= '</span>';
+
+	$wp_admin_bar->add_menu( array( 'id' => 'updates', 'title' => $update_title, 'href' => network_admin_url( 'update-core.php' ) ) );
+}
+
+/**
+ * Style and scripts for the admin bar.
+ *
+ * @since 3.1.0
+ *
+ */
+function wp_admin_bar_header() { ?>
+<style type="text/css" media="print">#wpadminbar { display:none; }</style>
+<?php
+}
+
+/**
+ * Default admin bar callback.
+ *
+ * @since 3.1.0
+ *
+ */
+function _admin_bar_bump_cb() { ?>
+<style type="text/css">
+	html { margin-top: 28px !important; }
+	* html body { margin-top: 28px !important; }
+</style>
+<?php
+}
+
+/**
+ * Set the display status of the admin bar
+ *
+ * This can be called immediately upon plugin load.  It does not need to be called from a function hooked to the init action.
+ *
+ * @since 3.1.0
+ *
+ * @param bool $show Whether to allow the admin bar to show.
+ * @return void
+ */
+function show_admin_bar( $show ) {
+	global $show_admin_bar;
+	$show_admin_bar = (bool) $show;
+}
+
+/**
+ * Determine whether the admin bar should be showing.
+ *
+ * @since 3.1.0
+ *
+ * @return bool Whether the admin bar should be showing.
+ */
+function is_admin_bar_showing() {
+	global $show_admin_bar;
+
+	/* For all these types of request we never want an admin bar period */
+	if ( defined('XMLRPC_REQUEST') || defined('APP_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') )
+		return false;
+
+	if ( ! isset( $show_admin_bar ) ) {
+		if ( ! is_user_logged_in() ) {
+			$show_admin_bar = false;
+		} else {
+			$context = is_admin() ? 'admin' : 'front';
+			$show_admin_bar = _get_admin_bar_pref( $context );
+		}
+	}
+
+	$show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar );
+
+	return $show_admin_bar;
+}
+
+/**
+ * Retrieve the admin bar display preference of a user based on context.
+ *
+ * @since 3.1.0
+ * @access private
+ *
+ * @param string $context Context of this preference check, either 'admin' or 'front'
+ * @param int $user Optional. ID of the user to check, defaults to 0 for current user
+ * @return bool Whether the admin bar should be showing for this user
+ */
+function _get_admin_bar_pref( $context, $user = 0 ) {
+	$pref = get_user_option( "show_admin_bar_{$context}", $user );
+	if ( false === $pref )
+		return 'admin' != $context || is_multisite();
+
+	return 'true' === $pref;
+}
+
+?>
Index: /tags/3.1/wp-includes/atomlib.php
===================================================================
--- /tags/3.1/wp-includes/atomlib.php	(revision 17487)
+++ /tags/3.1/wp-includes/atomlib.php	(revision 17487)
@@ -0,0 +1,354 @@
+<?php
+/**
+ * Atom Syndication Format PHP Library
+ *
+ * @package AtomLib
+ * @link http://code.google.com/p/phpatomlib/
+ *
+ * @author Elias Torres <elias@torrez.us>
+ * @version 0.4
+ * @since 2.3
+ */
+
+/**
+ * Structure that store common Atom Feed Properties
+ *
+ * @package AtomLib
+ */
+class AtomFeed {
+	/**
+	 * Stores Links
+	 * @var array
+	 * @access public
+	 */
+    var $links = array();
+    /**
+     * Stores Categories
+     * @var array
+     * @access public
+     */
+    var $categories = array();
+	/**
+	 * Stores Entries
+	 *
+	 * @var array
+	 * @access public
+	 */
+    var $entries = array();
+}
+
+/**
+ * Structure that store Atom Entry Properties
+ *
+ * @package AtomLib
+ */
+class AtomEntry {
+	/**
+	 * Stores Links
+	 * @var array
+	 * @access public
+	 */
+    var $links = array();
+    /**
+     * Stores Categories
+     * @var array
+	 * @access public
+     */
+    var $categories = array();
+}
+
+/**
+ * AtomLib Atom Parser API
+ *
+ * @package AtomLib
+ */
+class AtomParser {
+
+    var $NS = 'http://www.w3.org/2005/Atom';
+    var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights');
+    var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft');
+
+    var $debug = false;
+
+    var $depth = 0;
+    var $indent = 2;
+    var $in_content;
+    var $ns_contexts = array();
+    var $ns_decls = array();
+    var $content_ns_decls = array();
+    var $content_ns_contexts = array();
+    var $is_xhtml = false;
+    var $is_html = false;
+    var $is_text = true;
+    var $skipped_div = false;
+
+    var $FILE = "php://input";
+
+    var $feed;
+    var $current;
+
+    function AtomParser() {
+
+        $this->feed = new AtomFeed();
+        $this->current = null;
+        $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
+        $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');
+    }
+
+    function _p($msg) {
+        if($this->debug) {
+            print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
+        }
+    }
+
+    function error_handler($log_level, $log_text, $error_file, $error_line) {
+        $this->error = $log_text;
+    }
+
+    function parse() {
+
+        set_error_handler(array(&$this, 'error_handler'));
+
+        array_unshift($this->ns_contexts, array());
+
+        $parser = xml_parser_create_ns();
+        xml_set_object($parser, $this);
+        xml_set_element_handler($parser, "start_element", "end_element");
+        xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+        xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
+        xml_set_character_data_handler($parser, "cdata");
+        xml_set_default_handler($parser, "_default");
+        xml_set_start_namespace_decl_handler($parser, "start_ns");
+        xml_set_end_namespace_decl_handler($parser, "end_ns");
+
+        $this->content = '';
+
+        $ret = true;
+
+        $fp = fopen($this->FILE, "r");
+        while ($data = fread($fp, 4096)) {
+            if($this->debug) $this->content .= $data;
+
+            if(!xml_parse($parser, $data, feof($fp))) {
+                trigger_error(sprintf(__('XML error: %s at line %d')."\n",
+                    xml_error_string(xml_get_error_code($xml_parser)),
+                    xml_get_current_line_number($xml_parser)));
+                $ret = false;
+                break;
+            }
+        }
+        fclose($fp);
+
+        xml_parser_free($parser);
+
+        restore_error_handler();
+
+        return $ret;
+    }
+
+    function start_element($parser, $name, $attrs) {
+
+        $tag = array_pop(split(":", $name));
+
+        switch($name) {
+            case $this->NS . ':feed':
+                $this->current = $this->feed;
+                break;
+            case $this->NS . ':entry':
+                $this->current = new AtomEntry();
+                break;
+        };
+
+        $this->_p("start_element('$name')");
+        #$this->_p(print_r($this->ns_contexts,true));
+        #$this->_p('current(' . $this->current . ')');
+
+        array_unshift($this->ns_contexts, $this->ns_decls);
+
+        $this->depth++;
+
+        if(!empty($this->in_content)) {
+
+            $this->content_ns_decls = array();
+
+            if($this->is_html || $this->is_text)
+                trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup.");
+
+            $attrs_prefix = array();
+
+            // resolve prefixes for attributes
+            foreach($attrs as $key => $value) {
+                $with_prefix = $this->ns_to_prefix($key, true);
+                $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value);
+            }
+
+            $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
+            if(strlen($attrs_str) > 0) {
+                $attrs_str = " " . $attrs_str;
+            }
+
+            $with_prefix = $this->ns_to_prefix($name);
+
+            if(!$this->is_declared_content_ns($with_prefix[0])) {
+                array_push($this->content_ns_decls, $with_prefix[0]);
+            }
+
+            $xmlns_str = '';
+            if(count($this->content_ns_decls) > 0) {
+                array_unshift($this->content_ns_contexts, $this->content_ns_decls);
+                $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0])));
+                if(strlen($xmlns_str) > 0) {
+                    $xmlns_str = " " . $xmlns_str;
+                }
+            }
+
+            array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">"));
+
+        } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
+            $this->in_content = array();
+            $this->is_xhtml = $attrs['type'] == 'xhtml';
+            $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html';
+            $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text';
+            $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type']));
+
+            if(in_array('src',array_keys($attrs))) {
+                $this->current->$tag = $attrs;
+            } else {
+                array_push($this->in_content, array($tag,$this->depth, $type));
+            }
+        } else if($tag == 'link') {
+            array_push($this->current->links, $attrs);
+        } else if($tag == 'category') {
+            array_push($this->current->categories, $attrs);
+        }
+
+        $this->ns_decls = array();
+    }
+
+    function end_element($parser, $name) {
+
+        $tag = array_pop(split(":", $name));
+
+        $ccount = count($this->in_content);
+
+        # if we are *in* content, then let's proceed to serialize it
+        if(!empty($this->in_content)) {
+            # if we are ending the original content element
+            # then let's finalize the content
+            if($this->in_content[0][0] == $tag &&
+                $this->in_content[0][1] == $this->depth) {
+                $origtype = $this->in_content[0][2];
+                array_shift($this->in_content);
+                $newcontent = array();
+                foreach($this->in_content as $c) {
+                    if(count($c) == 3) {
+                        array_push($newcontent, $c[2]);
+                    } else {
+                        if($this->is_xhtml || $this->is_text) {
+                            array_push($newcontent, $this->xml_escape($c));
+                        } else {
+                            array_push($newcontent, $c);
+                        }
+                    }
+                }
+                if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
+                    $this->current->$tag = array($origtype, join('',$newcontent));
+                } else {
+                    $this->current->$tag = join('',$newcontent);
+                }
+                $this->in_content = array();
+            } else if($this->in_content[$ccount-1][0] == $tag &&
+                $this->in_content[$ccount-1][1] == $this->depth) {
+                $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
+            } else {
+                # else, just finalize the current element's content
+                $endtag = $this->ns_to_prefix($name);
+                array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>"));
+            }
+        }
+
+        array_shift($this->ns_contexts);
+
+        $this->depth--;
+
+        if($name == ($this->NS . ':entry')) {
+            array_push($this->feed->entries, $this->current);
+            $this->current = null;
+        }
+
+        $this->_p("end_element('$name')");
+    }
+
+    function start_ns($parser, $prefix, $uri) {
+        $this->_p("starting: " . $prefix . ":" . $uri);
+        array_push($this->ns_decls, array($prefix,$uri));
+    }
+
+    function end_ns($parser, $prefix) {
+        $this->_p("ending: #" . $prefix . "#");
+    }
+
+    function cdata($parser, $data) {
+        $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#");
+        if(!empty($this->in_content)) {
+            array_push($this->in_content, $data);
+        }
+    }
+
+    function _default($parser, $data) {
+        # when does this gets called?
+    }
+
+
+    function ns_to_prefix($qname, $attr=false) {
+        # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div')
+        $components = split(":", $qname);
+
+        # grab the last one (e.g 'div')
+        $name = array_pop($components);
+
+        if(!empty($components)) {
+            # re-join back the namespace component
+            $ns = join(":",$components);
+            foreach($this->ns_contexts as $context) {
+                foreach($context as $mapping) {
+                    if($mapping[1] == $ns && strlen($mapping[0]) > 0) {
+                        return array($mapping, "$mapping[0]:$name");
+                    }
+                }
+            }
+        }
+
+        if($attr) {
+            return array(null, $name);
+        } else {
+            foreach($this->ns_contexts as $context) {
+                foreach($context as $mapping) {
+                    if(strlen($mapping[0]) == 0) {
+                        return array($mapping, $name);
+                    }
+                }
+            }
+        }
+    }
+
+    function is_declared_content_ns($new_mapping) {
+        foreach($this->content_ns_contexts as $context) {
+            foreach($context as $mapping) {
+                if($new_mapping == $mapping) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    function xml_escape($string)
+    {
+             return str_replace(array('&','"',"'",'<','>'),
+                array('&amp;','&quot;','&apos;','&lt;','&gt;'),
+                $string );
+    }
+}
+
+?>
Index: /tags/3.1/wp-includes/author-template.php
===================================================================
--- /tags/3.1/wp-includes/author-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/author-template.php	(revision 17487)
@@ -0,0 +1,369 @@
+<?php
+/**
+ * Author Template functions for use in themes.
+ *
+ * These functions must be used within the WordPress Loop.
+ *
+ * @link http://codex.wordpress.org/Author_Templates
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Retrieve the author of the current post.
+ *
+ * @since 1.5
+ * @uses $authordata The current author's DB object.
+ * @uses apply_filters() Calls 'the_author' hook on the author display name.
+ *
+ * @param string $deprecated Deprecated.
+ * @return string The author's display name.
+ */
+function get_the_author($deprecated = '') {
+	global $authordata;
+
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.1' );
+
+	return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null);
+}
+
+/**
+ * Display the name of the author of the current post.
+ *
+ * The behavior of this function is based off of old functionality predating
+ * get_the_author(). This function is not deprecated, but is designed to echo
+ * the value from get_the_author() and as an result of any old theme that might
+ * still use the old behavior will also pass the value from get_the_author().
+ *
+ * The normal, expected behavior of this function is to echo the author and not
+ * return it. However, backwards compatiability has to be maintained.
+ *
+ * @since 0.71
+ * @see get_the_author()
+ * @link http://codex.wordpress.org/Template_Tags/the_author
+ *
+ * @param string $deprecated Deprecated.
+ * @param string $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it.
+ * @return string The author's display name, from get_the_author().
+ */
+function the_author( $deprecated = '', $deprecated_echo = true ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.1' );
+	if ( $deprecated_echo !== true )
+		_deprecated_argument( __FUNCTION__, '1.5', __('Use <code>get_the_author()</code> instead if you do not want the value echoed.') );
+	if ( $deprecated_echo )
+		echo get_the_author();
+	return get_the_author();
+}
+
+/**
+ * Retrieve the author who last edited the current post.
+ *
+ * @since 2.8
+ * @uses $post The current post's DB object.
+ * @uses get_post_meta() Retrieves the ID of the author who last edited the current post.
+ * @uses get_userdata() Retrieves the author's DB object.
+ * @uses apply_filters() Calls 'the_modified_author' hook on the author display name.
+ * @return string The author's display name.
+ */
+function get_the_modified_author() {
+	global $post;
+	if ( $last_id = get_post_meta($post->ID, '_edit_last', true) ) {
+		$last_user = get_userdata($last_id);
+		return apply_filters('the_modified_author', $last_user->display_name);
+	}
+}
+
+/**
+ * Display the name of the author who last edited the current post.
+ *
+ * @since 2.8
+ * @see get_the_author()
+ * @return string The author's display name, from get_the_modified_author().
+ */
+function the_modified_author() {
+	echo get_the_modified_author();
+}
+
+/**
+ * Retrieve the requested data of the author of the current post.
+ * @link http://codex.wordpress.org/Template_Tags/the_author_meta
+ * @since 2.8.0
+ * @uses $authordata The current author's DB object (if $user_id not specified).
+ * @param string $field selects the field of the users record.
+ * @param int $user_id Optional. User ID.
+ * @return string The author's field from the current author's DB object.
+ */
+function get_the_author_meta($field = '', $user_id = false) {
+	if ( ! $user_id )
+		global $authordata;
+	else
+		$authordata = get_userdata( $user_id );
+
+	// Keys used as object vars cannot have dashes.
+	$field = str_replace('-', '', $field);
+	$field = strtolower($field);
+	$user_field = "user_$field";
+
+	if ( 'id' == $field )
+		$value = isset($authordata->ID) ? (int)$authordata->ID : 0;
+	elseif ( isset($authordata->$user_field) )
+		$value = $authordata->$user_field;
+	else
+		$value = isset($authordata->$field) ? $authordata->$field : '';
+
+	return apply_filters('get_the_author_' . $field, $value, $user_id);
+}
+
+/**
+ * Retrieve the requested data of the author of the current post.
+ * @link http://codex.wordpress.org/Template_Tags/the_author_meta
+ * @since 2.8.0
+ * @param string $field selects the field of the users record.
+ * @param int $user_id Optional. User ID.
+ * @echo string The author's field from the current author's DB object.
+ */
+function the_author_meta($field = '', $user_id = false) {
+	echo apply_filters('the_author_' . $field, get_the_author_meta($field, $user_id), $user_id);
+}
+
+/**
+ * Retrieve either author's link or author's name.
+ *
+ * If the author has a home page set, return an HTML link, otherwise just return the
+ * author's name.
+ *
+ * @uses get_the_author_meta()
+ * @uses get_the_author()
+ */
+function get_the_author_link() {
+	if ( get_the_author_meta('url') ) {
+		return '<a href="' . get_the_author_meta('url') . '" title="' . esc_attr( sprintf(__("Visit %s&#8217;s website"), get_the_author()) ) . '" rel="external">' . get_the_author() . '</a>';
+	} else {
+		return get_the_author();
+	}
+}
+
+/**
+ * Display either author's link or author's name.
+ *
+ * If the author has a home page set, echo an HTML link, otherwise just echo the
+ * author's name.
+ *
+ * @link http://codex.wordpress.org/Template_Tags/the_author_link
+ * @since 2.1
+ * @uses get_the_author_link()
+ */
+function the_author_link() {
+	echo get_the_author_link();
+}
+
+/**
+ * Retrieve the number of posts by the author of the current post.
+ *
+ * @since 1.5
+ * @uses $post The current post in the Loop's DB object.
+ * @uses count_user_posts()
+ * @return int The number of posts by the author.
+ */
+function get_the_author_posts() {
+	global $post;
+	return count_user_posts($post->post_author);
+}
+
+/**
+ * Display the number of posts by the author of the current post.
+ *
+ * @link http://codex.wordpress.org/Template_Tags/the_author_posts
+ * @since 0.71
+ * @uses get_the_author_posts() Echoes returned value from function.
+ */
+function the_author_posts() {
+	echo get_the_author_posts();
+}
+
+/**
+ * Display an HTML link to the author page of the author of the current post.
+ *
+ * Does just echo get_author_posts_url() function, like the others do. The
+ * reason for this, is that another function is used to help in printing the
+ * link to the author's posts.
+ *
+ * @link http://codex.wordpress.org/Template_Tags/the_author_posts_link
+ * @since 1.2.0
+ * @uses $authordata The current author's DB object.
+ * @uses get_author_posts_url()
+ * @uses get_the_author()
+ * @param string $deprecated Deprecated.
+ */
+function the_author_posts_link($deprecated = '') {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.1' );
+
+	global $authordata;
+	$link = sprintf(
+		'<a href="%1$s" title="%2$s">%3$s</a>',
+		get_author_posts_url( $authordata->ID, $authordata->user_nicename ),
+		esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ),
+		get_the_author()
+	);
+	echo apply_filters( 'the_author_posts_link', $link );
+}
+
+/**
+ * Retrieve the URL to the author page for the user with the ID provided.
+ *
+ * @since 2.1.0
+ * @uses $wp_rewrite WP_Rewrite
+ * @return string The URL to the author's page.
+ */
+function get_author_posts_url($author_id, $author_nicename = '') {
+	global $wp_rewrite;
+	$auth_ID = (int) $author_id;
+	$link = $wp_rewrite->get_author_permastruct();
+
+	if ( empty($link) ) {
+		$file = home_url( '/' );
+		$link = $file . '?author=' . $auth_ID;
+	} else {
+		if ( '' == $author_nicename ) {
+			$user = get_userdata($author_id);
+			if ( !empty($user->user_nicename) )
+				$author_nicename = $user->user_nicename;
+		}
+		$link = str_replace('%author%', $author_nicename, $link);
+		$link = home_url( user_trailingslashit( $link ) );
+	}
+
+	$link = apply_filters('author_link', $link, $author_id, $author_nicename);
+
+	return $link;
+}
+
+/**
+ * List all the authors of the blog, with several options available.
+ *
+ * <ul>
+ * <li>optioncount (boolean) (false): Show the count in parenthesis next to the
+ * author's name.</li>
+ * <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is
+ * installed bydefault.</li>
+ * <li>show_fullname (boolean) (false): Show their full names.</li>
+ * <li>hide_empty (boolean) (true): Don't show authors without any posts.</li>
+ * <li>feed (string) (''): If isn't empty, show links to author's feeds.</li>
+ * <li>feed_image (string) (''): If isn't empty, use this image to link to
+ * feeds.</li>
+ * <li>echo (boolean) (true): Set to false to return the output, instead of
+ * echoing.</li>
+ * <li>style (string) ('list'): Whether to display list of authors in list form
+ * or as a string.</li>
+ * <li>html (bool) (true): Whether to list the items in html form or plaintext.
+ * </li>
+ * </ul>
+ *
+ * @link http://codex.wordpress.org/Template_Tags/wp_list_authors
+ * @since 1.2.0
+ * @param array $args The argument array.
+ * @return null|string The output, if echo is set to false.
+ */
+function wp_list_authors($args = '') {
+	global $wpdb;
+
+	$defaults = array(
+		'orderby' => 'name', 'order' => 'ASC', 'number' => '',
+		'optioncount' => false, 'exclude_admin' => true,
+		'show_fullname' => false, 'hide_empty' => true,
+		'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
+		'style' => 'list', 'html' => true
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+	extract( $args, EXTR_SKIP );
+
+	$return = '';
+
+	$query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number' ) );
+	$query_args['fields'] = 'ids';
+	$authors = get_users( $query_args );
+
+	$author_count = array();
+	foreach ( (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row )
+		$author_count[$row->post_author] = $row->count;
+
+	foreach ( $authors as $author_id ) {
+		$author = get_userdata( $author_id );
+
+		if ( $exclude_admin && 'admin' == $author->display_name )
+			continue;
+
+		$posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0;
+
+		if ( !$posts && $hide_empty )
+			continue;
+
+		$link = '';
+
+		if ( $show_fullname && $author->first_name && $author->last_name )
+			$name = "$author->first_name $author->last_name";
+		else
+			$name = $author->display_name;
+
+		if ( !$html ) {
+			$return .= $name . ', ';
+
+			continue; // No need to go further to process HTML.
+		}
+
+		if ( 'list' == $style ) {
+			$return .= '<li>';
+		}
+
+		$link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>';
+
+		if ( !empty( $feed_image ) || !empty( $feed ) ) {
+			$link .= ' ';
+			if ( empty( $feed_image ) ) {
+				$link .= '(';
+			}
+
+			$link .= '<a href="' . get_author_feed_link( $author->ID ) . '"';
+
+			$alt = $title = '';
+			if ( !empty( $feed ) ) {
+				$title = ' title="' . esc_attr( $feed ) . '"';
+				$alt = ' alt="' . esc_attr( $feed ) . '"';
+				$name = $feed;
+				$link .= $title;
+			}
+
+			$link .= '>';
+
+			if ( !empty( $feed_image ) )
+				$link .= '<img src="' . esc_url( $feed_image ) . '" style="border: none;"' . $alt . $title . ' />';
+			else
+				$link .= $name;
+
+			$link .= '</a>';
+
+			if ( empty( $feed_image ) )
+				$link .= ')';
+		}
+
+		if ( $optioncount )
+			$link .= ' ('. $posts . ')';
+
+		$return .= $link;
+		$return .= ( 'list' == $style ) ? '</li>' : ', ';
+	}
+
+	$return = rtrim($return, ', ');
+
+	if ( !$echo )
+		return $return;
+
+	echo $return;
+}
+
+?>
Index: /tags/3.1/wp-includes/bookmark-template.php
===================================================================
--- /tags/3.1/wp-includes/bookmark-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/bookmark-template.php	(revision 17487)
@@ -0,0 +1,256 @@
+<?php
+/**
+ * Bookmark Template Functions for usage in Themes
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * The formatted output of a list of bookmarks.
+ *
+ * The $bookmarks array must contain bookmark objects and will be iterated over
+ * to retrieve the bookmark to be used in the output.
+ *
+ * The output is formatted as HTML with no way to change that format. However,
+ * what is between, before, and after can be changed. The link itself will be
+ * HTML.
+ *
+ * This function is used internally by wp_list_bookmarks() and should not be
+ * used by themes.
+ *
+ * The defaults for overwriting are:
+ * 'show_updated' - Default is 0 (integer). Will show the time of when the
+ *		bookmark was last updated.
+ * 'show_description' - Default is 0 (integer). Whether to show the description
+ *		of the bookmark.
+ * 'show_images' - Default is 1 (integer). Whether to show link image if
+ *		available.
+ * 'show_name' - Default is 0 (integer). Whether to show link name if
+ *		available.
+ * 'before' - Default is '<li>' (string). The html or text to prepend to each
+ *		bookmarks.
+ * 'after' - Default is '</li>' (string). The html or text to append to each
+ *		bookmarks.
+ * 'link_before' - Default is '' (string). The html or text to prepend to each
+ *		bookmarks inside the <a> tag.
+ * 'link_after' - Default is '' (string). The html or text to append to each
+ *		bookmarks inside the <a> tag.
+ * 'between' - Default is '\n' (string). The string for use in between the link,
+ *		description, and image.
+ * 'show_rating' - Default is 0 (integer). Whether to show the link rating.
+ *
+ * @since 2.1.0
+ * @access private
+ * @usedby wp_list_bookmarks()
+ *
+ * @param array $bookmarks List of bookmarks to traverse
+ * @param string|array $args Optional. Overwrite the defaults.
+ * @return string Formatted output in HTML
+ */
+function _walk_bookmarks($bookmarks, $args = '' ) {
+	$defaults = array(
+		'show_updated' => 0, 'show_description' => 0,
+		'show_images' => 1, 'show_name' => 0,
+		'before' => '<li>', 'after' => '</li>', 'between' => "\n",
+		'show_rating' => 0, 'link_before' => '', 'link_after' => ''
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	$output = ''; // Blank string to start with.
+
+	foreach ( (array) $bookmarks as $bookmark ) {
+		if ( !isset($bookmark->recently_updated) )
+			$bookmark->recently_updated = false;
+		$output .= $before;
+		if ( $show_updated && $bookmark->recently_updated )
+			$output .= get_option('links_recently_updated_prepend');
+
+		$the_link = '#';
+		if ( !empty($bookmark->link_url) )
+			$the_link = esc_url($bookmark->link_url);
+
+		$desc = esc_attr(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display'));
+		$name = esc_attr(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display'));
+ 		$title = $desc;
+
+		if ( $show_updated )
+			if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) {
+				$title .= ' (';
+				$title .= sprintf(__('Last updated: %s'), date(get_option('links_updated_date_format'), $bookmark->link_updated_f + (get_option('gmt_offset') * 3600)));
+				$title .= ')';
+			}
+
+		$alt = ' alt="' . $name . ( $show_description ? ' ' . $title : '' ) . '"';
+
+		if ( '' != $title )
+			$title = ' title="' . $title . '"';
+
+		$rel = $bookmark->link_rel;
+		if ( '' != $rel )
+			$rel = ' rel="' . esc_attr($rel) . '"';
+
+		$target = $bookmark->link_target;
+		if ( '' != $target )
+			$target = ' target="' . $target . '"';
+
+		$output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
+
+		$output .= $link_before;
+
+		if ( $bookmark->link_image != null && $show_images ) {
+			if ( strpos($bookmark->link_image, 'http') === 0 )
+				$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
+			else // If it's a relative path
+				$output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
+
+			if ( $show_name )
+				$output .= " $name";
+		} else {
+			$output .= $name;
+		}
+
+		$output .= $link_after;
+
+		$output .= '</a>';
+
+		if ( $show_updated && $bookmark->recently_updated )
+			$output .= get_option('links_recently_updated_append');
+
+		if ( $show_description && '' != $desc )
+			$output .= $between . $desc;
+
+		if ( $show_rating )
+			$output .= $between . sanitize_bookmark_field('link_rating', $bookmark->link_rating, $bookmark->link_id, 'display');
+
+		$output .= "$after\n";
+	} // end while
+
+	return $output;
+}
+
+/**
+ * Retrieve or echo all of the bookmarks.
+ *
+ * List of default arguments are as follows:
+ * 'orderby' - Default is 'name' (string). How to order the links by. String is
+ *		based off of the bookmark scheme.
+ * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either
+ *		ascending or descending order.
+ * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to
+ *		display.
+ * 'category' - Default is empty string (string). Include the links in what
+ *		category ID(s).
+ * 'category_name' - Default is empty string (string). Get links by category
+ *		name.
+ * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide
+ *		links marked as 'invisible'.
+ * 'show_updated' - Default is 0 (integer). Will show the time of when the
+ *		bookmark was last updated.
+ * 'echo' - Default is 1 (integer). Whether to echo (default) or return the
+ *		formatted bookmarks.
+ * 'categorize' - Default is 1 (integer). Whether to show links listed by
+ *		category (default) or show links in one column.
+ * 'show_description' - Default is 0 (integer). Whether to show the description
+ *		of the bookmark.
+ *
+ * These options define how the Category name will appear before the category
+ * links are displayed, if 'categorize' is 1. If 'categorize' is 0, then it will
+ * display for only the 'title_li' string and only if 'title_li' is not empty.
+ * 'title_li' - Default is 'Bookmarks' (translatable string). What to show
+ *		before the links appear.
+ * 'title_before' - Default is '<h2>' (string). The HTML or text to show before
+ *		the 'title_li' string.
+ * 'title_after' - Default is '</h2>' (string). The HTML or text to show after
+ *		the 'title_li' string.
+ * 'class' - Default is 'linkcat' (string). The CSS class to use for the
+ *		'title_li'.
+ *
+ * 'category_before' - Default is '<li id="%id" class="%class">'. String must
+ *		contain '%id' and '%class' to get
+ * the id of the category and the 'class' argument. These are used for
+ *		formatting in themes.
+ * Argument will be displayed before the 'title_before' argument.
+ * 'category_after' - Default is '</li>' (string). The HTML or text that will
+ *		appear after the list of links.
+ *
+ * These are only used if 'categorize' is set to 1 or true.
+ * 'category_orderby' - Default is 'name'. How to order the bookmark category
+ *		based on term scheme.
+ * 'category_order' - Default is 'ASC'. Set the order by either ASC (ascending)
+ *		or DESC (descending).
+ *
+ * @see _walk_bookmarks() For other arguments that can be set in this function
+ *		and passed to _walk_bookmarks().
+ * @see get_bookmarks() For other arguments that can be set in this function and
+ *		passed to get_bookmarks().
+ * @link http://codex.wordpress.org/Template_Tags/wp_list_bookmarks
+ *
+ * @since 2.1.0
+ * @uses _list_bookmarks() Used to iterate over all of the bookmarks and return
+ *		the html
+ * @uses get_terms() Gets all of the categories that are for links.
+ *
+ * @param string|array $args Optional. Overwrite the defaults of the function
+ * @return string|null Will only return if echo option is set to not echo.
+ *		Default is not return anything.
+ */
+function wp_list_bookmarks($args = '') {
+	$defaults = array(
+		'orderby' => 'name', 'order' => 'ASC',
+		'limit' => -1, 'category' => '', 'exclude_category' => '',
+		'category_name' => '', 'hide_invisible' => 1,
+		'show_updated' => 0, 'echo' => 1,
+		'categorize' => 1, 'title_li' => __('Bookmarks'),
+		'title_before' => '<h2>', 'title_after' => '</h2>',
+		'category_orderby' => 'name', 'category_order' => 'ASC',
+		'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
+		'category_after' => '</li>'
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	$output = '';
+
+	if ( $categorize ) {
+		//Split the bookmarks into ul's for each category
+		$cats = get_terms('link_category', array('name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0));
+
+		foreach ( (array) $cats as $cat ) {
+			$params = array_merge($r, array('category'=>$cat->term_id));
+			$bookmarks = get_bookmarks($params);
+			if ( empty($bookmarks) )
+				continue;
+			$output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before);
+			$catname = apply_filters( "link_category", $cat->name );
+			$output .= "$title_before$catname$title_after\n\t<ul class='xoxo blogroll'>\n";
+			$output .= _walk_bookmarks($bookmarks, $r);
+			$output .= "\n\t</ul>\n$category_after\n";
+		}
+	} else {
+		//output one single list using title_li for the title
+		$bookmarks = get_bookmarks($r);
+
+		if ( !empty($bookmarks) ) {
+			if ( !empty( $title_li ) ){
+				$output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before);
+				$output .= "$title_before$title_li$title_after\n\t<ul class='xoxo blogroll'>\n";
+				$output .= _walk_bookmarks($bookmarks, $r);
+				$output .= "\n\t</ul>\n$category_after\n";
+			} else {
+				$output .= _walk_bookmarks($bookmarks, $r);
+			}
+		}
+	}
+
+	$output = apply_filters( 'wp_list_bookmarks', $output );
+
+	if ( !$echo )
+		return $output;
+	echo $output;
+}
+
+?>
Index: /tags/3.1/wp-includes/bookmark.php
===================================================================
--- /tags/3.1/wp-includes/bookmark.php	(revision 17487)
+++ /tags/3.1/wp-includes/bookmark.php	(revision 17487)
@@ -0,0 +1,370 @@
+<?php
+/**
+ * Link/Bookmark API
+ *
+ * @package WordPress
+ * @subpackage Bookmark
+ */
+
+/**
+ * Retrieve Bookmark data
+ *
+ * @since 2.1.0
+ * @uses $wpdb Database Object
+ *
+ * @param mixed $bookmark
+ * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant
+ * @param string $filter Optional, default is 'raw'.
+ * @return array|object Type returned depends on $output value.
+ */
+function get_bookmark($bookmark, $output = OBJECT, $filter = 'raw') {
+	global $wpdb;
+
+	if ( empty($bookmark) ) {
+		if ( isset($GLOBALS['link']) )
+			$_bookmark = & $GLOBALS['link'];
+		else
+			$_bookmark = null;
+	} elseif ( is_object($bookmark) ) {
+		wp_cache_add($bookmark->link_id, $bookmark, 'bookmark');
+		$_bookmark = $bookmark;
+	} else {
+		if ( isset($GLOBALS['link']) && ($GLOBALS['link']->link_id == $bookmark) ) {
+			$_bookmark = & $GLOBALS['link'];
+		} elseif ( ! $_bookmark = wp_cache_get($bookmark, 'bookmark') ) {
+			$_bookmark = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark));
+			$_bookmark->link_category = array_unique( wp_get_object_terms($_bookmark->link_id, 'link_category', array('fields' => 'ids')) );
+			wp_cache_add($_bookmark->link_id, $_bookmark, 'bookmark');
+		}
+	}
+
+	$_bookmark = sanitize_bookmark($_bookmark, $filter);
+
+	if ( $output == OBJECT ) {
+		return $_bookmark;
+	} elseif ( $output == ARRAY_A ) {
+		return get_object_vars($_bookmark);
+	} elseif ( $output == ARRAY_N ) {
+		return array_values(get_object_vars($_bookmark));
+	} else {
+		return $_bookmark;
+	}
+}
+
+/**
+ * Retrieve single bookmark data item or field.
+ *
+ * @since 2.3.0
+ * @uses get_bookmark() Gets bookmark object using $bookmark as ID
+ * @uses sanitize_bookmark_field() Sanitizes Bookmark field based on $context.
+ *
+ * @param string $field The name of the data field to return
+ * @param int $bookmark The bookmark ID to get field
+ * @param string $context Optional. The context of how the field will be used.
+ * @return string
+ */
+function get_bookmark_field( $field, $bookmark, $context = 'display' ) {
+	$bookmark = (int) $bookmark;
+	$bookmark = get_bookmark( $bookmark );
+
+	if ( is_wp_error($bookmark) )
+		return $bookmark;
+
+	if ( !is_object($bookmark) )
+		return '';
+
+	if ( !isset($bookmark->$field) )
+		return '';
+
+	return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context);
+}
+
+/**
+ * Retrieves the list of bookmarks
+ *
+ * Attempts to retrieve from the cache first based on MD5 hash of arguments. If
+ * that fails, then the query will be built from the arguments and executed. The
+ * results will be stored to the cache.
+ *
+ * List of default arguments are as follows:
+ * 'orderby' - Default is 'name' (string). How to order the links by. String is
+ *		based off of the bookmark scheme.
+ * 'order' - Default is 'ASC' (string). Either 'ASC' or 'DESC'. Orders in either
+ *		ascending or descending order.
+ * 'limit' - Default is -1 (integer) or show all. The amount of bookmarks to
+ *		display.
+ * 'category' - Default is empty string (string). Include the links in what
+ *		category ID(s).
+ * 'category_name' - Default is empty string (string). Get links by category
+ *		name.
+ * 'hide_invisible' - Default is 1 (integer). Whether to show (default) or hide
+ *		links marked as 'invisible'.
+ * 'show_updated' - Default is 0 (integer). Will show the time of when the
+ *		bookmark was last updated.
+ * 'include' - Default is empty string (string). Include other categories
+ *		separated by commas.
+ * 'exclude' - Default is empty string (string). Exclude other categories
+ *		separated by commas.
+ *
+ * @since 2.1.0
+ * @uses $wpdb Database Object
+ * @link http://codex.wordpress.org/Template_Tags/get_bookmarks
+ *
+ * @param string|array $args List of arguments to overwrite the defaults
+ * @return array List of bookmark row objects
+ */
+function get_bookmarks($args = '') {
+	global $wpdb;
+
+	$defaults = array(
+		'orderby' => 'name', 'order' => 'ASC',
+		'limit' => -1, 'category' => '',
+		'category_name' => '', 'hide_invisible' => 1,
+		'show_updated' => 0, 'include' => '',
+		'exclude' => '', 'search' => ''
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	$cache = array();
+	$key = md5( serialize( $r ) );
+	if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
+		if ( is_array($cache) && isset( $cache[ $key ] ) )
+			return apply_filters('get_bookmarks', $cache[ $key ], $r );
+	}
+
+	if ( !is_array($cache) )
+		$cache = array();
+
+	$inclusions = '';
+	if ( !empty($include) ) {
+		$exclude = '';  //ignore exclude, category, and category_name params if using include
+		$category = '';
+		$category_name = '';
+		$inclinks = preg_split('/[\s,]+/',$include);
+		if ( count($inclinks) ) {
+			foreach ( $inclinks as $inclink ) {
+				if (empty($inclusions))
+					$inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
+				else
+					$inclusions .= ' OR link_id = ' . intval($inclink) . ' ';
+			}
+		}
+	}
+	if (!empty($inclusions))
+		$inclusions .= ')';
+
+	$exclusions = '';
+	if ( !empty($exclude) ) {
+		$exlinks = preg_split('/[\s,]+/',$exclude);
+		if ( count($exlinks) ) {
+			foreach ( $exlinks as $exlink ) {
+				if (empty($exclusions))
+					$exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
+				else
+					$exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
+			}
+		}
+	}
+	if (!empty($exclusions))
+		$exclusions .= ')';
+
+	if ( !empty($category_name) ) {
+		if ( $category = get_term_by('name', $category_name, 'link_category') ) {
+			$category = $category->term_id;
+		} else {
+			$cache[ $key ] = array();
+			wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
+			return apply_filters( 'get_bookmarks', array(), $r );
+		}
+	}
+
+	if ( ! empty($search) ) {
+		$search = like_escape($search);
+		$search = " AND ( (link_url LIKE '%$search%') OR (link_name LIKE '%$search%') OR (link_description LIKE '%$search%') ) ";
+	}
+
+	$category_query = '';
+	$join = '';
+	if ( !empty($category) ) {
+		$incategories = preg_split('/[\s,]+/',$category);
+		if ( count($incategories) ) {
+			foreach ( $incategories as $incat ) {
+				if (empty($category_query))
+					$category_query = ' AND ( tt.term_id = ' . intval($incat) . ' ';
+				else
+					$category_query .= ' OR tt.term_id = ' . intval($incat) . ' ';
+			}
+		}
+	}
+	if (!empty($category_query)) {
+		$category_query .= ") AND taxonomy = 'link_category'";
+		$join = " INNER JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
+	}
+
+	if ( $show_updated && get_option('links_recently_updated_time') ) {
+		$recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_option('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
+	} else {
+		$recently_updated_test = '';
+	}
+
+	$get_updated = ( $show_updated ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';
+
+	$orderby = strtolower($orderby);
+	$length = '';
+	switch ($orderby) {
+		case 'length':
+			$length = ", CHAR_LENGTH(link_name) AS length";
+			break;
+		case 'rand':
+			$orderby = 'rand()';
+			break;
+		default:
+			$orderparams = array();
+			foreach ( explode(',', $orderby) as $ordparam )
+				$orderparams[] = 'link_' . trim($ordparam);
+			$orderby = implode(',', $orderparams);
+	}
+
+	if ( 'link_id' == $orderby )
+		$orderby = "$wpdb->links.link_id";
+
+	$visible = '';
+	if ( $hide_invisible )
+		$visible = "AND link_visible = 'Y'";
+
+	$query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
+	$query .= " $exclusions $inclusions $search";
+	$query .= " ORDER BY $orderby $order";
+	if ($limit != -1)
+		$query .= " LIMIT $limit";
+
+	$results = $wpdb->get_results($query);
+
+	$cache[ $key ] = $results;
+	wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
+
+	return apply_filters('get_bookmarks', $results, $r);
+}
+
+/**
+ * Sanitizes all bookmark fields
+ *
+ * @since 2.3.0
+ *
+ * @param object|array $bookmark Bookmark row
+ * @param string $context Optional, default is 'display'. How to filter the
+ *		fields
+ * @return object|array Same type as $bookmark but with fields sanitized.
+ */
+function sanitize_bookmark($bookmark, $context = 'display') {
+	$fields = array('link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category',
+		'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated',
+		'link_rel', 'link_notes', 'link_rss', );
+
+	if ( is_object($bookmark) ) {
+		$do_object = true;
+		$link_id = $bookmark->link_id;
+	} else {
+		$do_object = false;
+		$link_id = $bookmark['link_id'];
+	}
+
+	foreach ( $fields as $field ) {
+		if ( $do_object ) {
+			if ( isset($bookmark->$field) )
+				$bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $link_id, $context);
+		} else {
+			if ( isset($bookmark[$field]) )
+				$bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $link_id, $context);
+		}
+	}
+
+	return $bookmark;
+}
+
+/**
+ * Sanitizes a bookmark field
+ *
+ * Sanitizes the bookmark fields based on what the field name is. If the field
+ * has a strict value set, then it will be tested for that, else a more generic
+ * filtering is applied. After the more strict filter is applied, if the
+ * $context is 'raw' then the value is immediately return.
+ *
+ * Hooks exist for the more generic cases. With the 'edit' context, the
+ * 'edit_$field' filter will be called and passed the $value and $bookmark_id
+ * respectively. With the 'db' context, the 'pre_$field' filter is called and
+ * passed the value. The 'display' context is the final context and has the
+ * $field has the filter name and is passed the $value, $bookmark_id, and
+ * $context respectively.
+ *
+ * @since 2.3.0
+ *
+ * @param string $field The bookmark field
+ * @param mixed $value The bookmark field value
+ * @param int $bookmark_id Bookmark ID
+ * @param string $context How to filter the field value. Either 'raw', 'edit',
+ *		'attribute', 'js', 'db', or 'display'
+ * @return mixed The filtered value
+ */
+function sanitize_bookmark_field($field, $value, $bookmark_id, $context) {
+	switch ( $field ) {
+	case 'link_id' : // ints
+	case 'link_rating' :
+		$value = (int) $value;
+		break;
+	case 'link_category' : // array( ints )
+		$value = array_map('absint', (array) $value);
+		// We return here so that the categories aren't filtered.
+		// The 'link_category' filter is for the name of a link category, not an array of a link's link categories
+		return $value;
+		break;
+	case 'link_visible' : // bool stored as Y|N
+		$value = preg_replace('/[^YNyn]/', '', $value);
+		break;
+	case 'link_target' : // "enum"
+		$targets = array('_top', '_blank');
+		if ( ! in_array($value, $targets) )
+			$value = '';
+		break;
+	}
+
+	if ( 'raw' == $context )
+		return $value;
+
+	if ( 'edit' == $context ) {
+		$value = apply_filters("edit_$field", $value, $bookmark_id);
+
+		if ( 'link_notes' == $field ) {
+			$value = esc_html( $value ); // textarea_escaped
+		} else {
+			$value = esc_attr($value);
+		}
+	} else if ( 'db' == $context ) {
+		$value = apply_filters("pre_$field", $value);
+	} else {
+		// Use display filters by default.
+		$value = apply_filters($field, $value, $bookmark_id, $context);
+
+		if ( 'attribute' == $context )
+			$value = esc_attr($value);
+		else if ( 'js' == $context )
+			$value = esc_js($value);
+	}
+
+	return $value;
+}
+
+/**
+ * Deletes bookmark cache
+ *
+ * @since 2.7.0
+ * @uses wp_cache_delete() Deletes the contents of 'get_bookmarks'
+ */
+function clean_bookmark_cache($bookmark_id) {
+	wp_cache_delete( $bookmark_id, 'bookmark' );
+	wp_cache_delete( 'get_bookmarks', 'bookmark' );
+}
+
+?>
Index: /tags/3.1/wp-includes/cache.php
===================================================================
--- /tags/3.1/wp-includes/cache.php	(revision 17487)
+++ /tags/3.1/wp-includes/cache.php	(revision 17487)
@@ -0,0 +1,497 @@
+<?php
+/**
+ * Object Cache API
+ *
+ * @link http://codex.wordpress.org/Function_Reference/WP_Cache
+ *
+ * @package WordPress
+ * @subpackage Cache
+ */
+
+/**
+ * Adds data to the cache, if the cache key doesn't aleady exist.
+ *
+ * @since 2.0.0
+ * @uses $wp_object_cache Object Cache Class
+ * @see WP_Object_Cache::add()
+ *
+ * @param int|string $key The cache ID to use for retrieval later
+ * @param mixed $data The data to add to the cache store
+ * @param string $flag The group to add the cache to
+ * @param int $expire When the cache data should be expired
+ * @return unknown
+ */
+function wp_cache_add($key, $data, $flag = '', $expire = 0) {
+	global $wp_object_cache;
+
+	return $wp_object_cache->add($key, $data, $flag, $expire);
+}
+
+/**
+ * Closes the cache.
+ *
+ * This function has ceased to do anything since WordPress 2.5. The
+ * functionality was removed along with the rest of the persistant cache. This
+ * does not mean that plugins can't implement this function when they need to
+ * make sure that the cache is cleaned up after WordPress no longer needs it.
+ *
+ * @since 2.0.0
+ *
+ * @return bool Always returns True
+ */
+function wp_cache_close() {
+	return true;
+}
+
+/**
+ * Removes the cache contents matching ID and flag.
+ *
+ * @since 2.0.0
+ * @uses $wp_object_cache Object Cache Class
+ * @see WP_Object_Cache::delete()
+ *
+ * @param int|string $id What the contents in the cache are called
+ * @param string $flag Where the cache contents are grouped
+ * @return bool True on successful removal, false on failure
+ */
+function wp_cache_delete($id, $flag = '') {
+	global $wp_object_cache;
+
+	return $wp_object_cache->delete($id, $flag);
+}
+
+/**
+ * Removes all cache items.
+ *
+ * @since 2.0.0
+ * @uses $wp_object_cache Object Cache Class
+ * @see WP_Object_Cache::flush()
+ *
+ * @return bool Always returns true
+ */
+function wp_cache_flush() {
+	global $wp_object_cache;
+
+	return $wp_object_cache->flush();
+}
+
+/**
+ * Retrieves the cache contents from the cache by ID and flag.
+ *
+ * @since 2.0.0
+ * @uses $wp_object_cache Object Cache Class
+ * @see WP_Object_Cache::get()
+ *
+ * @param int|string $id What the contents in the cache are called
+ * @param string $flag Where the cache contents are grouped
+ * @return bool|mixed False on failure to retrieve contents or the cache
+ *		contents on success
+ */
+function wp_cache_get($id, $flag = '') {
+	global $wp_object_cache;
+
+	return $wp_object_cache->get($id, $flag);
+}
+
+/**
+ * Sets up Object Cache Global and assigns it.
+ *
+ * @since 2.0.0
+ * @global WP_Object_Cache $wp_object_cache WordPress Object Cache
+ */
+function wp_cache_init() {
+	$GLOBALS['wp_object_cache'] =& new WP_Object_Cache();
+}
+
+/**
+ * Replaces the contents of the cache with new data.
+ *
+ * @since 2.0.0
+ * @uses $wp_object_cache Object Cache Class
+ * @see WP_Object_Cache::replace()
+ *
+ * @param int|string $key What to call the contents in the cache
+ * @param mixed $data The contents to store in the cache
+ * @param string $flag Where to group the cache contents
+ * @param int $expire When to expire the cache contents
+ * @return bool False if cache ID and group already exists, true on success
+ */
+function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
+	global $wp_object_cache;
+
+	return $wp_object_cache->replace($key, $data, $flag, $expire);
+}
+
+/**
+ * Saves the data to the cache.
+ *
+ * @since 2.0
+ * @uses $wp_object_cache Object Cache Class
+ * @see WP_Object_Cache::set()
+ *
+ * @param int|string $key What to call the contents in the cache
+ * @param mixed $data The contents to store in the cache
+ * @param string $flag Where to group the cache contents
+ * @param int $expire When to expire the cache contents
+ * @return bool False if cache ID and group already exists, true on success
+ */
+function wp_cache_set($key, $data, $flag = '', $expire = 0) {
+	global $wp_object_cache;
+
+	return $wp_object_cache->set($key, $data, $flag, $expire);
+}
+
+/**
+ * Adds a group or set of groups to the list of global groups.
+ *
+ * @since 2.6.0
+ *
+ * @param string|array $groups A group or an array of groups to add
+ */
+function wp_cache_add_global_groups( $groups ) {
+	global $wp_object_cache;
+
+	return $wp_object_cache->add_global_groups($groups);
+}
+
+/**
+ * Adds a group or set of groups to the list of non-persistent groups.
+ *
+ * @since 2.6.0
+ *
+ * @param string|array $groups A group or an array of groups to add
+ */
+function wp_cache_add_non_persistent_groups( $groups ) {
+	// Default cache doesn't persist so nothing to do here.
+	return;
+}
+
+/**
+ * Reset internal cache keys and structures.  If the cache backend uses global blog or site IDs as part of its cache keys,
+ * this function instructs the backend to reset those keys and perform any cleanup since blog or site IDs have changed since cache init.
+ *
+ * @since 2.6.0
+ */
+function wp_cache_reset() {
+	global $wp_object_cache;
+
+	return $wp_object_cache->reset();
+}
+
+/**
+ * WordPress Object Cache
+ *
+ * The WordPress Object Cache is used to save on trips to the database. The
+ * Object Cache stores all of the cache data to memory and makes the cache
+ * contents available by using a key, which is used to name and later retrieve
+ * the cache contents.
+ *
+ * The Object Cache can be replaced by other caching mechanisms by placing files
+ * in the wp-content folder which is looked at in wp-settings. If that file
+ * exists, then this file will not be included.
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 2.0
+ */
+class WP_Object_Cache {
+
+	/**
+	 * Holds the cached objects
+	 *
+	 * @var array
+	 * @access private
+	 * @since 2.0.0
+	 */
+	var $cache = array ();
+
+	/**
+	 * Cache objects that do not exist in the cache
+	 *
+	 * @var array
+	 * @access private
+	 * @since 2.0.0
+	 */
+	var $non_existent_objects = array ();
+
+	/**
+	 * The amount of times the cache data was already stored in the cache.
+	 *
+	 * @since 2.5.0
+	 * @access private
+	 * @var int
+	 */
+	var $cache_hits = 0;
+
+	/**
+	 * Amount of times the cache did not have the request in cache
+	 *
+	 * @var int
+	 * @access public
+	 * @since 2.0.0
+	 */
+	var $cache_misses = 0;
+
+	/**
+	 * List of global groups
+	 *
+	 * @var array
+	 * @access protected
+	 * @since 3.0.0
+	 */
+	var $global_groups = array();
+
+	/**
+	 * Adds data to the cache if it doesn't already exist.
+	 *
+	 * @uses WP_Object_Cache::get Checks to see if the cache already has data.
+	 * @uses WP_Object_Cache::set Sets the data after the checking the cache
+	 *		contents existance.
+	 *
+	 * @since 2.0.0
+	 *
+	 * @param int|string $id What to call the contents in the cache
+	 * @param mixed $data The contents to store in the cache
+	 * @param string $group Where to group the cache contents
+	 * @param int $expire When to expire the cache contents
+	 * @return bool False if cache ID and group already exists, true on success
+	 */
+	function add( $id, $data, $group = 'default', $expire = '' ) {
+		if ( empty ($group) )
+			$group = 'default';
+
+		if (false !== $this->get($id, $group))
+			return false;
+
+		return $this->set($id, $data, $group, $expire);
+	}
+
+	/**
+	 * Sets the list of global groups.
+	 *
+	 * @since 3.0.0
+	 *
+	 * @param array $groups List of groups that are global.
+	 */
+	function add_global_groups( $groups ) {
+		$groups = (array) $groups;
+
+		$this->global_groups = array_merge($this->global_groups, $groups);
+		$this->global_groups = array_unique($this->global_groups);
+	}
+
+	/**
+	 * Remove the contents of the cache ID in the group
+	 *
+	 * If the cache ID does not exist in the group and $force parameter is set
+	 * to false, then nothing will happen. The $force parameter is set to false
+	 * by default.
+	 *
+	 * On success the group and the id will be added to the
+	 * $non_existent_objects property in the class.
+	 *
+	 * @since 2.0.0
+	 *
+	 * @param int|string $id What the contents in the cache are called
+	 * @param string $group Where the cache contents are grouped
+	 * @param bool $force Optional. Whether to force the unsetting of the cache
+	 *		ID in the group
+	 * @return bool False if the contents weren't deleted and true on success
+	 */
+	function delete($id, $group = 'default', $force = false) {
+		if (empty ($group))
+			$group = 'default';
+
+		if (!$force && false === $this->get($id, $group))
+			return false;
+
+		unset ($this->cache[$group][$id]);
+		$this->non_existent_objects[$group][$id] = true;
+		return true;
+	}
+
+	/**
+	 * Clears the object cache of all data
+	 *
+	 * @since 2.0.0
+	 *
+	 * @return bool Always returns true
+	 */
+	function flush() {
+		$this->cache = array ();
+
+		return true;
+	}
+
+	/**
+	 * Retrieves the cache contents, if it exists
+	 *
+	 * The contents will be first attempted to be retrieved by searching by the
+	 * ID in the cache group. If the cache is hit (success) then the contents
+	 * are returned.
+	 *
+	 * On failure, the $non_existent_objects property is checked and if the
+	 * cache group and ID exist in there the cache misses will not be
+	 * incremented. If not in the nonexistent objects property, then the cache
+	 * misses will be incremented and the cache group and ID will be added to
+	 * the nonexistent objects.
+	 *
+	 * @since 2.0.0
+	 *
+	 * @param int|string $id What the contents in the cache are called
+	 * @param string $group Where the cache contents are grouped
+	 * @return bool|mixed False on failure to retrieve contents or the cache
+	 *		contents on success
+	 */
+	function get($id, $group = 'default') {
+		if ( empty ($group) )
+			$group = 'default';
+
+		if ( isset ($this->cache[$group][$id]) ) {
+			$this->cache_hits += 1;
+			if ( is_object($this->cache[$group][$id]) )
+				return wp_clone($this->cache[$group][$id]);
+			else
+				return $this->cache[$group][$id];
+		}
+
+		if ( isset ($this->non_existent_objects[$group][$id]) )
+			return false;
+
+		$this->non_existent_objects[$group][$id] = true;
+		$this->cache_misses += 1;
+		return false;
+	}
+
+	/**
+	 * Replace the contents in the cache, if contents already exist
+	 *
+	 * @since 2.0.0
+	 * @see WP_Object_Cache::set()
+	 *
+	 * @param int|string $id What to call the contents in the cache
+	 * @param mixed $data The contents to store in the cache
+	 * @param string $group Where to group the cache contents
+	 * @param int $expire When to expire the cache contents
+	 * @return bool False if not exists, true if contents were replaced
+	 */
+	function replace($id, $data, $group = 'default', $expire = '') {
+		if (empty ($group))
+			$group = 'default';
+
+		if ( false === $this->get($id, $group) )
+			return false;
+
+		return $this->set($id, $data, $group, $expire);
+	}
+
+	/**
+	 * Reset keys
+	 *
+	 * @since 3.0.0
+	 */
+	function reset() {
+		// Clear out non-global caches since the blog ID has changed.
+		foreach ( array_keys($this->cache) as $group ) {
+			if ( !in_array($group, $this->global_groups) )
+				unset($this->cache[$group]);
+		}
+	}
+
+	/**
+	 * Sets the data contents into the cache
+	 *
+	 * The cache contents is grouped by the $group parameter followed by the
+	 * $id. This allows for duplicate ids in unique groups. Therefore, naming of
+	 * the group should be used with care and should follow normal function
+	 * naming guidelines outside of core WordPress usage.
+	 *
+	 * The $expire parameter is not used, because the cache will automatically
+	 * expire for each time a page is accessed and PHP finishes. The method is
+	 * more for cache plugins which use files.
+	 *
+	 * @since 2.0.0
+	 *
+	 * @param int|string $id What to call the contents in the cache
+	 * @param mixed $data The contents to store in the cache
+	 * @param string $group Where to group the cache contents
+	 * @param int $expire Not Used
+	 * @return bool Always returns true
+	 */
+	function set($id, $data, $group = 'default', $expire = '') {
+		if ( empty ($group) )
+			$group = 'default';
+
+		if ( NULL === $data )
+			$data = '';
+
+		if ( is_object($data) )
+			$data = wp_clone($data);
+
+		$this->cache[$group][$id] = $data;
+
+		if ( isset($this->non_existent_objects[$group][$id]) )
+			unset ($this->non_existent_objects[$group][$id]);
+
+		return true;
+	}
+
+	/**
+	 * Echoes the stats of the caching.
+	 *
+	 * Gives the cache hits, and cache misses. Also prints every cached group,
+	 * key and the data.
+	 *
+	 * @since 2.0.0
+	 */
+	function stats() {
+		echo "<p>";
+		echo "<strong>Cache Hits:</strong> {$this->cache_hits}<br />";
+		echo "<strong>Cache Misses:</strong> {$this->cache_misses}<br />";
+		echo "</p>";
+		echo '<ul>';
+		foreach ($this->cache as $group => $cache) {
+			echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / 1024, 2 ) . 'k )</li>';
+		}
+		echo '</ul>';
+	}
+
+	/**
+	 * PHP4 constructor; Calls PHP 5 style constructor
+	 *
+	 * @since 2.0.0
+	 *
+	 * @return WP_Object_Cache
+	 */
+	function WP_Object_Cache() {
+		return $this->__construct();
+	}
+
+	/**
+	 * Sets up object properties; PHP 5 style constructor
+	 *
+	 * @since 2.0.8
+	 * @return null|WP_Object_Cache If cache is disabled, returns null.
+	 */
+	function __construct() {
+		/**
+		 * @todo This should be moved to the PHP4 style constructor, PHP5
+		 * already calls __destruct()
+		 */
+		register_shutdown_function(array(&$this, "__destruct"));
+	}
+
+	/**
+	 * Will save the object cache before object is completely destroyed.
+	 *
+	 * Called upon object destruction, which should be when PHP ends.
+	 *
+	 * @since  2.0.8
+	 *
+	 * @return bool True value. Won't be used by PHP
+	 */
+	function __destruct() {
+		return true;
+	}
+}
+?>
Index: /tags/3.1/wp-includes/canonical.php
===================================================================
--- /tags/3.1/wp-includes/canonical.php	(revision 17487)
+++ /tags/3.1/wp-includes/canonical.php	(revision 17487)
@@ -0,0 +1,414 @@
+<?php
+/**
+ * Canonical API to handle WordPress Redirecting
+ *
+ * Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference"
+ * by Mark Jaquith
+ *
+ * @package WordPress
+ * @since 2.3.0
+ */
+
+/**
+ * Redirects incoming links to the proper URL based on the site url.
+ *
+ * Search engines consider www.somedomain.com and somedomain.com to be two
+ * different URLs when they both go to the same location. This SEO enhancement
+ * prevents penality for duplicate content by redirecting all incoming links to
+ * one or the other.
+ *
+ * Prevents redirection for feeds, trackbacks, searches, comment popup, and
+ * admin URLs. Does not redirect on IIS, page/post previews, and on form data.
+ *
+ * Will also attempt to find the correct link when a user enters a URL that does
+ * not exist based on exact WordPress query. Will instead try to parse the URL
+ * or query in an attempt to figure the correct page to go to.
+ *
+ * @since 2.3.0
+ * @uses $wp_rewrite
+ * @uses $is_IIS
+ *
+ * @param string $requested_url Optional. The URL that was requested, used to
+ *		figure if redirect is needed.
+ * @param bool $do_redirect Optional. Redirect to the new URL.
+ * @return null|false|string Null, if redirect not needed. False, if redirect
+ *		not needed or the string of the URL
+ */
+function redirect_canonical( $requested_url = null, $do_redirect = true ) {
+	global $wp_rewrite, $is_iis7, $wp_query, $wpdb;
+
+	if ( is_trackback() || is_search() || is_comments_popup() || is_admin() || !empty($_POST) || is_preview() || is_robots() || ( $is_iis7 && !iis7_supports_permalinks() ) )
+		return;
+
+	if ( !$requested_url ) {
+		// build the URL in the address bar
+		$requested_url  = is_ssl() ? 'https://' : 'http://';
+		$requested_url .= $_SERVER['HTTP_HOST'];
+		$requested_url .= $_SERVER['REQUEST_URI'];
+	}
+
+	$original = @parse_url($requested_url);
+	if ( false === $original )
+		return;
+
+	// Some PHP setups turn requests for / into /index.php in REQUEST_URI
+	// See: http://trac.wordpress.org/ticket/5017
+	// See: http://trac.wordpress.org/ticket/7173
+	// Disabled, for now:
+	// $original['path'] = preg_replace('|/index\.php$|', '/', $original['path']);
+
+	$redirect = $original;
+	$redirect_url = false;
+
+	// Notice fixing
+	if ( !isset($redirect['path']) )
+		$redirect['path'] = '';
+	if ( !isset($redirect['query']) )
+		$redirect['query'] = '';
+
+	if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
+
+		$vars = $wpdb->get_results( $wpdb->prepare("SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id) );
+
+		if ( isset($vars[0]) && $vars = $vars[0] ) {
+			if ( 'revision' == $vars->post_type && $vars->post_parent > 0 )
+				$id = $vars->post_parent;
+
+			if ( $redirect_url = get_permalink($id) )
+				$redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id', 'post_type'), $redirect['query']);
+		}
+	}
+
+	// These tests give us a WP-generated permalink
+	if ( is_404() ) {
+
+		// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
+		$id = max( get_query_var('p'), get_query_var('page_id'), get_query_var('attachment_id') );
+		if ( $id && $redirect_post = get_post($id) ) {
+			$post_type_obj = get_post_type_object($redirect_post->post_type);
+			if ( $post_type_obj->public ) {
+				$redirect_url = get_permalink($redirect_post);
+				$redirect['query'] = remove_query_arg(array('p', 'page_id', 'attachment_id', 'post_type'), $redirect['query']);
+			}
+		}
+
+		if ( ! $redirect_url )
+			$redirect_url = redirect_guess_404_permalink();
+
+	} elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
+		// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
+		if ( is_attachment() && !empty($_GET['attachment_id']) && ! $redirect_url ) {
+			if ( $redirect_url = get_attachment_link(get_query_var('attachment_id')) )
+				$redirect['query'] = remove_query_arg('attachment_id', $redirect['query']);
+		} elseif ( is_single() && !empty($_GET['p']) && ! $redirect_url ) {
+			if ( $redirect_url = get_permalink(get_query_var('p')) )
+				$redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
+		} elseif ( is_single() && !empty($_GET['name'])  && ! $redirect_url ) {
+			if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
+				$redirect['query'] = remove_query_arg('name', $redirect['query']);
+		} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
+			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
+				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
+		} elseif ( is_page() && !is_feed() && isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front')  && ! $redirect_url ) {
+			$redirect_url = home_url('/');
+		} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts')  && ! $redirect_url ) {
+			if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
+				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
+		} elseif ( !empty($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
+			$m = get_query_var('m');
+			switch ( strlen($m) ) {
+				case 4: // Yearly
+					$redirect_url = get_year_link($m);
+					break;
+				case 6: // Monthly
+					$redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );
+					break;
+				case 8: // Daily
+					$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
+					break;
+			}
+			if ( $redirect_url )
+				$redirect['query'] = remove_query_arg('m', $redirect['query']);
+		// now moving on to non ?m=X year/month/day links
+		} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && !empty($_GET['day']) ) {
+			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
+				$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
+		} elseif ( is_month() && get_query_var('year') && !empty($_GET['monthnum']) ) {
+			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
+				$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
+		} elseif ( is_year() && !empty($_GET['year']) ) {
+			if ( $redirect_url = get_year_link(get_query_var('year')) )
+				$redirect['query'] = remove_query_arg('year', $redirect['query']);
+		} elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
+			$author = get_userdata(get_query_var('author'));
+			if ( false !== $author && $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) )
+				$redirect['query'] = remove_query_arg('author', $redirect['query']);
+		} elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories)
+
+			$term_count = 0;
+			foreach ( $wp_query->tax_query->queries as $tax_query )
+				$term_count += count( $tax_query['terms'] );
+
+			$obj = $wp_query->get_queried_object();
+			if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
+				if ( !empty($redirect['query']) ) {
+					if ( is_category() ) {
+						$redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']);
+					} elseif ( is_tag() ) {
+						$redirect['query'] = remove_query_arg( array( 'tag', 'tag_id'), $redirect['query']);
+					} elseif ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too:
+						$tax = get_taxonomy( $obj->taxonomy );
+						if ( false !== $tax->query_var)
+							$redirect['query'] = remove_query_arg($tax->query_var, $redirect['query']);
+						else
+							$redirect['query'] = remove_query_arg( array( 'term', 'taxonomy'), $redirect['query']);
+					}
+				}
+				$tax_url = parse_url($tax_url);
+				if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=..
+					parse_str($tax_url['query'], $query_vars);
+					$redirect['query'] = add_query_arg($query_vars, $redirect['query']);
+				} else { // Taxonomy is accessable via a "pretty-URL"
+					$redirect['path'] = $tax_url['path'];
+				}
+			}
+		} elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {
+			$category = get_category_by_path(get_query_var('category_name'));
+			$post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));
+			if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) )
+				$redirect_url = get_permalink($wp_query->get_queried_object_id());
+		}
+
+		// Post Paging
+		if ( is_singular() && get_query_var('page') && $redirect_url ) {
+			$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
+			$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
+		}
+
+		// paging and feeds
+		if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
+			while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $redirect['path'] ) ) {
+				// Strip off paging and feed
+				$redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
+				$redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
+				$redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $redirect['path']); // strip off any existing comment paging
+			}
+
+			$addl_path = '';
+			if ( is_feed() ) {
+				$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
+				if ( get_query_var( 'withcomments' ) )
+					$addl_path .= 'comments/';
+				$addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
+				$redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
+			}
+
+			if ( get_query_var('paged') > 0 ) {
+				$paged = get_query_var('paged');
+				$redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
+				if ( !is_feed() ) {
+					if ( $paged > 1 && !is_single() ) {
+						$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
+					} elseif ( !is_single() ) {
+						$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
+					}
+				} elseif ( $paged > 1 ) {
+					$redirect['query'] = add_query_arg( 'paged', $paged, $redirect['query'] );
+				}
+			}
+
+			if ( get_option('page_comments') && ( ( 'newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 ) || ( 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1 ) ) ) {
+				$addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( 'comment-page-' . get_query_var('cpage'), 'commentpaged' );
+				$redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
+			}
+
+			$redirect['path'] = user_trailingslashit( preg_replace('|/index.php/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/
+			if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/index.php/') === false )
+				$redirect['path'] = trailingslashit($redirect['path']) . 'index.php/';
+			if ( !empty( $addl_path ) )
+				$redirect['path'] = trailingslashit($redirect['path']) . $addl_path;
+			$redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path'];
+		}
+	}
+
+	// tack on any additional query vars
+	$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
+	if ( $redirect_url && !empty($redirect['query']) ) {
+		parse_str( $redirect['query'], $_parsed_query );
+		$redirect = @parse_url($redirect_url);
+
+		if ( ! empty( $_parsed_query['name'] ) && ! empty( $redirect['query'] ) ) {
+			parse_str( $redirect['query'], $_parsed_redirect_query );
+
+			if ( empty( $_parsed_redirect_query['name'] ) )
+				unset( $_parsed_query['name'] );
+		}
+
+		$redirect_url = add_query_arg( $_parsed_query, $redirect_url );
+	}
+
+	if ( $redirect_url )
+		$redirect = @parse_url($redirect_url);
+
+	// www.example.com vs example.com
+	$user_home = @parse_url(home_url());
+	if ( !empty($user_home['host']) )
+		$redirect['host'] = $user_home['host'];
+	if ( empty($user_home['path']) )
+		$user_home['path'] = '/';
+
+	// Handle ports
+	if ( !empty($user_home['port']) )
+		$redirect['port'] = $user_home['port'];
+	else
+		unset($redirect['port']);
+
+	// trailing /index.php
+	$redirect['path'] = preg_replace('|/index.php/*?$|', '/', $redirect['path']);
+
+	// Remove trailing spaces from the path
+	$redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] );
+
+	if ( !empty( $redirect['query'] ) ) {
+		// Remove trailing spaces from certain terminating query string args
+		$redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
+
+		// Clean up empty query strings
+		$redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
+
+		// Remove redundant leading ampersands
+		$redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] );
+	}
+
+	// strip /index.php/ when we're not using PATHINFO permalinks
+	if ( !$wp_rewrite->using_index_permalinks() )
+		$redirect['path'] = str_replace('/index.php/', '/', $redirect['path']);
+
+	// trailing slashes
+	if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) {
+		$user_ts_type = '';
+		if ( get_query_var('paged') > 0 ) {
+			$user_ts_type = 'paged';
+		} else {
+			foreach ( array('single', 'category', 'page', 'day', 'month', 'year', 'home') as $type ) {
+				$func = 'is_' . $type;
+				if ( call_user_func($func) ) {
+					$user_ts_type = $type;
+					break;
+				}
+			}
+		}
+		$redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
+	} elseif ( is_front_page() ) {
+		$redirect['path'] = trailingslashit($redirect['path']);
+	}
+
+	// Strip multiple slashes out of the URL
+	if ( strpos($redirect['path'], '//') > -1 )
+		$redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
+
+	// Always trailing slash the Front Page URL
+	if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) )
+		$redirect['path'] = trailingslashit($redirect['path']);
+
+	// Ignore differences in host capitalization, as this can lead to infinite redirects
+	// Only redirect no-www <=> yes-www
+	if ( strtolower($original['host']) == strtolower($redirect['host']) ||
+		( strtolower($original['host']) != 'www.' . strtolower($redirect['host']) && 'www.' . strtolower($original['host']) != strtolower($redirect['host']) ) )
+		$redirect['host'] = $original['host'];
+
+	$compare_original = array($original['host'], $original['path']);
+
+	if ( !empty( $original['port'] ) )
+		$compare_original[] = $original['port'];
+
+	if ( !empty( $original['query'] ) )
+		$compare_original[] = $original['query'];
+
+	$compare_redirect = array($redirect['host'], $redirect['path']);
+
+	if ( !empty( $redirect['port'] ) )
+		$compare_redirect[] = $redirect['port'];
+
+	if ( !empty( $redirect['query'] ) )
+		$compare_redirect[] = $redirect['query'];
+
+	if ( $compare_original !== $compare_redirect ) {
+		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
+		if ( !empty($redirect['port']) )
+			$redirect_url .= ':' . $redirect['port'];
+		$redirect_url .= $redirect['path'];
+		if ( !empty($redirect['query']) )
+			$redirect_url .= '?' . $redirect['query'];
+	}
+
+	if ( !$redirect_url || $redirect_url == $requested_url )
+		return false;
+
+	// Hex encoded octets are case-insensitive.
+	if ( false !== strpos($requested_url, '%') ) {
+		if ( !function_exists('lowercase_octets') ) {
+			function lowercase_octets($matches) {
+				return strtolower( $matches[0] );
+			}
+		}
+		$requested_url = preg_replace_callback('|%[a-fA-F0-9][a-fA-F0-9]|', 'lowercase_octets', $requested_url);
+	}
+
+	// Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
+	$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
+
+	if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
+		return false;
+
+	if ( $do_redirect ) {
+		// protect against chained redirects
+		if ( !redirect_canonical($redirect_url, false) ) {
+			wp_redirect($redirect_url, 301);
+			exit();
+		} else {
+			// Debug
+			// die("1: $redirect_url<br />2: " . redirect_canonical( $redirect_url, false ) );
+			return false;
+		}
+	} else {
+		return $redirect_url;
+	}
+}
+
+/**
+ * Attempts to guess correct post based on query vars.
+ *
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @return bool|string Returns False, if it can't find post, returns correct
+ *		location on success.
+ */
+function redirect_guess_404_permalink() {
+	global $wpdb;
+
+	if ( !get_query_var('name') )
+		return false;
+
+	$where = $wpdb->prepare("post_name LIKE %s", like_escape( get_query_var('name') ) . '%');
+
+	// if any of post_type, year, monthnum, or day are set, use them to refine the query
+	if ( get_query_var('post_type') )
+		$where .= $wpdb->prepare(" AND post_type = %s", get_query_var('post_type'));
+	if ( get_query_var('year') )
+		$where .= $wpdb->prepare(" AND YEAR(post_date) = %d", get_query_var('year'));
+	if ( get_query_var('monthnum') )
+		$where .= $wpdb->prepare(" AND MONTH(post_date) = %d", get_query_var('monthnum'));
+	if ( get_query_var('day') )
+		$where .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", get_query_var('day'));
+
+	$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
+	if ( !$post_id )
+		return false;
+	return get_permalink($post_id);
+}
+
+add_action('template_redirect', 'redirect_canonical');
+
+?>
Index: /tags/3.1/wp-includes/capabilities.php
===================================================================
--- /tags/3.1/wp-includes/capabilities.php	(revision 17487)
+++ /tags/3.1/wp-includes/capabilities.php	(revision 17487)
@@ -0,0 +1,1215 @@
+<?php
+/**
+ * WordPress Roles and Capabilities.
+ *
+ * @package WordPress
+ * @subpackage User
+ */
+
+/**
+ * WordPress User Roles.
+ *
+ * The role option is simple, the structure is organized by role name that store
+ * the name in value of the 'name' key. The capabilities are stored as an array
+ * in the value of the 'capability' key.
+ *
+ * <code>
+ * array (
+ *		'rolename' => array (
+ *			'name' => 'rolename',
+ *			'capabilities' => array()
+ *		)
+ * )
+ * </code>
+ *
+ * @since 2.0.0
+ * @package WordPress
+ * @subpackage User
+ */
+class WP_Roles {
+	/**
+	 * List of roles and capabilities.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $roles;
+
+	/**
+	 * List of the role objects.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $role_objects = array();
+
+	/**
+	 * List of role names.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $role_names = array();
+
+	/**
+	 * Option name for storing role list.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $role_key;
+
+	/**
+	 * Whether to use the database for retrieval and storage.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var bool
+	 */
+	var $use_db = true;
+
+	/**
+	 * PHP4 Constructor - Call {@link WP_Roles::_init()} method.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @return WP_Roles
+	 */
+	function WP_Roles() {
+		$this->_init();
+	}
+
+	/**
+	 * Set up the object properties.
+	 *
+	 * The role key is set to the current prefix for the $wpdb object with
+	 * 'user_roles' appended. If the $wp_user_roles global is set, then it will
+	 * be used and the role option will not be updated or used.
+	 *
+	 * @since 2.1.0
+	 * @access protected
+	 * @uses $wpdb Used to get the database prefix.
+	 * @global array $wp_user_roles Used to set the 'roles' property value.
+	 */
+	function _init () {
+		global $wpdb, $wp_user_roles;
+		$this->role_key = $wpdb->prefix . 'user_roles';
+		if ( ! empty( $wp_user_roles ) ) {
+			$this->roles = $wp_user_roles;
+			$this->use_db = false;
+		} else {
+			$this->roles = get_option( $this->role_key );
+		}
+
+		if ( empty( $this->roles ) )
+			return;
+
+		$this->role_objects = array();
+		$this->role_names =  array();
+		foreach ( (array) $this->roles as $role => $data ) {
+			$this->role_objects[$role] = new WP_Role( $role, $this->roles[$role]['capabilities'] );
+			$this->role_names[$role] = $this->roles[$role]['name'];
+		}
+	}
+
+	/**
+	 * Add role name with capabilities to list.
+	 *
+	 * Updates the list of roles, if the role doesn't already exist.
+	 *
+	 * The capabilities are defined in the following format `array( 'read' => true );`
+	 * To explicitly deny a role a capability you set the value for that capability to false.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 * @param string $display_name Role display name.
+	 * @param array $capabilities List of role capabilities in the above format.
+	 * @return null|WP_Role WP_Role object if role is added, null if already exists.
+	 */
+	function add_role( $role, $display_name, $capabilities = array() ) {
+		if ( isset( $this->roles[$role] ) )
+			return;
+
+		$this->roles[$role] = array(
+			'name' => $display_name,
+			'capabilities' => $capabilities
+			);
+		if ( $this->use_db )
+			update_option( $this->role_key, $this->roles );
+		$this->role_objects[$role] = new WP_Role( $role, $capabilities );
+		$this->role_names[$role] = $display_name;
+		return $this->role_objects[$role];
+	}
+
+	/**
+	 * Remove role by name.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 */
+	function remove_role( $role ) {
+		if ( ! isset( $this->role_objects[$role] ) )
+			return;
+
+		unset( $this->role_objects[$role] );
+		unset( $this->role_names[$role] );
+		unset( $this->roles[$role] );
+
+		if ( $this->use_db )
+			update_option( $this->role_key, $this->roles );
+	}
+
+	/**
+	 * Add capability to role.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 * @param string $cap Capability name.
+	 * @param bool $grant Optional, default is true. Whether role is capable of performing capability.
+	 */
+	function add_cap( $role, $cap, $grant = true ) {
+		$this->roles[$role]['capabilities'][$cap] = $grant;
+		if ( $this->use_db )
+			update_option( $this->role_key, $this->roles );
+	}
+
+	/**
+	 * Remove capability from role.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 * @param string $cap Capability name.
+	 */
+	function remove_cap( $role, $cap ) {
+		unset( $this->roles[$role]['capabilities'][$cap] );
+		if ( $this->use_db )
+			update_option( $this->role_key, $this->roles );
+	}
+
+	/**
+	 * Retrieve role object by name.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 * @return object|null Null, if role does not exist. WP_Role object, if found.
+	 */
+	function &get_role( $role ) {
+		if ( isset( $this->role_objects[$role] ) )
+			return $this->role_objects[$role];
+		else
+			return null;
+	}
+
+	/**
+	 * Retrieve list of role names.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @return array List of role names.
+	 */
+	function get_names() {
+		return $this->role_names;
+	}
+
+	/**
+	 * Whether role name is currently in the list of available roles.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name to look up.
+	 * @return bool
+	 */
+	function is_role( $role )
+	{
+		return isset( $this->role_names[$role] );
+	}
+}
+
+/**
+ * WordPress Role class.
+ *
+ * @since 2.0.0
+ * @package WordPress
+ * @subpackage User
+ */
+class WP_Role {
+	/**
+	 * Role name.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $name;
+
+	/**
+	 * List of capabilities the role contains.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $capabilities;
+
+	/**
+	 * PHP4 Constructor - Set up object properties.
+	 *
+	 * The list of capabilities, must have the key as the name of the capability
+	 * and the value a boolean of whether it is granted to the role.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 * @param array $capabilities List of capabilities.
+	 * @return WP_Role
+	 */
+	function WP_Role( $role, $capabilities ) {
+		$this->name = $role;
+		$this->capabilities = $capabilities;
+	}
+
+	/**
+	 * Assign role a capability.
+	 *
+	 * @see WP_Roles::add_cap() Method uses implementation for role.
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $cap Capability name.
+	 * @param bool $grant Whether role has capability privilege.
+	 */
+	function add_cap( $cap, $grant = true ) {
+		global $wp_roles;
+
+		if ( ! isset( $wp_roles ) )
+			$wp_roles = new WP_Roles();
+
+		$this->capabilities[$cap] = $grant;
+		$wp_roles->add_cap( $this->name, $cap, $grant );
+	}
+
+	/**
+	 * Remove capability from role.
+	 *
+	 * This is a container for {@link WP_Roles::remove_cap()} to remove the
+	 * capability from the role. That is to say, that {@link
+	 * WP_Roles::remove_cap()} implements the functionality, but it also makes
+	 * sense to use this class, because you don't need to enter the role name.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $cap Capability name.
+	 */
+	function remove_cap( $cap ) {
+		global $wp_roles;
+
+		if ( ! isset( $wp_roles ) )
+			$wp_roles = new WP_Roles();
+
+		unset( $this->capabilities[$cap] );
+		$wp_roles->remove_cap( $this->name, $cap );
+	}
+
+	/**
+	 * Whether role has capability.
+	 *
+	 * The capabilities is passed through the 'role_has_cap' filter. The first
+	 * parameter for the hook is the list of capabilities the class has
+	 * assigned. The second parameter is the capability name to look for. The
+	 * third and final parameter for the hook is the role name.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $cap Capability name.
+	 * @return bool True, if user has capability. False, if doesn't have capability.
+	 */
+	function has_cap( $cap ) {
+		$capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );
+		if ( !empty( $capabilities[$cap] ) )
+			return $capabilities[$cap];
+		else
+			return false;
+	}
+
+}
+
+/**
+ * WordPress User class.
+ *
+ * @since 2.0.0
+ * @package WordPress
+ * @subpackage User
+ */
+class WP_User {
+	/**
+	 * User data container.
+	 *
+	 * This will be set as properties of the object.
+	 *
+	 * @since 2.0.0
+	 * @access private
+	 * @var array
+	 */
+	var $data;
+
+	/**
+	 * The user's ID.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var int
+	 */
+	var $ID = 0;
+
+	/**
+	 * The deprecated user's ID.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @deprecated Use WP_User::$ID
+	 * @see WP_User::$ID
+	 * @var int
+	 */
+	var $id = 0;
+
+	/**
+	 * The individual capabilities the user has been given.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $caps = array();
+
+	/**
+	 * User metadata option name.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $cap_key;
+
+	/**
+	 * The roles the user is part of.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $roles = array();
+
+	/**
+	 * All capabilities the user has, including individual and role based.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $allcaps = array();
+
+	/**
+	 * First name of the user.
+	 *
+	 * Created to prevent notices.
+	 *
+	 * @since 2.7.0
+	 * @access public
+	 * @var string
+	 */
+	var $first_name = '';
+
+	/**
+	 * Last name of the user.
+	 *
+	 * Created to prevent notices.
+	 *
+	 * @since 2.7.0
+	 * @access public
+	 * @var string
+	 */
+	var $last_name = '';
+
+	/**
+	 * The filter context applied to user data fields.
+	 *
+	 * @since 2.9.0
+	 * @access private
+	 * @var string
+	 */
+	var $filter = null;
+
+	/**
+	 * PHP4 Constructor - Sets up the object properties.
+	 *
+	 * Retrieves the userdata and then assigns all of the data keys to direct
+	 * properties of the object. Calls {@link WP_User::_init_caps()} after
+	 * setting up the object's user data properties.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param int|string $id User's ID or username
+	 * @param int $name Optional. User's username
+	 * @param int $blog_id Optional Blog ID, defaults to current blog.
+	 * @return WP_User
+	 */
+	function WP_User( $id, $name = '', $blog_id = '' ) {
+
+		if ( empty( $id ) && empty( $name ) )
+			return;
+
+		if ( ! is_numeric( $id ) ) {
+			$name = $id;
+			$id = 0;
+		}
+
+		if ( ! empty( $id ) )
+			$this->data = get_userdata( $id );
+		else
+			$this->data = get_userdatabylogin( $name );
+
+		if ( empty( $this->data->ID ) )
+			return;
+
+		foreach ( get_object_vars( $this->data ) as $key => $value ) {
+			$this->{$key} = $value;
+		}
+
+		$this->id = $this->ID;
+		$this->for_blog( $blog_id );
+	}
+
+	/**
+	 * Set up capability object properties.
+	 *
+	 * Will set the value for the 'cap_key' property to current database table
+	 * prefix, followed by 'capabilities'. Will then check to see if the
+	 * property matching the 'cap_key' exists and is an array. If so, it will be
+	 * used.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string $cap_key Optional capability key
+	 * @access protected
+	 */
+	function _init_caps( $cap_key = '' ) {
+		global $wpdb;
+		if ( empty($cap_key) )
+			$this->cap_key = $wpdb->prefix . 'capabilities';
+		else
+			$this->cap_key = $cap_key;
+		$this->caps = &$this->{$this->cap_key};
+		if ( ! is_array( $this->caps ) )
+			$this->caps = array();
+		$this->get_role_caps();
+	}
+
+	/**
+	 * Retrieve all of the role capabilities and merge with individual capabilities.
+	 *
+	 * All of the capabilities of the roles the user belongs to are merged with
+	 * the users individual roles. This also means that the user can be denied
+	 * specific roles that their role might have, but the specific user isn't
+	 * granted permission to.
+	 *
+	 * @since 2.0.0
+	 * @uses $wp_roles
+	 * @access public
+	 */
+	function get_role_caps() {
+		global $wp_roles;
+
+		if ( ! isset( $wp_roles ) )
+			$wp_roles = new WP_Roles();
+
+		//Filter out caps that are not role names and assign to $this->roles
+		if ( is_array( $this->caps ) )
+			$this->roles = array_filter( array_keys( $this->caps ), array( &$wp_roles, 'is_role' ) );
+
+		//Build $allcaps from role caps, overlay user's $caps
+		$this->allcaps = array();
+		foreach ( (array) $this->roles as $role ) {
+			$the_role =& $wp_roles->get_role( $role );
+			$this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities );
+		}
+		$this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps );
+	}
+
+	/**
+	 * Add role to user.
+	 *
+	 * Updates the user's meta data option with capabilities and roles.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 */
+	function add_role( $role ) {
+		$this->caps[$role] = true;
+		update_user_meta( $this->ID, $this->cap_key, $this->caps );
+		$this->get_role_caps();
+		$this->update_user_level_from_caps();
+	}
+
+	/**
+	 * Remove role from user.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 */
+	function remove_role( $role ) {
+		if ( !in_array($role, $this->roles) )
+			return;
+		unset( $this->caps[$role] );
+		update_user_meta( $this->ID, $this->cap_key, $this->caps );
+		$this->get_role_caps();
+		$this->update_user_level_from_caps();
+	}
+
+	/**
+	 * Set the role of the user.
+	 *
+	 * This will remove the previous roles of the user and assign the user the
+	 * new one. You can set the role to an empty string and it will remove all
+	 * of the roles from the user.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $role Role name.
+	 */
+	function set_role( $role ) {
+		foreach ( (array) $this->roles as $oldrole )
+			unset( $this->caps[$oldrole] );
+
+		if ( 1 == count( $this->roles ) && $role == $this->roles[0] )
+			return;
+
+		if ( !empty( $role ) ) {
+			$this->caps[$role] = true;
+			$this->roles = array( $role => true );
+		} else {
+			$this->roles = false;
+		}
+		update_user_meta( $this->ID, $this->cap_key, $this->caps );
+		$this->get_role_caps();
+		$this->update_user_level_from_caps();
+		do_action( 'set_user_role', $this->ID, $role );
+	}
+
+	/**
+	 * Choose the maximum level the user has.
+	 *
+	 * Will compare the level from the $item parameter against the $max
+	 * parameter. If the item is incorrect, then just the $max parameter value
+	 * will be returned.
+	 *
+	 * Used to get the max level based on the capabilities the user has. This
+	 * is also based on roles, so if the user is assigned the Administrator role
+	 * then the capability 'level_10' will exist and the user will get that
+	 * value.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param int $max Max level of user.
+	 * @param string $item Level capability name.
+	 * @return int Max Level.
+	 */
+	function level_reduction( $max, $item ) {
+		if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
+			$level = intval( $matches[1] );
+			return max( $max, $level );
+		} else {
+			return $max;
+		}
+	}
+
+	/**
+	 * Update the maximum user level for the user.
+	 *
+	 * Updates the 'user_level' user metadata (includes prefix that is the
+	 * database table prefix) with the maximum user level. Gets the value from
+	 * the all of the capabilities that the user has.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 */
+	function update_user_level_from_caps() {
+		global $wpdb;
+		$this->user_level = array_reduce( array_keys( $this->allcaps ), array( &$this, 'level_reduction' ), 0 );
+		update_user_meta( $this->ID, $wpdb->prefix . 'user_level', $this->user_level );
+	}
+
+	/**
+	 * Add capability and grant or deny access to capability.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $cap Capability name.
+	 * @param bool $grant Whether to grant capability to user.
+	 */
+	function add_cap( $cap, $grant = true ) {
+		$this->caps[$cap] = $grant;
+		update_user_meta( $this->ID, $this->cap_key, $this->caps );
+	}
+
+	/**
+	 * Remove capability from user.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string $cap Capability name.
+	 */
+	function remove_cap( $cap ) {
+		if ( empty( $this->caps[$cap] ) )
+			return;
+		unset( $this->caps[$cap] );
+		update_user_meta( $this->ID, $this->cap_key, $this->caps );
+	}
+
+	/**
+	 * Remove all of the capabilities of the user.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 */
+	function remove_all_caps() {
+		global $wpdb;
+		$this->caps = array();
+		delete_user_meta( $this->ID, $this->cap_key );
+		delete_user_meta( $this->ID, $wpdb->prefix . 'user_level' );
+		$this->get_role_caps();
+	}
+
+	/**
+	 * Whether user has capability or role name.
+	 *
+	 * This is useful for looking up whether the user has a specific role
+	 * assigned to the user. The second optional parameter can also be used to
+	 * check for capabilities against a specfic post.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param string|int $cap Capability or role name to search.
+	 * @param int $post_id Optional. Post ID to check capability against specific post.
+	 * @return bool True, if user has capability; false, if user does not have capability.
+	 */
+	function has_cap( $cap ) {
+		if ( is_numeric( $cap ) ) {
+			_deprecated_argument( __FUNCTION__, '2.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.') );
+			$cap = $this->translate_level_to_cap( $cap );
+		}
+
+		$args = array_slice( func_get_args(), 1 );
+		$args = array_merge( array( $cap, $this->ID ), $args );
+		$caps = call_user_func_array( 'map_meta_cap', $args );
+
+		// Multisite super admin has all caps by definition, Unless specifically denied.
+		if ( is_multisite() && is_super_admin( $this->ID ) ) {
+			if ( in_array('do_not_allow', $caps) )
+				return false;
+			return true;
+		}
+
+		// Must have ALL requested caps
+		$capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args );
+		$capabilities['exist'] = true; // Everyone is allowed to exist
+		foreach ( (array) $caps as $cap ) {
+			//echo "Checking cap $cap<br />";
+			if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] )
+				return false;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Convert numeric level to level capability name.
+	 *
+	 * Prepends 'level_' to level number.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 *
+	 * @param int $level Level number, 1 to 10.
+	 * @return string
+	 */
+	function translate_level_to_cap( $level ) {
+		return 'level_' . $level;
+	}
+
+	/**
+	 * Set the blog to operate on. Defaults to the current blog.
+	 *
+	 * @since 3.0.0
+	 *
+	 * @param int $blog_id Optional Blog ID, defaults to current blog.
+	 */
+	function for_blog( $blog_id = '' ) {
+		global $wpdb;
+		if ( ! empty( $blog_id ) )
+			$cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
+		else
+			$cap_key = '';
+		$this->_init_caps( $cap_key );
+	}
+}
+
+/**
+ * Map meta capabilities to primitive capabilities.
+ *
+ * This does not actually compare whether the user ID has the actual capability,
+ * just what the capability or capabilities are. Meta capability list value can
+ * be 'delete_user', 'edit_user', 'remove_user', 'promote_user', 'delete_post',
+ * 'delete_page', 'edit_post', 'edit_page', 'read_post', or 'read_page'.
+ *
+ * @since 2.0.0
+ *
+ * @param string $cap Capability name.
+ * @param int $user_id User ID.
+ * @return array Actual capabilities for meta capability.
+ */
+function map_meta_cap( $cap, $user_id ) {
+	$args = array_slice( func_get_args(), 2 );
+	$caps = array();
+
+	switch ( $cap ) {
+	case 'remove_user':
+		$caps[] = 'remove_users';
+		break;
+	case 'promote_user':
+		$caps[] = 'promote_users';
+		break;
+	case 'edit_user':
+		// Allow user to edit itself
+		if ( isset( $args[0] ) && $user_id == $args[0] )
+			break;
+		// Fall through
+	case 'edit_users':
+		// If multisite these caps are allowed only for super admins.
+		if ( is_multisite() && !is_super_admin( $user_id ) )
+			$caps[] = 'do_not_allow';
+		else
+			$caps[] = 'edit_users'; // Explicit due to primitive fall through
+		break;
+	case 'delete_post':
+	case 'delete_page':
+		$author_data = get_userdata( $user_id );
+		$post = get_post( $args[0] );
+		$post_type = get_post_type_object( $post->post_type );
+
+		if ( ! $post_type->map_meta_cap ) {
+			$caps[] = $post_type->cap->$cap;
+			// Prior to 3.1 we would re-call map_meta_cap here.
+			if ( 'delete_post' == $cap )
+				$cap = $post_type->cap->$cap;
+			break;
+		}
+
+		if ( '' != $post->post_author ) {
+			$post_author_data = get_userdata( $post->post_author );
+		} else {
+			// No author set yet, so default to current user for cap checks.
+			$post_author_data = $author_data;
+		}
+
+		// If the user is the author...
+		if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) {
+			// If the post is published...
+			if ( 'publish' == $post->post_status ) {
+				$caps[] = $post_type->cap->delete_published_posts;
+			} elseif ( 'trash' == $post->post_status ) {
+				if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) )
+					$caps[] = $post_type->cap->delete_published_posts;
+			} else {
+				// If the post is draft...
+				$caps[] = $post_type->cap->delete_posts;
+			}
+		} else {
+			// The user is trying to edit someone else's post.
+			$caps[] = $post_type->cap->delete_others_posts;
+			// The post is published, extra cap required.
+			if ( 'publish' == $post->post_status )
+				$caps[] = $post_type->cap->delete_published_posts;
+			elseif ( 'private' == $post->post_status )
+				$caps[] = $post_type->cap->delete_private_posts;
+		}
+		break;
+		// edit_post breaks down to edit_posts, edit_published_posts, or
+		// edit_others_posts
+	case 'edit_post':
+	case 'edit_page':
+		$author_data = get_userdata( $user_id );
+		$post = get_post( $args[0] );
+		$post_type = get_post_type_object( $post->post_type );
+
+		if ( ! $post_type->map_meta_cap ) {
+			$caps[] = $post_type->cap->$cap;
+			// Prior to 3.1 we would re-call map_meta_cap here.
+			if ( 'edit_post' == $cap )
+				$cap = $post_type->cap->$cap;
+			break;
+		}
+
+		if ( '' != $post->post_author ) {
+			$post_author_data = get_userdata( $post->post_author );
+		} else {
+			// No author set yet, so default to current user for cap checks.
+			$post_author_data = $author_data;
+		}
+
+		//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />";
+		// If the user is the author...
+		if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) {
+			// If the post is published...
+			if ( 'publish' == $post->post_status ) {
+				$caps[] = $post_type->cap->edit_published_posts;
+			} elseif ( 'trash' == $post->post_status ) {
+				if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) )
+					$caps[] = $post_type->cap->edit_published_posts;
+			} else {
+				// If the post is draft...
+				$caps[] = $post_type->cap->edit_posts;
+			}
+		} else {
+			// The user is trying to edit someone else's post.
+			$caps[] = $post_type->cap->edit_others_posts;
+			// The post is published, extra cap required.
+			if ( 'publish' == $post->post_status )
+				$caps[] = $post_type->cap->edit_published_posts;
+			elseif ( 'private' == $post->post_status )
+				$caps[] = $post_type->cap->edit_private_posts;
+		}
+		break;
+	case 'read_post':
+	case 'read_page':
+		$author_data = get_userdata( $user_id );
+		$post = get_post( $args[0] );
+		$post_type = get_post_type_object( $post->post_type );
+
+		if ( ! $post_type->map_meta_cap ) {
+			$caps[] = $post_type->cap->$cap;
+			// Prior to 3.1 we would re-call map_meta_cap here.
+			if ( 'read_post' == $cap )
+				$cap = $post_type->cap->$cap;
+			break;
+		}
+
+		if ( 'private' != $post->post_status ) {
+			$caps[] = $post_type->cap->read;
+			break;
+		}
+
+		if ( '' != $post->post_author ) {
+			$post_author_data = get_userdata( $post->post_author );
+		} else {
+			// No author set yet, so default to current user for cap checks.
+			$post_author_data = $author_data;
+		}
+
+		if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID )
+			$caps[] = $post_type->cap->read;
+		else
+			$caps[] = $post_type->cap->read_private_posts;
+		break;
+	case 'edit_comment':
+		$comment = get_comment( $args[0] );
+		$post = get_post( $comment->comment_post_ID );
+		$post_type_object = get_post_type_object( $post->post_type );
+
+		$caps = map_meta_cap( $post_type_object->cap->edit_post, $user_id, $post->ID );
+		break;
+	case 'unfiltered_upload':
+		if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
+			$caps[] = $cap;
+		else
+			$caps[] = 'do_not_allow';
+		break;
+	case 'edit_files':
+	case 'edit_plugins':
+	case 'edit_themes':
+		if ( defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT ) {
+			$caps[] = 'do_not_allow';
+			break;
+		}
+		// Fall through if not DISALLOW_FILE_EDIT.
+	case 'update_plugins':
+	case 'delete_plugins':
+	case 'install_plugins':
+	case 'update_themes':
+	case 'delete_themes':
+	case 'install_themes':
+	case 'update_core':
+		// Disallow anything that creates, deletes, or edits core, plugin, or theme files.
+		// Files in uploads are excepted.
+		if ( defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS ) {
+			$caps[] = 'do_not_allow';
+			break;
+		}
+		// Fall through if not DISALLOW_FILE_MODS.
+	case 'unfiltered_html':
+		// Disallow unfiltered_html for all users, even admins and super admins.
+		if ( defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML ) {
+			$caps[] = 'do_not_allow';
+			break;
+		}
+		// Fall through if not DISALLOW_UNFILTERED_HTML
+	case 'delete_user':
+	case 'delete_users':
+		// If multisite these caps are allowed only for super admins.
+		if ( is_multisite() && !is_super_admin( $user_id ) ) {
+			$caps[] = 'do_not_allow';
+		} else {
+			if ( 'delete_user' == $cap )
+				$cap = 'delete_users';
+			$caps[] = $cap;
+		}
+		break;
+	case 'create_users':
+		if ( !is_multisite() )
+			$caps[] = $cap;
+		elseif ( is_super_admin() || get_site_option( 'add_new_users' ) )
+			$caps[] = $cap;
+		else
+			$caps[] = 'do_not_allow';
+		break;
+	default:
+		// Handle meta capabilities for custom post types.
+		$post_type_meta_caps = _post_type_meta_capabilities();
+		if ( isset( $post_type_meta_caps[ $cap ] ) ) {
+			$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
+			return call_user_func_array( 'map_meta_cap', $args );
+		}
+
+		// If no meta caps match, return the original cap.
+		$caps[] = $cap;
+	}
+
+	return apply_filters('map_meta_cap', $caps, $cap, $user_id, $args);
+}
+
+/**
+ * Whether current user has capability or role.
+ *
+ * @since 2.0.0
+ *
+ * @param string $capability Capability or role name.
+ * @return bool
+ */
+function current_user_can( $capability ) {
+	$current_user = wp_get_current_user();
+
+	if ( empty( $current_user ) )
+		return false;
+
+	$args = array_slice( func_get_args(), 1 );
+	$args = array_merge( array( $capability ), $args );
+
+	return call_user_func_array( array( &$current_user, 'has_cap' ), $args );
+}
+
+/**
+ * Whether current user has a capability or role for a given blog.
+ *
+ * @since 3.0.0
+ *
+ * @param int $blog_id Blog ID
+ * @param string $capability Capability or role name.
+ * @return bool
+ */
+function current_user_can_for_blog( $blog_id, $capability ) {
+	$current_user = wp_get_current_user();
+
+	if ( empty( $current_user ) )
+		return false;
+
+	// Create new object to avoid stomping the global current_user.
+	$user = new WP_User( $current_user->id) ;
+
+	// Set the blog id.  @todo add blog id arg to WP_User constructor?
+	$user->for_blog( $blog_id );
+
+	$args = array_slice( func_get_args(), 2 );
+	$args = array_merge( array( $capability ), $args );
+
+	return call_user_func_array( array( &$user, 'has_cap' ), $args );
+}
+
+/**
+ * Whether author of supplied post has capability or role.
+ *
+ * @since 2.9.0
+ *
+ * @param int|object $post Post ID or post object.
+ * @param string $capability Capability or role name.
+ * @return bool
+ */
+function author_can( $post, $capability ) {
+	if ( !$post = get_post($post) )
+		return false;
+
+	$author = new WP_User( $post->post_author );
+
+	if ( empty( $author->ID ) )
+		return false;
+
+	$args = array_slice( func_get_args(), 2 );
+	$args = array_merge( array( $capability ), $args );
+
+	return call_user_func_array( array( &$author, 'has_cap' ), $args );
+}
+
+/**
+ * Whether a particular user has capability or role.
+ *
+ * @since 3.1.0
+ *
+ * @param int|object $user User ID or object.
+ * @param string $capability Capability or role name.
+ * @return bool
+ */
+function user_can( $user, $capability ) {
+	if ( ! is_object( $user ) )
+		$user = new WP_User( $user );
+
+	if ( ! $user || ! $user->ID )
+		return false;
+
+	$args = array_slice( func_get_args(), 2 );
+	$args = array_merge( array( $capability ), $args );
+
+	return call_user_func_array( array( &$user, 'has_cap' ), $args );
+}
+
+/**
+ * Retrieve role object.
+ *
+ * @see WP_Roles::get_role() Uses method to retrieve role object.
+ * @since 2.0.0
+ *
+ * @param string $role Role name.
+ * @return object
+ */
+function get_role( $role ) {
+	global $wp_roles;
+
+	if ( ! isset( $wp_roles ) )
+		$wp_roles = new WP_Roles();
+
+	return $wp_roles->get_role( $role );
+}
+
+/**
+ * Add role, if it does not exist.
+ *
+ * @see WP_Roles::add_role() Uses method to add role.
+ * @since 2.0.0
+ *
+ * @param string $role Role name.
+ * @param string $display_name Display name for role.
+ * @param array $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false );
+ * @return null|WP_Role WP_Role object if role is added, null if already exists.
+ */
+function add_role( $role, $display_name, $capabilities = array() ) {
+	global $wp_roles;
+
+	if ( ! isset( $wp_roles ) )
+		$wp_roles = new WP_Roles();
+
+	return $wp_roles->add_role( $role, $display_name, $capabilities );
+}
+
+/**
+ * Remove role, if it exists.
+ *
+ * @see WP_Roles::remove_role() Uses method to remove role.
+ * @since 2.0.0
+ *
+ * @param string $role Role name.
+ * @return null
+ */
+function remove_role( $role ) {
+	global $wp_roles;
+
+	if ( ! isset( $wp_roles ) )
+		$wp_roles = new WP_Roles();
+
+	return $wp_roles->remove_role( $role );
+}
+
+/**
+ * Retrieve a list of super admins.
+ *
+ * @since 3.0.0
+ *
+ * @uses $super_admins Super admins global variable, if set.
+ *
+ * @return array List of super admin logins
+ */
+function get_super_admins() {
+	global $super_admins;
+
+	if ( isset($super_admins) )
+		return $super_admins;
+	else
+		return get_site_option( 'site_admins', array('admin') );
+}
+
+/**
+ * Determine if user is a site admin.
+ *
+ * @since 3.0.0
+ *
+ * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
+ * @return bool True if the user is a site admin.
+ */
+function is_super_admin( $user_id = false ) {
+	if ( $user_id )
+		$user = new WP_User( $user_id );
+	else
+		$user = wp_get_current_user();
+
+	if ( empty( $user->id ) )
+		return false;
+
+	if ( is_multisite() ) {
+		$super_admins = get_super_admins();
+		if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) )
+			return true;
+	} else {
+		if ( $user->has_cap('delete_users') )
+			return true;
+	}
+
+	return false;
+}
+
+?>
Index: /tags/3.1/wp-includes/category-template.php
===================================================================
--- /tags/3.1/wp-includes/category-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/category-template.php	(revision 17487)
@@ -0,0 +1,1217 @@
+<?php
+/**
+ * Category Template Tags and API.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Retrieve category link URL.
+ *
+ * @since 1.0.0
+ * @see get_term_link()
+ *
+ * @param int|object $category Category ID or object.
+ * @return string Link on success, empty string if category does not exist.
+ */
+function get_category_link( $category ) {
+	if ( ! is_object( $category ) )
+		$category = (int) $category;
+
+	$category = get_term_link( $category, 'category' );
+
+	if ( is_wp_error( $category ) )
+		return '';
+
+	return $category;
+}
+
+/**
+ * Retrieve category parents with separator.
+ *
+ * @since 1.2.0
+ *
+ * @param int $id Category ID.
+ * @param bool $link Optional, default is false. Whether to format with link.
+ * @param string $separator Optional, default is '/'. How to separate categories.
+ * @param bool $nicename Optional, default is false. Whether to use nice name for display.
+ * @param array $visited Optional. Already linked to categories to prevent duplicates.
+ * @return string
+ */
+function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {
+	$chain = '';
+	$parent = &get_category( $id );
+	if ( is_wp_error( $parent ) )
+		return $parent;
+
+	if ( $nicename )
+		$name = $parent->slug;
+	else
+		$name = $parent->name;
+
+	if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {
+		$visited[] = $parent->parent;
+		$chain .= get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );
+	}
+
+	if ( $link )
+		$chain .= '<a href="' . get_category_link( $parent->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $parent->name ) ) . '">'.$name.'</a>' . $separator;
+	else
+		$chain .= $name.$separator;
+	return $chain;
+}
+
+/**
+ * Retrieve post categories.
+ *
+ * @since 0.71
+ * @uses $post
+ *
+ * @param int $id Optional, default to current post ID. The post ID.
+ * @return array
+ */
+function get_the_category( $id = false ) {
+	$categories = get_the_terms( $id, 'category' );
+	if ( ! $categories )
+		$categories = array();
+
+	$categories = array_values( $categories );
+
+	foreach ( array_keys( $categories ) as $key ) {
+		_make_cat_compat( $categories[$key] );
+	}
+
+	// Filter name is plural because we return alot of categories not just one
+	return apply_filters( 'get_the_categories', $categories );
+}
+
+/**
+ * Sort categories by name.
+ *
+ * Used by usort() as a callback, should not be used directly. Can actually be
+ * used to sort any term object.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param object $a
+ * @param object $b
+ * @return int
+ */
+function _usort_terms_by_name( $a, $b ) {
+	return strcmp( $a->name, $b->name );
+}
+
+/**
+ * Sort categories by ID.
+ *
+ * Used by usort() as a callback, should not be used directly. Can actually be
+ * used to sort any term object.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param object $a
+ * @param object $b
+ * @return int
+ */
+function _usort_terms_by_ID( $a, $b ) {
+	if ( $a->term_id > $b->term_id )
+		return 1;
+	elseif ( $a->term_id < $b->term_id )
+		return -1;
+	else
+		return 0;
+}
+
+/**
+ * Retrieve category name based on category ID.
+ *
+ * @since 0.71
+ *
+ * @param int $cat_ID Category ID.
+ * @return string Category name.
+ */
+function get_the_category_by_ID( $cat_ID ) {
+	$cat_ID = (int) $cat_ID;
+	$category = &get_category( $cat_ID );
+	if ( is_wp_error( $category ) )
+		return $category;
+	return $category->name;
+}
+
+/**
+ * Retrieve category list in either HTML list or custom format.
+ *
+ * @since 1.5.1
+ *
+ * @param string $separator Optional, default is empty string. Separator for between the categories.
+ * @param string $parents Optional. How to display the parents.
+ * @param int $post_id Optional. Post ID to retrieve categories.
+ * @return string
+ */
+function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
+	global $wp_rewrite;
+	$categories = get_the_category( $post_id );
+	if ( !is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) )
+		return apply_filters( 'the_category', '', $separator, $parents );
+
+	if ( empty( $categories ) )
+		return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents );
+
+	$rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"';
+
+	$thelist = '';
+	if ( '' == $separator ) {
+		$thelist .= '<ul class="post-categories">';
+		foreach ( $categories as $category ) {
+			$thelist .= "\n\t<li>";
+			switch ( strtolower( $parents ) ) {
+				case 'multiple':
+					if ( $category->parent )
+						$thelist .= get_category_parents( $category->parent, true, $separator );
+					$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
+					break;
+				case 'single':
+					$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>';
+					if ( $category->parent )
+						$thelist .= get_category_parents( $category->parent, false, $separator );
+					$thelist .= $category->name.'</a></li>';
+					break;
+				case '':
+				default:
+					$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a></li>';
+			}
+		}
+		$thelist .= '</ul>';
+	} else {
+		$i = 0;
+		foreach ( $categories as $category ) {
+			if ( 0 < $i )
+				$thelist .= $separator;
+			switch ( strtolower( $parents ) ) {
+				case 'multiple':
+					if ( $category->parent )
+						$thelist .= get_category_parents( $category->parent, true, $separator );
+					$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
+					break;
+				case 'single':
+					$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>';
+					if ( $category->parent )
+						$thelist .= get_category_parents( $category->parent, false, $separator );
+					$thelist .= "$category->name</a>";
+					break;
+				case '':
+				default:
+					$thelist .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '" ' . $rel . '>' . $category->name.'</a>';
+			}
+			++$i;
+		}
+	}
+	return apply_filters( 'the_category', $thelist, $separator, $parents );
+}
+
+
+/**
+ * Check if the current post in within any of the given categories.
+ *
+ * The given categories are checked against the post's categories' term_ids, names and slugs.
+ * Categories given as integers will only be checked against the post's categories' term_ids.
+ *
+ * Prior to v2.5 of WordPress, category names were not supported.
+ * Prior to v2.7, category slugs were not supported.
+ * Prior to v2.7, only one category could be compared: in_category( $single_category ).
+ * Prior to v2.7, this function could only be used in the WordPress Loop.
+ * As of 2.7, the function can be used anywhere if it is provided a post ID or post object.
+ *
+ * @since 1.2.0
+ *
+ * @param int|string|array $category Category ID, name or slug, or array of said.
+ * @param int|object $_post Optional. Post to check instead of the current post. (since 2.7.0)
+ * @return bool True if the current post is in any of the given categories.
+ */
+function in_category( $category, $post = null ) {
+	if ( empty( $category ) )
+		return false;
+
+	return has_term( $category, 'category', $post );
+}
+
+/**
+ * Display the category list for the post.
+ *
+ * @since 0.71
+ *
+ * @param string $separator Optional, default is empty string. Separator for between the categories.
+ * @param string $parents Optional. How to display the parents.
+ * @param int $post_id Optional. Post ID to retrieve categories.
+ */
+function the_category( $separator = '', $parents='', $post_id = false ) {
+	echo get_the_category_list( $separator, $parents, $post_id );
+}
+
+/**
+ * Retrieve category description.
+ *
+ * @since 1.0.0
+ *
+ * @param int $category Optional. Category ID. Will use global category ID by default.
+ * @return string Category description, available.
+ */
+function category_description( $category = 0 ) {
+	return term_description( $category, 'category' );
+}
+
+/**
+ * Display or retrieve the HTML dropdown list of categories.
+ *
+ * The list of arguments is below:
+ *     'show_option_all' (string) - Text to display for showing all categories.
+ *     'show_option_none' (string) - Text to display for showing no categories.
+ *     'orderby' (string) default is 'ID' - What column to use for ordering the
+ * categories.
+ *     'order' (string) default is 'ASC' - What direction to order categories.
+ *     'show_last_update' (bool|int) default is 0 - See {@link get_categories()}
+ *     'show_count' (bool|int) default is 0 - Whether to show how many posts are
+ * in the category.
+ *     'hide_empty' (bool|int) default is 1 - Whether to hide categories that
+ * don't have any posts attached to them.
+ *     'child_of' (int) default is 0 - See {@link get_categories()}.
+ *     'exclude' (string) - See {@link get_categories()}.
+ *     'echo' (bool|int) default is 1 - Whether to display or retrieve content.
+ *     'depth' (int) - The max depth.
+ *     'tab_index' (int) - Tab index for select element.
+ *     'name' (string) - The name attribute value for select element.
+ *     'id' (string) - The ID attribute value for select element. Defaults to name if omitted.
+ *     'class' (string) - The class attribute value for select element.
+ *     'selected' (int) - Which category ID is selected.
+ *     'taxonomy' (string) - The name of the taxonomy to retrieve. Defaults to category.
+ *
+ * The 'hierarchical' argument, which is disabled by default, will override the
+ * depth argument, unless it is true. When the argument is false, it will
+ * display all of the categories. When it is enabled it will use the value in
+ * the 'depth' argument.
+ *
+ * @since 2.1.0
+ *
+ * @param string|array $args Optional. Override default arguments.
+ * @return string HTML content only if 'echo' argument is 0.
+ */
+function wp_dropdown_categories( $args = '' ) {
+	$defaults = array(
+		'show_option_all' => '', 'show_option_none' => '',
+		'orderby' => 'id', 'order' => 'ASC',
+		'show_last_update' => 0, 'show_count' => 0,
+		'hide_empty' => 1, 'child_of' => 0,
+		'exclude' => '', 'echo' => 1,
+		'selected' => 0, 'hierarchical' => 0,
+		'name' => 'cat', 'id' => '',
+		'class' => 'postform', 'depth' => 0,
+		'tab_index' => 0, 'taxonomy' => 'category',
+		'hide_if_empty' => false
+	);
+
+	$defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
+
+	// Back compat.
+	if ( isset( $args['type'] ) && 'link' == $args['type'] ) {
+		_deprecated_argument( __FUNCTION__, '3.0', '' );
+		$args['taxonomy'] = 'link_category';
+	}
+
+	$r = wp_parse_args( $args, $defaults );
+
+	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
+		$r['pad_counts'] = true;
+	}
+
+	$r['include_last_update_time'] = $r['show_last_update'];
+	extract( $r );
+
+	$tab_index_attribute = '';
+	if ( (int) $tab_index > 0 )
+		$tab_index_attribute = " tabindex=\"$tab_index\"";
+
+	$categories = get_terms( $taxonomy, $r );
+	$name = esc_attr( $name );
+	$class = esc_attr( $class );
+	$id = $id ? esc_attr( $id ) : $name;
+
+	if ( ! $r['hide_if_empty'] || ! empty($categories) )
+		$output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
+	else
+		$output = '';
+
+	if ( empty($categories) && ! $r['hide_if_empty'] && !empty($show_option_none) ) {
+		$show_option_none = apply_filters( 'list_cats', $show_option_none );
+		$output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n";
+	}
+
+	if ( ! empty( $categories ) ) {
+
+		if ( $show_option_all ) {
+			$show_option_all = apply_filters( 'list_cats', $show_option_all );
+			$selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
+			$output .= "\t<option value='0'$selected>$show_option_all</option>\n";
+		}
+
+		if ( $show_option_none ) {
+			$show_option_none = apply_filters( 'list_cats', $show_option_none );
+			$selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
+			$output .= "\t<option value='-1'$selected>$show_option_none</option>\n";
+		}
+
+		if ( $hierarchical )
+			$depth = $r['depth'];  // Walk the full depth.
+		else
+			$depth = -1; // Flat.
+
+		$output .= walk_category_dropdown_tree( $categories, $depth, $r );
+	}
+	if ( ! $r['hide_if_empty'] || ! empty($categories) )
+		$output .= "</select>\n";
+
+
+	$output = apply_filters( 'wp_dropdown_cats', $output );
+
+	if ( $echo )
+		echo $output;
+
+	return $output;
+}
+
+/**
+ * Display or retrieve the HTML list of categories.
+ *
+ * The list of arguments is below:
+ *     'show_option_all' (string) - Text to display for showing all categories.
+ *     'orderby' (string) default is 'ID' - What column to use for ordering the
+ * categories.
+ *     'order' (string) default is 'ASC' - What direction to order categories.
+ *     'show_last_update' (bool|int) default is 0 - See {@link
+ * walk_category_dropdown_tree()}
+ *     'show_count' (bool|int) default is 0 - Whether to show how many posts are
+ * in the category.
+ *     'hide_empty' (bool|int) default is 1 - Whether to hide categories that
+ * don't have any posts attached to them.
+ *     'use_desc_for_title' (bool|int) default is 1 - Whether to use the
+ * description instead of the category title.
+ *     'feed' - See {@link get_categories()}.
+ *     'feed_type' - See {@link get_categories()}.
+ *     'feed_image' - See {@link get_categories()}.
+ *     'child_of' (int) default is 0 - See {@link get_categories()}.
+ *     'exclude' (string) - See {@link get_categories()}.
+ *     'exclude_tree' (string) - See {@link get_categories()}.
+ *     'echo' (bool|int) default is 1 - Whether to display or retrieve content.
+ *     'current_category' (int) - See {@link get_categories()}.
+ *     'hierarchical' (bool) - See {@link get_categories()}.
+ *     'title_li' (string) - See {@link get_categories()}.
+ *     'depth' (int) - The max depth.
+ *
+ * @since 2.1.0
+ *
+ * @param string|array $args Optional. Override default arguments.
+ * @return string HTML content only if 'echo' argument is 0.
+ */
+function wp_list_categories( $args = '' ) {
+	$defaults = array(
+		'show_option_all' => '', 'show_option_none' => __('No categories'),
+		'orderby' => 'name', 'order' => 'ASC',
+		'show_last_update' => 0, 'style' => 'list',
+		'show_count' => 0, 'hide_empty' => 1,
+		'use_desc_for_title' => 1, 'child_of' => 0,
+		'feed' => '', 'feed_type' => '',
+		'feed_image' => '', 'exclude' => '',
+		'exclude_tree' => '', 'current_category' => 0,
+		'hierarchical' => true, 'title_li' => __( 'Categories' ),
+		'echo' => 1, 'depth' => 0,
+		'taxonomy' => 'category'
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+
+	if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
+		$r['pad_counts'] = true;
+
+	if ( isset( $r['show_date'] ) )
+		$r['include_last_update_time'] = $r['show_date'];
+
+	if ( true == $r['hierarchical'] ) {
+		$r['exclude_tree'] = $r['exclude'];
+		$r['exclude'] = '';
+	}
+
+	if ( !isset( $r['class'] ) )
+		$r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
+
+	extract( $r );
+
+	if ( !taxonomy_exists($taxonomy) )
+		return false;
+
+	$categories = get_categories( $r );
+
+	$output = '';
+	if ( $title_li && 'list' == $style )
+			$output = '<li class="' . esc_attr( $class ) . '">' . $title_li . '<ul>';
+
+	if ( empty( $categories ) ) {
+		if ( ! empty( $show_option_none ) ) {
+			if ( 'list' == $style )
+				$output .= '<li>' . $show_option_none . '</li>';
+			else
+				$output .= $show_option_none;
+		}
+	} else {
+		if( !empty( $show_option_all ) )
+			if ( 'list' == $style )
+				$output .= '<li><a href="' .  get_bloginfo( 'url' )  . '">' . $show_option_all . '</a></li>';
+			else
+				$output .= '<a href="' .  get_bloginfo( 'url' )  . '">' . $show_option_all . '</a>';
+
+		if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
+			$current_term_object = get_queried_object();
+			if ( $r['taxonomy'] == $current_term_object->taxonomy )
+				$r['current_category'] = get_queried_object_id();
+		}
+
+		if ( $hierarchical )
+			$depth = $r['depth'];
+		else
+			$depth = -1; // Flat.
+
+		$output .= walk_category_tree( $categories, $depth, $r );
+	}
+
+	if ( $title_li && 'list' == $style )
+		$output .= '</ul></li>';
+
+	$output = apply_filters( 'wp_list_categories', $output, $args );
+
+	if ( $echo )
+		echo $output;
+	else
+		return $output;
+}
+
+/**
+ * Display tag cloud.
+ *
+ * The text size is set by the 'smallest' and 'largest' arguments, which will
+ * use the 'unit' argument value for the CSS text size unit. The 'format'
+ * argument can be 'flat' (default), 'list', or 'array'. The flat value for the
+ * 'format' argument will separate tags with spaces. The list value for the
+ * 'format' argument will format the tags in a UL HTML list. The array value for
+ * the 'format' argument will return in PHP array type format.
+ *
+ * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
+ * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.
+ *
+ * The 'number' argument is how many tags to return. By default, the limit will
+ * be to return the top 45 tags in the tag cloud list.
+ *
+ * The 'topic_count_text_callback' argument is a function, which, given the count
+ * of the posts  with that tag, returns a text for the tooltip of the tag link.
+ *
+ * The 'exclude' and 'include' arguments are used for the {@link get_tags()}
+ * function. Only one should be used, because only one will be used and the
+ * other ignored, if they are both set.
+ *
+ * @since 2.3.0
+ *
+ * @param array|string $args Optional. Override default arguments.
+ * @return array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
+ */
+function wp_tag_cloud( $args = '' ) {
+	$defaults = array(
+		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
+		'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',
+		'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'echo' => true
+	);
+	$args = wp_parse_args( $args, $defaults );
+
+	$tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
+
+	if ( empty( $tags ) )
+		return;
+
+	foreach ( $tags as $key => $tag ) {
+		if ( 'edit' == $args['link'] )
+			$link = get_edit_tag_link( $tag->term_id, $tag->taxonomy );
+		else
+			$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
+		if ( is_wp_error( $link ) )
+			return false;
+
+		$tags[ $key ]->link = $link;
+		$tags[ $key ]->id = $tag->term_id;
+	}
+
+	$return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
+
+	$return = apply_filters( 'wp_tag_cloud', $return, $args );
+
+	if ( 'array' == $args['format'] || empty($args['echo']) )
+		return $return;
+
+	echo $return;
+}
+
+/**
+ * Default text for tooltip for tag links
+ *
+ * @param integer $count number of posts with that tag
+ * @return string text for the tooltip of a tag link.
+ */
+function default_topic_count_text( $count ) {
+	return sprintf( _n('%s topic', '%s topics', $count), number_format_i18n( $count ) );
+}
+
+/**
+ * Default topic count scaling for tag links
+ *
+ * @param integer $count number of posts with that tag
+ * @return integer scaled count
+ */
+function default_topic_count_scale( $count ) {
+	return round(log10($count + 1) * 100);
+}
+
+
+/**
+ * Generates a tag cloud (heatmap) from provided data.
+ *
+ * The text size is set by the 'smallest' and 'largest' arguments, which will
+ * use the 'unit' argument value for the CSS text size unit. The 'format'
+ * argument can be 'flat' (default), 'list', or 'array'. The flat value for the
+ * 'format' argument will separate tags with spaces. The list value for the
+ * 'format' argument will format the tags in a UL HTML list. The array value for
+ * the 'format' argument will return in PHP array type format.
+ *
+ * The 'tag_cloud_sort' filter allows you to override the sorting.
+ * Passed to the filter: $tags array and $args array, has to return the $tags array
+ * after sorting it.
+ *
+ * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
+ * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC' or
+ * 'RAND'.
+ *
+ * The 'number' argument is how many tags to return. By default, the limit will
+ * be to return the entire tag cloud list.
+ *
+ * The 'topic_count_text_callback' argument is a function, which given the count
+ * of the posts  with that tag returns a text for the tooltip of the tag link.
+ *
+ * @todo Complete functionality.
+ * @since 2.3.0
+ *
+ * @param array $tags List of tags.
+ * @param string|array $args Optional, override default arguments.
+ * @return string
+ */
+function wp_generate_tag_cloud( $tags, $args = '' ) {
+	global $wp_rewrite;
+	$defaults = array(
+		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0,
+		'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',
+		'topic_count_text_callback' => 'default_topic_count_text',
+		'topic_count_scale_callback' => 'default_topic_count_scale', 'filter' => 1,
+	);
+
+	if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
+		$body = 'return sprintf (
+			_n(' . var_export($args['single_text'], true) . ', ' . var_export($args['multiple_text'], true) . ', $count),
+			number_format_i18n( $count ));';
+		$args['topic_count_text_callback'] = create_function('$count', $body);
+	}
+
+	$args = wp_parse_args( $args, $defaults );
+	extract( $args );
+
+	if ( empty( $tags ) )
+		return;
+
+	$tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
+	if ( $tags_sorted != $tags  ) { // the tags have been sorted by a plugin
+		$tags = $tags_sorted;
+		unset($tags_sorted);
+	} else {
+		if ( 'RAND' == $order ) {
+			shuffle($tags);
+		} else {
+			// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
+			if ( 'name' == $orderby )
+				uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') );
+			else
+				uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
+
+			if ( 'DESC' == $order )
+				$tags = array_reverse( $tags, true );
+		}
+	}
+
+	if ( $number > 0 )
+		$tags = array_slice($tags, 0, $number);
+
+	$counts = array();
+	$real_counts = array(); // For the alt tag
+	foreach ( (array) $tags as $key => $tag ) {
+		$real_counts[ $key ] = $tag->count;
+		$counts[ $key ] = $topic_count_scale_callback($tag->count);
+	}
+
+	$min_count = min( $counts );
+	$spread = max( $counts ) - $min_count;
+	if ( $spread <= 0 )
+		$spread = 1;
+	$font_spread = $largest - $smallest;
+	if ( $font_spread < 0 )
+		$font_spread = 1;
+	$font_step = $font_spread / $spread;
+
+	$a = array();
+
+	foreach ( $tags as $key => $tag ) {
+		$count = $counts[ $key ];
+		$real_count = $real_counts[ $key ];
+		$tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';
+		$tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
+		$tag_name = $tags[ $key ]->name;
+		$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( call_user_func( $topic_count_text_callback, $real_count ) ) . "' style='font-size: " .
+			( $smallest + ( ( $count - $min_count ) * $font_step ) )
+			. "$unit;'>$tag_name</a>";
+	}
+
+	switch ( $format ) :
+	case 'array' :
+		$return =& $a;
+		break;
+	case 'list' :
+		$return = "<ul class='wp-tag-cloud'>\n\t<li>";
+		$return .= join( "</li>\n\t<li>", $a );
+		$return .= "</li>\n</ul>\n";
+		break;
+	default :
+		$return = join( $separator, $a );
+		break;
+	endswitch;
+
+	if ( $filter )
+		return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args );
+	else
+		return $return;
+}
+
+/**
+ * Callback for comparing tags based on name
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _wp_tag_cloud_name_sort_cb( $a, $b ) {
+	return strnatcasecmp( $a->name, $b->name );
+}
+
+/**
+ * Callback for comparing tags based on count
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _wp_tag_cloud_count_sort_cb( $a, $b ) {
+	return ( $a->count > $b->count );
+}
+
+//
+// Helper functions
+//
+
+/**
+ * Retrieve HTML list content for category list.
+ *
+ * @uses Walker_Category to create HTML list content.
+ * @since 2.1.0
+ * @see Walker_Category::walk() for parameters and return description.
+ */
+function walk_category_tree() {
+	$args = func_get_args();
+	// the user's options are the third parameter
+	if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') )
+		$walker = new Walker_Category;
+	else
+		$walker = $args[2]['walker'];
+
+	return call_user_func_array(array( &$walker, 'walk' ), $args );
+}
+
+/**
+ * Retrieve HTML dropdown (select) content for category list.
+ *
+ * @uses Walker_CategoryDropdown to create HTML dropdown content.
+ * @since 2.1.0
+ * @see Walker_CategoryDropdown::walk() for parameters and return description.
+ */
+function walk_category_dropdown_tree() {
+	$args = func_get_args();
+	// the user's options are the third parameter
+	if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') )
+		$walker = new Walker_CategoryDropdown;
+	else
+		$walker = $args[2]['walker'];
+
+	return call_user_func_array(array( &$walker, 'walk' ), $args );
+}
+
+/**
+ * Create HTML list of categories.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
+class Walker_Category extends Walker {
+	/**
+	 * @see Walker::$tree_type
+	 * @since 2.1.0
+	 * @var string
+	 */
+	var $tree_type = 'category';
+
+	/**
+	 * @see Walker::$db_fields
+	 * @since 2.1.0
+	 * @todo Decouple this
+	 * @var array
+	 */
+	var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
+
+	/**
+	 * @see Walker::start_lvl()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of category. Used for tab indentation.
+	 * @param array $args Will only append content if style argument value is 'list'.
+	 */
+	function start_lvl(&$output, $depth, $args) {
+		if ( 'list' != $args['style'] )
+			return;
+
+		$indent = str_repeat("\t", $depth);
+		$output .= "$indent<ul class='children'>\n";
+	}
+
+	/**
+	 * @see Walker::end_lvl()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of category. Used for tab indentation.
+	 * @param array $args Will only append content if style argument value is 'list'.
+	 */
+	function end_lvl(&$output, $depth, $args) {
+		if ( 'list' != $args['style'] )
+			return;
+
+		$indent = str_repeat("\t", $depth);
+		$output .= "$indent</ul>\n";
+	}
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $category Category data object.
+	 * @param int $depth Depth of category in reference to parents.
+	 * @param array $args
+	 */
+	function start_el(&$output, $category, $depth, $args) {
+		extract($args);
+
+		$cat_name = esc_attr( $category->name );
+		$cat_name = apply_filters( 'list_cats', $cat_name, $category );
+		$link = '<a href="' . esc_attr( get_term_link($category) ) . '" ';
+		if ( $use_desc_for_title == 0 || empty($category->description) )
+			$link .= 'title="' . esc_attr( sprintf(__( 'View all posts filed under %s' ), $cat_name) ) . '"';
+		else
+			$link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
+		$link .= '>';
+		$link .= $cat_name . '</a>';
+
+		if ( !empty($feed_image) || !empty($feed) ) {
+			$link .= ' ';
+
+			if ( empty($feed_image) )
+				$link .= '(';
+
+			$link .= '<a href="' . get_term_feed_link( $category->term_id, $category->taxonomy, $feed_type ) . '"';
+
+			if ( empty($feed) ) {
+				$alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
+			} else {
+				$title = ' title="' . $feed . '"';
+				$alt = ' alt="' . $feed . '"';
+				$name = $feed;
+				$link .= $title;
+			}
+
+			$link .= '>';
+
+			if ( empty($feed_image) )
+				$link .= $name;
+			else
+				$link .= "<img src='$feed_image'$alt$title" . ' />';
+
+			$link .= '</a>';
+
+			if ( empty($feed_image) )
+				$link .= ')';
+		}
+
+		if ( !empty($show_count) )
+			$link .= ' (' . intval($category->count) . ')';
+
+		if ( !empty($show_date) )
+			$link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
+
+		if ( 'list' == $args['style'] ) {
+			$output .= "\t<li";
+			$class = 'cat-item cat-item-' . $category->term_id;
+			if ( !empty($current_category) ) {
+				$_current_category = get_term( $current_category, $category->taxonomy );
+				if ( $category->term_id == $current_category )
+					$class .=  ' current-cat';
+				elseif ( $category->term_id == $_current_category->parent )
+					$class .=  ' current-cat-parent';
+			}
+			$output .=  ' class="' . $class . '"';
+			$output .= ">$link\n";
+		} else {
+			$output .= "\t$link<br />\n";
+		}
+	}
+
+	/**
+	 * @see Walker::end_el()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $page Not used.
+	 * @param int $depth Depth of category. Not used.
+	 * @param array $args Only uses 'list' for whether should append to output.
+	 */
+	function end_el(&$output, $page, $depth, $args) {
+		if ( 'list' != $args['style'] )
+			return;
+
+		$output .= "</li>\n";
+	}
+
+}
+
+/**
+ * Create HTML dropdown list of Categories.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
+class Walker_CategoryDropdown extends Walker {
+	/**
+	 * @see Walker::$tree_type
+	 * @since 2.1.0
+	 * @var string
+	 */
+	var $tree_type = 'category';
+
+	/**
+	 * @see Walker::$db_fields
+	 * @since 2.1.0
+	 * @todo Decouple this
+	 * @var array
+	 */
+	var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $category Category data object.
+	 * @param int $depth Depth of category. Used for padding.
+	 * @param array $args Uses 'selected', 'show_count', and 'show_last_update' keys, if they exist.
+	 */
+	function start_el(&$output, $category, $depth, $args) {
+		$pad = str_repeat('&nbsp;', $depth * 3);
+
+		$cat_name = apply_filters('list_cats', $category->name, $category);
+		$output .= "\t<option class=\"level-$depth\" value=\"".$category->term_id."\"";
+		if ( $category->term_id == $args['selected'] )
+			$output .= ' selected="selected"';
+		$output .= '>';
+		$output .= $pad.$cat_name;
+		if ( $args['show_count'] )
+			$output .= '&nbsp;&nbsp;('. $category->count .')';
+		if ( $args['show_last_update'] ) {
+			$format = 'Y-m-d';
+			$output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp);
+		}
+		$output .= "</option>\n";
+	}
+}
+
+//
+// Tags
+//
+
+/**
+ * Retrieve the link to the tag.
+ *
+ * @since 2.3.0
+ * @see get_term_link()
+ *
+ * @param int|object $tag Tag ID or object.
+ * @return string Link on success, empty string if tag does not exist.
+ */
+function get_tag_link( $tag ) {
+	if ( ! is_object( $tag ) )
+		$tag = (int) $tag;
+
+	$tag = get_term_link( $tag, 'post_tag' );
+
+	if ( is_wp_error( $tag ) )
+		return '';
+
+	return $tag;
+}
+
+/**
+ * Retrieve the tags for a post.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'get_the_tags' filter on the list of post tags.
+ *
+ * @param int $id Post ID.
+ * @return array
+ */
+function get_the_tags( $id = 0 ) {
+	return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );
+}
+
+/**
+ * Retrieve the tags for a post formatted as a string.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'the_tags' filter on string list of tags.
+ *
+ * @param string $before Optional. Before tags.
+ * @param string $sep Optional. Between tags.
+ * @param string $after Optional. After tags.
+ * @return string
+ */
+function get_the_tag_list( $before = '', $sep = '', $after = '' ) {
+	return apply_filters( 'the_tags', get_the_term_list( 0, 'post_tag', $before, $sep, $after ), $before, $sep, $after);
+}
+
+/**
+ * Retrieve the tags for a post.
+ *
+ * @since 2.3.0
+ *
+ * @param string $before Optional. Before list.
+ * @param string $sep Optional. Separate items using this.
+ * @param string $after Optional. After list.
+ * @return string
+ */
+function the_tags( $before = null, $sep = ', ', $after = '' ) {
+	if ( null === $before )
+		$before = __('Tags: ');
+	echo get_the_tag_list($before, $sep, $after);
+}
+
+/**
+ * Retrieve tag description.
+ *
+ * @since 2.8
+ *
+ * @param int $tag Optional. Tag ID. Will use global tag ID by default.
+ * @return string Tag description, available.
+ */
+function tag_description( $tag = 0 ) {
+	return term_description( $tag );
+}
+
+/**
+ * Retrieve term description.
+ *
+ * @since 2.8
+ *
+ * @param int $term Optional. Term ID. Will use global term ID by default.
+ * @return string Term description, available.
+ */
+function term_description( $term = 0, $taxonomy = 'post_tag' ) {
+	if ( !$term && ( is_tax() || is_tag() || is_category() ) ) {
+		$term = get_queried_object();
+		$taxonomy = $term->taxonomy;
+		$term = $term->term_id;
+	}
+	$description = get_term_field( 'description', $term, $taxonomy );
+	return is_wp_error( $description ) ? '' : $description;
+}
+
+/**
+ * Retrieve the terms of the taxonomy that are attached to the post.
+ *
+ * This function can only be used within the loop.
+ *
+ * @since 2.5.0
+ *
+ * @param int $id Post ID. Is not optional.
+ * @param string $taxonomy Taxonomy name.
+ * @return array|bool False on failure. Array of term objects on success.
+ */
+function get_the_terms( $id = 0, $taxonomy ) {
+	global $post;
+
+ 	$id = (int) $id;
+
+	if ( !$id ) {
+		if ( !$post->ID )
+			return false;
+		else
+			$id = (int) $post->ID;
+	}
+
+	$terms = get_object_term_cache( $id, $taxonomy );
+	if ( false === $terms ) {
+		$terms = wp_get_object_terms( $id, $taxonomy );
+		wp_cache_add($id, $terms, $taxonomy . '_relationships');
+	}
+
+	$terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy );
+
+	if ( empty( $terms ) )
+		return false;
+
+	return $terms;
+}
+
+/**
+ * Retrieve a post's terms as a list with specified format.
+ *
+ * @since 2.5.0
+ *
+ * @param int $id Post ID.
+ * @param string $taxonomy Taxonomy name.
+ * @param string $before Optional. Before list.
+ * @param string $sep Optional. Separate items using this.
+ * @param string $after Optional. After list.
+ * @return string
+ */
+function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '' ) {
+	$terms = get_the_terms( $id, $taxonomy );
+
+	if ( is_wp_error( $terms ) )
+		return $terms;
+
+	if ( empty( $terms ) )
+		return false;
+
+	foreach ( $terms as $term ) {
+		$link = get_term_link( $term, $taxonomy );
+		if ( is_wp_error( $link ) )
+			return $link;
+		$term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
+	}
+
+	$term_links = apply_filters( "term_links-$taxonomy", $term_links );
+
+	return $before . join( $sep, $term_links ) . $after;
+}
+
+/**
+ * Display the terms in a list.
+ *
+ * @since 2.5.0
+ *
+ * @param int $id Post ID.
+ * @param string $taxonomy Taxonomy name.
+ * @param string $before Optional. Before list.
+ * @param string $sep Optional. Separate items using this.
+ * @param string $after Optional. After list.
+ * @return null|bool False on WordPress error. Returns null when displaying.
+ */
+function the_terms( $id = 0, $taxonomy, $before = '', $sep = ', ', $after = '' ) {
+	$term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
+
+	if ( is_wp_error( $term_list ) )
+		return false;
+
+	echo apply_filters('the_terms', $term_list, $taxonomy, $before, $sep, $after);
+}
+
+
+/**
+ * Check if the current post has any of given category.
+ *
+ * @since 3.1.0
+ *
+ * @param string|int|array $tag Optional. The category name/term_id/slug or array of them to check for.
+ * @param int|object $post Optional. Post to check instead of the current post.
+ * @return bool True if the current post has any of the given categories (or any category, if no category specified).
+ */
+function has_category( $category = '', $post = null ) {
+	return has_term( $category, 'category', $post );
+}
+
+/**
+ * Check if the current post has any of given tags.
+ *
+ * The given tags are checked against the post's tags' term_ids, names and slugs.
+ * Tags given as integers will only be checked against the post's tags' term_ids.
+ * If no tags are given, determines if post has any tags.
+ *
+ * Prior to v2.7 of WordPress, tags given as integers would also be checked against the post's tags' names and slugs (in addition to term_ids)
+ * Prior to v2.7, this function could only be used in the WordPress Loop.
+ * As of 2.7, the function can be used anywhere if it is provided a post ID or post object.
+ *
+ * @since 2.6.0
+ *
+ * @param string|int|array $tag Optional. The tag name/term_id/slug or array of them to check for.
+ * @param int|object $post Optional. Post to check instead of the current post. (since 2.7.0)
+ * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
+ */
+function has_tag( $tag = '', $post = null ) {
+	return has_term( $tag, 'post_tag', $post );
+}
+
+/**
+ * Check if the current post has any of given terms.
+ *
+ * The given terms are checked against the post's terms' term_ids, names and slugs.
+ * Terms given as integers will only be checked against the post's terms' term_ids.
+ * If no terms are given, determines if post has any terms.
+ *
+ * @since 3.1.0
+ *
+ * @param string|int|array $term Optional. The term name/term_id/slug or array of them to check for.
+ * @param string $taxonomy Taxonomy name
+ * @param int|object $post Optional. Post to check instead of the current post.
+ * @return bool True if the current post has any of the given tags (or any tag, if no tag specified).
+ */
+function has_term( $term = '', $taxonomy = '', $post = null ) {
+	$post = get_post($post);
+
+	if ( !$post )
+		return false;
+
+	$r = is_object_in_term( $post->ID, $taxonomy, $term );
+	if ( is_wp_error( $r ) )
+		return false;
+
+	return $r;
+}
+
+?>
Index: /tags/3.1/wp-includes/category.php
===================================================================
--- /tags/3.1/wp-includes/category.php	(revision 17487)
+++ /tags/3.1/wp-includes/category.php	(revision 17487)
@@ -0,0 +1,359 @@
+<?php
+/**
+ * WordPress Category API
+ *
+ * @package WordPress
+ */
+
+/**
+ * Retrieves all category IDs.
+ *
+ * @since 2.0.0
+ * @link http://codex.wordpress.org/Function_Reference/get_all_category_ids
+ *
+ * @return object List of all of the category IDs.
+ */
+function get_all_category_ids() {
+	if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) {
+		$cat_ids = get_terms( 'category', array('fields' => 'ids', 'get' => 'all') );
+		wp_cache_add( 'all_category_ids', $cat_ids, 'category' );
+	}
+
+	return $cat_ids;
+}
+
+/**
+ * Retrieve list of category objects.
+ *
+ * If you change the type to 'link' in the arguments, then the link categories
+ * will be returned instead. Also all categories will be updated to be backwards
+ * compatible with pre-2.3 plugins and themes.
+ *
+ * @since 2.1.0
+ * @see get_terms() Type of arguments that can be changed.
+ * @link http://codex.wordpress.org/Function_Reference/get_categories
+ *
+ * @param string|array $args Optional. Change the defaults retrieving categories.
+ * @return array List of categories.
+ */
+function &get_categories( $args = '' ) {
+	$defaults = array( 'taxonomy' => 'category' );
+	$args = wp_parse_args( $args, $defaults );
+
+	$taxonomy = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args );
+
+	// Back compat
+	if ( isset($args['type']) && 'link' == $args['type'] ) {
+		_deprecated_argument( __FUNCTION__, '3.0', '' );
+		$taxonomy = $args['taxonomy'] = 'link_category';
+	}
+
+	$categories = (array) get_terms( $taxonomy, $args );
+
+	foreach ( array_keys( $categories ) as $k )
+		_make_cat_compat( $categories[$k] );
+
+	return $categories;
+}
+
+/**
+ * Retrieves category data given a category ID or category object.
+ *
+ * If you pass the $category parameter an object, which is assumed to be the
+ * category row object retrieved the database. It will cache the category data.
+ *
+ * If you pass $category an integer of the category ID, then that category will
+ * be retrieved from the database, if it isn't already cached, and pass it back.
+ *
+ * If you look at get_term(), then both types will be passed through several
+ * filters and finally sanitized based on the $filter parameter value.
+ *
+ * The category will converted to maintain backwards compatibility.
+ *
+ * @since 1.5.1
+ * @uses get_term() Used to get the category data from the taxonomy.
+ *
+ * @param int|object $category Category ID or Category row object
+ * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
+ * @param string $filter Optional. Default is raw or no WordPress defined filter will applied.
+ * @return mixed Category data in type defined by $output parameter.
+ */
+function &get_category( $category, $output = OBJECT, $filter = 'raw' ) {
+	$category = get_term( $category, 'category', $output, $filter );
+	if ( is_wp_error( $category ) )
+		return $category;
+
+	_make_cat_compat( $category );
+
+	return $category;
+}
+
+/**
+ * Retrieve category based on URL containing the category slug.
+ *
+ * Breaks the $category_path parameter up to get the category slug.
+ *
+ * Tries to find the child path and will return it. If it doesn't find a
+ * match, then it will return the first category matching slug, if $full_match,
+ * is set to false. If it does not, then it will return null.
+ *
+ * It is also possible that it will return a WP_Error object on failure. Check
+ * for it when using this function.
+ *
+ * @since 2.1.0
+ *
+ * @param string $category_path URL containing category slugs.
+ * @param bool $full_match Optional. Whether full path should be matched.
+ * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
+ * @return null|object|array Null on failure. Type is based on $output value.
+ */
+function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) {
+	$category_path = rawurlencode( urldecode( $category_path ) );
+	$category_path = str_replace( '%2F', '/', $category_path );
+	$category_path = str_replace( '%20', ' ', $category_path );
+	$category_paths = '/' . trim( $category_path, '/' );
+	$leaf_path  = sanitize_title( basename( $category_paths ) );
+	$category_paths = explode( '/', $category_paths );
+	$full_path = '';
+	foreach ( (array) $category_paths as $pathdir )
+		$full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title( $pathdir );
+
+	$categories = get_terms( 'category', array('get' => 'all', 'slug' => $leaf_path) );
+
+	if ( empty( $categories ) )
+		return null;
+
+	foreach ( $categories as $category ) {
+		$path = '/' . $leaf_path;
+		$curcategory = $category;
+		while ( ( $curcategory->parent != 0 ) && ( $curcategory->parent != $curcategory->term_id ) ) {
+			$curcategory = get_term( $curcategory->parent, 'category' );
+			if ( is_wp_error( $curcategory ) )
+				return $curcategory;
+			$path = '/' . $curcategory->slug . $path;
+		}
+
+		if ( $path == $full_path )
+			return get_category( $category->term_id, $output );
+	}
+
+	// If full matching is not required, return the first cat that matches the leaf.
+	if ( ! $full_match )
+		return get_category( $categories[0]->term_id, $output );
+
+	return null;
+}
+
+/**
+ * Retrieve category object by category slug.
+ *
+ * @since 2.3.0
+ *
+ * @param string $slug The category slug.
+ * @return object Category data object
+ */
+function get_category_by_slug( $slug  ) {
+	$category = get_term_by( 'slug', $slug, 'category' );
+	if ( $category )
+		_make_cat_compat( $category );
+
+	return $category;
+}
+
+
+/**
+ * Retrieve the ID of a category from its name.
+ *
+ * @since 1.0.0
+ *
+ * @param string $cat_name Optional. Default is 'General' and can be any category name.
+ * @return int 0, if failure and ID of category on success.
+ */
+function get_cat_ID( $cat_name='General' ) {
+	$cat = get_term_by( 'name', $cat_name, 'category' );
+	if ( $cat )
+		return $cat->term_id;
+	return 0;
+}
+
+
+/**
+ * Retrieve the name of a category from its ID.
+ *
+ * @since 1.0.0
+ *
+ * @param int $cat_id Category ID
+ * @return string Category name, or an empty string if category doesn't exist.
+ */
+function get_cat_name( $cat_id ) {
+	$cat_id = (int) $cat_id;
+	$category = &get_category( $cat_id );
+	if ( ! $category || is_wp_error( $category ) )
+		return '';
+	return $category->name;
+}
+
+
+/**
+ * Check if a category is an ancestor of another category.
+ *
+ * You can use either an id or the category object for both parameters. If you
+ * use an integer the category will be retrieved.
+ *
+ * @since 2.1.0
+ *
+ * @param int|object $cat1 ID or object to check if this is the parent category.
+ * @param int|object $cat2 The child category.
+ * @return bool Whether $cat2 is child of $cat1
+ */
+function cat_is_ancestor_of( $cat1, $cat2 ) {
+	if ( ! isset($cat1->term_id) )
+		$cat1 = &get_category( $cat1 );
+	if ( ! isset($cat2->parent) )
+		$cat2 = &get_category( $cat2 );
+
+	if ( empty($cat1->term_id) || empty($cat2->parent) )
+		return false;
+	if ( $cat2->parent == $cat1->term_id )
+		return true;
+
+	return cat_is_ancestor_of( $cat1, get_category( $cat2->parent ) );
+}
+
+
+/**
+ * Sanitizes category data based on context.
+ *
+ * @since 2.3.0
+ * @uses sanitize_term() See this function for what context are supported.
+ *
+ * @param object|array $category Category data
+ * @param string $context Optional. Default is 'display'.
+ * @return object|array Same type as $category with sanitized data for safe use.
+ */
+function sanitize_category( $category, $context = 'display' ) {
+	return sanitize_term( $category, 'category', $context );
+}
+
+
+/**
+ * Sanitizes data in single category key field.
+ *
+ * @since 2.3.0
+ * @uses sanitize_term_field() See function for more details.
+ *
+ * @param string $field Category key to sanitize
+ * @param mixed $value Category value to sanitize
+ * @param int $cat_id Category ID
+ * @param string $context What filter to use, 'raw', 'display', etc.
+ * @return mixed Same type as $value after $value has been sanitized.
+ */
+function sanitize_category_field( $field, $value, $cat_id, $context ) {
+	return sanitize_term_field( $field, $value, $cat_id, 'category', $context );
+}
+
+/* Tags */
+
+
+/**
+ * Retrieves all post tags.
+ *
+ * @since 2.3.0
+ * @see get_terms() For list of arguments to pass.
+ * @uses apply_filters() Calls 'get_tags' hook on array of tags and with $args.
+ *
+ * @param string|array $args Tag arguments to use when retrieving tags.
+ * @return array List of tags.
+ */
+function &get_tags( $args = '' ) {
+	$tags = get_terms( 'post_tag', $args );
+
+	if ( empty( $tags ) ) {
+		$return = array();
+		return $return;
+	}
+
+	$tags = apply_filters( 'get_tags', $tags, $args );
+	return $tags;
+}
+
+
+/**
+ * Retrieve post tag by tag ID or tag object.
+ *
+ * If you pass the $tag parameter an object, which is assumed to be the tag row
+ * object retrieved the database. It will cache the tag data.
+ *
+ * If you pass $tag an integer of the tag ID, then that tag will
+ * be retrieved from the database, if it isn't already cached, and pass it back.
+ *
+ * If you look at get_term(), then both types will be passed through several
+ * filters and finally sanitized based on the $filter parameter value.
+ *
+ * @since 2.3.0
+ *
+ * @param int|object $tag
+ * @param string $output Optional. Constant OBJECT, ARRAY_A, or ARRAY_N
+ * @param string $filter Optional. Default is raw or no WordPress defined filter will applied.
+ * @return object|array Return type based on $output value.
+ */
+function &get_tag( $tag, $output = OBJECT, $filter = 'raw' ) {
+	return get_term( $tag, 'post_tag', $output, $filter );
+}
+
+
+/* Cache */
+
+
+/**
+ * Remove the category cache data based on ID.
+ *
+ * @since 2.1.0
+ * @uses clean_term_cache() Clears the cache for the category based on ID
+ *
+ * @param int $id Category ID
+ */
+function clean_category_cache( $id ) {
+	clean_term_cache( $id, 'category' );
+}
+
+
+/**
+ * Update category structure to old pre 2.3 from new taxonomy structure.
+ *
+ * This function was added for the taxonomy support to update the new category
+ * structure with the old category one. This will maintain compatibility with
+ * plugins and themes which depend on the old key or property names.
+ *
+ * The parameter should only be passed a variable and not create the array or
+ * object inline to the parameter. The reason for this is that parameter is
+ * passed by reference and PHP will fail unless it has the variable.
+ *
+ * There is no return value, because everything is updated on the variable you
+ * pass to it. This is one of the features with using pass by reference in PHP.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param array|object $category Category Row object or array
+ */
+function _make_cat_compat( &$category ) {
+	if ( is_object( $category ) ) {
+		$category->cat_ID = &$category->term_id;
+		$category->category_count = &$category->count;
+		$category->category_description = &$category->description;
+		$category->cat_name = &$category->name;
+		$category->category_nicename = &$category->slug;
+		$category->category_parent = &$category->parent;
+	} elseif ( is_array( $category ) && isset( $category['term_id'] ) ) {
+		$category['cat_ID'] = &$category['term_id'];
+		$category['category_count'] = &$category['count'];
+		$category['category_description'] = &$category['description'];
+		$category['cat_name'] = &$category['name'];
+		$category['category_nicename'] = &$category['slug'];
+		$category['category_parent'] = &$category['parent'];
+	}
+}
+
+
+?>
Index: /tags/3.1/wp-includes/class-IXR.php
===================================================================
--- /tags/3.1/wp-includes/class-IXR.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-IXR.php	(revision 17487)
@@ -0,0 +1,1065 @@
+<?php
+/**
+ * IXR - The Incutio XML-RPC Library
+ *
+ * Copyright (c) 2010, Incutio Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  - Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *  - Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *  - Neither the name of Incutio Ltd. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package IXR
+ * @since 1.5
+ *
+ * @copyright  Incutio Ltd 2010 (http://www.incutio.com)
+ * @version    1.7.4 7th September 2010
+ * @author     Simon Willison
+ * @link       http://scripts.incutio.com/xmlrpc/ Site/manual
+ * @license    http://www.opensource.org/licenses/bsd-license.php BSD
+ */
+
+/**
+ * IXR_Value
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_Value {
+    var $data;
+    var $type;
+
+    function IXR_Value($data, $type = false)
+    {
+        $this->data = $data;
+        if (!$type) {
+            $type = $this->calculateType();
+        }
+        $this->type = $type;
+        if ($type == 'struct') {
+            // Turn all the values in the array in to new IXR_Value objects
+            foreach ($this->data as $key => $value) {
+                $this->data[$key] = new IXR_Value($value);
+            }
+        }
+        if ($type == 'array') {
+            for ($i = 0, $j = count($this->data); $i < $j; $i++) {
+                $this->data[$i] = new IXR_Value($this->data[$i]);
+            }
+        }
+    }
+
+    function calculateType()
+    {
+        if ($this->data === true || $this->data === false) {
+            return 'boolean';
+        }
+        if (is_integer($this->data)) {
+            return 'int';
+        }
+        if (is_double($this->data)) {
+            return 'double';
+        }
+
+        // Deal with IXR object types base64 and date
+        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
+            return 'date';
+        }
+        if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
+            return 'base64';
+        }
+
+        // If it is a normal PHP object convert it in to a struct
+        if (is_object($this->data)) {
+            $this->data = get_object_vars($this->data);
+            return 'struct';
+        }
+        if (!is_array($this->data)) {
+            return 'string';
+        }
+
+        // We have an array - is it an array or a struct?
+        if ($this->isStruct($this->data)) {
+            return 'struct';
+        } else {
+            return 'array';
+        }
+    }
+
+    function getXml()
+    {
+        // Return XML for this value
+        switch ($this->type) {
+            case 'boolean':
+                return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
+                break;
+            case 'int':
+                return '<int>'.$this->data.'</int>';
+                break;
+            case 'double':
+                return '<double>'.$this->data.'</double>';
+                break;
+            case 'string':
+                return '<string>'.htmlspecialchars($this->data).'</string>';
+                break;
+            case 'array':
+                $return = '<array><data>'."\n";
+                foreach ($this->data as $item) {
+                    $return .= '  <value>'.$item->getXml()."</value>\n";
+                }
+                $return .= '</data></array>';
+                return $return;
+                break;
+            case 'struct':
+                $return = '<struct>'."\n";
+                foreach ($this->data as $name => $value) {
+					$name = htmlspecialchars($name);
+                    $return .= "  <member><name>$name</name><value>";
+                    $return .= $value->getXml()."</value></member>\n";
+                }
+                $return .= '</struct>';
+                return $return;
+                break;
+            case 'date':
+            case 'base64':
+                return $this->data->getXml();
+                break;
+        }
+        return false;
+    }
+
+    /**
+     * Checks whether or not the supplied array is a struct or not
+     *
+     * @param unknown_type $array
+     * @return boolean
+     */
+    function isStruct($array)
+    {
+        $expected = 0;
+        foreach ($array as $key => $value) {
+            if ((string)$key != (string)$expected) {
+                return true;
+            }
+            $expected++;
+        }
+        return false;
+    }
+}
+
+/**
+ * IXR_MESSAGE
+ *
+ * @package IXR
+ * @since 1.5
+ *
+ */
+class IXR_Message
+{
+    var $message;
+    var $messageType;  // methodCall / methodResponse / fault
+    var $faultCode;
+    var $faultString;
+    var $methodName;
+    var $params;
+
+    // Current variable stacks
+    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
+    var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
+    var $_currentStructName = array();  // A stack as well
+    var $_param;
+    var $_value;
+    var $_currentTag;
+    var $_currentTagContents;
+    // The XML parser
+    var $_parser;
+
+    function IXR_Message($message)
+    {
+        $this->message =& $message;
+    }
+
+    function parse()
+    {
+        // first remove the XML declaration
+        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
+        $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr($this->message, 0, 100), 1);
+        $this->message = substr_replace($this->message, $header, 0, 100);
+        if (trim($this->message) == '') {
+            return false;
+        }
+        $this->_parser = xml_parser_create();
+        // Set XML parser to take the case of tags in to account
+        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
+        // Set XML parser callback functions
+        xml_set_object($this->_parser, $this);
+        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
+        xml_set_character_data_handler($this->_parser, 'cdata');
+        $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages
+        $final = false;
+        do {
+            if (strlen($this->message) <= $chunk_size) {
+                $final = true;
+            }
+            $part = substr($this->message, 0, $chunk_size);
+            $this->message = substr($this->message, $chunk_size);
+            if (!xml_parse($this->_parser, $part, $final)) {
+                return false;
+            }
+            if ($final) {
+                break;
+            }
+        } while (true);
+        xml_parser_free($this->_parser);
+
+        // Grab the error messages, if any
+        if ($this->messageType == 'fault') {
+            $this->faultCode = $this->params[0]['faultCode'];
+            $this->faultString = $this->params[0]['faultString'];
+        }
+        return true;
+    }
+
+    function tag_open($parser, $tag, $attr)
+    {
+        $this->_currentTagContents = '';
+        $this->currentTag = $tag;
+        switch($tag) {
+            case 'methodCall':
+            case 'methodResponse':
+            case 'fault':
+                $this->messageType = $tag;
+                break;
+                /* Deal with stacks of arrays and structs */
+            case 'data':    // data is to all intents and puposes more interesting than array
+                $this->_arraystructstypes[] = 'array';
+                $this->_arraystructs[] = array();
+                break;
+            case 'struct':
+                $this->_arraystructstypes[] = 'struct';
+                $this->_arraystructs[] = array();
+                break;
+        }
+    }
+
+    function cdata($parser, $cdata)
+    {
+        $this->_currentTagContents .= $cdata;
+    }
+
+    function tag_close($parser, $tag)
+    {
+        $valueFlag = false;
+        switch($tag) {
+            case 'int':
+            case 'i4':
+                $value = (int)trim($this->_currentTagContents);
+                $valueFlag = true;
+                break;
+            case 'double':
+                $value = (double)trim($this->_currentTagContents);
+                $valueFlag = true;
+                break;
+            case 'string':
+                $value = (string)trim($this->_currentTagContents);
+                $valueFlag = true;
+                break;
+            case 'dateTime.iso8601':
+                $value = new IXR_Date(trim($this->_currentTagContents));
+                $valueFlag = true;
+                break;
+            case 'value':
+                // "If no type is indicated, the type is string."
+                if (trim($this->_currentTagContents) != '') {
+                    $value = (string)$this->_currentTagContents;
+                    $valueFlag = true;
+                }
+                break;
+            case 'boolean':
+                $value = (boolean)trim($this->_currentTagContents);
+                $valueFlag = true;
+                break;
+            case 'base64':
+                $value = base64_decode($this->_currentTagContents);
+                $valueFlag = true;
+                break;
+                /* Deal with stacks of arrays and structs */
+            case 'data':
+            case 'struct':
+                $value = array_pop($this->_arraystructs);
+                array_pop($this->_arraystructstypes);
+                $valueFlag = true;
+                break;
+            case 'member':
+                array_pop($this->_currentStructName);
+                break;
+            case 'name':
+                $this->_currentStructName[] = trim($this->_currentTagContents);
+                break;
+            case 'methodName':
+                $this->methodName = trim($this->_currentTagContents);
+                break;
+        }
+
+        if ($valueFlag) {
+            if (count($this->_arraystructs) > 0) {
+                // Add value to struct or array
+                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
+                    // Add to struct
+                    $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
+                } else {
+                    // Add to array
+                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
+                }
+            } else {
+                // Just add as a paramater
+                $this->params[] = $value;
+            }
+        }
+        $this->_currentTagContents = '';
+    }
+}
+
+/**
+ * IXR_Server
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_Server
+{
+    var $data;
+    var $callbacks = array();
+    var $message;
+    var $capabilities;
+
+    function IXR_Server($callbacks = false, $data = false, $wait = false)
+    {
+        $this->setCapabilities();
+        if ($callbacks) {
+            $this->callbacks = $callbacks;
+        }
+        $this->setCallbacks();
+        if (!$wait) {
+            $this->serve($data);
+        }
+    }
+
+    function serve($data = false)
+    {
+        if (!$data) {
+            if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
+            	header('Content-Type: text/plain'); // merged from WP #9093
+                die('XML-RPC server accepts POST requests only.');
+            }
+
+            global $HTTP_RAW_POST_DATA;
+            if (empty($HTTP_RAW_POST_DATA)) {
+                // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
+                $data = file_get_contents('php://input');
+            } else {
+                $data =& $HTTP_RAW_POST_DATA;
+            }
+        }
+        $this->message = new IXR_Message($data);
+        if (!$this->message->parse()) {
+            $this->error(-32700, 'parse error. not well formed');
+        }
+        if ($this->message->messageType != 'methodCall') {
+            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
+        }
+        $result = $this->call($this->message->methodName, $this->message->params);
+
+        // Is the result an error?
+        if (is_a($result, 'IXR_Error')) {
+            $this->error($result);
+        }
+
+        // Encode the result
+        $r = new IXR_Value($result);
+        $resultxml = $r->getXml();
+
+        // Create the XML
+        $xml = <<<EOD
+<methodResponse>
+  <params>
+    <param>
+      <value>
+      $resultxml
+      </value>
+    </param>
+  </params>
+</methodResponse>
+
+EOD;
+      // Send it
+      $this->output($xml);
+    }
+
+    function call($methodname, $args)
+    {
+        if (!$this->hasMethod($methodname)) {
+            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
+        }
+        $method = $this->callbacks[$methodname];
+
+        // Perform the callback and send the response
+        if (count($args) == 1) {
+            // If only one paramater just send that instead of the whole array
+            $args = $args[0];
+        }
+
+        // Are we dealing with a function or a method?
+        if (is_string($method) && substr($method, 0, 5) == 'this:') {
+            // It's a class method - check it exists
+            $method = substr($method, 5);
+            if (!method_exists($this, $method)) {
+                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
+            }
+
+            //Call the method
+            $result = $this->$method($args);
+        } else {
+            // It's a function - does it exist?
+            if (is_array($method)) {
+                if (!is_callable(array($method[0], $method[1]))) {
+                    return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.');
+                }
+            } else if (!function_exists($method)) {
+                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
+            }
+
+            // Call the function
+            $result = call_user_func($method, $args);
+        }
+        return $result;
+    }
+
+    function error($error, $message = false)
+    {
+        // Accepts either an error object or an error code and message
+        if ($message && !is_object($error)) {
+            $error = new IXR_Error($error, $message);
+        }
+        $this->output($error->getXml());
+    }
+
+    function output($xml)
+    {
+        $xml = '<?xml version="1.0"?>'."\n".$xml;
+        $length = strlen($xml);
+        header('Connection: close');
+        header('Content-Length: '.$length);
+        header('Content-Type: text/xml');
+        header('Date: '.date('r'));
+        echo $xml;
+        exit;
+    }
+
+    function hasMethod($method)
+    {
+        return in_array($method, array_keys($this->callbacks));
+    }
+
+    function setCapabilities()
+    {
+        // Initialises capabilities array
+        $this->capabilities = array(
+            'xmlrpc' => array(
+                'specUrl' => 'http://www.xmlrpc.com/spec',
+                'specVersion' => 1
+        ),
+            'faults_interop' => array(
+                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
+                'specVersion' => 20010516
+        ),
+            'system.multicall' => array(
+                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
+                'specVersion' => 1
+        ),
+        );
+    }
+
+    function getCapabilities($args)
+    {
+        return $this->capabilities;
+    }
+
+    function setCallbacks()
+    {
+        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
+        $this->callbacks['system.listMethods'] = 'this:listMethods';
+        $this->callbacks['system.multicall'] = 'this:multiCall';
+    }
+
+    function listMethods($args)
+    {
+        // Returns a list of methods - uses array_reverse to ensure user defined
+        // methods are listed before server defined methods
+        return array_reverse(array_keys($this->callbacks));
+    }
+
+    function multiCall($methodcalls)
+    {
+        // See http://www.xmlrpc.com/discuss/msgReader$1208
+        $return = array();
+        foreach ($methodcalls as $call) {
+            $method = $call['methodName'];
+            $params = $call['params'];
+            if ($method == 'system.multicall') {
+                $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
+            } else {
+                $result = $this->call($method, $params);
+            }
+            if (is_a($result, 'IXR_Error')) {
+                $return[] = array(
+                    'faultCode' => $result->code,
+                    'faultString' => $result->message
+                );
+            } else {
+                $return[] = array($result);
+            }
+        }
+        return $return;
+    }
+}
+
+/**
+ * IXR_Request
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_Request
+{
+    var $method;
+    var $args;
+    var $xml;
+
+    function IXR_Request($method, $args)
+    {
+        $this->method = $method;
+        $this->args = $args;
+        $this->xml = <<<EOD
+<?xml version="1.0"?>
+<methodCall>
+<methodName>{$this->method}</methodName>
+<params>
+
+EOD;
+        foreach ($this->args as $arg) {
+            $this->xml .= '<param><value>';
+            $v = new IXR_Value($arg);
+            $this->xml .= $v->getXml();
+            $this->xml .= "</value></param>\n";
+        }
+        $this->xml .= '</params></methodCall>';
+    }
+
+    function getLength()
+    {
+        return strlen($this->xml);
+    }
+
+    function getXml()
+    {
+        return $this->xml;
+    }
+}
+
+/**
+ * IXR_Client
+ *
+ * @package IXR
+ * @since 1.5
+ *
+ */
+class IXR_Client
+{
+    var $server;
+    var $port;
+    var $path;
+    var $useragent;
+    var $response;
+    var $message = false;
+    var $debug = false;
+    var $timeout;
+    var $headers = array();
+
+    // Storage place for an error message
+    var $error = false;
+
+    function IXR_Client($server, $path = false, $port = 80, $timeout = 15)
+    {
+        if (!$path) {
+            // Assume we have been given a URL instead
+            $bits = parse_url($server);
+            $this->server = $bits['host'];
+            $this->port = isset($bits['port']) ? $bits['port'] : 80;
+            $this->path = isset($bits['path']) ? $bits['path'] : '/';
+
+            // Make absolutely sure we have a path
+            if (!$this->path) {
+                $this->path = '/';
+            }
+        } else {
+            $this->server = $server;
+            $this->path = $path;
+            $this->port = $port;
+        }
+        $this->useragent = 'The Incutio XML-RPC PHP Library';
+        $this->timeout = $timeout;
+    }
+
+    function query()
+    {
+        $args = func_get_args();
+        $method = array_shift($args);
+        $request = new IXR_Request($method, $args);
+        $length = $request->getLength();
+        $xml = $request->getXml();
+        $r = "\r\n";
+        $request  = "POST {$this->path} HTTP/1.0$r";
+
+        // Merged from WP #8145 - allow custom headers
+        $this->headers['Host']          = $this->server;
+        $this->headers['Content-Type']  = 'text/xml';
+        $this->headers['User-Agent']    = $this->useragent;
+        $this->headers['Content-Length']= $length;
+
+        foreach( $this->headers as $header => $value ) {
+            $request .= "{$header}: {$value}{$r}";
+        }
+        $request .= $r;
+
+        $request .= $xml;
+
+        // Now send the request
+        if ($this->debug) {
+            echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n";
+        }
+
+        if ($this->timeout) {
+            $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout);
+        } else {
+            $fp = @fsockopen($this->server, $this->port, $errno, $errstr);
+        }
+        if (!$fp) {
+            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
+            return false;
+        }
+        fputs($fp, $request);
+        $contents = '';
+        $debugContents = '';
+        $gotFirstLine = false;
+        $gettingHeaders = true;
+        while (!feof($fp)) {
+            $line = fgets($fp, 4096);
+            if (!$gotFirstLine) {
+                // Check line for '200'
+                if (strstr($line, '200') === false) {
+                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
+                    return false;
+                }
+                $gotFirstLine = true;
+            }
+            if (trim($line) == '') {
+                $gettingHeaders = false;
+            }
+            if (!$gettingHeaders) {
+            	// merged from WP #12559 - remove trim
+                $contents .= $line;
+            }
+            if ($this->debug) {
+            	$debugContents .= $line;
+            }
+        }
+        if ($this->debug) {
+            echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
+        }
+
+        // Now parse what we've got back
+        $this->message = new IXR_Message($contents);
+        if (!$this->message->parse()) {
+            // XML error
+            $this->error = new IXR_Error(-32700, 'parse error. not well formed');
+            return false;
+        }
+
+        // Is the message a fault?
+        if ($this->message->messageType == 'fault') {
+            $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
+            return false;
+        }
+
+        // Message must be OK
+        return true;
+    }
+
+    function getResponse()
+    {
+        // methodResponses can only have one param - return that
+        return $this->message->params[0];
+    }
+
+    function isError()
+    {
+        return (is_object($this->error));
+    }
+
+    function getErrorCode()
+    {
+        return $this->error->code;
+    }
+
+    function getErrorMessage()
+    {
+        return $this->error->message;
+    }
+}
+
+
+/**
+ * IXR_Error
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_Error
+{
+    var $code;
+    var $message;
+
+    function IXR_Error($code, $message)
+    {
+        $this->code = $code;
+        $this->message = htmlspecialchars($message);
+    }
+
+    function getXml()
+    {
+        $xml = <<<EOD
+<methodResponse>
+  <fault>
+    <value>
+      <struct>
+        <member>
+          <name>faultCode</name>
+          <value><int>{$this->code}</int></value>
+        </member>
+        <member>
+          <name>faultString</name>
+          <value><string>{$this->message}</string></value>
+        </member>
+      </struct>
+    </value>
+  </fault>
+</methodResponse>
+
+EOD;
+        return $xml;
+    }
+}
+
+/**
+ * IXR_Date
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_Date {
+    var $year;
+    var $month;
+    var $day;
+    var $hour;
+    var $minute;
+    var $second;
+    var $timezone;
+
+    function IXR_Date($time)
+    {
+        // $time can be a PHP timestamp or an ISO one
+        if (is_numeric($time)) {
+            $this->parseTimestamp($time);
+        } else {
+            $this->parseIso($time);
+        }
+    }
+
+    function parseTimestamp($timestamp)
+    {
+        $this->year = date('Y', $timestamp);
+        $this->month = date('m', $timestamp);
+        $this->day = date('d', $timestamp);
+        $this->hour = date('H', $timestamp);
+        $this->minute = date('i', $timestamp);
+        $this->second = date('s', $timestamp);
+        $this->timezone = '';
+    }
+
+    function parseIso($iso)
+    {
+        $this->year = substr($iso, 0, 4);
+        $this->month = substr($iso, 4, 2);
+        $this->day = substr($iso, 6, 2);
+        $this->hour = substr($iso, 9, 2);
+        $this->minute = substr($iso, 12, 2);
+        $this->second = substr($iso, 15, 2);
+        $this->timezone = substr($iso, 17);
+    }
+
+    function getIso()
+    {
+        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
+    }
+
+    function getXml()
+    {
+        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
+    }
+
+    function getTimestamp()
+    {
+        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
+    }
+}
+
+/**
+ * IXR_Base64
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_Base64
+{
+    var $data;
+
+    function IXR_Base64($data)
+    {
+        $this->data = $data;
+    }
+
+    function getXml()
+    {
+        return '<base64>'.base64_encode($this->data).'</base64>';
+    }
+}
+
+/**
+ * IXR_IntrospectionServer
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_IntrospectionServer extends IXR_Server
+{
+    var $signatures;
+    var $help;
+
+    function IXR_IntrospectionServer()
+    {
+        $this->setCallbacks();
+        $this->setCapabilities();
+        $this->capabilities['introspection'] = array(
+            'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
+            'specVersion' => 1
+        );
+        $this->addCallback(
+            'system.methodSignature',
+            'this:methodSignature',
+            array('array', 'string'),
+            'Returns an array describing the return type and required parameters of a method'
+        );
+        $this->addCallback(
+            'system.getCapabilities',
+            'this:getCapabilities',
+            array('struct'),
+            'Returns a struct describing the XML-RPC specifications supported by this server'
+        );
+        $this->addCallback(
+            'system.listMethods',
+            'this:listMethods',
+            array('array'),
+            'Returns an array of available methods on this server'
+        );
+        $this->addCallback(
+            'system.methodHelp',
+            'this:methodHelp',
+            array('string', 'string'),
+            'Returns a documentation string for the specified method'
+        );
+    }
+
+    function addCallback($method, $callback, $args, $help)
+    {
+        $this->callbacks[$method] = $callback;
+        $this->signatures[$method] = $args;
+        $this->help[$method] = $help;
+    }
+
+    function call($methodname, $args)
+    {
+        // Make sure it's in an array
+        if ($args && !is_array($args)) {
+            $args = array($args);
+        }
+
+        // Over-rides default call method, adds signature check
+        if (!$this->hasMethod($methodname)) {
+            return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
+        }
+        $method = $this->callbacks[$methodname];
+        $signature = $this->signatures[$methodname];
+        $returnType = array_shift($signature);
+
+        // Check the number of arguments
+        if (count($args) != count($signature)) {
+            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
+        }
+
+        // Check the argument types
+        $ok = true;
+        $argsbackup = $args;
+        for ($i = 0, $j = count($args); $i < $j; $i++) {
+            $arg = array_shift($args);
+            $type = array_shift($signature);
+            switch ($type) {
+                case 'int':
+                case 'i4':
+                    if (is_array($arg) || !is_int($arg)) {
+                        $ok = false;
+                    }
+                    break;
+                case 'base64':
+                case 'string':
+                    if (!is_string($arg)) {
+                        $ok = false;
+                    }
+                    break;
+                case 'boolean':
+                    if ($arg !== false && $arg !== true) {
+                        $ok = false;
+                    }
+                    break;
+                case 'float':
+                case 'double':
+                    if (!is_float($arg)) {
+                        $ok = false;
+                    }
+                    break;
+                case 'date':
+                case 'dateTime.iso8601':
+                    if (!is_a($arg, 'IXR_Date')) {
+                        $ok = false;
+                    }
+                    break;
+            }
+            if (!$ok) {
+                return new IXR_Error(-32602, 'server error. invalid method parameters');
+            }
+        }
+        // It passed the test - run the "real" method call
+        return parent::call($methodname, $argsbackup);
+    }
+
+    function methodSignature($method)
+    {
+        if (!$this->hasMethod($method)) {
+            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
+        }
+        // We should be returning an array of types
+        $types = $this->signatures[$method];
+        $return = array();
+        foreach ($types as $type) {
+            switch ($type) {
+                case 'string':
+                    $return[] = 'string';
+                    break;
+                case 'int':
+                case 'i4':
+                    $return[] = 42;
+                    break;
+                case 'double':
+                    $return[] = 3.1415;
+                    break;
+                case 'dateTime.iso8601':
+                    $return[] = new IXR_Date(time());
+                    break;
+                case 'boolean':
+                    $return[] = true;
+                    break;
+                case 'base64':
+                    $return[] = new IXR_Base64('base64');
+                    break;
+                case 'array':
+                    $return[] = array('array');
+                    break;
+                case 'struct':
+                    $return[] = array('struct' => 'struct');
+                    break;
+            }
+        }
+        return $return;
+    }
+
+    function methodHelp($method)
+    {
+        return $this->help[$method];
+    }
+}
+
+/**
+ * IXR_ClientMulticall
+ *
+ * @package IXR
+ * @since 1.5
+ */
+class IXR_ClientMulticall extends IXR_Client
+{
+    var $calls = array();
+
+    function IXR_ClientMulticall($server, $path = false, $port = 80)
+    {
+        parent::IXR_Client($server, $path, $port);
+        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
+    }
+
+    function addCall()
+    {
+        $args = func_get_args();
+        $methodName = array_shift($args);
+        $struct = array(
+            'methodName' => $methodName,
+            'params' => $args
+        );
+        $this->calls[] = $struct;
+    }
+
+    function query()
+    {
+        // Prepare multicall, then call the parent::query() method
+        return parent::query('system.multicall', $this->calls);
+    }
+}
+
+?>
Index: /tags/3.1/wp-includes/class-feed.php
===================================================================
--- /tags/3.1/wp-includes/class-feed.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-feed.php	(revision 17487)
@@ -0,0 +1,103 @@
+<?php
+
+if ( !class_exists('SimplePie') )
+	require_once (ABSPATH . WPINC . '/class-simplepie.php');
+
+class WP_Feed_Cache extends SimplePie_Cache {
+	/**
+	 * Don't call the constructor. Please.
+	 *
+	 * @access private
+	 */
+	function WP_Feed_Cache() {
+		trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR);
+	}
+
+	/**
+	 * Create a new SimplePie_Cache object
+	 *
+	 * @static
+	 * @access public
+	 */
+	function create($location, $filename, $extension) {
+		return new WP_Feed_Cache_Transient($location, $filename, $extension);
+	}
+}
+
+class WP_Feed_Cache_Transient {
+	var $name;
+	var $mod_name;
+	var $lifetime = 43200; //Default lifetime in cache of 12 hours
+
+	function WP_Feed_Cache_Transient($location, $filename, $extension) {
+		$this->name = 'feed_' . $filename;
+		$this->mod_name = 'feed_mod_' . $filename;
+		$this->lifetime = apply_filters('wp_feed_cache_transient_lifetime', $this->lifetime, $filename);
+	}
+
+	function save($data) {
+		if ( is_a($data, 'SimplePie') )
+			$data = $data->data;
+
+		set_transient($this->name, $data, $this->lifetime);
+		set_transient($this->mod_name, time(), $this->lifetime);
+		return true;
+	}
+
+	function load() {
+		return get_transient($this->name);
+	}
+
+	function mtime() {
+		return get_transient($this->mod_name);
+	}
+
+	function touch() {
+		return set_transient($this->mod_name, time(), $this->lifetime);
+	}
+
+	function unlink() {
+		delete_transient($this->name);
+		delete_transient($this->mod_name);
+		return true;
+	}
+}
+
+class WP_SimplePie_File extends SimplePie_File {
+
+	function WP_SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
+		$this->url = $url;
+		$this->timeout = $timeout;
+		$this->redirects = $redirects;
+		$this->headers = $headers;
+		$this->useragent = $useragent;
+
+		$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
+
+		if ( preg_match('/^http(s)?:\/\//i', $url) ) {
+			$args = array( 'timeout' => $this->timeout, 'redirection' => $this->redirects);
+
+			if ( !empty($this->headers) )
+				$args['headers'] = $this->headers;
+
+			if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified
+				$args['user-agent'] = $this->useragent;
+
+			$res = wp_remote_request($url, $args);
+
+			if ( is_wp_error($res) ) {
+				$this->error = 'WP HTTP Error: ' . $res->get_error_message();
+				$this->success = false;
+			} else {
+				$this->headers = $res['headers'];
+				$this->body = $res['body'];
+				$this->status_code = $res['response']['code'];
+			}
+		} else {
+			if ( ! $this->body = file_get_contents($url) ) {
+				$this->error = 'file_get_contents could not read the file';
+				$this->success = false;
+			}
+		}
+	}
+}
Index: /tags/3.1/wp-includes/class-http.php
===================================================================
--- /tags/3.1/wp-includes/class-http.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-http.php	(revision 17487)
@@ -0,0 +1,2033 @@
+<?php
+/**
+ * Simple and uniform HTTP request API.
+ *
+ * Standardizes the HTTP requests for WordPress. Handles cookies, gzip encoding and decoding, chunk
+ * decoding, if HTTP 1.1 and various other difficult HTTP protocol implementations.
+ *
+ * @link http://trac.wordpress.org/ticket/4779 HTTP API Proposal
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7.0
+ */
+
+/**
+ * WordPress HTTP Class for managing HTTP Transports and making HTTP requests.
+ *
+ * This class is called for the functionality of making HTTP requests and replaces Snoopy
+ * functionality. There is no available functionality to add HTTP transport implementations, since
+ * most of the HTTP transports are added and available for use.
+ *
+ * There are no properties, because none are needed and for performance reasons. Some of the
+ * functions are static and while they do have some overhead over functions in PHP4, the purpose is
+ * maintainability. When PHP5 is finally the requirement, it will be easy to add the static keyword
+ * to the code. It is not as easy to convert a function to a method after enough code uses the old
+ * way.
+ *
+ * Debugging includes several actions, which pass different variables for debugging the HTTP API.
+ *
+ * <strong>http_transport_get_debug</strong> - gives working, nonblocking, and blocking transports.
+ *
+ * <strong>http_transport_post_debug</strong> - gives working, nonblocking, and blocking transports.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7.0
+ */
+class WP_Http {
+
+	/**
+	 * PHP4 style Constructor - Calls PHP5 Style Constructor
+	 *
+	 * @since 2.7.0
+	 * @return WP_Http
+	 */
+	function WP_Http() {
+		$this->__construct();
+	}
+
+	/**
+	 * PHP5 style Constructor - Set up available transport if not available.
+	 *
+	 * PHP4 does not have the 'self' keyword and since WordPress supports PHP4, the class needs to
+	 * be used for the static call. The transport are set up to save time and will only be created
+	 * once. This class can be created many times without having to go through the step of finding
+	 * which transports are available.
+	 *
+	 * @since 2.7.0
+	 * @return WP_Http
+	 */
+	function __construct() {
+		WP_Http::_getTransport();
+		WP_Http::_postTransport();
+	}
+
+	/**
+	 * Tests the WordPress HTTP objects for an object to use and returns it.
+	 *
+	 * Tests all of the objects and returns the object that passes. Also caches that object to be
+	 * used later.
+	 *
+	 * The order for the GET/HEAD requests are HTTP Extension, cURL, Streams, Fopen, and finally
+	 * Fsockopen. fsockopen() is used last, because it has the most overhead in its implementation.
+	 * There isn't any real way around it, since redirects have to be supported, much the same way
+	 * the other transports also handle redirects.
+	 *
+	 * There are currently issues with "localhost" not resolving correctly with DNS. This may cause
+	 * an error "failed to open stream: A connection attempt failed because the connected party did
+	 * not properly respond after a period of time, or established connection failed because [the]
+	 * connected host has failed to respond."
+	 *
+	 * @since 2.7.0
+	 * @access private
+	 *
+	 * @param array $args Request args, default us an empty array
+	 * @return object|null Null if no transports are available, HTTP transport object.
+	 */
+	function &_getTransport( $args = array() ) {
+		static $working_transport, $blocking_transport, $nonblocking_transport;
+
+		if ( is_null($working_transport) ) {
+			if ( true === WP_Http_ExtHttp::test($args) ) {
+				$working_transport['exthttp'] = new WP_Http_ExtHttp();
+				$blocking_transport[] = &$working_transport['exthttp'];
+			} else if ( true === WP_Http_Curl::test($args) ) {
+				$working_transport['curl'] = new WP_Http_Curl();
+				$blocking_transport[] = &$working_transport['curl'];
+			} else if ( true === WP_Http_Streams::test($args) ) {
+				$working_transport['streams'] = new WP_Http_Streams();
+				$blocking_transport[] = &$working_transport['streams'];
+			} else if ( true === WP_Http_Fopen::test($args) ) {
+				$working_transport['fopen'] = new WP_Http_Fopen();
+				$blocking_transport[] = &$working_transport['fopen'];
+			} else if ( true === WP_Http_Fsockopen::test($args) ) {
+				$working_transport['fsockopen'] = new WP_Http_Fsockopen();
+				$blocking_transport[] = &$working_transport['fsockopen'];
+			}
+
+			foreach ( array('curl', 'streams', 'fopen', 'fsockopen', 'exthttp') as $transport ) {
+				if ( isset($working_transport[$transport]) )
+					$nonblocking_transport[] = &$working_transport[$transport];
+			}
+		}
+
+		do_action( 'http_transport_get_debug', $working_transport, $blocking_transport, $nonblocking_transport );
+
+		if ( isset($args['blocking']) && !$args['blocking'] )
+			return $nonblocking_transport;
+		else
+			return $blocking_transport;
+	}
+
+	/**
+	 * Tests the WordPress HTTP objects for an object to use and returns it.
+	 *
+	 * Tests all of the objects and returns the object that passes. Also caches
+	 * that object to be used later. This is for posting content to a URL and
+	 * is used when there is a body. The plain Fopen Transport can not be used
+	 * to send content, but the streams transport can. This is a limitation that
+	 * is addressed here, by just not including that transport.
+	 *
+	 * @since 2.7.0
+	 * @access private
+	 *
+	 * @param array $args Request args, default us an empty array
+	 * @return object|null Null if no transports are available, HTTP transport object.
+	 */
+	function &_postTransport( $args = array() ) {
+		static $working_transport, $blocking_transport, $nonblocking_transport;
+
+		if ( is_null($working_transport) ) {
+			if ( true === WP_Http_ExtHttp::test($args) ) {
+				$working_transport['exthttp'] = new WP_Http_ExtHttp();
+				$blocking_transport[] = &$working_transport['exthttp'];
+			} else if ( true === WP_Http_Curl::test($args) ) {
+				$working_transport['curl'] = new WP_Http_Curl();
+				$blocking_transport[] = &$working_transport['curl'];
+			} else if ( true === WP_Http_Streams::test($args) ) {
+				$working_transport['streams'] = new WP_Http_Streams();
+				$blocking_transport[] = &$working_transport['streams'];
+			} else if ( true === WP_Http_Fsockopen::test($args) ) {
+				$working_transport['fsockopen'] = new WP_Http_Fsockopen();
+				$blocking_transport[] = &$working_transport['fsockopen'];
+			}
+
+			foreach ( array('curl', 'streams', 'fsockopen', 'exthttp') as $transport ) {
+				if ( isset($working_transport[$transport]) )
+					$nonblocking_transport[] = &$working_transport[$transport];
+			}
+		}
+
+		do_action( 'http_transport_post_debug', $working_transport, $blocking_transport, $nonblocking_transport );
+
+		if ( isset($args['blocking']) && !$args['blocking'] )
+			return $nonblocking_transport;
+		else
+			return $blocking_transport;
+	}
+
+	/**
+	 * Send a HTTP request to a URI.
+	 *
+	 * The body and headers are part of the arguments. The 'body' argument is for the body and will
+	 * accept either a string or an array. The 'headers' argument should be an array, but a string
+	 * is acceptable. If the 'body' argument is an array, then it will automatically be escaped
+	 * using http_build_query().
+	 *
+	 * The only URI that are supported in the HTTP Transport implementation are the HTTP and HTTPS
+	 * protocols. HTTP and HTTPS are assumed so the server might not know how to handle the send
+	 * headers. Other protocols are unsupported and most likely will fail.
+	 *
+	 * The defaults are 'method', 'timeout', 'redirection', 'httpversion', 'blocking' and
+	 * 'user-agent'.
+	 *
+	 * Accepted 'method' values are 'GET', 'POST', and 'HEAD', some transports technically allow
+	 * others, but should not be assumed. The 'timeout' is used to sent how long the connection
+	 * should stay open before failing when no response. 'redirection' is used to track how many
+	 * redirects were taken and used to sent the amount for other transports, but not all transports
+	 * accept setting that value.
+	 *
+	 * The 'httpversion' option is used to sent the HTTP version and accepted values are '1.0', and
+	 * '1.1' and should be a string. Version 1.1 is not supported, because of chunk response. The
+	 * 'user-agent' option is the user-agent and is used to replace the default user-agent, which is
+	 * 'WordPress/WP_Version', where WP_Version is the value from $wp_version.
+	 *
+	 * 'blocking' is the default, which is used to tell the transport, whether it should halt PHP
+	 * while it performs the request or continue regardless. Actually, that isn't entirely correct.
+	 * Blocking mode really just means whether the fread should just pull what it can whenever it
+	 * gets bytes or if it should wait until it has enough in the buffer to read or finishes reading
+	 * the entire content. It doesn't actually always mean that PHP will continue going after making
+	 * the request.
+	 *
+	 * @access public
+	 * @since 2.7.0
+	 * @todo Refactor this code. The code in this method extends the scope of its original purpose
+	 *		and should be refactored to allow for cleaner abstraction and reduce duplication of the
+	 *		code. One suggestion is to create a class specifically for the arguments, however
+	 *		preliminary refactoring to this affect has affect more than just the scope of the
+	 *		arguments. Something to ponder at least.
+	 *
+	 * @param string $url URI resource.
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return array containing 'headers', 'body', 'response', 'cookies'
+	 */
+	function request( $url, $args = array() ) {
+		global $wp_version;
+
+		$defaults = array(
+			'method' => 'GET',
+			'timeout' => apply_filters( 'http_request_timeout', 5),
+			'redirection' => apply_filters( 'http_request_redirection_count', 5),
+			'httpversion' => apply_filters( 'http_request_version', '1.0'),
+			'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )  ),
+			'blocking' => true,
+			'headers' => array(),
+			'cookies' => array(),
+			'body' => null,
+			'compress' => false,
+			'decompress' => true,
+			'sslverify' => true
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+		$r = apply_filters( 'http_request_args', $r, $url );
+
+		// Allow plugins to short-circuit the request
+		$pre = apply_filters( 'pre_http_request', false, $r, $url );
+		if ( false !== $pre )
+			return $pre;
+
+		$arrURL = parse_url( $url );
+
+		if ( empty( $url ) || empty( $arrURL['scheme'] ) )
+			return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
+
+		if ( $this->block_request( $url ) )
+			return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
+
+		// Determine if this is a https call and pass that on to the transport functions
+		// so that we can blacklist the transports that do not support ssl verification
+		$r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl';
+
+		// Determine if this request is to OUR install of WordPress
+		$homeURL = parse_url( get_bloginfo( 'url' ) );
+		$r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host'];
+		unset( $homeURL );
+
+		if ( is_null( $r['headers'] ) )
+			$r['headers'] = array();
+
+		if ( ! is_array( $r['headers'] ) ) {
+			$processedHeaders = WP_Http::processHeaders( $r['headers'] );
+			$r['headers'] = $processedHeaders['headers'];
+		}
+
+		if ( isset( $r['headers']['User-Agent'] ) ) {
+			$r['user-agent'] = $r['headers']['User-Agent'];
+			unset( $r['headers']['User-Agent'] );
+		}
+
+		if ( isset( $r['headers']['user-agent'] ) ) {
+			$r['user-agent'] = $r['headers']['user-agent'];
+			unset( $r['headers']['user-agent'] );
+		}
+
+		// Construct Cookie: header if any cookies are set
+		WP_Http::buildCookieHeader( $r );
+
+		if ( WP_Http_Encoding::is_available() )
+			$r['headers']['Accept-Encoding'] = WP_Http_Encoding::accept_encoding();
+
+		if ( empty($r['body']) ) {
+			$r['body'] = null;
+			// Some servers fail when sending content without the content-length header being set.
+			// Also, to fix another bug, we only send when doing POST and PUT and the content-length
+			// header isn't already set.
+			if ( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset( $r['headers']['Content-Length'] ) )
+				$r['headers']['Content-Length'] = 0;
+
+			// The method is ambiguous, because we aren't talking about HTTP methods, the "get" in
+			// this case is simply that we aren't sending any bodies and to get the transports that
+			// don't support sending bodies along with those which do.
+			$transports = WP_Http::_getTransport( $r );
+		} else {
+			if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) {
+				if ( ! version_compare(phpversion(), '5.1.2', '>=') )
+					$r['body'] = _http_build_query( $r['body'], null, '&' );
+				else
+					$r['body'] = http_build_query( $r['body'], null, '&' );
+				$r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset' );
+				$r['headers']['Content-Length'] = strlen( $r['body'] );
+			}
+
+			if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) )
+				$r['headers']['Content-Length'] = strlen( $r['body'] );
+
+			// The method is ambiguous, because we aren't talking about HTTP methods, the "post" in
+			// this case is simply that we are sending HTTP body and to get the transports that do
+			// support sending the body. Not all do, depending on the limitations of the PHP core
+			// limitations.
+			$transports = WP_Http::_postTransport( $r );
+		}
+
+		do_action( 'http_api_debug', $transports, 'transports_list' );
+
+		$response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
+		foreach ( (array) $transports as $transport ) {
+			$response = $transport->request( $url, $r );
+
+			do_action( 'http_api_debug', $response, 'response', get_class( $transport ) );
+
+			if ( ! is_wp_error( $response ) )
+				return apply_filters( 'http_response', $response, $r, $url );
+		}
+
+		return $response;
+	}
+
+	/**
+	 * Uses the POST HTTP method.
+	 *
+	 * Used for sending data that is expected to be in the body.
+	 *
+	 * @access public
+	 * @since 2.7.0
+	 *
+	 * @param string $url URI resource.
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return boolean
+	 */
+	function post($url, $args = array()) {
+		$defaults = array('method' => 'POST');
+		$r = wp_parse_args( $args, $defaults );
+		return $this->request($url, $r);
+	}
+
+	/**
+	 * Uses the GET HTTP method.
+	 *
+	 * Used for sending data that is expected to be in the body.
+	 *
+	 * @access public
+	 * @since 2.7.0
+	 *
+	 * @param string $url URI resource.
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return boolean
+	 */
+	function get($url, $args = array()) {
+		$defaults = array('method' => 'GET');
+		$r = wp_parse_args( $args, $defaults );
+		return $this->request($url, $r);
+	}
+
+	/**
+	 * Uses the HEAD HTTP method.
+	 *
+	 * Used for sending data that is expected to be in the body.
+	 *
+	 * @access public
+	 * @since 2.7.0
+	 *
+	 * @param string $url URI resource.
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return boolean
+	 */
+	function head($url, $args = array()) {
+		$defaults = array('method' => 'HEAD');
+		$r = wp_parse_args( $args, $defaults );
+		return $this->request($url, $r);
+	}
+
+	/**
+	 * Parses the responses and splits the parts into headers and body.
+	 *
+	 * @access public
+	 * @static
+	 * @since 2.7.0
+	 *
+	 * @param string $strResponse The full response string
+	 * @return array Array with 'headers' and 'body' keys.
+	 */
+	function processResponse($strResponse) {
+		$res = explode("\r\n\r\n", $strResponse, 2);
+
+		return array('headers' => isset($res[0]) ? $res[0] : array(), 'body' => isset($res[1]) ? $res[1] : '');
+	}
+
+	/**
+	 * Transform header string into an array.
+	 *
+	 * If an array is given then it is assumed to be raw header data with numeric keys with the
+	 * headers as the values. No headers must be passed that were already processed.
+	 *
+	 * @access public
+	 * @static
+	 * @since 2.7.0
+	 *
+	 * @param string|array $headers
+	 * @return array Processed string headers. If duplicate headers are encountered,
+	 * 					Then a numbered array is returned as the value of that header-key.
+	 */
+	function processHeaders($headers) {
+		// split headers, one per array element
+		if ( is_string($headers) ) {
+			// tolerate line terminator: CRLF = LF (RFC 2616 19.3)
+			$headers = str_replace("\r\n", "\n", $headers);
+			// unfold folded header fields. LWS = [CRLF] 1*( SP | HT ) <US-ASCII SP, space (32)>, <US-ASCII HT, horizontal-tab (9)> (RFC 2616 2.2)
+			$headers = preg_replace('/\n[ \t]/', ' ', $headers);
+			// create the headers array
+			$headers = explode("\n", $headers);
+		}
+
+		$response = array('code' => 0, 'message' => '');
+
+		// If a redirection has taken place, The headers for each page request may have been passed.
+		// In this case, determine the final HTTP header and parse from there.
+		for ( $i = count($headers)-1; $i >= 0; $i-- ) {
+			if ( !empty($headers[$i]) && false === strpos($headers[$i], ':') ) {
+				$headers = array_splice($headers, $i);
+				break;
+			}
+		}
+
+		$cookies = array();
+		$newheaders = array();
+		foreach ( $headers as $tempheader ) {
+			if ( empty($tempheader) )
+				continue;
+
+			if ( false === strpos($tempheader, ':') ) {
+				list( , $response['code'], $response['message']) = explode(' ', $tempheader, 3);
+				continue;
+			}
+
+			list($key, $value) = explode(':', $tempheader, 2);
+
+			if ( !empty( $value ) ) {
+				$key = strtolower( $key );
+				if ( isset( $newheaders[$key] ) ) {
+					if ( !is_array($newheaders[$key]) )
+						$newheaders[$key] = array($newheaders[$key]);
+					$newheaders[$key][] = trim( $value );
+				} else {
+					$newheaders[$key] = trim( $value );
+				}
+				if ( 'set-cookie' == $key )
+					$cookies[] = new WP_Http_Cookie( $value );
+			}
+		}
+
+		return array('response' => $response, 'headers' => $newheaders, 'cookies' => $cookies);
+	}
+
+	/**
+	 * Takes the arguments for a ::request() and checks for the cookie array.
+	 *
+	 * If it's found, then it's assumed to contain WP_Http_Cookie objects, which are each parsed
+	 * into strings and added to the Cookie: header (within the arguments array). Edits the array by
+	 * reference.
+	 *
+	 * @access public
+	 * @version 2.8.0
+	 * @static
+	 *
+	 * @param array $r Full array of args passed into ::request()
+	 */
+	function buildCookieHeader( &$r ) {
+		if ( ! empty($r['cookies']) ) {
+			$cookies_header = '';
+			foreach ( (array) $r['cookies'] as $cookie ) {
+				$cookies_header .= $cookie->getHeaderValue() . '; ';
+			}
+			$cookies_header = substr( $cookies_header, 0, -2 );
+			$r['headers']['cookie'] = $cookies_header;
+		}
+	}
+
+	/**
+	 * Decodes chunk transfer-encoding, based off the HTTP 1.1 specification.
+	 *
+	 * Based off the HTTP http_encoding_dechunk function. Does not support UTF-8. Does not support
+	 * returning footer headers. Shouldn't be too difficult to support it though.
+	 *
+	 * @todo Add support for footer chunked headers.
+	 * @access public
+	 * @since 2.7.0
+	 * @static
+	 *
+	 * @param string $body Body content
+	 * @return string Chunked decoded body on success or raw body on failure.
+	 */
+	function chunkTransferDecode($body) {
+		$body = str_replace(array("\r\n", "\r"), "\n", $body);
+		// The body is not chunked encoding or is malformed.
+		if ( ! preg_match( '/^[0-9a-f]+(\s|\n)+/mi', trim($body) ) )
+			return $body;
+
+		$parsedBody = '';
+		//$parsedHeaders = array(); Unsupported
+
+		while ( true ) {
+			$hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match );
+
+			if ( $hasChunk ) {
+				if ( empty( $match[1] ) )
+					return $body;
+
+				$length = hexdec( $match[1] );
+				$chunkLength = strlen( $match[0] );
+
+				$strBody = substr($body, $chunkLength, $length);
+				$parsedBody .= $strBody;
+
+				$body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n");
+
+				if ( "0" == trim($body) )
+					return $parsedBody; // Ignore footer headers.
+			} else {
+				return $body;
+			}
+		}
+	}
+
+	/**
+	 * Block requests through the proxy.
+	 *
+	 * Those who are behind a proxy and want to prevent access to certain hosts may do so. This will
+	 * prevent plugins from working and core functionality, if you don't include api.wordpress.org.
+	 *
+	 * You block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true in your wp-config.php
+	 * file and this will only allow localhost and your blog to make requests. The constant
+	 * WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the
+	 * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains
+	 * are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted.
+	 *
+	 * @since 2.8.0
+	 * @link http://core.trac.wordpress.org/ticket/8927 Allow preventing external requests.
+	 * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS
+	 *
+	 * @param string $uri URI of url.
+	 * @return bool True to block, false to allow.
+	 */
+	function block_request($uri) {
+		// We don't need to block requests, because nothing is blocked.
+		if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL )
+			return false;
+
+		// parse_url() only handles http, https type URLs, and will emit E_WARNING on failure.
+		// This will be displayed on blogs, which is not reasonable.
+		$check = @parse_url($uri);
+
+		/* Malformed URL, can not process, but this could mean ssl, so let through anyway.
+		 *
+		 * This isn't very security sound. There are instances where a hacker might attempt
+		 * to bypass the proxy and this check. However, the reason for this behavior is that
+		 * WordPress does not do any checking currently for non-proxy requests, so it is keeps with
+		 * the default unsecure nature of the HTTP request.
+		 */
+		if ( $check === false )
+			return false;
+
+		$home = parse_url( get_option('siteurl') );
+
+		// Don't block requests back to ourselves by default
+		if ( $check['host'] == 'localhost' || $check['host'] == $home['host'] )
+			return apply_filters('block_local_requests', false);
+
+		if ( !defined('WP_ACCESSIBLE_HOSTS') )
+			return true;
+
+		static $accessible_hosts;
+		static $wildcard_regex = false;
+		if ( null == $accessible_hosts ) {
+			$accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS);
+
+			if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) {
+				$wildcard_regex = array();
+				foreach ( $accessible_hosts as $host )
+					$wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/'));
+				$wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
+			}
+		}
+
+		if ( !empty($wildcard_regex) )
+			return !preg_match($wildcard_regex, $check['host']);
+		else
+			return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it.
+
+
+
+	}
+}
+
+/**
+ * HTTP request method uses fsockopen function to retrieve the url.
+ *
+ * This would be the preferred method, but the fsockopen implementation has the most overhead of all
+ * the HTTP transport implementations.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7.0
+ */
+class WP_Http_Fsockopen {
+	/**
+	 * Send a HTTP request to a URI using fsockopen().
+	 *
+	 * Does not support non-blocking mode.
+	 *
+	 * @see WP_Http::request For default options descriptions.
+	 *
+	 * @since 2.7
+	 * @access public
+	 * @param string $url URI resource.
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return array 'headers', 'body', 'cookies' and 'response' keys.
+	 */
+	function request($url, $args = array()) {
+		$defaults = array(
+			'method' => 'GET', 'timeout' => 5,
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true,
+			'headers' => array(), 'body' => null, 'cookies' => array()
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+
+		if ( isset($r['headers']['User-Agent']) ) {
+			$r['user-agent'] = $r['headers']['User-Agent'];
+			unset($r['headers']['User-Agent']);
+		} else if ( isset($r['headers']['user-agent']) ) {
+			$r['user-agent'] = $r['headers']['user-agent'];
+			unset($r['headers']['user-agent']);
+		}
+
+		// Construct Cookie: header if any cookies are set
+		WP_Http::buildCookieHeader( $r );
+
+		$iError = null; // Store error number
+		$strError = null; // Store error string
+
+		$arrURL = parse_url($url);
+
+		$fsockopen_host = $arrURL['host'];
+
+		$secure_transport = false;
+
+		if ( ! isset( $arrURL['port'] ) ) {
+			if ( ( $arrURL['scheme'] == 'ssl' || $arrURL['scheme'] == 'https' ) && extension_loaded('openssl') ) {
+				$fsockopen_host = "ssl://$fsockopen_host";
+				$arrURL['port'] = 443;
+				$secure_transport = true;
+			} else {
+				$arrURL['port'] = 80;
+			}
+		}
+
+		//fsockopen has issues with 'localhost' with IPv6 with certain versions of PHP, It attempts to connect to ::1,
+		// which fails when the server is not set up for it. For compatibility, always connect to the IPv4 address.
+		if ( 'localhost' == strtolower($fsockopen_host) )
+			$fsockopen_host = '127.0.0.1';
+
+		// There are issues with the HTTPS and SSL protocols that cause errors that can be safely
+		// ignored and should be ignored.
+		if ( true === $secure_transport )
+			$error_reporting = error_reporting(0);
+
+		$startDelay = time();
+
+		$proxy = new WP_HTTP_Proxy();
+
+		if ( !WP_DEBUG ) {
+			if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
+				$handle = @fsockopen( $proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] );
+			else
+				$handle = @fsockopen( $fsockopen_host, $arrURL['port'], $iError, $strError, $r['timeout'] );
+		} else {
+			if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
+				$handle = fsockopen( $proxy->host(), $proxy->port(), $iError, $strError, $r['timeout'] );
+			else
+				$handle = fsockopen( $fsockopen_host, $arrURL['port'], $iError, $strError, $r['timeout'] );
+		}
+
+		$endDelay = time();
+
+		// If the delay is greater than the timeout then fsockopen should't be used, because it will
+		// cause a long delay.
+		$elapseDelay = ($endDelay-$startDelay) > $r['timeout'];
+		if ( true === $elapseDelay )
+			add_option( 'disable_fsockopen', $endDelay, null, true );
+
+		if ( false === $handle )
+			return new WP_Error('http_request_failed', $iError . ': ' . $strError);
+
+		$timeout = (int) floor( $r['timeout'] );
+		$utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000;
+		stream_set_timeout( $handle, $timeout, $utimeout );
+
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) //Some proxies require full URL in this field.
+			$requestPath = $url;
+		else
+			$requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' );
+
+		if ( empty($requestPath) )
+			$requestPath .= '/';
+
+		$strHeaders = strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
+
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
+			$strHeaders .= 'Host: ' . $arrURL['host'] . ':' . $arrURL['port'] . "\r\n";
+		else
+			$strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
+
+		if ( isset($r['user-agent']) )
+			$strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n";
+
+		if ( is_array($r['headers']) ) {
+			foreach ( (array) $r['headers'] as $header => $headerValue )
+				$strHeaders .= $header . ': ' . $headerValue . "\r\n";
+		} else {
+			$strHeaders .= $r['headers'];
+		}
+
+		if ( $proxy->use_authentication() )
+			$strHeaders .= $proxy->authentication_header() . "\r\n";
+
+		$strHeaders .= "\r\n";
+
+		if ( ! is_null($r['body']) )
+			$strHeaders .= $r['body'];
+
+		fwrite($handle, $strHeaders);
+
+		if ( ! $r['blocking'] ) {
+			fclose($handle);
+			return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
+		}
+
+		$strResponse = '';
+		while ( ! feof($handle) )
+			$strResponse .= fread($handle, 4096);
+
+		fclose($handle);
+
+		if ( true === $secure_transport )
+			error_reporting($error_reporting);
+
+		$process = WP_Http::processResponse($strResponse);
+		$arrHeaders = WP_Http::processHeaders($process['headers']);
+
+		// Is the response code within the 400 range?
+		if ( (int) $arrHeaders['response']['code'] >= 400 && (int) $arrHeaders['response']['code'] < 500 )
+			return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']);
+
+		// If location is found, then assume redirect and redirect to location.
+		if ( 'HEAD' != $r['method'] && isset($arrHeaders['headers']['location']) ) {
+			if ( $r['redirection']-- > 0 ) {
+				return $this->request($arrHeaders['headers']['location'], $r);
+			} else {
+				return new WP_Error('http_request_failed', __('Too many redirects.'));
+			}
+		}
+
+		// If the body was chunk encoded, then decode it.
+		if ( ! empty( $process['body'] ) && isset( $arrHeaders['headers']['transfer-encoding'] ) && 'chunked' == $arrHeaders['headers']['transfer-encoding'] )
+			$process['body'] = WP_Http::chunkTransferDecode($process['body']);
+
+		if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($arrHeaders['headers']) )
+			$process['body'] = WP_Http_Encoding::decompress( $process['body'] );
+
+		return array('headers' => $arrHeaders['headers'], 'body' => $process['body'], 'response' => $arrHeaders['response'], 'cookies' => $arrHeaders['cookies']);
+	}
+
+	/**
+	 * Whether this class can be used for retrieving an URL.
+	 *
+	 * @since 2.7.0
+	 * @static
+	 * @return boolean False means this class can not be used, true means it can.
+	 */
+	function test( $args = array() ) {
+		if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours
+			return false;
+
+		$is_ssl = isset($args['ssl']) && $args['ssl'];
+
+		if ( ! $is_ssl && function_exists( 'fsockopen' ) )
+			$use = true;
+		elseif ( $is_ssl && extension_loaded('openssl') && function_exists( 'fsockopen' ) )
+			$use = true;
+		else
+			$use = false;
+
+		return apply_filters('use_fsockopen_transport', $use, $args);
+	}
+}
+
+/**
+ * HTTP request method uses fopen function to retrieve the url.
+ *
+ * Requires PHP version greater than 4.3.0 for stream support. Does not allow for $context support,
+ * but should still be okay, to write the headers, before getting the response. Also requires that
+ * 'allow_url_fopen' to be enabled.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7.0
+ */
+class WP_Http_Fopen {
+	/**
+	 * Send a HTTP request to a URI using fopen().
+	 *
+	 * This transport does not support sending of headers and body, therefore should not be used in
+	 * the instances, where there is a body and headers.
+	 *
+	 * Notes: Does not support non-blocking mode. Ignores 'redirection' option.
+	 *
+	 * @see WP_Http::retrieve For default options descriptions.
+	 *
+	 * @access public
+	 * @since 2.7.0
+	 *
+	 * @param string $url URI resource.
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return array 'headers', 'body', 'cookies' and 'response' keys.
+	 */
+	function request($url, $args = array()) {
+		$defaults = array(
+			'method' => 'GET', 'timeout' => 5,
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true,
+			'headers' => array(), 'body' => null, 'cookies' => array()
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+
+		$arrURL = parse_url($url);
+
+		if ( false === $arrURL )
+			return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
+
+		if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
+			$url = str_replace($arrURL['scheme'], 'http', $url);
+
+		if ( is_null( $r['headers'] ) )
+			$r['headers'] = array();
+
+		if ( is_string($r['headers']) ) {
+			$processedHeaders = WP_Http::processHeaders($r['headers']);
+			$r['headers'] = $processedHeaders['headers'];
+		}
+
+		$initial_user_agent = ini_get('user_agent');
+
+		if ( !empty($r['headers']) && is_array($r['headers']) ) {
+			$user_agent_extra_headers = '';
+			foreach ( $r['headers'] as $header => $value )
+				$user_agent_extra_headers .= "\r\n$header: $value";
+			@ini_set('user_agent', $r['user-agent'] . $user_agent_extra_headers);
+		} else {
+			@ini_set('user_agent', $r['user-agent']);
+		}
+
+		if ( !WP_DEBUG )
+			$handle = @fopen($url, 'r');
+		else
+			$handle = fopen($url, 'r');
+
+		if (! $handle)
+			return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
+
+		$timeout = (int) floor( $r['timeout'] );
+		$utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000;
+		stream_set_timeout( $handle, $timeout, $utimeout );
+
+		if ( ! $r['blocking'] ) {
+			fclose($handle);
+			@ini_set('user_agent', $initial_user_agent); //Clean up any extra headers added
+			return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
+		}
+
+		$strResponse = '';
+		while ( ! feof($handle) )
+			$strResponse .= fread($handle, 4096);
+
+		if ( function_exists('stream_get_meta_data') ) {
+			$meta = stream_get_meta_data($handle);
+
+			$theHeaders = $meta['wrapper_data'];
+			if ( isset( $meta['wrapper_data']['headers'] ) )
+				$theHeaders = $meta['wrapper_data']['headers'];
+		} else {
+			//$http_response_header is a PHP reserved variable which is set in the current-scope when using the HTTP Wrapper
+			//see http://php.oregonstate.edu/manual/en/reserved.variables.httpresponseheader.php
+			$theHeaders = $http_response_header;
+		}
+
+		fclose($handle);
+
+		@ini_set('user_agent', $initial_user_agent); //Clean up any extra headers added
+
+		$processedHeaders = WP_Http::processHeaders($theHeaders);
+
+		if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
+			$strResponse = WP_Http::chunkTransferDecode($strResponse);
+
+		if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($processedHeaders['headers']) )
+			$strResponse = WP_Http_Encoding::decompress( $strResponse );
+
+		return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response'], 'cookies' => $processedHeaders['cookies']);
+	}
+
+	/**
+	 * Whether this class can be used for retrieving an URL.
+	 *
+	 * @since 2.7.0
+	 * @static
+	 * @return boolean False means this class can not be used, true means it can.
+	 */
+	function test($args = array()) {
+		if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
+			return false;
+
+		if ( isset($args['method']) && 'HEAD' == $args['method'] ) //This transport cannot make a HEAD request
+			return false;
+
+		$use = true;
+		//PHP does not verify SSL certs, We can only make a request via this transports if SSL Verification is turned off.
+		$is_ssl = isset($args['ssl']) && $args['ssl'];
+		if ( $is_ssl ) {
+			$is_local = isset($args['local']) && $args['local'];
+			$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+			if ( $is_local && true != apply_filters('https_local_ssl_verify', true) )
+				$use = true;
+			elseif ( !$is_local && true != apply_filters('https_ssl_verify', true) )
+				$use = true;
+			elseif ( !$ssl_verify )
+				$use = true;
+			else
+				$use = false;
+		}
+
+		return apply_filters('use_fopen_transport', $use, $args);
+	}
+}
+
+/**
+ * HTTP request method uses Streams to retrieve the url.
+ *
+ * Requires PHP 5.0+ and uses fopen with stream context. Requires that 'allow_url_fopen' PHP setting
+ * to be enabled.
+ *
+ * Second preferred method for getting the URL, for PHP 5.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7.0
+ */
+class WP_Http_Streams {
+	/**
+	 * Send a HTTP request to a URI using streams with fopen().
+	 *
+	 * @access public
+	 * @since 2.7.0
+	 *
+	 * @param string $url
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return array 'headers', 'body', 'cookies' and 'response' keys.
+	 */
+	function request($url, $args = array()) {
+		$defaults = array(
+			'method' => 'GET', 'timeout' => 5,
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true,
+			'headers' => array(), 'body' => null, 'cookies' => array()
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+
+		if ( isset($r['headers']['User-Agent']) ) {
+			$r['user-agent'] = $r['headers']['User-Agent'];
+			unset($r['headers']['User-Agent']);
+		} else if ( isset($r['headers']['user-agent']) ) {
+			$r['user-agent'] = $r['headers']['user-agent'];
+			unset($r['headers']['user-agent']);
+		}
+
+		// Construct Cookie: header if any cookies are set
+		WP_Http::buildCookieHeader( $r );
+
+		$arrURL = parse_url($url);
+
+		if ( false === $arrURL )
+			return new WP_Error('http_request_failed', sprintf(__('Malformed URL: %s'), $url));
+
+		if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
+			$url = preg_replace('|^' . preg_quote($arrURL['scheme'], '|') . '|', 'http', $url);
+
+		// Convert Header array to string.
+		$strHeaders = '';
+		if ( is_array( $r['headers'] ) )
+			foreach ( $r['headers'] as $name => $value )
+				$strHeaders .= "{$name}: $value\r\n";
+		else if ( is_string( $r['headers'] ) )
+			$strHeaders = $r['headers'];
+
+		$is_local = isset($args['local']) && $args['local'];
+		$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+		if ( $is_local )
+			$ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify);
+		elseif ( ! $is_local )
+			$ssl_verify = apply_filters('https_ssl_verify', $ssl_verify);
+
+		$arrContext = array('http' =>
+			array(
+				'method' => strtoupper($r['method']),
+				'user_agent' => $r['user-agent'],
+				'max_redirects' => $r['redirection'] + 1, // See #11557
+				'protocol_version' => (float) $r['httpversion'],
+				'header' => $strHeaders,
+				'ignore_errors' => true, // Return non-200 requests.
+				'timeout' => $r['timeout'],
+				'ssl' => array(
+						'verify_peer' => $ssl_verify,
+						'verify_host' => $ssl_verify
+				)
+			)
+		);
+
+		$proxy = new WP_HTTP_Proxy();
+
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
+			$arrContext['http']['proxy'] = 'tcp://' . $proxy->host() . ':' . $proxy->port();
+			$arrContext['http']['request_fulluri'] = true;
+
+			// We only support Basic authentication so this will only work if that is what your proxy supports.
+			if ( $proxy->use_authentication() )
+				$arrContext['http']['header'] .= $proxy->authentication_header() . "\r\n";
+		}
+
+		if ( 'HEAD' == $r['method'] ) // Disable redirects for HEAD requests
+			$arrContext['http']['max_redirects'] = 1;
+
+		if ( ! empty($r['body'] ) )
+			$arrContext['http']['content'] = $r['body'];
+
+		$context = stream_context_create($arrContext);
+
+		if ( !WP_DEBUG )
+			$handle = @fopen($url, 'r', false, $context);
+		else
+			$handle = fopen($url, 'r', false, $context);
+
+		if ( ! $handle )
+			return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
+
+		$timeout = (int) floor( $r['timeout'] );
+		$utimeout = $timeout == $r['timeout'] ? 0 : 1000000 * $r['timeout'] % 1000000;
+		stream_set_timeout( $handle, $timeout, $utimeout );
+
+		if ( ! $r['blocking'] ) {
+			stream_set_blocking($handle, 0);
+			fclose($handle);
+			return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
+		}
+
+		$strResponse = stream_get_contents($handle);
+		$meta = stream_get_meta_data($handle);
+
+		fclose($handle);
+
+		$processedHeaders = array();
+		if ( isset( $meta['wrapper_data']['headers'] ) )
+			$processedHeaders = WP_Http::processHeaders($meta['wrapper_data']['headers']);
+		else
+			$processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
+
+		if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
+			$strResponse = WP_Http::chunkTransferDecode($strResponse);
+
+		if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($processedHeaders['headers']) )
+			$strResponse = WP_Http_Encoding::decompress( $strResponse );
+
+		return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response'], 'cookies' => $processedHeaders['cookies']);
+	}
+
+	/**
+	 * Whether this class can be used for retrieving an URL.
+	 *
+	 * @static
+	 * @access public
+	 * @since 2.7.0
+	 *
+	 * @return boolean False means this class can not be used, true means it can.
+	 */
+	function test($args = array()) {
+		if ( ! function_exists('fopen') || (function_exists('ini_get') && true != ini_get('allow_url_fopen')) )
+			return false;
+
+		if ( version_compare(PHP_VERSION, '5.0', '<') )
+			return false;
+
+		//HTTPS via Proxy was added in 5.1.0
+		$is_ssl = isset($args['ssl']) && $args['ssl'];
+		if ( $is_ssl && version_compare(PHP_VERSION, '5.1.0', '<') ) {
+			$proxy = new WP_HTTP_Proxy();
+			/**
+			 * No URL check, as its not currently passed to the ::test() function
+			 * In the case where a Proxy is in use, Just bypass this transport for HTTPS.
+			 */
+			if ( $proxy->is_enabled() )
+				return false;
+		}
+
+		return apply_filters('use_streams_transport', true, $args);
+	}
+}
+
+/**
+ * HTTP request method uses HTTP extension to retrieve the url.
+ *
+ * Requires the HTTP extension to be installed. This would be the preferred transport since it can
+ * handle a lot of the problems that forces the others to use the HTTP version 1.0. Even if PHP 5.2+
+ * is being used, it doesn't mean that the HTTP extension will be enabled.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7.0
+ */
+class WP_Http_ExtHttp {
+	/**
+	 * Send a HTTP request to a URI using HTTP extension.
+	 *
+	 * Does not support non-blocking.
+	 *
+	 * @access public
+	 * @since 2.7
+	 *
+	 * @param string $url
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return array 'headers', 'body', 'cookies' and 'response' keys.
+	 */
+	function request($url, $args = array()) {
+		$defaults = array(
+			'method' => 'GET', 'timeout' => 5,
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true,
+			'headers' => array(), 'body' => null, 'cookies' => array()
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+
+		if ( isset($r['headers']['User-Agent']) ) {
+			$r['user-agent'] = $r['headers']['User-Agent'];
+			unset($r['headers']['User-Agent']);
+		} else if ( isset($r['headers']['user-agent']) ) {
+			$r['user-agent'] = $r['headers']['user-agent'];
+			unset($r['headers']['user-agent']);
+		}
+
+		// Construct Cookie: header if any cookies are set
+		WP_Http::buildCookieHeader( $r );
+
+		switch ( $r['method'] ) {
+			case 'POST':
+				$r['method'] = HTTP_METH_POST;
+				break;
+			case 'HEAD':
+				$r['method'] = HTTP_METH_HEAD;
+				break;
+			case 'PUT':
+				$r['method'] =  HTTP_METH_PUT;
+				break;
+			case 'GET':
+			default:
+				$r['method'] = HTTP_METH_GET;
+		}
+
+		$arrURL = parse_url($url);
+
+		if ( 'http' != $arrURL['scheme'] && 'https' != $arrURL['scheme'] )
+			$url = preg_replace('|^' . preg_quote($arrURL['scheme'], '|') . '|', 'http', $url);
+
+		$is_local = isset($args['local']) && $args['local'];
+		$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+		if ( $is_local )
+			$ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify);
+		elseif ( ! $is_local )
+			$ssl_verify = apply_filters('https_ssl_verify', $ssl_verify);
+
+		$r['timeout'] = (int) ceil( $r['timeout'] );
+
+		$options = array(
+			'timeout' => $r['timeout'],
+			'connecttimeout' => $r['timeout'],
+			'redirect' => $r['redirection'],
+			'useragent' => $r['user-agent'],
+			'headers' => $r['headers'],
+			'ssl' => array(
+				'verifypeer' => $ssl_verify,
+				'verifyhost' => $ssl_verify
+			)
+		);
+
+		if ( HTTP_METH_HEAD == $r['method'] )
+			$options['redirect'] = 0; // Assumption: Docs seem to suggest that this means do not follow. Untested.
+
+		// The HTTP extensions offers really easy proxy support.
+		$proxy = new WP_HTTP_Proxy();
+
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
+			$options['proxyhost'] = $proxy->host();
+			$options['proxyport'] = $proxy->port();
+			$options['proxytype'] = HTTP_PROXY_HTTP;
+
+			if ( $proxy->use_authentication() ) {
+				$options['proxyauth'] = $proxy->authentication();
+				$options['proxyauthtype'] = HTTP_AUTH_ANY;
+			}
+		}
+
+		if ( !WP_DEBUG ) //Emits warning level notices for max redirects and timeouts
+			$strResponse = @http_request($r['method'], $url, $r['body'], $options, $info);
+		else
+			$strResponse = http_request($r['method'], $url, $r['body'], $options, $info); //Emits warning level notices for max redirects and timeouts
+
+		// Error may still be set, Response may return headers or partial document, and error
+		// contains a reason the request was aborted, eg, timeout expired or max-redirects reached.
+		if ( false === $strResponse || ! empty($info['error']) )
+			return new WP_Error('http_request_failed', $info['response_code'] . ': ' . $info['error']);
+
+		if ( ! $r['blocking'] )
+			return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
+
+		$headers_body = WP_HTTP::processResponse($strResponse);
+		$theHeaders = $headers_body['headers'];
+		$theBody = $headers_body['body'];
+		unset($headers_body);
+
+		$theHeaders = WP_Http::processHeaders($theHeaders);
+
+		if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] ) {
+			if ( !WP_DEBUG )
+				$theBody = @http_chunked_decode($theBody);
+			else
+				$theBody = http_chunked_decode($theBody);
+		}
+
+		if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) )
+			$theBody = http_inflate( $theBody );
+
+		$theResponse = array();
+		$theResponse['code'] = $info['response_code'];
+		$theResponse['message'] = get_status_header_desc($info['response_code']);
+
+		return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $theResponse, 'cookies' => $theHeaders['cookies']);
+	}
+
+	/**
+	 * Whether this class can be used for retrieving an URL.
+	 *
+	 * @static
+	 * @since 2.7.0
+	 *
+	 * @return boolean False means this class can not be used, true means it can.
+	 */
+	function test($args = array()) {
+		return apply_filters('use_http_extension_transport', function_exists('http_request'), $args );
+	}
+}
+
+/**
+ * HTTP request method uses Curl extension to retrieve the url.
+ *
+ * Requires the Curl extension to be installed.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7
+ */
+class WP_Http_Curl {
+
+	/**
+	 * Send a HTTP request to a URI using cURL extension.
+	 *
+	 * @access public
+	 * @since 2.7.0
+	 *
+	 * @param string $url
+	 * @param str|array $args Optional. Override the defaults.
+	 * @return array 'headers', 'body', 'cookies' and 'response' keys.
+	 */
+	function request($url, $args = array()) {
+		$defaults = array(
+			'method' => 'GET', 'timeout' => 5,
+			'redirection' => 5, 'httpversion' => '1.0',
+			'blocking' => true,
+			'headers' => array(), 'body' => null, 'cookies' => array()
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+
+		if ( isset($r['headers']['User-Agent']) ) {
+			$r['user-agent'] = $r['headers']['User-Agent'];
+			unset($r['headers']['User-Agent']);
+		} else if ( isset($r['headers']['user-agent']) ) {
+			$r['user-agent'] = $r['headers']['user-agent'];
+			unset($r['headers']['user-agent']);
+		}
+
+		// Construct Cookie: header if any cookies are set.
+		WP_Http::buildCookieHeader( $r );
+
+		$handle = curl_init();
+
+		// cURL offers really easy proxy support.
+		$proxy = new WP_HTTP_Proxy();
+
+		if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
+
+			$isPHP5 = version_compare(PHP_VERSION, '5.0.0', '>=');
+
+			if ( $isPHP5 ) {
+				curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP );
+				curl_setopt( $handle, CURLOPT_PROXY, $proxy->host() );
+				curl_setopt( $handle, CURLOPT_PROXYPORT, $proxy->port() );
+			} else {
+				curl_setopt( $handle, CURLOPT_PROXY, $proxy->host() .':'. $proxy->port() );
+			}
+
+			if ( $proxy->use_authentication() ) {
+				if ( $isPHP5 )
+					curl_setopt( $handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY );
+
+				curl_setopt( $handle, CURLOPT_PROXYUSERPWD, $proxy->authentication() );
+			}
+		}
+
+		$is_local = isset($args['local']) && $args['local'];
+		$ssl_verify = isset($args['sslverify']) && $args['sslverify'];
+		if ( $is_local )
+			$ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify);
+		elseif ( ! $is_local )
+			$ssl_verify = apply_filters('https_ssl_verify', $ssl_verify);
+
+
+		// CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers.  Have to use ceil since
+		// a value of 0 will allow an ulimited timeout.
+		$timeout = (int) ceil( $r['timeout'] );
+		curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $timeout );
+		curl_setopt( $handle, CURLOPT_TIMEOUT, $timeout );
+
+		curl_setopt( $handle, CURLOPT_URL, $url);
+		curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true );
+		curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, $ssl_verify );
+		curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, $ssl_verify );
+		curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] );
+		curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] );
+
+		switch ( $r['method'] ) {
+			case 'HEAD':
+				curl_setopt( $handle, CURLOPT_NOBODY, true );
+				break;
+			case 'POST':
+				curl_setopt( $handle, CURLOPT_POST, true );
+				curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] );
+				break;
+			case 'PUT':
+				curl_setopt( $handle, CURLOPT_CUSTOMREQUEST, 'PUT' );
+				curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] );
+				break;
+		}
+
+		if ( true === $r['blocking'] )
+			curl_setopt( $handle, CURLOPT_HEADER, true );
+		else
+			curl_setopt( $handle, CURLOPT_HEADER, false );
+
+		// The option doesn't work with safe mode or when open_basedir is set.
+		// Disable HEAD when making HEAD requests.
+		if ( !ini_get('safe_mode') && !ini_get('open_basedir') && 'HEAD' != $r['method'] )
+			curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
+
+		if ( !empty( $r['headers'] ) ) {
+			// cURL expects full header strings in each element
+			$headers = array();
+			foreach ( $r['headers'] as $name => $value ) {
+				$headers[] = "{$name}: $value";
+			}
+			curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers );
+		}
+
+		if ( $r['httpversion'] == '1.0' )
+			curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
+		else
+			curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
+
+		// Cookies are not handled by the HTTP API currently. Allow for plugin authors to handle it
+		// themselves... Although, it is somewhat pointless without some reference.
+		do_action_ref_array( 'http_api_curl', array(&$handle) );
+
+		// We don't need to return the body, so don't. Just execute request and return.
+		if ( ! $r['blocking'] ) {
+			curl_exec( $handle );
+			curl_close( $handle );
+			return array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() );
+		}
+
+		$theResponse = curl_exec( $handle );
+
+		if ( !empty($theResponse) ) {
+			$headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
+			$theHeaders = trim( substr($theResponse, 0, $headerLength) );
+			if ( strlen($theResponse) > $headerLength )
+				$theBody = substr( $theResponse, $headerLength );
+			else
+				$theBody = '';
+			if ( false !== strpos($theHeaders, "\r\n\r\n") ) {
+				$headerParts = explode("\r\n\r\n", $theHeaders);
+				$theHeaders = $headerParts[ count($headerParts) -1 ];
+			}
+			$theHeaders = WP_Http::processHeaders($theHeaders);
+		} else {
+			if ( $curl_error = curl_error($handle) )
+				return new WP_Error('http_request_failed', $curl_error);
+			if ( in_array( curl_getinfo( $handle, CURLINFO_HTTP_CODE ), array(301, 302) ) )
+				return new WP_Error('http_request_failed', __('Too many redirects.'));
+
+			$theHeaders = array( 'headers' => array(), 'cookies' => array() );
+			$theBody = '';
+		}
+
+		$response = array();
+		$response['code'] = curl_getinfo( $handle, CURLINFO_HTTP_CODE );
+		$response['message'] = get_status_header_desc($response['code']);
+
+		curl_close( $handle );
+
+		// See #11305 - When running under safe mode, redirection is disabled above. Handle it manually.
+		if ( !empty($theHeaders['headers']['location']) && (ini_get('safe_mode') || ini_get('open_basedir')) ) {
+			if ( $r['redirection']-- > 0 ) {
+				return $this->request($theHeaders['headers']['location'], $r);
+			} else {
+				return new WP_Error('http_request_failed', __('Too many redirects.'));
+			}
+		}
+
+		if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) )
+			$theBody = WP_Http_Encoding::decompress( $theBody );
+
+		return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $response, 'cookies' => $theHeaders['cookies']);
+	}
+
+	/**
+	 * Whether this class can be used for retrieving an URL.
+	 *
+	 * @static
+	 * @since 2.7.0
+	 *
+	 * @return boolean False means this class can not be used, true means it can.
+	 */
+	function test($args = array()) {
+		if ( function_exists('curl_init') && function_exists('curl_exec') )
+			return apply_filters('use_curl_transport', true, $args);
+
+		return false;
+	}
+}
+
+/**
+ * Adds Proxy support to the WordPress HTTP API.
+ *
+ * There are caveats to proxy support. It requires that defines be made in the wp-config.php file to
+ * enable proxy support. There are also a few filters that plugins can hook into for some of the
+ * constants.
+ *
+ * Please note that only BASIC authentication is supported by most transports.
+ * cURL and the PHP HTTP Extension MAY support more methods (such as NTLM authentication) depending on your environment.
+ *
+ * The constants are as follows:
+ * <ol>
+ * <li>WP_PROXY_HOST - Enable proxy support and host for connecting.</li>
+ * <li>WP_PROXY_PORT - Proxy port for connection. No default, must be defined.</li>
+ * <li>WP_PROXY_USERNAME - Proxy username, if it requires authentication.</li>
+ * <li>WP_PROXY_PASSWORD - Proxy password, if it requires authentication.</li>
+ * <li>WP_PROXY_BYPASS_HOSTS - Will prevent the hosts in this list from going through the proxy.
+ * You do not need to have localhost and the blog host in this list, because they will not be passed
+ * through the proxy. The list should be presented in a comma separated list, wildcards using * are supported, eg. *.wordpress.org</li>
+ * </ol>
+ *
+ * An example can be as seen below.
+ * <code>
+ * define('WP_PROXY_HOST', '192.168.84.101');
+ * define('WP_PROXY_PORT', '8080');
+ * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com, *.wordpress.org');
+ * </code>
+ *
+ * @link http://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress.
+ * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS
+ * @since 2.8
+ */
+class WP_HTTP_Proxy {
+
+	/**
+	 * Whether proxy connection should be used.
+	 *
+	 * @since 2.8
+	 * @use WP_PROXY_HOST
+	 * @use WP_PROXY_PORT
+	 *
+	 * @return bool
+	 */
+	function is_enabled() {
+		return defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT');
+	}
+
+	/**
+	 * Whether authentication should be used.
+	 *
+	 * @since 2.8
+	 * @use WP_PROXY_USERNAME
+	 * @use WP_PROXY_PASSWORD
+	 *
+	 * @return bool
+	 */
+	function use_authentication() {
+		return defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD');
+	}
+
+	/**
+	 * Retrieve the host for the proxy server.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string
+	 */
+	function host() {
+		if ( defined('WP_PROXY_HOST') )
+			return WP_PROXY_HOST;
+
+		return '';
+	}
+
+	/**
+	 * Retrieve the port for the proxy server.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string
+	 */
+	function port() {
+		if ( defined('WP_PROXY_PORT') )
+			return WP_PROXY_PORT;
+
+		return '';
+	}
+
+	/**
+	 * Retrieve the username for proxy authentication.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string
+	 */
+	function username() {
+		if ( defined('WP_PROXY_USERNAME') )
+			return WP_PROXY_USERNAME;
+
+		return '';
+	}
+
+	/**
+	 * Retrieve the password for proxy authentication.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string
+	 */
+	function password() {
+		if ( defined('WP_PROXY_PASSWORD') )
+			return WP_PROXY_PASSWORD;
+
+		return '';
+	}
+
+	/**
+	 * Retrieve authentication string for proxy authentication.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string
+	 */
+	function authentication() {
+		return $this->username() . ':' . $this->password();
+	}
+
+	/**
+	 * Retrieve header string for proxy authentication.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string
+	 */
+	function authentication_header() {
+		return 'Proxy-Authorization: Basic ' . base64_encode( $this->authentication() );
+	}
+
+	/**
+	 * Whether URL should be sent through the proxy server.
+	 *
+	 * We want to keep localhost and the blog URL from being sent through the proxy server, because
+	 * some proxies can not handle this. We also have the constant available for defining other
+	 * hosts that won't be sent through the proxy.
+	 *
+	 * @uses WP_PROXY_BYPASS_HOSTS
+	 * @since 2.8.0
+	 *
+	 * @param string $uri URI to check.
+	 * @return bool True, to send through the proxy and false if, the proxy should not be used.
+	 */
+	function send_through_proxy( $uri ) {
+		// parse_url() only handles http, https type URLs, and will emit E_WARNING on failure.
+		// This will be displayed on blogs, which is not reasonable.
+		$check = @parse_url($uri);
+
+		// Malformed URL, can not process, but this could mean ssl, so let through anyway.
+		if ( $check === false )
+			return true;
+
+		$home = parse_url( get_option('siteurl') );
+
+		if ( $check['host'] == 'localhost' || $check['host'] == $home['host'] )
+			return false;
+
+		if ( !defined('WP_PROXY_BYPASS_HOSTS') )
+			return true;
+
+		static $bypass_hosts;
+		static $wildcard_regex = false;
+		if ( null == $bypass_hosts ) {
+			$bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS);
+
+			if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) {
+				$wildcard_regex = array();
+				foreach ( $bypass_hosts as $host )
+					$wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/'));
+				$wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i';
+			}
+		}
+
+		if ( !empty($wildcard_regex) )
+			return !preg_match($wildcard_regex, $check['host']);
+		else
+			return !in_array( $check['host'], $bypass_hosts );
+	}
+}
+/**
+ * Internal representation of a single cookie.
+ *
+ * Returned cookies are represented using this class, and when cookies are set, if they are not
+ * already a WP_Http_Cookie() object, then they are turned into one.
+ *
+ * @todo The WordPress convention is to use underscores instead of camelCase for function and method
+ * names. Need to switch to use underscores instead for the methods.
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.8.0
+ */
+class WP_Http_Cookie {
+
+	/**
+	 * Cookie name.
+	 *
+	 * @since 2.8.0
+	 * @var string
+	 */
+	var $name;
+
+	/**
+	 * Cookie value.
+	 *
+	 * @since 2.8.0
+	 * @var string
+	 */
+	var $value;
+
+	/**
+	 * When the cookie expires.
+	 *
+	 * @since 2.8.0
+	 * @var string
+	 */
+	var $expires;
+
+	/**
+	 * Cookie URL path.
+	 *
+	 * @since 2.8.0
+	 * @var string
+	 */
+	var $path;
+
+	/**
+	 * Cookie Domain.
+	 *
+	 * @since 2.8.0
+	 * @var string
+	 */
+	var $domain;
+
+	/**
+	 * PHP4 style Constructor - Calls PHP5 Style Constructor.
+	 *
+	 * @access public
+	 * @since 2.8.0
+	 * @param string|array $data Raw cookie data.
+	 */
+	function WP_Http_Cookie( $data ) {
+		$this->__construct( $data );
+	}
+
+	/**
+	 * Sets up this cookie object.
+	 *
+	 * The parameter $data should be either an associative array containing the indices names below
+	 * or a header string detailing it.
+	 *
+	 * If it's an array, it should include the following elements:
+	 * <ol>
+	 * <li>Name</li>
+	 * <li>Value - should NOT be urlencoded already.</li>
+	 * <li>Expires - (optional) String or int (UNIX timestamp).</li>
+	 * <li>Path (optional)</li>
+	 * <li>Domain (optional)</li>
+	 * </ol>
+	 *
+	 * @access public
+	 * @since 2.8.0
+	 *
+	 * @param string|array $data Raw cookie data.
+	 */
+	function __construct( $data ) {
+		if ( is_string( $data ) ) {
+			// Assume it's a header string direct from a previous request
+			$pairs = explode( ';', $data );
+
+			// Special handling for first pair; name=value. Also be careful of "=" in value
+			$name  = trim( substr( $pairs[0], 0, strpos( $pairs[0], '=' ) ) );
+			$value = substr( $pairs[0], strpos( $pairs[0], '=' ) + 1 );
+			$this->name  = $name;
+			$this->value = urldecode( $value );
+			array_shift( $pairs ); //Removes name=value from items.
+
+			// Set everything else as a property
+			foreach ( $pairs as $pair ) {
+				$pair = rtrim($pair);
+				if ( empty($pair) ) //Handles the cookie ending in ; which results in a empty final pair
+					continue;
+
+				list( $key, $val ) = strpos( $pair, '=' ) ? explode( '=', $pair ) : array( $pair, '' );
+				$key = strtolower( trim( $key ) );
+				if ( 'expires' == $key )
+					$val = strtotime( $val );
+				$this->$key = $val;
+			}
+		} else {
+			if ( !isset( $data['name'] ) )
+				return false;
+
+			// Set properties based directly on parameters
+			$this->name   = $data['name'];
+			$this->value  = isset( $data['value'] ) ? $data['value'] : '';
+			$this->path   = isset( $data['path'] ) ? $data['path'] : '';
+			$this->domain = isset( $data['domain'] ) ? $data['domain'] : '';
+
+			if ( isset( $data['expires'] ) )
+				$this->expires = is_int( $data['expires'] ) ? $data['expires'] : strtotime( $data['expires'] );
+			else
+				$this->expires = null;
+		}
+	}
+
+	/**
+	 * Confirms that it's OK to send this cookie to the URL checked against.
+	 *
+	 * Decision is based on RFC 2109/2965, so look there for details on validity.
+	 *
+	 * @access public
+	 * @since 2.8.0
+	 *
+	 * @param string $url URL you intend to send this cookie to
+	 * @return boolean TRUE if allowed, FALSE otherwise.
+	 */
+	function test( $url ) {
+		// Expires - if expired then nothing else matters
+		if ( time() > $this->expires )
+			return false;
+
+		// Get details on the URL we're thinking about sending to
+		$url = parse_url( $url );
+		$url['port'] = isset( $url['port'] ) ? $url['port'] : 80;
+		$url['path'] = isset( $url['path'] ) ? $url['path'] : '/';
+
+		// Values to use for comparison against the URL
+		$path   = isset( $this->path )   ? $this->path   : '/';
+		$port   = isset( $this->port )   ? $this->port   : 80;
+		$domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] );
+		if ( false === stripos( $domain, '.' ) )
+			$domain .= '.local';
+
+		// Host - very basic check that the request URL ends with the domain restriction (minus leading dot)
+		$domain = substr( $domain, 0, 1 ) == '.' ? substr( $domain, 1 ) : $domain;
+		if ( substr( $url['host'], -strlen( $domain ) ) != $domain )
+			return false;
+
+		// Port - supports "port-lists" in the format: "80,8000,8080"
+		if ( !in_array( $url['port'], explode( ',', $port) ) )
+			return false;
+
+		// Path - request path must start with path restriction
+		if ( substr( $url['path'], 0, strlen( $path ) ) != $path )
+			return false;
+
+		return true;
+	}
+
+	/**
+	 * Convert cookie name and value back to header string.
+	 *
+	 * @access public
+	 * @since 2.8.0
+	 *
+	 * @return string Header encoded cookie name and value.
+	 */
+	function getHeaderValue() {
+		if ( empty( $this->name ) || empty( $this->value ) )
+			return '';
+
+		return $this->name . '=' . urlencode( $this->value );
+	}
+
+	/**
+	 * Retrieve cookie header for usage in the rest of the WordPress HTTP API.
+	 *
+	 * @access public
+	 * @since 2.8.0
+	 *
+	 * @return string
+	 */
+	function getFullHeader() {
+		return 'Cookie: ' . $this->getHeaderValue();
+	}
+}
+
+/**
+ * Implementation for deflate and gzip transfer encodings.
+ *
+ * Includes RFC 1950, RFC 1951, and RFC 1952.
+ *
+ * @since 2.8
+ * @package WordPress
+ * @subpackage HTTP
+ */
+class WP_Http_Encoding {
+
+	/**
+	 * Compress raw string using the deflate format.
+	 *
+	 * Supports the RFC 1951 standard.
+	 *
+	 * @since 2.8
+	 *
+	 * @param string $raw String to compress.
+	 * @param int $level Optional, default is 9. Compression level, 9 is highest.
+	 * @param string $supports Optional, not used. When implemented it will choose the right compression based on what the server supports.
+	 * @return string|bool False on failure.
+	 */
+	function compress( $raw, $level = 9, $supports = null ) {
+		return gzdeflate( $raw, $level );
+	}
+
+	/**
+	 * Decompression of deflated string.
+	 *
+	 * Will attempt to decompress using the RFC 1950 standard, and if that fails
+	 * then the RFC 1951 standard deflate will be attempted. Finally, the RFC
+	 * 1952 standard gzip decode will be attempted. If all fail, then the
+	 * original compressed string will be returned.
+	 *
+	 * @since 2.8
+	 *
+	 * @param string $compressed String to decompress.
+	 * @param int $length The optional length of the compressed data.
+	 * @return string|bool False on failure.
+	 */
+	function decompress( $compressed, $length = null ) {
+
+		if ( empty($compressed) )
+			return $compressed;
+
+		if ( false !== ( $decompressed = @gzinflate( $compressed ) ) )
+			return $decompressed;
+
+		if ( false !== ( $decompressed = WP_Http_Encoding::compatible_gzinflate( $compressed ) ) )
+			return $decompressed;
+
+		if ( false !== ( $decompressed = @gzuncompress( $compressed ) ) )
+			return $decompressed;
+
+		if ( function_exists('gzdecode') ) {
+			$decompressed = @gzdecode( $compressed );
+
+			if ( false !== $decompressed )
+				return $decompressed;
+		}
+
+		return $compressed;
+	}
+
+	/**
+	 * Decompression of deflated string while staying compatible with the majority of servers.
+	 *
+	 * Certain Servers will return deflated data with headers which PHP's gziniflate()
+	 * function cannot handle out of the box. The following function lifted from
+	 * http://au2.php.net/manual/en/function.gzinflate.php#77336 will attempt to deflate
+	 * the various return forms used.
+	 *
+	 * @since 2.8.1
+	 * @link http://au2.php.net/manual/en/function.gzinflate.php#77336
+	 *
+	 * @param string $gzData String to decompress.
+	 * @return string|bool False on failure.
+	 */
+	function compatible_gzinflate($gzData) {
+		if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) {
+			$i = 10;
+			$flg = ord( substr($gzData, 3, 1) );
+			if ( $flg > 0 ) {
+				if ( $flg & 4 ) {
+					list($xlen) = unpack('v', substr($gzData, $i, 2) );
+					$i = $i + 2 + $xlen;
+				}
+				if ( $flg & 8 )
+					$i = strpos($gzData, "\0", $i) + 1;
+				if ( $flg & 16 )
+					$i = strpos($gzData, "\0", $i) + 1;
+				if ( $flg & 2 )
+					$i = $i + 2;
+			}
+			return gzinflate( substr($gzData, $i, -8) );
+		} else {
+			return false;
+		}
+	}
+
+	/**
+	 * What encoding types to accept and their priority values.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string Types of encoding to accept.
+	 */
+	function accept_encoding() {
+		$type = array();
+		if ( function_exists( 'gzinflate' ) )
+			$type[] = 'deflate;q=1.0';
+
+		if ( function_exists( 'gzuncompress' ) )
+			$type[] = 'compress;q=0.5';
+
+		if ( function_exists( 'gzdecode' ) )
+			$type[] = 'gzip;q=0.5';
+
+		return implode(', ', $type);
+	}
+
+	/**
+	 * What enconding the content used when it was compressed to send in the headers.
+	 *
+	 * @since 2.8
+	 *
+	 * @return string Content-Encoding string to send in the header.
+	 */
+	function content_encoding() {
+		return 'deflate';
+	}
+
+	/**
+	 * Whether the content be decoded based on the headers.
+	 *
+	 * @since 2.8
+	 *
+	 * @param array|string $headers All of the available headers.
+	 * @return bool
+	 */
+	function should_decode($headers) {
+		if ( is_array( $headers ) ) {
+			if ( array_key_exists('content-encoding', $headers) && ! empty( $headers['content-encoding'] ) )
+				return true;
+		} else if ( is_string( $headers ) ) {
+			return ( stripos($headers, 'content-encoding:') !== false );
+		}
+
+		return false;
+	}
+
+	/**
+	 * Whether decompression and compression are supported by the PHP version.
+	 *
+	 * Each function is tested instead of checking for the zlib extension, to
+	 * ensure that the functions all exist in the PHP version and aren't
+	 * disabled.
+	 *
+	 * @since 2.8
+	 *
+	 * @return bool
+	 */
+	function is_available() {
+		return ( function_exists('gzuncompress') || function_exists('gzdeflate') || function_exists('gzinflate') );
+	}
+}
Index: /tags/3.1/wp-includes/class-json.php
===================================================================
--- /tags/3.1/wp-includes/class-json.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-json.php	(revision 17487)
@@ -0,0 +1,863 @@
+<?php
+if ( !class_exists( 'Services_JSON' ) ) :
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+/**
+ * Converts to and from JSON format.
+ *
+ * JSON (JavaScript Object Notation) is a lightweight data-interchange
+ * format. It is easy for humans to read and write. It is easy for machines
+ * to parse and generate. It is based on a subset of the JavaScript
+ * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
+ * This feature can also be found in  Python. JSON is a text format that is
+ * completely language independent but uses conventions that are familiar
+ * to programmers of the C-family of languages, including C, C++, C#, Java,
+ * JavaScript, Perl, TCL, and many others. These properties make JSON an
+ * ideal data-interchange language.
+ *
+ * This package provides a simple encoder and decoder for JSON notation. It
+ * is intended for use with client-side Javascript applications that make
+ * use of HTTPRequest to perform server communication functions - data can
+ * be encoded into JSON notation for use in a client-side javascript, or
+ * decoded from incoming Javascript requests. JSON format is native to
+ * Javascript, and can be directly eval()'ed with no further parsing
+ * overhead
+ *
+ * All strings should be in ASCII or UTF-8 format!
+ *
+ * LICENSE: Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met: Redistributions of source code must retain the
+ * above copyright notice, this list of conditions and the following
+ * disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * @category
+ * @package		Services_JSON
+ * @author		Michal Migurski <mike-json@teczno.com>
+ * @author		Matt Knapp <mdknapp[at]gmail[dot]com>
+ * @author		Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
+ * @copyright	2005 Michal Migurski
+ * @version     CVS: $Id: JSON.php 288200 2009-09-09 15:41:29Z alan_k $
+ * @license		http://www.opensource.org/licenses/bsd-license.php
+ * @link		http://pear.php.net/pepr/pepr-proposal-show.php?id=198
+ */
+
+/**
+ * Marker constant for Services_JSON::decode(), used to flag stack state
+ */
+define('SERVICES_JSON_SLICE', 1);
+
+/**
+ * Marker constant for Services_JSON::decode(), used to flag stack state
+ */
+define('SERVICES_JSON_IN_STR',  2);
+
+/**
+ * Marker constant for Services_JSON::decode(), used to flag stack state
+ */
+define('SERVICES_JSON_IN_ARR',  3);
+
+/**
+ * Marker constant for Services_JSON::decode(), used to flag stack state
+ */
+define('SERVICES_JSON_IN_OBJ',  4);
+
+/**
+ * Marker constant for Services_JSON::decode(), used to flag stack state
+ */
+define('SERVICES_JSON_IN_CMT', 5);
+
+/**
+ * Behavior switch for Services_JSON::decode()
+ */
+define('SERVICES_JSON_LOOSE_TYPE', 16);
+
+/**
+ * Behavior switch for Services_JSON::decode()
+ */
+define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
+
+/**
+ * Converts to and from JSON format.
+ *
+ * Brief example of use:
+ *
+ * <code>
+ * // create a new instance of Services_JSON
+ * $json = new Services_JSON();
+ *
+ * // convert a complexe value to JSON notation, and send it to the browser
+ * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
+ * $output = $json->encode($value);
+ *
+ * print($output);
+ * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
+ *
+ * // accept incoming POST data, assumed to be in JSON notation
+ * $input = file_get_contents('php://input', 1000000);
+ * $value = $json->decode($input);
+ * </code>
+ */
+class Services_JSON
+{
+ /**
+	* constructs a new JSON instance
+	*
+	* @param int $use object behavior flags; combine with boolean-OR
+	*
+	*						possible values:
+	*						- SERVICES_JSON_LOOSE_TYPE:  loose typing.
+	*								"{...}" syntax creates associative arrays
+	*								instead of objects in decode().
+	*						- SERVICES_JSON_SUPPRESS_ERRORS:  error suppression.
+	*								Values which can't be encoded (e.g. resources)
+	*								appear as NULL instead of throwing errors.
+	*								By default, a deeply-nested resource will
+	*								bubble up with an error, so all return values
+	*								from encode() should be checked with isError()
+	*/
+	function Services_JSON($use = 0)
+	{
+		$this->use = $use;
+	}
+
+ /**
+	* convert a string from one UTF-16 char to one UTF-8 char
+	*
+	* Normally should be handled by mb_convert_encoding, but
+	* provides a slower PHP-only method for installations
+	* that lack the multibye string extension.
+	*
+	* @param	string  $utf16  UTF-16 character
+	* @return string  UTF-8 character
+	* @access private
+	*/
+	function utf162utf8($utf16)
+	{
+		// oh please oh please oh please oh please oh please
+		if(function_exists('mb_convert_encoding')) {
+			return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
+		}
+
+		$bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);
+
+		switch(true) {
+			case ((0x7F & $bytes) == $bytes):
+				// this case should never be reached, because we are in ASCII range
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+				return chr(0x7F & $bytes);
+
+			case (0x07FF & $bytes) == $bytes:
+				// return a 2-byte UTF-8 character
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+				return chr(0xC0 | (($bytes >> 6) & 0x1F))
+					. chr(0x80 | ($bytes & 0x3F));
+
+			case (0xFFFF & $bytes) == $bytes:
+				// return a 3-byte UTF-8 character
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+				return chr(0xE0 | (($bytes >> 12) & 0x0F))
+					. chr(0x80 | (($bytes >> 6) & 0x3F))
+					. chr(0x80 | ($bytes & 0x3F));
+		}
+
+		// ignoring UTF-32 for now, sorry
+		return '';
+	}
+
+ /**
+	* convert a string from one UTF-8 char to one UTF-16 char
+	*
+	* Normally should be handled by mb_convert_encoding, but
+	* provides a slower PHP-only method for installations
+	* that lack the multibye string extension.
+	*
+	* @param	string  $utf8 UTF-8 character
+	* @return string  UTF-16 character
+	* @access private
+	*/
+	function utf82utf16($utf8)
+	{
+		// oh please oh please oh please oh please oh please
+		if(function_exists('mb_convert_encoding')) {
+			return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
+		}
+
+		switch(strlen($utf8)) {
+			case 1:
+				// this case should never be reached, because we are in ASCII range
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+				return $utf8;
+
+			case 2:
+				// return a UTF-16 character from a 2-byte UTF-8 char
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+				return chr(0x07 & (ord($utf8[0]) >> 2))
+					. chr((0xC0 & (ord($utf8[0]) << 6))
+						| (0x3F & ord($utf8[1])));
+
+			case 3:
+				// return a UTF-16 character from a 3-byte UTF-8 char
+				// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+				return chr((0xF0 & (ord($utf8[0]) << 4))
+						| (0x0F & (ord($utf8[1]) >> 2)))
+					. chr((0xC0 & (ord($utf8[1]) << 6))
+						| (0x7F & ord($utf8[2])));
+		}
+
+		// ignoring UTF-32 for now, sorry
+		return '';
+	}
+
+ /**
+	* encodes an arbitrary variable into JSON format (and sends JSON Header)
+	*
+	* @param	mixed $var	any number, boolean, string, array, or object to be encoded.
+	*						see argument 1 to Services_JSON() above for array-parsing behavior.
+	*						if var is a strng, note that encode() always expects it
+	*						to be in ASCII or UTF-8 format!
+	*
+	* @return mixed JSON string representation of input var or an error if a problem occurs
+	* @access public
+	*/
+	function encode($var)
+	{
+		header('Content-type: application/json');
+		return $this->_encode($var);
+	}
+	/**
+	* encodes an arbitrary variable into JSON format without JSON Header - warning - may allow CSS!!!!)
+	*
+	* @param	mixed $var	any number, boolean, string, array, or object to be encoded.
+	*						see argument 1 to Services_JSON() above for array-parsing behavior.
+	*						if var is a strng, note that encode() always expects it
+	*						to be in ASCII or UTF-8 format!
+	*
+	* @return mixed JSON string representation of input var or an error if a problem occurs
+	* @access public
+	*/
+	function encodeUnsafe($var)
+	{
+		return $this->_encode($var);
+	}
+	/**
+	* PRIVATE CODE that does the work of encodes an arbitrary variable into JSON format
+	*
+	* @param	mixed $var	any number, boolean, string, array, or object to be encoded.
+	*						see argument 1 to Services_JSON() above for array-parsing behavior.
+	*						if var is a strng, note that encode() always expects it
+	*						to be in ASCII or UTF-8 format!
+	*
+	* @return mixed JSON string representation of input var or an error if a problem occurs
+	* @access public
+	*/
+	function _encode($var)
+	{
+
+		switch (gettype($var)) {
+			case 'boolean':
+				return $var ? 'true' : 'false';
+
+			case 'NULL':
+				return 'null';
+
+			case 'integer':
+				return (int) $var;
+
+			case 'double':
+			case 'float':
+				return (float) $var;
+
+			case 'string':
+				// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
+				$ascii = '';
+				$strlen_var = strlen($var);
+
+			/*
+				* Iterate over every character in the string,
+				* escaping with a slash or encoding to UTF-8 where necessary
+				*/
+				for ($c = 0; $c < $strlen_var; ++$c) {
+
+					$ord_var_c = ord($var[$c]);
+
+					switch (true) {
+						case $ord_var_c == 0x08:
+							$ascii .= '\b';
+							break;
+						case $ord_var_c == 0x09:
+							$ascii .= '\t';
+							break;
+						case $ord_var_c == 0x0A:
+							$ascii .= '\n';
+							break;
+						case $ord_var_c == 0x0C:
+							$ascii .= '\f';
+							break;
+						case $ord_var_c == 0x0D:
+							$ascii .= '\r';
+							break;
+
+						case $ord_var_c == 0x22:
+						case $ord_var_c == 0x2F:
+						case $ord_var_c == 0x5C:
+							// double quote, slash, slosh
+							$ascii .= '\\'.$var[$c];
+							break;
+
+						case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
+							// characters U-00000000 - U-0000007F (same as ASCII)
+							$ascii .= $var[$c];
+							break;
+
+						case (($ord_var_c & 0xE0) == 0xC0):
+							// characters U-00000080 - U-000007FF, mask 110XXXXX
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+							if ($c+1 >= $strlen_var) {
+								$c += 1;
+								$ascii .= '?';
+								break;
+							}
+
+							$char = pack('C*', $ord_var_c, ord($var[$c + 1]));
+							$c += 1;
+							$utf16 = $this->utf82utf16($char);
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
+							break;
+
+						case (($ord_var_c & 0xF0) == 0xE0):
+							if ($c+2 >= $strlen_var) {
+								$c += 2;
+								$ascii .= '?';
+								break;
+							}
+							// characters U-00000800 - U-0000FFFF, mask 1110XXXX
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+							$char = pack('C*', $ord_var_c,
+										@ord($var[$c + 1]),
+										@ord($var[$c + 2]));
+							$c += 2;
+							$utf16 = $this->utf82utf16($char);
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
+							break;
+
+						case (($ord_var_c & 0xF8) == 0xF0):
+							if ($c+3 >= $strlen_var) {
+								$c += 3;
+								$ascii .= '?';
+								break;
+							}
+							// characters U-00010000 - U-001FFFFF, mask 11110XXX
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+							$char = pack('C*', $ord_var_c,
+										ord($var[$c + 1]),
+										ord($var[$c + 2]),
+										ord($var[$c + 3]));
+							$c += 3;
+							$utf16 = $this->utf82utf16($char);
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
+							break;
+
+						case (($ord_var_c & 0xFC) == 0xF8):
+							// characters U-00200000 - U-03FFFFFF, mask 111110XX
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+							if ($c+4 >= $strlen_var) {
+								$c += 4;
+								$ascii .= '?';
+								break;
+							}
+							$char = pack('C*', $ord_var_c,
+										ord($var[$c + 1]),
+										ord($var[$c + 2]),
+										ord($var[$c + 3]),
+										ord($var[$c + 4]));
+							$c += 4;
+							$utf16 = $this->utf82utf16($char);
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
+							break;
+
+						case (($ord_var_c & 0xFE) == 0xFC):
+						if ($c+5 >= $strlen_var) {
+								$c += 5;
+								$ascii .= '?';
+								break;
+							}
+							// characters U-04000000 - U-7FFFFFFF, mask 1111110X
+							// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+							$char = pack('C*', $ord_var_c,
+										ord($var[$c + 1]),
+										ord($var[$c + 2]),
+										ord($var[$c + 3]),
+										ord($var[$c + 4]),
+										ord($var[$c + 5]));
+							$c += 5;
+							$utf16 = $this->utf82utf16($char);
+							$ascii .= sprintf('\u%04s', bin2hex($utf16));
+							break;
+					}
+				}
+				return  '"'.$ascii.'"';
+
+			case 'array':
+			/*
+				* As per JSON spec if any array key is not an integer
+				* we must treat the the whole array as an object. We
+				* also try to catch a sparsely populated associative
+				* array with numeric keys here because some JS engines
+				* will create an array with empty indexes up to
+				* max_index which can cause memory issues and because
+				* the keys, which may be relevant, will be remapped
+				* otherwise.
+				*
+				* As per the ECMA and JSON specification an object may
+				* have any string as a property. Unfortunately due to
+				* a hole in the ECMA specification if the key is a
+				* ECMA reserved word or starts with a digit the
+				* parameter is only accessible using ECMAScript's
+				* bracket notation.
+				*/
+
+				// treat as a JSON object
+				if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
+					$properties = array_map(array($this, 'name_value'),
+											array_keys($var),
+											array_values($var));
+
+					foreach($properties as $property) {
+						if(Services_JSON::isError($property)) {
+							return $property;
+						}
+					}
+
+					return '{' . join(',', $properties) . '}';
+				}
+
+				// treat it like a regular array
+				$elements = array_map(array($this, '_encode'), $var);
+
+				foreach($elements as $element) {
+					if(Services_JSON::isError($element)) {
+						return $element;
+					}
+				}
+
+				return '[' . join(',', $elements) . ']';
+
+			case 'object':
+				$vars = get_object_vars($var);
+
+				$properties = array_map(array($this, 'name_value'),
+										array_keys($vars),
+										array_values($vars));
+
+				foreach($properties as $property) {
+					if(Services_JSON::isError($property)) {
+						return $property;
+					}
+				}
+
+				return '{' . join(',', $properties) . '}';
+
+			default:
+				return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
+					? 'null'
+					: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
+		}
+	}
+
+ /**
+	* array-walking function for use in generating JSON-formatted name-value pairs
+	*
+	* @param	string  $name name of key to use
+	* @param	mixed $value  reference to an array element to be encoded
+	*
+	* @return string  JSON-formatted name-value pair, like '"name":value'
+	* @access private
+	*/
+	function name_value($name, $value)
+	{
+		$encoded_value = $this->_encode($value);
+
+		if(Services_JSON::isError($encoded_value)) {
+			return $encoded_value;
+		}
+
+		return $this->_encode(strval($name)) . ':' . $encoded_value;
+	}
+
+ /**
+	* reduce a string by removing leading and trailing comments and whitespace
+	*
+	* @param	$str	string	string value to strip of comments and whitespace
+	*
+	* @return string  string value stripped of comments and whitespace
+	* @access private
+	*/
+	function reduce_string($str)
+	{
+		$str = preg_replace(array(
+
+				// eliminate single line comments in '// ...' form
+				'#^\s*//(.+)$#m',
+
+				// eliminate multi-line comments in '/* ... */' form, at start of string
+				'#^\s*/\*(.+)\*/#Us',
+
+				// eliminate multi-line comments in '/* ... */' form, at end of string
+				'#/\*(.+)\*/\s*$#Us'
+
+			), '', $str);
+
+		// eliminate extraneous space
+		return trim($str);
+	}
+
+ /**
+	* decodes a JSON string into appropriate variable
+	*
+	* @param	string  $str	JSON-formatted string
+	*
+	* @return mixed number, boolean, string, array, or object
+	*				corresponding to given JSON input string.
+	*				See argument 1 to Services_JSON() above for object-output behavior.
+	*				Note that decode() always returns strings
+	*				in ASCII or UTF-8 format!
+	* @access public
+	*/
+	function decode($str)
+	{
+		$str = $this->reduce_string($str);
+
+		switch (strtolower($str)) {
+			case 'true':
+				return true;
+
+			case 'false':
+				return false;
+
+			case 'null':
+				return null;
+
+			default:
+				$m = array();
+
+				if (is_numeric($str)) {
+					// Lookie-loo, it's a number
+
+					// This would work on its own, but I'm trying to be
+					// good about returning integers where appropriate:
+					// return (float)$str;
+
+					// Return float or int, as appropriate
+					return ((float)$str == (integer)$str)
+						? (integer)$str
+						: (float)$str;
+
+				} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
+					// STRINGS RETURNED IN UTF-8 FORMAT
+					$delim = substr($str, 0, 1);
+					$chrs = substr($str, 1, -1);
+					$utf8 = '';
+					$strlen_chrs = strlen($chrs);
+
+					for ($c = 0; $c < $strlen_chrs; ++$c) {
+
+						$substr_chrs_c_2 = substr($chrs, $c, 2);
+						$ord_chrs_c = ord($chrs[$c]);
+
+						switch (true) {
+							case $substr_chrs_c_2 == '\b':
+								$utf8 .= chr(0x08);
+								++$c;
+								break;
+							case $substr_chrs_c_2 == '\t':
+								$utf8 .= chr(0x09);
+								++$c;
+								break;
+							case $substr_chrs_c_2 == '\n':
+								$utf8 .= chr(0x0A);
+								++$c;
+								break;
+							case $substr_chrs_c_2 == '\f':
+								$utf8 .= chr(0x0C);
+								++$c;
+								break;
+							case $substr_chrs_c_2 == '\r':
+								$utf8 .= chr(0x0D);
+								++$c;
+								break;
+
+							case $substr_chrs_c_2 == '\\"':
+							case $substr_chrs_c_2 == '\\\'':
+							case $substr_chrs_c_2 == '\\\\':
+							case $substr_chrs_c_2 == '\\/':
+								if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
+								($delim == "'" && $substr_chrs_c_2 != '\\"')) {
+									$utf8 .= $chrs[++$c];
+								}
+								break;
+
+							case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
+								// single, escaped unicode character
+								$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
+									. chr(hexdec(substr($chrs, ($c + 4), 2)));
+								$utf8 .= $this->utf162utf8($utf16);
+								$c += 5;
+								break;
+
+							case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
+								$utf8 .= $chrs[$c];
+								break;
+
+							case ($ord_chrs_c & 0xE0) == 0xC0:
+								// characters U-00000080 - U-000007FF, mask 110XXXXX
+								//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+								$utf8 .= substr($chrs, $c, 2);
+								++$c;
+								break;
+
+							case ($ord_chrs_c & 0xF0) == 0xE0:
+								// characters U-00000800 - U-0000FFFF, mask 1110XXXX
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+								$utf8 .= substr($chrs, $c, 3);
+								$c += 2;
+								break;
+
+							case ($ord_chrs_c & 0xF8) == 0xF0:
+								// characters U-00010000 - U-001FFFFF, mask 11110XXX
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+								$utf8 .= substr($chrs, $c, 4);
+								$c += 3;
+								break;
+
+							case ($ord_chrs_c & 0xFC) == 0xF8:
+								// characters U-00200000 - U-03FFFFFF, mask 111110XX
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+								$utf8 .= substr($chrs, $c, 5);
+								$c += 4;
+								break;
+
+							case ($ord_chrs_c & 0xFE) == 0xFC:
+								// characters U-04000000 - U-7FFFFFFF, mask 1111110X
+								// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+								$utf8 .= substr($chrs, $c, 6);
+								$c += 5;
+								break;
+
+						}
+
+					}
+
+					return $utf8;
+
+				} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
+					// array, or object notation
+
+					if ($str[0] == '[') {
+						$stk = array(SERVICES_JSON_IN_ARR);
+						$arr = array();
+					} else {
+						if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
+							$stk = array(SERVICES_JSON_IN_OBJ);
+							$obj = array();
+						} else {
+							$stk = array(SERVICES_JSON_IN_OBJ);
+							$obj = new stdClass();
+						}
+					}
+
+					array_push($stk, array('what'  => SERVICES_JSON_SLICE,
+										'where' => 0,
+										'delim' => false));
+
+					$chrs = substr($str, 1, -1);
+					$chrs = $this->reduce_string($chrs);
+
+					if ($chrs == '') {
+						if (reset($stk) == SERVICES_JSON_IN_ARR) {
+							return $arr;
+
+						} else {
+							return $obj;
+
+						}
+					}
+
+					//print("\nparsing {$chrs}\n");
+
+					$strlen_chrs = strlen($chrs);
+
+					for ($c = 0; $c <= $strlen_chrs; ++$c) {
+
+						$top = end($stk);
+						$substr_chrs_c_2 = substr($chrs, $c, 2);
+
+						if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
+							// found a comma that is not inside a string, array, etc.,
+							// OR we've reached the end of the character list
+							$slice = substr($chrs, $top['where'], ($c - $top['where']));
+							array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
+							//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+							if (reset($stk) == SERVICES_JSON_IN_ARR) {
+								// we are in an array, so just push an element onto the stack
+								array_push($arr, $this->decode($slice));
+
+							} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
+								// we are in an object, so figure
+								// out the property name and set an
+								// element in an associative array,
+								// for now
+								$parts = array();
+
+								if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
+									// "name":value pair
+									$key = $this->decode($parts[1]);
+									$val = $this->decode($parts[2]);
+
+									if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
+										$obj[$key] = $val;
+									} else {
+										$obj->$key = $val;
+									}
+								} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
+									// name:value pair, where name is unquoted
+									$key = $parts[1];
+									$val = $this->decode($parts[2]);
+
+									if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
+										$obj[$key] = $val;
+									} else {
+										$obj->$key = $val;
+									}
+								}
+
+							}
+
+						} elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
+							// found a quote, and we are not inside a string
+							array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
+							//print("Found start of string at {$c}\n");
+
+						} elseif (($chrs[$c] == $top['delim']) &&
+								($top['what'] == SERVICES_JSON_IN_STR) &&
+								((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
+							// found a quote, we're in a string, and it's not escaped
+							// we know that it's not escaped becase there is _not_ an
+							// odd number of backslashes at the end of the string so far
+							array_pop($stk);
+							//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
+
+						} elseif (($chrs[$c] == '[') &&
+								in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
+							// found a left-bracket, and we are in an array, object, or slice
+							array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
+							//print("Found start of array at {$c}\n");
+
+						} elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
+							// found a right-bracket, and we're in an array
+							array_pop($stk);
+							//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+						} elseif (($chrs[$c] == '{') &&
+								in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
+							// found a left-brace, and we are in an array, object, or slice
+							array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
+							//print("Found start of object at {$c}\n");
+
+						} elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
+							// found a right-brace, and we're in an object
+							array_pop($stk);
+							//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+						} elseif (($substr_chrs_c_2 == '/*') &&
+								in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
+							// found a comment start, and we are in an array, object, or slice
+							array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
+							$c++;
+							//print("Found start of comment at {$c}\n");
+
+						} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
+							// found a comment end, and we're in one now
+							array_pop($stk);
+							$c++;
+
+							for ($i = $top['where']; $i <= $c; ++$i)
+								$chrs = substr_replace($chrs, ' ', $i, 1);
+
+							//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+						}
+
+					}
+
+					if (reset($stk) == SERVICES_JSON_IN_ARR) {
+						return $arr;
+
+					} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
+						return $obj;
+
+					}
+
+				}
+		}
+	}
+
+	/**
+	* @todo Ultimately, this should just call PEAR::isError()
+	*/
+	function isError($data, $code = null)
+	{
+		if (class_exists('pear')) {
+			return PEAR::isError($data, $code);
+		} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
+								is_subclass_of($data, 'services_json_error'))) {
+			return true;
+		}
+
+		return false;
+	}
+}
+
+if (class_exists('PEAR_Error')) {
+
+	class Services_JSON_Error extends PEAR_Error
+	{
+		function Services_JSON_Error($message = 'unknown error', $code = null,
+									$mode = null, $options = null, $userinfo = null)
+		{
+			parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
+		}
+	}
+
+} else {
+
+	/**
+	* @todo Ultimately, this class shall be descended from PEAR_Error
+	*/
+	class Services_JSON_Error
+	{
+		function Services_JSON_Error($message = 'unknown error', $code = null,
+									$mode = null, $options = null, $userinfo = null)
+		{
+
+		}
+	}
+
+}
+endif;
+?>
Index: /tags/3.1/wp-includes/class-oembed.php
===================================================================
--- /tags/3.1/wp-includes/class-oembed.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-oembed.php	(revision 17487)
@@ -0,0 +1,302 @@
+<?php
+/**
+ * API for fetching the HTML to embed remote content based on a provided URL.
+ * Used internally by the {@link WP_Embed} class, but is designed to be generic.
+ *
+ * @link http://codex.wordpress.org/oEmbed oEmbed Codex Article
+ * @link http://oembed.com/ oEmbed Homepage
+ *
+ * @package WordPress
+ * @subpackage oEmbed
+ */
+
+/**
+ * oEmbed class.
+ *
+ * @package WordPress
+ * @subpackage oEmbed
+ * @since 2.9.0
+ */
+class WP_oEmbed {
+	var $providers = array();
+
+	/**
+	 * PHP4 constructor
+	 */
+	function WP_oEmbed() {
+		return $this->__construct();
+	}
+
+	/**
+	 * PHP5 constructor
+	 *
+	 * @uses apply_filters() Filters a list of pre-defined oEmbed providers.
+	 */
+	function __construct() {
+		// List out some popular sites that support oEmbed.
+		// The WP_Embed class disables discovery for non-unfiltered_html users, so only providers in this array will be used for them.
+		// Add to this list using the wp_oembed_add_provider() function (see it's PHPDoc for details).
+		$this->providers = apply_filters( 'oembed_providers', array(
+			'#http://(www\.)?youtube.com/watch.*#i'         => array( 'http://www.youtube.com/oembed',            true  ),
+			'http://youtu.be/*'                             => array( 'http://www.youtube.com/oembed',            false ),
+			'http://blip.tv/file/*'                         => array( 'http://blip.tv/oembed/',                   false ),
+			'#http://(www\.)?vimeo\.com/.*#i'               => array( 'http://www.vimeo.com/api/oembed.{format}', true  ),
+			'#http://(www\.)?dailymotion\.com/.*#i'         => array( 'http://www.dailymotion.com/api/oembed',    true  ),
+			'#http://(www\.)?flickr\.com/.*#i'              => array( 'http://www.flickr.com/services/oembed/',   true  ),
+			'#http://(.+)?smugmug\.com/.*#i'                => array( 'http://api.smugmug.com/services/oembed/',  true  ),
+			'#http://(www\.)?hulu\.com/watch/.*#i'          => array( 'http://www.hulu.com/api/oembed.{format}',  true  ),
+			'#http://(www\.)?viddler\.com/.*#i'             => array( 'http://lab.viddler.com/services/oembed/',  true  ),
+			'http://qik.com/*'                              => array( 'http://qik.com/api/oembed.{format}',       false ),
+			'http://revision3.com/*'                        => array( 'http://revision3.com/api/oembed/',         false ),
+			'http://i*.photobucket.com/albums/*'            => array( 'http://photobucket.com/oembed',            false ),
+			'http://gi*.photobucket.com/groups/*'           => array( 'http://photobucket.com/oembed',            false ),
+			'#http://(www\.)?scribd\.com/.*#i'              => array( 'http://www.scribd.com/services/oembed',    true  ),
+			'http://wordpress.tv/*'                         => array( 'http://wordpress.tv/oembed/',              false ),
+			'#http://(answers|surveys)\.polldaddy.com/.*#i' => array( 'http://polldaddy.com/oembed/',             true  ),
+			'#http://(www\.)?funnyordie\.com/videos/.*#i'   => array( 'http://www.funnyordie.com/oembed',         true  ),
+		) );
+
+		// Fix any embeds that contain new lines in the middle of the HTML which breaks wpautop().
+		add_filter( 'oembed_dataparse', array(&$this, '_strip_newlines'), 10, 3 );
+	}
+
+	/**
+	 * The do-it-all function that takes a URL and attempts to return the HTML.
+	 *
+	 * @see WP_oEmbed::discover()
+	 * @see WP_oEmbed::fetch()
+	 * @see WP_oEmbed::data2html()
+	 *
+	 * @param string $url The URL to the content that should be attempted to be embedded.
+	 * @param array $args Optional arguments. Usually passed from a shortcode.
+	 * @return bool|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
+	 */
+	function get_html( $url, $args = '' ) {
+		$provider = false;
+
+		if ( !isset($args['discover']) )
+			$args['discover'] = true;
+
+		foreach ( $this->providers as $matchmask => $data ) {
+			list( $providerurl, $regex ) = $data;
+
+			// Turn the asterisk-type provider URLs into regex
+			if ( !$regex )
+				$matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i';
+
+			if ( preg_match( $matchmask, $url ) ) {
+				$provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML
+				break;
+			}
+		}
+
+		if ( !$provider && $args['discover'] )
+			$provider = $this->discover( $url );
+
+		if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
+			return false;
+
+		return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args );
+	}
+
+	/**
+	 * Attempts to find oEmbed provider discovery <link> tags at the given URL.
+	 *
+	 * @param string $url The URL that should be inspected for discovery <link> tags.
+	 * @return bool|string False on failure, otherwise the oEmbed provider URL.
+	 */
+	function discover( $url ) {
+		$providers = array();
+
+		// Fetch URL content
+		if ( $html = wp_remote_retrieve_body( wp_remote_get( $url ) ) ) {
+
+			// <link> types that contain oEmbed provider URLs
+			$linktypes = apply_filters( 'oembed_linktypes', array(
+				'application/json+oembed' => 'json',
+				'text/xml+oembed' => 'xml',
+				'application/xml+oembed' => 'xml', // Incorrect, but used by at least Vimeo
+			) );
+
+			// Strip <body>
+			$html = substr( $html, 0, stripos( $html, '</head>' ) );
+
+			// Do a quick check
+			$tagfound = false;
+			foreach ( $linktypes as $linktype => $format ) {
+				if ( stripos($html, $linktype) ) {
+					$tagfound = true;
+					break;
+				}
+			}
+
+			if ( $tagfound && preg_match_all( '/<link([^<>]+)>/i', $html, $links ) ) {
+				foreach ( $links[1] as $link ) {
+					$atts = shortcode_parse_atts( $link );
+
+					if ( !empty($atts['type']) && !empty($linktypes[$atts['type']]) && !empty($atts['href']) ) {
+						$providers[$linktypes[$atts['type']]] = $atts['href'];
+
+						// Stop here if it's JSON (that's all we need)
+						if ( 'json' == $linktypes[$atts['type']] )
+							break;
+					}
+				}
+			}
+		}
+
+		// JSON is preferred to XML
+		if ( !empty($providers['json']) )
+			return $providers['json'];
+		elseif ( !empty($providers['xml']) )
+			return $providers['xml'];
+		else
+			return false;
+	}
+
+	/**
+	 * Connects to a oEmbed provider and returns the result.
+	 *
+	 * @param string $provider The URL to the oEmbed provider.
+	 * @param string $url The URL to the content that is desired to be embedded.
+	 * @param array $args Optional arguments. Usually passed from a shortcode.
+	 * @return bool|object False on failure, otherwise the result in the form of an object.
+	 */
+	function fetch( $provider, $url, $args = '' ) {
+		$args = wp_parse_args( $args, wp_embed_defaults() );
+
+		$provider = add_query_arg( 'maxwidth', $args['width'], $provider );
+		$provider = add_query_arg( 'maxheight', $args['height'], $provider );
+		$provider = add_query_arg( 'url', urlencode($url), $provider );
+
+		foreach( array( 'json', 'xml' ) as $format ) {
+			$result = $this->_fetch_with_format( $provider, $format );
+			if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() )
+				continue;
+			return ( $result && ! is_wp_error( $result ) ) ? $result : false;
+		}
+		return false;
+	}
+
+	/**
+	 * Fetches result from an oEmbed provider for a specific format and complete provider URL
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 * @param string $provider_url_with_args URL to the provider with full arguments list (url, maxheight, etc.)
+	 * @param string $format Format to use
+	 * @return bool|object False on failure, otherwise the result in the form of an object.
+	 */
+	function _fetch_with_format( $provider_url_with_args, $format ) {
+		$provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
+		$response = wp_remote_get( $provider_url_with_args );
+		if ( 501 == wp_remote_retrieve_response_code( $response ) )
+			return new WP_Error( 'not-implemented' );
+		if ( ! $body = wp_remote_retrieve_body( $response ) )
+			return false;
+		$parse_method = "_parse_$format";
+		return $this->$parse_method( $body );
+	}
+
+	/**
+	 * Parses a json response body.
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 */
+	function _parse_json( $response_body ) {
+		return ( ( $data = json_decode( trim( $response_body ) ) ) && is_object( $data ) ) ? $data : false;
+	}
+
+	/**
+	 * Parses an XML response body.
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 */
+	function _parse_xml( $response_body ) {
+		if ( function_exists('simplexml_load_string') ) {
+			$errors = libxml_use_internal_errors( 'true' );
+			$data = simplexml_load_string( $response_body );
+			libxml_use_internal_errors( $errors );
+			if ( is_object( $data ) )
+				return $data;
+		}
+		return false;
+	}
+
+	/**
+	 * Converts a data object from {@link WP_oEmbed::fetch()} and returns the HTML.
+	 *
+	 * @param object $data A data object result from an oEmbed provider.
+	 * @param string $url The URL to the content that is desired to be embedded.
+	 * @return bool|string False on error, otherwise the HTML needed to embed.
+	 */
+	function data2html( $data, $url ) {
+		if ( !is_object($data) || empty($data->type) )
+			return false;
+
+		switch ( $data->type ) {
+			case 'photo':
+				if ( empty($data->url) || empty($data->width) || empty($data->height) )
+					return false;
+
+				$title = ( !empty($data->title) ) ? $data->title : '';
+				$return = '<a href="' . esc_url( $url ) . '"><img src="' . esc_url( $data->url ) . '" alt="' . esc_attr($title) . '" width="' . esc_attr($data->width) . '" height="' . esc_attr($data->height) . '" /></a>';
+				break;
+
+			case 'video':
+			case 'rich':
+				$return = ( !empty($data->html) ) ? $data->html : false;
+				break;
+
+			case 'link':
+				$return = ( !empty($data->title) ) ? '<a href="' . esc_url($url) . '">' . esc_html($data->title) . '</a>' : false;
+				break;
+
+			default;
+				$return = false;
+		}
+
+		// You can use this filter to add support for custom data types or to filter the result
+		return apply_filters( 'oembed_dataparse', $return, $data, $url );
+	}
+
+	/**
+	 * Strip any new lines from the HTML.
+	 *
+	 * @access private
+	 * @param string $html Existing HTML.
+	 * @param object $data Data object from WP_oEmbed::data2html()
+	 * @param string $url The original URL passed to oEmbed.
+	 * @return string Possibly modified $html
+	 */
+	function _strip_newlines( $html, $data, $url ) {
+		if ( false !== strpos( $html, "\n" ) )
+			$html = str_replace( array( "\r\n", "\n" ), '', $html );
+
+		return $html;
+	}
+}
+
+/**
+ * Returns the initialized {@link WP_oEmbed} object
+ *
+ * @since 2.9.0
+ * @access private
+ *
+ * @see WP_oEmbed
+ * @uses WP_oEmbed
+ *
+ * @return WP_oEmbed object.
+ */
+function &_wp_oembed_get_object() {
+	static $wp_oembed;
+
+	if ( is_null($wp_oembed) )
+		$wp_oembed = new WP_oEmbed();
+
+	return $wp_oembed;
+}
+
+?>
Index: /tags/3.1/wp-includes/class-phpass.php
===================================================================
--- /tags/3.1/wp-includes/class-phpass.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-phpass.php	(revision 17487)
@@ -0,0 +1,258 @@
+<?php
+/**
+ * Portable PHP password hashing framework.
+ * @package phpass
+ * @since 2.5
+ * @version 0.2 / genuine.
+ * @link http://www.openwall.com/phpass/
+ */
+
+#
+# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
+# the public domain.
+#
+# There's absolutely no warranty.
+#
+# Please be sure to update the Version line if you edit this file in any way.
+# It is suggested that you leave the main version number intact, but indicate
+# your project name (after the slash) and add your own revision information.
+#
+# Please do not change the "private" password hashing method implemented in
+# here, thereby making your hashes incompatible.  However, if you must, please
+# change the hash type identifier (the "$P$") to something different.
+#
+# Obviously, since this code is in the public domain, the above are not
+# requirements (there can be none), but merely suggestions.
+#
+
+/**
+ * Portable PHP password hashing framework.
+ *
+ * @package phpass
+ * @version 0.2 / genuine.
+ * @link http://www.openwall.com/phpass/
+ * @since 2.5
+ */
+class PasswordHash {
+	var $itoa64;
+	var $iteration_count_log2;
+	var $portable_hashes;
+	var $random_state;
+
+	function PasswordHash($iteration_count_log2, $portable_hashes)
+	{
+		$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
+
+		if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
+			$iteration_count_log2 = 8;
+		$this->iteration_count_log2 = $iteration_count_log2;
+
+		$this->portable_hashes = $portable_hashes;
+
+		$this->random_state = microtime() . uniqid(rand(), TRUE); // removed getmypid() for compability reasons
+	}
+
+	function get_random_bytes($count)
+	{
+		$output = '';
+		if ( @is_readable('/dev/urandom') &&
+		    ($fh = @fopen('/dev/urandom', 'rb'))) {
+			$output = fread($fh, $count);
+			fclose($fh);
+		}
+
+		if (strlen($output) < $count) {
+			$output = '';
+			for ($i = 0; $i < $count; $i += 16) {
+				$this->random_state =
+				    md5(microtime() . $this->random_state);
+				$output .=
+				    pack('H*', md5($this->random_state));
+			}
+			$output = substr($output, 0, $count);
+		}
+
+		return $output;
+	}
+
+	function encode64($input, $count)
+	{
+		$output = '';
+		$i = 0;
+		do {
+			$value = ord($input[$i++]);
+			$output .= $this->itoa64[$value & 0x3f];
+			if ($i < $count)
+				$value |= ord($input[$i]) << 8;
+			$output .= $this->itoa64[($value >> 6) & 0x3f];
+			if ($i++ >= $count)
+				break;
+			if ($i < $count)
+				$value |= ord($input[$i]) << 16;
+			$output .= $this->itoa64[($value >> 12) & 0x3f];
+			if ($i++ >= $count)
+				break;
+			$output .= $this->itoa64[($value >> 18) & 0x3f];
+		} while ($i < $count);
+
+		return $output;
+	}
+
+	function gensalt_private($input)
+	{
+		$output = '$P$';
+		$output .= $this->itoa64[min($this->iteration_count_log2 +
+			((PHP_VERSION >= '5') ? 5 : 3), 30)];
+		$output .= $this->encode64($input, 6);
+
+		return $output;
+	}
+
+	function crypt_private($password, $setting)
+	{
+		$output = '*0';
+		if (substr($setting, 0, 2) == $output)
+			$output = '*1';
+
+		if (substr($setting, 0, 3) != '$P$')
+			return $output;
+
+		$count_log2 = strpos($this->itoa64, $setting[3]);
+		if ($count_log2 < 7 || $count_log2 > 30)
+			return $output;
+
+		$count = 1 << $count_log2;
+
+		$salt = substr($setting, 4, 8);
+		if (strlen($salt) != 8)
+			return $output;
+
+		# We're kind of forced to use MD5 here since it's the only
+		# cryptographic primitive available in all versions of PHP
+		# currently in use.  To implement our own low-level crypto
+		# in PHP would result in much worse performance and
+		# consequently in lower iteration counts and hashes that are
+		# quicker to crack (by non-PHP code).
+		if (PHP_VERSION >= '5') {
+			$hash = md5($salt . $password, TRUE);
+			do {
+				$hash = md5($hash . $password, TRUE);
+			} while (--$count);
+		} else {
+			$hash = pack('H*', md5($salt . $password));
+			do {
+				$hash = pack('H*', md5($hash . $password));
+			} while (--$count);
+		}
+
+		$output = substr($setting, 0, 12);
+		$output .= $this->encode64($hash, 16);
+
+		return $output;
+	}
+
+	function gensalt_extended($input)
+	{
+		$count_log2 = min($this->iteration_count_log2 + 8, 24);
+		# This should be odd to not reveal weak DES keys, and the
+		# maximum valid value is (2**24 - 1) which is odd anyway.
+		$count = (1 << $count_log2) - 1;
+
+		$output = '_';
+		$output .= $this->itoa64[$count & 0x3f];
+		$output .= $this->itoa64[($count >> 6) & 0x3f];
+		$output .= $this->itoa64[($count >> 12) & 0x3f];
+		$output .= $this->itoa64[($count >> 18) & 0x3f];
+
+		$output .= $this->encode64($input, 3);
+
+		return $output;
+	}
+
+	function gensalt_blowfish($input)
+	{
+		# This one needs to use a different order of characters and a
+		# different encoding scheme from the one in encode64() above.
+		# We care because the last character in our encoded string will
+		# only represent 2 bits.  While two known implementations of
+		# bcrypt will happily accept and correct a salt string which
+		# has the 4 unused bits set to non-zero, we do not want to take
+		# chances and we also do not want to waste an additional byte
+		# of entropy.
+		$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+
+		$output = '$2a$';
+		$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
+		$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
+		$output .= '$';
+
+		$i = 0;
+		do {
+			$c1 = ord($input[$i++]);
+			$output .= $itoa64[$c1 >> 2];
+			$c1 = ($c1 & 0x03) << 4;
+			if ($i >= 16) {
+				$output .= $itoa64[$c1];
+				break;
+			}
+
+			$c2 = ord($input[$i++]);
+			$c1 |= $c2 >> 4;
+			$output .= $itoa64[$c1];
+			$c1 = ($c2 & 0x0f) << 2;
+
+			$c2 = ord($input[$i++]);
+			$c1 |= $c2 >> 6;
+			$output .= $itoa64[$c1];
+			$output .= $itoa64[$c2 & 0x3f];
+		} while (1);
+
+		return $output;
+	}
+
+	function HashPassword($password)
+	{
+		$random = '';
+
+		if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
+			$random = $this->get_random_bytes(16);
+			$hash =
+			    crypt($password, $this->gensalt_blowfish($random));
+			if (strlen($hash) == 60)
+				return $hash;
+		}
+
+		if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
+			if (strlen($random) < 3)
+				$random = $this->get_random_bytes(3);
+			$hash =
+			    crypt($password, $this->gensalt_extended($random));
+			if (strlen($hash) == 20)
+				return $hash;
+		}
+
+		if (strlen($random) < 6)
+			$random = $this->get_random_bytes(6);
+		$hash =
+		    $this->crypt_private($password,
+		    $this->gensalt_private($random));
+		if (strlen($hash) == 34)
+			return $hash;
+
+		# Returning '*' on error is safe here, but would _not_ be safe
+		# in a crypt(3)-like function used _both_ for generating new
+		# hashes and for validating passwords against existing hashes.
+		return '*';
+	}
+
+	function CheckPassword($password, $stored_hash)
+	{
+		$hash = $this->crypt_private($password, $stored_hash);
+		if ($hash[0] == '*')
+			$hash = crypt($password, $stored_hash);
+
+		return $hash == $stored_hash;
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/class-phpmailer.php
===================================================================
--- /tags/3.1/wp-includes/class-phpmailer.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-phpmailer.php	(revision 17487)
@@ -0,0 +1,1921 @@
+<?php
+/*~ class.phpmailer.php
+.---------------------------------------------------------------------------.
+|  Software: PHPMailer - PHP email class                                    |
+|   Version: 2.0.4                                                          |
+|   Contact: via sourceforge.net support pages (also www.codeworxtech.com)  |
+|      Info: http://phpmailer.sourceforge.net                               |
+|   Support: http://sourceforge.net/projects/phpmailer/                     |
+| ------------------------------------------------------------------------- |
+|    Author: Andy Prevost (project admininistrator)                         |
+|    Author: Brent R. Matzelle (original founder)                           |
+| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved.               |
+| Copyright (c) 2001-2003, Brent R. Matzelle                                |
+| ------------------------------------------------------------------------- |
+|   License: Distributed under the Lesser General Public License (LGPL)     |
+|            http://www.gnu.org/copyleft/lesser.html                        |
+| This program is distributed in the hope that it will be useful - WITHOUT  |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     |
+| FITNESS FOR A PARTICULAR PURPOSE.                                         |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com):                |
+| - Web Hosting on highly optimized fast and secure servers                 |
+| - Technology Consulting                                                   |
+| - Oursourcing (highly qualified programmers and graphic designers)        |
+'---------------------------------------------------------------------------'
+ */
+/**
+ * PHPMailer - PHP email transport class
+ * @package PHPMailer
+ * @author Andy Prevost
+ * @copyright 2004 - 2009 Andy Prevost
+ */
+
+class PHPMailer {
+
+  /////////////////////////////////////////////////
+  // PROPERTIES, PUBLIC
+  /////////////////////////////////////////////////
+
+  /**
+   * Email priority (1 = High, 3 = Normal, 5 = low).
+   * @var int
+   */
+  var $Priority          = 3;
+
+  /**
+   * Sets the CharSet of the message.
+   * @var string
+   */
+  var $CharSet           = 'iso-8859-1';
+
+  /**
+   * Sets the Content-type of the message.
+   * @var string
+   */
+  var $ContentType        = 'text/plain';
+
+  /**
+   * Sets the Encoding of the message. Options for this are "8bit",
+   * "7bit", "binary", "base64", and "quoted-printable".
+   * @var string
+   */
+  var $Encoding          = '8bit';
+
+  /**
+   * Holds the most recent mailer error message.
+   * @var string
+   */
+  var $ErrorInfo         = '';
+
+  /**
+   * Sets the From email address for the message.
+   * @var string
+   */
+  var $From              = 'root@localhost';
+
+  /**
+   * Sets the From name of the message.
+   * @var string
+   */
+  var $FromName          = 'Root User';
+
+  /**
+   * Sets the Sender email (Return-Path) of the message.  If not empty,
+   * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
+   * @var string
+   */
+  var $Sender            = '';
+
+  /**
+   * Sets the Subject of the message.
+   * @var string
+   */
+  var $Subject           = '';
+
+  /**
+   * Sets the Body of the message.  This can be either an HTML or text body.
+   * If HTML then run IsHTML(true).
+   * @var string
+   */
+  var $Body              = '';
+
+  /**
+   * Sets the text-only body of the message.  This automatically sets the
+   * email to multipart/alternative.  This body can be read by mail
+   * clients that do not have HTML email capability such as mutt. Clients
+   * that can read HTML will view the normal Body.
+   * @var string
+   */
+  var $AltBody           = '';
+
+  /**
+   * Sets word wrapping on the body of the message to a given number of
+   * characters.
+   * @var int
+   */
+  var $WordWrap          = 0;
+
+  /**
+   * Method to send mail: ("mail", "sendmail", or "smtp").
+   * @var string
+   */
+  var $Mailer            = 'mail';
+
+  /**
+   * Sets the path of the sendmail program.
+   * @var string
+   */
+  var $Sendmail          = '/usr/sbin/sendmail';
+
+  /**
+   * Path to PHPMailer plugins.  This is now only useful if the SMTP class
+   * is in a different directory than the PHP include path.
+   * @var string
+   */
+  var $PluginDir         = '';
+
+  /**
+   * Holds PHPMailer version.
+   * @var string
+   */
+  var $Version           = "2.0.4";
+
+  /**
+   * Sets the email address that a reading confirmation will be sent.
+   * @var string
+   */
+  var $ConfirmReadingTo  = '';
+
+  /**
+   * Sets the hostname to use in Message-Id and Received headers
+   * and as default HELO string. If empty, the value returned
+   * by SERVER_NAME is used or 'localhost.localdomain'.
+   * @var string
+   */
+  var $Hostname          = '';
+
+  /**
+   * Sets the message ID to be used in the Message-Id header.
+   * If empty, a unique id will be generated.
+   * @var string
+   */
+  var $MessageID         = '';
+
+  /////////////////////////////////////////////////
+  // PROPERTIES FOR SMTP
+  /////////////////////////////////////////////////
+
+  /**
+   * Sets the SMTP hosts.  All hosts must be separated by a
+   * semicolon.  You can also specify a different port
+   * for each host by using this format: [hostname:port]
+   * (e.g. "smtp1.example.com:25;smtp2.example.com").
+   * Hosts will be tried in order.
+   * @var string
+   */
+  var $Host        = 'localhost';
+
+  /**
+   * Sets the default SMTP server port.
+   * @var int
+   */
+  var $Port        = 25;
+
+  /**
+   * Sets the SMTP HELO of the message (Default is $Hostname).
+   * @var string
+   */
+  var $Helo        = '';
+
+  /**
+   * Sets connection prefix.
+   * Options are "", "ssl" or "tls"
+   * @var string
+   */
+  var $SMTPSecure = "";
+
+  /**
+   * Sets SMTP authentication. Utilizes the Username and Password variables.
+   * @var bool
+   */
+  var $SMTPAuth     = false;
+
+  /**
+   * Sets SMTP username.
+   * @var string
+   */
+  var $Username     = '';
+
+  /**
+   * Sets SMTP password.
+   * @var string
+   */
+  var $Password     = '';
+
+  /**
+   * Sets the SMTP server timeout in seconds. This function will not
+   * work with the win32 version.
+   * @var int
+   */
+  var $Timeout      = 10;
+
+  /**
+   * Sets SMTP class debugging on or off.
+   * @var bool
+   */
+  var $SMTPDebug    = false;
+
+  /**
+   * Prevents the SMTP connection from being closed after each mail
+   * sending.  If this is set to true then to close the connection
+   * requires an explicit call to SmtpClose().
+   * @var bool
+   */
+  var $SMTPKeepAlive = false;
+
+  /**
+   * Provides the ability to have the TO field process individual
+   * emails, instead of sending to entire TO addresses
+   * @var bool
+   */
+  var $SingleTo = false;
+
+  /////////////////////////////////////////////////
+  // PROPERTIES, PRIVATE
+  /////////////////////////////////////////////////
+
+  var $smtp            = NULL;
+  var $to              = array();
+  var $cc              = array();
+  var $bcc             = array();
+  var $ReplyTo         = array();
+  var $attachment      = array();
+  var $CustomHeader    = array();
+  var $message_type    = '';
+  var $boundary        = array();
+  var $language        = array();
+  var $error_count     = 0;
+  var $LE              = "\n";
+  var $sign_cert_file  = "";
+  var $sign_key_file   = "";
+  var $sign_key_pass   = "";
+
+  /////////////////////////////////////////////////
+  // METHODS, VARIABLES
+  /////////////////////////////////////////////////
+
+  /**
+   * Sets message type to HTML.
+   * @param bool $bool
+   * @return void
+   */
+  function IsHTML($bool) {
+    if($bool == true) {
+      $this->ContentType = 'text/html';
+    } else {
+      $this->ContentType = 'text/plain';
+    }
+  }
+
+  /**
+   * Sets Mailer to send message using SMTP.
+   * @return void
+   */
+  function IsSMTP() {
+    $this->Mailer = 'smtp';
+  }
+
+  /**
+   * Sets Mailer to send message using PHP mail() function.
+   * @return void
+   */
+  function IsMail() {
+    $this->Mailer = 'mail';
+  }
+
+  /**
+   * Sets Mailer to send message using the $Sendmail program.
+   * @return void
+   */
+  function IsSendmail() {
+    $this->Mailer = 'sendmail';
+  }
+
+  /**
+   * Sets Mailer to send message using the qmail MTA.
+   * @return void
+   */
+  function IsQmail() {
+    $this->Sendmail = '/var/qmail/bin/sendmail';
+    $this->Mailer = 'sendmail';
+  }
+
+  /////////////////////////////////////////////////
+  // METHODS, RECIPIENTS
+  /////////////////////////////////////////////////
+
+  /**
+   * Adds a "To" address.
+   * @param string $address
+   * @param string $name
+   * @return void
+   */
+  function AddAddress($address, $name = '') {
+    $cur = count($this->to);
+    $this->to[$cur][0] = trim($address);
+    $this->to[$cur][1] = $name;
+  }
+
+  /**
+   * Adds a "Cc" address. Note: this function works
+   * with the SMTP mailer on win32, not with the "mail"
+   * mailer.
+   * @param string $address
+   * @param string $name
+   * @return void
+   */
+  function AddCC($address, $name = '') {
+    $cur = count($this->cc);
+    $this->cc[$cur][0] = trim($address);
+    $this->cc[$cur][1] = $name;
+  }
+
+  /**
+   * Adds a "Bcc" address. Note: this function works
+   * with the SMTP mailer on win32, not with the "mail"
+   * mailer.
+   * @param string $address
+   * @param string $name
+   * @return void
+   */
+  function AddBCC($address, $name = '') {
+    $cur = count($this->bcc);
+    $this->bcc[$cur][0] = trim($address);
+    $this->bcc[$cur][1] = $name;
+  }
+
+  /**
+   * Adds a "Reply-To" address.
+   * @param string $address
+   * @param string $name
+   * @return void
+   */
+  function AddReplyTo($address, $name = '') {
+    $cur = count($this->ReplyTo);
+    $this->ReplyTo[$cur][0] = trim($address);
+    $this->ReplyTo[$cur][1] = $name;
+  }
+
+  /////////////////////////////////////////////////
+  // METHODS, MAIL SENDING
+  /////////////////////////////////////////////////
+
+  /**
+   * Creates message and assigns Mailer. If the message is
+   * not sent successfully then it returns false.  Use the ErrorInfo
+   * variable to view description of the error.
+   * @return bool
+   */
+  function Send() {
+    $header = '';
+    $body = '';
+    $result = true;
+
+    if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
+      $this->SetError($this->Lang('provide_address'));
+      return false;
+    }
+
+    /* Set whether the message is multipart/alternative */
+    if(!empty($this->AltBody)) {
+      $this->ContentType = 'multipart/alternative';
+    }
+
+    $this->error_count = 0; // reset errors
+    $this->SetMessageType();
+    $header .= $this->CreateHeader();
+    $body = $this->CreateBody();
+
+    if($body == '') {
+      return false;
+    }
+
+    /* Choose the mailer */
+    switch($this->Mailer) {
+      case 'sendmail':
+        $result = $this->SendmailSend($header, $body);
+        break;
+      case 'smtp':
+        $result = $this->SmtpSend($header, $body);
+        break;
+      case 'mail':
+        $result = $this->MailSend($header, $body);
+        break;
+      default:
+        $result = $this->MailSend($header, $body);
+        break;
+        //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
+        //$result = false;
+        //break;
+    }
+
+    return $result;
+  }
+
+  /**
+   * Sends mail using the $Sendmail program.
+   * @access private
+   * @return bool
+   */
+  function SendmailSend($header, $body) {
+    if ($this->Sender != '') {
+      $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
+    } else {
+      $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
+    }
+
+    if(!@$mail = popen($sendmail, 'w')) {
+      $this->SetError($this->Lang('execute') . $this->Sendmail);
+      return false;
+    }
+
+    fputs($mail, $header);
+    fputs($mail, $body);
+
+    $result = pclose($mail);
+    if (version_compare(phpversion(), '4.2.3') == -1) {
+      $result = $result >> 8 & 0xFF;
+    }
+    if($result != 0) {
+      $this->SetError($this->Lang('execute') . $this->Sendmail);
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Sends mail using the PHP mail() function.
+   * @access private
+   * @return bool
+   */
+  function MailSend($header, $body) {
+
+    $to = '';
+    for($i = 0; $i < count($this->to); $i++) {
+      if($i != 0) { $to .= ', '; }
+      $to .= $this->AddrFormat($this->to[$i]);
+    }
+
+    $toArr = split(',', $to);
+
+    $params = sprintf("-oi -f %s", $this->Sender);
+    if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
+      $old_from = ini_get('sendmail_from');
+      ini_set('sendmail_from', $this->Sender);
+      if ($this->SingleTo === true && count($toArr) > 1) {
+        foreach ($toArr as $key => $val) {
+          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+        }
+      } else {
+        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+      }
+    } else {
+      if ($this->SingleTo === true && count($toArr) > 1) {
+        foreach ($toArr as $key => $val) {
+          $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
+        }
+      } else {
+        $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
+      }
+    }
+
+    if (isset($old_from)) {
+      ini_set('sendmail_from', $old_from);
+    }
+
+    if(!$rt) {
+      $this->SetError($this->Lang('instantiate'));
+      return false;
+    }
+
+    return true;
+  }
+
+  /**
+   * Sends mail via SMTP using PhpSMTP (Author:
+   * Chris Ryan).  Returns bool.  Returns false if there is a
+   * bad MAIL FROM, RCPT, or DATA input.
+   * @access private
+   * @return bool
+   */
+  function SmtpSend($header, $body) {
+    include_once($this->PluginDir . 'class-smtp.php');
+    $error = '';
+    $bad_rcpt = array();
+
+    if(!$this->SmtpConnect()) {
+      return false;
+    }
+
+    $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
+    if(!$this->smtp->Mail($smtp_from)) {
+      $error = $this->Lang('from_failed') . $smtp_from;
+      $this->SetError($error);
+      $this->smtp->Reset();
+      return false;
+    }
+
+    /* Attempt to send attach all recipients */
+    for($i = 0; $i < count($this->to); $i++) {
+      if(!$this->smtp->Recipient($this->to[$i][0])) {
+        $bad_rcpt[] = $this->to[$i][0];
+      }
+    }
+    for($i = 0; $i < count($this->cc); $i++) {
+      if(!$this->smtp->Recipient($this->cc[$i][0])) {
+        $bad_rcpt[] = $this->cc[$i][0];
+      }
+    }
+    for($i = 0; $i < count($this->bcc); $i++) {
+      if(!$this->smtp->Recipient($this->bcc[$i][0])) {
+        $bad_rcpt[] = $this->bcc[$i][0];
+      }
+    }
+
+    if(count($bad_rcpt) > 0) { // Create error message
+      for($i = 0; $i < count($bad_rcpt); $i++) {
+        if($i != 0) {
+          $error .= ', ';
+        }
+        $error .= $bad_rcpt[$i];
+      }
+      $error = $this->Lang('recipients_failed') . $error;
+      $this->SetError($error);
+      $this->smtp->Reset();
+      return false;
+    }
+
+    if(!$this->smtp->Data($header . $body)) {
+      $this->SetError($this->Lang('data_not_accepted'));
+      $this->smtp->Reset();
+      return false;
+    }
+    if($this->SMTPKeepAlive == true) {
+      $this->smtp->Reset();
+    } else {
+      $this->SmtpClose();
+    }
+
+    return true;
+  }
+
+  /**
+   * Initiates a connection to an SMTP server.  Returns false if the
+   * operation failed.
+   * @access private
+   * @return bool
+   */
+  function SmtpConnect() {
+    if($this->smtp == NULL) {
+      $this->smtp = new SMTP();
+    }
+
+    $this->smtp->do_debug = $this->SMTPDebug;
+    $hosts = explode(';', $this->Host);
+    $index = 0;
+    $connection = ($this->smtp->Connected());
+
+    /* Retry while there is no connection */
+    while($index < count($hosts) && $connection == false) {
+      $hostinfo = array();
+      if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
+        $host = $hostinfo[1];
+        $port = $hostinfo[2];
+      } else {
+        $host = $hosts[$index];
+        $port = $this->Port;
+      }
+
+      if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {
+        if ($this->Helo != '') {
+          $this->smtp->Hello($this->Helo);
+        } else {
+          $this->smtp->Hello($this->ServerHostname());
+        }
+
+        $connection = true;
+        if($this->SMTPAuth) {
+          if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
+            $this->SetError($this->Lang('authenticate'));
+            $this->smtp->Reset();
+            $connection = false;
+          }
+        }
+      }
+      $index++;
+    }
+    if(!$connection) {
+      $this->SetError($this->Lang('connect_host'));
+    }
+
+    return $connection;
+  }
+
+  /**
+   * Closes the active SMTP session if one exists.
+   * @return void
+   */
+  function SmtpClose() {
+    if($this->smtp != NULL) {
+      if($this->smtp->Connected()) {
+        $this->smtp->Quit();
+        $this->smtp->Close();
+      }
+    }
+  }
+
+  /**
+   * Sets the language for all class error messages.  Returns false
+   * if it cannot load the language file.  The default language type
+   * is English.
+   * @param string $lang_type Type of language (e.g. Portuguese: "br")
+   * @param string $lang_path Path to the language file directory
+   * @access public
+   * @return bool
+   */
+  function SetLanguage($lang_type, $lang_path = 'language/') {
+    if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
+      include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
+    } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
+      include($lang_path.'phpmailer.lang-en.php');
+    } else {
+      $PHPMAILER_LANG = array();
+      $PHPMAILER_LANG["provide_address"]      = 'You must provide at least one ' .
+      $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
+      $PHPMAILER_LANG["execute"]              = 'Could not execute: ';
+      $PHPMAILER_LANG["instantiate"]          = 'Could not instantiate mail function.';
+      $PHPMAILER_LANG["authenticate"]         = 'SMTP Error: Could not authenticate.';
+      $PHPMAILER_LANG["from_failed"]          = 'The following From address failed: ';
+      $PHPMAILER_LANG["recipients_failed"]    = 'SMTP Error: The following ' .
+      $PHPMAILER_LANG["data_not_accepted"]    = 'SMTP Error: Data not accepted.';
+      $PHPMAILER_LANG["connect_host"]         = 'SMTP Error: Could not connect to SMTP host.';
+      $PHPMAILER_LANG["file_access"]          = 'Could not access file: ';
+      $PHPMAILER_LANG["file_open"]            = 'File Error: Could not open file: ';
+      $PHPMAILER_LANG["encoding"]             = 'Unknown encoding: ';
+      $PHPMAILER_LANG["signing"]              = 'Signing Error: ';
+    }
+    $this->language = $PHPMAILER_LANG;
+
+    return true;
+  }
+
+  /////////////////////////////////////////////////
+  // METHODS, MESSAGE CREATION
+  /////////////////////////////////////////////////
+
+  /**
+   * Creates recipient headers.
+   * @access private
+   * @return string
+   */
+  function AddrAppend($type, $addr) {
+    $addr_str = $type . ': ';
+    $addr_str .= $this->AddrFormat($addr[0]);
+    if(count($addr) > 1) {
+      for($i = 1; $i < count($addr); $i++) {
+        $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
+      }
+    }
+    $addr_str .= $this->LE;
+
+    return $addr_str;
+  }
+
+  /**
+   * Formats an address correctly.
+   * @access private
+   * @return string
+   */
+  function AddrFormat($addr) {
+    if(empty($addr[1])) {
+      $formatted = $this->SecureHeader($addr[0]);
+    } else {
+      $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
+    }
+
+    return $formatted;
+  }
+
+  /**
+   * Wraps message for use with mailers that do not
+   * automatically perform wrapping and for quoted-printable.
+   * Original written by philippe.
+   * @access private
+   * @return string
+   */
+  function WrapText($message, $length, $qp_mode = false) {
+    $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
+    // If utf-8 encoding is used, we will need to make sure we don't
+    // split multibyte characters when we wrap
+    $is_utf8 = (strtolower($this->CharSet) == "utf-8");
+
+    $message = $this->FixEOL($message);
+    if (substr($message, -1) == $this->LE) {
+      $message = substr($message, 0, -1);
+    }
+
+    $line = explode($this->LE, $message);
+    $message = '';
+    for ($i=0 ;$i < count($line); $i++) {
+      $line_part = explode(' ', $line[$i]);
+      $buf = '';
+      for ($e = 0; $e<count($line_part); $e++) {
+        $word = $line_part[$e];
+        if ($qp_mode and (strlen($word) > $length)) {
+          $space_left = $length - strlen($buf) - 1;
+          if ($e != 0) {
+            if ($space_left > 20) {
+              $len = $space_left;
+              if ($is_utf8) {
+                $len = $this->UTF8CharBoundary($word, $len);
+              } elseif (substr($word, $len - 1, 1) == "=") {
+                $len--;
+              } elseif (substr($word, $len - 2, 1) == "=") {
+                $len -= 2;
+              }
+              $part = substr($word, 0, $len);
+              $word = substr($word, $len);
+              $buf .= ' ' . $part;
+              $message .= $buf . sprintf("=%s", $this->LE);
+            } else {
+              $message .= $buf . $soft_break;
+            }
+            $buf = '';
+          }
+          while (strlen($word) > 0) {
+            $len = $length;
+            if ($is_utf8) {
+              $len = $this->UTF8CharBoundary($word, $len);
+            } elseif (substr($word, $len - 1, 1) == "=") {
+              $len--;
+            } elseif (substr($word, $len - 2, 1) == "=") {
+              $len -= 2;
+            }
+            $part = substr($word, 0, $len);
+            $word = substr($word, $len);
+
+            if (strlen($word) > 0) {
+              $message .= $part . sprintf("=%s", $this->LE);
+            } else {
+              $buf = $part;
+            }
+          }
+        } else {
+          $buf_o = $buf;
+          $buf .= ($e == 0) ? $word : (' ' . $word);
+
+          if (strlen($buf) > $length and $buf_o != '') {
+            $message .= $buf_o . $soft_break;
+            $buf = $word;
+          }
+        }
+      }
+      $message .= $buf . $this->LE;
+    }
+
+    return $message;
+  }
+
+  /**
+   * Finds last character boundary prior to maxLength in a utf-8
+   * quoted (printable) encoded string.
+   * Original written by Colin Brown.
+   * @access private
+   * @param string $encodedText utf-8 QP text
+   * @param int    $maxLength   find last character boundary prior to this length
+   * @return int
+   */
+  function UTF8CharBoundary($encodedText, $maxLength) {
+    $foundSplitPos = false;
+    $lookBack = 3;
+    while (!$foundSplitPos) {
+      $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
+      $encodedCharPos = strpos($lastChunk, "=");
+      if ($encodedCharPos !== false) {
+        // Found start of encoded character byte within $lookBack block.
+        // Check the encoded byte value (the 2 chars after the '=')
+        $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
+        $dec = hexdec($hex);
+        if ($dec < 128) { // Single byte character.
+          // If the encoded char was found at pos 0, it will fit
+          // otherwise reduce maxLength to start of the encoded char
+          $maxLength = ($encodedCharPos == 0) ? $maxLength :
+          $maxLength - ($lookBack - $encodedCharPos);
+          $foundSplitPos = true;
+        } elseif ($dec >= 192) { // First byte of a multi byte character
+          // Reduce maxLength to split at start of character
+          $maxLength = $maxLength - ($lookBack - $encodedCharPos);
+          $foundSplitPos = true;
+        } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
+          $lookBack += 3;
+        }
+      } else {
+        // No encoded character found
+        $foundSplitPos = true;
+      }
+    }
+    return $maxLength;
+  }
+
+  /**
+   * Set the body wrapping.
+   * @access private
+   * @return void
+   */
+  function SetWordWrap() {
+    if($this->WordWrap < 1) {
+      return;
+    }
+
+    switch($this->message_type) {
+      case 'alt':
+        /* fall through */
+      case 'alt_attachments':
+        $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
+        break;
+      default:
+        $this->Body = $this->WrapText($this->Body, $this->WordWrap);
+        break;
+    }
+  }
+
+  /**
+   * Assembles message header.
+   * @access private
+   * @return string
+   */
+  function CreateHeader() {
+    $result = '';
+
+    /* Set the boundaries */
+    $uniq_id = md5(uniqid(time()));
+    $this->boundary[1] = 'b1_' . $uniq_id;
+    $this->boundary[2] = 'b2_' . $uniq_id;
+
+    $result .= $this->HeaderLine('Date', $this->RFCDate());
+    if($this->Sender == '') {
+      $result .= $this->HeaderLine('Return-Path', trim($this->From));
+    } else {
+      $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
+    }
+
+    /* To be created automatically by mail() */
+    if($this->Mailer != 'mail') {
+      if(count($this->to) > 0) {
+        $result .= $this->AddrAppend('To', $this->to);
+      } elseif (count($this->cc) == 0) {
+        $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
+      }
+    }
+
+    $from = array();
+    $from[0][0] = trim($this->From);
+    $from[0][1] = $this->FromName;
+    $result .= $this->AddrAppend('From', $from);
+
+    /* sendmail and mail() extract Cc from the header before sending */
+    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
+      $result .= $this->AddrAppend('Cc', $this->cc);
+    }
+
+    /* sendmail and mail() extract Bcc from the header before sending */
+    if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
+      $result .= $this->AddrAppend('Bcc', $this->bcc);
+    }
+
+    if(count($this->ReplyTo) > 0) {
+      $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
+    }
+
+    /* mail() sets the subject itself */
+    if($this->Mailer != 'mail') {
+      $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
+    }
+
+    if($this->MessageID != '') {
+      $result .= $this->HeaderLine('Message-ID',$this->MessageID);
+    } else {
+      $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
+    }
+    $result .= $this->HeaderLine('X-Priority', $this->Priority);
+    $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
+
+    if($this->ConfirmReadingTo != '') {
+      $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
+    }
+
+    // Add custom headers
+    for($index = 0; $index < count($this->CustomHeader); $index++) {
+      $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
+    }
+    if (!$this->sign_key_file) {
+      $result .= $this->HeaderLine('MIME-Version', '1.0');
+      $result .= $this->GetMailMIME();
+    }
+
+    return $result;
+  }
+
+  /**
+   * Returns the message MIME.
+   * @access private
+   * @return string
+   */
+  function GetMailMIME() {
+    $result = '';
+    switch($this->message_type) {
+      case 'plain':
+        $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
+        $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
+        break;
+      case 'attachments':
+        /* fall through */
+      case 'alt_attachments':
+        if($this->InlineImageExists()){
+          $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
+        } else {
+          $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
+          $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+        }
+        break;
+      case 'alt':
+        $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
+        $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
+        break;
+    }
+
+    if($this->Mailer != 'mail') {
+      $result .= $this->LE.$this->LE;
+    }
+
+    return $result;
+  }
+
+  /**
+   * Assembles the message body.  Returns an empty string on failure.
+   * @access private
+   * @return string
+   */
+  function CreateBody() {
+    $result = '';
+    if ($this->sign_key_file) {
+      $result .= $this->GetMailMIME();
+    }
+
+    $this->SetWordWrap();
+
+    switch($this->message_type) {
+      case 'alt':
+        $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
+        $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->EndBoundary($this->boundary[1]);
+        break;
+      case 'plain':
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        break;
+      case 'attachments':
+        $result .= $this->GetBoundary($this->boundary[1], '', '', '');
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        $result .= $this->LE;
+        $result .= $this->AttachAll();
+        break;
+      case 'alt_attachments':
+        $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
+        $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
+        $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
+        $result .= $this->EncodeString($this->AltBody, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
+        $result .= $this->EncodeString($this->Body, $this->Encoding);
+        $result .= $this->LE.$this->LE;
+        $result .= $this->EndBoundary($this->boundary[2]);
+        $result .= $this->AttachAll();
+        break;
+    }
+
+    if($this->IsError()) {
+      $result = '';
+    } else if ($this->sign_key_file) {
+      $file = tempnam("", "mail");
+      $fp = fopen($file, "w");
+      fwrite($fp, $result);
+      fclose($fp);
+      $signed = tempnam("", "signed");
+
+      if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
+        $fp = fopen($signed, "r");
+        $result = fread($fp, filesize($this->sign_key_file));
+        $result = '';
+        while(!feof($fp)){
+          $result = $result . fread($fp, 1024);
+        }
+        fclose($fp);
+      } else {
+        $this->SetError($this->Lang("signing").openssl_error_string());
+        $result = '';
+      }
+
+      unlink($file);
+      unlink($signed);
+    }
+
+    return $result;
+  }
+
+  /**
+   * Returns the start of a message boundary.
+   * @access private
+   */
+  function GetBoundary($boundary, $charSet, $contentType, $encoding) {
+    $result = '';
+    if($charSet == '') {
+      $charSet = $this->CharSet;
+    }
+    if($contentType == '') {
+      $contentType = $this->ContentType;
+    }
+    if($encoding == '') {
+      $encoding = $this->Encoding;
+    }
+    $result .= $this->TextLine('--' . $boundary);
+    $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
+    $result .= $this->LE;
+    $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
+    $result .= $this->LE;
+
+    return $result;
+  }
+
+  /**
+   * Returns the end of a message boundary.
+   * @access private
+   */
+  function EndBoundary($boundary) {
+    return $this->LE . '--' . $boundary . '--' . $this->LE;
+  }
+
+  /**
+   * Sets the message type.
+   * @access private
+   * @return void
+   */
+  function SetMessageType() {
+    if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
+      $this->message_type = 'plain';
+    } else {
+      if(count($this->attachment) > 0) {
+        $this->message_type = 'attachments';
+      }
+      if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
+        $this->message_type = 'alt';
+      }
+      if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
+        $this->message_type = 'alt_attachments';
+      }
+    }
+  }
+
+  /* Returns a formatted header line.
+   * @access private
+   * @return string
+   */
+  function HeaderLine($name, $value) {
+    return $name . ': ' . $value . $this->LE;
+  }
+
+  /**
+   * Returns a formatted mail line.
+   * @access private
+   * @return string
+   */
+  function TextLine($value) {
+    return $value . $this->LE;
+  }
+
+  /////////////////////////////////////////////////
+  // CLASS METHODS, ATTACHMENTS
+  /////////////////////////////////////////////////
+
+  /**
+   * Adds an attachment from a path on the filesystem.
+   * Returns false if the file could not be found
+   * or accessed.
+   * @param string $path Path to the attachment.
+   * @param string $name Overrides the attachment name.
+   * @param string $encoding File encoding (see $Encoding).
+   * @param string $type File extension (MIME) type.
+   * @return bool
+   */
+  function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+    if(!@is_file($path)) {
+      $this->SetError($this->Lang('file_access') . $path);
+      return false;
+    }
+
+    $filename = basename($path);
+    if($name == '') {
+      $name = $filename;
+    }
+
+    $cur = count($this->attachment);
+    $this->attachment[$cur][0] = $path;
+    $this->attachment[$cur][1] = $filename;
+    $this->attachment[$cur][2] = $name;
+    $this->attachment[$cur][3] = $encoding;
+    $this->attachment[$cur][4] = $type;
+    $this->attachment[$cur][5] = false; // isStringAttachment
+    $this->attachment[$cur][6] = 'attachment';
+    $this->attachment[$cur][7] = 0;
+
+    return true;
+  }
+
+  /**
+   * Attaches all fs, string, and binary attachments to the message.
+   * Returns an empty string on failure.
+   * @access private
+   * @return string
+   */
+  function AttachAll() {
+    /* Return text of body */
+    $mime = array();
+
+    /* Add all attachments */
+    for($i = 0; $i < count($this->attachment); $i++) {
+      /* Check for string attachment */
+      $bString = $this->attachment[$i][5];
+      if ($bString) {
+        $string = $this->attachment[$i][0];
+      } else {
+        $path = $this->attachment[$i][0];
+      }
+
+      $filename    = $this->attachment[$i][1];
+      $name        = $this->attachment[$i][2];
+      $encoding    = $this->attachment[$i][3];
+      $type        = $this->attachment[$i][4];
+      $disposition = $this->attachment[$i][6];
+      $cid         = $this->attachment[$i][7];
+
+      $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
+      $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
+      $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
+
+      if($disposition == 'inline') {
+        $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
+      }
+
+      $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
+
+      /* Encode as string attachment */
+      if($bString) {
+        $mime[] = $this->EncodeString($string, $encoding);
+        if($this->IsError()) {
+          return '';
+        }
+        $mime[] = $this->LE.$this->LE;
+      } else {
+        $mime[] = $this->EncodeFile($path, $encoding);
+        if($this->IsError()) {
+          return '';
+        }
+        $mime[] = $this->LE.$this->LE;
+      }
+    }
+
+    $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
+
+    return join('', $mime);
+  }
+
+  /**
+   * Encodes attachment in requested format.  Returns an
+   * empty string on failure.
+   * @access private
+   * @return string
+   */
+  function EncodeFile ($path, $encoding = 'base64') {
+    if(!@$fd = fopen($path, 'rb')) {
+      $this->SetError($this->Lang('file_open') . $path);
+      return '';
+    }
+    $magic_quotes = get_magic_quotes_runtime();
+    set_magic_quotes_runtime(0);
+    $file_buffer = fread($fd, filesize($path));
+    $file_buffer = $this->EncodeString($file_buffer, $encoding);
+    fclose($fd);
+    set_magic_quotes_runtime($magic_quotes);
+
+    return $file_buffer;
+  }
+
+  /**
+   * Encodes string to requested format. Returns an
+   * empty string on failure.
+   * @access private
+   * @return string
+   */
+  function EncodeString ($str, $encoding = 'base64') {
+    $encoded = '';
+    switch(strtolower($encoding)) {
+      case 'base64':
+        /* chunk_split is found in PHP >= 3.0.6 */
+        $encoded = chunk_split(base64_encode($str), 76, $this->LE);
+        break;
+      case '7bit':
+      case '8bit':
+        $encoded = $this->FixEOL($str);
+        if (substr($encoded, -(strlen($this->LE))) != $this->LE)
+          $encoded .= $this->LE;
+        break;
+      case 'binary':
+        $encoded = $str;
+        break;
+      case 'quoted-printable':
+        $encoded = $this->EncodeQP($str);
+        break;
+      default:
+        $this->SetError($this->Lang('encoding') . $encoding);
+        break;
+    }
+    return $encoded;
+  }
+
+  /**
+   * Encode a header string to best of Q, B, quoted or none.
+   * @access private
+   * @return string
+   */
+  function EncodeHeader ($str, $position = 'text') {
+    $x = 0;
+
+    switch (strtolower($position)) {
+      case 'phrase':
+        if (!preg_match('/[\200-\377]/', $str)) {
+          /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
+          $encoded = addcslashes($str, "\0..\37\177\\\"");
+          if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
+            return ($encoded);
+          } else {
+            return ("\"$encoded\"");
+          }
+        }
+        $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
+        break;
+      case 'comment':
+        $x = preg_match_all('/[()"]/', $str, $matches);
+        /* Fall-through */
+      case 'text':
+      default:
+        $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
+        break;
+    }
+
+    if ($x == 0) {
+      return ($str);
+    }
+
+    $maxlen = 75 - 7 - strlen($this->CharSet);
+    /* Try to select the encoding which should produce the shortest output */
+    if (strlen($str)/3 < $x) {
+      $encoding = 'B';
+      if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
+     // Use a custom function which correctly encodes and wraps long
+     // multibyte strings without breaking lines within a character
+        $encoded = $this->Base64EncodeWrapMB($str);
+      } else {
+        $encoded = base64_encode($str);
+        $maxlen -= $maxlen % 4;
+        $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
+      }
+    } else {
+      $encoding = 'Q';
+      $encoded = $this->EncodeQ($str, $position);
+      $encoded = $this->WrapText($encoded, $maxlen, true);
+      $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
+    }
+
+    $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
+    $encoded = trim(str_replace("\n", $this->LE, $encoded));
+
+    return $encoded;
+  }
+
+  /**
+   * Checks if a string contains multibyte characters.
+   * @access private
+   * @param string $str multi-byte text to wrap encode
+   * @return bool
+   */
+  function HasMultiBytes($str) {
+    if (function_exists('mb_strlen')) {
+      return (strlen($str) > mb_strlen($str, $this->CharSet));
+    } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
+      return False;
+    }
+  }
+
+  /**
+   * Correctly encodes and wraps long multibyte strings for mail headers
+   * without breaking lines within a character.
+   * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
+   * @access private
+   * @param string $str multi-byte text to wrap encode
+   * @return string
+   */
+  function Base64EncodeWrapMB($str) {
+    $start = "=?".$this->CharSet."?B?";
+    $end = "?=";
+    $encoded = "";
+
+    $mb_length = mb_strlen($str, $this->CharSet);
+    // Each line must have length <= 75, including $start and $end
+    $length = 75 - strlen($start) - strlen($end);
+    // Average multi-byte ratio
+    $ratio = $mb_length / strlen($str);
+    // Base64 has a 4:3 ratio
+    $offset = $avgLength = floor($length * $ratio * .75);
+
+    for ($i = 0; $i < $mb_length; $i += $offset) {
+      $lookBack = 0;
+
+      do {
+        $offset = $avgLength - $lookBack;
+        $chunk = mb_substr($str, $i, $offset, $this->CharSet);
+        $chunk = base64_encode($chunk);
+        $lookBack++;
+      }
+      while (strlen($chunk) > $length);
+
+      $encoded .= $chunk . $this->LE;
+    }
+
+    // Chomp the last linefeed
+    $encoded = substr($encoded, 0, -strlen($this->LE));
+    return $encoded;
+  }
+
+  /**
+   * Encode string to quoted-printable.
+   * @access private
+   * @return string
+   */
+  function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
+    $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
+    $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
+    $eol = "\r\n";
+    $escape = '=';
+    $output = '';
+    while( list(, $line) = each($lines) ) {
+      $linlen = strlen($line);
+      $newline = '';
+      for($i = 0; $i < $linlen; $i++) {
+        $c = substr( $line, $i, 1 );
+        $dec = ord( $c );
+        if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
+          $c = '=2E';
+        }
+        if ( $dec == 32 ) {
+          if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
+            $c = '=20';
+          } else if ( $space_conv ) {
+            $c = '=20';
+          }
+        } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
+          $h2 = floor($dec/16);
+          $h1 = floor($dec%16);
+          $c = $escape.$hex[$h2].$hex[$h1];
+        }
+        if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
+          $output .= $newline.$escape.$eol; //  soft line break; " =\r\n" is okay
+          $newline = '';
+          // check if newline first character will be point or not
+          if ( $dec == 46 ) {
+            $c = '=2E';
+          }
+        }
+        $newline .= $c;
+      } // end of for
+      $output .= $newline.$eol;
+    } // end of while
+    return $output;
+  }
+
+  /**
+   * Callback for converting to "=XX".
+   * @access private
+   * @return string
+   */
+  function EncodeQ_callback ($matches) {
+    return sprintf('=%02X', ord($matches[1]));
+  }
+
+  /**
+   * Encode string to q encoding.
+   * @access private
+   * @return string
+   */
+  function EncodeQ ($str, $position = 'text') {
+    /* There should not be any EOL in the string */
+    $encoded = preg_replace("/[\r\n]/", '', $str);
+
+    switch (strtolower($position)) {
+      case 'phrase':
+        $encoded = preg_replace_callback("/([^A-Za-z0-9!*+\/ -])/",
+                                         array('PHPMailer', 'EncodeQ_callback'), $encoded);
+        break;
+      case 'comment':
+        $encoded = preg_replace_callback("/([\(\)\"])/",
+                                         array('PHPMailer', 'EncodeQ_callback'), $encoded);
+        break;
+      case 'text':
+      default:
+        /* Replace every high ascii, control =, ? and _ characters */
+        $encoded = preg_replace_callback('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',
+                                         array('PHPMailer', 'EncodeQ_callback'), $encoded);
+        break;
+    }
+
+    /* Replace every spaces to _ (more readable than =20) */
+    $encoded = str_replace(' ', '_', $encoded);
+
+    return $encoded;
+  }
+
+  /**
+   * Adds a string or binary attachment (non-filesystem) to the list.
+   * This method can be used to attach ascii or binary data,
+   * such as a BLOB record from a database.
+   * @param string $string String attachment data.
+   * @param string $filename Name of the attachment.
+   * @param string $encoding File encoding (see $Encoding).
+   * @param string $type File extension (MIME) type.
+   * @return void
+   */
+  function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
+    /* Append to $attachment array */
+    $cur = count($this->attachment);
+    $this->attachment[$cur][0] = $string;
+    $this->attachment[$cur][1] = $filename;
+    $this->attachment[$cur][2] = $filename;
+    $this->attachment[$cur][3] = $encoding;
+    $this->attachment[$cur][4] = $type;
+    $this->attachment[$cur][5] = true; // isString
+    $this->attachment[$cur][6] = 'attachment';
+    $this->attachment[$cur][7] = 0;
+  }
+
+  /**
+   * Adds an embedded attachment.  This can include images, sounds, and
+   * just about any other document.  Make sure to set the $type to an
+   * image type.  For JPEG images use "image/jpeg" and for GIF images
+   * use "image/gif".
+   * @param string $path Path to the attachment.
+   * @param string $cid Content ID of the attachment.  Use this to identify
+   *        the Id for accessing the image in an HTML form.
+   * @param string $name Overrides the attachment name.
+   * @param string $encoding File encoding (see $Encoding).
+   * @param string $type File extension (MIME) type.
+   * @return bool
+   */
+  function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
+
+    if(!@is_file($path)) {
+      $this->SetError($this->Lang('file_access') . $path);
+      return false;
+    }
+
+    $filename = basename($path);
+    if($name == '') {
+      $name = $filename;
+    }
+
+    /* Append to $attachment array */
+    $cur = count($this->attachment);
+    $this->attachment[$cur][0] = $path;
+    $this->attachment[$cur][1] = $filename;
+    $this->attachment[$cur][2] = $name;
+    $this->attachment[$cur][3] = $encoding;
+    $this->attachment[$cur][4] = $type;
+    $this->attachment[$cur][5] = false;
+    $this->attachment[$cur][6] = 'inline';
+    $this->attachment[$cur][7] = $cid;
+
+    return true;
+  }
+
+  /**
+   * Returns true if an inline attachment is present.
+   * @access private
+   * @return bool
+   */
+  function InlineImageExists() {
+    $result = false;
+    for($i = 0; $i < count($this->attachment); $i++) {
+      if($this->attachment[$i][6] == 'inline') {
+        $result = true;
+        break;
+      }
+    }
+
+    return $result;
+  }
+
+  /////////////////////////////////////////////////
+  // CLASS METHODS, MESSAGE RESET
+  /////////////////////////////////////////////////
+
+  /**
+   * Clears all recipients assigned in the TO array.  Returns void.
+   * @return void
+   */
+  function ClearAddresses() {
+    $this->to = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the CC array.  Returns void.
+   * @return void
+   */
+  function ClearCCs() {
+    $this->cc = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the BCC array.  Returns void.
+   * @return void
+   */
+  function ClearBCCs() {
+    $this->bcc = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the ReplyTo array.  Returns void.
+   * @return void
+   */
+  function ClearReplyTos() {
+    $this->ReplyTo = array();
+  }
+
+  /**
+   * Clears all recipients assigned in the TO, CC and BCC
+   * array.  Returns void.
+   * @return void
+   */
+  function ClearAllRecipients() {
+    $this->to = array();
+    $this->cc = array();
+    $this->bcc = array();
+  }
+
+  /**
+   * Clears all previously set filesystem, string, and binary
+   * attachments.  Returns void.
+   * @return void
+   */
+  function ClearAttachments() {
+    $this->attachment = array();
+  }
+
+  /**
+   * Clears all custom headers.  Returns void.
+   * @return void
+   */
+  function ClearCustomHeaders() {
+    $this->CustomHeader = array();
+  }
+
+  /////////////////////////////////////////////////
+  // CLASS METHODS, MISCELLANEOUS
+  /////////////////////////////////////////////////
+
+  /**
+   * Adds the error message to the error container.
+   * Returns void.
+   * @access private
+   * @return void
+   */
+  function SetError($msg) {
+    $this->error_count++;
+    $this->ErrorInfo = $msg;
+  }
+
+  /**
+   * Returns the proper RFC 822 formatted date.
+   * @access private
+   * @return string
+   */
+  function RFCDate() {
+    $tz = date('Z');
+    $tzs = ($tz < 0) ? '-' : '+';
+    $tz = abs($tz);
+    $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
+    $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
+
+    return $result;
+  }
+
+  /**
+   * Returns the appropriate server variable.  Should work with both
+   * PHP 4.1.0+ as well as older versions.  Returns an empty string
+   * if nothing is found.
+   * @access private
+   * @return mixed
+   */
+  function ServerVar($varName) {
+    global $HTTP_SERVER_VARS;
+    global $HTTP_ENV_VARS;
+
+    if(!isset($_SERVER)) {
+      $_SERVER = $HTTP_SERVER_VARS;
+      if(!isset($_SERVER['REMOTE_ADDR'])) {
+        $_SERVER = $HTTP_ENV_VARS; // must be Apache
+      }
+    }
+
+    if(isset($_SERVER[$varName])) {
+      return $_SERVER[$varName];
+    } else {
+      return '';
+    }
+  }
+
+  /**
+   * Returns the server hostname or 'localhost.localdomain' if unknown.
+   * @access private
+   * @return string
+   */
+  function ServerHostname() {
+    if ($this->Hostname != '') {
+      $result = $this->Hostname;
+    } elseif ($this->ServerVar('SERVER_NAME') != '') {
+      $result = $this->ServerVar('SERVER_NAME');
+    } else {
+      $result = 'localhost.localdomain';
+    }
+
+    return $result;
+  }
+
+  /**
+   * Returns a message in the appropriate language.
+   * @access private
+   * @return string
+   */
+  function Lang($key) {
+    if(count($this->language) < 1) {
+      $this->SetLanguage('en'); // set the default language
+    }
+
+    if(isset($this->language[$key])) {
+      return $this->language[$key];
+    } else {
+      return 'Language string failed to load: ' . $key;
+    }
+  }
+
+  /**
+   * Returns true if an error occurred.
+   * @return bool
+   */
+  function IsError() {
+    return ($this->error_count > 0);
+  }
+
+  /**
+   * Changes every end of line from CR or LF to CRLF.
+   * @access private
+   * @return string
+   */
+  function FixEOL($str) {
+    $str = str_replace("\r\n", "\n", $str);
+    $str = str_replace("\r", "\n", $str);
+    $str = str_replace("\n", $this->LE, $str);
+    return $str;
+  }
+
+  /**
+   * Adds a custom header.
+   * @return void
+   */
+  function AddCustomHeader($custom_header) {
+    $this->CustomHeader[] = explode(':', $custom_header, 2);
+  }
+
+  /**
+   * Evaluates the message and returns modifications for inline images and backgrounds
+   * @access public
+   * @return $message
+   */
+  function MsgHTML($message,$basedir='') {
+    preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
+    if(isset($images[2])) {
+      foreach($images[2] as $i => $url) {
+        // do not change urls for absolute images (thanks to corvuscorax)
+        if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
+          $filename = basename($url);
+          $directory = dirname($url);
+          ($directory == '.')?$directory='':'';
+          $cid = 'cid:' . md5($filename);
+          $fileParts = split("\.", $filename);
+          $ext = $fileParts[1];
+          $mimeType = $this->_mime_types($ext);
+          if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
+          if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
+          if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
+            $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
+          }
+        }
+      }
+    }
+    $this->IsHTML(true);
+    $this->Body = $message;
+    $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
+    if ( !empty($textMsg) && empty($this->AltBody) ) {
+      $this->AltBody = html_entity_decode($textMsg);
+    }
+    if ( empty($this->AltBody) ) {
+      $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
+    }
+  }
+
+  /**
+   * Gets the mime type of the embedded or inline image
+   * @access private
+   * @return mime type of ext
+   */
+  function _mime_types($ext = '') {
+    $mimes = array(
+      'ai'    =>  'application/postscript',
+      'aif'   =>  'audio/x-aiff',
+      'aifc'  =>  'audio/x-aiff',
+      'aiff'  =>  'audio/x-aiff',
+      'avi'   =>  'video/x-msvideo',
+      'bin'   =>  'application/macbinary',
+      'bmp'   =>  'image/bmp',
+      'class' =>  'application/octet-stream',
+      'cpt'   =>  'application/mac-compactpro',
+      'css'   =>  'text/css',
+      'dcr'   =>  'application/x-director',
+      'dir'   =>  'application/x-director',
+      'dll'   =>  'application/octet-stream',
+      'dms'   =>  'application/octet-stream',
+      'doc'   =>  'application/msword',
+      'dvi'   =>  'application/x-dvi',
+      'dxr'   =>  'application/x-director',
+      'eml'   =>  'message/rfc822',
+      'eps'   =>  'application/postscript',
+      'exe'   =>  'application/octet-stream',
+      'gif'   =>  'image/gif',
+      'gtar'  =>  'application/x-gtar',
+      'htm'   =>  'text/html',
+      'html'  =>  'text/html',
+      'jpe'   =>  'image/jpeg',
+      'jpeg'  =>  'image/jpeg',
+      'jpg'   =>  'image/jpeg',
+      'hqx'   =>  'application/mac-binhex40',
+      'js'    =>  'application/x-javascript',
+      'lha'   =>  'application/octet-stream',
+      'log'   =>  'text/plain',
+      'lzh'   =>  'application/octet-stream',
+      'mid'   =>  'audio/midi',
+      'midi'  =>  'audio/midi',
+      'mif'   =>  'application/vnd.mif',
+      'mov'   =>  'video/quicktime',
+      'movie' =>  'video/x-sgi-movie',
+      'mp2'   =>  'audio/mpeg',
+      'mp3'   =>  'audio/mpeg',
+      'mpe'   =>  'video/mpeg',
+      'mpeg'  =>  'video/mpeg',
+      'mpg'   =>  'video/mpeg',
+      'mpga'  =>  'audio/mpeg',
+      'oda'   =>  'application/oda',
+      'pdf'   =>  'application/pdf',
+      'php'   =>  'application/x-httpd-php',
+      'php3'  =>  'application/x-httpd-php',
+      'php4'  =>  'application/x-httpd-php',
+      'phps'  =>  'application/x-httpd-php-source',
+      'phtml' =>  'application/x-httpd-php',
+      'png'   =>  'image/png',
+      'ppt'   =>  'application/vnd.ms-powerpoint',
+      'ps'    =>  'application/postscript',
+      'psd'   =>  'application/octet-stream',
+      'qt'    =>  'video/quicktime',
+      'ra'    =>  'audio/x-realaudio',
+      'ram'   =>  'audio/x-pn-realaudio',
+      'rm'    =>  'audio/x-pn-realaudio',
+      'rpm'   =>  'audio/x-pn-realaudio-plugin',
+      'rtf'   =>  'text/rtf',
+      'rtx'   =>  'text/richtext',
+      'rv'    =>  'video/vnd.rn-realvideo',
+      'sea'   =>  'application/octet-stream',
+      'shtml' =>  'text/html',
+      'sit'   =>  'application/x-stuffit',
+      'so'    =>  'application/octet-stream',
+      'smi'   =>  'application/smil',
+      'smil'  =>  'application/smil',
+      'swf'   =>  'application/x-shockwave-flash',
+      'tar'   =>  'application/x-tar',
+      'text'  =>  'text/plain',
+      'txt'   =>  'text/plain',
+      'tgz'   =>  'application/x-tar',
+      'tif'   =>  'image/tiff',
+      'tiff'  =>  'image/tiff',
+      'wav'   =>  'audio/x-wav',
+      'wbxml' =>  'application/vnd.wap.wbxml',
+      'wmlc'  =>  'application/vnd.wap.wmlc',
+      'word'  =>  'application/msword',
+      'xht'   =>  'application/xhtml+xml',
+      'xhtml' =>  'application/xhtml+xml',
+      'xl'    =>  'application/excel',
+      'xls'   =>  'application/vnd.ms-excel',
+      'xml'   =>  'text/xml',
+      'xsl'   =>  'text/xml',
+      'zip'   =>  'application/zip'
+    );
+    return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
+  }
+
+  /**
+   * Set (or reset) Class Objects (variables)
+   *
+   * Usage Example:
+   * $page->set('X-Priority', '3');
+   *
+   * @access public
+   * @param string $name Parameter Name
+   * @param mixed $value Parameter Value
+   * NOTE: will not work with arrays, there are no arrays to set/reset
+   */
+  function set ( $name, $value = '' ) {
+    if ( isset($this->$name) ) {
+      $this->$name = $value;
+    } else {
+      $this->SetError('Cannot set or reset variable ' . $name);
+      return false;
+    }
+  }
+
+  /**
+   * Read a file from a supplied filename and return it.
+   *
+   * @access public
+   * @param string $filename Parameter File Name
+   */
+  function getFile($filename) {
+    $return = '';
+    if ($fp = fopen($filename, 'rb')) {
+      while (!feof($fp)) {
+        $return .= fread($fp, 1024);
+      }
+      fclose($fp);
+      return $return;
+    } else {
+      return false;
+    }
+  }
+
+  /**
+   * Strips newlines to prevent header injection.
+   * @access private
+   * @param string $str String
+   * @return string
+   */
+  function SecureHeader($str) {
+    $str = trim($str);
+    $str = str_replace("\r", "", $str);
+    $str = str_replace("\n", "", $str);
+    return $str;
+  }
+
+  /**
+   * Set the private key file and password to sign the message.
+   *
+   * @access public
+   * @param string $key_filename Parameter File Name
+   * @param string $key_pass Password for private key
+   */
+  function Sign($cert_filename, $key_filename, $key_pass) {
+    $this->sign_cert_file = $cert_filename;
+    $this->sign_key_file = $key_filename;
+    $this->sign_key_pass = $key_pass;
+  }
+
+}
+
+?>
Index: /tags/3.1/wp-includes/class-pop3.php
===================================================================
--- /tags/3.1/wp-includes/class-pop3.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-pop3.php	(revision 17487)
@@ -0,0 +1,652 @@
+<?php
+/**
+ * mail_fetch/setup.php
+ *
+ * @package SquirrelMail
+ *
+ * @copyright (c) 1999-2006 The SquirrelMail Project Team
+ *
+ * @copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
+ * Modified by Philippe Mingo 2001 mingo@rotedic.com
+ * An RFC 1939 compliant wrapper class for the POP3 protocol.
+ *
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
+ *
+ * pop3 class
+ *
+ * $Id$
+ */
+
+class POP3 {
+    var $ERROR      = '';       //  Error string.
+
+    var $TIMEOUT    = 60;       //  Default timeout before giving up on a
+                                //  network operation.
+
+    var $COUNT      = -1;       //  Mailbox msg count
+
+    var $BUFFER     = 512;      //  Socket buffer for socket fgets() calls.
+                                //  Per RFC 1939 the returned line a POP3
+                                //  server can send is 512 bytes.
+
+    var $FP         = '';       //  The connection to the server's
+                                //  file descriptor
+
+    var $MAILSERVER = '';       // Set this to hard code the server name
+
+    var $DEBUG      = FALSE;    // set to true to echo pop3
+                                // commands and responses to error_log
+                                // this WILL log passwords!
+
+    var $BANNER     = '';       //  Holds the banner returned by the
+                                //  pop server - used for apop()
+
+    var $ALLOWAPOP  = FALSE;    //  Allow or disallow apop()
+                                //  This must be set to true
+                                //  manually
+
+    function POP3 ( $server = '', $timeout = '' ) {
+        settype($this->BUFFER,"integer");
+        if( !empty($server) ) {
+            // Do not allow programs to alter MAILSERVER
+            // if it is already specified. They can get around
+            // this if they -really- want to, so don't count on it.
+            if(empty($this->MAILSERVER))
+                $this->MAILSERVER = $server;
+        }
+        if(!empty($timeout)) {
+            settype($timeout,"integer");
+            $this->TIMEOUT = $timeout;
+            if (!ini_get('safe_mode'))
+                set_time_limit($timeout);
+        }
+        return true;
+    }
+
+    function update_timer () {
+        if (!ini_get('safe_mode'))
+            set_time_limit($this->TIMEOUT);
+        return true;
+    }
+
+    function connect ($server, $port = 110)  {
+        //  Opens a socket to the specified server. Unless overridden,
+        //  port defaults to 110. Returns true on success, false on fail
+
+        // If MAILSERVER is set, override $server with it's value
+
+	if (!isset($port) || !$port) {$port = 110;}
+        if(!empty($this->MAILSERVER))
+            $server = $this->MAILSERVER;
+
+        if(empty($server)){
+            $this->ERROR = "POP3 connect: " . _("No server specified");
+            unset($this->FP);
+            return false;
+        }
+
+        $fp = @fsockopen("$server", $port, $errno, $errstr);
+
+        if(!$fp) {
+            $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
+            unset($this->FP);
+            return false;
+        }
+
+        socket_set_blocking($fp,-1);
+        $this->update_timer();
+        $reply = fgets($fp,$this->BUFFER);
+        $reply = $this->strip_clf($reply);
+        if($this->DEBUG)
+            error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
+        if(!$this->is_ok($reply)) {
+            $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
+            unset($this->FP);
+            return false;
+        }
+        $this->FP = $fp;
+        $this->BANNER = $this->parse_banner($reply);
+        return true;
+    }
+
+    function user ($user = "") {
+        // Sends the USER command, returns true or false
+
+        if( empty($user) ) {
+            $this->ERROR = "POP3 user: " . _("no login ID submitted");
+            return false;
+        } elseif(!isset($this->FP)) {
+            $this->ERROR = "POP3 user: " . _("connection not established");
+            return false;
+        } else {
+            $reply = $this->send_cmd("USER $user");
+            if(!$this->is_ok($reply)) {
+                $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
+                return false;
+            } else
+                return true;
+        }
+    }
+
+    function pass ($pass = "")     {
+        // Sends the PASS command, returns # of msgs in mailbox,
+        // returns false (undef) on Auth failure
+
+        if(empty($pass)) {
+            $this->ERROR = "POP3 pass: " . _("No password submitted");
+            return false;
+        } elseif(!isset($this->FP)) {
+            $this->ERROR = "POP3 pass: " . _("connection not established");
+            return false;
+        } else {
+            $reply = $this->send_cmd("PASS $pass");
+            if(!$this->is_ok($reply)) {
+                $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
+                $this->quit();
+                return false;
+            } else {
+                //  Auth successful.
+                $count = $this->last("count");
+                $this->COUNT = $count;
+                return $count;
+            }
+        }
+    }
+
+    function apop ($login,$pass) {
+        //  Attempts an APOP login. If this fails, it'll
+        //  try a standard login. YOUR SERVER MUST SUPPORT
+        //  THE USE OF THE APOP COMMAND!
+        //  (apop is optional per rfc1939)
+
+        if(!isset($this->FP)) {
+            $this->ERROR = "POP3 apop: " . _("No connection to server");
+            return false;
+        } elseif(!$this->ALLOWAPOP) {
+            $retVal = $this->login($login,$pass);
+            return $retVal;
+        } elseif(empty($login)) {
+            $this->ERROR = "POP3 apop: " . _("No login ID submitted");
+            return false;
+        } elseif(empty($pass)) {
+            $this->ERROR = "POP3 apop: " . _("No password submitted");
+            return false;
+        } else {
+            $banner = $this->BANNER;
+            if( (!$banner) or (empty($banner)) ) {
+                $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
+                $retVal = $this->login($login,$pass);
+                return $retVal;
+            } else {
+                $AuthString = $banner;
+                $AuthString .= $pass;
+                $APOPString = md5($AuthString);
+                $cmd = "APOP $login $APOPString";
+                $reply = $this->send_cmd($cmd);
+                if(!$this->is_ok($reply)) {
+                    $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
+                    $retVal = $this->login($login,$pass);
+                    return $retVal;
+                } else {
+                    //  Auth successful.
+                    $count = $this->last("count");
+                    $this->COUNT = $count;
+                    return $count;
+                }
+            }
+        }
+    }
+
+    function login ($login = "", $pass = "") {
+        // Sends both user and pass. Returns # of msgs in mailbox or
+        // false on failure (or -1, if the error occurs while getting
+        // the number of messages.)
+
+        if( !isset($this->FP) ) {
+            $this->ERROR = "POP3 login: " . _("No connection to server");
+            return false;
+        } else {
+            $fp = $this->FP;
+            if( !$this->user( $login ) ) {
+                //  Preserve the error generated by user()
+                return false;
+            } else {
+                $count = $this->pass($pass);
+                if( (!$count) || ($count == -1) ) {
+                    //  Preserve the error generated by last() and pass()
+                    return false;
+                } else
+                    return $count;
+            }
+        }
+    }
+
+    function top ($msgNum, $numLines = "0") {
+        //  Gets the header and first $numLines of the msg body
+        //  returns data in an array with each returned line being
+        //  an array element. If $numLines is empty, returns
+        //  only the header information, and none of the body.
+
+        if(!isset($this->FP)) {
+            $this->ERROR = "POP3 top: " . _("No connection to server");
+            return false;
+        }
+        $this->update_timer();
+
+        $fp = $this->FP;
+        $buffer = $this->BUFFER;
+        $cmd = "TOP $msgNum $numLines";
+        fwrite($fp, "TOP $msgNum $numLines\r\n");
+        $reply = fgets($fp, $buffer);
+        $reply = $this->strip_clf($reply);
+        if($this->DEBUG) {
+            @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
+        }
+        if(!$this->is_ok($reply))
+        {
+            $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
+            return false;
+        }
+
+        $count = 0;
+        $MsgArray = array();
+
+        $line = fgets($fp,$buffer);
+        while ( !ereg("^\.\r\n",$line))
+        {
+            $MsgArray[$count] = $line;
+            $count++;
+            $line = fgets($fp,$buffer);
+            if(empty($line))    { break; }
+        }
+
+        return $MsgArray;
+    }
+
+    function pop_list ($msgNum = "") {
+        //  If called with an argument, returns that msgs' size in octets
+        //  No argument returns an associative array of undeleted
+        //  msg numbers and their sizes in octets
+
+        if(!isset($this->FP))
+        {
+            $this->ERROR = "POP3 pop_list: " . _("No connection to server");
+            return false;
+        }
+        $fp = $this->FP;
+        $Total = $this->COUNT;
+        if( (!$Total) or ($Total == -1) )
+        {
+            return false;
+        }
+        if($Total == 0)
+        {
+            return array("0","0");
+            // return -1;   // mailbox empty
+        }
+
+        $this->update_timer();
+
+        if(!empty($msgNum))
+        {
+            $cmd = "LIST $msgNum";
+            fwrite($fp,"$cmd\r\n");
+            $reply = fgets($fp,$this->BUFFER);
+            $reply = $this->strip_clf($reply);
+            if($this->DEBUG) {
+                @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
+            }
+            if(!$this->is_ok($reply))
+            {
+                $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
+                return false;
+            }
+            list($junk,$num,$size) = preg_split('/\s+/',$reply);
+            return $size;
+        }
+        $cmd = "LIST";
+        $reply = $this->send_cmd($cmd);
+        if(!$this->is_ok($reply))
+        {
+            $reply = $this->strip_clf($reply);
+            $this->ERROR = "POP3 pop_list: " . _("Error ") .  "[$reply]";
+            return false;
+        }
+        $MsgArray = array();
+        $MsgArray[0] = $Total;
+        for($msgC=1;$msgC <= $Total; $msgC++)
+        {
+            if($msgC > $Total) { break; }
+            $line = fgets($fp,$this->BUFFER);
+            $line = $this->strip_clf($line);
+            if(ereg("^\.",$line))
+            {
+                $this->ERROR = "POP3 pop_list: " . _("Premature end of list");
+                return false;
+            }
+            list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
+            settype($thisMsg,"integer");
+            if($thisMsg != $msgC)
+            {
+                $MsgArray[$msgC] = "deleted";
+            }
+            else
+            {
+                $MsgArray[$msgC] = $msgSize;
+            }
+        }
+        return $MsgArray;
+    }
+
+    function get ($msgNum) {
+        //  Retrieve the specified msg number. Returns an array
+        //  where each line of the msg is an array element.
+
+        if(!isset($this->FP))
+        {
+            $this->ERROR = "POP3 get: " . _("No connection to server");
+            return false;
+        }
+
+        $this->update_timer();
+
+        $fp = $this->FP;
+        $buffer = $this->BUFFER;
+        $cmd = "RETR $msgNum";
+        $reply = $this->send_cmd($cmd);
+
+        if(!$this->is_ok($reply))
+        {
+            $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
+            return false;
+        }
+
+        $count = 0;
+        $MsgArray = array();
+
+        $line = fgets($fp,$buffer);
+        while ( !ereg("^\.\r\n",$line))
+        {
+            if ( $line[0] == '.' ) { $line = substr($line,1); }
+            $MsgArray[$count] = $line;
+            $count++;
+            $line = fgets($fp,$buffer);
+            if(empty($line))    { break; }
+        }
+        return $MsgArray;
+    }
+
+    function last ( $type = "count" ) {
+        //  Returns the highest msg number in the mailbox.
+        //  returns -1 on error, 0+ on success, if type != count
+        //  results in a popstat() call (2 element array returned)
+
+        $last = -1;
+        if(!isset($this->FP))
+        {
+            $this->ERROR = "POP3 last: " . _("No connection to server");
+            return $last;
+        }
+
+        $reply = $this->send_cmd("STAT");
+        if(!$this->is_ok($reply))
+        {
+            $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
+            return $last;
+        }
+
+        $Vars = preg_split('/\s+/',$reply);
+        $count = $Vars[1];
+        $size = $Vars[2];
+        settype($count,"integer");
+        settype($size,"integer");
+        if($type != "count")
+        {
+            return array($count,$size);
+        }
+        return $count;
+    }
+
+    function reset () {
+        //  Resets the status of the remote server. This includes
+        //  resetting the status of ALL msgs to not be deleted.
+        //  This method automatically closes the connection to the server.
+
+        if(!isset($this->FP))
+        {
+            $this->ERROR = "POP3 reset: " . _("No connection to server");
+            return false;
+        }
+        $reply = $this->send_cmd("RSET");
+        if(!$this->is_ok($reply))
+        {
+            //  The POP3 RSET command -never- gives a -ERR
+            //  response - if it ever does, something truely
+            //  wild is going on.
+
+            $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
+            @error_log("POP3 reset: ERROR [$reply]",0);
+        }
+        $this->quit();
+        return true;
+    }
+
+    function send_cmd ( $cmd = "" )
+    {
+        //  Sends a user defined command string to the
+        //  POP server and returns the results. Useful for
+        //  non-compliant or custom POP servers.
+        //  Do NOT includ the \r\n as part of your command
+        //  string - it will be appended automatically.
+
+        //  The return value is a standard fgets() call, which
+        //  will read up to $this->BUFFER bytes of data, until it
+        //  encounters a new line, or EOF, whichever happens first.
+
+        //  This method works best if $cmd responds with only
+        //  one line of data.
+
+        if(!isset($this->FP))
+        {
+            $this->ERROR = "POP3 send_cmd: " . _("No connection to server");
+            return false;
+        }
+
+        if(empty($cmd))
+        {
+            $this->ERROR = "POP3 send_cmd: " . _("Empty command string");
+            return "";
+        }
+
+        $fp = $this->FP;
+        $buffer = $this->BUFFER;
+        $this->update_timer();
+        fwrite($fp,"$cmd\r\n");
+        $reply = fgets($fp,$buffer);
+        $reply = $this->strip_clf($reply);
+        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
+        return $reply;
+    }
+
+    function quit() {
+        //  Closes the connection to the POP3 server, deleting
+        //  any msgs marked as deleted.
+
+        if(!isset($this->FP))
+        {
+            $this->ERROR = "POP3 quit: " . _("connection does not exist");
+            return false;
+        }
+        $fp = $this->FP;
+        $cmd = "QUIT";
+        fwrite($fp,"$cmd\r\n");
+        $reply = fgets($fp,$this->BUFFER);
+        $reply = $this->strip_clf($reply);
+        if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
+        fclose($fp);
+        unset($this->FP);
+        return true;
+    }
+
+    function popstat () {
+        //  Returns an array of 2 elements. The number of undeleted
+        //  msgs in the mailbox, and the size of the mbox in octets.
+
+        $PopArray = $this->last("array");
+
+        if($PopArray == -1) { return false; }
+
+        if( (!$PopArray) or (empty($PopArray)) )
+        {
+            return false;
+        }
+        return $PopArray;
+    }
+
+    function uidl ($msgNum = "")
+    {
+        //  Returns the UIDL of the msg specified. If called with
+        //  no arguments, returns an associative array where each
+        //  undeleted msg num is a key, and the msg's uidl is the element
+        //  Array element 0 will contain the total number of msgs
+
+        if(!isset($this->FP)) {
+            $this->ERROR = "POP3 uidl: " . _("No connection to server");
+            return false;
+        }
+
+        $fp = $this->FP;
+        $buffer = $this->BUFFER;
+
+        if(!empty($msgNum)) {
+            $cmd = "UIDL $msgNum";
+            $reply = $this->send_cmd($cmd);
+            if(!$this->is_ok($reply))
+            {
+                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
+                return false;
+            }
+            list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
+            return $myUidl;
+        } else {
+            $this->update_timer();
+
+            $UIDLArray = array();
+            $Total = $this->COUNT;
+            $UIDLArray[0] = $Total;
+
+            if ($Total < 1)
+            {
+                return $UIDLArray;
+            }
+            $cmd = "UIDL";
+            fwrite($fp, "UIDL\r\n");
+            $reply = fgets($fp, $buffer);
+            $reply = $this->strip_clf($reply);
+            if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
+            if(!$this->is_ok($reply))
+            {
+                $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
+                return false;
+            }
+
+            $line = "";
+            $count = 1;
+            $line = fgets($fp,$buffer);
+            while ( !ereg("^\.\r\n",$line)) {
+                if(ereg("^\.\r\n",$line)) {
+                    break;
+                }
+                list ($msg,$msgUidl) = preg_split('/\s+/',$line);
+                $msgUidl = $this->strip_clf($msgUidl);
+                if($count == $msg) {
+                    $UIDLArray[$msg] = $msgUidl;
+                }
+                else
+                {
+                    $UIDLArray[$count] = 'deleted';
+                }
+                $count++;
+                $line = fgets($fp,$buffer);
+            }
+        }
+        return $UIDLArray;
+    }
+
+    function delete ($msgNum = "") {
+        //  Flags a specified msg as deleted. The msg will not
+        //  be deleted until a quit() method is called.
+
+        if(!isset($this->FP))
+        {
+            $this->ERROR = "POP3 delete: " . _("No connection to server");
+            return false;
+        }
+        if(empty($msgNum))
+        {
+            $this->ERROR = "POP3 delete: " . _("No msg number submitted");
+            return false;
+        }
+        $reply = $this->send_cmd("DELE $msgNum");
+        if(!$this->is_ok($reply))
+        {
+            $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
+            return false;
+        }
+        return true;
+    }
+
+    //  *********************************************************
+
+    //  The following methods are internal to the class.
+
+    function is_ok ($cmd = "") {
+        //  Return true or false on +OK or -ERR
+
+        if( empty($cmd) )
+            return false;
+        else
+            return( ereg ("^\+OK", $cmd ) );
+    }
+
+    function strip_clf ($text = "") {
+        // Strips \r\n from server responses
+
+        if(empty($text))
+            return $text;
+        else {
+            $stripped = str_replace("\r",'',$text);
+            $stripped = str_replace("\n",'',$stripped);
+            return $stripped;
+        }
+    }
+
+    function parse_banner ( $server_text ) {
+        $outside = true;
+        $banner = "";
+        $length = strlen($server_text);
+        for($count =0; $count < $length; $count++)
+        {
+            $digit = substr($server_text,$count,1);
+            if(!empty($digit))             {
+                if( (!$outside) && ($digit != '<') && ($digit != '>') )
+                {
+                    $banner .= $digit;
+                }
+                if ($digit == '<')
+                {
+                    $outside = false;
+                }
+                if($digit == '>')
+                {
+                    $outside = true;
+                }
+            }
+        }
+        $banner = $this->strip_clf($banner);    // Just in case
+        return "<$banner>";
+    }
+
+}   // End class
+?>
Index: /tags/3.1/wp-includes/class-simplepie.php
===================================================================
--- /tags/3.1/wp-includes/class-simplepie.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-simplepie.php	(revision 17487)
@@ -0,0 +1,15002 @@
+<?php
+if ( !class_exists( 'SimplePie' ) ) :
+/**
+ * SimplePie
+ *
+ * A PHP-Based RSS and Atom Feed Framework.
+ * Takes the hard work out of managing a complete RSS/Atom solution.
+ *
+ * Copyright (c) 2004-2009, Ryan Parman and Geoffrey Sneddon
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 	* Redistributions of source code must retain the above copyright notice, this list of
+ * 	  conditions and the following disclaimer.
+ *
+ * 	* Redistributions in binary form must reproduce the above copyright notice, this list
+ * 	  of conditions and the following disclaimer in the documentation and/or other materials
+ * 	  provided with the distribution.
+ *
+ * 	* Neither the name of the SimplePie Team nor the names of its contributors may be used
+ * 	  to endorse or promote products derived from this software without specific prior
+ * 	  written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
+ * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package SimplePie
+ * @version 1.2
+ * @copyright 2004-2009 Ryan Parman, Geoffrey Sneddon
+ * @author Ryan Parman
+ * @author Geoffrey Sneddon
+ * @link http://simplepie.org/ SimplePie
+ * @link http://simplepie.org/support/ Please submit all bug reports and feature requests to the SimplePie forums
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @todo phpDoc comments
+ */
+
+/**
+ * SimplePie Name
+ */
+define('SIMPLEPIE_NAME', 'SimplePie');
+
+/**
+ * SimplePie Version
+ */
+define('SIMPLEPIE_VERSION', '1.2');
+
+/**
+ * SimplePie Build
+ */
+define('SIMPLEPIE_BUILD', '20090627192103');
+
+/**
+ * SimplePie Website URL
+ */
+define('SIMPLEPIE_URL', 'http://simplepie.org');
+
+/**
+ * SimplePie Useragent
+ * @see SimplePie::set_useragent()
+ */
+define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' . SIMPLEPIE_BUILD);
+
+/**
+ * SimplePie Linkback
+ */
+define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME . '</a>');
+
+/**
+ * No Autodiscovery
+ * @see SimplePie::set_autodiscovery_level()
+ */
+define('SIMPLEPIE_LOCATOR_NONE', 0);
+
+/**
+ * Feed Link Element Autodiscovery
+ * @see SimplePie::set_autodiscovery_level()
+ */
+define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1);
+
+/**
+ * Local Feed Extension Autodiscovery
+ * @see SimplePie::set_autodiscovery_level()
+ */
+define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2);
+
+/**
+ * Local Feed Body Autodiscovery
+ * @see SimplePie::set_autodiscovery_level()
+ */
+define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4);
+
+/**
+ * Remote Feed Extension Autodiscovery
+ * @see SimplePie::set_autodiscovery_level()
+ */
+define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8);
+
+/**
+ * Remote Feed Body Autodiscovery
+ * @see SimplePie::set_autodiscovery_level()
+ */
+define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16);
+
+/**
+ * All Feed Autodiscovery
+ * @see SimplePie::set_autodiscovery_level()
+ */
+define('SIMPLEPIE_LOCATOR_ALL', 31);
+
+/**
+ * No known feed type
+ */
+define('SIMPLEPIE_TYPE_NONE', 0);
+
+/**
+ * RSS 0.90
+ */
+define('SIMPLEPIE_TYPE_RSS_090', 1);
+
+/**
+ * RSS 0.91 (Netscape)
+ */
+define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2);
+
+/**
+ * RSS 0.91 (Userland)
+ */
+define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4);
+
+/**
+ * RSS 0.91 (both Netscape and Userland)
+ */
+define('SIMPLEPIE_TYPE_RSS_091', 6);
+
+/**
+ * RSS 0.92
+ */
+define('SIMPLEPIE_TYPE_RSS_092', 8);
+
+/**
+ * RSS 0.93
+ */
+define('SIMPLEPIE_TYPE_RSS_093', 16);
+
+/**
+ * RSS 0.94
+ */
+define('SIMPLEPIE_TYPE_RSS_094', 32);
+
+/**
+ * RSS 1.0
+ */
+define('SIMPLEPIE_TYPE_RSS_10', 64);
+
+/**
+ * RSS 2.0
+ */
+define('SIMPLEPIE_TYPE_RSS_20', 128);
+
+/**
+ * RDF-based RSS
+ */
+define('SIMPLEPIE_TYPE_RSS_RDF', 65);
+
+/**
+ * Non-RDF-based RSS (truly intended as syndication format)
+ */
+define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190);
+
+/**
+ * All RSS
+ */
+define('SIMPLEPIE_TYPE_RSS_ALL', 255);
+
+/**
+ * Atom 0.3
+ */
+define('SIMPLEPIE_TYPE_ATOM_03', 256);
+
+/**
+ * Atom 1.0
+ */
+define('SIMPLEPIE_TYPE_ATOM_10', 512);
+
+/**
+ * All Atom
+ */
+define('SIMPLEPIE_TYPE_ATOM_ALL', 768);
+
+/**
+ * All feed types
+ */
+define('SIMPLEPIE_TYPE_ALL', 1023);
+
+/**
+ * No construct
+ */
+define('SIMPLEPIE_CONSTRUCT_NONE', 0);
+
+/**
+ * Text construct
+ */
+define('SIMPLEPIE_CONSTRUCT_TEXT', 1);
+
+/**
+ * HTML construct
+ */
+define('SIMPLEPIE_CONSTRUCT_HTML', 2);
+
+/**
+ * XHTML construct
+ */
+define('SIMPLEPIE_CONSTRUCT_XHTML', 4);
+
+/**
+ * base64-encoded construct
+ */
+define('SIMPLEPIE_CONSTRUCT_BASE64', 8);
+
+/**
+ * IRI construct
+ */
+define('SIMPLEPIE_CONSTRUCT_IRI', 16);
+
+/**
+ * A construct that might be HTML
+ */
+define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32);
+
+/**
+ * All constructs
+ */
+define('SIMPLEPIE_CONSTRUCT_ALL', 63);
+
+/**
+ * Don't change case
+ */
+define('SIMPLEPIE_SAME_CASE', 1);
+
+/**
+ * Change to lowercase
+ */
+define('SIMPLEPIE_LOWERCASE', 2);
+
+/**
+ * Change to uppercase
+ */
+define('SIMPLEPIE_UPPERCASE', 4);
+
+/**
+ * PCRE for HTML attributes
+ */
+define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*');
+
+/**
+ * PCRE for XML attributes
+ */
+define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*');
+
+/**
+ * XML Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace');
+
+/**
+ * Atom 1.0 Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom');
+
+/**
+ * Atom 0.3 Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#');
+
+/**
+ * RDF Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
+
+/**
+ * RSS 0.90 Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/');
+
+/**
+ * RSS 1.0 Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/');
+
+/**
+ * RSS 1.0 Content Module Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/');
+
+/**
+ * RSS 2.0 Namespace
+ * (Stupid, I know, but I'm certain it will confuse people less with support.)
+ */
+define('SIMPLEPIE_NAMESPACE_RSS_20', '');
+
+/**
+ * DC 1.0 Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/');
+
+/**
+ * DC 1.1 Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/');
+
+/**
+ * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
+
+/**
+ * GeoRSS Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss');
+
+/**
+ * Media RSS Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/');
+
+/**
+ * Wrong Media RSS Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss');
+
+/**
+ * iTunes RSS Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
+
+/**
+ * XHTML Namespace
+ */
+define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml');
+
+/**
+ * IANA Link Relations Registry
+ */
+define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/');
+
+/**
+ * Whether we're running on PHP5
+ */
+define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>='));
+
+/**
+ * No file source
+ */
+define('SIMPLEPIE_FILE_SOURCE_NONE', 0);
+
+/**
+ * Remote file source
+ */
+define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1);
+
+/**
+ * Local file source
+ */
+define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2);
+
+/**
+ * fsockopen() file source
+ */
+define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4);
+
+/**
+ * cURL file source
+ */
+define('SIMPLEPIE_FILE_SOURCE_CURL', 8);
+
+/**
+ * file_get_contents() file source
+ */
+define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
+
+/**
+ * SimplePie
+ *
+ * @package SimplePie
+ */
+class SimplePie
+{
+	/**
+	 * @var array Raw data
+	 * @access private
+	 */
+	var $data = array();
+
+	/**
+	 * @var mixed Error string
+	 * @access private
+	 */
+	var $error;
+
+	/**
+	 * @var object Instance of SimplePie_Sanitize (or other class)
+	 * @see SimplePie::set_sanitize_class()
+	 * @access private
+	 */
+	var $sanitize;
+
+	/**
+	 * @var string SimplePie Useragent
+	 * @see SimplePie::set_useragent()
+	 * @access private
+	 */
+	var $useragent = SIMPLEPIE_USERAGENT;
+
+	/**
+	 * @var string Feed URL
+	 * @see SimplePie::set_feed_url()
+	 * @access private
+	 */
+	var $feed_url;
+
+	/**
+	 * @var object Instance of SimplePie_File to use as a feed
+	 * @see SimplePie::set_file()
+	 * @access private
+	 */
+	var $file;
+
+	/**
+	 * @var string Raw feed data
+	 * @see SimplePie::set_raw_data()
+	 * @access private
+	 */
+	var $raw_data;
+
+	/**
+	 * @var int Timeout for fetching remote files
+	 * @see SimplePie::set_timeout()
+	 * @access private
+	 */
+	var $timeout = 10;
+
+	/**
+	 * @var bool Forces fsockopen() to be used for remote files instead
+	 * of cURL, even if a new enough version is installed
+	 * @see SimplePie::force_fsockopen()
+	 * @access private
+	 */
+	var $force_fsockopen = false;
+
+	/**
+	 * @var bool Force the given data/URL to be treated as a feed no matter what
+	 * it appears like
+	 * @see SimplePie::force_feed()
+	 * @access private
+	 */
+	var $force_feed = false;
+
+	/**
+	 * @var bool Enable/Disable XML dump
+	 * @see SimplePie::enable_xml_dump()
+	 * @access private
+	 */
+	var $xml_dump = false;
+
+	/**
+	 * @var bool Enable/Disable Caching
+	 * @see SimplePie::enable_cache()
+	 * @access private
+	 */
+	var $cache = true;
+
+	/**
+	 * @var int Cache duration (in seconds)
+	 * @see SimplePie::set_cache_duration()
+	 * @access private
+	 */
+	var $cache_duration = 3600;
+
+	/**
+	 * @var int Auto-discovery cache duration (in seconds)
+	 * @see SimplePie::set_autodiscovery_cache_duration()
+	 * @access private
+	 */
+	var $autodiscovery_cache_duration = 604800; // 7 Days.
+
+	/**
+	 * @var string Cache location (relative to executing script)
+	 * @see SimplePie::set_cache_location()
+	 * @access private
+	 */
+	var $cache_location = './cache';
+
+	/**
+	 * @var string Function that creates the cache filename
+	 * @see SimplePie::set_cache_name_function()
+	 * @access private
+	 */
+	var $cache_name_function = 'md5';
+
+	/**
+	 * @var bool Reorder feed by date descending
+	 * @see SimplePie::enable_order_by_date()
+	 * @access private
+	 */
+	var $order_by_date = true;
+
+	/**
+	 * @var mixed Force input encoding to be set to the follow value
+	 * (false, or anything type-cast to false, disables this feature)
+	 * @see SimplePie::set_input_encoding()
+	 * @access private
+	 */
+	var $input_encoding = false;
+
+	/**
+	 * @var int Feed Autodiscovery Level
+	 * @see SimplePie::set_autodiscovery_level()
+	 * @access private
+	 */
+	var $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
+
+	/**
+	 * @var string Class used for caching feeds
+	 * @see SimplePie::set_cache_class()
+	 * @access private
+	 */
+	var $cache_class = 'SimplePie_Cache';
+
+	/**
+	 * @var string Class used for locating feeds
+	 * @see SimplePie::set_locator_class()
+	 * @access private
+	 */
+	var $locator_class = 'SimplePie_Locator';
+
+	/**
+	 * @var string Class used for parsing feeds
+	 * @see SimplePie::set_parser_class()
+	 * @access private
+	 */
+	var $parser_class = 'SimplePie_Parser';
+
+	/**
+	 * @var string Class used for fetching feeds
+	 * @see SimplePie::set_file_class()
+	 * @access private
+	 */
+	var $file_class = 'SimplePie_File';
+
+	/**
+	 * @var string Class used for items
+	 * @see SimplePie::set_item_class()
+	 * @access private
+	 */
+	var $item_class = 'SimplePie_Item';
+
+	/**
+	 * @var string Class used for authors
+	 * @see SimplePie::set_author_class()
+	 * @access private
+	 */
+	var $author_class = 'SimplePie_Author';
+
+	/**
+	 * @var string Class used for categories
+	 * @see SimplePie::set_category_class()
+	 * @access private
+	 */
+	var $category_class = 'SimplePie_Category';
+
+	/**
+	 * @var string Class used for enclosures
+	 * @see SimplePie::set_enclosures_class()
+	 * @access private
+	 */
+	var $enclosure_class = 'SimplePie_Enclosure';
+
+	/**
+	 * @var string Class used for Media RSS <media:text> captions
+	 * @see SimplePie::set_caption_class()
+	 * @access private
+	 */
+	var $caption_class = 'SimplePie_Caption';
+
+	/**
+	 * @var string Class used for Media RSS <media:copyright>
+	 * @see SimplePie::set_copyright_class()
+	 * @access private
+	 */
+	var $copyright_class = 'SimplePie_Copyright';
+
+	/**
+	 * @var string Class used for Media RSS <media:credit>
+	 * @see SimplePie::set_credit_class()
+	 * @access private
+	 */
+	var $credit_class = 'SimplePie_Credit';
+
+	/**
+	 * @var string Class used for Media RSS <media:rating>
+	 * @see SimplePie::set_rating_class()
+	 * @access private
+	 */
+	var $rating_class = 'SimplePie_Rating';
+
+	/**
+	 * @var string Class used for Media RSS <media:restriction>
+	 * @see SimplePie::set_restriction_class()
+	 * @access private
+	 */
+	var $restriction_class = 'SimplePie_Restriction';
+
+	/**
+	 * @var string Class used for content-type sniffing
+	 * @see SimplePie::set_content_type_sniffer_class()
+	 * @access private
+	 */
+	var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
+
+	/**
+	 * @var string Class used for item sources.
+	 * @see SimplePie::set_source_class()
+	 * @access private
+	 */
+	var $source_class = 'SimplePie_Source';
+
+	/**
+	 * @var mixed Set javascript query string parameter (false, or
+	 * anything type-cast to false, disables this feature)
+	 * @see SimplePie::set_javascript()
+	 * @access private
+	 */
+	var $javascript = 'js';
+
+	/**
+	 * @var int Maximum number of feeds to check with autodiscovery
+	 * @see SimplePie::set_max_checked_feeds()
+	 * @access private
+	 */
+	var $max_checked_feeds = 10;
+
+	/**
+	 * @var array All the feeds found during the autodiscovery process
+	 * @see SimplePie::get_all_discovered_feeds()
+	 * @access private
+	 */
+	var $all_discovered_feeds = array();
+
+	/**
+	 * @var string Web-accessible path to the handler_favicon.php file.
+	 * @see SimplePie::set_favicon_handler()
+	 * @access private
+	 */
+	var $favicon_handler = '';
+
+	/**
+	 * @var string Web-accessible path to the handler_image.php file.
+	 * @see SimplePie::set_image_handler()
+	 * @access private
+	 */
+	var $image_handler = '';
+
+	/**
+	 * @var array Stores the URLs when multiple feeds are being initialized.
+	 * @see SimplePie::set_feed_url()
+	 * @access private
+	 */
+	var $multifeed_url = array();
+
+	/**
+	 * @var array Stores SimplePie objects when multiple feeds initialized.
+	 * @access private
+	 */
+	var $multifeed_objects = array();
+
+	/**
+	 * @var array Stores the get_object_vars() array for use with multifeeds.
+	 * @see SimplePie::set_feed_url()
+	 * @access private
+	 */
+	var $config_settings = null;
+
+	/**
+	 * @var integer Stores the number of items to return per-feed with multifeeds.
+	 * @see SimplePie::set_item_limit()
+	 * @access private
+	 */
+	var $item_limit = 0;
+
+	/**
+	 * @var array Stores the default attributes to be stripped by strip_attributes().
+	 * @see SimplePie::strip_attributes()
+	 * @access private
+	 */
+	var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
+
+	/**
+	 * @var array Stores the default tags to be stripped by strip_htmltags().
+	 * @see SimplePie::strip_htmltags()
+	 * @access private
+	 */
+	var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
+
+	/**
+	 * The SimplePie class contains feed level data and options
+	 *
+	 * There are two ways that you can create a new SimplePie object. The first
+	 * is by passing a feed URL as a parameter to the SimplePie constructor
+	 * (as well as optionally setting the cache location and cache expiry). This
+	 * will initialise the whole feed with all of the default settings, and you
+	 * can begin accessing methods and properties immediately.
+	 *
+	 * The second way is to create the SimplePie object with no parameters
+	 * at all. This will enable you to set configuration options. After setting
+	 * them, you must initialise the feed using $feed->init(). At that point the
+	 * object's methods and properties will be available to you. This format is
+	 * what is used throughout this documentation.
+	 *
+	 * @access public
+	 * @since 1.0 Preview Release
+	 * @param string $feed_url This is the URL you want to parse.
+	 * @param string $cache_location This is where you want the cache to be stored.
+	 * @param int $cache_duration This is the number of seconds that you want to store the cache file for.
+	 */
+	function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null)
+	{
+		// Other objects, instances created here so we can set options on them
+		$this->sanitize =& new SimplePie_Sanitize;
+
+		// Set options if they're passed to the constructor
+		if ($cache_location !== null)
+		{
+			$this->set_cache_location($cache_location);
+		}
+
+		if ($cache_duration !== null)
+		{
+			$this->set_cache_duration($cache_duration);
+		}
+
+		// Only init the script if we're passed a feed URL
+		if ($feed_url !== null)
+		{
+			$this->set_feed_url($feed_url);
+			$this->init();
+		}
+	}
+
+	/**
+	 * Used for converting object to a string
+	 */
+	function __toString()
+	{
+		return md5(serialize($this->data));
+	}
+
+	/**
+	 * Remove items that link back to this before destroying this object
+	 */
+	function __destruct()
+	{
+		if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
+		{
+			if (!empty($this->data['items']))
+			{
+				foreach ($this->data['items'] as $item)
+				{
+					$item->__destruct();
+				}
+				unset($item, $this->data['items']);
+			}
+			if (!empty($this->data['ordered_items']))
+			{
+				foreach ($this->data['ordered_items'] as $item)
+				{
+					$item->__destruct();
+				}
+				unset($item, $this->data['ordered_items']);
+			}
+		}
+	}
+
+	/**
+	 * Force the given data/URL to be treated as a feed no matter what it
+	 * appears like
+	 *
+	 * @access public
+	 * @since 1.1
+	 * @param bool $enable Force the given data/URL to be treated as a feed
+	 */
+	function force_feed($enable = false)
+	{
+		$this->force_feed = (bool) $enable;
+	}
+
+	/**
+	 * This is the URL of the feed you want to parse.
+	 *
+	 * This allows you to enter the URL of the feed you want to parse, or the
+	 * website you want to try to use auto-discovery on. This takes priority
+	 * over any set raw data.
+	 *
+	 * You can set multiple feeds to mash together by passing an array instead
+	 * of a string for the $url. Remember that with each additional feed comes
+	 * additional processing and resources.
+	 *
+	 * @access public
+	 * @since 1.0 Preview Release
+	 * @param mixed $url This is the URL (or array of URLs) that you want to parse.
+	 * @see SimplePie::set_raw_data()
+	 */
+	function set_feed_url($url)
+	{
+		if (is_array($url))
+		{
+			$this->multifeed_url = array();
+			foreach ($url as $value)
+			{
+				$this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1);
+			}
+		}
+		else
+		{
+			$this->feed_url = SimplePie_Misc::fix_protocol($url, 1);
+		}
+	}
+
+	/**
+	 * Provides an instance of SimplePie_File to use as a feed
+	 *
+	 * @access public
+	 * @param object &$file Instance of SimplePie_File (or subclass)
+	 * @return bool True on success, false on failure
+	 */
+	function set_file(&$file)
+	{
+		if (is_a($file, 'SimplePie_File'))
+		{
+			$this->feed_url = $file->url;
+			$this->file =& $file;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to use a string of RSS/Atom data instead of a remote feed.
+	 *
+	 * If you have a feed available as a string in PHP, you can tell SimplePie
+	 * to parse that data string instead of a remote feed. Any set feed URL
+	 * takes precedence.
+	 *
+	 * @access public
+	 * @since 1.0 Beta 3
+	 * @param string $data RSS or Atom data as a string.
+	 * @see SimplePie::set_feed_url()
+	 */
+	function set_raw_data($data)
+	{
+		$this->raw_data = $data;
+	}
+
+	/**
+	 * Allows you to override the default timeout for fetching remote feeds.
+	 *
+	 * This allows you to change the maximum time the feed's server to respond
+	 * and send the feed back.
+	 *
+	 * @access public
+	 * @since 1.0 Beta 3
+	 * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
+	 */
+	function set_timeout($timeout = 10)
+	{
+		$this->timeout = (int) $timeout;
+	}
+
+	/**
+	 * Forces SimplePie to use fsockopen() instead of the preferred cURL
+	 * functions.
+	 *
+	 * @access public
+	 * @since 1.0 Beta 3
+	 * @param bool $enable Force fsockopen() to be used
+	 */
+	function force_fsockopen($enable = false)
+	{
+		$this->force_fsockopen = (bool) $enable;
+	}
+
+	/**
+	 * Outputs the raw XML content of the feed, after it has gone through
+	 * SimplePie's filters.
+	 *
+	 * Used only for debugging, this function will output the XML content as
+	 * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up
+	 * before trying to parse it. Many parts of the feed are re-written in
+	 * memory, and in the end, you have a parsable feed. XML dump shows you the
+	 * actual XML that SimplePie tries to parse, which may or may not be very
+	 * different from the original feed.
+	 *
+	 * @access public
+	 * @since 1.0 Preview Release
+	 * @param bool $enable Enable XML dump
+	 */
+	function enable_xml_dump($enable = false)
+	{
+		$this->xml_dump = (bool) $enable;
+	}
+
+	/**
+	 * Enables/disables caching in SimplePie.
+	 *
+	 * This option allows you to disable caching all-together in SimplePie.
+	 * However, disabling the cache can lead to longer load times.
+	 *
+	 * @access public
+	 * @since 1.0 Preview Release
+	 * @param bool $enable Enable caching
+	 */
+	function enable_cache($enable = true)
+	{
+		$this->cache = (bool) $enable;
+	}
+
+	/**
+	 * Set the length of time (in seconds) that the contents of a feed
+	 * will be cached.
+	 *
+	 * @access public
+	 * @param int $seconds The feed content cache duration.
+	 */
+	function set_cache_duration($seconds = 3600)
+	{
+		$this->cache_duration = (int) $seconds;
+	}
+
+	/**
+	 * Set the length of time (in seconds) that the autodiscovered feed
+	 * URL will be cached.
+	 *
+	 * @access public
+	 * @param int $seconds The autodiscovered feed URL cache duration.
+	 */
+	function set_autodiscovery_cache_duration($seconds = 604800)
+	{
+		$this->autodiscovery_cache_duration = (int) $seconds;
+	}
+
+	/**
+	 * Set the file system location where the cached files should be stored.
+	 *
+	 * @access public
+	 * @param string $location The file system location.
+	 */
+	function set_cache_location($location = './cache')
+	{
+		$this->cache_location = (string) $location;
+	}
+
+	/**
+	 * Determines whether feed items should be sorted into reverse chronological order.
+	 *
+	 * @access public
+	 * @param bool $enable Sort as reverse chronological order.
+	 */
+	function enable_order_by_date($enable = true)
+	{
+		$this->order_by_date = (bool) $enable;
+	}
+
+	/**
+	 * Allows you to override the character encoding reported by the feed.
+	 *
+	 * @access public
+	 * @param string $encoding Character encoding.
+	 */
+	function set_input_encoding($encoding = false)
+	{
+		if ($encoding)
+		{
+			$this->input_encoding = (string) $encoding;
+		}
+		else
+		{
+			$this->input_encoding = false;
+		}
+	}
+
+	/**
+	 * Set how much feed autodiscovery to do
+	 *
+	 * @access public
+	 * @see SIMPLEPIE_LOCATOR_NONE
+	 * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY
+	 * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION
+	 * @see SIMPLEPIE_LOCATOR_LOCAL_BODY
+	 * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION
+	 * @see SIMPLEPIE_LOCATOR_REMOTE_BODY
+	 * @see SIMPLEPIE_LOCATOR_ALL
+	 * @param int $level Feed Autodiscovery Level (level can be a
+	 * combination of the above constants, see bitwise OR operator)
+	 */
+	function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL)
+	{
+		$this->autodiscovery = (int) $level;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for caching.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_cache_class($class = 'SimplePie_Cache')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache'))
+		{
+			$this->cache_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for auto-discovery.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_locator_class($class = 'SimplePie_Locator')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator'))
+		{
+			$this->locator_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for XML parsing.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_parser_class($class = 'SimplePie_Parser')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser'))
+		{
+			$this->parser_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for remote file fetching.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_file_class($class = 'SimplePie_File')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File'))
+		{
+			$this->file_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for data sanitization.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_sanitize_class($class = 'SimplePie_Sanitize')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize'))
+		{
+			$this->sanitize =& new $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for handling feed items.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_item_class($class = 'SimplePie_Item')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item'))
+		{
+			$this->item_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for handling author data.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_author_class($class = 'SimplePie_Author')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author'))
+		{
+			$this->author_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for handling category data.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_category_class($class = 'SimplePie_Category')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category'))
+		{
+			$this->category_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for feed enclosures.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_enclosure_class($class = 'SimplePie_Enclosure')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure'))
+		{
+			$this->enclosure_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for <media:text> captions
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_caption_class($class = 'SimplePie_Caption')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption'))
+		{
+			$this->caption_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for <media:copyright>
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_copyright_class($class = 'SimplePie_Copyright')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright'))
+		{
+			$this->copyright_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for <media:credit>
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_credit_class($class = 'SimplePie_Credit')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit'))
+		{
+			$this->credit_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for <media:rating>
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_rating_class($class = 'SimplePie_Rating')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating'))
+		{
+			$this->rating_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for <media:restriction>
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_restriction_class($class = 'SimplePie_Restriction')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction'))
+		{
+			$this->restriction_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses for content-type sniffing.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer'))
+		{
+			$this->content_type_sniffer_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to change which class SimplePie uses item sources.
+	 * Useful when you are overloading or extending SimplePie's default classes.
+	 *
+	 * @access public
+	 * @param string $class Name of custom class.
+	 * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation
+	 * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation
+	 */
+	function set_source_class($class = 'SimplePie_Source')
+	{
+		if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source'))
+		{
+			$this->source_class = $class;
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * Allows you to override the default user agent string.
+	 *
+	 * @access public
+	 * @param string $ua New user agent string.
+	 */
+	function set_useragent($ua = SIMPLEPIE_USERAGENT)
+	{
+		$this->useragent = (string) $ua;
+	}
+
+	/**
+	 * Set callback function to create cache filename with
+	 *
+	 * @access public
+	 * @param mixed $function Callback function
+	 */
+	function set_cache_name_function($function = 'md5')
+	{
+		if (is_callable($function))
+		{
+			$this->cache_name_function = $function;
+		}
+	}
+
+	/**
+	 * Set javascript query string parameter
+	 *
+	 * @access public
+	 * @param mixed $get Javascript query string parameter
+	 */
+	function set_javascript($get = 'js')
+	{
+		if ($get)
+		{
+			$this->javascript = (string) $get;
+		}
+		else
+		{
+			$this->javascript = false;
+		}
+	}
+
+	/**
+	 * Set options to make SP as fast as possible.  Forgoes a
+	 * substantial amount of data sanitization in favor of speed.
+	 *
+	 * @access public
+	 * @param bool $set Whether to set them or not
+	 */
+	function set_stupidly_fast($set = false)
+	{
+		if ($set)
+		{
+			$this->enable_order_by_date(false);
+			$this->remove_div(false);
+			$this->strip_comments(false);
+			$this->strip_htmltags(false);
+			$this->strip_attributes(false);
+			$this->set_image_handler(false);
+		}
+	}
+
+	/**
+	 * Set maximum number of feeds to check with autodiscovery
+	 *
+	 * @access public
+	 * @param int $max Maximum number of feeds to check
+	 */
+	function set_max_checked_feeds($max = 10)
+	{
+		$this->max_checked_feeds = (int) $max;
+	}
+
+	function remove_div($enable = true)
+	{
+		$this->sanitize->remove_div($enable);
+	}
+
+	function strip_htmltags($tags = '', $encode = null)
+	{
+		if ($tags === '')
+		{
+			$tags = $this->strip_htmltags;
+		}
+		$this->sanitize->strip_htmltags($tags);
+		if ($encode !== null)
+		{
+			$this->sanitize->encode_instead_of_strip($tags);
+		}
+	}
+
+	function encode_instead_of_strip($enable = true)
+	{
+		$this->sanitize->encode_instead_of_strip($enable);
+	}
+
+	function strip_attributes($attribs = '')
+	{
+		if ($attribs === '')
+		{
+			$attribs = $this->strip_attributes;
+		}
+		$this->sanitize->strip_attributes($attribs);
+	}
+
+	function set_output_encoding($encoding = 'UTF-8')
+	{
+		$this->sanitize->set_output_encoding($encoding);
+	}
+
+	function strip_comments($strip = false)
+	{
+		$this->sanitize->strip_comments($strip);
+	}
+
+	/**
+	 * Set element/attribute key/value pairs of HTML attributes
+	 * containing URLs that need to be resolved relative to the feed
+	 *
+	 * @access public
+	 * @since 1.0
+	 * @param array $element_attribute Element/attribute key/value pairs
+	 */
+	function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
+	{
+		$this->sanitize->set_url_replacements($element_attribute);
+	}
+
+	/**
+	 * Set the handler to enable the display of cached favicons.
+	 *
+	 * @access public
+	 * @param str $page Web-accessible path to the handler_favicon.php file.
+	 * @param str $qs The query string that the value should be passed to.
+	 */
+	function set_favicon_handler($page = false, $qs = 'i')
+	{
+		if ($page !== false)
+		{
+			$this->favicon_handler = $page . '?' . $qs . '=';
+		}
+		else
+		{
+			$this->favicon_handler = '';
+		}
+	}
+
+	/**
+	 * Set the handler to enable the display of cached images.
+	 *
+	 * @access public
+	 * @param str $page Web-accessible path to the handler_image.php file.
+	 * @param str $qs The query string that the value should be passed to.
+	 */
+	function set_image_handler($page = false, $qs = 'i')
+	{
+		if ($page !== false)
+		{
+			$this->sanitize->set_image_handler($page . '?' . $qs . '=');
+		}
+		else
+		{
+			$this->image_handler = '';
+		}
+	}
+
+	/**
+	 * Set the limit for items returned per-feed with multifeeds.
+	 *
+	 * @access public
+	 * @param integer $limit The maximum number of items to return.
+	 */
+	function set_item_limit($limit = 0)
+	{
+		$this->item_limit = (int) $limit;
+	}
+
+	function init()
+	{
+		// Check absolute bare minimum requirements.
+		if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre'))
+		{
+			return false;
+		}
+		// Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader.
+		elseif (!extension_loaded('xmlreader'))
+		{
+			static $xml_is_sane = null;
+			if ($xml_is_sane === null)
+			{
+				$parser_check = xml_parser_create();
+				xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
+				xml_parser_free($parser_check);
+				$xml_is_sane = isset($values[0]['value']);
+			}
+			if (!$xml_is_sane)
+			{
+				return false;
+			}
+		}
+
+		if (isset($_GET[$this->javascript]))
+		{
+			SimplePie_Misc::output_javascript();
+			exit;
+		}
+
+		// Pass whatever was set with config options over to the sanitizer.
+		$this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class);
+		$this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen);
+
+		if ($this->feed_url !== null || $this->raw_data !== null)
+		{
+			$this->data = array();
+			$this->multifeed_objects = array();
+			$cache = false;
+
+			if ($this->feed_url !== null)
+			{
+				$parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url);
+				// Decide whether to enable caching
+				if ($this->cache && $parsed_feed_url['scheme'] !== '')
+				{
+					$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc');
+				}
+				// If it's enabled and we don't want an XML dump, use the cache
+				if ($cache && !$this->xml_dump)
+				{
+					// Load the Cache
+					$this->data = $cache->load();
+					if (!empty($this->data))
+					{
+						// If the cache is for an outdated build of SimplePie
+						if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD)
+						{
+							$cache->unlink();
+							$this->data = array();
+						}
+						// If we've hit a collision just rerun it with caching disabled
+						elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url)
+						{
+							$cache = false;
+							$this->data = array();
+						}
+						// If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL.
+						elseif (isset($this->data['feed_url']))
+						{
+							// If the autodiscovery cache is still valid use it.
+							if ($cache->mtime() + $this->autodiscovery_cache_duration > time())
+							{
+								// Do not need to do feed autodiscovery yet.
+								if ($this->data['feed_url'] === $this->data['url'])
+								{
+									$cache->unlink();
+									$this->data = array();
+								}
+								else
+								{
+									$this->set_feed_url($this->data['feed_url']);
+									return $this->init();
+								}
+							}
+						}
+						// Check if the cache has been updated
+						elseif ($cache->mtime() + $this->cache_duration < time())
+						{
+							// If we have last-modified and/or etag set
+							if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
+							{
+								$headers = array();
+								if (isset($this->data['headers']['last-modified']))
+								{
+									$headers['if-modified-since'] = $this->data['headers']['last-modified'];
+								}
+								if (isset($this->data['headers']['etag']))
+								{
+									$headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"';
+								}
+								$file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen);
+								if ($file->success)
+								{
+									if ($file->status_code === 304)
+									{
+										$cache->touch();
+										return true;
+									}
+									else
+									{
+										$headers = $file->headers;
+									}
+								}
+								else
+								{
+									unset($file);
+								}
+							}
+						}
+						// If the cache is still valid, just return true
+						else
+						{
+							return true;
+						}
+					}
+					// If the cache is empty, delete it
+					else
+					{
+						$cache->unlink();
+						$this->data = array();
+					}
+				}
+				// If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it.
+				if (!isset($file))
+				{
+					if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url)
+					{
+						$file =& $this->file;
+					}
+					else
+					{
+						$file =& new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen);
+					}
+				}
+				// If the file connection has an error, set SimplePie::error to that and quit
+				if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
+				{
+					$this->error = $file->error;
+					if (!empty($this->data))
+					{
+						return true;
+					}
+					else
+					{
+						return false;
+					}
+				}
+
+				if (!$this->force_feed)
+				{
+					// Check if the supplied URL is a feed, if it isn't, look for it.
+					$locate =& new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class);
+					if (!$locate->is_feed($file))
+					{
+						// We need to unset this so that if SimplePie::set_file() has been called that object is untouched
+						unset($file);
+						if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))
+						{
+							if ($cache)
+							{
+								$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
+								if (!$cache->save($this))
+								{
+									trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
+								}
+								$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc');
+							}
+							$this->feed_url = $file->url;
+						}
+						else
+						{
+							$this->error = "A feed could not be found at $this->feed_url";
+							SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
+							return false;
+						}
+					}
+					$locate = null;
+				}
+
+				$headers = $file->headers;
+				$data = $file->body;
+				$sniffer =& new $this->content_type_sniffer_class($file);
+				$sniffed = $sniffer->get_type();
+			}
+			else
+			{
+				$data = $this->raw_data;
+			}
+
+			// Set up array of possible encodings
+			$encodings = array();
+
+			// First check to see if input has been overridden.
+			if ($this->input_encoding !== false)
+			{
+				$encodings[] = $this->input_encoding;
+			}
+
+			$application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity');
+			$text_types = array('text/xml', 'text/xml-external-parsed-entity');
+
+			// RFC 3023 (only applies to sniffed content)
+			if (isset($sniffed))
+			{
+				if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml')
+				{
+					if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
+					{
+						$encodings[] = strtoupper($charset[1]);
+					}
+					$encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
+					$encodings[] = 'UTF-8';
+				}
+				elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
+				{
+					if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
+					{
+						$encodings[] = $charset[1];
+					}
+					$encodings[] = 'US-ASCII';
+				}
+				// Text MIME-type default
+				elseif (substr($sniffed, 0, 5) === 'text/')
+				{
+					$encodings[] = 'US-ASCII';
+				}
+			}
+
+			// Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1
+			$encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data));
+			$encodings[] = 'UTF-8';
+			$encodings[] = 'ISO-8859-1';
+
+			// There's no point in trying an encoding twice
+			$encodings = array_unique($encodings);
+
+			// If we want the XML, just output that with the most likely encoding and quit
+			if ($this->xml_dump)
+			{
+				header('Content-type: text/xml; charset=' . $encodings[0]);
+				echo $data;
+				exit;
+			}
+
+			// Loop through each possible encoding, till we return something, or run out of possibilities
+			foreach ($encodings as $encoding)
+			{
+				// Change the encoding to UTF-8 (as we always use UTF-8 internally)
+				if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'))
+				{
+					// Create new parser
+					$parser =& new $this->parser_class();
+
+					// If it's parsed fine
+					if ($parser->parse($utf8_data, 'UTF-8'))
+					{
+						$this->data = $parser->get_data();
+						if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE)
+						{
+							if (isset($headers))
+							{
+								$this->data['headers'] = $headers;
+							}
+							$this->data['build'] = SIMPLEPIE_BUILD;
+
+							// Cache the file if caching is enabled
+							if ($cache && !$cache->save($this))
+							{
+								trigger_error("$cache->name is not writeable", E_USER_WARNING);
+							}
+							return true;
+						}
+						else
+						{
+							$this->error = "A feed could not be found at $this->feed_url";
+							SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
+							return false;
+						}
+					}
+				}
+			}
+			if(isset($parser))
+			{
+				// We have an error, just set SimplePie_Misc::error to it and quit
+				$this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column());
+			}
+			else
+			{
+				$this->error = 'The data could not be converted to UTF-8';
+			}
+			SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__);
+			return false;
+		}
+		elseif (!empty($this->multifeed_url))
+		{
+			$i = 0;
+			$success = 0;
+			$this->multifeed_objects = array();
+			foreach ($this->multifeed_url as $url)
+			{
+				if (SIMPLEPIE_PHP5)
+				{
+					// This keyword needs to defy coding standards for PHP4 compatibility
+					$this->multifeed_objects[$i] = clone($this);
+				}
+				else
+				{
+					$this->multifeed_objects[$i] = $this;
+				}
+				$this->multifeed_objects[$i]->set_feed_url($url);
+				$success |= $this->multifeed_objects[$i]->init();
+				$i++;
+			}
+			return (bool) $success;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Return the error message for the occurred error
+	 *
+	 * @access public
+	 * @return string Error message
+	 */
+	function error()
+	{
+		return $this->error;
+	}
+
+	function get_encoding()
+	{
+		return $this->sanitize->output_encoding;
+	}
+
+	function handle_content_type($mime = 'text/html')
+	{
+		if (!headers_sent())
+		{
+			$header = "Content-type: $mime;";
+			if ($this->get_encoding())
+			{
+				$header .= ' charset=' . $this->get_encoding();
+			}
+			else
+			{
+				$header .= ' charset=UTF-8';
+			}
+			header($header);
+		}
+	}
+
+	function get_type()
+	{
+		if (!isset($this->data['type']))
+		{
+			$this->data['type'] = SIMPLEPIE_TYPE_ALL;
+			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed']))
+			{
+				$this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10;
+			}
+			elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed']))
+			{
+				$this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03;
+			}
+			elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF']))
+			{
+				if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel'])
+				|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image'])
+				|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])
+				|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput']))
+				{
+					$this->data['type'] &= SIMPLEPIE_TYPE_RSS_10;
+				}
+				if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel'])
+				|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image'])
+				|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])
+				|| isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput']))
+				{
+					$this->data['type'] &= SIMPLEPIE_TYPE_RSS_090;
+				}
+			}
+			elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss']))
+			{
+				$this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL;
+				if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
+				{
+					switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version']))
+					{
+						case '0.91':
+							$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091;
+							if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
+							{
+								switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data']))
+								{
+									case '0':
+										$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE;
+										break;
+
+									case '24':
+										$this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND;
+										break;
+								}
+							}
+							break;
+
+						case '0.92':
+							$this->data['type'] &= SIMPLEPIE_TYPE_RSS_092;
+							break;
+
+						case '0.93':
+							$this->data['type'] &= SIMPLEPIE_TYPE_RSS_093;
+							break;
+
+						case '0.94':
+							$this->data['type'] &= SIMPLEPIE_TYPE_RSS_094;
+							break;
+
+						case '2.0':
+							$this->data['type'] &= SIMPLEPIE_TYPE_RSS_20;
+							break;
+					}
+				}
+			}
+			else
+			{
+				$this->data['type'] = SIMPLEPIE_TYPE_NONE;
+			}
+		}
+		return $this->data['type'];
+	}
+
+	/**
+	 * Returns the URL for the favicon of the feed's website.
+	 *
+	 * @todo Cache atom:icon
+	 * @access public
+	 * @since 1.0
+	 */
+	function get_favicon()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url))
+		{
+			$favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
+
+			if ($this->cache && $this->favicon_handler)
+			{
+				$favicon_filename = call_user_func($this->cache_name_function, $favicon);
+				$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi');
+
+				if ($cache->load())
+				{
+					return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
+				}
+				else
+				{
+					$file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
+
+					if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0)
+					{
+						$sniffer =& new $this->content_type_sniffer_class($file);
+						if (substr($sniffer->get_type(), 0, 6) === 'image/')
+						{
+							if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
+							{
+								return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI);
+							}
+							else
+							{
+								trigger_error("$cache->name is not writeable", E_USER_WARNING);
+								return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
+							}
+						}
+						// not an image
+						else
+						{
+							return false;
+						}
+					}
+				}
+			}
+			else
+			{
+				return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI);
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * @todo If we have a perm redirect we should return the new URL
+	 * @todo When we make the above change, let's support <itunes:new-feed-url> as well
+	 * @todo Also, |atom:link|@rel=self
+	 */
+	function subscribe_url()
+	{
+		if ($this->feed_url !== null)
+		{
+			return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function subscribe_feed()
+	{
+		if ($this->feed_url !== null)
+		{
+			return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function subscribe_outlook()
+	{
+		if ($this->feed_url !== null)
+		{
+			return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function subscribe_podcast()
+	{
+		if ($this->feed_url !== null)
+		{
+			return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function subscribe_itunes()
+	{
+		if ($this->feed_url !== null)
+		{
+			return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * Creates the subscribe_* methods' return data
+	 *
+	 * @access private
+	 * @param string $feed_url String to prefix to the feed URL
+	 * @param string $site_url String to prefix to the site URL (and
+	 * suffix to the feed URL)
+	 * @return mixed URL if feed exists, false otherwise
+	 */
+	function subscribe_service($feed_url, $site_url = null)
+	{
+		if ($this->subscribe_url())
+		{
+			$return = $feed_url . rawurlencode($this->feed_url);
+			if ($site_url !== null && $this->get_link() !== null)
+			{
+				$return .= $site_url . rawurlencode($this->get_link());
+			}
+			return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function subscribe_aol()
+	{
+		return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url=');
+	}
+
+	function subscribe_bloglines()
+	{
+		return $this->subscribe_service('http://www.bloglines.com/sub/');
+	}
+
+	function subscribe_eskobo()
+	{
+		return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage=');
+	}
+
+	function subscribe_feedfeeds()
+	{
+		return $this->subscribe_service('http://www.feedfeeds.com/add?feed=');
+	}
+
+	function subscribe_feedster()
+	{
+		return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl=');
+	}
+
+	function subscribe_google()
+	{
+		return $this->subscribe_service('http://fusion.google.com/add?feedurl=');
+	}
+
+	function subscribe_gritwire()
+	{
+		return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl=');
+	}
+
+	function subscribe_msn()
+	{
+		return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru=');
+	}
+
+	function subscribe_netvibes()
+	{
+		return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url=');
+	}
+
+	function subscribe_newsburst()
+	{
+		return $this->subscribe_service('http://www.newsburst.com/Source/?add=');
+	}
+
+	function subscribe_newsgator()
+	{
+		return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url=');
+	}
+
+	function subscribe_odeo()
+	{
+		return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed=');
+	}
+
+	function subscribe_podnova()
+	{
+		return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url=');
+	}
+
+	function subscribe_rojo()
+	{
+		return $this->subscribe_service('http://www.rojo.com/add-subscription?resource=');
+	}
+
+	function subscribe_yahoo()
+	{
+		return $this->subscribe_service('http://add.my.yahoo.com/rss?url=');
+	}
+
+	function get_feed_tags($namespace, $tag)
+	{
+		$type = $this->get_type();
+		if ($type & SIMPLEPIE_TYPE_ATOM_10)
+		{
+			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
+			{
+				return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_ATOM_03)
+		{
+			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
+			{
+				return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_RSS_RDF)
+		{
+			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
+			{
+				return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
+		{
+			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
+			{
+				return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
+			}
+		}
+		return null;
+	}
+
+	function get_channel_tags($namespace, $tag)
+	{
+		$type = $this->get_type();
+		if ($type & SIMPLEPIE_TYPE_ATOM_ALL)
+		{
+			if ($return = $this->get_feed_tags($namespace, $tag))
+			{
+				return $return;
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_RSS_10)
+		{
+			if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel'))
+			{
+				if (isset($channel[0]['child'][$namespace][$tag]))
+				{
+					return $channel[0]['child'][$namespace][$tag];
+				}
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_RSS_090)
+		{
+			if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel'))
+			{
+				if (isset($channel[0]['child'][$namespace][$tag]))
+				{
+					return $channel[0]['child'][$namespace][$tag];
+				}
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
+		{
+			if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel'))
+			{
+				if (isset($channel[0]['child'][$namespace][$tag]))
+				{
+					return $channel[0]['child'][$namespace][$tag];
+				}
+			}
+		}
+		return null;
+	}
+
+	function get_image_tags($namespace, $tag)
+	{
+		$type = $this->get_type();
+		if ($type & SIMPLEPIE_TYPE_RSS_10)
+		{
+			if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image'))
+			{
+				if (isset($image[0]['child'][$namespace][$tag]))
+				{
+					return $image[0]['child'][$namespace][$tag];
+				}
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_RSS_090)
+		{
+			if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image'))
+			{
+				if (isset($image[0]['child'][$namespace][$tag]))
+				{
+					return $image[0]['child'][$namespace][$tag];
+				}
+			}
+		}
+		if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
+		{
+			if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image'))
+			{
+				if (isset($image[0]['child'][$namespace][$tag]))
+				{
+					return $image[0]['child'][$namespace][$tag];
+				}
+			}
+		}
+		return null;
+	}
+
+	function get_base($element = array())
+	{
+		if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
+		{
+			return $element['xml_base'];
+		}
+		elseif ($this->get_link() !== null)
+		{
+			return $this->get_link();
+		}
+		else
+		{
+			return $this->subscribe_url();
+		}
+	}
+
+	function sanitize($data, $type, $base = '')
+	{
+		return $this->sanitize->sanitize($data, $type, $base);
+	}
+
+	function get_title()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_category($key = 0)
+	{
+		$categories = $this->get_categories();
+		if (isset($categories[$key]))
+		{
+			return $categories[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_categories()
+	{
+		$categories = array();
+
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
+		{
+			$term = null;
+			$scheme = null;
+			$label = null;
+			if (isset($category['attribs']['']['term']))
+			{
+				$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($category['attribs']['']['scheme']))
+			{
+				$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($category['attribs']['']['label']))
+			{
+				$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			$categories[] =& new $this->category_class($term, $scheme, $label);
+		}
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
+		{
+			// This is really the label, but keep this as the term also for BC.
+			// Label will also work on retrieving because that falls back to term.
+			$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			if (isset($category['attribs']['']['domain']))
+			{
+				$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			else
+			{
+				$scheme = null;
+			}
+			$categories[] =& new $this->category_class($term, $scheme, null);
+		}
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
+		{
+			$categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
+		{
+			$categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+
+		if (!empty($categories))
+		{
+			return SimplePie_Misc::array_unique($categories);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_author($key = 0)
+	{
+		$authors = $this->get_authors();
+		if (isset($authors[$key]))
+		{
+			return $authors[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_authors()
+	{
+		$authors = array();
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
+		{
+			$name = null;
+			$uri = null;
+			$email = null;
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
+			{
+				$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
+			{
+				$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
+			}
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
+			{
+				$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $uri !== null)
+			{
+				$authors[] =& new $this->author_class($name, $uri, $email);
+			}
+		}
+		if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
+		{
+			$name = null;
+			$url = null;
+			$email = null;
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
+			{
+				$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
+			{
+				$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
+			}
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
+			{
+				$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $url !== null)
+			{
+				$authors[] =& new $this->author_class($name, $url, $email);
+			}
+		}
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
+		{
+			$authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
+		{
+			$authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
+		{
+			$authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+
+		if (!empty($authors))
+		{
+			return SimplePie_Misc::array_unique($authors);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_contributor($key = 0)
+	{
+		$contributors = $this->get_contributors();
+		if (isset($contributors[$key]))
+		{
+			return $contributors[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_contributors()
+	{
+		$contributors = array();
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
+		{
+			$name = null;
+			$uri = null;
+			$email = null;
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
+			{
+				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
+			{
+				$uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
+			{
+				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $uri !== null)
+			{
+				$contributors[] =& new $this->author_class($name, $uri, $email);
+			}
+		}
+		foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
+		{
+			$name = null;
+			$url = null;
+			$email = null;
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
+			{
+				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
+			{
+				$url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
+			{
+				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $url !== null)
+			{
+				$contributors[] =& new $this->author_class($name, $url, $email);
+			}
+		}
+
+		if (!empty($contributors))
+		{
+			return SimplePie_Misc::array_unique($contributors);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_link($key = 0, $rel = 'alternate')
+	{
+		$links = $this->get_links($rel);
+		if (isset($links[$key]))
+		{
+			return $links[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * Added for parity between the parent-level and the item/entry-level.
+	 */
+	function get_permalink()
+	{
+		return $this->get_link(0);
+	}
+
+	function get_links($rel = 'alternate')
+	{
+		if (!isset($this->data['links']))
+		{
+			$this->data['links'] = array();
+			if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
+			{
+				foreach ($links as $link)
+				{
+					if (isset($link['attribs']['']['href']))
+					{
+						$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
+						$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+					}
+				}
+			}
+			if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
+			{
+				foreach ($links as $link)
+				{
+					if (isset($link['attribs']['']['href']))
+					{
+						$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
+						$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+
+					}
+				}
+			}
+			if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+			if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+			if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+
+			$keys = array_keys($this->data['links']);
+			foreach ($keys as $key)
+			{
+				if (SimplePie_Misc::is_isegment_nz_nc($key))
+				{
+					if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
+					{
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
+						$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
+					}
+					else
+					{
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
+					}
+				}
+				elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
+				{
+					$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
+				}
+				$this->data['links'][$key] = array_unique($this->data['links'][$key]);
+			}
+		}
+
+		if (isset($this->data['links'][$rel]))
+		{
+			return $this->data['links'][$rel];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_all_discovered_feeds()
+	{
+		return $this->all_discovered_feeds;
+	}
+
+	function get_description()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_copyright()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_language()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang']))
+		{
+			return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang']))
+		{
+			return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang']))
+		{
+			return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif (isset($this->data['headers']['content-language']))
+		{
+			return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_latitude()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+		{
+			return (float) $match[1];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_longitude()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+		{
+			return (float) $match[2];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_image_title()
+	{
+		if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_image_url()
+	{
+		if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
+		{
+			return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_image_link()
+	{
+		if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_image_width()
+	{
+		if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width'))
+		{
+			return round($return[0]['data']);
+		}
+		elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
+		{
+			return 88.0;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_image_height()
+	{
+		if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height'))
+		{
+			return round($return[0]['data']);
+		}
+		elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
+		{
+			return 31.0;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_item_quantity($max = 0)
+	{
+		$max = (int) $max;
+		$qty = count($this->get_items());
+		if ($max === 0)
+		{
+			return $qty;
+		}
+		else
+		{
+			return ($qty > $max) ? $max : $qty;
+		}
+	}
+
+	function get_item($key = 0)
+	{
+		$items = $this->get_items();
+		if (isset($items[$key]))
+		{
+			return $items[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_items($start = 0, $end = 0)
+	{
+		if (!isset($this->data['items']))
+		{
+			if (!empty($this->multifeed_objects))
+			{
+				$this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
+			}
+			else
+			{
+				$this->data['items'] = array();
+				if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
+				{
+					$keys = array_keys($items);
+					foreach ($keys as $key)
+					{
+						$this->data['items'][] =& new $this->item_class($this, $items[$key]);
+					}
+				}
+				if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
+				{
+					$keys = array_keys($items);
+					foreach ($keys as $key)
+					{
+						$this->data['items'][] =& new $this->item_class($this, $items[$key]);
+					}
+				}
+				if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
+				{
+					$keys = array_keys($items);
+					foreach ($keys as $key)
+					{
+						$this->data['items'][] =& new $this->item_class($this, $items[$key]);
+					}
+				}
+				if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
+				{
+					$keys = array_keys($items);
+					foreach ($keys as $key)
+					{
+						$this->data['items'][] =& new $this->item_class($this, $items[$key]);
+					}
+				}
+				if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item'))
+				{
+					$keys = array_keys($items);
+					foreach ($keys as $key)
+					{
+						$this->data['items'][] =& new $this->item_class($this, $items[$key]);
+					}
+				}
+			}
+		}
+
+		if (!empty($this->data['items']))
+		{
+			// If we want to order it by date, check if all items have a date, and then sort it
+			if ($this->order_by_date && empty($this->multifeed_objects))
+			{
+				if (!isset($this->data['ordered_items']))
+				{
+					$do_sort = true;
+					foreach ($this->data['items'] as $item)
+					{
+						if (!$item->get_date('U'))
+						{
+							$do_sort = false;
+							break;
+						}
+					}
+					$item = null;
+					$this->data['ordered_items'] = $this->data['items'];
+					if ($do_sort)
+					{
+						usort($this->data['ordered_items'], array(&$this, 'sort_items'));
+					}
+				}
+				$items = $this->data['ordered_items'];
+			}
+			else
+			{
+				$items = $this->data['items'];
+			}
+
+			// Slice the data as desired
+			if ($end === 0)
+			{
+				return array_slice($items, $start);
+			}
+			else
+			{
+				return array_slice($items, $start, $end);
+			}
+		}
+		else
+		{
+			return array();
+		}
+	}
+
+	/**
+	 * @static
+	 */
+	function sort_items($a, $b)
+	{
+		return $a->get_date('U') <= $b->get_date('U');
+	}
+
+	/**
+	 * @static
+	 */
+	function merge_items($urls, $start = 0, $end = 0, $limit = 0)
+	{
+		if (is_array($urls) && sizeof($urls) > 0)
+		{
+			$items = array();
+			foreach ($urls as $arg)
+			{
+				if (is_a($arg, 'SimplePie'))
+				{
+					$items = array_merge($items, $arg->get_items(0, $limit));
+				}
+				else
+				{
+					trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
+				}
+			}
+
+			$do_sort = true;
+			foreach ($items as $item)
+			{
+				if (!$item->get_date('U'))
+				{
+					$do_sort = false;
+					break;
+				}
+			}
+			$item = null;
+			if ($do_sort)
+			{
+				usort($items, array('SimplePie', 'sort_items'));
+			}
+
+			if ($end === 0)
+			{
+				return array_slice($items, $start);
+			}
+			else
+			{
+				return array_slice($items, $start, $end);
+			}
+		}
+		else
+		{
+			trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
+			return array();
+		}
+	}
+}
+
+class SimplePie_Item
+{
+	var $feed;
+	var $data = array();
+
+	function SimplePie_Item($feed, $data)
+	{
+		$this->feed = $feed;
+		$this->data = $data;
+	}
+
+	function __toString()
+	{
+		return md5(serialize($this->data));
+	}
+
+	/**
+	 * Remove items that link back to this before destroying this object
+	 */
+	function __destruct()
+	{
+		if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
+		{
+			unset($this->feed);
+		}
+	}
+
+	function get_item_tags($namespace, $tag)
+	{
+		if (isset($this->data['child'][$namespace][$tag]))
+		{
+			return $this->data['child'][$namespace][$tag];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_base($element = array())
+	{
+		return $this->feed->get_base($element);
+	}
+
+	function sanitize($data, $type, $base = '')
+	{
+		return $this->feed->sanitize($data, $type, $base);
+	}
+
+	function get_feed()
+	{
+		return $this->feed;
+	}
+
+	function get_id($hash = false)
+	{
+		if (!$hash)
+		{
+			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
+			{
+				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
+			{
+				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
+			{
+				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
+			{
+				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
+			{
+				return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			elseif (($return = $this->get_permalink()) !== null)
+			{
+				return $return;
+			}
+			elseif (($return = $this->get_title()) !== null)
+			{
+				return $return;
+			}
+		}
+		if ($this->get_permalink() !== null || $this->get_title() !== null)
+		{
+			return md5($this->get_permalink() . $this->get_title());
+		}
+		else
+		{
+			return md5(serialize($this->data));
+		}
+	}
+
+	function get_title()
+	{
+		if (!isset($this->data['title']))
+		{
+			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
+			{
+				$this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
+			{
+				$this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
+			{
+				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
+			{
+				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
+			{
+				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
+			{
+				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
+			{
+				$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			else
+			{
+				$this->data['title'] = null;
+			}
+		}
+		return $this->data['title'];
+	}
+
+	function get_description($description_only = false)
+	{
+		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif (!$description_only)
+		{
+			return $this->get_content(true);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_content($content_only = false)
+	{
+		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		elseif (!$content_only)
+		{
+			return $this->get_description(true);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_category($key = 0)
+	{
+		$categories = $this->get_categories();
+		if (isset($categories[$key]))
+		{
+			return $categories[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_categories()
+	{
+		$categories = array();
+
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
+		{
+			$term = null;
+			$scheme = null;
+			$label = null;
+			if (isset($category['attribs']['']['term']))
+			{
+				$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($category['attribs']['']['scheme']))
+			{
+				$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($category['attribs']['']['label']))
+			{
+				$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			$categories[] =& new $this->feed->category_class($term, $scheme, $label);
+		}
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
+		{
+			// This is really the label, but keep this as the term also for BC.
+			// Label will also work on retrieving because that falls back to term.
+			$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			if (isset($category['attribs']['']['domain']))
+			{
+				$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			else
+			{
+				$scheme = null;
+			}
+			$categories[] =& new $this->feed->category_class($term, $scheme, null);
+		}
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
+		{
+			$categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
+		{
+			$categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+
+		if (!empty($categories))
+		{
+			return SimplePie_Misc::array_unique($categories);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_author($key = 0)
+	{
+		$authors = $this->get_authors();
+		if (isset($authors[$key]))
+		{
+			return $authors[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_contributor($key = 0)
+	{
+		$contributors = $this->get_contributors();
+		if (isset($contributors[$key]))
+		{
+			return $contributors[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_contributors()
+	{
+		$contributors = array();
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
+		{
+			$name = null;
+			$uri = null;
+			$email = null;
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
+			{
+				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
+			{
+				$uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
+			{
+				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $uri !== null)
+			{
+				$contributors[] =& new $this->feed->author_class($name, $uri, $email);
+			}
+		}
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
+		{
+			$name = null;
+			$url = null;
+			$email = null;
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
+			{
+				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
+			{
+				$url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
+			{
+				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $url !== null)
+			{
+				$contributors[] =& new $this->feed->author_class($name, $url, $email);
+			}
+		}
+
+		if (!empty($contributors))
+		{
+			return SimplePie_Misc::array_unique($contributors);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_authors()
+	{
+		$authors = array();
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
+		{
+			$name = null;
+			$uri = null;
+			$email = null;
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
+			{
+				$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
+			{
+				$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
+			}
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
+			{
+				$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $uri !== null)
+			{
+				$authors[] =& new $this->feed->author_class($name, $uri, $email);
+			}
+		}
+		if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
+		{
+			$name = null;
+			$url = null;
+			$email = null;
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
+			{
+				$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
+			{
+				$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
+			}
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
+			{
+				$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $url !== null)
+			{
+				$authors[] =& new $this->feed->author_class($name, $url, $email);
+			}
+		}
+		if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author'))
+		{
+			$authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+		}
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
+		{
+			$authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
+		{
+			$authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
+		{
+			$authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+
+		if (!empty($authors))
+		{
+			return SimplePie_Misc::array_unique($authors);
+		}
+		elseif (($source = $this->get_source()) && ($authors = $source->get_authors()))
+		{
+			return $authors;
+		}
+		elseif ($authors = $this->feed->get_authors())
+		{
+			return $authors;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_copyright()
+	{
+		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_date($date_format = 'j F Y, g:i a')
+	{
+		if (!isset($this->data['date']))
+		{
+			if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+			elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))
+			{
+				$this->data['date']['raw'] = $return[0]['data'];
+			}
+
+			if (!empty($this->data['date']['raw']))
+			{
+				$parser = SimplePie_Parse_Date::get();
+				$this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
+			}
+			else
+			{
+				$this->data['date'] = null;
+			}
+		}
+		if ($this->data['date'])
+		{
+			$date_format = (string) $date_format;
+			switch ($date_format)
+			{
+				case '':
+					return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
+
+				case 'U':
+					return $this->data['date']['parsed'];
+
+				default:
+					return date($date_format, $this->data['date']['parsed']);
+			}
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_local_date($date_format = '%c')
+	{
+		if (!$date_format)
+		{
+			return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif (($date = $this->get_date('U')) !== null)
+		{
+			return strftime($date_format, $date);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_permalink()
+	{
+		$link = $this->get_link();
+		$enclosure = $this->get_enclosure(0);
+		if ($link !== null)
+		{
+			return $link;
+		}
+		elseif ($enclosure !== null)
+		{
+			return $enclosure->get_link();
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_link($key = 0, $rel = 'alternate')
+	{
+		$links = $this->get_links($rel);
+		if ($links[$key] !== null)
+		{
+			return $links[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_links($rel = 'alternate')
+	{
+		if (!isset($this->data['links']))
+		{
+			$this->data['links'] = array();
+			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
+			{
+				if (isset($link['attribs']['']['href']))
+				{
+					$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
+					$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+
+				}
+			}
+			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
+			{
+				if (isset($link['attribs']['']['href']))
+				{
+					$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
+					$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+				}
+			}
+			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+			if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
+			{
+				if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true')
+				{
+					$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+				}
+			}
+
+			$keys = array_keys($this->data['links']);
+			foreach ($keys as $key)
+			{
+				if (SimplePie_Misc::is_isegment_nz_nc($key))
+				{
+					if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
+					{
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
+						$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
+					}
+					else
+					{
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
+					}
+				}
+				elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
+				{
+					$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
+				}
+				$this->data['links'][$key] = array_unique($this->data['links'][$key]);
+			}
+		}
+		if (isset($this->data['links'][$rel]))
+		{
+			return $this->data['links'][$rel];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * @todo Add ability to prefer one type of content over another (in a media group).
+	 */
+	function get_enclosure($key = 0, $prefer = null)
+	{
+		$enclosures = $this->get_enclosures();
+		if (isset($enclosures[$key]))
+		{
+			return $enclosures[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * Grabs all available enclosures (podcasts, etc.)
+	 *
+	 * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.
+	 *
+	 * At this point, we're pretty much assuming that all enclosures for an item are the same content.  Anything else is too complicated to properly support.
+	 *
+	 * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
+	 * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).
+	 */
+	function get_enclosures()
+	{
+		if (!isset($this->data['enclosures']))
+		{
+			$this->data['enclosures'] = array();
+
+			// Elements
+			$captions_parent = null;
+			$categories_parent = null;
+			$copyrights_parent = null;
+			$credits_parent = null;
+			$description_parent = null;
+			$duration_parent = null;
+			$hashes_parent = null;
+			$keywords_parent = null;
+			$player_parent = null;
+			$ratings_parent = null;
+			$restrictions_parent = null;
+			$thumbnails_parent = null;
+			$title_parent = null;
+
+			// Let's do the channel and item-level ones first, and just re-use them if we need to.
+			$parent = $this->get_feed();
+
+			// CAPTIONS
+			if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
+			{
+				foreach ($captions as $caption)
+				{
+					$caption_type = null;
+					$caption_lang = null;
+					$caption_startTime = null;
+					$caption_endTime = null;
+					$caption_text = null;
+					if (isset($caption['attribs']['']['type']))
+					{
+						$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['attribs']['']['lang']))
+					{
+						$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['attribs']['']['start']))
+					{
+						$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['attribs']['']['end']))
+					{
+						$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['data']))
+					{
+						$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
+				}
+			}
+			elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text'))
+			{
+				foreach ($captions as $caption)
+				{
+					$caption_type = null;
+					$caption_lang = null;
+					$caption_startTime = null;
+					$caption_endTime = null;
+					$caption_text = null;
+					if (isset($caption['attribs']['']['type']))
+					{
+						$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['attribs']['']['lang']))
+					{
+						$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['attribs']['']['start']))
+					{
+						$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['attribs']['']['end']))
+					{
+						$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($caption['data']))
+					{
+						$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
+				}
+			}
+			if (is_array($captions_parent))
+			{
+				$captions_parent = array_values(SimplePie_Misc::array_unique($captions_parent));
+			}
+
+			// CATEGORIES
+			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
+			{
+				$term = null;
+				$scheme = null;
+				$label = null;
+				if (isset($category['data']))
+				{
+					$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				if (isset($category['attribs']['']['scheme']))
+				{
+					$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				else
+				{
+					$scheme = 'http://search.yahoo.com/mrss/category_schema';
+				}
+				if (isset($category['attribs']['']['label']))
+				{
+					$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				$categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
+			}
+			foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category)
+			{
+				$term = null;
+				$scheme = null;
+				$label = null;
+				if (isset($category['data']))
+				{
+					$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				if (isset($category['attribs']['']['scheme']))
+				{
+					$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				else
+				{
+					$scheme = 'http://search.yahoo.com/mrss/category_schema';
+				}
+				if (isset($category['attribs']['']['label']))
+				{
+					$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				$categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
+			}
+			foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category)
+			{
+				$term = null;
+				$scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd';
+				$label = null;
+				if (isset($category['attribs']['']['text']))
+				{
+					$label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				$categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
+
+				if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category']))
+				{
+					foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory)
+					{
+						if (isset($subcategory['attribs']['']['text']))
+						{
+							$label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						$categories_parent[] =& new $this->feed->category_class($term, $scheme, $label);
+					}
+				}
+			}
+			if (is_array($categories_parent))
+			{
+				$categories_parent = array_values(SimplePie_Misc::array_unique($categories_parent));
+			}
+
+			// COPYRIGHT
+			if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
+			{
+				$copyright_url = null;
+				$copyright_label = null;
+				if (isset($copyright[0]['attribs']['']['url']))
+				{
+					$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				if (isset($copyright[0]['data']))
+				{
+					$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				$copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label);
+			}
+			elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright'))
+			{
+				$copyright_url = null;
+				$copyright_label = null;
+				if (isset($copyright[0]['attribs']['']['url']))
+				{
+					$copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				if (isset($copyright[0]['data']))
+				{
+					$copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+				$copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label);
+			}
+
+			// CREDITS
+			if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
+			{
+				foreach ($credits as $credit)
+				{
+					$credit_role = null;
+					$credit_scheme = null;
+					$credit_name = null;
+					if (isset($credit['attribs']['']['role']))
+					{
+						$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($credit['attribs']['']['scheme']))
+					{
+						$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					else
+					{
+						$credit_scheme = 'urn:ebu';
+					}
+					if (isset($credit['data']))
+					{
+						$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
+				}
+			}
+			elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit'))
+			{
+				foreach ($credits as $credit)
+				{
+					$credit_role = null;
+					$credit_scheme = null;
+					$credit_name = null;
+					if (isset($credit['attribs']['']['role']))
+					{
+						$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($credit['attribs']['']['scheme']))
+					{
+						$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					else
+					{
+						$credit_scheme = 'urn:ebu';
+					}
+					if (isset($credit['data']))
+					{
+						$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
+				}
+			}
+			if (is_array($credits_parent))
+			{
+				$credits_parent = array_values(SimplePie_Misc::array_unique($credits_parent));
+			}
+
+			// DESCRIPTION
+			if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
+			{
+				if (isset($description_parent[0]['data']))
+				{
+					$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+			}
+			elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description'))
+			{
+				if (isset($description_parent[0]['data']))
+				{
+					$description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+			}
+
+			// DURATION
+			if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration'))
+			{
+				$seconds = null;
+				$minutes = null;
+				$hours = null;
+				if (isset($duration_parent[0]['data']))
+				{
+					$temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+					if (sizeof($temp) > 0)
+					{
+						$seconds = (int) array_pop($temp);
+					}
+					if (sizeof($temp) > 0)
+					{
+						$minutes = (int) array_pop($temp);
+						$seconds += $minutes * 60;
+					}
+					if (sizeof($temp) > 0)
+					{
+						$hours = (int) array_pop($temp);
+						$seconds += $hours * 3600;
+					}
+					unset($temp);
+					$duration_parent = $seconds;
+				}
+			}
+
+			// HASHES
+			if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
+			{
+				foreach ($hashes_iterator as $hash)
+				{
+					$value = null;
+					$algo = null;
+					if (isset($hash['data']))
+					{
+						$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($hash['attribs']['']['algo']))
+					{
+						$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					else
+					{
+						$algo = 'md5';
+					}
+					$hashes_parent[] = $algo.':'.$value;
+				}
+			}
+			elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash'))
+			{
+				foreach ($hashes_iterator as $hash)
+				{
+					$value = null;
+					$algo = null;
+					if (isset($hash['data']))
+					{
+						$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($hash['attribs']['']['algo']))
+					{
+						$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					else
+					{
+						$algo = 'md5';
+					}
+					$hashes_parent[] = $algo.':'.$value;
+				}
+			}
+			if (is_array($hashes_parent))
+			{
+				$hashes_parent = array_values(SimplePie_Misc::array_unique($hashes_parent));
+			}
+
+			// KEYWORDS
+			if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
+			{
+				if (isset($keywords[0]['data']))
+				{
+					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+					foreach ($temp as $word)
+					{
+						$keywords_parent[] = trim($word);
+					}
+				}
+				unset($temp);
+			}
+			elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
+			{
+				if (isset($keywords[0]['data']))
+				{
+					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+					foreach ($temp as $word)
+					{
+						$keywords_parent[] = trim($word);
+					}
+				}
+				unset($temp);
+			}
+			elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords'))
+			{
+				if (isset($keywords[0]['data']))
+				{
+					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+					foreach ($temp as $word)
+					{
+						$keywords_parent[] = trim($word);
+					}
+				}
+				unset($temp);
+			}
+			elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords'))
+			{
+				if (isset($keywords[0]['data']))
+				{
+					$temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+					foreach ($temp as $word)
+					{
+						$keywords_parent[] = trim($word);
+					}
+				}
+				unset($temp);
+			}
+			if (is_array($keywords_parent))
+			{
+				$keywords_parent = array_values(SimplePie_Misc::array_unique($keywords_parent));
+			}
+
+			// PLAYER
+			if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
+			{
+				if (isset($player_parent[0]['attribs']['']['url']))
+				{
+					$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+				}
+			}
+			elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player'))
+			{
+				if (isset($player_parent[0]['attribs']['']['url']))
+				{
+					$player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+				}
+			}
+
+			// RATINGS
+			if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
+			{
+				foreach ($ratings as $rating)
+				{
+					$rating_scheme = null;
+					$rating_value = null;
+					if (isset($rating['attribs']['']['scheme']))
+					{
+						$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					else
+					{
+						$rating_scheme = 'urn:simple';
+					}
+					if (isset($rating['data']))
+					{
+						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
+				}
+			}
+			elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
+			{
+				foreach ($ratings as $rating)
+				{
+					$rating_scheme = 'urn:itunes';
+					$rating_value = null;
+					if (isset($rating['data']))
+					{
+						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
+				}
+			}
+			elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating'))
+			{
+				foreach ($ratings as $rating)
+				{
+					$rating_scheme = null;
+					$rating_value = null;
+					if (isset($rating['attribs']['']['scheme']))
+					{
+						$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					else
+					{
+						$rating_scheme = 'urn:simple';
+					}
+					if (isset($rating['data']))
+					{
+						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
+				}
+			}
+			elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit'))
+			{
+				foreach ($ratings as $rating)
+				{
+					$rating_scheme = 'urn:itunes';
+					$rating_value = null;
+					if (isset($rating['data']))
+					{
+						$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
+				}
+			}
+			if (is_array($ratings_parent))
+			{
+				$ratings_parent = array_values(SimplePie_Misc::array_unique($ratings_parent));
+			}
+
+			// RESTRICTIONS
+			if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
+			{
+				foreach ($restrictions as $restriction)
+				{
+					$restriction_relationship = null;
+					$restriction_type = null;
+					$restriction_value = null;
+					if (isset($restriction['attribs']['']['relationship']))
+					{
+						$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($restriction['attribs']['']['type']))
+					{
+						$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($restriction['data']))
+					{
+						$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
+				}
+			}
+			elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
+			{
+				foreach ($restrictions as $restriction)
+				{
+					$restriction_relationship = 'allow';
+					$restriction_type = null;
+					$restriction_value = 'itunes';
+					if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
+					{
+						$restriction_relationship = 'deny';
+					}
+					$restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
+				}
+			}
+			elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction'))
+			{
+				foreach ($restrictions as $restriction)
+				{
+					$restriction_relationship = null;
+					$restriction_type = null;
+					$restriction_value = null;
+					if (isset($restriction['attribs']['']['relationship']))
+					{
+						$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($restriction['attribs']['']['type']))
+					{
+						$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($restriction['data']))
+					{
+						$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					$restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
+				}
+			}
+			elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block'))
+			{
+				foreach ($restrictions as $restriction)
+				{
+					$restriction_relationship = 'allow';
+					$restriction_type = null;
+					$restriction_value = 'itunes';
+					if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes')
+					{
+						$restriction_relationship = 'deny';
+					}
+					$restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
+				}
+			}
+			if (is_array($restrictions_parent))
+			{
+				$restrictions_parent = array_values(SimplePie_Misc::array_unique($restrictions_parent));
+			}
+
+			// THUMBNAILS
+			if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
+			{
+				foreach ($thumbnails as $thumbnail)
+				{
+					if (isset($thumbnail['attribs']['']['url']))
+					{
+						$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+					}
+				}
+			}
+			elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
+			{
+				foreach ($thumbnails as $thumbnail)
+				{
+					if (isset($thumbnail['attribs']['']['url']))
+					{
+						$thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+					}
+				}
+			}
+
+			// TITLES
+			if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
+			{
+				if (isset($title_parent[0]['data']))
+				{
+					$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+			}
+			elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title'))
+			{
+				if (isset($title_parent[0]['data']))
+				{
+					$title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+				}
+			}
+
+			// Clear the memory
+			unset($parent);
+
+			// Attributes
+			$bitrate = null;
+			$channels = null;
+			$duration = null;
+			$expression = null;
+			$framerate = null;
+			$height = null;
+			$javascript = null;
+			$lang = null;
+			$length = null;
+			$medium = null;
+			$samplingrate = null;
+			$type = null;
+			$url = null;
+			$width = null;
+
+			// Elements
+			$captions = null;
+			$categories = null;
+			$copyrights = null;
+			$credits = null;
+			$description = null;
+			$hashes = null;
+			$keywords = null;
+			$player = null;
+			$ratings = null;
+			$restrictions = null;
+			$thumbnails = null;
+			$title = null;
+
+			// If we have media:group tags, loop through them.
+			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group)
+			{
+				// If we have media:content tags, loop through them.
+				foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
+				{
+					if (isset($content['attribs']['']['url']))
+					{
+						// Attributes
+						$bitrate = null;
+						$channels = null;
+						$duration = null;
+						$expression = null;
+						$framerate = null;
+						$height = null;
+						$javascript = null;
+						$lang = null;
+						$length = null;
+						$medium = null;
+						$samplingrate = null;
+						$type = null;
+						$url = null;
+						$width = null;
+
+						// Elements
+						$captions = null;
+						$categories = null;
+						$copyrights = null;
+						$credits = null;
+						$description = null;
+						$hashes = null;
+						$keywords = null;
+						$player = null;
+						$ratings = null;
+						$restrictions = null;
+						$thumbnails = null;
+						$title = null;
+
+						// Start checking the attributes of media:content
+						if (isset($content['attribs']['']['bitrate']))
+						{
+							$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['channels']))
+						{
+							$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['duration']))
+						{
+							$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						else
+						{
+							$duration = $duration_parent;
+						}
+						if (isset($content['attribs']['']['expression']))
+						{
+							$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['framerate']))
+						{
+							$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['height']))
+						{
+							$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['lang']))
+						{
+							$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['fileSize']))
+						{
+							$length = ceil($content['attribs']['']['fileSize']);
+						}
+						if (isset($content['attribs']['']['medium']))
+						{
+							$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['samplingrate']))
+						{
+							$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['type']))
+						{
+							$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['width']))
+						{
+							$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+
+						// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
+
+						// CAPTIONS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
+							{
+								$caption_type = null;
+								$caption_lang = null;
+								$caption_startTime = null;
+								$caption_endTime = null;
+								$caption_text = null;
+								if (isset($caption['attribs']['']['type']))
+								{
+									$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['lang']))
+								{
+									$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['start']))
+								{
+									$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['end']))
+								{
+									$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['data']))
+								{
+									$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
+							}
+							if (is_array($captions))
+							{
+								$captions = array_values(SimplePie_Misc::array_unique($captions));
+							}
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
+						{
+							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
+							{
+								$caption_type = null;
+								$caption_lang = null;
+								$caption_startTime = null;
+								$caption_endTime = null;
+								$caption_text = null;
+								if (isset($caption['attribs']['']['type']))
+								{
+									$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['lang']))
+								{
+									$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['start']))
+								{
+									$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['end']))
+								{
+									$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['data']))
+								{
+									$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
+							}
+							if (is_array($captions))
+							{
+								$captions = array_values(SimplePie_Misc::array_unique($captions));
+							}
+						}
+						else
+						{
+							$captions = $captions_parent;
+						}
+
+						// CATEGORIES
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
+						{
+							foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
+							{
+								$term = null;
+								$scheme = null;
+								$label = null;
+								if (isset($category['data']))
+								{
+									$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($category['attribs']['']['scheme']))
+								{
+									$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$scheme = 'http://search.yahoo.com/mrss/category_schema';
+								}
+								if (isset($category['attribs']['']['label']))
+								{
+									$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$categories[] =& new $this->feed->category_class($term, $scheme, $label);
+							}
+						}
+						if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
+						{
+							foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
+							{
+								$term = null;
+								$scheme = null;
+								$label = null;
+								if (isset($category['data']))
+								{
+									$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($category['attribs']['']['scheme']))
+								{
+									$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$scheme = 'http://search.yahoo.com/mrss/category_schema';
+								}
+								if (isset($category['attribs']['']['label']))
+								{
+									$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$categories[] =& new $this->feed->category_class($term, $scheme, $label);
+							}
+						}
+						if (is_array($categories) && is_array($categories_parent))
+						{
+							$categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
+						}
+						elseif (is_array($categories))
+						{
+							$categories = array_values(SimplePie_Misc::array_unique($categories));
+						}
+						elseif (is_array($categories_parent))
+						{
+							$categories = array_values(SimplePie_Misc::array_unique($categories_parent));
+						}
+
+						// COPYRIGHTS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
+						{
+							$copyright_url = null;
+							$copyright_label = null;
+							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
+							{
+								$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+							}
+							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
+							{
+								$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+							}
+							$copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
+						{
+							$copyright_url = null;
+							$copyright_label = null;
+							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
+							{
+								$copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+							}
+							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
+							{
+								$copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+							}
+							$copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
+						}
+						else
+						{
+							$copyrights = $copyrights_parent;
+						}
+
+						// CREDITS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
+							{
+								$credit_role = null;
+								$credit_scheme = null;
+								$credit_name = null;
+								if (isset($credit['attribs']['']['role']))
+								{
+									$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($credit['attribs']['']['scheme']))
+								{
+									$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$credit_scheme = 'urn:ebu';
+								}
+								if (isset($credit['data']))
+								{
+									$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
+							}
+							if (is_array($credits))
+							{
+								$credits = array_values(SimplePie_Misc::array_unique($credits));
+							}
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+						{
+							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
+							{
+								$credit_role = null;
+								$credit_scheme = null;
+								$credit_name = null;
+								if (isset($credit['attribs']['']['role']))
+								{
+									$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($credit['attribs']['']['scheme']))
+								{
+									$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$credit_scheme = 'urn:ebu';
+								}
+								if (isset($credit['data']))
+								{
+									$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
+							}
+							if (is_array($credits))
+							{
+								$credits = array_values(SimplePie_Misc::array_unique($credits));
+							}
+						}
+						else
+						{
+							$credits = $credits_parent;
+						}
+
+						// DESCRIPTION
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
+						{
+							$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
+						{
+							$description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						else
+						{
+							$description = $description_parent;
+						}
+
+						// HASHES
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
+							{
+								$value = null;
+								$algo = null;
+								if (isset($hash['data']))
+								{
+									$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($hash['attribs']['']['algo']))
+								{
+									$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$algo = 'md5';
+								}
+								$hashes[] = $algo.':'.$value;
+							}
+							if (is_array($hashes))
+							{
+								$hashes = array_values(SimplePie_Misc::array_unique($hashes));
+							}
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
+						{
+							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
+							{
+								$value = null;
+								$algo = null;
+								if (isset($hash['data']))
+								{
+									$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($hash['attribs']['']['algo']))
+								{
+									$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$algo = 'md5';
+								}
+								$hashes[] = $algo.':'.$value;
+							}
+							if (is_array($hashes))
+							{
+								$hashes = array_values(SimplePie_Misc::array_unique($hashes));
+							}
+						}
+						else
+						{
+							$hashes = $hashes_parent;
+						}
+
+						// KEYWORDS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
+						{
+							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
+							{
+								$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+								foreach ($temp as $word)
+								{
+									$keywords[] = trim($word);
+								}
+								unset($temp);
+							}
+							if (is_array($keywords))
+							{
+								$keywords = array_values(SimplePie_Misc::array_unique($keywords));
+							}
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
+						{
+							if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
+							{
+								$temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+								foreach ($temp as $word)
+								{
+									$keywords[] = trim($word);
+								}
+								unset($temp);
+							}
+							if (is_array($keywords))
+							{
+								$keywords = array_values(SimplePie_Misc::array_unique($keywords));
+							}
+						}
+						else
+						{
+							$keywords = $keywords_parent;
+						}
+
+						// PLAYER
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
+						{
+							$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
+						{
+							$player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+						}
+						else
+						{
+							$player = $player_parent;
+						}
+
+						// RATINGS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
+							{
+								$rating_scheme = null;
+								$rating_value = null;
+								if (isset($rating['attribs']['']['scheme']))
+								{
+									$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$rating_scheme = 'urn:simple';
+								}
+								if (isset($rating['data']))
+								{
+									$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
+							}
+							if (is_array($ratings))
+							{
+								$ratings = array_values(SimplePie_Misc::array_unique($ratings));
+							}
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
+						{
+							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
+							{
+								$rating_scheme = null;
+								$rating_value = null;
+								if (isset($rating['attribs']['']['scheme']))
+								{
+									$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$rating_scheme = 'urn:simple';
+								}
+								if (isset($rating['data']))
+								{
+									$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
+							}
+							if (is_array($ratings))
+							{
+								$ratings = array_values(SimplePie_Misc::array_unique($ratings));
+							}
+						}
+						else
+						{
+							$ratings = $ratings_parent;
+						}
+
+						// RESTRICTIONS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
+							{
+								$restriction_relationship = null;
+								$restriction_type = null;
+								$restriction_value = null;
+								if (isset($restriction['attribs']['']['relationship']))
+								{
+									$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($restriction['attribs']['']['type']))
+								{
+									$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($restriction['data']))
+								{
+									$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
+							}
+							if (is_array($restrictions))
+							{
+								$restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
+							}
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
+						{
+							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
+							{
+								$restriction_relationship = null;
+								$restriction_type = null;
+								$restriction_value = null;
+								if (isset($restriction['attribs']['']['relationship']))
+								{
+									$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($restriction['attribs']['']['type']))
+								{
+									$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($restriction['data']))
+								{
+									$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
+							}
+							if (is_array($restrictions))
+							{
+								$restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
+							}
+						}
+						else
+						{
+							$restrictions = $restrictions_parent;
+						}
+
+						// THUMBNAILS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
+							{
+								$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+							}
+							if (is_array($thumbnails))
+							{
+								$thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
+							}
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
+						{
+							foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
+							{
+								$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+							}
+							if (is_array($thumbnails))
+							{
+								$thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
+							}
+						}
+						else
+						{
+							$thumbnails = $thumbnails_parent;
+						}
+
+						// TITLES
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
+						{
+							$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
+						{
+							$title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						else
+						{
+							$title = $title_parent;
+						}
+
+						$this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
+					}
+				}
+			}
+
+			// If we have standalone media:content tags, loop through them.
+			if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content']))
+			{
+				foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content)
+				{
+					if (isset($content['attribs']['']['url']))
+					{
+						// Attributes
+						$bitrate = null;
+						$channels = null;
+						$duration = null;
+						$expression = null;
+						$framerate = null;
+						$height = null;
+						$javascript = null;
+						$lang = null;
+						$length = null;
+						$medium = null;
+						$samplingrate = null;
+						$type = null;
+						$url = null;
+						$width = null;
+
+						// Elements
+						$captions = null;
+						$categories = null;
+						$copyrights = null;
+						$credits = null;
+						$description = null;
+						$hashes = null;
+						$keywords = null;
+						$player = null;
+						$ratings = null;
+						$restrictions = null;
+						$thumbnails = null;
+						$title = null;
+
+						// Start checking the attributes of media:content
+						if (isset($content['attribs']['']['bitrate']))
+						{
+							$bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['channels']))
+						{
+							$channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['duration']))
+						{
+							$duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						else
+						{
+							$duration = $duration_parent;
+						}
+						if (isset($content['attribs']['']['expression']))
+						{
+							$expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['framerate']))
+						{
+							$framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['height']))
+						{
+							$height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['lang']))
+						{
+							$lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['fileSize']))
+						{
+							$length = ceil($content['attribs']['']['fileSize']);
+						}
+						if (isset($content['attribs']['']['medium']))
+						{
+							$medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['samplingrate']))
+						{
+							$samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['type']))
+						{
+							$type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						if (isset($content['attribs']['']['width']))
+						{
+							$width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						$url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+
+						// Checking the other optional media: elements. Priority: media:content, media:group, item, channel
+
+						// CAPTIONS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption)
+							{
+								$caption_type = null;
+								$caption_lang = null;
+								$caption_startTime = null;
+								$caption_endTime = null;
+								$caption_text = null;
+								if (isset($caption['attribs']['']['type']))
+								{
+									$caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['lang']))
+								{
+									$caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['start']))
+								{
+									$caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['attribs']['']['end']))
+								{
+									$caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($caption['data']))
+								{
+									$caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text);
+							}
+							if (is_array($captions))
+							{
+								$captions = array_values(SimplePie_Misc::array_unique($captions));
+							}
+						}
+						else
+						{
+							$captions = $captions_parent;
+						}
+
+						// CATEGORIES
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category']))
+						{
+							foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category)
+							{
+								$term = null;
+								$scheme = null;
+								$label = null;
+								if (isset($category['data']))
+								{
+									$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($category['attribs']['']['scheme']))
+								{
+									$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$scheme = 'http://search.yahoo.com/mrss/category_schema';
+								}
+								if (isset($category['attribs']['']['label']))
+								{
+									$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$categories[] =& new $this->feed->category_class($term, $scheme, $label);
+							}
+						}
+						if (is_array($categories) && is_array($categories_parent))
+						{
+							$categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent)));
+						}
+						elseif (is_array($categories))
+						{
+							$categories = array_values(SimplePie_Misc::array_unique($categories));
+						}
+						elseif (is_array($categories_parent))
+						{
+							$categories = array_values(SimplePie_Misc::array_unique($categories_parent));
+						}
+						else
+						{
+							$categories = null;
+						}
+
+						// COPYRIGHTS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright']))
+						{
+							$copyright_url = null;
+							$copyright_label = null;
+							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url']))
+							{
+								$copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT);
+							}
+							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data']))
+							{
+								$copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+							}
+							$copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label);
+						}
+						else
+						{
+							$copyrights = $copyrights_parent;
+						}
+
+						// CREDITS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit)
+							{
+								$credit_role = null;
+								$credit_scheme = null;
+								$credit_name = null;
+								if (isset($credit['attribs']['']['role']))
+								{
+									$credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($credit['attribs']['']['scheme']))
+								{
+									$credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$credit_scheme = 'urn:ebu';
+								}
+								if (isset($credit['data']))
+								{
+									$credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name);
+							}
+							if (is_array($credits))
+							{
+								$credits = array_values(SimplePie_Misc::array_unique($credits));
+							}
+						}
+						else
+						{
+							$credits = $credits_parent;
+						}
+
+						// DESCRIPTION
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description']))
+						{
+							$description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						else
+						{
+							$description = $description_parent;
+						}
+
+						// HASHES
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash)
+							{
+								$value = null;
+								$algo = null;
+								if (isset($hash['data']))
+								{
+									$value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($hash['attribs']['']['algo']))
+								{
+									$algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$algo = 'md5';
+								}
+								$hashes[] = $algo.':'.$value;
+							}
+							if (is_array($hashes))
+							{
+								$hashes = array_values(SimplePie_Misc::array_unique($hashes));
+							}
+						}
+						else
+						{
+							$hashes = $hashes_parent;
+						}
+
+						// KEYWORDS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords']))
+						{
+							if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data']))
+							{
+								$temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT));
+								foreach ($temp as $word)
+								{
+									$keywords[] = trim($word);
+								}
+								unset($temp);
+							}
+							if (is_array($keywords))
+							{
+								$keywords = array_values(SimplePie_Misc::array_unique($keywords));
+							}
+						}
+						else
+						{
+							$keywords = $keywords_parent;
+						}
+
+						// PLAYER
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
+						{
+							$player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+						}
+						else
+						{
+							$player = $player_parent;
+						}
+
+						// RATINGS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating)
+							{
+								$rating_scheme = null;
+								$rating_value = null;
+								if (isset($rating['attribs']['']['scheme']))
+								{
+									$rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								else
+								{
+									$rating_scheme = 'urn:simple';
+								}
+								if (isset($rating['data']))
+								{
+									$rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value);
+							}
+							if (is_array($ratings))
+							{
+								$ratings = array_values(SimplePie_Misc::array_unique($ratings));
+							}
+						}
+						else
+						{
+							$ratings = $ratings_parent;
+						}
+
+						// RESTRICTIONS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction)
+							{
+								$restriction_relationship = null;
+								$restriction_type = null;
+								$restriction_value = null;
+								if (isset($restriction['attribs']['']['relationship']))
+								{
+									$restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($restriction['attribs']['']['type']))
+								{
+									$restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								if (isset($restriction['data']))
+								{
+									$restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+								}
+								$restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value);
+							}
+							if (is_array($restrictions))
+							{
+								$restrictions = array_values(SimplePie_Misc::array_unique($restrictions));
+							}
+						}
+						else
+						{
+							$restrictions = $restrictions_parent;
+						}
+
+						// THUMBNAILS
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail']))
+						{
+							foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
+							{
+								$thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI);
+							}
+							if (is_array($thumbnails))
+							{
+								$thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails));
+							}
+						}
+						else
+						{
+							$thumbnails = $thumbnails_parent;
+						}
+
+						// TITLES
+						if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title']))
+						{
+							$title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+						}
+						else
+						{
+							$title = $title_parent;
+						}
+
+						$this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width);
+					}
+				}
+			}
+
+			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link)
+			{
+				if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
+				{
+					// Attributes
+					$bitrate = null;
+					$channels = null;
+					$duration = null;
+					$expression = null;
+					$framerate = null;
+					$height = null;
+					$javascript = null;
+					$lang = null;
+					$length = null;
+					$medium = null;
+					$samplingrate = null;
+					$type = null;
+					$url = null;
+					$width = null;
+
+					$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+					if (isset($link['attribs']['']['type']))
+					{
+						$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($link['attribs']['']['length']))
+					{
+						$length = ceil($link['attribs']['']['length']);
+					}
+
+					// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
+					$this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
+				}
+			}
+
+			foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link)
+			{
+				if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure')
+				{
+					// Attributes
+					$bitrate = null;
+					$channels = null;
+					$duration = null;
+					$expression = null;
+					$framerate = null;
+					$height = null;
+					$javascript = null;
+					$lang = null;
+					$length = null;
+					$medium = null;
+					$samplingrate = null;
+					$type = null;
+					$url = null;
+					$width = null;
+
+					$url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+					if (isset($link['attribs']['']['type']))
+					{
+						$type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($link['attribs']['']['length']))
+					{
+						$length = ceil($link['attribs']['']['length']);
+					}
+
+					// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
+					$this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
+				}
+			}
+
+			if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure'))
+			{
+				if (isset($enclosure[0]['attribs']['']['url']))
+				{
+					// Attributes
+					$bitrate = null;
+					$channels = null;
+					$duration = null;
+					$expression = null;
+					$framerate = null;
+					$height = null;
+					$javascript = null;
+					$lang = null;
+					$length = null;
+					$medium = null;
+					$samplingrate = null;
+					$type = null;
+					$url = null;
+					$width = null;
+
+					$url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0]));
+					if (isset($enclosure[0]['attribs']['']['type']))
+					{
+						$type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT);
+					}
+					if (isset($enclosure[0]['attribs']['']['length']))
+					{
+						$length = ceil($enclosure[0]['attribs']['']['length']);
+					}
+
+					// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
+					$this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
+				}
+			}
+
+			if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width))
+			{
+				// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
+				$this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width);
+			}
+
+			$this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures']));
+		}
+		if (!empty($this->data['enclosures']))
+		{
+			return $this->data['enclosures'];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_latitude()
+	{
+		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+		{
+			return (float) $match[1];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_longitude()
+	{
+		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+		{
+			return (float) $match[2];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_source()
+	{
+		if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source'))
+		{
+			return new $this->feed->source_class($this, $return[0]);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * Creates the add_to_* methods' return data
+	 *
+	 * @access private
+	 * @param string $item_url String to prefix to the item permalink
+	 * @param string $title_url String to prefix to the item title
+	 * (and suffix to the item permalink)
+	 * @return mixed URL if feed exists, false otherwise
+	 */
+	function add_to_service($item_url, $title_url = null, $summary_url = null)
+	{
+		if ($this->get_permalink() !== null)
+		{
+			$return = $item_url . rawurlencode($this->get_permalink());
+			if ($title_url !== null && $this->get_title() !== null)
+			{
+				$return .= $title_url . rawurlencode($this->get_title());
+			}
+			if ($summary_url !== null && $this->get_description() !== null)
+			{
+				$return .= $summary_url . rawurlencode($this->get_description());
+			}
+			return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function add_to_blinklist()
+	{
+		return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=', '&Title=');
+	}
+
+	function add_to_blogmarks()
+	{
+		return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=', '&title=');
+	}
+
+	function add_to_delicious()
+	{
+		return $this->add_to_service('http://del.icio.us/post/?v=4&url=', '&title=');
+	}
+
+	function add_to_digg()
+	{
+		return $this->add_to_service('http://digg.com/submit?url=', '&title=', '&bodytext=');
+	}
+
+	function add_to_furl()
+	{
+		return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=', '&t=');
+	}
+
+	function add_to_magnolia()
+	{
+		return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=', '&title=');
+	}
+
+	function add_to_myweb20()
+	{
+		return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=', '&t=');
+	}
+
+	function add_to_newsvine()
+	{
+		return $this->add_to_service('http://www.newsvine.com/_wine/save?u=', '&h=');
+	}
+
+	function add_to_reddit()
+	{
+		return $this->add_to_service('http://reddit.com/submit?url=', '&title=');
+	}
+
+	function add_to_segnalo()
+	{
+		return $this->add_to_service('http://segnalo.com/post.html.php?url=', '&title=');
+	}
+
+	function add_to_simpy()
+	{
+		return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=', '&title=');
+	}
+
+	function add_to_spurl()
+	{
+		return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=', '&title=');
+	}
+
+	function add_to_wists()
+	{
+		return $this->add_to_service('http://wists.com/r.php?c=&r=', '&title=');
+	}
+
+	function search_technorati()
+	{
+		return $this->add_to_service('http://www.technorati.com/search/');
+	}
+}
+
+class SimplePie_Source
+{
+	var $item;
+	var $data = array();
+
+	function SimplePie_Source($item, $data)
+	{
+		$this->item = $item;
+		$this->data = $data;
+	}
+
+	function __toString()
+	{
+		return md5(serialize($this->data));
+	}
+
+	function get_source_tags($namespace, $tag)
+	{
+		if (isset($this->data['child'][$namespace][$tag]))
+		{
+			return $this->data['child'][$namespace][$tag];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_base($element = array())
+	{
+		return $this->item->get_base($element);
+	}
+
+	function sanitize($data, $type, $base = '')
+	{
+		return $this->item->sanitize($data, $type, $base);
+	}
+
+	function get_item()
+	{
+		return $this->item;
+	}
+
+	function get_title()
+	{
+		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_category($key = 0)
+	{
+		$categories = $this->get_categories();
+		if (isset($categories[$key]))
+		{
+			return $categories[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_categories()
+	{
+		$categories = array();
+
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category)
+		{
+			$term = null;
+			$scheme = null;
+			$label = null;
+			if (isset($category['attribs']['']['term']))
+			{
+				$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($category['attribs']['']['scheme']))
+			{
+				$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($category['attribs']['']['label']))
+			{
+				$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			$categories[] =& new $this->item->feed->category_class($term, $scheme, $label);
+		}
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)
+		{
+			// This is really the label, but keep this as the term also for BC.
+			// Label will also work on retrieving because that falls back to term.
+			$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			if (isset($category['attribs']['']['domain']))
+			{
+				$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			else
+			{
+				$scheme = null;
+			}
+			$categories[] =& new $this->item->feed->category_class($term, $scheme, null);
+		}
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category)
+		{
+			$categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category)
+		{
+			$categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+
+		if (!empty($categories))
+		{
+			return SimplePie_Misc::array_unique($categories);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_author($key = 0)
+	{
+		$authors = $this->get_authors();
+		if (isset($authors[$key]))
+		{
+			return $authors[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_authors()
+	{
+		$authors = array();
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author)
+		{
+			$name = null;
+			$uri = null;
+			$email = null;
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
+			{
+				$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
+			{
+				$uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
+			}
+			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
+			{
+				$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $uri !== null)
+			{
+				$authors[] =& new $this->item->feed->author_class($name, $uri, $email);
+			}
+		}
+		if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
+		{
+			$name = null;
+			$url = null;
+			$email = null;
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
+			{
+				$name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
+			{
+				$url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
+			}
+			if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
+			{
+				$email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $url !== null)
+			{
+				$authors[] =& new $this->item->feed->author_class($name, $url, $email);
+			}
+		}
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author)
+		{
+			$authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author)
+		{
+			$authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author)
+		{
+			$authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null);
+		}
+
+		if (!empty($authors))
+		{
+			return SimplePie_Misc::array_unique($authors);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_contributor($key = 0)
+	{
+		$contributors = $this->get_contributors();
+		if (isset($contributors[$key]))
+		{
+			return $contributors[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_contributors()
+	{
+		$contributors = array();
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor)
+		{
+			$name = null;
+			$uri = null;
+			$email = null;
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
+			{
+				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
+			{
+				$uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]));
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data']))
+			{
+				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $uri !== null)
+			{
+				$contributors[] =& new $this->item->feed->author_class($name, $uri, $email);
+			}
+		}
+		foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor)
+		{
+			$name = null;
+			$url = null;
+			$email = null;
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data']))
+			{
+				$name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data']))
+			{
+				$url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]));
+			}
+			if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data']))
+			{
+				$email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+			}
+			if ($name !== null || $email !== null || $url !== null)
+			{
+				$contributors[] =& new $this->item->feed->author_class($name, $url, $email);
+			}
+		}
+
+		if (!empty($contributors))
+		{
+			return SimplePie_Misc::array_unique($contributors);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_link($key = 0, $rel = 'alternate')
+	{
+		$links = $this->get_links($rel);
+		if (isset($links[$key]))
+		{
+			return $links[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * Added for parity between the parent-level and the item/entry-level.
+	 */
+	function get_permalink()
+	{
+		return $this->get_link(0);
+	}
+
+	function get_links($rel = 'alternate')
+	{
+		if (!isset($this->data['links']))
+		{
+			$this->data['links'] = array();
+			if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link'))
+			{
+				foreach ($links as $link)
+				{
+					if (isset($link['attribs']['']['href']))
+					{
+						$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
+						$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+					}
+				}
+			}
+			if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link'))
+			{
+				foreach ($links as $link)
+				{
+					if (isset($link['attribs']['']['href']))
+					{
+						$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
+						$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link));
+
+					}
+				}
+			}
+			if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+			if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+			if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link'))
+			{
+				$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0]));
+			}
+
+			$keys = array_keys($this->data['links']);
+			foreach ($keys as $key)
+			{
+				if (SimplePie_Misc::is_isegment_nz_nc($key))
+				{
+					if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]))
+					{
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]);
+						$this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key];
+					}
+					else
+					{
+						$this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key];
+					}
+				}
+				elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY)
+				{
+					$this->data['links'][substr($key, 41)] =& $this->data['links'][$key];
+				}
+				$this->data['links'][$key] = array_unique($this->data['links'][$key]);
+			}
+		}
+
+		if (isset($this->data['links'][$rel]))
+		{
+			return $this->data['links'][$rel];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_description()
+	{
+		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_copyright()
+	{
+		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright'))
+		{
+			return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_language()
+	{
+		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		elseif (isset($this->data['xml_lang']))
+		{
+			return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_latitude()
+	{
+		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+		{
+			return (float) $match[1];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_longitude()
+	{
+		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon'))
+		{
+			return (float) $return[0]['data'];
+		}
+		elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match))
+		{
+			return (float) $match[2];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_image_url()
+	{
+		if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
+		{
+			return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
+		{
+			return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
+		}
+		else
+		{
+			return null;
+		}
+	}
+}
+
+class SimplePie_Author
+{
+	var $name;
+	var $link;
+	var $email;
+
+	// Constructor, used to input the data
+	function SimplePie_Author($name = null, $link = null, $email = null)
+	{
+		$this->name = $name;
+		$this->link = $link;
+		$this->email = $email;
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_name()
+	{
+		if ($this->name !== null)
+		{
+			return $this->name;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_link()
+	{
+		if ($this->link !== null)
+		{
+			return $this->link;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_email()
+	{
+		if ($this->email !== null)
+		{
+			return $this->email;
+		}
+		else
+		{
+			return null;
+		}
+	}
+}
+
+class SimplePie_Category
+{
+	var $term;
+	var $scheme;
+	var $label;
+
+	// Constructor, used to input the data
+	function SimplePie_Category($term = null, $scheme = null, $label = null)
+	{
+		$this->term = $term;
+		$this->scheme = $scheme;
+		$this->label = $label;
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_term()
+	{
+		if ($this->term !== null)
+		{
+			return $this->term;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_scheme()
+	{
+		if ($this->scheme !== null)
+		{
+			return $this->scheme;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_label()
+	{
+		if ($this->label !== null)
+		{
+			return $this->label;
+		}
+		else
+		{
+			return $this->get_term();
+		}
+	}
+}
+
+class SimplePie_Enclosure
+{
+	var $bitrate;
+	var $captions;
+	var $categories;
+	var $channels;
+	var $copyright;
+	var $credits;
+	var $description;
+	var $duration;
+	var $expression;
+	var $framerate;
+	var $handler;
+	var $hashes;
+	var $height;
+	var $javascript;
+	var $keywords;
+	var $lang;
+	var $length;
+	var $link;
+	var $medium;
+	var $player;
+	var $ratings;
+	var $restrictions;
+	var $samplingrate;
+	var $thumbnails;
+	var $title;
+	var $type;
+	var $width;
+
+	// Constructor, used to input the data
+	function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)
+	{
+		$this->bitrate = $bitrate;
+		$this->captions = $captions;
+		$this->categories = $categories;
+		$this->channels = $channels;
+		$this->copyright = $copyright;
+		$this->credits = $credits;
+		$this->description = $description;
+		$this->duration = $duration;
+		$this->expression = $expression;
+		$this->framerate = $framerate;
+		$this->hashes = $hashes;
+		$this->height = $height;
+		$this->javascript = $javascript;
+		$this->keywords = $keywords;
+		$this->lang = $lang;
+		$this->length = $length;
+		$this->link = $link;
+		$this->medium = $medium;
+		$this->player = $player;
+		$this->ratings = $ratings;
+		$this->restrictions = $restrictions;
+		$this->samplingrate = $samplingrate;
+		$this->thumbnails = $thumbnails;
+		$this->title = $title;
+		$this->type = $type;
+		$this->width = $width;
+		if (class_exists('idna_convert'))
+		{
+			$idn =& new idna_convert;
+			$parsed = SimplePie_Misc::parse_url($link);
+			$this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
+		}
+		$this->handler = $this->get_handler(); // Needs to load last
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_bitrate()
+	{
+		if ($this->bitrate !== null)
+		{
+			return $this->bitrate;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_caption($key = 0)
+	{
+		$captions = $this->get_captions();
+		if (isset($captions[$key]))
+		{
+			return $captions[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_captions()
+	{
+		if ($this->captions !== null)
+		{
+			return $this->captions;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_category($key = 0)
+	{
+		$categories = $this->get_categories();
+		if (isset($categories[$key]))
+		{
+			return $categories[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_categories()
+	{
+		if ($this->categories !== null)
+		{
+			return $this->categories;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_channels()
+	{
+		if ($this->channels !== null)
+		{
+			return $this->channels;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_copyright()
+	{
+		if ($this->copyright !== null)
+		{
+			return $this->copyright;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_credit($key = 0)
+	{
+		$credits = $this->get_credits();
+		if (isset($credits[$key]))
+		{
+			return $credits[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_credits()
+	{
+		if ($this->credits !== null)
+		{
+			return $this->credits;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_description()
+	{
+		if ($this->description !== null)
+		{
+			return $this->description;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_duration($convert = false)
+	{
+		if ($this->duration !== null)
+		{
+			if ($convert)
+			{
+				$time = SimplePie_Misc::time_hms($this->duration);
+				return $time;
+			}
+			else
+			{
+				return $this->duration;
+			}
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_expression()
+	{
+		if ($this->expression !== null)
+		{
+			return $this->expression;
+		}
+		else
+		{
+			return 'full';
+		}
+	}
+
+	function get_extension()
+	{
+		if ($this->link !== null)
+		{
+			$url = SimplePie_Misc::parse_url($this->link);
+			if ($url['path'] !== '')
+			{
+				return pathinfo($url['path'], PATHINFO_EXTENSION);
+			}
+		}
+		return null;
+	}
+
+	function get_framerate()
+	{
+		if ($this->framerate !== null)
+		{
+			return $this->framerate;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_handler()
+	{
+		return $this->get_real_type(true);
+	}
+
+	function get_hash($key = 0)
+	{
+		$hashes = $this->get_hashes();
+		if (isset($hashes[$key]))
+		{
+			return $hashes[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_hashes()
+	{
+		if ($this->hashes !== null)
+		{
+			return $this->hashes;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_height()
+	{
+		if ($this->height !== null)
+		{
+			return $this->height;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_language()
+	{
+		if ($this->lang !== null)
+		{
+			return $this->lang;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_keyword($key = 0)
+	{
+		$keywords = $this->get_keywords();
+		if (isset($keywords[$key]))
+		{
+			return $keywords[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_keywords()
+	{
+		if ($this->keywords !== null)
+		{
+			return $this->keywords;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_length()
+	{
+		if ($this->length !== null)
+		{
+			return $this->length;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_link()
+	{
+		if ($this->link !== null)
+		{
+			return urldecode($this->link);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_medium()
+	{
+		if ($this->medium !== null)
+		{
+			return $this->medium;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_player()
+	{
+		if ($this->player !== null)
+		{
+			return $this->player;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_rating($key = 0)
+	{
+		$ratings = $this->get_ratings();
+		if (isset($ratings[$key]))
+		{
+			return $ratings[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_ratings()
+	{
+		if ($this->ratings !== null)
+		{
+			return $this->ratings;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_restriction($key = 0)
+	{
+		$restrictions = $this->get_restrictions();
+		if (isset($restrictions[$key]))
+		{
+			return $restrictions[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_restrictions()
+	{
+		if ($this->restrictions !== null)
+		{
+			return $this->restrictions;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_sampling_rate()
+	{
+		if ($this->samplingrate !== null)
+		{
+			return $this->samplingrate;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_size()
+	{
+		$length = $this->get_length();
+		if ($length !== null)
+		{
+			return round($length/1048576, 2);
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_thumbnail($key = 0)
+	{
+		$thumbnails = $this->get_thumbnails();
+		if (isset($thumbnails[$key]))
+		{
+			return $thumbnails[$key];
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_thumbnails()
+	{
+		if ($this->thumbnails !== null)
+		{
+			return $this->thumbnails;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_title()
+	{
+		if ($this->title !== null)
+		{
+			return $this->title;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_type()
+	{
+		if ($this->type !== null)
+		{
+			return $this->type;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_width()
+	{
+		if ($this->width !== null)
+		{
+			return $this->width;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function native_embed($options='')
+	{
+		return $this->embed($options, true);
+	}
+
+	/**
+	 * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'.
+	 */
+	function embed($options = '', $native = false)
+	{
+		// Set up defaults
+		$audio = '';
+		$video = '';
+		$alt = '';
+		$altclass = '';
+		$loop = 'false';
+		$width = 'auto';
+		$height = 'auto';
+		$bgcolor = '#ffffff';
+		$mediaplayer = '';
+		$widescreen = false;
+		$handler = $this->get_handler();
+		$type = $this->get_real_type();
+
+		// Process options and reassign values as necessary
+		if (is_array($options))
+		{
+			extract($options);
+		}
+		else
+		{
+			$options = explode(',', $options);
+			foreach($options as $option)
+			{
+				$opt = explode(':', $option, 2);
+				if (isset($opt[0], $opt[1]))
+				{
+					$opt[0] = trim($opt[0]);
+					$opt[1] = trim($opt[1]);
+					switch ($opt[0])
+					{
+						case 'audio':
+							$audio = $opt[1];
+							break;
+
+						case 'video':
+							$video = $opt[1];
+							break;
+
+						case 'alt':
+							$alt = $opt[1];
+							break;
+
+						case 'altclass':
+							$altclass = $opt[1];
+							break;
+
+						case 'loop':
+							$loop = $opt[1];
+							break;
+
+						case 'width':
+							$width = $opt[1];
+							break;
+
+						case 'height':
+							$height = $opt[1];
+							break;
+
+						case 'bgcolor':
+							$bgcolor = $opt[1];
+							break;
+
+						case 'mediaplayer':
+							$mediaplayer = $opt[1];
+							break;
+
+						case 'widescreen':
+							$widescreen = $opt[1];
+							break;
+					}
+				}
+			}
+		}
+
+		$mime = explode('/', $type, 2);
+		$mime = $mime[0];
+
+		// Process values for 'auto'
+		if ($width === 'auto')
+		{
+			if ($mime === 'video')
+			{
+				if ($height === 'auto')
+				{
+					$width = 480;
+				}
+				elseif ($widescreen)
+				{
+					$width = round((intval($height)/9)*16);
+				}
+				else
+				{
+					$width = round((intval($height)/3)*4);
+				}
+			}
+			else
+			{
+				$width = '100%';
+			}
+		}
+
+		if ($height === 'auto')
+		{
+			if ($mime === 'audio')
+			{
+				$height = 0;
+			}
+			elseif ($mime === 'video')
+			{
+				if ($width === 'auto')
+				{
+					if ($widescreen)
+					{
+						$height = 270;
+					}
+					else
+					{
+						$height = 360;
+					}
+				}
+				elseif ($widescreen)
+				{
+					$height = round((intval($width)/16)*9);
+				}
+				else
+				{
+					$height = round((intval($width)/4)*3);
+				}
+			}
+			else
+			{
+				$height = 376;
+			}
+		}
+		elseif ($mime === 'audio')
+		{
+			$height = 0;
+		}
+
+		// Set proper placeholder value
+		if ($mime === 'audio')
+		{
+			$placeholder = $audio;
+		}
+		elseif ($mime === 'video')
+		{
+			$placeholder = $video;
+		}
+
+		$embed = '';
+
+		// Make sure the JS library is included
+		if (!$native)
+		{
+			static $javascript_outputted = null;
+			if (!$javascript_outputted && $this->javascript)
+			{
+				$embed .= '<script type="text/javascript" src="?' . htmlspecialchars($this->javascript) . '"></script>';
+				$javascript_outputted = true;
+			}
+		}
+
+		// Odeo Feed MP3's
+		if ($handler === 'odeo')
+		{
+			if ($native)
+			{
+				$embed .= '<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://adobe.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url=' . $this->get_link() . '"></embed>';
+			}
+			else
+			{
+				$embed .= '<script type="text/javascript">embed_odeo("' . $this->get_link() . '");</script>';
+			}
+		}
+
+		// Flash
+		elseif ($handler === 'flash')
+		{
+			if ($native)
+			{
+				$embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
+			}
+			else
+			{
+				$embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
+			}
+		}
+
+		// Flash Media Player file types.
+		// Preferred handler for MP3 file types.
+		elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
+		{
+			$height += 20;
+			if ($native)
+			{
+				$embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";
+			}
+			else
+			{
+				$embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>";
+			}
+		}
+
+		// QuickTime 7 file types.  Need to test with QuickTime 6.
+		// Only handle MP3's if the Flash Media Player is not present.
+		elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === ''))
+		{
+			$height += 16;
+			if ($native)
+			{
+				if ($placeholder !== '')
+				{
+					$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
+				}
+				else
+				{
+					$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
+				}
+			}
+			else
+			{
+				$embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>";
+			}
+		}
+
+		// Windows Media
+		elseif ($handler === 'wmedia')
+		{
+			$height += 45;
+			if ($native)
+			{
+				$embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>";
+			}
+			else
+			{
+				$embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>";
+			}
+		}
+
+		// Everything else
+		else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';
+
+		return $embed;
+	}
+
+	function get_real_type($find_handler = false)
+	{
+		// If it's Odeo, let's get it out of the way.
+		if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com')
+		{
+			return 'odeo';
+		}
+
+		// Mime-types by handler.
+		$types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash
+		$types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player
+		$types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime
+		$types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media
+		$types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3
+
+		if ($this->get_type() !== null)
+		{
+			$type = strtolower($this->type);
+		}
+		else
+		{
+			$type = null;
+		}
+
+		// If we encounter an unsupported mime-type, check the file extension and guess intelligently.
+		if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
+		{
+			switch (strtolower($this->get_extension()))
+			{
+				// Audio mime-types
+				case 'aac':
+				case 'adts':
+					$type = 'audio/acc';
+					break;
+
+				case 'aif':
+				case 'aifc':
+				case 'aiff':
+				case 'cdda':
+					$type = 'audio/aiff';
+					break;
+
+				case 'bwf':
+					$type = 'audio/wav';
+					break;
+
+				case 'kar':
+				case 'mid':
+				case 'midi':
+				case 'smf':
+					$type = 'audio/midi';
+					break;
+
+				case 'm4a':
+					$type = 'audio/x-m4a';
+					break;
+
+				case 'mp3':
+				case 'swa':
+					$type = 'audio/mp3';
+					break;
+
+				case 'wav':
+					$type = 'audio/wav';
+					break;
+
+				case 'wax':
+					$type = 'audio/x-ms-wax';
+					break;
+
+				case 'wma':
+					$type = 'audio/x-ms-wma';
+					break;
+
+				// Video mime-types
+				case '3gp':
+				case '3gpp':
+					$type = 'video/3gpp';
+					break;
+
+				case '3g2':
+				case '3gp2':
+					$type = 'video/3gpp2';
+					break;
+
+				case 'asf':
+					$type = 'video/x-ms-asf';
+					break;
+
+				case 'flv':
+					$type = 'video/x-flv';
+					break;
+
+				case 'm1a':
+				case 'm1s':
+				case 'm1v':
+				case 'm15':
+				case 'm75':
+				case 'mp2':
+				case 'mpa':
+				case 'mpeg':
+				case 'mpg':
+				case 'mpm':
+				case 'mpv':
+					$type = 'video/mpeg';
+					break;
+
+				case 'm4v':
+					$type = 'video/x-m4v';
+					break;
+
+				case 'mov':
+				case 'qt':
+					$type = 'video/quicktime';
+					break;
+
+				case 'mp4':
+				case 'mpg4':
+					$type = 'video/mp4';
+					break;
+
+				case 'sdv':
+					$type = 'video/sd-video';
+					break;
+
+				case 'wm':
+					$type = 'video/x-ms-wm';
+					break;
+
+				case 'wmv':
+					$type = 'video/x-ms-wmv';
+					break;
+
+				case 'wvx':
+					$type = 'video/x-ms-wvx';
+					break;
+
+				// Flash mime-types
+				case 'spl':
+					$type = 'application/futuresplash';
+					break;
+
+				case 'swf':
+					$type = 'application/x-shockwave-flash';
+					break;
+			}
+		}
+
+		if ($find_handler)
+		{
+			if (in_array($type, $types_flash))
+			{
+				return 'flash';
+			}
+			elseif (in_array($type, $types_fmedia))
+			{
+				return 'fmedia';
+			}
+			elseif (in_array($type, $types_quicktime))
+			{
+				return 'quicktime';
+			}
+			elseif (in_array($type, $types_wmedia))
+			{
+				return 'wmedia';
+			}
+			elseif (in_array($type, $types_mp3))
+			{
+				return 'mp3';
+			}
+			else
+			{
+				return null;
+			}
+		}
+		else
+		{
+			return $type;
+		}
+	}
+}
+
+class SimplePie_Caption
+{
+	var $type;
+	var $lang;
+	var $startTime;
+	var $endTime;
+	var $text;
+
+	// Constructor, used to input the data
+	function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
+	{
+		$this->type = $type;
+		$this->lang = $lang;
+		$this->startTime = $startTime;
+		$this->endTime = $endTime;
+		$this->text = $text;
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_endtime()
+	{
+		if ($this->endTime !== null)
+		{
+			return $this->endTime;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_language()
+	{
+		if ($this->lang !== null)
+		{
+			return $this->lang;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_starttime()
+	{
+		if ($this->startTime !== null)
+		{
+			return $this->startTime;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_text()
+	{
+		if ($this->text !== null)
+		{
+			return $this->text;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_type()
+	{
+		if ($this->type !== null)
+		{
+			return $this->type;
+		}
+		else
+		{
+			return null;
+		}
+	}
+}
+
+class SimplePie_Credit
+{
+	var $role;
+	var $scheme;
+	var $name;
+
+	// Constructor, used to input the data
+	function SimplePie_Credit($role = null, $scheme = null, $name = null)
+	{
+		$this->role = $role;
+		$this->scheme = $scheme;
+		$this->name = $name;
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_role()
+	{
+		if ($this->role !== null)
+		{
+			return $this->role;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_scheme()
+	{
+		if ($this->scheme !== null)
+		{
+			return $this->scheme;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_name()
+	{
+		if ($this->name !== null)
+		{
+			return $this->name;
+		}
+		else
+		{
+			return null;
+		}
+	}
+}
+
+class SimplePie_Copyright
+{
+	var $url;
+	var $label;
+
+	// Constructor, used to input the data
+	function SimplePie_Copyright($url = null, $label = null)
+	{
+		$this->url = $url;
+		$this->label = $label;
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_url()
+	{
+		if ($this->url !== null)
+		{
+			return $this->url;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_attribution()
+	{
+		if ($this->label !== null)
+		{
+			return $this->label;
+		}
+		else
+		{
+			return null;
+		}
+	}
+}
+
+class SimplePie_Rating
+{
+	var $scheme;
+	var $value;
+
+	// Constructor, used to input the data
+	function SimplePie_Rating($scheme = null, $value = null)
+	{
+		$this->scheme = $scheme;
+		$this->value = $value;
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_scheme()
+	{
+		if ($this->scheme !== null)
+		{
+			return $this->scheme;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_value()
+	{
+		if ($this->value !== null)
+		{
+			return $this->value;
+		}
+		else
+		{
+			return null;
+		}
+	}
+}
+
+class SimplePie_Restriction
+{
+	var $relationship;
+	var $type;
+	var $value;
+
+	// Constructor, used to input the data
+	function SimplePie_Restriction($relationship = null, $type = null, $value = null)
+	{
+		$this->relationship = $relationship;
+		$this->type = $type;
+		$this->value = $value;
+	}
+
+	function __toString()
+	{
+		// There is no $this->data here
+		return md5(serialize($this));
+	}
+
+	function get_relationship()
+	{
+		if ($this->relationship !== null)
+		{
+			return $this->relationship;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_type()
+	{
+		if ($this->type !== null)
+		{
+			return $this->type;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	function get_value()
+	{
+		if ($this->value !== null)
+		{
+			return $this->value;
+		}
+		else
+		{
+			return null;
+		}
+	}
+}
+
+/**
+ * @todo Move to properly supporting RFC2616 (HTTP/1.1)
+ */
+class SimplePie_File
+{
+	var $url;
+	var $useragent;
+	var $success = true;
+	var $headers = array();
+	var $body;
+	var $status_code;
+	var $redirects = 0;
+	var $error;
+	var $method = SIMPLEPIE_FILE_SOURCE_NONE;
+
+	function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
+	{
+		if (class_exists('idna_convert'))
+		{
+			$idn =& new idna_convert;
+			$parsed = SimplePie_Misc::parse_url($url);
+			$url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
+		}
+		$this->url = $url;
+		$this->useragent = $useragent;
+		if (preg_match('/^http(s)?:\/\//i', $url))
+		{
+			if ($useragent === null)
+			{
+				$useragent = ini_get('user_agent');
+				$this->useragent = $useragent;
+			}
+			if (!is_array($headers))
+			{
+				$headers = array();
+			}
+			if (!$force_fsockopen && function_exists('curl_exec'))
+			{
+				$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
+				$fp = curl_init();
+				$headers2 = array();
+				foreach ($headers as $key => $value)
+				{
+					$headers2[] = "$key: $value";
+				}
+				if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>='))
+				{
+					curl_setopt($fp, CURLOPT_ENCODING, '');
+				}
+				curl_setopt($fp, CURLOPT_URL, $url);
+				curl_setopt($fp, CURLOPT_HEADER, 1);
+				curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
+				curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
+				curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
+				curl_setopt($fp, CURLOPT_REFERER, $url);
+				curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
+				curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
+				if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))
+				{
+					curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
+					curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
+				}
+
+				$this->headers = curl_exec($fp);
+				if (curl_errno($fp) === 23 || curl_errno($fp) === 61)
+				{
+					curl_setopt($fp, CURLOPT_ENCODING, 'none');
+					$this->headers = curl_exec($fp);
+				}
+				if (curl_errno($fp))
+				{
+					$this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
+					$this->success = false;
+				}
+				else
+				{
+					$info = curl_getinfo($fp);
+					curl_close($fp);
+					$this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
+					$this->headers = array_pop($this->headers);
+					$parser =& new SimplePie_HTTP_Parser($this->headers);
+					if ($parser->parse())
+					{
+						$this->headers = $parser->headers;
+						$this->body = $parser->body;
+						$this->status_code = $parser->status_code;
+						if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
+						{
+							$this->redirects++;
+							$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
+							return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
+						}
+					}
+				}
+			}
+			else
+			{
+				$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
+				$url_parts = parse_url($url);
+				if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https')
+				{
+					$url_parts['host'] = "ssl://$url_parts[host]";
+					$url_parts['port'] = 443;
+				}
+				if (!isset($url_parts['port']))
+				{
+					$url_parts['port'] = 80;
+				}
+				$fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout);
+				if (!$fp)
+				{
+					$this->error = 'fsockopen error: ' . $errstr;
+					$this->success = false;
+				}
+				else
+				{
+					stream_set_timeout($fp, $timeout);
+					if (isset($url_parts['path']))
+					{
+						if (isset($url_parts['query']))
+						{
+							$get = "$url_parts[path]?$url_parts[query]";
+						}
+						else
+						{
+							$get = $url_parts['path'];
+						}
+					}
+					else
+					{
+						$get = '/';
+					}
+					$out = "GET $get HTTP/1.0\r\n";
+					$out .= "Host: $url_parts[host]\r\n";
+					$out .= "User-Agent: $useragent\r\n";
+					if (extension_loaded('zlib'))
+					{
+						$out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n";
+					}
+
+					if (isset($url_parts['user']) && isset($url_parts['pass']))
+					{
+						$out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n";
+					}
+					foreach ($headers as $key => $value)
+					{
+						$out .= "$key: $value\r\n";
+					}
+					$out .= "Connection: Close\r\n\r\n";
+					fwrite($fp, $out);
+
+					$info = stream_get_meta_data($fp);
+
+					$this->headers = '';
+					while (!$info['eof'] && !$info['timed_out'])
+					{
+						$this->headers .= fread($fp, 1160);
+						$info = stream_get_meta_data($fp);
+					}
+					if (!$info['timed_out'])
+					{
+						$parser =& new SimplePie_HTTP_Parser($this->headers);
+						if ($parser->parse())
+						{
+							$this->headers = $parser->headers;
+							$this->body = $parser->body;
+							$this->status_code = $parser->status_code;
+							if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
+							{
+								$this->redirects++;
+								$location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
+								return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
+							}
+							if (isset($this->headers['content-encoding']))
+							{
+								// Hey, we act dumb elsewhere, so let's do that here too
+								switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20")))
+								{
+									case 'gzip':
+									case 'x-gzip':
+										$decoder =& new SimplePie_gzdecode($this->body);
+										if (!$decoder->parse())
+										{
+											$this->error = 'Unable to decode HTTP "gzip" stream';
+											$this->success = false;
+										}
+										else
+										{
+											$this->body = $decoder->data;
+										}
+										break;
+
+									case 'deflate':
+										if (($body = gzuncompress($this->body)) === false)
+										{
+											if (($body = gzinflate($this->body)) === false)
+											{
+												$this->error = 'Unable to decode HTTP "deflate" stream';
+												$this->success = false;
+											}
+										}
+										$this->body = $body;
+										break;
+
+									default:
+										$this->error = 'Unknown content coding';
+										$this->success = false;
+								}
+							}
+						}
+					}
+					else
+					{
+						$this->error = 'fsocket timed out';
+						$this->success = false;
+					}
+					fclose($fp);
+				}
+			}
+		}
+		else
+		{
+			$this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS;
+			if (!$this->body = file_get_contents($url))
+			{
+				$this->error = 'file_get_contents could not read the file';
+				$this->success = false;
+			}
+		}
+	}
+}
+
+/**
+ * HTTP Response Parser
+ *
+ * @package SimplePie
+ */
+class SimplePie_HTTP_Parser
+{
+	/**
+	 * HTTP Version
+	 *
+	 * @access public
+	 * @var float
+	 */
+	var $http_version = 0.0;
+
+	/**
+	 * Status code
+	 *
+	 * @access public
+	 * @var int
+	 */
+	var $status_code = 0;
+
+	/**
+	 * Reason phrase
+	 *
+	 * @access public
+	 * @var string
+	 */
+	var $reason = '';
+
+	/**
+	 * Key/value pairs of the headers
+	 *
+	 * @access public
+	 * @var array
+	 */
+	var $headers = array();
+
+	/**
+	 * Body of the response
+	 *
+	 * @access public
+	 * @var string
+	 */
+	var $body = '';
+
+	/**
+	 * Current state of the state machine
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $state = 'http_version';
+
+	/**
+	 * Input data
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $data = '';
+
+	/**
+	 * Input data length (to avoid calling strlen() everytime this is needed)
+	 *
+	 * @access private
+	 * @var int
+	 */
+	var $data_length = 0;
+
+	/**
+	 * Current position of the pointer
+	 *
+	 * @var int
+	 * @access private
+	 */
+	var $position = 0;
+
+	/**
+	 * Name of the hedaer currently being parsed
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $name = '';
+
+	/**
+	 * Value of the hedaer currently being parsed
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $value = '';
+
+	/**
+	 * Create an instance of the class with the input data
+	 *
+	 * @access public
+	 * @param string $data Input data
+	 */
+	function SimplePie_HTTP_Parser($data)
+	{
+		$this->data = $data;
+		$this->data_length = strlen($this->data);
+	}
+
+	/**
+	 * Parse the input data
+	 *
+	 * @access public
+	 * @return bool true on success, false on failure
+	 */
+	function parse()
+	{
+		while ($this->state && $this->state !== 'emit' && $this->has_data())
+		{
+			$state = $this->state;
+			$this->$state();
+		}
+		$this->data = '';
+		if ($this->state === 'emit' || $this->state === 'body')
+		{
+			return true;
+		}
+		else
+		{
+			$this->http_version = '';
+			$this->status_code = '';
+			$this->reason = '';
+			$this->headers = array();
+			$this->body = '';
+			return false;
+		}
+	}
+
+	/**
+	 * Check whether there is data beyond the pointer
+	 *
+	 * @access private
+	 * @return bool true if there is further data, false if not
+	 */
+	function has_data()
+	{
+		return (bool) ($this->position < $this->data_length);
+	}
+
+	/**
+	 * See if the next character is LWS
+	 *
+	 * @access private
+	 * @return bool true if the next character is LWS, false if not
+	 */
+	function is_linear_whitespace()
+	{
+		return (bool) ($this->data[$this->position] === "\x09"
+			|| $this->data[$this->position] === "\x20"
+			|| ($this->data[$this->position] === "\x0A"
+				&& isset($this->data[$this->position + 1])
+				&& ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20")));
+	}
+
+	/**
+	 * Parse the HTTP version
+	 *
+	 * @access private
+	 */
+	function http_version()
+	{
+		if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/')
+		{
+			$len = strspn($this->data, '0123456789.', 5);
+			$this->http_version = substr($this->data, 5, $len);
+			$this->position += 5 + $len;
+			if (substr_count($this->http_version, '.') <= 1)
+			{
+				$this->http_version = (float) $this->http_version;
+				$this->position += strspn($this->data, "\x09\x20", $this->position);
+				$this->state = 'status';
+			}
+			else
+			{
+				$this->state = false;
+			}
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	/**
+	 * Parse the status code
+	 *
+	 * @access private
+	 */
+	function status()
+	{
+		if ($len = strspn($this->data, '0123456789', $this->position))
+		{
+			$this->status_code = (int) substr($this->data, $this->position, $len);
+			$this->position += $len;
+			$this->state = 'reason';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	/**
+	 * Parse the reason phrase
+	 *
+	 * @access private
+	 */
+	function reason()
+	{
+		$len = strcspn($this->data, "\x0A", $this->position);
+		$this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20");
+		$this->position += $len + 1;
+		$this->state = 'new_line';
+	}
+
+	/**
+	 * Deal with a new line, shifting data around as needed
+	 *
+	 * @access private
+	 */
+	function new_line()
+	{
+		$this->value = trim($this->value, "\x0D\x20");
+		if ($this->name !== '' && $this->value !== '')
+		{
+			$this->name = strtolower($this->name);
+			if (isset($this->headers[$this->name]))
+			{
+				$this->headers[$this->name] .= ', ' . $this->value;
+			}
+			else
+			{
+				$this->headers[$this->name] = $this->value;
+			}
+		}
+		$this->name = '';
+		$this->value = '';
+		if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A")
+		{
+			$this->position += 2;
+			$this->state = 'body';
+		}
+		elseif ($this->data[$this->position] === "\x0A")
+		{
+			$this->position++;
+			$this->state = 'body';
+		}
+		else
+		{
+			$this->state = 'name';
+		}
+	}
+
+	/**
+	 * Parse a header name
+	 *
+	 * @access private
+	 */
+	function name()
+	{
+		$len = strcspn($this->data, "\x0A:", $this->position);
+		if (isset($this->data[$this->position + $len]))
+		{
+			if ($this->data[$this->position + $len] === "\x0A")
+			{
+				$this->position += $len;
+				$this->state = 'new_line';
+			}
+			else
+			{
+				$this->name = substr($this->data, $this->position, $len);
+				$this->position += $len + 1;
+				$this->state = 'value';
+			}
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	/**
+	 * Parse LWS, replacing consecutive LWS characters with a single space
+	 *
+	 * @access private
+	 */
+	function linear_whitespace()
+	{
+		do
+		{
+			if (substr($this->data, $this->position, 2) === "\x0D\x0A")
+			{
+				$this->position += 2;
+			}
+			elseif ($this->data[$this->position] === "\x0A")
+			{
+				$this->position++;
+			}
+			$this->position += strspn($this->data, "\x09\x20", $this->position);
+		} while ($this->has_data() && $this->is_linear_whitespace());
+		$this->value .= "\x20";
+	}
+
+	/**
+	 * See what state to move to while within non-quoted header values
+	 *
+	 * @access private
+	 */
+	function value()
+	{
+		if ($this->is_linear_whitespace())
+		{
+			$this->linear_whitespace();
+		}
+		else
+		{
+			switch ($this->data[$this->position])
+			{
+				case '"':
+					$this->position++;
+					$this->state = 'quote';
+					break;
+
+				case "\x0A":
+					$this->position++;
+					$this->state = 'new_line';
+					break;
+
+				default:
+					$this->state = 'value_char';
+					break;
+			}
+		}
+	}
+
+	/**
+	 * Parse a header value while outside quotes
+	 *
+	 * @access private
+	 */
+	function value_char()
+	{
+		$len = strcspn($this->data, "\x09\x20\x0A\"", $this->position);
+		$this->value .= substr($this->data, $this->position, $len);
+		$this->position += $len;
+		$this->state = 'value';
+	}
+
+	/**
+	 * See what state to move to while within quoted header values
+	 *
+	 * @access private
+	 */
+	function quote()
+	{
+		if ($this->is_linear_whitespace())
+		{
+			$this->linear_whitespace();
+		}
+		else
+		{
+			switch ($this->data[$this->position])
+			{
+				case '"':
+					$this->position++;
+					$this->state = 'value';
+					break;
+
+				case "\x0A":
+					$this->position++;
+					$this->state = 'new_line';
+					break;
+
+				case '\\':
+					$this->position++;
+					$this->state = 'quote_escaped';
+					break;
+
+				default:
+					$this->state = 'quote_char';
+					break;
+			}
+		}
+	}
+
+	/**
+	 * Parse a header value while within quotes
+	 *
+	 * @access private
+	 */
+	function quote_char()
+	{
+		$len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position);
+		$this->value .= substr($this->data, $this->position, $len);
+		$this->position += $len;
+		$this->state = 'value';
+	}
+
+	/**
+	 * Parse an escaped character within quotes
+	 *
+	 * @access private
+	 */
+	function quote_escaped()
+	{
+		$this->value .= $this->data[$this->position];
+		$this->position++;
+		$this->state = 'quote';
+	}
+
+	/**
+	 * Parse the body
+	 *
+	 * @access private
+	 */
+	function body()
+	{
+		$this->body = substr($this->data, $this->position);
+		$this->state = 'emit';
+	}
+}
+
+/**
+ * gzdecode
+ *
+ * @package SimplePie
+ */
+class SimplePie_gzdecode
+{
+	/**
+	 * Compressed data
+	 *
+	 * @access private
+	 * @see gzdecode::$data
+	 */
+	var $compressed_data;
+
+	/**
+	 * Size of compressed data
+	 *
+	 * @access private
+	 */
+	var $compressed_size;
+
+	/**
+	 * Minimum size of a valid gzip string
+	 *
+	 * @access private
+	 */
+	var $min_compressed_size = 18;
+
+	/**
+	 * Current position of pointer
+	 *
+	 * @access private
+	 */
+	var $position = 0;
+
+	/**
+	 * Flags (FLG)
+	 *
+	 * @access private
+	 */
+	var $flags;
+
+	/**
+	 * Uncompressed data
+	 *
+	 * @access public
+	 * @see gzdecode::$compressed_data
+	 */
+	var $data;
+
+	/**
+	 * Modified time
+	 *
+	 * @access public
+	 */
+	var $MTIME;
+
+	/**
+	 * Extra Flags
+	 *
+	 * @access public
+	 */
+	var $XFL;
+
+	/**
+	 * Operating System
+	 *
+	 * @access public
+	 */
+	var $OS;
+
+	/**
+	 * Subfield ID 1
+	 *
+	 * @access public
+	 * @see gzdecode::$extra_field
+	 * @see gzdecode::$SI2
+	 */
+	var $SI1;
+
+	/**
+	 * Subfield ID 2
+	 *
+	 * @access public
+	 * @see gzdecode::$extra_field
+	 * @see gzdecode::$SI1
+	 */
+	var $SI2;
+
+	/**
+	 * Extra field content
+	 *
+	 * @access public
+	 * @see gzdecode::$SI1
+	 * @see gzdecode::$SI2
+	 */
+	var $extra_field;
+
+	/**
+	 * Original filename
+	 *
+	 * @access public
+	 */
+	var $filename;
+
+	/**
+	 * Human readable comment
+	 *
+	 * @access public
+	 */
+	var $comment;
+
+	/**
+	 * Don't allow anything to be set
+	 *
+	 * @access public
+	 */
+	function __set($name, $value)
+	{
+		trigger_error("Cannot write property $name", E_USER_ERROR);
+	}
+
+	/**
+	 * Set the compressed string and related properties
+	 *
+	 * @access public
+	 */
+	function SimplePie_gzdecode($data)
+	{
+		$this->compressed_data = $data;
+		$this->compressed_size = strlen($data);
+	}
+
+	/**
+	 * Decode the GZIP stream
+	 *
+	 * @access public
+	 */
+	function parse()
+	{
+		if ($this->compressed_size >= $this->min_compressed_size)
+		{
+			// Check ID1, ID2, and CM
+			if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08")
+			{
+				return false;
+			}
+
+			// Get the FLG (FLaGs)
+			$this->flags = ord($this->compressed_data[3]);
+
+			// FLG bits above (1 << 4) are reserved
+			if ($this->flags > 0x1F)
+			{
+				return false;
+			}
+
+			// Advance the pointer after the above
+			$this->position += 4;
+
+			// MTIME
+			$mtime = substr($this->compressed_data, $this->position, 4);
+			// Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
+			if (current(unpack('S', "\x00\x01")) === 1)
+			{
+				$mtime = strrev($mtime);
+			}
+			$this->MTIME = current(unpack('l', $mtime));
+			$this->position += 4;
+
+			// Get the XFL (eXtra FLags)
+			$this->XFL = ord($this->compressed_data[$this->position++]);
+
+			// Get the OS (Operating System)
+			$this->OS = ord($this->compressed_data[$this->position++]);
+
+			// Parse the FEXTRA
+			if ($this->flags & 4)
+			{
+				// Read subfield IDs
+				$this->SI1 = $this->compressed_data[$this->position++];
+				$this->SI2 = $this->compressed_data[$this->position++];
+
+				// SI2 set to zero is reserved for future use
+				if ($this->SI2 === "\x00")
+				{
+					return false;
+				}
+
+				// Get the length of the extra field
+				$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
+				$position += 2;
+
+				// Check the length of the string is still valid
+				$this->min_compressed_size += $len + 4;
+				if ($this->compressed_size >= $this->min_compressed_size)
+				{
+					// Set the extra field to the given data
+					$this->extra_field = substr($this->compressed_data, $this->position, $len);
+					$this->position += $len;
+				}
+				else
+				{
+					return false;
+				}
+			}
+
+			// Parse the FNAME
+			if ($this->flags & 8)
+			{
+				// Get the length of the filename
+				$len = strcspn($this->compressed_data, "\x00", $this->position);
+
+				// Check the length of the string is still valid
+				$this->min_compressed_size += $len + 1;
+				if ($this->compressed_size >= $this->min_compressed_size)
+				{
+					// Set the original filename to the given string
+					$this->filename = substr($this->compressed_data, $this->position, $len);
+					$this->position += $len + 1;
+				}
+				else
+				{
+					return false;
+				}
+			}
+
+			// Parse the FCOMMENT
+			if ($this->flags & 16)
+			{
+				// Get the length of the comment
+				$len = strcspn($this->compressed_data, "\x00", $this->position);
+
+				// Check the length of the string is still valid
+				$this->min_compressed_size += $len + 1;
+				if ($this->compressed_size >= $this->min_compressed_size)
+				{
+					// Set the original comment to the given string
+					$this->comment = substr($this->compressed_data, $this->position, $len);
+					$this->position += $len + 1;
+				}
+				else
+				{
+					return false;
+				}
+			}
+
+			// Parse the FHCRC
+			if ($this->flags & 2)
+			{
+				// Check the length of the string is still valid
+				$this->min_compressed_size += $len + 2;
+				if ($this->compressed_size >= $this->min_compressed_size)
+				{
+					// Read the CRC
+					$crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
+
+					// Check the CRC matches
+					if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc)
+					{
+						$this->position += 2;
+					}
+					else
+					{
+						return false;
+					}
+				}
+				else
+				{
+					return false;
+				}
+			}
+
+			// Decompress the actual data
+			if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false)
+			{
+				return false;
+			}
+			else
+			{
+				$this->position = $this->compressed_size - 8;
+			}
+
+			// Check CRC of data
+			$crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
+			$this->position += 4;
+			/*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
+			{
+				return false;
+			}*/
+
+			// Check ISIZE of data
+			$isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
+			$this->position += 4;
+			if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize))
+			{
+				return false;
+			}
+
+			// Wow, against all odds, we've actually got a valid gzip string
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+}
+
+class SimplePie_Cache
+{
+	/**
+	 * Don't call the constructor. Please.
+	 *
+	 * @access private
+	 */
+	function SimplePie_Cache()
+	{
+		trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR);
+	}
+
+	/**
+	 * Create a new SimplePie_Cache object
+	 *
+	 * @static
+	 * @access public
+	 */
+	function create($location, $filename, $extension)
+	{
+		$location_iri =& new SimplePie_IRI($location);
+		switch ($location_iri->get_scheme())
+		{
+			case 'mysql':
+				if (extension_loaded('mysql'))
+				{
+					return new SimplePie_Cache_MySQL($location_iri, $filename, $extension);
+				}
+				break;
+
+			default:
+				return new SimplePie_Cache_File($location, $filename, $extension);
+		}
+	}
+}
+
+class SimplePie_Cache_File
+{
+	var $location;
+	var $filename;
+	var $extension;
+	var $name;
+
+	function SimplePie_Cache_File($location, $filename, $extension)
+	{
+		$this->location = $location;
+		$this->filename = $filename;
+		$this->extension = $extension;
+		$this->name = "$this->location/$this->filename.$this->extension";
+	}
+
+	function save($data)
+	{
+		if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location))
+		{
+			if (is_a($data, 'SimplePie'))
+			{
+				$data = $data->data;
+			}
+
+			$data = serialize($data);
+
+			if (function_exists('file_put_contents'))
+			{
+				return (bool) file_put_contents($this->name, $data);
+			}
+			else
+			{
+				$fp = fopen($this->name, 'wb');
+				if ($fp)
+				{
+					fwrite($fp, $data);
+					fclose($fp);
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+
+	function load()
+	{
+		if (file_exists($this->name) && is_readable($this->name))
+		{
+			return unserialize(file_get_contents($this->name));
+		}
+		return false;
+	}
+
+	function mtime()
+	{
+		if (file_exists($this->name))
+		{
+			return filemtime($this->name);
+		}
+		return false;
+	}
+
+	function touch()
+	{
+		if (file_exists($this->name))
+		{
+			return touch($this->name);
+		}
+		return false;
+	}
+
+	function unlink()
+	{
+		if (file_exists($this->name))
+		{
+			return unlink($this->name);
+		}
+		return false;
+	}
+}
+
+class SimplePie_Cache_DB
+{
+	function prepare_simplepie_object_for_cache($data)
+	{
+		$items = $data->get_items();
+		$items_by_id = array();
+
+		if (!empty($items))
+		{
+			foreach ($items as $item)
+			{
+				$items_by_id[$item->get_id()] = $item;
+			}
+
+			if (count($items_by_id) !== count($items))
+			{
+				$items_by_id = array();
+				foreach ($items as $item)
+				{
+					$items_by_id[$item->get_id(true)] = $item;
+				}
+			}
+
+			if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
+			{
+				$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
+			}
+			elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
+			{
+				$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
+			}
+			elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
+			{
+				$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
+			}
+			elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]))
+			{
+				$channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0];
+			}
+			else
+			{
+				$channel = null;
+			}
+
+			if ($channel !== null)
+			{
+				if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']))
+				{
+					unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']);
+				}
+				if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']))
+				{
+					unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']);
+				}
+				if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']))
+				{
+					unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']);
+				}
+				if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']))
+				{
+					unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']);
+				}
+				if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']))
+				{
+					unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']);
+				}
+			}
+			if (isset($data->data['items']))
+			{
+				unset($data->data['items']);
+			}
+			if (isset($data->data['ordered_items']))
+			{
+				unset($data->data['ordered_items']);
+			}
+		}
+		return array(serialize($data->data), $items_by_id);
+	}
+}
+
+class SimplePie_Cache_MySQL extends SimplePie_Cache_DB
+{
+	var $mysql;
+	var $options;
+	var $id;
+
+	function SimplePie_Cache_MySQL($mysql_location, $name, $extension)
+	{
+		$host = $mysql_location->get_host();
+		if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')')
+		{
+			$server = ':' . substr($host, 5, -1);
+		}
+		else
+		{
+			$server = $host;
+			if ($mysql_location->get_port() !== null)
+			{
+				$server .= ':' . $mysql_location->get_port();
+			}
+		}
+
+		if (strpos($mysql_location->get_userinfo(), ':') !== false)
+		{
+			list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2);
+		}
+		else
+		{
+			$username = $mysql_location->get_userinfo();
+			$password = null;
+		}
+
+		if ($this->mysql = mysql_connect($server, $username, $password))
+		{
+			$this->id = $name . $extension;
+			$this->options = SimplePie_Misc::parse_str($mysql_location->get_query());
+			if (!isset($this->options['prefix'][0]))
+			{
+				$this->options['prefix'][0] = '';
+			}
+
+			if (mysql_select_db(ltrim($mysql_location->get_path(), '/'))
+				&& mysql_query('SET NAMES utf8')
+				&& ($query = mysql_unbuffered_query('SHOW TABLES')))
+			{
+				$db = array();
+				while ($row = mysql_fetch_row($query))
+				{
+					$db[] = $row[0];
+				}
+
+				if (!in_array($this->options['prefix'][0] . 'cache_data', $db))
+				{
+					if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))'))
+					{
+						$this->mysql = null;
+					}
+				}
+
+				if (!in_array($this->options['prefix'][0] . 'items', $db))
+				{
+					if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'))
+					{
+						$this->mysql = null;
+					}
+				}
+			}
+			else
+			{
+				$this->mysql = null;
+			}
+		}
+	}
+
+	function save($data)
+	{
+		if ($this->mysql)
+		{
+			$feed_id = "'" . mysql_real_escape_string($this->id) . "'";
+
+			if (is_a($data, 'SimplePie'))
+			{
+				if (SIMPLEPIE_PHP5)
+				{
+					// This keyword needs to defy coding standards for PHP4 compatibility
+					$data = clone($data);
+				}
+
+				$prepared = $this->prepare_simplepie_object_for_cache($data);
+
+				if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
+				{
+					if (mysql_num_rows($query))
+					{
+						$items = count($prepared[1]);
+						if ($items)
+						{
+							$sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
+						}
+						else
+						{
+							$sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id;
+						}
+
+						if (!mysql_query($sql, $this->mysql))
+						{
+							return false;
+						}
+					}
+					elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql))
+					{
+						return false;
+					}
+
+					$ids = array_keys($prepared[1]);
+					if (!empty($ids))
+					{
+						foreach ($ids as $id)
+						{
+							$database_ids[] = mysql_real_escape_string($id);
+						}
+
+						if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql))
+						{
+							$existing_ids = array();
+							while ($row = mysql_fetch_row($query))
+							{
+								$existing_ids[] = $row[0];
+							}
+
+							$new_ids = array_diff($ids, $existing_ids);
+
+							foreach ($new_ids as $new_id)
+							{
+								if (!($date = $prepared[1][$new_id]->get_date('U')))
+								{
+									$date = time();
+								}
+
+								if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql))
+								{
+									return false;
+								}
+							}
+							return true;
+						}
+					}
+					else
+					{
+						return true;
+					}
+				}
+			}
+			elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql))
+			{
+				if (mysql_num_rows($query))
+				{
+					if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql))
+					{
+						return true;
+					}
+				}
+				elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql))
+				{
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+
+	function load()
+	{
+		if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
+		{
+			$data = unserialize($row[1]);
+
+			if (isset($this->options['items'][0]))
+			{
+				$items = (int) $this->options['items'][0];
+			}
+			else
+			{
+				$items = (int) $row[0];
+			}
+
+			if ($items !== 0)
+			{
+				if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]))
+				{
+					$feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0];
+				}
+				elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]))
+				{
+					$feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0];
+				}
+				elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]))
+				{
+					$feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0];
+				}
+				elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]))
+				{
+					$feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0];
+				}
+				else
+				{
+					$feed = null;
+				}
+
+				if ($feed !== null)
+				{
+					$sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC';
+					if ($items > 0)
+					{
+						$sql .= ' LIMIT ' . $items;
+					}
+
+					if ($query = mysql_unbuffered_query($sql, $this->mysql))
+					{
+						while ($row = mysql_fetch_row($query))
+						{
+							$feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]);
+						}
+					}
+					else
+					{
+						return false;
+					}
+				}
+			}
+			return $data;
+		}
+		return false;
+	}
+
+	function mtime()
+	{
+		if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query)))
+		{
+			return $row[0];
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	function touch()
+	{
+		if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql))
+		{
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	function unlink()
+	{
+		if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)))
+		{
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+}
+
+class SimplePie_Misc
+{
+	function time_hms($seconds)
+	{
+		$time = '';
+
+		$hours = floor($seconds / 3600);
+		$remainder = $seconds % 3600;
+		if ($hours > 0)
+		{
+			$time .= $hours.':';
+		}
+
+		$minutes = floor($remainder / 60);
+		$seconds = $remainder % 60;
+		if ($minutes < 10 && $hours > 0)
+		{
+			$minutes = '0' . $minutes;
+		}
+		if ($seconds < 10)
+		{
+			$seconds = '0' . $seconds;
+		}
+
+		$time .= $minutes.':';
+		$time .= $seconds;
+
+		return $time;
+	}
+
+	function absolutize_url($relative, $base)
+	{
+		$iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
+		return $iri->get_iri();
+	}
+
+	function remove_dot_segments($input)
+	{
+		$output = '';
+		while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
+		{
+			// A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
+			if (strpos($input, '../') === 0)
+			{
+				$input = substr($input, 3);
+			}
+			elseif (strpos($input, './') === 0)
+			{
+				$input = substr($input, 2);
+			}
+			// B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
+			elseif (strpos($input, '/./') === 0)
+			{
+				$input = substr_replace($input, '/', 0, 3);
+			}
+			elseif ($input === '/.')
+			{
+				$input = '/';
+			}
+			// C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
+			elseif (strpos($input, '/../') === 0)
+			{
+				$input = substr_replace($input, '/', 0, 4);
+				$output = substr_replace($output, '', strrpos($output, '/'));
+			}
+			elseif ($input === '/..')
+			{
+				$input = '/';
+				$output = substr_replace($output, '', strrpos($output, '/'));
+			}
+			// D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
+			elseif ($input === '.' || $input === '..')
+			{
+				$input = '';
+			}
+			// E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
+			elseif (($pos = strpos($input, '/', 1)) !== false)
+			{
+				$output .= substr($input, 0, $pos);
+				$input = substr_replace($input, '', 0, $pos);
+			}
+			else
+			{
+				$output .= $input;
+				$input = '';
+			}
+		}
+		return $output . $input;
+	}
+
+	function get_element($realname, $string)
+	{
+		$return = array();
+		$name = preg_quote($realname, '/');
+		if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
+		{
+			for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
+			{
+				$return[$i]['tag'] = $realname;
+				$return[$i]['full'] = $matches[$i][0][0];
+				$return[$i]['offset'] = $matches[$i][0][1];
+				if (strlen($matches[$i][3][0]) <= 2)
+				{
+					$return[$i]['self_closing'] = true;
+				}
+				else
+				{
+					$return[$i]['self_closing'] = false;
+					$return[$i]['content'] = $matches[$i][4][0];
+				}
+				$return[$i]['attribs'] = array();
+				if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
+				{
+					for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
+					{
+						if (count($attribs[$j]) === 2)
+						{
+							$attribs[$j][2] = $attribs[$j][1];
+						}
+						$return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');
+					}
+				}
+			}
+		}
+		return $return;
+	}
+
+	function element_implode($element)
+	{
+		$full = "<$element[tag]";
+		foreach ($element['attribs'] as $key => $value)
+		{
+			$key = strtolower($key);
+			$full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
+		}
+		if ($element['self_closing'])
+		{
+			$full .= ' />';
+		}
+		else
+		{
+			$full .= ">$element[content]</$element[tag]>";
+		}
+		return $full;
+	}
+
+	function error($message, $level, $file, $line)
+	{
+		if ((ini_get('error_reporting') & $level) > 0)
+		{
+			switch ($level)
+			{
+				case E_USER_ERROR:
+					$note = 'PHP Error';
+					break;
+				case E_USER_WARNING:
+					$note = 'PHP Warning';
+					break;
+				case E_USER_NOTICE:
+					$note = 'PHP Notice';
+					break;
+				default:
+					$note = 'Unknown Error';
+					break;
+			}
+			error_log("$note: $message in $file on line $line", 0);
+		}
+		return $message;
+	}
+
+	/**
+	 * If a file has been cached, retrieve and display it.
+	 *
+	 * This is most useful for caching images (get_favicon(), etc.),
+	 * however it works for all cached files.  This WILL NOT display ANY
+	 * file/image/page/whatever, but rather only display what has already
+	 * been cached by SimplePie.
+	 *
+	 * @access public
+	 * @see SimplePie::get_favicon()
+	 * @param str $identifier_url URL that is used to identify the content.
+	 * This may or may not be the actual URL of the live content.
+	 * @param str $cache_location Location of SimplePie's cache.  Defaults
+	 * to './cache'.
+	 * @param str $cache_extension The file extension that the file was
+	 * cached with.  Defaults to 'spc'.
+	 * @param str $cache_class Name of the cache-handling class being used
+	 * in SimplePie.  Defaults to 'SimplePie_Cache', and should be left
+	 * as-is unless you've overloaded the class.
+	 * @param str $cache_name_function Obsolete. Exists for backwards
+	 * compatibility reasons only.
+	 */
+	function display_cached_file($identifier_url, $cache_location = './cache', $cache_extension = 'spc', $cache_class = 'SimplePie_Cache', $cache_name_function = 'md5')
+	{
+		$cache = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension);
+
+		if ($file = $cache->load())
+		{
+			if (isset($file['headers']['content-type']))
+			{
+				header('Content-type:' . $file['headers']['content-type']);
+			}
+			else
+			{
+				header('Content-type: application/octet-stream');
+			}
+			header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
+			echo $file['body'];
+			exit;
+		}
+
+		die('Cached file for ' . $identifier_url . ' cannot be found.');
+	}
+
+	function fix_protocol($url, $http = 1)
+	{
+		$url = SimplePie_Misc::normalize_url($url);
+		$parsed = SimplePie_Misc::parse_url($url);
+		if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https')
+		{
+			return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
+		}
+
+		if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
+		{
+			return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
+		}
+
+		if ($http === 2 && $parsed['scheme'] !== '')
+		{
+			return "feed:$url";
+		}
+		elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
+		{
+			return substr_replace($url, 'podcast', 0, 4);
+		}
+		elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
+		{
+			return substr_replace($url, 'itpc', 0, 4);
+		}
+		else
+		{
+			return $url;
+		}
+	}
+
+	function parse_url($url)
+	{
+		$iri =& new SimplePie_IRI($url);
+		return array(
+			'scheme' => (string) $iri->get_scheme(),
+			'authority' => (string) $iri->get_authority(),
+			'path' => (string) $iri->get_path(),
+			'query' => (string) $iri->get_query(),
+			'fragment' => (string) $iri->get_fragment()
+		);
+	}
+
+	function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
+	{
+		$iri =& new SimplePie_IRI('');
+		$iri->set_scheme($scheme);
+		$iri->set_authority($authority);
+		$iri->set_path($path);
+		$iri->set_query($query);
+		$iri->set_fragment($fragment);
+		return $iri->get_iri();
+	}
+
+	function normalize_url($url)
+	{
+		$iri =& new SimplePie_IRI($url);
+		return $iri->get_iri();
+	}
+
+	function percent_encoding_normalization($match)
+	{
+		$integer = hexdec($match[1]);
+		if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
+		{
+			return chr($integer);
+		}
+		else
+		{
+			return strtoupper($match[0]);
+		}
+	}
+
+	/**
+	 * Remove bad UTF-8 bytes
+	 *
+	 * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C
+	 * FAQ: Multilingual Forms (modified to include full ASCII range)
+	 *
+	 * @author Geoffrey Sneddon
+	 * @see http://www.w3.org/International/questions/qa-forms-utf-8
+	 * @param string $str String to remove bad UTF-8 bytes from
+	 * @return string UTF-8 string
+	 */
+	function utf8_bad_replace($str)
+	{
+		if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str)))
+		{
+			return $return;
+		}
+		elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8')))
+		{
+			return $return;
+		}
+		elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches))
+		{
+			return implode("\xEF\xBF\xBD", $matches[0]);
+		}
+		elseif ($str !== '')
+		{
+			return "\xEF\xBF\xBD";
+		}
+		else
+		{
+			return '';
+		}
+	}
+
+	/**
+	 * Converts a Windows-1252 encoded string to a UTF-8 encoded string
+	 *
+	 * @static
+	 * @access public
+	 * @param string $string Windows-1252 encoded string
+	 * @return string UTF-8 encoded string
+	 */
+	function windows_1252_to_utf8($string)
+	{
+		static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF");
+
+		return strtr($string, $convert_table);
+	}
+
+	function change_encoding($data, $input, $output)
+	{
+		$input = SimplePie_Misc::encoding($input);
+		$output = SimplePie_Misc::encoding($output);
+
+		// We fail to fail on non US-ASCII bytes
+		if ($input === 'US-ASCII')
+		{
+			static $non_ascii_octects = '';
+			if (!$non_ascii_octects)
+			{
+				for ($i = 0x80; $i <= 0xFF; $i++)
+				{
+					$non_ascii_octects .= chr($i);
+				}
+			}
+			$data = substr($data, 0, strcspn($data, $non_ascii_octects));
+		}
+
+		// This is first, as behaviour of this is completely predictable
+		if ($input === 'windows-1252' && $output === 'UTF-8')
+		{
+			return SimplePie_Misc::windows_1252_to_utf8($data);
+		}
+		// This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
+		elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input)))
+		{
+			return $return;
+		}
+		// This is last, as behaviour of this varies with OS userland and PHP version
+		elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data)))
+		{
+			return $return;
+		}
+		// If we can't do anything, just fail
+		else
+		{
+			return false;
+		}
+	}
+
+	function encoding($charset)
+	{
+		// Normalization from UTS #22
+		switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
+		{
+			case 'adobestandardencoding':
+			case 'csadobestandardencoding':
+				return 'Adobe-Standard-Encoding';
+
+			case 'adobesymbolencoding':
+			case 'cshppsmath':
+				return 'Adobe-Symbol-Encoding';
+
+			case 'ami1251':
+			case 'amiga1251':
+				return 'Amiga-1251';
+
+			case 'ansix31101983':
+			case 'csat5001983':
+			case 'csiso99naplps':
+			case 'isoir99':
+			case 'naplps':
+				return 'ANSI_X3.110-1983';
+
+			case 'arabic7':
+			case 'asmo449':
+			case 'csiso89asmo449':
+			case 'iso9036':
+			case 'isoir89':
+				return 'ASMO_449';
+
+			case 'big5':
+			case 'csbig5':
+			case 'xxbig5':
+				return 'Big5';
+
+			case 'big5hkscs':
+				return 'Big5-HKSCS';
+
+			case 'bocu1':
+			case 'csbocu1':
+				return 'BOCU-1';
+
+			case 'brf':
+			case 'csbrf':
+				return 'BRF';
+
+			case 'bs4730':
+			case 'csiso4unitedkingdom':
+			case 'gb':
+			case 'iso646gb':
+			case 'isoir4':
+			case 'uk':
+				return 'BS_4730';
+
+			case 'bsviewdata':
+			case 'csiso47bsviewdata':
+			case 'isoir47':
+				return 'BS_viewdata';
+
+			case 'cesu8':
+			case 'cscesu8':
+				return 'CESU-8';
+
+			case 'ca':
+			case 'csa71':
+			case 'csaz243419851':
+			case 'csiso121canadian1':
+			case 'iso646ca':
+			case 'isoir121':
+				return 'CSA_Z243.4-1985-1';
+
+			case 'csa72':
+			case 'csaz243419852':
+			case 'csiso122canadian2':
+			case 'iso646ca2':
+			case 'isoir122':
+				return 'CSA_Z243.4-1985-2';
+
+			case 'csaz24341985gr':
+			case 'csiso123csaz24341985gr':
+			case 'isoir123':
+				return 'CSA_Z243.4-1985-gr';
+
+			case 'csiso139csn369103':
+			case 'csn369103':
+			case 'isoir139':
+				return 'CSN_369103';
+
+			case 'csdecmcs':
+			case 'dec':
+			case 'decmcs':
+				return 'DEC-MCS';
+
+			case 'csiso21german':
+			case 'de':
+			case 'din66003':
+			case 'iso646de':
+			case 'isoir21':
+				return 'DIN_66003';
+
+			case 'csdkus':
+			case 'dkus':
+				return 'dk-us';
+
+			case 'csiso646danish':
+			case 'dk':
+			case 'ds2089':
+			case 'iso646dk':
+				return 'DS_2089';
+
+			case 'csibmebcdicatde':
+			case 'ebcdicatde':
+				return 'EBCDIC-AT-DE';
+
+			case 'csebcdicatdea':
+			case 'ebcdicatdea':
+				return 'EBCDIC-AT-DE-A';
+
+			case 'csebcdiccafr':
+			case 'ebcdiccafr':
+				return 'EBCDIC-CA-FR';
+
+			case 'csebcdicdkno':
+			case 'ebcdicdkno':
+				return 'EBCDIC-DK-NO';
+
+			case 'csebcdicdknoa':
+			case 'ebcdicdknoa':
+				return 'EBCDIC-DK-NO-A';
+
+			case 'csebcdices':
+			case 'ebcdices':
+				return 'EBCDIC-ES';
+
+			case 'csebcdicesa':
+			case 'ebcdicesa':
+				return 'EBCDIC-ES-A';
+
+			case 'csebcdicess':
+			case 'ebcdicess':
+				return 'EBCDIC-ES-S';
+
+			case 'csebcdicfise':
+			case 'ebcdicfise':
+				return 'EBCDIC-FI-SE';
+
+			case 'csebcdicfisea':
+			case 'ebcdicfisea':
+				return 'EBCDIC-FI-SE-A';
+
+			case 'csebcdicfr':
+			case 'ebcdicfr':
+				return 'EBCDIC-FR';
+
+			case 'csebcdicit':
+			case 'ebcdicit':
+				return 'EBCDIC-IT';
+
+			case 'csebcdicpt':
+			case 'ebcdicpt':
+				return 'EBCDIC-PT';
+
+			case 'csebcdicuk':
+			case 'ebcdicuk':
+				return 'EBCDIC-UK';
+
+			case 'csebcdicus':
+			case 'ebcdicus':
+				return 'EBCDIC-US';
+
+			case 'csiso111ecmacyrillic':
+			case 'ecmacyrillic':
+			case 'isoir111':
+			case 'koi8e':
+				return 'ECMA-cyrillic';
+
+			case 'csiso17spanish':
+			case 'es':
+			case 'iso646es':
+			case 'isoir17':
+				return 'ES';
+
+			case 'csiso85spanish2':
+			case 'es2':
+			case 'iso646es2':
+			case 'isoir85':
+				return 'ES2';
+
+			case 'cseucfixwidjapanese':
+			case 'extendedunixcodefixedwidthforjapanese':
+				return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
+
+			case 'cseucpkdfmtjapanese':
+			case 'eucjp':
+			case 'extendedunixcodepackedformatforjapanese':
+				return 'Extended_UNIX_Code_Packed_Format_for_Japanese';
+
+			case 'gb18030':
+				return 'GB18030';
+
+			case 'chinese':
+			case 'cp936':
+			case 'csgb2312':
+			case 'csiso58gb231280':
+			case 'gb2312':
+			case 'gb231280':
+			case 'gbk':
+			case 'isoir58':
+			case 'ms936':
+			case 'windows936':
+				return 'GBK';
+
+			case 'cn':
+			case 'csiso57gb1988':
+			case 'gb198880':
+			case 'iso646cn':
+			case 'isoir57':
+				return 'GB_1988-80';
+
+			case 'csiso153gost1976874':
+			case 'gost1976874':
+			case 'isoir153':
+			case 'stsev35888':
+				return 'GOST_19768-74';
+
+			case 'csiso150':
+			case 'csiso150greekccitt':
+			case 'greekccitt':
+			case 'isoir150':
+				return 'greek-ccitt';
+
+			case 'csiso88greek7':
+			case 'greek7':
+			case 'isoir88':
+				return 'greek7';
+
+			case 'csiso18greek7old':
+			case 'greek7old':
+			case 'isoir18':
+				return 'greek7-old';
+
+			case 'cshpdesktop':
+			case 'hpdesktop':
+				return 'HP-DeskTop';
+
+			case 'cshplegal':
+			case 'hplegal':
+				return 'HP-Legal';
+
+			case 'cshpmath8':
+			case 'hpmath8':
+				return 'HP-Math8';
+
+			case 'cshppifont':
+			case 'hppifont':
+				return 'HP-Pi-font';
+
+			case 'cshproman8':
+			case 'hproman8':
+			case 'r8':
+			case 'roman8':
+				return 'hp-roman8';
+
+			case 'hzgb2312':
+				return 'HZ-GB-2312';
+
+			case 'csibmsymbols':
+			case 'ibmsymbols':
+				return 'IBM-Symbols';
+
+			case 'csibmthai':
+			case 'ibmthai':
+				return 'IBM-Thai';
+
+			case 'ccsid858':
+			case 'cp858':
+			case 'ibm858':
+			case 'pcmultilingual850euro':
+				return 'IBM00858';
+
+			case 'ccsid924':
+			case 'cp924':
+			case 'ebcdiclatin9euro':
+			case 'ibm924':
+				return 'IBM00924';
+
+			case 'ccsid1140':
+			case 'cp1140':
+			case 'ebcdicus37euro':
+			case 'ibm1140':
+				return 'IBM01140';
+
+			case 'ccsid1141':
+			case 'cp1141':
+			case 'ebcdicde273euro':
+			case 'ibm1141':
+				return 'IBM01141';
+
+			case 'ccsid1142':
+			case 'cp1142':
+			case 'ebcdicdk277euro':
+			case 'ebcdicno277euro':
+			case 'ibm1142':
+				return 'IBM01142';
+
+			case 'ccsid1143':
+			case 'cp1143':
+			case 'ebcdicfi278euro':
+			case 'ebcdicse278euro':
+			case 'ibm1143':
+				return 'IBM01143';
+
+			case 'ccsid1144':
+			case 'cp1144':
+			case 'ebcdicit280euro':
+			case 'ibm1144':
+				return 'IBM01144';
+
+			case 'ccsid1145':
+			case 'cp1145':
+			case 'ebcdices284euro':
+			case 'ibm1145':
+				return 'IBM01145';
+
+			case 'ccsid1146':
+			case 'cp1146':
+			case 'ebcdicgb285euro':
+			case 'ibm1146':
+				return 'IBM01146';
+
+			case 'ccsid1147':
+			case 'cp1147':
+			case 'ebcdicfr297euro':
+			case 'ibm1147':
+				return 'IBM01147';
+
+			case 'ccsid1148':
+			case 'cp1148':
+			case 'ebcdicinternational500euro':
+			case 'ibm1148':
+				return 'IBM01148';
+
+			case 'ccsid1149':
+			case 'cp1149':
+			case 'ebcdicis871euro':
+			case 'ibm1149':
+				return 'IBM01149';
+
+			case 'cp37':
+			case 'csibm37':
+			case 'ebcdiccpca':
+			case 'ebcdiccpnl':
+			case 'ebcdiccpus':
+			case 'ebcdiccpwt':
+			case 'ibm37':
+				return 'IBM037';
+
+			case 'cp38':
+			case 'csibm38':
+			case 'ebcdicint':
+			case 'ibm38':
+				return 'IBM038';
+
+			case 'cp273':
+			case 'csibm273':
+			case 'ibm273':
+				return 'IBM273';
+
+			case 'cp274':
+			case 'csibm274':
+			case 'ebcdicbe':
+			case 'ibm274':
+				return 'IBM274';
+
+			case 'cp275':
+			case 'csibm275':
+			case 'ebcdicbr':
+			case 'ibm275':
+				return 'IBM275';
+
+			case 'csibm277':
+			case 'ebcdiccpdk':
+			case 'ebcdiccpno':
+			case 'ibm277':
+				return 'IBM277';
+
+			case 'cp278':
+			case 'csibm278':
+			case 'ebcdiccpfi':
+			case 'ebcdiccpse':
+			case 'ibm278':
+				return 'IBM278';
+
+			case 'cp280':
+			case 'csibm280':
+			case 'ebcdiccpit':
+			case 'ibm280':
+				return 'IBM280';
+
+			case 'cp281':
+			case 'csibm281':
+			case 'ebcdicjpe':
+			case 'ibm281':
+				return 'IBM281';
+
+			case 'cp284':
+			case 'csibm284':
+			case 'ebcdiccpes':
+			case 'ibm284':
+				return 'IBM284';
+
+			case 'cp285':
+			case 'csibm285':
+			case 'ebcdiccpgb':
+			case 'ibm285':
+				return 'IBM285';
+
+			case 'cp290':
+			case 'csibm290':
+			case 'ebcdicjpkana':
+			case 'ibm290':
+				return 'IBM290';
+
+			case 'cp297':
+			case 'csibm297':
+			case 'ebcdiccpfr':
+			case 'ibm297':
+				return 'IBM297';
+
+			case 'cp420':
+			case 'csibm420':
+			case 'ebcdiccpar1':
+			case 'ibm420':
+				return 'IBM420';
+
+			case 'cp423':
+			case 'csibm423':
+			case 'ebcdiccpgr':
+			case 'ibm423':
+				return 'IBM423';
+
+			case 'cp424':
+			case 'csibm424':
+			case 'ebcdiccphe':
+			case 'ibm424':
+				return 'IBM424';
+
+			case '437':
+			case 'cp437':
+			case 'cspc8codepage437':
+			case 'ibm437':
+				return 'IBM437';
+
+			case 'cp500':
+			case 'csibm500':
+			case 'ebcdiccpbe':
+			case 'ebcdiccpch':
+			case 'ibm500':
+				return 'IBM500';
+
+			case 'cp775':
+			case 'cspc775baltic':
+			case 'ibm775':
+				return 'IBM775';
+
+			case '850':
+			case 'cp850':
+			case 'cspc850multilingual':
+			case 'ibm850':
+				return 'IBM850';
+
+			case '851':
+			case 'cp851':
+			case 'csibm851':
+			case 'ibm851':
+				return 'IBM851';
+
+			case '852':
+			case 'cp852':
+			case 'cspcp852':
+			case 'ibm852':
+				return 'IBM852';
+
+			case '855':
+			case 'cp855':
+			case 'csibm855':
+			case 'ibm855':
+				return 'IBM855';
+
+			case '857':
+			case 'cp857':
+			case 'csibm857':
+			case 'ibm857':
+				return 'IBM857';
+
+			case '860':
+			case 'cp860':
+			case 'csibm860':
+			case 'ibm860':
+				return 'IBM860';
+
+			case '861':
+			case 'cp861':
+			case 'cpis':
+			case 'csibm861':
+			case 'ibm861':
+				return 'IBM861';
+
+			case '862':
+			case 'cp862':
+			case 'cspc862latinhebrew':
+			case 'ibm862':
+				return 'IBM862';
+
+			case '863':
+			case 'cp863':
+			case 'csibm863':
+			case 'ibm863':
+				return 'IBM863';
+
+			case 'cp864':
+			case 'csibm864':
+			case 'ibm864':
+				return 'IBM864';
+
+			case '865':
+			case 'cp865':
+			case 'csibm865':
+			case 'ibm865':
+				return 'IBM865';
+
+			case '866':
+			case 'cp866':
+			case 'csibm866':
+			case 'ibm866':
+				return 'IBM866';
+
+			case 'cp868':
+			case 'cpar':
+			case 'csibm868':
+			case 'ibm868':
+				return 'IBM868';
+
+			case '869':
+			case 'cp869':
+			case 'cpgr':
+			case 'csibm869':
+			case 'ibm869':
+				return 'IBM869';
+
+			case 'cp870':
+			case 'csibm870':
+			case 'ebcdiccproece':
+			case 'ebcdiccpyu':
+			case 'ibm870':
+				return 'IBM870';
+
+			case 'cp871':
+			case 'csibm871':
+			case 'ebcdiccpis':
+			case 'ibm871':
+				return 'IBM871';
+
+			case 'cp880':
+			case 'csibm880':
+			case 'ebcdiccyrillic':
+			case 'ibm880':
+				return 'IBM880';
+
+			case 'cp891':
+			case 'csibm891':
+			case 'ibm891':
+				return 'IBM891';
+
+			case 'cp903':
+			case 'csibm903':
+			case 'ibm903':
+				return 'IBM903';
+
+			case '904':
+			case 'cp904':
+			case 'csibbm904':
+			case 'ibm904':
+				return 'IBM904';
+
+			case 'cp905':
+			case 'csibm905':
+			case 'ebcdiccptr':
+			case 'ibm905':
+				return 'IBM905';
+
+			case 'cp918':
+			case 'csibm918':
+			case 'ebcdiccpar2':
+			case 'ibm918':
+				return 'IBM918';
+
+			case 'cp1026':
+			case 'csibm1026':
+			case 'ibm1026':
+				return 'IBM1026';
+
+			case 'ibm1047':
+				return 'IBM1047';
+
+			case 'csiso143iecp271':
+			case 'iecp271':
+			case 'isoir143':
+				return 'IEC_P27-1';
+
+			case 'csiso49inis':
+			case 'inis':
+			case 'isoir49':
+				return 'INIS';
+
+			case 'csiso50inis8':
+			case 'inis8':
+			case 'isoir50':
+				return 'INIS-8';
+
+			case 'csiso51iniscyrillic':
+			case 'iniscyrillic':
+			case 'isoir51':
+				return 'INIS-cyrillic';
+
+			case 'csinvariant':
+			case 'invariant':
+				return 'INVARIANT';
+
+			case 'iso2022cn':
+				return 'ISO-2022-CN';
+
+			case 'iso2022cnext':
+				return 'ISO-2022-CN-EXT';
+
+			case 'csiso2022jp':
+			case 'iso2022jp':
+				return 'ISO-2022-JP';
+
+			case 'csiso2022jp2':
+			case 'iso2022jp2':
+				return 'ISO-2022-JP-2';
+
+			case 'csiso2022kr':
+			case 'iso2022kr':
+				return 'ISO-2022-KR';
+
+			case 'cswindows30latin1':
+			case 'iso88591windows30latin1':
+				return 'ISO-8859-1-Windows-3.0-Latin-1';
+
+			case 'cswindows31latin1':
+			case 'iso88591windows31latin1':
+				return 'ISO-8859-1-Windows-3.1-Latin-1';
+
+			case 'csisolatin2':
+			case 'iso88592':
+			case 'iso885921987':
+			case 'isoir101':
+			case 'l2':
+			case 'latin2':
+				return 'ISO-8859-2';
+
+			case 'cswindows31latin2':
+			case 'iso88592windowslatin2':
+				return 'ISO-8859-2-Windows-Latin-2';
+
+			case 'csisolatin3':
+			case 'iso88593':
+			case 'iso885931988':
+			case 'isoir109':
+			case 'l3':
+			case 'latin3':
+				return 'ISO-8859-3';
+
+			case 'csisolatin4':
+			case 'iso88594':
+			case 'iso885941988':
+			case 'isoir110':
+			case 'l4':
+			case 'latin4':
+				return 'ISO-8859-4';
+
+			case 'csisolatincyrillic':
+			case 'cyrillic':
+			case 'iso88595':
+			case 'iso885951988':
+			case 'isoir144':
+				return 'ISO-8859-5';
+
+			case 'arabic':
+			case 'asmo708':
+			case 'csisolatinarabic':
+			case 'ecma114':
+			case 'iso88596':
+			case 'iso885961987':
+			case 'isoir127':
+				return 'ISO-8859-6';
+
+			case 'csiso88596e':
+			case 'iso88596e':
+				return 'ISO-8859-6-E';
+
+			case 'csiso88596i':
+			case 'iso88596i':
+				return 'ISO-8859-6-I';
+
+			case 'csisolatingreek':
+			case 'ecma118':
+			case 'elot928':
+			case 'greek':
+			case 'greek8':
+			case 'iso88597':
+			case 'iso885971987':
+			case 'isoir126':
+				return 'ISO-8859-7';
+
+			case 'csisolatinhebrew':
+			case 'hebrew':
+			case 'iso88598':
+			case 'iso885981988':
+			case 'isoir138':
+				return 'ISO-8859-8';
+
+			case 'csiso88598e':
+			case 'iso88598e':
+				return 'ISO-8859-8-E';
+
+			case 'csiso88598i':
+			case 'iso88598i':
+				return 'ISO-8859-8-I';
+
+			case 'cswindows31latin5':
+			case 'iso88599windowslatin5':
+				return 'ISO-8859-9-Windows-Latin-5';
+
+			case 'csisolatin6':
+			case 'iso885910':
+			case 'iso8859101992':
+			case 'isoir157':
+			case 'l6':
+			case 'latin6':
+				return 'ISO-8859-10';
+
+			case 'iso885913':
+				return 'ISO-8859-13';
+
+			case 'iso885914':
+			case 'iso8859141998':
+			case 'isoceltic':
+			case 'isoir199':
+			case 'l8':
+			case 'latin8':
+				return 'ISO-8859-14';
+
+			case 'iso885915':
+			case 'latin9':
+				return 'ISO-8859-15';
+
+			case 'iso885916':
+			case 'iso8859162001':
+			case 'isoir226':
+			case 'l10':
+			case 'latin10':
+				return 'ISO-8859-16';
+
+			case 'iso10646j1':
+				return 'ISO-10646-J-1';
+
+			case 'csunicode':
+			case 'iso10646ucs2':
+				return 'ISO-10646-UCS-2';
+
+			case 'csucs4':
+			case 'iso10646ucs4':
+				return 'ISO-10646-UCS-4';
+
+			case 'csunicodeascii':
+			case 'iso10646ucsbasic':
+				return 'ISO-10646-UCS-Basic';
+
+			case 'csunicodelatin1':
+			case 'iso10646':
+			case 'iso10646unicodelatin1':
+				return 'ISO-10646-Unicode-Latin1';
+
+			case 'csiso10646utf1':
+			case 'iso10646utf1':
+				return 'ISO-10646-UTF-1';
+
+			case 'csiso115481':
+			case 'iso115481':
+			case 'isotr115481':
+				return 'ISO-11548-1';
+
+			case 'csiso90':
+			case 'isoir90':
+				return 'iso-ir-90';
+
+			case 'csunicodeibm1261':
+			case 'isounicodeibm1261':
+				return 'ISO-Unicode-IBM-1261';
+
+			case 'csunicodeibm1264':
+			case 'isounicodeibm1264':
+				return 'ISO-Unicode-IBM-1264';
+
+			case 'csunicodeibm1265':
+			case 'isounicodeibm1265':
+				return 'ISO-Unicode-IBM-1265';
+
+			case 'csunicodeibm1268':
+			case 'isounicodeibm1268':
+				return 'ISO-Unicode-IBM-1268';
+
+			case 'csunicodeibm1276':
+			case 'isounicodeibm1276':
+				return 'ISO-Unicode-IBM-1276';
+
+			case 'csiso646basic1983':
+			case 'iso646basic1983':
+			case 'ref':
+				return 'ISO_646.basic:1983';
+
+			case 'csiso2intlrefversion':
+			case 'irv':
+			case 'iso646irv1983':
+			case 'isoir2':
+				return 'ISO_646.irv:1983';
+
+			case 'csiso2033':
+			case 'e13b':
+			case 'iso20331983':
+			case 'isoir98':
+				return 'ISO_2033-1983';
+
+			case 'csiso5427cyrillic':
+			case 'iso5427':
+			case 'isoir37':
+				return 'ISO_5427';
+
+			case 'iso5427cyrillic1981':
+			case 'iso54271981':
+			case 'isoir54':
+				return 'ISO_5427:1981';
+
+			case 'csiso5428greek':
+			case 'iso54281980':
+			case 'isoir55':
+				return 'ISO_5428:1980';
+
+			case 'csiso6937add':
+			case 'iso6937225':
+			case 'isoir152':
+				return 'ISO_6937-2-25';
+
+			case 'csisotextcomm':
+			case 'iso69372add':
+			case 'isoir142':
+				return 'ISO_6937-2-add';
+
+			case 'csiso8859supp':
+			case 'iso8859supp':
+			case 'isoir154':
+			case 'latin125':
+				return 'ISO_8859-supp';
+
+			case 'csiso10367box':
+			case 'iso10367box':
+			case 'isoir155':
+				return 'ISO_10367-box';
+
+			case 'csiso15italian':
+			case 'iso646it':
+			case 'isoir15':
+			case 'it':
+				return 'IT';
+
+			case 'csiso13jisc6220jp':
+			case 'isoir13':
+			case 'jisc62201969':
+			case 'jisc62201969jp':
+			case 'katakana':
+			case 'x2017':
+				return 'JIS_C6220-1969-jp';
+
+			case 'csiso14jisc6220ro':
+			case 'iso646jp':
+			case 'isoir14':
+			case 'jisc62201969ro':
+			case 'jp':
+				return 'JIS_C6220-1969-ro';
+
+			case 'csiso42jisc62261978':
+			case 'isoir42':
+			case 'jisc62261978':
+				return 'JIS_C6226-1978';
+
+			case 'csiso87jisx208':
+			case 'isoir87':
+			case 'jisc62261983':
+			case 'jisx2081983':
+			case 'x208':
+				return 'JIS_C6226-1983';
+
+			case 'csiso91jisc62291984a':
+			case 'isoir91':
+			case 'jisc62291984a':
+			case 'jpocra':
+				return 'JIS_C6229-1984-a';
+
+			case 'csiso92jisc62991984b':
+			case 'iso646jpocrb':
+			case 'isoir92':
+			case 'jisc62291984b':
+			case 'jpocrb':
+				return 'JIS_C6229-1984-b';
+
+			case 'csiso93jis62291984badd':
+			case 'isoir93':
+			case 'jisc62291984badd':
+			case 'jpocrbadd':
+				return 'JIS_C6229-1984-b-add';
+
+			case 'csiso94jis62291984hand':
+			case 'isoir94':
+			case 'jisc62291984hand':
+			case 'jpocrhand':
+				return 'JIS_C6229-1984-hand';
+
+			case 'csiso95jis62291984handadd':
+			case 'isoir95':
+			case 'jisc62291984handadd':
+			case 'jpocrhandadd':
+				return 'JIS_C6229-1984-hand-add';
+
+			case 'csiso96jisc62291984kana':
+			case 'isoir96':
+			case 'jisc62291984kana':
+				return 'JIS_C6229-1984-kana';
+
+			case 'csjisencoding':
+			case 'jisencoding':
+				return 'JIS_Encoding';
+
+			case 'cshalfwidthkatakana':
+			case 'jisx201':
+			case 'x201':
+				return 'JIS_X0201';
+
+			case 'csiso159jisx2121990':
+			case 'isoir159':
+			case 'jisx2121990':
+			case 'x212':
+				return 'JIS_X0212-1990';
+
+			case 'csiso141jusib1002':
+			case 'iso646yu':
+			case 'isoir141':
+			case 'js':
+			case 'jusib1002':
+			case 'yu':
+				return 'JUS_I.B1.002';
+
+			case 'csiso147macedonian':
+			case 'isoir147':
+			case 'jusib1003mac':
+			case 'macedonian':
+				return 'JUS_I.B1.003-mac';
+
+			case 'csiso146serbian':
+			case 'isoir146':
+			case 'jusib1003serb':
+			case 'serbian':
+				return 'JUS_I.B1.003-serb';
+
+			case 'koi7switched':
+				return 'KOI7-switched';
+
+			case 'cskoi8r':
+			case 'koi8r':
+				return 'KOI8-R';
+
+			case 'koi8u':
+				return 'KOI8-U';
+
+			case 'csksc5636':
+			case 'iso646kr':
+			case 'ksc5636':
+				return 'KSC5636';
+
+			case 'cskz1048':
+			case 'kz1048':
+			case 'rk1048':
+			case 'strk10482002':
+				return 'KZ-1048';
+
+			case 'csiso19latingreek':
+			case 'isoir19':
+			case 'latingreek':
+				return 'latin-greek';
+
+			case 'csiso27latingreek1':
+			case 'isoir27':
+			case 'latingreek1':
+				return 'Latin-greek-1';
+
+			case 'csiso158lap':
+			case 'isoir158':
+			case 'lap':
+			case 'latinlap':
+				return 'latin-lap';
+
+			case 'csmacintosh':
+			case 'mac':
+			case 'macintosh':
+				return 'macintosh';
+
+			case 'csmicrosoftpublishing':
+			case 'microsoftpublishing':
+				return 'Microsoft-Publishing';
+
+			case 'csmnem':
+			case 'mnem':
+				return 'MNEM';
+
+			case 'csmnemonic':
+			case 'mnemonic':
+				return 'MNEMONIC';
+
+			case 'csiso86hungarian':
+			case 'hu':
+			case 'iso646hu':
+			case 'isoir86':
+			case 'msz77953':
+				return 'MSZ_7795.3';
+
+			case 'csnatsdano':
+			case 'isoir91':
+			case 'natsdano':
+				return 'NATS-DANO';
+
+			case 'csnatsdanoadd':
+			case 'isoir92':
+			case 'natsdanoadd':
+				return 'NATS-DANO-ADD';
+
+			case 'csnatssefi':
+			case 'isoir81':
+			case 'natssefi':
+				return 'NATS-SEFI';
+
+			case 'csnatssefiadd':
+			case 'isoir82':
+			case 'natssefiadd':
+				return 'NATS-SEFI-ADD';
+
+			case 'csiso151cuba':
+			case 'cuba':
+			case 'iso646cu':
+			case 'isoir151':
+			case 'ncnc1081':
+				return 'NC_NC00-10:81';
+
+			case 'csiso69french':
+			case 'fr':
+			case 'iso646fr':
+			case 'isoir69':
+			case 'nfz62010':
+				return 'NF_Z_62-010';
+
+			case 'csiso25french':
+			case 'iso646fr1':
+			case 'isoir25':
+			case 'nfz620101973':
+				return 'NF_Z_62-010_(1973)';
+
+			case 'csiso60danishnorwegian':
+			case 'csiso60norwegian1':
+			case 'iso646no':
+			case 'isoir60':
+			case 'no':
+			case 'ns45511':
+				return 'NS_4551-1';
+
+			case 'csiso61norwegian2':
+			case 'iso646no2':
+			case 'isoir61':
+			case 'no2':
+			case 'ns45512':
+				return 'NS_4551-2';
+
+			case 'osdebcdicdf3irv':
+				return 'OSD_EBCDIC_DF03_IRV';
+
+			case 'osdebcdicdf41':
+				return 'OSD_EBCDIC_DF04_1';
+
+			case 'osdebcdicdf415':
+				return 'OSD_EBCDIC_DF04_15';
+
+			case 'cspc8danishnorwegian':
+			case 'pc8danishnorwegian':
+				return 'PC8-Danish-Norwegian';
+
+			case 'cspc8turkish':
+			case 'pc8turkish':
+				return 'PC8-Turkish';
+
+			case 'csiso16portuguese':
+			case 'iso646pt':
+			case 'isoir16':
+			case 'pt':
+				return 'PT';
+
+			case 'csiso84portuguese2':
+			case 'iso646pt2':
+			case 'isoir84':
+			case 'pt2':
+				return 'PT2';
+
+			case 'cp154':
+			case 'csptcp154':
+			case 'cyrillicasian':
+			case 'pt154':
+			case 'ptcp154':
+				return 'PTCP154';
+
+			case 'scsu':
+				return 'SCSU';
+
+			case 'csiso10swedish':
+			case 'fi':
+			case 'iso646fi':
+			case 'iso646se':
+			case 'isoir10':
+			case 'se':
+			case 'sen850200b':
+				return 'SEN_850200_B';
+
+			case 'csiso11swedishfornames':
+			case 'iso646se2':
+			case 'isoir11':
+			case 'se2':
+			case 'sen850200c':
+				return 'SEN_850200_C';
+
+			case 'csshiftjis':
+			case 'mskanji':
+			case 'shiftjis':
+				return 'Shift_JIS';
+
+			case 'csiso102t617bit':
+			case 'isoir102':
+			case 't617bit':
+				return 'T.61-7bit';
+
+			case 'csiso103t618bit':
+			case 'isoir103':
+			case 't61':
+			case 't618bit':
+				return 'T.61-8bit';
+
+			case 'csiso128t101g2':
+			case 'isoir128':
+			case 't101g2':
+				return 'T.101-G2';
+
+			case 'cstscii':
+			case 'tscii':
+				return 'TSCII';
+
+			case 'csunicode11':
+			case 'unicode11':
+				return 'UNICODE-1-1';
+
+			case 'csunicode11utf7':
+			case 'unicode11utf7':
+				return 'UNICODE-1-1-UTF-7';
+
+			case 'csunknown8bit':
+			case 'unknown8bit':
+				return 'UNKNOWN-8BIT';
+
+			case 'ansix341968':
+			case 'ansix341986':
+			case 'ascii':
+			case 'cp367':
+			case 'csascii':
+			case 'ibm367':
+			case 'iso646irv1991':
+			case 'iso646us':
+			case 'isoir6':
+			case 'us':
+			case 'usascii':
+				return 'US-ASCII';
+
+			case 'csusdk':
+			case 'usdk':
+				return 'us-dk';
+
+			case 'utf7':
+				return 'UTF-7';
+
+			case 'utf8':
+				return 'UTF-8';
+
+			case 'utf16':
+				return 'UTF-16';
+
+			case 'utf16be':
+				return 'UTF-16BE';
+
+			case 'utf16le':
+				return 'UTF-16LE';
+
+			case 'utf32':
+				return 'UTF-32';
+
+			case 'utf32be':
+				return 'UTF-32BE';
+
+			case 'utf32le':
+				return 'UTF-32LE';
+
+			case 'csventurainternational':
+			case 'venturainternational':
+				return 'Ventura-International';
+
+			case 'csventuramath':
+			case 'venturamath':
+				return 'Ventura-Math';
+
+			case 'csventuraus':
+			case 'venturaus':
+				return 'Ventura-US';
+
+			case 'csiso70videotexsupp1':
+			case 'isoir70':
+			case 'videotexsuppl':
+				return 'videotex-suppl';
+
+			case 'csviqr':
+			case 'viqr':
+				return 'VIQR';
+
+			case 'csviscii':
+			case 'viscii':
+				return 'VISCII';
+
+			case 'cswindows31j':
+			case 'windows31j':
+				return 'Windows-31J';
+
+			case 'iso885911':
+			case 'tis620':
+				return 'windows-874';
+
+			case 'cseuckr':
+			case 'csksc56011987':
+			case 'euckr':
+			case 'isoir149':
+			case 'korean':
+			case 'ksc5601':
+			case 'ksc56011987':
+			case 'ksc56011989':
+			case 'windows949':
+				return 'windows-949';
+
+			case 'windows1250':
+				return 'windows-1250';
+
+			case 'windows1251':
+				return 'windows-1251';
+
+			case 'cp819':
+			case 'csisolatin1':
+			case 'ibm819':
+			case 'iso88591':
+			case 'iso885911987':
+			case 'isoir100':
+			case 'l1':
+			case 'latin1':
+			case 'windows1252':
+				return 'windows-1252';
+
+			case 'windows1253':
+				return 'windows-1253';
+
+			case 'csisolatin5':
+			case 'iso88599':
+			case 'iso885991989':
+			case 'isoir148':
+			case 'l5':
+			case 'latin5':
+			case 'windows1254':
+				return 'windows-1254';
+
+			case 'windows1255':
+				return 'windows-1255';
+
+			case 'windows1256':
+				return 'windows-1256';
+
+			case 'windows1257':
+				return 'windows-1257';
+
+			case 'windows1258':
+				return 'windows-1258';
+
+			default:
+				return $charset;
+		}
+	}
+
+	function get_curl_version()
+	{
+		if (is_array($curl = curl_version()))
+		{
+			$curl = $curl['version'];
+		}
+		elseif (substr($curl, 0, 5) === 'curl/')
+		{
+			$curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
+		}
+		elseif (substr($curl, 0, 8) === 'libcurl/')
+		{
+			$curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
+		}
+		else
+		{
+			$curl = 0;
+		}
+		return $curl;
+	}
+
+	function is_subclass_of($class1, $class2)
+	{
+		if (func_num_args() !== 2)
+		{
+			trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING);
+		}
+		elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1))
+		{
+			return is_subclass_of($class1, $class2);
+		}
+		elseif (is_string($class1) && is_string($class2))
+		{
+			if (class_exists($class1))
+			{
+				if (class_exists($class2))
+				{
+					$class2 = strtolower($class2);
+					while ($class1 = strtolower(get_parent_class($class1)))
+					{
+						if ($class1 === $class2)
+						{
+							return true;
+						}
+					}
+				}
+			}
+			else
+			{
+				trigger_error('Unknown class passed as parameter', E_USER_WARNNG);
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Strip HTML comments
+	 *
+	 * @access public
+	 * @param string $data Data to strip comments from
+	 * @return string Comment stripped string
+	 */
+	function strip_comments($data)
+	{
+		$output = '';
+		while (($start = strpos($data, '<!--')) !== false)
+		{
+			$output .= substr($data, 0, $start);
+			if (($end = strpos($data, '-->', $start)) !== false)
+			{
+				$data = substr_replace($data, '', 0, $end + 3);
+			}
+			else
+			{
+				$data = '';
+			}
+		}
+		return $output . $data;
+	}
+
+	function parse_date($dt)
+	{
+		$parser = SimplePie_Parse_Date::get();
+		return $parser->parse($dt);
+	}
+
+	/**
+	 * Decode HTML entities
+	 *
+	 * @static
+	 * @access public
+	 * @param string $data Input data
+	 * @return string Output data
+	 */
+	function entities_decode($data)
+	{
+		$decoder =& new SimplePie_Decode_HTML_Entities($data);
+		return $decoder->parse();
+	}
+
+	/**
+	 * Remove RFC822 comments
+	 *
+	 * @access public
+	 * @param string $data Data to strip comments from
+	 * @return string Comment stripped string
+	 */
+	function uncomment_rfc822($string)
+	{
+		$string = (string) $string;
+		$position = 0;
+		$length = strlen($string);
+		$depth = 0;
+
+		$output = '';
+
+		while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
+		{
+			$output .= substr($string, $position, $pos - $position);
+			$position = $pos + 1;
+			if ($string[$pos - 1] !== '\\')
+			{
+				$depth++;
+				while ($depth && $position < $length)
+				{
+					$position += strcspn($string, '()', $position);
+					if ($string[$position - 1] === '\\')
+					{
+						$position++;
+						continue;
+					}
+					elseif (isset($string[$position]))
+					{
+						switch ($string[$position])
+						{
+							case '(':
+								$depth++;
+								break;
+
+							case ')':
+								$depth--;
+								break;
+						}
+						$position++;
+					}
+					else
+					{
+						break;
+					}
+				}
+			}
+			else
+			{
+				$output .= '(';
+			}
+		}
+		$output .= substr($string, $position);
+
+		return $output;
+	}
+
+	function parse_mime($mime)
+	{
+		if (($pos = strpos($mime, ';')) === false)
+		{
+			return trim($mime);
+		}
+		else
+		{
+			return trim(substr($mime, 0, $pos));
+		}
+	}
+
+	function htmlspecialchars_decode($string, $quote_style)
+	{
+		if (function_exists('htmlspecialchars_decode'))
+		{
+			return htmlspecialchars_decode($string, $quote_style);
+		}
+		else
+		{
+			return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
+		}
+	}
+
+	function atom_03_construct_type($attribs)
+	{
+		if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
+		{
+			$mode = SIMPLEPIE_CONSTRUCT_BASE64;
+		}
+		else
+		{
+			$mode = SIMPLEPIE_CONSTRUCT_NONE;
+		}
+		if (isset($attribs['']['type']))
+		{
+			switch (strtolower(trim($attribs['']['type'])))
+			{
+				case 'text':
+				case 'text/plain':
+					return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
+
+				case 'html':
+				case 'text/html':
+					return SIMPLEPIE_CONSTRUCT_HTML | $mode;
+
+				case 'xhtml':
+				case 'application/xhtml+xml':
+					return SIMPLEPIE_CONSTRUCT_XHTML | $mode;
+
+				default:
+					return SIMPLEPIE_CONSTRUCT_NONE | $mode;
+			}
+		}
+		else
+		{
+			return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
+		}
+	}
+
+	function atom_10_construct_type($attribs)
+	{
+		if (isset($attribs['']['type']))
+		{
+			switch (strtolower(trim($attribs['']['type'])))
+			{
+				case 'text':
+					return SIMPLEPIE_CONSTRUCT_TEXT;
+
+				case 'html':
+					return SIMPLEPIE_CONSTRUCT_HTML;
+
+				case 'xhtml':
+					return SIMPLEPIE_CONSTRUCT_XHTML;
+
+				default:
+					return SIMPLEPIE_CONSTRUCT_NONE;
+			}
+		}
+		return SIMPLEPIE_CONSTRUCT_TEXT;
+	}
+
+	function atom_10_content_construct_type($attribs)
+	{
+		if (isset($attribs['']['type']))
+		{
+			$type = strtolower(trim($attribs['']['type']));
+			switch ($type)
+			{
+				case 'text':
+					return SIMPLEPIE_CONSTRUCT_TEXT;
+
+				case 'html':
+					return SIMPLEPIE_CONSTRUCT_HTML;
+
+				case 'xhtml':
+					return SIMPLEPIE_CONSTRUCT_XHTML;
+			}
+			if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
+			{
+				return SIMPLEPIE_CONSTRUCT_NONE;
+			}
+			else
+			{
+				return SIMPLEPIE_CONSTRUCT_BASE64;
+			}
+		}
+		else
+		{
+			return SIMPLEPIE_CONSTRUCT_TEXT;
+		}
+	}
+
+	function is_isegment_nz_nc($string)
+	{
+		return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
+	}
+
+	function space_seperated_tokens($string)
+	{
+		$space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
+		$string_length = strlen($string);
+
+		$position = strspn($string, $space_characters);
+		$tokens = array();
+
+		while ($position < $string_length)
+		{
+			$len = strcspn($string, $space_characters, $position);
+			$tokens[] = substr($string, $position, $len);
+			$position += $len;
+			$position += strspn($string, $space_characters, $position);
+		}
+
+		return $tokens;
+	}
+
+	function array_unique($array)
+	{
+		if (version_compare(PHP_VERSION, '5.2', '>='))
+		{
+			return array_unique($array);
+		}
+		else
+		{
+			$array = (array) $array;
+			$new_array = array();
+			$new_array_strings = array();
+			foreach ($array as $key => $value)
+			{
+				if (is_object($value))
+				{
+					if (method_exists($value, '__toString'))
+					{
+						$cmp = $value->__toString();
+					}
+					else
+					{
+						trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR);
+					}
+				}
+				elseif (is_array($value))
+				{
+					$cmp = (string) reset($value);
+				}
+				else
+				{
+					$cmp = (string) $value;
+				}
+				if (!in_array($cmp, $new_array_strings))
+				{
+					$new_array[$key] = $value;
+					$new_array_strings[] = $cmp;
+				}
+			}
+			return $new_array;
+		}
+	}
+
+	/**
+	 * Converts a unicode codepoint to a UTF-8 character
+	 *
+	 * @static
+	 * @access public
+	 * @param int $codepoint Unicode codepoint
+	 * @return string UTF-8 character
+	 */
+	function codepoint_to_utf8($codepoint)
+	{
+		$codepoint = (int) $codepoint;
+		if ($codepoint < 0)
+		{
+			return false;
+		}
+		else if ($codepoint <= 0x7f)
+		{
+			return chr($codepoint);
+		}
+		else if ($codepoint <= 0x7ff)
+		{
+			return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
+		}
+		else if ($codepoint <= 0xffff)
+		{
+			return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
+		}
+		else if ($codepoint <= 0x10ffff)
+		{
+			return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
+		}
+		else
+		{
+			// U+FFFD REPLACEMENT CHARACTER
+			return "\xEF\xBF\xBD";
+		}
+	}
+
+	/**
+	 * Re-implementation of PHP 5's stripos()
+	 *
+	 * Returns the numeric position of the first occurrence of needle in the
+	 * haystack string.
+	 *
+	 * @static
+	 * @access string
+	 * @param object $haystack
+	 * @param string $needle Note that the needle may be a string of one or more
+	 *     characters. If needle is not a string, it is converted to an integer
+	 *     and applied as the ordinal value of a character.
+	 * @param int $offset The optional offset parameter allows you to specify which
+	 *     character in haystack to start searching. The position returned is still
+	 *     relative to the beginning of haystack.
+	 * @return bool If needle is not found, stripos() will return boolean false.
+	 */
+	function stripos($haystack, $needle, $offset = 0)
+	{
+		if (function_exists('stripos'))
+		{
+			return stripos($haystack, $needle, $offset);
+		}
+		else
+		{
+			if (is_string($needle))
+			{
+				$needle = strtolower($needle);
+			}
+			elseif (is_int($needle) || is_bool($needle) || is_double($needle))
+			{
+				$needle = strtolower(chr($needle));
+			}
+			else
+			{
+				trigger_error('needle is not a string or an integer', E_USER_WARNING);
+				return false;
+			}
+
+			return strpos(strtolower($haystack), $needle, $offset);
+		}
+	}
+
+	/**
+	 * Similar to parse_str()
+	 *
+	 * Returns an associative array of name/value pairs, where the value is an
+	 * array of values that have used the same name
+	 *
+	 * @static
+	 * @access string
+	 * @param string $str The input string.
+	 * @return array
+	 */
+	function parse_str($str)
+	{
+		$return = array();
+		$str = explode('&', $str);
+
+		foreach ($str as $section)
+		{
+			if (strpos($section, '=') !== false)
+			{
+				list($name, $value) = explode('=', $section, 2);
+				$return[urldecode($name)][] = urldecode($value);
+			}
+			else
+			{
+				$return[urldecode($section)][] = null;
+			}
+		}
+
+		return $return;
+	}
+
+	/**
+	 * Detect XML encoding, as per XML 1.0 Appendix F.1
+	 *
+	 * @todo Add support for EBCDIC
+	 * @param string $data XML data
+	 * @return array Possible encodings
+	 */
+	function xml_encoding($data)
+	{
+		// UTF-32 Big Endian BOM
+		if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
+		{
+			$encoding[] = 'UTF-32BE';
+		}
+		// UTF-32 Little Endian BOM
+		elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
+		{
+			$encoding[] = 'UTF-32LE';
+		}
+		// UTF-16 Big Endian BOM
+		elseif (substr($data, 0, 2) === "\xFE\xFF")
+		{
+			$encoding[] = 'UTF-16BE';
+		}
+		// UTF-16 Little Endian BOM
+		elseif (substr($data, 0, 2) === "\xFF\xFE")
+		{
+			$encoding[] = 'UTF-16LE';
+		}
+		// UTF-8 BOM
+		elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
+		{
+			$encoding[] = 'UTF-8';
+		}
+		// UTF-32 Big Endian Without BOM
+		elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
+		{
+			if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E"))
+			{
+				$parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8'));
+				if ($parser->parse())
+				{
+					$encoding[] = $parser->encoding;
+				}
+			}
+			$encoding[] = 'UTF-32BE';
+		}
+		// UTF-32 Little Endian Without BOM
+		elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
+		{
+			if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00"))
+			{
+				$parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8'));
+				if ($parser->parse())
+				{
+					$encoding[] = $parser->encoding;
+				}
+			}
+			$encoding[] = 'UTF-32LE';
+		}
+		// UTF-16 Big Endian Without BOM
+		elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
+		{
+			if ($pos = strpos($data, "\x00\x3F\x00\x3E"))
+			{
+				$parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8'));
+				if ($parser->parse())
+				{
+					$encoding[] = $parser->encoding;
+				}
+			}
+			$encoding[] = 'UTF-16BE';
+		}
+		// UTF-16 Little Endian Without BOM
+		elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
+		{
+			if ($pos = strpos($data, "\x3F\x00\x3E\x00"))
+			{
+				$parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8'));
+				if ($parser->parse())
+				{
+					$encoding[] = $parser->encoding;
+				}
+			}
+			$encoding[] = 'UTF-16LE';
+		}
+		// US-ASCII (or superset)
+		elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C")
+		{
+			if ($pos = strpos($data, "\x3F\x3E"))
+			{
+				$parser =& new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
+				if ($parser->parse())
+				{
+					$encoding[] = $parser->encoding;
+				}
+			}
+			$encoding[] = 'UTF-8';
+		}
+		// Fallback to UTF-8
+		else
+		{
+			$encoding[] = 'UTF-8';
+		}
+		return $encoding;
+	}
+
+	function output_javascript()
+	{
+		if (function_exists('ob_gzhandler'))
+		{
+			ob_start('ob_gzhandler');
+		}
+		header('Content-type: text/javascript; charset: UTF-8');
+		header('Cache-Control: must-revalidate');
+		header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
+		?>
+function embed_odeo(link) {
+	document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>');
+}
+
+function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
+	if (placeholder != '') {
+		document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
+	}
+	else {
+		document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
+	}
+}
+
+function embed_flash(bgcolor, width, height, link, loop, type) {
+	document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
+}
+
+function embed_flv(width, height, link, placeholder, loop, player) {
+	document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
+}
+
+function embed_wmedia(width, height, link) {
+	document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
+}
+		<?php
+	}
+}
+
+/**
+ * Decode HTML Entities
+ *
+ * This implements HTML5 as of revision 967 (2007-06-28)
+ *
+ * @package SimplePie
+ */
+class SimplePie_Decode_HTML_Entities
+{
+	/**
+	 * Data to be parsed
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $data = '';
+
+	/**
+	 * Currently consumed bytes
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $consumed = '';
+
+	/**
+	 * Position of the current byte being parsed
+	 *
+	 * @access private
+	 * @var int
+	 */
+	var $position = 0;
+
+	/**
+	 * Create an instance of the class with the input data
+	 *
+	 * @access public
+	 * @param string $data Input data
+	 */
+	function SimplePie_Decode_HTML_Entities($data)
+	{
+		$this->data = $data;
+	}
+
+	/**
+	 * Parse the input data
+	 *
+	 * @access public
+	 * @return string Output data
+	 */
+	function parse()
+	{
+		while (($this->position = strpos($this->data, '&', $this->position)) !== false)
+		{
+			$this->consume();
+			$this->entity();
+			$this->consumed = '';
+		}
+		return $this->data;
+	}
+
+	/**
+	 * Consume the next byte
+	 *
+	 * @access private
+	 * @return mixed The next byte, or false, if there is no more data
+	 */
+	function consume()
+	{
+		if (isset($this->data[$this->position]))
+		{
+			$this->consumed .= $this->data[$this->position];
+			return $this->data[$this->position++];
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Consume a range of characters
+	 *
+	 * @access private
+	 * @param string $chars Characters to consume
+	 * @return mixed A series of characters that match the range, or false
+	 */
+	function consume_range($chars)
+	{
+		if ($len = strspn($this->data, $chars, $this->position))
+		{
+			$data = substr($this->data, $this->position, $len);
+			$this->consumed .= $data;
+			$this->position += $len;
+			return $data;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Unconsume one byte
+	 *
+	 * @access private
+	 */
+	function unconsume()
+	{
+		$this->consumed = substr($this->consumed, 0, -1);
+		$this->position--;
+	}
+
+	/**
+	 * Decode an entity
+	 *
+	 * @access private
+	 */
+	function entity()
+	{
+		switch ($this->consume())
+		{
+			case "\x09":
+			case "\x0A":
+			case "\x0B":
+			case "\x0B":
+			case "\x0C":
+			case "\x20":
+			case "\x3C":
+			case "\x26":
+			case false:
+				break;
+
+			case "\x23":
+				switch ($this->consume())
+				{
+					case "\x78":
+					case "\x58":
+						$range = '0123456789ABCDEFabcdef';
+						$hex = true;
+						break;
+
+					default:
+						$range = '0123456789';
+						$hex = false;
+						$this->unconsume();
+						break;
+				}
+
+				if ($codepoint = $this->consume_range($range))
+				{
+					static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8");
+
+					if ($hex)
+					{
+						$codepoint = hexdec($codepoint);
+					}
+					else
+					{
+						$codepoint = intval($codepoint);
+					}
+
+					if (isset($windows_1252_specials[$codepoint]))
+					{
+						$replacement = $windows_1252_specials[$codepoint];
+					}
+					else
+					{
+						$replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
+					}
+
+					if (!in_array($this->consume(), array(';', false), true))
+					{
+						$this->unconsume();
+					}
+
+					$consumed_length = strlen($this->consumed);
+					$this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
+					$this->position += strlen($replacement) - $consumed_length;
+				}
+				break;
+
+			default:
+				static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C");
+
+				for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++)
+				{
+					$consumed = substr($this->consumed, 1);
+					if (isset($entities[$consumed]))
+					{
+						$match = $consumed;
+					}
+				}
+
+				if ($match !== null)
+				{
+ 					$this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
+					$this->position += strlen($entities[$match]) - strlen($consumed) - 1;
+				}
+				break;
+		}
+	}
+}
+
+/**
+ * IRI parser/serialiser
+ *
+ * @package SimplePie
+ */
+class SimplePie_IRI
+{
+	/**
+	 * Scheme
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $scheme;
+
+	/**
+	 * User Information
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $userinfo;
+
+	/**
+	 * Host
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $host;
+
+	/**
+	 * Port
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $port;
+
+	/**
+	 * Path
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $path;
+
+	/**
+	 * Query
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $query;
+
+	/**
+	 * Fragment
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $fragment;
+
+	/**
+	 * Whether the object represents a valid IRI
+	 *
+	 * @access private
+	 * @var array
+	 */
+	var $valid = array();
+
+	/**
+	 * Return the entire IRI when you try and read the object as a string
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function __toString()
+	{
+		return $this->get_iri();
+	}
+
+	/**
+	 * Create a new IRI object, from a specified string
+	 *
+	 * @access public
+	 * @param string $iri
+	 * @return SimplePie_IRI
+	 */
+	function SimplePie_IRI($iri)
+	{
+		$iri = (string) $iri;
+		if ($iri !== '')
+		{
+			$parsed = $this->parse_iri($iri);
+			$this->set_scheme($parsed['scheme']);
+			$this->set_authority($parsed['authority']);
+			$this->set_path($parsed['path']);
+			$this->set_query($parsed['query']);
+			$this->set_fragment($parsed['fragment']);
+		}
+	}
+
+	/**
+	 * Create a new IRI object by resolving a relative IRI
+	 *
+	 * @static
+	 * @access public
+	 * @param SimplePie_IRI $base Base IRI
+	 * @param string $relative Relative IRI
+	 * @return SimplePie_IRI
+	 */
+	function absolutize($base, $relative)
+	{
+		$relative = (string) $relative;
+		if ($relative !== '')
+		{
+			$relative =& new SimplePie_IRI($relative);
+			if ($relative->get_scheme() !== null)
+			{
+				$target = $relative;
+			}
+			elseif ($base->get_iri() !== null)
+			{
+				if ($relative->get_authority() !== null)
+				{
+					$target = $relative;
+					$target->set_scheme($base->get_scheme());
+				}
+				else
+				{
+					$target =& new SimplePie_IRI('');
+					$target->set_scheme($base->get_scheme());
+					$target->set_userinfo($base->get_userinfo());
+					$target->set_host($base->get_host());
+					$target->set_port($base->get_port());
+					if ($relative->get_path() !== null)
+					{
+						if (strpos($relative->get_path(), '/') === 0)
+						{
+							$target->set_path($relative->get_path());
+						}
+						elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null)
+						{
+							$target->set_path('/' . $relative->get_path());
+						}
+						elseif (($last_segment = strrpos($base->get_path(), '/')) !== false)
+						{
+							$target->set_path(substr($base->get_path(), 0, $last_segment + 1) . $relative->get_path());
+						}
+						else
+						{
+							$target->set_path($relative->get_path());
+						}
+						$target->set_query($relative->get_query());
+					}
+					else
+					{
+						$target->set_path($base->get_path());
+						if ($relative->get_query() !== null)
+						{
+							$target->set_query($relative->get_query());
+						}
+						elseif ($base->get_query() !== null)
+						{
+							$target->set_query($base->get_query());
+						}
+					}
+				}
+				$target->set_fragment($relative->get_fragment());
+			}
+			else
+			{
+				// No base URL, just return the relative URL
+				$target = $relative;
+			}
+		}
+		else
+		{
+			$target = $base;
+		}
+		return $target;
+	}
+
+	/**
+	 * Parse an IRI into scheme/authority/path/query/fragment segments
+	 *
+	 * @access private
+	 * @param string $iri
+	 * @return array
+	 */
+	function parse_iri($iri)
+	{
+		preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $iri, $match);
+		for ($i = count($match); $i <= 9; $i++)
+		{
+			$match[$i] = '';
+		}
+		return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]);
+	}
+
+	/**
+	 * Remove dot segments from a path
+	 *
+	 * @access private
+	 * @param string $input
+	 * @return string
+	 */
+	function remove_dot_segments($input)
+	{
+		$output = '';
+		while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..')
+		{
+			// A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise,
+			if (strpos($input, '../') === 0)
+			{
+				$input = substr($input, 3);
+			}
+			elseif (strpos($input, './') === 0)
+			{
+				$input = substr($input, 2);
+			}
+			// B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise,
+			elseif (strpos($input, '/./') === 0)
+			{
+				$input = substr_replace($input, '/', 0, 3);
+			}
+			elseif ($input === '/.')
+			{
+				$input = '/';
+			}
+			// C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise,
+			elseif (strpos($input, '/../') === 0)
+			{
+				$input = substr_replace($input, '/', 0, 4);
+				$output = substr_replace($output, '', strrpos($output, '/'));
+			}
+			elseif ($input === '/..')
+			{
+				$input = '/';
+				$output = substr_replace($output, '', strrpos($output, '/'));
+			}
+			// D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise,
+			elseif ($input === '.' || $input === '..')
+			{
+				$input = '';
+			}
+			// E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer
+			elseif (($pos = strpos($input, '/', 1)) !== false)
+			{
+				$output .= substr($input, 0, $pos);
+				$input = substr_replace($input, '', 0, $pos);
+			}
+			else
+			{
+				$output .= $input;
+				$input = '';
+			}
+		}
+		return $output . $input;
+	}
+
+	/**
+	 * Replace invalid character with percent encoding
+	 *
+	 * @access private
+	 * @param string $string Input string
+	 * @param string $valid_chars Valid characters
+	 * @param int $case Normalise case
+	 * @return string
+	 */
+	function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE)
+	{
+		// Normalise case
+		if ($case & SIMPLEPIE_LOWERCASE)
+		{
+			$string = strtolower($string);
+		}
+		elseif ($case & SIMPLEPIE_UPPERCASE)
+		{
+			$string = strtoupper($string);
+		}
+
+		// Store position and string length (to avoid constantly recalculating this)
+		$position = 0;
+		$strlen = strlen($string);
+
+		// Loop as long as we have invalid characters, advancing the position to the next invalid character
+		while (($position += strspn($string, $valid_chars, $position)) < $strlen)
+		{
+			// If we have a % character
+			if ($string[$position] === '%')
+			{
+				// If we have a pct-encoded section
+				if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2)
+				{
+					// Get the the represented character
+					$chr = chr(hexdec(substr($string, $position + 1, 2)));
+
+					// If the character is valid, replace the pct-encoded with the actual character while normalising case
+					if (strpos($valid_chars, $chr) !== false)
+					{
+						if ($case & SIMPLEPIE_LOWERCASE)
+						{
+							$chr = strtolower($chr);
+						}
+						elseif ($case & SIMPLEPIE_UPPERCASE)
+						{
+							$chr = strtoupper($chr);
+						}
+						$string = substr_replace($string, $chr, $position, 3);
+						$strlen -= 2;
+						$position++;
+					}
+
+					// Otherwise just normalise the pct-encoded to uppercase
+					else
+					{
+						$string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2);
+						$position += 3;
+					}
+				}
+				// If we don't have a pct-encoded section, just replace the % with its own esccaped form
+				else
+				{
+					$string = substr_replace($string, '%25', $position, 1);
+					$strlen += 2;
+					$position += 3;
+				}
+			}
+			// If we have an invalid character, change into its pct-encoded form
+			else
+			{
+				$replacement = sprintf("%%%02X", ord($string[$position]));
+				$string = str_replace($string[$position], $replacement, $string);
+				$strlen = strlen($string);
+			}
+		}
+		return $string;
+	}
+
+	/**
+	 * Check if the object represents a valid IRI
+	 *
+	 * @access public
+	 * @return bool
+	 */
+	function is_valid()
+	{
+		return array_sum($this->valid) === count($this->valid);
+	}
+
+	/**
+	 * Set the scheme. Returns true on success, false on failure (if there are
+	 * any invalid characters).
+	 *
+	 * @access public
+	 * @param string $scheme
+	 * @return bool
+	 */
+	function set_scheme($scheme)
+	{
+		if ($scheme === null || $scheme === '')
+		{
+			$this->scheme = null;
+		}
+		else
+		{
+			$len = strlen($scheme);
+			switch (true)
+			{
+				case $len > 1:
+					if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1))
+					{
+						$this->scheme = null;
+						$this->valid[__FUNCTION__] = false;
+						return false;
+					}
+
+				case $len > 0:
+					if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1))
+					{
+						$this->scheme = null;
+						$this->valid[__FUNCTION__] = false;
+						return false;
+					}
+			}
+			$this->scheme = strtolower($scheme);
+		}
+		$this->valid[__FUNCTION__] = true;
+		return true;
+	}
+
+	/**
+	 * Set the authority. Returns true on success, false on failure (if there are
+	 * any invalid characters).
+	 *
+	 * @access public
+	 * @param string $authority
+	 * @return bool
+	 */
+	function set_authority($authority)
+	{
+		if (($userinfo_end = strrpos($authority, '@')) !== false)
+		{
+			$userinfo = substr($authority, 0, $userinfo_end);
+			$authority = substr($authority, $userinfo_end + 1);
+		}
+		else
+		{
+			$userinfo = null;
+		}
+
+		if (($port_start = strpos($authority, ':')) !== false)
+		{
+			$port = substr($authority, $port_start + 1);
+			$authority = substr($authority, 0, $port_start);
+		}
+		else
+		{
+			$port = null;
+		}
+
+		return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port);
+	}
+
+	/**
+	 * Set the userinfo.
+	 *
+	 * @access public
+	 * @param string $userinfo
+	 * @return bool
+	 */
+	function set_userinfo($userinfo)
+	{
+		if ($userinfo === null || $userinfo === '')
+		{
+			$this->userinfo = null;
+		}
+		else
+		{
+			$this->userinfo = $this->replace_invalid_with_pct_encoding($userinfo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:');
+		}
+		$this->valid[__FUNCTION__] = true;
+		return true;
+	}
+
+	/**
+	 * Set the host. Returns true on success, false on failure (if there are
+	 * any invalid characters).
+	 *
+	 * @access public
+	 * @param string $host
+	 * @return bool
+	 */
+	function set_host($host)
+	{
+		if ($host === null || $host === '')
+		{
+			$this->host = null;
+			$this->valid[__FUNCTION__] = true;
+			return true;
+		}
+		elseif ($host[0] === '[' && substr($host, -1) === ']')
+		{
+			if (Net_IPv6::checkIPv6(substr($host, 1, -1)))
+			{
+				$this->host = $host;
+				$this->valid[__FUNCTION__] = true;
+				return true;
+			}
+			else
+			{
+				$this->host = null;
+				$this->valid[__FUNCTION__] = false;
+				return false;
+			}
+		}
+		else
+		{
+			$this->host = $this->replace_invalid_with_pct_encoding($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=', SIMPLEPIE_LOWERCASE);
+			$this->valid[__FUNCTION__] = true;
+			return true;
+		}
+	}
+
+	/**
+	 * Set the port. Returns true on success, false on failure (if there are
+	 * any invalid characters).
+	 *
+	 * @access public
+	 * @param string $port
+	 * @return bool
+	 */
+	function set_port($port)
+	{
+		if ($port === null || $port === '')
+		{
+			$this->port = null;
+			$this->valid[__FUNCTION__] = true;
+			return true;
+		}
+		elseif (strspn($port, '0123456789') === strlen($port))
+		{
+			$this->port = (int) $port;
+			$this->valid[__FUNCTION__] = true;
+			return true;
+		}
+		else
+		{
+			$this->port = null;
+			$this->valid[__FUNCTION__] = false;
+			return false;
+		}
+	}
+
+	/**
+	 * Set the path.
+	 *
+	 * @access public
+	 * @param string $path
+	 * @return bool
+	 */
+	function set_path($path)
+	{
+		if ($path === null || $path === '')
+		{
+			$this->path = null;
+			$this->valid[__FUNCTION__] = true;
+			return true;
+		}
+		elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null)
+		{
+			$this->path = null;
+			$this->valid[__FUNCTION__] = false;
+			return false;
+		}
+		else
+		{
+			$this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/');
+			if ($this->scheme !== null)
+			{
+				$this->path = $this->remove_dot_segments($this->path);
+			}
+			$this->valid[__FUNCTION__] = true;
+			return true;
+		}
+	}
+
+	/**
+	 * Set the query.
+	 *
+	 * @access public
+	 * @param string $query
+	 * @return bool
+	 */
+	function set_query($query)
+	{
+		if ($query === null || $query === '')
+		{
+			$this->query = null;
+		}
+		else
+		{
+			$this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
+		}
+		$this->valid[__FUNCTION__] = true;
+		return true;
+	}
+
+	/**
+	 * Set the fragment.
+	 *
+	 * @access public
+	 * @param string $fragment
+	 * @return bool
+	 */
+	function set_fragment($fragment)
+	{
+		if ($fragment === null || $fragment === '')
+		{
+			$this->fragment = null;
+		}
+		else
+		{
+			$this->fragment = $this->replace_invalid_with_pct_encoding($fragment, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?');
+		}
+		$this->valid[__FUNCTION__] = true;
+		return true;
+	}
+
+	/**
+	 * Get the complete IRI
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_iri()
+	{
+		$iri = '';
+		if ($this->scheme !== null)
+		{
+			$iri .= $this->scheme . ':';
+		}
+		if (($authority = $this->get_authority()) !== null)
+		{
+			$iri .= '//' . $authority;
+		}
+		if ($this->path !== null)
+		{
+			$iri .= $this->path;
+		}
+		if ($this->query !== null)
+		{
+			$iri .= '?' . $this->query;
+		}
+		if ($this->fragment !== null)
+		{
+			$iri .= '#' . $this->fragment;
+		}
+
+		if ($iri !== '')
+		{
+			return $iri;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * Get the scheme
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_scheme()
+	{
+		return $this->scheme;
+	}
+
+	/**
+	 * Get the complete authority
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_authority()
+	{
+		$authority = '';
+		if ($this->userinfo !== null)
+		{
+			$authority .= $this->userinfo . '@';
+		}
+		if ($this->host !== null)
+		{
+			$authority .= $this->host;
+		}
+		if ($this->port !== null)
+		{
+			$authority .= ':' . $this->port;
+		}
+
+		if ($authority !== '')
+		{
+			return $authority;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
+	/**
+	 * Get the user information
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_userinfo()
+	{
+		return $this->userinfo;
+	}
+
+	/**
+	 * Get the host
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_host()
+	{
+		return $this->host;
+	}
+
+	/**
+	 * Get the port
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_port()
+	{
+		return $this->port;
+	}
+
+	/**
+	 * Get the path
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_path()
+	{
+		return $this->path;
+	}
+
+	/**
+	 * Get the query
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_query()
+	{
+		return $this->query;
+	}
+
+	/**
+	 * Get the fragment
+	 *
+	 * @access public
+	 * @return string
+	 */
+	function get_fragment()
+	{
+		return $this->fragment;
+	}
+}
+
+/**
+ * Class to validate and to work with IPv6 addresses.
+ *
+ * @package SimplePie
+ * @copyright 2003-2005 The PHP Group
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * @link http://pear.php.net/package/Net_IPv6
+ * @author Alexander Merz <alexander.merz@web.de>
+ * @author elfrink at introweb dot nl
+ * @author Josh Peck <jmp at joshpeck dot org>
+ * @author Geoffrey Sneddon <geoffers@gmail.com>
+ */
+class SimplePie_Net_IPv6
+{
+	/**
+	 * Removes a possible existing netmask specification of an IP address.
+	 *
+	 * @param string $ip the (compressed) IP as Hex representation
+	 * @return string the IP the without netmask
+	 * @since 1.1.0
+	 * @access public
+	 * @static
+	 */
+	function removeNetmaskSpec($ip)
+	{
+		if (strpos($ip, '/') !== false)
+		{
+			list($addr, $nm) = explode('/', $ip);
+		}
+		else
+		{
+			$addr = $ip;
+		}
+		return $addr;
+	}
+
+	/**
+	 * Uncompresses an IPv6 address
+	 *
+	 * RFC 2373 allows you to compress zeros in an address to '::'. This
+	 * function expects an valid IPv6 address and expands the '::' to
+	 * the required zeros.
+	 *
+	 * Example:	 FF01::101	->	FF01:0:0:0:0:0:0:101
+	 *			 ::1		->	0:0:0:0:0:0:0:1
+	 *
+	 * @access public
+	 * @static
+	 * @param string $ip a valid IPv6-address (hex format)
+	 * @return string the uncompressed IPv6-address (hex format)
+	 */
+	function Uncompress($ip)
+	{
+		$uip = SimplePie_Net_IPv6::removeNetmaskSpec($ip);
+		$c1 = -1;
+		$c2 = -1;
+		if (strpos($ip, '::') !== false)
+		{
+			list($ip1, $ip2) = explode('::', $ip);
+			if ($ip1 === '')
+			{
+				$c1 = -1;
+			}
+			else
+			{
+				$pos = 0;
+				if (($pos = substr_count($ip1, ':')) > 0)
+				{
+					$c1 = $pos;
+				}
+				else
+				{
+					$c1 = 0;
+				}
+			}
+			if ($ip2 === '')
+			{
+				$c2 = -1;
+			}
+			else
+			{
+				$pos = 0;
+				if (($pos = substr_count($ip2, ':')) > 0)
+				{
+					$c2 = $pos;
+				}
+				else
+				{
+					$c2 = 0;
+				}
+			}
+			if (strstr($ip2, '.'))
+			{
+				$c2++;
+			}
+			// ::
+			if ($c1 === -1 && $c2 === -1)
+			{
+				$uip = '0:0:0:0:0:0:0:0';
+			}
+			// ::xxx
+			else if ($c1 === -1)
+			{
+				$fill = str_repeat('0:', 7 - $c2);
+				$uip =	str_replace('::', $fill, $uip);
+			}
+			// xxx::
+			else if ($c2 === -1)
+			{
+				$fill = str_repeat(':0', 7 - $c1);
+				$uip =	str_replace('::', $fill, $uip);
+			}
+			// xxx::xxx
+			else
+			{
+				$fill = str_repeat(':0:', 6 - $c2 - $c1);
+				$uip =	str_replace('::', $fill, $uip);
+				$uip =	str_replace('::', ':', $uip);
+			}
+		}
+		return $uip;
+	}
+
+	/**
+	 * Splits an IPv6 address into the IPv6 and a possible IPv4 part
+	 *
+	 * RFC 2373 allows you to note the last two parts of an IPv6 address as
+	 * an IPv4 compatible address
+	 *
+	 * Example:	 0:0:0:0:0:0:13.1.68.3
+	 *			 0:0:0:0:0:FFFF:129.144.52.38
+	 *
+	 * @access public
+	 * @static
+	 * @param string $ip a valid IPv6-address (hex format)
+	 * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
+	 */
+	function SplitV64($ip)
+	{
+		$ip = SimplePie_Net_IPv6::Uncompress($ip);
+		if (strstr($ip, '.'))
+		{
+			$pos = strrpos($ip, ':');
+			$ip[$pos] = '_';
+			$ipPart = explode('_', $ip);
+			return $ipPart;
+		}
+		else
+		{
+			return array($ip, '');
+		}
+	}
+
+	/**
+	 * Checks an IPv6 address
+	 *
+	 * Checks if the given IP is IPv6-compatible
+	 *
+	 * @access public
+	 * @static
+	 * @param string $ip a valid IPv6-address
+	 * @return bool true if $ip is an IPv6 address
+	 */
+	function checkIPv6($ip)
+	{
+		$ipPart = SimplePie_Net_IPv6::SplitV64($ip);
+		$count = 0;
+		if (!empty($ipPart[0]))
+		{
+			$ipv6 = explode(':', $ipPart[0]);
+			for ($i = 0; $i < count($ipv6); $i++)
+			{
+				$dec = hexdec($ipv6[$i]);
+				$hex = strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/', '\\1', $ipv6[$i]));
+				if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex === strtoupper(dechex($dec)))
+				{
+					$count++;
+				}
+			}
+			if ($count === 8)
+			{
+				return true;
+			}
+			elseif ($count === 6 && !empty($ipPart[1]))
+			{
+				$ipv4 = explode('.', $ipPart[1]);
+				$count = 0;
+				foreach ($ipv4 as $ipv4_part)
+				{
+					if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part))
+					{
+						$count++;
+					}
+				}
+				if ($count === 4)
+				{
+					return true;
+				}
+			}
+			else
+			{
+				return false;
+			}
+
+		}
+		else
+		{
+			return false;
+		}
+	}
+}
+
+/**
+ * Date Parser
+ *
+ * @package SimplePie
+ */
+class SimplePie_Parse_Date
+{
+	/**
+	 * Input data
+	 *
+	 * @access protected
+	 * @var string
+	 */
+	var $date;
+
+	/**
+	 * List of days, calendar day name => ordinal day number in the week
+	 *
+	 * @access protected
+	 * @var array
+	 */
+	var $day = array(
+		// English
+		'mon' => 1,
+		'monday' => 1,
+		'tue' => 2,
+		'tuesday' => 2,
+		'wed' => 3,
+		'wednesday' => 3,
+		'thu' => 4,
+		'thursday' => 4,
+		'fri' => 5,
+		'friday' => 5,
+		'sat' => 6,
+		'saturday' => 6,
+		'sun' => 7,
+		'sunday' => 7,
+		// Dutch
+		'maandag' => 1,
+		'dinsdag' => 2,
+		'woensdag' => 3,
+		'donderdag' => 4,
+		'vrijdag' => 5,
+		'zaterdag' => 6,
+		'zondag' => 7,
+		// French
+		'lundi' => 1,
+		'mardi' => 2,
+		'mercredi' => 3,
+		'jeudi' => 4,
+		'vendredi' => 5,
+		'samedi' => 6,
+		'dimanche' => 7,
+		// German
+		'montag' => 1,
+		'dienstag' => 2,
+		'mittwoch' => 3,
+		'donnerstag' => 4,
+		'freitag' => 5,
+		'samstag' => 6,
+		'sonnabend' => 6,
+		'sonntag' => 7,
+		// Italian
+		'lunedì' => 1,
+		'martedì' => 2,
+		'mercoledì' => 3,
+		'giovedì' => 4,
+		'venerdì' => 5,
+		'sabato' => 6,
+		'domenica' => 7,
+		// Spanish
+		'lunes' => 1,
+		'martes' => 2,
+		'miércoles' => 3,
+		'jueves' => 4,
+		'viernes' => 5,
+		'sábado' => 6,
+		'domingo' => 7,
+		// Finnish
+		'maanantai' => 1,
+		'tiistai' => 2,
+		'keskiviikko' => 3,
+		'torstai' => 4,
+		'perjantai' => 5,
+		'lauantai' => 6,
+		'sunnuntai' => 7,
+		// Hungarian
+		'hétfő' => 1,
+		'kedd' => 2,
+		'szerda' => 3,
+		'csütörtok' => 4,
+		'péntek' => 5,
+		'szombat' => 6,
+		'vasárnap' => 7,
+		// Greek
+		'Δευ' => 1,
+		'Τρι' => 2,
+		'Τετ' => 3,
+		'Πεμ' => 4,
+		'Παρ' => 5,
+		'Σαβ' => 6,
+		'Κυρ' => 7,
+	);
+
+	/**
+	 * List of months, calendar month name => calendar month number
+	 *
+	 * @access protected
+	 * @var array
+	 */
+	var $month = array(
+		// English
+		'jan' => 1,
+		'january' => 1,
+		'feb' => 2,
+		'february' => 2,
+		'mar' => 3,
+		'march' => 3,
+		'apr' => 4,
+		'april' => 4,
+		'may' => 5,
+		// No long form of May
+		'jun' => 6,
+		'june' => 6,
+		'jul' => 7,
+		'july' => 7,
+		'aug' => 8,
+		'august' => 8,
+		'sep' => 9,
+		'september' => 8,
+		'oct' => 10,
+		'october' => 10,
+		'nov' => 11,
+		'november' => 11,
+		'dec' => 12,
+		'december' => 12,
+		// Dutch
+		'januari' => 1,
+		'februari' => 2,
+		'maart' => 3,
+		'april' => 4,
+		'mei' => 5,
+		'juni' => 6,
+		'juli' => 7,
+		'augustus' => 8,
+		'september' => 9,
+		'oktober' => 10,
+		'november' => 11,
+		'december' => 12,
+		// French
+		'janvier' => 1,
+		'février' => 2,
+		'mars' => 3,
+		'avril' => 4,
+		'mai' => 5,
+		'juin' => 6,
+		'juillet' => 7,
+		'août' => 8,
+		'septembre' => 9,
+		'octobre' => 10,
+		'novembre' => 11,
+		'décembre' => 12,
+		// German
+		'januar' => 1,
+		'februar' => 2,
+		'märz' => 3,
+		'april' => 4,
+		'mai' => 5,
+		'juni' => 6,
+		'juli' => 7,
+		'august' => 8,
+		'september' => 9,
+		'oktober' => 10,
+		'november' => 11,
+		'dezember' => 12,
+		// Italian
+		'gennaio' => 1,
+		'febbraio' => 2,
+		'marzo' => 3,
+		'aprile' => 4,
+		'maggio' => 5,
+		'giugno' => 6,
+		'luglio' => 7,
+		'agosto' => 8,
+		'settembre' => 9,
+		'ottobre' => 10,
+		'novembre' => 11,
+		'dicembre' => 12,
+		// Spanish
+		'enero' => 1,
+		'febrero' => 2,
+		'marzo' => 3,
+		'abril' => 4,
+		'mayo' => 5,
+		'junio' => 6,
+		'julio' => 7,
+		'agosto' => 8,
+		'septiembre' => 9,
+		'setiembre' => 9,
+		'octubre' => 10,
+		'noviembre' => 11,
+		'diciembre' => 12,
+		// Finnish
+		'tammikuu' => 1,
+		'helmikuu' => 2,
+		'maaliskuu' => 3,
+		'huhtikuu' => 4,
+		'toukokuu' => 5,
+		'kesäkuu' => 6,
+		'heinäkuu' => 7,
+		'elokuu' => 8,
+		'suuskuu' => 9,
+		'lokakuu' => 10,
+		'marras' => 11,
+		'joulukuu' => 12,
+		// Hungarian
+		'január' => 1,
+		'február' => 2,
+		'március' => 3,
+		'április' => 4,
+		'május' => 5,
+		'június' => 6,
+		'július' => 7,
+		'augusztus' => 8,
+		'szeptember' => 9,
+		'október' => 10,
+		'november' => 11,
+		'december' => 12,
+		// Greek
+		'Ιαν' => 1,
+		'Φεβ' => 2,
+		'Μάώ' => 3,
+		'Μαώ' => 3,
+		'Απρ' => 4,
+		'Μάι' => 5,
+		'Μαϊ' => 5,
+		'Μαι' => 5,
+		'Ιούν' => 6,
+		'Ιον' => 6,
+		'Ιούλ' => 7,
+		'Ιολ' => 7,
+		'Αύγ' => 8,
+		'Αυγ' => 8,
+		'Σεπ' => 9,
+		'Οκτ' => 10,
+		'Νοέ' => 11,
+		'Δεκ' => 12,
+	);
+
+	/**
+	 * List of timezones, abbreviation => offset from UTC
+	 *
+	 * @access protected
+	 * @var array
+	 */
+	var $timezone = array(
+		'ACDT' => 37800,
+		'ACIT' => 28800,
+		'ACST' => 34200,
+		'ACT' => -18000,
+		'ACWDT' => 35100,
+		'ACWST' => 31500,
+		'AEDT' => 39600,
+		'AEST' => 36000,
+		'AFT' => 16200,
+		'AKDT' => -28800,
+		'AKST' => -32400,
+		'AMDT' => 18000,
+		'AMT' => -14400,
+		'ANAST' => 46800,
+		'ANAT' => 43200,
+		'ART' => -10800,
+		'AZOST' => -3600,
+		'AZST' => 18000,
+		'AZT' => 14400,
+		'BIOT' => 21600,
+		'BIT' => -43200,
+		'BOT' => -14400,
+		'BRST' => -7200,
+		'BRT' => -10800,
+		'BST' => 3600,
+		'BTT' => 21600,
+		'CAST' => 18000,
+		'CAT' => 7200,
+		'CCT' => 23400,
+		'CDT' => -18000,
+		'CEDT' => 7200,
+		'CET' => 3600,
+		'CGST' => -7200,
+		'CGT' => -10800,
+		'CHADT' => 49500,
+		'CHAST' => 45900,
+		'CIST' => -28800,
+		'CKT' => -36000,
+		'CLDT' => -10800,
+		'CLST' => -14400,
+		'COT' => -18000,
+		'CST' => -21600,
+		'CVT' => -3600,
+		'CXT' => 25200,
+		'DAVT' => 25200,
+		'DTAT' => 36000,
+		'EADT' => -18000,
+		'EAST' => -21600,
+		'EAT' => 10800,
+		'ECT' => -18000,
+		'EDT' => -14400,
+		'EEST' => 10800,
+		'EET' => 7200,
+		'EGT' => -3600,
+		'EKST' => 21600,
+		'EST' => -18000,
+		'FJT' => 43200,
+		'FKDT' => -10800,
+		'FKST' => -14400,
+		'FNT' => -7200,
+		'GALT' => -21600,
+		'GEDT' => 14400,
+		'GEST' => 10800,
+		'GFT' => -10800,
+		'GILT' => 43200,
+		'GIT' => -32400,
+		'GST' => 14400,
+		'GST' => -7200,
+		'GYT' => -14400,
+		'HAA' => -10800,
+		'HAC' => -18000,
+		'HADT' => -32400,
+		'HAE' => -14400,
+		'HAP' => -25200,
+		'HAR' => -21600,
+		'HAST' => -36000,
+		'HAT' => -9000,
+		'HAY' => -28800,
+		'HKST' => 28800,
+		'HMT' => 18000,
+		'HNA' => -14400,
+		'HNC' => -21600,
+		'HNE' => -18000,
+		'HNP' => -28800,
+		'HNR' => -25200,
+		'HNT' => -12600,
+		'HNY' => -32400,
+		'IRDT' => 16200,
+		'IRKST' => 32400,
+		'IRKT' => 28800,
+		'IRST' => 12600,
+		'JFDT' => -10800,
+		'JFST' => -14400,
+		'JST' => 32400,
+		'KGST' => 21600,
+		'KGT' => 18000,
+		'KOST' => 39600,
+		'KOVST' => 28800,
+		'KOVT' => 25200,
+		'KRAST' => 28800,
+		'KRAT' => 25200,
+		'KST' => 32400,
+		'LHDT' => 39600,
+		'LHST' => 37800,
+		'LINT' => 50400,
+		'LKT' => 21600,
+		'MAGST' => 43200,
+		'MAGT' => 39600,
+		'MAWT' => 21600,
+		'MDT' => -21600,
+		'MESZ' => 7200,
+		'MEZ' => 3600,
+		'MHT' => 43200,
+		'MIT' => -34200,
+		'MNST' => 32400,
+		'MSDT' => 14400,
+		'MSST' => 10800,
+		'MST' => -25200,
+		'MUT' => 14400,
+		'MVT' => 18000,
+		'MYT' => 28800,
+		'NCT' => 39600,
+		'NDT' => -9000,
+		'NFT' => 41400,
+		'NMIT' => 36000,
+		'NOVST' => 25200,
+		'NOVT' => 21600,
+		'NPT' => 20700,
+		'NRT' => 43200,
+		'NST' => -12600,
+		'NUT' => -39600,
+		'NZDT' => 46800,
+		'NZST' => 43200,
+		'OMSST' => 25200,
+		'OMST' => 21600,
+		'PDT' => -25200,
+		'PET' => -18000,
+		'PETST' => 46800,
+		'PETT' => 43200,
+		'PGT' => 36000,
+		'PHOT' => 46800,
+		'PHT' => 28800,
+		'PKT' => 18000,
+		'PMDT' => -7200,
+		'PMST' => -10800,
+		'PONT' => 39600,
+		'PST' => -28800,
+		'PWT' => 32400,
+		'PYST' => -10800,
+		'PYT' => -14400,
+		'RET' => 14400,
+		'ROTT' => -10800,
+		'SAMST' => 18000,
+		'SAMT' => 14400,
+		'SAST' => 7200,
+		'SBT' => 39600,
+		'SCDT' => 46800,
+		'SCST' => 43200,
+		'SCT' => 14400,
+		'SEST' => 3600,
+		'SGT' => 28800,
+		'SIT' => 28800,
+		'SRT' => -10800,
+		'SST' => -39600,
+		'SYST' => 10800,
+		'SYT' => 7200,
+		'TFT' => 18000,
+		'THAT' => -36000,
+		'TJT' => 18000,
+		'TKT' => -36000,
+		'TMT' => 18000,
+		'TOT' => 46800,
+		'TPT' => 32400,
+		'TRUT' => 36000,
+		'TVT' => 43200,
+		'TWT' => 28800,
+		'UYST' => -7200,
+		'UYT' => -10800,
+		'UZT' => 18000,
+		'VET' => -14400,
+		'VLAST' => 39600,
+		'VLAT' => 36000,
+		'VOST' => 21600,
+		'VUT' => 39600,
+		'WAST' => 7200,
+		'WAT' => 3600,
+		'WDT' => 32400,
+		'WEST' => 3600,
+		'WFT' => 43200,
+		'WIB' => 25200,
+		'WIT' => 32400,
+		'WITA' => 28800,
+		'WKST' => 18000,
+		'WST' => 28800,
+		'YAKST' => 36000,
+		'YAKT' => 32400,
+		'YAPT' => 36000,
+		'YEKST' => 21600,
+		'YEKT' => 18000,
+	);
+
+	/**
+	 * Cached PCRE for SimplePie_Parse_Date::$day
+	 *
+	 * @access protected
+	 * @var string
+	 */
+	var $day_pcre;
+
+	/**
+	 * Cached PCRE for SimplePie_Parse_Date::$month
+	 *
+	 * @access protected
+	 * @var string
+	 */
+	var $month_pcre;
+
+	/**
+	 * Array of user-added callback methods
+	 *
+	 * @access private
+	 * @var array
+	 */
+	var $built_in = array();
+
+	/**
+	 * Array of user-added callback methods
+	 *
+	 * @access private
+	 * @var array
+	 */
+	var $user = array();
+
+	/**
+	 * Create new SimplePie_Parse_Date object, and set self::day_pcre,
+	 * self::month_pcre, and self::built_in
+	 *
+	 * @access private
+	 */
+	function SimplePie_Parse_Date()
+	{
+		$this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
+		$this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
+
+		static $cache;
+		if (!isset($cache[get_class($this)]))
+		{
+			$all_methods = get_class_methods($this);
+
+			foreach ($all_methods as $method)
+			{
+				if (strtolower(substr($method, 0, 5)) === 'date_')
+				{
+					$cache[get_class($this)][] = $method;
+				}
+			}
+		}
+
+		foreach ($cache[get_class($this)] as $method)
+		{
+			$this->built_in[] = $method;
+		}
+	}
+
+	/**
+	 * Get the object
+	 *
+	 * @access public
+	 */
+	function get()
+	{
+		static $object;
+		if (!$object)
+		{
+			$object =& new SimplePie_Parse_Date;
+		}
+		return $object;
+	}
+
+	/**
+	 * Parse a date
+	 *
+	 * @final
+	 * @access public
+	 * @param string $date Date to parse
+	 * @return int Timestamp corresponding to date string, or false on failure
+	 */
+	function parse($date)
+	{
+		foreach ($this->user as $method)
+		{
+			if (($returned = call_user_func($method, $date)) !== false)
+			{
+				return $returned;
+			}
+		}
+
+		foreach ($this->built_in as $method)
+		{
+			if (($returned = call_user_func(array(&$this, $method), $date)) !== false)
+			{
+				return $returned;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * Add a callback method to parse a date
+	 *
+	 * @final
+	 * @access public
+	 * @param callback $callback
+	 */
+	function add_callback($callback)
+	{
+		if (is_callable($callback))
+		{
+			$this->user[] = $callback;
+		}
+		else
+		{
+			trigger_error('User-supplied function must be a valid callback', E_USER_WARNING);
+		}
+	}
+
+	/**
+	 * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
+	 * well as allowing any of upper or lower case "T", horizontal tabs, or
+	 * spaces to be used as the time seperator (including more than one))
+	 *
+	 * @access protected
+	 * @return int Timestamp
+	 */
+	function date_w3cdtf($date)
+	{
+		static $pcre;
+		if (!$pcre)
+		{
+			$year = '([0-9]{4})';
+			$month = $day = $hour = $minute = $second = '([0-9]{2})';
+			$decimal = '([0-9]*)';
+			$zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))';
+			$pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/';
+		}
+		if (preg_match($pcre, $date, $match))
+		{
+			/*
+			Capturing subpatterns:
+			1: Year
+			2: Month
+			3: Day
+			4: Hour
+			5: Minute
+			6: Second
+			7: Decimal fraction of a second
+			8: Zulu
+			9: Timezone ±
+			10: Timezone hours
+			11: Timezone minutes
+			*/
+
+			// Fill in empty matches
+			for ($i = count($match); $i <= 3; $i++)
+			{
+				$match[$i] = '1';
+			}
+
+			for ($i = count($match); $i <= 7; $i++)
+			{
+				$match[$i] = '0';
+			}
+
+			// Numeric timezone
+			if (isset($match[9]) && $match[9] !== '')
+			{
+				$timezone = $match[10] * 3600;
+				$timezone += $match[11] * 60;
+				if ($match[9] === '-')
+				{
+					$timezone = 0 - $timezone;
+				}
+			}
+			else
+			{
+				$timezone = 0;
+			}
+
+			// Convert the number of seconds to an integer, taking decimals into account
+			$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
+
+			return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Remove RFC822 comments
+	 *
+	 * @access protected
+	 * @param string $data Data to strip comments from
+	 * @return string Comment stripped string
+	 */
+	function remove_rfc2822_comments($string)
+	{
+		$string = (string) $string;
+		$position = 0;
+		$length = strlen($string);
+		$depth = 0;
+
+		$output = '';
+
+		while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
+		{
+			$output .= substr($string, $position, $pos - $position);
+			$position = $pos + 1;
+			if ($string[$pos - 1] !== '\\')
+			{
+				$depth++;
+				while ($depth && $position < $length)
+				{
+					$position += strcspn($string, '()', $position);
+					if ($string[$position - 1] === '\\')
+					{
+						$position++;
+						continue;
+					}
+					elseif (isset($string[$position]))
+					{
+						switch ($string[$position])
+						{
+							case '(':
+								$depth++;
+								break;
+
+							case ')':
+								$depth--;
+								break;
+						}
+						$position++;
+					}
+					else
+					{
+						break;
+					}
+				}
+			}
+			else
+			{
+				$output .= '(';
+			}
+		}
+		$output .= substr($string, $position);
+
+		return $output;
+	}
+
+	/**
+	 * Parse RFC2822's date format
+	 *
+	 * @access protected
+	 * @return int Timestamp
+	 */
+	function date_rfc2822($date)
+	{
+		static $pcre;
+		if (!$pcre)
+		{
+			$wsp = '[\x09\x20]';
+			$fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)';
+			$optional_fws = $fws . '?';
+			$day_name = $this->day_pcre;
+			$month = $this->month_pcre;
+			$day = '([0-9]{1,2})';
+			$hour = $minute = $second = '([0-9]{2})';
+			$year = '([0-9]{2,4})';
+			$num_zone = '([+\-])([0-9]{2})([0-9]{2})';
+			$character_zone = '([A-Z]{1,5})';
+			$zone = '(?:' . $num_zone . '|' . $character_zone . ')';
+			$pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i';
+		}
+		if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match))
+		{
+			/*
+			Capturing subpatterns:
+			1: Day name
+			2: Day
+			3: Month
+			4: Year
+			5: Hour
+			6: Minute
+			7: Second
+			8: Timezone ±
+			9: Timezone hours
+			10: Timezone minutes
+			11: Alphabetic timezone
+			*/
+
+			// Find the month number
+			$month = $this->month[strtolower($match[3])];
+
+			// Numeric timezone
+			if ($match[8] !== '')
+			{
+				$timezone = $match[9] * 3600;
+				$timezone += $match[10] * 60;
+				if ($match[8] === '-')
+				{
+					$timezone = 0 - $timezone;
+				}
+			}
+			// Character timezone
+			elseif (isset($this->timezone[strtoupper($match[11])]))
+			{
+				$timezone = $this->timezone[strtoupper($match[11])];
+			}
+			// Assume everything else to be -0000
+			else
+			{
+				$timezone = 0;
+			}
+
+			// Deal with 2/3 digit years
+			if ($match[4] < 50)
+			{
+				$match[4] += 2000;
+			}
+			elseif ($match[4] < 1000)
+			{
+				$match[4] += 1900;
+			}
+
+			// Second is optional, if it is empty set it to zero
+			if ($match[7] !== '')
+			{
+				$second = $match[7];
+			}
+			else
+			{
+				$second = 0;
+			}
+
+			return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Parse RFC850's date format
+	 *
+	 * @access protected
+	 * @return int Timestamp
+	 */
+	function date_rfc850($date)
+	{
+		static $pcre;
+		if (!$pcre)
+		{
+			$space = '[\x09\x20]+';
+			$day_name = $this->day_pcre;
+			$month = $this->month_pcre;
+			$day = '([0-9]{1,2})';
+			$year = $hour = $minute = $second = '([0-9]{2})';
+			$zone = '([A-Z]{1,5})';
+			$pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i';
+		}
+		if (preg_match($pcre, $date, $match))
+		{
+			/*
+			Capturing subpatterns:
+			1: Day name
+			2: Day
+			3: Month
+			4: Year
+			5: Hour
+			6: Minute
+			7: Second
+			8: Timezone
+			*/
+
+			// Month
+			$month = $this->month[strtolower($match[3])];
+
+			// Character timezone
+			if (isset($this->timezone[strtoupper($match[8])]))
+			{
+				$timezone = $this->timezone[strtoupper($match[8])];
+			}
+			// Assume everything else to be -0000
+			else
+			{
+				$timezone = 0;
+			}
+
+			// Deal with 2 digit year
+			if ($match[4] < 50)
+			{
+				$match[4] += 2000;
+			}
+			else
+			{
+				$match[4] += 1900;
+			}
+
+			return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Parse C99's asctime()'s date format
+	 *
+	 * @access protected
+	 * @return int Timestamp
+	 */
+	function date_asctime($date)
+	{
+		static $pcre;
+		if (!$pcre)
+		{
+			$space = '[\x09\x20]+';
+			$wday_name = $this->day_pcre;
+			$mon_name = $this->month_pcre;
+			$day = '([0-9]{1,2})';
+			$hour = $sec = $min = '([0-9]{2})';
+			$year = '([0-9]{4})';
+			$terminator = '\x0A?\x00?';
+			$pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i';
+		}
+		if (preg_match($pcre, $date, $match))
+		{
+			/*
+			Capturing subpatterns:
+			1: Day name
+			2: Month
+			3: Day
+			4: Hour
+			5: Minute
+			6: Second
+			7: Year
+			*/
+
+			$month = $this->month[strtolower($match[2])];
+			return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Parse dates using strtotime()
+	 *
+	 * @access protected
+	 * @return int Timestamp
+	 */
+	function date_strtotime($date)
+	{
+		$strtotime = strtotime($date);
+		if ($strtotime === -1 || $strtotime === false)
+		{
+			return false;
+		}
+		else
+		{
+			return $strtotime;
+		}
+	}
+}
+
+/**
+ * Content-type sniffing
+ *
+ * @package SimplePie
+ */
+class SimplePie_Content_Type_Sniffer
+{
+	/**
+	 * File object
+	 *
+	 * @var SimplePie_File
+	 * @access private
+	 */
+	var $file;
+
+	/**
+	 * Create an instance of the class with the input file
+	 *
+	 * @access public
+	 * @param SimplePie_Content_Type_Sniffer $file Input file
+	 */
+	function SimplePie_Content_Type_Sniffer($file)
+	{
+		$this->file = $file;
+	}
+
+	/**
+	 * Get the Content-Type of the specified file
+	 *
+	 * @access public
+	 * @return string Actual Content-Type
+	 */
+	function get_type()
+	{
+		if (isset($this->file->headers['content-type']))
+		{
+			if (!isset($this->file->headers['content-encoding'])
+				&& ($this->file->headers['content-type'] === 'text/plain'
+					|| $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1'
+					|| $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1'))
+			{
+				return $this->text_or_binary();
+			}
+
+			if (($pos = strpos($this->file->headers['content-type'], ';')) !== false)
+			{
+				$official = substr($this->file->headers['content-type'], 0, $pos);
+			}
+			else
+			{
+				$official = $this->file->headers['content-type'];
+			}
+			$official = strtolower($official);
+
+			if ($official === 'unknown/unknown'
+				|| $official === 'application/unknown')
+			{
+				return $this->unknown();
+			}
+			elseif (substr($official, -4) === '+xml'
+				|| $official === 'text/xml'
+				|| $official === 'application/xml')
+			{
+				return $official;
+			}
+			elseif (substr($official, 0, 6) === 'image/')
+			{
+				if ($return = $this->image())
+				{
+					return $return;
+				}
+				else
+				{
+					return $official;
+				}
+			}
+			elseif ($official === 'text/html')
+			{
+				return $this->feed_or_html();
+			}
+			else
+			{
+				return $official;
+			}
+		}
+		else
+		{
+			return $this->unknown();
+		}
+	}
+
+	/**
+	 * Sniff text or binary
+	 *
+	 * @access private
+	 * @return string Actual Content-Type
+	 */
+	function text_or_binary()
+	{
+		if (substr($this->file->body, 0, 2) === "\xFE\xFF"
+			|| substr($this->file->body, 0, 2) === "\xFF\xFE"
+			|| substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF"
+			|| substr($this->file->body, 0, 3) === "\xEF\xBB\xBF")
+		{
+			return 'text/plain';
+		}
+		elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body))
+		{
+			return 'application/octect-stream';
+		}
+		else
+		{
+			return 'text/plain';
+		}
+	}
+
+	/**
+	 * Sniff unknown
+	 *
+	 * @access private
+	 * @return string Actual Content-Type
+	 */
+	function unknown()
+	{
+		$ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20");
+		if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html'
+			|| strtolower(substr($this->file->body, $ws, 5)) === '<html'
+			|| strtolower(substr($this->file->body, $ws, 7)) === '<script')
+		{
+			return 'text/html';
+		}
+		elseif (substr($this->file->body, 0, 5) === '%PDF-')
+		{
+			return 'application/pdf';
+		}
+		elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-')
+		{
+			return 'application/postscript';
+		}
+		elseif (substr($this->file->body, 0, 6) === 'GIF87a'
+			|| substr($this->file->body, 0, 6) === 'GIF89a')
+		{
+			return 'image/gif';
+		}
+		elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
+		{
+			return 'image/png';
+		}
+		elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
+		{
+			return 'image/jpeg';
+		}
+		elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
+		{
+			return 'image/bmp';
+		}
+		else
+		{
+			return $this->text_or_binary();
+		}
+	}
+
+	/**
+	 * Sniff images
+	 *
+	 * @access private
+	 * @return string Actual Content-Type
+	 */
+	function image()
+	{
+		if (substr($this->file->body, 0, 6) === 'GIF87a'
+			|| substr($this->file->body, 0, 6) === 'GIF89a')
+		{
+			return 'image/gif';
+		}
+		elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
+		{
+			return 'image/png';
+		}
+		elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF")
+		{
+			return 'image/jpeg';
+		}
+		elseif (substr($this->file->body, 0, 2) === "\x42\x4D")
+		{
+			return 'image/bmp';
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	/**
+	 * Sniff HTML
+	 *
+	 * @access private
+	 * @return string Actual Content-Type
+	 */
+	function feed_or_html()
+	{
+		$len = strlen($this->file->body);
+		$pos = strspn($this->file->body, "\x09\x0A\x0D\x20");
+
+		while ($pos < $len)
+		{
+			switch ($this->file->body[$pos])
+			{
+				case "\x09":
+				case "\x0A":
+				case "\x0D":
+				case "\x20":
+					$pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos);
+					continue 2;
+
+				case '<':
+					$pos++;
+					break;
+
+				default:
+					return 'text/html';
+			}
+
+			if (substr($this->file->body, $pos, 3) === '!--')
+			{
+				$pos += 3;
+				if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false)
+				{
+					$pos += 3;
+				}
+				else
+				{
+					return 'text/html';
+				}
+			}
+			elseif (substr($this->file->body, $pos, 1) === '!')
+			{
+				if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false)
+				{
+					$pos++;
+				}
+				else
+				{
+					return 'text/html';
+				}
+			}
+			elseif (substr($this->file->body, $pos, 1) === '?')
+			{
+				if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false)
+				{
+					$pos += 2;
+				}
+				else
+				{
+					return 'text/html';
+				}
+			}
+			elseif (substr($this->file->body, $pos, 3) === 'rss'
+				|| substr($this->file->body, $pos, 7) === 'rdf:RDF')
+			{
+				return 'application/rss+xml';
+			}
+			elseif (substr($this->file->body, $pos, 4) === 'feed')
+			{
+				return 'application/atom+xml';
+			}
+			else
+			{
+				return 'text/html';
+			}
+		}
+
+		return 'text/html';
+	}
+}
+
+/**
+ * Parses the XML Declaration
+ *
+ * @package SimplePie
+ */
+class SimplePie_XML_Declaration_Parser
+{
+	/**
+	 * XML Version
+	 *
+	 * @access public
+	 * @var string
+	 */
+	var $version = '1.0';
+
+	/**
+	 * Encoding
+	 *
+	 * @access public
+	 * @var string
+	 */
+	var $encoding = 'UTF-8';
+
+	/**
+	 * Standalone
+	 *
+	 * @access public
+	 * @var bool
+	 */
+	var $standalone = false;
+
+	/**
+	 * Current state of the state machine
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $state = 'before_version_name';
+
+	/**
+	 * Input data
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $data = '';
+
+	/**
+	 * Input data length (to avoid calling strlen() everytime this is needed)
+	 *
+	 * @access private
+	 * @var int
+	 */
+	var $data_length = 0;
+
+	/**
+	 * Current position of the pointer
+	 *
+	 * @var int
+	 * @access private
+	 */
+	var $position = 0;
+
+	/**
+	 * Create an instance of the class with the input data
+	 *
+	 * @access public
+	 * @param string $data Input data
+	 */
+	function SimplePie_XML_Declaration_Parser($data)
+	{
+		$this->data = $data;
+		$this->data_length = strlen($this->data);
+	}
+
+	/**
+	 * Parse the input data
+	 *
+	 * @access public
+	 * @return bool true on success, false on failure
+	 */
+	function parse()
+	{
+		while ($this->state && $this->state !== 'emit' && $this->has_data())
+		{
+			$state = $this->state;
+			$this->$state();
+		}
+		$this->data = '';
+		if ($this->state === 'emit')
+		{
+			return true;
+		}
+		else
+		{
+			$this->version = '';
+			$this->encoding = '';
+			$this->standalone = '';
+			return false;
+		}
+	}
+
+	/**
+	 * Check whether there is data beyond the pointer
+	 *
+	 * @access private
+	 * @return bool true if there is further data, false if not
+	 */
+	function has_data()
+	{
+		return (bool) ($this->position < $this->data_length);
+	}
+
+	/**
+	 * Advance past any whitespace
+	 *
+	 * @return int Number of whitespace characters passed
+	 */
+	function skip_whitespace()
+	{
+		$whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position);
+		$this->position += $whitespace;
+		return $whitespace;
+	}
+
+	/**
+	 * Read value
+	 */
+	function get_value()
+	{
+		$quote = substr($this->data, $this->position, 1);
+		if ($quote === '"' || $quote === "'")
+		{
+			$this->position++;
+			$len = strcspn($this->data, $quote, $this->position);
+			if ($this->has_data())
+			{
+				$value = substr($this->data, $this->position, $len);
+				$this->position += $len + 1;
+				return $value;
+			}
+		}
+		return false;
+	}
+
+	function before_version_name()
+	{
+		if ($this->skip_whitespace())
+		{
+			$this->state = 'version_name';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function version_name()
+	{
+		if (substr($this->data, $this->position, 7) === 'version')
+		{
+			$this->position += 7;
+			$this->skip_whitespace();
+			$this->state = 'version_equals';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function version_equals()
+	{
+		if (substr($this->data, $this->position, 1) === '=')
+		{
+			$this->position++;
+			$this->skip_whitespace();
+			$this->state = 'version_value';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function version_value()
+	{
+		if ($this->version = $this->get_value())
+		{
+			$this->skip_whitespace();
+			if ($this->has_data())
+			{
+				$this->state = 'encoding_name';
+			}
+			else
+			{
+				$this->state = 'emit';
+			}
+		}
+		else
+		{
+			$this->state = 'standalone_name';
+		}
+	}
+
+	function encoding_name()
+	{
+		if (substr($this->data, $this->position, 8) === 'encoding')
+		{
+			$this->position += 8;
+			$this->skip_whitespace();
+			$this->state = 'encoding_equals';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function encoding_equals()
+	{
+		if (substr($this->data, $this->position, 1) === '=')
+		{
+			$this->position++;
+			$this->skip_whitespace();
+			$this->state = 'encoding_value';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function encoding_value()
+	{
+		if ($this->encoding = $this->get_value())
+		{
+			$this->skip_whitespace();
+			if ($this->has_data())
+			{
+				$this->state = 'standalone_name';
+			}
+			else
+			{
+				$this->state = 'emit';
+			}
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function standalone_name()
+	{
+		if (substr($this->data, $this->position, 10) === 'standalone')
+		{
+			$this->position += 10;
+			$this->skip_whitespace();
+			$this->state = 'standalone_equals';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function standalone_equals()
+	{
+		if (substr($this->data, $this->position, 1) === '=')
+		{
+			$this->position++;
+			$this->skip_whitespace();
+			$this->state = 'standalone_value';
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+
+	function standalone_value()
+	{
+		if ($standalone = $this->get_value())
+		{
+			switch ($standalone)
+			{
+				case 'yes':
+					$this->standalone = true;
+					break;
+
+				case 'no':
+					$this->standalone = false;
+					break;
+
+				default:
+					$this->state = false;
+					return;
+			}
+
+			$this->skip_whitespace();
+			if ($this->has_data())
+			{
+				$this->state = false;
+			}
+			else
+			{
+				$this->state = 'emit';
+			}
+		}
+		else
+		{
+			$this->state = false;
+		}
+	}
+}
+
+class SimplePie_Locator
+{
+	var $useragent;
+	var $timeout;
+	var $file;
+	var $local = array();
+	var $elsewhere = array();
+	var $file_class = 'SimplePie_File';
+	var $cached_entities = array();
+	var $http_base;
+	var $base;
+	var $base_location = 0;
+	var $checked_feeds = 0;
+	var $max_checked_feeds = 10;
+	var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer';
+
+	function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10, $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer')
+	{
+		$this->file =& $file;
+		$this->file_class = $file_class;
+		$this->useragent = $useragent;
+		$this->timeout = $timeout;
+		$this->max_checked_feeds = $max_checked_feeds;
+		$this->content_type_sniffer_class = $content_type_sniffer_class;
+	}
+
+	function find($type = SIMPLEPIE_LOCATOR_ALL, &$working)
+	{
+		if ($this->is_feed($this->file))
+		{
+			return $this->file;
+		}
+
+		if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
+		{
+			$sniffer =& new $this->content_type_sniffer_class($this->file);
+			if ($sniffer->get_type() !== 'text/html')
+			{
+				return null;
+			}
+		}
+
+		if ($type & ~SIMPLEPIE_LOCATOR_NONE)
+		{
+			$this->get_base();
+		}
+
+		if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery())
+		{
+			return $working[0];
+		}
+
+		if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links())
+		{
+			if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
+			{
+				return $working;
+			}
+
+			if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local))
+			{
+				return $working;
+			}
+
+			if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere))
+			{
+				return $working;
+			}
+
+			if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere))
+			{
+				return $working;
+			}
+		}
+		return null;
+	}
+
+	function is_feed(&$file)
+	{
+		if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
+		{
+			$sniffer =& new $this->content_type_sniffer_class($file);
+			$sniffed = $sniffer->get_type();
+			if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml')))
+			{
+				return true;
+			}
+			else
+			{
+				return false;
+			}
+		}
+		elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
+		{
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	function get_base()
+	{
+		$this->http_base = $this->file->url;
+		$this->base = $this->http_base;
+		$elements = SimplePie_Misc::get_element('base', $this->file->body);
+		foreach ($elements as $element)
+		{
+			if ($element['attribs']['href']['data'] !== '')
+			{
+				$this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data']), $this->http_base);
+				$this->base_location = $element['offset'];
+				break;
+			}
+		}
+	}
+
+	function autodiscovery()
+	{
+		$links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body));
+		$done = array();
+		$feeds = array();
+		foreach ($links as $link)
+		{
+			if ($this->checked_feeds === $this->max_checked_feeds)
+			{
+				break;
+			}
+			if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data']))
+			{
+				$rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data'])));
+
+				if ($this->base_location < $link['offset'])
+				{
+					$href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
+				}
+				else
+				{
+					$href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
+				}
+
+				if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
+				{
+					$this->checked_feeds++;
+					$feed =& new $this->file_class($href, $this->timeout, 5, null, $this->useragent);
+					if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
+					{
+						$feeds[$href] = $feed;
+					}
+				}
+				$done[] = $href;
+			}
+		}
+
+		if (!empty($feeds))
+		{
+			return array_values($feeds);
+		}
+		else {
+			return null;
+		}
+	}
+
+	function get_links()
+	{
+		$links = SimplePie_Misc::get_element('a', $this->file->body);
+		foreach ($links as $link)
+		{
+			if (isset($link['attribs']['href']['data']))
+			{
+				$href = trim($link['attribs']['href']['data']);
+				$parsed = SimplePie_Misc::parse_url($href);
+				if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme']))
+				{
+					if ($this->base_location < $link['offset'])
+					{
+						$href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base);
+					}
+					else
+					{
+						$href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base);
+					}
+
+					$current = SimplePie_Misc::parse_url($this->file->url);
+
+					if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority'])
+					{
+						$this->local[] = $href;
+					}
+					else
+					{
+						$this->elsewhere[] = $href;
+					}
+				}
+			}
+		}
+		$this->local = array_unique($this->local);
+		$this->elsewhere = array_unique($this->elsewhere);
+		if (!empty($this->local) || !empty($this->elsewhere))
+		{
+			return true;
+		}
+		return null;
+	}
+
+	function extension(&$array)
+	{
+		foreach ($array as $key => $value)
+		{
+			if ($this->checked_feeds === $this->max_checked_feeds)
+			{
+				break;
+			}
+			if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml')))
+			{
+				$this->checked_feeds++;
+				$feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
+				if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
+				{
+					return $feed;
+				}
+				else
+				{
+					unset($array[$key]);
+				}
+			}
+		}
+		return null;
+	}
+
+	function body(&$array)
+	{
+		foreach ($array as $key => $value)
+		{
+			if ($this->checked_feeds === $this->max_checked_feeds)
+			{
+				break;
+			}
+			if (preg_match('/(rss|rdf|atom|xml)/i', $value))
+			{
+				$this->checked_feeds++;
+				$feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent);
+				if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
+				{
+					return $feed;
+				}
+				else
+				{
+					unset($array[$key]);
+				}
+			}
+		}
+		return null;
+	}
+}
+
+class SimplePie_Parser
+{
+	var $error_code;
+	var $error_string;
+	var $current_line;
+	var $current_column;
+	var $current_byte;
+	var $separator = ' ';
+	var $namespace = array('');
+	var $element = array('');
+	var $xml_base = array('');
+	var $xml_base_explicit = array(false);
+	var $xml_lang = array('');
+	var $data = array();
+	var $datas = array(array());
+	var $current_xhtml_construct = -1;
+	var $encoding;
+
+	function parse(&$data, $encoding)
+	{
+		// Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
+		if (strtoupper($encoding) === 'US-ASCII')
+		{
+			$this->encoding = 'UTF-8';
+		}
+		else
+		{
+			$this->encoding = $encoding;
+		}
+
+		// Strip BOM:
+		// UTF-32 Big Endian BOM
+		if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
+		{
+			$data = substr($data, 4);
+		}
+		// UTF-32 Little Endian BOM
+		elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
+		{
+			$data = substr($data, 4);
+		}
+		// UTF-16 Big Endian BOM
+		elseif (substr($data, 0, 2) === "\xFE\xFF")
+		{
+			$data = substr($data, 2);
+		}
+		// UTF-16 Little Endian BOM
+		elseif (substr($data, 0, 2) === "\xFF\xFE")
+		{
+			$data = substr($data, 2);
+		}
+		// UTF-8 BOM
+		elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
+		{
+			$data = substr($data, 3);
+		}
+
+		if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false)
+		{
+			$declaration =& new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5));
+			if ($declaration->parse())
+			{
+				$data = substr($data, $pos + 2);
+				$data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;
+			}
+			else
+			{
+				$this->error_string = 'SimplePie bug! Please report this!';
+				return false;
+			}
+		}
+
+		$return = true;
+
+		static $xml_is_sane = null;
+		if ($xml_is_sane === null)
+		{
+			$parser_check = xml_parser_create();
+			xml_parse_into_struct($parser_check, '<foo>&amp;</foo>', $values);
+			xml_parser_free($parser_check);
+			$xml_is_sane = isset($values[0]['value']);
+		}
+
+		// Create the parser
+		if ($xml_is_sane)
+		{
+			$xml = xml_parser_create_ns($this->encoding, $this->separator);
+			xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
+			xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
+			xml_set_object($xml, $this);
+			xml_set_character_data_handler($xml, 'cdata');
+			xml_set_element_handler($xml, 'tag_open', 'tag_close');
+
+			// Parse!
+			if (!xml_parse($xml, $data, true))
+			{
+				$this->error_code = xml_get_error_code($xml);
+				$this->error_string = xml_error_string($this->error_code);
+				$return = false;
+			}
+			$this->current_line = xml_get_current_line_number($xml);
+			$this->current_column = xml_get_current_column_number($xml);
+			$this->current_byte = xml_get_current_byte_index($xml);
+			xml_parser_free($xml);
+			return $return;
+		}
+		else
+		{
+			libxml_clear_errors();
+			$xml =& new XMLReader();
+			$xml->xml($data);
+			while (@$xml->read())
+			{
+				switch ($xml->nodeType)
+				{
+
+					case constant('XMLReader::END_ELEMENT'):
+						if ($xml->namespaceURI !== '')
+						{
+							$tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+						}
+						else
+						{
+							$tagName = $xml->localName;
+						}
+						$this->tag_close(null, $tagName);
+						break;
+					case constant('XMLReader::ELEMENT'):
+						$empty = $xml->isEmptyElement;
+						if ($xml->namespaceURI !== '')
+						{
+							$tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+						}
+						else
+						{
+							$tagName = $xml->localName;
+						}
+						$attributes = array();
+						while ($xml->moveToNextAttribute())
+						{
+							if ($xml->namespaceURI !== '')
+							{
+								$attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}";
+							}
+							else
+							{
+								$attrName = $xml->localName;
+							}
+							$attributes[$attrName] = $xml->value;
+						}
+						$this->tag_open(null, $tagName, $attributes);
+						if ($empty)
+						{
+							$this->tag_close(null, $tagName);
+						}
+						break;
+					case constant('XMLReader::TEXT'):
+
+					case constant('XMLReader::CDATA'):
+						$this->cdata(null, $xml->value);
+						break;
+				}
+			}
+			if ($error = libxml_get_last_error())
+			{
+				$this->error_code = $error->code;
+				$this->error_string = $error->message;
+				$this->current_line = $error->line;
+				$this->current_column = $error->column;
+				return false;
+			}
+			else
+			{
+				return true;
+			}
+		}
+	}
+
+	function get_error_code()
+	{
+		return $this->error_code;
+	}
+
+	function get_error_string()
+	{
+		return $this->error_string;
+	}
+
+	function get_current_line()
+	{
+		return $this->current_line;
+	}
+
+	function get_current_column()
+	{
+		return $this->current_column;
+	}
+
+	function get_current_byte()
+	{
+		return $this->current_byte;
+	}
+
+	function get_data()
+	{
+		return $this->data;
+	}
+
+	function tag_open($parser, $tag, $attributes)
+	{
+		list($this->namespace[], $this->element[]) = $this->split_ns($tag);
+
+		$attribs = array();
+		foreach ($attributes as $name => $value)
+		{
+			list($attrib_namespace, $attribute) = $this->split_ns($name);
+			$attribs[$attrib_namespace][$attribute] = $value;
+		}
+
+		if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base']))
+		{
+			$this->xml_base[] = SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base));
+			$this->xml_base_explicit[] = true;
+		}
+		else
+		{
+			$this->xml_base[] = end($this->xml_base);
+			$this->xml_base_explicit[] = end($this->xml_base_explicit);
+		}
+
+		if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang']))
+		{
+			$this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang'];
+		}
+		else
+		{
+			$this->xml_lang[] = end($this->xml_lang);
+		}
+
+		if ($this->current_xhtml_construct >= 0)
+		{
+			$this->current_xhtml_construct++;
+			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML)
+			{
+				$this->data['data'] .= '<' . end($this->element);
+				if (isset($attribs['']))
+				{
+					foreach ($attribs[''] as $name => $value)
+					{
+						$this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"';
+					}
+				}
+				$this->data['data'] .= '>';
+			}
+		}
+		else
+		{
+			$this->datas[] =& $this->data;
+			$this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
+			$this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
+			if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
+			|| (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml'))
+			{
+				$this->current_xhtml_construct = 0;
+			}
+		}
+	}
+
+	function cdata($parser, $cdata)
+	{
+		if ($this->current_xhtml_construct >= 0)
+		{
+			$this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding);
+		}
+		else
+		{
+			$this->data['data'] .= $cdata;
+		}
+	}
+
+	function tag_close($parser, $tag)
+	{
+		if ($this->current_xhtml_construct >= 0)
+		{
+			$this->current_xhtml_construct--;
+			if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
+			{
+				$this->data['data'] .= '</' . end($this->element) . '>';
+			}
+		}
+		if ($this->current_xhtml_construct === -1)
+		{
+			$this->data =& $this->datas[count($this->datas) - 1];
+			array_pop($this->datas);
+		}
+
+		array_pop($this->element);
+		array_pop($this->namespace);
+		array_pop($this->xml_base);
+		array_pop($this->xml_base_explicit);
+		array_pop($this->xml_lang);
+	}
+
+	function split_ns($string)
+	{
+		static $cache = array();
+		if (!isset($cache[$string]))
+		{
+			if ($pos = strpos($string, $this->separator))
+			{
+				static $separator_length;
+				if (!$separator_length)
+				{
+					$separator_length = strlen($this->separator);
+				}
+				$namespace = substr($string, 0, $pos);
+				$local_name = substr($string, $pos + $separator_length);
+				if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES)
+				{
+					$namespace = SIMPLEPIE_NAMESPACE_ITUNES;
+				}
+
+				// Normalize the Media RSS namespaces
+				if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG)
+				{
+					$namespace = SIMPLEPIE_NAMESPACE_MEDIARSS;
+				}
+				$cache[$string] = array($namespace, $local_name);
+			}
+			else
+			{
+				$cache[$string] = array('', $string);
+			}
+		}
+		return $cache[$string];
+	}
+}
+
+/**
+ * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags
+ */
+class SimplePie_Sanitize
+{
+	// Private vars
+	var $base;
+
+	// Options
+	var $remove_div = true;
+	var $image_handler = '';
+	var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
+	var $encode_instead_of_strip = false;
+	var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
+	var $strip_comments = false;
+	var $output_encoding = 'UTF-8';
+	var $enable_cache = true;
+	var $cache_location = './cache';
+	var $cache_name_function = 'md5';
+	var $cache_class = 'SimplePie_Cache';
+	var $file_class = 'SimplePie_File';
+	var $timeout = 10;
+	var $useragent = '';
+	var $force_fsockopen = false;
+
+	var $replace_url_attributes = array(
+		'a' => 'href',
+		'area' => 'href',
+		'blockquote' => 'cite',
+		'del' => 'cite',
+		'form' => 'action',
+		'img' => array('longdesc', 'src'),
+		'input' => 'src',
+		'ins' => 'cite',
+		'q' => 'cite'
+	);
+
+	function remove_div($enable = true)
+	{
+		$this->remove_div = (bool) $enable;
+	}
+
+	function set_image_handler($page = false)
+	{
+		if ($page)
+		{
+			$this->image_handler = (string) $page;
+		}
+		else
+		{
+			$this->image_handler = false;
+		}
+	}
+
+	function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache')
+	{
+		if (isset($enable_cache))
+		{
+			$this->enable_cache = (bool) $enable_cache;
+		}
+
+		if ($cache_location)
+		{
+			$this->cache_location = (string) $cache_location;
+		}
+
+		if ($cache_name_function)
+		{
+			$this->cache_name_function = (string) $cache_name_function;
+		}
+
+		if ($cache_class)
+		{
+			$this->cache_class = (string) $cache_class;
+		}
+	}
+
+	function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false)
+	{
+		if ($file_class)
+		{
+			$this->file_class = (string) $file_class;
+		}
+
+		if ($timeout)
+		{
+			$this->timeout = (string) $timeout;
+		}
+
+		if ($useragent)
+		{
+			$this->useragent = (string) $useragent;
+		}
+
+		if ($force_fsockopen)
+		{
+			$this->force_fsockopen = (string) $force_fsockopen;
+		}
+	}
+
+	function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'))
+	{
+		if ($tags)
+		{
+			if (is_array($tags))
+			{
+				$this->strip_htmltags = $tags;
+			}
+			else
+			{
+				$this->strip_htmltags = explode(',', $tags);
+			}
+		}
+		else
+		{
+			$this->strip_htmltags = false;
+		}
+	}
+
+	function encode_instead_of_strip($encode = false)
+	{
+		$this->encode_instead_of_strip = (bool) $encode;
+	}
+
+	function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))
+	{
+		if ($attribs)
+		{
+			if (is_array($attribs))
+			{
+				$this->strip_attributes = $attribs;
+			}
+			else
+			{
+				$this->strip_attributes = explode(',', $attribs);
+			}
+		}
+		else
+		{
+			$this->strip_attributes = false;
+		}
+	}
+
+	function strip_comments($strip = false)
+	{
+		$this->strip_comments = (bool) $strip;
+	}
+
+	function set_output_encoding($encoding = 'UTF-8')
+	{
+		$this->output_encoding = (string) $encoding;
+	}
+
+	/**
+	 * Set element/attribute key/value pairs of HTML attributes
+	 * containing URLs that need to be resolved relative to the feed
+	 *
+	 * @access public
+	 * @since 1.0
+	 * @param array $element_attribute Element/attribute key/value pairs
+	 */
+	function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite'))
+	{
+		$this->replace_url_attributes = (array) $element_attribute;
+	}
+
+	function sanitize($data, $type, $base = '')
+	{
+		$data = trim($data);
+		if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI)
+		{
+			if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML)
+			{
+				if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data))
+				{
+					$type |= SIMPLEPIE_CONSTRUCT_HTML;
+				}
+				else
+				{
+					$type |= SIMPLEPIE_CONSTRUCT_TEXT;
+				}
+			}
+
+			if ($type & SIMPLEPIE_CONSTRUCT_BASE64)
+			{
+				$data = base64_decode($data);
+			}
+
+			if ($type & SIMPLEPIE_CONSTRUCT_XHTML)
+			{
+				if ($this->remove_div)
+				{
+					$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data);
+					$data = preg_replace('/<\/div>$/', '', $data);
+				}
+				else
+				{
+					$data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data);
+				}
+			}
+
+			if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML))
+			{
+				// Strip comments
+				if ($this->strip_comments)
+				{
+					$data = SimplePie_Misc::strip_comments($data);
+				}
+
+				// Strip out HTML tags and attributes that might cause various security problems.
+				// Based on recommendations by Mark Pilgrim at:
+				// http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely
+				if ($this->strip_htmltags)
+				{
+					foreach ($this->strip_htmltags as $tag)
+					{
+						$pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU';
+						while (preg_match($pcre, $data))
+						{
+							$data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data);
+						}
+					}
+				}
+
+				if ($this->strip_attributes)
+				{
+					foreach ($this->strip_attributes as $attrib)
+					{
+						$data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data);
+					}
+				}
+
+				// Replace relative URLs
+				$this->base = $base;
+				foreach ($this->replace_url_attributes as $element => $attributes)
+				{
+					$data = $this->replace_urls($data, $element, $attributes);
+				}
+
+				// If image handling (caching, etc.) is enabled, cache and rewrite all the image tags.
+				if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache)
+				{
+					$images = SimplePie_Misc::get_element('img', $data);
+					foreach ($images as $img)
+					{
+						if (isset($img['attribs']['src']['data']))
+						{
+							$image_url = call_user_func($this->cache_name_function, $img['attribs']['src']['data']);
+							$cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $image_url, 'spi');
+
+							if ($cache->load())
+							{
+								$img['attribs']['src']['data'] = $this->image_handler . $image_url;
+								$data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
+							}
+							else
+							{
+								$file =& new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen);
+								$headers = $file->headers;
+
+								if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
+								{
+									if ($cache->save(array('headers' => $file->headers, 'body' => $file->body)))
+									{
+										$img['attribs']['src']['data'] = $this->image_handler . $image_url;
+										$data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data);
+									}
+									else
+									{
+										trigger_error("$this->cache_location is not writeable", E_USER_WARNING);
+									}
+								}
+							}
+						}
+					}
+				}
+
+				// Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data
+				$data = trim($data);
+			}
+
+			if ($type & SIMPLEPIE_CONSTRUCT_IRI)
+			{
+				$data = SimplePie_Misc::absolutize_url($data, $base);
+			}
+
+			if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI))
+			{
+				$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
+			}
+
+			if ($this->output_encoding !== 'UTF-8')
+			{
+				$data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding);
+			}
+		}
+		return $data;
+	}
+
+	function replace_urls($data, $tag, $attributes)
+	{
+		if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
+		{
+			$elements = SimplePie_Misc::get_element($tag, $data);
+			foreach ($elements as $element)
+			{
+				if (is_array($attributes))
+				{
+					foreach ($attributes as $attribute)
+					{
+						if (isset($element['attribs'][$attribute]['data']))
+						{
+							$element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base);
+							$new_element = SimplePie_Misc::element_implode($element);
+							$data = str_replace($element['full'], $new_element, $data);
+							$element['full'] = $new_element;
+						}
+					}
+				}
+				elseif (isset($element['attribs'][$attributes]['data']))
+				{
+					$element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base);
+					$data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data);
+				}
+			}
+		}
+		return $data;
+	}
+
+	function do_strip_htmltags($match)
+	{
+		if ($this->encode_instead_of_strip)
+		{
+			if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
+			{
+				$match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
+				$match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
+				return "&lt;$match[1]$match[2]&gt;$match[3]&lt;/$match[1]&gt;";
+			}
+			else
+			{
+				return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
+			}
+		}
+		elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
+		{
+			return $match[4];
+		}
+		else
+		{
+			return '';
+		}
+	}
+}
+endif;
+?>
Index: /tags/3.1/wp-includes/class-smtp.php
===================================================================
--- /tags/3.1/wp-includes/class-smtp.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-smtp.php	(revision 17487)
@@ -0,0 +1,1062 @@
+<?php
+/*~ class.smtp.php
+.---------------------------------------------------------------------------.
+|  Software: PHPMailer - PHP email class                                    |
+|   Version: 2.0.4                                                          |
+|   Contact: via sourceforge.net support pages (also www.codeworxtech.com)  |
+|      Info: http://phpmailer.sourceforge.net                               |
+|   Support: http://sourceforge.net/projects/phpmailer/                     |
+| ------------------------------------------------------------------------- |
+|    Author: Andy Prevost (project admininistrator)                         |
+|    Author: Brent R. Matzelle (original founder)                           |
+| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved.               |
+| Copyright (c) 2001-2003, Brent R. Matzelle                                |
+| ------------------------------------------------------------------------- |
+|   License: Distributed under the Lesser General Public License (LGPL)     |
+|            http://www.gnu.org/copyleft/lesser.html                        |
+| This program is distributed in the hope that it will be useful - WITHOUT  |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     |
+| FITNESS FOR A PARTICULAR PURPOSE.                                         |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com):                |
+| - Web Hosting on highly optimized fast and secure servers                 |
+| - Technology Consulting                                                   |
+| - Oursourcing (highly qualified programmers and graphic designers)        |
+'---------------------------------------------------------------------------'
+ */
+/**
+ * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
+ * commands except TURN which will always return a not implemented
+ * error. SMTP also provides some utility methods for sending mail
+ * to an SMTP server.
+ * @package PHPMailer
+ * @author Chris Ryan
+ */
+
+class SMTP
+{
+  /**
+   *  SMTP server port
+   *  @var int
+   */
+  var $SMTP_PORT = 25;
+
+  /**
+   *  SMTP reply line ending
+   *  @var string
+   */
+  var $CRLF = "\r\n";
+
+  /**
+   *  Sets whether debugging is turned on
+   *  @var bool
+   */
+  var $do_debug;       # the level of debug to perform
+
+  /**
+   *  Sets VERP use on/off (default is off)
+   *  @var bool
+   */
+  var $do_verp = false;
+
+  /**#@+
+   * @access private
+   */
+  var $smtp_conn;      # the socket to the server
+  var $error;          # error if any on the last call
+  var $helo_rply;      # the reply the server sent to us for HELO
+  /**#@-*/
+
+  /**
+   * Initialize the class so that the data is in a known state.
+   * @access public
+   * @return void
+   */
+  function SMTP() {
+    $this->smtp_conn = 0;
+    $this->error = null;
+    $this->helo_rply = null;
+
+    $this->do_debug = 0;
+  }
+
+  /*************************************************************
+   *                    CONNECTION FUNCTIONS                  *
+   ***********************************************************/
+
+  /**
+   * Connect to the server specified on the port specified.
+   * If the port is not specified use the default SMTP_PORT.
+   * If tval is specified then a connection will try and be
+   * established with the server for that number of seconds.
+   * If tval is not specified the default is 30 seconds to
+   * try on the connection.
+   *
+   * SMTP CODE SUCCESS: 220
+   * SMTP CODE FAILURE: 421
+   * @access public
+   * @return bool
+   */
+  function Connect($host,$port=0,$tval=30) {
+    # set the error val to null so there is no confusion
+    $this->error = null;
+
+    # make sure we are __not__ connected
+    if($this->connected()) {
+      # ok we are connected! what should we do?
+      # for now we will just give an error saying we
+      # are already connected
+      $this->error = array("error" => "Already connected to a server");
+      return false;
+    }
+
+    if(empty($port)) {
+      $port = $this->SMTP_PORT;
+    }
+
+    #connect to the smtp server
+    $this->smtp_conn = fsockopen($host,    # the host of the server
+                                 $port,    # the port to use
+                                 $errno,   # error number if any
+                                 $errstr,  # error message if any
+                                 $tval);   # give up after ? secs
+    # verify we connected properly
+    if(empty($this->smtp_conn)) {
+      $this->error = array("error" => "Failed to connect to server",
+                           "errno" => $errno,
+                           "errstr" => $errstr);
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": $errstr ($errno)" . $this->CRLF;
+      }
+      return false;
+    }
+
+    # sometimes the SMTP server takes a little longer to respond
+    # so we will give it a longer timeout for the first read
+    // Windows still does not have support for this timeout function
+    if(substr(PHP_OS, 0, 3) != "WIN")
+     socket_set_timeout($this->smtp_conn, $tval, 0);
+
+    # get any announcement stuff
+    $announce = $this->get_lines();
+
+    # set the timeout  of any socket functions at 1/10 of a second
+    //if(function_exists("socket_set_timeout"))
+    //   socket_set_timeout($this->smtp_conn, 0, 100000);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
+    }
+
+    return true;
+  }
+
+  /**
+   * Performs SMTP authentication.  Must be run after running the
+   * Hello() method.  Returns true if successfully authenticated.
+   * @access public
+   * @return bool
+   */
+  function Authenticate($username, $password) {
+    // Start authentication
+    fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($code != 334) {
+      $this->error =
+        array("error" => "AUTH not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    // Send encoded username
+    fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($code != 334) {
+      $this->error =
+        array("error" => "Username not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    // Send encoded password
+    fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($code != 235) {
+      $this->error =
+        array("error" => "Password not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    return true;
+  }
+
+  /**
+   * Returns true if connected to a server otherwise false
+   * @access private
+   * @return bool
+   */
+  function Connected() {
+    if(!empty($this->smtp_conn)) {
+      $sock_status = socket_get_status($this->smtp_conn);
+      if($sock_status["eof"]) {
+        # hmm this is an odd situation... the socket is
+        # valid but we are not connected anymore
+        if($this->do_debug >= 1) {
+            echo "SMTP -> NOTICE:" . $this->CRLF .
+                 "EOF caught while checking if connected";
+        }
+        $this->Close();
+        return false;
+      }
+      return true; # everything looks good
+    }
+    return false;
+  }
+
+  /**
+   * Closes the socket and cleans up the state of the class.
+   * It is not considered good to use this function without
+   * first trying to use QUIT.
+   * @access public
+   * @return void
+   */
+  function Close() {
+    $this->error = null; # so there is no confusion
+    $this->helo_rply = null;
+    if(!empty($this->smtp_conn)) {
+      # close the connection and cleanup
+      fclose($this->smtp_conn);
+      $this->smtp_conn = 0;
+    }
+  }
+
+  /***************************************************************
+   *                        SMTP COMMANDS                       *
+   *************************************************************/
+
+  /**
+   * Issues a data command and sends the msg_data to the server
+   * finializing the mail transaction. $msg_data is the message
+   * that is to be send with the headers. Each header needs to be
+   * on a single line followed by a <CRLF> with the message headers
+   * and the message body being separated by and additional <CRLF>.
+   *
+   * Implements rfc 821: DATA <CRLF>
+   *
+   * SMTP CODE INTERMEDIATE: 354
+   *     [data]
+   *     <CRLF>.<CRLF>
+   *     SMTP CODE SUCCESS: 250
+   *     SMTP CODE FAILURE: 552,554,451,452
+   * SMTP CODE FAILURE: 451,554
+   * SMTP CODE ERROR  : 500,501,503,421
+   * @access public
+   * @return bool
+   */
+  function Data($msg_data) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Data() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"DATA" . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 354) {
+      $this->error =
+        array("error" => "DATA command not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    # the server is ready to accept data!
+    # according to rfc 821 we should not send more than 1000
+    # including the CRLF
+    # characters on a single line so we will break the data up
+    # into lines by \r and/or \n then if needed we will break
+    # each of those into smaller lines to fit within the limit.
+    # in addition we will be looking for lines that start with
+    # a period '.' and append and additional period '.' to that
+    # line. NOTE: this does not count towards are limit.
+
+    # normalize the line breaks so we know the explode works
+    $msg_data = str_replace("\r\n","\n",$msg_data);
+    $msg_data = str_replace("\r","\n",$msg_data);
+    $lines = explode("\n",$msg_data);
+
+    # we need to find a good way to determine is headers are
+    # in the msg_data or if it is a straight msg body
+    # currently I am assuming rfc 822 definitions of msg headers
+    # and if the first field of the first line (':' sperated)
+    # does not contain a space then it _should_ be a header
+    # and we can process all lines before a blank "" line as
+    # headers.
+    $field = substr($lines[0],0,strpos($lines[0],":"));
+    $in_headers = false;
+    if(!empty($field) && !strstr($field," ")) {
+      $in_headers = true;
+    }
+
+    $max_line_length = 998; # used below; set here for ease in change
+
+    while(list(,$line) = @each($lines)) {
+      $lines_out = null;
+      if($line == "" && $in_headers) {
+        $in_headers = false;
+      }
+      # ok we need to break this line up into several
+      # smaller lines
+      while(strlen($line) > $max_line_length) {
+        $pos = strrpos(substr($line,0,$max_line_length)," ");
+
+        # Patch to fix DOS attack
+        if(!$pos) {
+          $pos = $max_line_length - 1;
+        }
+
+        $lines_out[] = substr($line,0,$pos);
+        $line = substr($line,$pos + 1);
+        # if we are processing headers we need to
+        # add a LWSP-char to the front of the new line
+        # rfc 822 on long msg headers
+        if($in_headers) {
+          $line = "\t" . $line;
+        }
+      }
+      $lines_out[] = $line;
+
+      # now send the lines to the server
+      while(list(,$line_out) = @each($lines_out)) {
+        if(strlen($line_out) > 0)
+        {
+          if(substr($line_out, 0, 1) == ".") {
+            $line_out = "." . $line_out;
+          }
+        }
+        fputs($this->smtp_conn,$line_out . $this->CRLF);
+      }
+    }
+
+    # ok all the message data has been sent so lets get this
+    # over with aleady
+    fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "DATA not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Expand takes the name and asks the server to list all the
+   * people who are members of the _list_. Expand will return
+   * back and array of the result or false if an error occurs.
+   * Each value in the array returned has the format of:
+   *     [ <full-name> <sp> ] <path>
+   * The definition of <path> is defined in rfc 821
+   *
+   * Implements rfc 821: EXPN <SP> <string> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE FAILURE: 550
+   * SMTP CODE ERROR  : 500,501,502,504,421
+   * @access public
+   * @return string array
+   */
+  function Expand($name) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+            "error" => "Called Expand() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "EXPN not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    # parse the reply and place in our array to return to user
+    $entries = explode($this->CRLF,$rply);
+    while(list(,$l) = @each($entries)) {
+      $list[] = substr($l,4);
+    }
+
+    return $list;
+  }
+
+  /**
+   * Sends the HELO command to the smtp server.
+   * This makes sure that we and the server are in
+   * the same known state.
+   *
+   * Implements from rfc 821: HELO <SP> <domain> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE ERROR  : 500, 501, 504, 421
+   * @access public
+   * @return bool
+   */
+  function Hello($host="") {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+            "error" => "Called Hello() without being connected");
+      return false;
+    }
+
+    # if a hostname for the HELO was not specified determine
+    # a suitable one to send
+    if(empty($host)) {
+      # we need to determine some sort of appopiate default
+      # to send to the server
+      $host = "localhost";
+    }
+
+    // Send extended hello first (RFC 2821)
+    if(!$this->SendHello("EHLO", $host))
+    {
+      if(!$this->SendHello("HELO", $host))
+          return false;
+    }
+
+    return true;
+  }
+
+  /**
+   * Sends a HELO/EHLO command.
+   * @access private
+   * @return bool
+   */
+  function SendHello($hello, $host) {
+    fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => $hello . " not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    $this->helo_rply = $rply;
+
+    return true;
+  }
+
+  /**
+   * Gets help information on the keyword specified. If the keyword
+   * is not specified then returns generic help, ussually contianing
+   * A list of keywords that help is available on. This function
+   * returns the results back to the user. It is up to the user to
+   * handle the returned data. If an error occurs then false is
+   * returned with $this->error set appropiately.
+   *
+   * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
+   *
+   * SMTP CODE SUCCESS: 211,214
+   * SMTP CODE ERROR  : 500,501,502,504,421
+   * @access public
+   * @return string
+   */
+  function Help($keyword="") {
+    $this->error = null; # to avoid confusion
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Help() without being connected");
+      return false;
+    }
+
+    $extra = "";
+    if(!empty($keyword)) {
+      $extra = " " . $keyword;
+    }
+
+    fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 211 && $code != 214) {
+      $this->error =
+        array("error" => "HELP not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    return $rply;
+  }
+
+  /**
+   * Starts a mail transaction from the email address specified in
+   * $from. Returns true if successful or false otherwise. If True
+   * the mail transaction is started and then one or more Recipient
+   * commands may be called followed by a Data command.
+   *
+   * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE SUCCESS: 552,451,452
+   * SMTP CODE SUCCESS: 500,501,421
+   * @access public
+   * @return bool
+   */
+  function Mail($from) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Mail() without being connected");
+      return false;
+    }
+
+    $useVerp = ($this->do_verp ? "XVERP" : "");
+    fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "MAIL not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Sends the command NOOP to the SMTP server.
+   *
+   * Implements from rfc 821: NOOP <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE ERROR  : 500, 421
+   * @access public
+   * @return bool
+   */
+  function Noop() {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Noop() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"NOOP" . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "NOOP not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Sends the quit command to the server and then closes the socket
+   * if there is no error or the $close_on_error argument is true.
+   *
+   * Implements from rfc 821: QUIT <CRLF>
+   *
+   * SMTP CODE SUCCESS: 221
+   * SMTP CODE ERROR  : 500
+   * @access public
+   * @return bool
+   */
+  function Quit($close_on_error=true) {
+    $this->error = null; # so there is no confusion
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Quit() without being connected");
+      return false;
+    }
+
+    # send the quit command to the server
+    fputs($this->smtp_conn,"quit" . $this->CRLF);
+
+    # get any good-bye messages
+    $byemsg = $this->get_lines();
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
+    }
+
+    $rval = true;
+    $e = null;
+
+    $code = substr($byemsg,0,3);
+    if($code != 221) {
+      # use e as a tmp var cause Close will overwrite $this->error
+      $e = array("error" => "SMTP server rejected quit command",
+                 "smtp_code" => $code,
+                 "smtp_rply" => substr($byemsg,4));
+      $rval = false;
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $e["error"] . ": " .
+                 $byemsg . $this->CRLF;
+      }
+    }
+
+    if(empty($e) || $close_on_error) {
+      $this->Close();
+    }
+
+    return $rval;
+  }
+
+  /**
+   * Sends the command RCPT to the SMTP server with the TO: argument of $to.
+   * Returns true if the recipient was accepted false if it was rejected.
+   *
+   * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250,251
+   * SMTP CODE FAILURE: 550,551,552,553,450,451,452
+   * SMTP CODE ERROR  : 500,501,503,421
+   * @access public
+   * @return bool
+   */
+  function Recipient($to) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Recipient() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250 && $code != 251) {
+      $this->error =
+        array("error" => "RCPT not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Sends the RSET command to abort and transaction that is
+   * currently in progress. Returns true if successful false
+   * otherwise.
+   *
+   * Implements rfc 821: RSET <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE ERROR  : 500,501,504,421
+   * @access public
+   * @return bool
+   */
+  function Reset() {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Reset() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"RSET" . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "RSET failed",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+
+    return true;
+  }
+
+  /**
+   * Starts a mail transaction from the email address specified in
+   * $from. Returns true if successful or false otherwise. If True
+   * the mail transaction is started and then one or more Recipient
+   * commands may be called followed by a Data command. This command
+   * will send the message to the users terminal if they are logged
+   * in.
+   *
+   * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE SUCCESS: 552,451,452
+   * SMTP CODE SUCCESS: 500,501,502,421
+   * @access public
+   * @return bool
+   */
+  function Send($from) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Send() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "SEND not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Starts a mail transaction from the email address specified in
+   * $from. Returns true if successful or false otherwise. If True
+   * the mail transaction is started and then one or more Recipient
+   * commands may be called followed by a Data command. This command
+   * will send the message to the users terminal if they are logged
+   * in and send them an email.
+   *
+   * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE SUCCESS: 552,451,452
+   * SMTP CODE SUCCESS: 500,501,502,421
+   * @access public
+   * @return bool
+   */
+  function SendAndMail($from) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+          "error" => "Called SendAndMail() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "SAML not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * Starts a mail transaction from the email address specified in
+   * $from. Returns true if successful or false otherwise. If True
+   * the mail transaction is started and then one or more Recipient
+   * commands may be called followed by a Data command. This command
+   * will send the message to the users terminal if they are logged
+   * in or mail it to them if they are not.
+   *
+   * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE SUCCESS: 552,451,452
+   * SMTP CODE SUCCESS: 500,501,502,421
+   * @access public
+   * @return bool
+   */
+  function SendOrMail($from) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+          "error" => "Called SendOrMail() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250) {
+      $this->error =
+        array("error" => "SOML not accepted from server",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return true;
+  }
+
+  /**
+   * This is an optional command for SMTP that this class does not
+   * support. This method is here to make the RFC821 Definition
+   * complete for this class and __may__ be implimented in the future
+   *
+   * Implements from rfc 821: TURN <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250
+   * SMTP CODE FAILURE: 502
+   * SMTP CODE ERROR  : 500, 503
+   * @access public
+   * @return bool
+   */
+  function Turn() {
+    $this->error = array("error" => "This method, TURN, of the SMTP ".
+                                    "is not implemented");
+    if($this->do_debug >= 1) {
+      echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
+    }
+    return false;
+  }
+
+  /**
+   * Verifies that the name is recognized by the server.
+   * Returns false if the name could not be verified otherwise
+   * the response from the server is returned.
+   *
+   * Implements rfc 821: VRFY <SP> <string> <CRLF>
+   *
+   * SMTP CODE SUCCESS: 250,251
+   * SMTP CODE FAILURE: 550,551,553
+   * SMTP CODE ERROR  : 500,501,502,421
+   * @access public
+   * @return int
+   */
+  function Verify($name) {
+    $this->error = null; # so no confusion is caused
+
+    if(!$this->connected()) {
+      $this->error = array(
+              "error" => "Called Verify() without being connected");
+      return false;
+    }
+
+    fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
+
+    $rply = $this->get_lines();
+    $code = substr($rply,0,3);
+
+    if($this->do_debug >= 2) {
+      echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+    }
+
+    if($code != 250 && $code != 251) {
+      $this->error =
+        array("error" => "VRFY failed on name '$name'",
+              "smtp_code" => $code,
+              "smtp_msg" => substr($rply,4));
+      if($this->do_debug >= 1) {
+        echo "SMTP -> ERROR: " . $this->error["error"] .
+                 ": " . $rply . $this->CRLF;
+      }
+      return false;
+    }
+    return $rply;
+  }
+
+  /*******************************************************************
+   *                       INTERNAL FUNCTIONS                       *
+   ******************************************************************/
+
+  /**
+   * Read in as many lines as possible
+   * either before eof or socket timeout occurs on the operation.
+   * With SMTP we can tell if we have more lines to read if the
+   * 4th character is '-' symbol. If it is a space then we don't
+   * need to read anything else.
+   * @access private
+   * @return string
+   */
+  function get_lines() {
+    $data = "";
+    while($str = @fgets($this->smtp_conn,515)) {
+      if($this->do_debug >= 4) {
+        echo "SMTP -> get_lines(): \$data was \"$data\"" .
+                 $this->CRLF;
+        echo "SMTP -> get_lines(): \$str is \"$str\"" .
+                 $this->CRLF;
+      }
+      $data .= $str;
+      if($this->do_debug >= 4) {
+        echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
+      }
+      # if the 4th character is a space then we are done reading
+      # so just break the loop
+      if(substr($str,3,1) == " ") { break; }
+    }
+    return $data;
+  }
+
+}
+
+
+ ?>
Index: /tags/3.1/wp-includes/class-snoopy.php
===================================================================
--- /tags/3.1/wp-includes/class-snoopy.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-snoopy.php	(revision 17487)
@@ -0,0 +1,1256 @@
+<?php
+
+/**
+ * Deprecated. Use WP_HTTP (http.php, class-http.php) instead.
+ */
+_deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/http.php' );
+
+if ( !class_exists( 'Snoopy' ) ) :
+/*************************************************
+
+Snoopy - the PHP net client
+Author: Monte Ohrt <monte@ispi.net>
+Copyright (c): 1999-2008 New Digital Group, all rights reserved
+Version: 1.2.4
+
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+You may contact the author of Snoopy by e-mail at:
+monte@ohrt.com
+
+The latest version of Snoopy can be obtained from:
+http://snoopy.sourceforge.net/
+
+*************************************************/
+
+class Snoopy
+{
+	/**** Public variables ****/
+
+	/* user definable vars */
+
+	var $host			=	"www.php.net";		// host name we are connecting to
+	var $port			=	80;					// port we are connecting to
+	var $proxy_host		=	"";					// proxy host to use
+	var $proxy_port		=	"";					// proxy port to use
+	var $proxy_user		=	"";					// proxy user to use
+	var $proxy_pass		=	"";					// proxy password to use
+
+	var $agent			=	"Snoopy v1.2.4";	// agent we masquerade as
+	var	$referer		=	"";					// referer info to pass
+	var $cookies		=	array();			// array of cookies to pass
+												// $cookies["username"]="joe";
+	var	$rawheaders		=	array();			// array of raw headers to send
+												// $rawheaders["Content-type"]="text/html";
+
+	var $maxredirs		=	5;					// http redirection depth maximum. 0 = disallow
+	var $lastredirectaddr	=	"";				// contains address of last redirected address
+	var	$offsiteok		=	true;				// allows redirection off-site
+	var $maxframes		=	0;					// frame content depth maximum. 0 = disallow
+	var $expandlinks	=	true;				// expand links to fully qualified URLs.
+												// this only applies to fetchlinks()
+												// submitlinks(), and submittext()
+	var $passcookies	=	true;				// pass set cookies back through redirects
+												// NOTE: this currently does not respect
+												// dates, domains or paths.
+
+	var	$user			=	"";					// user for http authentication
+	var	$pass			=	"";					// password for http authentication
+
+	// http accept types
+	var $accept			=	"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
+
+	var $results		=	"";					// where the content is put
+
+	var $error			=	"";					// error messages sent here
+	var	$response_code	=	"";					// response code returned from server
+	var	$headers		=	array();			// headers returned from server sent here
+	var	$maxlength		=	500000;				// max return data length (body)
+	var $read_timeout	=	0;					// timeout on read operations, in seconds
+												// supported only since PHP 4 Beta 4
+												// set to 0 to disallow timeouts
+	var $timed_out		=	false;				// if a read operation timed out
+	var	$status			=	0;					// http request status
+
+	var $temp_dir		=	"/tmp";				// temporary directory that the webserver
+												// has permission to write to.
+												// under Windows, this should be C:\temp
+
+	var	$curl_path		=	"/usr/local/bin/curl";
+												// Snoopy will use cURL for fetching
+												// SSL content if a full system path to
+												// the cURL binary is supplied here.
+												// set to false if you do not have
+												// cURL installed. See http://curl.haxx.se
+												// for details on installing cURL.
+												// Snoopy does *not* use the cURL
+												// library functions built into php,
+												// as these functions are not stable
+												// as of this Snoopy release.
+
+	/**** Private variables ****/
+
+	var	$_maxlinelen	=	4096;				// max line length (headers)
+
+	var $_httpmethod	=	"GET";				// default http request method
+	var $_httpversion	=	"HTTP/1.0";			// default http request version
+	var $_submit_method	=	"POST";				// default submit method
+	var $_submit_type	=	"application/x-www-form-urlencoded";	// default submit type
+	var $_mime_boundary	=   "";					// MIME boundary for multipart/form-data submit type
+	var $_redirectaddr	=	false;				// will be set if page fetched is a redirect
+	var $_redirectdepth	=	0;					// increments on an http redirect
+	var $_frameurls		= 	array();			// frame src urls
+	var $_framedepth	=	0;					// increments on frame depth
+
+	var $_isproxy		=	false;				// set if using a proxy server
+	var $_fp_timeout	=	30;					// timeout for socket connection
+
+/*======================================================================*\
+	Function:	fetch
+	Purpose:	fetch the contents of a web page
+				(and possibly other protocols in the
+				future like ftp, nntp, gopher, etc.)
+	Input:		$URI	the location of the page to fetch
+	Output:		$this->results	the output text from the fetch
+\*======================================================================*/
+
+	function fetch($URI)
+	{
+
+		//preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
+		$URI_PARTS = parse_url($URI);
+		if (!empty($URI_PARTS["user"]))
+			$this->user = $URI_PARTS["user"];
+		if (!empty($URI_PARTS["pass"]))
+			$this->pass = $URI_PARTS["pass"];
+		if (empty($URI_PARTS["query"]))
+			$URI_PARTS["query"] = '';
+		if (empty($URI_PARTS["path"]))
+			$URI_PARTS["path"] = '';
+
+		switch(strtolower($URI_PARTS["scheme"]))
+		{
+			case "http":
+				$this->host = $URI_PARTS["host"];
+				if(!empty($URI_PARTS["port"]))
+					$this->port = $URI_PARTS["port"];
+				if($this->_connect($fp))
+				{
+					if($this->_isproxy)
+					{
+						// using proxy, send entire URI
+						$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
+					}
+					else
+					{
+						$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
+						// no proxy, send only the path
+						$this->_httprequest($path, $fp, $URI, $this->_httpmethod);
+					}
+
+					$this->_disconnect($fp);
+
+					if($this->_redirectaddr)
+					{
+						/* url was redirected, check if we've hit the max depth */
+						if($this->maxredirs > $this->_redirectdepth)
+						{
+							// only follow redirect if it's on this site, or offsiteok is true
+							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
+							{
+								/* follow the redirect */
+								$this->_redirectdepth++;
+								$this->lastredirectaddr=$this->_redirectaddr;
+								$this->fetch($this->_redirectaddr);
+							}
+						}
+					}
+
+					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
+					{
+						$frameurls = $this->_frameurls;
+						$this->_frameurls = array();
+
+						while(list(,$frameurl) = each($frameurls))
+						{
+							if($this->_framedepth < $this->maxframes)
+							{
+								$this->fetch($frameurl);
+								$this->_framedepth++;
+							}
+							else
+								break;
+						}
+					}
+				}
+				else
+				{
+					return false;
+				}
+				return true;
+				break;
+			case "https":
+				if(!$this->curl_path)
+					return false;
+				if(function_exists("is_executable"))
+				    if (!is_executable($this->curl_path))
+				        return false;
+				$this->host = $URI_PARTS["host"];
+				if(!empty($URI_PARTS["port"]))
+					$this->port = $URI_PARTS["port"];
+				if($this->_isproxy)
+				{
+					// using proxy, send entire URI
+					$this->_httpsrequest($URI,$URI,$this->_httpmethod);
+				}
+				else
+				{
+					$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
+					// no proxy, send only the path
+					$this->_httpsrequest($path, $URI, $this->_httpmethod);
+				}
+
+				if($this->_redirectaddr)
+				{
+					/* url was redirected, check if we've hit the max depth */
+					if($this->maxredirs > $this->_redirectdepth)
+					{
+						// only follow redirect if it's on this site, or offsiteok is true
+						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
+						{
+							/* follow the redirect */
+							$this->_redirectdepth++;
+							$this->lastredirectaddr=$this->_redirectaddr;
+							$this->fetch($this->_redirectaddr);
+						}
+					}
+				}
+
+				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
+				{
+					$frameurls = $this->_frameurls;
+					$this->_frameurls = array();
+
+					while(list(,$frameurl) = each($frameurls))
+					{
+						if($this->_framedepth < $this->maxframes)
+						{
+							$this->fetch($frameurl);
+							$this->_framedepth++;
+						}
+						else
+							break;
+					}
+				}
+				return true;
+				break;
+			default:
+				// not a valid protocol
+				$this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
+				return false;
+				break;
+		}
+		return true;
+	}
+
+/*======================================================================*\
+	Function:	submit
+	Purpose:	submit an http form
+	Input:		$URI	the location to post the data
+				$formvars	the formvars to use.
+					format: $formvars["var"] = "val";
+				$formfiles  an array of files to submit
+					format: $formfiles["var"] = "/dir/filename.ext";
+	Output:		$this->results	the text output from the post
+\*======================================================================*/
+
+	function submit($URI, $formvars="", $formfiles="")
+	{
+		unset($postdata);
+
+		$postdata = $this->_prepare_post_body($formvars, $formfiles);
+
+		$URI_PARTS = parse_url($URI);
+		if (!empty($URI_PARTS["user"]))
+			$this->user = $URI_PARTS["user"];
+		if (!empty($URI_PARTS["pass"]))
+			$this->pass = $URI_PARTS["pass"];
+		if (empty($URI_PARTS["query"]))
+			$URI_PARTS["query"] = '';
+		if (empty($URI_PARTS["path"]))
+			$URI_PARTS["path"] = '';
+
+		switch(strtolower($URI_PARTS["scheme"]))
+		{
+			case "http":
+				$this->host = $URI_PARTS["host"];
+				if(!empty($URI_PARTS["port"]))
+					$this->port = $URI_PARTS["port"];
+				if($this->_connect($fp))
+				{
+					if($this->_isproxy)
+					{
+						// using proxy, send entire URI
+						$this->_httprequest($URI,$fp,$URI,$this->_submit_method,$this->_submit_type,$postdata);
+					}
+					else
+					{
+						$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
+						// no proxy, send only the path
+						$this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata);
+					}
+
+					$this->_disconnect($fp);
+
+					if($this->_redirectaddr)
+					{
+						/* url was redirected, check if we've hit the max depth */
+						if($this->maxredirs > $this->_redirectdepth)
+						{
+							if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
+								$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
+
+							// only follow redirect if it's on this site, or offsiteok is true
+							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
+							{
+								/* follow the redirect */
+								$this->_redirectdepth++;
+								$this->lastredirectaddr=$this->_redirectaddr;
+								if( strpos( $this->_redirectaddr, "?" ) > 0 )
+									$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
+								else
+									$this->submit($this->_redirectaddr,$formvars, $formfiles);
+							}
+						}
+					}
+
+					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
+					{
+						$frameurls = $this->_frameurls;
+						$this->_frameurls = array();
+
+						while(list(,$frameurl) = each($frameurls))
+						{
+							if($this->_framedepth < $this->maxframes)
+							{
+								$this->fetch($frameurl);
+								$this->_framedepth++;
+							}
+							else
+								break;
+						}
+					}
+
+				}
+				else
+				{
+					return false;
+				}
+				return true;
+				break;
+			case "https":
+				if(!$this->curl_path)
+					return false;
+				if(function_exists("is_executable"))
+				    if (!is_executable($this->curl_path))
+				        return false;
+				$this->host = $URI_PARTS["host"];
+				if(!empty($URI_PARTS["port"]))
+					$this->port = $URI_PARTS["port"];
+				if($this->_isproxy)
+				{
+					// using proxy, send entire URI
+					$this->_httpsrequest($URI, $URI, $this->_submit_method, $this->_submit_type, $postdata);
+				}
+				else
+				{
+					$path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : "");
+					// no proxy, send only the path
+					$this->_httpsrequest($path, $URI, $this->_submit_method, $this->_submit_type, $postdata);
+				}
+
+				if($this->_redirectaddr)
+				{
+					/* url was redirected, check if we've hit the max depth */
+					if($this->maxredirs > $this->_redirectdepth)
+					{
+						if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
+							$this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
+
+						// only follow redirect if it's on this site, or offsiteok is true
+						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
+						{
+							/* follow the redirect */
+							$this->_redirectdepth++;
+							$this->lastredirectaddr=$this->_redirectaddr;
+							if( strpos( $this->_redirectaddr, "?" ) > 0 )
+								$this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get
+							else
+								$this->submit($this->_redirectaddr,$formvars, $formfiles);
+						}
+					}
+				}
+
+				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
+				{
+					$frameurls = $this->_frameurls;
+					$this->_frameurls = array();
+
+					while(list(,$frameurl) = each($frameurls))
+					{
+						if($this->_framedepth < $this->maxframes)
+						{
+							$this->fetch($frameurl);
+							$this->_framedepth++;
+						}
+						else
+							break;
+					}
+				}
+				return true;
+				break;
+
+			default:
+				// not a valid protocol
+				$this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
+				return false;
+				break;
+		}
+		return true;
+	}
+
+/*======================================================================*\
+	Function:	fetchlinks
+	Purpose:	fetch the links from a web page
+	Input:		$URI	where you are fetching from
+	Output:		$this->results	an array of the URLs
+\*======================================================================*/
+
+	function fetchlinks($URI)
+	{
+		if ($this->fetch($URI))
+		{
+			if($this->lastredirectaddr)
+				$URI = $this->lastredirectaddr;
+			if(is_array($this->results))
+			{
+				for($x=0;$x<count($this->results);$x++)
+					$this->results[$x] = $this->_striplinks($this->results[$x]);
+			}
+			else
+				$this->results = $this->_striplinks($this->results);
+
+			if($this->expandlinks)
+				$this->results = $this->_expandlinks($this->results, $URI);
+			return true;
+		}
+		else
+			return false;
+	}
+
+/*======================================================================*\
+	Function:	fetchform
+	Purpose:	fetch the form elements from a web page
+	Input:		$URI	where you are fetching from
+	Output:		$this->results	the resulting html form
+\*======================================================================*/
+
+	function fetchform($URI)
+	{
+
+		if ($this->fetch($URI))
+		{
+
+			if(is_array($this->results))
+			{
+				for($x=0;$x<count($this->results);$x++)
+					$this->results[$x] = $this->_stripform($this->results[$x]);
+			}
+			else
+				$this->results = $this->_stripform($this->results);
+
+			return true;
+		}
+		else
+			return false;
+	}
+
+
+/*======================================================================*\
+	Function:	fetchtext
+	Purpose:	fetch the text from a web page, stripping the links
+	Input:		$URI	where you are fetching from
+	Output:		$this->results	the text from the web page
+\*======================================================================*/
+
+	function fetchtext($URI)
+	{
+		if($this->fetch($URI))
+		{
+			if(is_array($this->results))
+			{
+				for($x=0;$x<count($this->results);$x++)
+					$this->results[$x] = $this->_striptext($this->results[$x]);
+			}
+			else
+				$this->results = $this->_striptext($this->results);
+			return true;
+		}
+		else
+			return false;
+	}
+
+/*======================================================================*\
+	Function:	submitlinks
+	Purpose:	grab links from a form submission
+	Input:		$URI	where you are submitting from
+	Output:		$this->results	an array of the links from the post
+\*======================================================================*/
+
+	function submitlinks($URI, $formvars="", $formfiles="")
+	{
+		if($this->submit($URI,$formvars, $formfiles))
+		{
+			if($this->lastredirectaddr)
+				$URI = $this->lastredirectaddr;
+			if(is_array($this->results))
+			{
+				for($x=0;$x<count($this->results);$x++)
+				{
+					$this->results[$x] = $this->_striplinks($this->results[$x]);
+					if($this->expandlinks)
+						$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
+				}
+			}
+			else
+			{
+				$this->results = $this->_striplinks($this->results);
+				if($this->expandlinks)
+					$this->results = $this->_expandlinks($this->results,$URI);
+			}
+			return true;
+		}
+		else
+			return false;
+	}
+
+/*======================================================================*\
+	Function:	submittext
+	Purpose:	grab text from a form submission
+	Input:		$URI	where you are submitting from
+	Output:		$this->results	the text from the web page
+\*======================================================================*/
+
+	function submittext($URI, $formvars = "", $formfiles = "")
+	{
+		if($this->submit($URI,$formvars, $formfiles))
+		{
+			if($this->lastredirectaddr)
+				$URI = $this->lastredirectaddr;
+			if(is_array($this->results))
+			{
+				for($x=0;$x<count($this->results);$x++)
+				{
+					$this->results[$x] = $this->_striptext($this->results[$x]);
+					if($this->expandlinks)
+						$this->results[$x] = $this->_expandlinks($this->results[$x],$URI);
+				}
+			}
+			else
+			{
+				$this->results = $this->_striptext($this->results);
+				if($this->expandlinks)
+					$this->results = $this->_expandlinks($this->results,$URI);
+			}
+			return true;
+		}
+		else
+			return false;
+	}
+
+
+
+/*======================================================================*\
+	Function:	set_submit_multipart
+	Purpose:	Set the form submission content type to
+				multipart/form-data
+\*======================================================================*/
+	function set_submit_multipart()
+	{
+		$this->_submit_type = "multipart/form-data";
+	}
+
+
+/*======================================================================*\
+	Function:	set_submit_normal
+	Purpose:	Set the form submission content type to
+				application/x-www-form-urlencoded
+\*======================================================================*/
+	function set_submit_normal()
+	{
+		$this->_submit_type = "application/x-www-form-urlencoded";
+	}
+
+
+
+
+/*======================================================================*\
+	Private functions
+\*======================================================================*/
+
+
+/*======================================================================*\
+	Function:	_striplinks
+	Purpose:	strip the hyperlinks from an html document
+	Input:		$document	document to strip.
+	Output:		$match		an array of the links
+\*======================================================================*/
+
+	function _striplinks($document)
+	{
+		preg_match_all("'<\s*a\s.*?href\s*=\s*			# find <a href=
+						([\"\'])?					# find single or double quote
+						(?(1) (.*?)\\1 | ([^\s\>]+))		# if quote found, match up to next matching
+													# quote, otherwise match up to next space
+						'isx",$document,$links);
+
+
+		// catenate the non-empty matches from the conditional subpattern
+
+		while(list($key,$val) = each($links[2]))
+		{
+			if(!empty($val))
+				$match[] = $val;
+		}
+
+		while(list($key,$val) = each($links[3]))
+		{
+			if(!empty($val))
+				$match[] = $val;
+		}
+
+		// return the links
+		return $match;
+	}
+
+/*======================================================================*\
+	Function:	_stripform
+	Purpose:	strip the form elements from an html document
+	Input:		$document	document to strip.
+	Output:		$match		an array of the links
+\*======================================================================*/
+
+	function _stripform($document)
+	{
+		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
+
+		// catenate the matches
+		$match = implode("\r\n",$elements[0]);
+
+		// return the links
+		return $match;
+	}
+
+
+
+/*======================================================================*\
+	Function:	_striptext
+	Purpose:	strip the text from an html document
+	Input:		$document	document to strip.
+	Output:		$text		the resulting text
+\*======================================================================*/
+
+	function _striptext($document)
+	{
+
+		// I didn't use preg eval (//e) since that is only available in PHP 4.0.
+		// so, list your entities one by one here. I included some of the
+		// more common ones.
+
+		$search = array("'<script[^>]*?>.*?</script>'si",	// strip out javascript
+						"'<[\/\!]*?[^<>]*?>'si",			// strip out html tags
+						"'([\r\n])[\s]+'",					// strip out white space
+						"'&(quot|#34|#034|#x22);'i",		// replace html entities
+						"'&(amp|#38|#038|#x26);'i",			// added hexadecimal values
+						"'&(lt|#60|#060|#x3c);'i",
+						"'&(gt|#62|#062|#x3e);'i",
+						"'&(nbsp|#160|#xa0);'i",
+						"'&(iexcl|#161);'i",
+						"'&(cent|#162);'i",
+						"'&(pound|#163);'i",
+						"'&(copy|#169);'i",
+						"'&(reg|#174);'i",
+						"'&(deg|#176);'i",
+						"'&(#39|#039|#x27);'",
+						"'&(euro|#8364);'i",				// europe
+						"'&a(uml|UML);'",					// german
+						"'&o(uml|UML);'",
+						"'&u(uml|UML);'",
+						"'&A(uml|UML);'",
+						"'&O(uml|UML);'",
+						"'&U(uml|UML);'",
+						"'&szlig;'i",
+						);
+		$replace = array(	"",
+							"",
+							"\\1",
+							"\"",
+							"&",
+							"<",
+							">",
+							" ",
+							chr(161),
+							chr(162),
+							chr(163),
+							chr(169),
+							chr(174),
+							chr(176),
+							chr(39),
+							chr(128),
+							chr(0xE4), // ANSI &auml;
+							chr(0xF6), // ANSI &ouml;
+							chr(0xFC), // ANSI &uuml;
+							chr(0xC4), // ANSI &Auml;
+							chr(0xD6), // ANSI &Ouml;
+							chr(0xDC), // ANSI &Uuml;
+							chr(0xDF), // ANSI &szlig;
+						);
+
+		$text = preg_replace($search,$replace,$document);
+
+		return $text;
+	}
+
+/*======================================================================*\
+	Function:	_expandlinks
+	Purpose:	expand each link into a fully qualified URL
+	Input:		$links			the links to qualify
+				$URI			the full URI to get the base from
+	Output:		$expandedLinks	the expanded links
+\*======================================================================*/
+
+	function _expandlinks($links,$URI)
+	{
+
+		preg_match("/^[^\?]+/",$URI,$match);
+
+		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
+		$match = preg_replace("|/$|","",$match);
+		$match_part = parse_url($match);
+		$match_root =
+		$match_part["scheme"]."://".$match_part["host"];
+
+		$search = array( 	"|^http://".preg_quote($this->host)."|i",
+							"|^(\/)|i",
+							"|^(?!http://)(?!mailto:)|i",
+							"|/\./|",
+							"|/[^\/]+/\.\./|"
+						);
+
+		$replace = array(	"",
+							$match_root."/",
+							$match."/",
+							"/",
+							"/"
+						);
+
+		$expandedLinks = preg_replace($search,$replace,$links);
+
+		return $expandedLinks;
+	}
+
+/*======================================================================*\
+	Function:	_httprequest
+	Purpose:	go get the http data from the server
+	Input:		$url		the url to fetch
+				$fp			the current open file pointer
+				$URI		the full URI
+				$body		body contents to send if any (POST)
+	Output:
+\*======================================================================*/
+
+	function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
+	{
+		$cookie_headers = '';
+		if($this->passcookies && $this->_redirectaddr)
+			$this->setcookies();
+
+		$URI_PARTS = parse_url($URI);
+		if(empty($url))
+			$url = "/";
+		$headers = $http_method." ".$url." ".$this->_httpversion."\r\n";
+		if(!empty($this->agent))
+			$headers .= "User-Agent: ".$this->agent."\r\n";
+		if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
+			$headers .= "Host: ".$this->host;
+			if(!empty($this->port) && $this->port != 80)
+				$headers .= ":".$this->port;
+			$headers .= "\r\n";
+		}
+		if(!empty($this->accept))
+			$headers .= "Accept: ".$this->accept."\r\n";
+		if(!empty($this->referer))
+			$headers .= "Referer: ".$this->referer."\r\n";
+		if(!empty($this->cookies))
+		{
+			if(!is_array($this->cookies))
+				$this->cookies = (array)$this->cookies;
+
+			reset($this->cookies);
+			if ( count($this->cookies) > 0 ) {
+				$cookie_headers .= 'Cookie: ';
+				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
+				$cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
+				}
+				$headers .= substr($cookie_headers,0,-2) . "\r\n";
+			}
+		}
+		if(!empty($this->rawheaders))
+		{
+			if(!is_array($this->rawheaders))
+				$this->rawheaders = (array)$this->rawheaders;
+			while(list($headerKey,$headerVal) = each($this->rawheaders))
+				$headers .= $headerKey.": ".$headerVal."\r\n";
+		}
+		if(!empty($content_type)) {
+			$headers .= "Content-type: $content_type";
+			if ($content_type == "multipart/form-data")
+				$headers .= "; boundary=".$this->_mime_boundary;
+			$headers .= "\r\n";
+		}
+		if(!empty($body))
+			$headers .= "Content-length: ".strlen($body)."\r\n";
+		if(!empty($this->user) || !empty($this->pass))
+			$headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n";
+
+		//add proxy auth headers
+		if(!empty($this->proxy_user))
+			$headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n";
+
+
+		$headers .= "\r\n";
+
+		// set the read timeout if needed
+		if ($this->read_timeout > 0)
+			socket_set_timeout($fp, $this->read_timeout);
+		$this->timed_out = false;
+
+		fwrite($fp,$headers.$body,strlen($headers.$body));
+
+		$this->_redirectaddr = false;
+		unset($this->headers);
+
+		while($currentHeader = fgets($fp,$this->_maxlinelen))
+		{
+			if ($this->read_timeout > 0 && $this->_check_timeout($fp))
+			{
+				$this->status=-100;
+				return false;
+			}
+
+			if($currentHeader == "\r\n")
+				break;
+
+			// if a header begins with Location: or URI:, set the redirect
+			if(preg_match("/^(Location:|URI:)/i",$currentHeader))
+			{
+				// get URL portion of the redirect
+				preg_match("/^(Location:|URI:)[ ]+(.*)/i",chop($currentHeader),$matches);
+				// look for :// in the Location header to see if hostname is included
+				if(!preg_match("|\:\/\/|",$matches[2]))
+				{
+					// no host in the path, so prepend
+					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
+					// eliminate double slash
+					if(!preg_match("|^/|",$matches[2]))
+							$this->_redirectaddr .= "/".$matches[2];
+					else
+							$this->_redirectaddr .= $matches[2];
+				}
+				else
+					$this->_redirectaddr = $matches[2];
+			}
+
+			if(preg_match("|^HTTP/|",$currentHeader))
+			{
+                if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
+				{
+					$this->status= $status[1];
+                }
+				$this->response_code = $currentHeader;
+			}
+
+			$this->headers[] = $currentHeader;
+		}
+
+		$results = '';
+		do {
+    		$_data = fread($fp, $this->maxlength);
+    		if (strlen($_data) == 0) {
+        		break;
+    		}
+    		$results .= $_data;
+		} while(true);
+
+		if ($this->read_timeout > 0 && $this->_check_timeout($fp))
+		{
+			$this->status=-100;
+			return false;
+		}
+
+		// check if there is a a redirect meta tag
+
+		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
+
+		{
+			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);
+		}
+
+		// have we hit our frame depth and is there frame src to fetch?
+		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
+		{
+			$this->results[] = $results;
+			for($x=0; $x<count($match[1]); $x++)
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
+		}
+		// have we already fetched framed content?
+		elseif(is_array($this->results))
+			$this->results[] = $results;
+		// no framed content
+		else
+			$this->results = $results;
+
+		return true;
+	}
+
+/*======================================================================*\
+	Function:	_httpsrequest
+	Purpose:	go get the https data from the server using curl
+	Input:		$url		the url to fetch
+				$URI		the full URI
+				$body		body contents to send if any (POST)
+	Output:
+\*======================================================================*/
+
+	function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
+	{
+		if($this->passcookies && $this->_redirectaddr)
+			$this->setcookies();
+
+		$headers = array();
+
+		$URI_PARTS = parse_url($URI);
+		if(empty($url))
+			$url = "/";
+		// GET ... header not needed for curl
+		//$headers[] = $http_method." ".$url." ".$this->_httpversion;
+		if(!empty($this->agent))
+			$headers[] = "User-Agent: ".$this->agent;
+		if(!empty($this->host))
+			if(!empty($this->port))
+				$headers[] = "Host: ".$this->host.":".$this->port;
+			else
+				$headers[] = "Host: ".$this->host;
+		if(!empty($this->accept))
+			$headers[] = "Accept: ".$this->accept;
+		if(!empty($this->referer))
+			$headers[] = "Referer: ".$this->referer;
+		if(!empty($this->cookies))
+		{
+			if(!is_array($this->cookies))
+				$this->cookies = (array)$this->cookies;
+
+			reset($this->cookies);
+			if ( count($this->cookies) > 0 ) {
+				$cookie_str = 'Cookie: ';
+				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
+				$cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
+				}
+				$headers[] = substr($cookie_str,0,-2);
+			}
+		}
+		if(!empty($this->rawheaders))
+		{
+			if(!is_array($this->rawheaders))
+				$this->rawheaders = (array)$this->rawheaders;
+			while(list($headerKey,$headerVal) = each($this->rawheaders))
+				$headers[] = $headerKey.": ".$headerVal;
+		}
+		if(!empty($content_type)) {
+			if ($content_type == "multipart/form-data")
+				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
+			else
+				$headers[] = "Content-type: $content_type";
+		}
+		if(!empty($body))
+			$headers[] = "Content-length: ".strlen($body);
+		if(!empty($this->user) || !empty($this->pass))
+			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
+
+		for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
+			$safer_header = strtr( $headers[$curr_header], "\"", " " );
+			$cmdline_params .= " -H \"".$safer_header."\"";
+		}
+
+		if(!empty($body))
+			$cmdline_params .= " -d \"$body\"";
+
+		if($this->read_timeout > 0)
+			$cmdline_params .= " -m ".$this->read_timeout;
+
+		$headerfile = tempnam($temp_dir, "sno");
+
+		exec($this->curl_path." -k -D \"$headerfile\"".$cmdline_params." \"".escapeshellcmd($URI)."\"",$results,$return);
+
+		if($return)
+		{
+			$this->error = "Error: cURL could not retrieve the document, error $return.";
+			return false;
+		}
+
+
+		$results = implode("\r\n",$results);
+
+		$result_headers = file("$headerfile");
+
+		$this->_redirectaddr = false;
+		unset($this->headers);
+
+		for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
+		{
+
+			// if a header begins with Location: or URI:, set the redirect
+			if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
+			{
+				// get URL portion of the redirect
+				preg_match("/^(Location: |URI:)\s+(.*)/",chop($result_headers[$currentHeader]),$matches);
+				// look for :// in the Location header to see if hostname is included
+				if(!preg_match("|\:\/\/|",$matches[2]))
+				{
+					// no host in the path, so prepend
+					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
+					// eliminate double slash
+					if(!preg_match("|^/|",$matches[2]))
+							$this->_redirectaddr .= "/".$matches[2];
+					else
+							$this->_redirectaddr .= $matches[2];
+				}
+				else
+					$this->_redirectaddr = $matches[2];
+			}
+
+			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
+				$this->response_code = $result_headers[$currentHeader];
+
+			$this->headers[] = $result_headers[$currentHeader];
+		}
+
+		// check if there is a a redirect meta tag
+
+		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
+		{
+			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);
+		}
+
+		// have we hit our frame depth and is there frame src to fetch?
+		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
+		{
+			$this->results[] = $results;
+			for($x=0; $x<count($match[1]); $x++)
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
+		}
+		// have we already fetched framed content?
+		elseif(is_array($this->results))
+			$this->results[] = $results;
+		// no framed content
+		else
+			$this->results = $results;
+
+		unlink("$headerfile");
+
+		return true;
+	}
+
+/*======================================================================*\
+	Function:	setcookies()
+	Purpose:	set cookies for a redirection
+\*======================================================================*/
+
+	function setcookies()
+	{
+		for($x=0; $x<count($this->headers); $x++)
+		{
+		if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x],$match))
+			$this->cookies[$match[1]] = urldecode($match[2]);
+		}
+	}
+
+
+/*======================================================================*\
+	Function:	_check_timeout
+	Purpose:	checks whether timeout has occurred
+	Input:		$fp	file pointer
+\*======================================================================*/
+
+	function _check_timeout($fp)
+	{
+		if ($this->read_timeout > 0) {
+			$fp_status = socket_get_status($fp);
+			if ($fp_status["timed_out"]) {
+				$this->timed_out = true;
+				return true;
+			}
+		}
+		return false;
+	}
+
+/*======================================================================*\
+	Function:	_connect
+	Purpose:	make a socket connection
+	Input:		$fp	file pointer
+\*======================================================================*/
+
+	function _connect(&$fp)
+	{
+		if(!empty($this->proxy_host) && !empty($this->proxy_port))
+			{
+				$this->_isproxy = true;
+
+				$host = $this->proxy_host;
+				$port = $this->proxy_port;
+			}
+		else
+		{
+			$host = $this->host;
+			$port = $this->port;
+		}
+
+		$this->status = 0;
+
+		if($fp = fsockopen(
+					$host,
+					$port,
+					$errno,
+					$errstr,
+					$this->_fp_timeout
+					))
+		{
+			// socket connection succeeded
+
+			return true;
+		}
+		else
+		{
+			// socket connection failed
+			$this->status = $errno;
+			switch($errno)
+			{
+				case -3:
+					$this->error="socket creation failed (-3)";
+				case -4:
+					$this->error="dns lookup failure (-4)";
+				case -5:
+					$this->error="connection refused or timed out (-5)";
+				default:
+					$this->error="connection failed (".$errno.")";
+			}
+			return false;
+		}
+	}
+/*======================================================================*\
+	Function:	_disconnect
+	Purpose:	disconnect a socket connection
+	Input:		$fp	file pointer
+\*======================================================================*/
+
+	function _disconnect($fp)
+	{
+		return(fclose($fp));
+	}
+
+
+/*======================================================================*\
+	Function:	_prepare_post_body
+	Purpose:	Prepare post body according to encoding type
+	Input:		$formvars  - form variables
+				$formfiles - form upload files
+	Output:		post body
+\*======================================================================*/
+
+	function _prepare_post_body($formvars, $formfiles)
+	{
+		settype($formvars, "array");
+		settype($formfiles, "array");
+		$postdata = '';
+
+		if (count($formvars) == 0 && count($formfiles) == 0)
+			return;
+
+		switch ($this->_submit_type) {
+			case "application/x-www-form-urlencoded":
+				reset($formvars);
+				while(list($key,$val) = each($formvars)) {
+					if (is_array($val) || is_object($val)) {
+						while (list($cur_key, $cur_val) = each($val)) {
+							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
+						}
+					} else
+						$postdata .= urlencode($key)."=".urlencode($val)."&";
+				}
+				break;
+
+			case "multipart/form-data":
+				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
+
+				reset($formvars);
+				while(list($key,$val) = each($formvars)) {
+					if (is_array($val) || is_object($val)) {
+						while (list($cur_key, $cur_val) = each($val)) {
+							$postdata .= "--".$this->_mime_boundary."\r\n";
+							$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
+							$postdata .= "$cur_val\r\n";
+						}
+					} else {
+						$postdata .= "--".$this->_mime_boundary."\r\n";
+						$postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
+						$postdata .= "$val\r\n";
+					}
+				}
+
+				reset($formfiles);
+				while (list($field_name, $file_names) = each($formfiles)) {
+					settype($file_names, "array");
+					while (list(, $file_name) = each($file_names)) {
+						if (!is_readable($file_name)) continue;
+
+						$fp = fopen($file_name, "r");
+						$file_content = fread($fp, filesize($file_name));
+						fclose($fp);
+						$base_name = basename($file_name);
+
+						$postdata .= "--".$this->_mime_boundary."\r\n";
+						$postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n";
+						$postdata .= "$file_content\r\n";
+					}
+				}
+				$postdata .= "--".$this->_mime_boundary."--\r\n";
+				break;
+		}
+
+		return $postdata;
+	}
+}
+endif;
+?>
Index: /tags/3.1/wp-includes/class-wp-admin-bar.php
===================================================================
--- /tags/3.1/wp-includes/class-wp-admin-bar.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-wp-admin-bar.php	(revision 17487)
@@ -0,0 +1,236 @@
+<?php
+class WP_Admin_Bar {
+	var $changed_locale = false;
+	var $menu;
+	var $need_to_change_locale = false;
+	var $proto = 'http://';
+	var $user;
+
+	function initialize() {
+		/* Set the protocol used throughout this code */
+		if ( is_ssl() )
+			$this->proto = 'https://';
+
+		$this->user = new stdClass;
+		$this->menu = new stdClass;
+
+		/* Populate settings we need for the menu based on the current user. */
+		$this->user->blogs = get_blogs_of_user( get_current_user_id() );
+		if ( is_multisite() ) {
+			$this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
+			$this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
+			$this->user->account_domain = $this->user->domain;
+		} else {
+			$this->user->active_blog = $this->user->blogs[get_current_blog_id()];
+			$this->user->domain = trailingslashit( home_url() );
+			$this->user->account_domain = $this->user->domain;
+		}
+		$this->user->locale = get_locale();
+
+		add_action( 'wp_head', 'wp_admin_bar_header' );
+
+		add_action( 'admin_head', 'wp_admin_bar_header' );
+
+		if ( current_theme_supports( 'admin-bar' ) ) {
+			$admin_bar_args = get_theme_support( 'admin-bar' ); // add_theme_support( 'admin-bar', array( 'callback' => '__return_false') );
+			$header_callback = $admin_bar_args[0]['callback'];
+		}
+
+		if ( empty($header_callback) )
+			$header_callback = '_admin_bar_bump_cb';
+
+		add_action('wp_head', $header_callback);
+
+		wp_enqueue_script( 'admin-bar' );
+		wp_enqueue_style( 'admin-bar' );
+
+		do_action( 'admin_bar_init' );
+	}
+
+	function add_menu( $args = array() ) {
+		$defaults = array(
+			'title' => false,
+			'href' => false,
+			'parent' => false, // false for a root menu, pass the ID value for a submenu of that menu.
+			'id' => false, // defaults to a sanitized title value.
+			'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+		extract( $r, EXTR_SKIP );
+
+		if ( empty( $title ) )
+			return false;
+
+		/* Make sure we have a valid ID */
+		if ( empty( $id ) )
+			$id = esc_attr( sanitize_title( trim( $title ) ) );
+
+		if ( ! empty( $parent ) ) {
+			/* Add the menu to the parent item */
+			$child = array( 'id' => $id, 'title' => $title, 'href' => $href );
+
+			if ( ! empty( $meta ) )
+				$child['meta'] = $meta;
+
+			$this->add_node( $parent, $this->menu, $child );
+		} else {
+			/* Add the menu item */
+			$this->menu->{$id} = array( 'title' => $title, 'href' => $href );
+
+			if ( ! empty( $meta ) )
+				$this->menu->{$id}['meta'] = $meta;
+		}
+	}
+
+	function remove_menu( $id ) {
+		return $this->remove_node( $id, $this->menu );
+	}
+
+	function render() {
+		?>
+		<div id="wpadminbar">
+			<div class="quicklinks">
+				<ul>
+					<?php foreach ( (array) $this->menu as $id => $menu_item ) : ?>
+						<?php $this->recursive_render( $id, $menu_item ) ?>
+					<?php endforeach; ?>
+				</ul>
+			</div>
+
+			<div id="adminbarsearch-wrap">
+				<form action="<?php echo home_url(); ?>" method="get" id="adminbarsearch">
+					<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />
+					<input type="submit" class="adminbar-button" value="<?php _e('Search'); ?>"/>
+				</form>
+			</div>
+		</div>
+
+		<?php
+		/* Wipe the menu, might reduce memory usage, but probably not. */
+		$this->menu = null;
+	}
+
+	/* Helpers */
+	function recursive_render( $id, &$menu_item ) { ?>
+		<?php
+		$is_parent =  ! empty( $menu_item['children'] );
+
+		$menuclass = $is_parent ? 'menupop' : '';
+		if ( ! empty( $menu_item['meta']['class'] ) )
+			$menuclass .= ' ' . $menu_item['meta']['class'];
+		?>
+
+		<li id="<?php echo esc_attr( "wp-admin-bar-$id" ); ?>" class="<?php echo esc_attr( $menuclass ); ?>">
+			<a href="<?php echo esc_url( $menu_item['href'] ) ?>"<?php
+				if ( ! empty( $menu_item['meta']['onclick'] ) ) :
+					?> onclick="<?php echo esc_js( $menu_item['meta']['onclick'] ); ?>"<?php
+				endif;
+			if ( ! empty( $menu_item['meta']['target'] ) ) :
+				?> target="<?php echo esc_attr( $menu_item['meta']['target'] ); ?>"<?php
+			endif;
+			if ( ! empty( $menu_item['meta']['title'] ) ) :
+				?> title="<?php echo esc_attr( $menu_item['meta']['title'] ); ?>"<?php
+			endif;
+
+			?>><?php
+
+			if ( $is_parent ) :
+				?><span><?php
+			endif;
+
+			echo $menu_item['title'];
+
+			if ( $is_parent ) :
+				?></span><?php
+			endif;
+
+			?></a>
+
+			<?php if ( $is_parent ) : ?>
+			<ul>
+				<?php foreach ( $menu_item['children'] as $child_id => $child_menu_item ) : ?>
+					<?php $this->recursive_render( $child_id, $child_menu_item ); ?>
+				<?php endforeach; ?>
+			</ul>
+			<?php endif; ?>
+
+			<?php if ( ! empty( $menu_item['meta']['html'] ) ) : ?>
+				<?php echo $menu_item['meta']['html']; ?>
+			<?php endif; ?>
+		</li><?php
+	}
+
+	function add_node( $parent_id, &$menu, $child ) {
+		foreach( $menu as $id => $menu_item ) {
+			if ( $parent_id == $id ) {
+				$menu->{$parent_id}['children']->{$child['id']} = $child;
+				$child = null;
+				return true;
+			}
+
+			if ( ! empty( $menu->{$id}['children'] ) )
+				$this->add_node( $parent_id, $menu->{$id}['children'], $child );
+		}
+
+		$child = null;
+
+		return false;
+	}
+
+	function add_menus() {
+		add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 10 );
+		add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
+		add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 30 );
+		add_action( 'admin_bar_menu', 'wp_admin_bar_shortlink_menu', 80 );
+		add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 70 );
+
+		if ( !is_network_admin() && !is_user_admin() ) {
+			add_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 40 );
+			add_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 50 );
+			add_action( 'admin_bar_menu', 'wp_admin_bar_appearance_menu', 60 );
+		}
+
+		do_action( 'add_admin_bar_menus' );
+	}
+
+	function remove_node( $id, &$menu ) {
+		if ( isset( $menu->$id ) ) {
+			unset( $menu->$id );
+			return true;
+		}
+
+		foreach( $menu as $menu_item_id => $menu_item ) {
+			if ( ! empty( $menu->{$menu_item_id}['children'] ) )
+				$this->remove_node( $id, $menu->{$menu_item_id}['children'] );
+		}
+
+		return false;
+	}
+
+	// TODO: Convert to a core feature for multisite or remove
+	function load_user_locale_translations() {
+		$this->need_to_change_locale = ( get_locale() != $this->user->locale );
+		if ( ! $this->need_to_change_locale )
+			return;
+		/*
+		$this->previous_translations = get_translations_for_domain( 'default' );
+		$this->adminbar_locale_filter = lambda( '$_', '$GLOBALS["wp_admin_bar"]->user->locale;' );
+		unload_textdomain( 'default' );
+		add_filter( 'locale', $this->adminbar_locale_filter );
+		load_default_textdomain();
+		$this->changed_locale = true;
+		*/
+	}
+
+	function unload_user_locale_translations() {
+		global $l10n;
+		if ( ! $this->changed_locale )
+			return;
+		/*
+		remove_filter( 'locale', $this->adminbar_locale_filter );
+		$l10n['default'] = &$this->previous_translations;
+		*/
+	}
+}
+?>
Index: /tags/3.1/wp-includes/class-wp-ajax-response.php
===================================================================
--- /tags/3.1/wp-includes/class-wp-ajax-response.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-wp-ajax-response.php	(revision 17487)
@@ -0,0 +1,138 @@
+<?php
+/**
+ * Send XML response back to AJAX request.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ */
+class WP_Ajax_Response {
+	/**
+	 * Store XML responses to send.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $responses = array();
+
+	/**
+	 * PHP4 Constructor - Passes args to {@link WP_Ajax_Response::add()}.
+	 *
+	 * @since 2.1.0
+	 * @see WP_Ajax_Response::add()
+	 *
+	 * @param string|array $args Optional. Will be passed to add() method.
+	 * @return WP_Ajax_Response
+	 */
+	function WP_Ajax_Response( $args = '' ) {
+		if ( !empty($args) )
+			$this->add($args);
+	}
+
+	/**
+	 * Append to XML response based on given arguments.
+	 *
+	 * The arguments that can be passed in the $args parameter are below. It is
+	 * also possible to pass a WP_Error object in either the 'id' or 'data'
+	 * argument. The parameter isn't actually optional, content should be given
+	 * in order to send the correct response.
+	 *
+	 * 'what' argument is a string that is the XMLRPC response type.
+	 * 'action' argument is a boolean or string that acts like a nonce.
+	 * 'id' argument can be WP_Error or an integer.
+	 * 'old_id' argument is false by default or an integer of the previous ID.
+	 * 'position' argument is an integer or a string with -1 = top, 1 = bottom,
+	 * html ID = after, -html ID = before.
+	 * 'data' argument is a string with the content or message.
+	 * 'supplemental' argument is an array of strings that will be children of
+	 * the supplemental element.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string|array $args Override defaults.
+	 * @return string XML response.
+	 */
+	function add( $args = '' ) {
+		$defaults = array(
+			'what' => 'object', 'action' => false,
+			'id' => '0', 'old_id' => false,
+			'position' => 1,
+			'data' => '', 'supplemental' => array()
+		);
+
+		$r = wp_parse_args( $args, $defaults );
+		extract( $r, EXTR_SKIP );
+		$position = preg_replace( '/[^a-z0-9:_-]/i', '', $position );
+
+		if ( is_wp_error($id) ) {
+			$data = $id;
+			$id = 0;
+		}
+
+		$response = '';
+		if ( is_wp_error($data) ) {
+			foreach ( (array) $data->get_error_codes() as $code ) {
+				$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>";
+				if ( !$error_data = $data->get_error_data($code) )
+					continue;
+				$class = '';
+				if ( is_object($error_data) ) {
+					$class = ' class="' . get_class($error_data) . '"';
+					$error_data = get_object_vars($error_data);
+				}
+
+				$response .= "<wp_error_data code='$code'$class>";
+
+				if ( is_scalar($error_data) ) {
+					$response .= "<![CDATA[$error_data]]>";
+				} elseif ( is_array($error_data) ) {
+					foreach ( $error_data as $k => $v )
+						$response .= "<$k><![CDATA[$v]]></$k>";
+				}
+
+				$response .= "</wp_error_data>";
+			}
+		} else {
+			$response = "<response_data><![CDATA[$data]]></response_data>";
+		}
+
+		$s = '';
+		if ( is_array($supplemental) ) {
+			foreach ( $supplemental as $k => $v )
+				$s .= "<$k><![CDATA[$v]]></$k>";
+			$s = "<supplemental>$s</supplemental>";
+		}
+
+		if ( false === $action )
+			$action = $_POST['action'];
+
+		$x = '';
+		$x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action
+		$x .=	"<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>";
+		$x .=		$response;
+		$x .=		$s;
+		$x .=	"</$what>";
+		$x .= "</response>";
+
+		$this->responses[] = $x;
+		return $x;
+	}
+
+	/**
+	 * Display XML formatted responses.
+	 *
+	 * Sets the content type header to text/xml.
+	 *
+	 * @since 2.1.0
+	 */
+	function send() {
+		header('Content-Type: text/xml');
+		echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";
+		foreach ( (array) $this->responses as $response )
+			echo $response;
+		echo '</wp_ajax>';
+		die();
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/class-wp-error.php
===================================================================
--- /tags/3.1/wp-includes/class-wp-error.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-wp-error.php	(revision 17487)
@@ -0,0 +1,212 @@
+<?php
+/**
+ * WordPress Error API.
+ *
+ * Contains the WP_Error class and the is_wp_error() function.
+ *
+ * @package WordPress
+ */
+
+/**
+ * WordPress Error class.
+ *
+ * Container for checking for WordPress errors and error messages. Return
+ * WP_Error and use {@link is_wp_error()} to check if this class is returned.
+ * Many core WordPress functions pass this class in the event of an error and
+ * if not handled properly will result in code errors.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ */
+class WP_Error {
+	/**
+	 * Stores the list of errors.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $errors = array();
+
+	/**
+	 * Stores the list of data for error codes.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $error_data = array();
+
+	/**
+	 * PHP4 Constructor - Sets up error message.
+	 *
+	 * If code parameter is empty then nothing will be done. It is possible to
+	 * add multiple messages to the same code, but with other methods in the
+	 * class.
+	 *
+	 * All parameters are optional, but if the code parameter is set, then the
+	 * data parameter is optional.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string|int $code Error code
+	 * @param string $message Error message
+	 * @param mixed $data Optional. Error data.
+	 * @return WP_Error
+	 */
+	function WP_Error($code = '', $message = '', $data = '') {
+		if ( empty($code) )
+			return;
+
+		$this->errors[$code][] = $message;
+
+		if ( ! empty($data) )
+			$this->error_data[$code] = $data;
+	}
+
+	/**
+	 * Retrieve all error codes.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @return array List of error codes, if avaiable.
+	 */
+	function get_error_codes() {
+		if ( empty($this->errors) )
+			return array();
+
+		return array_keys($this->errors);
+	}
+
+	/**
+	 * Retrieve first error code available.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @return string|int Empty string, if no error codes.
+	 */
+	function get_error_code() {
+		$codes = $this->get_error_codes();
+
+		if ( empty($codes) )
+			return '';
+
+		return $codes[0];
+	}
+
+	/**
+	 * Retrieve all error messages or error messages matching code.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string|int $code Optional. Retrieve messages matching code, if exists.
+	 * @return array Error strings on success, or empty array on failure (if using codee parameter).
+	 */
+	function get_error_messages($code = '') {
+		// Return all messages if no code specified.
+		if ( empty($code) ) {
+			$all_messages = array();
+			foreach ( (array) $this->errors as $code => $messages )
+				$all_messages = array_merge($all_messages, $messages);
+
+			return $all_messages;
+		}
+
+		if ( isset($this->errors[$code]) )
+			return $this->errors[$code];
+		else
+			return array();
+	}
+
+	/**
+	 * Get single error message.
+	 *
+	 * This will get the first message available for the code. If no code is
+	 * given then the first code available will be used.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string|int $code Optional. Error code to retrieve message.
+	 * @return string
+	 */
+	function get_error_message($code = '') {
+		if ( empty($code) )
+			$code = $this->get_error_code();
+		$messages = $this->get_error_messages($code);
+		if ( empty($messages) )
+			return '';
+		return $messages[0];
+	}
+
+	/**
+	 * Retrieve error data for error code.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string|int $code Optional. Error code.
+	 * @return mixed Null, if no errors.
+	 */
+	function get_error_data($code = '') {
+		if ( empty($code) )
+			$code = $this->get_error_code();
+
+		if ( isset($this->error_data[$code]) )
+			return $this->error_data[$code];
+		return null;
+	}
+
+	/**
+	 * Append more error messages to list of error messages.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string|int $code Error code.
+	 * @param string $message Error message.
+	 * @param mixed $data Optional. Error data.
+	 */
+	function add($code, $message, $data = '') {
+		$this->errors[$code][] = $message;
+		if ( ! empty($data) )
+			$this->error_data[$code] = $data;
+	}
+
+	/**
+	 * Add data for error code.
+	 *
+	 * The error code can only contain one error data.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param mixed $data Error data.
+	 * @param string|int $code Error code.
+	 */
+	function add_data($data, $code = '') {
+		if ( empty($code) )
+			$code = $this->get_error_code();
+
+		$this->error_data[$code] = $data;
+	}
+}
+
+/**
+ * Check whether variable is a WordPress Error.
+ *
+ * Looks at the object and if a WP_Error class. Does not check to see if the
+ * parent is also WP_Error, so can't inherit WP_Error and still use this
+ * function.
+ *
+ * @since 2.1.0
+ *
+ * @param mixed $thing Check if unknown variable is WordPress Error object.
+ * @return bool True, if WP_Error. False, if not WP_Error.
+ */
+function is_wp_error($thing) {
+	if ( is_object($thing) && is_a($thing, 'WP_Error') )
+		return true;
+	return false;
+}
+
+?>
Index: /tags/3.1/wp-includes/class-wp-http-ixr-client.php
===================================================================
--- /tags/3.1/wp-includes/class-wp-http-ixr-client.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-wp-http-ixr-client.php	(revision 17487)
@@ -0,0 +1,91 @@
+<?php
+/**
+ * WP_HTTP_IXR_Client
+ *
+ * @package WordPress
+ * @since 3.1.0
+ *
+ */
+class WP_HTTP_IXR_Client extends IXR_Client {
+	function WP_HTTP_IXR_Client($server, $path = false, $port = 80, $timeout = 15) {
+		if ( ! $path ) {
+			// Assume we have been given a URL instead
+			$bits = parse_url($server);
+			$this->scheme = $bits['scheme'];
+			$this->server = $bits['host'];
+			$this->port = isset($bits['port']) ? $bits['port'] : 80;
+			$this->path = !empty($bits['path']) ? $bits['path'] : '/';
+
+			// Make absolutely sure we have a path
+			if ( ! $this->path )
+				$this->path = '/';
+		} else {
+			$this->scheme = 'http';
+			$this->server = $server;
+			$this->path = $path;
+			$this->port = $port;
+		}
+		$this->useragent = 'The Incutio XML-RPC PHP Library';
+		$this->timeout = $timeout;
+	}
+
+	function query() {
+		$args = func_get_args();
+		$method = array_shift($args);
+		$request = new IXR_Request($method, $args);
+		$xml = $request->getXml();
+
+		$url = $this->scheme . '://' . $this->server . ':' . $this->port . $this->path;
+		$args = array(
+			'headers'    => array('Content-Type' => 'text/xml'),
+			'user-agent' => $this->useragent,
+			'body'       => $xml,
+		);
+
+		// Merge Custom headers ala #8145
+		foreach ( $this->headers as $header => $value )
+			$args['headers'][$header] = $value;
+
+		if ( $this->timeout !== false )
+			$args['timeout'] = $this->timeout;
+
+		// Now send the request
+		if ( $this->debug )
+			echo '<pre class="ixr_request">' . htmlspecialchars($xml) . "\n</pre>\n\n";
+
+		$response = wp_remote_post($url, $args);
+
+		if ( is_wp_error($response) ) {
+			$errno    = $response->get_error_code();
+			$errorstr = $response->get_error_message();
+			$this->error = new IXR_Error(-32300, "transport error: $errno $errorstr");
+			return false;
+		}
+
+		if ( $response['response']['code'] != 200 ) {
+			$this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ({$response['response']['code']})");
+			return false;
+		}
+
+		if ( $this->debug )
+			echo '<pre class="ixr_response">' . htmlspecialchars($response['body']) . "\n</pre>\n\n";
+
+		// Now parse what we've got back
+		$this->message = new IXR_Message( $response['body'] );
+		if ( ! $this->message->parse() ) {
+			// XML error
+			$this->error = new IXR_Error(-32700, 'parse error. not well formed');
+			return false;
+		}
+
+		// Is the message a fault?
+		if ( $this->message->messageType == 'fault' ) {
+			$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
+			return false;
+		}
+
+		// Message must be OK
+		return true;
+	}
+}
+?>
Index: /tags/3.1/wp-includes/class-wp-walker.php
===================================================================
--- /tags/3.1/wp-includes/class-wp-walker.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-wp-walker.php	(revision 17487)
@@ -0,0 +1,399 @@
+<?php
+/**
+ * A class for displaying various tree-like structures.
+ *
+ * Extend the Walker class to use it, see examples at the below. Child classes
+ * do not need to implement all of the abstract methods in the class. The child
+ * only needs to implement the methods that are needed. Also, the methods are
+ * not strictly abstract in that the parameter definition needs to be followed.
+ * The child classes can have additional parameters.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @abstract
+ */
+class Walker {
+	/**
+	 * What the class handles.
+	 *
+	 * @since 2.1.0
+	 * @var string
+	 * @access public
+	 */
+	var $tree_type;
+
+	/**
+	 * DB fields to use.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access protected
+	 */
+	var $db_fields;
+
+	/**
+	 * Max number of pages walked by the paged walker
+	 *
+	 * @since 2.7.0
+	 * @var int
+	 * @access protected
+	 */
+	var $max_pages = 1;
+
+	/**
+	 * Starts the list before the elements are added.
+	 *
+	 * Additional parameters are used in child classes. The args parameter holds
+	 * additional values that may be used with the child class methods. This
+	 * method is called at the start of the output list.
+	 *
+	 * @since 2.1.0
+	 * @abstract
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 */
+	function start_lvl(&$output) {}
+
+	/**
+	 * Ends the list of after the elements are added.
+	 *
+	 * Additional parameters are used in child classes. The args parameter holds
+	 * additional values that may be used with the child class methods. This
+	 * method finishes the list at the end of output of the elements.
+	 *
+	 * @since 2.1.0
+	 * @abstract
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 */
+	function end_lvl(&$output)   {}
+
+	/**
+	 * Start the element output.
+	 *
+	 * Additional parameters are used in child classes. The args parameter holds
+	 * additional values that may be used with the child class methods. Includes
+	 * the element output also.
+	 *
+	 * @since 2.1.0
+	 * @abstract
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 */
+	function start_el(&$output)  {}
+
+	/**
+	 * Ends the element output, if needed.
+	 *
+	 * Additional parameters are used in child classes. The args parameter holds
+	 * additional values that may be used with the child class methods.
+	 *
+	 * @since 2.1.0
+	 * @abstract
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 */
+	function end_el(&$output)    {}
+
+	/**
+	 * Traverse elements to create list from elements.
+	 *
+	 * Display one element if the element doesn't have any children otherwise,
+	 * display the element and its children. Will only traverse up to the max
+	 * depth and no ignore elements under that depth. It is possible to set the
+	 * max depth to include all depths, see walk() method.
+	 *
+	 * This method shouldn't be called directly, use the walk() method instead.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param object $element Data object
+	 * @param array $children_elements List of elements to continue traversing.
+	 * @param int $max_depth Max depth to traverse.
+	 * @param int $depth Depth of current element.
+	 * @param array $args
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @return null Null on failure with no changes to parameters.
+	 */
+	function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
+
+		if ( !$element )
+			return;
+
+		$id_field = $this->db_fields['id'];
+
+		//display this element
+		if ( is_array( $args[0] ) )
+			$args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] );
+		$cb_args = array_merge( array(&$output, $element, $depth), $args);
+		call_user_func_array(array(&$this, 'start_el'), $cb_args);
+
+		$id = $element->$id_field;
+
+		// descend only when the depth is right and there are childrens for this element
+		if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) {
+
+			foreach( $children_elements[ $id ] as $child ){
+
+				if ( !isset($newlevel) ) {
+					$newlevel = true;
+					//start the child delimiter
+					$cb_args = array_merge( array(&$output, $depth), $args);
+					call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
+				}
+				$this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
+			}
+			unset( $children_elements[ $id ] );
+		}
+
+		if ( isset($newlevel) && $newlevel ){
+			//end the child delimiter
+			$cb_args = array_merge( array(&$output, $depth), $args);
+			call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
+		}
+
+		//end this element
+		$cb_args = array_merge( array(&$output, $element, $depth), $args);
+		call_user_func_array(array(&$this, 'end_el'), $cb_args);
+	}
+
+	/**
+	 * Display array of elements hierarchically.
+	 *
+	 * It is a generic function which does not assume any existing order of
+	 * elements. max_depth = -1 means flatly display every element. max_depth =
+	 * 0 means display all levels. max_depth > 0  specifies the number of
+	 * display levels.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param array $elements
+	 * @param int $max_depth
+	 * @return string
+	 */
+	function walk( $elements, $max_depth) {
+
+		$args = array_slice(func_get_args(), 2);
+		$output = '';
+
+		if ($max_depth < -1) //invalid parameter
+			return $output;
+
+		if (empty($elements)) //nothing to walk
+			return $output;
+
+		$id_field = $this->db_fields['id'];
+		$parent_field = $this->db_fields['parent'];
+
+		// flat display
+		if ( -1 == $max_depth ) {
+			$empty_array = array();
+			foreach ( $elements as $e )
+				$this->display_element( $e, $empty_array, 1, 0, $args, $output );
+			return $output;
+		}
+
+		/*
+		 * need to display in hierarchical order
+		 * separate elements into two buckets: top level and children elements
+		 * children_elements is two dimensional array, eg.
+		 * children_elements[10][] contains all sub-elements whose parent is 10.
+		 */
+		$top_level_elements = array();
+		$children_elements  = array();
+		foreach ( $elements as $e) {
+			if ( 0 == $e->$parent_field )
+				$top_level_elements[] = $e;
+			else
+				$children_elements[ $e->$parent_field ][] = $e;
+		}
+
+		/*
+		 * when none of the elements is top level
+		 * assume the first one must be root of the sub elements
+		 */
+		if ( empty($top_level_elements) ) {
+
+			$first = array_slice( $elements, 0, 1 );
+			$root = $first[0];
+
+			$top_level_elements = array();
+			$children_elements  = array();
+			foreach ( $elements as $e) {
+				if ( $root->$parent_field == $e->$parent_field )
+					$top_level_elements[] = $e;
+				else
+					$children_elements[ $e->$parent_field ][] = $e;
+			}
+		}
+
+		foreach ( $top_level_elements as $e )
+			$this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
+
+		/*
+		 * if we are displaying all levels, and remaining children_elements is not empty,
+		 * then we got orphans, which should be displayed regardless
+		 */
+		if ( ( $max_depth == 0 ) && count( $children_elements ) > 0 ) {
+			$empty_array = array();
+			foreach ( $children_elements as $orphans )
+				foreach( $orphans as $op )
+					$this->display_element( $op, $empty_array, 1, 0, $args, $output );
+		 }
+
+		 return $output;
+	}
+
+	/**
+ 	 * paged_walk() - produce a page of nested elements
+ 	 *
+ 	 * Given an array of hierarchical elements, the maximum depth, a specific page number,
+ 	 * and number of elements per page, this function first determines all top level root elements
+ 	 * belonging to that page, then lists them and all of their children in hierarchical order.
+ 	 *
+ 	 * @package WordPress
+ 	 * @since 2.7
+ 	 * @param int $max_depth = 0 means display all levels; $max_depth > 0 specifies the number of display levels.
+ 	 * @param int $page_num the specific page number, beginning with 1.
+ 	 * @return XHTML of the specified page of elements
+ 	 */
+	function paged_walk( $elements, $max_depth, $page_num, $per_page ) {
+
+		/* sanity check */
+		if ( empty($elements) || $max_depth < -1 )
+			return '';
+
+		$args = array_slice( func_get_args(), 4 );
+		$output = '';
+
+		$id_field = $this->db_fields['id'];
+		$parent_field = $this->db_fields['parent'];
+
+		$count = -1;
+		if ( -1 == $max_depth )
+			$total_top = count( $elements );
+		if ( $page_num < 1 || $per_page < 0  ) {
+			// No paging
+			$paging = false;
+			$start = 0;
+			if ( -1 == $max_depth )
+				$end = $total_top;
+			$this->max_pages = 1;
+		} else {
+			$paging = true;
+			$start = ( (int)$page_num - 1 ) * (int)$per_page;
+			$end   = $start + $per_page;
+			if ( -1 == $max_depth )
+				$this->max_pages = ceil($total_top / $per_page);
+		}
+
+		// flat display
+		if ( -1 == $max_depth ) {
+			if ( !empty($args[0]['reverse_top_level']) ) {
+				$elements = array_reverse( $elements );
+				$oldstart = $start;
+				$start = $total_top - $end;
+				$end = $total_top - $oldstart;
+			}
+
+			$empty_array = array();
+			foreach ( $elements as $e ) {
+				$count++;
+				if ( $count < $start )
+					continue;
+				if ( $count >= $end )
+					break;
+				$this->display_element( $e, $empty_array, 1, 0, $args, $output );
+			}
+			return $output;
+		}
+
+		/*
+		 * separate elements into two buckets: top level and children elements
+		 * children_elements is two dimensional array, eg.
+		 * children_elements[10][] contains all sub-elements whose parent is 10.
+		 */
+		$top_level_elements = array();
+		$children_elements  = array();
+		foreach ( $elements as $e) {
+			if ( 0 == $e->$parent_field )
+				$top_level_elements[] = $e;
+			else
+				$children_elements[ $e->$parent_field ][] = $e;
+		}
+
+		$total_top = count( $top_level_elements );
+		if ( $paging )
+			$this->max_pages = ceil($total_top / $per_page);
+		else
+			$end = $total_top;
+
+		if ( !empty($args[0]['reverse_top_level']) ) {
+			$top_level_elements = array_reverse( $top_level_elements );
+			$oldstart = $start;
+			$start = $total_top - $end;
+			$end = $total_top - $oldstart;
+		}
+		if ( !empty($args[0]['reverse_children']) ) {
+			foreach ( $children_elements as $parent => $children )
+				$children_elements[$parent] = array_reverse( $children );
+		}
+
+		foreach ( $top_level_elements as $e ) {
+			$count++;
+
+			//for the last page, need to unset earlier children in order to keep track of orphans
+			if ( $end >= $total_top && $count < $start )
+					$this->unset_children( $e, $children_elements );
+
+			if ( $count < $start )
+				continue;
+
+			if ( $count >= $end )
+				break;
+
+			$this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
+		}
+
+		if ( $end >= $total_top && count( $children_elements ) > 0 ) {
+			$empty_array = array();
+			foreach ( $children_elements as $orphans )
+				foreach( $orphans as $op )
+					$this->display_element( $op, $empty_array, 1, 0, $args, $output );
+		}
+
+		return $output;
+	}
+
+	function get_number_of_root_elements( $elements ){
+
+		$num = 0;
+		$parent_field = $this->db_fields['parent'];
+
+		foreach ( $elements as $e) {
+			if ( 0 == $e->$parent_field )
+				$num++;
+		}
+		return $num;
+	}
+
+	// unset all the children for a given top level element
+	function unset_children( $e, &$children_elements ){
+
+		if ( !$e || !$children_elements )
+			return;
+
+		$id_field = $this->db_fields['id'];
+		$id = $e->$id_field;
+
+		if ( !empty($children_elements[$id]) && is_array($children_elements[$id]) )
+			foreach ( (array) $children_elements[$id] as $child )
+				$this->unset_children( $child, $children_elements );
+
+		if ( isset($children_elements[$id]) )
+			unset( $children_elements[$id] );
+
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/class-wp-xmlrpc-server.php
===================================================================
--- /tags/3.1/wp-includes/class-wp-xmlrpc-server.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-wp-xmlrpc-server.php	(revision 17487)
@@ -0,0 +1,3527 @@
+<?php
+/**
+ * XML-RPC protocol support for WordPress
+ *
+ * @package WordPress
+ */
+
+/**
+ * WordPress XMLRPC server implementation.
+ *
+ * Implements compatability for Blogger API, MetaWeblog API, MovableType, and
+ * pingback. Additional WordPress API for managing comments, pages, posts,
+ * options, etc.
+ *
+ * Since WordPress 2.6.0, WordPress XMLRPC server can be disabled in the
+ * administration panels.
+ *
+ * @package WordPress
+ * @subpackage Publishing
+ * @since 1.5.0
+ */
+class wp_xmlrpc_server extends IXR_Server {
+
+	/**
+	 * Register all of the XMLRPC methods that XMLRPC server understands.
+	 *
+	 * PHP4 constructor and sets up server and method property. Passes XMLRPC
+	 * methods through the 'xmlrpc_methods' filter to allow plugins to extend
+	 * or replace XMLRPC methods.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @return wp_xmlrpc_server
+	 */
+	function wp_xmlrpc_server() {
+		$this->methods = array(
+			// WordPress API
+			'wp.getUsersBlogs'		=> 'this:wp_getUsersBlogs',
+			'wp.getPage'			=> 'this:wp_getPage',
+			'wp.getPages'			=> 'this:wp_getPages',
+			'wp.newPage'			=> 'this:wp_newPage',
+			'wp.deletePage'			=> 'this:wp_deletePage',
+			'wp.editPage'			=> 'this:wp_editPage',
+			'wp.getPageList'		=> 'this:wp_getPageList',
+			'wp.getAuthors'			=> 'this:wp_getAuthors',
+			'wp.getCategories'		=> 'this:mw_getCategories',		// Alias
+			'wp.getTags'			=> 'this:wp_getTags',
+			'wp.newCategory'		=> 'this:wp_newCategory',
+			'wp.deleteCategory'		=> 'this:wp_deleteCategory',
+			'wp.suggestCategories'	=> 'this:wp_suggestCategories',
+			'wp.uploadFile'			=> 'this:mw_newMediaObject',	// Alias
+			'wp.getCommentCount'	=> 'this:wp_getCommentCount',
+			'wp.getPostStatusList'	=> 'this:wp_getPostStatusList',
+			'wp.getPageStatusList'	=> 'this:wp_getPageStatusList',
+			'wp.getPageTemplates'	=> 'this:wp_getPageTemplates',
+			'wp.getOptions'			=> 'this:wp_getOptions',
+			'wp.setOptions'			=> 'this:wp_setOptions',
+			'wp.getComment'			=> 'this:wp_getComment',
+			'wp.getComments'		=> 'this:wp_getComments',
+			'wp.deleteComment'		=> 'this:wp_deleteComment',
+			'wp.editComment'		=> 'this:wp_editComment',
+			'wp.newComment'			=> 'this:wp_newComment',
+			'wp.getCommentStatusList' => 'this:wp_getCommentStatusList',
+			'wp.getMediaItem'		=> 'this:wp_getMediaItem',
+			'wp.getMediaLibrary'	=> 'this:wp_getMediaLibrary',
+			'wp.getPostFormats'     => 'this:wp_getPostFormats',
+
+			// Blogger API
+			'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
+			'blogger.getUserInfo' => 'this:blogger_getUserInfo',
+			'blogger.getPost' => 'this:blogger_getPost',
+			'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
+			'blogger.getTemplate' => 'this:blogger_getTemplate',
+			'blogger.setTemplate' => 'this:blogger_setTemplate',
+			'blogger.newPost' => 'this:blogger_newPost',
+			'blogger.editPost' => 'this:blogger_editPost',
+			'blogger.deletePost' => 'this:blogger_deletePost',
+
+			// MetaWeblog API (with MT extensions to structs)
+			'metaWeblog.newPost' => 'this:mw_newPost',
+			'metaWeblog.editPost' => 'this:mw_editPost',
+			'metaWeblog.getPost' => 'this:mw_getPost',
+			'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
+			'metaWeblog.getCategories' => 'this:mw_getCategories',
+			'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
+
+			// MetaWeblog API aliases for Blogger API
+			// see http://www.xmlrpc.com/stories/storyReader$2460
+			'metaWeblog.deletePost' => 'this:blogger_deletePost',
+			'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
+			'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
+			'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
+
+			// MovableType API
+			'mt.getCategoryList' => 'this:mt_getCategoryList',
+			'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
+			'mt.getPostCategories' => 'this:mt_getPostCategories',
+			'mt.setPostCategories' => 'this:mt_setPostCategories',
+			'mt.supportedMethods' => 'this:mt_supportedMethods',
+			'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
+			'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
+			'mt.publishPost' => 'this:mt_publishPost',
+
+			// PingBack
+			'pingback.ping' => 'this:pingback_ping',
+			'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
+
+			'demo.sayHello' => 'this:sayHello',
+			'demo.addTwoNumbers' => 'this:addTwoNumbers'
+		);
+
+		$this->initialise_blog_option_info( );
+		$this->methods = apply_filters('xmlrpc_methods', $this->methods);
+	}
+
+	function serve_request() {
+		$this->IXR_Server($this->methods);
+	}
+
+	/**
+	 * Test XMLRPC API by saying, "Hello!" to client.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method Parameters.
+	 * @return string
+	 */
+	function sayHello($args) {
+		return 'Hello!';
+	}
+
+	/**
+	 * Test XMLRPC API by adding two numbers for client.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method Parameters.
+	 * @return int
+	 */
+	function addTwoNumbers($args) {
+		$number1 = $args[0];
+		$number2 = $args[1];
+		return $number1 + $number2;
+	}
+
+	/**
+	 * Check user's credentials.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param string $user_login User's username.
+	 * @param string $user_pass User's password.
+	 * @return bool Whether authentication passed.
+	 * @deprecated use wp_xmlrpc_server::login
+	 * @see wp_xmlrpc_server::login
+	 */
+	function login_pass_ok($user_login, $user_pass) {
+		if ( !get_option( 'enable_xmlrpc' ) ) {
+			$this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.  An admin user can enable them at %s'),  admin_url('options-writing.php') ) );
+			return false;
+		}
+
+		if (!user_pass_ok($user_login, $user_pass)) {
+			$this->error = new IXR_Error(403, __('Bad login/pass combination.'));
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Log user in.
+	 *
+	 * @since 2.8
+	 *
+	 * @param string $username User's username.
+	 * @param string $password User's password.
+	 * @return mixed WP_User object if authentication passed, false otherwise
+	 */
+	function login($username, $password) {
+		if ( !get_option( 'enable_xmlrpc' ) ) {
+			$this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.  An admin user can enable them at %s'),  admin_url('options-writing.php') ) );
+			return false;
+		}
+
+		$user = wp_authenticate($username, $password);
+
+		if (is_wp_error($user)) {
+			$this->error = new IXR_Error(403, __('Bad login/pass combination.'));
+			return false;
+		}
+
+		wp_set_current_user( $user->ID );
+		return $user;
+	}
+
+	/**
+	 * Sanitize string or array of strings for database.
+	 *
+	 * @since 1.5.2
+	 *
+	 * @param string|array $array Sanitize single string or array of strings.
+	 * @return string|array Type matches $array and sanitized for the database.
+	 */
+	function escape(&$array) {
+		global $wpdb;
+
+		if (!is_array($array)) {
+			return($wpdb->escape($array));
+		} else {
+			foreach ( (array) $array as $k => $v ) {
+				if ( is_array($v) ) {
+					$this->escape($array[$k]);
+				} else if ( is_object($v) ) {
+					//skip
+				} else {
+					$array[$k] = $wpdb->escape($v);
+				}
+			}
+		}
+	}
+
+	/**
+	 * Retrieve custom fields for post.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param int $post_id Post ID.
+	 * @return array Custom fields, if exist.
+	 */
+	function get_custom_fields($post_id) {
+		$post_id = (int) $post_id;
+
+		$custom_fields = array();
+
+		foreach ( (array) has_meta($post_id) as $meta ) {
+			// Don't expose protected fields.
+			if ( strpos($meta['meta_key'], '_wp_') === 0 ) {
+				continue;
+			}
+
+			$custom_fields[] = array(
+				"id"    => $meta['meta_id'],
+				"key"   => $meta['meta_key'],
+				"value" => $meta['meta_value']
+			);
+		}
+
+		return $custom_fields;
+	}
+
+	/**
+	 * Set custom fields for post.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param int $post_id Post ID.
+	 * @param array $fields Custom fields.
+	 */
+	function set_custom_fields($post_id, $fields) {
+		$post_id = (int) $post_id;
+
+		foreach ( (array) $fields as $meta ) {
+			if ( isset($meta['id']) ) {
+				$meta['id'] = (int) $meta['id'];
+
+				if ( isset($meta['key']) ) {
+					update_meta($meta['id'], $meta['key'], $meta['value']);
+				}
+				else {
+					delete_meta($meta['id']);
+				}
+			}
+			else {
+				$_POST['metakeyinput'] = $meta['key'];
+				$_POST['metavalue'] = $meta['value'];
+				add_meta($post_id);
+			}
+		}
+	}
+
+	/**
+	 * Set up blog options property.
+	 *
+	 * Passes property through 'xmlrpc_blog_options' filter.
+	 *
+	 * @since 2.6.0
+	 */
+	function initialise_blog_option_info( ) {
+		global $wp_version;
+
+		$this->blog_options = array(
+			// Read only options
+			'software_name'		=> array(
+				'desc'			=> __( 'Software Name' ),
+				'readonly'		=> true,
+				'value'			=> 'WordPress'
+			),
+			'software_version'	=> array(
+				'desc'			=> __( 'Software Version' ),
+				'readonly'		=> true,
+				'value'			=> $wp_version
+			),
+			'blog_url'			=> array(
+				'desc'			=> __( 'Site URL' ),
+				'readonly'		=> true,
+				'option'		=> 'siteurl'
+			),
+
+			// Updatable options
+			'time_zone'			=> array(
+				'desc'			=> __( 'Time Zone' ),
+				'readonly'		=> false,
+				'option'		=> 'gmt_offset'
+			),
+			'blog_title'		=> array(
+				'desc'			=> __( 'Site Title' ),
+				'readonly'		=> false,
+				'option'			=> 'blogname'
+			),
+			'blog_tagline'		=> array(
+				'desc'			=> __( 'Site Tagline' ),
+				'readonly'		=> false,
+				'option'		=> 'blogdescription'
+			),
+			'date_format'		=> array(
+				'desc'			=> __( 'Date Format' ),
+				'readonly'		=> false,
+				'option'		=> 'date_format'
+			),
+			'time_format'		=> array(
+				'desc'			=> __( 'Time Format' ),
+				'readonly'		=> false,
+				'option'		=> 'time_format'
+			),
+			'users_can_register'	=> array(
+				'desc'			=> __( 'Allow new users to sign up' ),
+				'readonly'		=> false,
+				'option'		=> 'users_can_register'
+			),
+			'thumbnail_size_w'	=> array(
+				'desc'			=> __( 'Thumbnail Width' ),
+				'readonly'		=> false,
+				'option'		=> 'thumbnail_size_w'
+			),
+			'thumbnail_size_h'	=> array(
+				'desc'			=> __( 'Thumbnail Height' ),
+				'readonly'		=> false,
+				'option'		=> 'thumbnail_size_h'
+			),
+			'thumbnail_crop'	=> array(
+				'desc'			=> __( 'Crop thumbnail to exact dimensions' ),
+				'readonly'		=> false,
+				'option'		=> 'thumbnail_crop'
+			),
+			'medium_size_w'	=> array(
+				'desc'			=> __( 'Medium size image width' ),
+				'readonly'		=> false,
+				'option'		=> 'medium_size_w'
+			),
+			'medium_size_h'	=> array(
+				'desc'			=> __( 'Medium size image height' ),
+				'readonly'		=> false,
+				'option'		=> 'medium_size_h'
+			),
+			'large_size_w'	=> array(
+				'desc'			=> __( 'Large size image width' ),
+				'readonly'		=> false,
+				'option'		=> 'large_size_w'
+			),
+			'large_size_h'	=> array(
+				'desc'			=> __( 'Large size image height' ),
+				'readonly'		=> false,
+				'option'		=> 'large_size_h'
+			)
+		);
+
+		$this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options );
+	}
+
+	/**
+	 * Retrieve the blogs of the user.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getUsersBlogs( $args ) {
+		global $current_site;
+		// If this isn't on WPMU then just use blogger_getUsersBlogs
+		if ( !is_multisite() ) {
+			array_unshift( $args, 1 );
+			return $this->blogger_getUsersBlogs( $args );
+		}
+
+		$this->escape( $args );
+
+		$username = $args[0];
+		$password = $args[1];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+
+		do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
+
+		$blogs = (array) get_blogs_of_user( $user->ID );
+		$struct = array( );
+
+		foreach ( $blogs as $blog ) {
+			// Don't include blogs that aren't hosted at this site
+			if ( $blog->site_id != $current_site->id )
+				continue;
+
+			$blog_id = $blog->userblog_id;
+			switch_to_blog($blog_id);
+			$is_admin = current_user_can('manage_options');
+
+			$struct[] = array(
+				'isAdmin'		=> $is_admin,
+				'url'			=> get_option( 'home' ) . '/',
+				'blogid'		=> (string) $blog_id,
+				'blogName'		=> get_option( 'blogname' ),
+				'xmlrpc'		=> site_url( 'xmlrpc.php' )
+			);
+
+			restore_current_blog( );
+		}
+
+		return $struct;
+	}
+
+	/**
+	 * Retrieve page.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getPage($args) {
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$page_id	= (int) $args[1];
+		$username	= $args[2];
+		$password	= $args[3];
+
+		if ( !$user = $this->login($username, $password) ) {
+			return $this->error;
+		}
+
+		if ( !current_user_can( 'edit_page', $page_id ) )
+			return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
+
+		do_action('xmlrpc_call', 'wp.getPage');
+
+		// Lookup page info.
+		$page = get_page($page_id);
+
+		// If we found the page then format the data.
+		if ( $page->ID && ($page->post_type == "page") ) {
+			// Get all of the page content and link.
+			$full_page = get_extended($page->post_content);
+			$link = post_permalink($page->ID);
+
+			// Get info the page parent if there is one.
+			$parent_title = "";
+			if ( !empty($page->post_parent) ) {
+				$parent = get_page($page->post_parent);
+				$parent_title = $parent->post_title;
+			}
+
+			// Determine comment and ping settings.
+			$allow_comments = comments_open($page->ID) ? 1 : 0;
+			$allow_pings = pings_open($page->ID) ? 1 : 0;
+
+			// Format page date.
+			$page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
+			$page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
+
+			// For drafts use the GMT version of the date
+			if ( $page->post_status == 'draft' )
+				$page_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page->post_date ), 'Ymd\TH:i:s' );
+
+			// Pull the categories info together.
+			$categories = array();
+			foreach ( wp_get_post_categories($page->ID) as $cat_id ) {
+				$categories[] = get_cat_name($cat_id);
+			}
+
+			// Get the author info.
+			$author = get_userdata($page->post_author);
+
+			$page_template = get_post_meta( $page->ID, '_wp_page_template', true );
+			if ( empty( $page_template ) )
+				$page_template = 'default';
+
+			$page_struct = array(
+				"dateCreated"			=> new IXR_Date($page_date),
+				"userid"				=> $page->post_author,
+				"page_id"				=> $page->ID,
+				"page_status"			=> $page->post_status,
+				"description"			=> $full_page["main"],
+				"title"					=> $page->post_title,
+				"link"					=> $link,
+				"permaLink"				=> $link,
+				"categories"			=> $categories,
+				"excerpt"				=> $page->post_excerpt,
+				"text_more"				=> $full_page["extended"],
+				"mt_allow_comments"		=> $allow_comments,
+				"mt_allow_pings"		=> $allow_pings,
+				"wp_slug"				=> $page->post_name,
+				"wp_password"			=> $page->post_password,
+				"wp_author"				=> $author->display_name,
+				"wp_page_parent_id"		=> $page->post_parent,
+				"wp_page_parent_title"	=> $parent_title,
+				"wp_page_order"			=> $page->menu_order,
+				"wp_author_id"			=> $author->ID,
+				"wp_author_display_name"	=> $author->display_name,
+				"date_created_gmt"		=> new IXR_Date($page_date_gmt),
+				"custom_fields"			=> $this->get_custom_fields($page_id),
+				"wp_page_template"		=> $page_template
+			);
+
+			return($page_struct);
+		}
+		// If the page doesn't exist indicate that.
+		else {
+			return(new IXR_Error(404, __("Sorry, no such page.")));
+		}
+	}
+
+	/**
+	 * Retrieve Pages.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getPages($args) {
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$num_pages	= isset($args[3]) ? (int) $args[3] : 10;
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_pages' ) )
+			return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
+
+		do_action('xmlrpc_call', 'wp.getPages');
+
+		$pages = get_posts( array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => $num_pages) );
+		$num_pages = count($pages);
+
+		// If we have pages, put together their info.
+		if ( $num_pages >= 1 ) {
+			$pages_struct = array();
+
+			for ( $i = 0; $i < $num_pages; $i++ ) {
+				$page = wp_xmlrpc_server::wp_getPage(array(
+					$blog_id, $pages[$i]->ID, $username, $password
+				));
+				$pages_struct[] = $page;
+			}
+
+			return($pages_struct);
+		}
+		// If no pages were found return an error.
+		else {
+			return(array());
+		}
+	}
+
+	/**
+	 * Create new page.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return unknown
+	 */
+	function wp_newPage($args) {
+		// Items not escaped here will be escaped in newPost.
+		$username	= $this->escape($args[1]);
+		$password	= $this->escape($args[2]);
+		$page		= $args[3];
+		$publish	= $args[4];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'wp.newPage');
+
+		// Make sure the user is allowed to add new pages.
+		if ( !current_user_can("publish_pages") )
+			return(new IXR_Error(401, __("Sorry, you cannot add new pages.")));
+
+		// Mark this as content for a page.
+		$args[3]["post_type"] = "page";
+
+		// Let mw_newPost do all of the heavy lifting.
+		return($this->mw_newPost($args));
+	}
+
+	/**
+	 * Delete page.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return bool True, if success.
+	 */
+	function wp_deletePage($args) {
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$page_id	= (int) $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'wp.deletePage');
+
+		// Get the current page based on the page_id and
+		// make sure it is a page and not a post.
+		$actual_page = wp_get_single_post($page_id, ARRAY_A);
+		if ( !$actual_page || ($actual_page["post_type"] != "page") )
+			return(new IXR_Error(404, __("Sorry, no such page.")));
+
+		// Make sure the user can delete pages.
+		if ( !current_user_can("delete_page", $page_id) )
+			return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page.")));
+
+		// Attempt to delete the page.
+		$result = wp_delete_post($page_id);
+		if ( !$result )
+			return(new IXR_Error(500, __("Failed to delete the page.")));
+
+		return(true);
+	}
+
+	/**
+	 * Edit page.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return unknown
+	 */
+	function wp_editPage($args) {
+		// Items not escaped here will be escaped in editPost.
+		$blog_id	= (int) $args[0];
+		$page_id	= (int) $this->escape($args[1]);
+		$username	= $this->escape($args[2]);
+		$password	= $this->escape($args[3]);
+		$content	= $args[4];
+		$publish	= $args[5];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'wp.editPage');
+
+		// Get the page data and make sure it is a page.
+		$actual_page = wp_get_single_post($page_id, ARRAY_A);
+		if ( !$actual_page || ($actual_page["post_type"] != "page") )
+			return(new IXR_Error(404, __("Sorry, no such page.")));
+
+		// Make sure the user is allowed to edit pages.
+		if ( !current_user_can("edit_page", $page_id) )
+			return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
+
+		// Mark this as content for a page.
+		$content["post_type"] = "page";
+
+		// Arrange args in the way mw_editPost understands.
+		$args = array(
+			$page_id,
+			$username,
+			$password,
+			$content,
+			$publish
+		);
+
+		// Let mw_editPost do all of the heavy lifting.
+		return($this->mw_editPost($args));
+	}
+
+	/**
+	 * Retrieve page list.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return unknown
+	 */
+	function wp_getPageList($args) {
+		global $wpdb;
+
+		$this->escape($args);
+
+		$blog_id				= (int) $args[0];
+		$username				= $args[1];
+		$password				= $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_pages' ) )
+			return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
+
+		do_action('xmlrpc_call', 'wp.getPageList');
+
+		// Get list of pages ids and titles
+		$page_list = $wpdb->get_results("
+			SELECT ID page_id,
+				post_title page_title,
+				post_parent page_parent_id,
+				post_date_gmt,
+				post_date,
+				post_status
+			FROM {$wpdb->posts}
+			WHERE post_type = 'page'
+			ORDER BY ID
+		");
+
+		// The date needs to be formated properly.
+		$num_pages = count($page_list);
+		for ( $i = 0; $i < $num_pages; $i++ ) {
+			$post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false);
+			$post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false);
+
+			$page_list[$i]->dateCreated = new IXR_Date($post_date);
+			$page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
+
+			// For drafts use the GMT version of the date
+			if ( $page_list[$i]->post_status == 'draft' ) {
+				$page_list[$i]->date_created_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $page_list[$i]->post_date ), 'Ymd\TH:i:s' );
+				$page_list[$i]->date_created_gmt = new IXR_Date( $page_list[$i]->date_created_gmt );
+			}
+
+			unset($page_list[$i]->post_date_gmt);
+			unset($page_list[$i]->post_date);
+			unset($page_list[$i]->post_status);
+		}
+
+		return($page_list);
+	}
+
+	/**
+	 * Retrieve authors list.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getAuthors($args) {
+
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can("edit_posts") )
+			return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site.")));
+
+		do_action('xmlrpc_call', 'wp.getAuthors');
+
+		$authors = array();
+		foreach ( get_users( array( 'fields' => array('ID','user_login','display_name') ) ) as $user ) {
+			$authors[] = array(
+				"user_id"       => $user->ID,
+				"user_login"    => $user->user_login,
+				"display_name"  => $user->display_name
+			);
+		}
+
+		return $authors;
+	}
+
+	/**
+	 * Get list of all tags
+	 *
+	 * @since 2.7
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getTags( $args ) {
+		$this->escape( $args );
+
+		$blog_id		= (int) $args[0];
+		$username		= $args[1];
+		$password		= $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_posts' ) )
+			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
+
+		do_action( 'xmlrpc_call', 'wp.getKeywords' );
+
+		$tags = array( );
+
+		if ( $all_tags = get_tags() ) {
+			foreach( (array) $all_tags as $tag ) {
+				$struct['tag_id']			= $tag->term_id;
+				$struct['name']				= $tag->name;
+				$struct['count']			= $tag->count;
+				$struct['slug']				= $tag->slug;
+				$struct['html_url']			= esc_html( get_tag_link( $tag->term_id ) );
+				$struct['rss_url']			= esc_html( get_tag_feed_link( $tag->term_id ) );
+
+				$tags[] = $struct;
+			}
+		}
+
+		return $tags;
+	}
+
+	/**
+	 * Create new category.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return int Category ID.
+	 */
+	function wp_newCategory($args) {
+		$this->escape($args);
+
+		$blog_id				= (int) $args[0];
+		$username				= $args[1];
+		$password				= $args[2];
+		$category				= $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'wp.newCategory');
+
+		// Make sure the user is allowed to add a category.
+		if ( !current_user_can("manage_categories") )
+			return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
+
+		// If no slug was provided make it empty so that
+		// WordPress will generate one.
+		if ( empty($category["slug"]) )
+			$category["slug"] = "";
+
+		// If no parent_id was provided make it empty
+		// so that it will be a top level page (no parent).
+		if ( !isset($category["parent_id"]) )
+			$category["parent_id"] = "";
+
+		// If no description was provided make it empty.
+		if ( empty($category["description"]) )
+			$category["description"] = "";
+
+		$new_category = array(
+			"cat_name"				=> $category["name"],
+			"category_nicename"		=> $category["slug"],
+			"category_parent"		=> $category["parent_id"],
+			"category_description"	=> $category["description"]
+		);
+
+		$cat_id = wp_insert_category($new_category, true);
+		if ( is_wp_error( $cat_id ) ) {
+			if ( 'term_exists' == $cat_id->get_error_code() )
+				return (int) $cat_id->get_error_data();
+			else
+				return(new IXR_Error(500, __("Sorry, the new category failed.")));
+		} elseif ( ! $cat_id ) {
+			return(new IXR_Error(500, __("Sorry, the new category failed.")));
+		}
+
+		return($cat_id);
+	}
+
+	/**
+	 * Remove category.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return mixed See {@link wp_delete_term()} for return info.
+	 */
+	function wp_deleteCategory($args) {
+		$this->escape($args);
+
+		$blog_id		= (int) $args[0];
+		$username		= $args[1];
+		$password		= $args[2];
+		$category_id	= (int) $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'wp.deleteCategory');
+
+		if ( !current_user_can("manage_categories") )
+			return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) );
+
+		return wp_delete_term( $category_id, 'category' );
+	}
+
+	/**
+	 * Retrieve category list.
+	 *
+	 * @since 2.2.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_suggestCategories($args) {
+		$this->escape($args);
+
+		$blog_id				= (int) $args[0];
+		$username				= $args[1];
+		$password				= $args[2];
+		$category				= $args[3];
+		$max_results			= (int) $args[4];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_posts' ) )
+			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) );
+
+		do_action('xmlrpc_call', 'wp.suggestCategories');
+
+		$category_suggestions = array();
+		$args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
+		foreach ( (array) get_categories($args) as $cat ) {
+			$category_suggestions[] = array(
+				"category_id"	=> $cat->term_id,
+				"category_name"	=> $cat->name
+			);
+		}
+
+		return($category_suggestions);
+	}
+
+	/**
+	 * Retrieve comment.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getComment($args) {
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$comment_id	= (int) $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'moderate_comments' ) )
+			return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
+
+		do_action('xmlrpc_call', 'wp.getComment');
+
+		if ( ! $comment = get_comment($comment_id) )
+			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
+
+		// Format page date.
+		$comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
+		$comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
+
+		if ( '0' == $comment->comment_approved )
+			$comment_status = 'hold';
+		else if ( 'spam' == $comment->comment_approved )
+			$comment_status = 'spam';
+		else if ( '1' == $comment->comment_approved )
+			$comment_status = 'approve';
+		else
+			$comment_status = $comment->comment_approved;
+
+		$link = get_comment_link($comment);
+
+		$comment_struct = array(
+			"date_created_gmt"		=> new IXR_Date($comment_date_gmt),
+			"user_id"				=> $comment->user_id,
+			"comment_id"			=> $comment->comment_ID,
+			"parent"				=> $comment->comment_parent,
+			"status"				=> $comment_status,
+			"content"				=> $comment->comment_content,
+			"link"					=> $link,
+			"post_id"				=> $comment->comment_post_ID,
+			"post_title"			=> get_the_title($comment->comment_post_ID),
+			"author"				=> $comment->comment_author,
+			"author_url"			=> $comment->comment_author_url,
+			"author_email"			=> $comment->comment_author_email,
+			"author_ip"				=> $comment->comment_author_IP,
+			"type"					=> $comment->comment_type,
+		);
+
+		return $comment_struct;
+	}
+
+	/**
+	 * Retrieve comments.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getComments($args) {
+		$raw_args = $args;
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$struct		= $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'moderate_comments' ) )
+			return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) );
+
+		do_action('xmlrpc_call', 'wp.getComments');
+
+		if ( isset($struct['status']) )
+			$status = $struct['status'];
+		else
+			$status = '';
+
+		$post_id = '';
+		if ( isset($struct['post_id']) )
+			$post_id = absint($struct['post_id']);
+
+		$offset = 0;
+		if ( isset($struct['offset']) )
+			$offset = absint($struct['offset']);
+
+		$number = 10;
+		if ( isset($struct['number']) )
+			$number = absint($struct['number']);
+
+		$comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
+		$num_comments = count($comments);
+
+		if ( ! $num_comments )
+			return array();
+
+		$comments_struct = array();
+
+		for ( $i = 0; $i < $num_comments; $i++ ) {
+			$comment = wp_xmlrpc_server::wp_getComment(array(
+				$raw_args[0], $raw_args[1], $raw_args[2], $comments[$i]->comment_ID,
+			));
+			$comments_struct[] = $comment;
+		}
+
+		return $comments_struct;
+	}
+
+	/**
+	 * Remove comment.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return mixed {@link wp_delete_comment()}
+	 */
+	function wp_deleteComment($args) {
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$comment_ID	= (int) $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'moderate_comments' ) )
+			return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
+
+		if ( !current_user_can( 'edit_comment', $comment_ID ) )
+			return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
+
+		do_action('xmlrpc_call', 'wp.deleteComment');
+
+		if ( ! get_comment($comment_ID) )
+			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
+
+		return wp_delete_comment($comment_ID);
+	}
+
+	/**
+	 * Edit comment.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return bool True, on success.
+	 */
+	function wp_editComment($args) {
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$comment_ID	= (int) $args[3];
+		$content_struct = $args[4];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'moderate_comments' ) )
+			return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
+
+		if ( !current_user_can( 'edit_comment', $comment_ID ) )
+			return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
+
+		do_action('xmlrpc_call', 'wp.editComment');
+
+		if ( ! get_comment($comment_ID) )
+			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
+
+		if ( isset($content_struct['status']) ) {
+			$statuses = get_comment_statuses();
+			$statuses = array_keys($statuses);
+
+			if ( ! in_array($content_struct['status'], $statuses) )
+				return new IXR_Error( 401, __( 'Invalid comment status.' ) );
+			$comment_approved = $content_struct['status'];
+		}
+
+		// Do some timestamp voodoo
+		if ( !empty( $content_struct['date_created_gmt'] ) ) {
+			$dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
+			$comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
+			$comment_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
+		}
+
+		if ( isset($content_struct['content']) )
+			$comment_content = $content_struct['content'];
+
+		if ( isset($content_struct['author']) )
+			$comment_author = $content_struct['author'];
+
+		if ( isset($content_struct['author_url']) )
+			$comment_author_url = $content_struct['author_url'];
+
+		if ( isset($content_struct['author_email']) )
+			$comment_author_email = $content_struct['author_email'];
+
+		// We've got all the data -- post it:
+		$comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url');
+
+		$result = wp_update_comment($comment);
+		if ( is_wp_error( $result ) )
+			return new IXR_Error(500, $result->get_error_message());
+
+		if ( !$result )
+			return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.'));
+
+		return true;
+	}
+
+	/**
+	 * Create new comment.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return mixed {@link wp_new_comment()}
+	 */
+	function wp_newComment($args) {
+		global $wpdb;
+
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$post		= $args[3];
+		$content_struct = $args[4];
+
+		$allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false);
+
+		$user = $this->login($username, $password);
+
+		if ( !$user ) {
+			$logged_in = false;
+			if ( $allow_anon && get_option('comment_registration') )
+				return new IXR_Error( 403, __( 'You must be registered to comment' ) );
+			else if ( !$allow_anon )
+				return $this->error;
+		} else {
+			$logged_in = true;
+		}
+
+		if ( is_numeric($post) )
+			$post_id = absint($post);
+		else
+			$post_id = url_to_postid($post);
+
+		if ( ! $post_id )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
+		if ( ! get_post($post_id) )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
+		$comment['comment_post_ID'] = $post_id;
+
+		if ( $logged_in ) {
+			$comment['comment_author'] = $wpdb->escape( $user->display_name );
+			$comment['comment_author_email'] = $wpdb->escape( $user->user_email );
+			$comment['comment_author_url'] = $wpdb->escape( $user->user_url );
+			$comment['user_ID'] = $user->ID;
+		} else {
+			$comment['comment_author'] = '';
+			if ( isset($content_struct['author']) )
+				$comment['comment_author'] = $content_struct['author'];
+
+			$comment['comment_author_email'] = '';
+			if ( isset($content_struct['author_email']) )
+				$comment['comment_author_email'] = $content_struct['author_email'];
+
+			$comment['comment_author_url'] = '';
+			if ( isset($content_struct['author_url']) )
+				$comment['comment_author_url'] = $content_struct['author_url'];
+
+			$comment['user_ID'] = 0;
+
+			if ( get_option('require_name_email') ) {
+				if ( 6 > strlen($comment['comment_author_email']) || '' == $comment['comment_author'] )
+					return new IXR_Error( 403, __( 'Comment author name and email are required' ) );
+				elseif ( !is_email($comment['comment_author_email']) )
+					return new IXR_Error( 403, __( 'A valid email address is required' ) );
+			}
+		}
+
+		$comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0;
+
+		$comment['comment_content'] =  isset($content_struct['content']) ? $content_struct['content'] : null;
+
+		do_action('xmlrpc_call', 'wp.newComment');
+
+		return wp_new_comment($comment);
+	}
+
+	/**
+	 * Retrieve all of the comment status.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getCommentStatusList($args) {
+		$this->escape( $args );
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'moderate_comments' ) )
+			return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
+
+		do_action('xmlrpc_call', 'wp.getCommentStatusList');
+
+		return get_comment_statuses( );
+	}
+
+	/**
+	 * Retrieve comment count.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getCommentCount( $args ) {
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$post_id	= (int) $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_posts' ) )
+			return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) );
+
+		do_action('xmlrpc_call', 'wp.getCommentCount');
+
+		$count = wp_count_comments( $post_id );
+		return array(
+			"approved" => $count->approved,
+			"awaiting_moderation" => $count->moderated,
+			"spam" => $count->spam,
+			"total_comments" => $count->total_comments
+		);
+	}
+
+	/**
+	 * Retrieve post statuses.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getPostStatusList( $args ) {
+		$this->escape( $args );
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_posts' ) )
+			return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
+
+		do_action('xmlrpc_call', 'wp.getPostStatusList');
+
+		return get_post_statuses( );
+	}
+
+	/**
+	 * Retrieve page statuses.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getPageStatusList( $args ) {
+		$this->escape( $args );
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_pages' ) )
+			return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
+
+		do_action('xmlrpc_call', 'wp.getPageStatusList');
+
+		return get_page_statuses( );
+	}
+
+	/**
+	 * Retrieve page templates.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getPageTemplates( $args ) {
+		$this->escape( $args );
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_pages' ) )
+			return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
+
+		$templates = get_page_templates( );
+		$templates['Default'] = 'default';
+
+		return $templates;
+	}
+
+	/**
+	 * Retrieve blog options.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function wp_getOptions( $args ) {
+		$this->escape( $args );
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$options	= isset( $args[3] ) ? (array) $args[3] : array();
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		// If no specific options where asked for, return all of them
+		if ( count( $options ) == 0 )
+			$options = array_keys($this->blog_options);
+
+		return $this->_getOptions($options);
+	}
+
+	/**
+	 * Retrieve blog options value from list.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param array $options Options to retrieve.
+	 * @return array
+	 */
+	function _getOptions($options) {
+		$data = array( );
+		foreach ( $options as $option ) {
+			if ( array_key_exists( $option, $this->blog_options ) ) {
+				$data[$option] = $this->blog_options[$option];
+				//Is the value static or dynamic?
+				if ( isset( $data[$option]['option'] ) ) {
+					$data[$option]['value'] = get_option( $data[$option]['option'] );
+					unset($data[$option]['option']);
+				}
+			}
+		}
+
+		return $data;
+	}
+
+	/**
+	 * Update blog options.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return unknown
+	 */
+	function wp_setOptions( $args ) {
+		$this->escape( $args );
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$options	= (array) $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'manage_options' ) )
+			return new IXR_Error( 403, __( 'You are not allowed to update options.' ) );
+
+		foreach ( $options as $o_name => $o_value ) {
+			$option_names[] = $o_name;
+			if ( !array_key_exists( $o_name, $this->blog_options ) )
+				continue;
+
+			if ( $this->blog_options[$o_name]['readonly'] == true )
+				continue;
+
+			update_option( $this->blog_options[$o_name]['option'], $o_value );
+		}
+
+		//Now return the updated values
+		return $this->_getOptions($option_names);
+	}
+
+	/**
+	 * Retrieve a media item by ID
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param array $args Method parameters. Contains:
+	 *  - blog_id
+	 *  - username
+	 *  - password
+	 *  - attachment_id
+	 * @return array. Assocciative array containing:
+	 *  - 'date_created_gmt'
+	 *  - 'parent'
+	 *  - 'link'
+	 *  - 'thumbnail'
+	 *  - 'title'
+	 *  - 'caption'
+	 *  - 'description'
+	 *  - 'metadata'
+	 */
+	function wp_getMediaItem($args) {
+		$this->escape($args);
+
+		$blog_id		= (int) $args[0];
+		$username		= $args[1];
+		$password		= $args[2];
+		$attachment_id	= (int) $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'upload_files' ) )
+			return new IXR_Error( 403, __( 'You are not allowed to upload files on this site.' ) );
+
+		do_action('xmlrpc_call', 'wp.getMediaItem');
+
+		if ( ! $attachment = get_post($attachment_id) )
+			return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
+
+		// Format page date.
+		$attachment_date = mysql2date("Ymd\TH:i:s", $attachment->post_date, false);
+		$attachment_date_gmt = mysql2date("Ymd\TH:i:s", $attachment->post_date_gmt, false);
+
+		$link = wp_get_attachment_url($attachment->ID);
+		$thumbnail_link = wp_get_attachment_thumb_url($attachment->ID);
+
+		$attachment_struct = array(
+			"date_created_gmt"		=> new IXR_Date($attachment_date_gmt),
+			"parent"				=> $attachment->post_parent,
+			"link"					=> $link,
+			"thumbnail"				=> $thumbnail_link,
+			"title"					=> $attachment->post_title,
+			"caption"				=> $attachment->post_excerpt,
+			"description"			=> $attachment->post_content,
+			"metadata"				=> wp_get_attachment_metadata($attachment->ID),
+		);
+
+		return $attachment_struct;
+	}
+
+	/**
+	 * Retrieves a collection of media library items (or attachments)
+	 *
+	 * Besides the common blog_id, username, and password arguments, it takes a filter
+	 * array as last argument.
+	 *
+	 * Accepted 'filter' keys are 'parent_id', 'mime_type', 'offset', and 'number'.
+	 *
+	 * The defaults are as follows:
+	 * - 'number' - Default is 5. Total number of media items to retrieve.
+	 * - 'offset' - Default is 0. See {@link WP_Query::query()} for more.
+	 * - 'parent_id' - Default is ''. The post where the media item is attached. Empty string shows all media items. 0 shows unattached media items.
+	 * - 'mime_type' - Default is ''. Filter by mime type (e.g., 'image/jpeg', 'application/pdf')
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param array $args Method parameters. Contains:
+	 *  - blog_id
+	 *  - username
+	 *  - password
+	 *  - filter
+	 * @return array. Contains a collection of media items. See {@link wp_xmlrpc_server::wp_getMediaItem()} for a description of each item contents
+	 */
+	function wp_getMediaLibrary($args) {
+		$raw_args = $args;
+		$this->escape($args);
+
+		$blog_id	= (int) $args[0];
+		$username	= $args[1];
+		$password	= $args[2];
+		$struct		= isset( $args[3] ) ? $args[3] : array() ;
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'upload_files' ) )
+			return new IXR_Error( 401, __( 'Sorry, you cannot upload files.' ) );
+
+		do_action('xmlrpc_call', 'wp.getMediaLibrary');
+
+		$parent_id = ( isset($struct['parent_id']) ) ? absint($struct['parent_id']) : '' ;
+		$mime_type = ( isset($struct['mime_type']) ) ? $struct['mime_type'] : '' ;
+		$offset = ( isset($struct['offset']) ) ? absint($struct['offset']) : 0 ;
+		$number = ( isset($struct['number']) ) ? absint($struct['number']) : -1 ;
+
+		$attachments = get_posts( array('post_type' => 'attachment', 'post_parent' => $parent_id, 'offset' => $offset, 'numberposts' => $number, 'post_mime_type' => $mime_type ) );
+		$num_attachments = count($attachments);
+
+		if ( ! $num_attachments )
+			return array();
+
+		$attachments_struct = array();
+
+		foreach ($attachments as $attachment )
+			$attachments_struct[] = $this->wp_getMediaItem( array( $raw_args[0], $raw_args[1], $raw_args[2], $attachment->ID ) );
+
+		return $attachments_struct;
+	}
+
+	/**
+	  * Retrives a list of post formats used by the site
+	  *
+	  * @since 3.1
+	  *
+	  * @param array $args Method parameters. Contains:
+	  *  - blog_id
+	  *  - username
+	  *  - password
+	  * @return array
+	  */
+	function wp_getPostFormats( $args ) {
+		$this->escape( $args );
+
+		$blog_id = (int) $args[0];
+		$username = $args[1];
+		$password = $args[2];
+
+		if ( !$user = $this->login( $username, $password ) )
+			return $this->error;
+
+		do_action( 'xmlrpc_call', 'wp.getPostFormats' );
+		return get_post_format_strings();
+	}
+
+	/* Blogger API functions.
+	 * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
+	 */
+
+	/**
+	 * Retrieve blogs that user owns.
+	 *
+	 * Will make more sense once we support multiple blogs.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function blogger_getUsersBlogs($args) {
+		if ( is_multisite() )
+			return $this->_multisite_getUsersBlogs($args);
+
+		$this->escape($args);
+
+		$username = $args[1];
+		$password  = $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'blogger.getUsersBlogs');
+
+		$is_admin = current_user_can('manage_options');
+
+		$struct = array(
+			'isAdmin'  => $is_admin,
+			'url'      => get_option('home') . '/',
+			'blogid'   => '1',
+			'blogName' => get_option('blogname'),
+			'xmlrpc'   => site_url( 'xmlrpc.php' )
+		);
+
+		return array($struct);
+	}
+
+	/**
+	 * Private function for retrieving a users blogs for multisite setups
+	 *
+	 * @access protected
+	 */
+	function _multisite_getUsersBlogs($args) {
+		global $current_blog;
+		$domain = $current_blog->domain;
+		$path = $current_blog->path . 'xmlrpc.php';
+		$protocol = is_ssl() ? 'https' : 'http';
+
+		$rpc = new IXR_Client("$protocol://{$domain}{$path}");
+		$rpc->query('wp.getUsersBlogs', $args[1], $args[2]);
+		$blogs = $rpc->getResponse();
+
+		if ( isset($blogs['faultCode']) )
+			return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
+
+		if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) {
+			return $blogs;
+		} else {
+			foreach ( (array) $blogs as $blog ) {
+				if ( strpos($blog['url'], $_SERVER['HTTP_HOST']) )
+					return array($blog);
+			}
+			return array();
+		}
+	}
+
+	/**
+	 * Retrieve user's data.
+	 *
+	 * Gives your client some info about you, so you don't have to.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function blogger_getUserInfo($args) {
+
+		$this->escape($args);
+
+		$username = $args[1];
+		$password  = $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_posts' ) )
+			return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) );
+
+		do_action('xmlrpc_call', 'blogger.getUserInfo');
+
+		$struct = array(
+			'nickname'  => $user->nickname,
+			'userid'    => $user->ID,
+			'url'       => $user->user_url,
+			'lastname'  => $user->last_name,
+			'firstname' => $user->first_name
+		);
+
+		return $struct;
+	}
+
+	/**
+	 * Retrieve post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function blogger_getPost($args) {
+
+		$this->escape($args);
+
+		$post_ID    = (int) $args[1];
+		$username = $args[2];
+		$password  = $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_post', $post_ID ) )
+			return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
+
+		do_action('xmlrpc_call', 'blogger.getPost');
+
+		$post_data = wp_get_single_post($post_ID, ARRAY_A);
+
+		$categories = implode(',', wp_get_post_categories($post_ID));
+
+		$content  = '<title>'.stripslashes($post_data['post_title']).'</title>';
+		$content .= '<category>'.$categories.'</category>';
+		$content .= stripslashes($post_data['post_content']);
+
+		$struct = array(
+			'userid'    => $post_data['post_author'],
+			'dateCreated' => new IXR_Date(mysql2date('Ymd\TH:i:s', $post_data['post_date'], false)),
+			'content'     => $content,
+			'postid'  => (string) $post_data['ID']
+		);
+
+		return $struct;
+	}
+
+	/**
+	 * Retrieve list of recent posts.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function blogger_getRecentPosts($args) {
+
+		$this->escape($args);
+
+		// $args[0] = appkey - ignored
+		$blog_ID    = (int) $args[1]; /* though we don't use it yet */
+		$username = $args[2];
+		$password  = $args[3];
+		if ( isset( $args[4] ) )
+			$query = array( 'numberposts' => absint( $args[4] ) );
+		else
+			$query = array();
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'blogger.getRecentPosts');
+
+		$posts_list = wp_get_recent_posts( $query );
+
+		if ( !$posts_list ) {
+			$this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
+			return $this->error;
+		}
+
+		foreach ($posts_list as $entry) {
+			if ( !current_user_can( 'edit_post', $entry['ID'] ) )
+				continue;
+
+			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
+			$categories = implode(',', wp_get_post_categories($entry['ID']));
+
+			$content  = '<title>'.stripslashes($entry['post_title']).'</title>';
+			$content .= '<category>'.$categories.'</category>';
+			$content .= stripslashes($entry['post_content']);
+
+			$struct[] = array(
+				'userid' => $entry['post_author'],
+				'dateCreated' => new IXR_Date($post_date),
+				'content' => $content,
+				'postid' => (string) $entry['ID'],
+			);
+
+		}
+
+		$recent_posts = array();
+		for ( $j=0; $j<count($struct); $j++ ) {
+			array_push($recent_posts, $struct[$j]);
+		}
+
+		return $recent_posts;
+	}
+
+	/**
+	 * Retrieve blog_filename content.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return string
+	 */
+	function blogger_getTemplate($args) {
+
+		$this->escape($args);
+
+		$blog_ID    = (int) $args[1];
+		$username = $args[2];
+		$password  = $args[3];
+		$template   = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'blogger.getTemplate');
+
+		if ( !current_user_can('edit_themes') )
+			return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
+
+		/* warning: here we make the assumption that the blog's URL is on the same server */
+		$filename = get_option('home') . '/';
+		$filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
+
+		$f = fopen($filename, 'r');
+		$content = fread($f, filesize($filename));
+		fclose($f);
+
+		/* so it is actually editable with a windows/mac client */
+		// FIXME: (or delete me) do we really want to cater to bad clients at the expense of good ones by BEEPing up their line breaks? commented.     $content = str_replace("\n", "\r\n", $content);
+
+		return $content;
+	}
+
+	/**
+	 * Updates the content of blog_filename.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return bool True when done.
+	 */
+	function blogger_setTemplate($args) {
+
+		$this->escape($args);
+
+		$blog_ID    = (int) $args[1];
+		$username = $args[2];
+		$password  = $args[3];
+		$content    = $args[4];
+		$template   = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'blogger.setTemplate');
+
+		if ( !current_user_can('edit_themes') )
+			return new IXR_Error(401, __('Sorry, this user cannot edit the template.'));
+
+		/* warning: here we make the assumption that the blog's URL is on the same server */
+		$filename = get_option('home') . '/';
+		$filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
+
+		if ($f = fopen($filename, 'w+')) {
+			fwrite($f, $content);
+			fclose($f);
+		} else {
+			return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.'));
+		}
+
+		return true;
+	}
+
+	/**
+	 * Create new post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return int
+	 */
+	function blogger_newPost($args) {
+
+		$this->escape($args);
+
+		$blog_ID    = (int) $args[1]; /* though we don't use it yet */
+		$username = $args[2];
+		$password  = $args[3];
+		$content    = $args[4];
+		$publish    = $args[5];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'blogger.newPost');
+
+		$cap = ($publish) ? 'publish_posts' : 'edit_posts';
+		if ( !current_user_can($cap) )
+			return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.'));
+
+		$post_status = ($publish) ? 'publish' : 'draft';
+
+		$post_author = $user->ID;
+
+		$post_title = xmlrpc_getposttitle($content);
+		$post_category = xmlrpc_getpostcategory($content);
+		$post_content = xmlrpc_removepostdata($content);
+
+		$post_date = current_time('mysql');
+		$post_date_gmt = current_time('mysql', 1);
+
+		$post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status');
+
+		$post_ID = wp_insert_post($post_data);
+		if ( is_wp_error( $post_ID ) )
+			return new IXR_Error(500, $post_ID->get_error_message());
+
+		if ( !$post_ID )
+			return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
+
+		$this->attach_uploads( $post_ID, $post_content );
+
+		logIO('O', "Posted ! ID: $post_ID");
+
+		return $post_ID;
+	}
+
+	/**
+	 * Edit a post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return bool true when done.
+	 */
+	function blogger_editPost($args) {
+
+		$this->escape($args);
+
+		$post_ID     = (int) $args[1];
+		$username  = $args[2];
+		$password   = $args[3];
+		$content     = $args[4];
+		$publish     = $args[5];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'blogger.editPost');
+
+		$actual_post = wp_get_single_post($post_ID,ARRAY_A);
+
+		if ( !$actual_post || $actual_post['post_type'] != 'post' )
+			return new IXR_Error(404, __('Sorry, no such post.'));
+
+		$this->escape($actual_post);
+
+		if ( !current_user_can('edit_post', $post_ID) )
+			return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
+
+		extract($actual_post, EXTR_SKIP);
+
+		if ( ('publish' == $post_status) && !current_user_can('publish_posts') )
+			return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
+
+		$post_title = xmlrpc_getposttitle($content);
+		$post_category = xmlrpc_getpostcategory($content);
+		$post_content = xmlrpc_removepostdata($content);
+
+		$postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');
+
+		$result = wp_update_post($postdata);
+
+		if ( !$result )
+			return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.'));
+
+		$this->attach_uploads( $ID, $post_content );
+
+		return true;
+	}
+
+	/**
+	 * Remove a post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return bool True when post is deleted.
+	 */
+	function blogger_deletePost($args) {
+		$this->escape($args);
+
+		$post_ID     = (int) $args[1];
+		$username  = $args[2];
+		$password   = $args[3];
+		$publish     = $args[4];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'blogger.deletePost');
+
+		$actual_post = wp_get_single_post($post_ID,ARRAY_A);
+
+		if ( !$actual_post || $actual_post['post_type'] != 'post' )
+			return new IXR_Error(404, __('Sorry, no such post.'));
+
+		if ( !current_user_can('delete_post', $post_ID) )
+			return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));
+
+		$result = wp_delete_post($post_ID);
+
+		if ( !$result )
+			return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.'));
+
+		return true;
+	}
+
+	/* MetaWeblog API functions
+	 * specs on wherever Dave Winer wants them to be
+	 */
+
+	/**
+	 * Create a new post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return int
+	 */
+	function mw_newPost($args) {
+		$this->escape($args);
+
+		$blog_ID     = (int) $args[0]; // we will support this in the near future
+		$username  = $args[1];
+		$password   = $args[2];
+		$content_struct = $args[3];
+		$publish     = isset( $args[4] ) ? $args[4] : 0;
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'metaWeblog.newPost');
+
+		$page_template = '';
+		if ( !empty( $content_struct['post_type'] ) ) {
+			if ( $content_struct['post_type'] == 'page' ) {
+				if ( $publish )
+					$cap  = 'publish_pages';
+				elseif ('publish' == $content_struct['page_status'])
+					$cap  = 'publish_pages';
+				else
+					$cap = 'edit_pages';
+				$error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
+				$post_type = 'page';
+				if ( !empty( $content_struct['wp_page_template'] ) )
+					$page_template = $content_struct['wp_page_template'];
+			} elseif ( $content_struct['post_type'] == 'post' ) {
+				if ( $publish )
+					$cap  = 'publish_posts';
+				elseif ('publish' == $content_struct['post_status'])
+					$cap  = 'publish_posts';
+				else
+					$cap = 'edit_posts';
+				$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
+				$post_type = 'post';
+			} else {
+				// No other post_type values are allowed here
+				return new IXR_Error( 401, __( 'Invalid post type.' ) );
+			}
+		} else {
+			if ( $publish )
+				$cap  = 'publish_posts';
+			elseif ('publish' == $content_struct['post_status'])
+				$cap  = 'publish_posts';
+			else
+				$cap = 'edit_posts';
+			$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
+			$post_type = 'post';
+		}
+
+		if ( !current_user_can( $cap ) )
+			return new IXR_Error( 401, $error_message );
+
+		// Check for a valid post format if one was given
+		if ( isset( $content_struct['wp_post_format'] ) ) {
+			$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
+			if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
+				return new IXR_Error( 404, __( 'Invalid post format' ) );
+			}
+		}
+
+		// Let WordPress generate the post_name (slug) unless
+		// one has been provided.
+		$post_name = "";
+		if ( isset($content_struct["wp_slug"]) )
+			$post_name = $content_struct["wp_slug"];
+
+		// Only use a password if one was given.
+		if ( isset($content_struct["wp_password"]) )
+			$post_password = $content_struct["wp_password"];
+
+		// Only set a post parent if one was provided.
+		if ( isset($content_struct["wp_page_parent_id"]) )
+			$post_parent = $content_struct["wp_page_parent_id"];
+
+		// Only set the menu_order if it was provided.
+		if ( isset($content_struct["wp_page_order"]) )
+			$menu_order = $content_struct["wp_page_order"];
+
+		$post_author = $user->ID;
+
+		// If an author id was provided then use it instead.
+		if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
+			switch ( $post_type ) {
+				case "post":
+					if ( !current_user_can("edit_others_posts") )
+						return(new IXR_Error(401, __("You are not allowed to post as this user")));
+					break;
+				case "page":
+					if ( !current_user_can("edit_others_pages") )
+						return(new IXR_Error(401, __("You are not allowed to create pages as this user")));
+					break;
+				default:
+					return(new IXR_Error(401, __("Invalid post type.")));
+					break;
+			}
+			$post_author = $content_struct["wp_author_id"];
+		}
+
+		$post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : null;
+		$post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : null;
+
+		$post_status = $publish ? 'publish' : 'draft';
+
+		if ( isset( $content_struct["{$post_type}_status"] ) ) {
+			switch ( $content_struct["{$post_type}_status"] ) {
+				case 'draft':
+				case 'private':
+				case 'publish':
+					$post_status = $content_struct["{$post_type}_status"];
+					break;
+				case 'pending':
+					// Pending is only valid for posts, not pages.
+					if ( $post_type === 'post' )
+						$post_status = $content_struct["{$post_type}_status"];
+					break;
+				default:
+					$post_status = $publish ? 'publish' : 'draft';
+					break;
+			}
+		}
+
+		$post_excerpt = isset($content_struct['mt_excerpt']) ? $content_struct['mt_excerpt'] : null;
+		$post_more = isset($content_struct['mt_text_more']) ? $content_struct['mt_text_more'] : null;
+
+		$tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null;
+
+		if ( isset($content_struct["mt_allow_comments"]) ) {
+			if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
+				switch ( $content_struct["mt_allow_comments"] ) {
+					case "closed":
+						$comment_status = "closed";
+						break;
+					case "open":
+						$comment_status = "open";
+						break;
+					default:
+						$comment_status = get_option("default_comment_status");
+						break;
+				}
+			} else {
+				switch ( (int) $content_struct["mt_allow_comments"] ) {
+					case 0:
+					case 2:
+						$comment_status = "closed";
+						break;
+					case 1:
+						$comment_status = "open";
+						break;
+					default:
+						$comment_status = get_option("default_comment_status");
+						break;
+				}
+			}
+		} else {
+			$comment_status = get_option("default_comment_status");
+		}
+
+		if ( isset($content_struct["mt_allow_pings"]) ) {
+			if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
+				switch ( $content_struct['mt_allow_pings'] ) {
+					case "closed":
+						$ping_status = "closed";
+						break;
+					case "open":
+						$ping_status = "open";
+						break;
+					default:
+						$ping_status = get_option("default_ping_status");
+						break;
+				}
+			} else {
+				switch ( (int) $content_struct["mt_allow_pings"] ) {
+					case 0:
+						$ping_status = "closed";
+						break;
+					case 1:
+						$ping_status = "open";
+						break;
+					default:
+						$ping_status = get_option("default_ping_status");
+						break;
+				}
+			}
+		} else {
+			$ping_status = get_option("default_ping_status");
+		}
+
+		if ( $post_more )
+			$post_content = $post_content . "<!--more-->" . $post_more;
+
+		$to_ping = null;
+		if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
+			$to_ping = $content_struct['mt_tb_ping_urls'];
+			if ( is_array($to_ping) )
+				$to_ping = implode(' ', $to_ping);
+		}
+
+		// Do some timestamp voodoo
+		if ( !empty( $content_struct['date_created_gmt'] ) )
+			$dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
+		elseif ( !empty( $content_struct['dateCreated']) )
+			$dateCreated = $content_struct['dateCreated']->getIso();
+
+		if ( !empty( $dateCreated ) ) {
+			$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
+			$post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
+		} else {
+			$post_date = current_time('mysql');
+			$post_date_gmt = current_time('mysql', 1);
+		}
+
+		$post_category = array();
+		if ( isset( $content_struct['categories'] ) ) {
+			$catnames = $content_struct['categories'];
+			logIO('O', 'Post cats: ' . var_export($catnames,true));
+
+			if ( is_array($catnames) ) {
+				foreach ($catnames as $cat) {
+					$post_category[] = get_cat_ID($cat);
+				}
+			}
+		}
+
+		// We've got all the data -- post it:
+		$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template');
+
+		$post_ID = wp_insert_post($postdata, true);
+		if ( is_wp_error( $post_ID ) )
+			return new IXR_Error(500, $post_ID->get_error_message());
+
+		if ( !$post_ID )
+			return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
+
+		// Only posts can be sticky
+		if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
+			if ( $content_struct['sticky'] == true )
+				stick_post( $post_ID );
+			elseif ( $content_struct['sticky'] == false )
+				unstick_post( $post_ID );
+		}
+
+		if ( isset($content_struct['custom_fields']) )
+			$this->set_custom_fields($post_ID, $content_struct['custom_fields']);
+
+		// Handle enclosures
+		$thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null;
+		$this->add_enclosure_if_new($post_ID, $thisEnclosure);
+
+		$this->attach_uploads( $post_ID, $post_content );
+
+		// Handle post formats if assigned, value is validated earlier
+		// in this function
+		if ( isset( $content_struct['wp_post_format'] ) )
+			wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' );
+
+		logIO('O', "Posted ! ID: $post_ID");
+
+		return strval($post_ID);
+	}
+
+	function add_enclosure_if_new($post_ID, $enclosure) {
+		if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
+
+			$encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'];
+			$found = false;
+			foreach ( (array) get_post_custom($post_ID) as $key => $val) {
+				if ($key == 'enclosure') {
+					foreach ( (array) $val as $enc ) {
+						if ($enc == $encstring) {
+							$found = true;
+							break 2;
+						}
+					}
+				}
+			}
+			if (!$found)
+				add_post_meta( $post_ID, 'enclosure', $encstring );
+		}
+	}
+
+	/**
+	 * Attach upload to a post.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param int $post_ID Post ID.
+	 * @param string $post_content Post Content for attachment.
+	 */
+	function attach_uploads( $post_ID, $post_content ) {
+		global $wpdb;
+
+		// find any unattached files
+		$attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
+		if ( is_array( $attachments ) ) {
+			foreach ( $attachments as $file ) {
+				if ( strpos( $post_content, $file->guid ) !== false )
+					$wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) );
+			}
+		}
+	}
+
+	/**
+	 * Edit a post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return bool True on success.
+	 */
+	function mw_editPost($args) {
+
+		$this->escape($args);
+
+		$post_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+		$content_struct = $args[3];
+		$publish     = $args[4];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'metaWeblog.editPost');
+
+		$cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
+		$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
+		$post_type = 'post';
+		$page_template = '';
+		if ( !empty( $content_struct['post_type'] ) ) {
+			if ( $content_struct['post_type'] == 'page' ) {
+				if ( $publish || 'publish' == $content_struct['page_status'] )
+					$cap  = 'publish_pages';
+				else
+					$cap = 'edit_pages';
+				$error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
+				$post_type = 'page';
+				if ( !empty( $content_struct['wp_page_template'] ) )
+					$page_template = $content_struct['wp_page_template'];
+			} elseif ( $content_struct['post_type'] == 'post' ) {
+				if ( $publish || 'publish' == $content_struct['post_status'] )
+					$cap  = 'publish_posts';
+				else
+					$cap = 'edit_posts';
+				$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
+				$post_type = 'post';
+			} else {
+				// No other post_type values are allowed here
+				return new IXR_Error( 401, __( 'Invalid post type.' ) );
+			}
+		} else {
+			if ( $publish || 'publish' == $content_struct['post_status'] )
+				$cap  = 'publish_posts';
+			else
+				$cap = 'edit_posts';
+			$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
+			$post_type = 'post';
+		}
+
+		if ( !current_user_can( $cap ) )
+			return new IXR_Error( 401, $error_message );
+
+		// Check for a valid post format if one was given
+		if ( isset( $content_struct['wp_post_format'] ) ) {
+			$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
+			if ( !array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
+				return new IXR_Error( 404, __( 'Invalid post format' ) );
+			}
+		}
+
+		$postdata = wp_get_single_post($post_ID, ARRAY_A);
+
+		// If there is no post data for the give post id, stop
+		// now and return an error.  Other wise a new post will be
+		// created (which was the old behavior).
+		if ( empty($postdata["ID"]) )
+			return(new IXR_Error(404, __("Invalid post ID.")));
+
+		$this->escape($postdata);
+		extract($postdata, EXTR_SKIP);
+
+		// Let WordPress manage slug if none was provided.
+		$post_name = "";
+		if ( isset($content_struct["wp_slug"]) )
+			$post_name = $content_struct["wp_slug"];
+
+		// Only use a password if one was given.
+		if ( isset($content_struct["wp_password"]) )
+			$post_password = $content_struct["wp_password"];
+
+		// Only set a post parent if one was given.
+		if ( isset($content_struct["wp_page_parent_id"]) )
+			$post_parent = $content_struct["wp_page_parent_id"];
+
+		// Only set the menu_order if it was given.
+		if ( isset($content_struct["wp_page_order"]) )
+			$menu_order = $content_struct["wp_page_order"];
+
+		$post_author = $postdata["post_author"];
+
+		// Only set the post_author if one is set.
+		if ( isset($content_struct["wp_author_id"]) && ($user->ID != $content_struct["wp_author_id"]) ) {
+			switch ( $post_type ) {
+				case "post":
+					if ( !current_user_can("edit_others_posts") )
+						return(new IXR_Error(401, __("You are not allowed to change the post author as this user.")));
+					break;
+				case "page":
+					if ( !current_user_can("edit_others_pages") )
+						return(new IXR_Error(401, __("You are not allowed to change the page author as this user.")));
+					break;
+				default:
+					return(new IXR_Error(401, __("Invalid post type.")));
+					break;
+			}
+			$post_author = $content_struct["wp_author_id"];
+		}
+
+		if ( isset($content_struct["mt_allow_comments"]) ) {
+			if ( !is_numeric($content_struct["mt_allow_comments"]) ) {
+				switch ( $content_struct["mt_allow_comments"] ) {
+					case "closed":
+						$comment_status = "closed";
+						break;
+					case "open":
+						$comment_status = "open";
+						break;
+					default:
+						$comment_status = get_option("default_comment_status");
+						break;
+				}
+			} else {
+				switch ( (int) $content_struct["mt_allow_comments"] ) {
+					case 0:
+					case 2:
+						$comment_status = "closed";
+						break;
+					case 1:
+						$comment_status = "open";
+						break;
+					default:
+						$comment_status = get_option("default_comment_status");
+						break;
+				}
+			}
+		}
+
+		if ( isset($content_struct["mt_allow_pings"]) ) {
+			if ( !is_numeric($content_struct["mt_allow_pings"]) ) {
+				switch ( $content_struct["mt_allow_pings"] ) {
+					case "closed":
+						$ping_status = "closed";
+						break;
+					case "open":
+						$ping_status = "open";
+						break;
+					default:
+						$ping_status = get_option("default_ping_status");
+						break;
+				}
+			} else {
+				switch ( (int) $content_struct["mt_allow_pings"] ) {
+					case 0:
+						$ping_status = "closed";
+						break;
+					case 1:
+						$ping_status = "open";
+						break;
+					default:
+						$ping_status = get_option("default_ping_status");
+						break;
+				}
+			}
+		}
+
+		$post_title = isset( $content_struct['title'] ) ? $content_struct['title'] : null;
+		$post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : null;
+
+		$post_category = array();
+		if ( isset( $content_struct['categories'] ) ) {
+			$catnames = $content_struct['categories'];
+			if ( is_array($catnames) ) {
+				foreach ($catnames as $cat) {
+					$post_category[] = get_cat_ID($cat);
+				}
+			}
+		}
+
+		$post_excerpt = isset( $content_struct['mt_excerpt'] ) ? $content_struct['mt_excerpt'] : null;
+		$post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : null;
+
+		$post_status = $publish ? 'publish' : 'draft';
+		if ( isset( $content_struct["{$post_type}_status"] ) ) {
+			switch( $content_struct["{$post_type}_status"] ) {
+				case 'draft':
+				case 'private':
+				case 'publish':
+					$post_status = $content_struct["{$post_type}_status"];
+					break;
+				case 'pending':
+					// Pending is only valid for posts, not pages.
+					if ( $post_type === 'post' )
+						$post_status = $content_struct["{$post_type}_status"];
+					break;
+				default:
+					$post_status = $publish ? 'publish' : 'draft';
+					break;
+			}
+		}
+
+		$tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : null;
+
+		if ( ('publish' == $post_status) ) {
+			if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') )
+				return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.'));
+			else if ( !current_user_can('publish_posts') )
+				return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
+		}
+
+		if ( $post_more )
+			$post_content = $post_content . "<!--more-->" . $post_more;
+
+		$to_ping = null;
+		if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
+			$to_ping = $content_struct['mt_tb_ping_urls'];
+			if ( is_array($to_ping) )
+				$to_ping = implode(' ', $to_ping);
+		}
+
+		// Do some timestamp voodoo
+		if ( !empty( $content_struct['date_created_gmt'] ) )
+			$dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
+		elseif ( !empty( $content_struct['dateCreated']) )
+			$dateCreated = $content_struct['dateCreated']->getIso();
+
+		if ( !empty( $dateCreated ) ) {
+			$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
+			$post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
+		} else {
+			$post_date     = $postdata['post_date'];
+			$post_date_gmt = $postdata['post_date_gmt'];
+		}
+
+		// We've got all the data -- post it:
+		$newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template');
+
+		$result = wp_update_post($newpost, true);
+		if ( is_wp_error( $result ) )
+			return new IXR_Error(500, $result->get_error_message());
+
+		if ( !$result )
+			return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
+
+		// Only posts can be sticky
+		if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
+			if ( $content_struct['sticky'] == true )
+				stick_post( $post_ID );
+			elseif ( $content_struct['sticky'] == false )
+				unstick_post( $post_ID );
+		}
+
+		if ( isset($content_struct['custom_fields']) )
+			$this->set_custom_fields($post_ID, $content_struct['custom_fields']);
+
+		// Handle enclosures
+		$thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null;
+		$this->add_enclosure_if_new($post_ID, $thisEnclosure);
+
+		$this->attach_uploads( $ID, $post_content );
+
+		// Handle post formats if assigned, validation is handled
+		// earlier in this function
+		if ( isset( $content_struct['wp_post_format'] ) )
+			wp_set_post_terms( $post_ID, array( 'post-format-' . $content_struct['wp_post_format'] ), 'post_format' );
+
+		logIO('O',"(MW) Edited ! ID: $post_ID");
+
+		return true;
+	}
+
+	/**
+	 * Retrieve post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mw_getPost($args) {
+
+		$this->escape($args);
+
+		$post_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_post', $post_ID ) )
+			return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
+
+		do_action('xmlrpc_call', 'metaWeblog.getPost');
+
+		$postdata = wp_get_single_post($post_ID, ARRAY_A);
+
+		if ($postdata['post_date'] != '') {
+			$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date'], false);
+			$post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt'], false);
+
+			// For drafts use the GMT version of the post date
+			if ( $postdata['post_status'] == 'draft' )
+				$post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $postdata['post_date'] ), 'Ymd\TH:i:s' );
+
+			$categories = array();
+			$catids = wp_get_post_categories($post_ID);
+			foreach($catids as $catid)
+				$categories[] = get_cat_name($catid);
+
+			$tagnames = array();
+			$tags = wp_get_post_tags( $post_ID );
+			if ( !empty( $tags ) ) {
+				foreach ( $tags as $tag )
+					$tagnames[] = $tag->name;
+				$tagnames = implode( ', ', $tagnames );
+			} else {
+				$tagnames = '';
+			}
+
+			$post = get_extended($postdata['post_content']);
+			$link = post_permalink($postdata['ID']);
+
+			// Get the author info.
+			$author = get_userdata($postdata['post_author']);
+
+			$allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0;
+			$allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0;
+
+			// Consider future posts as published
+			if ( $postdata['post_status'] === 'future' )
+				$postdata['post_status'] = 'publish';
+
+			// Get post format
+			$post_format = get_post_format( $post_ID );
+			if ( empty( $post_format ) )
+				$post_format = 'standard';
+
+			$sticky = false;
+			if ( is_sticky( $post_ID ) )
+				$sticky = true;
+
+			$enclosure = array();
+			foreach ( (array) get_post_custom($post_ID) as $key => $val) {
+				if ($key == 'enclosure') {
+					foreach ( (array) $val as $enc ) {
+						$encdata = split("\n", $enc);
+						$enclosure['url'] = trim(htmlspecialchars($encdata[0]));
+						$enclosure['length'] = (int) trim($encdata[1]);
+						$enclosure['type'] = trim($encdata[2]);
+						break 2;
+					}
+				}
+			}
+
+			$resp = array(
+				'dateCreated' => new IXR_Date($post_date),
+				'userid' => $postdata['post_author'],
+				'postid' => $postdata['ID'],
+				'description' => $post['main'],
+				'title' => $postdata['post_title'],
+				'link' => $link,
+				'permaLink' => $link,
+				// commented out because no other tool seems to use this
+				//	      'content' => $entry['post_content'],
+				'categories' => $categories,
+				'mt_excerpt' => $postdata['post_excerpt'],
+				'mt_text_more' => $post['extended'],
+				'mt_allow_comments' => $allow_comments,
+				'mt_allow_pings' => $allow_pings,
+				'mt_keywords' => $tagnames,
+				'wp_slug' => $postdata['post_name'],
+				'wp_password' => $postdata['post_password'],
+				'wp_author_id' => $author->ID,
+				'wp_author_display_name'	=> $author->display_name,
+				'date_created_gmt' => new IXR_Date($post_date_gmt),
+				'post_status' => $postdata['post_status'],
+				'custom_fields' => $this->get_custom_fields($post_ID),
+				'wp_post_format' => $post_format,
+				'sticky' => $sticky
+			);
+
+			if ( !empty($enclosure) ) $resp['enclosure'] = $enclosure;
+
+			return $resp;
+		} else {
+			return new IXR_Error(404, __('Sorry, no such post.'));
+		}
+	}
+
+	/**
+	 * Retrieve list of recent posts.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mw_getRecentPosts($args) {
+
+		$this->escape($args);
+
+		$blog_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+		if ( isset( $args[3] ) )
+			$query = array( 'numberposts' => absint( $args[3] ) );
+		else
+			$query = array();
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'metaWeblog.getRecentPosts');
+
+		$posts_list = wp_get_recent_posts( $query );
+
+		if ( !$posts_list )
+			return array( );
+
+		foreach ($posts_list as $entry) {
+			if ( !current_user_can( 'edit_post', $entry['ID'] ) )
+				continue;
+
+			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
+			$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
+
+			// For drafts use the GMT version of the date
+			if ( $entry['post_status'] == 'draft' )
+				$post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
+
+			$categories = array();
+			$catids = wp_get_post_categories($entry['ID']);
+			foreach( $catids as $catid )
+				$categories[] = get_cat_name($catid);
+
+			$tagnames = array();
+			$tags = wp_get_post_tags( $entry['ID'] );
+			if ( !empty( $tags ) ) {
+				foreach ( $tags as $tag ) {
+					$tagnames[] = $tag->name;
+				}
+				$tagnames = implode( ', ', $tagnames );
+			} else {
+				$tagnames = '';
+			}
+
+			$post = get_extended($entry['post_content']);
+			$link = post_permalink($entry['ID']);
+
+			// Get the post author info.
+			$author = get_userdata($entry['post_author']);
+
+			$allow_comments = ('open' == $entry['comment_status']) ? 1 : 0;
+			$allow_pings = ('open' == $entry['ping_status']) ? 1 : 0;
+
+			// Consider future posts as published
+			if ( $entry['post_status'] === 'future' )
+				$entry['post_status'] = 'publish';
+
+			// Get post format
+			$post_format = get_post_format( $entry['ID'] );
+			if ( empty( $post_format ) )
+				$post_format = 'standard';
+
+			$struct[] = array(
+				'dateCreated' => new IXR_Date($post_date),
+				'userid' => $entry['post_author'],
+				'postid' => (string) $entry['ID'],
+				'description' => $post['main'],
+				'title' => $entry['post_title'],
+				'link' => $link,
+				'permaLink' => $link,
+				// commented out because no other tool seems to use this
+				// 'content' => $entry['post_content'],
+				'categories' => $categories,
+				'mt_excerpt' => $entry['post_excerpt'],
+				'mt_text_more' => $post['extended'],
+				'mt_allow_comments' => $allow_comments,
+				'mt_allow_pings' => $allow_pings,
+				'mt_keywords' => $tagnames,
+				'wp_slug' => $entry['post_name'],
+				'wp_password' => $entry['post_password'],
+				'wp_author_id' => $author->ID,
+				'wp_author_display_name' => $author->display_name,
+				'date_created_gmt' => new IXR_Date($post_date_gmt),
+				'post_status' => $entry['post_status'],
+				'custom_fields' => $this->get_custom_fields($entry['ID']),
+				'wp_post_format' => $post_format
+			);
+
+		}
+
+		$recent_posts = array();
+		for ( $j=0; $j<count($struct); $j++ ) {
+			array_push($recent_posts, $struct[$j]);
+		}
+
+		return $recent_posts;
+	}
+
+	/**
+	 * Retrieve the list of categories on a given blog.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mw_getCategories($args) {
+
+		$this->escape($args);
+
+		$blog_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_posts' ) )
+			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
+
+		do_action('xmlrpc_call', 'metaWeblog.getCategories');
+
+		$categories_struct = array();
+
+		if ( $cats = get_categories(array('get' => 'all')) ) {
+			foreach ( $cats as $cat ) {
+				$struct['categoryId'] = $cat->term_id;
+				$struct['parentId'] = $cat->parent;
+				$struct['description'] = $cat->name;
+				$struct['categoryDescription'] = $cat->description;
+				$struct['categoryName'] = $cat->name;
+				$struct['htmlUrl'] = esc_html(get_category_link($cat->term_id));
+				$struct['rssUrl'] = esc_html(get_category_feed_link($cat->term_id, 'rss2'));
+
+				$categories_struct[] = $struct;
+			}
+		}
+
+		return $categories_struct;
+	}
+
+	/**
+	 * Uploads a file, following your settings.
+	 *
+	 * Adapted from a patch by Johann Richard.
+	 *
+	 * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mw_newMediaObject($args) {
+		global $wpdb;
+
+		$blog_ID     = (int) $args[0];
+		$username  = $wpdb->escape($args[1]);
+		$password   = $wpdb->escape($args[2]);
+		$data        = $args[3];
+
+		$name = sanitize_file_name( $data['name'] );
+		$type = $data['type'];
+		$bits = $data['bits'];
+
+		logIO('O', '(MW) Received '.strlen($bits).' bytes');
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'metaWeblog.newMediaObject');
+
+		if ( !current_user_can('upload_files') ) {
+			logIO('O', '(MW) User does not have upload_files capability');
+			$this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.'));
+			return $this->error;
+		}
+
+		if ( $upload_err = apply_filters( "pre_upload_error", false ) )
+			return new IXR_Error(500, $upload_err);
+
+		if ( !empty($data["overwrite"]) && ($data["overwrite"] == true) ) {
+			// Get postmeta info on the object.
+			$old_file = $wpdb->get_row("
+				SELECT ID
+				FROM {$wpdb->posts}
+				WHERE post_title = '{$name}'
+					AND post_type = 'attachment'
+			");
+
+			// Delete previous file.
+			wp_delete_attachment($old_file->ID);
+
+			// Make sure the new name is different by pre-pending the
+			// previous post id.
+			$filename = preg_replace("/^wpid\d+-/", "", $name);
+			$name = "wpid{$old_file->ID}-{$filename}";
+		}
+
+		$upload = wp_upload_bits($name, NULL, $bits);
+		if ( ! empty($upload['error']) ) {
+			$errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);
+			logIO('O', '(MW) ' . $errorString);
+			return new IXR_Error(500, $errorString);
+		}
+		// Construct the attachment array
+		// attach to post_id 0
+		$post_id = 0;
+		$attachment = array(
+			'post_title' => $name,
+			'post_content' => '',
+			'post_type' => 'attachment',
+			'post_parent' => $post_id,
+			'post_mime_type' => $type,
+			'guid' => $upload[ 'url' ]
+		);
+
+		// Save the data
+		$id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
+		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
+
+		return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ), 'upload' );
+	}
+
+	/* MovableType API functions
+	 * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html
+	 */
+
+	/**
+	 * Retrieve the post titles of recent posts.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mt_getRecentPostTitles($args) {
+
+		$this->escape($args);
+
+		$blog_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+		if ( isset( $args[3] ) )
+			$query = array( 'numberposts' => absint( $args[3] ) );
+		else
+			$query = array();
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'mt.getRecentPostTitles');
+
+		$posts_list = wp_get_recent_posts( $query );
+
+		if ( !$posts_list ) {
+			$this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
+			return $this->error;
+		}
+
+		foreach ($posts_list as $entry) {
+			if ( !current_user_can( 'edit_post', $entry['ID'] ) )
+				continue;
+
+			$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date'], false);
+			$post_date_gmt = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt'], false);
+
+			// For drafts use the GMT version of the date
+			if ( $entry['post_status'] == 'draft' )
+				$post_date_gmt = get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $entry['post_date'] ), 'Ymd\TH:i:s' );
+
+			$struct[] = array(
+				'dateCreated' => new IXR_Date($post_date),
+				'userid' => $entry['post_author'],
+				'postid' => (string) $entry['ID'],
+				'title' => $entry['post_title'],
+				'date_created_gmt' => new IXR_Date($post_date_gmt)
+			);
+
+		}
+
+		$recent_posts = array();
+		for ( $j=0; $j<count($struct); $j++ ) {
+			array_push($recent_posts, $struct[$j]);
+		}
+
+		return $recent_posts;
+	}
+
+	/**
+	 * Retrieve list of all categories on blog.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mt_getCategoryList($args) {
+
+		$this->escape($args);
+
+		$blog_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_posts' ) )
+			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
+
+		do_action('xmlrpc_call', 'mt.getCategoryList');
+
+		$categories_struct = array();
+
+		if ( $cats = get_categories(array('hide_empty' => 0, 'hierarchical' => 0)) ) {
+			foreach ( $cats as $cat ) {
+				$struct['categoryId'] = $cat->term_id;
+				$struct['categoryName'] = $cat->name;
+
+				$categories_struct[] = $struct;
+			}
+		}
+
+		return $categories_struct;
+	}
+
+	/**
+	 * Retrieve post categories.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mt_getPostCategories($args) {
+
+		$this->escape($args);
+
+		$post_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		if ( !current_user_can( 'edit_post', $post_ID ) )
+			return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
+
+		do_action('xmlrpc_call', 'mt.getPostCategories');
+
+		$categories = array();
+		$catids = wp_get_post_categories(intval($post_ID));
+		// first listed category will be the primary category
+		$isPrimary = true;
+		foreach ( $catids as $catid ) {
+			$categories[] = array(
+				'categoryName' => get_cat_name($catid),
+				'categoryId' => (string) $catid,
+				'isPrimary' => $isPrimary
+			);
+			$isPrimary = false;
+		}
+
+		return $categories;
+	}
+
+	/**
+	 * Sets categories for a post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return bool True on success.
+	 */
+	function mt_setPostCategories($args) {
+
+		$this->escape($args);
+
+		$post_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+		$categories  = $args[3];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'mt.setPostCategories');
+
+		if ( !current_user_can('edit_post', $post_ID) )
+			return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
+
+		foreach ( $categories as $cat ) {
+			$catids[] = $cat['categoryId'];
+		}
+
+		wp_set_post_categories($post_ID, $catids);
+
+		return true;
+	}
+
+	/**
+	 * Retrieve an array of methods supported by this server.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function mt_supportedMethods($args) {
+
+		do_action('xmlrpc_call', 'mt.supportedMethods');
+
+		$supported_methods = array();
+		foreach ( $this->methods as $key => $value ) {
+			$supported_methods[] = $key;
+		}
+
+		return $supported_methods;
+	}
+
+	/**
+	 * Retrieve an empty array because we don't support per-post text filters.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 */
+	function mt_supportedTextFilters($args) {
+		do_action('xmlrpc_call', 'mt.supportedTextFilters');
+		return apply_filters('xmlrpc_text_filters', array());
+	}
+
+	/**
+	 * Retrieve trackbacks sent to a given post.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return mixed
+	 */
+	function mt_getTrackbackPings($args) {
+
+		global $wpdb;
+
+		$post_ID = intval($args);
+
+		do_action('xmlrpc_call', 'mt.getTrackbackPings');
+
+		$actual_post = wp_get_single_post($post_ID, ARRAY_A);
+
+		if ( !$actual_post )
+			return new IXR_Error(404, __('Sorry, no such post.'));
+
+		$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
+
+		if ( !$comments )
+			return array();
+
+		$trackback_pings = array();
+		foreach ( $comments as $comment ) {
+			if ( 'trackback' == $comment->comment_type ) {
+				$content = $comment->comment_content;
+				$title = substr($content, 8, (strpos($content, '</strong>') - 8));
+				$trackback_pings[] = array(
+					'pingTitle' => $title,
+					'pingURL'   => $comment->comment_author_url,
+					'pingIP'    => $comment->comment_author_IP
+				);
+			}
+		}
+
+		return $trackback_pings;
+	}
+
+	/**
+	 * Sets a post's publish status to 'publish'.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return int
+	 */
+	function mt_publishPost($args) {
+
+		$this->escape($args);
+
+		$post_ID     = (int) $args[0];
+		$username  = $args[1];
+		$password   = $args[2];
+
+		if ( !$user = $this->login($username, $password) )
+			return $this->error;
+
+		do_action('xmlrpc_call', 'mt.publishPost');
+
+		if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) )
+			return new IXR_Error(401, __('Sorry, you cannot publish this post.'));
+
+		$postdata = wp_get_single_post($post_ID,ARRAY_A);
+
+		$postdata['post_status'] = 'publish';
+
+		// retain old cats
+		$cats = wp_get_post_categories($post_ID);
+		$postdata['post_category'] = $cats;
+		$this->escape($postdata);
+
+		$result = wp_update_post($postdata);
+
+		return $result;
+	}
+
+	/* PingBack functions
+	 * specs on www.hixie.ch/specs/pingback/pingback
+	 */
+
+	/**
+	 * Retrieves a pingback and registers it.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function pingback_ping($args) {
+		global $wpdb;
+
+		do_action('xmlrpc_call', 'pingback.ping');
+
+		$this->escape($args);
+
+		$pagelinkedfrom = $args[0];
+		$pagelinkedto   = $args[1];
+
+		$title = '';
+
+		$pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
+		$pagelinkedto = str_replace('&amp;', '&', $pagelinkedto);
+		$pagelinkedto = str_replace('&', '&amp;', $pagelinkedto);
+
+		// Check if the page linked to is in our site
+		$pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home')));
+		if ( !$pos1 )
+			return new IXR_Error(0, __('Is there no link to us?'));
+
+		// let's find which post is linked to
+		// FIXME: does url_to_postid() cover all these cases already?
+		//        if so, then let's use it and drop the old code.
+		$urltest = parse_url($pagelinkedto);
+		if ( $post_ID = url_to_postid($pagelinkedto) ) {
+			$way = 'url_to_postid()';
+		} elseif ( preg_match('#p/[0-9]{1,}#', $urltest['path'], $match) ) {
+			// the path defines the post_ID (archives/p/XXXX)
+			$blah = explode('/', $match[0]);
+			$post_ID = (int) $blah[1];
+			$way = 'from the path';
+		} elseif ( preg_match('#p=[0-9]{1,}#', $urltest['query'], $match) ) {
+			// the querystring defines the post_ID (?p=XXXX)
+			$blah = explode('=', $match[0]);
+			$post_ID = (int) $blah[1];
+			$way = 'from the querystring';
+		} elseif ( isset($urltest['fragment']) ) {
+			// an #anchor is there, it's either...
+			if ( intval($urltest['fragment']) ) {
+				// ...an integer #XXXX (simpliest case)
+				$post_ID = (int) $urltest['fragment'];
+				$way = 'from the fragment (numeric)';
+			} elseif ( preg_match('/post-[0-9]+/',$urltest['fragment']) ) {
+				// ...a post id in the form 'post-###'
+				$post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
+				$way = 'from the fragment (post-###)';
+			} elseif ( is_string($urltest['fragment']) ) {
+				// ...or a string #title, a little more complicated
+				$title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']);
+				$sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", like_escape( $title ) );
+				if (! ($post_ID = $wpdb->get_var($sql)) ) {
+					// returning unknown error '0' is better than die()ing
+			  		return new IXR_Error(0, '');
+				}
+				$way = 'from the fragment (title)';
+			}
+		} else {
+			// TODO: Attempt to extract a post ID from the given URL
+	  		return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn&#8217;t exist, or it is not a pingback-enabled resource.'));
+		}
+		$post_ID = (int) $post_ID;
+
+
+		logIO("O","(PB) URL='$pagelinkedto' ID='$post_ID' Found='$way'");
+
+		$post = get_post($post_ID);
+
+		if ( !$post ) // Post_ID not found
+	  		return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn&#8217;t exist, or it is not a pingback-enabled resource.'));
+
+		if ( $post_ID == url_to_postid($pagelinkedfrom) )
+			return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.'));
+
+		// Check if pings are on
+		if ( !pings_open($post) )
+	  		return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn&#8217;t exist, or it is not a pingback-enabled resource.'));
+
+		// Let's check that the remote site didn't already pingback this entry
+		if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )
+			return new IXR_Error( 48, __( 'The pingback has already been registered.' ) );
+
+		// very stupid, but gives time to the 'from' server to publish !
+		sleep(1);
+
+		// Let's check the remote site
+		$linea = wp_remote_fopen( $pagelinkedfrom );
+		if ( !$linea )
+	  		return new IXR_Error(16, __('The source URL does not exist.'));
+
+		$linea = apply_filters('pre_remote_source', $linea, $pagelinkedto);
+
+		// Work around bug in strip_tags():
+		$linea = str_replace('<!DOC', '<DOC', $linea);
+		$linea = preg_replace( '/[\s\r\n\t]+/', ' ', $linea ); // normalize spaces
+		$linea = preg_replace( "/ <(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $linea );
+
+		preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
+		$title = $matchtitle[1];
+		if ( empty( $title ) )
+			return new IXR_Error(32, __('We cannot find a title on that page.'));
+
+		$linea = strip_tags( $linea, '<a>' ); // just keep the tag we need
+
+		$p = explode( "\n\n", $linea );
+
+		$preg_target = preg_quote($pagelinkedto, '|');
+
+		foreach ( $p as $para ) {
+			if ( strpos($para, $pagelinkedto) !== false ) { // it exists, but is it a link?
+				preg_match("|<a[^>]+?".$preg_target."[^>]*>([^>]+?)</a>|", $para, $context);
+
+				// If the URL isn't in a link context, keep looking
+				if ( empty($context) )
+					continue;
+
+				// We're going to use this fake tag to mark the context in a bit
+				// the marker is needed in case the link text appears more than once in the paragraph
+				$excerpt = preg_replace('|\</?wpcontext\>|', '', $para);
+
+				// prevent really long link text
+				if ( strlen($context[1]) > 100 )
+					$context[1] = substr($context[1], 0, 100) . '...';
+
+				$marker = '<wpcontext>'.$context[1].'</wpcontext>';    // set up our marker
+				$excerpt= str_replace($context[0], $marker, $excerpt); // swap out the link for our marker
+				$excerpt = strip_tags($excerpt, '<wpcontext>');        // strip all tags but our context marker
+				$excerpt = trim($excerpt);
+				$preg_marker = preg_quote($marker, '|');
+				$excerpt = preg_replace("|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt);
+				$excerpt = strip_tags($excerpt); // YES, again, to remove the marker wrapper
+				break;
+			}
+		}
+
+		if ( empty($context) ) // Link to target not found
+			return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.'));
+
+		$pagelinkedfrom = str_replace('&', '&amp;', $pagelinkedfrom);
+
+		$context = '[...] ' . esc_html( $excerpt ) . ' [...]';
+		$pagelinkedfrom = $wpdb->escape( $pagelinkedfrom );
+
+		$comment_post_ID = (int) $post_ID;
+		$comment_author = $title;
+		$comment_author_email = '';
+		$this->escape($comment_author);
+		$comment_author_url = $pagelinkedfrom;
+		$comment_content = $context;
+		$this->escape($comment_content);
+		$comment_type = 'pingback';
+
+		$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type');
+
+		$comment_ID = wp_new_comment($commentdata);
+		do_action('pingback_post', $comment_ID);
+
+		return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto);
+	}
+
+	/**
+	 * Retrieve array of URLs that pingbacked the given URL.
+	 *
+	 * Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param array $args Method parameters.
+	 * @return array
+	 */
+	function pingback_extensions_getPingbacks($args) {
+
+		global $wpdb;
+
+		do_action('xmlrpc_call', 'pingback.extensions.getPingbacks');
+
+		$this->escape($args);
+
+		$url = $args;
+
+		$post_ID = url_to_postid($url);
+		if ( !$post_ID ) {
+			// We aren't sure that the resource is available and/or pingback enabled
+	  		return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn&#8217;t exist, or it is not a pingback-enabled resource.'));
+		}
+
+		$actual_post = wp_get_single_post($post_ID, ARRAY_A);
+
+		if ( !$actual_post ) {
+			// No such post = resource not found
+	  		return new IXR_Error(32, __('The specified target URL does not exist.'));
+		}
+
+		$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
+
+		if ( !$comments )
+			return array();
+
+		$pingbacks = array();
+		foreach ( $comments as $comment ) {
+			if ( 'pingback' == $comment->comment_type )
+				$pingbacks[] = $comment->comment_author_url;
+		}
+
+		return $pingbacks;
+	}
+}
+?>
Index: /tags/3.1/wp-includes/class-wp.php
===================================================================
--- /tags/3.1/wp-includes/class-wp.php	(revision 17487)
+++ /tags/3.1/wp-includes/class-wp.php	(revision 17487)
@@ -0,0 +1,611 @@
+<?php
+/**
+ * WordPress environment setup class.
+ *
+ * @package WordPress
+ * @since 2.0.0
+ */
+class WP {
+	/**
+	 * Public query variables.
+	 *
+	 * Long list of public query variables.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var array
+	 */
+	var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');
+
+	/**
+	 * Private query variables.
+	 *
+	 * Long list of private query variables.
+	 *
+	 * @since 2.0.0
+	 * @var array
+	 */
+	var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page', 'post__in', 'post__not_in');
+
+	/**
+	 * Extra query variables set by the user.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 */
+	var $extra_query_vars = array();
+
+	/**
+	 * Query variables for setting up the WordPress Query Loop.
+	 *
+	 * @since 2.0.0
+	 * @var array
+	 */
+	var $query_vars;
+
+	/**
+	 * String parsed to set the query variables.
+	 *
+	 * @since 2.0.0
+	 * @var string
+	 */
+	var $query_string;
+
+	/**
+	 * Permalink or requested URI.
+	 *
+	 * @since 2.0.0
+	 * @var string
+	 */
+	var $request;
+
+	/**
+	 * Rewrite rule the request matched.
+	 *
+	 * @since 2.0.0
+	 * @var string
+	 */
+	var $matched_rule;
+
+	/**
+	 * Rewrite query the request matched.
+	 *
+	 * @since 2.0.0
+	 * @var string
+	 */
+	var $matched_query;
+
+	/**
+	 * Whether already did the permalink.
+	 *
+	 * @since 2.0.0
+	 * @var bool
+	 */
+	var $did_permalink = false;
+
+	/**
+	 * Add name to list of public query variables.
+	 *
+	 * @since 2.1.0
+	 *
+	 * @param string $qv Query variable name.
+	 */
+	function add_query_var($qv) {
+		if ( !in_array($qv, $this->public_query_vars) )
+			$this->public_query_vars[] = $qv;
+	}
+
+	/**
+	 * Set the value of a query variable.
+	 *
+	 * @since 2.3.0
+	 *
+	 * @param string $key Query variable name.
+	 * @param mixed $value Query variable value.
+	 */
+	function set_query_var($key, $value) {
+		$this->query_vars[$key] = $value;
+	}
+
+	/**
+	 * Parse request to find correct WordPress query.
+	 *
+	 * Sets up the query variables based on the request. There are also many
+	 * filters and actions that can be used to further manipulate the result.
+	 *
+	 * @since 2.0.0
+	 *
+	 * @param array|string $extra_query_vars Set the extra query variables.
+	 */
+	function parse_request($extra_query_vars = '') {
+		global $wp_rewrite;
+
+		$this->query_vars = array();
+		$post_type_query_vars = array();
+
+		if ( is_array($extra_query_vars) )
+			$this->extra_query_vars = & $extra_query_vars;
+		else if (! empty($extra_query_vars))
+			parse_str($extra_query_vars, $this->extra_query_vars);
+
+		// Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
+
+		// Fetch the rewrite rules.
+		$rewrite = $wp_rewrite->wp_rewrite_rules();
+
+		if ( ! empty($rewrite) ) {
+			// If we match a rewrite rule, this will be cleared.
+			$error = '404';
+			$this->did_permalink = true;
+
+			if ( isset($_SERVER['PATH_INFO']) )
+				$pathinfo = $_SERVER['PATH_INFO'];
+			else
+				$pathinfo = '';
+			$pathinfo_array = explode('?', $pathinfo);
+			$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
+			$req_uri = $_SERVER['REQUEST_URI'];
+			$req_uri_array = explode('?', $req_uri);
+			$req_uri = $req_uri_array[0];
+			$self = $_SERVER['PHP_SELF'];
+			$home_path = parse_url(home_url());
+			if ( isset($home_path['path']) )
+				$home_path = $home_path['path'];
+			else
+				$home_path = '';
+			$home_path = trim($home_path, '/');
+
+			// Trim path info from the end and the leading home path from the
+			// front.  For path info requests, this leaves us with the requesting
+			// filename, if any.  For 404 requests, this leaves us with the
+			// requested permalink.
+			$req_uri = str_replace($pathinfo, '', $req_uri);
+			$req_uri = trim($req_uri, '/');
+			$req_uri = preg_replace("|^$home_path|", '', $req_uri);
+			$req_uri = trim($req_uri, '/');
+			$pathinfo = trim($pathinfo, '/');
+			$pathinfo = preg_replace("|^$home_path|", '', $pathinfo);
+			$pathinfo = trim($pathinfo, '/');
+			$self = trim($self, '/');
+			$self = preg_replace("|^$home_path|", '', $self);
+			$self = trim($self, '/');
+
+			// The requested permalink is in $pathinfo for path info requests and
+			//  $req_uri for other requests.
+			if ( ! empty($pathinfo) && !preg_match('|^.*' . $wp_rewrite->index . '$|', $pathinfo) ) {
+				$request = $pathinfo;
+			} else {
+				// If the request uri is the index, blank it out so that we don't try to match it against a rule.
+				if ( $req_uri == $wp_rewrite->index )
+					$req_uri = '';
+				$request = $req_uri;
+			}
+
+			$this->request = $request;
+
+			// Look for matches.
+			$request_match = $request;
+			foreach ( (array) $rewrite as $match => $query) {
+				// Don't try to match against AtomPub calls
+				if ( $req_uri == 'wp-app.php' )
+					break;
+
+				// If the requesting file is the anchor of the match, prepend it
+				// to the path info.
+				if ( (! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request) )
+					$request_match = $req_uri . '/' . $request;
+
+				if ( preg_match("#^$match#", $request_match, $matches) ||
+					preg_match("#^$match#", urldecode($request_match), $matches) ) {
+					// Got a match.
+					$this->matched_rule = $match;
+
+					// Trim the query of everything up to the '?'.
+					$query = preg_replace("!^.+\?!", '', $query);
+
+					// Substitute the substring matches into the query.
+					$query = addslashes(WP_MatchesMapRegex::apply($query, $matches));
+
+					$this->matched_query = $query;
+
+					// Parse the query.
+					parse_str($query, $perma_query_vars);
+
+					// If we're processing a 404 request, clear the error var
+					// since we found something.
+					if ( isset($_GET['error']) )
+						unset($_GET['error']);
+
+					if ( isset($error) )
+						unset($error);
+
+					break;
+				}
+			}
+
+			// If req_uri is empty or if it is a request for ourself, unset error.
+			if ( empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) {
+				if ( isset($_GET['error']) )
+					unset($_GET['error']);
+
+				if ( isset($error) )
+					unset($error);
+
+				if ( isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false )
+					unset($perma_query_vars);
+
+				$this->did_permalink = false;
+			}
+		}
+
+		$this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
+
+		foreach ( $GLOBALS['wp_post_types'] as $post_type => $t )
+			if ( $t->query_var )
+				$post_type_query_vars[$t->query_var] = $post_type;
+
+		foreach ( $this->public_query_vars as $wpvar ) {
+			if ( isset( $this->extra_query_vars[$wpvar] ) )
+				$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
+			elseif ( isset( $_POST[$wpvar] ) )
+				$this->query_vars[$wpvar] = $_POST[$wpvar];
+			elseif ( isset( $_GET[$wpvar] ) )
+				$this->query_vars[$wpvar] = $_GET[$wpvar];
+			elseif ( isset( $perma_query_vars[$wpvar] ) )
+				$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
+
+			if ( !empty( $this->query_vars[$wpvar] ) ) {
+				if ( ! is_array( $this->query_vars[$wpvar] ) ) {
+					$this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
+				} else {
+					foreach ( $this->query_vars[$wpvar] as $vkey => $v ) {
+						if ( !is_object( $v ) ) {
+							$this->query_vars[$wpvar][$vkey] = (string) $v;
+						}
+					}
+				}
+
+				if ( isset($post_type_query_vars[$wpvar] ) ) {
+					$this->query_vars['post_type'] = $post_type_query_vars[$wpvar];
+					$this->query_vars['name'] = $this->query_vars[$wpvar];
+				}
+			}
+		}
+
+		// Convert urldecoded spaces back into +
+		foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t )
+			if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
+				$this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] );
+
+		// Limit publicly queried post_types to those that are publicly_queryable
+		if ( isset( $this->query_vars['post_type']) ) {
+			$queryable_post_types = get_post_types( array('publicly_queryable' => true) );
+			if ( ! is_array( $this->query_vars['post_type'] ) ) {
+				if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) )
+					unset( $this->query_vars['post_type'] );
+			} else {
+				$this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types );
+			}
+		}
+
+		foreach ( (array) $this->private_query_vars as $var) {
+			if ( isset($this->extra_query_vars[$var]) )
+				$this->query_vars[$var] = $this->extra_query_vars[$var];
+		}
+
+		if ( isset($error) )
+			$this->query_vars['error'] = $error;
+
+		$this->query_vars = apply_filters('request', $this->query_vars);
+
+		do_action_ref_array('parse_request', array(&$this));
+	}
+
+	/**
+	 * Send additional HTTP headers for caching, content type, etc.
+	 *
+	 * Sets the X-Pingback header, 404 status (if 404), Content-type. If showing
+	 * a feed, it will also send last-modified, etag, and 304 status if needed.
+	 *
+	 * @since 2.0.0
+	 */
+	function send_headers() {
+		$headers = array('X-Pingback' => get_bloginfo('pingback_url'));
+		$status = null;
+		$exit_required = false;
+
+		if ( is_user_logged_in() )
+			$headers = array_merge($headers, wp_get_nocache_headers());
+		if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) {
+			$status = 404;
+			if ( !is_user_logged_in() )
+				$headers = array_merge($headers, wp_get_nocache_headers());
+			$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
+		} else if ( empty($this->query_vars['feed']) ) {
+			$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
+		} else {
+			// We're showing a feed, so WP is indeed the only thing that last changed
+			if ( !empty($this->query_vars['withcomments'])
+				|| ( empty($this->query_vars['withoutcomments'])
+					&& ( !empty($this->query_vars['p'])
+						|| !empty($this->query_vars['name'])
+						|| !empty($this->query_vars['page_id'])
+						|| !empty($this->query_vars['pagename'])
+						|| !empty($this->query_vars['attachment'])
+						|| !empty($this->query_vars['attachment_id'])
+					)
+				)
+			)
+				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
+			else
+				$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
+			$wp_etag = '"' . md5($wp_last_modified) . '"';
+			$headers['Last-Modified'] = $wp_last_modified;
+			$headers['ETag'] = $wp_etag;
+
+			// Support for Conditional GET
+			if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
+				$client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
+			else $client_etag = false;
+
+			$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
+			// If string is empty, return 0. If not, attempt to parse into a timestamp
+			$client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
+
+			// Make a timestamp for our most recent modification...
+			$wp_modified_timestamp = strtotime($wp_last_modified);
+
+			if ( ($client_last_modified && $client_etag) ?
+					 (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
+					 (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
+				$status = 304;
+				$exit_required = true;
+			}
+		}
+
+		$headers = apply_filters('wp_headers', $headers, $this);
+
+		if ( ! empty( $status ) )
+			status_header( $status );
+		foreach( (array) $headers as $name => $field_value )
+			@header("{$name}: {$field_value}");
+
+		if ( $exit_required )
+			exit();
+
+		do_action_ref_array('send_headers', array(&$this));
+	}
+
+	/**
+	 * Sets the query string property based off of the query variable property.
+	 *
+	 * The 'query_string' filter is deprecated, but still works. Plugins should
+	 * use the 'request' filter instead.
+	 *
+	 * @since 2.0.0
+	 */
+	function build_query_string() {
+		$this->query_string = '';
+		foreach ( (array) array_keys($this->query_vars) as $wpvar) {
+			if ( '' != $this->query_vars[$wpvar] ) {
+				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
+				if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
+					continue;
+				$this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
+			}
+		}
+
+		// query_string filter deprecated.  Use request filter instead.
+		if ( has_filter('query_string') ) {  // Don't bother filtering and parsing if no plugins are hooked in.
+			$this->query_string = apply_filters('query_string', $this->query_string);
+			parse_str($this->query_string, $this->query_vars);
+		}
+	}
+
+	/**
+	 * Set up the WordPress Globals.
+	 *
+	 * The query_vars property will be extracted to the GLOBALS. So care should
+	 * be taken when naming global variables that might interfere with the
+	 * WordPress environment.
+	 *
+	 * @global string $query_string Query string for the loop.
+	 * @global int $more Only set, if single page or post.
+	 * @global int $single If single page or post. Only set, if single page or post.
+	 *
+	 * @since 2.0.0
+	 */
+	function register_globals() {
+		global $wp_query;
+		// Extract updated query vars back into global namespace.
+		foreach ( (array) $wp_query->query_vars as $key => $value) {
+			$GLOBALS[$key] = $value;
+		}
+
+		$GLOBALS['query_string'] = $this->query_string;
+		$GLOBALS['posts'] = & $wp_query->posts;
+		$GLOBALS['post'] = (isset($wp_query->post)) ? $wp_query->post : null;
+		$GLOBALS['request'] = $wp_query->request;
+
+		if ( is_single() || is_page() ) {
+			$GLOBALS['more'] = 1;
+			$GLOBALS['single'] = 1;
+		}
+	}
+
+	/**
+	 * Set up the current user.
+	 *
+	 * @since 2.0.0
+	 */
+	function init() {
+		wp_get_current_user();
+	}
+
+	/**
+	 * Set up the Loop based on the query variables.
+	 *
+	 * @uses WP::$query_vars
+	 * @since 2.0.0
+	 */
+	function query_posts() {
+		global $wp_the_query;
+		$this->build_query_string();
+		$wp_the_query->query($this->query_vars);
+ 	}
+
+ 	/**
+ 	 * Set the Headers for 404, if nothing is found for requested URL.
+	 *
+	 * Issue a 404 if a request doesn't match any posts and doesn't match
+	 * any object (e.g. an existing-but-empty category, tag, author) and a 404 was not already
+	 * issued, and if the request was not a search or the homepage.
+	 *
+	 * Otherwise, issue a 200.
+	 *
+	 * @since 2.0.0
+ 	 */
+	function handle_404() {
+		global $wp_query;
+
+		if ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) {
+			// Don't 404 for these queries if they matched an object.
+			if ( ( is_tag() || is_category() || is_tax() || is_author() ) && $wp_query->get_queried_object() && !is_paged() ) {
+				if ( !is_404() )
+					status_header( 200 );
+				return;
+			}
+			$wp_query->set_404();
+			status_header( 404 );
+			nocache_headers();
+		} elseif ( !is_404() ) {
+			status_header( 200 );
+		}
+	}
+
+	/**
+	 * Sets up all of the variables required by the WordPress environment.
+	 *
+	 * The action 'wp' has one parameter that references the WP object. It
+	 * allows for accessing the properties and methods to further manipulate the
+	 * object.
+	 *
+	 * @since 2.0.0
+	 *
+	 * @param string|array $query_args Passed to {@link parse_request()}
+	 */
+	function main($query_args = '') {
+		$this->init();
+		$this->parse_request($query_args);
+		$this->send_headers();
+		$this->query_posts();
+		$this->handle_404();
+		$this->register_globals();
+		do_action_ref_array('wp', array(&$this));
+	}
+
+	/**
+	 * PHP4 Constructor - Does nothing.
+	 *
+	 * Call main() method when ready to run setup.
+	 *
+	 * @since 2.0.0
+	 *
+	 * @return WP
+	 */
+	function WP() {
+		// Empty.
+	}
+}
+
+/**
+ * Helper class to remove the need to use eval to replace $matches[] in query strings.
+ *
+ * @since 2.9.0
+ */
+class WP_MatchesMapRegex {
+	/**
+	 * store for matches
+	 *
+	 * @access private
+	 * @var array
+	 */
+	var $_matches;
+
+	/**
+	 * store for mapping result
+	 *
+	 * @access public
+	 * @var string
+	 */
+	var $output;
+
+	/**
+	 * subject to perform mapping on (query string containing $matches[] references
+	 *
+	 * @access private
+	 * @var string
+	 */
+	var $_subject;
+
+	/**
+	 * regexp pattern to match $matches[] references
+	 *
+	 * @var string
+	 */
+	var $_pattern = '(\$matches\[[1-9]+[0-9]*\])'; // magic number
+
+	/**
+	 * constructor
+	 *
+	 * @param string $subject subject if regex
+	 * @param array  $matches data to use in map
+	 * @return self
+	 */
+	function WP_MatchesMapRegex($subject, $matches) {
+		$this->_subject = $subject;
+		$this->_matches = $matches;
+		$this->output = $this->_map();
+	}
+
+	/**
+	 * Substitute substring matches in subject.
+	 *
+	 * static helper function to ease use
+	 *
+	 * @access public
+	 * @param string $subject subject
+	 * @param array  $matches data used for subsitution
+	 * @return string
+	 */
+	function apply($subject, $matches) {
+		$oSelf =& new WP_MatchesMapRegex($subject, $matches);
+		return $oSelf->output;
+	}
+
+	/**
+	 * do the actual mapping
+	 *
+	 * @access private
+	 * @return string
+	 */
+	function _map() {
+		$callback = array(&$this, 'callback');
+		return preg_replace_callback($this->_pattern, $callback, $this->_subject);
+	}
+
+	/**
+	 * preg_replace_callback hook
+	 *
+	 * @access public
+	 * @param  array $matches preg_replace regexp matches
+	 * @return string
+	 */
+	function callback($matches) {
+		$index = intval(substr($matches[0], 9, -1));
+		return ( isset( $this->_matches[$index] ) ? urlencode($this->_matches[$index]) : '' );
+	}
+
+}
+
+?>
Index: /tags/3.1/wp-includes/class.wp-dependencies.php
===================================================================
--- /tags/3.1/wp-includes/class.wp-dependencies.php	(revision 17487)
+++ /tags/3.1/wp-includes/class.wp-dependencies.php	(revision 17487)
@@ -0,0 +1,243 @@
+<?php
+/**
+ * BackPress Scripts enqueue.
+ *
+ * These classes were refactored from the WordPress WP_Scripts and WordPress
+ * script enqueue API.
+ *
+ * @package BackPress
+ * @since r74
+ */
+
+/**
+ * BackPress enqueued dependiences class.
+ *
+ * @package BackPress
+ * @uses _WP_Dependency
+ * @since r74
+ */
+class WP_Dependencies {
+	var $registered = array();
+	var $queue = array();
+	var $to_do = array();
+	var $done = array();
+	var $args = array();
+	var $groups = array();
+	var $group = 0;
+
+	function WP_Dependencies() {
+		$args = func_get_args();
+		call_user_func_array( array(&$this, '__construct'), $args );
+	}
+
+	function __construct() {}
+
+	/**
+	 * Do the dependencies
+	 *
+	 * Process the items passed to it or the queue.  Processes all dependencies.
+	 *
+	 * @param mixed $handles (optional) items to be processed. (void) processes queue, (string) process that item, (array of strings) process those items
+	 * @return array Items that have been processed
+	 */
+	function do_items( $handles = false, $group = false ) {
+		// Print the queue if nothing is passed. If a string is passed, print that script. If an array is passed, print those scripts.
+		$handles = false === $handles ? $this->queue : (array) $handles;
+		$this->all_deps( $handles );
+
+		foreach( $this->to_do as $key => $handle ) {
+			if ( !in_array($handle, $this->done) && isset($this->registered[$handle]) ) {
+
+				if ( ! $this->registered[$handle]->src ) { // Defines a group.
+					$this->done[] = $handle;
+					continue;
+				}
+
+				if ( $this->do_item( $handle, $group ) )
+					$this->done[] = $handle;
+
+				unset( $this->to_do[$key] );
+			}
+		}
+
+		return $this->done;
+	}
+
+	function do_item( $handle ) {
+		return isset($this->registered[$handle]);
+	}
+
+	/**
+	 * Determines dependencies
+	 *
+	 * Recursively builds array of items to process taking dependencies into account.  Does NOT catch infinite loops.
+	 *
+	 *
+	 * @param mixed $handles Accepts (string) dep name or (array of strings) dep names
+	 * @param bool $recursion Used internally when function calls itself
+	 */
+	function all_deps( $handles, $recursion = false, $group = false ) {
+		if ( !$handles = (array) $handles )
+			return false;
+
+		foreach ( $handles as $handle ) {
+			$handle_parts = explode('?', $handle);
+			$handle = $handle_parts[0];
+			$queued = in_array($handle, $this->to_do, true);
+
+			if ( in_array($handle, $this->done, true) ) // Already done
+				continue;
+
+			$moved = $this->set_group( $handle, $recursion, $group );
+
+			if ( $queued && !$moved ) // already queued and in the right group
+				continue;
+
+			$keep_going = true;
+			if ( !isset($this->registered[$handle]) )
+				$keep_going = false; // Script doesn't exist
+			elseif ( $this->registered[$handle]->deps && array_diff($this->registered[$handle]->deps, array_keys($this->registered)) )
+				$keep_going = false; // Script requires deps which don't exist (not a necessary check.  efficiency?)
+			elseif ( $this->registered[$handle]->deps && !$this->all_deps( $this->registered[$handle]->deps, true, $group ) )
+				$keep_going = false; // Script requires deps which don't exist
+
+			if ( !$keep_going ) { // Either script or its deps don't exist.
+				if ( $recursion )
+					return false; // Abort this branch.
+				else
+					continue; // We're at the top level.  Move on to the next one.
+			}
+
+			if ( $queued ) // Already grobbed it and its deps
+				continue;
+
+			if ( isset($handle_parts[1]) )
+				$this->args[$handle] = $handle_parts[1];
+
+			$this->to_do[] = $handle;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Adds item
+	 *
+	 * Adds the item only if no item of that name already exists
+	 *
+	 * @param string $handle Script name
+	 * @param string $src Script url
+	 * @param array $deps (optional) Array of script names on which this script depends
+	 * @param string $ver (optional) Script version (used for cache busting)
+	 * @return array Hierarchical array of dependencies
+	 */
+	function add( $handle, $src, $deps = array(), $ver = false, $args = null ) {
+		if ( isset($this->registered[$handle]) )
+			return false;
+		$this->registered[$handle] = new _WP_Dependency( $handle, $src, $deps, $ver, $args );
+		return true;
+	}
+
+	/**
+	 * Adds extra data
+	 *
+	 * Adds data only if script has already been added
+	 *
+	 * @param string $handle Script name
+	 * @param string $data_name Name of object in which to store extra data
+	 * @param array $data Array of extra data
+	 * @return bool success
+	 */
+	function add_data( $handle, $data_name, $data ) {
+		if ( !isset($this->registered[$handle]) )
+			return false;
+		return $this->registered[$handle]->add_data( $data_name, $data );
+	}
+
+	function remove( $handles ) {
+		foreach ( (array) $handles as $handle )
+			unset($this->registered[$handle]);
+	}
+
+	function enqueue( $handles ) {
+		foreach ( (array) $handles as $handle ) {
+			$handle = explode('?', $handle);
+			if ( !in_array($handle[0], $this->queue) && isset($this->registered[$handle[0]]) ) {
+				$this->queue[] = $handle[0];
+				if ( isset($handle[1]) )
+					$this->args[$handle[0]] = $handle[1];
+			}
+		}
+	}
+
+	function dequeue( $handles ) {
+		foreach ( (array) $handles as $handle ) {
+			$handle = explode('?', $handle);
+			$key = array_search($handle[0], $this->queue);
+			if ( false !== $key ) {
+				unset($this->queue[$key]);
+				unset($this->args[$handle[0]]);
+			}
+		}
+	}
+
+	function query( $handle, $list = 'registered' ) { // registered, queue, done, to_do
+		switch ( $list ) :
+		case 'registered':
+		case 'scripts': // back compat
+			if ( isset($this->registered[$handle]) )
+				return $this->registered[$handle];
+			break;
+		case 'to_print': // back compat
+		case 'printed': // back compat
+			if ( 'to_print' == $list )
+				$list = 'to_do';
+			else
+				$list = 'printed';
+		default:
+			if ( in_array($handle, $this->$list) )
+				return true;
+			break;
+		endswitch;
+		return false;
+	}
+
+	function set_group( $handle, $recursion, $group ) {
+		$group = (int) $group;
+
+		if ( $recursion )
+			$group = min($this->group, $group);
+		else
+			$this->group = $group;
+
+		if ( isset($this->groups[$handle]) && $this->groups[$handle] <= $group )
+			return false;
+
+		$this->groups[$handle] = $group;
+		return true;
+	}
+
+}
+
+class _WP_Dependency {
+	var $handle;
+	var $src;
+	var $deps = array();
+	var $ver = false;
+	var $args = null;
+
+	var $extra = array();
+
+	function _WP_Dependency() {
+		@list($this->handle, $this->src, $this->deps, $this->ver, $this->args) = func_get_args();
+		if ( !is_array($this->deps) )
+			$this->deps = array();
+	}
+
+	function add_data( $name, $data ) {
+		if ( !is_scalar($name) )
+			return false;
+		$this->extra[$name] = $data;
+		return true;
+	}
+}
Index: /tags/3.1/wp-includes/class.wp-scripts.php
===================================================================
--- /tags/3.1/wp-includes/class.wp-scripts.php	(revision 17487)
+++ /tags/3.1/wp-includes/class.wp-scripts.php	(revision 17487)
@@ -0,0 +1,205 @@
+<?php
+/**
+ * BackPress Scripts enqueue.
+ *
+ * These classes were refactored from the WordPress WP_Scripts and WordPress
+ * script enqueue API.
+ *
+ * @package BackPress
+ * @since r16
+ */
+
+/**
+ * BackPress Scripts enqueue class.
+ *
+ * @package BackPress
+ * @uses WP_Dependencies
+ * @since r16
+ */
+class WP_Scripts extends WP_Dependencies {
+	var $base_url; // Full URL with trailing slash
+	var $content_url;
+	var $default_version;
+	var $in_footer = array();
+	var $concat = '';
+	var $concat_version = '';
+	var $do_concat = false;
+	var $print_html = '';
+	var $print_code = '';
+	var $ext_handles = '';
+	var $ext_version = '';
+	var $default_dirs;
+
+	function __construct() {
+		do_action_ref_array( 'wp_default_scripts', array(&$this) );
+	}
+
+	/**
+	 * Prints scripts
+	 *
+	 * Prints the scripts passed to it or the print queue.  Also prints all necessary dependencies.
+	 *
+	 * @param mixed $handles (optional) Scripts to be printed.  (void) prints queue, (string) prints that script, (array of strings) prints those scripts.
+	 * @param int $group (optional) If scripts were queued in groups prints this group number.
+	 * @return array Scripts that have been printed
+	 */
+	function print_scripts( $handles = false, $group = false ) {
+		return $this->do_items( $handles, $group );
+	}
+
+	function print_scripts_l10n( $handle, $echo = true ) {
+		if ( empty($this->registered[$handle]->extra['l10n']) || empty($this->registered[$handle]->extra['l10n'][0]) || !is_array($this->registered[$handle]->extra['l10n'][1]) )
+			return false;
+
+		$object_name = $this->registered[$handle]->extra['l10n'][0];
+
+		$data = "var $object_name = {\n";
+		$eol = '';
+		foreach ( $this->registered[$handle]->extra['l10n'][1] as $var => $val ) {
+			if ( 'l10n_print_after' == $var ) {
+				$after = $val;
+				continue;
+			}
+			$data .= "$eol\t$var: \"" . esc_js( $val ) . '"';
+			$eol = ",\n";
+		}
+		$data .= "\n};\n";
+		$data .= isset($after) ? "$after\n" : '';
+
+		if ( $echo ) {
+			echo "<script type='text/javascript'>\n";
+			echo "/* <![CDATA[ */\n";
+			echo $data;
+			echo "/* ]]> */\n";
+			echo "</script>\n";
+			return true;
+		} else {
+			return $data;
+		}
+	}
+
+	function do_item( $handle, $group = false ) {
+		if ( !parent::do_item($handle) )
+			return false;
+
+		if ( 0 === $group && $this->groups[$handle] > 0 ) {
+			$this->in_footer[] = $handle;
+			return false;
+		}
+
+		if ( false === $group && in_array($handle, $this->in_footer, true) )
+			$this->in_footer = array_diff( $this->in_footer, (array) $handle );
+
+		if ( null === $this->registered[$handle]->ver )
+			$ver = '';
+		else
+			$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
+
+		if ( isset($this->args[$handle]) )
+			$ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
+
+		$src = $this->registered[$handle]->src;
+
+		if ( $this->do_concat ) {
+			$srce = apply_filters( 'script_loader_src', $src, $handle );
+			if ( $this->in_default_dir($srce) ) {
+				$this->print_code .= $this->print_scripts_l10n( $handle, false );
+				$this->concat .= "$handle,";
+				$this->concat_version .= "$handle$ver";
+				return true;
+			} else {
+				$this->ext_handles .= "$handle,";
+				$this->ext_version .= "$handle$ver";
+			}
+		}
+
+		$this->print_scripts_l10n( $handle );
+		if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
+			$src = $this->base_url . $src;
+		}
+
+		if ( !empty($ver) )
+			$src = add_query_arg('ver', $ver, $src);
+		$src = esc_url(apply_filters( 'script_loader_src', $src, $handle ));
+
+		if ( $this->do_concat )
+			$this->print_html .= "<script type='text/javascript' src='$src'></script>\n";
+		else
+			echo "<script type='text/javascript' src='$src'></script>\n";
+
+		return true;
+	}
+
+	/**
+	 * Localizes a script
+	 *
+	 * Localizes only if script has already been added
+	 *
+	 * @param string $handle Script name
+	 * @param string $object_name Name of JS object to hold l10n info
+	 * @param array $l10n Array of JS var name => localized string
+	 * @return bool Successful localization
+	 */
+	function localize( $handle, $object_name, $l10n ) {
+		if ( !$object_name || !$l10n )
+			return false;
+		return $this->add_data( $handle, 'l10n', array( $object_name, $l10n ) );
+	}
+
+	function set_group( $handle, $recursion, $group = false ) {
+		$grp = isset($this->registered[$handle]->extra['group']) ? (int) $this->registered[$handle]->extra['group'] : 0;
+		if ( false !== $group && $grp > $group )
+			$grp = $group;
+
+		return parent::set_group( $handle, $recursion, $grp );
+	}
+
+	function all_deps( $handles, $recursion = false, $group = false ) {
+		$r = parent::all_deps( $handles, $recursion );
+		if ( !$recursion )
+			$this->to_do = apply_filters( 'print_scripts_array', $this->to_do );
+		return $r;
+	}
+
+	function do_head_items() {
+		$this->do_items(false, 0);
+		return $this->done;
+	}
+
+	function do_footer_items() {
+		if ( !empty($this->in_footer) ) {
+			foreach( $this->in_footer as $key => $handle ) {
+				if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) {
+					$this->do_item($handle);
+					$this->done[] = $handle;
+					unset( $this->in_footer[$key] );
+				}
+			}
+		}
+		return $this->done;
+	}
+
+	function in_default_dir($src) {
+		if ( ! $this->default_dirs )
+			return true;
+
+		if ( 0 === strpos( $src, '/wp-includes/js/l10n' ) )
+			return false;
+
+		foreach ( (array) $this->default_dirs as $test ) {
+			if ( 0 === strpos($src, $test) )
+				return true;
+		}
+		return false;
+	}
+
+	function reset() {
+		$this->do_concat = false;
+		$this->print_code = '';
+		$this->concat = '';
+		$this->concat_version = '';
+		$this->print_html = '';
+		$this->ext_version = '';
+		$this->ext_handles = '';
+	}
+}
Index: /tags/3.1/wp-includes/class.wp-styles.php
===================================================================
--- /tags/3.1/wp-includes/class.wp-styles.php	(revision 17487)
+++ /tags/3.1/wp-includes/class.wp-styles.php	(revision 17487)
@@ -0,0 +1,126 @@
+<?php
+/**
+ * BackPress Styles enqueue.
+ *
+ * These classes were refactored from the WordPress WP_Scripts and WordPress
+ * script enqueue API.
+ *
+ * @package BackPress
+ * @since r74
+ */
+
+/**
+ * BackPress Styles enqueue class.
+ *
+ * @package BackPress
+ * @uses WP_Dependencies
+ * @since r74
+ */
+class WP_Styles extends WP_Dependencies {
+	var $base_url;
+	var $content_url;
+	var $default_version;
+	var $text_direction = 'ltr';
+	var $concat = '';
+	var $concat_version = '';
+	var $do_concat = false;
+	var $print_html = '';
+	var $default_dirs;
+
+	function __construct() {
+		do_action_ref_array( 'wp_default_styles', array(&$this) );
+	}
+
+	function do_item( $handle ) {
+		if ( !parent::do_item($handle) )
+			return false;
+
+		if ( null === $this->registered[$handle]->ver )
+			$ver = '';
+		else
+			$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
+
+		if ( isset($this->args[$handle]) )
+			$ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
+
+		if ( $this->do_concat ) {
+			if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) {
+				$this->concat .= "$handle,";
+				$this->concat_version .= "$handle$ver";
+				return true;
+			}
+		}
+
+		if ( isset($this->registered[$handle]->args) )
+			$media = esc_attr( $this->registered[$handle]->args );
+		else
+			$media = 'all';
+
+		$href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
+		$rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
+		$title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : '';
+
+		$end_cond = $tag = '';
+		if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
+			$tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
+			$end_cond = "<![endif]-->\n";
+		}
+
+		$tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle );
+		if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
+			if ( is_bool( $this->registered[$handle]->extra['rtl'] ) ) {
+				$suffix = isset( $this->registered[$handle]->extra['suffix'] ) ? $this->registered[$handle]->extra['suffix'] : '';
+				$rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" ));
+			} else {
+				$rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
+			}
+
+			$tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle );
+		}
+
+		$tag .= $end_cond;
+
+		if ( $this->do_concat )
+			$this->print_html .= $tag;
+		else
+			echo $tag;
+
+		// Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
+//		echo "<style type='text/css'>\n";
+//		echo "/* <![CDATA[ */\n";
+//		echo "/* ]]> */\n";
+//		echo "</style>\n";
+
+		return true;
+	}
+
+	function all_deps( $handles, $recursion = false, $group = false ) {
+		$r = parent::all_deps( $handles, $recursion );
+		if ( !$recursion )
+			$this->to_do = apply_filters( 'print_styles_array', $this->to_do );
+		return $r;
+	}
+
+	function _css_href( $src, $ver, $handle ) {
+		if ( !is_bool($src) && !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
+			$src = $this->base_url . $src;
+		}
+
+		if ( !empty($ver) )
+			$src = add_query_arg('ver', $ver, $src);
+		$src = apply_filters( 'style_loader_src', $src, $handle );
+		return esc_url( $src );
+	}
+
+	function in_default_dir($src) {
+		if ( ! $this->default_dirs )
+			return true;
+
+		foreach ( (array) $this->default_dirs as $test ) {
+			if ( 0 === strpos($src, $test) )
+				return true;
+		}
+		return false;
+	}
+
+}
Index: /tags/3.1/wp-includes/comment-template.php
===================================================================
--- /tags/3.1/wp-includes/comment-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/comment-template.php	(revision 17487)
@@ -0,0 +1,1589 @@
+<?php
+/**
+ * Comment template functions
+ *
+ * These functions are meant to live inside of the WordPress loop.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Retrieve the author of the current comment.
+ *
+ * If the comment has an empty comment_author field, then 'Anonymous' person is
+ * assumed.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'get_comment_author' hook on the comment author
+ *
+ * @param int $comment_ID The ID of the comment for which to retrieve the author. Optional.
+ * @return string The comment author
+ */
+function get_comment_author( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	if ( empty($comment->comment_author) ) {
+		if (!empty($comment->user_id)){
+			$user=get_userdata($comment->user_id);
+			$author=$user->user_login;
+		} else {
+			$author = __('Anonymous');
+		}
+	} else {
+		$author = $comment->comment_author;
+	}
+	return apply_filters('get_comment_author', $author);
+}
+
+/**
+ * Displays the author of the current comment.
+ *
+ * @since 0.71
+ * @uses apply_filters() Calls 'comment_author' on comment author before displaying
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author. Optional.
+ */
+function comment_author( $comment_ID = 0 ) {
+	$author = apply_filters('comment_author', get_comment_author( $comment_ID ) );
+	echo $author;
+}
+
+/**
+ * Retrieve the email of the author of the current comment.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email
+ * @uses $comment
+ *
+ * @param int $comment_ID The ID of the comment for which to get the author's email.  Optional.
+ * @return string The current comment author's email
+ */
+function get_comment_author_email( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	return apply_filters('get_comment_author_email', $comment->comment_author_email);
+}
+
+/**
+ * Display the email of the author of the current global $comment.
+ *
+ * Care should be taken to protect the email address and assure that email
+ * harvesters do not capture your commentors' email address. Most assume that
+ * their email address will not appear in raw form on the blog. Doing so will
+ * enable anyone, including those that people don't want to get the email
+ * address and use it for their own means good and bad.
+ *
+ * @since 0.71
+ * @uses apply_filters() Calls 'author_email' hook on the author email
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's email. Optional.
+ */
+function comment_author_email( $comment_ID = 0 ) {
+	echo apply_filters('author_email', get_comment_author_email( $comment_ID ) );
+}
+
+/**
+ * Display the html email link to the author of the current comment.
+ *
+ * Care should be taken to protect the email address and assure that email
+ * harvesters do not capture your commentors' email address. Most assume that
+ * their email address will not appear in raw form on the blog. Doing so will
+ * enable anyone, including those that people don't want to get the email
+ * address and use it for their own means good and bad.
+ *
+ * @since 0.71
+ * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email
+ * @uses get_comment_author_email_link() For generating the link
+ * @global object $comment The current Comment row object
+ *
+ * @param string $linktext The text to display instead of the comment author's email address
+ * @param string $before The text or HTML to display before the email link.
+ * @param string $after The text or HTML to display after the email link.
+ */
+function comment_author_email_link($linktext='', $before='', $after='') {
+	if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
+		echo $link;
+}
+
+/**
+ * Return the html email link to the author of the current comment.
+ *
+ * Care should be taken to protect the email address and assure that email
+ * harvesters do not capture your commentors' email address. Most assume that
+ * their email address will not appear in raw form on the blog. Doing so will
+ * enable anyone, including those that people don't want to get the email
+ * address and use it for their own means good and bad.
+ *
+ * @since 2.7
+ * @uses apply_filters() Calls 'comment_email' hook for the display of the comment author's email
+ * @global object $comment The current Comment row object
+ *
+ * @param string $linktext The text to display instead of the comment author's email address
+ * @param string $before The text or HTML to display before the email link.
+ * @param string $after The text or HTML to display after the email link.
+ */
+function get_comment_author_email_link($linktext='', $before='', $after='') {
+	global $comment;
+	$email = apply_filters('comment_email', $comment->comment_author_email);
+	if ((!empty($email)) && ($email != '@')) {
+	$display = ($linktext != '') ? $linktext : $email;
+		$return  = $before;
+		$return .= "<a href='mailto:$email'>$display</a>";
+	 	$return .= $after;
+		return $return;
+	} else {
+		return '';
+	}
+}
+
+/**
+ * Retrieve the html link to the url of the author of the current comment.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author
+ *
+ * @param int $comment_ID The ID of the comment for which to get the author's link.  Optional.
+ * @return string Comment Author name or HTML link for author's URL
+ */
+function get_comment_author_link( $comment_ID = 0 ) {
+	/** @todo Only call these functions when they are needed. Include in if... else blocks */
+	$url    = get_comment_author_url( $comment_ID );
+	$author = get_comment_author( $comment_ID );
+
+	if ( empty( $url ) || 'http://' == $url )
+		$return = $author;
+	else
+		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
+	return apply_filters('get_comment_author_link', $return);
+}
+
+/**
+ * Display the html link to the url of the author of the current comment.
+ *
+ * @since 0.71
+ * @see get_comment_author_link() Echoes result
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's link. Optional.
+ */
+function comment_author_link( $comment_ID = 0 ) {
+	echo get_comment_author_link( $comment_ID );
+}
+
+/**
+ * Retrieve the IP address of the author of the current comment.
+ *
+ * @since 1.5.0
+ * @uses $comment
+ * @uses apply_filters()
+ *
+ * @param int $comment_ID The ID of the comment for which to get the author's IP address. Optional.
+ * @return string The comment author's IP address.
+ */
+function get_comment_author_IP( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	return apply_filters('get_comment_author_IP', $comment->comment_author_IP);
+}
+
+/**
+ * Display the IP address of the author of the current comment.
+ *
+ * @since 0.71
+ * @see get_comment_author_IP() Echoes Result
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's IP address.  Optional.
+ */
+function comment_author_IP( $comment_ID = 0 ) {
+	echo get_comment_author_IP( $comment_ID );
+}
+
+/**
+ * Retrieve the url of the author of the current comment.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL
+ *
+ * @param int $comment_ID The ID of the comment for which to get the author's URL.  Optional.
+ * @return string
+ */
+function get_comment_author_url( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	$url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
+	$url = esc_url( $url, array('http', 'https') );
+	return apply_filters('get_comment_author_url', $url);
+}
+
+/**
+ * Display the url of the author of the current comment.
+ *
+ * @since 0.71
+ * @uses apply_filters()
+ * @uses get_comment_author_url() Retrieves the comment author's URL
+ *
+ * @param int $comment_ID The ID of the comment for which to print the author's URL. Optional.
+ */
+function comment_author_url( $comment_ID = 0 ) {
+	echo apply_filters('comment_url', get_comment_author_url( $comment_ID ));
+}
+
+/**
+ * Retrieves the HTML link of the url of the author of the current comment.
+ *
+ * $linktext parameter is only used if the URL does not exist for the comment
+ * author. If the URL does exist then the URL will be used and the $linktext
+ * will be ignored.
+ *
+ * Encapsulate the HTML link between the $before and $after. So it will appear
+ * in the order of $before, link, and finally $after.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls the 'get_comment_author_url_link' on the complete HTML before returning.
+ *
+ * @param string $linktext The text to display instead of the comment author's email address
+ * @param string $before The text or HTML to display before the email link.
+ * @param string $after The text or HTML to display after the email link.
+ * @return string The HTML link between the $before and $after parameters
+ */
+function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
+	$url = get_comment_author_url();
+	$display = ($linktext != '') ? $linktext : $url;
+	$display = str_replace( 'http://www.', '', $display );
+	$display = str_replace( 'http://', '', $display );
+	if ( '/' == substr($display, -1) )
+		$display = substr($display, 0, -1);
+	$return = "$before<a href='$url' rel='external'>$display</a>$after";
+	return apply_filters('get_comment_author_url_link', $return);
+}
+
+/**
+ * Displays the HTML link of the url of the author of the current comment.
+ *
+ * @since 0.71
+ * @see get_comment_author_url_link() Echoes result
+ *
+ * @param string $linktext The text to display instead of the comment author's email address
+ * @param string $before The text or HTML to display before the email link.
+ * @param string $after The text or HTML to display after the email link.
+ */
+function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
+	echo get_comment_author_url_link( $linktext, $before, $after );
+}
+
+/**
+ * Generates semantic classes for each comment element
+ *
+ * @since 2.7.0
+ *
+ * @param string|array $class One or more classes to add to the class list
+ * @param int $comment_id An optional comment ID
+ * @param int $post_id An optional post ID
+ * @param bool $echo Whether comment_class should echo or return
+ */
+function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) {
+	// Separates classes with a single space, collates classes for comment DIV
+	$class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"';
+	if ( $echo)
+		echo $class;
+	else
+		return $class;
+}
+
+/**
+ * Returns the classes for the comment div as an array
+ *
+ * @since 2.7.0
+ *
+ * @param string|array $class One or more classes to add to the class list
+ * @param int $comment_id An optional comment ID
+ * @param int $post_id An optional post ID
+ * @return array Array of classes
+ */
+function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
+	global $comment_alt, $comment_depth, $comment_thread_alt;
+
+	$comment = get_comment($comment_id);
+
+	$classes = array();
+
+	// Get the comment type (comment, trackback),
+	$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
+
+	// If the comment author has an id (registered), then print the log in name
+	if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
+		// For all registered users, 'byuser'
+		$classes[] = 'byuser';
+		$classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id);
+		// For comment authors who are the author of the post
+		if ( $post = get_post($post_id) ) {
+			if ( $comment->user_id === $post->post_author )
+				$classes[] = 'bypostauthor';
+		}
+	}
+
+	if ( empty($comment_alt) )
+		$comment_alt = 0;
+	if ( empty($comment_depth) )
+		$comment_depth = 1;
+	if ( empty($comment_thread_alt) )
+		$comment_thread_alt = 0;
+
+	if ( $comment_alt % 2 ) {
+		$classes[] = 'odd';
+		$classes[] = 'alt';
+	} else {
+		$classes[] = 'even';
+	}
+
+	$comment_alt++;
+
+	// Alt for top-level comments
+	if ( 1 == $comment_depth ) {
+		if ( $comment_thread_alt % 2 ) {
+			$classes[] = 'thread-odd';
+			$classes[] = 'thread-alt';
+		} else {
+			$classes[] = 'thread-even';
+		}
+		$comment_thread_alt++;
+	}
+
+	$classes[] = "depth-$comment_depth";
+
+	if ( !empty($class) ) {
+		if ( !is_array( $class ) )
+			$class = preg_split('#\s+#', $class);
+		$classes = array_merge($classes, $class);
+	}
+
+	$classes = array_map('esc_attr', $classes);
+
+	return apply_filters('comment_class', $classes, $class, $comment_id, $post_id);
+}
+
+/**
+ * Retrieve the comment date of the current comment.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'get_comment_date' hook with the formated date and the $d parameter respectively
+ * @uses $comment
+ *
+ * @param string $d The format of the date (defaults to user's config)
+ * @param int $comment_ID The ID of the comment for which to get the date. Optional.
+ * @return string The comment's date
+ */
+function get_comment_date( $d = '', $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	if ( '' == $d )
+		$date = mysql2date(get_option('date_format'), $comment->comment_date);
+	else
+		$date = mysql2date($d, $comment->comment_date);
+	return apply_filters('get_comment_date', $date, $d);
+}
+
+/**
+ * Display the comment date of the current comment.
+ *
+ * @since 0.71
+ *
+ * @param string $d The format of the date (defaults to user's config)
+ * @param int $comment_ID The ID of the comment for which to print the date.  Optional.
+ */
+function comment_date( $d = '', $comment_ID = 0 ) {
+	echo get_comment_date( $d, $comment_ID );
+}
+
+/**
+ * Retrieve the excerpt of the current comment.
+ *
+ * Will cut each word and only output the first 20 words with '...' at the end.
+ * If the word count is less than 20, then no truncating is done and no '...'
+ * will appear.
+ *
+ * @since 1.5.0
+ * @uses $comment
+ * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment
+ *
+ * @param int $comment_ID The ID of the comment for which to get the excerpt. Optional.
+ * @return string The maybe truncated comment with 20 words or less
+ */
+function get_comment_excerpt( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	$comment_text = strip_tags($comment->comment_content);
+	$blah = explode(' ', $comment_text);
+	if (count($blah) > 20) {
+		$k = 20;
+		$use_dotdotdot = 1;
+	} else {
+		$k = count($blah);
+		$use_dotdotdot = 0;
+	}
+	$excerpt = '';
+	for ($i=0; $i<$k; $i++) {
+		$excerpt .= $blah[$i] . ' ';
+	}
+	$excerpt .= ($use_dotdotdot) ? '...' : '';
+	return apply_filters('get_comment_excerpt', $excerpt);
+}
+
+/**
+ * Display the excerpt of the current comment.
+ *
+ * @since 1.2.0
+ * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt
+ *
+ * @param int $comment_ID The ID of the comment for which to print the excerpt. Optional.
+ */
+function comment_excerpt( $comment_ID = 0 ) {
+	echo apply_filters('comment_excerpt', get_comment_excerpt($comment_ID) );
+}
+
+/**
+ * Retrieve the comment id of the current comment.
+ *
+ * @since 1.5.0
+ * @uses $comment
+ * @uses apply_filters() Calls the 'get_comment_ID' hook for the comment ID
+ *
+ * @return int The comment ID
+ */
+function get_comment_ID() {
+	global $comment;
+	return apply_filters('get_comment_ID', $comment->comment_ID);
+}
+
+/**
+ * Displays the comment id of the current comment.
+ *
+ * @since 0.71
+ * @see get_comment_ID() Echoes Result
+ */
+function comment_ID() {
+	echo get_comment_ID();
+}
+
+/**
+ * Retrieve the link to a given comment.
+ *
+ * @since 1.5.0
+ * @uses $comment
+ *
+ * @param object|string|int $comment Comment to retrieve.
+ * @param array $args Optional args.
+ * @return string The permalink to the given comment.
+ */
+function get_comment_link( $comment = null, $args = array() ) {
+	global $wp_rewrite, $in_comment_loop;
+
+	$comment = get_comment($comment);
+
+	// Backwards compat
+	if ( !is_array($args) ) {
+		$page = $args;
+		$args = array();
+		$args['page'] = $page;
+	}
+
+	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
+	$args = wp_parse_args( $args, $defaults );
+
+	if ( '' === $args['per_page'] && get_option('page_comments') )
+		$args['per_page'] = get_option('comments_per_page');
+
+	if ( empty($args['per_page']) ) {
+		$args['per_page'] = 0;
+		$args['page'] = 0;
+	}
+
+	if ( $args['per_page'] ) {
+		if ( '' == $args['page'] )
+			$args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
+
+		if ( $wp_rewrite->using_permalinks() )
+			$link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' );
+		else
+			$link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );
+	} else {
+		$link = get_permalink( $comment->comment_post_ID );
+	}
+
+	return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args );
+}
+
+/**
+ * Retrieves the link to the current post comments.
+ *
+ * @since 1.5.0
+ *
+ * @param int $post_id Optional post id
+ * @return string The link to the comments
+ */
+function get_comments_link($post_id = 0) {
+	return get_permalink($post_id) . '#comments';
+}
+
+/**
+ * Displays the link to the current post comments.
+ *
+ * @since 0.71
+ *
+ * @param string $deprecated Not Used
+ * @param bool $deprecated_2 Not Used
+ */
+function comments_link( $deprecated = '', $deprecated_2 = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '0.72' );
+	if ( !empty( $deprecated_2 ) )
+		_deprecated_argument( __FUNCTION__, '1.3' );
+	echo get_comments_link();
+}
+
+/**
+ * Retrieve the amount of comments a post has.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls the 'get_comments_number' hook on the number of comments
+ *
+ * @param int $post_id The Post ID
+ * @return int The number of comments a post has
+ */
+function get_comments_number( $post_id = 0 ) {
+	$post_id = absint( $post_id );
+
+	if ( !$post_id )
+		$post_id = get_the_ID();
+
+	$post = get_post($post_id);
+	if ( ! isset($post->comment_count) )
+		$count = 0;
+	else
+		$count = $post->comment_count;
+
+	return apply_filters('get_comments_number', $count, $post_id);
+}
+
+/**
+ * Display the language string for the number of comments the current post has.
+ *
+ * @since 0.71
+ * @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively.
+ *
+ * @param string $zero Text for no comments
+ * @param string $one Text for one comment
+ * @param string $more Text for more than one comment
+ * @param string $deprecated Not used.
+ */
+function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '1.3' );
+
+	$number = get_comments_number();
+
+	if ( $number > 1 )
+		$output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
+	elseif ( $number == 0 )
+		$output = ( false === $zero ) ? __('No Comments') : $zero;
+	else // must be one
+		$output = ( false === $one ) ? __('1 Comment') : $one;
+
+	echo apply_filters('comments_number', $output, $number);
+}
+
+/**
+ * Retrieve the text of the current comment.
+ *
+ * @since 1.5.0
+ * @uses $comment
+ *
+ * @param int $comment_ID The ID of the comment for which to get the text. Optional.
+ * @return string The comment content
+ */
+function get_comment_text( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	return apply_filters( 'get_comment_text', $comment->comment_content, $comment );
+}
+
+/**
+ * Displays the text of the current comment.
+ *
+ * @since 0.71
+ * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display
+ * @uses get_comment_text() Gets the comment content
+ *
+ * @param int $comment_ID The ID of the comment for which to print the text. Optional.
+ */
+function comment_text( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	echo apply_filters( 'comment_text', get_comment_text( $comment_ID ), $comment );
+}
+
+/**
+ * Retrieve the comment time of the current comment.
+ *
+ * @since 1.5.0
+ * @uses $comment
+ * @uses apply_filter() Calls 'get_comment_time' hook with the formatted time, the $d parameter, and $gmt parameter passed.
+ *
+ * @param string $d Optional. The format of the time (defaults to user's config)
+ * @param bool $gmt Whether to use the GMT date
+ * @param bool $translate Whether to translate the time (for use in feeds)
+ * @return string The formatted time
+ */
+function get_comment_time( $d = '', $gmt = false, $translate = true ) {
+	global $comment;
+	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
+	if ( '' == $d )
+		$date = mysql2date(get_option('time_format'), $comment_date, $translate);
+	else
+		$date = mysql2date($d, $comment_date, $translate);
+	return apply_filters('get_comment_time', $date, $d, $gmt, $translate);
+}
+
+/**
+ * Display the comment time of the current comment.
+ *
+ * @since 0.71
+ *
+ * @param string $d Optional. The format of the time (defaults to user's config)
+ */
+function comment_time( $d = '' ) {
+	echo get_comment_time($d);
+}
+
+/**
+ * Retrieve the comment type of the current comment.
+ *
+ * @since 1.5.0
+ * @uses $comment
+ * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type
+ *
+ * @param int $comment_ID The ID of the comment for which to get the type. Optional.
+ * @return string The comment type
+ */
+function get_comment_type( $comment_ID = 0 ) {
+	$comment = get_comment( $comment_ID );
+	if ( '' == $comment->comment_type )
+		$comment->comment_type = 'comment';
+
+	return apply_filters('get_comment_type', $comment->comment_type);
+}
+
+/**
+ * Display the comment type of the current comment.
+ *
+ * @since 0.71
+ *
+ * @param string $commenttxt The string to display for comment type
+ * @param string $trackbacktxt The string to display for trackback type
+ * @param string $pingbacktxt The string to display for pingback type
+ */
+function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) {
+	if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
+	if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
+	if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
+	$type = get_comment_type();
+	switch( $type ) {
+		case 'trackback' :
+			echo $trackbacktxt;
+			break;
+		case 'pingback' :
+			echo $pingbacktxt;
+			break;
+		default :
+			echo $commenttxt;
+	}
+}
+
+/**
+ * Retrieve The current post's trackback URL.
+ *
+ * There is a check to see if permalink's have been enabled and if so, will
+ * retrieve the pretty path. If permalinks weren't enabled, the ID of the
+ * current post is used and appended to the correct page to go to.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
+ *
+ * @return string The trackback URL after being filtered
+ */
+function get_trackback_url() {
+	if ( '' != get_option('permalink_structure') ) {
+		$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
+	} else {
+		$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
+	}
+	return apply_filters('trackback_url', $tb_url);
+}
+
+/**
+ * Displays the current post's trackback URL.
+ *
+ * @since 0.71
+ * @uses get_trackback_url() Gets the trackback url for the current post
+ *
+ * @param bool $deprecated_echo Remove backwards compat in 2.5
+ * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() for the result instead.
+ */
+function trackback_url( $deprecated_echo = true ) {
+	if ( $deprecated_echo !== true )
+		_deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') );
+	if ( $deprecated_echo )
+		echo get_trackback_url();
+	else
+		return get_trackback_url();
+}
+
+/**
+ * Generates and displays the RDF for the trackback information of current post.
+ *
+ * Deprecated in 3.0.0, and restored in 3.0.1.
+ *
+ * @since 0.71
+ *
+ * @param int $deprecated Not used (Was $timezone = 0)
+ */
+function trackback_rdf( $deprecated = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.5' );
+
+	if ( false !== stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') )
+		return;
+
+	echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+			xmlns:dc="http://purl.org/dc/elements/1.1/"
+			xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
+		<rdf:Description rdf:about="';
+	the_permalink();
+	echo '"'."\n";
+	echo '    dc:identifier="';
+	the_permalink();
+	echo '"'."\n";
+	echo '    dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'"'."\n";
+	echo '    trackback:ping="'.get_trackback_url().'"'." />\n";
+	echo '</rdf:RDF>';
+}
+
+/**
+ * Whether the current post is open for comments.
+ *
+ * @since 1.5.0
+ * @uses $post
+ *
+ * @param int $post_id An optional post ID to check instead of the current post.
+ * @return bool True if the comments are open
+ */
+function comments_open( $post_id=NULL ) {
+
+	$_post = get_post($post_id);
+
+	$open = ( 'open' == $_post->comment_status );
+	return apply_filters( 'comments_open', $open, $post_id );
+}
+
+/**
+ * Whether the current post is open for pings.
+ *
+ * @since 1.5.0
+ * @uses $post
+ *
+ * @param int $post_id An optional post ID to check instead of the current post.
+ * @return bool True if pings are accepted
+ */
+function pings_open( $post_id = NULL ) {
+
+	$_post = get_post($post_id);
+
+	$open = ( 'open' == $_post->ping_status );
+	return apply_filters( 'pings_open', $open, $post_id );
+}
+
+/**
+ * Displays form token for unfiltered comments.
+ *
+ * Will only display nonce token if the current user has permissions for
+ * unfiltered html. Won't display the token for other users.
+ *
+ * The function was backported to 2.0.10 and was added to versions 2.1.3 and
+ * above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in
+ * the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0.
+ *
+ * Backported to 2.0.10.
+ *
+ * @since 2.1.3
+ * @uses $post Gets the ID of the current post for the token
+ */
+function wp_comment_form_unfiltered_html_nonce() {
+	global $post;
+
+	$post_id = 0;
+	if ( !empty($post) )
+		$post_id = $post->ID;
+
+	if ( current_user_can('unfiltered_html') )
+		wp_nonce_field('unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment', false);
+}
+
+/**
+ * Loads the comment template specified in $file.
+ *
+ * Will not display the comments template if not on single post or page, or if
+ * the post does not have comments.
+ *
+ * Uses the WordPress database object to query for the comments. The comments
+ * are passed through the 'comments_array' filter hook with the list of comments
+ * and the post ID respectively.
+ *
+ * The $file path is passed through a filter hook called, 'comments_template'
+ * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
+ * first and if it fails it will require the default comment themplate from the
+ * default theme. If either does not exist, then the WordPress process will be
+ * halted. It is advised for that reason, that the default theme is not deleted.
+ *
+ * @since 1.5.0
+ * @global array $comment List of comment objects for the current post
+ * @uses $wpdb
+ * @uses $post
+ * @uses $withcomments Will not try to get the comments if the post has none.
+ *
+ * @param string $file Optional, default '/comments.php'. The file to load
+ * @param bool $separate_comments Optional, whether to separate the comments by comment type. Default is false.
+ * @return null Returns null if no comments appear
+ */
+function comments_template( $file = '/comments.php', $separate_comments = false ) {
+	global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
+
+	if ( !(is_single() || is_page() || $withcomments) || empty($post) )
+		return;
+
+	if ( empty($file) )
+		$file = '/comments.php';
+
+	$req = get_option('require_name_email');
+
+	/**
+	 * Comment author information fetched from the comment cookies.
+	 *
+	 * @uses wp_get_current_commenter()
+	 */
+	$commenter = wp_get_current_commenter();
+
+	/**
+	 * The name of the current comment author escaped for use in attributes.
+	 */
+	$comment_author = $commenter['comment_author']; // Escaped by sanitize_comment_cookies()
+
+	/**
+	 * The email address of the current comment author escaped for use in attributes.
+	 */
+	$comment_author_email = $commenter['comment_author_email'];  // Escaped by sanitize_comment_cookies()
+
+	/**
+	 * The url of the current comment author escaped for use in attributes.
+	 */
+	$comment_author_url = esc_url($commenter['comment_author_url']);
+
+	/** @todo Use API instead of SELECTs. */
+	if ( $user_ID) {
+		$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) )  ORDER BY comment_date_gmt", $post->ID, $user_ID));
+	} else if ( empty($comment_author) ) {
+		$comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') );
+	} else {
+		$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email));
+	}
+
+	// keep $comments for legacy's sake
+	$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
+	$comments = &$wp_query->comments;
+	$wp_query->comment_count = count($wp_query->comments);
+	update_comment_cache($wp_query->comments);
+
+	if ( $separate_comments ) {
+		$wp_query->comments_by_type = &separate_comments($comments);
+		$comments_by_type = &$wp_query->comments_by_type;
+	}
+
+	$overridden_cpage = FALSE;
+	if ( '' == get_query_var('cpage') && get_option('page_comments') ) {
+		set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 );
+		$overridden_cpage = TRUE;
+	}
+
+	if ( !defined('COMMENTS_TEMPLATE') || !COMMENTS_TEMPLATE)
+		define('COMMENTS_TEMPLATE', true);
+
+	$include = apply_filters('comments_template', STYLESHEETPATH . $file );
+	if ( file_exists( $include ) )
+		require( $include );
+	elseif ( file_exists( TEMPLATEPATH . $file ) )
+		require( TEMPLATEPATH .  $file );
+	else // Backward compat code will be removed in a future release
+		require( ABSPATH . WPINC . '/theme-compat/comments.php');
+}
+
+/**
+ * Displays the JS popup script to show a comment.
+ *
+ * If the $file parameter is empty, then the home page is assumed. The defaults
+ * for the window are 400px by 400px.
+ *
+ * For the comment link popup to work, this function has to be called or the
+ * normal comment link will be assumed.
+ *
+ * @since 0.71
+ * @global string $wpcommentspopupfile The URL to use for the popup window
+ * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called
+ *
+ * @param int $width Optional. The width of the popup window
+ * @param int $height Optional. The height of the popup window
+ * @param string $file Optional. Sets the location of the popup window
+ */
+function comments_popup_script($width=400, $height=400, $file='') {
+	global $wpcommentspopupfile, $wpcommentsjavascript;
+
+	if (empty ($file)) {
+		$wpcommentspopupfile = '';  // Use the index.
+	} else {
+		$wpcommentspopupfile = $file;
+	}
+
+	$wpcommentsjavascript = 1;
+	$javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n    window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
+	echo $javascript;
+}
+
+/**
+ * Displays the link to the comments popup window for the current post ID.
+ *
+ * Is not meant to be displayed on single posts and pages. Should be used on the
+ * lists of posts
+ *
+ * @since 0.71
+ * @uses $wpcommentspopupfile
+ * @uses $wpcommentsjavascript
+ * @uses $post
+ *
+ * @param string $zero The string to display when no comments
+ * @param string $one The string to display when only one comment is available
+ * @param string $more The string to display when there are more than one comment
+ * @param string $css_class The CSS class to use for comments
+ * @param string $none The string to display when comments have been turned off
+ * @return null Returns null on single posts and pages.
+ */
+function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
+	global $wpcommentspopupfile, $wpcommentsjavascript;
+
+	$id = get_the_ID();
+
+	if ( false === $zero ) $zero = __( 'No Comments' );
+	if ( false === $one ) $one = __( '1 Comment' );
+	if ( false === $more ) $more = __( '% Comments' );
+	if ( false === $none ) $none = __( 'Comments Off' );
+
+	$number = get_comments_number( $id );
+
+	if ( 0 == $number && !comments_open() && !pings_open() ) {
+		echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
+		return;
+	}
+
+	if ( post_password_required() ) {
+		echo __('Enter your password to view comments.');
+		return;
+	}
+
+	echo '<a href="';
+	if ( $wpcommentsjavascript ) {
+		if ( empty( $wpcommentspopupfile ) )
+			$home = home_url();
+		else
+			$home = get_option('siteurl');
+		echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
+		echo '" onclick="wpopen(this.href); return false"';
+	} else { // if comments_popup_script() is not in the template, display simple comment link
+		if ( 0 == $number )
+			echo get_permalink() . '#respond';
+		else
+			comments_link();
+		echo '"';
+	}
+
+	if ( !empty( $css_class ) ) {
+		echo ' class="'.$css_class.'" ';
+	}
+	$title = the_title_attribute( array('echo' => 0 ) );
+
+	echo apply_filters( 'comments_popup_link_attributes', '' );
+
+	echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">';
+	comments_number( $zero, $one, $more );
+	echo '</a>';
+}
+
+/**
+ * Retrieve HTML content for reply to comment link.
+ *
+ * The default arguments that can be override are 'add_below', 'respond_id',
+ * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
+ * used, if the user must log in or register first before posting a comment. The
+ * 'reply_text' will be used, if they can post a reply. The 'add_below' and
+ * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
+ * parameters.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Optional. Override default options.
+ * @param int $comment Optional. Comment being replied to.
+ * @param int $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function get_comment_reply_link($args = array(), $comment = null, $post = null) {
+	global $user_ID;
+
+	$defaults = array('add_below' => 'comment', 'respond_id' => 'respond', 'reply_text' => __('Reply'),
+		'login_text' => __('Log in to Reply'), 'depth' => 0, 'before' => '', 'after' => '');
+
+	$args = wp_parse_args($args, $defaults);
+
+	if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] )
+		return;
+
+	extract($args, EXTR_SKIP);
+
+	$comment = get_comment($comment);
+	if ( empty($post) )
+		$post = $comment->comment_post_ID;
+	$post = get_post($post);
+
+	if ( !comments_open($post->ID) )
+		return false;
+
+	$link = '';
+
+	if ( get_option('comment_registration') && !$user_ID )
+		$link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>';
+	else
+		$link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
+	return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
+}
+
+/**
+ * Displays the HTML content for reply to comment link.
+ *
+ * @since 2.7.0
+ * @see get_comment_reply_link() Echoes result
+ *
+ * @param array $args Optional. Override default options.
+ * @param int $comment Optional. Comment being replied to.
+ * @param int $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function comment_reply_link($args = array(), $comment = null, $post = null) {
+	echo get_comment_reply_link($args, $comment, $post);
+}
+
+/**
+ * Retrieve HTML content for reply to post link.
+ *
+ * The default arguments that can be override are 'add_below', 'respond_id',
+ * 'reply_text', 'login_text', and 'depth'. The 'login_text' argument will be
+ * used, if the user must log in or register first before posting a comment. The
+ * 'reply_text' will be used, if they can post a reply. The 'add_below' and
+ * 'respond_id' arguments are for the JavaScript moveAddCommentForm() function
+ * parameters.
+ *
+ * @since 2.7.0
+ *
+ * @param array $args Optional. Override default options.
+ * @param int|object $post Optional. Post that the comment is going to be displayed on.  Defaults to current post.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function get_post_reply_link($args = array(), $post = null) {
+	global $user_ID;
+
+	$defaults = array('add_below' => 'post', 'respond_id' => 'respond', 'reply_text' => __('Leave a Comment'),
+		'login_text' => __('Log in to leave a Comment'), 'before' => '', 'after' => '');
+
+	$args = wp_parse_args($args, $defaults);
+	extract($args, EXTR_SKIP);
+	$post = get_post($post);
+
+	if ( !comments_open($post->ID) )
+		return false;
+
+	if ( get_option('comment_registration') && !$user_ID ) {
+		$link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>';
+	} else {
+		$link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
+	}
+	return apply_filters('post_comments_link', $before . $link . $after, $post);
+}
+
+/**
+ * Displays the HTML content for reply to post link.
+ * @since 2.7.0
+ * @see get_post_reply_link()
+ *
+ * @param array $args Optional. Override default options.
+ * @param int|object $post Optional. Post that the comment is going to be displayed on.
+ * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ */
+function post_reply_link($args = array(), $post = null) {
+	echo get_post_reply_link($args, $post);
+}
+
+/**
+ * Retrieve HTML content for cancel comment reply link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $text Optional. Text to display for cancel reply link.
+ */
+function get_cancel_comment_reply_link($text = '') {
+	if ( empty($text) )
+		$text = __('Click here to cancel reply.');
+
+	$style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
+	$link = esc_html( remove_query_arg('replytocom') ) . '#respond';
+	return apply_filters('cancel_comment_reply_link', '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text);
+}
+
+/**
+ * Display HTML content for cancel comment reply link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $text Optional. Text to display for cancel reply link.
+ */
+function cancel_comment_reply_link($text = '') {
+	echo get_cancel_comment_reply_link($text);
+}
+
+/**
+ * Retrieve hidden input HTML for replying to comments.
+ *
+ * @since 3.0.0
+ *
+ * @return string Hidden input HTML for replying to comments
+ */
+function get_comment_id_fields() {
+	$id = get_the_ID();
+
+	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
+	$result  = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
+	$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
+	return apply_filters('comment_id_fields', $result, $id, $replytoid);
+}
+
+/**
+ * Output hidden input HTML for replying to comments.
+ *
+ * @since 2.7.0
+ * @see get_comment_id_fields() Echoes result
+ */
+function comment_id_fields() {
+	echo get_comment_id_fields();
+}
+
+/**
+ * Display text based on comment reply status. Only affects users with Javascript disabled.
+ *
+ * @since 2.7.0
+ *
+ * @param string $noreplytext Optional. Text to display when not replying to a comment.
+ * @param string $replytext Optional. Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to.
+ * @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment.
+ */
+function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = TRUE ) {
+	global $comment;
+
+	if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
+	if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' );
+
+	$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
+
+	if ( 0 == $replytoid )
+		echo $noreplytext;
+	else {
+		$comment = get_comment($replytoid);
+		$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author();
+		printf( $replytext, $author );
+	}
+}
+
+/**
+ * HTML comment list class.
+ *
+ * @package WordPress
+ * @uses Walker
+ * @since 2.7.0
+ */
+class Walker_Comment extends Walker {
+	/**
+	 * @see Walker::$tree_type
+	 * @since 2.7.0
+	 * @var string
+	 */
+	var $tree_type = 'comment';
+
+	/**
+	 * @see Walker::$db_fields
+	 * @since 2.7.0
+	 * @var array
+	 */
+	var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
+
+	/**
+	 * @see Walker::start_lvl()
+	 * @since 2.7.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of comment.
+	 * @param array $args Uses 'style' argument for type of HTML list.
+	 */
+	function start_lvl(&$output, $depth, $args) {
+		$GLOBALS['comment_depth'] = $depth + 1;
+
+		switch ( $args['style'] ) {
+			case 'div':
+				break;
+			case 'ol':
+				echo "<ol class='children'>\n";
+				break;
+			default:
+			case 'ul':
+				echo "<ul class='children'>\n";
+				break;
+		}
+	}
+
+	/**
+	 * @see Walker::end_lvl()
+	 * @since 2.7.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of comment.
+	 * @param array $args Will only append content if style argument value is 'ol' or 'ul'.
+	 */
+	function end_lvl(&$output, $depth, $args) {
+		$GLOBALS['comment_depth'] = $depth + 1;
+
+		switch ( $args['style'] ) {
+			case 'div':
+				break;
+			case 'ol':
+				echo "</ol>\n";
+				break;
+			default:
+			case 'ul':
+				echo "</ul>\n";
+				break;
+		}
+	}
+
+	/**
+	 * This function is designed to enhance Walker::display_element() to
+	 * display children of higher nesting levels than selected inline on
+	 * the highest depth level displayed. This prevents them being orphaned
+	 * at the end of the comment list.
+	 *
+	 * Example: max_depth = 2, with 5 levels of nested content.
+	 * 1
+	 *  1.1
+	 *    1.1.1
+	 *    1.1.1.1
+	 *    1.1.1.1.1
+	 *    1.1.2
+	 *    1.1.2.1
+	 * 2
+	 *  2.2
+	 *
+	 */
+	function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
+
+		if ( !$element )
+			return;
+
+		$id_field = $this->db_fields['id'];
+		$id = $element->$id_field;
+
+		parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
+
+		// If we're at the max depth, and the current element still has children, loop over those and display them at this level
+		// This is to prevent them being orphaned to the end of the list.
+		if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) {
+			foreach ( $children_elements[ $id ] as $child )
+				$this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output );
+
+			unset( $children_elements[ $id ] );
+		}
+
+	}
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 2.7.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $comment Comment data object.
+	 * @param int $depth Depth of comment in reference to parents.
+	 * @param array $args
+	 */
+	function start_el(&$output, $comment, $depth, $args) {
+		$depth++;
+		$GLOBALS['comment_depth'] = $depth;
+
+		if ( !empty($args['callback']) ) {
+			call_user_func($args['callback'], $comment, $args, $depth);
+			return;
+		}
+
+		$GLOBALS['comment'] = $comment;
+		extract($args, EXTR_SKIP);
+
+		if ( 'div' == $args['style'] ) {
+			$tag = 'div';
+			$add_below = 'comment';
+		} else {
+			$tag = 'li';
+			$add_below = 'div-comment';
+		}
+?>
+		<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
+		<?php if ( 'div' != $args['style'] ) : ?>
+		<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
+		<?php endif; ?>
+		<div class="comment-author vcard">
+		<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
+		<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
+		</div>
+<?php if ($comment->comment_approved == '0') : ?>
+		<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
+		<br />
+<?php endif; ?>
+
+		<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
+			<?php
+				/* translators: 1: date, 2: time */
+				printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'&nbsp;&nbsp;','' );
+			?>
+		</div>
+
+		<?php comment_text() ?>
+
+		<div class="reply">
+		<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
+		</div>
+		<?php if ( 'div' != $args['style'] ) : ?>
+		</div>
+		<?php endif; ?>
+<?php
+	}
+
+	/**
+	 * @see Walker::end_el()
+	 * @since 2.7.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $comment
+	 * @param int $depth Depth of comment.
+	 * @param array $args
+	 */
+	function end_el(&$output, $comment, $depth, $args) {
+		if ( !empty($args['end-callback']) ) {
+			call_user_func($args['end-callback'], $comment, $args, $depth);
+			return;
+		}
+		if ( 'div' == $args['style'] )
+			echo "</div>\n";
+		else
+			echo "</li>\n";
+	}
+
+}
+
+/**
+ * List comments
+ *
+ * Used in the comments.php template to list comments for a particular post
+ *
+ * @since 2.7.0
+ * @uses Walker_Comment
+ *
+ * @param string|array $args Formatting options
+ * @param array $comments Optional array of comment objects.  Defaults to $wp_query->comments
+ */
+function wp_list_comments($args = array(), $comments = null ) {
+	global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
+
+	$in_comment_loop = true;
+
+	$comment_alt = $comment_thread_alt = 0;
+	$comment_depth = 1;
+
+	$defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
+		'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
+
+	$r = wp_parse_args( $args, $defaults );
+
+	// Figure out what comments we'll be looping through ($_comments)
+	if ( null !== $comments ) {
+		$comments = (array) $comments;
+		if ( empty($comments) )
+			return;
+		if ( 'all' != $r['type'] ) {
+			$comments_by_type = &separate_comments($comments);
+			if ( empty($comments_by_type[$r['type']]) )
+				return;
+			$_comments = $comments_by_type[$r['type']];
+		} else {
+			$_comments = $comments;
+		}
+	} else {
+		if ( empty($wp_query->comments) )
+			return;
+		if ( 'all' != $r['type'] ) {
+			if ( empty($wp_query->comments_by_type) )
+				$wp_query->comments_by_type = &separate_comments($wp_query->comments);
+			if ( empty($wp_query->comments_by_type[$r['type']]) )
+				return;
+			$_comments = $wp_query->comments_by_type[$r['type']];
+		} else {
+			$_comments = $wp_query->comments;
+		}
+	}
+
+	if ( '' === $r['per_page'] && get_option('page_comments') )
+		$r['per_page'] = get_query_var('comments_per_page');
+
+	if ( empty($r['per_page']) ) {
+		$r['per_page'] = 0;
+		$r['page'] = 0;
+	}
+
+	if ( '' === $r['max_depth'] ) {
+		if ( get_option('thread_comments') )
+			$r['max_depth'] = get_option('thread_comments_depth');
+		else
+			$r['max_depth'] = -1;
+	}
+
+	if ( '' === $r['page'] ) {
+		if ( empty($overridden_cpage) ) {
+			$r['page'] = get_query_var('cpage');
+		} else {
+			$threaded = ( -1 != $r['max_depth'] );
+			$r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
+			set_query_var( 'cpage', $r['page'] );
+		}
+	}
+	// Validation check
+	$r['page'] = intval($r['page']);
+	if ( 0 == $r['page'] && 0 != $r['per_page'] )
+		$r['page'] = 1;
+
+	if ( null === $r['reverse_top_level'] )
+		$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
+
+	extract( $r, EXTR_SKIP );
+
+	if ( empty($walker) )
+		$walker = new Walker_Comment;
+
+	$walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
+	$wp_query->max_num_comment_pages = $walker->max_pages;
+
+	$in_comment_loop = false;
+}
+
+/**
+ * Outputs a complete commenting form for use within a template.
+ * Most strings and form fields may be controlled through the $args array passed
+ * into the function, while you may also choose to use the comment_form_default_fields
+ * filter to modify the array of default fields if you'd just like to add a new
+ * one or remove a single field. All fields are also individually passed through
+ * a filter of the form comment_form_field_$name where $name is the key used
+ * in the array of fields.
+ *
+ * @since 3.0.0
+ * @param array $args Options for strings, fields etc in the form
+ * @param mixed $post_id Post ID to generate the form for, uses the current post if null
+ * @return void
+ */
+function comment_form( $args = array(), $post_id = null ) {
+	global $user_identity, $id;
+
+	if ( null === $post_id )
+		$post_id = $id;
+	else
+		$id = $post_id;
+
+	$commenter = wp_get_current_commenter();
+
+	$req = get_option( 'require_name_email' );
+	$aria_req = ( $req ? " aria-required='true'" : '' );
+	$fields =  array(
+		'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
+		            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
+		'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
+		            '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
+		'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
+		            '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
+	);
+
+	$required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
+	$defaults = array(
+		'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
+		'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
+		'must_log_in'          => '<p class="must-log-in">' .  sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
+		'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
+		'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>',
+		'comment_notes_after'  => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
+		'id_form'              => 'commentform',
+		'id_submit'            => 'submit',
+		'title_reply'          => __( 'Leave a Reply' ),
+		'title_reply_to'       => __( 'Leave a Reply to %s' ),
+		'cancel_reply_link'    => __( 'Cancel reply' ),
+		'label_submit'         => __( 'Post Comment' ),
+	);
+
+	$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
+
+	?>
+		<?php if ( comments_open() ) : ?>
+			<?php do_action( 'comment_form_before' ); ?>
+			<div id="respond">
+				<h3 id="reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3>
+				<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
+					<?php echo $args['must_log_in']; ?>
+					<?php do_action( 'comment_form_must_log_in_after' ); ?>
+				<?php else : ?>
+					<form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>">
+						<?php do_action( 'comment_form_top' ); ?>
+						<?php if ( is_user_logged_in() ) : ?>
+							<?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>
+							<?php do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?>
+						<?php else : ?>
+							<?php echo $args['comment_notes_before']; ?>
+							<?php
+							do_action( 'comment_form_before_fields' );
+							foreach ( (array) $args['fields'] as $name => $field ) {
+								echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
+							}
+							do_action( 'comment_form_after_fields' );
+							?>
+						<?php endif; ?>
+						<?php echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?>
+						<?php echo $args['comment_notes_after']; ?>
+						<p class="form-submit">
+							<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />
+							<?php comment_id_fields(); ?>
+						</p>
+						<?php do_action( 'comment_form', $post_id ); ?>
+					</form>
+				<?php endif; ?>
+			</div><!-- #respond -->
+			<?php do_action( 'comment_form_after' ); ?>
+		<?php else : ?>
+			<?php do_action( 'comment_form_comments_closed' ); ?>
+		<?php endif; ?>
+	<?php
+}
+
+?>
Index: /tags/3.1/wp-includes/comment.php
===================================================================
--- /tags/3.1/wp-includes/comment.php	(revision 17487)
+++ /tags/3.1/wp-includes/comment.php	(revision 17487)
@@ -0,0 +1,1998 @@
+<?php
+/**
+ * Manages WordPress comments
+ *
+ * @package WordPress
+ * @subpackage Comment
+ */
+
+/**
+ * Checks whether a comment passes internal checks to be allowed to add.
+ *
+ * If comment moderation is set in the administration, then all comments,
+ * regardless of their type and whitelist will be set to false. If the number of
+ * links exceeds the amount in the administration, then the check fails. If any
+ * of the parameter contents match the blacklist of words, then the check fails.
+ *
+ * If the number of links exceeds the amount in the administration, then the
+ * check fails. If any of the parameter contents match the blacklist of words,
+ * then the check fails.
+ *
+ * If the comment author was approved before, then the comment is
+ * automatically whitelisted.
+ *
+ * If none of the checks fail, then the failback is to set the check to pass
+ * (return true).
+ *
+ * @since 1.2.0
+ * @uses $wpdb
+ *
+ * @param string $author Comment Author's name
+ * @param string $email Comment Author's email
+ * @param string $url Comment Author's URL
+ * @param string $comment Comment contents
+ * @param string $user_ip Comment Author's IP address
+ * @param string $user_agent Comment Author's User Agent
+ * @param string $comment_type Comment type, either user submitted comment,
+ *		trackback, or pingback
+ * @return bool Whether the checks passed (true) and the comments should be
+ *		displayed or set to moderated
+ */
+function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
+	global $wpdb;
+
+	if ( 1 == get_option('comment_moderation') )
+		return false; // If moderation is set to manual
+
+	$comment = apply_filters( 'comment_text', $comment );
+
+	// Check # of external links
+	if ( $max_links = get_option( 'comment_max_links' ) ) {
+		$num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out );
+		$num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); // provide for counting of $url as a link
+		if ( $num_links >= $max_links )
+			return false;
+	}
+
+	$mod_keys = trim(get_option('moderation_keys'));
+	if ( !empty($mod_keys) ) {
+		$words = explode("\n", $mod_keys );
+
+		foreach ( (array) $words as $word) {
+			$word = trim($word);
+
+			// Skip empty lines
+			if ( empty($word) )
+				continue;
+
+			// Do some escaping magic so that '#' chars in the
+			// spam words don't break things:
+			$word = preg_quote($word, '#');
+
+			$pattern = "#$word#i";
+			if ( preg_match($pattern, $author) ) return false;
+			if ( preg_match($pattern, $email) ) return false;
+			if ( preg_match($pattern, $url) ) return false;
+			if ( preg_match($pattern, $comment) ) return false;
+			if ( preg_match($pattern, $user_ip) ) return false;
+			if ( preg_match($pattern, $user_agent) ) return false;
+		}
+	}
+
+	// Comment whitelisting:
+	if ( 1 == get_option('comment_whitelist')) {
+		if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) {
+			// expected_slashed ($author, $email)
+			$ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
+			if ( ( 1 == $ok_to_comment ) &&
+				( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
+					return true;
+			else
+				return false;
+		} else {
+			return false;
+		}
+	}
+	return true;
+}
+
+/**
+ * Retrieve the approved comments for post $post_id.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ *
+ * @param int $post_id The ID of the post
+ * @return array $comments The approved comments
+ */
+function get_approved_comments($post_id) {
+	global $wpdb;
+	return $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id));
+}
+
+/**
+ * Retrieves comment data given a comment ID or comment object.
+ *
+ * If an object is passed then the comment data will be cached and then returned
+ * after being passed through a filter. If the comment is empty, then the global
+ * comment variable will be used, if it is set.
+ *
+ * If the comment is empty, then the global comment variable will be used, if it
+ * is set.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ *
+ * @param object|string|int $comment Comment to retrieve.
+ * @param string $output Optional. OBJECT or ARRAY_A or ARRAY_N constants.
+ * @return object|array|null Depends on $output value.
+ */
+function &get_comment(&$comment, $output = OBJECT) {
+	global $wpdb;
+	$null = null;
+
+	if ( empty($comment) ) {
+		if ( isset($GLOBALS['comment']) )
+			$_comment = & $GLOBALS['comment'];
+		else
+			$_comment = null;
+	} elseif ( is_object($comment) ) {
+		wp_cache_add($comment->comment_ID, $comment, 'comment');
+		$_comment = $comment;
+	} else {
+		if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) {
+			$_comment = & $GLOBALS['comment'];
+		} elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) {
+			$_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment));
+			if ( ! $_comment )
+				return $null;
+			wp_cache_add($_comment->comment_ID, $_comment, 'comment');
+		}
+	}
+
+	$_comment = apply_filters('get_comment', $_comment);
+
+	if ( $output == OBJECT ) {
+		return $_comment;
+	} elseif ( $output == ARRAY_A ) {
+		$__comment = get_object_vars($_comment);
+		return $__comment;
+	} elseif ( $output == ARRAY_N ) {
+		$__comment = array_values(get_object_vars($_comment));
+		return $__comment;
+	} else {
+		return $_comment;
+	}
+}
+
+/**
+ * Retrieve a list of comments.
+ *
+ * The comment list can be for the blog as a whole or for an individual post.
+ *
+ * The list of comment arguments are 'status', 'orderby', 'comment_date_gmt',
+ * 'order', 'number', 'offset', and 'post_id'.
+ *
+ * @since 2.7.0
+ * @uses $wpdb
+ *
+ * @param mixed $args Optional. Array or string of options to override defaults.
+ * @return array List of comments.
+ */
+function get_comments( $args = '' ) {
+	$query = new WP_Comment_Query;
+	return $query->query( $args );
+}
+
+/**
+ * WordPress Comment Query class.
+ *
+ * @since 3.1.0
+ */
+class WP_Comment_Query {
+
+	/**
+	 * Execute the query
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param string|array $query_vars
+	 * @return int|array
+	 */
+	function query( $query_vars ) {
+		global $wpdb;
+
+		$defaults = array(
+			'author_email' => '',
+			'ID' => '',
+			'karma' => '',
+			'number' => '',
+			'offset' => '',
+			'orderby' => '',
+			'order' => 'DESC',
+			'parent' => '',
+			'post_ID' => '',
+			'post_id' => 0,
+			'status' => '',
+			'type' => '',
+			'user_id' => '',
+			'search' => '',
+			'count' => false
+		);
+
+		$this->query_vars = wp_parse_args( $query_vars, $defaults );
+		do_action_ref_array( 'pre_get_comments', array( &$this ) );
+		extract( $this->query_vars, EXTR_SKIP );
+
+		// $args can be whatever, only use the args defined in defaults to compute the key
+		$key = md5( serialize( compact(array_keys($defaults)) )  );
+		$last_changed = wp_cache_get('last_changed', 'comment');
+		if ( !$last_changed ) {
+			$last_changed = time();
+			wp_cache_set('last_changed', $last_changed, 'comment');
+		}
+		$cache_key = "get_comments:$key:$last_changed";
+
+		if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) {
+			return $cache;
+		}
+
+		$post_id = absint($post_id);
+
+		if ( 'hold' == $status )
+			$approved = "comment_approved = '0'";
+		elseif ( 'approve' == $status )
+			$approved = "comment_approved = '1'";
+		elseif ( 'spam' == $status )
+			$approved = "comment_approved = 'spam'";
+		elseif ( 'trash' == $status )
+			$approved = "comment_approved = 'trash'";
+		else
+			$approved = "( comment_approved = '0' OR comment_approved = '1' )";
+
+		$order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC';
+
+		if ( ! empty( $orderby ) ) {
+			$ordersby = is_array($orderby) ? $orderby : preg_split('/[,\s]/', $orderby);
+			$ordersby = array_intersect(
+				$ordersby,
+				array(
+					'comment_agent',
+					'comment_approved',
+					'comment_author',
+					'comment_author_email',
+					'comment_author_IP',
+					'comment_author_url',
+					'comment_content',
+					'comment_date',
+					'comment_date_gmt',
+					'comment_ID',
+					'comment_karma',
+					'comment_parent',
+					'comment_post_ID',
+					'comment_type',
+					'user_id',
+				)
+			);
+			$orderby = empty( $ordersby ) ? 'comment_date_gmt' : implode(', ', $ordersby);
+		} else {
+			$orderby = 'comment_date_gmt';
+		}
+
+		$number = absint($number);
+		$offset = absint($offset);
+
+		if ( !empty($number) ) {
+			if ( $offset )
+				$limits = 'LIMIT ' . $offset . ',' . $number;
+			else
+				$limits = 'LIMIT ' . $number;
+		} else {
+			$limits = '';
+		}
+
+		if ( $count )
+			$fields = 'COUNT(*)';
+		else
+			$fields = '*';
+
+		$join = '';
+		$where = $approved;
+
+		if ( ! empty($post_id) )
+			$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
+		if ( '' !== $author_email )
+			$where .= $wpdb->prepare( ' AND comment_author_email = %s', $author_email );
+		if ( '' !== $karma )
+			$where .= $wpdb->prepare( ' AND comment_karma = %d', $karma );
+		if ( 'comment' == $type ) {
+			$where .= " AND comment_type = ''";
+		} elseif( 'pings' == $type ) {
+			$where .= ' AND comment_type IN ("pingback", "trackback")';
+		} elseif ( ! empty( $type ) ) {
+			$where .= $wpdb->prepare( ' AND comment_type = %s', $type );
+		}
+		if ( '' !== $parent )
+			$where .= $wpdb->prepare( ' AND comment_parent = %d', $parent );
+		if ( '' !== $user_id )
+			$where .= $wpdb->prepare( ' AND user_id = %d', $user_id );
+		if ( '' !== $search )
+			$where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) );
+
+		$pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
+		$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
+		foreach ( $pieces as $piece )
+			$$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
+
+		$query = "SELECT $fields FROM $wpdb->comments $join WHERE $where ORDER BY $orderby $order $limits";
+
+		if ( $count )
+			return $wpdb->get_var( $query );
+
+		$comments = $wpdb->get_results( $query );
+		$comments = apply_filters_ref_array( 'the_comments', array( $comments, &$this ) );
+
+		wp_cache_add( $cache_key, $comments, 'comment' );
+
+		return $comments;
+	}
+
+	/*
+	 * Used internally to generate an SQL string for searching across multiple columns
+	 *
+	 * @access protected
+	 * @since 3.1.0
+	 *
+	 * @param string $string
+	 * @param array $cols
+	 * @return string
+	 */
+	function get_search_sql( $string, $cols ) {
+		$string = esc_sql( like_escape( $string ) );
+
+		$searches = array();
+		foreach ( $cols as $col )
+			$searches[] = "$col LIKE '%$string%'";
+
+		return ' AND (' . implode(' OR ', $searches) . ')';
+	}
+}
+
+/**
+ * Retrieve all of the WordPress supported comment statuses.
+ *
+ * Comments have a limited set of valid status values, this provides the comment
+ * status values and descriptions.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 2.7.0
+ *
+ * @return array List of comment statuses.
+ */
+function get_comment_statuses( ) {
+	$status = array(
+		'hold'		=> __('Unapproved'),
+		/* translators: comment status  */
+		'approve'	=> _x('Approved', 'adjective'),
+		/* translators: comment status */
+		'spam'		=> _x('Spam', 'adjective'),
+	);
+
+	return $status;
+}
+
+
+/**
+ * The date the last comment was modified.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ * @global array $cache_lastcommentmodified
+ *
+ * @param string $timezone Which timezone to use in reference to 'gmt', 'blog',
+ *		or 'server' locations.
+ * @return string Last comment modified date.
+ */
+function get_lastcommentmodified($timezone = 'server') {
+	global $cache_lastcommentmodified, $wpdb;
+
+	if ( isset($cache_lastcommentmodified[$timezone]) )
+		return $cache_lastcommentmodified[$timezone];
+
+	$add_seconds_server = date('Z');
+
+	switch ( strtolower($timezone)) {
+		case 'gmt':
+			$lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
+			break;
+		case 'blog':
+			$lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1");
+			break;
+		case 'server':
+			$lastcommentmodified = $wpdb->get_var($wpdb->prepare("SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server));
+			break;
+	}
+
+	$cache_lastcommentmodified[$timezone] = $lastcommentmodified;
+
+	return $lastcommentmodified;
+}
+
+/**
+ * The amount of comments in a post or total comments.
+ *
+ * A lot like {@link wp_count_comments()}, in that they both return comment
+ * stats (albeit with different types). The {@link wp_count_comments()} actual
+ * caches, but this function does not.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ *
+ * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide.
+ * @return array The amount of spam, approved, awaiting moderation, and total comments.
+ */
+function get_comment_count( $post_id = 0 ) {
+	global $wpdb;
+
+	$post_id = (int) $post_id;
+
+	$where = '';
+	if ( $post_id > 0 ) {
+		$where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id);
+	}
+
+	$totals = (array) $wpdb->get_results("
+		SELECT comment_approved, COUNT( * ) AS total
+		FROM {$wpdb->comments}
+		{$where}
+		GROUP BY comment_approved
+	", ARRAY_A);
+
+	$comment_count = array(
+		"approved"              => 0,
+		"awaiting_moderation"   => 0,
+		"spam"                  => 0,
+		"total_comments"        => 0
+	);
+
+	foreach ( $totals as $row ) {
+		switch ( $row['comment_approved'] ) {
+			case 'spam':
+				$comment_count['spam'] = $row['total'];
+				$comment_count["total_comments"] += $row['total'];
+				break;
+			case 1:
+				$comment_count['approved'] = $row['total'];
+				$comment_count['total_comments'] += $row['total'];
+				break;
+			case 0:
+				$comment_count['awaiting_moderation'] = $row['total'];
+				$comment_count['total_comments'] += $row['total'];
+				break;
+			default:
+				break;
+		}
+	}
+
+	return $comment_count;
+}
+
+//
+// Comment meta functions
+//
+
+/**
+ * Add meta data field to a comment.
+ *
+ * @since 2.9.0
+ * @uses add_metadata
+ * @link http://codex.wordpress.org/Function_Reference/add_comment_meta
+ *
+ * @param int $comment_id Comment ID.
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Metadata value.
+ * @param bool $unique Optional, default is false. Whether the same key should not be added.
+ * @return bool False for failure. True for success.
+ */
+function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false) {
+	return add_metadata('comment', $comment_id, $meta_key, $meta_value, $unique);
+}
+
+/**
+ * Remove metadata matching criteria from a comment.
+ *
+ * You can match based on the key, or key and value. Removing based on key and
+ * value, will keep from removing duplicate metadata with the same key. It also
+ * allows removing all metadata matching key, if needed.
+ *
+ * @since 2.9.0
+ * @uses delete_metadata
+ * @link http://codex.wordpress.org/Function_Reference/delete_comment_meta
+ *
+ * @param int $comment_id comment ID
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Optional. Metadata value.
+ * @return bool False for failure. True for success.
+ */
+function delete_comment_meta($comment_id, $meta_key, $meta_value = '') {
+	return delete_metadata('comment', $comment_id, $meta_key, $meta_value);
+}
+
+/**
+ * Retrieve comment meta field for a comment.
+ *
+ * @since 2.9.0
+ * @uses get_metadata
+ * @link http://codex.wordpress.org/Function_Reference/get_comment_meta
+ *
+ * @param int $comment_id Comment ID.
+ * @param string $key The meta key to retrieve.
+ * @param bool $single Whether to return a single value.
+ * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
+ *  is true.
+ */
+function get_comment_meta($comment_id, $key, $single = false) {
+	return get_metadata('comment', $comment_id, $key, $single);
+}
+
+/**
+ * Update comment meta field based on comment ID.
+ *
+ * Use the $prev_value parameter to differentiate between meta fields with the
+ * same key and comment ID.
+ *
+ * If the meta field for the comment does not exist, it will be added.
+ *
+ * @since 2.9.0
+ * @uses update_metadata
+ * @link http://codex.wordpress.org/Function_Reference/update_comment_meta
+ *
+ * @param int $comment_id Comment ID.
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @param mixed $prev_value Optional. Previous value to check before removing.
+ * @return bool False on failure, true if success.
+ */
+function update_comment_meta($comment_id, $meta_key, $meta_value, $prev_value = '') {
+	return update_metadata('comment', $comment_id, $meta_key, $meta_value, $prev_value);
+}
+
+/**
+ * Sanitizes the cookies sent to the user already.
+ *
+ * Will only do anything if the cookies have already been created for the user.
+ * Mostly used after cookies had been sent to use elsewhere.
+ *
+ * @since 2.0.4
+ */
+function sanitize_comment_cookies() {
+	if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
+		$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
+		$comment_author = stripslashes($comment_author);
+		$comment_author = esc_attr($comment_author);
+		$_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
+	}
+
+	if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
+		$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
+		$comment_author_email = stripslashes($comment_author_email);
+		$comment_author_email = esc_attr($comment_author_email);
+		$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
+	}
+
+	if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
+		$comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
+		$comment_author_url = stripslashes($comment_author_url);
+		$_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
+	}
+}
+
+/**
+ * Validates whether this comment is allowed to be made.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ * @uses apply_filters() Calls 'pre_comment_approved' hook on the type of comment
+ * @uses apply_filters() Calls 'comment_duplicate_trigger' hook on commentdata.
+ * @uses do_action() Calls 'check_comment_flood' hook on $comment_author_IP, $comment_author_email, and $comment_date_gmt
+ *
+ * @param array $commentdata Contains information on the comment
+ * @return mixed Signifies the approval status (0|1|'spam')
+ */
+function wp_allow_comment($commentdata) {
+	global $wpdb;
+	extract($commentdata, EXTR_SKIP);
+
+	// Simple duplicate check
+	// expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
+	$dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' ";
+	if ( $comment_author_email )
+		$dupe .= "OR comment_author_email = '$comment_author_email' ";
+	$dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
+	if ( $wpdb->get_var($dupe) ) {
+		do_action( 'comment_duplicate_trigger', $commentdata );
+		if ( defined('DOING_AJAX') )
+			die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
+
+		wp_die( __('Duplicate comment detected; it looks as though you&#8217;ve already said that!') );
+	}
+
+	do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );
+
+	if ( isset($user_id) && $user_id) {
+		$userdata = get_userdata($user_id);
+		$user = new WP_User($user_id);
+		$post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID));
+	}
+
+	if ( isset($userdata) && ( $user_id == $post_author || $user->has_cap('moderate_comments') ) ) {
+		// The author and the admins get respect.
+		$approved = 1;
+	 } else {
+		// Everyone else's comments will be checked.
+		if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
+			$approved = 1;
+		else
+			$approved = 0;
+		if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
+			$approved = 'spam';
+	}
+
+	$approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );
+	return $approved;
+}
+
+/**
+ * Check whether comment flooding is occurring.
+ *
+ * Won't run, if current user can manage options, so to not block
+ * administrators.
+ *
+ * @since 2.3.0
+ * @uses $wpdb
+ * @uses apply_filters() Calls 'comment_flood_filter' filter with first
+ *		parameter false, last comment timestamp, new comment timestamp.
+ * @uses do_action() Calls 'comment_flood_trigger' action with parameters with
+ *		last comment timestamp and new comment timestamp.
+ *
+ * @param string $ip Comment IP.
+ * @param string $email Comment author email address.
+ * @param string $date MySQL time string.
+ */
+function check_comment_flood_db( $ip, $email, $date ) {
+	global $wpdb;
+	if ( current_user_can( 'manage_options' ) )
+		return; // don't throttle admins
+	$hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 );
+	if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) {
+		$time_lastcomment = mysql2date('U', $lasttime, false);
+		$time_newcomment  = mysql2date('U', $date, false);
+		$flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment);
+		if ( $flood_die ) {
+			do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
+
+			if ( defined('DOING_AJAX') )
+				die( __('You are posting comments too quickly.  Slow down.') );
+
+			wp_die( __('You are posting comments too quickly.  Slow down.'), '', array('response' => 403) );
+		}
+	}
+}
+
+/**
+ * Separates an array of comments into an array keyed by comment_type.
+ *
+ * @since 2.7.0
+ *
+ * @param array $comments Array of comments
+ * @return array Array of comments keyed by comment_type.
+ */
+function &separate_comments(&$comments) {
+	$comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());
+	$count = count($comments);
+	for ( $i = 0; $i < $count; $i++ ) {
+		$type = $comments[$i]->comment_type;
+		if ( empty($type) )
+			$type = 'comment';
+		$comments_by_type[$type][] = &$comments[$i];
+		if ( 'trackback' == $type || 'pingback' == $type )
+			$comments_by_type['pings'][] = &$comments[$i];
+	}
+
+	return $comments_by_type;
+}
+
+/**
+ * Calculate the total number of comment pages.
+ *
+ * @since 2.7.0
+ * @uses get_query_var() Used to fill in the default for $per_page parameter.
+ * @uses get_option() Used to fill in defaults for parameters.
+ * @uses Walker_Comment
+ *
+ * @param array $comments Optional array of comment objects.  Defaults to $wp_query->comments
+ * @param int $per_page Optional comments per page.
+ * @param boolean $threaded Optional control over flat or threaded comments.
+ * @return int Number of comment pages.
+ */
+function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
+	global $wp_query;
+
+	if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) )
+		return $wp_query->max_num_comment_pages;
+
+	if ( !$comments || !is_array($comments) )
+		$comments = $wp_query->comments;
+
+	if ( empty($comments) )
+		return 0;
+
+	if ( !isset($per_page) )
+		$per_page = (int) get_query_var('comments_per_page');
+	if ( 0 === $per_page )
+		$per_page = (int) get_option('comments_per_page');
+	if ( 0 === $per_page )
+		return 1;
+
+	if ( !isset($threaded) )
+		$threaded = get_option('thread_comments');
+
+	if ( $threaded ) {
+		$walker = new Walker_Comment;
+		$count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page );
+	} else {
+		$count = ceil( count( $comments ) / $per_page );
+	}
+
+	return $count;
+}
+
+/**
+ * Calculate what page number a comment will appear on for comment paging.
+ *
+ * @since 2.7.0
+ * @uses get_comment() Gets the full comment of the $comment_ID parameter.
+ * @uses get_option() Get various settings to control function and defaults.
+ * @uses get_page_of_comment() Used to loop up to top level comment.
+ *
+ * @param int $comment_ID Comment ID.
+ * @param array $args Optional args.
+ * @return int|null Comment page number or null on error.
+ */
+function get_page_of_comment( $comment_ID, $args = array() ) {
+	global $wpdb;
+
+	if ( !$comment = get_comment( $comment_ID ) )
+		return;
+
+	$defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' );
+	$args = wp_parse_args( $args, $defaults );
+
+	if ( '' === $args['per_page'] && get_option('page_comments') )
+		$args['per_page'] = get_query_var('comments_per_page');
+	if ( empty($args['per_page']) ) {
+		$args['per_page'] = 0;
+		$args['page'] = 0;
+	}
+	if ( $args['per_page'] < 1 )
+		return 1;
+
+	if ( '' === $args['max_depth'] ) {
+		if ( get_option('thread_comments') )
+			$args['max_depth'] = get_option('thread_comments_depth');
+		else
+			$args['max_depth'] = -1;
+	}
+
+	// Find this comment's top level parent if threading is enabled
+	if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent )
+		return get_page_of_comment( $comment->comment_parent, $args );
+
+	$allowedtypes = array(
+		'comment' => '',
+		'pingback' => 'pingback',
+		'trackback' => 'trackback',
+	);
+
+	$comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : '';
+
+	// Count comments older than this one
+	$oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) );
+
+	// No older comments? Then it's page #1.
+	if ( 0 == $oldercoms )
+		return 1;
+
+	// Divide comments older than this one by comments per page to get this comment's page number
+	return ceil( ( $oldercoms + 1 ) / $args['per_page'] );
+}
+
+/**
+ * Does comment contain blacklisted characters or words.
+ *
+ * @since 1.5.0
+ * @uses do_action() Calls 'wp_blacklist_check' hook for all parameters.
+ *
+ * @param string $author The author of the comment
+ * @param string $email The email of the comment
+ * @param string $url The url used in the comment
+ * @param string $comment The comment content
+ * @param string $user_ip The comment author IP address
+ * @param string $user_agent The author's browser user agent
+ * @return bool True if comment contains blacklisted content, false if comment does not
+ */
+function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) {
+	do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent);
+
+	$mod_keys = trim( get_option('blacklist_keys') );
+	if ( '' == $mod_keys )
+		return false; // If moderation keys are empty
+	$words = explode("\n", $mod_keys );
+
+	foreach ( (array) $words as $word ) {
+		$word = trim($word);
+
+		// Skip empty lines
+		if ( empty($word) ) { continue; }
+
+		// Do some escaping magic so that '#' chars in the
+		// spam words don't break things:
+		$word = preg_quote($word, '#');
+
+		$pattern = "#$word#i";
+		if (
+			   preg_match($pattern, $author)
+			|| preg_match($pattern, $email)
+			|| preg_match($pattern, $url)
+			|| preg_match($pattern, $comment)
+			|| preg_match($pattern, $user_ip)
+			|| preg_match($pattern, $user_agent)
+		 )
+			return true;
+	}
+	return false;
+}
+
+/**
+ * Retrieve total comments for blog or single post.
+ *
+ * The properties of the returned object contain the 'moderated', 'approved',
+ * and spam comments for either the entire blog or single post. Those properties
+ * contain the amount of comments that match the status. The 'total_comments'
+ * property contains the integer of total comments.
+ *
+ * The comment stats are cached and then retrieved, if they already exist in the
+ * cache.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return object Comment stats.
+ */
+function wp_count_comments( $post_id = 0 ) {
+	global $wpdb;
+
+	$post_id = (int) $post_id;
+
+	$stats = apply_filters('wp_count_comments', array(), $post_id);
+	if ( !empty($stats) )
+		return $stats;
+
+	$count = wp_cache_get("comments-{$post_id}", 'counts');
+
+	if ( false !== $count )
+		return $count;
+
+	$where = '';
+	if ( $post_id > 0 )
+		$where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id );
+
+	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
+
+	$total = 0;
+	$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
+	$known_types = array_keys( $approved );
+	foreach ( (array) $count as $row ) {
+		// Don't count post-trashed toward totals
+		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
+			$total += $row['num_comments'];
+		if ( in_array( $row['comment_approved'], $known_types ) )
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
+	}
+
+	$stats['total_comments'] = $total;
+	foreach ( $approved as $key ) {
+		if ( empty($stats[$key]) )
+			$stats[$key] = 0;
+	}
+
+	$stats = (object) $stats;
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
+
+	return $stats;
+}
+
+/**
+ * Trashes or deletes a comment.
+ *
+ * The comment is moved to trash instead of permanently deleted unless trash is
+ * disabled, item is already in the trash, or $force_delete is true.
+ *
+ * The post comment count will be updated if the comment was approved and has a
+ * post ID available.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ * @uses do_action() Calls 'delete_comment' hook on comment ID
+ * @uses do_action() Calls 'deleted_comment' hook on comment ID after deletion, on success
+ * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter
+ * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
+ *
+ * @param int $comment_id Comment ID
+ * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
+ * @return bool False if delete comment query failure, true on success.
+ */
+function wp_delete_comment($comment_id, $force_delete = false) {
+	global $wpdb;
+	if (!$comment = get_comment($comment_id))
+		return false;
+
+	if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) )
+		return wp_trash_comment($comment_id);
+
+	do_action('delete_comment', $comment_id);
+
+	// Move children up a level.
+	$children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) );
+	if ( !empty($children) ) {
+		$wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id));
+		clean_comment_cache($children);
+	}
+
+	// Delete metadata
+	$meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d ", $comment_id ) );
+	if ( !empty($meta_ids) ) {
+		do_action( 'delete_commentmeta', $meta_ids );
+		$in_meta_ids = "'" . implode("', '", $meta_ids) . "'";
+		$wpdb->query( "DELETE FROM $wpdb->commentmeta WHERE meta_id IN ($in_meta_ids)" );
+		do_action( 'deleted_commentmeta', $meta_ids );
+	}
+
+	if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
+		return false;
+	do_action('deleted_comment', $comment_id);
+
+	$post_id = $comment->comment_post_ID;
+	if ( $post_id && $comment->comment_approved == 1 )
+		wp_update_comment_count($post_id);
+
+	clean_comment_cache($comment_id);
+
+	do_action('wp_set_comment_status', $comment_id, 'delete');
+	wp_transition_comment_status('delete', $comment->comment_approved, $comment);
+	return true;
+}
+
+/**
+ * Moves a comment to the Trash
+ *
+ * If trash is disabled, comment is permanently deleted.
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'trash_comment' before trashing
+ * @uses do_action() on 'trashed_comment' after trashing
+ * @uses wp_delete_comment() if trash is disabled
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_trash_comment($comment_id) {
+	if ( !EMPTY_TRASH_DAYS )
+		return wp_delete_comment($comment_id, true);
+
+	if ( !$comment = get_comment($comment_id) )
+		return false;
+
+	do_action('trash_comment', $comment_id);
+
+	if ( wp_set_comment_status($comment_id, 'trash') ) {
+		add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
+		add_comment_meta($comment_id, '_wp_trash_meta_time', time() );
+		do_action('trashed_comment', $comment_id);
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * Removes a comment from the Trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'untrash_comment' before untrashing
+ * @uses do_action() on 'untrashed_comment' after untrashing
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_untrash_comment($comment_id) {
+	if ( ! (int)$comment_id )
+		return false;
+
+	do_action('untrash_comment', $comment_id);
+
+	$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
+	if ( empty($status) )
+		$status = '0';
+
+	if ( wp_set_comment_status($comment_id, $status) ) {
+		delete_comment_meta($comment_id, '_wp_trash_meta_time');
+		delete_comment_meta($comment_id, '_wp_trash_meta_status');
+		do_action('untrashed_comment', $comment_id);
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * Marks a comment as Spam
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'spam_comment' before spamming
+ * @uses do_action() on 'spammed_comment' after spamming
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_spam_comment($comment_id) {
+	if ( !$comment = get_comment($comment_id) )
+		return false;
+
+	do_action('spam_comment', $comment_id);
+
+	if ( wp_set_comment_status($comment_id, 'spam') ) {
+		add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
+		do_action('spammed_comment', $comment_id);
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * Removes a comment from the Spam
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'unspam_comment' before unspamming
+ * @uses do_action() on 'unspammed_comment' after unspamming
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_unspam_comment($comment_id) {
+	if ( ! (int)$comment_id )
+		return false;
+
+	do_action('unspam_comment', $comment_id);
+
+	$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
+	if ( empty($status) )
+		$status = '0';
+
+	if ( wp_set_comment_status($comment_id, $status) ) {
+		delete_comment_meta($comment_id, '_wp_trash_meta_status');
+		do_action('unspammed_comment', $comment_id);
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * The status of a comment by ID.
+ *
+ * @since 1.0.0
+ *
+ * @param int $comment_id Comment ID
+ * @return string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
+ */
+function wp_get_comment_status($comment_id) {
+	$comment = get_comment($comment_id);
+	if ( !$comment )
+		return false;
+
+	$approved = $comment->comment_approved;
+
+	if ( $approved == NULL )
+		return false;
+	elseif ( $approved == '1' )
+		return 'approved';
+	elseif ( $approved == '0' )
+		return 'unapproved';
+	elseif ( $approved == 'spam' )
+		return 'spam';
+	elseif ( $approved == 'trash' )
+		return 'trash';
+	else
+		return false;
+}
+
+/**
+ * Call hooks for when a comment status transition occurs.
+ *
+ * Calls hooks for comment status transitions. If the new comment status is not the same
+ * as the previous comment status, then two hooks will be ran, the first is
+ * 'transition_comment_status' with new status, old status, and comment data. The
+ * next action called is 'comment_OLDSTATUS_to_NEWSTATUS' the NEWSTATUS is the
+ * $new_status parameter and the OLDSTATUS is $old_status parameter; it has the
+ * comment data.
+ *
+ * The final action will run whether or not the comment statuses are the same. The
+ * action is named 'comment_NEWSTATUS_COMMENTTYPE', NEWSTATUS is from the $new_status
+ * parameter and COMMENTTYPE is comment_type comment data.
+ *
+ * @since 2.7.0
+ *
+ * @param string $new_status New comment status.
+ * @param string $old_status Previous comment status.
+ * @param object $comment Comment data.
+ */
+function wp_transition_comment_status($new_status, $old_status, $comment) {
+	// Translate raw statuses to human readable formats for the hooks
+	// This is not a complete list of comment status, it's only the ones that need to be renamed
+	$comment_statuses = array(
+		0         => 'unapproved',
+		'hold'    => 'unapproved', // wp_set_comment_status() uses "hold"
+		1         => 'approved',
+		'approve' => 'approved', // wp_set_comment_status() uses "approve"
+	);
+	if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status];
+	if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status];
+
+	// Call the hooks
+	if ( $new_status != $old_status ) {
+		do_action('transition_comment_status', $new_status, $old_status, $comment);
+		do_action("comment_{$old_status}_to_{$new_status}", $comment);
+	}
+	do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment);
+}
+
+/**
+ * Get current commenter's name, email, and URL.
+ *
+ * Expects cookies content to already be sanitized. User of this function might
+ * wish to recheck the returned array for validity.
+ *
+ * @see sanitize_comment_cookies() Use to sanitize cookies
+ *
+ * @since 2.0.4
+ *
+ * @return array Comment author, email, url respectively.
+ */
+function wp_get_current_commenter() {
+	// Cookies should already be sanitized.
+
+	$comment_author = '';
+	if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )
+		$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];
+
+	$comment_author_email = '';
+	if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )
+		$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];
+
+	$comment_author_url = '';
+	if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )
+		$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];
+
+	return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));
+}
+
+/**
+ * Inserts a comment to the database.
+ *
+ * The available comment data key names are 'comment_author_IP', 'comment_date',
+ * 'comment_date_gmt', 'comment_parent', 'comment_approved', and 'user_id'.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ *
+ * @param array $commentdata Contains information on the comment.
+ * @return int The new comment's ID.
+ */
+function wp_insert_comment($commentdata) {
+	global $wpdb;
+	extract(stripslashes_deep($commentdata), EXTR_SKIP);
+
+	if ( ! isset($comment_author_IP) )
+		$comment_author_IP = '';
+	if ( ! isset($comment_date) )
+		$comment_date = current_time('mysql');
+	if ( ! isset($comment_date_gmt) )
+		$comment_date_gmt = get_gmt_from_date($comment_date);
+	if ( ! isset($comment_parent) )
+		$comment_parent = 0;
+	if ( ! isset($comment_approved) )
+		$comment_approved = 1;
+	if ( ! isset($comment_karma) )
+		$comment_karma = 0;
+	if ( ! isset($user_id) )
+		$user_id = 0;
+	if ( ! isset($comment_type) )
+		$comment_type = '';
+
+	$data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');
+	$wpdb->insert($wpdb->comments, $data);
+
+	$id = (int) $wpdb->insert_id;
+
+	if ( $comment_approved == 1 )
+		wp_update_comment_count($comment_post_ID);
+
+	$comment = get_comment($id);
+	do_action('wp_insert_comment', $id, $comment);
+
+	return $id;
+}
+
+/**
+ * Filters and sanitizes comment data.
+ *
+ * Sets the comment data 'filtered' field to true when finished. This can be
+ * checked as to whether the comment should be filtered and to keep from
+ * filtering the same comment more than once.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'pre_user_id' hook on comment author's user ID
+ * @uses apply_filters() Calls 'pre_comment_user_agent' hook on comment author's user agent
+ * @uses apply_filters() Calls 'pre_comment_author_name' hook on comment author's name
+ * @uses apply_filters() Calls 'pre_comment_content' hook on the comment's content
+ * @uses apply_filters() Calls 'pre_comment_user_ip' hook on comment author's IP
+ * @uses apply_filters() Calls 'pre_comment_author_url' hook on comment author's URL
+ * @uses apply_filters() Calls 'pre_comment_author_email' hook on comment author's email address
+ *
+ * @param array $commentdata Contains information on the comment.
+ * @return array Parsed comment information.
+ */
+function wp_filter_comment($commentdata) {
+	if ( isset($commentdata['user_ID']) )
+		$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']);
+	elseif ( isset($commentdata['user_id']) )
+		$commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_id']);
+	$commentdata['comment_agent']        = apply_filters('pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );
+	$commentdata['comment_author']       = apply_filters('pre_comment_author_name', $commentdata['comment_author']);
+	$commentdata['comment_content']      = apply_filters('pre_comment_content', $commentdata['comment_content']);
+	$commentdata['comment_author_IP']    = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']);
+	$commentdata['comment_author_url']   = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']);
+	$commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']);
+	$commentdata['filtered'] = true;
+	return $commentdata;
+}
+
+/**
+ * Whether comment should be blocked because of comment flood.
+ *
+ * @since 2.1.0
+ *
+ * @param bool $block Whether plugin has already blocked comment.
+ * @param int $time_lastcomment Timestamp for last comment.
+ * @param int $time_newcomment Timestamp for new comment.
+ * @return bool Whether comment should be blocked.
+ */
+function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) {
+	if ( $block ) // a plugin has already blocked... we'll let that decision stand
+		return $block;
+	if ( ($time_newcomment - $time_lastcomment) < 15 )
+		return true;
+	return false;
+}
+
+/**
+ * Adds a new comment to the database.
+ *
+ * Filters new comment to ensure that the fields are sanitized and valid before
+ * inserting comment into database. Calls 'comment_post' action with comment ID
+ * and whether comment is approved by WordPress. Also has 'preprocess_comment'
+ * filter for processing the comment data before the function handles it.
+ *
+ * We use REMOTE_ADDR here directly. If you are behind a proxy, you should ensure
+ * that it is properly set, such as in wp-config.php, for your environment.
+ * See {@link http://core.trac.wordpress.org/ticket/9235}
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'preprocess_comment' hook on $commentdata parameter array before processing
+ * @uses do_action() Calls 'comment_post' hook on $comment_ID returned from adding the comment and if the comment was approved.
+ * @uses wp_filter_comment() Used to filter comment before adding comment.
+ * @uses wp_allow_comment() checks to see if comment is approved.
+ * @uses wp_insert_comment() Does the actual comment insertion to the database.
+ *
+ * @param array $commentdata Contains information on the comment.
+ * @return int The ID of the comment after adding.
+ */
+function wp_new_comment( $commentdata ) {
+	$commentdata = apply_filters('preprocess_comment', $commentdata);
+
+	$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
+	if ( isset($commentdata['user_ID']) )
+		$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
+	elseif ( isset($commentdata['user_id']) )
+		$commentdata['user_id'] = (int) $commentdata['user_id'];
+
+	$commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
+	$parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
+	$commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
+
+	$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
+	$commentdata['comment_agent']     = substr($_SERVER['HTTP_USER_AGENT'], 0, 254);
+
+	$commentdata['comment_date']     = current_time('mysql');
+	$commentdata['comment_date_gmt'] = current_time('mysql', 1);
+
+	$commentdata = wp_filter_comment($commentdata);
+
+	$commentdata['comment_approved'] = wp_allow_comment($commentdata);
+
+	$comment_ID = wp_insert_comment($commentdata);
+
+	do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
+
+	if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
+		if ( '0' == $commentdata['comment_approved'] )
+			wp_notify_moderator($comment_ID);
+
+		$post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
+
+		if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) )
+			wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );
+	}
+
+	return $comment_ID;
+}
+
+/**
+ * Sets the status of a comment.
+ *
+ * The 'wp_set_comment_status' action is called after the comment is handled and
+ * will only be called, if the comment status is either 'hold', 'approve', or
+ * 'spam'. If the comment status is not in the list, then false is returned and
+ * if the status is 'delete', then the comment is deleted without calling the
+ * action.
+ *
+ * @since 1.0.0
+ * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
+ *
+ * @param int $comment_id Comment ID.
+ * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'delete'.
+ * @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false.
+ * @return bool False on failure or deletion and true on success.
+ */
+function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
+	global $wpdb;
+
+	$status = '0';
+	switch ( $comment_status ) {
+		case 'hold':
+		case '0':
+			$status = '0';
+			break;
+		case 'approve':
+		case '1':
+			$status = '1';
+			if ( get_option('comments_notify') ) {
+				$comment = get_comment($comment_id);
+				wp_notify_postauthor($comment_id, $comment->comment_type);
+			}
+			break;
+		case 'spam':
+			$status = 'spam';
+			break;
+		case 'trash':
+			$status = 'trash';
+			break;
+		default:
+			return false;
+	}
+
+	$comment_old = wp_clone(get_comment($comment_id));
+
+	if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) {
+		if ( $wp_error )
+			return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
+		else
+			return false;
+	}
+
+	clean_comment_cache($comment_id);
+
+	$comment = get_comment($comment_id);
+
+	do_action('wp_set_comment_status', $comment_id, $comment_status);
+	wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
+
+	wp_update_comment_count($comment->comment_post_ID);
+
+	return true;
+}
+
+/**
+ * Updates an existing comment in the database.
+ *
+ * Filters the comment and makes sure certain fields are valid before updating.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
+ *
+ * @param array $commentarr Contains information on the comment.
+ * @return int Comment was updated if value is 1, or was not updated if value is 0.
+ */
+function wp_update_comment($commentarr) {
+	global $wpdb;
+
+	// First, get all of the original fields
+	$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
+
+	// Escape data pulled from DB.
+	$comment = esc_sql($comment);
+
+	$old_status = $comment['comment_approved'];
+
+	// Merge old and new fields with new fields overwriting old ones.
+	$commentarr = array_merge($comment, $commentarr);
+
+	$commentarr = wp_filter_comment( $commentarr );
+
+	// Now extract the merged array.
+	extract(stripslashes_deep($commentarr), EXTR_SKIP);
+
+	$comment_content = apply_filters('comment_save_pre', $comment_content);
+
+	$comment_date_gmt = get_gmt_from_date($comment_date);
+
+	if ( !isset($comment_approved) )
+		$comment_approved = 1;
+	else if ( 'hold' == $comment_approved )
+		$comment_approved = 0;
+	else if ( 'approve' == $comment_approved )
+		$comment_approved = 1;
+
+	$data = compact('comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt');
+	$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
+
+	clean_comment_cache($comment_ID);
+	wp_update_comment_count($comment_post_ID);
+	do_action('edit_comment', $comment_ID);
+	$comment = get_comment($comment_ID);
+	wp_transition_comment_status($comment->comment_approved, $old_status, $comment);
+	return $rval;
+}
+
+/**
+ * Whether to defer comment counting.
+ *
+ * When setting $defer to true, all post comment counts will not be updated
+ * until $defer is set to false. When $defer is set to false, then all
+ * previously deferred updated post comment counts will then be automatically
+ * updated without having to call wp_update_comment_count() after.
+ *
+ * @since 2.5.0
+ * @staticvar bool $_defer
+ *
+ * @param bool $defer
+ * @return unknown
+ */
+function wp_defer_comment_counting($defer=null) {
+	static $_defer = false;
+
+	if ( is_bool($defer) ) {
+		$_defer = $defer;
+		// flush any deferred counts
+		if ( !$defer )
+			wp_update_comment_count( null, true );
+	}
+
+	return $_defer;
+}
+
+/**
+ * Updates the comment count for post(s).
+ *
+ * When $do_deferred is false (is by default) and the comments have been set to
+ * be deferred, the post_id will be added to a queue, which will be updated at a
+ * later date and only updated once per post ID.
+ *
+ * If the comments have not be set up to be deferred, then the post will be
+ * updated. When $do_deferred is set to true, then all previous deferred post
+ * IDs will be updated along with the current $post_id.
+ *
+ * @since 2.1.0
+ * @see wp_update_comment_count_now() For what could cause a false return value
+ *
+ * @param int $post_id Post ID
+ * @param bool $do_deferred Whether to process previously deferred post comment counts
+ * @return bool True on success, false on failure
+ */
+function wp_update_comment_count($post_id, $do_deferred=false) {
+	static $_deferred = array();
+
+	if ( $do_deferred ) {
+		$_deferred = array_unique($_deferred);
+		foreach ( $_deferred as $i => $_post_id ) {
+			wp_update_comment_count_now($_post_id);
+			unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */
+		}
+	}
+
+	if ( wp_defer_comment_counting() ) {
+		$_deferred[] = $post_id;
+		return true;
+	}
+	elseif ( $post_id ) {
+		return wp_update_comment_count_now($post_id);
+	}
+
+}
+
+/**
+ * Updates the comment count for the post.
+ *
+ * @since 2.5.0
+ * @uses $wpdb
+ * @uses do_action() Calls 'wp_update_comment_count' hook on $post_id, $new, and $old
+ * @uses do_action() Calls 'edit_posts' hook on $post_id and $post
+ *
+ * @param int $post_id Post ID
+ * @return bool False on '0' $post_id or if post with ID does not exist. True on success.
+ */
+function wp_update_comment_count_now($post_id) {
+	global $wpdb;
+	$post_id = (int) $post_id;
+	if ( !$post_id )
+		return false;
+	if ( !$post = get_post($post_id) )
+		return false;
+
+	$old = (int) $post->comment_count;
+	$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
+	$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
+
+	if ( 'page' == $post->post_type )
+		clean_page_cache( $post_id );
+	else
+		clean_post_cache( $post_id );
+
+	do_action('wp_update_comment_count', $post_id, $new, $old);
+	do_action('edit_post', $post_id, $post);
+
+	return true;
+}
+
+//
+// Ping and trackback functions.
+//
+
+/**
+ * Finds a pingback server URI based on the given URL.
+ *
+ * Checks the HTML for the rel="pingback" link and x-pingback headers. It does
+ * a check for the x-pingback headers first and returns that, if available. The
+ * check for the rel="pingback" has more overhead than just the header.
+ *
+ * @since 1.5.0
+ *
+ * @param string $url URL to ping.
+ * @param int $deprecated Not Used.
+ * @return bool|string False on failure, string containing URI on success.
+ */
+function discover_pingback_server_uri( $url, $deprecated = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.7' );
+
+	$pingback_str_dquote = 'rel="pingback"';
+	$pingback_str_squote = 'rel=\'pingback\'';
+
+	/** @todo Should use Filter Extension or custom preg_match instead. */
+	$parsed_url = parse_url($url);
+
+	if ( ! isset( $parsed_url['host'] ) ) // Not an URL. This should never happen.
+		return false;
+
+	//Do not search for a pingback server on our own uploads
+	$uploads_dir = wp_upload_dir();
+	if ( 0 === strpos($url, $uploads_dir['baseurl']) )
+		return false;
+
+	$response = wp_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
+
+	if ( is_wp_error( $response ) )
+		return false;
+
+	if ( isset( $response['headers']['x-pingback'] ) )
+		return $response['headers']['x-pingback'];
+
+	// Not an (x)html, sgml, or xml page, no use going further.
+	if ( isset( $response['headers']['content-type'] ) && preg_match('#(image|audio|video|model)/#is', $response['headers']['content-type']) )
+		return false;
+
+	// Now do a GET since we're going to look in the html headers (and we're sure its not a binary file)
+	$response = wp_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
+
+	if ( is_wp_error( $response ) )
+		return false;
+
+	$contents = $response['body'];
+
+	$pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
+	$pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
+	if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) {
+		$quote = ($pingback_link_offset_dquote) ? '"' : '\'';
+		$pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
+		$pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
+		$pingback_href_start = $pingback_href_pos+6;
+		$pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
+		$pingback_server_url_len = $pingback_href_end - $pingback_href_start;
+		$pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
+
+		// We may find rel="pingback" but an incomplete pingback URL
+		if ( $pingback_server_url_len > 0 ) { // We got it!
+			return $pingback_server_url;
+		}
+	}
+
+	return false;
+}
+
+/**
+ * Perform all pingbacks, enclosures, trackbacks, and send to pingback services.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ */
+function do_all_pings() {
+	global $wpdb;
+
+	// Do pingbacks
+	while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
+		$mid = $wpdb->get_var( "SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme' LIMIT 1");
+		do_action( 'delete_postmeta', $mid );
+		$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE meta_id = %d", $mid ) );
+		do_action( 'deleted_postmeta', $mid );
+		pingback($ping->post_content, $ping->ID);
+	}
+
+	// Do Enclosures
+	while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
+		$mid = $wpdb->get_var( $wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_encloseme'", $enclosure->ID) );
+		do_action( 'delete_postmeta', $mid );
+		$wpdb->query( $wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_id =  %d", $mid) );
+		do_action( 'deleted_postmeta', $mid );
+		do_enclose($enclosure->post_content, $enclosure->ID);
+	}
+
+	// Do Trackbacks
+	$trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'");
+	if ( is_array($trackbacks) )
+		foreach ( $trackbacks as $trackback )
+			do_trackbacks($trackback);
+
+	//Do Update Services/Generic Pings
+	generic_ping();
+}
+
+/**
+ * Perform trackbacks.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ *
+ * @param int $post_id Post ID to do trackbacks on.
+ */
+function do_trackbacks($post_id) {
+	global $wpdb;
+
+	$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) );
+	$to_ping = get_to_ping($post_id);
+	$pinged  = get_pung($post_id);
+	if ( empty($to_ping) ) {
+		$wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) );
+		return;
+	}
+
+	if ( empty($post->post_excerpt) )
+		$excerpt = apply_filters('the_content', $post->post_content);
+	else
+		$excerpt = apply_filters('the_excerpt', $post->post_excerpt);
+	$excerpt = str_replace(']]>', ']]&gt;', $excerpt);
+	$excerpt = wp_html_excerpt($excerpt, 252) . '...';
+
+	$post_title = apply_filters('the_title', $post->post_title);
+	$post_title = strip_tags($post_title);
+
+	if ( $to_ping ) {
+		foreach ( (array) $to_ping as $tb_ping ) {
+			$tb_ping = trim($tb_ping);
+			if ( !in_array($tb_ping, $pinged) ) {
+				trackback($tb_ping, $post_title, $excerpt, $post_id);
+				$pinged[] = $tb_ping;
+			} else {
+				$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) );
+			}
+		}
+	}
+}
+
+/**
+ * Sends pings to all of the ping site services.
+ *
+ * @since 1.2.0
+ *
+ * @param int $post_id Post ID. Not actually used.
+ * @return int Same as Post ID from parameter
+ */
+function generic_ping($post_id = 0) {
+	$services = get_option('ping_sites');
+
+	$services = explode("\n", $services);
+	foreach ( (array) $services as $service ) {
+		$service = trim($service);
+		if ( '' != $service )
+			weblog_ping($service);
+	}
+
+	return $post_id;
+}
+
+/**
+ * Pings back the links found in a post.
+ *
+ * @since 0.71
+ * @uses $wp_version
+ * @uses IXR_Client
+ *
+ * @param string $content Post content to check for links.
+ * @param int $post_ID Post ID.
+ */
+function pingback($content, $post_ID) {
+	global $wp_version;
+	include_once(ABSPATH . WPINC . '/class-IXR.php');
+	include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php');
+
+	// original code by Mort (http://mort.mine.nu:8080)
+	$post_links = array();
+
+	$pung = get_pung($post_ID);
+
+	// Variables
+	$ltrs = '\w';
+	$gunk = '/#~:.?+=&%@!\-';
+	$punc = '.:?\-';
+	$any = $ltrs . $gunk . $punc;
+
+	// Step 1
+	// Parsing the post, external links (if any) are stored in the $post_links array
+	// This regexp comes straight from phpfreaks.com
+	// http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
+	preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
+
+	// Step 2.
+	// Walking thru the links array
+	// first we get rid of links pointing to sites, not to specific files
+	// Example:
+	// http://dummy-weblog.org
+	// http://dummy-weblog.org/
+	// http://dummy-weblog.org/post.php
+	// We don't wanna ping first and second types, even if they have a valid <link/>
+
+	foreach ( (array) $post_links_temp[0] as $link_test ) :
+		if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
+				&& !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
+			if ( $test = @parse_url($link_test) ) {
+				if ( isset($test['query']) )
+					$post_links[] = $link_test;
+				elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) )
+					$post_links[] = $link_test;
+			}
+		endif;
+	endforeach;
+
+	do_action_ref_array('pre_ping', array(&$post_links, &$pung));
+
+	foreach ( (array) $post_links as $pagelinkedto ) {
+		$pingback_server_url = discover_pingback_server_uri( $pagelinkedto );
+
+		if ( $pingback_server_url ) {
+			@ set_time_limit( 60 );
+			 // Now, the RPC call
+			$pagelinkedfrom = get_permalink($post_ID);
+
+			// using a timeout of 3 seconds should be enough to cover slow servers
+			$client = new WP_HTTP_IXR_Client($pingback_server_url);
+			$client->timeout = 3;
+			$client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom);
+			// when set to true, this outputs debug messages by itself
+			$client->debug = false;
+
+			if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered
+				add_ping( $post_ID, $pagelinkedto );
+		}
+	}
+}
+
+/**
+ * Check whether blog is public before returning sites.
+ *
+ * @since 2.1.0
+ *
+ * @param mixed $sites Will return if blog is public, will not return if not public.
+ * @return mixed Empty string if blog is not public, returns $sites, if site is public.
+ */
+function privacy_ping_filter($sites) {
+	if ( '0' != get_option('blog_public') )
+		return $sites;
+	else
+		return '';
+}
+
+/**
+ * Send a Trackback.
+ *
+ * Updates database when sending trackback to prevent duplicates.
+ *
+ * @since 0.71
+ * @uses $wpdb
+ *
+ * @param string $trackback_url URL to send trackbacks.
+ * @param string $title Title of post.
+ * @param string $excerpt Excerpt of post.
+ * @param int $ID Post ID.
+ * @return mixed Database query from update.
+ */
+function trackback($trackback_url, $title, $excerpt, $ID) {
+	global $wpdb;
+
+	if ( empty($trackback_url) )
+		return;
+
+	$options = array();
+	$options['timeout'] = 4;
+	$options['body'] = array(
+		'title' => $title,
+		'url' => get_permalink($ID),
+		'blog_name' => get_option('blogname'),
+		'excerpt' => $excerpt
+	);
+
+	$response = wp_remote_post($trackback_url, $options);
+
+	if ( is_wp_error( $response ) )
+		return;
+
+	$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) );
+	return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) );
+}
+
+/**
+ * Send a pingback.
+ *
+ * @since 1.2.0
+ * @uses $wp_version
+ * @uses IXR_Client
+ *
+ * @param string $server Host of blog to connect to.
+ * @param string $path Path to send the ping.
+ */
+function weblog_ping($server = '', $path = '') {
+	global $wp_version;
+	include_once(ABSPATH . WPINC . '/class-IXR.php');
+	include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php');
+
+	// using a timeout of 3 seconds should be enough to cover slow servers
+	$client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
+	$client->timeout = 3;
+	$client->useragent .= ' -- WordPress/'.$wp_version;
+
+	// when set to true, this outputs debug messages by itself
+	$client->debug = false;
+	$home = trailingslashit( home_url() );
+	if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
+		$client->query('weblogUpdates.ping', get_option('blogname'), $home);
+}
+
+//
+// Cache
+//
+
+/**
+ * Removes comment ID from the comment cache.
+ *
+ * @since 2.3.0
+ * @package WordPress
+ * @subpackage Cache
+ *
+ * @param int|array $ids Comment ID or array of comment IDs to remove from cache
+ */
+function clean_comment_cache($ids) {
+	foreach ( (array) $ids as $id )
+		wp_cache_delete($id, 'comment');
+
+	wp_cache_set('last_changed', time(), 'comment');
+}
+
+/**
+ * Updates the comment cache of given comments.
+ *
+ * Will add the comments in $comments to the cache. If comment ID already exists
+ * in the comment cache then it will not be updated. The comment is added to the
+ * cache using the comment group with the key using the ID of the comments.
+ *
+ * @since 2.3.0
+ * @package WordPress
+ * @subpackage Cache
+ *
+ * @param array $comments Array of comment row objects
+ */
+function update_comment_cache($comments) {
+	foreach ( (array) $comments as $comment )
+		wp_cache_add($comment->comment_ID, $comment, 'comment');
+}
+
+//
+// Internal
+//
+
+/**
+ * Close comments on old posts on the fly, without any extra DB queries.  Hooked to the_posts.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @param object $posts Post data object.
+ * @return object
+ */
+function _close_comments_for_old_posts( $posts ) {
+	if ( empty($posts) || !is_singular() || !get_option('close_comments_for_old_posts') )
+		return $posts;
+
+	$days_old = (int) get_option('close_comments_days_old');
+	if ( !$days_old )
+		return $posts;
+
+	if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) {
+		$posts[0]->comment_status = 'closed';
+		$posts[0]->ping_status = 'closed';
+	}
+
+	return $posts;
+}
+
+/**
+ * Close comments on an old post.  Hooked to comments_open and pings_open.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @param bool $open Comments open or closed
+ * @param int $post_id Post ID
+ * @return bool $open
+ */
+function _close_comments_for_old_post( $open, $post_id ) {
+	if ( ! $open )
+		return $open;
+
+	if ( !get_option('close_comments_for_old_posts') )
+		return $open;
+
+	$days_old = (int) get_option('close_comments_days_old');
+	if ( !$days_old )
+		return $open;
+
+	$post = get_post($post_id);
+
+	if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
+		return false;
+
+	return $open;
+}
+
+?>
Index: /tags/3.1/wp-includes/compat.php
===================================================================
--- /tags/3.1/wp-includes/compat.php	(revision 17487)
+++ /tags/3.1/wp-includes/compat.php	(revision 17487)
@@ -0,0 +1,170 @@
+<?php
+/**
+ * WordPress implementation for PHP functions missing from older PHP versions.
+ *
+ * @package PHP
+ * @access private
+ */
+
+// Added in PHP 5.0
+
+if (!function_exists('http_build_query')) {
+	function http_build_query($data, $prefix=null, $sep=null) {
+		return _http_build_query($data, $prefix, $sep);
+	}
+}
+
+// from php.net (modified by Mark Jaquith to behave like the native PHP5 function)
+function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) {
+	$ret = array();
+
+	foreach ( (array) $data as $k => $v ) {
+		if ( $urlencode)
+			$k = urlencode($k);
+		if ( is_int($k) && $prefix != null )
+			$k = $prefix.$k;
+		if ( !empty($key) )
+			$k = $key . '%5B' . $k . '%5D';
+		if ( $v === NULL )
+			continue;
+		elseif ( $v === FALSE )
+			$v = '0';
+
+		if ( is_array($v) || is_object($v) )
+			array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
+		elseif ( $urlencode )
+			array_push($ret, $k.'='.urlencode($v));
+		else
+			array_push($ret, $k.'='.$v);
+	}
+
+	if ( NULL === $sep )
+		$sep = ini_get('arg_separator.output');
+
+	return implode($sep, $ret);
+}
+
+if ( !function_exists('_') ) {
+	function _($string) {
+		return $string;
+	}
+}
+
+if (!function_exists('stripos')) {
+	function stripos($haystack, $needle, $offset = 0) {
+		return strpos(strtolower($haystack), strtolower($needle), $offset);
+	}
+}
+
+if ( !function_exists('hash_hmac') ):
+function hash_hmac($algo, $data, $key, $raw_output = false) {
+	return _hash_hmac($algo, $data, $key, $raw_output);
+}
+endif;
+
+function _hash_hmac($algo, $data, $key, $raw_output = false) {
+	$packs = array('md5' => 'H32', 'sha1' => 'H40');
+
+	if ( !isset($packs[$algo]) )
+		return false;
+
+	$pack = $packs[$algo];
+
+	if (strlen($key) > 64)
+		$key = pack($pack, $algo($key));
+
+	$key = str_pad($key, 64, chr(0));
+
+	$ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
+	$opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));
+
+	$hmac = $algo($opad . pack($pack, $algo($ipad . $data)));
+
+	if ( $raw_output )
+		return pack( $pack, $hmac );
+	return $hmac;
+}
+
+if ( !function_exists('mb_substr') ):
+	function mb_substr( $str, $start, $length=null, $encoding=null ) {
+		return _mb_substr($str, $start, $length, $encoding);
+	}
+endif;
+
+function _mb_substr( $str, $start, $length=null, $encoding=null ) {
+	// the solution below, works only for utf-8, so in case of a different
+	// charset, just use built-in substr
+	$charset = get_option( 'blog_charset' );
+	if ( !in_array( $charset, array('utf8', 'utf-8', 'UTF8', 'UTF-8') ) ) {
+		return is_null( $length )? substr( $str, $start ) : substr( $str, $start, $length);
+	}
+	// use the regex unicode support to separate the UTF-8 characters into an array
+	preg_match_all( '/./us', $str, $match );
+	$chars = is_null( $length )? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length );
+	return implode( '', $chars );
+}
+
+if ( !function_exists( 'htmlspecialchars_decode' ) ) {
+	// Added in PHP 5.1.0
+	// Error checks from PEAR::PHP_Compat
+	function htmlspecialchars_decode( $string, $quote_style = ENT_COMPAT )
+	{
+		if ( !is_scalar( $string ) ) {
+			trigger_error( 'htmlspecialchars_decode() expects parameter 1 to be string, ' . gettype( $string ) . ' given', E_USER_WARNING );
+			return;
+		}
+
+		if ( !is_int( $quote_style ) && $quote_style !== null ) {
+			trigger_error( 'htmlspecialchars_decode() expects parameter 2 to be integer, ' . gettype( $quote_style ) . ' given', E_USER_WARNING );
+			return;
+		}
+
+		return wp_specialchars_decode( $string, $quote_style );
+	}
+}
+
+// For PHP < 5.2.0
+if ( !function_exists('json_encode') ) {
+	function json_encode( $string ) {
+		global $wp_json;
+
+		if ( !is_a($wp_json, 'Services_JSON') ) {
+			require_once( ABSPATH . WPINC . '/class-json.php' );
+			$wp_json = new Services_JSON();
+		}
+
+		return $wp_json->encodeUnsafe( $string );
+	}
+}
+
+if ( !function_exists('json_decode') ) {
+	function json_decode( $string, $assoc_array = false ) {
+		global $wp_json;
+
+		if ( !is_a($wp_json, 'Services_JSON') ) {
+			require_once( ABSPATH . WPINC . '/class-json.php' );
+			$wp_json = new Services_JSON();
+		}
+
+		$res = $wp_json->decode( $string );
+		if ( $assoc_array )
+			$res = _json_decode_object_helper( $res );
+		return $res;
+	}
+	function _json_decode_object_helper($data) {
+		if ( is_object($data) )
+			$data = get_object_vars($data);
+		return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
+	}
+}
+
+// pathinfo that fills 'filename' without extension like in PHP 5.2+
+function pathinfo52($path) {
+	$parts = pathinfo($path);
+	if ( !isset($parts['filename']) ) {
+		$parts['filename'] = substr( $parts['basename'], 0, strrpos($parts['basename'], '.') );
+		if ( empty($parts['filename']) ) // there's no extension
+			$parts['filename'] = $parts['basename'];
+	}
+	return $parts;
+}
Index: /tags/3.1/wp-includes/cron.php
===================================================================
--- /tags/3.1/wp-includes/cron.php	(revision 17487)
+++ /tags/3.1/wp-includes/cron.php	(revision 17487)
@@ -0,0 +1,407 @@
+<?php
+/**
+ * WordPress CRON API
+ *
+ * @package WordPress
+ */
+
+/**
+ * Schedules a hook to run only once.
+ *
+ * Schedules a hook which will be executed once by the WordPress actions core at
+ * a time which you specify. The action will fire off when someone visits your
+ * WordPress site, if the schedule time has passed.
+ *
+ * @since 2.1.0
+ * @link http://codex.wordpress.org/Function_Reference/wp_schedule_single_event
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ */
+function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
+	// don't schedule a duplicate if there's already an identical event due in the next 10 minutes
+	$next = wp_next_scheduled($hook, $args);
+	if ( $next && $next <= $timestamp + 600 )
+		return;
+
+	$crons = _get_cron_array();
+	$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args );
+	$event = apply_filters('schedule_event', $event);
+
+	// A plugin disallowed this event
+	if ( ! $event )
+		return false;
+
+	$key = md5(serialize($event->args));
+
+	$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args );
+	uksort( $crons, "strnatcasecmp" );
+	_set_cron_array( $crons );
+}
+
+/**
+ * Schedule a periodic event.
+ *
+ * Schedules a hook which will be executed by the WordPress actions core on a
+ * specific interval, specified by you. The action will trigger when someone
+ * visits your WordPress site, if the scheduled time has passed.
+ *
+ * Valid values for the recurrence are hourly, daily and twicedaily.  These can
+ * be extended using the cron_schedules filter in wp_get_schedules().
+ *
+ * Use wp_next_scheduled() to prevent duplicates
+ *
+ * @since 2.1.0
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $recurrence How often the event should recur.
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return bool|null False on failure, null when complete with scheduling event.
+ */
+function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
+	$crons = _get_cron_array();
+	$schedules = wp_get_schedules();
+
+	if ( !isset( $schedules[$recurrence] ) )
+		return false;
+
+	$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
+	$event = apply_filters('schedule_event', $event);
+
+	// A plugin disallowed this event
+	if ( ! $event )
+		return false;
+
+	$key = md5(serialize($event->args));
+
+	$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval );
+	uksort( $crons, "strnatcasecmp" );
+	_set_cron_array( $crons );
+}
+
+/**
+ * Reschedule a recurring event.
+ *
+ * @since 2.1.0
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $recurrence How often the event should recur.
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return bool|null False on failure. Null when event is rescheduled.
+ */
+function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
+	$crons = _get_cron_array();
+	$schedules = wp_get_schedules();
+	$key = md5(serialize($args));
+	$interval = 0;
+
+	// First we try to get it from the schedule
+	if ( 0 == $interval )
+		$interval = $schedules[$recurrence]['interval'];
+	// Now we try to get it from the saved interval in case the schedule disappears
+	if ( 0 == $interval )
+		$interval = $crons[$timestamp][$hook][$key]['interval'];
+	// Now we assume something is wrong and fail to schedule
+	if ( 0 == $interval )
+		return false;
+
+	$now = time();
+
+	if ( $timestamp >= $now )
+		$timestamp = $now + $interval;
+	else
+		$timestamp = $now + ($interval - (($now - $timestamp) % $interval));
+
+	wp_schedule_event( $timestamp, $recurrence, $hook, $args );
+}
+
+/**
+ * Unschedule a previously scheduled cron job.
+ *
+ * The $timestamp and $hook parameters are required, so that the event can be
+ * identified.
+ *
+ * @since 2.1.0
+ *
+ * @param int $timestamp Timestamp for when to run the event.
+ * @param string $hook Action hook, the execution of which will be unscheduled.
+ * @param array $args Arguments to pass to the hook's callback function.
+ * Although not passed to a callback function, these arguments are used
+ * to uniquely identify the scheduled event, so they should be the same
+ * as those used when originally scheduling the event.
+ */
+function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
+	$crons = _get_cron_array();
+	$key = md5(serialize($args));
+	unset( $crons[$timestamp][$hook][$key] );
+	if ( empty($crons[$timestamp][$hook]) )
+		unset( $crons[$timestamp][$hook] );
+	if ( empty($crons[$timestamp]) )
+		unset( $crons[$timestamp] );
+	_set_cron_array( $crons );
+}
+
+/**
+ * Unschedule all cron jobs attached to a specific hook.
+ *
+ * @since 2.1.0
+ *
+ * @param string $hook Action hook, the execution of which will be unscheduled.
+ * @param array $args Optional. Arguments that were to be pass to the hook's callback function.
+ */
+function wp_clear_scheduled_hook( $hook, $args = array() ) {
+	// Backward compatibility
+	// Previously this function took the arguments as discrete vars rather than an array like the rest of the API
+	if ( !is_array($args) ) {
+		_deprecated_argument( __FUNCTION__, '3.0', __('This argument has changed to an array to match the behavior of the other cron functions.') );
+		$args = array_slice( func_get_args(), 1 );
+	}
+
+	while ( $timestamp = wp_next_scheduled( $hook, $args ) )
+		wp_unschedule_event( $timestamp, $hook, $args );
+}
+
+/**
+ * Retrieve the next timestamp for a cron event.
+ *
+ * @since 2.1.0
+ *
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return bool|int The UNIX timestamp of the next time the scheduled event will occur.
+ */
+function wp_next_scheduled( $hook, $args = array() ) {
+	$crons = _get_cron_array();
+	$key = md5(serialize($args));
+	if ( empty($crons) )
+		return false;
+	foreach ( $crons as $timestamp => $cron ) {
+		if ( isset( $cron[$hook][$key] ) )
+			return $timestamp;
+	}
+	return false;
+}
+
+/**
+ * Send request to run cron through HTTP request that doesn't halt page loading.
+ *
+ * @since 2.1.0
+ *
+ * @return null Cron could not be spawned, because it is not needed to run.
+ */
+function spawn_cron( $local_time = 0 ) {
+
+	if ( !$local_time )
+		$local_time = time();
+
+	if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
+		return;
+
+	/*
+	* multiple processes on multiple web servers can run this code concurrently
+	* try to make this as atomic as possible by setting doing_cron switch
+	*/
+	$flag = get_transient('doing_cron');
+
+	if ( $flag > $local_time + 10*60 )
+		$flag = 0;
+
+	// don't run if another process is currently running it or more than once every 60 sec.
+	if ( $flag + 60 > $local_time )
+		return;
+
+	//sanity check
+	$crons = _get_cron_array();
+	if ( !is_array($crons) )
+		return;
+
+	$keys = array_keys( $crons );
+	if ( isset($keys[0]) && $keys[0] > $local_time )
+		return;
+
+	if ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ) {
+		if ( !empty($_POST) || defined('DOING_AJAX') )
+			return;
+
+		set_transient( 'doing_cron', $local_time );
+
+		ob_start();
+		wp_redirect( add_query_arg('doing_wp_cron', '', stripslashes($_SERVER['REQUEST_URI'])) );
+		echo ' ';
+
+		// flush any buffers and send the headers
+		while ( @ob_end_flush() );
+		flush();
+
+		WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' );
+		return;
+	}
+
+	set_transient( 'doing_cron', $local_time );
+
+	$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron';
+	wp_remote_post( $cron_url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true)) );
+}
+
+/**
+ * Run scheduled callbacks or spawn cron for all scheduled events.
+ *
+ * @since 2.1.0
+ *
+ * @return null When doesn't need to run Cron.
+ */
+function wp_cron() {
+
+	// Prevent infinite loops caused by lack of wp-cron.php
+	if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) )
+		return;
+
+	if ( false === $crons = _get_cron_array() )
+		return;
+
+	$local_time = time();
+	$keys = array_keys( $crons );
+	if ( isset($keys[0]) && $keys[0] > $local_time )
+		return;
+
+	$schedules = wp_get_schedules();
+	foreach ( $crons as $timestamp => $cronhooks ) {
+		if ( $timestamp > $local_time ) break;
+		foreach ( (array) $cronhooks as $hook => $args ) {
+			if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
+				continue;
+			spawn_cron( $local_time );
+			break 2;
+		}
+	}
+}
+
+/**
+ * Retrieve supported and filtered Cron recurrences.
+ *
+ * The supported recurrences are 'hourly' and 'daily'. A plugin may add more by
+ * hooking into the 'cron_schedules' filter. The filter accepts an array of
+ * arrays. The outer array has a key that is the name of the schedule or for
+ * example 'weekly'. The value is an array with two keys, one is 'interval' and
+ * the other is 'display'.
+ *
+ * The 'interval' is a number in seconds of when the cron job should run. So for
+ * 'hourly', the time is 3600 or 60*60. For weekly, the value would be
+ * 60*60*24*7 or 604800. The value of 'interval' would then be 604800.
+ *
+ * The 'display' is the description. For the 'weekly' key, the 'display' would
+ * be <code>__('Once Weekly')</code>.
+ *
+ * For your plugin, you will be passed an array. you can easily add your
+ * schedule by doing the following.
+ * <code>
+ * // filter parameter variable name is 'array'
+ *	$array['weekly'] = array(
+ *		'interval' => 604800,
+ *		'display' => __('Once Weekly')
+ *	);
+ * </code>
+ *
+ * @since 2.1.0
+ *
+ * @return array
+ */
+function wp_get_schedules() {
+	$schedules = array(
+		'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
+		'twicedaily' => array( 'interval' => 43200, 'display' => __('Twice Daily') ),
+		'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ),
+	);
+	return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
+}
+
+/**
+ * Retrieve Cron schedule for hook with arguments.
+ *
+ * @since 2.1.0
+ *
+ * @param string $hook Action hook to execute when cron is run.
+ * @param array $args Optional. Arguments to pass to the hook's callback function.
+ * @return string|bool False, if no schedule. Schedule on success.
+ */
+function wp_get_schedule($hook, $args = array()) {
+	$crons = _get_cron_array();
+	$key = md5(serialize($args));
+	if ( empty($crons) )
+		return false;
+	foreach ( $crons as $timestamp => $cron ) {
+		if ( isset( $cron[$hook][$key] ) )
+			return $cron[$hook][$key]['schedule'];
+	}
+	return false;
+}
+
+//
+// Private functions
+//
+
+/**
+ * Retrieve cron info array option.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @return array CRON info array.
+ */
+function _get_cron_array()  {
+	$cron = get_option('cron');
+	if ( ! is_array($cron) )
+		return false;
+
+	if ( !isset($cron['version']) )
+		$cron = _upgrade_cron_array($cron);
+
+	unset($cron['version']);
+
+	return $cron;
+}
+
+/**
+ * Updates the CRON option with the new CRON array.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param array $cron Cron info array from {@link _get_cron_array()}.
+ */
+function _set_cron_array($cron) {
+	$cron['version'] = 2;
+	update_option( 'cron', $cron );
+}
+
+/**
+ * Upgrade a Cron info array.
+ *
+ * This function upgrades the Cron info array to version 2.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param array $cron Cron info array from {@link _get_cron_array()}.
+ * @return array An upgraded Cron info array.
+ */
+function _upgrade_cron_array($cron) {
+	if ( isset($cron['version']) && 2 == $cron['version'])
+		return $cron;
+
+	$new_cron = array();
+
+	foreach ( (array) $cron as $timestamp => $hooks) {
+		foreach ( (array) $hooks as $hook => $args ) {
+			$key = md5(serialize($args['args']));
+			$new_cron[$timestamp][$hook][$key] = $args;
+		}
+	}
+
+	$new_cron['version'] = 2;
+	update_option( 'cron', $new_cron );
+	return $new_cron;
+}
Index: /tags/3.1/wp-includes/css/admin-bar-rtl.css
===================================================================
--- /tags/3.1/wp-includes/css/admin-bar-rtl.css	(revision 17487)
+++ /tags/3.1/wp-includes/css/admin-bar-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+#wpadminbar{direction:rtl;font-family:Tahoma,Arial,sans-serif;right:0;left:auto;}#wpadminbar .quicklinks ul{text-align:right;}#wpadminbar .quicklinks ul li{float:right;}#wpadminbar .quicklinks>ul>li>a{border-left:1px solid #686868;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-left:none;border-right:1px solid #808080;}#wpadminbar .quicklinks>ul>li:hover>a{border-right-color:#707070;border-left-color:#686868;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a img{margin:-2px -5px 0 23px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul{left:auto;right:30px;}#wpadminbar .quicklinks .menupop li:hover>ul,#wpadminbar .quicklinks .menupop li.hover>ul{margin-right:100%;margin-left:0;}#wpadminbar .quicklinks .menupop a>span{background:url(../images/admin-bar-sprite-rtl.png?d=11122010) left -58px no-repeat;padding-right:0;padding-left:.8em;}#wpadminbar .quicklinks .menupop ul li a>span{background:url(../images/admin-bar-sprite-rtl.png?d=11122010) left -29px no-repeat;padding-right:0;padding-left:1.5em;}#wpadminbar .quicklinks a{font-family:Tahoma,Arial,Helvetica,sans-serif;}#wpadminbar .quicklinks .menupop li a img.blavatar{margin-right:0;margin-left:8px;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{background:url(../images/admin-bar-sprite-rtl.png?d=11122010) top right no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-my-account>a,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{border-right:none;border-left:1px solid #686868;}#wpadminbar #adminbarsearch{float:left;}#wpadminbar #adminbarsearch .adminbar-input{float:right;font-family:Tahoma,Arial,Helvetica,sans-serif;margin-right:0;margin-left:3px;-moz-box-shadow:inset 2px -2px 1px #cdcdcd;-webkit-box-shadow:inset -2px 2px 1px #cdcdcd;box-shadow:inset 2px -2px 1px #cdcdcd;}#wpadminbar #adminbarsearch .adminbar-button{float:right;font-family:Tahoma,Arial,Helvetica,sans-serif;}
Index: /tags/3.1/wp-includes/css/admin-bar-rtl.dev.css
===================================================================
--- /tags/3.1/wp-includes/css/admin-bar-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-includes/css/admin-bar-rtl.dev.css	(revision 17487)
@@ -0,0 +1,94 @@
+#wpadminbar {
+	direction: rtl;
+	font-family: Tahoma, Arial ,sans-serif;
+	right: 0;
+	left: auto;
+}
+
+#wpadminbar .quicklinks ul {
+	text-align: right;
+}
+
+#wpadminbar .quicklinks ul li {
+	float: right;
+}
+
+#wpadminbar .quicklinks > ul > li > a {
+	border-left: 1px solid #686868;
+	border-right: 1px solid #808080;
+}
+
+#wpadminbar .quicklinks > ul > li:last-child > a {
+	border-left: none;
+	border-right: 1px solid #808080;
+}
+
+#wpadminbar .quicklinks > ul > li:hover > a {
+	border-right-color: #707070;
+	border-left-color: #686868;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a img  {
+	margin: -2px -5px 0 23px;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul {
+	left: auto;
+	right: 30px;
+}
+
+#wpadminbar .quicklinks .menupop li:hover > ul,
+#wpadminbar .quicklinks .menupop li.hover > ul {
+	margin-right: 100%;
+	margin-left: 0;
+}
+
+#wpadminbar .quicklinks .menupop a > span {
+	background: url(../images/admin-bar-sprite-rtl.png?d=11122010) left -58px no-repeat;
+	padding-right: 0;
+	padding-left: .8em;
+}
+
+#wpadminbar .quicklinks .menupop ul li a > span {
+	background: url(../images/admin-bar-sprite-rtl.png?d=11122010) left -29px no-repeat;
+	padding-right: 0;
+	padding-left: 1.5em;
+}
+
+#wpadminbar .quicklinks a {
+	font-family: Tahoma, Arial, Helvetica, sans-serif;
+}
+
+#wpadminbar .quicklinks .menupop li a img.blavatar {
+	margin-right: 0;
+	margin-left: 8px;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a {
+	background: url(../images/admin-bar-sprite-rtl.png?d=11122010) top right no-repeat;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account > a,
+#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a {
+	border-right: none;
+	border-left: 1px solid #686868;
+}
+
+#wpadminbar #adminbarsearch {
+	float: left;
+}
+
+#wpadminbar #adminbarsearch .adminbar-input {
+	float: right;
+	font-family: Tahoma, Arial, Helvetica, sans-serif;
+	margin-right: 0;
+	margin-left: 3px;
+	-moz-box-shadow: inset 2px -2px 1px #cdcdcd;
+	-webkit-box-shadow: inset -2px 2px 1px #cdcdcd;
+	box-shadow: inset 2px -2px 1px #cdcdcd;
+}
+
+#wpadminbar #adminbarsearch .adminbar-button {
+	float: right;
+	font-family: Tahoma, Arial, Helvetica, sans-serif;
+}
Index: /tags/3.1/wp-includes/css/admin-bar.css
===================================================================
--- /tags/3.1/wp-includes/css/admin-bar.css	(revision 17487)
+++ /tags/3.1/wp-includes/css/admin-bar.css	(revision 17487)
@@ -0,0 +1,1 @@
+#wpadminbar *{height:auto;width:auto;margin:0;padding:0;position:static;text-transform:none;letter-spacing:normal;line-height:1;}#wpadminbar :before,#wpadminbar :after{content:normal;}#wpadminbar a,#wpadminbar a:hover,#wpadminbar a img,#wpadminbar a img:hover{outline:none;border:none;text-decoration:none;background:none;}#wpadminbar{direction:ltr;background-color:#777;background-image:-moz-linear-gradient(bottom,#666,#7f7f7f);background-image:-webkit-gradient(linear,left bottom,left top,from(#666),to(#7f7f7f));color:#ddd;font:normal 12px/28px Arial,Helvetica,sans-serif;height:28px;position:fixed;top:0;left:0;width:100%;z-index:99999;min-width:960px;}#wpadminbar ul,#wpadminbar ul li{background:none;list-style:none;margin:0;padding:0;position:relative;z-index:99999;}#wpadminbar .quicklinks ul{text-align:left;}#wpadminbar .quicklinks ul li{float:left;}#wpadminbar .quicklinks>ul>li>a{border-right:1px solid #686868;border-left:1px solid #808080;}#wpadminbar .quicklinks>ul>li:last-child>a{border-right:none;}#wpadminbar .quicklinks>ul>li:hover>a{border-left-color:#707070;}#wpadminbar .quicklinks a,#wpadminbar .shortlink-input{color:#ddd;height:28px;text-shadow:#555 0 -1px 0;display:block;font:normal 13px/28px Arial,Helvetica,sans-serif;padding:0 .85em;margin:0;}#wpadminbar .quicklinks a>span{line-height:28px;}#wpadminbar .quicklinks .menupop ul,#wpadminbar .shortlink-input{-moz-box-shadow:0 4px 8px rgba(0,0,0,0.1);-webkit-box-shadow:0 4px 8px rgba(0,0,0,0.1);box-shadow:0 4px 8px rgba(0,0,0,0.1);background:#fff;background:rgba(255,255,255,0.97);display:none;position:absolute;border:1px solid #dfdfdf;border-top:none;float:none;}#wpadminbar .selected .shortlink-input{display:block;}#wpadminbar .quicklinks .menupop ul li{float:none;}#wpadminbar .quicklinks .menupop ul li a,#wpadminbar .shortlink-input{color:#555;text-shadow:none;white-space:nowrap;min-width:140px;}#wpadminbar .shortlink-input{width:200px;}#wpadminbar .quicklinks .menupop ul li:hover>a{color:#fff;text-shadow:#666 0 -1px 0;}#wpadminbar .quicklinks li:hover>ul,#wpadminbar .quicklinks li.hover>ul{display:block;}#wpadminbar .quicklinks .menupop li:hover>ul,#wpadminbar .quicklinks .menupop li.hover>ul{margin-left:100%;margin-top:-28px;}#wpadminbar .quicklinks li:hover,#wpadminbar .quicklinks .selected{background:#555;background:-moz-linear-gradient(bottom,#555,#3e3e3e);background:-webkit-gradient(linear,left bottom,left top,from(#555),to(#3e3e3e));}#wpadminbar .quicklinks .menupop li:hover{background:#888;background:-moz-linear-gradient(bottom,#888,#9d9d9d);background:-webkit-gradient(linear,left bottom,left top,from(#888),to(#9d9d9d));}#wpadminbar .quicklinks .menupop a>span{display:inline;background:url(../images/admin-bar-sprite.png?d=11122010) right -58px no-repeat;padding-right:.8em;}#wpadminbar .quicklinks .menupop ul li a>span{display:block;background:url(../images/admin-bar-sprite.png?d=11122010) right -29px no-repeat;padding-right:1.5em;}#wpadminbar .quicklinks a span#ab-awaiting-mod,#wpadminbar .quicklinks a span#ab-updates{background:#eee;color:#333;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:bold;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}#wpadminbar .quicklinks a:hover span#ab-awaiting-mod,#wpadminbar .quicklinks a:hover span#ab-updates{background:#fff;color:#000;}#wpadminbar .quicklinks li#wp-admin-bar-my-account>a{border-left:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a{border-left:none;background:url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar>a img{display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 23px 0 -5px;padding:0;background:#eee;float:none;}#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul{left:30px;}#wpadminbar .quicklinks .menupop li a img.blavatar{vertical-align:middle;margin:0 8px 0 0;padding:0;}#wpadminbar #adminbarsearch{float:right;height:18px;padding:3px;margin:0;}#wpadminbar #adminbarsearch .adminbar-input{width:140px;height:auto;float:left;font:12px Arial,Helvetica,sans-serif;color:#555;text-shadow:0 1px 0 #fff;border:1px solid #626262;padding:2px 3px;margin:0 3px 0 0;background:#ddd;-moz-box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-box-shadow:inset 2px 2px 1px #cdcdcd;box-shadow:inset 2px 2px 1px #cdcdcd;-webkit-border-radius:0;-khtml-border-radius:0;-moz-border-radius:0;border-radius:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;outline:none;}#wpadminbar #adminbarsearch .adminbar-button{font:bold 12px Arial,Helvetica,sans-serif;color:#444;text-shadow:0 1px 0 #eee;cursor:pointer;float:left;background:#aaa;background:-moz-linear-gradient(bottom,#aaa,#cecece);background:-webkit-gradient(linear,left bottom,left top,from(#aaa),to(#cecece));-webkit-border-radius:10px;-khtml-border-radius:10px;-moz-border-radius:10px;border-radius:10px;border:1px solid #626262;padding:2px 13px;margin:0;width:auto;height:auto;}#wpadminbar #adminbarsearch .adminbar-button:active{background:#a0a0a0;background:-moz-linear-gradient(bottom,#a0a0a0,#c1c1c1);background:-webkit-gradient(linear,left bottom,left top,from(#a0a0a0),to(#c1c1c1));-moz-box-shadow:inset 1px 1px 1px #9b9b9b;-webkit-box-shadow:inset 1px 1px 1px #9b9b9b;box-shadow:inset 1px 1px 1px #9b9b9b;}#wpadminbar #adminbarsearch .adminbar-button:hover{color:#000;}#wpadminbar #adminbarsearch .adminbar-button::-moz-focus-inner{border:none;}* html #wpadminbar{overflow:hidden;position:absolute;}* html #wpadminbar .quicklinks ul li a{float:left;}* html #wpadminbar .menupop a span{background-image:none;}
Index: /tags/3.1/wp-includes/css/admin-bar.dev.css
===================================================================
--- /tags/3.1/wp-includes/css/admin-bar.dev.css	(revision 17487)
+++ /tags/3.1/wp-includes/css/admin-bar.dev.css	(revision 17487)
@@ -0,0 +1,298 @@
+#wpadminbar * {
+	height: auto;
+	width: auto;
+	margin: 0;
+	padding: 0;
+	position: static;
+	text-transform: none;
+	letter-spacing: normal;
+	line-height: 1;
+}
+
+#wpadminbar :before,
+#wpadminbar :after {
+	content: normal;
+}
+
+#wpadminbar a,
+#wpadminbar a:hover,
+#wpadminbar a img, 
+#wpadminbar a img:hover {
+	outline: none;
+	border: none;
+	text-decoration: none;
+	background: none;
+}
+
+#wpadminbar {
+	direction: ltr;
+	background-color: #777;
+	background-image: -moz-linear-gradient(bottom,  #666,  #7f7f7f);
+	background-image: -webkit-gradient(linear, left bottom, left top, from(#666), to(#7f7f7f));
+	color: #ddd;
+	font: normal 12px/28px Arial, Helvetica, sans-serif;
+	height: 28px;
+	position: fixed;
+	top: 0;
+	left: 0;
+	width: 100%;
+	z-index: 99999;
+	min-width: 960px;
+}
+
+#wpadminbar ul,
+#wpadminbar ul li {
+	background: none;
+	list-style: none;
+	margin: 0;
+	padding: 0;
+	position: relative;
+	z-index: 99999;
+}
+
+#wpadminbar .quicklinks ul {
+	text-align: left;
+}
+
+#wpadminbar .quicklinks ul li {
+	float: left;
+}
+
+#wpadminbar .quicklinks > ul > li > a {
+	border-right: 1px solid #686868;
+	border-left: 1px solid #808080;
+}
+
+#wpadminbar .quicklinks > ul > li:last-child > a {
+	border-right: none;
+}
+
+#wpadminbar .quicklinks > ul > li:hover > a {
+	border-left-color: #707070;
+}
+
+#wpadminbar .quicklinks a,
+#wpadminbar .shortlink-input {
+	color: #ddd;
+	height: 28px;
+	text-shadow: #555 0px -1px 0px;
+	display: block;
+	font: normal 13px/28px Arial, Helvetica, sans-serif;
+	padding: 0 0.85em;
+	margin: 0;
+}
+
+#wpadminbar .quicklinks a > span {
+	line-height: 28px;
+}
+
+#wpadminbar .quicklinks .menupop ul,
+#wpadminbar .shortlink-input {
+	-moz-box-shadow: 0 4px 8px rgba(0,0,0,0.1);
+	-webkit-box-shadow: 0 4px 8px rgba(0,0,0,0.1);
+	box-shadow: 0 4px 8px rgba(0,0,0,0.1);
+	background: #fff;
+	background: rgba(255,255,255,0.97);
+	display: none;
+	position: absolute;
+	border: 1px solid #dfdfdf;
+	border-top: none;
+	float: none;
+}
+
+#wpadminbar .selected .shortlink-input {
+	display: block;
+}
+
+#wpadminbar .quicklinks .menupop ul li {
+	float: none;
+}
+
+#wpadminbar .quicklinks .menupop ul li a,
+#wpadminbar .shortlink-input {
+	color: #555;
+	text-shadow: none;
+	white-space: nowrap;
+	min-width: 140px;
+}
+
+#wpadminbar .shortlink-input {
+	width: 200px;
+}
+
+#wpadminbar .quicklinks .menupop ul li:hover > a {
+	color: #fff;
+	text-shadow: #666 0px -1px 0px;
+}
+
+#wpadminbar .quicklinks li:hover > ul,
+#wpadminbar .quicklinks li.hover > ul {
+	display: block;
+}
+
+#wpadminbar .quicklinks .menupop li:hover > ul,
+#wpadminbar .quicklinks .menupop li.hover > ul {
+	margin-left: 100%;
+	margin-top: -28px;
+}
+
+#wpadminbar .quicklinks li:hover,
+#wpadminbar .quicklinks .selected {
+	background: #555;
+	background: -moz-linear-gradient(bottom,  #555,  #3e3e3e);
+	background: -webkit-gradient(linear, left bottom, left top, from(#555), to(#3e3e3e));
+}
+
+#wpadminbar .quicklinks .menupop li:hover {
+	background: #888;
+	background: -moz-linear-gradient(bottom,  #888,  #9d9d9d);
+	background: -webkit-gradient(linear, left bottom, left top, from(#888), to(#9d9d9d));
+}
+
+#wpadminbar .quicklinks .menupop a > span {
+	display: inline;
+	background: url(../images/admin-bar-sprite.png?d=11122010) right -58px no-repeat;
+	padding-right: .8em;
+}
+
+#wpadminbar .quicklinks .menupop ul li a > span {
+	display: block;
+	background: url(../images/admin-bar-sprite.png?d=11122010) right -29px no-repeat;
+	padding-right: 1.5em;
+}
+
+#wpadminbar .quicklinks a span#ab-awaiting-mod,
+#wpadminbar .quicklinks a span#ab-updates {
+	background: #eee;
+	color: #333;
+	text-shadow: none;
+	display: inline;
+	padding: 2px 5px;
+	font-size: 10px;
+	font-weight: bold;
+	-moz-border-radius: 10px;
+	-khtml-border-radius: 10px;
+	-webkit-border-radius: 10px;
+	border-radius: 10px;
+}
+
+#wpadminbar .quicklinks a:hover span#ab-awaiting-mod,
+#wpadminbar .quicklinks a:hover span#ab-updates  {
+	background: #fff;
+	color: #000;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account > a {
+	border-left: none;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a {
+	border-left: none;
+	background: url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar > a img {
+	display: inline;
+	border: 1px solid #999;
+	vertical-align: middle;
+	margin: -2px 23px 0 -5px;
+	padding: 0;
+	background: #eee;
+	float: none;
+}
+
+#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul {
+	left: 30px;
+}
+
+#wpadminbar .quicklinks .menupop li a img.blavatar {
+	vertical-align: middle;
+	margin: 0 8px 0 0;
+	padding: 0;
+}
+
+#wpadminbar #adminbarsearch {
+	float: right;
+	height: 18px;
+	padding: 3px;
+	margin: 0;
+}
+
+#wpadminbar #adminbarsearch .adminbar-input {
+	width: 140px;
+	height: auto;
+	float: left;
+	font: 12px Arial, Helvetica, sans-serif;
+	color: #555;
+	text-shadow: 0 1px 0 #fff;
+	border: 1px solid #626262;
+	padding: 2px 3px;
+	margin: 0 3px 0 0;
+	background: #ddd;
+	-moz-box-shadow: inset 2px 2px 1px #cdcdcd;
+	-webkit-box-shadow: inset 2px 2px 1px #cdcdcd;
+	box-shadow: inset 2px 2px 1px #cdcdcd;
+	-webkit-border-radius: 0;
+	-khtml-border-radius: 0;
+	-moz-border-radius: 0;
+	border-radius: 0;
+	-moz-box-sizing: border-box;
+	-webkit-box-sizing: border-box;
+	-ms-box-sizing: border-box;
+	box-sizing: border-box;
+	outline: none;
+}
+
+#wpadminbar #adminbarsearch .adminbar-button {
+	font: bold 12px Arial, Helvetica, sans-serif;
+	color: #444;
+	text-shadow: 0px 1px 0px #eee;
+	cursor: pointer;
+	float: left;
+	background: #aaa;
+	background: -moz-linear-gradient(bottom,  #aaa,  #cecece);
+	background: -webkit-gradient(linear, left bottom, left top, from(#aaa), to(#cecece));
+	-webkit-border-radius: 10px;
+	-khtml-border-radius: 10px;
+	-moz-border-radius: 10px;
+	border-radius: 10px;
+	border: 1px solid #626262;
+	padding: 2px 13px;
+	margin: 0;
+	width: auto;
+	height: auto;
+}
+
+#wpadminbar #adminbarsearch .adminbar-button:active {
+	background: #a0a0a0;
+	background:-moz-linear-gradient(bottom,  #a0a0a0,  #c1c1c1);
+	background:-webkit-gradient(linear, left bottom, left top, from(#a0a0a0), to(#c1c1c1));
+	-moz-box-shadow: inset 1px 1px 1px #9b9b9b;
+	-webkit-box-shadow: inset 1px 1px 1px #9b9b9b;
+	box-shadow: inset 1px 1px 1px #9b9b9b;
+}
+
+#wpadminbar #adminbarsearch .adminbar-button:hover {
+	color: #000;
+}
+
+#wpadminbar #adminbarsearch .adminbar-button::-moz-focus-inner {
+	border: none;
+}
+
+
+/**
+ * IE 6-targeted rules
+ */
+* html #wpadminbar {
+	overflow: hidden;
+	position: absolute;
+}
+
+* html #wpadminbar .quicklinks ul li a {
+	float: left;
+}
+
+* html #wpadminbar .menupop a span {
+	background-image: none;
+}
Index: /tags/3.1/wp-includes/css/jquery-ui-dialog.css
===================================================================
--- /tags/3.1/wp-includes/css/jquery-ui-dialog.css	(revision 17487)
+++ /tags/3.1/wp-includes/css/jquery-ui-dialog.css	(revision 17487)
@@ -0,0 +1,1 @@
+.ui-helper-hidden{display:none;}.ui-helper-hidden-accessible{position:absolute;left:-99999999px;}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none;}.ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}.ui-helper-clearfix{display:inline-block;}/* required comment for clearfix to work in Opera \*/ * html .ui-helper-clearfix{height:1%;}.ui-helper-clearfix{display:block;}/* end clearfix */ .ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0);}.ui-state-disabled{cursor:default!important;}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat;}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%;}.ui-resizable{position:relative;}.ui-resizable-handle{position:absolute;font-size:.1px;z-index:99999;display:block;}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none;}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0;}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0;}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%;}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%;}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px;}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px;}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px;}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px;}.wp-dialog{position:absolute;width:300px;overflow:hidden;}.wp-dialog .ui-dialog-titlebar{position:relative;}.wp-dialog .ui-dialog-titlebar-close span{display:block;margin:1px;}.wp-dialog .ui-dialog-content{position:relative;border:0;padding:0;background:none;overflow:auto;zoom:1;}.wp-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em;}.wp-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right;}.wp-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer;}.wp-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px;}.ui-draggable .ui-dialog-titlebar{cursor:move;}.wp-dialog{border:1px solid #999;-moz-box-shadow:0 0 16px rgba(0,0,0,0.3);-webkit-box-shadow:0 0 16px rgba(0,0,0,0.3);box-shadow:0 0 16px rgba(0,0,0,0.3);}.wp-dialog .ui-dialog-title{display:block;text-align:center;padding:1px 0 2px;}.wp-dialog .ui-dialog-titlebar{padding:0 1em;background-color:#444;font-weight:bold;font-size:11px;line-height:18px;color:#e5e5e5;}.wp-dialog{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-right-radius:4px;border-top-right-radius:4px;}.wp-dialog .ui-dialog-titlebar{-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px;}.wp-dialog .ui-dialog-titlebar-close{position:absolute;width:29px;height:16px;top:2px;right:6px;background:url('../js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif') no-repeat -87px -16px;padding:0;}.wp-dialog .ui-dialog-titlebar-close:hover,.wp-dialog .ui-dialog-titlebar-close:focus{background-position:-87px -32px;}.ui-widget-overlay{background-color:#000;opacity:.6;filter:alpha(opacity=60);}
Index: /tags/3.1/wp-includes/css/jquery-ui-dialog.dev.css
===================================================================
--- /tags/3.1/wp-includes/css/jquery-ui-dialog.dev.css	(revision 17487)
+++ /tags/3.1/wp-includes/css/jquery-ui-dialog.dev.css	(revision 17487)
@@ -0,0 +1,143 @@
+/*
+ * jQuery UI CSS Framework @VERSION
+ *
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Theming/API
+ */
+
+/* Layout helpers
+----------------------------------*/
+.ui-helper-hidden { display: none; }
+.ui-helper-hidden-accessible { position: absolute; left: -99999999px; }
+.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
+.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
+.ui-helper-clearfix { display: inline-block; }
+/* required comment for clearfix to work in Opera \*/
+* html .ui-helper-clearfix { height:1%; }
+.ui-helper-clearfix { display:block; }
+/* end clearfix */
+.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
+
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-disabled { cursor: default !important; }
+
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Overlays */
+.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
+
+/*
+ * jQuery UI Resizable
+ *
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Resizable#theming
+ */
+.ui-resizable { position: relative;}
+.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;}
+.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
+.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
+.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
+.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
+.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
+.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
+.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
+.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
+.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}
+
+/*
+ * jQuery UI Dialog
+ *
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Dialog#theming
+ */
+.wp-dialog { position: absolute; width: 300px; overflow: hidden; }
+.wp-dialog .ui-dialog-titlebar { position: relative; }
+.wp-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
+.wp-dialog .ui-dialog-content { position: relative; border: 0; padding: 0; background: none; overflow: auto; zoom: 1; }
+.wp-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
+.wp-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
+.wp-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
+.wp-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
+.ui-draggable .ui-dialog-titlebar { cursor: move; }
+
+
+
+/* WP jQuery Dialog Theme */
+.wp-dialog {
+	border: 1px solid #999;
+	-moz-box-shadow: 0px 0px 16px rgba( 0,0,0,0.3 );
+	-webkit-box-shadow: 0px 0px 16px rgba( 0,0,0,0.3 );
+	box-shadow: 0px 0px 16px rgba( 0,0,0,0.3 );
+}
+.wp-dialog .ui-dialog-title {
+	display: block;
+	text-align: center;
+	padding: 1px 0 2px;
+}
+.wp-dialog .ui-dialog-titlebar {
+	padding: 0 1em;
+	background-color: #444;
+	font-weight: bold;
+	font-size: 11px;
+	line-height: 18px;
+	color: #e5e5e5;
+}
+.wp-dialog {
+	-moz-border-radius-topleft: 4px;
+	-webkit-border-top-left-radius: 4px;
+	-khtml-border-top-left-radius: 4px;
+	border-top-left-radius: 4px;
+	-moz-border-radius-topright: 4px;
+	-webkit-border-top-right-radius: 4px;
+	-khtml-border-top-right-radius: 4px;
+	border-top-right-radius: 4px;
+}
+.wp-dialog .ui-dialog-titlebar {
+	-moz-border-radius-topleft: 3px;
+	-webkit-border-top-left-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	border-top-left-radius: 3px;
+	-moz-border-radius-topright: 3px;
+	-webkit-border-top-right-radius: 3px;
+	-khtml-border-top-right-radius: 3px;
+	border-top-right-radius: 3px;
+}
+
+.wp-dialog .ui-dialog-titlebar-close {
+	position: absolute;
+	width: 29px;
+	height: 16px;
+	top: 2px;
+	right: 6px;
+	background: url('../js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif') no-repeat -87px -16px;
+	padding: 0;
+}
+.wp-dialog .ui-dialog-titlebar-close:hover,
+.wp-dialog .ui-dialog-titlebar-close:focus {
+	background-position: -87px -32px;
+}
+.ui-widget-overlay {
+	background-color: #000;
+	opacity: 0.6;
+	filter: alpha(opacity=60);
+}
Index: /tags/3.1/wp-includes/default-constants.php
===================================================================
--- /tags/3.1/wp-includes/default-constants.php	(revision 17487)
+++ /tags/3.1/wp-includes/default-constants.php	(revision 17487)
@@ -0,0 +1,297 @@
+<?php
+/**
+ * Defines constants and global variables that can be overridden, generally in wp-config.php.
+ *
+ * @package WordPress
+ */
+
+/**
+ * Defines initial WordPress constants
+ *
+ * @see wp_debug_mode()
+ *
+ * @since 3.0.0
+ */
+function wp_initial_constants( ) {
+	global $blog_id;
+
+	// set memory limits
+	if ( !defined('WP_MEMORY_LIMIT') ) {
+		if( is_multisite() ) {
+			define('WP_MEMORY_LIMIT', '64M');
+		} else {
+			define('WP_MEMORY_LIMIT', '32M');
+		}
+	}
+
+	/**
+	 * The $blog_id global, which you can change in the config allows you to create a simple
+	 * multiple blog installation using just one WordPress and changing $blog_id around.
+	 *
+	 * @global int $blog_id
+	 * @since 2.0.0
+	 */
+	if ( ! isset($blog_id) )
+		$blog_id = 1;
+
+	// set memory limits.
+	if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
+		@ini_set('memory_limit', WP_MEMORY_LIMIT);
+
+	if ( !defined('WP_CONTENT_DIR') )
+		define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
+
+	// Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
+	if ( !defined('WP_DEBUG') )
+		define( 'WP_DEBUG', false );
+
+	// Add define('WP_DEBUG_DISPLAY', false); to wp-config.php use the globally configured setting for display_errors and not force errors to be displayed.
+	if ( !defined('WP_DEBUG_DISPLAY') )
+		define( 'WP_DEBUG_DISPLAY', true );
+
+	// Add define('WP_DEBUG_LOG', true); to enable error logging to wp-content/debug.log.
+	if ( !defined('WP_DEBUG_LOG') )
+		define('WP_DEBUG_LOG', false);
+
+	if ( !defined('WP_CACHE') )
+		define('WP_CACHE', false);
+
+	/**
+	 * Private
+	 */
+	if ( !defined('MEDIA_TRASH') )
+		define('MEDIA_TRASH', false);
+
+	if ( !defined('SHORTINIT') )
+		define('SHORTINIT', false);
+}
+
+/**
+ * Defines plugin directory WordPress constants
+ *
+ * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in
+ *
+ * @since 3.0.0
+ */
+function wp_plugin_directory_constants( ) {
+	if ( !defined('WP_CONTENT_URL') )
+		define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
+
+	/**
+	 * Allows for the plugins directory to be moved from the default location.
+	 *
+	 * @since 2.6.0
+	 */
+	if ( !defined('WP_PLUGIN_DIR') )
+		define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
+
+	/**
+	 * Allows for the plugins directory to be moved from the default location.
+	 *
+	 * @since 2.6.0
+	 */
+	if ( !defined('WP_PLUGIN_URL') )
+		define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
+
+	/**
+	 * Allows for the plugins directory to be moved from the default location.
+	 *
+	 * @since 2.1.0
+	 * @deprecated
+	 */
+	if ( !defined('PLUGINDIR') )
+		define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH.  For back compat.
+
+	/**
+	 * Allows for the mu-plugins directory to be moved from the default location.
+	 *
+	 * @since 2.8.0
+	 */
+	if ( !defined('WPMU_PLUGIN_DIR') )
+		define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
+
+	/**
+	 * Allows for the mu-plugins directory to be moved from the default location.
+	 *
+	 * @since 2.8.0
+	 */
+	if ( !defined('WPMU_PLUGIN_URL') )
+		define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
+
+	/**
+	 * Allows for the mu-plugins directory to be moved from the default location.
+	 *
+	 * @since 2.8.0
+	 * @deprecated
+	 */
+	if ( !defined( 'MUPLUGINDIR' ) )
+		define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH.  For back compat.
+}
+
+/**
+ * Defines cookie related WordPress constants
+ *
+ * Defines constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
+ * @since 3.0.0
+ */
+function wp_cookie_constants( ) {
+	global $wp_default_secret_key;
+
+	/**
+	 * Used to guarantee unique hash cookies
+	 * @since 1.5
+	 */
+	if ( !defined( 'COOKIEHASH' ) ) {
+		$siteurl = get_site_option( 'siteurl' );
+		if ( $siteurl )
+			define( 'COOKIEHASH', md5( $siteurl ) );
+		else
+			define( 'COOKIEHASH', '' );
+	}
+
+	/**
+	 * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
+	 * @since 2.5.0
+	 */
+	$wp_default_secret_key = 'put your unique phrase here';
+
+	/**
+	 * @since 2.0.0
+	 */
+	if ( !defined('USER_COOKIE') )
+		define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
+
+	/**
+	 * @since 2.0.0
+	 */
+	if ( !defined('PASS_COOKIE') )
+		define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
+
+	/**
+	 * @since 2.5.0
+	 */
+	if ( !defined('AUTH_COOKIE') )
+		define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
+
+	/**
+	 * @since 2.6.0
+	 */
+	if ( !defined('SECURE_AUTH_COOKIE') )
+		define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
+
+	/**
+	 * @since 2.6.0
+	 */
+	if ( !defined('LOGGED_IN_COOKIE') )
+		define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
+
+	/**
+	 * @since 2.3.0
+	 */
+	if ( !defined('TEST_COOKIE') )
+		define('TEST_COOKIE', 'wordpress_test_cookie');
+
+	/**
+	 * @since 1.2.0
+	 */
+	if ( !defined('COOKIEPATH') )
+		define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
+
+	/**
+	 * @since 1.5.0
+	 */
+	if ( !defined('SITECOOKIEPATH') )
+		define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
+
+	/**
+	 * @since 2.6.0
+	 */
+	if ( !defined('ADMIN_COOKIE_PATH') )
+		define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
+
+	/**
+	 * @since 2.6.0
+	 */
+	if ( !defined('PLUGINS_COOKIE_PATH') )
+		define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL)  );
+
+	/**
+	 * @since 2.0.0
+	 */
+	if ( !defined('COOKIE_DOMAIN') )
+		define('COOKIE_DOMAIN', false);
+}
+
+/**
+ * Defines cookie related WordPress constants
+ *
+ * @since 3.0.0
+ */
+function wp_ssl_constants( ) {
+	/**
+	 * @since 2.6.0
+	 */
+	if ( !defined('FORCE_SSL_ADMIN') )
+		define('FORCE_SSL_ADMIN', false);
+	force_ssl_admin(FORCE_SSL_ADMIN);
+
+	/**
+	 * @since 2.6.0
+	 */
+	if ( !defined('FORCE_SSL_LOGIN') )
+		define('FORCE_SSL_LOGIN', false);
+	force_ssl_login(FORCE_SSL_LOGIN);
+}
+
+/**
+ * Defines functionality related WordPress constants
+ *
+ * @since 3.0.0
+ */
+function wp_functionality_constants( ) {
+	/**
+	 * @since 2.5.0
+	 */
+	if ( !defined( 'AUTOSAVE_INTERVAL' ) )
+		define( 'AUTOSAVE_INTERVAL', 60 );
+
+	/**
+	 * @since 2.9.0
+	 */
+	if ( !defined( 'EMPTY_TRASH_DAYS' ) )
+		define( 'EMPTY_TRASH_DAYS', 30 );
+
+	if ( !defined('WP_POST_REVISIONS') )
+		define('WP_POST_REVISIONS', true);
+}
+
+/**
+ * Defines templating related WordPress constants
+ *
+ * @since 3.0.0
+ */
+function wp_templating_constants( ) {
+	/**
+	 * Web Path to the current active template directory
+	 * @since 1.5.0
+	 */
+	define('TEMPLATEPATH', get_template_directory());
+
+	/**
+	 * Web Path to the current active template stylesheet directory
+	 * @since 2.1.0
+	 */
+	define('STYLESHEETPATH', get_stylesheet_directory());
+
+	/**
+	 * Slug of the default theme for this install.
+	 * Used as the default theme when installing new sites.
+	 * Will be used as the fallback if the current theme doesn't exist.
+	 * @since 3.0.0
+	 */
+	if ( !defined('WP_DEFAULT_THEME') )
+		define( 'WP_DEFAULT_THEME', 'twentyten' );
+
+}
+
+?>
Index: /tags/3.1/wp-includes/default-embeds.php
===================================================================
--- /tags/3.1/wp-includes/default-embeds.php	(revision 17487)
+++ /tags/3.1/wp-includes/default-embeds.php	(revision 17487)
@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * Default Embed Handlers
+ *
+ * @package WordPress
+ * @subpackage Embeds
+ */
+
+/**
+ * The Google Video embed handler callback. Google Video does not support oEmbed.
+ *
+ * @see WP_Embed::register_handler()
+ * @see WP_Embed::shortcode()
+ *
+ * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
+ * @param array $attr Embed attributes.
+ * @param string $url The original URL that was matched by the regex.
+ * @param array $rawattr The original unmodified attributes.
+ * @return string The embed HTML.
+ */
+function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
+	// If the user supplied a fixed width AND height, use it
+	if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) {
+		$width  = (int) $rawattr['width'];
+		$height = (int) $rawattr['height'];
+	} else {
+		list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] );
+	}
+
+	return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&amp;hl=en&amp;fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr );
+}
+wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' );
+
+?>
Index: /tags/3.1/wp-includes/default-filters.php
===================================================================
--- /tags/3.1/wp-includes/default-filters.php	(revision 17487)
+++ /tags/3.1/wp-includes/default-filters.php	(revision 17487)
@@ -0,0 +1,278 @@
+<?php
+/**
+ * Sets up the default filters and actions for most
+ * of the WordPress hooks.
+ *
+ * If you need to remove a default hook, this file will
+ * give you the priority for which to use to remove the
+ * hook.
+ *
+ * Not all of the default hooks are found in default-filters.php
+ *
+ * @package WordPress
+ */
+
+// Strip, trim, kses, special chars for string saves
+foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) {
+	add_filter( $filter, 'sanitize_text_field'  );
+	add_filter( $filter, 'wp_filter_kses'       );
+	add_filter( $filter, '_wp_specialchars', 30 );
+}
+
+// Strip, kses, special chars for string display
+foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) {
+	if ( is_admin() ) {
+		// These are expensive. Run only on admin pages for defense in depth.
+		add_filter( $filter, 'sanitize_text_field'  );
+		add_filter( $filter, 'wp_kses_data'       );
+	}
+	add_filter( $filter, '_wp_specialchars', 30 );
+}
+
+// Kses only for textarea saves
+foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
+	add_filter( $filter, 'wp_filter_kses' );
+}
+
+// Kses only for textarea admin displays
+if ( is_admin() ) {
+	foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) {
+		add_filter( $filter, 'wp_kses_data' );
+	}
+	add_filter( 'comment_text', 'wp_kses_post' );
+}
+
+// Email saves
+foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) {
+	add_filter( $filter, 'trim'           );
+	add_filter( $filter, 'sanitize_email' );
+	add_filter( $filter, 'wp_filter_kses' );
+}
+
+// Email admin display
+foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) {
+	add_filter( $filter, 'sanitize_email' );
+	if ( is_admin() )
+		add_filter( $filter, 'wp_kses_data' );
+}
+
+// Save URL
+foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
+	'pre_link_rss' ) as $filter ) {
+	add_filter( $filter, 'wp_strip_all_tags' );
+	add_filter( $filter, 'esc_url_raw'       );
+	add_filter( $filter, 'wp_filter_kses'    );
+}
+
+// Display URL
+foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' ) as $filter ) {
+	if ( is_admin() )
+		add_filter( $filter, 'wp_strip_all_tags' );
+	add_filter( $filter, 'esc_url'           );
+	if ( is_admin() )
+		add_filter( $filter, 'wp_kses_data'    );
+}
+
+// Slugs
+foreach ( array( 'pre_term_slug' ) as $filter ) {
+	add_filter( $filter, 'sanitize_title' );
+}
+
+// Keys
+foreach ( array( 'pre_post_type' ) as $filter ) {
+	add_filter( $filter, 'sanitize_user' );
+}
+foreach ( array( 'pre_post_status', 'pre_post_comment_status', 'pre_post_ping_status' ) as $filter ) {
+	add_filter( $filter, 'sanitize_key' );
+}
+
+// Places to balance tags on input
+foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) {
+	add_filter( $filter, 'balanceTags', 50 );
+}
+
+// Format strings for display.
+foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) {
+	add_filter( $filter, 'wptexturize'   );
+	add_filter( $filter, 'convert_chars' );
+	add_filter( $filter, 'esc_html'      );
+}
+
+// Format WordPress
+foreach ( array( 'the_content', 'the_title' ) as $filter )
+	add_filter( $filter, 'capital_P_dangit', 11 );
+add_filter( 'comment_text', 'capital_P_dangit', 31 );
+
+// Format titles
+foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) {
+	add_filter( $filter, 'wptexturize' );
+	add_filter( $filter, 'strip_tags'  );
+}
+
+// Format text area for display.
+foreach ( array( 'term_description' ) as $filter ) {
+	add_filter( $filter, 'wptexturize'      );
+	add_filter( $filter, 'convert_chars'    );
+	add_filter( $filter, 'wpautop'          );
+	add_filter( $filter, 'shortcode_unautop');
+}
+
+// Format for RSS
+foreach ( array( 'term_name_rss' ) as $filter ) {
+	add_filter( $filter, 'convert_chars' );
+}
+
+// Pre save hierarchy
+add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 );
+add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
+
+// Display filters
+add_filter( 'the_title', 'wptexturize'   );
+add_filter( 'the_title', 'convert_chars' );
+add_filter( 'the_title', 'trim'          );
+
+add_filter( 'the_content', 'wptexturize'        );
+add_filter( 'the_content', 'convert_smilies'    );
+add_filter( 'the_content', 'convert_chars'      );
+add_filter( 'the_content', 'wpautop'            );
+add_filter( 'the_content', 'shortcode_unautop'  );
+add_filter( 'the_content', 'prepend_attachment' );
+
+add_filter( 'the_excerpt',     'wptexturize'      );
+add_filter( 'the_excerpt',     'convert_smilies'  );
+add_filter( 'the_excerpt',     'convert_chars'    );
+add_filter( 'the_excerpt',     'wpautop'          );
+add_filter( 'the_excerpt',     'shortcode_unautop');
+add_filter( 'get_the_excerpt', 'wp_trim_excerpt'  );
+
+add_filter( 'comment_text', 'wptexturize'            );
+add_filter( 'comment_text', 'convert_chars'          );
+add_filter( 'comment_text', 'make_clickable',      9 );
+add_filter( 'comment_text', 'force_balance_tags', 25 );
+add_filter( 'comment_text', 'convert_smilies',    20 );
+add_filter( 'comment_text', 'wpautop',            30 );
+
+add_filter( 'comment_excerpt', 'convert_chars' );
+
+add_filter( 'list_cats',         'wptexturize' );
+
+add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 );
+
+// RSS filters
+add_filter( 'the_title_rss',      'strip_tags'      );
+add_filter( 'the_title_rss',      'ent2ncr',      8 );
+add_filter( 'the_title_rss',      'esc_html'        );
+add_filter( 'the_content_rss',    'ent2ncr',      8 );
+add_filter( 'the_excerpt_rss',    'convert_chars'   );
+add_filter( 'the_excerpt_rss',    'ent2ncr',      8 );
+add_filter( 'comment_author_rss', 'ent2ncr',      8 );
+add_filter( 'comment_text_rss',   'ent2ncr',      8 );
+add_filter( 'comment_text_rss',   'esc_html'        );
+add_filter( 'bloginfo_rss',       'ent2ncr',      8 );
+add_filter( 'the_author',         'ent2ncr',      8 );
+
+// Misc filters
+add_filter( 'option_ping_sites',    'privacy_ping_filter'                 );
+add_filter( 'option_blog_charset',  '_wp_specialchars'                    ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop
+add_filter( 'option_home',          '_config_wp_home'                     );
+add_filter( 'option_siteurl',       '_config_wp_siteurl'                  );
+add_filter( 'tiny_mce_before_init', '_mce_set_direction'                  );
+add_filter( 'pre_kses',             'wp_pre_kses_less_than'               );
+add_filter( 'sanitize_title',       'sanitize_title_with_dashes'          );
+add_action( 'check_comment_flood',  'check_comment_flood_db',       10, 3 );
+add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood',    10, 3 );
+add_filter( 'pre_comment_content',  'wp_rel_nofollow',              15    );
+add_filter( 'comment_email',        'antispambot'                         );
+add_filter( 'option_tag_base',      '_wp_filter_taxonomy_base'            );
+add_filter( 'option_category_base', '_wp_filter_taxonomy_base'            );
+add_filter( 'the_posts',            '_close_comments_for_old_posts'       );
+add_filter( 'comments_open',        '_close_comments_for_old_post', 10, 2 );
+add_filter( 'pings_open',           '_close_comments_for_old_post', 10, 2 );
+add_filter( 'editable_slug',        'urldecode'                           );
+add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'    );
+
+// Atom SSL support
+add_filter( 'atom_service_url','atom_service_url_filter' );
+
+// Actions
+add_action( 'wp_head',             'wp_enqueue_scripts',            1     );
+add_action( 'wp_head',             'feed_links',                    2     );
+add_action( 'wp_head',             'feed_links_extra',              3     );
+add_action( 'wp_head',             'rsd_link'                             );
+add_action( 'wp_head',             'wlwmanifest_link'                     );
+add_action( 'wp_head',             'index_rel_link'                       );
+add_action( 'wp_head',             'parent_post_rel_link',          10, 0 );
+add_action( 'wp_head',             'start_post_rel_link',           10, 0 );
+add_action( 'wp_head',             'adjacent_posts_rel_link_wp_head', 10, 0 );
+add_action( 'wp_head',             'locale_stylesheet'                    );
+add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
+add_action( 'wp_head',             'noindex',                       1     );
+add_action( 'wp_head',             'wp_print_styles',               8     );
+add_action( 'wp_head',             'wp_print_head_scripts',         9     );
+add_action( 'wp_head',             'wp_generator'                         );
+add_action( 'wp_head',             'rel_canonical'                        );
+add_action( 'wp_footer',           'wp_print_footer_scripts'              );
+add_action( 'wp_head',             'wp_shortlink_wp_head',          10, 0 );
+add_action( 'template_redirect',   'wp_shortlink_header',           11, 0 );
+
+// Login actions
+add_action( 'login_head',          'wp_print_head_scripts',         9     );
+add_action( 'login_footer',        'wp_print_footer_scripts'              );
+
+// Feed Generator Tags
+foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) {
+	add_action( $action, 'the_generator' );
+}
+
+// WP Cron
+if ( !defined( 'DOING_CRON' ) )
+	add_action( 'sanitize_comment_cookies', 'wp_cron' );
+
+// 2 Actions 2 Furious
+add_action( 'do_feed_rdf',                'do_feed_rdf',             10, 1 );
+add_action( 'do_feed_rss',                'do_feed_rss',             10, 1 );
+add_action( 'do_feed_rss2',               'do_feed_rss2',            10, 1 );
+add_action( 'do_feed_atom',               'do_feed_atom',            10, 1 );
+add_action( 'do_pings',                   'do_all_pings',            10, 1 );
+add_action( 'do_robots',                  'do_robots'                      );
+add_action( 'sanitize_comment_cookies',   'sanitize_comment_cookies'       );
+add_action( 'admin_print_scripts',        'print_head_scripts',      20    );
+add_action( 'admin_print_footer_scripts', 'print_footer_scripts',    20    );
+add_action( 'admin_print_styles',         'print_admin_styles',      20    );
+add_action( 'init',                       'smilies_init',             5    );
+add_action( 'plugins_loaded',             'wp_maybe_load_widgets',    0    );
+add_action( 'plugins_loaded',             'wp_maybe_load_embeds',     0    );
+add_action( 'shutdown',                   'wp_ob_end_flush_all',      1    );
+add_action( 'pre_post_update',            'wp_save_post_revision'          );
+add_action( 'publish_post',               '_publish_post_hook',       5, 1 );
+add_action( 'save_post',                  '_save_post_hook',          5, 2 );
+add_action( 'transition_post_status',     '_transition_post_status',  5, 3 );
+add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce'        );
+add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'            );
+
+// Navigation menu actions
+add_action( 'delete_post',                '_wp_delete_post_menu_item'      );
+add_action( 'delete_term',                '_wp_delete_tax_menu_item'       );
+add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu',  10, 3 );
+
+// Post Thumbnail CSS class filtering
+add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'    );
+add_action( 'end_fetch_post_thumbnail_html',   '_wp_post_thumbnail_class_filter_remove' );
+
+// Redirect Old Slugs
+add_action( 'template_redirect', 'wp_old_slug_redirect'              );
+add_action( 'post_updated',      'wp_check_for_changed_slugs', 12, 3 );
+
+// Nonce check for Post Previews
+add_action( 'init', '_show_post_preview' );
+
+// Timezone
+add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' );
+
+// Admin Color Schemes
+add_action( 'admin_init', 'register_admin_color_schemes', 1);
+add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
+
+unset($filter, $action);
+
+?>
Index: /tags/3.1/wp-includes/default-widgets.php
===================================================================
--- /tags/3.1/wp-includes/default-widgets.php	(revision 17487)
+++ /tags/3.1/wp-includes/default-widgets.php	(revision 17487)
@@ -0,0 +1,1158 @@
+<?php
+/**
+ * Default Widgets
+ *
+ * @package WordPress
+ * @subpackage Widgets
+ */
+
+/**
+ * Pages widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Pages extends WP_Widget {
+
+	function WP_Widget_Pages() {
+		$widget_ops = array('classname' => 'widget_pages', 'description' => __( 'Your site&#8217;s WordPress Pages') );
+		$this->WP_Widget('pages', __('Pages'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract( $args );
+
+		$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base);
+		$sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
+		$exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
+
+		if ( $sortby == 'menu_order' )
+			$sortby = 'menu_order, post_title';
+
+		$out = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude) ) );
+
+		if ( !empty( $out ) ) {
+			echo $before_widget;
+			if ( $title)
+				echo $before_title . $title . $after_title;
+		?>
+		<ul>
+			<?php echo $out; ?>
+		</ul>
+		<?php
+			echo $after_widget;
+		}
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+		if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
+			$instance['sortby'] = $new_instance['sortby'];
+		} else {
+			$instance['sortby'] = 'menu_order';
+		}
+
+		$instance['exclude'] = strip_tags( $new_instance['exclude'] );
+
+		return $instance;
+	}
+
+	function form( $instance ) {
+		//Defaults
+		$instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );
+		$title = esc_attr( $instance['title'] );
+		$exclude = esc_attr( $instance['exclude'] );
+	?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
+		<p>
+			<label for="<?php echo $this->get_field_id('sortby'); ?>"><?php _e( 'Sort by:' ); ?></label>
+			<select name="<?php echo $this->get_field_name('sortby'); ?>" id="<?php echo $this->get_field_id('sortby'); ?>" class="widefat">
+				<option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e('Page title'); ?></option>
+				<option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e('Page order'); ?></option>
+				<option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
+			</select>
+		</p>
+		<p>
+			<label for="<?php echo $this->get_field_id('exclude'); ?>"><?php _e( 'Exclude:' ); ?></label> <input type="text" value="<?php echo $exclude; ?>" name="<?php echo $this->get_field_name('exclude'); ?>" id="<?php echo $this->get_field_id('exclude'); ?>" class="widefat" />
+			<br />
+			<small><?php _e( 'Page IDs, separated by commas.' ); ?></small>
+		</p>
+<?php
+	}
+
+}
+
+/**
+ * Links widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Links extends WP_Widget {
+
+	function WP_Widget_Links() {
+		$widget_ops = array('description' => __( "Your blogroll" ) );
+		$this->WP_Widget('links', __('Links'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract($args, EXTR_SKIP);
+
+		$show_description = isset($instance['description']) ? $instance['description'] : false;
+		$show_name = isset($instance['name']) ? $instance['name'] : false;
+		$show_rating = isset($instance['rating']) ? $instance['rating'] : false;
+		$show_images = isset($instance['images']) ? $instance['images'] : true;
+		$category = isset($instance['category']) ? $instance['category'] : false;
+
+		if ( is_admin() && !$category ) {
+			// Display All Links widget as such in the widgets screen
+			echo $before_widget . $before_title. __('All Links') . $after_title . $after_widget;
+			return;
+		}
+
+		$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
+		wp_list_bookmarks(apply_filters('widget_links_args', array(
+			'title_before' => $before_title, 'title_after' => $after_title,
+			'category_before' => $before_widget, 'category_after' => $after_widget,
+			'show_images' => $show_images, 'show_description' => $show_description,
+			'show_name' => $show_name, 'show_rating' => $show_rating,
+			'category' => $category, 'class' => 'linkcat widget'
+		)));
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$new_instance = (array) $new_instance;
+		$instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0);
+		foreach ( $instance as $field => $val ) {
+			if ( isset($new_instance[$field]) )
+				$instance[$field] = 1;
+		}
+		$instance['category'] = intval($new_instance['category']);
+
+		return $instance;
+	}
+
+	function form( $instance ) {
+
+		//Defaults
+		$instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) );
+		$link_cats = get_terms( 'link_category');
+?>
+		<p>
+		<label for="<?php echo $this->get_field_id('category'); ?>" class="screen-reader-text"><?php _e('Select Link Category'); ?></label>
+		<select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
+		<option value=""><?php _e('All Links'); ?></option>
+		<?php
+		foreach ( $link_cats as $link_cat ) {
+			echo '<option value="' . intval($link_cat->term_id) . '"'
+				. ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )
+				. '>' . $link_cat->name . "</option>\n";
+		}
+		?>
+		</select></p>
+		<p>
+		<input class="checkbox" type="checkbox" <?php checked($instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />
+		<label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
+		<input class="checkbox" type="checkbox" <?php checked($instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />
+		<label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
+		<input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />
+		<label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
+		<input class="checkbox" type="checkbox" <?php checked($instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />
+		<label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
+		</p>
+<?php
+	}
+}
+
+/**
+ * Search widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Search extends WP_Widget {
+
+	function WP_Widget_Search() {
+		$widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site") );
+		$this->WP_Widget('search', __('Search'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract($args);
+		$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
+
+		echo $before_widget;
+		if ( $title )
+			echo $before_title . $title . $after_title;
+
+		// Use current theme search form if it exists
+		get_search_form();
+
+		echo $after_widget;
+	}
+
+	function form( $instance ) {
+		$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
+		$title = $instance['title'];
+?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
+<?php
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
+		$instance['title'] = strip_tags($new_instance['title']);
+		return $instance;
+	}
+
+}
+
+/**
+ * Archives widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Archives extends WP_Widget {
+
+	function WP_Widget_Archives() {
+		$widget_ops = array('classname' => 'widget_archive', 'description' => __( 'A monthly archive of your site&#8217;s posts') );
+		$this->WP_Widget('archives', __('Archives'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract($args);
+		$c = $instance['count'] ? '1' : '0';
+		$d = $instance['dropdown'] ? '1' : '0';
+		$title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base);
+
+		echo $before_widget;
+		if ( $title )
+			echo $before_title . $title . $after_title;
+
+		if ( $d ) {
+?>
+		<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo esc_attr(__('Select Month')); ?></option> <?php wp_get_archives(apply_filters('widget_archives_dropdown_args', array('type' => 'monthly', 'format' => 'option', 'show_post_count' => $c))); ?> </select>
+<?php
+		} else {
+?>
+		<ul>
+		<?php wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c))); ?>
+		</ul>
+<?php
+		}
+
+		echo $after_widget;
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
+		$instance['title'] = strip_tags($new_instance['title']);
+		$instance['count'] = $new_instance['count'] ? 1 : 0;
+		$instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0;
+
+		return $instance;
+	}
+
+	function form( $instance ) {
+		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
+		$title = strip_tags($instance['title']);
+		$count = $instance['count'] ? 'checked="checked"' : '';
+		$dropdown = $instance['dropdown'] ? 'checked="checked"' : '';
+?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
+		<p>
+			<input class="checkbox" type="checkbox" <?php echo $dropdown; ?> id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>" /> <label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e('Display as dropdown'); ?></label>
+			<br/>
+			<input class="checkbox" type="checkbox" <?php echo $count; ?> id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" /> <label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Show post counts'); ?></label>
+		</p>
+<?php
+	}
+}
+
+/**
+ * Meta widget class
+ *
+ * Displays log in/out, RSS feed links, etc.
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Meta extends WP_Widget {
+
+	function WP_Widget_Meta() {
+		$widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") );
+		$this->WP_Widget('meta', __('Meta'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract($args);
+		$title = apply_filters('widget_title', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base);
+
+		echo $before_widget;
+		if ( $title )
+			echo $before_title . $title . $after_title;
+?>
+			<ul>
+			<?php wp_register(); ?>
+			<li><?php wp_loginout(); ?></li>
+			<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo esc_attr(__('Syndicate this site using RSS 2.0')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
+			<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>'); ?></a></li>
+			<li><a href="http://wordpress.org/" title="<?php echo esc_attr(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.')); ?>">WordPress.org</a></li>
+			<?php wp_meta(); ?>
+			</ul>
+<?php
+		echo $after_widget;
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+
+		return $instance;
+	}
+
+	function form( $instance ) {
+		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
+		$title = strip_tags($instance['title']);
+?>
+			<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
+<?php
+	}
+}
+
+/**
+ * Calendar widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Calendar extends WP_Widget {
+
+	function WP_Widget_Calendar() {
+		$widget_ops = array('classname' => 'widget_calendar', 'description' => __( 'A calendar of your site&#8217;s posts') );
+		$this->WP_Widget('calendar', __('Calendar'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract($args);
+		$title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title'], $instance, $this->id_base);
+		echo $before_widget;
+		if ( $title )
+			echo $before_title . $title . $after_title;
+		echo '<div id="calendar_wrap">';
+		get_calendar();
+		echo '</div>';
+		echo $after_widget;
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+
+		return $instance;
+	}
+
+	function form( $instance ) {
+		$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
+		$title = strip_tags($instance['title']);
+?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
+		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
+<?php
+	}
+}
+
+/**
+ * Text widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Text extends WP_Widget {
+
+	function WP_Widget_Text() {
+		$widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML'));
+		$control_ops = array('width' => 400, 'height' => 350);
+		$this->WP_Widget('text', __('Text'), $widget_ops, $control_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract($args);
+		$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
+		$text = apply_filters( 'widget_text', $instance['text'], $instance );
+		echo $before_widget;
+		if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
+			<div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
+		<?php
+		echo $after_widget;
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+		if ( current_user_can('unfiltered_html') )
+			$instance['text'] =  $new_instance['text'];
+		else
+			$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
+		$instance['filter'] = isset($new_instance['filter']);
+		return $instance;
+	}
+
+	function form( $instance ) {
+		$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
+		$title = strip_tags($instance['title']);
+		$text = esc_textarea($instance['text']);
+?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
+		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
+
+		<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
+
+		<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
+<?php
+	}
+}
+
+/**
+ * Categories widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Categories extends WP_Widget {
+
+	function WP_Widget_Categories() {
+		$widget_ops = array( 'classname' => 'widget_categories', 'description' => __( "A list or dropdown of categories" ) );
+		$this->WP_Widget('categories', __('Categories'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract( $args );
+
+		$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
+		$c = $instance['count'] ? '1' : '0';
+		$h = $instance['hierarchical'] ? '1' : '0';
+		$d = $instance['dropdown'] ? '1' : '0';
+
+		echo $before_widget;
+		if ( $title )
+			echo $before_title . $title . $after_title;
+
+		$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
+
+		if ( $d ) {
+			$cat_args['show_option_none'] = __('Select Category');
+			wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
+?>
+
+<script type='text/javascript'>
+/* <![CDATA[ */
+	var dropdown = document.getElementById("cat");
+	function onCatChange() {
+		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
+			location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
+		}
+	}
+	dropdown.onchange = onCatChange;
+/* ]]> */
+</script>
+
+<?php
+		} else {
+?>
+		<ul>
+<?php
+		$cat_args['title_li'] = '';
+		wp_list_categories(apply_filters('widget_categories_args', $cat_args));
+?>
+		</ul>
+<?php
+		}
+
+		echo $after_widget;
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+		$instance['count'] = !empty($new_instance['count']) ? 1 : 0;
+		$instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
+		$instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
+
+		return $instance;
+	}
+
+	function form( $instance ) {
+		//Defaults
+		$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
+		$title = esc_attr( $instance['title'] );
+		$count = isset($instance['count']) ? (bool) $instance['count'] :false;
+		$hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
+		$dropdown = isset( $instance['dropdown'] ) ? (bool) $instance['dropdown'] : false;
+?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:' ); ?></label>
+		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
+
+		<p><input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('dropdown'); ?>" name="<?php echo $this->get_field_name('dropdown'); ?>"<?php checked( $dropdown ); ?> />
+		<label for="<?php echo $this->get_field_id('dropdown'); ?>"><?php _e( 'Display as dropdown' ); ?></label><br />
+
+		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>"<?php checked( $count ); ?> />
+		<label for="<?php echo $this->get_field_id('count'); ?>"><?php _e( 'Show post counts' ); ?></label><br />
+
+		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('hierarchical'); ?>" name="<?php echo $this->get_field_name('hierarchical'); ?>"<?php checked( $hierarchical ); ?> />
+		<label for="<?php echo $this->get_field_id('hierarchical'); ?>"><?php _e( 'Show hierarchy' ); ?></label></p>
+<?php
+	}
+
+}
+
+/**
+ * Recent_Posts widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Recent_Posts extends WP_Widget {
+
+	function WP_Widget_Recent_Posts() {
+		$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
+		$this->WP_Widget('recent-posts', __('Recent Posts'), $widget_ops);
+		$this->alt_option_name = 'widget_recent_entries';
+
+		add_action( 'save_post', array(&$this, 'flush_widget_cache') );
+		add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
+		add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
+	}
+
+	function widget($args, $instance) {
+		$cache = wp_cache_get('widget_recent_posts', 'widget');
+
+		if ( !is_array($cache) )
+			$cache = array();
+
+		if ( isset($cache[$args['widget_id']]) ) {
+			echo $cache[$args['widget_id']];
+			return;
+		}
+
+		ob_start();
+		extract($args);
+
+		$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
+		if ( ! $number = absint( $instance['number'] ) )
+ 			$number = 10;
+
+		$r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
+		if ($r->have_posts()) :
+?>
+		<?php echo $before_widget; ?>
+		<?php if ( $title ) echo $before_title . $title . $after_title; ?>
+		<ul>
+		<?php  while ($r->have_posts()) : $r->the_post(); ?>
+		<li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a></li>
+		<?php endwhile; ?>
+		</ul>
+		<?php echo $after_widget; ?>
+<?php
+		// Reset the global $the_post as this query will have stomped on it
+		wp_reset_postdata();
+
+		endif;
+
+		$cache[$args['widget_id']] = ob_get_flush();
+		wp_cache_set('widget_recent_posts', $cache, 'widget');
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+		$instance['number'] = (int) $new_instance['number'];
+		$this->flush_widget_cache();
+
+		$alloptions = wp_cache_get( 'alloptions', 'options' );
+		if ( isset($alloptions['widget_recent_entries']) )
+			delete_option('widget_recent_entries');
+
+		return $instance;
+	}
+
+	function flush_widget_cache() {
+		wp_cache_delete('widget_recent_posts', 'widget');
+	}
+
+	function form( $instance ) {
+		$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
+		$number = isset($instance['number']) ? absint($instance['number']) : 5;
+?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
+		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
+
+		<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
+		<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
+<?php
+	}
+}
+
+/**
+ * Recent_Comments widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Recent_Comments extends WP_Widget {
+
+	function WP_Widget_Recent_Comments() {
+		$widget_ops = array('classname' => 'widget_recent_comments', 'description' => __( 'The most recent comments' ) );
+		$this->WP_Widget('recent-comments', __('Recent Comments'), $widget_ops);
+		$this->alt_option_name = 'widget_recent_comments';
+
+		if ( is_active_widget(false, false, $this->id_base) )
+			add_action( 'wp_head', array(&$this, 'recent_comments_style') );
+
+		add_action( 'comment_post', array(&$this, 'flush_widget_cache') );
+		add_action( 'transition_comment_status', array(&$this, 'flush_widget_cache') );
+	}
+
+	function recent_comments_style() {
+		if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876
+			|| ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) )
+			return;
+		?>
+	<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
+<?php
+	}
+
+	function flush_widget_cache() {
+		wp_cache_delete('widget_recent_comments', 'widget');
+	}
+
+	function widget( $args, $instance ) {
+		global $comments, $comment;
+
+		$cache = wp_cache_get('widget_recent_comments', 'widget');
+
+		if ( ! is_array( $cache ) )
+			$cache = array();
+
+		if ( isset( $cache[$args['widget_id']] ) ) {
+			echo $cache[$args['widget_id']];
+			return;
+		}
+
+ 		extract($args, EXTR_SKIP);
+ 		$output = '';
+ 		$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
+
+		if ( ! $number = absint( $instance['number'] ) )
+ 			$number = 5;
+
+		$comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) );
+		$output .= $before_widget;
+		if ( $title )
+			$output .= $before_title . $title . $after_title;
+
+		$output .= '<ul id="recentcomments">';
+		if ( $comments ) {
+			foreach ( (array) $comments as $comment) {
+				$output .=  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
+			}
+ 		}
+		$output .= '</ul>';
+		$output .= $after_widget;
+
+		echo $output;
+		$cache[$args['widget_id']] = $output;
+		wp_cache_set('widget_recent_comments', $cache, 'widget');
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance = $old_instance;
+		$instance['title'] = strip_tags($new_instance['title']);
+		$instance['number'] = absint( $new_instance['number'] );
+		$this->flush_widget_cache();
+
+		$alloptions = wp_cache_get( 'alloptions', 'options' );
+		if ( isset($alloptions['widget_recent_comments']) )
+			delete_option('widget_recent_comments');
+
+		return $instance;
+	}
+
+	function form( $instance ) {
+		$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
+		$number = isset($instance['number']) ? absint($instance['number']) : 5;
+?>
+		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
+		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
+
+		<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of comments to show:'); ?></label>
+		<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
+<?php
+	}
+}
+
+/**
+ * RSS widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_RSS extends WP_Widget {
+
+	function WP_Widget_RSS() {
+		$widget_ops = array( 'description' => __('Entries from any RSS or Atom feed') );
+		$control_ops = array( 'width' => 400, 'height' => 200 );
+		$this->WP_Widget( 'rss', __('RSS'), $widget_ops, $control_ops );
+	}
+
+	function widget($args, $instance) {
+
+		if ( isset($instance['error']) && $instance['error'] )
+			return;
+
+		extract($args, EXTR_SKIP);
+
+		$url = $instance['url'];
+		while ( stristr($url, 'http') != $url )
+			$url = substr($url, 1);
+
+		if ( empty($url) )
+			return;
+
+		// self-url destruction sequence
+		if ( $url == site_url() || $url == home_url() )
+			return;
+
+		$rss = fetch_feed($url);
+		$title = $instance['title'];
+		$desc = '';
+		$link = '';
+
+		if ( ! is_wp_error($rss) ) {
+			$desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
+			if ( empty($title) )
+				$title = esc_html(strip_tags($rss->get_title()));
+			$link = esc_url(strip_tags($rss->get_permalink()));
+			while ( stristr($link, 'http') != $link )
+				$link = substr($link, 1);
+		}
+
+		if ( empty($title) )
+			$title = empty($desc) ? __('Unknown Feed') : $desc;
+
+		$title = apply_filters('widget_title', $title, $instance, $this->id_base);
+		$url = esc_url(strip_tags($url));
+		$icon = includes_url('images/rss.png');
+		if ( $title )
+			$title = "<a class='rsswidget' href='$url' title='" . esc_attr__( 'Syndicate this content' ) ."'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a> <a class='rsswidget' href='$link' title='$desc'>$title</a>";
+
+		echo $before_widget;
+		if ( $title )
+			echo $before_title . $title . $after_title;
+		wp_widget_rss_output( $rss, $instance );
+		echo $after_widget;
+
+		if ( ! is_wp_error($rss) )
+			$rss->__destruct();
+		unset($rss);
+	}
+
+	function update($new_instance, $old_instance) {
+		$testurl = ( isset($new_instance['url']) && ($new_instance['url'] != $old_instance['url']) );
+		return wp_widget_rss_process( $new_instance, $testurl );
+	}
+
+	function form($instance) {
+
+		if ( empty($instance) )
+			$instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
+		$instance['number'] = $this->number;
+
+		wp_widget_rss_form( $instance );
+	}
+}
+
+/**
+ * Display the RSS entries in a list.
+ *
+ * @since 2.5.0
+ *
+ * @param string|array|object $rss RSS url.
+ * @param array $args Widget arguments.
+ */
+function wp_widget_rss_output( $rss, $args = array() ) {
+	if ( is_string( $rss ) ) {
+		$rss = fetch_feed($rss);
+	} elseif ( is_array($rss) && isset($rss['url']) ) {
+		$args = $rss;
+		$rss = fetch_feed($rss['url']);
+	} elseif ( !is_object($rss) ) {
+		return;
+	}
+
+	if ( is_wp_error($rss) ) {
+		if ( is_admin() || current_user_can('manage_options') )
+			echo '<p>' . sprintf( __('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
+		return;
+	}
+
+	$default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 );
+	$args = wp_parse_args( $args, $default_args );
+	extract( $args, EXTR_SKIP );
+
+	$items = (int) $items;
+	if ( $items < 1 || 20 < $items )
+		$items = 10;
+	$show_summary  = (int) $show_summary;
+	$show_author   = (int) $show_author;
+	$show_date     = (int) $show_date;
+
+	if ( !$rss->get_item_quantity() ) {
+		echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
+		$rss->__destruct();
+		unset($rss);
+		return;
+	}
+
+	echo '<ul>';
+	foreach ( $rss->get_items(0, $items) as $item ) {
+		$link = $item->get_link();
+		while ( stristr($link, 'http') != $link )
+			$link = substr($link, 1);
+		$link = esc_url(strip_tags($link));
+		$title = esc_attr(strip_tags($item->get_title()));
+		if ( empty($title) )
+			$title = __('Untitled');
+
+		$desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) );
+		$desc = wp_html_excerpt( $desc, 360 );
+
+		// Append ellipsis. Change existing [...] to [&hellip;].
+		if ( '[...]' == substr( $desc, -5 ) )
+			$desc = substr( $desc, 0, -5 ) . '[&hellip;]';
+		elseif ( '[&hellip;]' != substr( $desc, -10 ) )
+			$desc .= ' [&hellip;]';
+
+		$desc = esc_html( $desc );
+
+		if ( $show_summary ) {
+			$summary = "<div class='rssSummary'>$desc</div>";
+		} else {
+			$summary = '';
+		}
+
+		$date = '';
+		if ( $show_date ) {
+			$date = $item->get_date( 'U' );
+
+			if ( $date ) {
+				$date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date ) . '</span>';
+			}
+		}
+
+		$author = '';
+		if ( $show_author ) {
+			$author = $item->get_author();
+			if ( is_object($author) ) {
+				$author = $author->get_name();
+				$author = ' <cite>' . esc_html( strip_tags( $author ) ) . '</cite>';
+			}
+		}
+
+		if ( $link == '' ) {
+			echo "<li>$title{$date}{$summary}{$author}</li>";
+		} else {
+			echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
+		}
+	}
+	echo '</ul>';
+	$rss->__destruct();
+	unset($rss);
+}
+
+
+
+/**
+ * Display RSS widget options form.
+ *
+ * The options for what fields are displayed for the RSS form are all booleans
+ * and are as follows: 'url', 'title', 'items', 'show_summary', 'show_author',
+ * 'show_date'.
+ *
+ * @since 2.5.0
+ *
+ * @param array|string $args Values for input fields.
+ * @param array $inputs Override default display options.
+ */
+function wp_widget_rss_form( $args, $inputs = null ) {
+
+	$default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true );
+	$inputs = wp_parse_args( $inputs, $default_inputs );
+	extract( $args );
+	extract( $inputs, EXTR_SKIP);
+
+	$number = esc_attr( $number );
+	$title  = esc_attr( $title );
+	$url    = esc_url( $url );
+	$items  = (int) $items;
+	if ( $items < 1 || 20 < $items )
+		$items  = 10;
+	$show_summary   = (int) $show_summary;
+	$show_author    = (int) $show_author;
+	$show_date      = (int) $show_date;
+
+	if ( !empty($error) )
+		echo '<p class="widget-error"><strong>' . sprintf( __('RSS Error: %s'), $error) . '</strong></p>';
+
+	if ( $inputs['url'] ) :
+?>
+	<p><label for="rss-url-<?php echo $number; ?>"><?php _e('Enter the RSS feed URL here:'); ?></label>
+	<input class="widefat" id="rss-url-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][url]" type="text" value="<?php echo $url; ?>" /></p>
+<?php endif; if ( $inputs['title'] ) : ?>
+	<p><label for="rss-title-<?php echo $number; ?>"><?php _e('Give the feed a title (optional):'); ?></label>
+	<input class="widefat" id="rss-title-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /></p>
+<?php endif; if ( $inputs['items'] ) : ?>
+	<p><label for="rss-items-<?php echo $number; ?>"><?php _e('How many items would you like to display?'); ?></label>
+	<select id="rss-items-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][items]">
+<?php
+		for ( $i = 1; $i <= 20; ++$i )
+			echo "<option value='$i' " . ( $items == $i ? "selected='selected'" : '' ) . ">$i</option>";
+?>
+	</select></p>
+<?php endif; if ( $inputs['show_summary'] ) : ?>
+	<p><input id="rss-show-summary-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_summary]" type="checkbox" value="1" <?php if ( $show_summary ) echo 'checked="checked"'; ?>/>
+	<label for="rss-show-summary-<?php echo $number; ?>"><?php _e('Display item content?'); ?></label></p>
+<?php endif; if ( $inputs['show_author'] ) : ?>
+	<p><input id="rss-show-author-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_author]" type="checkbox" value="1" <?php if ( $show_author ) echo 'checked="checked"'; ?>/>
+	<label for="rss-show-author-<?php echo $number; ?>"><?php _e('Display item author if available?'); ?></label></p>
+<?php endif; if ( $inputs['show_date'] ) : ?>
+	<p><input id="rss-show-date-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][show_date]" type="checkbox" value="1" <?php if ( $show_date ) echo 'checked="checked"'; ?>/>
+	<label for="rss-show-date-<?php echo $number; ?>"><?php _e('Display item date?'); ?></label></p>
+<?php
+	endif;
+	foreach ( array_keys($default_inputs) as $input ) :
+		if ( 'hidden' === $inputs[$input] ) :
+			$id = str_replace( '_', '-', $input );
+?>
+	<input type="hidden" id="rss-<?php echo $id; ?>-<?php echo $number; ?>" name="widget-rss[<?php echo $number; ?>][<?php echo $input; ?>]" value="<?php echo $$input; ?>" />
+<?php
+		endif;
+	endforeach;
+}
+
+/**
+ * Process RSS feed widget data and optionally retrieve feed items.
+ *
+ * The feed widget can not have more than 20 items or it will reset back to the
+ * default, which is 10.
+ *
+ * The resulting array has the feed title, feed url, feed link (from channel),
+ * feed items, error (if any), and whether to show summary, author, and date.
+ * All respectively in the order of the array elements.
+ *
+ * @since 2.5.0
+ *
+ * @param array $widget_rss RSS widget feed data. Expects unescaped data.
+ * @param bool $check_feed Optional, default is true. Whether to check feed for errors.
+ * @return array
+ */
+function wp_widget_rss_process( $widget_rss, $check_feed = true ) {
+	$items = (int) $widget_rss['items'];
+	if ( $items < 1 || 20 < $items )
+		$items = 10;
+	$url           = esc_url_raw(strip_tags( $widget_rss['url'] ));
+	$title         = trim(strip_tags( $widget_rss['title'] ));
+	$show_summary  = isset($widget_rss['show_summary']) ? (int) $widget_rss['show_summary'] : 0;
+	$show_author   = isset($widget_rss['show_author']) ? (int) $widget_rss['show_author'] :0;
+	$show_date     = isset($widget_rss['show_date']) ? (int) $widget_rss['show_date'] : 0;
+
+	if ( $check_feed ) {
+		$rss = fetch_feed($url);
+		$error = false;
+		$link = '';
+		if ( is_wp_error($rss) ) {
+			$error = $rss->get_error_message();
+		} else {
+			$link = esc_url(strip_tags($rss->get_permalink()));
+			while ( stristr($link, 'http') != $link )
+				$link = substr($link, 1);
+
+			$rss->__destruct();
+			unset($rss);
+		}
+	}
+
+	return compact( 'title', 'url', 'link', 'items', 'error', 'show_summary', 'show_author', 'show_date' );
+}
+
+/**
+ * Tag cloud widget class
+ *
+ * @since 2.8.0
+ */
+class WP_Widget_Tag_Cloud extends WP_Widget {
+
+	function WP_Widget_Tag_Cloud() {
+		$widget_ops = array( 'description' => __( "Your most used tags in cloud format") );
+		$this->WP_Widget('tag_cloud', __('Tag Cloud'), $widget_ops);
+	}
+
+	function widget( $args, $instance ) {
+		extract($args);
+		$current_taxonomy = $this->_get_current_taxonomy($instance);
+		if ( !empty($instance['title']) ) {
+			$title = $instance['title'];
+		} else {
+			if ( 'post_tag' == $current_taxonomy ) {
+				$title = __('Tags');
+			} else {
+				$tax = get_taxonomy($current_taxonomy);
+				$title = $tax->labels->name;
+			}
+		}
+		$title = apply_filters('widget_title', $title, $instance, $this->id_base);
+
+		echo $before_widget;
+		if ( $title )
+			echo $before_title . $title . $after_title;
+		echo '<div class="tagcloud">';
+		wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) );
+		echo "</div>\n";
+		echo $after_widget;
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance['title'] = strip_tags(stripslashes($new_instance['title']));
+		$instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
+		return $instance;
+	}
+
+	function form( $instance ) {
+		$current_taxonomy = $this->_get_current_taxonomy($instance);
+?>
+	<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
+	<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
+	<p><label for="<?php echo $this->get_field_id('taxonomy'); ?>"><?php _e('Taxonomy:') ?></label>
+	<select class="widefat" id="<?php echo $this->get_field_id('taxonomy'); ?>" name="<?php echo $this->get_field_name('taxonomy'); ?>">
+	<?php foreach ( get_object_taxonomies('post') as $taxonomy ) :
+				$tax = get_taxonomy($taxonomy);
+				if ( !$tax->show_tagcloud || empty($tax->labels->name) )
+					continue;
+	?>
+		<option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>
+	<?php endforeach; ?>
+	</select></p><?php
+	}
+
+	function _get_current_taxonomy($instance) {
+		if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
+			return $instance['taxonomy'];
+
+		return 'post_tag';
+	}
+}
+
+/**
+ * Navigation Menu widget class
+ *
+ * @since 3.0.0
+ */
+ class WP_Nav_Menu_Widget extends WP_Widget {
+
+	function WP_Nav_Menu_Widget() {
+		$widget_ops = array( 'description' => __('Use this widget to add one of your custom menus as a widget.') );
+		parent::WP_Widget( 'nav_menu', __('Custom Menu'), $widget_ops );
+	}
+
+	function widget($args, $instance) {
+		// Get menu
+		$nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] );
+
+		if ( !$nav_menu )
+			return;
+
+		$instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
+
+		echo $args['before_widget'];
+
+		if ( !empty($instance['title']) )
+			echo $args['before_title'] . $instance['title'] . $args['after_title'];
+
+		wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) );
+
+		echo $args['after_widget'];
+	}
+
+	function update( $new_instance, $old_instance ) {
+		$instance['title'] = strip_tags( stripslashes($new_instance['title']) );
+		$instance['nav_menu'] = (int) $new_instance['nav_menu'];
+		return $instance;
+	}
+
+	function form( $instance ) {
+		$title = isset( $instance['title'] ) ? $instance['title'] : '';
+		$nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
+
+		// Get menus
+		$menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
+
+		// If no menus exists, direct the user to go and create some.
+		if ( !$menus ) {
+			echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
+			return;
+		}
+		?>
+		<p>
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
+			<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />
+		</p>
+		<p>
+			<label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
+			<select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
+		<?php
+			foreach ( $menus as $menu ) {
+				$selected = $nav_menu == $menu->term_id ? ' selected="selected"' : '';
+				echo '<option'. $selected .' value="'. $menu->term_id .'">'. $menu->name .'</option>';
+			}
+		?>
+			</select>
+		</p>
+		<?php
+	}
+}
+
+/**
+ * Register all of the default WordPress widgets on startup.
+ *
+ * Calls 'widgets_init' action after all of the WordPress widgets have been
+ * registered.
+ *
+ * @since 2.2.0
+ */
+function wp_widgets_init() {
+	if ( !is_blog_installed() )
+		return;
+
+	register_widget('WP_Widget_Pages');
+
+	register_widget('WP_Widget_Calendar');
+
+	register_widget('WP_Widget_Archives');
+
+	register_widget('WP_Widget_Links');
+
+	register_widget('WP_Widget_Meta');
+
+	register_widget('WP_Widget_Search');
+
+	register_widget('WP_Widget_Text');
+
+	register_widget('WP_Widget_Categories');
+
+	register_widget('WP_Widget_Recent_Posts');
+
+	register_widget('WP_Widget_Recent_Comments');
+
+	register_widget('WP_Widget_RSS');
+
+	register_widget('WP_Widget_Tag_Cloud');
+
+	register_widget('WP_Nav_Menu_Widget');
+
+	do_action('widgets_init');
+}
+
+add_action('init', 'wp_widgets_init', 1);
Index: /tags/3.1/wp-includes/deprecated.php
===================================================================
--- /tags/3.1/wp-includes/deprecated.php	(revision 17487)
+++ /tags/3.1/wp-includes/deprecated.php	(revision 17487)
@@ -0,0 +1,2604 @@
+<?php
+/**
+ * Deprecated functions from past WordPress versions. You shouldn't use these
+ * functions and look for the alternatives instead. The functions will be
+ * removed in a later version.
+ *
+ * @package WordPress
+ * @subpackage Deprecated
+ */
+
+/*
+ * Deprecated functions come here to die.
+ */
+
+/**
+ * Entire Post data.
+ *
+ * @since 0.71
+ * @deprecated 1.5.1
+ * @deprecated Use get_post()
+ * @see get_post()
+ *
+ * @param int $postid
+ * @return array
+ */
+function get_postdata($postid) {
+	_deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
+
+	$post = &get_post($postid);
+
+	$postdata = array (
+		'ID' => $post->ID,
+		'Author_ID' => $post->post_author,
+		'Date' => $post->post_date,
+		'Content' => $post->post_content,
+		'Excerpt' => $post->post_excerpt,
+		'Title' => $post->post_title,
+		'Category' => $post->post_category,
+		'post_status' => $post->post_status,
+		'comment_status' => $post->comment_status,
+		'ping_status' => $post->ping_status,
+		'post_password' => $post->post_password,
+		'to_ping' => $post->to_ping,
+		'pinged' => $post->pinged,
+		'post_type' => $post->post_type,
+		'post_name' => $post->post_name
+	);
+
+	return $postdata;
+}
+
+/**
+ * Sets up the WordPress Loop.
+ *
+ * @since 1.0.1
+ * @deprecated 1.5
+ * @deprecated Use The Loop - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop}
+ */
+function start_wp() {
+	global $wp_query, $post;
+
+	_deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') );
+
+	// Since the old style loop is being used, advance the query iterator here.
+	$wp_query->next_post();
+
+	setup_postdata($post);
+}
+
+/**
+ * Return or Print Category ID.
+ *
+ * @since 0.71
+ * @deprecated 0.71
+ * @deprecated use get_the_category()
+ * @see get_the_category()
+ *
+ * @param bool $echo
+ * @return null|int
+ */
+function the_category_ID($echo = true) {
+	_deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );
+
+	// Grab the first cat in the list.
+	$categories = get_the_category();
+	$cat = $categories[0]->term_id;
+
+	if ( $echo )
+		echo $cat;
+
+	return $cat;
+}
+
+/**
+ * Print category with optional text before and after.
+ *
+ * @since 0.71
+ * @deprecated 0.71
+ * @deprecated use get_the_category_by_ID()
+ * @see get_the_category_by_ID()
+ *
+ * @param string $before
+ * @param string $after
+ */
+function the_category_head($before='', $after='') {
+	global $currentcat, $previouscat;
+
+	_deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' );
+
+	// Grab the first cat in the list.
+	$categories = get_the_category();
+	$currentcat = $categories[0]->category_id;
+	if ( $currentcat != $previouscat ) {
+		echo $before;
+		echo get_the_category_by_ID($currentcat);
+		echo $after;
+		$previouscat = $currentcat;
+	}
+}
+
+/**
+ * Prints link to the previous post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use previous_post_link()
+ * @see previous_post_link()
+ *
+ * @param string $format
+ * @param string $previous
+ * @param string $title
+ * @param string $in_same_cat
+ * @param int $limitprev
+ * @param string $excluded_categories
+ */
+function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
+
+	_deprecated_function( __FUNCTION__, '2.0', 'previous_post_link()' );
+
+	if ( empty($in_same_cat) || 'no' == $in_same_cat )
+		$in_same_cat = false;
+	else
+		$in_same_cat = true;
+
+	$post = get_previous_post($in_same_cat, $excluded_categories);
+
+	if ( !$post )
+		return;
+
+	$string = '<a href="'.get_permalink($post->ID).'">'.$previous;
+	if ( 'yes' == $title )
+		$string .= apply_filters('the_title', $post->post_title, $post);
+	$string .= '</a>';
+	$format = str_replace('%', $string, $format);
+	echo $format;
+}
+
+/**
+ * Prints link to the next post.
+ *
+ * @since 0.71
+ * @deprecated 2.0
+ * @deprecated Use next_post_link()
+ * @see next_post_link()
+ *
+ * @param string $format
+ * @param string $next
+ * @param string $title
+ * @param string $in_same_cat
+ * @param int $limitnext
+ * @param string $excluded_categories
+ */
+function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
+	_deprecated_function( __FUNCTION__, '2.0', 'next_post_link()' );
+
+	if ( empty($in_same_cat) || 'no' == $in_same_cat )
+		$in_same_cat = false;
+	else
+		$in_same_cat = true;
+
+	$post = get_next_post($in_same_cat, $excluded_categories);
+
+	if ( !$post	)
+		return;
+
+	$string = '<a href="'.get_permalink($post->ID).'">'.$next;
+	if ( 'yes' == $title )
+		$string .= apply_filters('the_title', $post->post_title, $nextpost);
+	$string .= '</a>';
+	$format = str_replace('%', $string, $format);
+	echo $format;
+}
+
+/**
+ * Whether user can create a post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $blog_id Not Used
+ * @param int $category_id Not Used
+ * @return bool
+ */
+function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	$author_data = get_userdata($user_id);
+	return ($author_data->user_level > 1);
+}
+
+/**
+ * Whether user can create a post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $blog_id Not Used
+ * @param int $category_id Not Used
+ * @return bool
+ */
+function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	$author_data = get_userdata($user_id);
+	return ($author_data->user_level >= 1);
+}
+
+/**
+ * Whether user can edit a post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $post_id
+ * @param int $blog_id Not Used
+ * @return bool
+ */
+function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	$author_data = get_userdata($user_id);
+	$post = get_post($post_id);
+	$post_author_data = get_userdata($post->post_author);
+
+	if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
+			 || ($author_data->user_level > $post_author_data->user_level)
+			 || ($author_data->user_level >= 10) ) {
+		return true;
+	} else {
+		return false;
+	}
+}
+
+/**
+ * Whether user can delete a post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $post_id
+ * @param int $blog_id Not Used
+ * @return bool
+ */
+function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	// right now if one can edit, one can delete
+	return user_can_edit_post($user_id, $post_id, $blog_id);
+}
+
+/**
+ * Whether user can set new posts' dates.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $blog_id Not Used
+ * @param int $category_id Not Used
+ * @return bool
+ */
+function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	$author_data = get_userdata($user_id);
+	return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
+}
+
+/**
+ * Whether user can delete a post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $post_id
+ * @param int $blog_id Not Used
+ * @return bool returns true if $user_id can edit $post_id's date
+ */
+function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	$author_data = get_userdata($user_id);
+	return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
+}
+
+/**
+ * Whether user can delete a post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $post_id
+ * @param int $blog_id Not Used
+ * @return bool returns true if $user_id can edit $post_id's comments
+ */
+function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	// right now if one can edit a post, one can edit comments made on it
+	return user_can_edit_post($user_id, $post_id, $blog_id);
+}
+
+/**
+ * Whether user can delete a post.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $post_id
+ * @param int $blog_id Not Used
+ * @return bool returns true if $user_id can delete $post_id's comments
+ */
+function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	// right now if one can edit comments, one can delete comments
+	return user_can_edit_post_comments($user_id, $post_id, $blog_id);
+}
+
+/**
+ * Can user can edit other user.
+ *
+ * @since 1.5
+ * @deprecated 2.0
+ * @deprecated Use current_user_can()
+ * @see current_user_can()
+ *
+ * @param int $user_id
+ * @param int $other_user
+ * @return bool
+ */
+function user_can_edit_user($user_id, $other_user) {
+	_deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' );
+
+	$user  = get_userdata($user_id);
+	$other = get_userdata($other_user);
+	if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
+		return true;
+	else
+		return false;
+}
+
+/**
+ * Gets the links associated with category $cat_name.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use get_bookmarks()
+ * @see get_bookmarks()
+ *
+ * @param string $cat_name Optional. The category name to use. If no match is found uses all.
+ * @param string $before Optional. The html to output before the link.
+ * @param string $after Optional. The html to output after the link.
+ * @param string $between Optional. The html to output between the link/image and it's description. Not used if no image or $show_images is true.
+ * @param bool $show_images Optional. Whether to show images (if defined).
+ * @param string $orderby Optional. The order to output the links. E.g. 'id', 'name', 'url', 'description' or 'rating'. Or maybe owner.
+ *		If you start the name with an underscore the order will be reversed. You can also specify 'rand' as the order which will return links in a
+ *		random order.
+ * @param bool $show_description Optional. Whether to show the description if show_images=false/not defined.
+ * @param bool $show_rating Optional. Show rating stars/chars.
+ * @param int $limit		Optional. Limit to X entries. If not specified, all entries are shown.
+ * @param int $show_updated Optional. Whether to show last updated timestamp
+ */
+function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id',
+						 $show_description = true, $show_rating = false,
+						 $limit = -1, $show_updated = 0) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
+
+	$cat_id = -1;
+	$cat = get_term_by('name', $cat_name, 'link_category');
+	if ( $cat )
+		$cat_id = $cat->term_id;
+
+	get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated);
+}
+
+/**
+ * Gets the links associated with the named category.
+ *
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use wp_list_bookmarks()
+ * @see wp_list_bookmarks()
+ *
+ * @param string $category The category to use.
+ * @param string $args
+ * @return bool|null
+ */
+function wp_get_linksbyname($category, $args = '') {
+	_deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()');
+
+	$defaults = array(
+		'after' => '<br />',
+		'before' => '',
+		'categorize' => 0,
+		'category_after' => '',
+		'category_before' => '',
+		'category_name' => $category,
+		'show_description' => 1,
+		'title_li' => '',
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+
+	return wp_list_bookmarks($r);
+}
+
+/**
+ * Gets an array of link objects associated with category $cat_name.
+ *
+ * <code>
+ *	$links = get_linkobjectsbyname('fred');
+ *	foreach ($links as $link) {
+ * 		echo '<li>'.$link->link_name.'</li>';
+ *	}
+ * </code>
+ *
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use get_bookmarks()
+ * @see get_bookmarks()
+ *
+ * @param string $cat_name The category name to use. If no match is found uses all.
+ * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url', 'description', or 'rating'.
+ *		Or maybe owner. If you start the name with an underscore the order will be reversed. You can also
+ *		specify 'rand' as the order which will return links in a random order.
+ * @param int $limit Limit to X entries. If not specified, all entries are shown.
+ * @return unknown
+ */
+function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
+
+	$cat_id = -1;
+	$cat = get_term_by('name', $cat_name, 'link_category');
+	if ( $cat )
+		$cat_id = $cat->term_id;
+
+	return get_linkobjects($cat_id, $orderby, $limit);
+}
+
+/**
+ * Gets an array of link objects associated with category n.
+ *
+ * Usage:
+ * <code>
+ *	$links = get_linkobjects(1);
+ *	if ($links) {
+ *		foreach ($links as $link) {
+ *			echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
+ *		}
+ *	}
+ * </code>
+ *
+ * Fields are:
+ * <ol>
+ *	<li>link_id</li>
+ *	<li>link_url</li>
+ *	<li>link_name</li>
+ *	<li>link_image</li>
+ *	<li>link_target</li>
+ *	<li>link_category</li>
+ *	<li>link_description</li>
+ *	<li>link_visible</li>
+ *	<li>link_owner</li>
+ *	<li>link_rating</li>
+ *	<li>link_updated</li>
+ *	<li>link_rel</li>
+ *	<li>link_notes</li>
+ * </ol>
+ *
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use get_bookmarks()
+ * @see get_bookmarks()
+ *
+ * @param int $category The category to use. If no category supplied uses all
+ * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
+ *		'description', or 'rating'. Or maybe owner. If you start the name with an
+ *		underscore the order will be reversed. You can also specify 'rand' as the
+ *		order which will return links in a random order.
+ * @param int $limit Limit to X entries. If not specified, all entries are shown.
+ * @return unknown
+ */
+function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
+
+	$links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ;
+
+	$links_array = array();
+	foreach ($links as $link)
+		$links_array[] = $link;
+
+	return $links_array;
+}
+
+/**
+ * Gets the links associated with category 'cat_name' and display rating stars/chars.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use get_bookmarks()
+ * @see get_bookmarks()
+ *
+ * @param string $cat_name The category name to use. If no match is found uses all
+ * @param string $before The html to output before the link
+ * @param string $after The html to output after the link
+ * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images is true
+ * @param bool $show_images Whether to show images (if defined).
+ * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
+ *		'description', or 'rating'. Or maybe owner. If you start the name with an
+ *		underscore the order will be reversed. You can also specify 'rand' as the
+ *		order which will return links in a random order.
+ * @param bool $show_description Whether to show the description if show_images=false/not defined
+ * @param int $limit Limit to X entries. If not specified, all entries are shown.
+ * @param int $show_updated Whether to show last updated timestamp
+ */
+function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ",
+									$show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
+
+	get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
+}
+
+/**
+ * Gets the links associated with category n and display rating stars/chars.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use get_bookmarks()
+ * @see get_bookmarks()
+ *
+ * @param int $category The category to use. If no category supplied uses all
+ * @param string $before The html to output before the link
+ * @param string $after The html to output after the link
+ * @param string $between The html to output between the link/image and it's description. Not used if no image or show_images == true
+ * @param bool $show_images Whether to show images (if defined).
+ * @param string $orderby The order to output the links. E.g. 'id', 'name', 'url',
+ *		'description', or 'rating'. Or maybe owner. If you start the name with an
+ *		underscore the order will be reversed. You can also specify 'rand' as the
+ *		order which will return links in a random order.
+ * @param bool $show_description Whether to show the description if show_images=false/not defined.
+ * @param string $limit Limit to X entries. If not specified, all entries are shown.
+ * @param int $show_updated Whether to show last updated timestamp
+ */
+function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true,
+							  $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
+
+	get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated);
+}
+
+/**
+ * Gets the auto_toggle setting.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated No alternative function available
+ *
+ * @param int $id The category to get. If no category supplied uses 0
+ * @return int Only returns 0.
+ */
+function get_autotoggle($id = 0) {
+	_deprecated_function( __FUNCTION__, '2.1' );
+	return 0;
+}
+
+/**
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use wp_list_categories()
+ * @see wp_list_categories()
+ *
+ * @param int $optionall
+ * @param string $all
+ * @param string $sort_column
+ * @param string $sort_order
+ * @param string $file
+ * @param bool $list
+ * @param int $optiondates
+ * @param int $optioncount
+ * @param int $hide_empty
+ * @param int $use_desc_for_title
+ * @param bool $children
+ * @param int $child_of
+ * @param int $categories
+ * @param int $recurse
+ * @param string $feed
+ * @param string $feed_image
+ * @param string $exclude
+ * @param bool $hierarchical
+ * @return unknown
+ */
+function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0,
+				   $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0,
+				   $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' );
+
+	$query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children',
+		'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical');
+	return wp_list_cats($query);
+}
+
+/**
+ * @since 1.2
+ * @deprecated 2.1
+ * @deprecated Use wp_list_categories()
+ * @see wp_list_categories()
+ *
+ * @param string|array $args
+ * @return unknown
+ */
+function wp_list_cats($args = '') {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' );
+
+	$r = wp_parse_args( $args );
+
+	// Map to new names.
+	if ( isset($r['optionall']) && isset($r['all']))
+		$r['show_option_all'] = $r['all'];
+	if ( isset($r['sort_column']) )
+		$r['orderby'] = $r['sort_column'];
+	if ( isset($r['sort_order']) )
+		$r['order'] = $r['sort_order'];
+	if ( isset($r['optiondates']) )
+		$r['show_last_update'] = $r['optiondates'];
+	if ( isset($r['optioncount']) )
+		$r['show_count'] = $r['optioncount'];
+	if ( isset($r['list']) )
+		$r['style'] = $r['list'] ? 'list' : 'break';
+	$r['title_li'] = '';
+
+	return wp_list_categories($r);
+}
+
+/**
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use wp_dropdown_categories()
+ * @see wp_dropdown_categories()
+ *
+ * @param int $optionall
+ * @param string $all
+ * @param string $orderby
+ * @param string $order
+ * @param int $show_last_update
+ * @param int $show_count
+ * @param int $hide_empty
+ * @param bool $optionnone
+ * @param int $selected
+ * @param int $exclude
+ * @return unknown
+ */
+function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
+		$show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false,
+		$selected = 0, $exclude = 0) {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_dropdown_categories()' );
+
+	$show_option_all = '';
+	if ( $optionall )
+		$show_option_all = $all;
+
+	$show_option_none = '';
+	if ( $optionnone )
+		$show_option_none = __('None');
+
+	$vars = compact('show_option_all', 'show_option_none', 'orderby', 'order',
+					'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude');
+	$query = add_query_arg($vars, '');
+	return wp_dropdown_categories($query);
+}
+
+/**
+ * @since 1.2
+ * @deprecated 2.1
+ * @deprecated Use wp_list_authors()
+ * @see wp_list_authors()
+ *
+ * @param bool $optioncount
+ * @param bool $exclude_admin
+ * @param bool $show_fullname
+ * @param bool $hide_empty
+ * @param string $feed
+ * @param string $feed_image
+ * @return unknown
+ */
+function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_list_authors()' );
+
+	$args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
+	return wp_list_authors($args);
+}
+
+/**
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use wp_get_post_categories()
+ * @see wp_get_post_categories()
+ *
+ * @param int $blogid Not Used
+ * @param int $post_ID
+ * @return unknown
+ */
+function wp_get_post_cats($blogid = '1', $post_ID = 0) {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_get_post_categories()' );
+	return wp_get_post_categories($post_ID);
+}
+
+/**
+ * Sets the categories that the post id belongs to.
+ *
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use wp_set_post_categories()
+ * @see wp_set_post_categories()
+ *
+ * @param int $blogid Not used
+ * @param int $post_ID
+ * @param array $post_categories
+ * @return unknown
+ */
+function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_set_post_categories()' );
+	return wp_set_post_categories($post_ID, $post_categories);
+}
+
+/**
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use wp_get_archives()
+ * @see wp_get_archives()
+ *
+ * @param string $type
+ * @param string $limit
+ * @param string $format
+ * @param string $before
+ * @param string $after
+ * @param bool $show_post_count
+ * @return unknown
+ */
+function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_get_archives()' );
+	$args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');
+	return wp_get_archives($args);
+}
+
+/**
+ * Returns or Prints link to the author's posts.
+ *
+ * @since 1.2
+ * @deprecated 2.1
+ * @deprecated Use get_author_posts_url()
+ * @see get_author_posts_url()
+ *
+ * @param bool $echo Optional.
+ * @param int $author_id Required.
+ * @param string $author_nicename Optional.
+ * @return string|null
+ */
+function get_author_link($echo = false, $author_id, $author_nicename = '') {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_author_posts_url()' );
+
+	$link = get_author_posts_url($author_id, $author_nicename);
+
+	if ( $echo )
+		echo $link;
+	return $link;
+}
+
+/**
+ * Print list of pages based on arguments.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use wp_link_pages()
+ * @see wp_link_pages()
+ *
+ * @param string $before
+ * @param string $after
+ * @param string $next_or_number
+ * @param string $nextpagelink
+ * @param string $previouspagelink
+ * @param string $pagelink
+ * @param string $more_file
+ * @return string
+ */
+function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page',
+					$pagelink='%', $more_file='') {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_link_pages()' );
+
+	$args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file');
+	return wp_link_pages($args);
+}
+
+/**
+ * Get value based on option.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use get_option()
+ * @see get_option()
+ *
+ * @param string $option
+ * @return string
+ */
+function get_settings($option) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_option()' );
+
+	return get_option($option);
+}
+
+/**
+ * Print the permalink of the current post in the loop.
+ *
+ * @since 0.71
+ * @deprecated 1.2
+ * @deprecated Use the_permalink()
+ * @see the_permalink()
+ */
+function permalink_link() {
+	_deprecated_function( __FUNCTION__, '1.2', 'the_permalink()' );
+	the_permalink();
+}
+
+/**
+ * Print the permalink to the RSS feed.
+ *
+ * @since 0.71
+ * @deprecated 2.3
+ * @deprecated Use the_permalink_rss()
+ * @see the_permalink_rss()
+ *
+ * @param string $deprecated
+ */
+function permalink_single_rss($deprecated = '') {
+	_deprecated_function( __FUNCTION__, '2.3', 'the_permalink_rss()' );
+	the_permalink_rss();
+}
+
+/**
+ * Gets the links associated with category.
+ *
+ * @see get_links() for argument information that can be used in $args
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use wp_list_bookmarks()
+ * @see wp_list_bookmarks()
+ *
+ * @param string $args a query string
+ * @return null|string
+ */
+function wp_get_links($args = '') {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' );
+
+	if ( strpos( $args, '=' ) === false ) {
+		$cat_id = $args;
+		$args = add_query_arg( 'category', $cat_id, $args );
+	}
+
+	$defaults = array(
+		'after' => '<br />',
+		'before' => '',
+		'between' => ' ',
+		'categorize' => 0,
+		'category' => '',
+		'echo' => true,
+		'limit' => -1,
+		'orderby' => 'name',
+		'show_description' => true,
+		'show_images' => true,
+		'show_rating' => false,
+		'show_updated' => true,
+		'title_li' => '',
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+
+	return wp_list_bookmarks($r);
+}
+
+/**
+ * Gets the links associated with category by id.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use get_bookmarks()
+ * @see get_bookmarks()
+ *
+ * @param int $category The category to use. If no category supplied uses all
+ * @param string $before the html to output before the link
+ * @param string $after the html to output after the link
+ * @param string $between the html to output between the link/image and its description.
+ *		Not used if no image or show_images == true
+ * @param bool $show_images whether to show images (if defined).
+ * @param string $orderby the order to output the links. E.g. 'id', 'name', 'url',
+ *		'description', or 'rating'. Or maybe owner. If you start the name with an
+ *		underscore the order will be reversed. You can also specify 'rand' as the order
+ *		which will return links in a random order.
+ * @param bool $show_description whether to show the description if show_images=false/not defined.
+ * @param bool $show_rating show rating stars/chars
+ * @param int $limit Limit to X entries. If not specified, all entries are shown.
+ * @param int $show_updated whether to show last updated timestamp
+ * @param bool $echo whether to echo the results, or return them instead
+ * @return null|string
+ */
+function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name',
+			$show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' );
+
+	$order = 'ASC';
+	if ( substr($orderby, 0, 1) == '_' ) {
+		$order = 'DESC';
+		$orderby = substr($orderby, 1);
+	}
+
+	if ( $category == -1 ) //get_bookmarks uses '' to signify all categories
+		$category = '';
+
+	$results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit));
+
+	if ( !$results )
+		return;
+
+	$output = '';
+
+	foreach ( (array) $results as $row ) {
+		if ( !isset($row->recently_updated) )
+			$row->recently_updated = false;
+		$output .= $before;
+		if ( $show_updated && $row->recently_updated )
+			$output .= get_option('links_recently_updated_prepend');
+		$the_link = '#';
+		if ( !empty($row->link_url) )
+			$the_link = esc_url($row->link_url);
+		$rel = $row->link_rel;
+		if ( '' != $rel )
+			$rel = ' rel="' . $rel . '"';
+
+		$desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display'));
+		$name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display'));
+		$title = $desc;
+
+		if ( $show_updated )
+			if (substr($row->link_updated_f, 0, 2) != '00')
+				$title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')';
+
+		if ( '' != $title )
+			$title = ' title="' . $title . '"';
+
+		$alt = ' alt="' . $name . '"';
+
+		$target = $row->link_target;
+		if ( '' != $target )
+			$target = ' target="' . $target . '"';
+
+		$output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
+
+		if ( $row->link_image != null && $show_images ) {
+			if ( strpos($row->link_image, 'http') !== false )
+				$output .= "<img src=\"$row->link_image\" $alt $title />";
+			else // If it's a relative path
+				$output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />";
+		} else {
+			$output .= $name;
+		}
+
+		$output .= '</a>';
+
+		if ( $show_updated && $row->recently_updated )
+			$output .= get_option('links_recently_updated_append');
+
+		if ( $show_description && '' != $desc )
+			$output .= $between . $desc;
+
+		if ($show_rating) {
+			$output .= $between . get_linkrating($row);
+		}
+
+		$output .= "$after\n";
+	} // end while
+
+	if ( !$echo )
+		return $output;
+	echo $output;
+}
+
+/**
+ * Output entire list of links by category.
+ *
+ * Output a list of all links, listed by category, using the settings in
+ * $wpdb->linkcategories and output it as a nested HTML unordered list.
+ *
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use wp_list_bookmarks()
+ * @see wp_list_bookmarks()
+ *
+ * @param string $order Sort link categories by 'name' or 'id'
+ */
+function get_links_list($order = 'name') {
+	_deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' );
+
+	$order = strtolower($order);
+
+	// Handle link category sorting
+	$direction = 'ASC';
+	if ( '_' == substr($order,0,1) ) {
+		$direction = 'DESC';
+		$order = substr($order,1);
+	}
+
+	if ( !isset($direction) )
+		$direction = '';
+
+	$cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0));
+
+	// Display each category
+	if ( $cats ) {
+		foreach ( (array) $cats as $cat ) {
+			// Handle each category.
+
+			// Display the category name
+			echo '  <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";
+			// Call get_links() with all the appropriate params
+			get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);
+
+			// Close the last category
+			echo "\n\t</ul>\n</li>\n";
+		}
+	}
+}
+
+/**
+ * Show the link to the links popup and the number of links.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated {@internal Use function instead is unknown}}
+ *
+ * @param string $text the text of the link
+ * @param int $width the width of the popup window
+ * @param int $height the height of the popup window
+ * @param string $file the page to open in the popup window
+ * @param bool $count the number of links in the db
+ */
+function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
+	_deprecated_function( __FUNCTION__, '2.1' );
+
+	if ( $count )
+		$counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links");
+
+	$javascript = "<a href=\"#\" onclick=\"javascript:window.open('$file?popup=1', '_blank', 'width=$width,height=$height,scrollbars=yes,status=no'); return false\">";
+	$javascript .= $text;
+
+	if ( $count )
+		$javascript .= " ($counts)";
+
+	$javascript .= "</a>\n\n";
+		echo $javascript;
+}
+
+/**
+ * @since 1.0.1
+ * @deprecated 2.1
+ * @deprecated Use sanitize_bookmark_field()
+ * @see sanitize_bookmark_field()
+ *
+ * @param object $link
+ * @return unknown
+ */
+function get_linkrating($link) {
+	_deprecated_function( __FUNCTION__, '2.1', 'sanitize_bookmark_field()' );
+	return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display');
+}
+
+/**
+ * Gets the name of category by id.
+ *
+ * @since 0.71
+ * @deprecated 2.1
+ * @deprecated Use get_category()
+ * @see get_category()
+ *
+ * @param int $id The category to get. If no category supplied uses 0
+ * @return string
+ */
+function get_linkcatname($id = 0) {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_category()' );
+
+	$id = (int) $id;
+
+	if ( empty($id) )
+		return '';
+
+	$cats = wp_get_link_cats($id);
+
+	if ( empty($cats) || ! is_array($cats) )
+		return '';
+
+	$cat_id = (int) $cats[0]; // Take the first cat.
+
+	$cat = get_category($cat_id);
+	return $cat->name;
+}
+
+/**
+ * Print RSS comment feed link.
+ *
+ * @since 1.0.1
+ * @deprecated 2.5
+ * @deprecated Use post_comments_feed_link()
+ * @see post_comments_feed_link()
+ *
+ * @param string $link_text
+ */
+function comments_rss_link($link_text = 'Comments RSS') {
+	_deprecated_function( __FUNCTION__, '2.5', 'post_comments_feed_link()' );
+	post_comments_feed_link($link_text);
+}
+
+/**
+ * Print/Return link to category RSS2 feed.
+ *
+ * @since 1.2
+ * @deprecated 2.5
+ * @deprecated Use get_category_feed_link()
+ * @see get_category_feed_link()
+ *
+ * @param bool $echo
+ * @param int $cat_ID
+ * @return string|null
+ */
+function get_category_rss_link($echo = false, $cat_ID = 1) {
+	_deprecated_function( __FUNCTION__, '2.5', 'get_category_feed_link()' );
+
+	$link = get_category_feed_link($cat_ID, 'rss2');
+
+	if ( $echo )
+		echo $link;
+	return $link;
+}
+
+/**
+ * Print/Return link to author RSS feed.
+ *
+ * @since 1.2
+ * @deprecated 2.5
+ * @deprecated Use get_author_feed_link()
+ * @see get_author_feed_link()
+ *
+ * @param bool $echo
+ * @param int $author_id
+ * @return string|null
+ */
+function get_author_rss_link($echo = false, $author_id = 1) {
+	_deprecated_function( __FUNCTION__, '2.5', 'get_author_feed_link()' );
+
+	$link = get_author_feed_link($author_id);
+	if ( $echo )
+		echo $link;
+	return $link;
+}
+
+/**
+ * Return link to the post RSS feed.
+ *
+ * @since 1.5
+ * @deprecated 2.2
+ * @deprecated Use get_post_comments_feed_link()
+ * @see get_post_comments_feed_link()
+ *
+ * @return string
+ */
+function comments_rss() {
+	_deprecated_function( __FUNCTION__, '2.2', 'get_post_comments_feed_link()' );
+	return get_post_comments_feed_link();
+}
+
+/**
+ * An alias of wp_create_user().
+ *
+ * @since 2.0
+ * @deprecated 2.0
+ * @deprecated Use wp_create_user()
+ * @see wp_create_user()
+ *
+ * @param string $username The user's username.
+ * @param string $password The user's password.
+ * @param string $email The user's email (optional).
+ * @return int The new user's ID.
+ */
+function create_user($username, $password, $email) {
+	_deprecated_function( __FUNCTION__, '2.0', 'wp_create_user()' );
+	return wp_create_user($username, $password, $email);
+}
+
+/**
+ * Unused function.
+ *
+ * @deprecated 2.5
+*/
+function gzip_compression() {
+	_deprecated_function( __FUNCTION__, '2.5' );
+	return false;
+}
+
+/**
+ * Retrieve an array of comment data about comment $comment_ID.
+ *
+ * @since 0.71
+ * @deprecated 2.7
+ * @deprecated Use get_comment()
+ * @see get_comment()
+ *
+ * @param int $comment_ID The ID of the comment
+ * @param int $no_cache Whether to use the cache (cast to bool)
+ * @param bool $include_unapproved Whether to include unapproved comments
+ * @return array The comment data
+ */
+function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) {
+	_deprecated_function( __FUNCTION__, '2.7', 'get_comment()' );
+	return get_comment($comment_ID, ARRAY_A);
+}
+
+/**
+ * Retrieve the category name by the category ID.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use get_cat_name()
+ * @see get_cat_name()
+ *
+ * @param int $cat_ID Category ID
+ * @return string category name
+ */
+function get_catname( $cat_ID ) {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_cat_name()' );
+	return get_cat_name( $cat_ID );
+}
+
+/**
+ * Retrieve category children list separated before and after the term IDs.
+ *
+ * @since 1.2.0
+ * @deprecated 2.8
+ * @deprecated Use get_term_children()
+ * @see get_term_children()
+ *
+ * @param int $id Category ID to retrieve children.
+ * @param string $before Optional. Prepend before category term ID.
+ * @param string $after Optional, default is empty string. Append after category term ID.
+ * @param array $visited Optional. Category Term IDs that have already been added.
+ * @return string
+ */
+function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_term_children()' );
+	if ( 0 == $id )
+		return '';
+
+	$chain = '';
+	/** TODO: consult hierarchy */
+	$cat_ids = get_all_category_ids();
+	foreach ( (array) $cat_ids as $cat_id ) {
+		if ( $cat_id == $id )
+			continue;
+
+		$category = get_category( $cat_id );
+		if ( is_wp_error( $category ) )
+			return $category;
+		if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
+			$visited[] = $category->term_id;
+			$chain .= $before.$category->term_id.$after;
+			$chain .= get_category_children( $category->term_id, $before, $after );
+		}
+	}
+	return $chain;
+}
+
+/**
+ * Retrieve the description of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('description')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's description.
+ */
+function get_the_author_description() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'description\')' );
+	return get_the_author_meta('description');
+}
+
+/**
+ * Display the description of the author of the current post.
+ *
+ * @since 1.0.0
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('description')
+ * @see the_author_meta()
+ */
+function the_author_description() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')' );
+	the_author_meta('description');
+}
+
+/**
+ * Retrieve the login name of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('login')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's login name (username).
+ */
+function get_the_author_login() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'login\')' );
+	return get_the_author_meta('login');
+}
+
+/**
+ * Display the login name of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('login')
+ * @see the_author_meta()
+ */
+function the_author_login() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')' );
+	the_author_meta('login');
+}
+
+/**
+ * Retrieve the first name of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('first_name')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's first name.
+ */
+function get_the_author_firstname() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')' );
+	return get_the_author_meta('first_name');
+}
+
+/**
+ * Display the first name of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('first_name')
+ * @see the_author_meta()
+ */
+function the_author_firstname() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'first_name\')' );
+	the_author_meta('first_name');
+}
+
+/**
+ * Retrieve the last name of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('last_name')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's last name.
+ */
+function get_the_author_lastname() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')' );
+	return get_the_author_meta('last_name');
+}
+
+/**
+ * Display the last name of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('last_name')
+ * @see the_author_meta()
+ */
+function the_author_lastname() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'last_name\')' );
+	the_author_meta('last_name');
+}
+
+/**
+ * Retrieve the nickname of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('nickname')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's nickname.
+ */
+function get_the_author_nickname() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')' );
+	return get_the_author_meta('nickname');
+}
+
+/**
+ * Display the nickname of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('nickname')
+ * @see the_author_meta()
+ */
+function the_author_nickname() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' );
+	the_author_meta('nickname');
+}
+
+/**
+ * Retrieve the email of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('email')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's username.
+ */
+function get_the_author_email() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'email\')' );
+	return get_the_author_meta('email');
+}
+
+/**
+ * Display the email of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('email')
+ * @see the_author_meta()
+ */
+function the_author_email() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')' );
+	the_author_meta('email');
+}
+
+/**
+ * Retrieve the ICQ number of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('icq')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's ICQ number.
+ */
+function get_the_author_icq() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')' );
+	return get_the_author_meta('icq');
+}
+
+/**
+ * Display the ICQ number of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('icq')
+ * @see the_author_meta()
+ */
+function the_author_icq() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')' );
+	the_author_meta('icq');
+}
+
+/**
+ * Retrieve the Yahoo! IM name of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('yim')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's Yahoo! IM name.
+ */
+function get_the_author_yim() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')' );
+	return get_the_author_meta('yim');
+}
+
+/**
+ * Display the Yahoo! IM name of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('yim')
+ * @see the_author_meta()
+ */
+function the_author_yim() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')' );
+	the_author_meta('yim');
+}
+
+/**
+ * Retrieve the MSN address of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('msn')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's MSN address.
+ */
+function get_the_author_msn() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')' );
+	return get_the_author_meta('msn');
+}
+
+/**
+ * Display the MSN address of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('msn')
+ * @see the_author_meta()
+ */
+function the_author_msn() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')' );
+	the_author_meta('msn');
+}
+
+/**
+ * Retrieve the AIM address of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('aim')
+ * @see get_the_author_meta()
+ *
+ * @return string The author's AIM address.
+ */
+function get_the_author_aim() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'aim\')' );
+	return get_the_author_meta('aim');
+}
+
+/**
+ * Display the AIM address of the author of the current post.
+ *
+ * @since 0.71
+ * @see the_author_meta()
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('aim')
+ */
+function the_author_aim() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')' );
+	the_author_meta('aim');
+}
+
+/**
+ * Retrieve the specified author's preferred display name.
+ *
+ * @since 1.0.0
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('display_name')
+ * @see get_the_author_meta()
+ *
+ * @param int $auth_id The ID of the author.
+ * @return string The author's display name.
+ */
+function get_author_name( $auth_id = false ) {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')' );
+	return get_the_author_meta('display_name', $auth_id);
+}
+
+/**
+ * Retrieve the URL to the home page of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('url')
+ * @see get_the_author_meta()
+ *
+ * @return string The URL to the author's page.
+ */
+function get_the_author_url() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'url\')' );
+	return get_the_author_meta('url');
+}
+
+/**
+ * Display the URL to the home page of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('url')
+ * @see the_author_meta()
+ */
+function the_author_url() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')' );
+	the_author_meta('url');
+}
+
+/**
+ * Retrieve the ID of the author of the current post.
+ *
+ * @since 1.5
+ * @deprecated 2.8
+ * @deprecated Use get_the_author_meta('ID')
+ * @see get_the_author_meta()
+ *
+ * @return int The author's ID.
+ */
+function get_the_author_ID() {
+	_deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')' );
+	return get_the_author_meta('ID');
+}
+
+/**
+ * Display the ID of the author of the current post.
+ *
+ * @since 0.71
+ * @deprecated 2.8
+ * @deprecated Use the_author_meta('ID')
+ * @see the_author_meta()
+*/
+function the_author_ID() {
+	_deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')' );
+	the_author_meta('ID');
+}
+
+/**
+ * Display the post content for the feed.
+ *
+ * For encoding the html or the $encode_html parameter, there are three possible
+ * values. '0' will make urls footnotes and use make_url_footnote(). '1' will
+ * encode special characters and automatically display all of the content. The
+ * value of '2' will strip all HTML tags from the content.
+ *
+ * Also note that you cannot set the amount of words and not set the html
+ * encoding. If that is the case, then the html encoding will default to 2,
+ * which will strip all HTML tags.
+ *
+ * To restrict the amount of words of the content, you can use the cut
+ * parameter. If the content is less than the amount, then there won't be any
+ * dots added to the end. If there is content left over, then dots will be added
+ * and the rest of the content will be removed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 0.71
+ * @uses apply_filters() Calls 'the_content_rss' on the content before processing.
+ * @see get_the_content() For the $more_link_text, $stripteaser, and $more_file
+ *		parameters.
+ *
+ * @deprecated 2.9.0
+ * @deprecated Use the_content_feed()
+ * @see the_content_feed()
+ *
+ * @param string $more_link_text Optional. Text to display when more content is available but not displayed.
+ * @param int|bool $stripteaser Optional. Default is 0.
+ * @param string $more_file Optional.
+ * @param int $cut Optional. Amount of words to keep for the content.
+ * @param int $encode_html Optional. How to encode the content.
+ */
+function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
+	_deprecated_function( __FUNCTION__, '2.9', 'the_content_feed' );
+	$content = get_the_content($more_link_text, $stripteaser, $more_file);
+	$content = apply_filters('the_content_rss', $content);
+	if ( $cut && !$encode_html )
+		$encode_html = 2;
+	if ( 1== $encode_html ) {
+		$content = esc_html($content);
+		$cut = 0;
+	} elseif ( 0 == $encode_html ) {
+		$content = make_url_footnote($content);
+	} elseif ( 2 == $encode_html ) {
+		$content = strip_tags($content);
+	}
+	if ( $cut ) {
+		$blah = explode(' ', $content);
+		if ( count($blah) > $cut ) {
+			$k = $cut;
+			$use_dotdotdot = 1;
+		} else {
+			$k = count($blah);
+			$use_dotdotdot = 0;
+		}
+
+		/** @todo Check performance, might be faster to use array slice instead. */
+		for ( $i=0; $i<$k; $i++ )
+			$excerpt .= $blah[$i].' ';
+		$excerpt .= ($use_dotdotdot) ? '...' : '';
+		$content = $excerpt;
+	}
+	$content = str_replace(']]>', ']]&gt;', $content);
+	echo $content;
+}
+
+/**
+ * Strip HTML and put links at the bottom of stripped content.
+ *
+ * Searches for all of the links, strips them out of the content, and places
+ * them at the bottom of the content with numbers.
+ *
+ * @since 0.71
+ * @deprecated 2.9.0
+ *
+ * @param string $content Content to get links
+ * @return string HTML stripped out of content with links at the bottom.
+ */
+function make_url_footnote( $content ) {
+	_deprecated_function( __FUNCTION__, '2.9', '' );
+	preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches );
+	$links_summary = "\n";
+	for ( $i=0; $i<count($matches[0]); $i++ ) {
+		$link_match = $matches[0][$i];
+		$link_number = '['.($i+1).']';
+		$link_url = $matches[2][$i];
+		$link_text = $matches[4][$i];
+		$content = str_replace( $link_match, $link_text . ' ' . $link_number, $content );
+		$link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url;
+		$links_summary .= "\n" . $link_number . ' ' . $link_url;
+	}
+	$content  = strip_tags( $content );
+	$content .= $links_summary;
+	return $content;
+}
+
+/**
+ * Retrieve translated string with vertical bar context
+ *
+ * Quite a few times, there will be collisions with similar translatable text
+ * found in more than two places but with different translated context.
+ *
+ * In order to use the separate contexts, the _c() function is used and the
+ * translatable string uses a pipe ('|') which has the context the string is in.
+ *
+ * When the translated string is returned, it is everything before the pipe, not
+ * including the pipe character. If there is no pipe in the translated text then
+ * everything is returned.
+ *
+ * @since 2.2.0
+ * @deprecated 2.9.0
+ * @deprecated Use _x()
+ * @see _x()
+ *
+ * @param string $text Text to translate
+ * @param string $domain Optional. Domain to retrieve the translated text
+ * @return string Translated context string without pipe
+ */
+function _c( $text, $domain = 'default' ) {
+	_deprecated_function( __FUNCTION__, '2.9', '_x()' );
+	return before_last_bar( translate( $text, $domain ) );
+}
+
+/**
+ * Translates $text like translate(), but assumes that the text
+ * contains a context after its last vertical bar.
+ *
+ * @since 2.5
+ * @uses translate()
+ * @deprecated 3.0.0
+ * @deprecated Use _x()
+ * @see _x()
+ *
+ * @param string $text Text to translate
+ * @param string $domain Domain to retrieve the translated text
+ * @return string Translated text
+ */
+function translate_with_context( $text, $domain = 'default' ) {
+	_deprecated_function( __FUNCTION__, '2.9', '_x()' );
+	return before_last_bar( translate( $text, $domain ) );
+}
+
+/**
+ * A version of _n(), which supports contexts.
+ * Strips everything from the translation after the last bar.
+ *
+ * @since 2.7.0
+ * @deprecated 3.0.0
+ * @deprecated Use _nx()
+ * @see _nx()
+ * @see _n() For parameters.
+ * @see _c() For parameters. _c() is deprecated.
+ *
+ */
+function _nc( $single, $plural, $number, $domain = 'default' ) {
+	_deprecated_function( __FUNCTION__, '2.9', '_nx()' );
+	return before_last_bar( _n( $single, $plural, $number, $domain ) );
+}
+
+/**
+ * Retrieve the plural or single form based on the amount.
+ *
+ * @since 1.2.0
+ * @deprecated 2.8.0
+ * @deprecated Use _n()
+ * @see _n()
+ */
+function __ngettext() {
+	_deprecated_function( __FUNCTION__, '2.8', '_n()' );
+	$args = func_get_args();
+	return call_user_func_array('_n', $args);
+}
+
+/**
+ * Register plural strings in POT file, but don't translate them.
+ *
+ * @since 2.5
+ * @deprecated 2.8.0
+ * @deprecated Use _n_noop()
+ * @see _n_noop()
+ */
+function __ngettext_noop() {
+	_deprecated_function( __FUNCTION__, '2.8', '_n_noop()' );
+	$args = func_get_args();
+	return call_user_func_array('_n_noop', $args);
+
+}
+
+/**
+ * Retrieve all autoload options, or all options if no autoloaded ones exist.
+ *
+ * @since 1.0.0
+ * @deprecated 3.0.0
+ * @deprecated Use wp_load_alloptions())
+ * @see wp_load_alloptions()
+ *
+ * @return array List of all options.
+ */
+function get_alloptions() {
+	_deprecated_function( __FUNCTION__, '3.0', 'wp_load_alloptions()' );
+	return wp_load_alloptions();
+}
+
+/**
+ * Retrieve HTML content of attachment image with link.
+ *
+ * @since 2.0.0
+ * @deprecated 2.5.0
+ * @deprecated Use wp_get_attachment_link()
+ * @see wp_get_attachment_link()
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default is false. Whether to use full size image.
+ * @param array $max_dims Optional. Max image dimensions.
+ * @param bool $permalink Optional, default is false. Whether to include permalink to image.
+ * @return string
+ */
+function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
+	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' );
+	$id = (int) $id;
+	$_post = & get_post($id);
+
+	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
+		return __('Missing Attachment');
+
+	if ( $permalink )
+		$url = get_attachment_link($_post->ID);
+
+	$post_title = esc_attr($_post->post_title);
+
+	$innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
+	return "<a href='$url' title='$post_title'>$innerHTML</a>";
+}
+
+/**
+ * Retrieve icon URL and Path.
+ *
+ * @since 2.1.0
+ * @deprecated 2.5.0
+ * @deprecated Use wp_get_attachment_image_src()
+ * @see wp_get_attachment_image_src()
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default to false. Whether to have full image.
+ * @return array Icon URL and full path to file, respectively.
+ */
+function get_attachment_icon_src( $id = 0, $fullsize = false ) {
+	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' );
+	$id = (int) $id;
+	if ( !$post = & get_post($id) )
+		return false;
+
+	$file = get_attached_file( $post->ID );
+
+	if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
+		// We have a thumbnail desired, specified and existing
+
+		$src_file = basename($src);
+		$class = 'attachmentthumb';
+	} elseif ( wp_attachment_is_image( $post->ID ) ) {
+		// We have an image without a thumbnail
+
+		$src = wp_get_attachment_url( $post->ID );
+		$src_file = & $file;
+		$class = 'attachmentimage';
+	} elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
+		// No thumb, no image. We'll look for a mime-related icon instead.
+
+		$icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
+		$src_file = $icon_dir . '/' . basename($src);
+	}
+
+	if ( !isset($src) || !$src )
+		return false;
+
+	return array($src, $src_file);
+}
+
+/**
+ * Retrieve HTML content of icon attachment image element.
+ *
+ * @since 2.0.0
+ * @deprecated 2.5.0
+ * @deprecated Use wp_get_attachment_image()
+ * @see wp_get_attachment_image()
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default to false. Whether to have full size image.
+ * @param array $max_dims Optional. Dimensions of image.
+ * @return string HTML content.
+ */
+function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
+	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
+	$id = (int) $id;
+	if ( !$post = & get_post($id) )
+		return false;
+
+	if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
+		return false;
+
+	list($src, $src_file) = $src;
+
+	// Do we need to constrain the image?
+	if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
+
+		$imagesize = getimagesize($src_file);
+
+		if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
+			$actual_aspect = $imagesize[0] / $imagesize[1];
+			$desired_aspect = $max_dims[0] / $max_dims[1];
+
+			if ( $actual_aspect >= $desired_aspect ) {
+				$height = $actual_aspect * $max_dims[0];
+				$constraint = "width='{$max_dims[0]}' ";
+				$post->iconsize = array($max_dims[0], $height);
+			} else {
+				$width = $max_dims[1] / $actual_aspect;
+				$constraint = "height='{$max_dims[1]}' ";
+				$post->iconsize = array($width, $max_dims[1]);
+			}
+		} else {
+			$post->iconsize = array($imagesize[0], $imagesize[1]);
+			$constraint = '';
+		}
+	} else {
+		$constraint = '';
+	}
+
+	$post_title = esc_attr($post->post_title);
+
+	$icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
+
+	return apply_filters( 'attachment_icon', $icon, $post->ID );
+}
+
+/**
+ * Retrieve HTML content of image element.
+ *
+ * @since 2.0.0
+ * @deprecated 2.5.0
+ * @deprecated Use wp_get_attachment_image()
+ * @see wp_get_attachment_image()
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default to false. Whether to have full size image.
+ * @param array $max_dims Optional. Dimensions of image.
+ * @return string
+ */
+function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
+	_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
+	$id = (int) $id;
+	if ( !$post = & get_post($id) )
+		return false;
+
+	if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
+		return $innerHTML;
+
+
+	$innerHTML = esc_attr($post->post_title);
+
+	return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
+}
+
+/**
+ * Retrieve bookmark data based on ID.
+ *
+ * @since 2.0.0
+ * @deprecated 2.1.0
+ * @deprecated Use get_bookmark()
+ * @see get_bookmark()
+ *
+ * @param int $bookmark_id ID of link
+ * @param string $output OBJECT, ARRAY_N, or ARRAY_A
+ * @return object|array
+ */
+function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {
+	_deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' );
+	return get_bookmark($bookmark_id, $output, $filter);
+}
+
+/**
+ * Performs esc_url() for database or redirect usage.
+ *
+ * @since 2.3.1
+ * @deprecated 2.8.0
+ * @deprecated Use esc_url_raw()
+ * @see esc_url_raw()
+ *
+ * @param string $url The URL to be cleaned.
+ * @param array $protocols An array of acceptable protocols.
+ * @return string The cleaned URL.
+ */
+function sanitize_url( $url, $protocols = null ) {
+	_deprecated_function( __FUNCTION__, '2.8', 'esc_url_raw()' );
+	return esc_url_raw( $url, $protocols );
+}
+
+/**
+ * Checks and cleans a URL.
+ *
+ * A number of characters are removed from the URL. If the URL is for displaying
+ * (the default behaviour) amperstands are also replaced. The 'clean_url' filter
+ * is applied to the returned cleaned URL.
+ *
+ * @since 1.2.0
+ * @deprecated 3.0.0
+ * @deprecated Use esc_url()
+ * @see Alias for esc_url()
+ *
+ * @param string $url The URL to be cleaned.
+ * @param array $protocols Optional. An array of acceptable protocols.
+ * @param string $context Optional. How the URL will be used. Default is 'display'.
+ * @return string The cleaned $url after the 'clean_url' filter is applied.
+ */
+function clean_url( $url, $protocols = null, $context = 'display' ) {
+	if ( $context == 'db' )
+		_deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' );
+	else
+		_deprecated_function( __FUNCTION__, '3.0', 'esc_url()' );
+	return esc_url( $url, $protocols, $context );
+}
+
+/**
+ * Escape single quotes, specialchar double quotes, and fix line endings.
+ *
+ * The filter 'js_escape' is also applied by esc_js()
+ *
+ * @since 2.0.4
+ * @deprecated 2.8.0
+ * @deprecated Use esc_js()
+ * @see esc_js()
+ *
+ * @param string $text The text to be escaped.
+ * @return string Escaped text.
+ */
+function js_escape( $text ) {
+	_deprecated_function( __FUNCTION__, '2.8', 'esc_js()' );
+	return esc_js( $text );
+}
+
+/**
+ * Escaping for HTML blocks.
+ *
+ * @deprecated 2.8.0
+ * @deprecated Use esc_html()
+ * @see esc_html()
+ */
+function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
+	_deprecated_function( __FUNCTION__, '2.8', 'esc_html()' );
+	if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args
+		$args = func_get_args();
+		return call_user_func_array( '_wp_specialchars', $args );
+	} else {
+		return esc_html( $string );
+	}
+}
+
+
+/**
+ * Escaping for HTML attributes.
+ *
+ * @since 2.0.6
+ * @deprecated 2.8.0
+ * @deprecated Use esc_attr()
+ * @see esc_attr()
+ *
+ * @param string $text
+ * @return string
+ */
+function attribute_escape( $text ) {
+	_deprecated_function( __FUNCTION__, '2.8', 'esc_attr()' );
+	return esc_attr( $text );
+}
+
+/**
+ * Register widget for sidebar with backwards compatibility.
+ *
+ * Allows $name to be an array that accepts either three elements to grab the
+ * first element and the third for the name or just uses the first element of
+ * the array for the name.
+ *
+ * Passes to {@link wp_register_sidebar_widget()} after argument list and
+ * backwards compatibility is complete.
+ *
+ * @since 2.2.0
+ * @deprecated 2.8.0
+ * @deprecated Use wp_register_sidebar_widget()
+ * @see wp_register_sidebar_widget()
+ *
+ * @param string|int $name Widget ID.
+ * @param callback $output_callback Run when widget is called.
+ * @param string $classname Classname widget option.
+ * @param mixed $params,... Widget parameters.
+ */
+function register_sidebar_widget($name, $output_callback, $classname = '') {
+	_deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' );
+	// Compat
+	if ( is_array($name) ) {
+		if ( count($name) == 3 )
+			$name = sprintf($name[0], $name[2]);
+		else
+			$name = $name[0];
+	}
+
+	$id = sanitize_title($name);
+	$options = array();
+	if ( !empty($classname) && is_string($classname) )
+		$options['classname'] = $classname;
+	$params = array_slice(func_get_args(), 2);
+	$args = array($id, $name, $output_callback, $options);
+	if ( !empty($params) )
+		$args = array_merge($args, $params);
+
+	call_user_func_array('wp_register_sidebar_widget', $args);
+}
+
+/**
+ * Alias of {@link wp_unregister_sidebar_widget()}.
+ *
+ * @since 2.2.0
+ * @deprecated 2.8.0
+ * @deprecated Use wp_unregister_sidebar_widget()
+ * @see wp_unregister_sidebar_widget()
+ *
+ * @param int|string $id Widget ID.
+ */
+function unregister_sidebar_widget($id) {
+	_deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_sidebar_widget()' );
+	return wp_unregister_sidebar_widget($id);
+}
+
+/**
+ * Registers widget control callback for customizing options.
+ *
+ * Allows $name to be an array that accepts either three elements to grab the
+ * first element and the third for the name or just uses the first element of
+ * the array for the name.
+ *
+ * Passes to {@link wp_register_widget_control()} after the argument list has
+ * been compiled.
+ *
+ * @since 2.2.0
+ * @deprecated 2.8.0
+ * @deprecated Use wp_register_widget_control()
+ * @see wp_register_widget_control()
+ *
+ * @param int|string $name Sidebar ID.
+ * @param callback $control_callback Widget control callback to display and process form.
+ * @param int $width Widget width.
+ * @param int $height Widget height.
+ */
+function register_widget_control($name, $control_callback, $width = '', $height = '') {
+	_deprecated_function( __FUNCTION__, '2.8', 'wp_register_widget_control()' );
+	// Compat
+	if ( is_array($name) ) {
+		if ( count($name) == 3 )
+			$name = sprintf($name[0], $name[2]);
+		else
+			$name = $name[0];
+	}
+
+	$id = sanitize_title($name);
+	$options = array();
+	if ( !empty($width) )
+		$options['width'] = $width;
+	if ( !empty($height) )
+		$options['height'] = $height;
+	$params = array_slice(func_get_args(), 4);
+	$args = array($id, $name, $control_callback, $options);
+	if ( !empty($params) )
+		$args = array_merge($args, $params);
+
+	call_user_func_array('wp_register_widget_control', $args);
+}
+
+/**
+ * Alias of {@link wp_unregister_widget_control()}.
+ *
+ * @since 2.2.0
+ * @deprecated 2.8.0
+ * @deprecated Use wp_unregister_widget_control()
+ * @see wp_unregister_widget_control()
+ *
+ * @param int|string $id Widget ID.
+ */
+function unregister_widget_control($id) {
+	_deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_widget_control()' );
+	return wp_unregister_widget_control($id);
+}
+
+/**
+ * Remove user meta data.
+ *
+ * @since 2.0.0
+ * @deprecated 3.0.0
+ * @deprecated Use delete_user_meta()
+ * @see delete_user_meta()
+ *
+ * @param int $user_id User ID.
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @return bool True deletion completed and false if user_id is not a number.
+ */
+function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'delete_user_meta()' );
+	global $wpdb;
+	if ( !is_numeric( $user_id ) )
+		return false;
+	$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
+
+	if ( is_array($meta_value) || is_object($meta_value) )
+		$meta_value = serialize($meta_value);
+	$meta_value = trim( $meta_value );
+
+	$cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
+
+	if ( $cur && $cur->umeta_id )
+		do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
+
+	if ( ! empty($meta_value) )
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) );
+	else
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
+
+	clean_user_cache( $user_id );
+	wp_cache_delete( $user_id, 'user_meta' );
+
+	if ( $cur && $cur->umeta_id )
+		do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
+
+	return true;
+}
+
+/**
+ * Retrieve user metadata.
+ *
+ * If $user_id is not a number, then the function will fail over with a 'false'
+ * boolean return value. Other returned values depend on whether there is only
+ * one item to be returned, which be that single item type. If there is more
+ * than one metadata value, then it will be list of metadata values.
+ *
+ * @since 2.0.0
+ * @deprecated 3.0.0
+ * @deprecated Use get_user_meta()
+ * @see get_user_meta()
+ *
+ * @param int $user_id User ID
+ * @param string $meta_key Optional. Metadata key.
+ * @return mixed
+ */
+function get_usermeta( $user_id, $meta_key = '' ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'get_user_meta()' );
+	global $wpdb;
+	$user_id = (int) $user_id;
+
+	if ( !$user_id )
+		return false;
+
+	if ( !empty($meta_key) ) {
+		$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
+		$user = wp_cache_get($user_id, 'users');
+		// Check the cached user object
+		if ( false !== $user && isset($user->$meta_key) )
+			$metas = array($user->$meta_key);
+		else
+			$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
+	} else {
+		$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) );
+	}
+
+	if ( empty($metas) ) {
+		if ( empty($meta_key) )
+			return array();
+		else
+			return '';
+	}
+
+	$metas = array_map('maybe_unserialize', $metas);
+
+	if ( count($metas) == 1 )
+		return $metas[0];
+	else
+		return $metas;
+}
+
+/**
+ * Update metadata of user.
+ *
+ * There is no need to serialize values, they will be serialized if it is
+ * needed. The metadata key can only be a string with underscores. All else will
+ * be removed.
+ *
+ * Will remove the metadata, if the meta value is empty.
+ *
+ * @since 2.0.0
+ * @deprecated 3.0.0
+ * @deprecated Use update_user_meta()
+ * @see update_user_meta()
+ *
+ * @param int $user_id User ID
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @return bool True on successful update, false on failure.
+ */
+function update_usermeta( $user_id, $meta_key, $meta_value ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'update_user_meta()' );
+	global $wpdb;
+	if ( !is_numeric( $user_id ) )
+		return false;
+	$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
+
+	/** @todo Might need fix because usermeta data is assumed to be already escaped */
+	if ( is_string($meta_value) )
+		$meta_value = stripslashes($meta_value);
+	$meta_value = maybe_serialize($meta_value);
+
+	if (empty($meta_value)) {
+		return delete_usermeta($user_id, $meta_key);
+	}
+
+	$cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
+
+	if ( $cur )
+		do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
+
+	if ( !$cur )
+		$wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') );
+	else if ( $cur->meta_value != $meta_value )
+		$wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') );
+	else
+		return false;
+
+	clean_user_cache( $user_id );
+	wp_cache_delete( $user_id, 'user_meta' );
+
+	if ( !$cur )
+		do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value );
+	else
+		do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value );
+
+	return true;
+}
+
+/**
+ * Get users for the blog.
+ *
+ * For setups that use the multi-blog feature. Can be used outside of the
+ * multi-blog feature.
+ *
+ * @since 2.2.0
+ * @deprecated 3.1.0
+ * @uses $wpdb WordPress database object for queries
+ * @uses $blog_id The Blog id of the blog for those that use more than one blog
+ *
+ * @param int $id Blog ID.
+ * @return array List of users that are part of that Blog ID
+ */
+function get_users_of_blog( $id = '' ) {
+	_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
+
+	global $wpdb, $blog_id;
+	if ( empty($id) )
+		$id = (int) $blog_id;
+	$blog_prefix = $wpdb->get_blog_prefix($id);
+	$users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" );
+	return $users;
+}
+
+/**
+ * Enable/disable automatic general feed link outputting.
+ *
+ * @since 2.8.0
+ * @deprecated 3.0.0
+ * @deprecated Use add_theme_support( 'automatic-feed-links' )
+ *
+ * @param boolean $add Optional, default is true. Add or remove links. Defaults to true.
+ */
+function automatic_feed_links( $add = true ) {
+	_deprecated_function( __FUNCTION__, '3.0', "add_theme_support( 'automatic-feed-links' )" );
+
+	if ( $add )
+		add_theme_support( 'automatic-feed-links' );
+	else
+		remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+
+}
+
+/**
+ * Retrieve user data based on field.
+ *
+ * @since 1.5.0
+ * @deprecated 3.0.0
+ * @deprecated Use get_the_author_meta()
+ * @see get_the_author_meta()
+ */
+function get_profile( $field, $user = false ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'get_the_author_meta()' );
+	if ( $user ) {
+		$user = get_user_by( 'login', $user );
+		$user = $user->ID;
+	}
+	return get_the_author_meta( $field, $user );
+}
+
+/**
+ * Number of posts user has written.
+ *
+ * @since 0.71
+ * @deprecated 3.0.0
+ * @deprecated Use count_user_posts()
+ * @see count_user_posts()
+ */
+function get_usernumposts( $userid ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'count_user_posts()' );
+	return count_user_posts( $userid );
+}
+
+/**
+ * Callback used to change %uXXXX to &#YYY; syntax
+ *
+ * @since 2.8.0
+ * @access private
+ * @deprecated 3.0.0
+ *
+ * @param array $matches Single Match
+ * @return string An HTML entity
+ */
+function funky_javascript_callback($matches) {
+	return "&#".base_convert($matches[1],16,10).";";
+}
+
+/**
+ * Fixes javascript bugs in browsers.
+ *
+ * Converts unicode characters to HTML numbered entities.
+ *
+ * @since 1.5.0
+ * @uses $is_macIE
+ * @uses $is_winIE
+ * @deprecated 3.0.0
+ *
+ * @param string $text Text to be made safe.
+ * @return string Fixed text.
+ */
+function funky_javascript_fix($text) {
+	_deprecated_function( __FUNCTION__, '3.0' );
+	// Fixes for browsers' javascript bugs
+	global $is_macIE, $is_winIE;
+
+	if ( $is_winIE || $is_macIE )
+		$text =  preg_replace_callback("/\%u([0-9A-F]{4,4})/",
+					"funky_javascript_callback",
+					$text);
+
+	return $text;
+}
+
+/**
+ * Checks that the taxonomy name exists.
+ *
+ * @since 2.3.0
+ * @deprecated 3.0.0
+ * @deprecated Use taxonomy_exists()
+ * @see taxonomy_exists()
+ *
+ * @param string $taxonomy Name of taxonomy object
+ * @return bool Whether the taxonomy exists.
+ */
+function is_taxonomy( $taxonomy ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'taxonomy_exists()' );
+	return taxonomy_exists( $taxonomy );
+}
+
+/**
+ * Check if Term exists.
+ *
+ * @since 2.3.0
+ * @deprecated 3.0.0
+ * @deprecated Use term_exists()
+ * @see term_exists()
+ *
+ * @param int|string $term The term to check
+ * @param string $taxonomy The taxonomy name to use
+ * @param int $parent ID of parent term under which to confine the exists search.
+ * @return mixed Get the term id or Term Object, if exists.
+ */
+function is_term( $term, $taxonomy = '', $parent = 0 ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'term_exists()' );
+	return term_exists( $term, $taxonomy, $parent );
+}
+
+/**
+ * Is the current admin page generated by a plugin?
+ *
+ * @since 1.5.0
+ * @deprecated 3.1
+ * @deprecated Use global $plugin_page and/or get_plugin_page_hookname() hooks.
+ *
+ * @global $plugin_page
+ *
+ * @return bool
+ */
+function is_plugin_page() {
+	_deprecated_function( __FUNCTION__, '3.1'  );
+
+	global $plugin_page;
+
+	if ( isset($plugin_page) )
+		return true;
+
+	return false;
+}
+
+/**
+ * Update the categories cache.
+ *
+ * This function does not appear to be used anymore or does not appear to be
+ * needed. It might be a legacy function left over from when there was a need
+ * for updating the category cache.
+ *
+ * @since 1.5.0
+ * @deprecated 3.1
+ *
+ * @return bool Always return True
+ */
+function update_category_cache() {
+	_deprecated_function( __FUNCTION__, '3.1'  );
+
+	return true;
+}
+
Index: /tags/3.1/wp-includes/feed-atom-comments.php
===================================================================
--- /tags/3.1/wp-includes/feed-atom-comments.php	(revision 17487)
+++ /tags/3.1/wp-includes/feed-atom-comments.php	(revision 17487)
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Atom Feed Template for displaying Atom Comments feed.
+ *
+ * @package WordPress
+ */
+
+header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true);
+echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>';
+?>
+<feed
+	xmlns="http://www.w3.org/2005/Atom"
+	xml:lang="<?php echo get_option('rss_language'); ?>"
+	xmlns:thr="http://purl.org/syndication/thread/1.0"
+	<?php do_action('atom_ns'); do_action('atom_comments_ns'); ?>
+>
+	<title type="text"><?php
+		if ( is_singular() )
+			printf(ent2ncr(__('Comments on %s')), get_the_title_rss());
+		elseif ( is_search() )
+			printf(ent2ncr(__('Comments for %1$s searching on %2$s')), get_bloginfo_rss( 'name' ), get_search_query() );
+		else
+			printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
+	?></title>
+	<subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
+
+	<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
+
+<?php if ( is_singular() ) { ?>
+	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php comments_link_feed(); ?>" />
+	<link rel="self" type="application/atom+xml" href="<?php echo get_post_comments_feed_link('', 'atom'); ?>" />
+	<id><?php echo get_post_comments_feed_link('', 'atom'); ?></id>
+<?php } elseif(is_search()) { ?>
+	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
+	<link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
+	<id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
+<?php } else { ?>
+	<link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url'); ?>" />
+	<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" />
+	<id><?php bloginfo_rss('comments_atom_url'); ?></id>
+<?php } ?>
+<?php do_action('comments_atom_head'); ?>
+<?php
+if ( have_comments() ) : while ( have_comments() ) : the_comment();
+	$comment_post = get_post($comment->comment_post_ID);
+	get_post_custom($comment_post->ID);
+?>
+	<entry>
+		<title><?php
+			if ( !is_singular() ) {
+				$title = get_the_title($comment_post->ID);
+				$title = apply_filters('the_title_rss', $title);
+				printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
+			} else {
+				printf(ent2ncr(__('By: %s')), get_comment_author_rss());
+			}
+		?></title>
+		<link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
+
+		<author>
+			<name><?php comment_author_rss(); ?></name>
+			<?php if (get_comment_author_url()) echo '<uri>' . get_comment_author_url() . '</uri>'; ?>
+
+		</author>
+
+		<id><?php comment_guid(); ?></id>
+		<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></updated>
+		<published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></published>
+<?php if ( post_password_required($comment_post) ) : ?>
+		<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
+<?php else : // post pass ?>
+		<content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
+<?php endif; // post pass
+	// Return comment threading information (http://www.ietf.org/rfc/rfc4685.txt)
+	if ( $comment->comment_parent == 0 ) : // This comment is top level ?>
+		<thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss() ?>" type="<?php bloginfo_rss('html_type'); ?>" />
+<?php else : // This comment is in reply to another comment
+	$parent_comment = get_comment($comment->comment_parent);
+	// The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, its more important that they both use the same system
+?>
+		<thr:in-reply-to ref="<?php comment_guid($parent_comment) ?>" href="<?php echo get_comment_link($parent_comment) ?>" type="<?php bloginfo_rss('html_type'); ?>" />
+<?php endif;
+	do_action('comment_atom_entry', $comment->comment_ID, $comment_post->ID);
+?>
+	</entry>
+<?php endwhile; endif; ?>
+</feed>
Index: /tags/3.1/wp-includes/feed-atom.php
===================================================================
--- /tags/3.1/wp-includes/feed-atom.php	(revision 17487)
+++ /tags/3.1/wp-includes/feed-atom.php	(revision 17487)
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Atom Feed Template for displaying Atom Posts feed.
+ *
+ * @package WordPress
+ */
+
+header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true);
+$more = 1;
+
+echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
+<feed
+  xmlns="http://www.w3.org/2005/Atom"
+  xmlns:thr="http://purl.org/syndication/thread/1.0"
+  xml:lang="<?php echo get_option('rss_language'); ?>"
+  xml:base="<?php bloginfo_rss('url') ?>/wp-atom.php"
+  <?php do_action('atom_ns'); ?>
+ >
+	<title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
+	<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
+
+	<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
+
+	<link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" />
+	<id><?php bloginfo('atom_url'); ?></id>
+	<link rel="self" type="application/atom+xml" href="<?php self_link(); ?>" />
+
+	<?php do_action('atom_head'); ?>
+	<?php while (have_posts()) : the_post(); ?>
+	<entry>
+		<author>
+			<name><?php the_author() ?></name>
+			<?php $author_url = get_the_author_meta('url'); if ( !empty($author_url) ) : ?>
+			<uri><?php the_author_meta('url')?></uri>
+			<?php endif; ?>
+		</author>
+		<title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss() ?>]]></title>
+		<link rel="alternate" type="text/html" href="<?php the_permalink_rss() ?>" />
+		<id><?php the_guid() ; ?></id>
+		<updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated>
+		<published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
+		<?php the_category_rss('atom') ?>
+		<summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
+<?php if ( !get_option('rss_use_excerpt') ) : ?>
+		<content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content_feed('atom') ?>]]></content>
+<?php endif; ?>
+<?php atom_enclosure(); ?>
+<?php do_action('atom_entry'); ?>
+		<link rel="replies" type="text/html" href="<?php the_permalink_rss() ?>#comments" thr:count="<?php echo get_comments_number()?>"/>
+		<link rel="replies" type="application/atom+xml" href="<?php echo get_post_comments_feed_link(0,'atom') ?>" thr:count="<?php echo get_comments_number()?>"/>
+		<thr:total><?php echo get_comments_number()?></thr:total>
+	</entry>
+	<?php endwhile ; ?>
+</feed>
Index: /tags/3.1/wp-includes/feed-rdf.php
===================================================================
--- /tags/3.1/wp-includes/feed-rdf.php	(revision 17487)
+++ /tags/3.1/wp-includes/feed-rdf.php	(revision 17487)
@@ -0,0 +1,54 @@
+<?php
+/**
+ * RSS 1 RDF Feed Template for displaying RSS 1 Posts feed.
+ *
+ * @package WordPress
+ */
+
+header('Content-Type: ' . feed_content_type('rdf') . '; charset=' . get_option('blog_charset'), true);
+$more = 1;
+
+echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
+<rdf:RDF
+	xmlns="http://purl.org/rss/1.0/"
+	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+	xmlns:dc="http://purl.org/dc/elements/1.1/"
+	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
+	xmlns:admin="http://webns.net/mvcb/"
+	xmlns:content="http://purl.org/rss/1.0/modules/content/"
+	<?php do_action('rdf_ns'); ?>
+>
+<channel rdf:about="<?php bloginfo_rss("url") ?>">
+	<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
+	<link><?php bloginfo_rss('url') ?></link>
+	<description><?php bloginfo_rss('description') ?></description>
+	<dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>
+	<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
+	<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
+	<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
+	<?php do_action('rdf_header'); ?>
+	<items>
+		<rdf:Seq>
+		<?php while (have_posts()): the_post(); ?>
+			<rdf:li rdf:resource="<?php the_permalink_rss() ?>"/>
+		<?php endwhile; ?>
+		</rdf:Seq>
+	</items>
+</channel>
+<?php rewind_posts(); while (have_posts()): the_post(); ?>
+<item rdf:about="<?php the_permalink_rss() ?>">
+	<title><?php the_title_rss() ?></title>
+	<link><?php the_permalink_rss() ?></link>
+	 <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt, false); ?></dc:date>
+	<dc:creator><?php the_author() ?></dc:creator>
+	<?php the_category_rss('rdf') ?>
+<?php if (get_option('rss_use_excerpt')) : ?>
+	<description><?php the_excerpt_rss() ?></description>
+<?php else : ?>
+	<description><?php the_excerpt_rss() ?></description>
+	<content:encoded><![CDATA[<?php the_content_feed('rdf') ?>]]></content:encoded>
+<?php endif; ?>
+	<?php do_action('rdf_item'); ?>
+</item>
+<?php endwhile;  ?>
+</rdf:RDF>
Index: /tags/3.1/wp-includes/feed-rss.php
===================================================================
--- /tags/3.1/wp-includes/feed-rss.php	(revision 17487)
+++ /tags/3.1/wp-includes/feed-rss.php	(revision 17487)
@@ -0,0 +1,31 @@
+<?php
+/**
+ * RSS 0.92 Feed Template for displaying RSS 0.92 Posts feed.
+ *
+ * @package WordPress
+ */
+
+header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
+$more = 1;
+
+echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
+<rss version="0.92">
+<channel>
+	<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
+	<link><?php bloginfo_rss('url') ?></link>
+	<description><?php bloginfo_rss('description') ?></description>
+	<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
+	<docs>http://backend.userland.com/rss092</docs>
+	<language><?php echo get_option('rss_language'); ?></language>
+	<?php do_action('rss_head'); ?>
+
+<?php while (have_posts()) : the_post(); ?>
+	<item>
+		<title><?php the_title_rss() ?></title>
+		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
+		<link><?php the_permalink_rss() ?></link>
+		<?php do_action('rss_item'); ?>
+	</item>
+<?php endwhile; ?>
+</channel>
+</rss>
Index: /tags/3.1/wp-includes/feed-rss2-comments.php
===================================================================
--- /tags/3.1/wp-includes/feed-rss2-comments.php	(revision 17487)
+++ /tags/3.1/wp-includes/feed-rss2-comments.php	(revision 17487)
@@ -0,0 +1,66 @@
+<?php
+/**
+ * RSS2 Feed Template for displaying RSS2 Comments feed.
+ *
+ * @package WordPress
+ */
+
+header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
+
+echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
+?>
+<rss version="2.0"
+	xmlns:content="http://purl.org/rss/1.0/modules/content/"
+	xmlns:dc="http://purl.org/dc/elements/1.1/"
+	xmlns:atom="http://www.w3.org/2005/Atom"
+	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
+	<?php do_action('rss2_ns'); do_action('rss2_comments_ns'); ?>
+	>
+<channel>
+	<title><?php
+		if ( is_singular() )
+			printf(ent2ncr(__('Comments on: %s')), get_the_title_rss());
+		elseif ( is_search() )
+			printf(ent2ncr(__('Comments for %s searching on %s')), get_bloginfo_rss( 'name' ), esc_attr($wp_query->query_vars['s']));
+		else
+			printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
+	?></title>
+	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
+	<link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
+	<description><?php bloginfo_rss("description") ?></description>
+	<lastBuildDate><?php echo mysql2date('r', get_lastcommentmodified('GMT')); ?></lastBuildDate>
+	<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
+	<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
+	<?php do_action('commentsrss2_head'); ?>
+<?php
+if ( have_comments() ) : while ( have_comments() ) : the_comment();
+	$comment_post = get_post($comment->comment_post_ID);
+	get_post_custom($comment_post->ID);
+?>
+	<item>
+		<title><?php
+			if ( !is_singular() ) {
+				$title = get_the_title($comment_post->ID);
+				$title = apply_filters('the_title_rss', $title);
+				printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
+			} else {
+				printf(ent2ncr(__('By: %s')), get_comment_author_rss());
+			}
+		?></title>
+		<link><?php comment_link() ?></link>
+		<dc:creator><?php echo get_comment_author_rss() ?></dc:creator>
+		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true, false), false); ?></pubDate>
+		<guid isPermaLink="false"><?php comment_guid() ?></guid>
+<?php if ( post_password_required($comment_post) ) : ?>
+		<description><?php echo ent2ncr(__('Protected Comments: Please enter your password to view comments.')); ?></description>
+		<content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
+<?php else : // post pass ?>
+		<description><?php comment_text_rss() ?></description>
+		<content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
+<?php endif; // post pass
+	do_action('commentrss2_item', $comment->comment_ID, $comment_post->ID);
+?>
+	</item>
+<?php endwhile; endif; ?>
+</channel>
+</rss>
Index: /tags/3.1/wp-includes/feed-rss2.php
===================================================================
--- /tags/3.1/wp-includes/feed-rss2.php	(revision 17487)
+++ /tags/3.1/wp-includes/feed-rss2.php	(revision 17487)
@@ -0,0 +1,60 @@
+<?php
+/**
+ * RSS2 Feed Template for displaying RSS2 Posts feed.
+ *
+ * @package WordPress
+ */
+
+header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
+$more = 1;
+
+echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
+
+<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:atom="http://www.w3.org/2005/Atom"
+	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
+	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+	<?php do_action('rss2_ns'); ?>
+>
+
+<channel>
+	<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
+	<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
+	<link><?php bloginfo_rss('url') ?></link>
+	<description><?php bloginfo_rss("description") ?></description>
+	<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
+	<language><?php echo get_option('rss_language'); ?></language>
+	<sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod>
+	<sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency>
+	<?php do_action('rss2_head'); ?>
+	<?php while( have_posts()) : the_post(); ?>
+	<item>
+		<title><?php the_title_rss() ?></title>
+		<link><?php the_permalink_rss() ?></link>
+		<comments><?php comments_link_feed(); ?></comments>
+		<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 the_category_rss('rss2') ?>
+
+		<guid isPermaLink="false"><?php the_guid(); ?></guid>
+<?php if (get_option('rss_use_excerpt')) : ?>
+		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
+<?php else : ?>
+		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
+	<?php if ( strlen( $post->post_content ) > 0 ) : ?>
+		<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
+	<?php else : ?>
+		<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
+	<?php endif; ?>
+<?php endif; ?>
+		<wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
+		<slash:comments><?php echo get_comments_number(); ?></slash:comments>
+<?php rss_enclosure(); ?>
+	<?php do_action('rss2_item'); ?>
+	</item>
+	<?php endwhile; ?>
+</channel>
+</rss>
Index: /tags/3.1/wp-includes/feed.php
===================================================================
--- /tags/3.1/wp-includes/feed.php	(revision 17487)
+++ /tags/3.1/wp-includes/feed.php	(revision 17487)
@@ -0,0 +1,546 @@
+<?php
+/**
+ * WordPress Feed API
+ *
+ * Many of the functions used in here belong in The Loop, or The Loop for the
+ * Feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ */
+
+/**
+ * RSS container for the bloginfo function.
+ *
+ * You can retrieve anything that you can using the get_bloginfo() function.
+ * Everything will be stripped of tags and characters converted, when the values
+ * are retrieved for use in the feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 1.5.1
+ * @uses apply_filters() Calls 'get_bloginfo_rss' hook with two parameters.
+ * @see get_bloginfo() For the list of possible values to display.
+ *
+ * @param string $show See get_bloginfo() for possible values.
+ * @return string
+ */
+function get_bloginfo_rss($show = '') {
+	$info = strip_tags(get_bloginfo($show));
+	return apply_filters('get_bloginfo_rss', convert_chars($info), $show);
+}
+
+/**
+ * Display RSS container for the bloginfo function.
+ *
+ * You can retrieve anything that you can using the get_bloginfo() function.
+ * Everything will be stripped of tags and characters converted, when the values
+ * are retrieved for use in the feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 0.71
+ * @uses apply_filters() Calls 'bloginfo_rss' hook with two parameters.
+ * @see get_bloginfo() For the list of possible values to display.
+ *
+ * @param string $show See get_bloginfo() for possible values.
+ */
+function bloginfo_rss($show = '') {
+	echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show);
+}
+
+/**
+ * Retrieve the default feed.
+ *
+ * The default feed is 'rss2', unless a plugin changes it through the
+ * 'default_feed' filter.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5
+ * @uses apply_filters() Calls 'default_feed' hook on the default feed string.
+ *
+ * @return string Default feed, or for example 'rss2', 'atom', etc.
+ */
+function get_default_feed() {
+	return apply_filters('default_feed', 'rss2');
+}
+
+/**
+ * Retrieve the blog title for the feed title.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.2.0
+ * @uses apply_filters() Calls 'get_wp_title_rss' hook on title.
+ * @uses wp_title() See function for $sep parameter usage.
+ *
+ * @param string $sep Optional.How to separate the title. See wp_title() for more info.
+ * @return string Error message on failure or blog title on success.
+ */
+function get_wp_title_rss($sep = '&#187;') {
+	$title = wp_title($sep, false);
+	if ( is_wp_error( $title ) )
+		return $title->get_error_message();
+	$title = apply_filters('get_wp_title_rss', $title);
+	return $title;
+}
+
+/**
+ * Display the blog title for display of the feed title.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.2.0
+ * @uses apply_filters() Calls 'wp_title_rss' on the blog title.
+ * @see wp_title() $sep parameter usage.
+ *
+ * @param string $sep Optional.
+ */
+function wp_title_rss($sep = '&#187;') {
+	echo apply_filters('wp_title_rss', get_wp_title_rss($sep));
+}
+
+/**
+ * Retrieve the current post title for the feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'the_title_rss' on the post title.
+ *
+ * @return string Current post title.
+ */
+function get_the_title_rss() {
+	$title = get_the_title();
+	$title = apply_filters('the_title_rss', $title);
+	return $title;
+}
+
+/**
+ * Display the post title in the feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 0.71
+ * @uses get_the_title_rss() Used to retrieve current post title.
+ */
+function the_title_rss() {
+	echo get_the_title_rss();
+}
+
+/**
+ * Retrieve the post content for feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.9.0
+ * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
+ * @see get_the_content()
+ *
+ * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
+ */
+function get_the_content_feed($feed_type = null) {
+	if ( !$feed_type )
+		$feed_type = get_default_feed();
+
+	$content = apply_filters('the_content', get_the_content());
+	$content = str_replace(']]>', ']]&gt;', $content);
+	return apply_filters('the_content_feed', $content, $feed_type);
+}
+
+/**
+ * Display the post content for feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.9.0
+ * @uses apply_filters() Calls 'the_content_feed' on the content before processing.
+ * @see get_the_content()
+ *
+ * @param string $feed_type The type of feed. rss2 | atom | rss | rdf
+ */
+function the_content_feed($feed_type = null) {
+	echo get_the_content_feed($feed_type);
+}
+
+/**
+ * Display the post excerpt for the feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 0.71
+ * @uses apply_filters() Calls 'the_excerpt_rss' hook on the excerpt.
+ */
+function the_excerpt_rss() {
+	$output = get_the_excerpt();
+	echo apply_filters('the_excerpt_rss', $output);
+}
+
+/**
+ * Display the permalink to the post for use in feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.3.0
+ * @uses apply_filters() Call 'the_permalink_rss' on the post permalink
+ */
+function the_permalink_rss() {
+	echo esc_url( apply_filters('the_permalink_rss', get_permalink() ));
+}
+
+/**
+ * Outputs the link to the comments for the current post in an xml safe way
+ *
+ * @since 3.0.0
+ * @return none
+ */
+function comments_link_feed() {
+	echo esc_url( get_comments_link() );
+}
+
+/**
+ * Display the feed GUID for the current comment.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5.0
+ *
+ * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
+ */
+function comment_guid($comment_id = null) {
+	echo esc_url( get_comment_guid($comment_id) );
+}
+
+/**
+ * Retrieve the feed GUID for the current comment.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5.0
+ *
+ * @param int|object $comment_id Optional comment object or id. Defaults to global comment object.
+ * @return bool|string false on failure or guid for comment on success.
+ */
+function get_comment_guid($comment_id = null) {
+	$comment = get_comment($comment_id);
+
+	if ( !is_object($comment) )
+		return false;
+
+	return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
+}
+
+/**
+ * Display the link to the comments.
+ *
+ * @since 1.5.0
+ */
+function comment_link() {
+	echo esc_url( get_comment_link() );
+}
+
+/**
+ * Retrieve the current comment author for use in the feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'comment_author_rss' hook on comment author.
+ * @uses get_comment_author()
+ *
+ * @return string Comment Author
+ */
+function get_comment_author_rss() {
+	return apply_filters('comment_author_rss', get_comment_author() );
+}
+
+/**
+ * Display the current comment author in the feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 1.0.0
+ */
+function comment_author_rss() {
+	echo get_comment_author_rss();
+}
+
+/**
+ * Display the current comment content for use in the feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 1.0.0
+ * @uses apply_filters() Calls 'comment_text_rss' filter on comment content.
+ * @uses get_comment_text()
+ */
+function comment_text_rss() {
+	$comment_text = get_comment_text();
+	$comment_text = apply_filters('comment_text_rss', $comment_text);
+	echo $comment_text;
+}
+
+/**
+ * Retrieve all of the post categories, formatted for use in feeds.
+ *
+ * All of the categories for the current post in the feed loop, will be
+ * retrieved and have feed markup added, so that they can easily be added to the
+ * RSS2, Atom, or RSS1 and RSS0.91 RDF feeds.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.1.0
+ * @uses apply_filters()
+ *
+ * @param string $type Optional, default is the type returned by get_default_feed().
+ * @return string All of the post categories for displaying in the feed.
+ */
+function get_the_category_rss($type = null) {
+	if ( empty($type) )
+		$type = get_default_feed();
+	$categories = get_the_category();
+	$tags = get_the_tags();
+	$the_list = '';
+	$cat_names = array();
+
+	$filter = 'rss';
+	if ( 'atom' == $type )
+		$filter = 'raw';
+
+	if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
+		$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
+	}
+
+	if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
+		$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
+	}
+
+	$cat_names = array_unique($cat_names);
+
+	foreach ( $cat_names as $cat_name ) {
+		if ( 'rdf' == $type )
+			$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
+		elseif ( 'atom' == $type )
+			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), esc_attr( $cat_name ) );
+		else
+			$the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n";
+	}
+
+	return apply_filters('the_category_rss', $the_list, $type);
+}
+
+/**
+ * Display the post categories in the feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 0.71
+ * @see get_the_category_rss() For better explanation.
+ *
+ * @param string $type Optional, default is the type returned by get_default_feed().
+ */
+function the_category_rss($type = null) {
+	echo get_the_category_rss($type);
+}
+
+/**
+ * Display the HTML type based on the blog setting.
+ *
+ * The two possible values are either 'xhtml' or 'html'.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.2.0
+ */
+function html_type_rss() {
+	$type = get_bloginfo('html_type');
+	if (strpos($type, 'xhtml') !== false)
+		$type = 'xhtml';
+	else
+		$type = 'html';
+	echo $type;
+}
+
+/**
+ * Display the rss enclosure for the current post.
+ *
+ * Uses the global $post to check whether the post requires a password and if
+ * the user has the password for the post. If not then it will return before
+ * displaying.
+ *
+ * Also uses the function get_post_custom() to get the post's 'enclosure'
+ * metadata field and parses the value to display the enclosure(s). The
+ * enclosure(s) consist of enclosure HTML tag(s) with a URI and other
+ * attributes.
+ *
+ * @package WordPress
+ * @subpackage Template
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'rss_enclosure' hook on rss enclosure.
+ * @uses get_post_custom() To get the current post enclosure metadata.
+ */
+function rss_enclosure() {
+	if ( post_password_required() )
+		return;
+
+	foreach ( (array) get_post_custom() as $key => $val) {
+		if ($key == 'enclosure') {
+			foreach ( (array) $val as $enc ) {
+				$enclosure = explode("\n", $enc);
+
+				//only get the the first element eg, audio/mpeg from 'audio/mpeg mpga mp2 mp3'
+				$t = preg_split('/[ \t]/', trim($enclosure[2]) );
+				$type = $t[0];
+
+				echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . $type . '" />' . "\n");
+			}
+		}
+	}
+}
+
+/**
+ * Display the atom enclosure for the current post.
+ *
+ * Uses the global $post to check whether the post requires a password and if
+ * the user has the password for the post. If not then it will return before
+ * displaying.
+ *
+ * Also uses the function get_post_custom() to get the post's 'enclosure'
+ * metadata field and parses the value to display the enclosure(s). The
+ * enclosure(s) consist of link HTML tag(s) with a URI and other attributes.
+ *
+ * @package WordPress
+ * @subpackage Template
+ * @since 2.2.0
+ * @uses apply_filters() Calls 'atom_enclosure' hook on atom enclosure.
+ * @uses get_post_custom() To get the current post enclosure metadata.
+ */
+function atom_enclosure() {
+	if ( post_password_required() )
+		return;
+
+	foreach ( (array) get_post_custom() as $key => $val ) {
+		if ($key == 'enclosure') {
+			foreach ( (array) $val as $enc ) {
+				$enclosure = split("\n", $enc);
+				echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
+			}
+		}
+	}
+}
+
+/**
+ * Determine the type of a string of data with the data formatted.
+ *
+ * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1.
+ *
+ * In the case of WordPress, text is defined as containing no markup,
+ * xhtml is defined as "well formed", and html as tag soup (i.e., the rest).
+ *
+ * Container div tags are added to xhtml values, per section 3.1.1.3.
+ *
+ * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5
+ *
+ * @param string $data Input string
+ * @return array array(type, value)
+ */
+function prep_atom_text_construct($data) {
+	if (strpos($data, '<') === false && strpos($data, '&') === false) {
+		return array('text', $data);
+	}
+
+	$parser = xml_parser_create();
+	xml_parse($parser, '<div>' . $data . '</div>', true);
+	$code = xml_get_error_code($parser);
+	xml_parser_free($parser);
+
+	if (!$code) {
+		if (strpos($data, '<') === false) {
+			return array('text', $data);
+		} else {
+			$data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
+			return array('xhtml', $data);
+		}
+	}
+
+	if (strpos($data, ']]>') == false) {
+		return array('html', "<![CDATA[$data]]>");
+	} else {
+		return array('html', htmlspecialchars($data));
+	}
+}
+
+/**
+ * Display the link for the currently displayed feed in a XSS safe way.
+ *
+ * Generate a correct link for the atom:self element.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5
+ */
+function self_link() {
+	$host = @parse_url(home_url());
+	$host = $host['host'];
+	echo esc_url(
+		'http'
+		. ( (isset($_SERVER['https']) && $_SERVER['https'] == 'on') ? 's' : '' ) . '://'
+		. $host
+		. stripslashes($_SERVER['REQUEST_URI'])
+		);
+}
+
+/**
+ * Return the content type for specified feed type.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.8.0
+ */
+function feed_content_type( $type = '' ) {
+	if ( empty($type) )
+		$type = get_default_feed();
+
+	$types = array(
+		'rss'  => 'application/rss+xml',
+		'rss2' => 'application/rss+xml',
+		'rss-http'  => 'text/xml',
+		'atom' => 'application/atom+xml',
+		'rdf'  => 'application/rdf+xml'
+	);
+
+	$content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream';
+
+	return apply_filters( 'feed_content_type', $content_type, $type );
+}
+
+/**
+ * Build SimplePie object based on RSS or Atom feed from URL.
+ *
+ * @since 2.8
+ *
+ * @param string $url URL to retrieve feed
+ * @return WP_Error|SimplePie WP_Error object on failure or SimplePie object on success
+ */
+function fetch_feed($url) {
+	require_once (ABSPATH . WPINC . '/class-feed.php');
+
+	$feed = new SimplePie();
+	$feed->set_feed_url($url);
+	$feed->set_cache_class('WP_Feed_Cache');
+	$feed->set_file_class('WP_SimplePie_File');
+	$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
+	do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
+	$feed->init();
+	$feed->handle_content_type();
+
+	if ( $feed->error() )
+		return new WP_Error('simplepie-error', $feed->error());
+
+	return $feed;
+}
Index: /tags/3.1/wp-includes/formatting.php
===================================================================
--- /tags/3.1/wp-includes/formatting.php	(revision 17487)
+++ /tags/3.1/wp-includes/formatting.php	(revision 17487)
@@ -0,0 +1,2902 @@
+<?php
+/**
+ * Main WordPress Formatting API.
+ *
+ * Handles many functions for formatting output.
+ *
+ * @package WordPress
+ **/
+
+/**
+ * Replaces common plain text characters into formatted entities
+ *
+ * As an example,
+ * <code>
+ * 'cause today's effort makes it worth tomorrow's "holiday"...
+ * </code>
+ * Becomes:
+ * <code>
+ * &#8217;cause today&#8217;s effort makes it worth tomorrow&#8217;s &#8220;holiday&#8221;&#8230;
+ * </code>
+ * Code within certain html blocks are skipped.
+ *
+ * @since 0.71
+ * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases
+ *
+ * @param string $text The text to be formatted
+ * @return string The string replaced with html entities
+ */
+function wptexturize($text) {
+	global $wp_cockneyreplace;
+	static $static_setup = false, $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements;
+	$output = '';
+	$curl = '';
+	$textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+	$stop = count($textarr);
+
+	// No need to set up these variables more than once
+	if (!$static_setup) {
+		/* translators: opening curly quote */
+		$opening_quote = _x('&#8220;', 'opening curly quote');
+		/* translators: closing curly quote */
+		$closing_quote = _x('&#8221;', 'closing curly quote');
+
+		$default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt');
+		$default_no_texturize_shortcodes = array('code');
+
+		// if a plugin has provided an autocorrect array, use it
+		if ( isset($wp_cockneyreplace) ) {
+			$cockney = array_keys($wp_cockneyreplace);
+			$cockneyreplace = array_values($wp_cockneyreplace);
+		} else {
+			$cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
+			$cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
+		}
+
+		$static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn&#8211;', '...', '``', '\'\'', ' (tm)'), $cockney);
+		$static_replacements = array_merge(array('&#8212;', ' &#8212; ', '&#8211;', ' &#8211; ', 'xn--', '&#8230;', $opening_quote, $closing_quote, ' &#8482;'), $cockneyreplace);
+
+		$dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/');
+		$dynamic_replacements = array('&#8217;$1','&#8217;$1', '$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '&#8217;$1', '$1&#215;$2');
+
+		$static_setup = true;
+	}
+
+	// Transform into regexp sub-expression used in _wptexturize_pushpop_element
+	// Must do this everytime in case plugins use these filters in a context sensitive manner
+	$no_texturize_tags = '(' . implode('|', apply_filters('no_texturize_tags', $default_no_texturize_tags) ) . ')';
+	$no_texturize_shortcodes = '(' . implode('|', apply_filters('no_texturize_shortcodes', $default_no_texturize_shortcodes) ) . ')';
+
+	$no_texturize_tags_stack = array();
+	$no_texturize_shortcodes_stack = array();
+
+	for ( $i = 0; $i < $stop; $i++ ) {
+		$curl = $textarr[$i];
+
+		if ( !empty($curl) && '<' != $curl[0] && '[' != $curl[0]
+				&& empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) {
+			// This is not a tag, nor is the texturization disabled
+			// static strings
+			$curl = str_replace($static_characters, $static_replacements, $curl);
+			// regular expressions
+			$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
+		} elseif (!empty($curl)) {
+			/*
+			 * Only call _wptexturize_pushpop_element if first char is correct
+			 * tag opening
+			 */
+			if ('<' == $curl[0])
+				_wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>');
+			elseif ('[' == $curl[0])
+				_wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']');
+		}
+
+		$curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$1', $curl);
+		$output .= $curl;
+	}
+
+	return $output;
+}
+
+/**
+ * Search for disabled element tags. Push element to stack on tag open and pop
+ * on tag close. Assumes first character of $text is tag opening.
+ *
+ * @access private
+ * @since 2.9.0
+ *
+ * @param string $text Text to check. First character is assumed to be $opening
+ * @param array $stack Array used as stack of opened tag elements
+ * @param string $disabled_elements Tags to match against formatted as regexp sub-expression
+ * @param string $opening Tag opening character, assumed to be 1 character long
+ * @param string $opening Tag closing  character
+ * @return object
+ */
+function _wptexturize_pushpop_element($text, &$stack, $disabled_elements, $opening = '<', $closing = '>') {
+	// Check if it is a closing tag -- otherwise assume opening tag
+	if (strncmp($opening . '/', $text, 2)) {
+		// Opening? Check $text+1 against disabled elements
+		if (preg_match('/^' . $disabled_elements . '\b/', substr($text, 1), $matches)) {
+			/*
+			 * This disables texturize until we find a closing tag of our type
+			 * (e.g. <pre>) even if there was invalid nesting before that
+			 *
+			 * Example: in the case <pre>sadsadasd</code>"baba"</pre>
+			 *          "baba" won't be texturize
+			 */
+
+			array_push($stack, $matches[1]);
+		}
+	} else {
+		// Closing? Check $text+2 against disabled elements
+		$c = preg_quote($closing, '/');
+		if (preg_match('/^' . $disabled_elements . $c . '/', substr($text, 2), $matches)) {
+			$last = array_pop($stack);
+
+			// Make sure it matches the opening tag
+			if ($last != $matches[1])
+				array_push($stack, $last);
+		}
+	}
+}
+
+/**
+ * Accepts matches array from preg_replace_callback in wpautop() or a string.
+ *
+ * Ensures that the contents of a <<pre>>...<</pre>> HTML block are not
+ * converted into paragraphs or line-breaks.
+ *
+ * @since 1.2.0
+ *
+ * @param array|string $matches The array or string
+ * @return string The pre block without paragraph/line-break conversion.
+ */
+function clean_pre($matches) {
+	if ( is_array($matches) )
+		$text = $matches[1] . $matches[2] . "</pre>";
+	else
+		$text = $matches;
+
+	$text = str_replace('<br />', '', $text);
+	$text = str_replace('<p>', "\n", $text);
+	$text = str_replace('</p>', '', $text);
+
+	return $text;
+}
+
+/**
+ * Replaces double line-breaks with paragraph elements.
+ *
+ * A group of regex replaces used to identify text formatted with newlines and
+ * replace double line-breaks with HTML paragraph tags. The remaining
+ * line-breaks after conversion become <<br />> tags, unless $br is set to '0'
+ * or 'false'.
+ *
+ * @since 0.71
+ *
+ * @param string $pee The text which has to be formatted.
+ * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true.
+ * @return string Text which has been converted into correct paragraph tags.
+ */
+function wpautop($pee, $br = 1) {
+
+	if ( trim($pee) === '' )
+		return '';
+	$pee = $pee . "\n"; // just to make things a little easier, pad the end
+	$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
+	// Space things out a little
+	$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
+	$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
+	$pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
+	$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
+	if ( strpos($pee, '<object') !== false ) {
+		$pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed
+		$pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);
+	}
+	$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
+	// make paragraphs, including one at the end
+	$pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
+	$pee = '';
+	foreach ( $pees as $tinkle )
+		$pee .= '<p>' . trim($tinkle, "\n") . "</p>\n";
+	$pee = preg_replace('|<p>\s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
+	$pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee);
+	$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
+	$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
+	$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
+	$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
+	$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
+	$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
+	if ($br) {
+		$pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
+		$pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
+		$pee = str_replace('<WPPreserveNewline />', "\n", $pee);
+	}
+	$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
+	$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
+	if (strpos($pee, '<pre') !== false)
+		$pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee );
+	$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
+
+	return $pee;
+}
+
+/**
+ * Newline preservation help function for wpautop
+ *
+ * @since 3.1.0
+ * @access private
+ * @param array $matches preg_replace_callback matches array
+ * @returns string
+ */
+function _autop_newline_preservation_helper( $matches ) {
+	return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
+}
+
+/**
+ * Don't auto-p wrap shortcodes that stand alone
+ *
+ * Ensures that shortcodes are not wrapped in <<p>>...<</p>>.
+ *
+ * @since 2.9.0
+ *
+ * @param string $pee The content.
+ * @return string The filtered content.
+ */
+function shortcode_unautop($pee) {
+	global $shortcode_tags;
+
+	if ( !empty($shortcode_tags) && is_array($shortcode_tags) ) {
+		$tagnames = array_keys($shortcode_tags);
+		$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
+		$pee = preg_replace('/<p>\\s*?(\\[(' . $tagregexp . ')\\b.*?\\/?\\](?:.+?\\[\\/\\2\\])?)\\s*<\\/p>/s', '$1', $pee);
+	}
+
+	return $pee;
+}
+
+/**
+ * Checks to see if a string is utf8 encoded.
+ *
+ * NOTE: This function checks for 5-Byte sequences, UTF8
+ *       has Bytes Sequences with a maximum length of 4.
+ *
+ * @author bmorel at ssi dot fr (modified)
+ * @since 1.2.1
+ *
+ * @param string $str The string to be checked
+ * @return bool True if $str fits a UTF-8 model, false otherwise.
+ */
+function seems_utf8($str) {
+	$length = strlen($str);
+	for ($i=0; $i < $length; $i++) {
+		$c = ord($str[$i]);
+		if ($c < 0x80) $n = 0; # 0bbbbbbb
+		elseif (($c & 0xE0) == 0xC0) $n=1; # 110bbbbb
+		elseif (($c & 0xF0) == 0xE0) $n=2; # 1110bbbb
+		elseif (($c & 0xF8) == 0xF0) $n=3; # 11110bbb
+		elseif (($c & 0xFC) == 0xF8) $n=4; # 111110bb
+		elseif (($c & 0xFE) == 0xFC) $n=5; # 1111110b
+		else return false; # Does not match any model
+		for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
+			if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))
+				return false;
+		}
+	}
+	return true;
+}
+
+/**
+ * Converts a number of special characters into their HTML entities.
+ *
+ * Specifically deals with: &, <, >, ", and '.
+ *
+ * $quote_style can be set to ENT_COMPAT to encode " to
+ * &quot;, or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded.
+ *
+ * @since 1.2.2
+ *
+ * @param string $string The text which is to be encoded.
+ * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
+ * @param string $charset Optional. The character encoding of the string. Default is false.
+ * @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false.
+ * @return string The encoded text with HTML entities.
+ */
+function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
+	$string = (string) $string;
+
+	if ( 0 === strlen( $string ) ) {
+		return '';
+	}
+
+	// Don't bother if there are no specialchars - saves some processing
+	if ( !preg_match( '/[&<>"\']/', $string ) ) {
+		return $string;
+	}
+
+	// Account for the previous behaviour of the function when the $quote_style is not an accepted value
+	if ( empty( $quote_style ) ) {
+		$quote_style = ENT_NOQUOTES;
+	} elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
+		$quote_style = ENT_QUOTES;
+	}
+
+	// Store the site charset as a static to avoid multiple calls to wp_load_alloptions()
+	if ( !$charset ) {
+		static $_charset;
+		if ( !isset( $_charset ) ) {
+			$alloptions = wp_load_alloptions();
+			$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';
+		}
+		$charset = $_charset;
+	}
+	if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) {
+		$charset = 'UTF-8';
+	}
+
+	$_quote_style = $quote_style;
+
+	if ( $quote_style === 'double' ) {
+		$quote_style = ENT_COMPAT;
+		$_quote_style = ENT_COMPAT;
+	} elseif ( $quote_style === 'single' ) {
+		$quote_style = ENT_NOQUOTES;
+	}
+
+	// Handle double encoding ourselves
+	if ( !$double_encode ) {
+		$string = wp_specialchars_decode( $string, $_quote_style );
+
+		/* Critical */
+		// The previous line decodes &amp;phrase; into &phrase;  We must guarantee that &phrase; is valid before proceeding.
+		$string = wp_kses_normalize_entities($string);
+
+		// Now proceed with custom double-encoding silliness
+		$string = preg_replace( '/&(#?x?[0-9a-z]+);/i', '|wp_entity|$1|/wp_entity|', $string );
+	}
+
+	$string = @htmlspecialchars( $string, $quote_style, $charset );
+
+	// Handle double encoding ourselves
+	if ( !$double_encode ) {
+		$string = str_replace( array( '|wp_entity|', '|/wp_entity|' ), array( '&', ';' ), $string );
+	}
+
+	// Backwards compatibility
+	if ( 'single' === $_quote_style ) {
+		$string = str_replace( "'", '&#039;', $string );
+	}
+
+	return $string;
+}
+
+/**
+ * Converts a number of HTML entities into their special characters.
+ *
+ * Specifically deals with: &, <, >, ", and '.
+ *
+ * $quote_style can be set to ENT_COMPAT to decode " entities,
+ * or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded.
+ *
+ * @since 2.8
+ *
+ * @param string $string The text which is to be decoded.
+ * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
+ * @return string The decoded text without HTML entities.
+ */
+function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
+	$string = (string) $string;
+
+	if ( 0 === strlen( $string ) ) {
+		return '';
+	}
+
+	// Don't bother if there are no entities - saves a lot of processing
+	if ( strpos( $string, '&' ) === false ) {
+		return $string;
+	}
+
+	// Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value
+	if ( empty( $quote_style ) ) {
+		$quote_style = ENT_NOQUOTES;
+	} elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {
+		$quote_style = ENT_QUOTES;
+	}
+
+	// More complete than get_html_translation_table( HTML_SPECIALCHARS )
+	$single = array( '&#039;'  => '\'', '&#x27;' => '\'' );
+	$single_preg = array( '/&#0*39;/'  => '&#039;', '/&#x0*27;/i' => '&#x27;' );
+	$double = array( '&quot;' => '"', '&#034;'  => '"', '&#x22;' => '"' );
+	$double_preg = array( '/&#0*34;/'  => '&#034;', '/&#x0*22;/i' => '&#x22;' );
+	$others = array( '&lt;'   => '<', '&#060;'  => '<', '&gt;'   => '>', '&#062;'  => '>', '&amp;'  => '&', '&#038;'  => '&', '&#x26;' => '&' );
+	$others_preg = array( '/&#0*60;/'  => '&#060;', '/&#0*62;/'  => '&#062;', '/&#0*38;/'  => '&#038;', '/&#x0*26;/i' => '&#x26;' );
+
+	if ( $quote_style === ENT_QUOTES ) {
+		$translation = array_merge( $single, $double, $others );
+		$translation_preg = array_merge( $single_preg, $double_preg, $others_preg );
+	} elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {
+		$translation = array_merge( $double, $others );
+		$translation_preg = array_merge( $double_preg, $others_preg );
+	} elseif ( $quote_style === 'single' ) {
+		$translation = array_merge( $single, $others );
+		$translation_preg = array_merge( $single_preg, $others_preg );
+	} elseif ( $quote_style === ENT_NOQUOTES ) {
+		$translation = $others;
+		$translation_preg = $others_preg;
+	}
+
+	// Remove zero padding on numeric entities
+	$string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string );
+
+	// Replace characters according to translation table
+	return strtr( $string, $translation );
+}
+
+/**
+ * Checks for invalid UTF8 in a string.
+ *
+ * @since 2.8
+ *
+ * @param string $string The text which is to be checked.
+ * @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
+ * @return string The checked text.
+ */
+function wp_check_invalid_utf8( $string, $strip = false ) {
+	$string = (string) $string;
+
+	if ( 0 === strlen( $string ) ) {
+		return '';
+	}
+
+	// Store the site charset as a static to avoid multiple calls to get_option()
+	static $is_utf8;
+	if ( !isset( $is_utf8 ) ) {
+		$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
+	}
+	if ( !$is_utf8 ) {
+		return $string;
+	}
+
+	// Check for support for utf8 in the installed PCRE library once and store the result in a static
+	static $utf8_pcre;
+	if ( !isset( $utf8_pcre ) ) {
+		$utf8_pcre = @preg_match( '/^./u', 'a' );
+	}
+	// We can't demand utf8 in the PCRE installation, so just return the string in those cases
+	if ( !$utf8_pcre ) {
+		return $string;
+	}
+
+	// preg_match fails when it encounters invalid UTF8 in $string
+	if ( 1 === @preg_match( '/^./us', $string ) ) {
+		return $string;
+	}
+
+	// Attempt to strip the bad chars if requested (not recommended)
+	if ( $strip && function_exists( 'iconv' ) ) {
+		return iconv( 'utf-8', 'utf-8', $string );
+	}
+
+	return '';
+}
+
+/**
+ * Encode the Unicode values to be used in the URI.
+ *
+ * @since 1.5.0
+ *
+ * @param string $utf8_string
+ * @param int $length Max length of the string
+ * @return string String with Unicode encoded for URI.
+ */
+function utf8_uri_encode( $utf8_string, $length = 0 ) {
+	$unicode = '';
+	$values = array();
+	$num_octets = 1;
+	$unicode_length = 0;
+
+	$string_length = strlen( $utf8_string );
+	for ($i = 0; $i < $string_length; $i++ ) {
+
+		$value = ord( $utf8_string[ $i ] );
+
+		if ( $value < 128 ) {
+			if ( $length && ( $unicode_length >= $length ) )
+				break;
+			$unicode .= chr($value);
+			$unicode_length++;
+		} else {
+			if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
+
+			$values[] = $value;
+
+			if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )
+				break;
+			if ( count( $values ) == $num_octets ) {
+				if ($num_octets == 3) {
+					$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
+					$unicode_length += 9;
+				} else {
+					$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
+					$unicode_length += 6;
+				}
+
+				$values = array();
+				$num_octets = 1;
+			}
+		}
+	}
+
+	return $unicode;
+}
+
+/**
+ * Converts all accent characters to ASCII characters.
+ *
+ * If there are no accent characters, then the string given is just returned.
+ *
+ * @since 1.2.1
+ *
+ * @param string $string Text that might have accent characters
+ * @return string Filtered string with replaced "nice" characters.
+ */
+function remove_accents($string) {
+	if ( !preg_match('/[\x80-\xff]/', $string) )
+		return $string;
+
+	if (seems_utf8($string)) {
+		$chars = array(
+		// Decompositions for Latin-1 Supplement
+		chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
+		chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
+		chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
+		chr(195).chr(134) => 'AE',chr(195).chr(135) => 'C',
+		chr(195).chr(136) => 'E', chr(195).chr(137) => 'E',
+		chr(195).chr(138) => 'E', chr(195).chr(139) => 'E',
+		chr(195).chr(140) => 'I', chr(195).chr(141) => 'I',
+		chr(195).chr(142) => 'I', chr(195).chr(143) => 'I',
+		chr(195).chr(144) => 'D', chr(195).chr(145) => 'N',
+		chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
+		chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
+		chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
+		chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
+		chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
+		chr(195).chr(158) => 'TH',chr(195).chr(159) => 's',
+		chr(195).chr(160) => 'a', chr(195).chr(161) => 'a',
+		chr(195).chr(162) => 'a', chr(195).chr(163) => 'a',
+		chr(195).chr(164) => 'a', chr(195).chr(165) => 'a',
+		chr(195).chr(166) => 'ae',chr(195).chr(167) => 'c',
+		chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
+		chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
+		chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
+		chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
+		chr(195).chr(176) => 'd', chr(195).chr(177) => 'n',
+		chr(195).chr(178) => 'o', chr(195).chr(179) => 'o',
+		chr(195).chr(180) => 'o', chr(195).chr(181) => 'o',
+		chr(195).chr(182) => 'o', chr(195).chr(182) => 'o',
+		chr(195).chr(185) => 'u', chr(195).chr(186) => 'u',
+		chr(195).chr(187) => 'u', chr(195).chr(188) => 'u',
+		chr(195).chr(189) => 'y', chr(195).chr(190) => 'th',
+		chr(195).chr(191) => 'y',
+		// Decompositions for Latin Extended-A
+		chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
+		chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
+		chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
+		chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
+		chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
+		chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
+		chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
+		chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
+		chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
+		chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
+		chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
+		chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
+		chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
+		chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
+		chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
+		chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
+		chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
+		chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
+		chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
+		chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
+		chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
+		chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
+		chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
+		chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
+		chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
+		chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
+		chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
+		chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
+		chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
+		chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
+		chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
+		chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
+		chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
+		chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
+		chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
+		chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
+		chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
+		chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
+		chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
+		chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
+		chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
+		chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
+		chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
+		chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
+		chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
+		chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
+		chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
+		chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
+		chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
+		chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
+		chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
+		chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
+		chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
+		chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
+		chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
+		chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
+		chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
+		chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
+		chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
+		chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
+		chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
+		chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
+		chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
+		chr(197).chr(190) => 'z', chr(197).chr(191) => 's',
+		// Decompositions for Latin Extended-B
+		chr(200).chr(152) => 'S', chr(200).chr(153) => 's',
+		chr(200).chr(154) => 'T', chr(200).chr(155) => 't',
+		// Euro Sign
+		chr(226).chr(130).chr(172) => 'E',
+		// GBP (Pound) Sign
+		chr(194).chr(163) => '');
+
+		$string = strtr($string, $chars);
+	} else {
+		// Assume ISO-8859-1 if not UTF-8
+		$chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
+			.chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
+			.chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)
+			.chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)
+			.chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)
+			.chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)
+			.chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)
+			.chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)
+			.chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)
+			.chr(252).chr(253).chr(255);
+
+		$chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
+
+		$string = strtr($string, $chars['in'], $chars['out']);
+		$double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));
+		$double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
+		$string = str_replace($double_chars['in'], $double_chars['out'], $string);
+	}
+
+	return $string;
+}
+
+/**
+ * Sanitizes a filename replacing whitespace with dashes
+ *
+ * Removes special characters that are illegal in filenames on certain
+ * operating systems and special characters requiring special escaping
+ * to manipulate at the command line. Replaces spaces and consecutive
+ * dashes with a single dash. Trim period, dash and underscore from beginning
+ * and end of filename.
+ *
+ * @since 2.1.0
+ *
+ * @param string $filename The filename to be sanitized
+ * @return string The sanitized filename
+ */
+function sanitize_file_name( $filename ) {
+	$filename_raw = $filename;
+	$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
+	$special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
+	$filename = str_replace($special_chars, '', $filename);
+	$filename = preg_replace('/[\s-]+/', '-', $filename);
+	$filename = trim($filename, '.-_');
+
+	// Split the filename into a base and extension[s]
+	$parts = explode('.', $filename);
+
+	// Return if only one extension
+	if ( count($parts) <= 2 )
+		return apply_filters('sanitize_file_name', $filename, $filename_raw);
+
+	// Process multiple extensions
+	$filename = array_shift($parts);
+	$extension = array_pop($parts);
+	$mimes = get_allowed_mime_types();
+
+	// Loop over any intermediate extensions.  Munge them with a trailing underscore if they are a 2 - 5 character
+	// long alpha string not in the extension whitelist.
+	foreach ( (array) $parts as $part) {
+		$filename .= '.' . $part;
+
+		if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) {
+			$allowed = false;
+			foreach ( $mimes as $ext_preg => $mime_match ) {
+				$ext_preg = '!(^' . $ext_preg . ')$!i';
+				if ( preg_match( $ext_preg, $part ) ) {
+					$allowed = true;
+					break;
+				}
+			}
+			if ( !$allowed )
+				$filename .= '_';
+		}
+	}
+	$filename .= '.' . $extension;
+
+	return apply_filters('sanitize_file_name', $filename, $filename_raw);
+}
+
+/**
+ * Sanitize username stripping out unsafe characters.
+ *
+ * Removes tags, octets, entities, and if strict is enabled, will only keep
+ * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
+ * raw username (the username in the parameter), and the value of $strict as
+ * parameters for the 'sanitize_user' filter.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'sanitize_user' hook on username, raw username,
+ *		and $strict parameter.
+ *
+ * @param string $username The username to be sanitized.
+ * @param bool $strict If set limits $username to specific characters. Default false.
+ * @return string The sanitized username, after passing through filters.
+ */
+function sanitize_user( $username, $strict = false ) {
+	$raw_username = $username;
+	$username = wp_strip_all_tags( $username );
+	$username = remove_accents( $username );
+	// Kill octets
+	$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
+	$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
+
+	// If strict, reduce to ASCII for max portability.
+	if ( $strict )
+		$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
+
+	$username = trim( $username );
+	// Consolidate contiguous whitespace
+	$username = preg_replace( '|\s+|', ' ', $username );
+
+	return apply_filters( 'sanitize_user', $username, $raw_username, $strict );
+}
+
+/**
+ * Sanitize a string key.
+ *
+ * Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.
+ *
+ * @since 3.0.0
+ *
+ * @param string $key String key
+ * @return string Sanitized key
+ */
+function sanitize_key( $key ) {
+	$raw_key = $key;
+	$key = strtolower( $key );
+	$key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
+	return apply_filters( 'sanitize_key', $key, $raw_key );
+}
+
+/**
+ * Sanitizes title or use fallback title.
+ *
+ * Specifically, HTML and PHP tags are stripped. Further actions can be added
+ * via the plugin API. If $title is empty and $fallback_title is set, the latter
+ * will be used.
+ *
+ * @since 1.0.0
+ *
+ * @param string $title The string to be sanitized.
+ * @param string $fallback_title Optional. A title to use if $title is empty.
+ * @param string $context Optional. The operation for which the string is sanitized
+ * @return string The sanitized string.
+ */
+function sanitize_title($title, $fallback_title = '', $context = 'save') {
+	$raw_title = $title;
+
+	if ( 'save' == $context )
+		$title = remove_accents($title);
+
+	$title = apply_filters('sanitize_title', $title, $raw_title, $context);
+
+	if ( '' === $title || false === $title )
+		$title = $fallback_title;
+
+	return $title;
+}
+
+function sanitize_title_for_query($title) {
+	return sanitize_title($title, '', 'query');
+}
+
+/**
+ * Sanitizes title, replacing whitespace with dashes.
+ *
+ * Limits the output to alphanumeric characters, underscore (_) and dash (-).
+ * Whitespace becomes a dash.
+ *
+ * @since 1.2.0
+ *
+ * @param string $title The title to be sanitized.
+ * @return string The sanitized title.
+ */
+function sanitize_title_with_dashes($title) {
+	$title = strip_tags($title);
+	// Preserve escaped octets.
+	$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
+	// Remove percent signs that are not part of an octet.
+	$title = str_replace('%', '', $title);
+	// Restore octets.
+	$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
+
+	if (seems_utf8($title)) {
+		if (function_exists('mb_strtolower')) {
+			$title = mb_strtolower($title, 'UTF-8');
+		}
+		$title = utf8_uri_encode($title, 200);
+	}
+
+	$title = strtolower($title);
+	$title = preg_replace('/&.+?;/', '', $title); // kill entities
+	$title = str_replace('.', '-', $title);
+	$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
+	$title = preg_replace('/\s+/', '-', $title);
+	$title = preg_replace('|-+|', '-', $title);
+	$title = trim($title, '-');
+
+	return $title;
+}
+
+/**
+ * Ensures a string is a valid SQL order by clause.
+ *
+ * Accepts one or more columns, with or without ASC/DESC, and also accepts
+ * RAND().
+ *
+ * @since 2.5.1
+ *
+ * @param string $orderby Order by string to be checked.
+ * @return string|false Returns the order by clause if it is a match, false otherwise.
+ */
+function sanitize_sql_orderby( $orderby ){
+	preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches);
+	if ( !$obmatches )
+		return false;
+	return $orderby;
+}
+
+/**
+ * Santizes a html classname to ensure it only contains valid characters
+ *
+ * Strips the string down to A-Z,a-z,0-9,'-' if this results in an empty
+ * string then it will return the alternative value supplied.
+ *
+ * @todo Expand to support the full range of CDATA that a class attribute can contain.
+ *
+ * @since 2.8.0
+ *
+ * @param string $class The classname to be sanitized
+ * @param string $fallback Optional. The value to return if the sanitization end's up as an empty string.
+ * 	Defaults to an empty string.
+ * @return string The sanitized value
+ */
+function sanitize_html_class( $class, $fallback = '' ) {
+	//Strip out any % encoded octets
+	$sanitized = preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $class);
+
+	//Limit to A-Z,a-z,0-9,'-'
+	$sanitized = preg_replace('/[^A-Za-z0-9-]/', '', $sanitized);
+
+	if ( '' == $sanitized )
+		$sanitized = $fallback;
+
+	return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
+}
+
+/**
+ * Converts a number of characters from a string.
+ *
+ * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are
+ * converted into correct XHTML and Unicode characters are converted to the
+ * valid range.
+ *
+ * @since 0.71
+ *
+ * @param string $content String of characters to be converted.
+ * @param string $deprecated Not used.
+ * @return string Converted string.
+ */
+function convert_chars($content, $deprecated = '') {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '0.71' );
+
+	// Translation of invalid Unicode references range to valid range
+	$wp_htmltranswinuni = array(
+	'&#128;' => '&#8364;', // the Euro sign
+	'&#129;' => '',
+	'&#130;' => '&#8218;', // these are Windows CP1252 specific characters
+	'&#131;' => '&#402;',  // they would look weird on non-Windows browsers
+	'&#132;' => '&#8222;',
+	'&#133;' => '&#8230;',
+	'&#134;' => '&#8224;',
+	'&#135;' => '&#8225;',
+	'&#136;' => '&#710;',
+	'&#137;' => '&#8240;',
+	'&#138;' => '&#352;',
+	'&#139;' => '&#8249;',
+	'&#140;' => '&#338;',
+	'&#141;' => '',
+	'&#142;' => '&#382;',
+	'&#143;' => '',
+	'&#144;' => '',
+	'&#145;' => '&#8216;',
+	'&#146;' => '&#8217;',
+	'&#147;' => '&#8220;',
+	'&#148;' => '&#8221;',
+	'&#149;' => '&#8226;',
+	'&#150;' => '&#8211;',
+	'&#151;' => '&#8212;',
+	'&#152;' => '&#732;',
+	'&#153;' => '&#8482;',
+	'&#154;' => '&#353;',
+	'&#155;' => '&#8250;',
+	'&#156;' => '&#339;',
+	'&#157;' => '',
+	'&#158;' => '',
+	'&#159;' => '&#376;'
+	);
+
+	// Remove metadata tags
+	$content = preg_replace('/<title>(.+?)<\/title>/','',$content);
+	$content = preg_replace('/<category>(.+?)<\/category>/','',$content);
+
+	// Converts lone & characters into &#38; (a.k.a. &amp;)
+	$content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content);
+
+	// Fix Word pasting
+	$content = strtr($content, $wp_htmltranswinuni);
+
+	// Just a little XHTML help
+	$content = str_replace('<br>', '<br />', $content);
+	$content = str_replace('<hr>', '<hr />', $content);
+
+	return $content;
+}
+
+/**
+ * Will only balance the tags if forced to and the option is set to balance tags.
+ *
+ * The option 'use_balanceTags' is used for whether the tags will be balanced.
+ * Both the $force parameter and 'use_balanceTags' option will have to be true
+ * before the tags will be balanced.
+ *
+ * @since 0.71
+ *
+ * @param string $text Text to be balanced
+ * @param bool $force Forces balancing, ignoring the value of the option. Default false.
+ * @return string Balanced text
+ */
+function balanceTags( $text, $force = false ) {
+	if ( !$force && get_option('use_balanceTags') == 0 )
+		return $text;
+	return force_balance_tags( $text );
+}
+
+/**
+ * Balances tags of string using a modified stack.
+ *
+ * @since 2.0.4
+ *
+ * @author Leonard Lin <leonard@acm.org>
+ * @license GPL
+ * @copyright November 4, 2001
+ * @version 1.1
+ * @todo Make better - change loop condition to $text in 1.2
+ * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
+ *		1.1  Fixed handling of append/stack pop order of end text
+ *			 Added Cleaning Hooks
+ *		1.0  First Version
+ *
+ * @param string $text Text to be balanced.
+ * @return string Balanced text.
+ */
+function force_balance_tags( $text ) {
+	$tagstack = array();
+	$stacksize = 0;
+	$tagqueue = '';
+	$newtext = '';
+	$single_tags = array('br', 'hr', 'img', 'input'); // Known single-entity/self-closing tags
+	$nestable_tags = array('blockquote', 'div', 'span'); // Tags that can be immediately nested within themselves
+
+	// WP bug fix for comments - in case you REALLY meant to type '< !--'
+	$text = str_replace('< !--', '<    !--', $text);
+	// WP bug fix for LOVE <3 (and other situations with '<' before a number)
+	$text = preg_replace('#<([0-9]{1})#', '&lt;$1', $text);
+
+	while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) {
+		$newtext .= $tagqueue;
+
+		$i = strpos($text, $regex[0]);
+		$l = strlen($regex[0]);
+
+		// clear the shifter
+		$tagqueue = '';
+		// Pop or Push
+		if ( isset($regex[1][0]) && '/' == $regex[1][0] ) { // End Tag
+			$tag = strtolower(substr($regex[1],1));
+			// if too many closing tags
+			if( $stacksize <= 0 ) {
+				$tag = '';
+				// or close to be safe $tag = '/' . $tag;
+			}
+			// if stacktop value = tag close value then pop
+			else if ( $tagstack[$stacksize - 1] == $tag ) { // found closing tag
+				$tag = '</' . $tag . '>'; // Close Tag
+				// Pop
+				array_pop( $tagstack );
+				$stacksize--;
+			} else { // closing tag not at top, search for it
+				for ( $j = $stacksize-1; $j >= 0; $j-- ) {
+					if ( $tagstack[$j] == $tag ) {
+					// add tag to tagqueue
+						for ( $k = $stacksize-1; $k >= $j; $k--) {
+							$tagqueue .= '</' . array_pop( $tagstack ) . '>';
+							$stacksize--;
+						}
+						break;
+					}
+				}
+				$tag = '';
+			}
+		} else { // Begin Tag
+			$tag = strtolower($regex[1]);
+
+			// Tag Cleaning
+
+			// If self-closing or '', don't do anything.
+			if ( substr($regex[2],-1) == '/' || $tag == '' ) {
+				// do nothing
+			}
+			// ElseIf it's a known single-entity tag but it doesn't close itself, do so
+			elseif ( in_array($tag, $single_tags) ) {
+				$regex[2] .= '/';
+			} else {	// Push the tag onto the stack
+				// If the top of the stack is the same as the tag we want to push, close previous tag
+				if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) {
+					$tagqueue = '</' . array_pop ($tagstack) . '>';
+					$stacksize--;
+				}
+				$stacksize = array_push ($tagstack, $tag);
+			}
+
+			// Attributes
+			$attributes = $regex[2];
+			if( !empty($attributes) )
+				$attributes = ' '.$attributes;
+
+			$tag = '<' . $tag . $attributes . '>';
+			//If already queuing a close tag, then put this tag on, too
+			if ( !empty($tagqueue) ) {
+				$tagqueue .= $tag;
+				$tag = '';
+			}
+		}
+		$newtext .= substr($text, 0, $i) . $tag;
+		$text = substr($text, $i + $l);
+	}
+
+	// Clear Tag Queue
+	$newtext .= $tagqueue;
+
+	// Add Remaining text
+	$newtext .= $text;
+
+	// Empty Stack
+	while( $x = array_pop($tagstack) )
+		$newtext .= '</' . $x . '>'; // Add remaining tags to close
+
+	// WP fix for the bug with HTML comments
+	$newtext = str_replace("< !--","<!--",$newtext);
+	$newtext = str_replace("<    !--","< !--",$newtext);
+
+	return $newtext;
+}
+
+/**
+ * Acts on text which is about to be edited.
+ *
+ * Unless $richedit is set, it is simply a holder for the 'format_to_edit'
+ * filter. If $richedit is set true htmlspecialchars(), through esc_textarea(),
+ * will be run on the content, converting special characters to HTML entities.
+ *
+ * @since 0.71
+ *
+ * @param string $content The text about to be edited.
+ * @param bool $richedit Whether the $content should pass through htmlspecialchars(). Default false.
+ * @return string The text after the filter (and possibly htmlspecialchars()) has been run.
+ */
+function format_to_edit( $content, $richedit = false ) {
+	$content = apply_filters( 'format_to_edit', $content );
+	if ( ! $richedit )
+		$content = esc_textarea( $content );
+	return $content;
+}
+
+/**
+ * Holder for the 'format_to_post' filter.
+ *
+ * @since 0.71
+ *
+ * @param string $content The text to pass through the filter.
+ * @return string Text returned from the 'format_to_post' filter.
+ */
+function format_to_post($content) {
+	$content = apply_filters('format_to_post', $content);
+	return $content;
+}
+
+/**
+ * Add leading zeros when necessary.
+ *
+ * If you set the threshold to '4' and the number is '10', then you will get
+ * back '0010'. If you set the number to '4' and the number is '5000', then you
+ * will get back '5000'.
+ *
+ * Uses sprintf to append the amount of zeros based on the $threshold parameter
+ * and the size of the number. If the number is large enough, then no zeros will
+ * be appended.
+ *
+ * @since 0.71
+ *
+ * @param mixed $number Number to append zeros to if not greater than threshold.
+ * @param int $threshold Digit places number needs to be to not have zeros added.
+ * @return string Adds leading zeros to number if needed.
+ */
+function zeroise($number, $threshold) {
+	return sprintf('%0'.$threshold.'s', $number);
+}
+
+/**
+ * Adds backslashes before letters and before a number at the start of a string.
+ *
+ * @since 0.71
+ *
+ * @param string $string Value to which backslashes will be added.
+ * @return string String with backslashes inserted.
+ */
+function backslashit($string) {
+	$string = preg_replace('/^([0-9])/', '\\\\\\\\\1', $string);
+	$string = preg_replace('/([a-z])/i', '\\\\\1', $string);
+	return $string;
+}
+
+/**
+ * Appends a trailing slash.
+ *
+ * Will remove trailing slash if it exists already before adding a trailing
+ * slash. This prevents double slashing a string or path.
+ *
+ * The primary use of this is for paths and thus should be used for paths. It is
+ * not restricted to paths and offers no specific path support.
+ *
+ * @since 1.2.0
+ * @uses untrailingslashit() Unslashes string if it was slashed already.
+ *
+ * @param string $string What to add the trailing slash to.
+ * @return string String with trailing slash added.
+ */
+function trailingslashit($string) {
+	return untrailingslashit($string) . '/';
+}
+
+/**
+ * Removes trailing slash if it exists.
+ *
+ * The primary use of this is for paths and thus should be used for paths. It is
+ * not restricted to paths and offers no specific path support.
+ *
+ * @since 2.2.0
+ *
+ * @param string $string What to remove the trailing slash from.
+ * @return string String without the trailing slash.
+ */
+function untrailingslashit($string) {
+	return rtrim($string, '/');
+}
+
+/**
+ * Adds slashes to escape strings.
+ *
+ * Slashes will first be removed if magic_quotes_gpc is set, see {@link
+ * http://www.php.net/magic_quotes} for more details.
+ *
+ * @since 0.71
+ *
+ * @param string $gpc The string returned from HTTP request data.
+ * @return string Returns a string escaped with slashes.
+ */
+function addslashes_gpc($gpc) {
+	if ( get_magic_quotes_gpc() )
+		$gpc = stripslashes($gpc);
+
+	return esc_sql($gpc);
+}
+
+/**
+ * Navigates through an array and removes slashes from the values.
+ *
+ * If an array is passed, the array_map() function causes a callback to pass the
+ * value back to the function. The slashes from this value will removed.
+ *
+ * @since 2.0.0
+ *
+ * @param array|string $value The array or string to be striped.
+ * @return array|string Stripped array (or string in the callback).
+ */
+function stripslashes_deep($value) {
+	if ( is_array($value) ) {
+		$value = array_map('stripslashes_deep', $value);
+	} elseif ( is_object($value) ) {
+		$vars = get_object_vars( $value );
+		foreach ($vars as $key=>$data) {
+			$value->{$key} = stripslashes_deep( $data );
+		}
+	} else {
+		$value = stripslashes($value);
+	}
+
+	return $value;
+}
+
+/**
+ * Navigates through an array and encodes the values to be used in a URL.
+ *
+ * Uses a callback to pass the value of the array back to the function as a
+ * string.
+ *
+ * @since 2.2.0
+ *
+ * @param array|string $value The array or string to be encoded.
+ * @return array|string $value The encoded array (or string from the callback).
+ */
+function urlencode_deep($value) {
+	$value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);
+	return $value;
+}
+
+/**
+ * Converts email addresses characters to HTML entities to block spam bots.
+ *
+ * @since 0.71
+ *
+ * @param string $emailaddy Email address.
+ * @param int $mailto Optional. Range from 0 to 1. Used for encoding.
+ * @return string Converted email address.
+ */
+function antispambot($emailaddy, $mailto=0) {
+	$emailNOSPAMaddy = '';
+	srand ((float) microtime() * 1000000);
+	for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
+		$j = floor(rand(0, 1+$mailto));
+		if ($j==0) {
+			$emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
+		} elseif ($j==1) {
+			$emailNOSPAMaddy .= substr($emailaddy,$i,1);
+		} elseif ($j==2) {
+			$emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
+		}
+	}
+	$emailNOSPAMaddy = str_replace('@','&#64;',$emailNOSPAMaddy);
+	return $emailNOSPAMaddy;
+}
+
+/**
+ * Callback to convert URI match to HTML A element.
+ *
+ * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
+ * make_clickable()}.
+ *
+ * @since 2.3.2
+ * @access private
+ *
+ * @param array $matches Single Regex Match.
+ * @return string HTML A element with URI address.
+ */
+function _make_url_clickable_cb($matches) {
+	$url = $matches[2];
+	$suffix = '';
+
+	/** Include parentheses in the URL only if paired **/
+	while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
+		$suffix = strrchr( $url, ')' ) . $suffix;
+		$url = substr( $url, 0, strrpos( $url, ')' ) );
+	}
+
+	$url = esc_url($url);
+	if ( empty($url) )
+		return $matches[0];
+
+	return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;
+}
+
+/**
+ * Callback to convert URL match to HTML A element.
+ *
+ * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
+ * make_clickable()}.
+ *
+ * @since 2.3.2
+ * @access private
+ *
+ * @param array $matches Single Regex Match.
+ * @return string HTML A element with URL address.
+ */
+function _make_web_ftp_clickable_cb($matches) {
+	$ret = '';
+	$dest = $matches[2];
+	$dest = 'http://' . $dest;
+	$dest = esc_url($dest);
+	if ( empty($dest) )
+		return $matches[0];
+
+	// removed trailing [.,;:)] from URL
+	if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
+		$ret = substr($dest, -1);
+		$dest = substr($dest, 0, strlen($dest)-1);
+	}
+	return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
+}
+
+/**
+ * Callback to convert email address match to HTML A element.
+ *
+ * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link
+ * make_clickable()}.
+ *
+ * @since 2.3.2
+ * @access private
+ *
+ * @param array $matches Single Regex Match.
+ * @return string HTML A element with email address.
+ */
+function _make_email_clickable_cb($matches) {
+	$email = $matches[2] . '@' . $matches[3];
+	return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
+}
+
+/**
+ * Convert plaintext URI to HTML links.
+ *
+ * Converts URI, www and ftp, and email addresses. Finishes by fixing links
+ * within links.
+ *
+ * @since 0.71
+ *
+ * @param string $ret Content to convert URIs.
+ * @return string Content with converted URIs.
+ */
+function make_clickable($ret) {
+	$ret = ' ' . $ret;
+	// in testing, using arrays here was found to be faster
+	$ret = preg_replace_callback('#(?<!=[\'"])(?<=[*\')+.,;:!&$\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#%~/?@\[\]-]|[\'*(+.,;:!=&$](?![\b\)]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
+	$ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
+	$ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
+	// this one is not in an array because we need it to run last, for cleanup of accidental links within links
+	$ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
+	$ret = trim($ret);
+	return $ret;
+}
+
+/**
+ * Adds rel nofollow string to all HTML A elements in content.
+ *
+ * @since 1.5.0
+ *
+ * @param string $text Content that may contain HTML A elements.
+ * @return string Converted content.
+ */
+function wp_rel_nofollow( $text ) {
+	// This is a pre save filter, so text is already escaped.
+	$text = stripslashes($text);
+	$text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);
+	$text = esc_sql($text);
+	return $text;
+}
+
+/**
+ * Callback to used to add rel=nofollow string to HTML A element.
+ *
+ * Will remove already existing rel="nofollow" and rel='nofollow' from the
+ * string to prevent from invalidating (X)HTML.
+ *
+ * @since 2.3.0
+ *
+ * @param array $matches Single Match
+ * @return string HTML A Element with rel nofollow.
+ */
+function wp_rel_nofollow_callback( $matches ) {
+	$text = $matches[1];
+	$text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text);
+	return "<a $text rel=\"nofollow\">";
+}
+
+/**
+ * Convert one smiley code to the icon graphic file equivalent.
+ *
+ * Looks up one smiley code in the $wpsmiliestrans global array and returns an
+ * <img> string for that smiley.
+ *
+ * @global array $wpsmiliestrans
+ * @since 2.8.0
+ *
+ * @param string $smiley Smiley code to convert to image.
+ * @return string Image string for smiley.
+ */
+function translate_smiley($smiley) {
+	global $wpsmiliestrans;
+
+	if (count($smiley) == 0) {
+		return '';
+	}
+
+	$smiley = trim(reset($smiley));
+	$img = $wpsmiliestrans[$smiley];
+	$smiley_masked = esc_attr($smiley);
+
+	$srcurl = apply_filters('smilies_src', includes_url("images/smilies/$img"), $img, site_url());
+
+	return " <img src='$srcurl' alt='$smiley_masked' class='wp-smiley' /> ";
+}
+
+/**
+ * Convert text equivalent of smilies to images.
+ *
+ * Will only convert smilies if the option 'use_smilies' is true and the global
+ * used in the function isn't empty.
+ *
+ * @since 0.71
+ * @uses $wp_smiliessearch
+ *
+ * @param string $text Content to convert smilies from text.
+ * @return string Converted content with text smilies replaced with images.
+ */
+function convert_smilies($text) {
+	global $wp_smiliessearch;
+	$output = '';
+	if ( get_option('use_smilies') && !empty($wp_smiliessearch) ) {
+		// HTML loop taken from texturize function, could possible be consolidated
+		$textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
+		$stop = count($textarr);// loop stuff
+		for ($i = 0; $i < $stop; $i++) {
+			$content = $textarr[$i];
+			if ((strlen($content) > 0) && ('<' != $content[0])) { // If it's not a tag
+				$content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);
+			}
+			$output .= $content;
+		}
+	} else {
+		// return default text.
+		$output = $text;
+	}
+	return $output;
+}
+
+/**
+ * Verifies that an email is valid.
+ *
+ * Does not grok i18n domains. Not RFC compliant.
+ *
+ * @since 0.71
+ *
+ * @param string $email Email address to verify.
+ * @param boolean $deprecated Deprecated.
+ * @return string|bool Either false or the valid email address.
+ */
+function is_email( $email, $deprecated = false ) {
+	if ( ! empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '3.0' );
+
+	// Test for the minimum length the email can be
+	if ( strlen( $email ) < 3 ) {
+		return apply_filters( 'is_email', false, $email, 'email_too_short' );
+	}
+
+	// Test for an @ character after the first position
+	if ( strpos( $email, '@', 1 ) === false ) {
+		return apply_filters( 'is_email', false, $email, 'email_no_at' );
+	}
+
+	// Split out the local and domain parts
+	list( $local, $domain ) = explode( '@', $email, 2 );
+
+	// LOCAL PART
+	// Test for invalid characters
+	if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
+		return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
+	}
+
+	// DOMAIN PART
+	// Test for sequences of periods
+	if ( preg_match( '/\.{2,}/', $domain ) ) {
+		return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
+	}
+
+	// Test for leading and trailing periods and whitespace
+	if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
+		return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
+	}
+
+	// Split the domain into subs
+	$subs = explode( '.', $domain );
+
+	// Assume the domain will have at least two subs
+	if ( 2 > count( $subs ) ) {
+		return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
+	}
+
+	// Loop through each sub
+	foreach ( $subs as $sub ) {
+		// Test for leading and trailing hyphens and whitespace
+		if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) {
+			return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
+		}
+
+		// Test for invalid characters
+		if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) {
+			return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
+		}
+	}
+
+	// Congratulations your email made it!
+	return apply_filters( 'is_email', $email, $email, null );
+}
+
+/**
+ * Convert to ASCII from email subjects.
+ *
+ * @since 1.2.0
+ * @usedby wp_mail() handles charsets in email subjects
+ *
+ * @param string $string Subject line
+ * @return string Converted string to ASCII
+ */
+function wp_iso_descrambler($string) {
+	/* this may only work with iso-8859-1, I'm afraid */
+	if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
+		return $string;
+	} else {
+		$subject = str_replace('_', ' ', $matches[2]);
+		$subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject);
+		return $subject;
+	}
+}
+
+/**
+ * Helper function to convert hex encoded chars to ascii
+ *
+ * @since 3.1.0
+ * @access private
+ * @param array $match the preg_replace_callback matches array
+ */
+function _wp_iso_convert( $match ) {
+	return chr( hexdec( strtolower( $match[1] ) ) );
+}
+
+/**
+ * Returns a date in the GMT equivalent.
+ *
+ * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the
+ * value of the 'gmt_offset' option. Return format can be overridden using the
+ * $format parameter. If PHP5 is supported, the function uses the DateTime and
+ * DateTimeZone objects to respect time zone differences in DST.
+ *
+ * @since 1.2.0
+ *
+ * @uses get_option() to retrieve the the value of 'gmt_offset'.
+ * @param string $string The date to be converted.
+ * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
+ * @return string GMT version of the date provided.
+ */
+function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
+	preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+	$tz = get_option('timezone_string');
+	if( class_exists('DateTime') && $tz ) {
+		//PHP5
+		date_default_timezone_set( $tz );
+		$datetime = new DateTime( $string );
+		$datetime->setTimezone( new DateTimeZone('UTC') );
+		$offset = $datetime->getOffset();
+		$datetime->modify( '+' . $offset / 3600 . ' hours');
+		$string_gmt = gmdate($format, $datetime->format('U'));
+
+		date_default_timezone_set('UTC');
+	}
+	else {
+		//PHP4
+		$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+		$string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600);
+	}
+	return $string_gmt;
+}
+
+/**
+ * Converts a GMT date into the correct format for the blog.
+ *
+ * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of
+ * gmt_offset.Return format can be overridden using the $format parameter
+ *
+ * @since 1.2.0
+ *
+ * @param string $string The date to be converted.
+ * @param string $format The format string for the returned date (default is Y-m-d H:i:s)
+ * @return string Formatted date relative to the GMT offset.
+ */
+function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') {
+	preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
+	$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
+	$string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600);
+	return $string_localtime;
+}
+
+/**
+ * Computes an offset in seconds from an iso8601 timezone.
+ *
+ * @since 1.5.0
+ *
+ * @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
+ * @return int|float The offset in seconds.
+ */
+function iso8601_timezone_to_offset($timezone) {
+	// $timezone is either 'Z' or '[+|-]hhmm'
+	if ($timezone == 'Z') {
+		$offset = 0;
+	} else {
+		$sign    = (substr($timezone, 0, 1) == '+') ? 1 : -1;
+		$hours   = intval(substr($timezone, 1, 2));
+		$minutes = intval(substr($timezone, 3, 4)) / 60;
+		$offset  = $sign * 3600 * ($hours + $minutes);
+	}
+	return $offset;
+}
+
+/**
+ * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].
+ *
+ * @since 1.5.0
+ *
+ * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}.
+ * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
+ * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.
+ */
+function iso8601_to_datetime($date_string, $timezone = 'user') {
+	$timezone = strtolower($timezone);
+
+	if ($timezone == 'gmt') {
+
+		preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);
+
+		if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
+			$offset = iso8601_timezone_to_offset($date_bits[7]);
+		} else { // we don't have a timezone, so we assume user local timezone (not server's!)
+			$offset = 3600 * get_option('gmt_offset');
+		}
+
+		$timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
+		$timestamp -= $offset;
+
+		return gmdate('Y-m-d H:i:s', $timestamp);
+
+	} else if ($timezone == 'user') {
+		return preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);
+	}
+}
+
+/**
+ * Adds a element attributes to open links in new windows.
+ *
+ * Comment text in popup windows should be filtered through this. Right now it's
+ * a moderately dumb function, ideally it would detect whether a target or rel
+ * attribute was already there and adjust its actions accordingly.
+ *
+ * @since 0.71
+ *
+ * @param string $text Content to replace links to open in a new window.
+ * @return string Content that has filtered links.
+ */
+function popuplinks($text) {
+	$text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
+	return $text;
+}
+
+/**
+ * Strips out all characters that are not allowable in an email.
+ *
+ * @since 1.5.0
+ *
+ * @param string $email Email address to filter.
+ * @return string Filtered email address.
+ */
+function sanitize_email( $email ) {
+	// Test for the minimum length the email can be
+	if ( strlen( $email ) < 3 ) {
+		return apply_filters( 'sanitize_email', '', $email, 'email_too_short' );
+	}
+
+	// Test for an @ character after the first position
+	if ( strpos( $email, '@', 1 ) === false ) {
+		return apply_filters( 'sanitize_email', '', $email, 'email_no_at' );
+	}
+
+	// Split out the local and domain parts
+	list( $local, $domain ) = explode( '@', $email, 2 );
+
+	// LOCAL PART
+	// Test for invalid characters
+	$local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local );
+	if ( '' === $local ) {
+		return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' );
+	}
+
+	// DOMAIN PART
+	// Test for sequences of periods
+	$domain = preg_replace( '/\.{2,}/', '', $domain );
+	if ( '' === $domain ) {
+		return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' );
+	}
+
+	// Test for leading and trailing periods and whitespace
+	$domain = trim( $domain, " \t\n\r\0\x0B." );
+	if ( '' === $domain ) {
+		return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' );
+	}
+
+	// Split the domain into subs
+	$subs = explode( '.', $domain );
+
+	// Assume the domain will have at least two subs
+	if ( 2 > count( $subs ) ) {
+		return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );
+	}
+
+	// Create an array that will contain valid subs
+	$new_subs = array();
+
+	// Loop through each sub
+	foreach ( $subs as $sub ) {
+		// Test for leading and trailing hyphens
+		$sub = trim( $sub, " \t\n\r\0\x0B-" );
+
+		// Test for invalid characters
+		$sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub );
+
+		// If there's anything left, add it to the valid subs
+		if ( '' !== $sub ) {
+			$new_subs[] = $sub;
+		}
+	}
+
+	// If there aren't 2 or more valid subs
+	if ( 2 > count( $new_subs ) ) {
+		return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );
+	}
+
+	// Join valid subs into the new domain
+	$domain = join( '.', $new_subs );
+
+	// Put the email back together
+	$email = $local . '@' . $domain;
+
+	// Congratulations your email made it!
+	return apply_filters( 'sanitize_email', $email, $email, null );
+}
+
+/**
+ * Determines the difference between two timestamps.
+ *
+ * The difference is returned in a human readable format such as "1 hour",
+ * "5 mins", "2 days".
+ *
+ * @since 1.5.0
+ *
+ * @param int $from Unix timestamp from which the difference begins.
+ * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
+ * @return string Human readable time difference.
+ */
+function human_time_diff( $from, $to = '' ) {
+	if ( empty($to) )
+		$to = time();
+	$diff = (int) abs($to - $from);
+	if ($diff <= 3600) {
+		$mins = round($diff / 60);
+		if ($mins <= 1) {
+			$mins = 1;
+		}
+		/* translators: min=minute */
+		$since = sprintf(_n('%s min', '%s mins', $mins), $mins);
+	} else if (($diff <= 86400) && ($diff > 3600)) {
+		$hours = round($diff / 3600);
+		if ($hours <= 1) {
+			$hours = 1;
+		}
+		$since = sprintf(_n('%s hour', '%s hours', $hours), $hours);
+	} elseif ($diff >= 86400) {
+		$days = round($diff / 86400);
+		if ($days <= 1) {
+			$days = 1;
+		}
+		$since = sprintf(_n('%s day', '%s days', $days), $days);
+	}
+	return $since;
+}
+
+/**
+ * Generates an excerpt from the content, if needed.
+ *
+ * The excerpt word amount will be 55 words and if the amount is greater than
+ * that, then the string ' [...]' will be appended to the excerpt. If the string
+ * is less than 55 words, then the content will be returned as is.
+ *
+ * The 55 word limit can be modified by plugins/themes using the excerpt_length filter
+ * The ' [...]' string can be modified by plugins/themes using the excerpt_more filter
+ *
+ * @since 1.5.0
+ *
+ * @param string $text The excerpt. If set to empty an excerpt is generated.
+ * @return string The excerpt.
+ */
+function wp_trim_excerpt($text) {
+	$raw_excerpt = $text;
+	if ( '' == $text ) {
+		$text = get_the_content('');
+
+		$text = strip_shortcodes( $text );
+
+		$text = apply_filters('the_content', $text);
+		$text = str_replace(']]>', ']]&gt;', $text);
+		$text = strip_tags($text);
+		$excerpt_length = apply_filters('excerpt_length', 55);
+		$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
+		$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
+		if ( count($words) > $excerpt_length ) {
+			array_pop($words);
+			$text = implode(' ', $words);
+			$text = $text . $excerpt_more;
+		} else {
+			$text = implode(' ', $words);
+		}
+	}
+	return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
+}
+
+/**
+ * Converts named entities into numbered entities.
+ *
+ * @since 1.5.1
+ *
+ * @param string $text The text within which entities will be converted.
+ * @return string Text with converted entities.
+ */
+function ent2ncr($text) {
+	$to_ncr = array(
+		'&quot;' => '&#34;',
+		'&amp;' => '&#38;',
+		'&frasl;' => '&#47;',
+		'&lt;' => '&#60;',
+		'&gt;' => '&#62;',
+		'|' => '&#124;',
+		'&nbsp;' => '&#160;',
+		'&iexcl;' => '&#161;',
+		'&cent;' => '&#162;',
+		'&pound;' => '&#163;',
+		'&curren;' => '&#164;',
+		'&yen;' => '&#165;',
+		'&brvbar;' => '&#166;',
+		'&brkbar;' => '&#166;',
+		'&sect;' => '&#167;',
+		'&uml;' => '&#168;',
+		'&die;' => '&#168;',
+		'&copy;' => '&#169;',
+		'&ordf;' => '&#170;',
+		'&laquo;' => '&#171;',
+		'&not;' => '&#172;',
+		'&shy;' => '&#173;',
+		'&reg;' => '&#174;',
+		'&macr;' => '&#175;',
+		'&hibar;' => '&#175;',
+		'&deg;' => '&#176;',
+		'&plusmn;' => '&#177;',
+		'&sup2;' => '&#178;',
+		'&sup3;' => '&#179;',
+		'&acute;' => '&#180;',
+		'&micro;' => '&#181;',
+		'&para;' => '&#182;',
+		'&middot;' => '&#183;',
+		'&cedil;' => '&#184;',
+		'&sup1;' => '&#185;',
+		'&ordm;' => '&#186;',
+		'&raquo;' => '&#187;',
+		'&frac14;' => '&#188;',
+		'&frac12;' => '&#189;',
+		'&frac34;' => '&#190;',
+		'&iquest;' => '&#191;',
+		'&Agrave;' => '&#192;',
+		'&Aacute;' => '&#193;',
+		'&Acirc;' => '&#194;',
+		'&Atilde;' => '&#195;',
+		'&Auml;' => '&#196;',
+		'&Aring;' => '&#197;',
+		'&AElig;' => '&#198;',
+		'&Ccedil;' => '&#199;',
+		'&Egrave;' => '&#200;',
+		'&Eacute;' => '&#201;',
+		'&Ecirc;' => '&#202;',
+		'&Euml;' => '&#203;',
+		'&Igrave;' => '&#204;',
+		'&Iacute;' => '&#205;',
+		'&Icirc;' => '&#206;',
+		'&Iuml;' => '&#207;',
+		'&ETH;' => '&#208;',
+		'&Ntilde;' => '&#209;',
+		'&Ograve;' => '&#210;',
+		'&Oacute;' => '&#211;',
+		'&Ocirc;' => '&#212;',
+		'&Otilde;' => '&#213;',
+		'&Ouml;' => '&#214;',
+		'&times;' => '&#215;',
+		'&Oslash;' => '&#216;',
+		'&Ugrave;' => '&#217;',
+		'&Uacute;' => '&#218;',
+		'&Ucirc;' => '&#219;',
+		'&Uuml;' => '&#220;',
+		'&Yacute;' => '&#221;',
+		'&THORN;' => '&#222;',
+		'&szlig;' => '&#223;',
+		'&agrave;' => '&#224;',
+		'&aacute;' => '&#225;',
+		'&acirc;' => '&#226;',
+		'&atilde;' => '&#227;',
+		'&auml;' => '&#228;',
+		'&aring;' => '&#229;',
+		'&aelig;' => '&#230;',
+		'&ccedil;' => '&#231;',
+		'&egrave;' => '&#232;',
+		'&eacute;' => '&#233;',
+		'&ecirc;' => '&#234;',
+		'&euml;' => '&#235;',
+		'&igrave;' => '&#236;',
+		'&iacute;' => '&#237;',
+		'&icirc;' => '&#238;',
+		'&iuml;' => '&#239;',
+		'&eth;' => '&#240;',
+		'&ntilde;' => '&#241;',
+		'&ograve;' => '&#242;',
+		'&oacute;' => '&#243;',
+		'&ocirc;' => '&#244;',
+		'&otilde;' => '&#245;',
+		'&ouml;' => '&#246;',
+		'&divide;' => '&#247;',
+		'&oslash;' => '&#248;',
+		'&ugrave;' => '&#249;',
+		'&uacute;' => '&#250;',
+		'&ucirc;' => '&#251;',
+		'&uuml;' => '&#252;',
+		'&yacute;' => '&#253;',
+		'&thorn;' => '&#254;',
+		'&yuml;' => '&#255;',
+		'&OElig;' => '&#338;',
+		'&oelig;' => '&#339;',
+		'&Scaron;' => '&#352;',
+		'&scaron;' => '&#353;',
+		'&Yuml;' => '&#376;',
+		'&fnof;' => '&#402;',
+		'&circ;' => '&#710;',
+		'&tilde;' => '&#732;',
+		'&Alpha;' => '&#913;',
+		'&Beta;' => '&#914;',
+		'&Gamma;' => '&#915;',
+		'&Delta;' => '&#916;',
+		'&Epsilon;' => '&#917;',
+		'&Zeta;' => '&#918;',
+		'&Eta;' => '&#919;',
+		'&Theta;' => '&#920;',
+		'&Iota;' => '&#921;',
+		'&Kappa;' => '&#922;',
+		'&Lambda;' => '&#923;',
+		'&Mu;' => '&#924;',
+		'&Nu;' => '&#925;',
+		'&Xi;' => '&#926;',
+		'&Omicron;' => '&#927;',
+		'&Pi;' => '&#928;',
+		'&Rho;' => '&#929;',
+		'&Sigma;' => '&#931;',
+		'&Tau;' => '&#932;',
+		'&Upsilon;' => '&#933;',
+		'&Phi;' => '&#934;',
+		'&Chi;' => '&#935;',
+		'&Psi;' => '&#936;',
+		'&Omega;' => '&#937;',
+		'&alpha;' => '&#945;',
+		'&beta;' => '&#946;',
+		'&gamma;' => '&#947;',
+		'&delta;' => '&#948;',
+		'&epsilon;' => '&#949;',
+		'&zeta;' => '&#950;',
+		'&eta;' => '&#951;',
+		'&theta;' => '&#952;',
+		'&iota;' => '&#953;',
+		'&kappa;' => '&#954;',
+		'&lambda;' => '&#955;',
+		'&mu;' => '&#956;',
+		'&nu;' => '&#957;',
+		'&xi;' => '&#958;',
+		'&omicron;' => '&#959;',
+		'&pi;' => '&#960;',
+		'&rho;' => '&#961;',
+		'&sigmaf;' => '&#962;',
+		'&sigma;' => '&#963;',
+		'&tau;' => '&#964;',
+		'&upsilon;' => '&#965;',
+		'&phi;' => '&#966;',
+		'&chi;' => '&#967;',
+		'&psi;' => '&#968;',
+		'&omega;' => '&#969;',
+		'&thetasym;' => '&#977;',
+		'&upsih;' => '&#978;',
+		'&piv;' => '&#982;',
+		'&ensp;' => '&#8194;',
+		'&emsp;' => '&#8195;',
+		'&thinsp;' => '&#8201;',
+		'&zwnj;' => '&#8204;',
+		'&zwj;' => '&#8205;',
+		'&lrm;' => '&#8206;',
+		'&rlm;' => '&#8207;',
+		'&ndash;' => '&#8211;',
+		'&mdash;' => '&#8212;',
+		'&lsquo;' => '&#8216;',
+		'&rsquo;' => '&#8217;',
+		'&sbquo;' => '&#8218;',
+		'&ldquo;' => '&#8220;',
+		'&rdquo;' => '&#8221;',
+		'&bdquo;' => '&#8222;',
+		'&dagger;' => '&#8224;',
+		'&Dagger;' => '&#8225;',
+		'&bull;' => '&#8226;',
+		'&hellip;' => '&#8230;',
+		'&permil;' => '&#8240;',
+		'&prime;' => '&#8242;',
+		'&Prime;' => '&#8243;',
+		'&lsaquo;' => '&#8249;',
+		'&rsaquo;' => '&#8250;',
+		'&oline;' => '&#8254;',
+		'&frasl;' => '&#8260;',
+		'&euro;' => '&#8364;',
+		'&image;' => '&#8465;',
+		'&weierp;' => '&#8472;',
+		'&real;' => '&#8476;',
+		'&trade;' => '&#8482;',
+		'&alefsym;' => '&#8501;',
+		'&crarr;' => '&#8629;',
+		'&lArr;' => '&#8656;',
+		'&uArr;' => '&#8657;',
+		'&rArr;' => '&#8658;',
+		'&dArr;' => '&#8659;',
+		'&hArr;' => '&#8660;',
+		'&forall;' => '&#8704;',
+		'&part;' => '&#8706;',
+		'&exist;' => '&#8707;',
+		'&empty;' => '&#8709;',
+		'&nabla;' => '&#8711;',
+		'&isin;' => '&#8712;',
+		'&notin;' => '&#8713;',
+		'&ni;' => '&#8715;',
+		'&prod;' => '&#8719;',
+		'&sum;' => '&#8721;',
+		'&minus;' => '&#8722;',
+		'&lowast;' => '&#8727;',
+		'&radic;' => '&#8730;',
+		'&prop;' => '&#8733;',
+		'&infin;' => '&#8734;',
+		'&ang;' => '&#8736;',
+		'&and;' => '&#8743;',
+		'&or;' => '&#8744;',
+		'&cap;' => '&#8745;',
+		'&cup;' => '&#8746;',
+		'&int;' => '&#8747;',
+		'&there4;' => '&#8756;',
+		'&sim;' => '&#8764;',
+		'&cong;' => '&#8773;',
+		'&asymp;' => '&#8776;',
+		'&ne;' => '&#8800;',
+		'&equiv;' => '&#8801;',
+		'&le;' => '&#8804;',
+		'&ge;' => '&#8805;',
+		'&sub;' => '&#8834;',
+		'&sup;' => '&#8835;',
+		'&nsub;' => '&#8836;',
+		'&sube;' => '&#8838;',
+		'&supe;' => '&#8839;',
+		'&oplus;' => '&#8853;',
+		'&otimes;' => '&#8855;',
+		'&perp;' => '&#8869;',
+		'&sdot;' => '&#8901;',
+		'&lceil;' => '&#8968;',
+		'&rceil;' => '&#8969;',
+		'&lfloor;' => '&#8970;',
+		'&rfloor;' => '&#8971;',
+		'&lang;' => '&#9001;',
+		'&rang;' => '&#9002;',
+		'&larr;' => '&#8592;',
+		'&uarr;' => '&#8593;',
+		'&rarr;' => '&#8594;',
+		'&darr;' => '&#8595;',
+		'&harr;' => '&#8596;',
+		'&loz;' => '&#9674;',
+		'&spades;' => '&#9824;',
+		'&clubs;' => '&#9827;',
+		'&hearts;' => '&#9829;',
+		'&diams;' => '&#9830;'
+	);
+
+	return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );
+}
+
+/**
+ * Formats text for the rich text editor.
+ *
+ * The filter 'richedit_pre' is applied here. If $text is empty the filter will
+ * be applied to an empty string.
+ *
+ * @since 2.0.0
+ *
+ * @param string $text The text to be formatted.
+ * @return string The formatted text after filter is applied.
+ */
+function wp_richedit_pre($text) {
+	// Filtering a blank results in an annoying <br />\n
+	if ( empty($text) ) return apply_filters('richedit_pre', '');
+
+	$output = convert_chars($text);
+	$output = wpautop($output);
+	$output = htmlspecialchars($output, ENT_NOQUOTES);
+
+	return apply_filters('richedit_pre', $output);
+}
+
+/**
+ * Formats text for the HTML editor.
+ *
+ * Unless $output is empty it will pass through htmlspecialchars before the
+ * 'htmledit_pre' filter is applied.
+ *
+ * @since 2.5.0
+ *
+ * @param string $output The text to be formatted.
+ * @return string Formatted text after filter applied.
+ */
+function wp_htmledit_pre($output) {
+	if ( !empty($output) )
+		$output = htmlspecialchars($output, ENT_NOQUOTES); // convert only < > &
+
+	return apply_filters('htmledit_pre', $output);
+}
+
+/**
+ * Perform a deep string replace operation to ensure the values in $search are no longer present
+ *
+ * Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values
+ * e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that
+ * str_replace would return
+ *
+ * @since 2.8.1
+ * @access private
+ *
+ * @param string|array $search
+ * @param string $subject
+ * @return string The processed string
+ */
+function _deep_replace( $search, $subject ) {
+	$found = true;
+	$subject = (string) $subject;
+	while ( $found ) {
+		$found = false;
+		foreach ( (array) $search as $val ) {
+			while ( strpos( $subject, $val ) !== false ) {
+				$found = true;
+				$subject = str_replace( $val, '', $subject );
+			}
+		}
+	}
+
+	return $subject;
+}
+
+/**
+ * Escapes data for use in a MySQL query
+ *
+ * This is just a handy shortcut for $wpdb->escape(), for completeness' sake
+ *
+ * @since 2.8.0
+ * @param string $sql Unescaped SQL data
+ * @return string The cleaned $sql
+ */
+function esc_sql( $sql ) {
+	global $wpdb;
+	return $wpdb->escape( $sql );
+}
+
+/**
+ * Checks and cleans a URL.
+ *
+ * A number of characters are removed from the URL. If the URL is for displaying
+ * (the default behaviour) amperstands are also replaced. The 'clean_url' filter
+ * is applied to the returned cleaned URL.
+ *
+ * @since 2.8.0
+ * @uses wp_kses_bad_protocol() To only permit protocols in the URL set
+ *		via $protocols or the common ones set in the function.
+ *
+ * @param string $url The URL to be cleaned.
+ * @param array $protocols Optional. An array of acceptable protocols.
+ *		Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.
+ * @param string $_context Private. Use esc_url_raw() for database usage.
+ * @return string The cleaned $url after the 'clean_url' filter is applied.
+ */
+function esc_url( $url, $protocols = null, $_context = 'display' ) {
+	$original_url = $url;
+
+	if ( '' == $url )
+		return $url;
+	$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
+	$strip = array('%0d', '%0a', '%0D', '%0A');
+	$url = _deep_replace($strip, $url);
+	$url = str_replace(';//', '://', $url);
+	/* If the URL doesn't appear to contain a scheme, we
+	 * presume it needs http:// appended (unless a relative
+	 * link starting with / or a php file).
+	 */
+	if ( strpos($url, ':') === false &&
+		substr( $url, 0, 1 ) != '/' && substr( $url, 0, 1 ) != '#' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
+		$url = 'http://' . $url;
+
+	// Replace ampersands and single quotes only when displaying.
+	if ( 'display' == $_context ) {
+		$url = wp_kses_normalize_entities( $url );
+		$url = str_replace( '&amp;', '&#038;', $url );
+		$url = str_replace( "'", '&#039;', $url );
+	}
+
+	if ( !is_array($protocols) )
+		$protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn');
+	if ( wp_kses_bad_protocol( $url, $protocols ) != $url )
+		return '';
+
+	return apply_filters('clean_url', $url, $original_url, $_context);
+}
+
+/**
+ * Performs esc_url() for database usage.
+ *
+ * @since 2.8.0
+ * @uses esc_url()
+ *
+ * @param string $url The URL to be cleaned.
+ * @param array $protocols An array of acceptable protocols.
+ * @return string The cleaned URL.
+ */
+function esc_url_raw( $url, $protocols = null ) {
+	return esc_url( $url, $protocols, 'db' );
+}
+
+/**
+ * Convert entities, while preserving already-encoded entities.
+ *
+ * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.
+ *
+ * @since 1.2.2
+ *
+ * @param string $myHTML The text to be converted.
+ * @return string Converted text.
+ */
+function htmlentities2($myHTML) {
+	$translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
+	$translation_table[chr(38)] = '&';
+	return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr($myHTML, $translation_table) );
+}
+
+/**
+ * Escape single quotes, htmlspecialchar " < > &, and fix line endings.
+ *
+ * Escapes text strings for echoing in JS. It is intended to be used for inline JS
+ * (in a tag attribute, for example onclick="..."). Note that the strings have to
+ * be in single quotes. The filter 'js_escape' is also applied here.
+ *
+ * @since 2.8.0
+ *
+ * @param string $text The text to be escaped.
+ * @return string Escaped text.
+ */
+function esc_js( $text ) {
+	$safe_text = wp_check_invalid_utf8( $text );
+	$safe_text = _wp_specialchars( $safe_text, ENT_COMPAT );
+	$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
+	$safe_text = str_replace( "\r", '', $safe_text );
+	$safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );
+	return apply_filters( 'js_escape', $safe_text, $text );
+}
+
+/**
+ * Escaping for HTML blocks.
+ *
+ * @since 2.8.0
+ *
+ * @param string $text
+ * @return string
+ */
+function esc_html( $text ) {
+	$safe_text = wp_check_invalid_utf8( $text );
+	$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
+	return apply_filters( 'esc_html', $safe_text, $text );
+}
+
+/**
+ * Escaping for HTML attributes.
+ *
+ * @since 2.8.0
+ *
+ * @param string $text
+ * @return string
+ */
+function esc_attr( $text ) {
+	$safe_text = wp_check_invalid_utf8( $text );
+	$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
+	return apply_filters( 'attribute_escape', $safe_text, $text );
+}
+
+/**
+ * Escaping for textarea values.
+ *
+ * @since 3.1
+ *
+ * @param string $text
+ * @return string
+ */
+function esc_textarea( $text ) {
+	$safe_text = htmlspecialchars( $text, ENT_QUOTES );
+	return apply_filters( 'esc_textarea', $safe_text, $text );
+}
+
+/**
+ * Escape a HTML tag name.
+ *
+ * @since 2.5.0
+ *
+ * @param string $tag_name
+ * @return string
+ */
+function tag_escape($tag_name) {
+	$safe_tag = strtolower( preg_replace('/[^a-zA-Z_:]/', '', $tag_name) );
+	return apply_filters('tag_escape', $safe_tag, $tag_name);
+}
+
+/**
+ * Escapes text for SQL LIKE special characters % and _.
+ *
+ * @since 2.5.0
+ *
+ * @param string $text The text to be escaped.
+ * @return string text, safe for inclusion in LIKE query.
+ */
+function like_escape($text) {
+	return str_replace(array("%", "_"), array("\\%", "\\_"), $text);
+}
+
+/**
+ * Convert full URL paths to absolute paths.
+ *
+ * Removes the http or https protocols and the domain. Keeps the path '/' at the
+ * beginning, so it isn't a true relative link, but from the web root base.
+ *
+ * @since 2.1.0
+ *
+ * @param string $link Full URL path.
+ * @return string Absolute path.
+ */
+function wp_make_link_relative( $link ) {
+	return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );
+}
+
+/**
+ * Sanitises various option values based on the nature of the option.
+ *
+ * This is basically a switch statement which will pass $value through a number
+ * of functions depending on the $option.
+ *
+ * @since 2.0.5
+ *
+ * @param string $option The name of the option.
+ * @param string $value The unsanitised value.
+ * @return string Sanitized value.
+ */
+function sanitize_option($option, $value) {
+
+	switch ( $option ) {
+		case 'admin_email':
+			$value = sanitize_email($value);
+			if ( !is_email($value) ) {
+				$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
+				if ( function_exists('add_settings_error') )
+					add_settings_error('admin_email', 'invalid_admin_email', __('The email address entered did not appear to be a valid email address. Please enter a valid email address.'));
+			}
+			break;
+
+		case 'thumbnail_size_w':
+		case 'thumbnail_size_h':
+		case 'medium_size_w':
+		case 'medium_size_h':
+		case 'large_size_w':
+		case 'large_size_h':
+		case 'embed_size_h':
+		case 'default_post_edit_rows':
+		case 'mailserver_port':
+		case 'comment_max_links':
+		case 'page_on_front':
+		case 'page_for_posts':
+		case 'rss_excerpt_length':
+		case 'default_category':
+		case 'default_email_category':
+		case 'default_link_category':
+		case 'close_comments_days_old':
+		case 'comments_per_page':
+		case 'thread_comments_depth':
+		case 'users_can_register':
+		case 'start_of_week':
+			$value = absint( $value );
+			break;
+
+		case 'embed_size_w':
+			if ( '' !== $value )
+				$value = absint( $value );
+			break;
+
+		case 'posts_per_page':
+		case 'posts_per_rss':
+			$value = (int) $value;
+			if ( empty($value) )
+				$value = 1;
+			if ( $value < -1 )
+				$value = abs($value);
+			break;
+
+		case 'default_ping_status':
+		case 'default_comment_status':
+			// Options that if not there have 0 value but need to be something like "closed"
+			if ( $value == '0' || $value == '')
+				$value = 'closed';
+			break;
+
+		case 'blogdescription':
+		case 'blogname':
+			$value = addslashes($value);
+			$value = wp_filter_post_kses( $value ); // calls stripslashes then addslashes
+			$value = stripslashes($value);
+			$value = esc_html( $value );
+			break;
+
+		case 'blog_charset':
+			$value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value); // strips slashes
+			break;
+
+		case 'date_format':
+		case 'time_format':
+		case 'mailserver_url':
+		case 'mailserver_login':
+		case 'mailserver_pass':
+		case 'ping_sites':
+		case 'upload_path':
+			$value = strip_tags($value);
+			$value = addslashes($value);
+			$value = wp_filter_kses($value); // calls stripslashes then addslashes
+			$value = stripslashes($value);
+			break;
+
+		case 'gmt_offset':
+			$value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes
+			break;
+
+		case 'siteurl':
+			if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {
+				$value = esc_url_raw($value);
+			} else {
+				$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
+				if ( function_exists('add_settings_error') )
+					add_settings_error('siteurl', 'invalid_siteurl', __('The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.'));
+			}
+			break;
+
+		case 'home':
+			if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {
+				$value = esc_url_raw($value);
+			} else {
+				$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
+				if ( function_exists('add_settings_error') )
+					add_settings_error('home', 'invalid_home', __('The Site address you entered did not appear to be a valid URL. Please enter a valid URL.'));
+			}
+			break;
+
+		default :
+			$value = apply_filters("sanitize_option_{$option}", $value, $option);
+			break;
+	}
+
+	return $value;
+}
+
+/**
+ * Parses a string into variables to be stored in an array.
+ *
+ * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if
+ * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.
+ *
+ * @since 2.2.1
+ * @uses apply_filters() for the 'wp_parse_str' filter.
+ *
+ * @param string $string The string to be parsed.
+ * @param array $array Variables will be stored in this array.
+ */
+function wp_parse_str( $string, &$array ) {
+	parse_str( $string, $array );
+	if ( get_magic_quotes_gpc() )
+		$array = stripslashes_deep( $array );
+	$array = apply_filters( 'wp_parse_str', $array );
+}
+
+/**
+ * Convert lone less than signs.
+ *
+ * KSES already converts lone greater than signs.
+ *
+ * @uses wp_pre_kses_less_than_callback in the callback function.
+ * @since 2.3.0
+ *
+ * @param string $text Text to be converted.
+ * @return string Converted text.
+ */
+function wp_pre_kses_less_than( $text ) {
+	return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);
+}
+
+/**
+ * Callback function used by preg_replace.
+ *
+ * @uses esc_html to format the $matches text.
+ * @since 2.3.0
+ *
+ * @param array $matches Populated by matches to preg_replace.
+ * @return string The text returned after esc_html if needed.
+ */
+function wp_pre_kses_less_than_callback( $matches ) {
+	if ( false === strpos($matches[0], '>') )
+		return esc_html($matches[0]);
+	return $matches[0];
+}
+
+/**
+ * WordPress implementation of PHP sprintf() with filters.
+ *
+ * @since 2.5.0
+ * @link http://www.php.net/sprintf
+ *
+ * @param string $pattern The string which formatted args are inserted.
+ * @param mixed $args,... Arguments to be formatted into the $pattern string.
+ * @return string The formatted string.
+ */
+function wp_sprintf( $pattern ) {
+	$args = func_get_args( );
+	$len = strlen($pattern);
+	$start = 0;
+	$result = '';
+	$arg_index = 0;
+	while ( $len > $start ) {
+		// Last character: append and break
+		if ( strlen($pattern) - 1 == $start ) {
+			$result .= substr($pattern, -1);
+			break;
+		}
+
+		// Literal %: append and continue
+		if ( substr($pattern, $start, 2) == '%%' ) {
+			$start += 2;
+			$result .= '%';
+			continue;
+		}
+
+		// Get fragment before next %
+		$end = strpos($pattern, '%', $start + 1);
+		if ( false === $end )
+			$end = $len;
+		$fragment = substr($pattern, $start, $end - $start);
+
+		// Fragment has a specifier
+		if ( $pattern[$start] == '%' ) {
+			// Find numbered arguments or take the next one in order
+			if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) {
+				$arg = isset($args[$matches[1]]) ? $args[$matches[1]] : '';
+				$fragment = str_replace("%{$matches[1]}$", '%', $fragment);
+			} else {
+				++$arg_index;
+				$arg = isset($args[$arg_index]) ? $args[$arg_index] : '';
+			}
+
+			// Apply filters OR sprintf
+			$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
+			if ( $_fragment != $fragment )
+				$fragment = $_fragment;
+			else
+				$fragment = sprintf($fragment, strval($arg) );
+		}
+
+		// Append to result and move to next fragment
+		$result .= $fragment;
+		$start = $end;
+	}
+	return $result;
+}
+
+/**
+ * Localize list items before the rest of the content.
+ *
+ * The '%l' must be at the first characters can then contain the rest of the
+ * content. The list items will have ', ', ', and', and ' and ' added depending
+ * on the amount of list items in the $args parameter.
+ *
+ * @since 2.5.0
+ *
+ * @param string $pattern Content containing '%l' at the beginning.
+ * @param array $args List items to prepend to the content and replace '%l'.
+ * @return string Localized list items and rest of the content.
+ */
+function wp_sprintf_l($pattern, $args) {
+	// Not a match
+	if ( substr($pattern, 0, 2) != '%l' )
+		return $pattern;
+
+	// Nothing to work with
+	if ( empty($args) )
+		return '';
+
+	// Translate and filter the delimiter set (avoid ampersands and entities here)
+	$l = apply_filters('wp_sprintf_l', array(
+		/* translators: used between list items, there is a space after the coma */
+		'between'          => __(', '),
+		/* translators: used between list items, there is a space after the and */
+		'between_last_two' => __(', and '),
+		/* translators: used between only two list items, there is a space after the and */
+		'between_only_two' => __(' and '),
+		));
+
+	$args = (array) $args;
+	$result = array_shift($args);
+	if ( count($args) == 1 )
+		$result .= $l['between_only_two'] . array_shift($args);
+	// Loop when more than two args
+	$i = count($args);
+	while ( $i ) {
+		$arg = array_shift($args);
+		$i--;
+		if ( 0 == $i )
+			$result .= $l['between_last_two'] . $arg;
+		else
+			$result .= $l['between'] . $arg;
+	}
+	return $result . substr($pattern, 2);
+}
+
+/**
+ * Safely extracts not more than the first $count characters from html string.
+ *
+ * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*
+ * be counted as one character. For example &amp; will be counted as 4, &lt; as
+ * 3, etc.
+ *
+ * @since 2.5.0
+ *
+ * @param integer $str String to get the excerpt from.
+ * @param integer $count Maximum number of characters to take.
+ * @return string The excerpt.
+ */
+function wp_html_excerpt( $str, $count ) {
+	$str = wp_strip_all_tags( $str, true );
+	$str = mb_substr( $str, 0, $count );
+	// remove part of an entity at the end
+	$str = preg_replace( '/&[^;\s]{0,6}$/', '', $str );
+	return $str;
+}
+
+/**
+ * Add a Base url to relative links in passed content.
+ *
+ * By default it supports the 'src' and 'href' attributes. However this can be
+ * changed via the 3rd param.
+ *
+ * @since 2.7.0
+ *
+ * @param string $content String to search for links in.
+ * @param string $base The base URL to prefix to links.
+ * @param array $attrs The attributes which should be processed.
+ * @return string The processed content.
+ */
+function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
+	global $_links_add_base;
+	$_links_add_base = $base;
+	$attrs = implode('|', (array)$attrs);
+	return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );
+}
+
+/**
+ * Callback to add a base url to relative links in passed content.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @param string $m The matched link.
+ * @return string The processed link.
+ */
+function _links_add_base($m) {
+	global $_links_add_base;
+	//1 = attribute name  2 = quotation mark  3 = URL
+	return $m[1] . '=' . $m[2] .
+		(strpos($m[3], 'http://') === false ?
+			path_join($_links_add_base, $m[3]) :
+			$m[3])
+		. $m[2];
+}
+
+/**
+ * Adds a Target attribute to all links in passed content.
+ *
+ * This function by default only applies to <a> tags, however this can be
+ * modified by the 3rd param.
+ *
+ * <b>NOTE:</b> Any current target attributed will be striped and replaced.
+ *
+ * @since 2.7.0
+ *
+ * @param string $content String to search for links in.
+ * @param string $target The Target to add to the links.
+ * @param array $tags An array of tags to apply to.
+ * @return string The processed content.
+ */
+function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
+	global $_links_add_target;
+	$_links_add_target = $target;
+	$tags = implode('|', (array)$tags);
+	return preg_replace_callback( "!<($tags)(.+?)>!i", '_links_add_target', $content );
+}
+
+/**
+ * Callback to add a target attribute to all links in passed content.
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @param string $m The matched link.
+ * @return string The processed link.
+ */
+function _links_add_target( $m ) {
+	global $_links_add_target;
+	$tag = $m[1];
+	$link = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]);
+	return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
+}
+
+// normalize EOL characters and strip duplicate whitespace
+function normalize_whitespace( $str ) {
+	$str  = trim($str);
+	$str  = str_replace("\r", "\n", $str);
+	$str  = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
+	return $str;
+}
+
+/**
+ * Properly strip all HTML tags including script and style
+ *
+ * @since 2.9.0
+ *
+ * @param string $string String containing HTML tags
+ * @param bool $remove_breaks optional Whether to remove left over line breaks and white space chars
+ * @return string The processed string.
+ */
+function wp_strip_all_tags($string, $remove_breaks = false) {
+	$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
+	$string = strip_tags($string);
+
+	if ( $remove_breaks )
+		$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
+
+	return trim($string);
+}
+
+/**
+ * Sanitize a string from user input or from the db
+ *
+ * check for invalid UTF-8,
+ * Convert single < characters to entity,
+ * strip all tags,
+ * remove line breaks, tabs and extra white space,
+ * strip octets.
+ *
+ * @since 2.9.0
+ *
+ * @param string $str
+ * @return string
+ */
+function sanitize_text_field($str) {
+	$filtered = wp_check_invalid_utf8( $str );
+
+	if ( strpos($filtered, '<') !== false ) {
+		$filtered = wp_pre_kses_less_than( $filtered );
+		// This will strip extra whitespace for us.
+		$filtered = wp_strip_all_tags( $filtered, true );
+	} else {
+		$filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filtered) );
+	}
+
+	$match = array();
+	$found = false;
+	while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {
+		$filtered = str_replace($match[0], '', $filtered);
+		$found = true;
+	}
+
+	if ( $found ) {
+		// Strip out the whitespace that may now exist after removing the octets.
+		$filtered = trim( preg_replace('/ +/', ' ', $filtered) );
+	}
+
+	return apply_filters('sanitize_text_field', $filtered, $str);
+}
+
+/**
+ * i18n friendly version of basename()
+ *
+ * @since 3.1.0
+ *
+ * @param string $path A path.
+ * @param string $suffix If the filename ends in suffix this will also be cut off.
+ * @return string
+ */
+function wp_basename( $path, $suffix = '' ) {
+	return urldecode( basename( str_replace( '%2F', '/', urlencode( $path ) ), $suffix ) );
+}
+
+/**
+ * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence).
+ *
+ * Violating our coding standards for a good function name.
+ *
+ * @since 3.0.0
+ */
+function capital_P_dangit( $text ) {
+	// Simple replacement for titles
+	if ( 'the_title' === current_filter() )
+		return str_replace( 'Wordpress', 'WordPress', $text );
+	// Still here? Use the more judicious replacement
+	static $dblq = false;
+	if ( false === $dblq )
+		$dblq = _x('&#8220;', 'opening curly quote');
+	return str_replace(
+		array( ' Wordpress', '&#8216;Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),
+		array( ' WordPress', '&#8216;WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
+	$text );
+
+}
+
+?>
Index: /tags/3.1/wp-includes/functions.php
===================================================================
--- /tags/3.1/wp-includes/functions.php	(revision 17487)
+++ /tags/3.1/wp-includes/functions.php	(revision 17487)
@@ -0,0 +1,4485 @@
+<?php
+/**
+ * Main WordPress API
+ *
+ * @package WordPress
+ */
+
+/**
+ * Converts MySQL DATETIME field to user specified date format.
+ *
+ * If $dateformatstring has 'G' value, then gmmktime() function will be used to
+ * make the time. If $dateformatstring is set to 'U', then mktime() function
+ * will be used to make the time.
+ *
+ * The $translate will only be used, if it is set to true and it is by default
+ * and if the $wp_locale object has the month and weekday set.
+ *
+ * @since 0.71
+ *
+ * @param string $dateformatstring Either 'G', 'U', or php date format.
+ * @param string $mysqlstring Time from mysql DATETIME field.
+ * @param bool $translate Optional. Default is true. Will switch format to locale.
+ * @return string Date formated by $dateformatstring or locale (if available).
+ */
+function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
+	$m = $mysqlstring;
+	if ( empty( $m ) )
+		return false;
+
+	if ( 'G' == $dateformatstring )
+		return strtotime( $m . ' +0000' );
+
+	$i = strtotime( $m );
+
+	if ( 'U' == $dateformatstring )
+		return $i;
+
+	if ( $translate )
+		return date_i18n( $dateformatstring, $i );
+	else
+		return date( $dateformatstring, $i );
+}
+
+/**
+ * Retrieve the current time based on specified type.
+ *
+ * The 'mysql' type will return the time in the format for MySQL DATETIME field.
+ * The 'timestamp' type will return the current timestamp.
+ *
+ * If $gmt is set to either '1' or 'true', then both types will use GMT time.
+ * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
+ *
+ * @since 1.0.0
+ *
+ * @param string $type Either 'mysql' or 'timestamp'.
+ * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false.
+ * @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
+ */
+function current_time( $type, $gmt = 0 ) {
+	switch ( $type ) {
+		case 'mysql':
+			return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
+			break;
+		case 'timestamp':
+			return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 );
+			break;
+	}
+}
+
+/**
+ * Retrieve the date in localized format, based on timestamp.
+ *
+ * If the locale specifies the locale month and weekday, then the locale will
+ * take over the format for the date. If it isn't, then the date format string
+ * will be used instead.
+ *
+ * @since 0.71
+ *
+ * @param string $dateformatstring Format to display the date.
+ * @param int $unixtimestamp Optional. Unix timestamp.
+ * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
+ * @return string The date, translated if locale specifies it.
+ */
+function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
+	global $wp_locale;
+	$i = $unixtimestamp;
+	// Sanity check for PHP 5.1.0-
+	if ( false === $i || intval($i) < 0 ) {
+		if ( ! $gmt )
+			$i = current_time( 'timestamp' );
+		else
+			$i = time();
+		// we should not let date() interfere with our
+		// specially computed timestamp
+		$gmt = true;
+	}
+
+	// store original value for language with untypical grammars
+	// see http://core.trac.wordpress.org/ticket/9396
+	$req_format = $dateformatstring;
+
+	$datefunc = $gmt? 'gmdate' : 'date';
+
+	if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
+		$datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );
+		$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
+		$dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) );
+		$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
+		$datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) );
+		$datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) );
+		$dateformatstring = ' '.$dateformatstring;
+		$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
+		$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
+		$dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );
+		$dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );
+		$dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );
+		$dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );
+
+		$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
+	}
+	$timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
+	$timezone_formats_re = implode( '|', $timezone_formats );
+	if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) && wp_timezone_supported() ) {
+		$timezone_string = get_option( 'timezone_string' );
+		if ( $timezone_string ) {
+			$timezone_object = timezone_open( $timezone_string );
+			$date_object = date_create( null, $timezone_object );
+			foreach( $timezone_formats as $timezone_format ) {
+				if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
+					$formatted = date_format( $date_object, $timezone_format );
+					$dateformatstring = ' '.$dateformatstring;
+					$dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
+					$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
+				}
+			}
+		}
+	}
+	$j = @$datefunc( $dateformatstring, $i );
+	// allow plugins to redo this entirely for languages with untypical grammars
+	$j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
+	return $j;
+}
+
+/**
+ * Convert integer number to format based on the locale.
+ *
+ * @since 2.3.0
+ *
+ * @param int $number The number to convert based on locale.
+ * @param int $decimals Precision of the number of decimal places.
+ * @return string Converted number in string format.
+ */
+function number_format_i18n( $number, $decimals = 0 ) {
+	global $wp_locale;
+	$formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
+	return apply_filters( 'number_format_i18n', $formatted );
+}
+
+/**
+ * Convert number of bytes largest unit bytes will fit into.
+ *
+ * It is easier to read 1kB than 1024 bytes and 1MB than 1048576 bytes. Converts
+ * number of bytes to human readable number by taking the number of that unit
+ * that the bytes will go into it. Supports TB value.
+ *
+ * Please note that integers in PHP are limited to 32 bits, unless they are on
+ * 64 bit architecture, then they have 64 bit size. If you need to place the
+ * larger size then what PHP integer type will hold, then use a string. It will
+ * be converted to a double, which should always have 64 bit length.
+ *
+ * Technically the correct unit names for powers of 1024 are KiB, MiB etc.
+ * @link http://en.wikipedia.org/wiki/Byte
+ *
+ * @since 2.3.0
+ *
+ * @param int|string $bytes Number of bytes. Note max integer size for integers.
+ * @param int $decimals Precision of number of decimal places. Deprecated.
+ * @return bool|string False on failure. Number string on success.
+ */
+function size_format( $bytes, $decimals = 0 ) {
+	$quant = array(
+		// ========================= Origin ====
+		'TB' => 1099511627776,  // pow( 1024, 4)
+		'GB' => 1073741824,     // pow( 1024, 3)
+		'MB' => 1048576,        // pow( 1024, 2)
+		'kB' => 1024,           // pow( 1024, 1)
+		'B ' => 1,              // pow( 1024, 0)
+	);
+	foreach ( $quant as $unit => $mag )
+		if ( doubleval($bytes) >= $mag )
+			return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit;
+
+	return false;
+}
+
+/**
+ * Get the week start and end from the datetime or date string from mysql.
+ *
+ * @since 0.71
+ *
+ * @param string $mysqlstring Date or datetime field type from mysql.
+ * @param int $start_of_week Optional. Start of the week as an integer.
+ * @return array Keys are 'start' and 'end'.
+ */
+function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
+	$my = substr( $mysqlstring, 0, 4 ); // Mysql string Year
+	$mm = substr( $mysqlstring, 8, 2 ); // Mysql string Month
+	$md = substr( $mysqlstring, 5, 2 ); // Mysql string day
+	$day = mktime( 0, 0, 0, $md, $mm, $my ); // The timestamp for mysqlstring day.
+	$weekday = date( 'w', $day ); // The day of the week from the timestamp
+	if ( !is_numeric($start_of_week) )
+		$start_of_week = get_option( 'start_of_week' );
+
+	if ( $weekday < $start_of_week )
+		$weekday += 7;
+
+	$start = $day - 86400 * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
+	$end = $start + 604799; // $start + 7 days - 1 second
+	return compact( 'start', 'end' );
+}
+
+/**
+ * Unserialize value only if it was serialized.
+ *
+ * @since 2.0.0
+ *
+ * @param string $original Maybe unserialized original, if is needed.
+ * @return mixed Unserialized data can be any type.
+ */
+function maybe_unserialize( $original ) {
+	if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
+		return @unserialize( $original );
+	return $original;
+}
+
+/**
+ * Check value to find if it was serialized.
+ *
+ * If $data is not an string, then returned value will always be false.
+ * Serialized data is always a string.
+ *
+ * @since 2.0.5
+ *
+ * @param mixed $data Value to check to see if was serialized.
+ * @return bool False if not serialized and true if it was.
+ */
+function is_serialized( $data ) {
+	// if it isn't a string, it isn't serialized
+	if ( ! is_string( $data ) )
+		return false;
+	$data = trim( $data );
+ 	if ( 'N;' == $data )
+		return true;
+	$length = strlen( $data );
+	if ( $length < 4 )
+		return false;
+	if ( ':' !== $data[1] )
+		return false;
+	$lastc = $data[$length-1];
+	if ( ';' !== $lastc && '}' !== $lastc )
+		return false;
+	$token = $data[0];
+	switch ( $token ) {
+		case 's' :
+			if ( '"' !== $data[$length-2] )
+				return false;
+		case 'a' :
+		case 'O' :
+			return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data );
+		case 'b' :
+		case 'i' :
+		case 'd' :
+			return (bool) preg_match( "/^{$token}:[0-9.E-]+;\$/", $data );
+	}
+	return false;
+}
+
+/**
+ * Check whether serialized data is of string type.
+ *
+ * @since 2.0.5
+ *
+ * @param mixed $data Serialized data
+ * @return bool False if not a serialized string, true if it is.
+ */
+function is_serialized_string( $data ) {
+	// if it isn't a string, it isn't a serialized string
+	if ( !is_string( $data ) )
+		return false;
+	$data = trim( $data );
+	if ( preg_match( '/^s:[0-9]+:.*;$/s', $data ) ) // this should fetch all serialized strings
+		return true;
+	return false;
+}
+
+/**
+ * Retrieve option value based on name of option.
+ *
+ * If the option does not exist or does not have a value, then the return value
+ * will be false. This is useful to check whether you need to install an option
+ * and is commonly used during installation of plugin options and to test
+ * whether upgrading is required.
+ *
+ * If the option was serialized then it will be unserialized when it is returned.
+ *
+ * @since 1.5.0
+ * @package WordPress
+ * @subpackage Option
+ * @uses apply_filters() Calls 'pre_option_$option' before checking the option.
+ * 	Any value other than false will "short-circuit" the retrieval of the option
+ *	and return the returned value. You should not try to override special options,
+ * 	but you will not be prevented from doing so.
+ * @uses apply_filters() Calls 'option_$option', after checking the option, with
+ * 	the option value.
+ *
+ * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
+ * @return mixed Value set for the option.
+ */
+function get_option( $option, $default = false ) {
+	global $wpdb;
+
+	// Allow plugins to short-circuit options.
+	$pre = apply_filters( 'pre_option_' . $option, false );
+	if ( false !== $pre )
+		return $pre;
+
+	$option = trim($option);
+	if ( empty($option) )
+		return false;
+
+	if ( defined( 'WP_SETUP_CONFIG' ) )
+		return false;
+
+	if ( ! defined( 'WP_INSTALLING' ) ) {
+		// prevent non-existent options from triggering multiple queries
+		$notoptions = wp_cache_get( 'notoptions', 'options' );
+		if ( isset( $notoptions[$option] ) )
+			return $default;
+
+		$alloptions = wp_load_alloptions();
+
+		if ( isset( $alloptions[$option] ) ) {
+			$value = $alloptions[$option];
+		} else {
+			$value = wp_cache_get( $option, 'options' );
+
+			if ( false === $value ) {
+				$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
+
+				// Has to be get_row instead of get_var because of funkiness with 0, false, null values
+				if ( is_object( $row ) ) {
+					$value = $row->option_value;
+					wp_cache_add( $option, $value, 'options' );
+				} else { // option does not exist, so we must cache its non-existence
+					$notoptions[$option] = true;
+					wp_cache_set( 'notoptions', $notoptions, 'options' );
+					return $default;
+				}
+			}
+		}
+	} else {
+		$suppress = $wpdb->suppress_errors();
+		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
+		$wpdb->suppress_errors( $suppress );
+		if ( is_object( $row ) )
+			$value = $row->option_value;
+		else
+			return $default;
+	}
+
+	// If home is not set use siteurl.
+	if ( 'home' == $option && '' == $value )
+		return get_option( 'siteurl' );
+
+	if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
+		$value = untrailingslashit( $value );
+
+	return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
+}
+
+/**
+ * Protect WordPress special option from being modified.
+ *
+ * Will die if $option is in protected list. Protected options are 'alloptions'
+ * and 'notoptions' options.
+ *
+ * @since 2.2.0
+ * @package WordPress
+ * @subpackage Option
+ *
+ * @param string $option Option name.
+ */
+function wp_protect_special_option( $option ) {
+	$protected = array( 'alloptions', 'notoptions' );
+	if ( in_array( $option, $protected ) )
+		wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) );
+}
+
+/**
+ * Print option value after sanitizing for forms.
+ *
+ * @uses attr Sanitizes value.
+ * @since 1.5.0
+ * @package WordPress
+ * @subpackage Option
+ *
+ * @param string $option Option name.
+ */
+function form_option( $option ) {
+	echo esc_attr( get_option( $option ) );
+}
+
+/**
+ * Loads and caches all autoloaded options, if available or all options.
+ *
+ * @since 2.2.0
+ * @package WordPress
+ * @subpackage Option
+ *
+ * @return array List of all options.
+ */
+function wp_load_alloptions() {
+	global $wpdb;
+
+	if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
+		$alloptions = wp_cache_get( 'alloptions', 'options' );
+	else
+		$alloptions = false;
+
+	if ( !$alloptions ) {
+		$suppress = $wpdb->suppress_errors();
+		if ( !$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) )
+			$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
+		$wpdb->suppress_errors($suppress);
+		$alloptions = array();
+		foreach ( (array) $alloptions_db as $o ) {
+			$alloptions[$o->option_name] = $o->option_value;
+		}
+		if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
+			wp_cache_add( 'alloptions', $alloptions, 'options' );
+	}
+
+	return $alloptions;
+}
+
+/**
+ * Loads and caches certain often requested site options if is_multisite() and a peristent cache is not being used.
+ *
+ * @since 3.0.0
+ * @package WordPress
+ * @subpackage Option
+ *
+ * @param int $site_id Optional site ID for which to query the options. Defaults to the current site.
+ */
+function wp_load_core_site_options( $site_id = null ) {
+	global $wpdb, $_wp_using_ext_object_cache;
+
+	if ( !is_multisite() || $_wp_using_ext_object_cache || defined( 'WP_INSTALLING' ) )
+		return;
+
+	if ( empty($site_id) )
+		$site_id = $wpdb->siteid;
+
+	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' );
+
+	$core_options_in = "'" . implode("', '", $core_options) . "'";
+	$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
+
+	foreach ( $options as $option ) {
+		$key = $option->meta_key;
+		$cache_key = "{$site_id}:$key";
+		$option->meta_value = maybe_unserialize( $option->meta_value );
+
+		wp_cache_set( $cache_key, $option->meta_value, 'site-options' );
+	}
+}
+
+/**
+ * Update the value of an option that was already added.
+ *
+ * You do not need to serialize values. If the value needs to be serialized, then
+ * it will be serialized before it is inserted into the database. Remember,
+ * resources can not be serialized or added as an option.
+ *
+ * If the option does not exist, then the option will be added with the option
+ * value, but you will not be able to set whether it is autoloaded. If you want
+ * to set whether an option is autoloaded, then you need to use the add_option().
+ *
+ * @since 1.0.0
+ * @package WordPress
+ * @subpackage Option
+ *
+ * @uses apply_filters() Calls 'pre_update_option_$option' hook to allow overwriting the
+ * 	option value to be stored.
+ * @uses do_action() Calls 'update_option' hook before updating the option.
+ * @uses do_action() Calls 'update_option_$option' and 'updated_option' hooks on success.
+ *
+ * @param string $option Option name. Expected to not be SQL-escaped.
+ * @param mixed $newvalue Option value. Expected to not be SQL-escaped.
+ * @return bool False if value was not updated and true if value was updated.
+ */
+function update_option( $option, $newvalue ) {
+	global $wpdb;
+
+	$option = trim($option);
+	if ( empty($option) )
+		return false;
+
+	wp_protect_special_option( $option );
+
+	if ( is_object($newvalue) )
+		$newvalue = wp_clone($newvalue);
+
+	$newvalue = sanitize_option( $option, $newvalue );
+	$oldvalue = get_option( $option );
+	$newvalue = apply_filters( 'pre_update_option_' . $option, $newvalue, $oldvalue );
+
+	// If the new and old values are the same, no need to update.
+	if ( $newvalue === $oldvalue )
+		return false;
+
+	if ( false === $oldvalue )
+		return add_option( $option, $newvalue );
+
+	$notoptions = wp_cache_get( 'notoptions', 'options' );
+	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
+		unset( $notoptions[$option] );
+		wp_cache_set( 'notoptions', $notoptions, 'options' );
+	}
+
+	$_newvalue = $newvalue;
+	$newvalue = maybe_serialize( $newvalue );
+
+	do_action( 'update_option', $option, $oldvalue, $_newvalue );
+	if ( ! defined( 'WP_INSTALLING' ) ) {
+		$alloptions = wp_load_alloptions();
+		if ( isset( $alloptions[$option] ) ) {
+			$alloptions[$option] = $_newvalue;
+			wp_cache_set( 'alloptions', $alloptions, 'options' );
+		} else {
+			wp_cache_set( $option, $_newvalue, 'options' );
+		}
+	}
+
+	$result = $wpdb->update( $wpdb->options, array( 'option_value' => $newvalue ), array( 'option_name' => $option ) );
+
+	if ( $result ) {
+		do_action( "update_option_{$option}", $oldvalue, $_newvalue );
+		do_action( 'updated_option', $option, $oldvalue, $_newvalue );
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Add a new option.
+ *
+ * You do not need to serialize values. If the value needs to be serialized, then
+ * it will be serialized before it is inserted into the database. Remember,
+ * resources can not be serialized or added as an option.
+ *
+ * You can create options without values and then add values later. Does not
+ * check whether the option has already been added, but does check that you
+ * aren't adding a protected WordPress option. Care should be taken to not name
+ * options the same as the ones which are protected and to not add options
+ * that were already added.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 1.0.0
+ *
+ * @uses do_action() Calls 'add_option' hook before adding the option.
+ * @uses do_action() Calls 'add_option_$option' and 'added_option' hooks on success.
+ *
+ * @param string $option Name of option to add. Expected to not be SQL-escaped.
+ * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.
+ * @param mixed $deprecated Optional. Description. Not used anymore.
+ * @param bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up.
+ * @return null returns when finished.
+ */
+function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
+	global $wpdb;
+
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.3' );
+
+	$option = trim($option);
+	if ( empty($option) )
+		return false;
+
+	wp_protect_special_option( $option );
+
+	if ( is_object($value) )
+		$value = wp_clone($value);
+
+	$value = sanitize_option( $option, $value );
+
+	// Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
+	$notoptions = wp_cache_get( 'notoptions', 'options' );
+	if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
+		if ( false !== get_option( $option ) )
+			return;
+
+	$_value = $value;
+	$value = maybe_serialize( $value );
+	$autoload = ( 'no' === $autoload ) ? 'no' : 'yes';
+	do_action( 'add_option', $option, $_value );
+	if ( ! defined( 'WP_INSTALLING' ) ) {
+		if ( 'yes' == $autoload ) {
+			$alloptions = wp_load_alloptions();
+			$alloptions[$option] = $value;
+			wp_cache_set( 'alloptions', $alloptions, 'options' );
+		} else {
+			wp_cache_set( $option, $value, 'options' );
+		}
+	}
+
+	// This option exists now
+	$notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh
+	if ( is_array( $notoptions ) && isset( $notoptions[$option] ) ) {
+		unset( $notoptions[$option] );
+		wp_cache_set( 'notoptions', $notoptions, 'options' );
+	}
+
+	$result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $value, $autoload ) );
+
+	if ( $result ) {
+		do_action( "add_option_{$option}", $option, $_value );
+		do_action( 'added_option', $option, $_value );
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Removes option by name. Prevents removal of protected WordPress options.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 1.2.0
+ *
+ * @uses do_action() Calls 'delete_option' hook before option is deleted.
+ * @uses do_action() Calls 'deleted_option' and 'delete_option_$option' hooks on success.
+ *
+ * @param string $option Name of option to remove. Expected to not be SQL-escaped.
+ * @return bool True, if option is successfully deleted. False on failure.
+ */
+function delete_option( $option ) {
+	global $wpdb;
+
+	wp_protect_special_option( $option );
+
+	// Get the ID, if no ID then return
+	$row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) );
+	if ( is_null( $row ) )
+		return false;
+	do_action( 'delete_option', $option );
+	$result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = %s", $option) );
+	if ( ! defined( 'WP_INSTALLING' ) ) {
+		if ( 'yes' == $row->autoload ) {
+			$alloptions = wp_load_alloptions();
+			if ( is_array( $alloptions ) && isset( $alloptions[$option] ) ) {
+				unset( $alloptions[$option] );
+				wp_cache_set( 'alloptions', $alloptions, 'options' );
+			}
+		} else {
+			wp_cache_delete( $option, 'options' );
+		}
+	}
+	if ( $result ) {
+		do_action( "delete_option_$option", $option );
+		do_action( 'deleted_option', $option );
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Delete a transient
+ *
+ * @since 2.8.0
+ * @package WordPress
+ * @subpackage Transient
+ *
+ * @uses do_action() Calls 'delete_transient_$transient' hook before transient is deleted.
+ * @uses do_action() Calls 'deleted_transient' hook on success.
+ *
+ * @param string $transient Transient name. Expected to not be SQL-escaped.
+ * @return bool true if successful, false otherwise
+ */
+function delete_transient( $transient ) {
+	global $_wp_using_ext_object_cache;
+
+	do_action( 'delete_transient_' . $transient, $transient );
+
+	if ( $_wp_using_ext_object_cache ) {
+		$result = wp_cache_delete( $transient, 'transient' );
+	} else {
+		$option_timeout = '_transient_timeout_' . $transient;
+		$option = '_transient_' . $transient;
+		$result = delete_option( $option );
+		if ( $result )
+			delete_option( $option_timeout );
+	}
+
+	if ( $result )
+		do_action( 'deleted_transient', $transient );
+	return $result;
+}
+
+/**
+ * Get the value of a transient
+ *
+ * If the transient does not exist or does not have a value, then the return value
+ * will be false.
+ *
+ * @uses apply_filters() Calls 'pre_transient_$transient' hook before checking the transient.
+ * 	Any value other than false will "short-circuit" the retrieval of the transient
+ *	and return the returned value.
+ * @uses apply_filters() Calls 'transient_$option' hook, after checking the transient, with
+ * 	the transient value.
+ *
+ * @since 2.8.0
+ * @package WordPress
+ * @subpackage Transient
+ *
+ * @param string $transient Transient name. Expected to not be SQL-escaped
+ * @return mixed Value of transient
+ */
+function get_transient( $transient ) {
+	global $_wp_using_ext_object_cache;
+
+	$pre = apply_filters( 'pre_transient_' . $transient, false );
+	if ( false !== $pre )
+		return $pre;
+
+	if ( $_wp_using_ext_object_cache ) {
+		$value = wp_cache_get( $transient, 'transient' );
+	} else {
+		$transient_option = '_transient_' . $transient;
+		if ( ! defined( 'WP_INSTALLING' ) ) {
+			// If option is not in alloptions, it is not autoloaded and thus has a timeout
+			$alloptions = wp_load_alloptions();
+			if ( !isset( $alloptions[$transient_option] ) ) {
+				$transient_timeout = '_transient_timeout_' . $transient;
+				if ( get_option( $transient_timeout ) < time() ) {
+					delete_option( $transient_option  );
+					delete_option( $transient_timeout );
+					return false;
+				}
+			}
+		}
+
+		$value = get_option( $transient_option );
+	}
+
+	return apply_filters( 'transient_' . $transient, $value );
+}
+
+/**
+ * Set/update the value of a transient
+ *
+ * You do not need to serialize values. If the value needs to be serialized, then
+ * it will be serialized before it is set.
+ *
+ * @since 2.8.0
+ * @package WordPress
+ * @subpackage Transient
+ *
+ * @uses apply_filters() Calls 'pre_set_transient_$transient' hook to allow overwriting the
+ * 	transient value to be stored.
+ * @uses do_action() Calls 'set_transient_$transient' and 'setted_transient' hooks on success.
+ *
+ * @param string $transient Transient name. Expected to not be SQL-escaped.
+ * @param mixed $value Transient value. Expected to not be SQL-escaped.
+ * @param int $expiration Time until expiration in seconds, default 0
+ * @return bool False if value was not set and true if value was set.
+ */
+function set_transient( $transient, $value, $expiration = 0 ) {
+	global $_wp_using_ext_object_cache;
+
+	$value = apply_filters( 'pre_set_transient_' . $transient, $value );
+
+	if ( $_wp_using_ext_object_cache ) {
+		$result = wp_cache_set( $transient, $value, 'transient', $expiration );
+	} else {
+		$transient_timeout = '_transient_timeout_' . $transient;
+		$transient = '_transient_' . $transient;
+		if ( false === get_option( $transient ) ) {
+			$autoload = 'yes';
+			if ( $expiration ) {
+				$autoload = 'no';
+				add_option( $transient_timeout, time() + $expiration, '', 'no' );
+			}
+			$result = add_option( $transient, $value, '', $autoload );
+		} else {
+			if ( $expiration )
+				update_option( $transient_timeout, time() + $expiration );
+			$result = update_option( $transient, $value );
+		}
+	}
+	if ( $result ) {
+		do_action( 'set_transient_' . $transient );
+		do_action( 'setted_transient', $transient );
+	}
+	return $result;
+}
+
+/**
+ * Saves and restores user interface settings stored in a cookie.
+ *
+ * Checks if the current user-settings cookie is updated and stores it. When no
+ * cookie exists (different browser used), adds the last saved cookie restoring
+ * the settings.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ */
+function wp_user_settings() {
+
+	if ( ! is_admin() )
+		return;
+
+	if ( defined('DOING_AJAX') )
+		return;
+
+	if ( ! $user = wp_get_current_user() )
+		return;
+
+	$settings = get_user_option( 'user-settings', $user->ID );
+
+	if ( isset( $_COOKIE['wp-settings-' . $user->ID] ) ) {
+		$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] );
+
+		if ( ! empty( $cookie ) && strpos( $cookie, '=' ) ) {
+			if ( $cookie == $settings )
+				return;
+
+			$last_time = (int) get_user_option( 'user-settings-time', $user->ID );
+			$saved = isset( $_COOKIE['wp-settings-time-' . $user->ID]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user->ID] ) : 0;
+
+			if ( $saved > $last_time ) {
+				update_user_option( $user->ID, 'user-settings', $cookie, false );
+				update_user_option( $user->ID, 'user-settings-time', time() - 5, false );
+				return;
+			}
+		}
+	}
+
+	setcookie( 'wp-settings-' . $user->ID, $settings, time() + 31536000, SITECOOKIEPATH );
+	setcookie( 'wp-settings-time-' . $user->ID, time(), time() + 31536000, SITECOOKIEPATH );
+	$_COOKIE['wp-settings-' . $user->ID] = $settings;
+}
+
+/**
+ * Retrieve user interface setting value based on setting name.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ *
+ * @param string $name The name of the setting.
+ * @param string $default Optional default value to return when $name is not set.
+ * @return mixed the last saved user setting or the default value/false if it doesn't exist.
+ */
+function get_user_setting( $name, $default = false ) {
+
+	$all = get_all_user_settings();
+
+	return isset($all[$name]) ? $all[$name] : $default;
+}
+
+/**
+ * Add or update user interface setting.
+ *
+ * Both $name and $value can contain only ASCII letters, numbers and underscores.
+ * This function has to be used before any output has started as it calls setcookie().
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
+ *
+ * @param string $name The name of the setting.
+ * @param string $value The value for the setting.
+ * @return bool true if set successfully/false if not.
+ */
+function set_user_setting( $name, $value ) {
+
+	if ( headers_sent() )
+		return false;
+
+	$all = get_all_user_settings();
+	$name = preg_replace( '/[^A-Za-z0-9_]+/', '', $name );
+
+	if ( empty($name) )
+		return false;
+
+	$all[$name] = $value;
+
+	return wp_set_all_user_settings($all);
+}
+
+/**
+ * Delete user interface settings.
+ *
+ * Deleting settings would reset them to the defaults.
+ * This function has to be used before any output has started as it calls setcookie().
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ *
+ * @param mixed $names The name or array of names of the setting to be deleted.
+ * @return bool true if deleted successfully/false if not.
+ */
+function delete_user_setting( $names ) {
+
+	if ( headers_sent() )
+		return false;
+
+	$all = get_all_user_settings();
+	$names = (array) $names;
+
+	foreach ( $names as $name ) {
+		if ( isset($all[$name]) ) {
+			unset($all[$name]);
+			$deleted = true;
+		}
+	}
+
+	if ( isset($deleted) )
+		return wp_set_all_user_settings($all);
+
+	return false;
+}
+
+/**
+ * Retrieve all user interface settings.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ *
+ * @return array the last saved user settings or empty array.
+ */
+function get_all_user_settings() {
+	global $_updated_user_settings;
+
+	if ( ! $user = wp_get_current_user() )
+		return array();
+
+	if ( isset($_updated_user_settings) && is_array($_updated_user_settings) )
+		return $_updated_user_settings;
+
+	$all = array();
+	if ( isset($_COOKIE['wp-settings-' . $user->ID]) ) {
+		$cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user->ID] );
+
+		if ( $cookie && strpos($cookie, '=') ) // the '=' cannot be 1st char
+			parse_str($cookie, $all);
+
+	} else {
+		$option = get_user_option('user-settings', $user->ID);
+		if ( $option && is_string($option) )
+			parse_str( $option, $all );
+	}
+
+	return $all;
+}
+
+/**
+ * Private. Set all user interface settings.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
+ *
+ * @param unknown $all
+ * @return bool
+ */
+function wp_set_all_user_settings($all) {
+	global $_updated_user_settings;
+
+	if ( ! $user = wp_get_current_user() )
+		return false;
+
+	$_updated_user_settings = $all;
+	$settings = '';
+	foreach ( $all as $k => $v ) {
+		$v = preg_replace( '/[^A-Za-z0-9_]+/', '', $v );
+		$settings .= $k . '=' . $v . '&';
+	}
+
+	$settings = rtrim($settings, '&');
+
+	update_user_option( $user->ID, 'user-settings', $settings, false );
+	update_user_option( $user->ID, 'user-settings-time', time(), false );
+
+	return true;
+}
+
+/**
+ * Delete the user settings of the current user.
+ *
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.7.0
+ */
+function delete_all_user_settings() {
+	if ( ! $user = wp_get_current_user() )
+		return;
+
+	update_user_option( $user->ID, 'user-settings', '', false );
+	setcookie('wp-settings-' . $user->ID, ' ', time() - 31536000, SITECOOKIEPATH);
+}
+
+/**
+ * Serialize data, if needed.
+ *
+ * @since 2.0.5
+ *
+ * @param mixed $data Data that might be serialized.
+ * @return mixed A scalar data
+ */
+function maybe_serialize( $data ) {
+	if ( is_array( $data ) || is_object( $data ) )
+		return serialize( $data );
+
+	if ( is_serialized( $data ) )
+		return serialize( $data );
+
+	return $data;
+}
+
+/**
+ * Retrieve post title from XMLRPC XML.
+ *
+ * If the title element is not part of the XML, then the default post title from
+ * the $post_default_title will be used instead.
+ *
+ * @package WordPress
+ * @subpackage XMLRPC
+ * @since 0.71
+ *
+ * @global string $post_default_title Default XMLRPC post title.
+ *
+ * @param string $content XMLRPC XML Request content
+ * @return string Post title
+ */
+function xmlrpc_getposttitle( $content ) {
+	global $post_default_title;
+	if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) {
+		$post_title = $matchtitle[1];
+	} else {
+		$post_title = $post_default_title;
+	}
+	return $post_title;
+}
+
+/**
+ * Retrieve the post category or categories from XMLRPC XML.
+ *
+ * If the category element is not found, then the default post category will be
+ * used. The return type then would be what $post_default_category. If the
+ * category is found, then it will always be an array.
+ *
+ * @package WordPress
+ * @subpackage XMLRPC
+ * @since 0.71
+ *
+ * @global string $post_default_category Default XMLRPC post category.
+ *
+ * @param string $content XMLRPC XML Request content
+ * @return string|array List of categories or category name.
+ */
+function xmlrpc_getpostcategory( $content ) {
+	global $post_default_category;
+	if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
+		$post_category = trim( $matchcat[1], ',' );
+		$post_category = explode( ',', $post_category );
+	} else {
+		$post_category = $post_default_category;
+	}
+	return $post_category;
+}
+
+/**
+ * XMLRPC XML content without title and category elements.
+ *
+ * @package WordPress
+ * @subpackage XMLRPC
+ * @since 0.71
+ *
+ * @param string $content XMLRPC XML Request content
+ * @return string XMLRPC XML Request content without title and category elements.
+ */
+function xmlrpc_removepostdata( $content ) {
+	$content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content );
+	$content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content );
+	$content = trim( $content );
+	return $content;
+}
+
+/**
+ * Open the file handle for debugging.
+ *
+ * This function is used for XMLRPC feature, but it is general purpose enough
+ * to be used in anywhere.
+ *
+ * @see fopen() for mode options.
+ * @package WordPress
+ * @subpackage Debug
+ * @since 0.71
+ * @uses $debug Used for whether debugging is enabled.
+ *
+ * @param string $filename File path to debug file.
+ * @param string $mode Same as fopen() mode parameter.
+ * @return bool|resource File handle. False on failure.
+ */
+function debug_fopen( $filename, $mode ) {
+	global $debug;
+	if ( 1 == $debug ) {
+		$fp = fopen( $filename, $mode );
+		return $fp;
+	} else {
+		return false;
+	}
+}
+
+/**
+ * Write contents to the file used for debugging.
+ *
+ * Technically, this can be used to write to any file handle when the global
+ * $debug is set to 1 or true.
+ *
+ * @package WordPress
+ * @subpackage Debug
+ * @since 0.71
+ * @uses $debug Used for whether debugging is enabled.
+ *
+ * @param resource $fp File handle for debugging file.
+ * @param string $string Content to write to debug file.
+ */
+function debug_fwrite( $fp, $string ) {
+	global $debug;
+	if ( 1 == $debug )
+		fwrite( $fp, $string );
+}
+
+/**
+ * Close the debugging file handle.
+ *
+ * Technically, this can be used to close any file handle when the global $debug
+ * is set to 1 or true.
+ *
+ * @package WordPress
+ * @subpackage Debug
+ * @since 0.71
+ * @uses $debug Used for whether debugging is enabled.
+ *
+ * @param resource $fp Debug File handle.
+ */
+function debug_fclose( $fp ) {
+	global $debug;
+	if ( 1 == $debug )
+		fclose( $fp );
+}
+
+/**
+ * Check content for video and audio links to add as enclosures.
+ *
+ * Will not add enclosures that have already been added and will
+ * remove enclosures that are no longer in the post. This is called as
+ * pingbacks and trackbacks.
+ *
+ * @package WordPress
+ * @since 1.5.0
+ *
+ * @uses $wpdb
+ *
+ * @param string $content Post Content
+ * @param int $post_ID Post ID
+ */
+function do_enclose( $content, $post_ID ) {
+	global $wpdb;
+
+	//TODO: Tidy this ghetto code up and make the debug code optional
+	include_once( ABSPATH . WPINC . '/class-IXR.php' );
+
+	$log = debug_fopen( ABSPATH . 'enclosures.log', 'a' );
+	$post_links = array();
+	debug_fwrite( $log, 'BEGIN ' . date( 'YmdHis', time() ) . "\n" );
+
+	$pung = get_enclosed( $post_ID );
+
+	$ltrs = '\w';
+	$gunk = '/#~:.?+=&%@!\-';
+	$punc = '.:?\-';
+	$any = $ltrs . $gunk . $punc;
+
+	preg_match_all( "{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp );
+
+	debug_fwrite( $log, 'Post contents:' );
+	debug_fwrite( $log, $content . "\n" );
+
+	foreach ( $pung as $link_test ) {
+		if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post
+			$mid = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $link_test ) . '%') );
+			do_action( 'delete_postmeta', $mid );
+			$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN(%s)", implode( ',', $mid ) ) );
+			do_action( 'deleted_postmeta', $mid );
+		}
+	}
+
+	foreach ( (array) $post_links_temp[0] as $link_test ) {
+		if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
+			$test = @parse_url( $link_test );
+			if ( false === $test )
+				continue;
+			if ( isset( $test['query'] ) )
+				$post_links[] = $link_test;
+			elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) )
+				$post_links[] = $link_test;
+		}
+	}
+
+	foreach ( (array) $post_links as $url ) {
+		if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $url ) . '%' ) ) ) {
+
+			if ( $headers = wp_get_http_headers( $url) ) {
+				$len = (int) $headers['content-length'];
+				$type = $headers['content-type'];
+				$allowed_types = array( 'video', 'audio' );
+
+				// Check to see if we can figure out the mime type from
+				// the extension
+				$url_parts = @parse_url( $url );
+				if ( false !== $url_parts ) {
+					$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
+					if ( !empty( $extension ) ) {
+						foreach ( get_allowed_mime_types( ) as $exts => $mime ) {
+							if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
+								$type = $mime;
+								break;
+							}
+						}
+					}
+				}
+
+				if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
+					$meta_value = "$url\n$len\n$type\n";
+					$wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) );
+					do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value );
+				}
+			}
+		}
+	}
+}
+
+/**
+ * Perform a HTTP HEAD or GET request.
+ *
+ * If $file_path is a writable filename, this will do a GET request and write
+ * the file to that path.
+ *
+ * @since 2.5.0
+ *
+ * @param string $url URL to fetch.
+ * @param string|bool $file_path Optional. File path to write request to.
+ * @param int $red (private) The number of Redirects followed, Upon 5 being hit, returns false.
+ * @return bool|string False on failure and string of headers if HEAD request.
+ */
+function wp_get_http( $url, $file_path = false, $red = 1 ) {
+	@set_time_limit( 60 );
+
+	if ( $red > 5 )
+		return false;
+
+	$options = array();
+	$options['redirection'] = 5;
+
+	if ( false == $file_path )
+		$options['method'] = 'HEAD';
+	else
+		$options['method'] = 'GET';
+
+	$response = wp_remote_request($url, $options);
+
+	if ( is_wp_error( $response ) )
+		return false;
+
+	$headers = wp_remote_retrieve_headers( $response );
+	$headers['response'] = $response['response']['code'];
+
+	// WP_HTTP no longer follows redirects for HEAD requests.
+	if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
+		return wp_get_http( $headers['location'], $file_path, ++$red );
+	}
+
+	if ( false == $file_path )
+		return $headers;
+
+	// GET request - write it to the supplied filename
+	$out_fp = fopen($file_path, 'w');
+	if ( !$out_fp )
+		return $headers;
+
+	fwrite( $out_fp,  $response['body']);
+	fclose($out_fp);
+	clearstatcache();
+
+	return $headers;
+}
+
+/**
+ * Retrieve HTTP Headers from URL.
+ *
+ * @since 1.5.1
+ *
+ * @param string $url
+ * @param bool $deprecated Not Used.
+ * @return bool|string False on failure, headers on success.
+ */
+function wp_get_http_headers( $url, $deprecated = false ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.7' );
+
+	$response = wp_remote_head( $url );
+
+	if ( is_wp_error( $response ) )
+		return false;
+
+	return wp_remote_retrieve_headers( $response );
+}
+
+/**
+ * Whether today is a new day.
+ *
+ * @since 0.71
+ * @uses $day Today
+ * @uses $previousday Previous day
+ *
+ * @return int 1 when new day, 0 if not a new day.
+ */
+function is_new_day() {
+	global $currentday, $previousday;
+	if ( $currentday != $previousday )
+		return 1;
+	else
+		return 0;
+}
+
+/**
+ * Build URL query based on an associative and, or indexed array.
+ *
+ * This is a convenient function for easily building url queries. It sets the
+ * separator to '&' and uses _http_build_query() function.
+ *
+ * @see _http_build_query() Used to build the query
+ * @link http://us2.php.net/manual/en/function.http-build-query.php more on what
+ *		http_build_query() does.
+ *
+ * @since 2.3.0
+ *
+ * @param array $data URL-encode key/value pairs.
+ * @return string URL encoded string
+ */
+function build_query( $data ) {
+	return _http_build_query( $data, null, '&', '', false );
+}
+
+/**
+ * Retrieve a modified URL query string.
+ *
+ * You can rebuild the URL and append a new query variable to the URL query by
+ * using this function. You can also retrieve the full URL with query data.
+ *
+ * Adding a single key & value or an associative array. Setting a key value to
+ * emptystring removes the key. Omitting oldquery_or_uri uses the $_SERVER
+ * value.
+ *
+ * @since 1.5.0
+ *
+ * @param mixed $param1 Either newkey or an associative_array
+ * @param mixed $param2 Either newvalue or oldquery or uri
+ * @param mixed $param3 Optional. Old query or uri
+ * @return string New URL query string.
+ */
+function add_query_arg() {
+	$ret = '';
+	if ( is_array( func_get_arg(0) ) ) {
+		if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) )
+			$uri = $_SERVER['REQUEST_URI'];
+		else
+			$uri = @func_get_arg( 1 );
+	} else {
+		if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) )
+			$uri = $_SERVER['REQUEST_URI'];
+		else
+			$uri = @func_get_arg( 2 );
+	}
+
+	if ( $frag = strstr( $uri, '#' ) )
+		$uri = substr( $uri, 0, -strlen( $frag ) );
+	else
+		$frag = '';
+
+	if ( preg_match( '|^https?://|i', $uri, $matches ) ) {
+		$protocol = $matches[0];
+		$uri = substr( $uri, strlen( $protocol ) );
+	} else {
+		$protocol = '';
+	}
+
+	if ( strpos( $uri, '?' ) !== false ) {
+		$parts = explode( '?', $uri, 2 );
+		if ( 1 == count( $parts ) ) {
+			$base = '?';
+			$query = $parts[0];
+		} else {
+			$base = $parts[0] . '?';
+			$query = $parts[1];
+		}
+	} elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) {
+		$base = $uri . '?';
+		$query = '';
+	} else {
+		$base = '';
+		$query = $uri;
+	}
+
+	wp_parse_str( $query, $qs );
+	$qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string
+	if ( is_array( func_get_arg( 0 ) ) ) {
+		$kayvees = func_get_arg( 0 );
+		$qs = array_merge( $qs, $kayvees );
+	} else {
+		$qs[func_get_arg( 0 )] = func_get_arg( 1 );
+	}
+
+	foreach ( (array) $qs as $k => $v ) {
+		if ( $v === false )
+			unset( $qs[$k] );
+	}
+
+	$ret = build_query( $qs );
+	$ret = trim( $ret, '?' );
+	$ret = preg_replace( '#=(&|$)#', '$1', $ret );
+	$ret = $protocol . $base . $ret . $frag;
+	$ret = rtrim( $ret, '?' );
+	return $ret;
+}
+
+/**
+ * Removes an item or list from the query string.
+ *
+ * @since 1.5.0
+ *
+ * @param string|array $key Query key or keys to remove.
+ * @param bool $query When false uses the $_SERVER value.
+ * @return string New URL query string.
+ */
+function remove_query_arg( $key, $query=false ) {
+	if ( is_array( $key ) ) { // removing multiple keys
+		foreach ( $key as $k )
+			$query = add_query_arg( $k, false, $query );
+		return $query;
+	}
+	return add_query_arg( $key, false, $query );
+}
+
+/**
+ * Walks the array while sanitizing the contents.
+ *
+ * @since 0.71
+ *
+ * @param array $array Array to used to walk while sanitizing contents.
+ * @return array Sanitized $array.
+ */
+function add_magic_quotes( $array ) {
+	foreach ( (array) $array as $k => $v ) {
+		if ( is_array( $v ) ) {
+			$array[$k] = add_magic_quotes( $v );
+		} else {
+			$array[$k] = addslashes( $v );
+		}
+	}
+	return $array;
+}
+
+/**
+ * HTTP request for URI to retrieve content.
+ *
+ * @since 1.5.1
+ * @uses wp_remote_get()
+ *
+ * @param string $uri URI/URL of web page to retrieve.
+ * @return bool|string HTTP content. False on failure.
+ */
+function wp_remote_fopen( $uri ) {
+	$parsed_url = @parse_url( $uri );
+
+	if ( !$parsed_url || !is_array( $parsed_url ) )
+		return false;
+
+	$options = array();
+	$options['timeout'] = 10;
+
+	$response = wp_remote_get( $uri, $options );
+
+	if ( is_wp_error( $response ) )
+		return false;
+
+	return $response['body'];
+}
+
+/**
+ * Set up the WordPress query.
+ *
+ * @since 2.0.0
+ *
+ * @param string $query_vars Default WP_Query arguments.
+ */
+function wp( $query_vars = '' ) {
+	global $wp, $wp_query, $wp_the_query;
+	$wp->main( $query_vars );
+
+	if ( !isset($wp_the_query) )
+		$wp_the_query = $wp_query;
+}
+
+/**
+ * Retrieve the description for the HTTP status.
+ *
+ * @since 2.3.0
+ *
+ * @param int $code HTTP status code.
+ * @return string Empty string if not found, or description if found.
+ */
+function get_status_header_desc( $code ) {
+	global $wp_header_to_desc;
+
+	$code = absint( $code );
+
+	if ( !isset( $wp_header_to_desc ) ) {
+		$wp_header_to_desc = array(
+			100 => 'Continue',
+			101 => 'Switching Protocols',
+			102 => 'Processing',
+
+			200 => 'OK',
+			201 => 'Created',
+			202 => 'Accepted',
+			203 => 'Non-Authoritative Information',
+			204 => 'No Content',
+			205 => 'Reset Content',
+			206 => 'Partial Content',
+			207 => 'Multi-Status',
+			226 => 'IM Used',
+
+			300 => 'Multiple Choices',
+			301 => 'Moved Permanently',
+			302 => 'Found',
+			303 => 'See Other',
+			304 => 'Not Modified',
+			305 => 'Use Proxy',
+			306 => 'Reserved',
+			307 => 'Temporary Redirect',
+
+			400 => 'Bad Request',
+			401 => 'Unauthorized',
+			402 => 'Payment Required',
+			403 => 'Forbidden',
+			404 => 'Not Found',
+			405 => 'Method Not Allowed',
+			406 => 'Not Acceptable',
+			407 => 'Proxy Authentication Required',
+			408 => 'Request Timeout',
+			409 => 'Conflict',
+			410 => 'Gone',
+			411 => 'Length Required',
+			412 => 'Precondition Failed',
+			413 => 'Request Entity Too Large',
+			414 => 'Request-URI Too Long',
+			415 => 'Unsupported Media Type',
+			416 => 'Requested Range Not Satisfiable',
+			417 => 'Expectation Failed',
+			422 => 'Unprocessable Entity',
+			423 => 'Locked',
+			424 => 'Failed Dependency',
+			426 => 'Upgrade Required',
+
+			500 => 'Internal Server Error',
+			501 => 'Not Implemented',
+			502 => 'Bad Gateway',
+			503 => 'Service Unavailable',
+			504 => 'Gateway Timeout',
+			505 => 'HTTP Version Not Supported',
+			506 => 'Variant Also Negotiates',
+			507 => 'Insufficient Storage',
+			510 => 'Not Extended'
+		);
+	}
+
+	if ( isset( $wp_header_to_desc[$code] ) )
+		return $wp_header_to_desc[$code];
+	else
+		return '';
+}
+
+/**
+ * Set HTTP status header.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'status_header' on status header string, HTTP
+ *		HTTP code, HTTP code description, and protocol string as separate
+ *		parameters.
+ *
+ * @param int $header HTTP status code
+ * @return unknown
+ */
+function status_header( $header ) {
+	$text = get_status_header_desc( $header );
+
+	if ( empty( $text ) )
+		return false;
+
+	$protocol = $_SERVER["SERVER_PROTOCOL"];
+	if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
+		$protocol = 'HTTP/1.0';
+	$status_header = "$protocol $header $text";
+	if ( function_exists( 'apply_filters' ) )
+		$status_header = apply_filters( 'status_header', $status_header, $header, $text, $protocol );
+
+	return @header( $status_header, true, $header );
+}
+
+/**
+ * Gets the header information to prevent caching.
+ *
+ * The several different headers cover the different ways cache prevention is handled
+ * by different browsers
+ *
+ * @since 2.8.0
+ *
+ * @uses apply_filters()
+ * @return array The associative array of header names and field values.
+ */
+function wp_get_nocache_headers() {
+	$headers = array(
+		'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
+		'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT',
+		'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
+		'Pragma' => 'no-cache',
+	);
+
+	if ( function_exists('apply_filters') ) {
+		$headers = (array) apply_filters('nocache_headers', $headers);
+	}
+	return $headers;
+}
+
+/**
+ * Sets the headers to prevent caching for the different browsers.
+ *
+ * Different browsers support different nocache headers, so several headers must
+ * be sent so that all of them get the point that no caching should occur.
+ *
+ * @since 2.0.0
+ * @uses wp_get_nocache_headers()
+ */
+function nocache_headers() {
+	$headers = wp_get_nocache_headers();
+	foreach( $headers as $name => $field_value )
+		@header("{$name}: {$field_value}");
+}
+
+/**
+ * Set the headers for caching for 10 days with JavaScript content type.
+ *
+ * @since 2.1.0
+ */
+function cache_javascript_headers() {
+	$expiresOffset = 864000; // 10 days
+	header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) );
+	header( "Vary: Accept-Encoding" ); // Handle proxies
+	header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
+}
+
+/**
+ * Retrieve the number of database queries during the WordPress execution.
+ *
+ * @since 2.0.0
+ *
+ * @return int Number of database queries
+ */
+function get_num_queries() {
+	global $wpdb;
+	return $wpdb->num_queries;
+}
+
+/**
+ * Whether input is yes or no. Must be 'y' to be true.
+ *
+ * @since 1.0.0
+ *
+ * @param string $yn Character string containing either 'y' or 'n'
+ * @return bool True if yes, false on anything else
+ */
+function bool_from_yn( $yn ) {
+	return ( strtolower( $yn ) == 'y' );
+}
+
+/**
+ * Loads the feed template from the use of an action hook.
+ *
+ * If the feed action does not have a hook, then the function will die with a
+ * message telling the visitor that the feed is not valid.
+ *
+ * It is better to only have one hook for each feed.
+ *
+ * @since 2.1.0
+ * @uses $wp_query Used to tell if the use a comment feed.
+ * @uses do_action() Calls 'do_feed_$feed' hook, if a hook exists for the feed.
+ */
+function do_feed() {
+	global $wp_query;
+
+	$feed = get_query_var( 'feed' );
+
+	// Remove the pad, if present.
+	$feed = preg_replace( '/^_+/', '', $feed );
+
+	if ( $feed == '' || $feed == 'feed' )
+		$feed = get_default_feed();
+
+	$hook = 'do_feed_' . $feed;
+	if ( !has_action($hook) ) {
+		$message = sprintf( __( 'ERROR: %s is not a valid feed template.' ), esc_html($feed));
+		wp_die( $message, '', array( 'response' => 404 ) );
+	}
+
+	do_action( $hook, $wp_query->is_comment_feed );
+}
+
+/**
+ * Load the RDF RSS 0.91 Feed template.
+ *
+ * @since 2.1.0
+ */
+function do_feed_rdf() {
+	load_template( ABSPATH . WPINC . '/feed-rdf.php' );
+}
+
+/**
+ * Load the RSS 1.0 Feed Template
+ *
+ * @since 2.1.0
+ */
+function do_feed_rss() {
+	load_template( ABSPATH . WPINC . '/feed-rss.php' );
+}
+
+/**
+ * Load either the RSS2 comment feed or the RSS2 posts feed.
+ *
+ * @since 2.1.0
+ *
+ * @param bool $for_comments True for the comment feed, false for normal feed.
+ */
+function do_feed_rss2( $for_comments ) {
+	if ( $for_comments )
+		load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
+	else
+		load_template( ABSPATH . WPINC . '/feed-rss2.php' );
+}
+
+/**
+ * Load either Atom comment feed or Atom posts feed.
+ *
+ * @since 2.1.0
+ *
+ * @param bool $for_comments True for the comment feed, false for normal feed.
+ */
+function do_feed_atom( $for_comments ) {
+	if ($for_comments)
+		load_template( ABSPATH . WPINC . '/feed-atom-comments.php');
+	else
+		load_template( ABSPATH . WPINC . '/feed-atom.php' );
+}
+
+/**
+ * Display the robot.txt file content.
+ *
+ * The echo content should be with usage of the permalinks or for creating the
+ * robot.txt file.
+ *
+ * @since 2.1.0
+ * @uses do_action() Calls 'do_robotstxt' hook for displaying robot.txt rules.
+ */
+function do_robots() {
+	header( 'Content-Type: text/plain; charset=utf-8' );
+
+	do_action( 'do_robotstxt' );
+
+	$output = '';
+	$public = get_option( 'blog_public' );
+	if ( '0' ==  $public ) {
+		$output .= "User-agent: *\n";
+		$output .= "Disallow: /\n";
+	} else {
+		$output .= "User-agent: *\n";
+		$output .= "Disallow:\n";
+	}
+
+	echo apply_filters('robots_txt', $output, $public);
+}
+
+/**
+ * Test whether blog is already installed.
+ *
+ * The cache will be checked first. If you have a cache plugin, which saves the
+ * cache values, then this will work. If you use the default WordPress cache,
+ * and the database goes away, then you might have problems.
+ *
+ * Checks for the option siteurl for whether WordPress is installed.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ *
+ * @return bool Whether blog is already installed.
+ */
+function is_blog_installed() {
+	global $wpdb;
+
+	// Check cache first. If options table goes away and we have true cached, oh well.
+	if ( wp_cache_get( 'is_blog_installed' ) )
+		return true;
+
+	$suppress = $wpdb->suppress_errors();
+	if ( ! defined( 'WP_INSTALLING' ) ) {
+		$alloptions = wp_load_alloptions();
+	}
+	// If siteurl is not set to autoload, check it specifically
+	if ( !isset( $alloptions['siteurl'] ) )
+		$installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" );
+	else
+		$installed = $alloptions['siteurl'];
+	$wpdb->suppress_errors( $suppress );
+
+	$installed = !empty( $installed );
+	wp_cache_set( 'is_blog_installed', $installed );
+
+	if ( $installed )
+		return true;
+
+	$suppress = $wpdb->suppress_errors();
+	$tables = $wpdb->get_col('SHOW TABLES');
+	$wpdb->suppress_errors( $suppress );
+
+	$wp_tables = $wpdb->tables();
+	// Loop over the WP tables.  If none exist, then scratch install is allowed.
+	// If one or more exist, suggest table repair since we got here because the options
+	// table could not be accessed.
+	foreach ( $wp_tables as $table ) {
+		// If one of the WP tables exist, then we are in an insane state.
+		if ( in_array( $table, $tables ) ) {
+			// The existence of custom user tables shouldn't suggest an insane state or prevent a clean install.
+			if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table )
+				continue;
+			if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table )
+				continue;
+
+			// If visiting repair.php, return true and let it take over.
+			if ( defined('WP_REPAIRING') )
+				return true;
+			// Die with a DB error.
+			$wpdb->error = sprintf( /*WP_I18N_NO_TABLES*/'One or more database tables are unavailable.  The database may need to be <a href="%s">repaired</a>.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' );
+			dead_db();
+		}
+	}
+
+	wp_cache_set( 'is_blog_installed', false );
+
+	return false;
+}
+
+/**
+ * Retrieve URL with nonce added to URL query.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $actionurl URL to add nonce action
+ * @param string $action Optional. Nonce action name
+ * @return string URL with nonce action added.
+ */
+function wp_nonce_url( $actionurl, $action = -1 ) {
+	$actionurl = str_replace( '&amp;', '&', $actionurl );
+	return esc_html( add_query_arg( '_wpnonce', wp_create_nonce( $action ), $actionurl ) );
+}
+
+/**
+ * Retrieve or display nonce hidden field for forms.
+ *
+ * The nonce field is used to validate that the contents of the form came from
+ * the location on the current site and not somewhere else. The nonce does not
+ * offer absolute protection, but should protect against most cases. It is very
+ * important to use nonce field in forms.
+ *
+ * If you set $echo to true and set $referer to true, then you will need to
+ * retrieve the {@link wp_referer_field() wp referer field}. If you have the
+ * $referer set to true and are echoing the nonce field, it will also echo the
+ * referer field.
+ *
+ * The $action and $name are optional, but if you want to have better security,
+ * it is strongly suggested to set those two parameters. It is easier to just
+ * call the function without any parameters, because validation of the nonce
+ * doesn't require any parameters, but since crackers know what the default is
+ * it won't be difficult for them to find a way around your nonce and cause
+ * damage.
+ *
+ * The input name will be whatever $name value you gave. The input value will be
+ * the nonce creation value.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action Optional. Action name.
+ * @param string $name Optional. Nonce name.
+ * @param bool $referer Optional, default true. Whether to set the referer field for validation.
+ * @param bool $echo Optional, default true. Whether to display or return hidden form field.
+ * @return string Nonce field.
+ */
+function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
+	$name = esc_attr( $name );
+	$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
+	if ( $echo )
+		echo $nonce_field;
+
+	if ( $referer )
+		wp_referer_field( $echo );
+
+	return $nonce_field;
+}
+
+/**
+ * Retrieve or display referer hidden field for forms.
+ *
+ * The referer link is the current Request URI from the server super global. The
+ * input name is '_wp_http_referer', in case you wanted to check manually.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param bool $echo Whether to echo or return the referer field.
+ * @return string Referer field.
+ */
+function wp_referer_field( $echo = true ) {
+	$ref = esc_attr( $_SERVER['REQUEST_URI'] );
+	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
+
+	if ( $echo )
+		echo $referer_field;
+	return $referer_field;
+}
+
+/**
+ * Retrieve or display original referer hidden field for forms.
+ *
+ * The input name is '_wp_original_http_referer' and will be either the same
+ * value of {@link wp_referer_field()}, if that was posted already or it will
+ * be the current page, if it doesn't exist.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param bool $echo Whether to echo the original http referer
+ * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
+ * @return string Original referer field.
+ */
+function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
+	$jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
+	$ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to;
+	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( stripslashes( $ref ) ) . '" />';
+	if ( $echo )
+		echo $orig_referer_field;
+	return $orig_referer_field;
+}
+
+/**
+ * Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @return string|bool False on failure. Referer URL on success.
+ */
+function wp_get_referer() {
+	$ref = '';
+	if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
+		$ref = $_REQUEST['_wp_http_referer'];
+	else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
+		$ref = $_SERVER['HTTP_REFERER'];
+
+	if ( $ref !== $_SERVER['REQUEST_URI'] )
+		return $ref;
+	return false;
+}
+
+/**
+ * Retrieve original referer that was posted, if it exists.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @return string|bool False if no original referer or original referer if set.
+ */
+function wp_get_original_referer() {
+	if ( !empty( $_REQUEST['_wp_original_http_referer'] ) )
+		return $_REQUEST['_wp_original_http_referer'];
+	return false;
+}
+
+/**
+ * Recursive directory creation based on full path.
+ *
+ * Will attempt to set permissions on folders.
+ *
+ * @since 2.0.1
+ *
+ * @param string $target Full path to attempt to create.
+ * @return bool Whether the path was created. True if path already exists.
+ */
+function wp_mkdir_p( $target ) {
+	// from php.net/mkdir user contributed notes
+	$target = str_replace( '//', '/', $target );
+
+	// safe mode fails with a trailing slash under certain PHP versions.
+	$target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency.
+	if ( empty($target) )
+		$target = '/';
+
+	if ( file_exists( $target ) )
+		return @is_dir( $target );
+
+	// Attempting to create the directory may clutter up our display.
+	if ( @mkdir( $target ) ) {
+		$stat = @stat( dirname( $target ) );
+		$dir_perms = $stat['mode'] & 0007777;  // Get the permission bits.
+		@chmod( $target, $dir_perms );
+		return true;
+	} elseif ( is_dir( dirname( $target ) ) ) {
+			return false;
+	}
+
+	// If the above failed, attempt to create the parent node, then try again.
+	if ( ( $target != '/' ) && ( wp_mkdir_p( dirname( $target ) ) ) )
+		return wp_mkdir_p( $target );
+
+	return false;
+}
+
+/**
+ * Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows').
+ *
+ * @since 2.5.0
+ *
+ * @param string $path File path
+ * @return bool True if path is absolute, false is not absolute.
+ */
+function path_is_absolute( $path ) {
+	// this is definitive if true but fails if $path does not exist or contains a symbolic link
+	if ( realpath($path) == $path )
+		return true;
+
+	if ( strlen($path) == 0 || $path[0] == '.' )
+		return false;
+
+	// windows allows absolute paths like this
+	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
+		return true;
+
+	// a path starting with / or \ is absolute; anything else is relative
+	return (bool) preg_match('#^[/\\\\]#', $path);
+}
+
+/**
+ * Join two filesystem paths together (e.g. 'give me $path relative to $base').
+ *
+ * If the $path is absolute, then it the full path is returned.
+ *
+ * @since 2.5.0
+ *
+ * @param string $base
+ * @param string $path
+ * @return string The path with the base or absolute path.
+ */
+function path_join( $base, $path ) {
+	if ( path_is_absolute($path) )
+		return $path;
+
+	return rtrim($base, '/') . '/' . ltrim($path, '/');
+}
+
+/**
+ * Get an array containing the current upload directory's path and url.
+ *
+ * Checks the 'upload_path' option, which should be from the web root folder,
+ * and if it isn't empty it will be used. If it is empty, then the path will be
+ * 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will
+ * override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.
+ *
+ * The upload URL path is set either by the 'upload_url_path' option or by using
+ * the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.
+ *
+ * If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in
+ * the administration settings panel), then the time will be used. The format
+ * will be year first and then month.
+ *
+ * If the path couldn't be created, then an error will be returned with the key
+ * 'error' containing the error message. The error suggests that the parent
+ * directory is not writable by the server.
+ *
+ * On success, the returned array will have many indices:
+ * 'path' - base directory and sub directory or full path to upload directory.
+ * 'url' - base url and sub directory or absolute URL to upload directory.
+ * 'subdir' - sub directory if uploads use year/month folders option is on.
+ * 'basedir' - path without subdir.
+ * 'baseurl' - URL path without subdir.
+ * 'error' - set to false.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'upload_dir' on returned array.
+ *
+ * @param string $time Optional. Time formatted in 'yyyy/mm'.
+ * @return array See above for description.
+ */
+function wp_upload_dir( $time = null ) {
+	global $switched;
+	$siteurl = get_option( 'siteurl' );
+	$upload_path = get_option( 'upload_path' );
+	$upload_path = trim($upload_path);
+	$main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site();
+	if ( empty($upload_path) ) {
+		$dir = WP_CONTENT_DIR . '/uploads';
+	} else {
+		$dir = $upload_path;
+		if ( 'wp-content/uploads' == $upload_path ) {
+			$dir = WP_CONTENT_DIR . '/uploads';
+		} elseif ( 0 !== strpos($dir, ABSPATH) ) {
+			// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
+			$dir = path_join( ABSPATH, $dir );
+		}
+	}
+
+	if ( !$url = get_option( 'upload_url_path' ) ) {
+		if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
+			$url = WP_CONTENT_URL . '/uploads';
+		else
+			$url = trailingslashit( $siteurl ) . $upload_path;
+	}
+
+	if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
+		$dir = ABSPATH . UPLOADS;
+		$url = trailingslashit( $siteurl ) . UPLOADS;
+	}
+
+	if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
+		if ( defined( 'BLOGUPLOADDIR' ) )
+			$dir = untrailingslashit(BLOGUPLOADDIR);
+		$url = str_replace( UPLOADS, 'files', $url );
+	}
+
+	$bdir = $dir;
+	$burl = $url;
+
+	$subdir = '';
+	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
+		// Generate the yearly and monthly dirs
+		if ( !$time )
+			$time = current_time( 'mysql' );
+		$y = substr( $time, 0, 4 );
+		$m = substr( $time, 5, 2 );
+		$subdir = "/$y/$m";
+	}
+
+	$dir .= $subdir;
+	$url .= $subdir;
+
+	$uploads = apply_filters( 'upload_dir', array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ) );
+
+	// Make sure we have an uploads dir
+	if ( ! wp_mkdir_p( $uploads['path'] ) ) {
+		$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $uploads['path'] );
+		return array( 'error' => $message );
+	}
+
+	return $uploads;
+}
+
+/**
+ * Get a filename that is sanitized and unique for the given directory.
+ *
+ * If the filename is not unique, then a number will be added to the filename
+ * before the extension, and will continue adding numbers until the filename is
+ * unique.
+ *
+ * The callback is passed three parameters, the first one is the directory, the
+ * second is the filename, and the third is the extension.
+ *
+ * @since 2.5.0
+ *
+ * @param string $dir
+ * @param string $filename
+ * @param mixed $unique_filename_callback Callback.
+ * @return string New filename, if given wasn't unique.
+ */
+function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
+	// sanitize the file name before we begin processing
+	$filename = sanitize_file_name($filename);
+
+	// separate the filename into a name and extension
+	$info = pathinfo($filename);
+	$ext = !empty($info['extension']) ? '.' . $info['extension'] : '';
+	$name = basename($filename, $ext);
+
+	// edge case: if file is named '.ext', treat as an empty name
+	if ( $name === $ext )
+		$name = '';
+
+	// Increment the file number until we have a unique file to save in $dir. Use callback if supplied.
+	if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) {
+		$filename = call_user_func( $unique_filename_callback, $dir, $name, $ext );
+	} else {
+		$number = '';
+
+		// change '.ext' to lower case
+		if ( $ext && strtolower($ext) != $ext ) {
+			$ext2 = strtolower($ext);
+			$filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename );
+
+			// check for both lower and upper case extension or image sub-sizes may be overwritten
+			while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) {
+				$new_number = $number + 1;
+				$filename = str_replace( "$number$ext", "$new_number$ext", $filename );
+				$filename2 = str_replace( "$number$ext2", "$new_number$ext2", $filename2 );
+				$number = $new_number;
+			}
+			return $filename2;
+		}
+
+		while ( file_exists( $dir . "/$filename" ) ) {
+			if ( '' == "$number$ext" )
+				$filename = $filename . ++$number . $ext;
+			else
+				$filename = str_replace( "$number$ext", ++$number . $ext, $filename );
+		}
+	}
+
+	return $filename;
+}
+
+/**
+ * Create a file in the upload folder with given content.
+ *
+ * If there is an error, then the key 'error' will exist with the error message.
+ * If success, then the key 'file' will have the unique file path, the 'url' key
+ * will have the link to the new file. and the 'error' key will be set to false.
+ *
+ * This function will not move an uploaded file to the upload folder. It will
+ * create a new file with the content in $bits parameter. If you move the upload
+ * file, read the content of the uploaded file, and then you can give the
+ * filename and content to this function, which will add it to the upload
+ * folder.
+ *
+ * The permissions will be set on the new file automatically by this function.
+ *
+ * @since 2.0.0
+ *
+ * @param string $name
+ * @param null $deprecated Never used. Set to null.
+ * @param mixed $bits File content
+ * @param string $time Optional. Time formatted in 'yyyy/mm'.
+ * @return array
+ */
+function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.0' );
+
+	if ( empty( $name ) )
+		return array( 'error' => __( 'Empty filename' ) );
+
+	$wp_filetype = wp_check_filetype( $name );
+	if ( !$wp_filetype['ext'] )
+		return array( 'error' => __( 'Invalid file type' ) );
+
+	$upload = wp_upload_dir( $time );
+
+	if ( $upload['error'] !== false )
+		return $upload;
+
+	$upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) );
+	if ( !is_array( $upload_bits_error ) ) {
+		$upload[ 'error' ] = $upload_bits_error;
+		return $upload;
+	}
+
+	$filename = wp_unique_filename( $upload['path'], $name );
+
+	$new_file = $upload['path'] . "/$filename";
+	if ( ! wp_mkdir_p( dirname( $new_file ) ) ) {
+		$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), dirname( $new_file ) );
+		return array( 'error' => $message );
+	}
+
+	$ifp = @ fopen( $new_file, 'wb' );
+	if ( ! $ifp )
+		return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) );
+
+	@fwrite( $ifp, $bits );
+	fclose( $ifp );
+	clearstatcache();
+
+	// Set correct file permissions
+	$stat = @ stat( dirname( $new_file ) );
+	$perms = $stat['mode'] & 0007777;
+	$perms = $perms & 0000666;
+	@ chmod( $new_file, $perms );
+	clearstatcache();
+
+	// Compute the URL
+	$url = $upload['url'] . "/$filename";
+
+	return array( 'file' => $new_file, 'url' => $url, 'error' => false );
+}
+
+/**
+ * Retrieve the file type based on the extension name.
+ *
+ * @package WordPress
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'ext2type' hook on default supported types.
+ *
+ * @param string $ext The extension to search.
+ * @return string|null The file type, example: audio, video, document, spreadsheet, etc. Null if not found.
+ */
+function wp_ext2type( $ext ) {
+	$ext2type = apply_filters( 'ext2type', array(
+		'audio'       => array( 'aac', 'ac3',  'aif',  'aiff', 'm3a',  'm4a',   'm4b', 'mka', 'mp1', 'mp2',  'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
+		'video'       => array( 'asf', 'avi',  'divx', 'dv',   'flv',  'm4v',   'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt',  'rm', 'vob', 'wmv' ),
+		'document'    => array( 'doc', 'docx', 'docm', 'dotm', 'odt',  'pages', 'pdf', 'rtf', 'wp',  'wpd' ),
+		'spreadsheet' => array( 'numbers',     'ods',  'xls',  'xlsx', 'xlsb',  'xlsm' ),
+		'interactive' => array( 'key', 'ppt',  'pptx', 'pptm', 'odp',  'swf' ),
+		'text'        => array( 'asc', 'csv',  'tsv',  'txt' ),
+		'archive'     => array( 'bz2', 'cab',  'dmg',  'gz',   'rar',  'sea',   'sit', 'sqx', 'tar', 'tgz',  'zip' ),
+		'code'        => array( 'css', 'htm',  'html', 'php',  'js' ),
+	));
+	foreach ( $ext2type as $type => $exts )
+		if ( in_array( $ext, $exts ) )
+			return $type;
+}
+
+/**
+ * Retrieve the file type from the file name.
+ *
+ * You can optionally define the mime array, if needed.
+ *
+ * @since 2.0.4
+ *
+ * @param string $filename File name or path.
+ * @param array $mimes Optional. Key is the file extension with value as the mime type.
+ * @return array Values with extension first and mime type.
+ */
+function wp_check_filetype( $filename, $mimes = null ) {
+	if ( empty($mimes) )
+		$mimes = get_allowed_mime_types();
+	$type = false;
+	$ext = false;
+
+	foreach ( $mimes as $ext_preg => $mime_match ) {
+		$ext_preg = '!\.(' . $ext_preg . ')$!i';
+		if ( preg_match( $ext_preg, $filename, $ext_matches ) ) {
+			$type = $mime_match;
+			$ext = $ext_matches[1];
+			break;
+		}
+	}
+
+	return compact( 'ext', 'type' );
+}
+
+/**
+ * Attempt to determine the real file type of a file.
+ * If unable to, the file name extension will be used to determine type.
+ *
+ * If it's determined that the extension does not match the file's real type,
+ * then the "proper_filename" value will be set with a proper filename and extension.
+ *
+ * Currently this function only supports validating images known to getimagesize().
+ *
+ * @since 3.0.0
+ *
+ * @param string $file Full path to the image.
+ * @param string $filename The filename of the image (may differ from $file due to $file being in a tmp directory)
+ * @param array $mimes Optional. Key is the file extension with value as the mime type.
+ * @return array Values for the extension, MIME, and either a corrected filename or false if original $filename is valid
+ */
+function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
+
+	$proper_filename = false;
+
+	// Do basic extension validation and MIME mapping
+	$wp_filetype = wp_check_filetype( $filename, $mimes );
+	extract( $wp_filetype );
+
+	// We can't do any further validation without a file to work with
+	if ( ! file_exists( $file ) )
+		return compact( 'ext', 'type', 'proper_filename' );
+
+	// We're able to validate images using GD
+	if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
+
+		// Attempt to figure out what type of image it actually is
+		$imgstats = @getimagesize( $file );
+
+		// If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
+		if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
+			// This is a simplified array of MIMEs that getimagesize() can detect and their extensions
+			// You shouldn't need to use this filter, but it's here just in case
+			$mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
+				'image/jpeg' => 'jpg',
+				'image/png'  => 'png',
+				'image/gif'  => 'gif',
+				'image/bmp'  => 'bmp',
+				'image/tiff' => 'tif',
+			) );
+
+			// Replace whatever is after the last period in the filename with the correct extension
+			if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {
+				$filename_parts = explode( '.', $filename );
+				array_pop( $filename_parts );
+				$filename_parts[] = $mime_to_ext[ $imgstats['mime'] ];
+				$new_filename = implode( '.', $filename_parts );
+
+				if ( $new_filename != $filename )
+					$proper_filename = $new_filename; // Mark that it changed
+
+				// Redefine the extension / MIME
+				$wp_filetype = wp_check_filetype( $new_filename, $mimes );
+				extract( $wp_filetype );
+			}
+		}
+	}
+
+	// Let plugins try and validate other types of files
+	// Should return an array in the style of array( 'ext' => $ext, 'type' => $type, 'proper_filename' => $proper_filename )
+	return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes );
+}
+
+/**
+ * Retrieve list of allowed mime types and file extensions.
+ *
+ * @since 2.8.6
+ *
+ * @return array Array of mime types keyed by the file extension regex corresponding to those types.
+ */
+function get_allowed_mime_types() {
+	static $mimes = false;
+
+	if ( !$mimes ) {
+		// Accepted MIME types are set here as PCRE unless provided.
+		$mimes = apply_filters( 'upload_mimes', array(
+		'jpg|jpeg|jpe' => 'image/jpeg',
+		'gif' => 'image/gif',
+		'png' => 'image/png',
+		'bmp' => 'image/bmp',
+		'tif|tiff' => 'image/tiff',
+		'ico' => 'image/x-icon',
+		'asf|asx|wax|wmv|wmx' => 'video/asf',
+		'avi' => 'video/avi',
+		'divx' => 'video/divx',
+		'flv' => 'video/x-flv',
+		'mov|qt' => 'video/quicktime',
+		'mpeg|mpg|mpe' => 'video/mpeg',
+		'txt|asc|c|cc|h' => 'text/plain',
+		'csv' => 'text/csv',
+		'tsv' => 'text/tab-separated-values',
+		'rtx' => 'text/richtext',
+		'css' => 'text/css',
+		'htm|html' => 'text/html',
+		'mp3|m4a|m4b' => 'audio/mpeg',
+		'mp4|m4v' => 'video/mp4',
+		'ra|ram' => 'audio/x-realaudio',
+		'wav' => 'audio/wav',
+		'ogg|oga' => 'audio/ogg',
+		'ogv' => 'video/ogg',
+		'mid|midi' => 'audio/midi',
+		'wma' => 'audio/wma',
+		'mka' => 'audio/x-matroska',
+		'mkv' => 'video/x-matroska',
+		'rtf' => 'application/rtf',
+		'js' => 'application/javascript',
+		'pdf' => 'application/pdf',
+		'doc|docx' => 'application/msword',
+		'pot|pps|ppt|pptx|ppam|pptm|sldm|ppsm|potm' => 'application/vnd.ms-powerpoint',
+		'wri' => 'application/vnd.ms-write',
+		'xla|xls|xlsx|xlt|xlw|xlam|xlsb|xlsm|xltm' => 'application/vnd.ms-excel',
+		'mdb' => 'application/vnd.ms-access',
+		'mpp' => 'application/vnd.ms-project',
+		'docm|dotm' => 'application/vnd.ms-word',
+		'pptx|sldx|ppsx|potx' => 'application/vnd.openxmlformats-officedocument.presentationml',
+		'xlsx|xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml',
+		'docx|dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml',
+		'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote',
+		'swf' => 'application/x-shockwave-flash',
+		'class' => 'application/java',
+		'tar' => 'application/x-tar',
+		'zip' => 'application/zip',
+		'gz|gzip' => 'application/x-gzip',
+		'exe' => 'application/x-msdownload',
+		// openoffice formats
+		'odt' => 'application/vnd.oasis.opendocument.text',
+		'odp' => 'application/vnd.oasis.opendocument.presentation',
+		'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+		'odg' => 'application/vnd.oasis.opendocument.graphics',
+		'odc' => 'application/vnd.oasis.opendocument.chart',
+		'odb' => 'application/vnd.oasis.opendocument.database',
+		'odf' => 'application/vnd.oasis.opendocument.formula',
+		// wordperfect formats
+		'wp|wpd' => 'application/wordperfect',
+		) );
+	}
+
+	return $mimes;
+}
+
+/**
+ * Retrieve nonce action "Are you sure" message.
+ *
+ * The action is split by verb and noun. The action format is as follows:
+ * verb-action_extra. The verb is before the first dash and has the format of
+ * letters and no spaces and numbers. The noun is after the dash and before the
+ * underscore, if an underscore exists. The noun is also only letters.
+ *
+ * The filter will be called for any action, which is not defined by WordPress.
+ * You may use the filter for your plugin to explain nonce actions to the user,
+ * when they get the "Are you sure?" message. The filter is in the format of
+ * 'explain_nonce_$verb-$noun' with the $verb replaced by the found verb and the
+ * $noun replaced by the found noun. The two parameters that are given to the
+ * hook are the localized "Are you sure you want to do this?" message with the
+ * extra text (the text after the underscore).
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action Nonce action.
+ * @return string Are you sure message.
+ */
+function wp_explain_nonce( $action ) {
+	if ( $action !== -1 && preg_match( '/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches ) ) {
+		$verb = $matches[1];
+		$noun = $matches[2];
+
+		$trans = array();
+		$trans['update']['attachment'] = array( __( 'Your attempt to edit this attachment: &#8220;%s&#8221; has failed.' ), 'get_the_title' );
+
+		$trans['add']['category']      = array( __( 'Your attempt to add this category has failed.' ), false );
+		$trans['delete']['category']   = array( __( 'Your attempt to delete this category: &#8220;%s&#8221; has failed.' ), 'get_cat_name' );
+		$trans['update']['category']   = array( __( 'Your attempt to edit this category: &#8220;%s&#8221; has failed.' ), 'get_cat_name' );
+
+		$trans['delete']['comment']    = array( __( 'Your attempt to delete this comment: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['unapprove']['comment'] = array( __( 'Your attempt to unapprove this comment: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['approve']['comment']   = array( __( 'Your attempt to approve this comment: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['update']['comment']    = array( __( 'Your attempt to edit this comment: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['bulk']['comments']     = array( __( 'Your attempt to bulk modify comments has failed.' ), false );
+		$trans['moderate']['comments'] = array( __( 'Your attempt to moderate comments has failed.' ), false );
+
+		$trans['add']['bookmark']      = array( __( 'Your attempt to add this link has failed.' ), false );
+		$trans['delete']['bookmark']   = array( __( 'Your attempt to delete this link: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['update']['bookmark']   = array( __( 'Your attempt to edit this link: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['bulk']['bookmarks']    = array( __( 'Your attempt to bulk modify links has failed.' ), false );
+
+		$trans['add']['page']          = array( __( 'Your attempt to add this page has failed.' ), false );
+		$trans['delete']['page']       = array( __( 'Your attempt to delete this page: &#8220;%s&#8221; has failed.' ), 'get_the_title' );
+		$trans['update']['page']       = array( __( 'Your attempt to edit this page: &#8220;%s&#8221; has failed.' ), 'get_the_title' );
+
+		$trans['edit']['plugin']       = array( __( 'Your attempt to edit this plugin file: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['activate']['plugin']   = array( __( 'Your attempt to activate this plugin: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['deactivate']['plugin'] = array( __( 'Your attempt to deactivate this plugin: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['upgrade']['plugin']    = array( __( 'Your attempt to update this plugin: &#8220;%s&#8221; has failed.' ), 'use_id' );
+
+		$trans['add']['post']          = array( __( 'Your attempt to add this post has failed.' ), false );
+		$trans['delete']['post']       = array( __( 'Your attempt to delete this post: &#8220;%s&#8221; has failed.' ), 'get_the_title' );
+		$trans['update']['post']       = array( __( 'Your attempt to edit this post: &#8220;%s&#8221; has failed.' ), 'get_the_title' );
+
+		$trans['add']['user']          = array( __( 'Your attempt to add this user has failed.' ), false );
+		$trans['delete']['users']      = array( __( 'Your attempt to delete users has failed.' ), false );
+		$trans['bulk']['users']        = array( __( 'Your attempt to bulk modify users has failed.' ), false );
+		$trans['update']['user']       = array( __( 'Your attempt to edit this user: &#8220;%s&#8221; has failed.' ), 'get_the_author_meta', 'display_name' );
+		$trans['update']['profile']    = array( __( 'Your attempt to modify the profile for: &#8220;%s&#8221; has failed.' ), 'get_the_author_meta', 'display_name' );
+
+		$trans['update']['options']    = array( __( 'Your attempt to edit your settings has failed.' ), false );
+		$trans['update']['permalink']  = array( __( 'Your attempt to change your permalink structure to: %s has failed.' ), 'use_id' );
+		$trans['edit']['file']         = array( __( 'Your attempt to edit this file: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['edit']['theme']        = array( __( 'Your attempt to edit this theme file: &#8220;%s&#8221; has failed.' ), 'use_id' );
+		$trans['switch']['theme']      = array( __( 'Your attempt to switch to this theme: &#8220;%s&#8221; has failed.' ), 'use_id' );
+
+		$trans['log']['out']           = array( sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'sitename' ) ), false );
+
+		if ( isset( $trans[$verb][$noun] ) ) {
+			if ( !empty( $trans[$verb][$noun][1] ) ) {
+				$lookup = $trans[$verb][$noun][1];
+				if ( isset($trans[$verb][$noun][2]) )
+					$lookup_value = $trans[$verb][$noun][2];
+				$object = $matches[4];
+				if ( 'use_id' != $lookup ) {
+					if ( isset( $lookup_value ) )
+						$object = call_user_func( $lookup, $lookup_value, $object );
+					else
+						$object = call_user_func( $lookup, $object );
+				}
+				return sprintf( $trans[$verb][$noun][0], esc_html($object) );
+			} else {
+				return $trans[$verb][$noun][0];
+			}
+		}
+
+		return apply_filters( 'explain_nonce_' . $verb . '-' . $noun, __( 'Are you sure you want to do this?' ), isset($matches[4]) ? $matches[4] : '' );
+	} else {
+		return apply_filters( 'explain_nonce_' . $action, __( 'Are you sure you want to do this?' ) );
+	}
+}
+
+/**
+ * Display "Are You Sure" message to confirm the action being taken.
+ *
+ * If the action has the nonce explain message, then it will be displayed along
+ * with the "Are you sure?" message.
+ *
+ * @package WordPress
+ * @subpackage Security
+ * @since 2.0.4
+ *
+ * @param string $action The nonce action.
+ */
+function wp_nonce_ays( $action ) {
+	$title = __( 'WordPress Failure Notice' );
+	$html = esc_html( wp_explain_nonce( $action ) );
+	if ( 'log-out' == $action )
+		$html .= "</p><p>" . sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url() );
+	elseif ( wp_get_referer() )
+		$html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>";
+
+	wp_die( $html, $title, array('response' => 403) );
+}
+
+
+/**
+ * Kill WordPress execution and display HTML message with error message.
+ *
+ * This function complements the die() PHP function. The difference is that
+ * HTML will be displayed to the user. It is recommended to use this function
+ * only, when the execution should not continue any further. It is not
+ * recommended to call this function very often and try to handle as many errors
+ * as possible siliently.
+ *
+ * @since 2.0.4
+ *
+ * @param string $message Error message.
+ * @param string $title Error title.
+ * @param string|array $args Optional arguements to control behaviour.
+ */
+function wp_die( $message, $title = '', $args = array() ) {
+	if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
+		die('-1');
+
+	if ( function_exists( 'apply_filters' ) ) {
+		$function = apply_filters( 'wp_die_handler', '_default_wp_die_handler');
+	} else {
+		$function = '_default_wp_die_handler';
+	}
+
+	call_user_func( $function, $message, $title, $args );
+}
+
+/**
+ * Kill WordPress execution and display HTML message with error message.
+ *
+ * This is the default handler for wp_die if you want a custom one for your
+ * site then you can overload using the wp_die_handler filter in wp_die
+ *
+ * @since 3.0.0
+ * @access private
+ *
+ * @param string $message Error message.
+ * @param string $title Error title.
+ * @param string|array $args Optional arguements to control behaviour.
+ */
+function _default_wp_die_handler( $message, $title = '', $args = array() ) {
+	$defaults = array( 'response' => 500 );
+	$r = wp_parse_args($args, $defaults);
+
+	$have_gettext = function_exists('__');
+
+	if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {
+		if ( empty( $title ) ) {
+			$error_data = $message->get_error_data();
+			if ( is_array( $error_data ) && isset( $error_data['title'] ) )
+				$title = $error_data['title'];
+		}
+		$errors = $message->get_error_messages();
+		switch ( count( $errors ) ) :
+		case 0 :
+			$message = '';
+			break;
+		case 1 :
+			$message = "<p>{$errors[0]}</p>";
+			break;
+		default :
+			$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";
+			break;
+		endswitch;
+	} elseif ( is_string( $message ) ) {
+		$message = "<p>$message</p>";
+	}
+
+	if ( isset( $r['back_link'] ) && $r['back_link'] ) {
+		$back_text = $have_gettext? __('&laquo; Back') : '&laquo; Back';
+		$message .= "\n<p><a href='javascript:history.back()'>$back_text</p>";
+	}
+
+	if ( defined( 'WP_SITEURL' ) && '' != WP_SITEURL )
+		$admin_dir = WP_SITEURL . '/wp-admin/';
+	elseif ( function_exists( 'get_bloginfo' ) && '' != get_bloginfo( 'wpurl' ) )
+		$admin_dir = get_bloginfo( 'wpurl' ) . '/wp-admin/';
+	elseif ( strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) !== false )
+		$admin_dir = '';
+	else
+		$admin_dir = 'wp-admin/';
+
+	if ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) :
+	if ( !headers_sent() ) {
+		status_header( $r['response'] );
+		nocache_headers();
+		header( 'Content-Type: text/html; charset=utf-8' );
+	}
+
+	if ( empty($title) )
+		$title = $have_gettext ? __('WordPress &rsaquo; Error') : 'WordPress &rsaquo; Error';
+
+	$text_direction = 'ltr';
+	if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
+		$text_direction = 'rtl';
+	elseif ( function_exists( 'is_rtl' ) && is_rtl() )
+		$text_direction = 'rtl';
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono -->
+<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<title><?php echo $title ?></title>
+	<link rel="stylesheet" href="<?php echo $admin_dir; ?>css/install.css" type="text/css" />
+<?php
+if ( 'rtl' == $text_direction ) : ?>
+	<link rel="stylesheet" href="<?php echo $admin_dir; ?>css/install-rtl.css" type="text/css" />
+<?php endif; ?>
+</head>
+<body id="error-page">
+<?php endif; ?>
+	<?php echo $message; ?>
+</body>
+</html>
+<?php
+	die();
+}
+
+/**
+ * Retrieve the WordPress home page URL.
+ *
+ * If the constant named 'WP_HOME' exists, then it willl be used and returned by
+ * the function. This can be used to counter the redirection on your local
+ * development environment.
+ *
+ * @access private
+ * @package WordPress
+ * @since 2.2.0
+ *
+ * @param string $url URL for the home location
+ * @return string Homepage location.
+ */
+function _config_wp_home( $url = '' ) {
+	if ( defined( 'WP_HOME' ) )
+		return WP_HOME;
+	return $url;
+}
+
+/**
+ * Retrieve the WordPress site URL.
+ *
+ * If the constant named 'WP_SITEURL' is defined, then the value in that
+ * constant will always be returned. This can be used for debugging a site on
+ * your localhost while not having to change the database to your URL.
+ *
+ * @access private
+ * @package WordPress
+ * @since 2.2.0
+ *
+ * @param string $url URL to set the WordPress site location.
+ * @return string The WordPress Site URL
+ */
+function _config_wp_siteurl( $url = '' ) {
+	if ( defined( 'WP_SITEURL' ) )
+		return WP_SITEURL;
+	return $url;
+}
+
+/**
+ * Set the localized direction for MCE plugin.
+ *
+ * Will only set the direction to 'rtl', if the WordPress locale has the text
+ * direction set to 'rtl'.
+ *
+ * Fills in the 'directionality', 'plugins', and 'theme_advanced_button1' array
+ * keys. These keys are then returned in the $input array.
+ *
+ * @access private
+ * @package WordPress
+ * @subpackage MCE
+ * @since 2.1.0
+ *
+ * @param array $input MCE plugin array.
+ * @return array Direction set for 'rtl', if needed by locale.
+ */
+function _mce_set_direction( $input ) {
+	if ( is_rtl() ) {
+		$input['directionality'] = 'rtl';
+		$input['plugins'] .= ',directionality';
+		$input['theme_advanced_buttons1'] .= ',ltr';
+	}
+
+	return $input;
+}
+
+
+/**
+ * Convert smiley code to the icon graphic file equivalent.
+ *
+ * You can turn off smilies, by going to the write setting screen and unchecking
+ * the box, or by setting 'use_smilies' option to false or removing the option.
+ *
+ * Plugins may override the default smiley list by setting the $wpsmiliestrans
+ * to an array, with the key the code the blogger types in and the value the
+ * image file.
+ *
+ * The $wp_smiliessearch global is for the regular expression and is set each
+ * time the function is called.
+ *
+ * The full list of smilies can be found in the function and won't be listed in
+ * the description. Probably should create a Codex page for it, so that it is
+ * available.
+ *
+ * @global array $wpsmiliestrans
+ * @global array $wp_smiliessearch
+ * @since 2.2.0
+ */
+function smilies_init() {
+	global $wpsmiliestrans, $wp_smiliessearch;
+
+	// don't bother setting up smilies if they are disabled
+	if ( !get_option( 'use_smilies' ) )
+		return;
+
+	if ( !isset( $wpsmiliestrans ) ) {
+		$wpsmiliestrans = array(
+		':mrgreen:' => 'icon_mrgreen.gif',
+		':neutral:' => 'icon_neutral.gif',
+		':twisted:' => 'icon_twisted.gif',
+		  ':arrow:' => 'icon_arrow.gif',
+		  ':shock:' => 'icon_eek.gif',
+		  ':smile:' => 'icon_smile.gif',
+		    ':???:' => 'icon_confused.gif',
+		   ':cool:' => 'icon_cool.gif',
+		   ':evil:' => 'icon_evil.gif',
+		   ':grin:' => 'icon_biggrin.gif',
+		   ':idea:' => 'icon_idea.gif',
+		   ':oops:' => 'icon_redface.gif',
+		   ':razz:' => 'icon_razz.gif',
+		   ':roll:' => 'icon_rolleyes.gif',
+		   ':wink:' => 'icon_wink.gif',
+		    ':cry:' => 'icon_cry.gif',
+		    ':eek:' => 'icon_surprised.gif',
+		    ':lol:' => 'icon_lol.gif',
+		    ':mad:' => 'icon_mad.gif',
+		    ':sad:' => 'icon_sad.gif',
+		      '8-)' => 'icon_cool.gif',
+		      '8-O' => 'icon_eek.gif',
+		      ':-(' => 'icon_sad.gif',
+		      ':-)' => 'icon_smile.gif',
+		      ':-?' => 'icon_confused.gif',
+		      ':-D' => 'icon_biggrin.gif',
+		      ':-P' => 'icon_razz.gif',
+		      ':-o' => 'icon_surprised.gif',
+		      ':-x' => 'icon_mad.gif',
+		      ':-|' => 'icon_neutral.gif',
+		      ';-)' => 'icon_wink.gif',
+		       '8)' => 'icon_cool.gif',
+		       '8O' => 'icon_eek.gif',
+		       ':(' => 'icon_sad.gif',
+		       ':)' => 'icon_smile.gif',
+		       ':?' => 'icon_confused.gif',
+		       ':D' => 'icon_biggrin.gif',
+		       ':P' => 'icon_razz.gif',
+		       ':o' => 'icon_surprised.gif',
+		       ':x' => 'icon_mad.gif',
+		       ':|' => 'icon_neutral.gif',
+		       ';)' => 'icon_wink.gif',
+		      ':!:' => 'icon_exclaim.gif',
+		      ':?:' => 'icon_question.gif',
+		);
+	}
+
+	if (count($wpsmiliestrans) == 0) {
+		return;
+	}
+
+	/*
+	 * NOTE: we sort the smilies in reverse key order. This is to make sure
+	 * we match the longest possible smilie (:???: vs :?) as the regular
+	 * expression used below is first-match
+	 */
+	krsort($wpsmiliestrans);
+
+	$wp_smiliessearch = '/(?:\s|^)';
+
+	$subchar = '';
+	foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
+		$firstchar = substr($smiley, 0, 1);
+		$rest = substr($smiley, 1);
+
+		// new subpattern?
+		if ($firstchar != $subchar) {
+			if ($subchar != '') {
+				$wp_smiliessearch .= ')|(?:\s|^)';
+			}
+			$subchar = $firstchar;
+			$wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
+		} else {
+			$wp_smiliessearch .= '|';
+		}
+		$wp_smiliessearch .= preg_quote($rest, '/');
+	}
+
+	$wp_smiliessearch .= ')(?:\s|$)/m';
+}
+
+/**
+ * Merge user defined arguments into defaults array.
+ *
+ * This function is used throughout WordPress to allow for both string or array
+ * to be merged into another array.
+ *
+ * @since 2.2.0
+ *
+ * @param string|array $args Value to merge with $defaults
+ * @param array $defaults Array that serves as the defaults.
+ * @return array Merged user defined values with defaults.
+ */
+function wp_parse_args( $args, $defaults = '' ) {
+	if ( is_object( $args ) )
+		$r = get_object_vars( $args );
+	elseif ( is_array( $args ) )
+		$r =& $args;
+	else
+		wp_parse_str( $args, $r );
+
+	if ( is_array( $defaults ) )
+		return array_merge( $defaults, $r );
+	return $r;
+}
+
+/**
+ * Clean up an array, comma- or space-separated list of IDs
+ *
+ * @since 3.0.0
+ *
+ * @param array|string $list
+ * @return array Sanitized array of IDs
+ */
+function wp_parse_id_list( $list ) {
+	if ( !is_array($list) )
+		$list = preg_split('/[\s,]+/', $list);
+
+	return array_unique(array_map('absint', $list));
+}
+
+/**
+ * Extract a slice of an array, given a list of keys
+ *
+ * @since 3.1.0
+ *
+ * @param array $array The original array
+ * @param array $keys The list of keys
+ * @return array The array slice
+ */
+function wp_array_slice_assoc( $array, $keys ) {
+	$slice = array();
+	foreach ( $keys as $key )
+		if ( isset( $array[ $key ] ) )
+			$slice[ $key ] = $array[ $key ];
+
+	return $slice;
+}
+
+/**
+ * Filters a list of objects, based on a set of key => value arguments
+ *
+ * @since 3.0.0
+ *
+ * @param array $list An array of objects to filter
+ * @param array $args An array of key => value arguments to match against each object
+ * @param string $operator The logical operation to perform. 'or' means only one element
+ *	from the array needs to match; 'and' means all elements must match. The default is 'and'.
+ * @param bool|string $field A field from the object to place instead of the entire object
+ * @return array A list of objects or object fields
+ */
+function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) {
+	if ( ! is_array( $list ) )
+		return array();
+
+	$list = wp_list_filter( $list, $args, $operator );
+
+	if ( $field )
+		$list = wp_list_pluck( $list, $field );
+
+	return $list;
+}
+
+/**
+ * Filters a list of objects, based on a set of key => value arguments
+ *
+ * @since 3.1.0
+ *
+ * @param array $list An array of objects to filter
+ * @param array $args An array of key => value arguments to match against each object
+ * @param string $operator The logical operation to perform:
+ *    'AND' means all elements from the array must match;
+ *    'OR' means only one element needs to match;
+ *    'NOT' means no elements may match.
+ *   The default is 'AND'.
+ * @return array
+ */
+function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
+	if ( ! is_array( $list ) )
+		return array();
+
+	if ( empty( $args ) )
+		return $list;
+
+	$operator = strtoupper( $operator );
+	$count = count( $args );
+	$filtered = array();
+
+	foreach ( $list as $key => $obj ) {
+		$matched = count( array_intersect_assoc( (array) $obj, $args ) );
+		if ( ( 'AND' == $operator && $matched == $count )
+		  || ( 'OR' == $operator && $matched <= $count )
+		  || ( 'NOT' == $operator && 0 == $matched ) ) {
+			$filtered[$key] = $obj;
+		}
+	}
+
+	return $filtered;
+}
+
+/**
+ * Pluck a certain field out of each object in a list
+ *
+ * @since 3.1.0
+ *
+ * @param array $list A list of objects or arrays
+ * @param int|string $field A field from the object to place instead of the entire object
+ * @return array
+ */
+function wp_list_pluck( $list, $field ) {
+	foreach ( $list as $key => $value ) {
+		$value = (array) $value;
+		$list[ $key ] = $value[ $field ];
+	}
+
+	return $list;
+}
+
+/**
+ * Determines if default embed handlers should be loaded.
+ *
+ * Checks to make sure that the embeds library hasn't already been loaded. If
+ * it hasn't, then it will load the embeds library.
+ *
+ * @since 2.9.0
+ */
+function wp_maybe_load_embeds() {
+	if ( ! apply_filters('load_default_embeds', true) )
+		return;
+	require_once( ABSPATH . WPINC . '/default-embeds.php' );
+}
+
+/**
+ * Determines if Widgets library should be loaded.
+ *
+ * Checks to make sure that the widgets library hasn't already been loaded. If
+ * it hasn't, then it will load the widgets library and run an action hook.
+ *
+ * @since 2.2.0
+ * @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value.
+ */
+function wp_maybe_load_widgets() {
+	if ( ! apply_filters('load_default_widgets', true) )
+		return;
+	require_once( ABSPATH . WPINC . '/default-widgets.php' );
+	add_action( '_admin_menu', 'wp_widgets_add_menu' );
+}
+
+/**
+ * Append the Widgets menu to the themes main menu.
+ *
+ * @since 2.2.0
+ * @uses $submenu The administration submenu list.
+ */
+function wp_widgets_add_menu() {
+	global $submenu;
+	$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' );
+	ksort( $submenu['themes.php'], SORT_NUMERIC );
+}
+
+/**
+ * Flush all output buffers for PHP 5.2.
+ *
+ * Make sure all output buffers are flushed before our singletons our destroyed.
+ *
+ * @since 2.2.0
+ */
+function wp_ob_end_flush_all() {
+	$levels = ob_get_level();
+	for ($i=0; $i<$levels; $i++)
+		ob_end_flush();
+}
+
+/**
+ * Load custom DB error or display WordPress DB error.
+ *
+ * If a file exists in the wp-content directory named db-error.php, then it will
+ * be loaded instead of displaying the WordPress DB error. If it is not found,
+ * then the WordPress DB error will be displayed instead.
+ *
+ * The WordPress DB error sets the HTTP status header to 500 to try to prevent
+ * search engines from caching the message. Custom DB messages should do the
+ * same.
+ *
+ * This function was backported to the the WordPress 2.3.2, but originally was
+ * added in WordPress 2.5.0.
+ *
+ * @since 2.3.2
+ * @uses $wpdb
+ */
+function dead_db() {
+	global $wpdb;
+
+	// Load custom DB error template, if present.
+	if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
+		require_once( WP_CONTENT_DIR . '/db-error.php' );
+		die();
+	}
+
+	// If installing or in the admin, provide the verbose message.
+	if ( defined('WP_INSTALLING') || defined('WP_ADMIN') )
+		wp_die($wpdb->error);
+
+	// Otherwise, be terse.
+	status_header( 500 );
+	nocache_headers();
+	header( 'Content-Type: text/html; charset=utf-8' );
+?>
+<!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 if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+	<title>Database Error</title>
+
+</head>
+<body>
+	<h1>Error establishing a database connection</h1>
+</body>
+</html>
+<?php
+	die();
+}
+
+/**
+ * Converts value to nonnegative integer.
+ *
+ * @since 2.5.0
+ *
+ * @param mixed $maybeint Data you wish to have convered to an nonnegative integer
+ * @return int An nonnegative integer
+ */
+function absint( $maybeint ) {
+	return abs( intval( $maybeint ) );
+}
+
+/**
+ * Determines if the blog can be accessed over SSL.
+ *
+ * Determines if blog can be accessed over SSL by using cURL to access the site
+ * using the https in the siteurl. Requires cURL extension to work correctly.
+ *
+ * @since 2.5.0
+ *
+ * @param string $url
+ * @return bool Whether SSL access is available
+ */
+function url_is_accessable_via_ssl($url)
+{
+	if (in_array('curl', get_loaded_extensions())) {
+		$ssl = preg_replace( '/^http:\/\//', 'https://',  $url );
+
+		$ch = curl_init();
+		curl_setopt($ch, CURLOPT_URL, $ssl);
+		curl_setopt($ch, CURLOPT_FAILONERROR, true);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
+
+		curl_exec($ch);
+
+		$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+		curl_close ($ch);
+
+		if ($status == 200 || $status == 401) {
+			return true;
+		}
+	}
+	return false;
+}
+
+/**
+ * Secure URL, if available or the given URL.
+ *
+ * @since 2.5.0
+ *
+ * @param string $url Complete URL path with transport.
+ * @return string Secure or regular URL path.
+ */
+function atom_service_url_filter($url)
+{
+	if ( url_is_accessable_via_ssl($url) )
+		return preg_replace( '/^http:\/\//', 'https://',  $url );
+	else
+		return $url;
+}
+
+/**
+ * Marks a function as deprecated and informs when it has been used.
+ *
+ * There is a hook deprecated_function_run that will be called that can be used
+ * to get the backtrace up to what file and function called the deprecated
+ * function.
+ *
+ * The current behavior is to trigger a user error if WP_DEBUG is true.
+ *
+ * This function is to be used in every function that is deprecated.
+ *
+ * @package WordPress
+ * @subpackage Debug
+ * @since 2.5.0
+ * @access private
+ *
+ * @uses do_action() Calls 'deprecated_function_run' and passes the function name, what to use instead,
+ *   and the version the function was deprecated in.
+ * @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do
+ *   trigger or false to not trigger error.
+ *
+ * @param string $function The function that was called
+ * @param string $version The version of WordPress that deprecated the function
+ * @param string $replacement Optional. The function that should have been called
+ */
+function _deprecated_function( $function, $version, $replacement=null ) {
+
+	do_action( 'deprecated_function_run', $function, $replacement, $version );
+
+	// Allow plugin to filter the output error trigger
+	if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
+		if ( ! is_null($replacement) )
+			trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
+		else
+			trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
+	}
+}
+
+/**
+ * Marks a file as deprecated and informs when it has been used.
+ *
+ * There is a hook deprecated_file_included that will be called that can be used
+ * to get the backtrace up to what file and function included the deprecated
+ * file.
+ *
+ * The current behavior is to trigger a user error if WP_DEBUG is true.
+ *
+ * This function is to be used in every file that is deprecated.
+ *
+ * @package WordPress
+ * @subpackage Debug
+ * @since 2.5.0
+ * @access private
+ *
+ * @uses do_action() Calls 'deprecated_file_included' and passes the file name, what to use instead,
+ *   the version in which the file was deprecated, and any message regarding the change.
+ * @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do
+ *   trigger or false to not trigger error.
+ *
+ * @param string $file The file that was included
+ * @param string $version The version of WordPress that deprecated the file
+ * @param string $replacement Optional. The file that should have been included based on ABSPATH
+ * @param string $message Optional. A message regarding the change
+ */
+function _deprecated_file( $file, $version, $replacement = null, $message = '' ) {
+
+	do_action( 'deprecated_file_included', $file, $replacement, $version, $message );
+
+	// Allow plugin to filter the output error trigger
+	if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) {
+		$message = empty( $message ) ? '' : ' ' . $message;
+		if ( ! is_null( $replacement ) )
+			trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );
+		else
+			trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
+	}
+}
+/**
+ * Marks a function argument as deprecated and informs when it has been used.
+ *
+ * This function is to be used whenever a deprecated function argument is used.
+ * Before this function is called, the argument must be checked for whether it was
+ * used by comparing it to its default value or evaluating whether it is empty.
+ * For example:
+ * <code>
+ * if ( !empty($deprecated) )
+ * 	_deprecated_argument( __FUNCTION__, '3.0' );
+ * </code>
+ *
+ * There is a hook deprecated_argument_run that will be called that can be used
+ * to get the backtrace up to what file and function used the deprecated
+ * argument.
+ *
+ * The current behavior is to trigger a user error if WP_DEBUG is true.
+ *
+ * @package WordPress
+ * @subpackage Debug
+ * @since 3.0.0
+ * @access private
+ *
+ * @uses do_action() Calls 'deprecated_argument_run' and passes the function name, a message on the change,
+ *   and the version in which the argument was deprecated.
+ * @uses apply_filters() Calls 'deprecated_argument_trigger_error' and expects boolean value of true to do
+ *   trigger or false to not trigger error.
+ *
+ * @param string $function The function that was called
+ * @param string $version The version of WordPress that deprecated the argument used
+ * @param string $message Optional. A message regarding the change.
+ */
+function _deprecated_argument( $function, $version, $message = null ) {
+
+	do_action( 'deprecated_argument_run', $function, $message, $version );
+
+	// Allow plugin to filter the output error trigger
+	if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
+		if ( ! is_null( $message ) )
+			trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
+		else
+			trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
+	}
+}
+
+/**
+ * Marks something as being incorrectly called.
+ *
+ * There is a hook doing_it_wrong_run that will be called that can be used
+ * to get the backtrace up to what file and function called the deprecated
+ * function.
+ *
+ * The current behavior is to trigger a user error if WP_DEBUG is true.
+ *
+ * @package WordPress
+ * @subpackage Debug
+ * @since 3.1.0
+ * @access private
+ *
+ * @uses do_action() Calls 'doing_it_wrong_run' and passes the function arguments.
+ * @uses apply_filters() Calls 'doing_it_wrong_trigger_error' and expects boolean value of true to do
+ *   trigger or false to not trigger error.
+ *
+ * @param string $function The function that was called.
+ * @param string $message A message explaining what has been done incorrectly.
+ * @param string $version The version of WordPress where the message was added.
+ */
+function _doing_it_wrong( $function, $message, $version ) {
+
+	do_action( 'doing_it_wrong_run', $function, $message, $version );
+
+	// Allow plugin to filter the output error trigger
+	if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
+		$version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version );
+		trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
+	}
+}
+
+/**
+ * Is the server running earlier than 1.5.0 version of lighttpd
+ *
+ * @since 2.5.0
+ *
+ * @return bool Whether the server is running lighttpd < 1.5.0
+ */
+function is_lighttpd_before_150() {
+	$server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );
+	$server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : '';
+	return  'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' );
+}
+
+/**
+ * Does the specified module exist in the apache config?
+ *
+ * @since 2.5.0
+ *
+ * @param string $mod e.g. mod_rewrite
+ * @param bool $default The default return value if the module is not found
+ * @return bool
+ */
+function apache_mod_loaded($mod, $default = false) {
+	global $is_apache;
+
+	if ( !$is_apache )
+		return false;
+
+	if ( function_exists('apache_get_modules') ) {
+		$mods = apache_get_modules();
+		if ( in_array($mod, $mods) )
+			return true;
+	} elseif ( function_exists('phpinfo') ) {
+			ob_start();
+			phpinfo(8);
+			$phpinfo = ob_get_clean();
+			if ( false !== strpos($phpinfo, $mod) )
+				return true;
+	}
+	return $default;
+}
+
+/**
+ * Check if IIS 7 supports pretty permalinks
+ *
+ * @since 2.8.0
+ *
+ * @return bool
+ */
+function iis7_supports_permalinks() {
+	global $is_iis7;
+
+	$supports_permalinks = false;
+	if ( $is_iis7 ) {
+		/* First we check if the DOMDocument class exists. If it does not exist,
+		 * which is the case for PHP 4.X, then we cannot easily update the xml configuration file,
+		 * hence we just bail out and tell user that pretty permalinks cannot be used.
+		 * This is not a big issue because PHP 4.X is going to be depricated and for IIS it
+		 * is recommended to use PHP 5.X NTS.
+		 * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When
+		 * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'.
+		 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs
+		 * via ISAPI then pretty permalinks will not work.
+		 */
+		$supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' );
+	}
+
+	return apply_filters('iis7_supports_permalinks', $supports_permalinks);
+}
+
+/**
+ * File validates against allowed set of defined rules.
+ *
+ * A return value of '1' means that the $file contains either '..' or './'. A
+ * return value of '2' means that the $file contains ':' after the first
+ * character. A return value of '3' means that the file is not in the allowed
+ * files list.
+ *
+ * @since 1.2.0
+ *
+ * @param string $file File path.
+ * @param array $allowed_files List of allowed files.
+ * @return int 0 means nothing is wrong, greater than 0 means something was wrong.
+ */
+function validate_file( $file, $allowed_files = '' ) {
+	if ( false !== strpos( $file, '..' ))
+		return 1;
+
+	if ( false !== strpos( $file, './' ))
+		return 1;
+
+	if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
+		return 3;
+
+	if (':' == substr( $file, 1, 1 ))
+		return 2;
+
+	return 0;
+}
+
+/**
+ * Determine if SSL is used.
+ *
+ * @since 2.6.0
+ *
+ * @return bool True if SSL, false if not used.
+ */
+function is_ssl() {
+	if ( isset($_SERVER['HTTPS']) ) {
+		if ( 'on' == strtolower($_SERVER['HTTPS']) )
+			return true;
+		if ( '1' == $_SERVER['HTTPS'] )
+			return true;
+	} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Whether SSL login should be forced.
+ *
+ * @since 2.6.0
+ *
+ * @param string|bool $force Optional.
+ * @return bool True if forced, false if not forced.
+ */
+function force_ssl_login( $force = null ) {
+	static $forced = false;
+
+	if ( !is_null( $force ) ) {
+		$old_forced = $forced;
+		$forced = $force;
+		return $old_forced;
+	}
+
+	return $forced;
+}
+
+/**
+ * Whether to force SSL used for the Administration Panels.
+ *
+ * @since 2.6.0
+ *
+ * @param string|bool $force
+ * @return bool True if forced, false if not forced.
+ */
+function force_ssl_admin( $force = null ) {
+	static $forced = false;
+
+	if ( !is_null( $force ) ) {
+		$old_forced = $forced;
+		$forced = $force;
+		return $old_forced;
+	}
+
+	return $forced;
+}
+
+/**
+ * Guess the URL for the site.
+ *
+ * Will remove wp-admin links to retrieve only return URLs not in the wp-admin
+ * directory.
+ *
+ * @since 2.6.0
+ *
+ * @return string
+ */
+function wp_guess_url() {
+	if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
+		$url = WP_SITEURL;
+	} else {
+		$schema = is_ssl() ? 'https://' : 'http://';
+		$url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+	}
+	return rtrim($url, '/');
+}
+
+/**
+ * Suspend cache invalidation.
+ *
+ * Turns cache invalidation on and off.  Useful during imports where you don't wont to do invalidations
+ * every time a post is inserted.  Callers must be sure that what they are doing won't lead to an inconsistent
+ * cache when invalidation is suspended.
+ *
+ * @since 2.7.0
+ *
+ * @param bool $suspend Whether to suspend or enable cache invalidation
+ * @return bool The current suspend setting
+ */
+function wp_suspend_cache_invalidation($suspend = true) {
+	global $_wp_suspend_cache_invalidation;
+
+	$current_suspend = $_wp_suspend_cache_invalidation;
+	$_wp_suspend_cache_invalidation = $suspend;
+	return $current_suspend;
+}
+
+/**
+ * Retrieve site option value based on name of option.
+ *
+ * @see get_option()
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
+ *
+ * @uses apply_filters() Calls 'pre_site_option_$option' before checking the option.
+ * 	Any value other than false will "short-circuit" the retrieval of the option
+ *	and return the returned value.
+ * @uses apply_filters() Calls 'site_option_$option', after checking the  option, with
+ * 	the option value.
+ *
+ * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
+ * @param mixed $default Optional value to return if option doesn't exist. Default false.
+ * @param bool $use_cache Whether to use cache. Multisite only. Default true.
+ * @return mixed Value set for the option.
+ */
+function get_site_option( $option, $default = false, $use_cache = true ) {
+	global $wpdb;
+
+	// Allow plugins to short-circuit site options.
+ 	$pre = apply_filters( 'pre_site_option_' . $option, false );
+ 	if ( false !== $pre )
+ 		return $pre;
+
+	if ( !is_multisite() ) {
+		$value = get_option($option, $default);
+	} else {
+		$cache_key = "{$wpdb->siteid}:$option";
+		if ( $use_cache )
+			$value = wp_cache_get($cache_key, 'site-options');
+
+		if ( !isset($value) || (false === $value) ) {
+			$row = $wpdb->get_row( $wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) );
+
+			// Has to be get_row instead of get_var because of funkiness with 0, false, null values
+			if ( is_object( $row ) )
+				$value = $row->meta_value;
+			else
+				$value = $default;
+
+			$value = maybe_unserialize( $value );
+
+			wp_cache_set( $cache_key, $value, 'site-options' );
+		}
+	}
+
+ 	return apply_filters( 'site_option_' . $option, $value );
+}
+
+/**
+ * Add a new site option.
+ *
+ * @see add_option()
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
+ *
+ * @uses apply_filters() Calls 'pre_add_site_option_$option' hook to allow overwriting the
+ * 	option value to be stored.
+ * @uses do_action() Calls 'add_site_option_$option' and 'add_site_option' hooks on success.
+ *
+ * @param string $option Name of option to add. Expected to not be SQL-escaped.
+ * @param mixed $value Optional. Option value, can be anything. Expected to not be SQL-escaped.
+ * @return bool False if option was not added and true if option was added.
+ */
+function add_site_option( $option, $value ) {
+	global $wpdb;
+
+	$value = apply_filters( 'pre_add_site_option_' . $option, $value );
+
+	if ( !is_multisite() ) {
+		$result = add_option( $option, $value );
+	} else {
+		$cache_key = "{$wpdb->siteid}:$option";
+
+		if ( $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
+			return update_site_option( $option, $value );
+
+		$value = sanitize_option( $option, $value );
+		wp_cache_set( $cache_key, $value, 'site-options' );
+
+		$_value = $value;
+		$value = maybe_serialize($value);
+		$result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );
+		$value = $_value;
+	}
+
+	do_action( "add_site_option_{$option}", $option, $value );
+	do_action( "add_site_option", $option, $value );
+
+	return $result;
+}
+
+/**
+ * Removes site option by name.
+ *
+ * @see delete_option()
+ * @package WordPress
+ * @subpackage Option
+ * @since 2.8.0
+ *
+ * @uses do_action() Calls 'pre_delete_site_option_$option' hook before option is deleted.
+ * @uses do_action() Calls 'delete_site_option' and 'delete_site_option_$option'
+ * 	hooks on success.
+ *
+ * @param string $option Name of option to remove. Expected to not be SQL-escaped.
+ * @return bool True, if succeed. False, if failure.
+ */
+function delete_site_option( $option ) {
+	global $wpdb;
+
+	// ms_protect_special_option( $option ); @todo
+
+	do_action( 'pre_delete_site_option_' . $option );
+
+	if ( !is_multisite() ) {
+		$result = delete_option( $option );
+	} else {
+		$row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) );
+		if ( is_null( $row ) || !$row->meta_id )
+			return false;
+		$cache_key = "{$wpdb->siteid}:$option";
+		wp_cache_delete( $cache_key, 'site-options' );
+
+		$result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) );
+	}
+
+	if ( $result ) {
+		do_action( "delete_site_option_{$option}", $option );
+		do_action( "delete_site_option", $option );
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Update the value of a site option that was already added.
+ *
+ * @see update_option()
+ * @since 2.8.0
+ * @package WordPress
+ * @subpackage Option
+ *
+ * @uses apply_filters() Calls 'pre_update_site_option_$option' hook to allow overwriting the
+ * 	option value to be stored.
+ * @uses do_action() Calls 'update_site_option_$option' and 'update_site_option' hooks on success.
+ *
+ * @param string $option Name of option. Expected to not be SQL-escaped.
+ * @param mixed $value Option value. Expected to not be SQL-escaped.
+ * @return bool False if value was not updated and true if value was updated.
+ */
+function update_site_option( $option, $value ) {
+	global $wpdb;
+
+	$oldvalue = get_site_option( $option );
+	$value = apply_filters( 'pre_update_site_option_' . $option, $value, $oldvalue );
+
+	if ( $value === $oldvalue )
+		return false;
+
+	if ( !is_multisite() ) {
+		$result = update_option( $option, $value );
+	} else {
+		$cache_key = "{$wpdb->siteid}:$option";
+
+		if ( $value && !$wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
+			return add_site_option( $option, $value );
+		$value = sanitize_option( $option, $value );
+		wp_cache_set( $cache_key, $value, 'site-options' );
+
+		$_value = $value;
+		$value = maybe_serialize( $value );
+		$result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $value ), array( 'site_id' => $wpdb->siteid, 'meta_key' => $option ) );
+		$value = $_value;
+	}
+
+	if ( $result ) {
+		do_action( "update_site_option_{$option}", $option, $value );
+		do_action( "update_site_option", $option, $value );
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Delete a site transient
+ *
+ * @since 2.9.0
+ * @package WordPress
+ * @subpackage Transient
+ *
+ * @uses do_action() Calls 'delete_site_transient_$transient' hook before transient is deleted.
+ * @uses do_action() Calls 'deleted_site_transient' hook on success.
+ *
+ * @param string $transient Transient name. Expected to not be SQL-escaped.
+ * @return bool True if successful, false otherwise
+ */
+function delete_site_transient( $transient ) {
+	global $_wp_using_ext_object_cache;
+
+	do_action( 'delete_site_transient_' . $transient, $transient );
+	if ( $_wp_using_ext_object_cache ) {
+		$result = wp_cache_delete( $transient, 'site-transient' );
+	} else {
+		$option_timeout = '_site_transient_timeout_' . $transient;
+		$option = '_site_transient_' . $transient;
+		$result = delete_site_option( $option );
+		if ( $result )
+			delete_site_option( $option_timeout );
+	}
+	if ( $result )
+		do_action( 'deleted_site_transient', $transient );
+	return $result;
+}
+
+/**
+ * Get the value of a site transient
+ *
+ * If the transient does not exist or does not have a value, then the return value
+ * will be false.
+ *
+ * @see get_transient()
+ * @since 2.9.0
+ * @package WordPress
+ * @subpackage Transient
+ *
+ * @uses apply_filters() Calls 'pre_site_transient_$transient' hook before checking the transient.
+ * 	Any value other than false will "short-circuit" the retrieval of the transient
+ *	and return the returned value.
+ * @uses apply_filters() Calls 'site_transient_$option' hook, after checking the transient, with
+ * 	the transient value.
+ *
+ * @param string $transient Transient name. Expected to not be SQL-escaped.
+ * @return mixed Value of transient
+ */
+function get_site_transient( $transient ) {
+	global $_wp_using_ext_object_cache;
+
+	$pre = apply_filters( 'pre_site_transient_' . $transient, false );
+	if ( false !== $pre )
+		return $pre;
+
+	if ( $_wp_using_ext_object_cache ) {
+		$value = wp_cache_get( $transient, 'site-transient' );
+	} else {
+		// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
+		$no_timeout = array('update_core', 'update_plugins', 'update_themes');
+		$transient_option = '_site_transient_' . $transient;
+		if ( ! in_array( $transient, $no_timeout ) ) {
+			$transient_timeout = '_site_transient_timeout_' . $transient;
+			$timeout = get_site_option( $transient_timeout );
+			if ( false !== $timeout && $timeout < time() ) {
+				delete_site_option( $transient_option  );
+				delete_site_option( $transient_timeout );
+				return false;
+			}
+		}
+
+		$value = get_site_option( $transient_option );
+	}
+
+	return apply_filters( 'site_transient_' . $transient, $value );
+}
+
+/**
+ * Set/update the value of a site transient
+ *
+ * You do not need to serialize values, if the value needs to be serialize, then
+ * it will be serialized before it is set.
+ *
+ * @see set_transient()
+ * @since 2.9.0
+ * @package WordPress
+ * @subpackage Transient
+ *
+ * @uses apply_filters() Calls 'pre_set_site_transient_$transient' hook to allow overwriting the
+ * 	transient value to be stored.
+ * @uses do_action() Calls 'set_site_transient_$transient' and 'setted_site_transient' hooks on success.
+ *
+ * @param string $transient Transient name. Expected to not be SQL-escaped.
+ * @param mixed $value Transient value. Expected to not be SQL-escaped.
+ * @param int $expiration Time until expiration in seconds, default 0
+ * @return bool False if value was not set and true if value was set.
+ */
+function set_site_transient( $transient, $value, $expiration = 0 ) {
+	global $_wp_using_ext_object_cache;
+
+	$value = apply_filters( 'pre_set_site_transient_' . $transient, $value );
+
+	if ( $_wp_using_ext_object_cache ) {
+		$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
+	} else {
+		$transient_timeout = '_site_transient_timeout_' . $transient;
+		$transient = '_site_transient_' . $transient;
+		if ( false === get_site_option( $transient ) ) {
+			if ( $expiration )
+				add_site_option( $transient_timeout, time() + $expiration );
+			$result = add_site_option( $transient, $value );
+		} else {
+			if ( $expiration )
+				update_site_option( $transient_timeout, time() + $expiration );
+			$result = update_site_option( $transient, $value );
+		}
+	}
+	if ( $result ) {
+		do_action( 'set_site_transient_' . $transient );
+		do_action( 'setted_site_transient', $transient );
+	}
+	return $result;
+}
+
+/**
+ * is main site
+ *
+ *
+ * @since 3.0.0
+ * @package WordPress
+ *
+ * @param int $blog_id optional blog id to test (default current blog)
+ * @return bool True if not multisite or $blog_id is main site
+ */
+function is_main_site( $blog_id = '' ) {
+	global $current_site, $current_blog;
+
+	if ( !is_multisite() )
+		return true;
+
+	if ( !$blog_id )
+		$blog_id = $current_blog->blog_id;
+
+	return $blog_id == $current_site->blog_id;
+}
+
+/**
+ * Whether global terms are enabled.
+ *
+ *
+ * @since 3.0.0
+ * @package WordPress
+ *
+ * @return bool True if multisite and global terms enabled
+ */
+function global_terms_enabled() {
+	if ( ! is_multisite() )
+		return false;
+
+	static $global_terms = null;
+	if ( is_null( $global_terms ) ) {
+		$filter = apply_filters( 'global_terms_enabled', null );
+		if ( ! is_null( $filter ) )
+			$global_terms = (bool) $filter;
+		else
+			$global_terms = (bool) get_site_option( 'global_terms_enabled', false );
+	}
+	return $global_terms;
+}
+
+/**
+ * gmt_offset modification for smart timezone handling
+ *
+ * Overrides the gmt_offset option if we have a timezone_string available
+ *
+ * @since 2.8.0
+ *
+ * @return float|bool
+ */
+function wp_timezone_override_offset() {
+	if ( !wp_timezone_supported() ) {
+		return false;
+	}
+	if ( !$timezone_string = get_option( 'timezone_string' ) ) {
+		return false;
+	}
+
+	$timezone_object = timezone_open( $timezone_string );
+	$datetime_object = date_create();
+	if ( false === $timezone_object || false === $datetime_object ) {
+		return false;
+	}
+	return round( timezone_offset_get( $timezone_object, $datetime_object ) / 3600, 2 );
+}
+
+/**
+ * Check for PHP timezone support
+ *
+ * @since 2.9.0
+ *
+ * @return bool
+ */
+function wp_timezone_supported() {
+	$support = false;
+	if (
+		function_exists( 'date_create' ) &&
+		function_exists( 'date_default_timezone_set' ) &&
+		function_exists( 'timezone_identifiers_list' ) &&
+		function_exists( 'timezone_open' ) &&
+		function_exists( 'timezone_offset_get' )
+	) {
+		$support = true;
+	}
+	return apply_filters( 'timezone_support', $support );
+}
+
+/**
+ * {@internal Missing Short Description}}
+ *
+ * @since 2.9.0
+ *
+ * @param unknown_type $a
+ * @param unknown_type $b
+ * @return int
+ */
+function _wp_timezone_choice_usort_callback( $a, $b ) {
+	// Don't use translated versions of Etc
+	if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) {
+		// Make the order of these more like the old dropdown
+		if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) {
+			return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) );
+		}
+		if ( 'UTC' === $a['city'] ) {
+			if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) {
+				return 1;
+			}
+			return -1;
+		}
+		if ( 'UTC' === $b['city'] ) {
+			if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) {
+				return -1;
+			}
+			return 1;
+		}
+		return strnatcasecmp( $a['city'], $b['city'] );
+	}
+	if ( $a['t_continent'] == $b['t_continent'] ) {
+		if ( $a['t_city'] == $b['t_city'] ) {
+			return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] );
+		}
+		return strnatcasecmp( $a['t_city'], $b['t_city'] );
+	} else {
+		// Force Etc to the bottom of the list
+		if ( 'Etc' === $a['continent'] ) {
+			return 1;
+		}
+		if ( 'Etc' === $b['continent'] ) {
+			return -1;
+		}
+		return strnatcasecmp( $a['t_continent'], $b['t_continent'] );
+	}
+}
+
+/**
+ * Gives a nicely formatted list of timezone strings // temporary! Not in final
+ *
+ * @since 2.9.0
+ *
+ * @param string $selected_zone Selected Zone
+ * @return string
+ */
+function wp_timezone_choice( $selected_zone ) {
+	static $mo_loaded = false;
+
+	$continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
+
+	// Load translations for continents and cities
+	if ( !$mo_loaded ) {
+		$locale = get_locale();
+		$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
+		load_textdomain( 'continents-cities', $mofile );
+		$mo_loaded = true;
+	}
+
+	$zonen = array();
+	foreach ( timezone_identifiers_list() as $zone ) {
+		$zone = explode( '/', $zone );
+		if ( !in_array( $zone[0], $continents ) ) {
+			continue;
+		}
+
+		// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
+		$exists = array(
+			0 => ( isset( $zone[0] ) && $zone[0] ),
+			1 => ( isset( $zone[1] ) && $zone[1] ),
+			2 => ( isset( $zone[2] ) && $zone[2] ),
+		);
+		$exists[3] = ( $exists[0] && 'Etc' !== $zone[0] );
+		$exists[4] = ( $exists[1] && $exists[3] );
+		$exists[5] = ( $exists[2] && $exists[3] );
+
+		$zonen[] = array(
+			'continent'   => ( $exists[0] ? $zone[0] : '' ),
+			'city'        => ( $exists[1] ? $zone[1] : '' ),
+			'subcity'     => ( $exists[2] ? $zone[2] : '' ),
+			't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ),
+			't_city'      => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ),
+			't_subcity'   => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' )
+		);
+	}
+	usort( $zonen, '_wp_timezone_choice_usort_callback' );
+
+	$structure = array();
+
+	if ( empty( $selected_zone ) ) {
+		$structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>';
+	}
+
+	foreach ( $zonen as $key => $zone ) {
+		// Build value in an array to join later
+		$value = array( $zone['continent'] );
+
+		if ( empty( $zone['city'] ) ) {
+			// It's at the continent level (generally won't happen)
+			$display = $zone['t_continent'];
+		} else {
+			// It's inside a continent group
+
+			// Continent optgroup
+			if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
+				$label = $zone['t_continent'];
+				$structure[] = '<optgroup label="'. esc_attr( $label ) .'">';
+			}
+
+			// Add the city to the value
+			$value[] = $zone['city'];
+
+			$display = $zone['t_city'];
+			if ( !empty( $zone['subcity'] ) ) {
+				// Add the subcity to the value
+				$value[] = $zone['subcity'];
+				$display .= ' - ' . $zone['t_subcity'];
+			}
+		}
+
+		// Build the value
+		$value = join( '/', $value );
+		$selected = '';
+		if ( $value === $selected_zone ) {
+			$selected = 'selected="selected" ';
+		}
+		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . "</option>";
+
+		// Close continent optgroup
+		if ( !empty( $zone['city'] ) && ( !isset($zonen[$key + 1]) || (isset( $zonen[$key + 1] ) && $zonen[$key + 1]['continent'] !== $zone['continent']) ) ) {
+			$structure[] = '</optgroup>';
+		}
+	}
+
+	// Do UTC
+	$structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
+	$selected = '';
+	if ( 'UTC' === $selected_zone )
+		$selected = 'selected="selected" ';
+	$structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
+	$structure[] = '</optgroup>';
+
+	// Do manual UTC offsets
+	$structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">';
+	$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;
+		else
+			$offset_name = (string) $offset;
+
+		$offset_value = $offset_name;
+		$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
+		$offset_name = 'UTC' . $offset_name;
+		$offset_value = 'UTC' . $offset_value;
+		$selected = '';
+		if ( $offset_value === $selected_zone )
+			$selected = 'selected="selected" ';
+		$structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
+
+	}
+	$structure[] = '</optgroup>';
+
+	return join( "\n", $structure );
+}
+
+/**
+ * Strip close comment and close php tags from file headers used by WP
+ * See http://core.trac.wordpress.org/ticket/8497
+ *
+ * @since 2.8.0
+ *
+ * @param string $str
+ * @return string
+ */
+function _cleanup_header_comment($str) {
+	return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
+}
+
+/**
+ * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
+ *
+ * @since 2.9.0
+ */
+function wp_scheduled_delete() {
+	global $wpdb;
+
+	$delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
+
+	$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
+
+	foreach ( (array) $posts_to_delete as $post ) {
+		$post_id = (int) $post['post_id'];
+		if ( !$post_id )
+			continue;
+
+		$del_post = get_post($post_id);
+
+		if ( !$del_post || 'trash' != $del_post->post_status ) {
+			delete_post_meta($post_id, '_wp_trash_meta_status');
+			delete_post_meta($post_id, '_wp_trash_meta_time');
+		} else {
+			wp_delete_post($post_id);
+		}
+	}
+
+	$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
+
+	foreach ( (array) $comments_to_delete as $comment ) {
+		$comment_id = (int) $comment['comment_id'];
+		if ( !$comment_id )
+			continue;
+
+		$del_comment = get_comment($comment_id);
+
+		if ( !$del_comment || 'trash' != $del_comment->comment_approved ) {
+			delete_comment_meta($comment_id, '_wp_trash_meta_time');
+			delete_comment_meta($comment_id, '_wp_trash_meta_status');
+		} else {
+			wp_delete_comment($comment_id);
+		}
+	}
+}
+
+/**
+ * Retrieve metadata from a file.
+ *
+ * Searches for metadata in the first 8kiB of a file, such as a plugin or theme.
+ * Each piece of metadata must be on its own line. Fields can not span multple
+ * lines, the value will get cut at the end of the first line.
+ *
+ * If the file data is not within that first 8kiB, then the author should correct
+ * their plugin file and move the data headers to the top.
+ *
+ * @see http://codex.wordpress.org/File_Header
+ *
+ * @since 2.9.0
+ * @param string $file Path to the file
+ * @param array $default_headers List of headers, in the format array('HeaderKey' => 'Header Name')
+ * @param string $context If specified adds filter hook "extra_{$context}_headers"
+ */
+function get_file_data( $file, $default_headers, $context = '' ) {
+	// We don't need to write to the file, so just open for reading.
+	$fp = fopen( $file, 'r' );
+
+	// Pull only the first 8kiB of the file in.
+	$file_data = fread( $fp, 8192 );
+
+	// PHP will close file handle, but we are good citizens.
+	fclose( $fp );
+
+	if ( $context != '' ) {
+		$extra_headers = apply_filters( "extra_{$context}_headers", array() );
+
+		$extra_headers = array_flip( $extra_headers );
+		foreach( $extra_headers as $key=>$value ) {
+			$extra_headers[$key] = $key;
+		}
+		$all_headers = array_merge( $extra_headers, (array) $default_headers );
+	} else {
+		$all_headers = $default_headers;
+	}
+
+	foreach ( $all_headers as $field => $regex ) {
+		preg_match( '/^[ \t\/*#]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field});
+		if ( !empty( ${$field} ) )
+			${$field} = _cleanup_header_comment( ${$field}[1] );
+		else
+			${$field} = '';
+	}
+
+	$file_data = compact( array_keys( $all_headers ) );
+
+	return $file_data;
+}
+
+/**
+ * Used internally to tidy up the search terms
+ *
+ * @access private
+ * @since 2.9.0
+ *
+ * @param string $t
+ * @return string
+ */
+function _search_terms_tidy($t) {
+	return trim($t, "\"'\n\r ");
+}
+
+/**
+ * Returns true
+ *
+ * Useful for returning true to filters easily
+ *
+ * @since 3.0.0
+ * @see __return_false()
+ * @return bool true
+ */
+function __return_true() {
+	return true;
+}
+
+/**
+ * Returns false
+ *
+ * Useful for returning false to filters easily
+ *
+ * @since 3.0.0
+ * @see __return_true()
+ * @return bool false
+ */
+function __return_false() {
+	return false;
+}
+
+/**
+ * Returns 0
+ *
+ * Useful for returning 0 to filters easily
+ *
+ * @since 3.0.0
+ * @see __return_zero()
+ * @return int 0
+ */
+function __return_zero() {
+	return 0;
+}
+
+/**
+ * Returns an empty array
+ *
+ * Useful for returning an empty array to filters easily
+ *
+ * @since 3.0.0
+ * @see __return_zero()
+ * @return array Empty array
+ */
+function __return_empty_array() {
+	return array();
+}
+
+/**
+ * Send a HTTP header to disable content type sniffing in browsers which support it.
+ *
+ * @link http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx
+ * @link http://src.chromium.org/viewvc/chrome?view=rev&revision=6985
+ *
+ * @since 3.0.0
+ * @return none
+ */
+function send_nosniff_header() {
+	@header( 'X-Content-Type-Options: nosniff' );
+}
+
+/**
+ * Returns a MySQL expression for selecting the week number based on the start_of_week option.
+ *
+ * @internal
+ * @since 3.0.0
+ * @param string $column
+ * @return string
+ */
+function _wp_mysql_week( $column ) {
+	switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) {
+	default :
+	case 0 :
+		return "WEEK( $column, 0 )";
+	case 1 :
+		return "WEEK( $column, 1 )";
+	case 2 :
+	case 3 :
+	case 4 :
+	case 5 :
+	case 6 :
+		return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )";
+	}
+}
+
+/**
+ * Finds hierarchy loops using a callback function that maps object IDs to parent IDs.
+ *
+ * @since 3.1.0
+ * @access private
+ *
+ * @param callback $callback function that accepts ( ID, $callback_args ) and outputs parent_ID
+ * @param int $start The ID to start the loop check at
+ * @param int $start_parent the parent_ID of $start to use instead of calling $callback( $start ). Use null to always use $callback
+ * @param array $callback_args optional additional arguments to send to $callback
+ * @return array IDs of all members of loop
+ */
+function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
+	$override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
+
+	if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) )
+		return array();
+
+	return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true );
+}
+
+/**
+ * Uses the "The Tortoise and the Hare" algorithm to detect loops.
+ *
+ * For every step of the algorithm, the hare takes two steps and the tortoise one.
+ * If the hare ever laps the tortoise, there must be a loop.
+ *
+ * @since 3.1.0
+ * @access private
+ *
+ * @param callback $callback function that accupts ( ID, callback_arg, ... ) and outputs parent_ID
+ * @param int $start The ID to start the loop check at
+ * @param array $override an array of ( ID => parent_ID, ... ) to use instead of $callback
+ * @param array $callback_args optional additional arguments to send to $callback
+ * @param bool $_return_loop Return loop members or just detect presence of loop?
+ *             Only set to true if you already know the given $start is part of a loop
+ *             (otherwise the returned array might include branches)
+ * @return mixed scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if $_return_loop
+ */
+function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) {
+	$tortoise = $hare = $evanescent_hare = $start;
+	$return = array();
+
+	// Set evanescent_hare to one past hare
+	// Increment hare two steps
+	while (
+		$tortoise
+	&&
+		( $evanescent_hare = isset( $override[$hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )
+	&&
+		( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
+	) {
+		if ( $_return_loop )
+			$return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true;
+
+		// tortoise got lapped - must be a loop
+		if ( $tortoise == $evanescent_hare || $tortoise == $hare )
+			return $_return_loop ? $return : $tortoise;
+
+		// Increment tortoise by one step
+		$tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );
+	}
+
+	return false;
+}
+
+?>
Index: /tags/3.1/wp-includes/functions.wp-scripts.php
===================================================================
--- /tags/3.1/wp-includes/functions.wp-scripts.php	(revision 17487)
+++ /tags/3.1/wp-includes/functions.wp-scripts.php	(revision 17487)
@@ -0,0 +1,147 @@
+<?php
+/**
+ * BackPress script procedural API.
+ *
+ * @package BackPress
+ * @since r16
+ */
+
+/**
+ * Prints script tags in document head.
+ *
+ * Called by admin-header.php and by wp_head hook. Since it is called by wp_head
+ * on every page load, the function does not instantiate the WP_Scripts object
+ * unless script names are explicitly passed. Does make use of already
+ * instantiated $wp_scripts if present. Use provided wp_print_scripts hook to
+ * register/enqueue new scripts.
+ *
+ * @since r16
+ * @see WP_Dependencies::print_scripts()
+ */
+function wp_print_scripts( $handles = false ) {
+	do_action( 'wp_print_scripts' );
+	if ( '' === $handles ) // for wp_head
+		$handles = false;
+
+	global $wp_scripts;
+	if ( !is_a($wp_scripts, 'WP_Scripts') ) {
+		if ( !$handles )
+			return array(); // No need to instantiate if nothing's there.
+		else
+			$wp_scripts = new WP_Scripts();
+	}
+
+	return $wp_scripts->do_items( $handles );
+}
+
+/**
+ * Register new JavaScript file.
+ *
+ * @since r16
+ * @param string $handle Script name
+ * @param string $src Script url
+ * @param array $deps (optional) Array of script names on which this script depends
+ * @param string|bool $ver (optional) Script version (used for cache busting), set to NULL to disable
+ * @param bool $in_footer (optional) Whether to enqueue the script before </head> or before </body>
+ * @return null
+ */
+function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
+	global $wp_scripts;
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		$wp_scripts = new WP_Scripts();
+
+	$wp_scripts->add( $handle, $src, $deps, $ver );
+	if ( $in_footer )
+		$wp_scripts->add_data( $handle, 'group', 1 );
+}
+
+/**
+ * Localizes a script.
+ *
+ * Localizes only if script has already been added.
+ *
+ * @since r16
+ * @see WP_Scripts::localize()
+ */
+function wp_localize_script( $handle, $object_name, $l10n ) {
+	global $wp_scripts;
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		return false;
+
+	return $wp_scripts->localize( $handle, $object_name, $l10n );
+}
+
+/**
+ * Remove a registered script.
+ *
+ * @since r16
+ * @see WP_Scripts::remove() For parameter information.
+ */
+function wp_deregister_script( $handle ) {
+	global $wp_scripts;
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		$wp_scripts = new WP_Scripts();
+
+	$wp_scripts->remove( $handle );
+}
+
+/**
+ * Enqueues script.
+ *
+ * Registers the script if src provided (does NOT overwrite) and enqueues.
+ *
+ * @since r16
+ * @see wp_register_script() For parameter information.
+ */
+function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
+	global $wp_scripts;
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		$wp_scripts = new WP_Scripts();
+
+	if ( $src ) {
+		$_handle = explode('?', $handle);
+		$wp_scripts->add( $_handle[0], $src, $deps, $ver );
+		if ( $in_footer )
+			$wp_scripts->add_data( $_handle[0], 'group', 1 );
+	}
+	$wp_scripts->enqueue( $handle );
+}
+
+/**
+ * Remove an enqueued script.
+ *
+ * @since WP 3.1
+ * @see WP_Scripts::dequeue() For parameter information.
+ */
+function wp_dequeue_script( $handle ) {
+	global $wp_scripts;
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		$wp_scripts = new WP_Scripts();
+
+	$wp_scripts->dequeue( $handle );
+}
+
+/**
+ * Check whether script has been added to WordPress Scripts.
+ *
+ * The values for list defaults to 'queue', which is the same as enqueue for
+ * scripts.
+ *
+ * @since WP unknown; BP unknown
+ *
+ * @param string $handle Handle used to add script.
+ * @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do'
+ * @return bool
+ */
+function wp_script_is( $handle, $list = 'queue' ) {
+	global $wp_scripts;
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		$wp_scripts = new WP_Scripts();
+
+	$query = $wp_scripts->query( $handle, $list );
+
+	if ( is_object( $query ) )
+		return true;
+
+	return $query;
+}
Index: /tags/3.1/wp-includes/functions.wp-styles.php
===================================================================
--- /tags/3.1/wp-includes/functions.wp-styles.php	(revision 17487)
+++ /tags/3.1/wp-includes/functions.wp-styles.php	(revision 17487)
@@ -0,0 +1,145 @@
+<?php
+/**
+ * BackPress styles procedural API.
+ *
+ * @package BackPress
+ * @since r79
+ */
+
+/**
+ * Display styles that are in the queue or part of $handles.
+ *
+ * @since r79
+ * @uses do_action() Calls 'wp_print_styles' hook.
+ * @global object $wp_styles The WP_Styles object for printing styles.
+ *
+ * @param array|bool $handles Styles to be printed. An empty array prints the queue,
+ *  an array with one string prints that style, and an array of strings prints those styles.
+ * @return bool True on success, false on failure.
+ */
+function wp_print_styles( $handles = false ) {
+	do_action( 'wp_print_styles' );
+	if ( '' === $handles ) // for wp_head
+		$handles = false;
+
+	global $wp_styles;
+	if ( !is_a($wp_styles, 'WP_Styles') ) {
+		if ( !$handles )
+			return array(); // No need to instantiate if nothing's there.
+		else
+			$wp_styles = new WP_Styles();
+	}
+
+	return $wp_styles->do_items( $handles );
+}
+
+/**
+ * Register CSS style file.
+ *
+ * @since r79
+ * @see WP_Styles::add() For additional information.
+ * @global object $wp_styles The WP_Styles object for printing styles.
+ * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
+ *
+ * @param string $handle Name of the stylesheet.
+ * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
+ * @param array $deps Array of handles of any stylesheet that this stylesheet depends on.
+ *  (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
+ * @param string|bool $ver String specifying the stylesheet version number. Set to NULL to disable.
+ *  Used to ensure that the correct version is sent to the client regardless of caching.
+ * @param string $media The media for which this stylesheet has been defined.
+ */
+function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
+	global $wp_styles;
+	if ( !is_a($wp_styles, 'WP_Styles') )
+		$wp_styles = new WP_Styles();
+
+	$wp_styles->add( $handle, $src, $deps, $ver, $media );
+}
+
+/**
+ * Remove a registered CSS file.
+ *
+ * @since r79
+ * @see WP_Styles::remove() For additional information.
+ * @global object $wp_styles The WP_Styles object for printing styles.
+ *
+ * @param string $handle Name of the stylesheet.
+ */
+function wp_deregister_style( $handle ) {
+	global $wp_styles;
+	if ( !is_a($wp_styles, 'WP_Styles') )
+		$wp_styles = new WP_Styles();
+
+	$wp_styles->remove( $handle );
+}
+
+/**
+ * Enqueue a CSS style file.
+ *
+ * Registers the style if src provided (does NOT overwrite) and enqueues.
+ *
+ * @since r79
+ * @see WP_Styles::add(), WP_Styles::enqueue()
+ * @global object $wp_styles The WP_Styles object for printing styles.
+ * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
+ *
+ * @param string $handle Name of the stylesheet.
+ * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
+ * @param array $deps Array of handles (names) of any stylesheet that this stylesheet depends on.
+ *  (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
+ * @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter
+ *  is used to ensure that the correct version is sent to the client regardless of caching, and so should be included
+ *  if a version number is available and makes sense for the stylesheet.
+ * @param string $media The media for which this stylesheet has been defined.
+ */
+function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
+	global $wp_styles;
+	if ( !is_a($wp_styles, 'WP_Styles') )
+		$wp_styles = new WP_Styles();
+
+	if ( $src ) {
+		$_handle = explode('?', $handle);
+		$wp_styles->add( $_handle[0], $src, $deps, $ver, $media );
+	}
+	$wp_styles->enqueue( $handle );
+}
+
+/**
+ * Remove an enqueued style.
+ *
+ * @since WP 3.1
+ * @see WP_Styles::dequeue() For parameter information.
+ */
+function wp_dequeue_style( $handle ) {
+	global $wp_styles;
+	if ( !is_a($wp_styles, 'WP_Styles') )
+		$wp_styles = new WP_Styles();
+
+	$wp_styles->dequeue( $handle );
+}
+
+/**
+ * Check whether style has been added to WordPress Styles.
+ *
+ * The values for list defaults to 'queue', which is the same as wp_enqueue_style().
+ *
+ * @since WP unknown; BP unknown
+ * @global object $wp_styles The WP_Styles object for printing styles.
+ *
+ * @param string $handle Name of the stylesheet.
+ * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'.
+ * @return bool True on success, false on failure.
+ */
+function wp_style_is( $handle, $list = 'queue' ) {
+	global $wp_styles;
+	if ( !is_a($wp_styles, 'WP_Styles') )
+		$wp_styles = new WP_Styles();
+
+	$query = $wp_styles->query( $handle, $list );
+
+	if ( is_object( $query ) )
+		return true;
+
+	return $query;
+}
Index: /tags/3.1/wp-includes/general-template.php
===================================================================
--- /tags/3.1/wp-includes/general-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/general-template.php	(revision 17487)
@@ -0,0 +1,2320 @@
+<?php
+/**
+ * General template tags that can go anywhere in a template.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Load header template.
+ *
+ * Includes the header template for a theme or if a name is specified then a
+ * specialised header will be included.
+ *
+ * For the parameter, if the file is called "header-special.php" then specify
+ * "special".
+ *
+ * @uses locate_template()
+ * @since 1.5.0
+ * @uses do_action() Calls 'get_header' action.
+ *
+ * @param string $name The name of the specialised header.
+ */
+function get_header( $name = null ) {
+	do_action( 'get_header', $name );
+
+	$templates = array();
+	if ( isset($name) )
+		$templates[] = "header-{$name}.php";
+
+	$templates[] = "header.php";
+
+	// Backward compat code will be removed in a future release
+	if ('' == locate_template($templates, true))
+		load_template( ABSPATH . WPINC . '/theme-compat/header.php');
+}
+
+/**
+ * Load footer template.
+ *
+ * Includes the footer template for a theme or if a name is specified then a
+ * specialised footer will be included.
+ *
+ * For the parameter, if the file is called "footer-special.php" then specify
+ * "special".
+ *
+ * @uses locate_template()
+ * @since 1.5.0
+ * @uses do_action() Calls 'get_footer' action.
+ *
+ * @param string $name The name of the specialised footer.
+ */
+function get_footer( $name = null ) {
+	do_action( 'get_footer', $name );
+
+	$templates = array();
+	if ( isset($name) )
+		$templates[] = "footer-{$name}.php";
+
+	$templates[] = "footer.php";
+
+	// Backward compat code will be removed in a future release
+	if ('' == locate_template($templates, true))
+		load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
+}
+
+/**
+ * Load sidebar template.
+ *
+ * Includes the sidebar template for a theme or if a name is specified then a
+ * specialised sidebar will be included.
+ *
+ * For the parameter, if the file is called "sidebar-special.php" then specify
+ * "special".
+ *
+ * @uses locate_template()
+ * @since 1.5.0
+ * @uses do_action() Calls 'get_sidebar' action.
+ *
+ * @param string $name The name of the specialised sidebar.
+ */
+function get_sidebar( $name = null ) {
+	do_action( 'get_sidebar', $name );
+
+	$templates = array();
+	if ( isset($name) )
+		$templates[] = "sidebar-{$name}.php";
+
+	$templates[] = "sidebar.php";
+
+	// Backward compat code will be removed in a future release
+	if ('' == locate_template($templates, true))
+		load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
+}
+
+/**
+ * Load a template part into a template
+ *
+ * Makes it easy for a theme to reuse sections of code in a easy to overload way
+ * for child themes.
+ *
+ * Includes the named template part for a theme or if a name is specified then a
+ * specialised part will be included. If the theme contains no {slug}.php file
+ * then no template will be included.
+ *
+ * The template is included using require, not require_once, so you may include the
+ * same template part multiple times.
+ *
+ * For the parameter, if the file is called "{slug}-special.php" then specify
+ * "special".
+ *
+ * @uses locate_template()
+ * @since 3.0.0
+ * @uses do_action() Calls 'get_template_part{$slug}' action.
+ *
+ * @param string $slug The slug name for the generic template.
+ * @param string $name The name of the specialised template.
+ */
+function get_template_part( $slug, $name = null ) {
+	do_action( "get_template_part_{$slug}", $slug, $name );
+
+	$templates = array();
+	if ( isset($name) )
+		$templates[] = "{$slug}-{$name}.php";
+
+	$templates[] = "{$slug}.php";
+
+	locate_template($templates, true, false);
+}
+
+/**
+ * Display search form.
+ *
+ * Will first attempt to locate the searchform.php file in either the child or
+ * the parent, then load it. If it doesn't exist, then the default search form
+ * will be displayed. The default search form is HTML, which will be displayed.
+ * There is a filter applied to the search form HTML in order to edit or replace
+ * it. The filter is 'get_search_form'.
+ *
+ * This function is primarily used by themes which want to hardcode the search
+ * form into the sidebar and also by the search widget in WordPress.
+ *
+ * There is also an action that is called whenever the function is run called,
+ * 'get_search_form'. This can be useful for outputting JavaScript that the
+ * search relies on or various formatting that applies to the beginning of the
+ * search. To give a few examples of what it can be used for.
+ *
+ * @since 2.7.0
+ * @param boolean $echo Default to echo and not return the form.
+ */
+function get_search_form($echo = true) {
+	do_action( 'get_search_form' );
+
+	$search_form_template = locate_template('searchform.php');
+	if ( '' != $search_form_template ) {
+		require($search_form_template);
+		return;
+	}
+
+	$form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
+	<div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
+	<input type="text" value="' . get_search_query() . '" name="s" id="s" />
+	<input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
+	</div>
+	</form>';
+
+	if ( $echo )
+		echo apply_filters('get_search_form', $form);
+	else
+		return apply_filters('get_search_form', $form);
+}
+
+/**
+ * Display the Log In/Out link.
+ *
+ * Displays a link, which allows users to navigate to the Log In page to log in
+ * or log out depending on whether they are currently logged in.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'loginout' hook on HTML link content.
+ *
+ * @param string $redirect Optional path to redirect to on login/logout.
+ * @param boolean $echo Default to echo and not return the link.
+ */
+function wp_loginout($redirect = '', $echo = true) {
+	if ( ! is_user_logged_in() )
+		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
+	else
+		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
+
+	if ( $echo )
+		echo apply_filters('loginout', $link);
+	else
+		return apply_filters('loginout', $link);
+}
+
+/**
+ * Returns the Log Out URL.
+ *
+ * Returns the URL that allows the user to log out of the site
+ *
+ * @since 2.7.0
+ * @uses wp_nonce_url() To protect against CSRF
+ * @uses site_url() To generate the log in URL
+ * @uses apply_filters() calls 'logout_url' hook on final logout url
+ *
+ * @param string $redirect Path to redirect to on logout.
+ */
+function wp_logout_url($redirect = '') {
+	$args = array( 'action' => 'logout' );
+	if ( !empty($redirect) ) {
+		$args['redirect_to'] = urlencode( $redirect );
+	}
+
+	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
+	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
+
+	return apply_filters('logout_url', $logout_url, $redirect);
+}
+
+/**
+ * Returns the Log In URL.
+ *
+ * Returns the URL that allows the user to log in to the site
+ *
+ * @since 2.7.0
+ * @uses site_url() To generate the log in URL
+ * @uses apply_filters() calls 'login_url' hook on final login url
+ *
+ * @param string $redirect Path to redirect to on login.
+ * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
+ * @return string A log in url
+ */
+function wp_login_url($redirect = '', $force_reauth = false) {
+	$login_url = site_url('wp-login.php', 'login');
+
+	if ( !empty($redirect) )
+		$login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
+
+	if ( $force_reauth )
+		$login_url = add_query_arg('reauth', '1', $login_url);
+
+	return apply_filters('login_url', $login_url, $redirect);
+}
+
+/**
+ * Provides a simple login form for use anywhere within WordPress. By default, it echoes
+ * the HTML immediately. Pass array('echo'=>false) to return the string instead.
+ *
+ * @since 3.0.0
+ * @param array $args Configuration options to modify the form output
+ * @return Void, or string containing the form
+ */
+function wp_login_form( $args = array() ) {
+	$defaults = array( 'echo' => true,
+						'redirect' => site_url( $_SERVER['REQUEST_URI'] ), // Default redirect is back to the current page
+	 					'form_id' => 'loginform',
+						'label_username' => __( 'Username' ),
+						'label_password' => __( 'Password' ),
+						'label_remember' => __( 'Remember Me' ),
+						'label_log_in' => __( 'Log In' ),
+						'id_username' => 'user_login',
+						'id_password' => 'user_pass',
+						'id_remember' => 'rememberme',
+						'id_submit' => 'wp-submit',
+						'remember' => true,
+						'value_username' => '',
+						'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
+					);
+	$args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
+
+	$form = '
+		<form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . site_url( 'wp-login.php', 'login' ) . '" method="post">
+			' . apply_filters( 'login_form_top', '', $args ) . '
+			<p class="login-username">
+				<label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
+				<input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" tabindex="10" />
+			</p>
+			<p class="login-password">
+				<label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
+				<input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" tabindex="20" />
+			</p>
+			' . apply_filters( 'login_form_middle', '', $args ) . '
+			' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever" tabindex="90"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
+			<p class="login-submit">
+				<input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" tabindex="100" />
+				<input type="hidden" name="redirect_to" value="' . esc_attr( $args['redirect'] ) . '" />
+			</p>
+			' . apply_filters( 'login_form_bottom', '', $args ) . '
+		</form>';
+
+	if ( $args['echo'] )
+		echo $form;
+	else
+		return $form;
+}
+
+/**
+ * Returns the Lost Password URL.
+ *
+ * Returns the URL that allows the user to retrieve the lost password
+ *
+ * @since 2.8.0
+ * @uses site_url() To generate the lost password URL
+ * @uses apply_filters() calls 'lostpassword_url' hook on the lostpassword url
+ *
+ * @param string $redirect Path to redirect to on login.
+ */
+function wp_lostpassword_url($redirect = '') {
+	$args = array( 'action' => 'lostpassword' );
+	if ( !empty($redirect) ) {
+		$args['redirect_to'] = $redirect;
+	}
+
+	$lostpassword_url = add_query_arg($args, site_url('wp-login.php', 'login'));
+	return apply_filters('lostpassword_url', $lostpassword_url, $redirect);
+}
+
+/**
+ * Display the Registration or Admin link.
+ *
+ * Display a link which allows the user to navigate to the registration page if
+ * not logged in and registration is enabled or to the dashboard if logged in.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'register' hook on register / admin link content.
+ *
+ * @param string $before Text to output before the link (defaults to <li>).
+ * @param string $after Text to output after the link (defaults to </li>).
+ * @param boolean $echo Default to echo and not return the link.
+ */
+function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
+
+	if ( ! is_user_logged_in() ) {
+		if ( get_option('users_can_register') )
+			$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
+		else
+			$link = '';
+	} else {
+		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
+	}
+
+	if ( $echo )
+		echo apply_filters('register', $link);
+	else
+		return apply_filters('register', $link);
+}
+
+/**
+ * Theme container function for the 'wp_meta' action.
+ *
+ * The 'wp_meta' action can have several purposes, depending on how you use it,
+ * but one purpose might have been to allow for theme switching.
+ *
+ * @since 1.5.0
+ * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
+ * @uses do_action() Calls 'wp_meta' hook.
+ */
+function wp_meta() {
+	do_action('wp_meta');
+}
+
+/**
+ * Display information about the blog.
+ *
+ * @see get_bloginfo() For possible values for the parameter.
+ * @since 0.71
+ *
+ * @param string $show What to display.
+ */
+function bloginfo( $show='' ) {
+	echo get_bloginfo( $show, 'display' );
+}
+
+/**
+ * Retrieve information about the blog.
+ *
+ * Some show parameter values are deprecated and will be removed in future
+ * versions. These options will trigger the _deprecated_argument() function.
+ * The deprecated blog info options are listed in the function contents.
+ *
+ * The possible values for the 'show' parameter are listed below.
+ * <ol>
+ * <li><strong>url</strong> - Blog URI to homepage.</li>
+ * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li>
+ * <li><strong>description</strong> - Secondary title</li>
+ * </ol>
+ *
+ * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
+ * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
+ * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
+ * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
+ *
+ * @since 0.71
+ *
+ * @param string $show Blog info to retrieve.
+ * @param string $filter How to filter what is retrieved.
+ * @return string Mostly string values, might be empty.
+ */
+function get_bloginfo( $show = '', $filter = 'raw' ) {
+
+	switch( $show ) {
+		case 'home' : // DEPRECATED
+		case 'siteurl' : // DEPRECATED
+			_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> option instead.' ), 'url'  ) );
+		case 'url' :
+			$output = home_url();
+			break;
+		case 'wpurl' :
+			$output = site_url();
+			break;
+		case 'description':
+			$output = get_option('blogdescription');
+			break;
+		case 'rdf_url':
+			$output = get_feed_link('rdf');
+			break;
+		case 'rss_url':
+			$output = get_feed_link('rss');
+			break;
+		case 'rss2_url':
+			$output = get_feed_link('rss2');
+			break;
+		case 'atom_url':
+			$output = get_feed_link('atom');
+			break;
+		case 'comments_atom_url':
+			$output = get_feed_link('comments_atom');
+			break;
+		case 'comments_rss2_url':
+			$output = get_feed_link('comments_rss2');
+			break;
+		case 'pingback_url':
+			$output = get_option('siteurl') .'/xmlrpc.php';
+			break;
+		case 'stylesheet_url':
+			$output = get_stylesheet_uri();
+			break;
+		case 'stylesheet_directory':
+			$output = get_stylesheet_directory_uri();
+			break;
+		case 'template_directory':
+		case 'template_url':
+			$output = get_template_directory_uri();
+			break;
+		case 'admin_email':
+			$output = get_option('admin_email');
+			break;
+		case 'charset':
+			$output = get_option('blog_charset');
+			if ('' == $output) $output = 'UTF-8';
+			break;
+		case 'html_type' :
+			$output = get_option('html_type');
+			break;
+		case 'version':
+			global $wp_version;
+			$output = $wp_version;
+			break;
+		case 'language':
+			$output = get_locale();
+			$output = str_replace('_', '-', $output);
+			break;
+		case 'text_direction':
+			//_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> function instead.' ), 'is_rtl()'  ) );
+			if ( function_exists( 'is_rtl' ) ) {
+				$output = is_rtl() ? 'rtl' : 'ltr';
+			} else {
+				$output = 'ltr';
+			}
+			break;
+		case 'name':
+		default:
+			$output = get_option('blogname');
+			break;
+	}
+
+	$url = true;
+	if (strpos($show, 'url') === false &&
+		strpos($show, 'directory') === false &&
+		strpos($show, 'home') === false)
+		$url = false;
+
+	if ( 'display' == $filter ) {
+		if ( $url )
+			$output = apply_filters('bloginfo_url', $output, $show);
+		else
+			$output = apply_filters('bloginfo', $output, $show);
+	}
+
+	return $output;
+}
+
+/**
+ * Retrieve the current blog id
+ *
+ * @since 3.1.0
+ *
+ * @return int Blog id
+ */
+function get_current_blog_id() {
+	global $blog_id;
+	return absint($blog_id);
+}
+
+/**
+ * Display or retrieve page title for all areas of blog.
+ *
+ * By default, the page title will display the separator before the page title,
+ * so that the blog title will be before the page title. This is not good for
+ * title display, since the blog title shows up on most tabs and not what is
+ * important, which is the page that the user is looking at.
+ *
+ * There are also SEO benefits to having the blog title after or to the 'right'
+ * or the page title. However, it is mostly common sense to have the blog title
+ * to the right with most browsers supporting tabs. You can achieve this by
+ * using the seplocation parameter and setting the value to 'right'. This change
+ * was introduced around 2.5.0, in case backwards compatibility of themes is
+ * important.
+ *
+ * @since 1.0.0
+ *
+ * @param string $sep Optional, default is '&raquo;'. How to separate the various items within the page title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @param string $seplocation Optional. Direction to display title, 'right'.
+ * @return string|null String on retrieve, null when displaying.
+ */
+function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
+	global $wpdb, $wp_locale;
+
+	$m = get_query_var('m');
+	$year = get_query_var('year');
+	$monthnum = get_query_var('monthnum');
+	$day = get_query_var('day');
+	$search = get_query_var('s');
+	$title = '';
+
+	$t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
+
+	// If there is a post
+	if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
+		$title = single_post_title( '', false );
+	}
+
+	// If there's a category or tag
+	if ( is_category() || is_tag() ) {
+		$title = single_term_title( '', false );
+	}
+
+	// If there's a taxonomy
+	if ( is_tax() ) {
+		$term = get_queried_object();
+		$tax = get_taxonomy( $term->taxonomy );
+		$title = single_term_title( $tax->labels->name . $t_sep, false );
+	}
+
+	// If there's an author
+	if ( is_author() ) {
+		$author = get_queried_object();
+		$title = $author->display_name;
+	}
+
+	// If there's a post type archive
+	if ( is_post_type_archive() )
+		$title = post_type_archive_title( '', false );
+
+	// If there's a month
+	if ( is_archive() && !empty($m) ) {
+		$my_year = substr($m, 0, 4);
+		$my_month = $wp_locale->get_month(substr($m, 4, 2));
+		$my_day = intval(substr($m, 6, 2));
+		$title = $my_year . ($my_month ? $t_sep . $my_month : "") . ($my_day ? $t_sep . $my_day : "");
+	}
+
+	// If there's a year
+	if ( is_archive() && !empty($year) ) {
+		$title = $year;
+		if ( !empty($monthnum) )
+			$title .= $t_sep . $wp_locale->get_month($monthnum);
+		if ( !empty($day) )
+			$title .= $t_sep . zeroise($day, 2);
+	}
+
+	// If it's a search
+	if ( is_search() ) {
+		/* translators: 1: separator, 2: search phrase */
+		$title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
+	}
+
+	// If it's a 404 page
+	if ( is_404() ) {
+		$title = __('Page not found');
+	}
+
+	$prefix = '';
+	if ( !empty($title) )
+		$prefix = " $sep ";
+
+ 	// Determines position of the separator and direction of the breadcrumb
+	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
+		$title_array = explode( $t_sep, $title );
+		$title_array = array_reverse( $title_array );
+		$title = implode( " $sep ", $title_array ) . $prefix;
+	} else {
+		$title_array = explode( $t_sep, $title );
+		$title = $prefix . implode( " $sep ", $title_array );
+	}
+
+	$title = apply_filters('wp_title', $title, $sep, $seplocation);
+
+	// Send it out
+	if ( $display )
+		echo $title;
+	else
+		return $title;
+
+}
+
+/**
+ * Display or retrieve page title for post.
+ *
+ * This is optimized for single.php template file for displaying the post title.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
+function single_post_title($prefix = '', $display = true) {
+	$_post = get_queried_object();
+
+	if ( !isset($_post->post_title) )
+		return;
+
+	$title = apply_filters('single_post_title', $_post->post_title, $_post);
+	if ( $display )
+		echo $prefix . $title;
+	else
+		return $title;
+}
+
+/**
+ * Display or retrieve title for a post type archive.
+ *
+ * This is optimized for archive.php and archive-{$post_type}.php template files
+ * for displaying the title of the post type.
+ *
+ * @since 3.1.0
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
+function post_type_archive_title( $prefix = '', $display = true ) {
+	if ( ! is_post_type_archive() )
+		return;
+
+	$post_type_obj = get_queried_object();
+	$title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
+
+	if ( $display )
+		echo $prefix . $title;
+	else
+		return $title;
+}
+
+/**
+ * Display or retrieve page title for category archive.
+ *
+ * This is useful for category template file or files, because it is optimized
+ * for category page title and with less overhead than {@link wp_title()}.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
+function single_cat_title( $prefix = '', $display = true ) {
+	return single_term_title( $prefix, $display );
+}
+
+/**
+ * Display or retrieve page title for tag post archive.
+ *
+ * Useful for tag template files for displaying the tag page title. It has less
+ * overhead than {@link wp_title()}, because of its limited implementation.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 2.3.0
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
+function single_tag_title( $prefix = '', $display = true ) {
+	return single_term_title( $prefix, $display );
+}
+
+/**
+ * Display or retrieve page title for taxonomy term archive.
+ *
+ * Useful for taxonomy term template files for displaying the taxonomy term page title.
+ * It has less overhead than {@link wp_title()}, because of its limited implementation.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 3.1.0
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
+function single_term_title( $prefix = '', $display = true ) {
+	$term = get_queried_object();
+
+	if ( !$term )
+		return;
+
+	if ( is_category() )
+		$term_name = apply_filters( 'single_cat_title', $term->name );
+	elseif ( is_tag() )
+		$term_name = apply_filters( 'single_tag_title', $term->name );
+	elseif ( is_tax() )
+		$term_name = apply_filters( 'single_term_title', $term->name );
+	else
+		return;
+
+	if ( empty( $term_name ) )
+		return;
+
+	if ( $display )
+		echo $prefix . $term_name;
+	else
+		return $term_name;
+}
+
+/**
+ * Display or retrieve page title for post archive based on date.
+ *
+ * Useful for when the template only needs to display the month and year, if
+ * either are available. Optimized for just this purpose, so if it is all that
+ * is needed, should be better than {@link wp_title()}.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
+function single_month_title($prefix = '', $display = true ) {
+	global $wp_locale;
+
+	$m = get_query_var('m');
+	$year = get_query_var('year');
+	$monthnum = get_query_var('monthnum');
+
+	if ( !empty($monthnum) && !empty($year) ) {
+		$my_year = $year;
+		$my_month = $wp_locale->get_month($monthnum);
+	} elseif ( !empty($m) ) {
+		$my_year = substr($m, 0, 4);
+		$my_month = $wp_locale->get_month(substr($m, 4, 2));
+	}
+
+	if ( empty($my_month) )
+		return false;
+
+	$result = $prefix . $my_month . $prefix . $my_year;
+
+	if ( !$display )
+		return $result;
+	echo $result;
+}
+
+/**
+ * Retrieve archive link content based on predefined or custom code.
+ *
+ * The format can be one of four styles. The 'link' for head element, 'option'
+ * for use in the select element, 'html' for use in list (either ol or ul HTML
+ * elements). Custom content is also supported using the before and after
+ * parameters.
+ *
+ * The 'link' format uses the link HTML element with the <em>archives</em>
+ * relationship. The before and after parameters are not used. The text
+ * parameter is used to describe the link.
+ *
+ * The 'option' format uses the option HTML element for use in select element.
+ * The value is the url parameter and the before and after parameters are used
+ * between the text description.
+ *
+ * The 'html' format, which is the default, uses the li HTML element for use in
+ * the list HTML elements. The before parameter is before the link and the after
+ * parameter is after the closing link.
+ *
+ * The custom format uses the before parameter before the link ('a' HTML
+ * element) and the after parameter after the closing link tag. If the above
+ * three values for the format are not used, then custom format is assumed.
+ *
+ * @since 1.0.0
+ *
+ * @param string $url URL to archive.
+ * @param string $text Archive text description.
+ * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
+ * @param string $before Optional.
+ * @param string $after Optional.
+ * @return string HTML link content for archive.
+ */
+function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
+	$text = wptexturize($text);
+	$title_text = esc_attr($text);
+	$url = esc_url($url);
+
+	if ('link' == $format)
+		$link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
+	elseif ('option' == $format)
+		$link_html = "\t<option value='$url'>$before $text $after</option>\n";
+	elseif ('html' == $format)
+		$link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
+	else // custom
+		$link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
+
+	$link_html = apply_filters( "get_archives_link", $link_html );
+
+	return $link_html;
+}
+
+/**
+ * Display archive links based on type and format.
+ *
+ * The 'type' argument offers a few choices and by default will display monthly
+ * archive links. The other options for values are 'daily', 'weekly', 'monthly',
+ * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
+ * same archive link list, the difference between the two is that 'alpha'
+ * will order by post title and 'postbypost' will order by post date.
+ *
+ * The date archives will logically display dates with links to the archive post
+ * page. The 'postbypost' and 'alpha' values for 'type' argument will display
+ * the post titles.
+ *
+ * The 'limit' argument will only display a limited amount of links, specified
+ * by the 'limit' integer value. By default, there is no limit. The
+ * 'show_post_count' argument will show how many posts are within the archive.
+ * By default, the 'show_post_count' argument is set to false.
+ *
+ * For the 'format', 'before', and 'after' arguments, see {@link
+ * get_archives_link()}. The values of these arguments have to do with that
+ * function.
+ *
+ * @since 1.2.0
+ *
+ * @param string|array $args Optional. Override defaults.
+ */
+function wp_get_archives($args = '') {
+	global $wpdb, $wp_locale;
+
+	$defaults = array(
+		'type' => 'monthly', 'limit' => '',
+		'format' => 'html', 'before' => '',
+		'after' => '', 'show_post_count' => false,
+		'echo' => 1
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	if ( '' == $type )
+		$type = 'monthly';
+
+	if ( '' != $limit ) {
+		$limit = absint($limit);
+		$limit = ' LIMIT '.$limit;
+	}
+
+	// this is what will separate dates on weekly archive links
+	$archive_week_separator = '&#8211;';
+
+	// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
+	$archive_date_format_over_ride = 0;
+
+	// options for daily archive (only if you over-ride the general date format)
+	$archive_day_date_format = 'Y/m/d';
+
+	// options for weekly archive (only if you over-ride the general date format)
+	$archive_week_start_date_format = 'Y/m/d';
+	$archive_week_end_date_format	= 'Y/m/d';
+
+	if ( !$archive_date_format_over_ride ) {
+		$archive_day_date_format = get_option('date_format');
+		$archive_week_start_date_format = get_option('date_format');
+		$archive_week_end_date_format = get_option('date_format');
+	}
+
+	//filters
+	$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
+	$join = apply_filters('getarchives_join', "", $r);
+
+	$output = '';
+
+	if ( 'monthly' == $type ) {
+		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
+		$key = md5($query);
+		$cache = wp_cache_get( 'wp_get_archives' , 'general');
+		if ( !isset( $cache[ $key ] ) ) {
+			$arcresults = $wpdb->get_results($query);
+			$cache[ $key ] = $arcresults;
+			wp_cache_set( 'wp_get_archives', $cache, 'general' );
+		} else {
+			$arcresults = $cache[ $key ];
+		}
+		if ( $arcresults ) {
+			$afterafter = $after;
+			foreach ( (array) $arcresults as $arcresult ) {
+				$url = get_month_link( $arcresult->year, $arcresult->month );
+				/* translators: 1: month name, 2: 4-digit year */
+				$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
+				if ( $show_post_count )
+					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
+				$output .= get_archives_link($url, $text, $format, $before, $after);
+			}
+		}
+	} elseif ('yearly' == $type) {
+		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit";
+		$key = md5($query);
+		$cache = wp_cache_get( 'wp_get_archives' , 'general');
+		if ( !isset( $cache[ $key ] ) ) {
+			$arcresults = $wpdb->get_results($query);
+			$cache[ $key ] = $arcresults;
+			wp_cache_set( 'wp_get_archives', $cache, 'general' );
+		} else {
+			$arcresults = $cache[ $key ];
+		}
+		if ($arcresults) {
+			$afterafter = $after;
+			foreach ( (array) $arcresults as $arcresult) {
+				$url = get_year_link($arcresult->year);
+				$text = sprintf('%d', $arcresult->year);
+				if ($show_post_count)
+					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
+				$output .= get_archives_link($url, $text, $format, $before, $after);
+			}
+		}
+	} elseif ( 'daily' == $type ) {
+		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit";
+		$key = md5($query);
+		$cache = wp_cache_get( 'wp_get_archives' , 'general');
+		if ( !isset( $cache[ $key ] ) ) {
+			$arcresults = $wpdb->get_results($query);
+			$cache[ $key ] = $arcresults;
+			wp_cache_set( 'wp_get_archives', $cache, 'general' );
+		} else {
+			$arcresults = $cache[ $key ];
+		}
+		if ( $arcresults ) {
+			$afterafter = $after;
+			foreach ( (array) $arcresults as $arcresult ) {
+				$url	= get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+				$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
+				$text = mysql2date($archive_day_date_format, $date);
+				if ($show_post_count)
+					$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
+				$output .= get_archives_link($url, $text, $format, $before, $after);
+			}
+		}
+	} elseif ( 'weekly' == $type ) {
+		$week = _wp_mysql_week( '`post_date`' );
+		$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` DESC $limit";
+		$key = md5($query);
+		$cache = wp_cache_get( 'wp_get_archives' , 'general');
+		if ( !isset( $cache[ $key ] ) ) {
+			$arcresults = $wpdb->get_results($query);
+			$cache[ $key ] = $arcresults;
+			wp_cache_set( 'wp_get_archives', $cache, 'general' );
+		} else {
+			$arcresults = $cache[ $key ];
+		}
+		$arc_w_last = '';
+		$afterafter = $after;
+		if ( $arcresults ) {
+				foreach ( (array) $arcresults as $arcresult ) {
+					if ( $arcresult->week != $arc_w_last ) {
+						$arc_year = $arcresult->yr;
+						$arc_w_last = $arcresult->week;
+						$arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
+						$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
+						$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
+						$url  = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
+						$text = $arc_week_start . $archive_week_separator . $arc_week_end;
+						if ($show_post_count)
+							$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
+						$output .= get_archives_link($url, $text, $format, $before, $after);
+					}
+				}
+		}
+	} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
+		$orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC ";
+		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
+		$key = md5($query);
+		$cache = wp_cache_get( 'wp_get_archives' , 'general');
+		if ( !isset( $cache[ $key ] ) ) {
+			$arcresults = $wpdb->get_results($query);
+			$cache[ $key ] = $arcresults;
+			wp_cache_set( 'wp_get_archives', $cache, 'general' );
+		} else {
+			$arcresults = $cache[ $key ];
+		}
+		if ( $arcresults ) {
+			foreach ( (array) $arcresults as $arcresult ) {
+				if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
+					$url  = get_permalink($arcresult);
+					$arc_title = $arcresult->post_title;
+					if ( $arc_title )
+						$text = strip_tags(apply_filters('the_title', $arc_title));
+					else
+						$text = $arcresult->ID;
+					$output .= get_archives_link($url, $text, $format, $before, $after);
+				}
+			}
+		}
+	}
+	if ( $echo )
+		echo $output;
+	else
+		return $output;
+}
+
+/**
+ * Get number of days since the start of the week.
+ *
+ * @since 1.5.0
+ * @usedby get_calendar()
+ *
+ * @param int $num Number of day.
+ * @return int Days since the start of the week.
+ */
+function calendar_week_mod($num) {
+	$base = 7;
+	return ($num - $base*floor($num/$base));
+}
+
+/**
+ * Display calendar with days that have posts as links.
+ *
+ * The calendar is cached, which will be retrieved, if it exists. If there are
+ * no posts for the month, then it will not be displayed.
+ *
+ * @since 1.0.0
+ *
+ * @param bool $initial Optional, default is true. Use initial calendar names.
+ * @param bool $echo Optional, default is true. Set to false for return.
+ */
+function get_calendar($initial = true, $echo = true) {
+	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
+
+	$cache = array();
+	$key = md5( $m . $monthnum . $year );
+	if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
+		if ( is_array($cache) && isset( $cache[ $key ] ) ) {
+			if ( $echo ) {
+				echo apply_filters( 'get_calendar',  $cache[$key] );
+				return;
+			} else {
+				return apply_filters( 'get_calendar',  $cache[$key] );
+			}
+		}
+	}
+
+	if ( !is_array($cache) )
+		$cache = array();
+
+	// Quick check. If we have no posts at all, abort!
+	if ( !$posts ) {
+		$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
+		if ( !$gotsome ) {
+			$cache[ $key ] = '';
+			wp_cache_set( 'get_calendar', $cache, 'calendar' );
+			return;
+		}
+	}
+
+	if ( isset($_GET['w']) )
+		$w = ''.intval($_GET['w']);
+
+	// week_begins = 0 stands for Sunday
+	$week_begins = intval(get_option('start_of_week'));
+
+	// Let's figure out when we are
+	if ( !empty($monthnum) && !empty($year) ) {
+		$thismonth = ''.zeroise(intval($monthnum), 2);
+		$thisyear = ''.intval($year);
+	} elseif ( !empty($w) ) {
+		// We need to get the month from MySQL
+		$thisyear = ''.intval(substr($m, 0, 4));
+		$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
+		$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
+	} elseif ( !empty($m) ) {
+		$thisyear = ''.intval(substr($m, 0, 4));
+		if ( strlen($m) < 6 )
+				$thismonth = '01';
+		else
+				$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
+	} else {
+		$thisyear = gmdate('Y', current_time('timestamp'));
+		$thismonth = gmdate('m', current_time('timestamp'));
+	}
+
+	$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
+	$last_day = date('t', $unixmonth);
+
+	// Get the next and previous month and year with at least one post
+	$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
+		FROM $wpdb->posts
+		WHERE post_date < '$thisyear-$thismonth-01'
+		AND post_type = 'post' AND post_status = 'publish'
+			ORDER BY post_date DESC
+			LIMIT 1");
+	$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
+		FROM $wpdb->posts
+		WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
+		AND post_type = 'post' AND post_status = 'publish'
+			ORDER BY post_date ASC
+			LIMIT 1");
+
+	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
+	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
+	$calendar_output = '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">
+	<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
+	<thead>
+	<tr>';
+
+	$myweek = array();
+
+	for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
+		$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
+	}
+
+	foreach ( $myweek as $wd ) {
+		$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
+		$wd = esc_attr($wd);
+		$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
+	}
+
+	$calendar_output .= '
+	</tr>
+	</thead>
+
+	<tfoot>
+	<tr>';
+
+	if ( $previous ) {
+		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
+	} else {
+		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
+	}
+
+	$calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
+
+	if ( $next ) {
+		$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
+	} else {
+		$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
+	}
+
+	$calendar_output .= '
+	</tr>
+	</tfoot>
+
+	<tbody>
+	<tr>';
+
+	// Get days with posts
+	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
+		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
+		AND post_type = 'post' AND post_status = 'publish'
+		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
+	if ( $dayswithposts ) {
+		foreach ( (array) $dayswithposts as $daywith ) {
+			$daywithpost[] = $daywith[0];
+		}
+	} else {
+		$daywithpost = array();
+	}
+
+	if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
+		$ak_title_separator = "\n";
+	else
+		$ak_title_separator = ', ';
+
+	$ak_titles_for_day = array();
+	$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
+		."FROM $wpdb->posts "
+		."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
+		."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
+		."AND post_type = 'post' AND post_status = 'publish'"
+	);
+	if ( $ak_post_titles ) {
+		foreach ( (array) $ak_post_titles as $ak_post_title ) {
+
+				$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
+
+				if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
+					$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
+				if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
+					$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
+				else
+					$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
+		}
+	}
+
+
+	// See how much we should pad in the beginning
+	$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
+	if ( 0 != $pad )
+		$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
+
+	$daysinmonth = intval(date('t', $unixmonth));
+	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
+		if ( isset($newrow) && $newrow )
+			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
+		$newrow = false;
+
+		if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
+			$calendar_output .= '<td id="today">';
+		else
+			$calendar_output .= '<td>';
+
+		if ( in_array($day, $daywithpost) ) // any posts today?
+				$calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">$day</a>";
+		else
+			$calendar_output .= $day;
+		$calendar_output .= '</td>';
+
+		if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
+			$newrow = true;
+	}
+
+	$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
+	if ( $pad != 0 && $pad != 7 )
+		$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
+
+	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
+
+	$cache[ $key ] = $calendar_output;
+	wp_cache_set( 'get_calendar', $cache, 'calendar' );
+
+	if ( $echo )
+		echo apply_filters( 'get_calendar',  $calendar_output );
+	else
+		return apply_filters( 'get_calendar',  $calendar_output );
+
+}
+
+/**
+ * Purge the cached results of get_calendar.
+ *
+ * @see get_calendar
+ * @since 2.1.0
+ */
+function delete_get_calendar_cache() {
+	wp_cache_delete( 'get_calendar', 'calendar' );
+}
+add_action( 'save_post', 'delete_get_calendar_cache' );
+add_action( 'delete_post', 'delete_get_calendar_cache' );
+add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
+add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
+
+/**
+ * Display all of the allowed tags in HTML format with attributes.
+ *
+ * This is useful for displaying in the comment area, which elements and
+ * attributes are supported. As well as any plugins which want to display it.
+ *
+ * @since 1.0.1
+ * @uses $allowedtags
+ *
+ * @return string HTML allowed tags entity encoded.
+ */
+function allowed_tags() {
+	global $allowedtags;
+	$allowed = '';
+	foreach ( (array) $allowedtags as $tag => $attributes ) {
+		$allowed .= '<'.$tag;
+		if ( 0 < count($attributes) ) {
+			foreach ( $attributes as $attribute => $limits ) {
+				$allowed .= ' '.$attribute.'=""';
+			}
+		}
+		$allowed .= '> ';
+	}
+	return htmlentities($allowed);
+}
+
+/***** Date/Time tags *****/
+
+/**
+ * Outputs the date in iso8601 format for xml files.
+ *
+ * @since 1.0.0
+ */
+function the_date_xml() {
+	global $post;
+	echo mysql2date('Y-m-d', $post->post_date, false);
+}
+
+/**
+ * Display or Retrieve the date the current $post was written (once per date)
+ *
+ * Will only output the date if the current post's date is different from the
+ * previous one output.
+ *
+ * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
+ * function is called several times for each post.
+ *
+ * HTML output can be filtered with 'the_date'.
+ * Date string output can be filtered with 'get_the_date'.
+ *
+ * @since 0.71
+ * @uses get_the_date()
+ * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
+ * @param string $before Optional. Output before the date.
+ * @param string $after Optional. Output after the date.
+ * @param bool $echo Optional, default is display. Whether to echo the date or return it.
+ * @return string|null Null if displaying, string if retrieving.
+ */
+function the_date( $d = '', $before = '', $after = '', $echo = true ) {
+	global $currentday, $previousday;
+	$the_date = '';
+	if ( $currentday != $previousday ) {
+		$the_date .= $before;
+		$the_date .= get_the_date( $d );
+		$the_date .= $after;
+		$previousday = $currentday;
+
+		$the_date = apply_filters('the_date', $the_date, $d, $before, $after);
+
+		if ( $echo )
+			echo $the_date;
+		else
+			return $the_date;
+	}
+
+	return null;
+}
+
+/**
+ * Retrieve the date the current $post was written.
+ *
+ * Unlike the_date() this function will always return the date.
+ * Modify output with 'get_the_date' filter.
+ *
+ * @since 3.0.0
+ *
+ * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
+ * @return string|null Null if displaying, string if retrieving.
+ */
+function get_the_date( $d = '' ) {
+	global $post;
+	$the_date = '';
+
+	if ( '' == $d )
+		$the_date .= mysql2date(get_option('date_format'), $post->post_date);
+	else
+		$the_date .= mysql2date($d, $post->post_date);
+
+	return apply_filters('get_the_date', $the_date, $d);
+}
+
+/**
+ * Display the date on which the post was last modified.
+ *
+ * @since 2.1.0
+ *
+ * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
+ * @param string $before Optional. Output before the date.
+ * @param string $after Optional. Output after the date.
+ * @param bool $echo Optional, default is display. Whether to echo the date or return it.
+ * @return string|null Null if displaying, string if retrieving.
+ */
+function the_modified_date($d = '', $before='', $after='', $echo = true) {
+
+	$the_modified_date = $before . get_the_modified_date($d) . $after;
+	$the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after);
+
+	if ( $echo )
+		echo $the_modified_date;
+	else
+		return $the_modified_date;
+
+}
+
+/**
+ * Retrieve the date on which the post was last modified.
+ *
+ * @since 2.1.0
+ *
+ * @param string $d Optional. PHP date format. Defaults to the "date_format" option
+ * @return string
+ */
+function get_the_modified_date($d = '') {
+	if ( '' == $d )
+		$the_time = get_post_modified_time(get_option('date_format'), null, null, true);
+	else
+		$the_time = get_post_modified_time($d, null, null, true);
+	return apply_filters('get_the_modified_date', $the_time, $d);
+}
+
+/**
+ * Display the time at which the post was written.
+ *
+ * @since 0.71
+ *
+ * @param string $d Either 'G', 'U', or php date format.
+ */
+function the_time( $d = '' ) {
+	echo apply_filters('the_time', get_the_time( $d ), $d);
+}
+
+/**
+ * Retrieve the time at which the post was written.
+ *
+ * @since 1.5.0
+ *
+ * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
+ * @param int|object $post Optional post ID or object. Default is global $post object.
+ * @return string
+ */
+function get_the_time( $d = '', $post = null ) {
+	$post = get_post($post);
+
+	if ( '' == $d )
+		$the_time = get_post_time(get_option('time_format'), false, $post, true);
+	else
+		$the_time = get_post_time($d, false, $post, true);
+	return apply_filters('get_the_time', $the_time, $d, $post);
+}
+
+/**
+ * Retrieve the time at which the post was written.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Optional Either 'G', 'U', or php date format.
+ * @param bool $gmt Optional, default is false. Whether to return the gmt time.
+ * @param int|object $post Optional post ID or object. Default is global $post object.
+ * @param bool $translate Whether to translate the time string
+ * @return string
+ */
+function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
+	$post = get_post($post);
+
+	if ( $gmt )
+		$time = $post->post_date_gmt;
+	else
+		$time = $post->post_date;
+
+	$time = mysql2date($d, $time, $translate);
+	return apply_filters('get_post_time', $time, $d, $gmt);
+}
+
+/**
+ * Display the time at which the post was last modified.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
+ */
+function the_modified_time($d = '') {
+	echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
+}
+
+/**
+ * Retrieve the time at which the post was last modified.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
+ * @return string
+ */
+function get_the_modified_time($d = '') {
+	if ( '' == $d )
+		$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
+	else
+		$the_time = get_post_modified_time($d, null, null, true);
+	return apply_filters('get_the_modified_time', $the_time, $d);
+}
+
+/**
+ * Retrieve the time at which the post was last modified.
+ *
+ * @since 2.0.0
+ *
+ * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
+ * @param bool $gmt Optional, default is false. Whether to return the gmt time.
+ * @param int|object $post Optional, default is global post object. A post_id or post object
+ * @param bool $translate Optional, default is false. Whether to translate the result
+ * @return string Returns timestamp
+ */
+function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
+	$post = get_post($post);
+
+	if ( $gmt )
+		$time = $post->post_modified_gmt;
+	else
+		$time = $post->post_modified;
+	$time = mysql2date($d, $time, $translate);
+
+	return apply_filters('get_post_modified_time', $time, $d, $gmt);
+}
+
+/**
+ * Display the weekday on which the post was written.
+ *
+ * @since 0.71
+ * @uses $wp_locale
+ * @uses $post
+ */
+function the_weekday() {
+	global $wp_locale, $post;
+	$the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
+	$the_weekday = apply_filters('the_weekday', $the_weekday);
+	echo $the_weekday;
+}
+
+/**
+ * Display the weekday on which the post was written.
+ *
+ * Will only output the weekday if the current post's weekday is different from
+ * the previous one output.
+ *
+ * @since 0.71
+ *
+ * @param string $before Optional Output before the date.
+ * @param string $after Optional Output after the date.
+ */
+function the_weekday_date($before='',$after='') {
+	global $wp_locale, $post, $day, $previousweekday;
+	$the_weekday_date = '';
+	if ( $currentday != $previousweekday ) {
+		$the_weekday_date .= $before;
+		$the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
+		$the_weekday_date .= $after;
+		$previousweekday = $currentday;
+	}
+	$the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
+	echo $the_weekday_date;
+}
+
+/**
+ * Fire the wp_head action
+ *
+ * @since 1.2.0
+ * @uses do_action() Calls 'wp_head' hook.
+ */
+function wp_head() {
+	do_action('wp_head');
+}
+
+/**
+ * Fire the wp_footer action
+ *
+ * @since 1.5.1
+ * @uses do_action() Calls 'wp_footer' hook.
+ */
+function wp_footer() {
+	do_action('wp_footer');
+}
+
+/**
+ * Display the links to the general feeds.
+ *
+ * @since 2.8.0
+ *
+ * @param array $args Optional arguments.
+ */
+function feed_links( $args = array() ) {
+	if ( !current_theme_supports('automatic-feed-links') )
+		return;
+
+	$defaults = array(
+		/* translators: Separator between blog name and feed type in feed links */
+		'separator'	=> _x('&raquo;', 'feed link'),
+		/* translators: 1: blog title, 2: separator (raquo) */
+		'feedtitle'	=> __('%1$s %2$s Feed'),
+		/* translators: %s: blog title, 2: separator (raquo) */
+		'comstitle'	=> __('%1$s %2$s Comments Feed'),
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
+	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . "\" />\n";
+	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link( 'comments_' . get_default_feed() ) . "\" />\n";
+}
+
+/**
+ * Display the links to the extra feeds such as category feeds.
+ *
+ * @since 2.8.0
+ *
+ * @param array $args Optional arguments.
+ */
+function feed_links_extra( $args = array() ) {
+	$defaults = array(
+		/* translators: Separator between blog name and feed type in feed links */
+		'separator'   => _x('&raquo;', 'feed link'),
+		/* translators: 1: blog name, 2: separator(raquo), 3: post title */
+		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
+		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
+		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
+		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
+		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
+		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
+		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
+		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
+		'searchtitle' => __('%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed'),
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+
+	if ( is_single() || is_page() ) {
+		$post = &get_post( $id = 0 );
+
+		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
+			$title = esc_attr(sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ));
+			$href = get_post_comments_feed_link( $post->ID );
+		}
+	} elseif ( is_category() ) {
+		$term = get_queried_object();
+
+		$title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ));
+		$href = get_category_feed_link( $term->term_id );
+	} elseif ( is_tag() ) {
+		$term = get_queried_object();
+
+		$title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ));
+		$href = get_tag_feed_link( $term->term_id );
+	} elseif ( is_author() ) {
+		$author_id = intval( get_query_var('author') );
+
+		$title = esc_attr(sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ));
+		$href = get_author_feed_link( $author_id );
+	} elseif ( is_search() ) {
+		$title = esc_attr(sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ));
+		$href = get_search_feed_link();
+	}
+
+	if ( isset($title) && isset($href) )
+		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n";
+}
+
+/**
+ * Display the link to the Really Simple Discovery service endpoint.
+ *
+ * @link http://archipelago.phrasewise.com/rsd
+ * @since 2.0.0
+ */
+function rsd_link() {
+	echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
+}
+
+/**
+ * Display the link to the Windows Live Writer manifest file.
+ *
+ * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
+ * @since 2.3.1
+ */
+function wlwmanifest_link() {
+	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
+		. get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
+}
+
+/**
+ * Display a noindex meta tag if required by the blog configuration.
+ *
+ * If a blog is marked as not being public then the noindex meta tag will be
+ * output to tell web robots not to index the page content.
+ *
+ * @since 2.1.0
+ */
+function noindex() {
+	// If the blog is not public, tell robots to go away.
+	if ( '0' == get_option('blog_public') )
+		echo "<meta name='robots' content='noindex,nofollow' />\n";
+}
+
+/**
+ * Determine if TinyMCE is available.
+ *
+ * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
+ *
+ * @since 2.1.0
+ *
+ * @return bool Whether TinyMCE exists.
+ */
+function rich_edit_exists() {
+	global $wp_rich_edit_exists;
+	if ( !isset($wp_rich_edit_exists) )
+		$wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
+	return $wp_rich_edit_exists;
+}
+
+/**
+ * Whether the user should have a WYSIWIG editor.
+ *
+ * Checks that the user requires a WYSIWIG editor and that the editor is
+ * supported in the users browser.
+ *
+ * @since 2.0.0
+ *
+ * @return bool
+ */
+function user_can_richedit() {
+	global $wp_rich_edit, $pagenow, $is_iphone;
+
+	if ( !isset( $wp_rich_edit) ) {
+		if ( get_user_option( 'rich_editing' ) == 'true' &&
+			!$is_iphone && // this includes all Safari mobile browsers
+			( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
+				!preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) )
+				&& 'comment.php' != $pagenow ) {
+			$wp_rich_edit = true;
+		} else {
+			$wp_rich_edit = false;
+		}
+	}
+
+	return apply_filters('user_can_richedit', $wp_rich_edit);
+}
+
+/**
+ * Find out which editor should be displayed by default.
+ *
+ * Works out which of the two editors to display as the current editor for a
+ * user.
+ *
+ * @since 2.5.0
+ *
+ * @return string Either 'tinymce', or 'html', or 'test'
+ */
+function wp_default_editor() {
+	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
+	if ( $user = wp_get_current_user() ) { // look for cookie
+		$ed = get_user_setting('editor', 'tinymce');
+		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
+	}
+	return apply_filters( 'wp_default_editor', $r ); // filter
+}
+
+/**
+ * Display visual editor forms: TinyMCE, or HTML, or both.
+ *
+ * The amount of rows the text area will have for the content has to be between
+ * 3 and 100 or will default at 12. There is only one option used for all users,
+ * named 'default_post_edit_rows'.
+ *
+ * If the user can not use the rich editor (TinyMCE), then the switch button
+ * will not be displayed.
+ *
+ * @since 2.1.0
+ *
+ * @param string $content Textarea content.
+ * @param string $id Optional, default is 'content'. HTML ID attribute value.
+ * @param string $prev_id Optional, default is 'title'. HTML ID name for switching back and forth between visual editors.
+ * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
+ * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
+ */
+function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2) {
+	$rows = get_option('default_post_edit_rows');
+	if (($rows < 3) || ($rows > 100))
+		$rows = 12;
+
+	if ( !current_user_can( 'upload_files' ) )
+		$media_buttons = false;
+
+	$richedit =  user_can_richedit();
+	$class = '';
+
+	if ( $richedit || $media_buttons ) { ?>
+	<div id="editor-toolbar">
+<?php
+	if ( $richedit ) {
+		$wp_default_editor = wp_default_editor(); ?>
+		<div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
+<?php	if ( 'html' == $wp_default_editor ) {
+			add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
+			<a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
+			<a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
+<?php	} else {
+			$class = " class='theEditor'";
+			add_filter('the_editor_content', 'wp_richedit_pre'); ?>
+			<a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
+			<a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
+<?php	}
+	}
+
+	if ( $media_buttons ) { ?>
+		<div id="media-buttons" class="hide-if-no-js">
+<?php	do_action( 'media_buttons' ); ?>
+		</div>
+<?php
+	} ?>
+	</div>
+<?php
+	}
+?>
+	<div id="quicktags"><?php
+	wp_print_scripts( 'quicktags' ); ?>
+	<script type="text/javascript">edToolbar()</script>
+	</div>
+
+<?php
+	$the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
+	$the_editor_content = apply_filters('the_editor_content', $content);
+
+	printf($the_editor, $the_editor_content);
+
+?>
+	<script type="text/javascript">
+	edCanvas = document.getElementById('<?php echo $id; ?>');
+	</script>
+<?php
+}
+
+/**
+ * Retrieve the contents of the search WordPress query variable.
+ *
+ * The search query string is passed through {@link esc_attr()}
+ * to ensure that it is safe for placing in an html attribute.
+ *
+ * @since 2.3.0
+ * @uses esc_attr()
+ *
+ * @param bool $escaped Whether the result is escaped. Default true.
+ * 	Only use when you are later escaping it. Do not use unescaped.
+ * @return string
+ */
+function get_search_query( $escaped = true ) {
+	$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
+	if ( $escaped )
+		$query = esc_attr( $query );
+	return $query;
+}
+
+/**
+ * Display the contents of the search query variable.
+ *
+ * The search query string is passed through {@link esc_attr()}
+ * to ensure that it is safe for placing in an html attribute.
+ *
+ * @uses esc_attr()
+ * @since 2.1.0
+ */
+function the_search_query() {
+	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
+}
+
+/**
+ * Display the language attributes for the html tag.
+ *
+ * Builds up a set of html attributes containing the text direction and language
+ * information for the page.
+ *
+ * @since 2.1.0
+ *
+ * @param string $doctype The type of html document (xhtml|html).
+ */
+function language_attributes($doctype = 'html') {
+	$attributes = array();
+	$output = '';
+
+	if ( function_exists( 'is_rtl' ) )
+		$attributes[] = 'dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"';
+
+	if ( $lang = get_bloginfo('language') ) {
+		if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
+			$attributes[] = "lang=\"$lang\"";
+
+		if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
+			$attributes[] = "xml:lang=\"$lang\"";
+	}
+
+	$output = implode(' ', $attributes);
+	$output = apply_filters('language_attributes', $output);
+	echo $output;
+}
+
+/**
+ * Retrieve paginated link for archive post pages.
+ *
+ * Technically, the function can be used to create paginated link list for any
+ * area. The 'base' argument is used to reference the url, which will be used to
+ * create the paginated links. The 'format' argument is then used for replacing
+ * the page number. It is however, most likely and by default, to be used on the
+ * archive post pages.
+ *
+ * The 'type' argument controls format of the returned value. The default is
+ * 'plain', which is just a string with the links separated by a newline
+ * character. The other possible values are either 'array' or 'list'. The
+ * 'array' value will return an array of the paginated link list to offer full
+ * control of display. The 'list' value will place all of the paginated links in
+ * an unordered HTML list.
+ *
+ * The 'total' argument is the total amount of pages and is an integer. The
+ * 'current' argument is the current page number and is also an integer.
+ *
+ * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
+ * and the '%_%' is required. The '%_%' will be replaced by the contents of in
+ * the 'format' argument. An example for the 'format' argument is "?page=%#%"
+ * and the '%#%' is also required. The '%#%' will be replaced with the page
+ * number.
+ *
+ * You can include the previous and next links in the list by setting the
+ * 'prev_next' argument to true, which it is by default. You can set the
+ * previous text, by using the 'prev_text' argument. You can set the next text
+ * by setting the 'next_text' argument.
+ *
+ * If the 'show_all' argument is set to true, then it will show all of the pages
+ * instead of a short list of the pages near the current page. By default, the
+ * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
+ * arguments. The 'end_size' argument is how many numbers on either the start
+ * and the end list edges, by default is 1. The 'mid_size' argument is how many
+ * numbers to either side of current page, but not including current page.
+ *
+ * It is possible to add query vars to the link by using the 'add_args' argument
+ * and see {@link add_query_arg()} for more information.
+ *
+ * @since 2.1.0
+ *
+ * @param string|array $args Optional. Override defaults.
+ * @return array|string String of page links or array of page links.
+ */
+function paginate_links( $args = '' ) {
+	$defaults = array(
+		'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
+		'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
+		'total' => 1,
+		'current' => 0,
+		'show_all' => false,
+		'prev_next' => true,
+		'prev_text' => __('&laquo; Previous'),
+		'next_text' => __('Next &raquo;'),
+		'end_size' => 1,
+		'mid_size' => 2,
+		'type' => 'plain',
+		'add_args' => false, // array of query args to add
+		'add_fragment' => ''
+	);
+
+	$args = wp_parse_args( $args, $defaults );
+	extract($args, EXTR_SKIP);
+
+	// Who knows what else people pass in $args
+	$total = (int) $total;
+	if ( $total < 2 )
+		return;
+	$current  = (int) $current;
+	$end_size = 0  < (int) $end_size ? (int) $end_size : 1; // Out of bounds?  Make it the default.
+	$mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
+	$add_args = is_array($add_args) ? $add_args : false;
+	$r = '';
+	$page_links = array();
+	$n = 0;
+	$dots = false;
+
+	if ( $prev_next && $current && 1 < $current ) :
+		$link = str_replace('%_%', 2 == $current ? '' : $format, $base);
+		$link = str_replace('%#%', $current - 1, $link);
+		if ( $add_args )
+			$link = add_query_arg( $add_args, $link );
+		$link .= $add_fragment;
+		$page_links[] = "<a class='prev page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$prev_text</a>";
+	endif;
+	for ( $n = 1; $n <= $total; $n++ ) :
+		$n_display = number_format_i18n($n);
+		if ( $n == $current ) :
+			$page_links[] = "<span class='page-numbers current'>$n_display</span>";
+			$dots = true;
+		else :
+			if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
+				$link = str_replace('%_%', 1 == $n ? '' : $format, $base);
+				$link = str_replace('%#%', $n, $link);
+				if ( $add_args )
+					$link = add_query_arg( $add_args, $link );
+				$link .= $add_fragment;
+				$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
+				$dots = true;
+			elseif ( $dots && !$show_all ) :
+				$page_links[] = "<span class='page-numbers dots'>...</span>";
+				$dots = false;
+			endif;
+		endif;
+	endfor;
+	if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
+		$link = str_replace('%_%', $format, $base);
+		$link = str_replace('%#%', $current + 1, $link);
+		if ( $add_args )
+			$link = add_query_arg( $add_args, $link );
+		$link .= $add_fragment;
+		$page_links[] = "<a class='next page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$next_text</a>";
+	endif;
+	switch ( $type ) :
+		case 'array' :
+			return $page_links;
+			break;
+		case 'list' :
+			$r .= "<ul class='page-numbers'>\n\t<li>";
+			$r .= join("</li>\n\t<li>", $page_links);
+			$r .= "</li>\n</ul>\n";
+			break;
+		default :
+			$r = join("\n", $page_links);
+			break;
+	endswitch;
+	return $r;
+}
+
+/**
+ * Registers an admin colour scheme css file.
+ *
+ * Allows a plugin to register a new admin colour scheme. For example:
+ * <code>
+ * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
+ * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
+ * </code>
+ *
+ * @since 2.5.0
+ *
+ * @param string $key The unique key for this theme.
+ * @param string $name The name of the theme.
+ * @param string $url The url of the css file containing the colour scheme.
+ * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
+ */
+function wp_admin_css_color($key, $name, $url, $colors = array()) {
+	global $_wp_admin_css_colors;
+
+	if ( !isset($_wp_admin_css_colors) )
+		$_wp_admin_css_colors = array();
+
+	$_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
+}
+
+/**
+ * Registers the default Admin color schemes
+ *
+ * @since 3.0.0
+ */
+function register_admin_color_schemes() {
+	wp_admin_css_color( 'classic', __( 'Blue' ), admin_url( 'css/colors-classic.css' ),
+		array( '#5589aa', '#cfdfe9', '#d1e5ee', '#eff8ff' ) );
+	wp_admin_css_color( 'fresh', __( 'Gray' ), admin_url( 'css/colors-fresh.css' ),
+		array( '#7c7976', '#c6c6c6', '#e0e0e0', '#f1f1f1' ) );
+}
+
+/**
+ * Display the URL of a WordPress admin CSS file.
+ *
+ * @see WP_Styles::_css_href and its style_loader_src filter.
+ *
+ * @since 2.3.0
+ *
+ * @param string $file file relative to wp-admin/ without its ".css" extension.
+ */
+function wp_admin_css_uri( $file = 'wp-admin' ) {
+	if ( defined('WP_INSTALLING') ) {
+		$_file = "./$file.css";
+	} else {
+		$_file = admin_url("$file.css");
+	}
+	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
+
+	return apply_filters( 'wp_admin_css_uri', $_file, $file );
+}
+
+/**
+ * Enqueues or directly prints a stylesheet link to the specified CSS file.
+ *
+ * "Intelligently" decides to enqueue or to print the CSS file. If the
+ * 'wp_print_styles' action has *not* yet been called, the CSS file will be
+ * enqueued. If the wp_print_styles action *has* been called, the CSS link will
+ * be printed. Printing may be forced by passing TRUE as the $force_echo
+ * (second) parameter.
+ *
+ * For backward compatibility with WordPress 2.3 calling method: If the $file
+ * (first) parameter does not correspond to a registered CSS file, we assume
+ * $file is a file relative to wp-admin/ without its ".css" extension. A
+ * stylesheet link to that generated URL is printed.
+ *
+ * @package WordPress
+ * @since 2.3.0
+ * @uses $wp_styles WordPress Styles Object
+ *
+ * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
+ * 	 to wp-admin/. Defaults to 'wp-admin'.
+ * @param bool $force_echo Optional.  Force the stylesheet link to be printed rather than enqueued.
+ */
+function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
+	global $wp_styles;
+	if ( !is_a($wp_styles, 'WP_Styles') )
+		$wp_styles = new WP_Styles();
+
+	// For backward compatibility
+	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
+
+	if ( $wp_styles->query( $handle ) ) {
+		if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue.  Print this one immediately
+			wp_print_styles( $handle );
+		else // Add to style queue
+			wp_enqueue_style( $handle );
+		return;
+	}
+
+	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
+	if ( is_rtl() )
+		echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
+}
+
+/**
+ * Enqueues the default ThickBox js and css.
+ *
+ * If any of the settings need to be changed, this can be done with another js
+ * file similar to media-upload.js and theme-preview.js. That file should
+ * require array('thickbox') to ensure it is loaded after.
+ *
+ * @since 2.5.0
+ */
+function add_thickbox() {
+	wp_enqueue_script( 'thickbox' );
+	wp_enqueue_style( 'thickbox' );
+
+	if ( is_network_admin() )
+		add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
+}
+
+/**
+ * Display the XHTML generator that is generated on the wp_head hook.
+ *
+ * @since 2.5.0
+ */
+function wp_generator() {
+	the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
+}
+
+/**
+ * Display the generator XML or Comment for RSS, ATOM, etc.
+ *
+ * Returns the correct generator type for the requested output format. Allows
+ * for a plugin to filter generators overall the the_generator filter.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'the_generator' hook.
+ *
+ * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
+ */
+function the_generator( $type ) {
+	echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
+}
+
+/**
+ * Creates the generator XML or Comment for RSS, ATOM, etc.
+ *
+ * Returns the correct generator type for the requested output format. Allows
+ * for a plugin to filter generators on an individual basis using the
+ * 'get_the_generator_{$type}' filter.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'get_the_generator_$type' hook.
+ *
+ * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
+ * @return string The HTML content for the generator.
+ */
+function get_the_generator( $type = '' ) {
+	if ( empty( $type ) ) {
+
+		$current_filter = current_filter();
+		if ( empty( $current_filter ) )
+			return;
+
+		switch ( $current_filter ) {
+			case 'rss2_head' :
+			case 'commentsrss2_head' :
+				$type = 'rss2';
+				break;
+			case 'rss_head' :
+			case 'opml_head' :
+				$type = 'comment';
+				break;
+			case 'rdf_header' :
+				$type = 'rdf';
+				break;
+			case 'atom_head' :
+			case 'comments_atom_head' :
+			case 'app_head' :
+				$type = 'atom';
+				break;
+		}
+	}
+
+	switch ( $type ) {
+		case 'html':
+			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
+			break;
+		case 'xhtml':
+			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
+			break;
+		case 'atom':
+			$gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
+			break;
+		case 'rss2':
+			$gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
+			break;
+		case 'rdf':
+			$gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
+			break;
+		case 'comment':
+			$gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
+			break;
+		case 'export':
+			$gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
+			break;
+	}
+	return apply_filters( "get_the_generator_{$type}", $gen, $type );
+}
+
+/**
+ * Outputs the html checked attribute.
+ *
+ * Compares the first two arguments and if identical marks as checked
+ *
+ * @since 1.0.0
+ *
+ * @param mixed $checked One of the values to compare
+ * @param mixed $current (true) The other value to compare if not just true
+ * @param bool $echo Whether to echo or just return the string
+ * @return string html attribute or empty string
+ */
+function checked( $checked, $current = true, $echo = true ) {
+	return __checked_selected_helper( $checked, $current, $echo, 'checked' );
+}
+
+/**
+ * Outputs the html selected attribute.
+ *
+ * Compares the first two arguments and if identical marks as selected
+ *
+ * @since 1.0.0
+ *
+ * @param mixed $selected One of the values to compare
+ * @param mixed $current (true) The other value to compare if not just true
+ * @param bool $echo Whether to echo or just return the string
+ * @return string html attribute or empty string
+ */
+function selected( $selected, $current = true, $echo = true ) {
+	return __checked_selected_helper( $selected, $current, $echo, 'selected' );
+}
+
+/**
+ * Outputs the html disabled attribute.
+ *
+ * Compares the first two arguments and if identical marks as disabled
+ *
+ * @since 3.0.0
+ *
+ * @param mixed $disabled One of the values to compare
+ * @param mixed $current (true) The other value to compare if not just true
+ * @param bool $echo Whether to echo or just return the string
+ * @return string html attribute or empty string
+ */
+function disabled( $disabled, $current = true, $echo = true ) {
+	return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
+}
+
+/**
+ * Private helper function for checked, selected, and disabled.
+ *
+ * Compares the first two arguments and if identical marks as $type
+ *
+ * @since 2.8.0
+ * @access private
+ *
+ * @param any $helper One of the values to compare
+ * @param any $current (true) The other value to compare if not just true
+ * @param bool $echo Whether to echo or just return the string
+ * @param string $type The type of checked|selected|disabled we are doing
+ * @return string html attribute or empty string
+ */
+function __checked_selected_helper( $helper, $current, $echo, $type ) {
+	if ( (string) $helper === (string) $current )
+		$result = " $type='$type'";
+	else
+		$result = '';
+
+	if ( $echo )
+		echo $result;
+
+	return $result;
+}
+
+?>
Index: /tags/3.1/wp-includes/http.php
===================================================================
--- /tags/3.1/wp-includes/http.php	(revision 17487)
+++ /tags/3.1/wp-includes/http.php	(revision 17487)
@@ -0,0 +1,194 @@
+<?php
+/**
+ * Simple and uniform HTTP request API.
+ *
+ * Will eventually replace and standardize the WordPress HTTP requests made.
+ *
+ * @link http://trac.wordpress.org/ticket/4779 HTTP API Proposal
+ *
+ * @package WordPress
+ * @subpackage HTTP
+ * @since 2.7.0
+ */
+
+/**
+ * Returns the initialized WP_Http Object
+ *
+ * @since 2.7.0
+ * @access private
+ *
+ * @return WP_Http HTTP Transport object.
+ */
+function &_wp_http_get_object() {
+	static $http;
+
+	if ( is_null($http) )
+		$http = new WP_Http();
+
+	return $http;
+}
+
+/**
+ * Retrieve the raw response from the HTTP request.
+ *
+ * The array structure is a little complex.
+ *
+ * <code>
+ * $res = array( 'headers' => array(), 'response' => array('code' => int, 'message' => string) );
+ * </code>
+ *
+ * All of the headers in $res['headers'] are with the name as the key and the
+ * value as the value. So to get the User-Agent, you would do the following.
+ *
+ * <code>
+ * $user_agent = $res['headers']['user-agent'];
+ * </code>
+ *
+ * The body is the raw response content and can be retrieved from $res['body'].
+ *
+ * This function is called first to make the request and there are other API
+ * functions to abstract out the above convoluted setup.
+ *
+ * @since 2.7.0
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return WP_Error|array The response or WP_Error on failure.
+ */
+function wp_remote_request($url, $args = array()) {
+	$objFetchSite = _wp_http_get_object();
+	return $objFetchSite->request($url, $args);
+}
+
+/**
+ * Retrieve the raw response from the HTTP request using the GET method.
+ *
+ * @see wp_remote_request() For more information on the response array format.
+ *
+ * @since 2.7.0
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return WP_Error|array The response or WP_Error on failure.
+ */
+function wp_remote_get($url, $args = array()) {
+	$objFetchSite = _wp_http_get_object();
+	return $objFetchSite->get($url, $args);
+}
+
+/**
+ * Retrieve the raw response from the HTTP request using the POST method.
+ *
+ * @see wp_remote_request() For more information on the response array format.
+ *
+ * @since 2.7.0
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return WP_Error|array The response or WP_Error on failure.
+ */
+function wp_remote_post($url, $args = array()) {
+	$objFetchSite = _wp_http_get_object();
+	return $objFetchSite->post($url, $args);
+}
+
+/**
+ * Retrieve the raw response from the HTTP request using the HEAD method.
+ *
+ * @see wp_remote_request() For more information on the response array format.
+ *
+ * @since 2.7.0
+ *
+ * @param string $url Site URL to retrieve.
+ * @param array $args Optional. Override the defaults.
+ * @return WP_Error|array The response or WP_Error on failure.
+ */
+function wp_remote_head($url, $args = array()) {
+	$objFetchSite = _wp_http_get_object();
+	return $objFetchSite->head($url, $args);
+}
+
+/**
+ * Retrieve only the headers from the raw response.
+ *
+ * @since 2.7.0
+ *
+ * @param array $response HTTP response.
+ * @return array The headers of the response. Empty array if incorrect parameter given.
+ */
+function wp_remote_retrieve_headers(&$response) {
+	if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
+		return array();
+
+	return $response['headers'];
+}
+
+/**
+ * Retrieve a single header by name from the raw response.
+ *
+ * @since 2.7.0
+ *
+ * @param array $response
+ * @param string $header Header name to retrieve value from.
+ * @return string The header value. Empty string on if incorrect parameter given, or if the header doesnt exist.
+ */
+function wp_remote_retrieve_header(&$response, $header) {
+	if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
+		return '';
+
+	if ( array_key_exists($header, $response['headers']) )
+		return $response['headers'][$header];
+
+	return '';
+}
+
+/**
+ * Retrieve only the response code from the raw response.
+ *
+ * Will return an empty array if incorrect parameter value is given.
+ *
+ * @since 2.7.0
+ *
+ * @param array $response HTTP response.
+ * @return string the response code. Empty string on incorrect parameter given.
+ */
+function wp_remote_retrieve_response_code(&$response) {
+	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
+		return '';
+
+	return $response['response']['code'];
+}
+
+/**
+ * Retrieve only the response message from the raw response.
+ *
+ * Will return an empty array if incorrect parameter value is given.
+ *
+ * @since 2.7.0
+ *
+ * @param array $response HTTP response.
+ * @return string The response message. Empty string on incorrect parameter given.
+ */
+function wp_remote_retrieve_response_message(&$response) {
+	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
+		return '';
+
+	return $response['response']['message'];
+}
+
+/**
+ * Retrieve only the body from the raw response.
+ *
+ * @since 2.7.0
+ *
+ * @param array $response HTTP response.
+ * @return string The body of the response. Empty string if no body or incorrect parameter given.
+ */
+function wp_remote_retrieve_body(&$response) {
+	if ( is_wp_error($response) || ! isset($response['body']) )
+		return '';
+
+	return $response['body'];
+}
+
+?>
Index: /tags/3.1/wp-includes/images/crystal/license.txt
===================================================================
--- /tags/3.1/wp-includes/images/crystal/license.txt	(revision 17487)
+++ /tags/3.1/wp-includes/images/crystal/license.txt	(revision 17487)
@@ -0,0 +1,9 @@
+Crystal Project Icons
+by Everaldo Coelho
+http://everaldo.com
+
+Released under LGPL
+
+Modified February 2008
+for WordPress
+http://wordpress.org
Index: /tags/3.1/wp-includes/js/admin-bar.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/admin-bar.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/admin-bar.dev.js	(revision 17487)
@@ -0,0 +1,140 @@
+(function(d, w) {
+	var addEvent = function( obj, type, fn ) {
+		if (obj.addEventListener)
+			obj.addEventListener(type, fn, false);
+		else if (obj.attachEvent)
+			obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);});
+	},
+
+	aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],
+	rselected = new RegExp('\\bselected\\b', 'g'),
+
+	/**
+	 * Get the timeout ID of the given element
+	 */
+	getTOID = function(el) {
+		var i = q.length;
+		while( i-- )
+			if ( q[i] && el == q[i][1] )
+				return q[i][0];
+		return false;
+	},
+
+	addHoverClass = function(t) {
+		var i, id, inA, hovering, ul, li,
+			ancestors = [],
+			ancestorLength = 0;
+
+		while ( t && t != aB && t != d ) {
+			if( 'LI' == t.nodeName.toUpperCase() ) {
+				ancestors[ ancestors.length ] = t;
+				id = getTOID(t);
+				if ( id )
+					clearTimeout( id );
+				t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover';
+				hovering = t;
+			}
+			t = t.parentNode;
+		}
+
+		// Remove any selected classes.
+		if ( hovering && hovering.parentNode ) {
+			ul = hovering.parentNode;
+			if ( ul && 'UL' == ul.nodeName.toUpperCase() ) {
+				i = ul.childNodes.length;
+				while ( i-- ) {
+					li = ul.childNodes[i];
+					if ( li != hovering )
+						li.className = li.className ? li.className.replace( rselected, '' ) : '';
+				}
+			}
+		}
+
+		/* remove the hover class for any objects not in the immediate element's ancestry */
+		i = q.length;
+		while ( i-- ) {
+			inA = false;
+			ancestorLength = ancestors.length;
+			while( ancestorLength-- ) {
+				if ( ancestors[ ancestorLength ] == q[i][1] )
+					inA = true;
+			}
+
+			if ( ! inA )
+				q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : '';
+		}
+	},
+
+	removeHoverClass = function(t) {
+		while ( t && t != aB && t != d ) {
+			if( 'LI' == t.nodeName.toUpperCase() ) {
+				(function(t) {
+					var to = setTimeout(function() {
+						t.className = t.className ? t.className.replace(hc, '') : '';
+					}, 500);
+					q[q.length] = [to, t];
+				})(t);
+			}
+			t = t.parentNode;
+		}
+	},
+
+	clickShortlink = function(e) {
+		var i, l, node,
+			t = e.target || e.srcElement;
+
+		// Make t the shortlink menu item, or return.
+		while ( true ) {
+			// Check if we've gone past the shortlink node,
+			// or if the user is clicking on the input.
+			if ( ! t || t == d || t == aB )
+				return;
+			// Check if we've found the shortlink node.
+			if ( t.id && t.id == 'wp-admin-bar-get-shortlink' )
+				break;
+			t = t.parentNode;
+		}
+
+		// IE doesn't support preventDefault, and does support returnValue
+		if ( e.preventDefault )
+			e.preventDefault();
+		e.returnValue = false;
+
+		if ( -1 == t.className.indexOf('selected') )
+			t.className += ' selected';
+
+		for ( i = 0, l = t.childNodes.length; i < l; i++ ) {
+			node = t.childNodes[i];
+			if ( node.className && -1 != node.className.indexOf('shortlink-input') ) {
+				node.focus();
+				node.select();
+				node.onblur = function() {
+					t.className = t.className ? t.className.replace( rselected, '' ) : '';
+				};
+				break;
+			}
+		}
+		return false;
+	};
+
+	addEvent(w, 'load', function() {
+		aB = d.getElementById('wpadminbar');
+
+		if ( d.body && aB ) {
+			d.body.appendChild( aB );
+
+			addEvent(aB, 'mouseover', function(e) {
+				addHoverClass( e.target || e.srcElement );
+			});
+
+			addEvent(aB, 'mouseout', function(e) {
+				removeHoverClass( e.target || e.srcElement );
+			});
+
+			addEvent(aB, 'click', clickShortlink );
+		}
+
+		if ( w.location.hash )
+			w.scrollBy(0,-32);
+	});
+})(document, window);
Index: /tags/3.1/wp-includes/js/admin-bar.js
===================================================================
--- /tags/3.1/wp-includes/js/admin-bar.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/admin-bar.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(i,k){var c=function(n,m,d){if(n.addEventListener){n.addEventListener(m,d,false)}else{if(n.attachEvent){n.attachEvent("on"+m,function(){return d.call(n,window.event)})}}},e,f=new RegExp("\\bhover\\b","g"),a=[],j=new RegExp("\\bselected\\b","g"),g=function(m){var d=a.length;while(d--){if(a[d]&&m==a[d][1]){return a[d][0]}}return false},h=function(s){var n,d,q,m,p,r,u=[],o=0;while(s&&s!=e&&s!=i){if("LI"==s.nodeName.toUpperCase()){u[u.length]=s;d=g(s);if(d){clearTimeout(d)}s.className=s.className?(s.className.replace(f,"")+" hover"):"hover";m=s}s=s.parentNode}if(m&&m.parentNode){p=m.parentNode;if(p&&"UL"==p.nodeName.toUpperCase()){n=p.childNodes.length;while(n--){r=p.childNodes[n];if(r!=m){r.className=r.className?r.className.replace(j,""):""}}}}n=a.length;while(n--){q=false;o=u.length;while(o--){if(u[o]==a[n][1]){q=true}}if(!q){a[n][1].className=a[n][1].className?a[n][1].className.replace(f,""):""}}},l=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){(function(m){var n=setTimeout(function(){m.className=m.className?m.className.replace(f,""):""},500);a[a.length]=[n,m]})(d)}d=d.parentNode}},b=function(p){var n,d,o,m=p.target||p.srcElement;while(true){if(!m||m==i||m==e){return}if(m.id&&m.id=="wp-admin-bar-get-shortlink"){break}m=m.parentNode}if(p.preventDefault){p.preventDefault()}p.returnValue=false;if(-1==m.className.indexOf("selected")){m.className+=" selected"}for(n=0,d=m.childNodes.length;n<d;n++){o=m.childNodes[n];if(o.className&&-1!=o.className.indexOf("shortlink-input")){o.focus();o.select();o.onblur=function(){m.className=m.className?m.className.replace(j,""):""};break}}return false};c(k,"load",function(){e=i.getElementById("wpadminbar");if(i.body&&e){i.body.appendChild(e);c(e,"mouseover",function(d){h(d.target||d.srcElement)});c(e,"mouseout",function(d){l(d.target||d.srcElement)});c(e,"click",b)}if(k.location.hash){k.scrollBy(0,-32)}})})(document,window);
Index: /tags/3.1/wp-includes/js/autosave.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/autosave.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/autosave.dev.js	(revision 17487)
@@ -0,0 +1,289 @@
+var autosave, autosaveLast = '', autosavePeriodical, autosaveOldMessage = '', autosaveDelayPreview = false, notSaved = true, blockSave = false, interimLogin = false;
+
+jQuery(document).ready( function($) {
+	var dotabkey = true;
+
+	autosaveLast = $('#post #title').val() + $('#post #content').val();
+	autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true});
+
+	//Disable autosave after the form has been submitted
+	$("#post").submit(function() {
+		$.cancel(autosavePeriodical);
+	});
+
+	$('input[type="submit"], a.submitdelete', '#submitpost').click(function(){
+		blockSave = true;
+		window.onbeforeunload = null;
+		$(':button, :submit', '#submitpost').each(function(){
+			var t = $(this);
+			if ( t.hasClass('button-primary') )
+				t.addClass('button-primary-disabled');
+			else
+				t.addClass('button-disabled');
+		});
+		if ( $(this).attr('id') == 'publish' )
+			$('#ajax-loading').css('visibility', 'visible');
+		else
+			$('#draft-ajax-loading').css('visibility', 'visible');
+	});
+
+	window.onbeforeunload = function(){
+		var mce = typeof(tinyMCE) != 'undefined' ? tinyMCE.activeEditor : false, title, content;
+
+		if ( mce && !mce.isHidden() ) {
+			if ( mce.isDirty() )
+				return autosaveL10n.saveAlert;
+		} else {
+			title = $('#post #title').val(), content = $('#post #content').val();
+			if ( ( title || content ) && title + content != autosaveLast )
+				return autosaveL10n.saveAlert;
+		}
+	};
+
+	// preview
+	$('#post-preview').click(function(){
+		if ( $('#auto_draft').val() == '1' && notSaved ) {
+			autosaveDelayPreview = true;
+			autosave();
+			return false;
+		}
+		doPreview();
+		return false;
+	});
+
+	doPreview = function() {
+		$('input#wp-preview').val('dopreview');
+		$('form#post').attr('target', 'wp-preview').submit().attr('target', '');
+		$('input#wp-preview').val('');
+	}
+
+	//  This code is meant to allow tabbing from Title to Post if tinyMCE is defined.
+	if ( typeof tinyMCE != 'undefined' ) {
+		$('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) {
+			if ( e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey ) {
+				if ( ($('#auto_draft').val() == '1') && ($("#title").val().length > 0) ) { autosave(); }
+				if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
+					e.preventDefault();
+					dotabkey = false;
+					tinyMCE.activeEditor.focus();
+					return false;
+				}
+			}
+		});
+	}
+
+	// autosave new posts after a title is typed but not if Publish or Save Draft is clicked
+	if ( '1' == $('#auto_draft').val() ) {
+		$('#title').blur( function() {
+			if ( !this.value || $('#auto_draft').val() != '1' )
+				return;
+			delayed_autosave();
+		});
+	}
+});
+
+function autosave_parse_response(response) {
+	var res = wpAjax.parseAjaxResponse(response, 'autosave'), message = '', postID, sup, url;
+
+	if ( res && res.responses && res.responses.length ) {
+		message = res.responses[0].data; // The saved message or error.
+		// someone else is editing: disable autosave, set errors
+		if ( res.responses[0].supplemental ) {
+			sup = res.responses[0].supplemental;
+			if ( 'disable' == sup['disable_autosave'] ) {
+				autosave = function() {};
+				res = { errors: true };
+			}
+			if ( sup['session_expired'] && (url = sup['session_expired']) ) {
+				if ( !interimLogin || interimLogin.closed ) {
+					interimLogin = window.open(url, 'login', 'width=600,height=450,resizable=yes,scrollbars=yes,status=yes');
+					interimLogin.focus();
+				}
+				delete sup['session_expired'];
+			}
+			jQuery.each(sup, function(selector, value) {
+				if ( selector.match(/^replace-/) ) {
+					jQuery('#'+selector.replace('replace-', '')).val(value);
+				}
+			});
+		}
+
+		// if no errors: add slug UI
+		if ( !res.errors ) {
+			postID = parseInt( res.responses[0].id, 10 );
+			if ( !isNaN(postID) && postID > 0 ) {
+				autosave_update_slug(postID);
+			}
+		}
+	}
+	if ( message ) { jQuery('#autosave').html(message); } // update autosave message
+	else if ( autosaveOldMessage && res ) { jQuery('#autosave').html( autosaveOldMessage ); }
+	return res;
+}
+
+// called when autosaving pre-existing post
+function autosave_saved(response) {
+	blockSave = false;
+	autosave_parse_response(response); // parse the ajax response
+	autosave_enable_buttons(); // re-enable disabled form buttons
+}
+
+// called when autosaving new post
+function autosave_saved_new(response) {
+	blockSave = false;
+	var res = autosave_parse_response(response), tempID, postID;
+	if ( res && res.responses.length && !res.errors ) {
+		// An ID is sent only for real auto-saves, not for autosave=0 "keepalive" saves
+		postID = parseInt( res.responses[0].id, 10 );
+		if ( !isNaN(postID) && postID > 0 ) {
+			notSaved = false;
+			jQuery('#auto_draft').val('0'); // No longer an auto-draft
+		}
+		autosave_enable_buttons();
+		if ( autosaveDelayPreview ) {
+			autosaveDelayPreview = false;
+			doPreview();
+		}
+	} else {
+		autosave_enable_buttons(); // re-enable disabled form buttons
+	}
+}
+
+function autosave_update_slug(post_id) {
+	// create slug area only if not already there
+	if ( 'undefined' != makeSlugeditClickable && jQuery.isFunction(makeSlugeditClickable) && !jQuery('#edit-slug-box > *').size() ) {
+		jQuery.post(
+			ajaxurl,
+			{
+				action: 'sample-permalink',
+				post_id: post_id,
+				new_title: jQuery('#title').val(),
+				samplepermalinknonce: jQuery('#samplepermalinknonce').val()
+			},
+			function(data) {
+				jQuery('#edit-slug-box').html(data);
+				makeSlugeditClickable();
+			}
+		);
+	}
+}
+
+function autosave_loading() {
+	jQuery('#autosave').html(autosaveL10n.savingText);
+}
+
+function autosave_enable_buttons() {
+	// delay that a bit to avoid some rare collisions while the DOM is being updated.
+	setTimeout(function(){
+		jQuery(':button, :submit', '#submitpost').removeAttr('disabled');
+		jQuery('.ajax-loading').css('visibility', 'hidden');
+	}, 500);
+}
+
+function autosave_disable_buttons() {
+	jQuery(':button, :submit', '#submitpost').attr('disabled', 'disabled');
+	// Re-enable 5 sec later.  Just gives autosave a head start to avoid collisions.
+	setTimeout(autosave_enable_buttons, 5000);
+}
+
+function delayed_autosave() {
+	setTimeout(function(){
+		if ( blockSave )
+			return;
+		autosave();
+	}, 200);
+}
+
+autosave = function() {
+	// (bool) is rich editor enabled and active
+	blockSave = true;
+	var rich = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(), post_data, doAutoSave, ed, origStatus, successCallback;
+
+	autosave_disable_buttons();
+
+	post_data = {
+		action: "autosave",
+		post_ID:  jQuery("#post_ID").val() || 0,
+		post_title: jQuery("#title").val() || "",
+		autosavenonce: jQuery('#autosavenonce').val(),
+		post_type: jQuery('#post_type').val() || "",
+		autosave: 1
+	};
+
+	jQuery('.tags-input').each( function() {
+		post_data[this.name] = this.value;
+	} );
+
+	// We always send the ajax request in order to keep the post lock fresh.
+	// This (bool) tells whether or not to write the post to the DB during the ajax request.
+	doAutoSave = true;
+
+	// No autosave while thickbox is open (media buttons)
+	if ( jQuery("#TB_window").css('display') == 'block' )
+		doAutoSave = false;
+
+	/* Gotta do this up here so we can check the length when tinyMCE is in use */
+	if ( rich && doAutoSave ) {
+		ed = tinyMCE.activeEditor;
+		// Don't run while the TinyMCE spellcheck is on. It resets all found words.
+		if ( ed.plugins.spellchecker && ed.plugins.spellchecker.active ) {
+			doAutoSave = false;
+		} else {
+			if ( 'mce_fullscreen' == ed.id )
+				tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
+			tinyMCE.get('content').save();
+		}
+	}
+
+	post_data["content"] = jQuery("#content").val();
+	if ( jQuery('#post_name').val() )
+		post_data["post_name"] = jQuery('#post_name').val();
+
+	// Nothing to save or no change.
+	if ( ( post_data["post_title"].length == 0 && post_data["content"].length == 0 ) || post_data["post_title"] + post_data["content"] == autosaveLast ) {
+		doAutoSave = false;
+	}
+
+	origStatus = jQuery('#original_post_status').val();
+
+	goodcats = ([]);
+	jQuery("[name='post_category[]']:checked").each( function(i) {
+		goodcats.push(this.value);
+	} );
+	post_data["catslist"] = goodcats.join(",");
+
+	if ( jQuery("#comment_status").attr("checked") )
+		post_data["comment_status"] = 'open';
+	if ( jQuery("#ping_status").attr("checked") )
+		post_data["ping_status"] = 'open';
+	if ( jQuery("#excerpt").size() )
+		post_data["excerpt"] = jQuery("#excerpt").val();
+	if ( jQuery("#post_author").size() )
+		post_data["post_author"] = jQuery("#post_author").val();
+	if ( jQuery("#parent_id").val() )
+		post_data["parent_id"] = jQuery("#parent_id").val();
+	post_data["user_ID"] = jQuery("#user-id").val();
+	if ( jQuery('#auto_draft').val() == '1' )
+		post_data["auto_draft"] = '1';
+
+	if ( doAutoSave ) {
+		autosaveLast = jQuery("#title").val() + jQuery("#content").val();
+	} else {
+		post_data['autosave'] = 0;
+	}
+
+	if ( post_data["auto_draft"] == '1' ) {
+		successCallback = autosave_saved_new; // new post
+	} else {
+		successCallback = autosave_saved; // pre-existing post
+	}
+
+	autosaveOldMessage = jQuery('#autosave').html();
+	jQuery.ajax({
+		data: post_data,
+		beforeSend: doAutoSave ? autosave_loading : null,
+		type: "POST",
+		url: autosaveL10n.requestFile,
+		success: successCallback
+	});
+}
Index: /tags/3.1/wp-includes/js/autosave.js
===================================================================
--- /tags/3.1/wp-includes/js/autosave.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/autosave.js	(revision 17487)
@@ -0,0 +1,1 @@
+var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function(b){var a=true;autosaveLast=b("#post #title").val()+b("#post #content").val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b("#post").submit(function(){b.cancel(autosavePeriodical)});b('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;b(":button, :submit","#submitpost").each(function(){var c=b(this);if(c.hasClass("button-primary")){c.addClass("button-primary-disabled")}else{c.addClass("button-disabled")}});if(b(this).attr("id")=="publish"){b("#ajax-loading").css("visibility","visible")}else{b("#draft-ajax-loading").css("visibility","visible")}});window.onbeforeunload=function(){var c=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,e,d;if(c&&!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{e=b("#post #title").val(),d=b("#post #content").val();if((e||d)&&e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b("#post-preview").click(function(){if(b("#auto_draft").val()=="1"&&notSaved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b("input#wp-preview").val("dopreview");b("form#post").attr("target","wp-preview").submit().attr("target","");b("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){b("#title")[b.browser.opera?"keypress":"keydown"](function(c){if(c.which==9&&!c.shiftKey&&!c.controlKey&&!c.altKey){if((b("#auto_draft").val()=="1")&&(b("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(c){var e=wpAjax.parseAjaxResponse(c,"autosave"),f="",a,b,d;if(e&&e.responses&&e.responses.length){f=e.responses[0].data;if(e.responses[0].supplemental){b=e.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};e={errors:true}}if(b.session_expired&&(d=b.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(d,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete b.session_expired}jQuery.each(b,function(g,h){if(g.match(/^replace-/)){jQuery("#"+g.replace("replace-","")).val(h)}})}if(!e.errors){a=parseInt(e.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(f){jQuery("#autosave").html(f)}else{if(autosaveOldMessage&&e){jQuery("#autosave").html(autosaveOldMessage)}}return e}function autosave_saved(a){blockSave=false;autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){blockSave=false;var d=autosave_parse_response(b),c,a;if(d&&d.responses.length&&!d.errors){a=parseInt(d.responses[0].id,10);if(!isNaN(a)&&a>0){notSaved=false;jQuery("#auto_draft").val("0")}autosave_enable_buttons();if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery(".ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=false}else{if("mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}d.content=jQuery("#content").val();if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){d.parent_id=jQuery("#parent_id").val()}d.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){d.auto_draft="1"}if(f){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{d.autosave=0}if(d.auto_draft=="1"){a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:a})};
Index: /tags/3.1/wp-includes/js/colorpicker.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/colorpicker.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/colorpicker.dev.js	(revision 17487)
@@ -0,0 +1,707 @@
+// ===================================================================
+// Author: Matt Kruse <matt@mattkruse.com>
+// WWW: http://www.mattkruse.com/
+//
+// NOTICE: You may use this code for any purpose, commercial or
+// private, without any further permission from the author. You may
+// remove this notice from your final code if you wish, however it is
+// appreciated by the author if at least my web site address is kept.
+//
+// You may *NOT* re-distribute this code in any way except through its
+// use. That means, you can include it in your product, or your web
+// site, or any other form where the code is actually being used. You
+// may not put the plain javascript up on your site for download or
+// include it in your javascript libraries for download. 
+// If you wish to share this code with others, please just point them
+// to the URL instead.
+// Please DO NOT link directly to my .js files from your site. Copy
+// the files to your server and use them there. Thank you.
+// ===================================================================
+
+
+/* SOURCE FILE: AnchorPosition.js */
+
+/* 
+AnchorPosition.js
+Author: Matt Kruse
+Last modified: 10/11/02
+
+DESCRIPTION: These functions find the position of an <A> tag in a document,
+so other elements can be positioned relative to it.
+
+COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
+positioning errors - usually with Window positioning - occur on the 
+Macintosh platform.
+
+FUNCTIONS:
+getAnchorPosition(anchorname)
+  Returns an Object() having .x and .y properties of the pixel coordinates
+  of the upper-left corner of the anchor. Position is relative to the PAGE.
+
+getAnchorWindowPosition(anchorname)
+  Returns an Object() having .x and .y properties of the pixel coordinates
+  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.
+
+NOTES:
+
+1) For popping up separate browser windows, use getAnchorWindowPosition. 
+   Otherwise, use getAnchorPosition
+
+2) Your anchor tag MUST contain both NAME and ID attributes which are the 
+   same. For example:
+   <A NAME="test" ID="test"> </A>
+
+3) There must be at least a space between <A> </A> for IE5.5 to see the 
+   anchor tag correctly. Do not do <A></A> with no space.
+*/ 
+
+// getAnchorPosition(anchorname)
+//   This function returns an object having .x and .y properties which are the coordinates
+//   of the named anchor, relative to the page.
+function getAnchorPosition(anchorname) {
+	// This function will return an Object with x and y properties
+	var useWindow=false;
+	var coordinates=new Object();
+	var x=0,y=0;
+	// Browser capability sniffing
+	var use_gebi=false, use_css=false, use_layers=false;
+	if (document.getElementById) { use_gebi=true; }
+	else if (document.all) { use_css=true; }
+	else if (document.layers) { use_layers=true; }
+	// Logic to find position
+ 	if (use_gebi && document.all) {
+		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
+		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
+		}
+	else if (use_gebi) {
+		var o=document.getElementById(anchorname);
+		x=AnchorPosition_getPageOffsetLeft(o);
+		y=AnchorPosition_getPageOffsetTop(o);
+		}
+ 	else if (use_css) {
+		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
+		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
+		}
+	else if (use_layers) {
+		var found=0;
+		for (var i=0; i<document.anchors.length; i++) {
+			if (document.anchors[i].name==anchorname) { found=1; break; }
+			}
+		if (found==0) {
+			coordinates.x=0; coordinates.y=0; return coordinates;
+			}
+		x=document.anchors[i].x;
+		y=document.anchors[i].y;
+		}
+	else {
+		coordinates.x=0; coordinates.y=0; return coordinates;
+		}
+	coordinates.x=x;
+	coordinates.y=y;
+	return coordinates;
+	}
+
+// getAnchorWindowPosition(anchorname)
+//   This function returns an object having .x and .y properties which are the coordinates
+//   of the named anchor, relative to the window
+function getAnchorWindowPosition(anchorname) {
+	var coordinates=getAnchorPosition(anchorname);
+	var x=0;
+	var y=0;
+	if (document.getElementById) {
+		if (isNaN(window.screenX)) {
+			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
+			y=coordinates.y-document.body.scrollTop+window.screenTop;
+			}
+		else {
+			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
+			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
+			}
+		}
+	else if (document.all) {
+		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
+		y=coordinates.y-document.body.scrollTop+window.screenTop;
+		}
+	else if (document.layers) {
+		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
+		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
+		}
+	coordinates.x=x;
+	coordinates.y=y;
+	return coordinates;
+	}
+
+// Functions for IE to get position of an object
+function AnchorPosition_getPageOffsetLeft (el) {
+	var ol=el.offsetLeft;
+	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
+	return ol;
+	}
+function AnchorPosition_getWindowOffsetLeft (el) {
+	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
+	}
+function AnchorPosition_getPageOffsetTop (el) {
+	var ot=el.offsetTop;
+	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
+	return ot;
+	}
+function AnchorPosition_getWindowOffsetTop (el) {
+	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
+	}
+
+/* SOURCE FILE: PopupWindow.js */
+
+/* 
+PopupWindow.js
+Author: Matt Kruse
+Last modified: 02/16/04
+
+DESCRIPTION: This object allows you to easily and quickly popup a window
+in a certain place. The window can either be a DIV or a separate browser
+window.
+
+COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
+positioning errors - usually with Window positioning - occur on the 
+Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 
+window with <STYLE> tags may cause errors.
+
+USAGE:
+// Create an object for a WINDOW popup
+var win = new PopupWindow(); 
+
+// Create an object for a DIV window using the DIV named 'mydiv'
+var win = new PopupWindow('mydiv'); 
+
+// Set the window to automatically hide itself when the user clicks 
+// anywhere else on the page except the popup
+win.autoHide(); 
+
+// Show the window relative to the anchor name passed in
+win.showPopup(anchorname);
+
+// Hide the popup
+win.hidePopup();
+
+// Set the size of the popup window (only applies to WINDOW popups
+win.setSize(width,height);
+
+// Populate the contents of the popup window that will be shown. If you 
+// change the contents while it is displayed, you will need to refresh()
+win.populate(string);
+
+// set the URL of the window, rather than populating its contents
+// manually
+win.setUrl("http://www.site.com/");
+
+// Refresh the contents of the popup
+win.refresh();
+
+// Specify how many pixels to the right of the anchor the popup will appear
+win.offsetX = 50;
+
+// Specify how many pixels below the anchor the popup will appear
+win.offsetY = 100;
+
+NOTES:
+1) Requires the functions in AnchorPosition.js
+
+2) Your anchor tag MUST contain both NAME and ID attributes which are the 
+   same. For example:
+   <A NAME="test" ID="test"> </A>
+
+3) There must be at least a space between <A> </A> for IE5.5 to see the 
+   anchor tag correctly. Do not do <A></A> with no space.
+
+4) When a PopupWindow object is created, a handler for 'onmouseup' is
+   attached to any event handler you may have already defined. Do NOT define
+   an event handler for 'onmouseup' after you define a PopupWindow object or
+   the autoHide() will not work correctly.
+*/ 
+
+// Set the position of the popup window based on the anchor
+function PopupWindow_getXYPosition(anchorname) {
+	var coordinates;
+	if (this.type == "WINDOW") {
+		coordinates = getAnchorWindowPosition(anchorname);
+		}
+	else {
+		coordinates = getAnchorPosition(anchorname);
+		}
+	this.x = coordinates.x;
+	this.y = coordinates.y;
+	}
+// Set width/height of DIV/popup window
+function PopupWindow_setSize(width,height) {
+	this.width = width;
+	this.height = height;
+	}
+// Fill the window with contents
+function PopupWindow_populate(contents) {
+	this.contents = contents;
+	this.populated = false;
+	}
+// Set the URL to go to
+function PopupWindow_setUrl(url) {
+	this.url = url;
+	}
+// Set the window popup properties
+function PopupWindow_setWindowProperties(props) {
+	this.windowProperties = props;
+	}
+// Refresh the displayed contents of the popup
+function PopupWindow_refresh() {
+	if (this.divName != null) {
+		// refresh the DIV object
+		if (this.use_gebi) {
+			document.getElementById(this.divName).innerHTML = this.contents;
+			}
+		else if (this.use_css) { 
+			document.all[this.divName].innerHTML = this.contents;
+			}
+		else if (this.use_layers) { 
+			var d = document.layers[this.divName]; 
+			d.document.open();
+			d.document.writeln(this.contents);
+			d.document.close();
+			}
+		}
+	else {
+		if (this.popupWindow != null && !this.popupWindow.closed) {
+			if (this.url!="") {
+				this.popupWindow.location.href=this.url;
+				}
+			else {
+				this.popupWindow.document.open();
+				this.popupWindow.document.writeln(this.contents);
+				this.popupWindow.document.close();
+			}
+			this.popupWindow.focus();
+			}
+		}
+	}
+// Position and show the popup, relative to an anchor object
+function PopupWindow_showPopup(anchorname) {
+	this.getXYPosition(anchorname);
+	this.x += this.offsetX;
+	this.y += this.offsetY;
+	if (!this.populated && (this.contents != "")) {
+		this.populated = true;
+		this.refresh();
+		}
+	if (this.divName != null) {
+		// Show the DIV object
+		if (this.use_gebi) {
+			document.getElementById(this.divName).style.left = this.x + "px";
+			document.getElementById(this.divName).style.top = this.y;
+			document.getElementById(this.divName).style.visibility = "visible";
+			}
+		else if (this.use_css) {
+			document.all[this.divName].style.left = this.x;
+			document.all[this.divName].style.top = this.y;
+			document.all[this.divName].style.visibility = "visible";
+			}
+		else if (this.use_layers) {
+			document.layers[this.divName].left = this.x;
+			document.layers[this.divName].top = this.y;
+			document.layers[this.divName].visibility = "visible";
+			}
+		}
+	else {
+		if (this.popupWindow == null || this.popupWindow.closed) {
+			// If the popup window will go off-screen, move it so it doesn't
+			if (this.x<0) { this.x=0; }
+			if (this.y<0) { this.y=0; }
+			if (screen && screen.availHeight) {
+				if ((this.y + this.height) > screen.availHeight) {
+					this.y = screen.availHeight - this.height;
+					}
+				}
+			if (screen && screen.availWidth) {
+				if ((this.x + this.width) > screen.availWidth) {
+					this.x = screen.availWidth - this.width;
+					}
+				}
+			var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
+			this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
+			}
+		this.refresh();
+		}
+	}
+// Hide the popup
+function PopupWindow_hidePopup() {
+	if (this.divName != null) {
+		if (this.use_gebi) {
+			document.getElementById(this.divName).style.visibility = "hidden";
+			}
+		else if (this.use_css) {
+			document.all[this.divName].style.visibility = "hidden";
+			}
+		else if (this.use_layers) {
+			document.layers[this.divName].visibility = "hidden";
+			}
+		}
+	else {
+		if (this.popupWindow && !this.popupWindow.closed) {
+			this.popupWindow.close();
+			this.popupWindow = null;
+			}
+		}
+	}
+// Pass an event and return whether or not it was the popup DIV that was clicked
+function PopupWindow_isClicked(e) {
+	if (this.divName != null) {
+		if (this.use_layers) {
+			var clickX = e.pageX;
+			var clickY = e.pageY;
+			var t = document.layers[this.divName];
+			if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
+				return true;
+				}
+			else { return false; }
+			}
+		else if (document.all) { // Need to hard-code this to trap IE for error-handling
+			var t = window.event.srcElement;
+			while (t.parentElement != null) {
+				if (t.id==this.divName) {
+					return true;
+					}
+				t = t.parentElement;
+				}
+			return false;
+			}
+		else if (this.use_gebi && e) {
+			var t = e.originalTarget;
+			while (t.parentNode != null) {
+				if (t.id==this.divName) {
+					return true;
+					}
+				t = t.parentNode;
+				}
+			return false;
+			}
+		return false;
+		}
+	return false;
+	}
+
+// Check an onMouseDown event to see if we should hide
+function PopupWindow_hideIfNotClicked(e) {
+	if (this.autoHideEnabled && !this.isClicked(e)) {
+		this.hidePopup();
+		}
+	}
+// Call this to make the DIV disable automatically when mouse is clicked outside it
+function PopupWindow_autoHide() {
+	this.autoHideEnabled = true;
+	}
+// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
+function PopupWindow_hidePopupWindows(e) {
+	for (var i=0; i<popupWindowObjects.length; i++) {
+		if (popupWindowObjects[i] != null) {
+			var p = popupWindowObjects[i];
+			p.hideIfNotClicked(e);
+			}
+		}
+	}
+// Run this immediately to attach the event listener
+function PopupWindow_attachListener() {
+	if (document.layers) {
+		document.captureEvents(Event.MOUSEUP);
+		}
+	window.popupWindowOldEventListener = document.onmouseup;
+	if (window.popupWindowOldEventListener != null) {
+		document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
+		}
+	else {
+		document.onmouseup = PopupWindow_hidePopupWindows;
+		}
+	}
+// CONSTRUCTOR for the PopupWindow object
+// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
+function PopupWindow() {
+	if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
+	if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
+	if (!window.listenerAttached) {
+		window.listenerAttached = true;
+		PopupWindow_attachListener();
+		}
+	this.index = popupWindowIndex++;
+	popupWindowObjects[this.index] = this;
+	this.divName = null;
+	this.popupWindow = null;
+	this.width=0;
+	this.height=0;
+	this.populated = false;
+	this.visible = false;
+	this.autoHideEnabled = false;
+
+	this.contents = "";
+	this.url="";
+	this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
+	if (arguments.length>0) {
+		this.type="DIV";
+		this.divName = arguments[0];
+		}
+	else {
+		this.type="WINDOW";
+		}
+	this.use_gebi = false;
+	this.use_css = false;
+	this.use_layers = false;
+	if (document.getElementById) { this.use_gebi = true; }
+	else if (document.all) { this.use_css = true; }
+	else if (document.layers) { this.use_layers = true; }
+	else { this.type = "WINDOW"; }
+	this.offsetX = 0;
+	this.offsetY = 0;
+	// Method mappings
+	this.getXYPosition = PopupWindow_getXYPosition;
+	this.populate = PopupWindow_populate;
+	this.setUrl = PopupWindow_setUrl;
+	this.setWindowProperties = PopupWindow_setWindowProperties;
+	this.refresh = PopupWindow_refresh;
+	this.showPopup = PopupWindow_showPopup;
+	this.hidePopup = PopupWindow_hidePopup;
+	this.setSize = PopupWindow_setSize;
+	this.isClicked = PopupWindow_isClicked;
+	this.autoHide = PopupWindow_autoHide;
+	this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
+	}
+
+/* SOURCE FILE: ColorPicker2.js */
+
+/* 
+Last modified: 02/24/2003
+
+DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB 
+form. It uses a color "swatch" to display the standard 216-color web-safe 
+palette. The user can then click on a color to select it.
+
+COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js.
+Only the latest DHTML-capable browsers will show the color and hex values
+at the bottom as your mouse goes over them.
+
+USAGE:
+// Create a new ColorPicker object using DHTML popup
+var cp = new ColorPicker();
+
+// Create a new ColorPicker object using Window Popup
+var cp = new ColorPicker('window');
+
+// Add a link in your page to trigger the popup. For example:
+<A HREF="#" onClick="cp.show('pick');return false;" NAME="pick" ID="pick">Pick</A>
+
+// Or use the built-in "select" function to do the dirty work for you:
+<A HREF="#" onClick="cp.select(document.forms[0].color,'pick');return false;" NAME="pick" ID="pick">Pick</A>
+
+// If using DHTML popup, write out the required DIV tag near the bottom
+// of your page.
+<SCRIPT LANGUAGE="JavaScript">cp.writeDiv()</SCRIPT>
+
+// Write the 'pickColor' function that will be called when the user clicks
+// a color and do something with the value. This is only required if you
+// want to do something other than simply populate a form field, which is 
+// what the 'select' function will give you.
+function pickColor(color) {
+	field.value = color;
+	}
+
+NOTES:
+1) Requires the functions in AnchorPosition.js and PopupWindow.js
+
+2) Your anchor tag MUST contain both NAME and ID attributes which are the 
+   same. For example:
+   <A NAME="test" ID="test"> </A>
+
+3) There must be at least a space between <A> </A> for IE5.5 to see the 
+   anchor tag correctly. Do not do <A></A> with no space.
+
+4) When a ColorPicker object is created, a handler for 'onmouseup' is
+   attached to any event handler you may have already defined. Do NOT define
+   an event handler for 'onmouseup' after you define a ColorPicker object or
+   the color picker will not hide itself correctly.
+*/ 
+ColorPicker_targetInput = null;
+function ColorPicker_writeDiv() {
+	document.writeln("<DIV ID=\"colorPickerDiv\" STYLE=\"position:absolute;visibility:hidden;\"> </DIV>");
+	}
+
+function ColorPicker_show(anchorname) {
+	this.showPopup(anchorname);
+	}
+
+function ColorPicker_pickColor(color,obj) {
+	obj.hidePopup();
+	pickColor(color);
+	}
+
+// A Default "pickColor" function to accept the color passed back from popup.
+// User can over-ride this with their own function.
+function pickColor(color) {
+	if (ColorPicker_targetInput==null) {
+		alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");
+		return;
+		}
+	ColorPicker_targetInput.value = color;
+	}
+
+// This function is the easiest way to popup the window, select a color, and
+// have the value populate a form field, which is what most people want to do.
+function ColorPicker_select(inputobj,linkname) {
+	if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 
+		alert("colorpicker.select: Input object passed is not a valid form input object"); 
+		window.ColorPicker_targetInput=null;
+		return;
+		}
+	window.ColorPicker_targetInput = inputobj;
+	this.show(linkname);
+	}
+
+// This function runs when you move your mouse over a color block, if you have a newer browser
+function ColorPicker_highlightColor(c) {
+	var thedoc = (arguments.length>1)?arguments[1]:window.document;
+	var d = thedoc.getElementById("colorPickerSelectedColor");
+	d.style.backgroundColor = c;
+	d = thedoc.getElementById("colorPickerSelectedColorValue");
+	d.innerHTML = c;
+	}
+
+function ColorPicker() {
+	var windowMode = false;
+	// Create a new PopupWindow object
+	if (arguments.length==0) {
+		var divname = "colorPickerDiv";
+		}
+	else if (arguments[0] == "window") {
+		var divname = '';
+		windowMode = true;
+		}
+	else {
+		var divname = arguments[0];
+		}
+
+	if (divname != "") {
+		var cp = new PopupWindow(divname);
+		}
+	else {
+		var cp = new PopupWindow();
+		cp.setSize(225,250);
+		}
+
+	// Object variables
+	cp.currentValue = "#FFFFFF";
+
+	// Method Mappings
+	cp.writeDiv = ColorPicker_writeDiv;
+	cp.highlightColor = ColorPicker_highlightColor;
+	cp.show = ColorPicker_show;
+	cp.select = ColorPicker_select;
+
+	// Code to populate color picker window
+	var colors = new Array(	"#4180B6","#69AEE7","#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099",
+							"#3300CC","#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099",
+							"#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066","#FF0099",
+							"#FF00CC","#FF00FF","#7FFFFF","#7FFFFF","#7FF7F7","#7FEFEF","#7FE7E7","#7FDFDF","#7FD7D7","#7FCFCF","#7FC7C7","#7FBFBF",
+							"#7FB7B7","#7FAFAF","#7FA7A7","#7F9F9F","#7F9797","#7F8F8F","#7F8787","#7F7F7F","#7F7777","#7F6F6F","#7F6767","#7F5F5F",
+							"#7F5757","#7F4F4F","#7F4747","#7F3F3F","#7F3737","#7F2F2F","#7F2727","#7F1F1F","#7F1717","#7F0F0F","#7F0707","#7F0000",
+
+							"#4180B6","#69AEE7","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333","#333366","#333399",
+							"#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300","#993333","#993366","#993399",
+							"#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#FF3300","#FF3333","#FF3366","#FF3399",
+							"#FF33CC","#FF33FF","#FF7FFF","#FF7FFF","#F77FF7","#EF7FEF","#E77FE7","#DF7FDF","#D77FD7","#CF7FCF","#C77FC7","#BF7FBF",
+							"#B77FB7","#AF7FAF","#A77FA7","#9F7F9F","#977F97","#8F7F8F","#877F87","#7F7F7F","#777F77","#6F7F6F","#677F67","#5F7F5F",
+							"#577F57","#4F7F4F","#477F47","#3F7F3F","#377F37","#2F7F2F","#277F27","#1F7F1F","#177F17","#0F7F0F","#077F07","#007F00",
+
+							"#4180B6","#69AEE7","#006600","#006633","#006666","#006699","#0066CC","#0066FF","#336600","#336633","#336666","#336699",
+							"#3366CC","#3366FF","#666600","#666633","#666666","#666699","#6666CC","#6666FF","#996600","#996633","#996666","#996699",
+							"#9966CC","#9966FF","#CC6600","#CC6633","#CC6666","#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699",
+							"#FF66CC","#FF66FF","#FFFF7F","#FFFF7F","#F7F77F","#EFEF7F","#E7E77F","#DFDF7F","#D7D77F","#CFCF7F","#C7C77F","#BFBF7F",
+							"#B7B77F","#AFAF7F","#A7A77F","#9F9F7F","#97977F","#8F8F7F","#87877F","#7F7F7F","#77777F","#6F6F7F","#67677F","#5F5F7F",
+							"#57577F","#4F4F7F","#47477F","#3F3F7F","#37377F","#2F2F7F","#27277F","#1F1F7F","#17177F","#0F0F7F","#07077F","#00007F",
+
+							"#4180B6","#69AEE7","#009900","#009933","#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999",
+							"#3399CC","#3399FF","#669900","#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999",
+							"#9999CC","#9999FF","#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999",
+							"#FF99CC","#FF99FF","#3FFFFF","#3FFFFF","#3FF7F7","#3FEFEF","#3FE7E7","#3FDFDF","#3FD7D7","#3FCFCF","#3FC7C7","#3FBFBF",
+							"#3FB7B7","#3FAFAF","#3FA7A7","#3F9F9F","#3F9797","#3F8F8F","#3F8787","#3F7F7F","#3F7777","#3F6F6F","#3F6767","#3F5F5F",
+							"#3F5757","#3F4F4F","#3F4747","#3F3F3F","#3F3737","#3F2F2F","#3F2727","#3F1F1F","#3F1717","#3F0F0F","#3F0707","#3F0000",
+
+							"#4180B6","#69AEE7","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99",
+							"#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66","#99CC99",
+							"#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33","#FFCC66","#FFCC99",
+							"#FFCCCC","#FFCCFF","#FF3FFF","#FF3FFF","#F73FF7","#EF3FEF","#E73FE7","#DF3FDF","#D73FD7","#CF3FCF","#C73FC7","#BF3FBF",
+							"#B73FB7","#AF3FAF","#A73FA7","#9F3F9F","#973F97","#8F3F8F","#873F87","#7F3F7F","#773F77","#6F3F6F","#673F67","#5F3F5F",
+							"#573F57","#4F3F4F","#473F47","#3F3F3F","#373F37","#2F3F2F","#273F27","#1F3F1F","#173F17","#0F3F0F","#073F07","#003F00",
+
+							"#4180B6","#69AEE7","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00","#33FF33","#33FF66","#33FF99",
+							"#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF","#99FF00","#99FF33","#99FF66","#99FF99",
+							"#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC","#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99",
+							"#FFFFCC","#FFFFFF","#FFFF3F","#FFFF3F","#F7F73F","#EFEF3F","#E7E73F","#DFDF3F","#D7D73F","#CFCF3F","#C7C73F","#BFBF3F",
+							"#B7B73F","#AFAF3F","#A7A73F","#9F9F3F","#97973F","#8F8F3F","#87873F","#7F7F3F","#77773F","#6F6F3F","#67673F","#5F5F3F",
+							"#57573F","#4F4F3F","#47473F","#3F3F3F","#37373F","#2F2F3F","#27273F","#1F1F3F","#17173F","#0F0F3F","#07073F","#00003F",
+
+							"#4180B6","#69AEE7","#FFFFFF","#FFEEEE","#FFDDDD","#FFCCCC","#FFBBBB","#FFAAAA","#FF9999","#FF8888","#FF7777","#FF6666",
+							"#FF5555","#FF4444","#FF3333","#FF2222","#FF1111","#FF0000","#FF0000","#FF0000","#FF0000","#EE0000","#DD0000","#CC0000",
+							"#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000",
+							"#000000","#000000","#000000","#001111","#002222","#003333","#004444","#005555","#006666","#007777","#008888","#009999",
+							"#00AAAA","#00BBBB","#00CCCC","#00DDDD","#00EEEE","#00FFFF","#00FFFF","#00FFFF","#00FFFF","#11FFFF","#22FFFF","#33FFFF",
+							"#44FFFF","#55FFFF","#66FFFF","#77FFFF","#88FFFF","#99FFFF","#AAFFFF","#BBFFFF","#CCFFFF","#DDFFFF","#EEFFFF","#FFFFFF",
+
+							"#4180B6","#69AEE7","#FFFFFF","#EEFFEE","#DDFFDD","#CCFFCC","#BBFFBB","#AAFFAA","#99FF99","#88FF88","#77FF77","#66FF66",
+							"#55FF55","#44FF44","#33FF33","#22FF22","#11FF11","#00FF00","#00FF00","#00FF00","#00FF00","#00EE00","#00DD00","#00CC00",
+							"#00BB00","#00AA00","#009900","#008800","#007700","#006600","#005500","#004400","#003300","#002200","#001100","#000000",
+							"#000000","#000000","#000000","#110011","#220022","#330033","#440044","#550055","#660066","#770077","#880088","#990099",
+							"#AA00AA","#BB00BB","#CC00CC","#DD00DD","#EE00EE","#FF00FF","#FF00FF","#FF00FF","#FF00FF","#FF11FF","#FF22FF","#FF33FF",
+							"#FF44FF","#FF55FF","#FF66FF","#FF77FF","#FF88FF","#FF99FF","#FFAAFF","#FFBBFF","#FFCCFF","#FFDDFF","#FFEEFF","#FFFFFF",
+
+							"#4180B6","#69AEE7","#FFFFFF","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF","#7777FF","#6666FF",
+							"#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF","#0000FF","#0000FF","#0000FF","#0000EE","#0000DD","#0000CC",
+							"#0000BB","#0000AA","#000099","#000088","#000077","#000066","#000055","#000044","#000033","#000022","#000011","#000000",
+							"#000000","#000000","#000000","#111100","#222200","#333300","#444400","#555500","#666600","#777700","#888800","#999900",
+							"#AAAA00","#BBBB00","#CCCC00","#DDDD00","#EEEE00","#FFFF00","#FFFF00","#FFFF00","#FFFF00","#FFFF11","#FFFF22","#FFFF33",
+							"#FFFF44","#FFFF55","#FFFF66","#FFFF77","#FFFF88","#FFFF99","#FFFFAA","#FFFFBB","#FFFFCC","#FFFFDD","#FFFFEE","#FFFFFF",
+
+							"#4180B6","#69AEE7","#FFFFFF","#FFFFFF","#FBFBFB","#F7F7F7","#F3F3F3","#EFEFEF","#EBEBEB","#E7E7E7","#E3E3E3","#DFDFDF",
+							"#DBDBDB","#D7D7D7","#D3D3D3","#CFCFCF","#CBCBCB","#C7C7C7","#C3C3C3","#BFBFBF","#BBBBBB","#B7B7B7","#B3B3B3","#AFAFAF",
+							"#ABABAB","#A7A7A7","#A3A3A3","#9F9F9F","#9B9B9B","#979797","#939393","#8F8F8F","#8B8B8B","#878787","#838383","#7F7F7F",
+							"#7B7B7B","#777777","#737373","#6F6F6F","#6B6B6B","#676767","#636363","#5F5F5F","#5B5B5B","#575757","#535353","#4F4F4F",
+							"#4B4B4B","#474747","#434343","#3F3F3F","#3B3B3B","#373737","#333333","#2F2F2F","#2B2B2B","#272727","#232323","#1F1F1F",
+							"#1B1B1B","#171717","#131313","#0F0F0F","#0B0B0B","#070707","#030303","#000000","#000000","#000000","#000000","#000000");
+	var total = colors.length;
+	var width = 72;
+	var cp_contents = "";
+	var windowRef = (windowMode)?"window.opener.":"";
+	if (windowMode) {
+		cp_contents += "<html><head><title>Select Color</title></head>";
+		cp_contents += "<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><span style='text-align: center;'>";
+		}
+	cp_contents += "<table style='border: none;' cellspacing=0 cellpadding=0>";
+	var use_highlight = (document.getElementById || document.all)?true:false;
+	for (var i=0; i<total; i++) {
+		if ((i % width) == 0) { cp_contents += "<tr>"; }
+		if (use_highlight) { var mo = 'onMouseOver="'+windowRef+'ColorPicker_highlightColor(\''+colors[i]+'\',window.document)"'; }
+		else { mo = ""; }
+		cp_contents += '<td style="background-color: '+colors[i]+';"><a href="javascript:void()" onclick="'+windowRef+'ColorPicker_pickColor(\''+colors[i]+'\','+windowRef+'window.popupWindowObjects['+cp.index+']);return false;" '+mo+'>&nbsp;</a></td>';
+		if ( ((i+1)>=total) || (((i+1) % width) == 0)) { 
+			cp_contents += "</tr>";
+			}
+		}
+	// If the browser supports dynamically changing TD cells, add the fancy stuff
+	if (document.getElementById) {
+		var width1 = Math.floor(width/2);
+		var width2 = width = width1;
+		cp_contents += "<tr><td colspan='"+width1+"' style='background-color: #FFF;' ID='colorPickerSelectedColor'>&nbsp;</td><td colspan='"+width2+"' style='text-align: center;' id='colorPickerSelectedColorValue'>#FFFFFF</td></tr>";
+		}
+	cp_contents += "</table>";
+	if (windowMode) {
+		cp_contents += "</span></body></html>";
+		}
+	// end populate code
+
+	// Write the contents to the popup object
+	cp.populate(cp_contents+"\n");
+	// Move the table down a bit so you can see it
+	cp.offsetY = 25;
+	cp.autoHide();
+	return cp;
+	}
Index: /tags/3.1/wp-includes/js/colorpicker.js
===================================================================
--- /tags/3.1/wp-includes/js/colorpicker.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/colorpicker.js	(revision 17487)
@@ -0,0 +1,1 @@
+function getAnchorPosition(b){var e=false;var k=new Object();var j=0,g=0;var d=false,f=false,h=false;if(document.getElementById){d=true}else{if(document.all){f=true}else{if(document.layers){h=true}}}if(d&&document.all){j=AnchorPosition_getPageOffsetLeft(document.all[b]);g=AnchorPosition_getPageOffsetTop(document.all[b])}else{if(d){var a=document.getElementById(b);j=AnchorPosition_getPageOffsetLeft(a);g=AnchorPosition_getPageOffsetTop(a)}else{if(f){j=AnchorPosition_getPageOffsetLeft(document.all[b]);g=AnchorPosition_getPageOffsetTop(document.all[b])}else{if(h){var l=0;for(var c=0;c<document.anchors.length;c++){if(document.anchors[c].name==b){l=1;break}}if(l==0){k.x=0;k.y=0;return k}j=document.anchors[c].x;g=document.anchors[c].y}else{k.x=0;k.y=0;return k}}}}k.x=j;k.y=g;return k}function getAnchorWindowPosition(b){var c=getAnchorPosition(b);var a=0;var d=0;if(document.getElementById){if(isNaN(window.screenX)){a=c.x-document.body.scrollLeft+window.screenLeft;d=c.y-document.body.scrollTop+window.screenTop}else{a=c.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;d=c.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset}}else{if(document.all){a=c.x-document.body.scrollLeft+window.screenLeft;d=c.y-document.body.scrollTop+window.screenTop}else{if(document.layers){a=c.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;d=c.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset}}}c.x=a;c.y=d;return c}function AnchorPosition_getPageOffsetLeft(b){var a=b.offsetLeft;while((b=b.offsetParent)!=null){a+=b.offsetLeft}return a}function AnchorPosition_getWindowOffsetLeft(a){return AnchorPosition_getPageOffsetLeft(a)-document.body.scrollLeft}function AnchorPosition_getPageOffsetTop(a){var b=a.offsetTop;while((a=a.offsetParent)!=null){b+=a.offsetTop}return b}function AnchorPosition_getWindowOffsetTop(a){return AnchorPosition_getPageOffsetTop(a)-document.body.scrollTop}function PopupWindow_getXYPosition(a){var b;if(this.type=="WINDOW"){b=getAnchorWindowPosition(a)}else{b=getAnchorPosition(a)}this.x=b.x;this.y=b.y}function PopupWindow_setSize(b,a){this.width=b;this.height=a}function PopupWindow_populate(a){this.contents=a;this.populated=false}function PopupWindow_setUrl(a){this.url=a}function PopupWindow_setWindowProperties(a){this.windowProperties=a}function PopupWindow_refresh(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).innerHTML=this.contents}else{if(this.use_css){document.all[this.divName].innerHTML=this.contents}else{if(this.use_layers){var a=document.layers[this.divName];a.document.open();a.document.writeln(this.contents);a.document.close()}}}}else{if(this.popupWindow!=null&&!this.popupWindow.closed){if(this.url!=""){this.popupWindow.location.href=this.url}else{this.popupWindow.document.open();this.popupWindow.document.writeln(this.contents);this.popupWindow.document.close()}this.popupWindow.focus()}}}function PopupWindow_showPopup(a){this.getXYPosition(a);this.x+=this.offsetX;this.y+=this.offsetY;if(!this.populated&&(this.contents!="")){this.populated=true;this.refresh()}if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.left=this.x+"px";document.getElementById(this.divName).style.top=this.y;document.getElementById(this.divName).style.visibility="visible"}else{if(this.use_css){document.all[this.divName].style.left=this.x;document.all[this.divName].style.top=this.y;document.all[this.divName].style.visibility="visible"}else{if(this.use_layers){document.layers[this.divName].left=this.x;document.layers[this.divName].top=this.y;document.layers[this.divName].visibility="visible"}}}}else{if(this.popupWindow==null||this.popupWindow.closed){if(this.x<0){this.x=0}if(this.y<0){this.y=0}if(screen&&screen.availHeight){if((this.y+this.height)>screen.availHeight){this.y=screen.availHeight-this.height}}if(screen&&screen.availWidth){if((this.x+this.width)>screen.availWidth){this.x=screen.availWidth-this.width}}var b=window.opera||(document.layers&&!navigator.mimeTypes["*"])||navigator.vendor=="KDE"||(document.childNodes&&!document.all&&!navigator.taintEnabled);this.popupWindow=window.open(b?"":"about:blank","window_"+a,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"")}this.refresh()}}function PopupWindow_hidePopup(){if(this.divName!=null){if(this.use_gebi){document.getElementById(this.divName).style.visibility="hidden"}else{if(this.use_css){document.all[this.divName].style.visibility="hidden"}else{if(this.use_layers){document.layers[this.divName].visibility="hidden"}}}}else{if(this.popupWindow&&!this.popupWindow.closed){this.popupWindow.close();this.popupWindow=null}}}function PopupWindow_isClicked(c){if(this.divName!=null){if(this.use_layers){var d=c.pageX;var b=c.pageY;var a=document.layers[this.divName];if((d>a.left)&&(d<a.left+a.clip.width)&&(b>a.top)&&(b<a.top+a.clip.height)){return true}else{return false}}else{if(document.all){var a=window.event.srcElement;while(a.parentElement!=null){if(a.id==this.divName){return true}a=a.parentElement}return false}else{if(this.use_gebi&&c){var a=c.originalTarget;while(a.parentNode!=null){if(a.id==this.divName){return true}a=a.parentNode}return false}}}return false}return false}function PopupWindow_hideIfNotClicked(a){if(this.autoHideEnabled&&!this.isClicked(a)){this.hidePopup()}}function PopupWindow_autoHide(){this.autoHideEnabled=true}function PopupWindow_hidePopupWindows(c){for(var a=0;a<popupWindowObjects.length;a++){if(popupWindowObjects[a]!=null){var b=popupWindowObjects[a];b.hideIfNotClicked(c)}}}function PopupWindow_attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP)}window.popupWindowOldEventListener=document.onmouseup;if(window.popupWindowOldEventListener!=null){document.onmouseup=new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();")}else{document.onmouseup=PopupWindow_hidePopupWindows}}function PopupWindow(){if(!window.popupWindowIndex){window.popupWindowIndex=0}if(!window.popupWindowObjects){window.popupWindowObjects=new Array()}if(!window.listenerAttached){window.listenerAttached=true;PopupWindow_attachListener()}this.index=popupWindowIndex++;popupWindowObjects[this.index]=this;this.divName=null;this.popupWindow=null;this.width=0;this.height=0;this.populated=false;this.visible=false;this.autoHideEnabled=false;this.contents="";this.url="";this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";if(arguments.length>0){this.type="DIV";this.divName=arguments[0]}else{this.type="WINDOW"}this.use_gebi=false;this.use_css=false;this.use_layers=false;if(document.getElementById){this.use_gebi=true}else{if(document.all){this.use_css=true}else{if(document.layers){this.use_layers=true}else{this.type="WINDOW"}}}this.offsetX=0;this.offsetY=0;this.getXYPosition=PopupWindow_getXYPosition;this.populate=PopupWindow_populate;this.setUrl=PopupWindow_setUrl;this.setWindowProperties=PopupWindow_setWindowProperties;this.refresh=PopupWindow_refresh;this.showPopup=PopupWindow_showPopup;this.hidePopup=PopupWindow_hidePopup;this.setSize=PopupWindow_setSize;this.isClicked=PopupWindow_isClicked;this.autoHide=PopupWindow_autoHide;this.hideIfNotClicked=PopupWindow_hideIfNotClicked}ColorPicker_targetInput=null;function ColorPicker_writeDiv(){document.writeln('<DIV ID="colorPickerDiv" STYLE="position:absolute;visibility:hidden;"> </DIV>')}function ColorPicker_show(a){this.showPopup(a)}function ColorPicker_pickColor(a,b){b.hidePopup();pickColor(a)}function pickColor(a){if(ColorPicker_targetInput==null){alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!");return}ColorPicker_targetInput.value=a}function ColorPicker_select(b,a){if(b.type!="text"&&b.type!="hidden"&&b.type!="textarea"){alert("colorpicker.select: Input object passed is not a valid form input object");window.ColorPicker_targetInput=null;return}window.ColorPicker_targetInput=b;this.show(a)}function ColorPicker_highlightColor(e){var a=(arguments.length>1)?arguments[1]:window.document;var b=a.getElementById("colorPickerSelectedColor");b.style.backgroundColor=e;b=a.getElementById("colorPickerSelectedColorValue");b.innerHTML=e}function ColorPicker(){var g=false;if(arguments.length==0){var e="colorPickerDiv"}else{if(arguments[0]=="window"){var e="";g=true}else{var e=arguments[0]}}if(e!=""){var m=new PopupWindow(e)}else{var m=new PopupWindow();m.setSize(225,250)}m.currentValue="#FFFFFF";m.writeDiv=ColorPicker_writeDiv;m.highlightColor=ColorPicker_highlightColor;m.show=ColorPicker_show;m.select=ColorPicker_select;var a=new Array("#4180B6","#69AEE7","#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099","#3300CC","#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099","#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#7FFFFF","#7FFFFF","#7FF7F7","#7FEFEF","#7FE7E7","#7FDFDF","#7FD7D7","#7FCFCF","#7FC7C7","#7FBFBF","#7FB7B7","#7FAFAF","#7FA7A7","#7F9F9F","#7F9797","#7F8F8F","#7F8787","#7F7F7F","#7F7777","#7F6F6F","#7F6767","#7F5F5F","#7F5757","#7F4F4F","#7F4747","#7F3F3F","#7F3737","#7F2F2F","#7F2727","#7F1F1F","#7F1717","#7F0F0F","#7F0707","#7F0000","#4180B6","#69AEE7","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333","#333366","#333399","#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300","#993333","#993366","#993399","#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF7FFF","#FF7FFF","#F77FF7","#EF7FEF","#E77FE7","#DF7FDF","#D77FD7","#CF7FCF","#C77FC7","#BF7FBF","#B77FB7","#AF7FAF","#A77FA7","#9F7F9F","#977F97","#8F7F8F","#877F87","#7F7F7F","#777F77","#6F7F6F","#677F67","#5F7F5F","#577F57","#4F7F4F","#477F47","#3F7F3F","#377F37","#2F7F2F","#277F27","#1F7F1F","#177F17","#0F7F0F","#077F07","#007F00","#4180B6","#69AEE7","#006600","#006633","#006666","#006699","#0066CC","#0066FF","#336600","#336633","#336666","#336699","#3366CC","#3366FF","#666600","#666633","#666666","#666699","#6666CC","#6666FF","#996600","#996633","#996666","#996699","#9966CC","#9966FF","#CC6600","#CC6633","#CC6666","#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699","#FF66CC","#FF66FF","#FFFF7F","#FFFF7F","#F7F77F","#EFEF7F","#E7E77F","#DFDF7F","#D7D77F","#CFCF7F","#C7C77F","#BFBF7F","#B7B77F","#AFAF7F","#A7A77F","#9F9F7F","#97977F","#8F8F7F","#87877F","#7F7F7F","#77777F","#6F6F7F","#67677F","#5F5F7F","#57577F","#4F4F7F","#47477F","#3F3F7F","#37377F","#2F2F7F","#27277F","#1F1F7F","#17177F","#0F0F7F","#07077F","#00007F","#4180B6","#69AEE7","#009900","#009933","#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999","#3399CC","#3399FF","#669900","#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999","#9999CC","#9999FF","#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999","#FF99CC","#FF99FF","#3FFFFF","#3FFFFF","#3FF7F7","#3FEFEF","#3FE7E7","#3FDFDF","#3FD7D7","#3FCFCF","#3FC7C7","#3FBFBF","#3FB7B7","#3FAFAF","#3FA7A7","#3F9F9F","#3F9797","#3F8F8F","#3F8787","#3F7F7F","#3F7777","#3F6F6F","#3F6767","#3F5F5F","#3F5757","#3F4F4F","#3F4747","#3F3F3F","#3F3737","#3F2F2F","#3F2727","#3F1F1F","#3F1717","#3F0F0F","#3F0707","#3F0000","#4180B6","#69AEE7","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66","#99CC99","#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33","#FFCC66","#FFCC99","#FFCCCC","#FFCCFF","#FF3FFF","#FF3FFF","#F73FF7","#EF3FEF","#E73FE7","#DF3FDF","#D73FD7","#CF3FCF","#C73FC7","#BF3FBF","#B73FB7","#AF3FAF","#A73FA7","#9F3F9F","#973F97","#8F3F8F","#873F87","#7F3F7F","#773F77","#6F3F6F","#673F67","#5F3F5F","#573F57","#4F3F4F","#473F47","#3F3F3F","#373F37","#2F3F2F","#273F27","#1F3F1F","#173F17","#0F3F0F","#073F07","#003F00","#4180B6","#69AEE7","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00","#33FF33","#33FF66","#33FF99","#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF","#99FF00","#99FF33","#99FF66","#99FF99","#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC","#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99","#FFFFCC","#FFFFFF","#FFFF3F","#FFFF3F","#F7F73F","#EFEF3F","#E7E73F","#DFDF3F","#D7D73F","#CFCF3F","#C7C73F","#BFBF3F","#B7B73F","#AFAF3F","#A7A73F","#9F9F3F","#97973F","#8F8F3F","#87873F","#7F7F3F","#77773F","#6F6F3F","#67673F","#5F5F3F","#57573F","#4F4F3F","#47473F","#3F3F3F","#37373F","#2F2F3F","#27273F","#1F1F3F","#17173F","#0F0F3F","#07073F","#00003F","#4180B6","#69AEE7","#FFFFFF","#FFEEEE","#FFDDDD","#FFCCCC","#FFBBBB","#FFAAAA","#FF9999","#FF8888","#FF7777","#FF6666","#FF5555","#FF4444","#FF3333","#FF2222","#FF1111","#FF0000","#FF0000","#FF0000","#FF0000","#EE0000","#DD0000","#CC0000","#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000","#000000","#000000","#000000","#001111","#002222","#003333","#004444","#005555","#006666","#007777","#008888","#009999","#00AAAA","#00BBBB","#00CCCC","#00DDDD","#00EEEE","#00FFFF","#00FFFF","#00FFFF","#00FFFF","#11FFFF","#22FFFF","#33FFFF","#44FFFF","#55FFFF","#66FFFF","#77FFFF","#88FFFF","#99FFFF","#AAFFFF","#BBFFFF","#CCFFFF","#DDFFFF","#EEFFFF","#FFFFFF","#4180B6","#69AEE7","#FFFFFF","#EEFFEE","#DDFFDD","#CCFFCC","#BBFFBB","#AAFFAA","#99FF99","#88FF88","#77FF77","#66FF66","#55FF55","#44FF44","#33FF33","#22FF22","#11FF11","#00FF00","#00FF00","#00FF00","#00FF00","#00EE00","#00DD00","#00CC00","#00BB00","#00AA00","#009900","#008800","#007700","#006600","#005500","#004400","#003300","#002200","#001100","#000000","#000000","#000000","#000000","#110011","#220022","#330033","#440044","#550055","#660066","#770077","#880088","#990099","#AA00AA","#BB00BB","#CC00CC","#DD00DD","#EE00EE","#FF00FF","#FF00FF","#FF00FF","#FF00FF","#FF11FF","#FF22FF","#FF33FF","#FF44FF","#FF55FF","#FF66FF","#FF77FF","#FF88FF","#FF99FF","#FFAAFF","#FFBBFF","#FFCCFF","#FFDDFF","#FFEEFF","#FFFFFF","#4180B6","#69AEE7","#FFFFFF","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF","#7777FF","#6666FF","#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF","#0000FF","#0000FF","#0000FF","#0000EE","#0000DD","#0000CC","#0000BB","#0000AA","#000099","#000088","#000077","#000066","#000055","#000044","#000033","#000022","#000011","#000000","#000000","#000000","#000000","#111100","#222200","#333300","#444400","#555500","#666600","#777700","#888800","#999900","#AAAA00","#BBBB00","#CCCC00","#DDDD00","#EEEE00","#FFFF00","#FFFF00","#FFFF00","#FFFF00","#FFFF11","#FFFF22","#FFFF33","#FFFF44","#FFFF55","#FFFF66","#FFFF77","#FFFF88","#FFFF99","#FFFFAA","#FFFFBB","#FFFFCC","#FFFFDD","#FFFFEE","#FFFFFF","#4180B6","#69AEE7","#FFFFFF","#FFFFFF","#FBFBFB","#F7F7F7","#F3F3F3","#EFEFEF","#EBEBEB","#E7E7E7","#E3E3E3","#DFDFDF","#DBDBDB","#D7D7D7","#D3D3D3","#CFCFCF","#CBCBCB","#C7C7C7","#C3C3C3","#BFBFBF","#BBBBBB","#B7B7B7","#B3B3B3","#AFAFAF","#ABABAB","#A7A7A7","#A3A3A3","#9F9F9F","#9B9B9B","#979797","#939393","#8F8F8F","#8B8B8B","#878787","#838383","#7F7F7F","#7B7B7B","#777777","#737373","#6F6F6F","#6B6B6B","#676767","#636363","#5F5F5F","#5B5B5B","#575757","#535353","#4F4F4F","#4B4B4B","#474747","#434343","#3F3F3F","#3B3B3B","#373737","#333333","#2F2F2F","#2B2B2B","#272727","#232323","#1F1F1F","#1B1B1B","#171717","#131313","#0F0F0F","#0B0B0B","#070707","#030303","#000000","#000000","#000000","#000000","#000000");var n=a.length;var c=72;var k="";var j=(g)?"window.opener.":"";if(g){k+="<html><head><title>Select Color</title></head>";k+="<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><span style='text-align: center;'>"}k+="<table style='border: none;' cellspacing=0 cellpadding=0>";var l=(document.getElementById||document.all)?true:false;for(var h=0;h<n;h++){if((h%c)==0){k+="<tr>"}if(l){var f='onMouseOver="'+j+"ColorPicker_highlightColor('"+a[h]+"',window.document)\""}else{f=""}k+='<td style="background-color: '+a[h]+';"><a href="javascript:void()" onclick="'+j+"ColorPicker_pickColor('"+a[h]+"',"+j+"window.popupWindowObjects["+m.index+']);return false;" '+f+">&nbsp;</a></td>";if(((h+1)>=n)||(((h+1)%c)==0)){k+="</tr>"}}if(document.getElementById){var d=Math.floor(c/2);var b=c=d;k+="<tr><td colspan='"+d+"' style='background-color: #FFF;' ID='colorPickerSelectedColor'>&nbsp;</td><td colspan='"+b+"' style='text-align: center;' id='colorPickerSelectedColorValue'>#FFFFFF</td></tr>"}k+="</table>";if(g){k+="</span></body></html>"}m.populate(k+"\n");m.offsetY=25;m.autoHide();return m};
Index: /tags/3.1/wp-includes/js/comment-reply.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/comment-reply.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/comment-reply.dev.js	(revision 17487)
@@ -0,0 +1,48 @@
+
+addComment = {
+	moveForm : function(commId, parentId, respondId, postId) {
+		var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
+
+		if ( ! comm || ! respond || ! cancel || ! parent )
+			return;
+
+		t.respondId = respondId;
+		postId = postId || false;
+
+		if ( ! t.I('wp-temp-form-div') ) {
+			div = document.createElement('div');
+			div.id = 'wp-temp-form-div';
+			div.style.display = 'none';
+			respond.parentNode.insertBefore(div, respond);
+		}
+
+		comm.parentNode.insertBefore(respond, comm.nextSibling);
+		if ( post && postId )
+			post.value = postId;
+		parent.value = parentId;
+		cancel.style.display = '';
+
+		cancel.onclick = function() {
+			var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
+
+			if ( ! temp || ! respond )
+				return;
+
+			t.I('comment_parent').value = '0';
+			temp.parentNode.insertBefore(respond, temp);
+			temp.parentNode.removeChild(temp);
+			this.style.display = 'none';
+			this.onclick = null;
+			return false;
+		}
+
+		try { t.I('comment').focus(); }
+		catch(e) {}
+
+		return false;
+	},
+
+	I : function(e) {
+		return document.getElementById(e);
+	}
+}
Index: /tags/3.1/wp-includes/js/comment-reply.js
===================================================================
--- /tags/3.1/wp-includes/js/comment-reply.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/comment-reply.js	(revision 17487)
@@ -0,0 +1,1 @@
+addComment={moveForm:function(d,f,i,c){var m=this,a,h=m.I(d),b=m.I(i),l=m.I("cancel-comment-reply-link"),j=m.I("comment_parent"),k=m.I("comment_post_ID");if(!h||!b||!l||!j){return}m.respondId=i;c=c||false;if(!m.I("wp-temp-form-div")){a=document.createElement("div");a.id="wp-temp-form-div";a.style.display="none";b.parentNode.insertBefore(a,b)}h.parentNode.insertBefore(b,h.nextSibling);if(k&&c){k.value=c}j.value=f;l.style.display="";l.onclick=function(){var n=addComment,e=n.I("wp-temp-form-div"),o=n.I(n.respondId);if(!e||!o){return}n.I("comment_parent").value="0";e.parentNode.insertBefore(o,e);e.parentNode.removeChild(e);this.style.display="none";this.onclick=null;return false};try{m.I("comment").focus()}catch(g){}return false},I:function(a){return document.getElementById(a)}};
Index: /tags/3.1/wp-includes/js/crop/cropper.css
===================================================================
--- /tags/3.1/wp-includes/js/crop/cropper.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/crop/cropper.css	(revision 17487)
@@ -0,0 +1,165 @@
+.imgCrop_wrap {
+	/* width: 500px;   @done_in_js */
+	/* height: 375px;  @done_in_js */
+	position: relative;
+	cursor: crosshair;
+}
+
+/* an extra classname is applied for Opera < 9.0 to fix it's lack of opacity support */
+.imgCrop_wrap.opera8 .imgCrop_overlay,
+.imgCrop_wrap.opera8 .imgCrop_clickArea { 
+	background-color: transparent;
+}
+
+/* fix for IE displaying all boxes at line-height by default, although they are still 1 pixel high until we combine them with the pointless span */
+.imgCrop_wrap,
+.imgCrop_wrap * {
+	font-size: 0;
+}
+
+.imgCrop_overlay {
+	background-color: #000;
+	opacity: 0.5;
+	filter:alpha(opacity=50);
+	position: absolute;
+	width: 100%;
+	height: 100%;
+}
+
+.imgCrop_selArea {
+	position: absolute;
+	/* @done_in_js 
+	top: 20px;
+	left: 20px;
+	width: 200px;
+	height: 200px;
+	background: transparent url(castle.jpg) no-repeat  -210px -110px;
+	*/
+	cursor: move;
+	z-index: 2;
+}
+
+/* clickArea is all a fix for IE 5.5 & 6 to allow the user to click on the given area */
+.imgCrop_clickArea {
+	width: 100%;
+	height: 100%;
+	background-color: #FFF;
+	opacity: 0.01;
+	filter:alpha(opacity=01);
+}
+
+.imgCrop_marqueeHoriz {
+	position: absolute;
+	width: 100%;
+	height: 1px;
+	background: transparent url(marqueeHoriz.gif) repeat-x 0 0;
+	z-index: 3;
+}
+
+.imgCrop_marqueeVert {
+	position: absolute;
+	height: 100%;
+	width: 1px;
+	background: transparent url(marqueeVert.gif) repeat-y 0 0;
+	z-index: 3;
+}
+
+.imgCrop_marqueeNorth { top: 0; left: 0; }
+.imgCrop_marqueeEast  { top: 0; right: 0; }
+.imgCrop_marqueeSouth { bottom: 0px; left: 0; }
+.imgCrop_marqueeWest  { top: 0; left: 0; }
+
+
+.imgCrop_handle {
+	position: absolute;
+	border: 1px solid #333;
+	width: 6px;
+	height: 6px;
+	background: #FFF;
+	opacity: 0.5;
+	filter:alpha(opacity=50);
+	z-index: 4;
+}
+
+/* fix IE 5 box model */
+* html .imgCrop_handle {
+	width: 8px;
+	height: 8px;
+	wid\th: 6px;
+	hei\ght: 6px;
+}
+
+.imgCrop_handleN {
+	top: -3px;
+	left: 0;
+	/* margin-left: 49%;    @done_in_js */
+	cursor: n-resize;
+}
+
+.imgCrop_handleNE { 
+	top: -3px;
+	right: -3px;
+	cursor: ne-resize;
+}
+
+.imgCrop_handleE {
+	top: 0;
+	right: -3px;
+	/* margin-top: 49%;    @done_in_js */
+	cursor: e-resize;
+}
+
+.imgCrop_handleSE {
+	right: -3px;
+	bottom: -3px;
+	cursor: se-resize;
+}
+
+.imgCrop_handleS {
+	right: 0;
+	bottom: -3px;
+	/* margin-right: 49%; @done_in_js */
+	cursor: s-resize;
+}
+
+.imgCrop_handleSW {
+	left: -3px;
+	bottom: -3px;
+	cursor: sw-resize;
+}
+
+.imgCrop_handleW {
+	top: 0;
+	left: -3px;
+	/* margin-top: 49%;  @done_in_js */
+	cursor: e-resize;
+}
+
+.imgCrop_handleNW {
+	top: -3px;
+	left: -3px;
+	cursor: nw-resize;
+}
+
+/**
+ * Create an area to click & drag around on as the default browser behaviour is to let you drag the image 
+ */
+.imgCrop_dragArea {
+	width: 100%;
+	height: 100%;
+	z-index: 200;
+	position: absolute;
+	top: 0;
+	left: 0;
+}
+
+.imgCrop_previewWrap {
+	/* width: 200px;  @done_in_js */
+	/* height: 200px; @done_in_js */
+	overflow: hidden;
+	position: relative;
+}
+
+.imgCrop_previewWrap img {
+	position: absolute;
+}
Index: /tags/3.1/wp-includes/js/crop/cropper.js
===================================================================
--- /tags/3.1/wp-includes/js/crop/cropper.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/crop/cropper.js	(revision 17487)
@@ -0,0 +1,516 @@
+/**
+ * Copyright (c) 2006, David Spurr (http://www.defusion.org.uk/)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ *
+ *     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * http://www.opensource.org/licenses/bsd-license.php
+ *
+ * See scriptaculous.js for full scriptaculous licence
+ */
+
+var CropDraggable=Class.create();
+Object.extend(Object.extend(CropDraggable.prototype,Draggable.prototype),{initialize:function(_1){
+this.options=Object.extend({drawMethod:function(){
+}},arguments[1]||{});
+this.element=$(_1);
+this.handle=this.element;
+this.delta=this.currentDelta();
+this.dragging=false;
+this.eventMouseDown=this.initDrag.bindAsEventListener(this);
+Event.observe(this.handle,"mousedown",this.eventMouseDown);
+Draggables.register(this);
+},draw:function(_2){
+var _3=Position.cumulativeOffset(this.element);
+var d=this.currentDelta();
+_3[0]-=d[0];
+_3[1]-=d[1];
+var p=[0,1].map(function(i){
+return (_2[i]-_3[i]-this.offset[i]);
+}.bind(this));
+this.options.drawMethod(p);
+}});
+var Cropper={};
+Cropper.Img=Class.create();
+Cropper.Img.prototype={initialize:function(_7,_8){
+this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true},_8||{});
+if(this.options.minWidth>0&&this.options.minHeight>0){
+this.options.ratioDim.x=this.options.minWidth;
+this.options.ratioDim.y=this.options.minHeight;
+}
+this.img=$(_7);
+this.clickCoords={x:0,y:0};
+this.dragging=false;
+this.resizing=false;
+this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent);
+this.isIE=/MSIE/.test(navigator.userAgent);
+this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent);
+this.ratioX=0;
+this.ratioY=0;
+this.attached=false;
+$A(document.getElementsByTagName("script")).each(function(s){
+if(s.src.match(/cropper\.js/)){
+var _a=s.src.replace(/cropper\.js(.*)?/,"");
+var _b=document.createElement("link");
+_b.rel="stylesheet";
+_b.type="text/css";
+_b.href=_a+"cropper.css";
+_b.media="screen";
+document.getElementsByTagName("head")[0].appendChild(_b);
+}
+});
+if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){
+var _c=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y);
+this.ratioX=this.options.ratioDim.x/_c;
+this.ratioY=this.options.ratioDim.y/_c;
+}
+this.subInitialize();
+if(this.img.complete||this.isWebKit){
+this.onLoad();
+}else{
+Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this));
+}
+},getGCD:function(a,b){return 1;
+if(b==0){
+return a;
+}
+return this.getGCD(b,a%b);
+},onLoad:function(){
+var _f="imgCrop_";
+var _10=this.img.parentNode;
+var _11="";
+if(this.isOpera8){
+_11=" opera8";
+}
+this.imgWrap=Builder.node("div",{"class":_f+"wrap"+_11});
+if(this.isIE){
+this.north=Builder.node("div",{"class":_f+"overlay "+_f+"north"},[Builder.node("span")]);
+this.east=Builder.node("div",{"class":_f+"overlay "+_f+"east"},[Builder.node("span")]);
+this.south=Builder.node("div",{"class":_f+"overlay "+_f+"south"},[Builder.node("span")]);
+this.west=Builder.node("div",{"class":_f+"overlay "+_f+"west"},[Builder.node("span")]);
+var _12=[this.north,this.east,this.south,this.west];
+}else{
+this.overlay=Builder.node("div",{"class":_f+"overlay"});
+var _12=[this.overlay];
+}
+this.dragArea=Builder.node("div",{"class":_f+"dragArea"},_12);
+this.handleN=Builder.node("div",{"class":_f+"handle "+_f+"handleN"});
+this.handleNE=Builder.node("div",{"class":_f+"handle "+_f+"handleNE"});
+this.handleE=Builder.node("div",{"class":_f+"handle "+_f+"handleE"});
+this.handleSE=Builder.node("div",{"class":_f+"handle "+_f+"handleSE"});
+this.handleS=Builder.node("div",{"class":_f+"handle "+_f+"handleS"});
+this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"});
+this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"});
+this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"});
+this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]);
+Element.setStyle($(this.selArea),{backgroundColor:"transparent",backgroundRepeat:"no-repeat",backgroundPosition:"0 0"});
+this.imgWrap.appendChild(this.img);
+this.imgWrap.appendChild(this.dragArea);
+this.dragArea.appendChild(this.selArea);
+this.dragArea.appendChild(Builder.node("div",{"class":_f+"clickArea"}));
+_10.appendChild(this.imgWrap);
+Event.observe(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));
+Event.observe(document,"mousemove",this.onDrag.bindAsEventListener(this));
+Event.observe(document,"mouseup",this.endCrop.bindAsEventListener(this));
+var _13=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];
+for(var i=0;i<_13.length;i++){
+Event.observe(_13[i],"mousedown",this.startResize.bindAsEventListener(this));
+}
+if(this.options.captureKeys){
+Event.observe(document,"keydown",this.handleKeys.bindAsEventListener(this));
+}
+new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)});
+this.setParams();
+},setParams:function(){
+this.imgW=this.img.width;
+this.imgH=this.img.height;
+if(!this.isIE){
+Element.setStyle($(this.overlay),{width:this.imgW+"px",height:this.imgH+"px"});
+Element.hide($(this.overlay));
+Element.setStyle($(this.selArea),{backgroundImage:"url("+this.img.src+")"});
+}else{
+Element.setStyle($(this.north),{height:0});
+Element.setStyle($(this.east),{width:0,height:0});
+Element.setStyle($(this.south),{height:0});
+Element.setStyle($(this.west),{width:0,height:0});
+}
+Element.setStyle($(this.imgWrap),{"width":this.imgW+"px","height":this.imgH+"px"});
+Element.hide($(this.selArea));
+var _15=Position.positionedOffset(this.imgWrap);
+this.wrapOffsets={"top":_15[1],"left":_15[0]};
+var _16={x1:0,y1:0,x2:0,y2:0};
+this.setAreaCoords(_16);
+if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0&&this.options.displayOnInit){
+_16.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2);
+_16.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2);
+_16.x2=_16.x1+this.options.ratioDim.x;
+_16.y2=_16.y1+this.options.ratioDim.y;
+Element.show(this.selArea);
+this.drawArea();
+this.endCrop();
+}
+this.attached=true;
+},remove:function(){
+this.attached=false;
+this.imgWrap.parentNode.insertBefore(this.img,this.imgWrap);
+this.imgWrap.parentNode.removeChild(this.imgWrap);
+Event.stopObserving(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));
+Event.stopObserving(document,"mousemove",this.onDrag.bindAsEventListener(this));
+Event.stopObserving(document,"mouseup",this.endCrop.bindAsEventListener(this));
+var _17=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];
+for(var i=0;i<_17.length;i++){
+Event.stopObserving(_17[i],"mousedown",this.startResize.bindAsEventListener(this));
+}
+if(this.options.captureKeys){
+Event.stopObserving(document,"keydown",this.handleKeys.bindAsEventListener(this));
+}
+},reset:function(){
+if(!this.attached){
+this.onLoad();
+}else{
+this.setParams();
+}
+this.endCrop();
+},handleKeys:function(e){
+var dir={x:0,y:0};
+if(!this.dragging){
+switch(e.keyCode){
+case (37):
+dir.x=-1;
+break;
+case (38):
+dir.y=-1;
+break;
+case (39):
+dir.x=1;
+break;
+case (40):
+dir.y=1;
+break;
+}
+if(dir.x!=0||dir.y!=0){
+if(e.shiftKey){
+dir.x*=10;
+dir.y*=10;
+}
+this.moveArea([this.areaCoords.x1+dir.x,this.areaCoords.y1+dir.y]);
+Event.stop(e);
+}
+}
+},calcW:function(){
+return (this.areaCoords.x2-this.areaCoords.x1);
+},calcH:function(){
+return (this.areaCoords.y2-this.areaCoords.y1);
+},moveArea:function(_1b){
+this.setAreaCoords({x1:_1b[0],y1:_1b[1],x2:_1b[0]+this.calcW(),y2:_1b[1]+this.calcH()},true);
+this.drawArea();
+},cloneCoords:function(_1c){
+return {x1:_1c.x1,y1:_1c.y1,x2:_1c.x2,y2:_1c.y2};
+},setAreaCoords:function(_1d,_1e,_1f,_20,_21){
+var _22=typeof _1e!="undefined"?_1e:false;
+var _23=typeof _1f!="undefined"?_1f:false;
+if(_1e){
+var _24=_1d.x2-_1d.x1;
+var _25=_1d.y2-_1d.y1;
+if(_1d.x1<0){
+_1d.x1=0;
+_1d.x2=_24;
+}
+if(_1d.y1<0){
+_1d.y1=0;
+_1d.y2=_25;
+}
+if(_1d.x2>this.imgW){
+_1d.x2=this.imgW;
+_1d.x1=this.imgW-_24;
+}
+if(_1d.y2>this.imgH){
+_1d.y2=this.imgH;
+_1d.y1=this.imgH-_25;
+}
+}else{
+if(_1d.x1<0){
+_1d.x1=0;
+}
+if(_1d.y1<0){
+_1d.y1=0;
+}
+if(_1d.x2>this.imgW){
+_1d.x2=this.imgW;
+}
+if(_1d.y2>this.imgH){
+_1d.y2=this.imgH;
+}
+if(typeof (_20)!="undefined"){
+if(this.ratioX>0){
+this.applyRatio(_1d,{x:this.ratioX,y:this.ratioY},_20,_21);
+}else{
+if(_23){
+this.applyRatio(_1d,{x:1,y:1},_20,_21);
+}
+}
+var _26={a1:_1d.x1,a2:_1d.x2};
+var _27={a1:_1d.y1,a2:_1d.y2};
+var _28=this.options.minWidth;
+var _29=this.options.minHeight;
+if((_28==0||_29==0)&&_23){
+if(_28>0){
+_29=_28;
+}else{
+if(_29>0){
+_28=_29;
+}
+}
+}
+this.applyMinDimension(_26,_28,_20.x,{min:0,max:this.imgW});
+this.applyMinDimension(_27,_29,_20.y,{min:0,max:this.imgH});
+_1d={x1:_26.a1,y1:_27.a1,x2:_26.a2,y2:_27.a2};
+}
+}
+this.areaCoords=_1d;
+},applyMinDimension:function(_2a,_2b,_2c,_2d){
+if((_2a.a2-_2a.a1)<_2b){
+if(_2c==1){
+_2a.a2=_2a.a1+_2b;
+}else{
+_2a.a1=_2a.a2-_2b;
+}
+if(_2a.a1<_2d.min){
+_2a.a1=_2d.min;
+_2a.a2=_2b;
+}else{
+if(_2a.a2>_2d.max){
+_2a.a1=_2d.max-_2b;
+_2a.a2=_2d.max;
+}
+}
+}
+},applyRatio:function(_2e,_2f,_30,_31){
+var _32;
+if(_31=="N"||_31=="S"){
+_32=this.applyRatioToAxis({a1:_2e.y1,b1:_2e.x1,a2:_2e.y2,b2:_2e.x2},{a:_2f.y,b:_2f.x},{a:_30.y,b:_30.x},{min:0,max:this.imgW});
+_2e.x1=_32.b1;
+_2e.y1=_32.a1;
+_2e.x2=_32.b2;
+_2e.y2=_32.a2;
+}else{
+_32=this.applyRatioToAxis({a1:_2e.x1,b1:_2e.y1,a2:_2e.x2,b2:_2e.y2},{a:_2f.x,b:_2f.y},{a:_30.x,b:_30.y},{min:0,max:this.imgH});
+_2e.x1=_32.a1;
+_2e.y1=_32.b1;
+_2e.x2=_32.a2;
+_2e.y2=_32.b2;
+}
+},applyRatioToAxis:function(_33,_34,_35,_36){
+var _37=Object.extend(_33,{});
+var _38=_37.a2-_37.a1;
+var _3a=Math.floor(_38*_34.b/_34.a);
+var _3b;
+var _3c;
+var _3d=null;
+if(_35.b==1){
+_3b=_37.b1+_3a;
+if(_3b>_36.max){
+_3b=_36.max;
+_3d=_3b-_37.b1;
+}
+_37.b2=_3b;
+}else{
+_3b=_37.b2-_3a;
+if(_3b<_36.min){
+_3b=_36.min;
+_3d=_3b+_37.b2;
+}
+_37.b1=_3b;
+}
+if(_3d!=null){
+_3c=Math.floor(_3d*_34.a/_34.b);
+if(_35.a==1){
+_37.a2=_37.a1+_3c;
+}else{
+_37.a1=_37.a1=_37.a2-_3c;
+}
+}
+return _37;
+},drawArea:function(){
+if(!this.isIE){
+Element.show($(this.overlay));
+}
+var _3e=this.calcW();
+var _3f=this.calcH();
+var _40=this.areaCoords.x2;
+var _41=this.areaCoords.y2;
+var _42=this.selArea.style;
+_42.left=this.areaCoords.x1+"px";
+_42.top=this.areaCoords.y1+"px";
+_42.width=_3e+"px";
+_42.height=_3f+"px";
+var _43=Math.ceil((_3e-6)/2)+"px";
+var _44=Math.ceil((_3f-6)/2)+"px";
+this.handleN.style.left=_43;
+this.handleE.style.top=_44;
+this.handleS.style.left=_43;
+this.handleW.style.top=_44;
+if(this.isIE){
+this.north.style.height=this.areaCoords.y1+"px";
+var _45=this.east.style;
+_45.top=this.areaCoords.y1+"px";
+_45.height=_3f+"px";
+_45.left=_40+"px";
+_45.width=(this.img.width-_40)+"px";
+var _46=this.south.style;
+_46.top=_41+"px";
+_46.height=(this.img.height-_41)+"px";
+var _47=this.west.style;
+_47.top=this.areaCoords.y1+"px";
+_47.height=_3f+"px";
+_47.width=this.areaCoords.x1+"px";
+}else{
+_42.backgroundPosition="-"+this.areaCoords.x1+"px "+"-"+this.areaCoords.y1+"px";
+}
+this.subDrawArea();
+this.forceReRender();
+},forceReRender:function(){
+if(this.isIE||this.isWebKit){
+var n=document.createTextNode(" ");
+var d,el,fixEL,i;
+if(this.isIE){
+fixEl=this.selArea;
+}else{
+if(this.isWebKit){
+fixEl=document.getElementsByClassName("imgCrop_marqueeSouth",this.imgWrap)[0];
+d=Builder.node("div","");
+d.style.visibility="hidden";
+var _4a=["SE","S","SW"];
+for(i=0;i<_4a.length;i++){
+el=document.getElementsByClassName("imgCrop_handle"+_4a[i],this.selArea)[0];
+if(el.childNodes.length){
+el.removeChild(el.childNodes[0]);
+}
+el.appendChild(d);
+}
+}
+}
+fixEl.appendChild(n);
+fixEl.removeChild(n);
+}
+},startResize:function(e){
+this.startCoords=this.cloneCoords(this.areaCoords);
+this.resizing=true;
+this.resizeHandle=Element.classNames(Event.element(e)).toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,"");
+Event.stop(e);
+},startDrag:function(e){
+Element.show(this.selArea);
+this.clickCoords=this.getCurPos(e);
+this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y});
+this.dragging=true;
+this.onDrag(e);
+Event.stop(e);
+},getCurPos:function(e){
+return curPos={x:Event.pointerX(e)-this.wrapOffsets.left,y:Event.pointerY(e)-this.wrapOffsets.top};
+},onDrag:function(e){
+var _4f=null;
+if(this.dragging||this.resizing){
+var _50=this.getCurPos(e);
+var _51=this.cloneCoords(this.areaCoords);
+var _52={x:1,y:1};
+}
+if(this.dragging){
+if(_50.x<this.clickCoords.x){
+_52.x=-1;
+}
+if(_50.y<this.clickCoords.y){
+_52.y=-1;
+}
+this.transformCoords(_50.x,this.clickCoords.x,_51,"x");
+this.transformCoords(_50.y,this.clickCoords.y,_51,"y");
+}else{
+if(this.resizing){
+_4f=this.resizeHandle;
+if(_4f.match(/E/)){
+this.transformCoords(_50.x,this.startCoords.x1,_51,"x");
+if(_50.x<this.startCoords.x1){
+_52.x=-1;
+}
+}else{
+if(_4f.match(/W/)){
+this.transformCoords(_50.x,this.startCoords.x2,_51,"x");
+if(_50.x<this.startCoords.x2){
+_52.x=-1;
+}
+}
+}
+if(_4f.match(/N/)){
+this.transformCoords(_50.y,this.startCoords.y2,_51,"y");
+if(_50.y<this.startCoords.y2){
+_52.y=-1;
+}
+}else{
+if(_4f.match(/S/)){
+this.transformCoords(_50.y,this.startCoords.y1,_51,"y");
+if(_50.y<this.startCoords.y1){
+_52.y=-1;
+}
+}
+}
+}
+}
+if(this.dragging||this.resizing){
+this.setAreaCoords(_51,false,e.shiftKey,_52,_4f);
+this.drawArea();
+Event.stop(e);
+}
+},transformCoords:function(_53,_54,_55,_56){
+var _57=new Array();
+if(_53<_54){
+_57[0]=_53;
+_57[1]=_54;
+}else{
+_57[0]=_54;
+_57[1]=_53;
+}
+if(_56=="x"){
+_55.x1=_57[0];
+_55.x2=_57[1];
+}else{
+_55.y1=_57[0];
+_55.y2=_57[1];
+}
+},endCrop:function(){
+this.dragging=false;
+this.resizing=false;
+this.options.onEndCrop(this.areaCoords,{width:this.calcW(),height:this.calcH()});
+},subInitialize:function(){
+},subDrawArea:function(){
+}};
+Cropper.ImgWithPreview=Class.create();
+Object.extend(Object.extend(Cropper.ImgWithPreview.prototype,Cropper.Img.prototype),{subInitialize:function(){
+this.hasPreviewImg=false;
+if(typeof (this.options.previewWrap)!="undefined"&&this.options.minWidth>0&&this.options.minHeight>0){
+this.previewWrap=$(this.options.previewWrap);
+this.previewImg=this.img.cloneNode(false);
+this.options.displayOnInit=true;
+this.hasPreviewImg=true;
+Element.addClassName(this.previewWrap,"imgCrop_previewWrap");
+Element.setStyle(this.previewWrap,{width:this.options.minWidth+"px",height:this.options.minHeight+"px"});
+this.previewWrap.appendChild(this.previewImg);
+}
+},subDrawArea:function(){
+if(this.hasPreviewImg){
+var _58=this.calcW();
+var _59=this.calcH();
+var _5a={x:this.imgW/_58,y:this.imgH/_59};
+var _5b={x:_58/this.options.minWidth,y:_59/this.options.minHeight};
+var _5c={w:Math.ceil(this.options.minWidth*_5a.x)+"px",h:Math.ceil(this.options.minHeight*_5a.y)+"px",x:"-"+Math.ceil(this.areaCoords.x1/_5b.x)+"px",y:"-"+Math.ceil(this.areaCoords.y1/_5b.y)+"px"};
+var _5d=this.previewImg.style;
+_5d.width=_5c.w;
+_5d.height=_5c.h;
+_5d.left=_5c.x;
+_5d.top=_5c.y;
+}
+}});
Index: /tags/3.1/wp-includes/js/hoverIntent.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/hoverIntent.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/hoverIntent.dev.js	(revision 17487)
@@ -0,0 +1,128 @@
+/**
+* hoverIntent is similar to jQuery's built-in "hover" function except that
+* instead of firing the onMouseOver event immediately, hoverIntent checks
+* to see if the user's mouse has slowed down (beneath the sensitivity
+* threshold) before firing the onMouseOver event.
+* 
+* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
+* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
+* 
+* hoverIntent is currently available for use in all personal or commercial 
+* projects under both MIT and GPL licenses. This means that you can choose 
+* the license that best suits your project, and use it accordingly.
+* 
+* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
+* $("ul li").hoverIntent( showNav , hideNav );
+* 
+* // advanced usage receives configuration object only
+* $("ul li").hoverIntent({
+*	sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
+*	interval: 100,   // number = milliseconds of polling interval
+*	over: showNav,  // function = onMouseOver callback (required)
+*	timeout: 0,   // number = milliseconds delay before onMouseOut function call
+*	out: hideNav    // function = onMouseOut callback (required)
+* });
+* 
+* @param  f  onMouseOver function || An object with configuration options
+* @param  g  onMouseOut function  || Nothing (use configuration options object)
+* @author    Brian Cherne <brian@cherne.net>
+*/
+(function($) {
+	$.fn.hoverIntent = function(f,g) {
+		// default configuration options
+		var cfg = {
+			sensitivity: 7,
+			interval: 100,
+			timeout: 0
+		};
+		// override configuration options with user supplied object
+		cfg = $.extend(cfg, g ? { over: f, out: g } : f );
+
+		// instantiate variables
+		// cX, cY = current X and Y position of mouse, updated by mousemove event
+		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
+		var cX, cY, pX, pY;
+
+		// A private function for getting mouse position
+		var track = function(ev) {
+			cX = ev.pageX;
+			cY = ev.pageY;
+		};
+
+		// A private function for comparing current and previous mouse position
+		var compare = function(ev,ob) {
+			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
+			// compare mouse positions to see if they've crossed the threshold
+			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
+				$(ob).unbind("mousemove",track);
+				// set hoverIntent state to true (so mouseOut can be called)
+				ob.hoverIntent_s = 1;
+				return cfg.over.apply(ob,[ev]);
+			} else {
+				// set previous coordinates for next time
+				pX = cX; pY = cY;
+				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
+				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
+			}
+		};
+
+		// A private function for delaying the mouseOut function
+		var delay = function(ev,ob) {
+			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
+			ob.hoverIntent_s = 0;
+			return cfg.out.apply(ob,[ev]);
+		};
+		
+		// workaround for Mozilla bug: not firing mouseout/mouseleave on absolute positioned elements over textareas and input type="text"
+		var handleHover = function(e) {
+			var t = this;
+			
+			// next two lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
+			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
+			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
+			if ( p == this ) {
+				if ( $.browser.mozilla ) {
+					if ( e.type == "mouseout" ) {
+						t.mtout = setTimeout( function(){doHover(e,t);}, 30 );
+					} else {
+						if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
+					}
+				}
+				return;
+			} else {
+				if (t.mtout) { t.mtout = clearTimeout(t.mtout); }
+				doHover(e,t);
+			}
+		};
+
+		// A private function for handling mouse 'hovering'
+		var doHover = function(e,ob) {
+
+			// copy objects to be passed into t (required for event object to be passed in IE)
+			var ev = jQuery.extend({},e);
+
+			// cancel hoverIntent timer if it exists
+			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
+
+			// else e.type == "onmouseover"
+			if (e.type == "mouseover") {
+				// set "previous" X and Y position based on initial entry point
+				pX = ev.pageX; pY = ev.pageY;
+				// update "current" X and Y position based on mousemove
+				$(ob).bind("mousemove",track);
+				// start polling interval (self-calling timeout) to compare mouse coordinates over time
+				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
+
+			// else e.type == "onmouseout"
+			} else {
+				// unbind expensive mousemove event
+				$(ob).unbind("mousemove",track);
+				// if hoverIntent state is true, then call the mouseOut function after the specified delay
+				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
+			}
+		};
+
+		// bind the function to the two event listeners
+		return this.mouseover(handleHover).mouseout(handleHover);
+	};
+})(jQuery);
Index: /tags/3.1/wp-includes/js/hoverIntent.js
===================================================================
--- /tags/3.1/wp-includes/js/hoverIntent.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/hoverIntent.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){a.fn.hoverIntent=function(l,j){var m={sensitivity:7,interval:100,timeout:0};m=a.extend(m,j?{over:l,out:j}:l);var o,n,h,d;var e=function(f){o=f.pageX;n=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-o)+Math.abs(d-n))<m.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return m.over.apply(f,[g])}else{h=o;d=n;f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return m.out.apply(f,[g])};var b=function(q){var f=this;var g=(q.type=="mouseover"?q.fromElement:q.toElement)||q.relatedTarget;while(g&&g!=this){try{g=g.parentNode}catch(q){g=this}}if(g==this){if(a.browser.mozilla){if(q.type=="mouseout"){f.mtout=setTimeout(function(){k(q,f)},30)}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}}}return}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}k(q,f)}};var k=function(p,f){var g=jQuery.extend({},p);if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(p.type=="mouseover"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},m.timeout)}}};return this.mouseover(b).mouseout(b)}})(jQuery);
Index: /tags/3.1/wp-includes/js/imgareaselect/imgareaselect.css
===================================================================
--- /tags/3.1/wp-includes/js/imgareaselect/imgareaselect.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/imgareaselect/imgareaselect.css	(revision 17487)
@@ -0,0 +1,41 @@
+/*
+ * imgAreaSelect animated border style
+ */
+
+.imgareaselect-border1 {
+	background: url(border-anim-v.gif) repeat-y left top;
+}
+
+.imgareaselect-border2 {
+    background: url(border-anim-h.gif) repeat-x left top;
+}
+
+.imgareaselect-border3 {
+    background: url(border-anim-v.gif) repeat-y right top;
+}
+
+.imgareaselect-border4 {
+    background: url(border-anim-h.gif) repeat-x left bottom;
+}
+
+.imgareaselect-border1, .imgareaselect-border2,
+.imgareaselect-border3, .imgareaselect-border4 {
+	opacity: 0.5;
+    filter: alpha(opacity=50);
+}
+
+.imgareaselect-handle {
+    background-color: #fff;
+	border: solid 1px #000;
+	opacity: 0.4;
+	filter: alpha(opacity=40);
+}
+
+.imgareaselect-outer {
+	background-color: #000;
+	opacity: 0.4;
+    filter: alpha(opacity=40);
+}
+
+.imgareaselect-selection {
+}
Index: /tags/3.1/wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js	(revision 17487)
@@ -0,0 +1,691 @@
+/*
+ * imgAreaSelect jQuery plugin
+ * version 0.9.1
+ *
+ * Copyright (c) 2008-2009 Michal Wojciechowski (odyniec.net)
+ *
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://odyniec.net/projects/imgareaselect/
+ *
+ */
+
+(function($) {
+
+var abs = Math.abs,
+    max = Math.max,
+    min = Math.min,
+    round = Math.round;
+
+function div() {
+    return $('<div/>');
+}
+
+$.imgAreaSelect = function (img, options) {
+    var
+
+        $img = $(img),
+
+        imgLoaded,
+
+        $box = div(),
+        $area = div(),
+        $border = div().add(div()).add(div()).add(div()),
+        $outer = div().add(div()).add(div()).add(div()),
+        $handles = $([]),
+
+        $areaOpera,
+
+        left, top,
+
+        imgOfs,
+
+        imgWidth, imgHeight,
+
+        $parent,
+
+        parOfs,
+
+        zIndex = 0,
+
+        position = 'absolute',
+
+        startX, startY,
+
+        scaleX, scaleY,
+
+        resizeMargin = 10,
+
+        resize,
+
+        aspectRatio,
+
+        shown,
+
+        x1, y1, x2, y2,
+
+        selection = { x1: 0, y1: 0, x2: 0, y2: 0, width: 0, height: 0 },
+
+        $p, d, i, o, w, h, adjusted;
+
+    function viewX(x) {
+        return x + imgOfs.left - parOfs.left;
+    }
+
+    function viewY(y) {
+        return y + imgOfs.top - parOfs.top;
+    }
+
+    function selX(x) {
+        return x - imgOfs.left + parOfs.left;
+    }
+
+    function selY(y) {
+        return y - imgOfs.top + parOfs.top;
+    }
+
+    function evX(event) {
+        return event.pageX - parOfs.left;
+    }
+
+    function evY(event) {
+        return event.pageY - parOfs.top;
+    }
+
+    function getSelection(noScale) {
+        var sx = noScale || scaleX, sy = noScale || scaleY;
+
+        return { x1: round(selection.x1 * sx),
+            y1: round(selection.y1 * sy),
+            x2: round(selection.x2 * sx),
+            y2: round(selection.y2 * sy),
+            width: round(selection.x2 * sx) - round(selection.x1 * sx),
+            height: round(selection.y2 * sy) - round(selection.y1 * sy) };
+    }
+
+    function setSelection(x1, y1, x2, y2, noScale) {
+        var sx = noScale || scaleX, sy = noScale || scaleY;
+
+        selection = {
+            x1: round(x1 / sx),
+            y1: round(y1 / sy),
+            x2: round(x2 / sx),
+            y2: round(y2 / sy)
+        };
+
+        selection.width = (x2 = viewX(selection.x2)) - (x1 = viewX(selection.x1));
+        selection.height = (y2 = viewX(selection.y2)) - (y1 = viewX(selection.y1));
+    }
+
+    function adjust() {
+        if (!$img.width())
+            return;
+
+        imgOfs = { left: round($img.offset().left), top: round($img.offset().top) };
+
+        imgWidth = $img.width();
+        imgHeight = $img.height();
+
+        if ($().jquery == '1.3.2' && $.browser.safari && position == 'fixed') {
+            imgOfs.top += max(document.documentElement.scrollTop, $('body').scrollTop());
+
+            imgOfs.left += max(document.documentElement.scrollLeft, $('body').scrollLeft());
+        }
+
+        parOfs = $.inArray($parent.css('position'), ['absolute', 'relative']) + 1 ?
+            { left: round($parent.offset().left) - $parent.scrollLeft(),
+                top: round($parent.offset().top) - $parent.scrollTop() } :
+            position == 'fixed' ?
+                { left: $(document).scrollLeft(), top: $(document).scrollTop() } :
+                { left: 0, top: 0 };
+
+        left = viewX(0);
+        top = viewY(0);
+    }
+
+    function update(resetKeyPress) {
+        if (!shown) return;
+
+        $box.css({ left: viewX(selection.x1), top: viewY(selection.y1) })
+            .add($area).width(w = selection.width).height(h = selection.height);
+
+        $area.add($border).add($handles).css({ left: 0, top: 0 });
+
+        $border
+            .width(max(w - $border.outerWidth() + $border.innerWidth(), 0))
+            .height(max(h - $border.outerHeight() + $border.innerHeight(), 0));
+
+        $($outer[0]).css({ left: left, top: top,
+            width: selection.x1, height: imgHeight });
+        $($outer[1]).css({ left: left + selection.x1, top: top,
+            width: w, height: selection.y1 });
+        $($outer[2]).css({ left: left + selection.x2, top: top,
+            width: imgWidth - selection.x2, height: imgHeight });
+        $($outer[3]).css({ left: left + selection.x1, top: top + selection.y2,
+            width: w, height: imgHeight - selection.y2 });
+
+        w -= $handles.outerWidth();
+        h -= $handles.outerHeight();
+
+        switch ($handles.length) {
+        case 8:
+            $($handles[4]).css({ left: w / 2 });
+            $($handles[5]).css({ left: w, top: h / 2 });
+            $($handles[6]).css({ left: w / 2, top: h });
+            $($handles[7]).css({ top: h / 2 });
+        case 4:
+            $handles.slice(1,3).css({ left: w });
+            $handles.slice(2,4).css({ top: h });
+        }
+
+        if (resetKeyPress !== false) {
+            if ($.imgAreaSelect.keyPress != docKeyPress)
+                $(document).unbind($.imgAreaSelect.keyPress,
+                    $.imgAreaSelect.onKeyPress);
+
+            if (options.keys)
+                $(document)[$.imgAreaSelect.keyPress](
+                    $.imgAreaSelect.onKeyPress = docKeyPress);
+        }
+
+        if ($.browser.msie && $border.outerWidth() - $border.innerWidth() == 2) {
+            $border.css('margin', 0);
+            setTimeout(function () { $border.css('margin', 'auto'); }, 0);
+        }
+    }
+
+    function doUpdate(resetKeyPress) {
+        adjust();
+        update(resetKeyPress);
+        x1 = viewX(selection.x1); y1 = viewY(selection.y1);
+        x2 = viewX(selection.x2); y2 = viewY(selection.y2);
+    }
+
+    function hide($elem, fn) {
+        options.fadeSpeed ? $elem.fadeOut(options.fadeSpeed, fn) : $elem.hide();
+
+    }
+
+    function areaMouseMove(event) {
+        var x = selX(evX(event)) - selection.x1,
+            y = selY(evY(event)) - selection.y1;
+
+        if (!adjusted) {
+            adjust();
+            adjusted = true;
+
+            $box.one('mouseout', function () { adjusted = false; });
+        }
+
+        resize = '';
+
+        if (options.resizable) {
+            if (y <= resizeMargin)
+                resize = 'n';
+            else if (y >= selection.height - resizeMargin)
+                resize = 's';
+            if (x <= resizeMargin)
+                resize += 'w';
+            else if (x >= selection.width - resizeMargin)
+                resize += 'e';
+        }
+
+        $box.css('cursor', resize ? resize + '-resize' :
+            options.movable ? 'move' : '');
+        if ($areaOpera)
+            $areaOpera.toggle();
+    }
+
+    function docMouseUp(event) {
+        $('body').css('cursor', '');
+
+        if (options.autoHide || selection.width * selection.height == 0)
+            hide($box.add($outer), function () { $(this).hide(); });
+
+        options.onSelectEnd(img, getSelection());
+
+        $(document).unbind('mousemove', selectingMouseMove);
+        $box.mousemove(areaMouseMove);
+    }
+
+    function areaMouseDown(event) {
+        if (event.which != 1) return false;
+
+        adjust();
+
+        if (resize) {
+            $('body').css('cursor', resize + '-resize');
+
+            x1 = viewX(selection[/w/.test(resize) ? 'x2' : 'x1']);
+            y1 = viewY(selection[/n/.test(resize) ? 'y2' : 'y1']);
+
+            $(document).mousemove(selectingMouseMove)
+                .one('mouseup', docMouseUp);
+            $box.unbind('mousemove', areaMouseMove);
+        }
+        else if (options.movable) {
+            startX = left + selection.x1 - evX(event);
+            startY = top + selection.y1 - evY(event);
+
+            $box.unbind('mousemove', areaMouseMove);
+
+            $(document).mousemove(movingMouseMove)
+                .one('mouseup', function () {
+                    options.onSelectEnd(img, getSelection());
+
+                    $(document).unbind('mousemove', movingMouseMove);
+                    $box.mousemove(areaMouseMove);
+                });
+        }
+        else
+            $img.mousedown(event);
+
+        return false;
+    }
+
+    function aspectRatioXY() {
+        x2 = max(left, min(left + imgWidth,
+            x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1)));
+
+        y2 = round(max(top, min(top + imgHeight,
+            y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1))));
+        x2 = round(x2);
+    }
+
+    function aspectRatioYX() {
+        y2 = max(top, min(top + imgHeight,
+            y1 + abs(x2 - x1) / aspectRatio * (y2 > y1 || -1)));
+        x2 = round(max(left, min(left + imgWidth,
+            x1 + abs(y2 - y1) * aspectRatio * (x2 > x1 || -1))));
+        y2 = round(y2);
+    }
+
+    function doResize() {
+        if (abs(x2 - x1) < options.minWidth) {
+            x2 = x1 - options.minWidth * (x2 < x1 || -1);
+
+            if (x2 < left)
+                x1 = left + options.minWidth;
+            else if (x2 > left + imgWidth)
+                x1 = left + imgWidth - options.minWidth;
+        }
+
+        if (abs(y2 - y1) < options.minHeight) {
+            y2 = y1 - options.minHeight * (y2 < y1 || -1);
+
+            if (y2 < top)
+                y1 = top + options.minHeight;
+            else if (y2 > top + imgHeight)
+                y1 = top + imgHeight - options.minHeight;
+        }
+
+        x2 = max(left, min(x2, left + imgWidth));
+        y2 = max(top, min(y2, top + imgHeight));
+
+        if (aspectRatio)
+            if (abs(x2 - x1) / aspectRatio > abs(y2 - y1))
+                aspectRatioYX();
+            else
+                aspectRatioXY();
+
+        if (abs(x2 - x1) > options.maxWidth) {
+            x2 = x1 - options.maxWidth * (x2 < x1 || -1);
+            if (aspectRatio) aspectRatioYX();
+        }
+
+        if (abs(y2 - y1) > options.maxHeight) {
+            y2 = y1 - options.maxHeight * (y2 < y1 || -1);
+            if (aspectRatio) aspectRatioXY();
+        }
+
+        selection = { x1: selX(min(x1, x2)), x2: selX(max(x1, x2)),
+            y1: selY(min(y1, y2)), y2: selY(max(y1, y2)),
+            width: abs(x2 - x1), height: abs(y2 - y1) };
+
+        update();
+
+        options.onSelectChange(img, getSelection());
+    }
+
+    function selectingMouseMove(event) {
+        x2 = resize == '' || /w|e/.test(resize) || aspectRatio ? evX(event) : viewX(selection.x2);
+        y2 = resize == '' || /n|s/.test(resize) || aspectRatio ? evY(event) : viewY(selection.y2);
+
+        doResize();
+
+        return false;
+
+    }
+
+    function doMove(newX1, newY1) {
+        x2 = (x1 = newX1) + selection.width;
+        y2 = (y1 = newY1) + selection.height;
+
+        selection = $.extend(selection, { x1: selX(x1), y1: selY(y1),
+            x2: selX(x2), y2: selY(y2) });
+
+        update();
+
+        options.onSelectChange(img, getSelection());
+    }
+
+    function movingMouseMove(event) {
+        x1 = max(left, min(startX + evX(event), left + imgWidth - selection.width));
+        y1 = max(top, min(startY + evY(event), top + imgHeight - selection.height));
+
+        doMove(x1, y1);
+
+        event.preventDefault();
+
+        return false;
+    }
+
+    function startSelection() {
+        adjust();
+
+        x2 = x1;
+        y2 = y1;
+
+        doResize();
+
+        resize = '';
+
+        if ($outer.is(':not(:visible)'))
+            $box.add($outer).hide().fadeIn(options.fadeSpeed||0);
+
+        shown = true;
+
+        $(document).unbind('mouseup', cancelSelection)
+            .mousemove(selectingMouseMove).one('mouseup', docMouseUp);
+        $box.unbind('mousemove', areaMouseMove);
+
+        options.onSelectStart(img, getSelection());
+    }
+
+    function cancelSelection() {
+        $(document).unbind('mousemove', startSelection);
+        hide($box.add($outer));
+
+        selection = { x1: selX(x1), y1: selY(y1), x2: selX(x1), y2: selY(y1),
+                width: 0, height: 0 };
+
+        options.onSelectChange(img, getSelection());
+        options.onSelectEnd(img, getSelection());
+    }
+
+    function imgMouseDown(event) {
+        if (event.which != 1 || $outer.is(':animated')) return false;
+
+        adjust();
+        startX = x1 = evX(event);
+        startY = y1 = evY(event);
+
+        $(document).one('mousemove', startSelection)
+            .one('mouseup', cancelSelection);
+
+        return false;
+    }
+
+    function parentScroll() {
+        doUpdate(false);
+    }
+
+    function imgLoad() {
+        imgLoaded = true;
+
+        setOptions(options = $.extend({
+            classPrefix: 'imgareaselect',
+            movable: true,
+            resizable: true,
+            parent: 'body',
+            onInit: function () {},
+            onSelectStart: function () {},
+            onSelectChange: function () {},
+            onSelectEnd: function () {}
+        }, options));
+
+        $box.add($outer).css({ visibility: '' });
+
+        if (options.show) {
+            shown = true;
+            adjust();
+            update();
+            $box.add($outer).hide().fadeIn(options.fadeSpeed||0);
+        }
+
+        setTimeout(function () { options.onInit(img, getSelection()); }, 0);
+    }
+
+    var docKeyPress = function(event) {
+        var k = options.keys, d, t, key = event.keyCode || event.which;
+
+        d = !isNaN(k.alt) && (event.altKey || event.originalEvent.altKey) ? k.alt :
+            !isNaN(k.ctrl) && event.ctrlKey ? k.ctrl :
+            !isNaN(k.shift) && event.shiftKey ? k.shift :
+            !isNaN(k.arrows) ? k.arrows : 10;
+
+        if (k.arrows == 'resize' || (k.shift == 'resize' && event.shiftKey) ||
+            (k.ctrl == 'resize' && event.ctrlKey) ||
+            (k.alt == 'resize' && (event.altKey || event.originalEvent.altKey)))
+        {
+            switch (key) {
+            case 37:
+                d = -d;
+            case 39:
+                t = max(x1, x2);
+                x1 = min(x1, x2);
+                x2 = max(t + d, x1);
+                if (aspectRatio) aspectRatioYX();
+                break;
+            case 38:
+                d = -d;
+            case 40:
+                t = max(y1, y2);
+                y1 = min(y1, y2);
+                y2 = max(t + d, y1);
+                if (aspectRatio) aspectRatioXY();
+                break;
+            default:
+                return;
+            }
+
+            doResize();
+        }
+        else {
+            x1 = min(x1, x2);
+            y1 = min(y1, y2);
+
+            switch (key) {
+            case 37:
+                doMove(max(x1 - d, left), y1);
+                break;
+            case 38:
+                doMove(x1, max(y1 - d, top));
+                break;
+            case 39:
+                doMove(x1 + min(d, imgWidth - selX(x2)), y1);
+                break;
+            case 40:
+                doMove(x1, y1 + min(d, imgHeight - selY(y2)));
+                break;
+            default:
+                return;
+            }
+        }
+
+        return false;
+    };
+
+    function styleOptions($elem, props) {
+        for (option in props)
+            if (options[option] !== undefined)
+                $elem.css(props[option], options[option]);
+    }
+
+    function setOptions(newOptions) {
+        if (newOptions.parent)
+            ($parent = $(newOptions.parent)).append($box.add($outer));
+
+        options = $.extend(options, newOptions);
+
+        adjust();
+
+        if (newOptions.handles != null) {
+            $handles.remove();
+            $handles = $([]);
+
+            i = newOptions.handles ? newOptions.handles == 'corners' ? 4 : 8 : 0;
+
+            while (i--)
+                $handles = $handles.add(div());
+
+            $handles.addClass(options.classPrefix + '-handle').css({
+                position: 'absolute',
+                fontSize: 0,
+                zIndex: zIndex + 1 || 1
+            });
+
+            if (!parseInt($handles.css('width')))
+                $handles.width(5).height(5);
+
+            if (o = options.borderWidth)
+                $handles.css({ borderWidth: o, borderStyle: 'solid' });
+
+            styleOptions($handles, { borderColor1: 'border-color',
+                borderColor2: 'background-color',
+                borderOpacity: 'opacity' });
+        }
+
+        scaleX = options.imageWidth / imgWidth || 1;
+        scaleY = options.imageHeight / imgHeight || 1;
+
+        if (newOptions.x1 != null) {
+            setSelection(newOptions.x1, newOptions.y1, newOptions.x2,
+                    newOptions.y2);
+            newOptions.show = !newOptions.hide;
+        }
+
+        if (newOptions.keys)
+            options.keys = $.extend({ shift: 1, ctrl: 'resize' },
+                newOptions.keys);
+
+        $outer.addClass(options.classPrefix + '-outer');
+        $area.addClass(options.classPrefix + '-selection');
+        for (i = 0; i++ < 4;)
+            $($border[i-1]).addClass(options.classPrefix + '-border' + i);
+
+        styleOptions($area, { selectionColor: 'background-color',
+            selectionOpacity: 'opacity' });
+        styleOptions($border, { borderOpacity: 'opacity',
+            borderWidth: 'border-width' });
+        styleOptions($outer, { outerColor: 'background-color',
+            outerOpacity: 'opacity' });
+        if (o = options.borderColor1)
+            $($border[0]).css({ borderStyle: 'solid', borderColor: o });
+        if (o = options.borderColor2)
+            $($border[1]).css({ borderStyle: 'dashed', borderColor: o });
+
+        $box.append($area.add($border).add($handles).add($areaOpera));
+
+        if ($.browser.msie) {
+            if (o = $outer.css('filter').match(/opacity=([0-9]+)/))
+                $outer.css('opacity', o[1]/100);
+            if (o = $border.css('filter').match(/opacity=([0-9]+)/))
+                $border.css('opacity', o[1]/100);
+        }
+
+        if (newOptions.hide)
+            hide($box.add($outer));
+        else if (newOptions.show && imgLoaded) {
+            shown = true;
+            $box.add($outer).fadeIn(options.fadeSpeed||0);
+            doUpdate();
+        }
+
+        aspectRatio = (d = (options.aspectRatio || '').split(/:/))[0] / d[1];
+
+        if (options.disable || options.enable === false) {
+            $box.unbind('mousemove', areaMouseMove).unbind('mousedown', areaMouseDown);
+            $img.add($outer).unbind('mousedown', imgMouseDown);
+            $(window).unbind('resize', parentScroll);
+            $img.add($img.parents()).unbind('scroll', parentScroll);
+        }
+        else if (options.enable || options.disable === false) {
+            if (options.resizable || options.movable)
+                $box.mousemove(areaMouseMove).mousedown(areaMouseDown);
+
+            if (!options.persistent)
+                $img.add($outer).mousedown(imgMouseDown);
+            $(window).resize(parentScroll);
+            $img.add($img.parents()).scroll(parentScroll);
+        }
+
+        options.enable = options.disable = undefined;
+    }
+
+    this.getOptions = function () { return options; };
+
+    this.setOptions = setOptions;
+
+    this.getSelection = getSelection;
+
+    this.setSelection = setSelection;
+
+    this.update = doUpdate;
+
+    $p = $img;
+
+    while ($p.length && !$p.is('body')) {
+        if (!isNaN($p.css('z-index')) && $p.css('z-index') > zIndex)
+            zIndex = $p.css('z-index');
+        if ($p.css('position') == 'fixed')
+            position = 'fixed';
+
+        $p = $p.parent();
+    }
+
+    if (!isNaN(options.zIndex))
+        zIndex = options.zIndex;
+
+    if ($.browser.msie)
+        $img.attr('unselectable', 'on');
+
+    $.imgAreaSelect.keyPress = $.browser.msie ||
+        $.browser.safari ? 'keydown' : 'keypress';
+
+    if ($.browser.opera)
+        $areaOpera = div().css({ width: '100%', height: '100%',
+            position: 'absolute', zIndex: zIndex + 2 || 2 });
+
+    $box.add($outer).css({ visibility: 'hidden', position: position,
+        overflow: 'hidden', zIndex: zIndex || '0' });
+    $box.css({ zIndex: zIndex + 2 || 2 });
+    $area.add($border).css({ position: 'absolute' });
+
+    img.complete || img.readyState == 'complete' || !$img.is('img') ?
+        imgLoad() : $img.one('load', imgLoad);
+
+};
+
+$.fn.imgAreaSelect = function (options) {
+    options = options || {};
+
+    this.each(function () {
+        if ($(this).data('imgAreaSelect'))
+            $(this).data('imgAreaSelect').setOptions(options);
+        else {
+            if (options.enable === undefined && options.disable === undefined)
+                options.enable = true;
+
+            $(this).data('imgAreaSelect', new $.imgAreaSelect(this, options));
+        }
+    });
+
+    if (options.instance)
+        return $(this).data('imgAreaSelect');
+
+    return this;
+};
+
+})(jQuery);
Index: /tags/3.1/wp-includes/js/imgareaselect/jquery.imgareaselect.js
===================================================================
--- /tags/3.1/wp-includes/js/imgareaselect/jquery.imgareaselect.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/imgareaselect/jquery.imgareaselect.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(e){var b=Math.abs,a=Math.max,d=Math.min,c=Math.round;function f(){return e("<div/>")}e.imgAreaSelect=function(q,S){var aw=e(q),U,ar=f(),af=f(),H=f().add(f()).add(f()).add(f()),Y=f().add(f()).add(f()).add(f()),L=e([]),R,n,p,az,N,j,A,M,B=0,ad="absolute",Q,P,aa,Z,V=10,I,T,K,y,aA,x,ay,v={x1:0,y1:0,x2:0,y2:0,width:0,height:0},l,aq,am,ag,ac,an,u;function G(h){return h+az.left-M.left}function F(h){return h+az.top-M.top}function E(h){return h-az.left+M.left}function z(h){return h-az.top+M.top}function ak(h){return h.pageX-M.left}function ai(h){return h.pageY-M.top}function D(h){var o=h||aa,i=h||Z;return{x1:c(v.x1*o),y1:c(v.y1*i),x2:c(v.x2*o),y2:c(v.y2*i),width:c(v.x2*o)-c(v.x1*o),height:c(v.y2*i)-c(v.y1*i)}}function ae(i,w,h,o,aB){var aD=aB||aa,aC=aB||Z;v={x1:c(i/aD),y1:c(w/aC),x2:c(h/aD),y2:c(o/aC)};v.width=(h=G(v.x2))-(i=G(v.x1));v.height=(o=G(v.y2))-(w=G(v.y1))}function ao(){if(!aw.width()){return}az={left:c(aw.offset().left),top:c(aw.offset().top)};N=aw.width();j=aw.height();if(e().jquery=="1.3.2"&&e.browser.safari&&ad=="fixed"){az.top+=a(document.documentElement.scrollTop,e("body").scrollTop());az.left+=a(document.documentElement.scrollLeft,e("body").scrollLeft())}M=e.inArray(A.css("position"),["absolute","relative"])+1?{left:c(A.offset().left)-A.scrollLeft(),top:c(A.offset().top)-A.scrollTop()}:ad=="fixed"?{left:e(document).scrollLeft(),top:e(document).scrollTop()}:{left:0,top:0};n=G(0);p=F(0)}function X(h){if(!K){return}ar.css({left:G(v.x1),top:F(v.y1)}).add(af).width(ac=v.width).height(an=v.height);af.add(H).add(L).css({left:0,top:0});H.width(a(ac-H.outerWidth()+H.innerWidth(),0)).height(a(an-H.outerHeight()+H.innerHeight(),0));e(Y[0]).css({left:n,top:p,width:v.x1,height:j});e(Y[1]).css({left:n+v.x1,top:p,width:ac,height:v.y1});e(Y[2]).css({left:n+v.x2,top:p,width:N-v.x2,height:j});e(Y[3]).css({left:n+v.x1,top:p+v.y2,width:ac,height:j-v.y2});ac-=L.outerWidth();an-=L.outerHeight();switch(L.length){case 8:e(L[4]).css({left:ac/2});e(L[5]).css({left:ac,top:an/2});e(L[6]).css({left:ac/2,top:an});e(L[7]).css({top:an/2});case 4:L.slice(1,3).css({left:ac});L.slice(2,4).css({top:an})}if(h!==false){if(e.imgAreaSelect.keyPress!=at){e(document).unbind(e.imgAreaSelect.keyPress,e.imgAreaSelect.onKeyPress)}if(S.keys){e(document)[e.imgAreaSelect.keyPress](e.imgAreaSelect.onKeyPress=at)}}if(e.browser.msie&&H.outerWidth()-H.innerWidth()==2){H.css("margin",0);setTimeout(function(){H.css("margin","auto")},0)}}function t(h){ao();X(h);y=G(v.x1);aA=F(v.y1);x=G(v.x2);ay=F(v.y2)}function ah(h,i){S.fadeSpeed?h.fadeOut(S.fadeSpeed,i):h.hide()}function C(i){var h=E(ak(i))-v.x1,o=z(ai(i))-v.y1;if(!u){ao();u=true;ar.one("mouseout",function(){u=false})}I="";if(S.resizable){if(o<=V){I="n"}else{if(o>=v.height-V){I="s"}}if(h<=V){I+="w"}else{if(h>=v.width-V){I+="e"}}}ar.css("cursor",I?I+"-resize":S.movable?"move":"");if(R){R.toggle()}}function aj(h){e("body").css("cursor","");if(S.autoHide||v.width*v.height==0){ah(ar.add(Y),function(){e(this).hide()})}S.onSelectEnd(q,D());e(document).unbind("mousemove",ab);ar.mousemove(C)}function s(h){if(h.which!=1){return false}ao();if(I){e("body").css("cursor",I+"-resize");y=G(v[/w/.test(I)?"x2":"x1"]);aA=F(v[/n/.test(I)?"y2":"y1"]);e(document).mousemove(ab).one("mouseup",aj);ar.unbind("mousemove",C)}else{if(S.movable){Q=n+v.x1-ak(h);P=p+v.y1-ai(h);ar.unbind("mousemove",C);e(document).mousemove(g).one("mouseup",function(){S.onSelectEnd(q,D());e(document).unbind("mousemove",g);ar.mousemove(C)})}else{aw.mousedown(h)}}return false}function r(){x=a(n,d(n+N,y+b(ay-aA)*T*(x>y||-1)));ay=c(a(p,d(p+j,aA+b(x-y)/T*(ay>aA||-1))));x=c(x)}function al(){ay=a(p,d(p+j,aA+b(x-y)/T*(ay>aA||-1)));x=c(a(n,d(n+N,y+b(ay-aA)*T*(x>y||-1))));ay=c(ay)}function av(){if(b(x-y)<S.minWidth){x=y-S.minWidth*(x<y||-1);if(x<n){y=n+S.minWidth}else{if(x>n+N){y=n+N-S.minWidth}}}if(b(ay-aA)<S.minHeight){ay=aA-S.minHeight*(ay<aA||-1);if(ay<p){aA=p+S.minHeight}else{if(ay>p+j){aA=p+j-S.minHeight}}}x=a(n,d(x,n+N));ay=a(p,d(ay,p+j));if(T){if(b(x-y)/T>b(ay-aA)){al()}else{r()}}if(b(x-y)>S.maxWidth){x=y-S.maxWidth*(x<y||-1);if(T){al()}}if(b(ay-aA)>S.maxHeight){ay=aA-S.maxHeight*(ay<aA||-1);if(T){r()}}v={x1:E(d(y,x)),x2:E(a(y,x)),y1:z(d(aA,ay)),y2:z(a(aA,ay)),width:b(x-y),height:b(ay-aA)};X();S.onSelectChange(q,D())}function ab(h){x=I==""||/w|e/.test(I)||T?ak(h):G(v.x2);ay=I==""||/n|s/.test(I)||T?ai(h):F(v.y2);av();return false}function O(h,i){x=(y=h)+v.width;ay=(aA=i)+v.height;v=e.extend(v,{x1:E(y),y1:z(aA),x2:E(x),y2:z(ay)});X();S.onSelectChange(q,D())}function g(h){y=a(n,d(Q+ak(h),n+N-v.width));aA=a(p,d(P+ai(h),p+j-v.height));O(y,aA);h.preventDefault();return false}function ax(){ao();x=y;ay=aA;av();I="";if(Y.is(":not(:visible)")){ar.add(Y).hide().fadeIn(S.fadeSpeed||0)}K=true;e(document).unbind("mouseup",ap).mousemove(ab).one("mouseup",aj);ar.unbind("mousemove",C);S.onSelectStart(q,D())}function ap(){e(document).unbind("mousemove",ax);ah(ar.add(Y));v={x1:E(y),y1:z(aA),x2:E(y),y2:z(aA),width:0,height:0};S.onSelectChange(q,D());S.onSelectEnd(q,D())}function m(h){if(h.which!=1||Y.is(":animated")){return false}ao();Q=y=ak(h);P=aA=ai(h);e(document).one("mousemove",ax).one("mouseup",ap);return false}function W(){t(false)}function au(){U=true;J(S=e.extend({classPrefix:"imgareaselect",movable:true,resizable:true,parent:"body",onInit:function(){},onSelectStart:function(){},onSelectChange:function(){},onSelectEnd:function(){}},S));ar.add(Y).css({visibility:""});if(S.show){K=true;ao();X();ar.add(Y).hide().fadeIn(S.fadeSpeed||0)}setTimeout(function(){S.onInit(q,D())},0)}var at=function(w){var h=S.keys,aB,o,i=w.keyCode||w.which;aB=!isNaN(h.alt)&&(w.altKey||w.originalEvent.altKey)?h.alt:!isNaN(h.ctrl)&&w.ctrlKey?h.ctrl:!isNaN(h.shift)&&w.shiftKey?h.shift:!isNaN(h.arrows)?h.arrows:10;if(h.arrows=="resize"||(h.shift=="resize"&&w.shiftKey)||(h.ctrl=="resize"&&w.ctrlKey)||(h.alt=="resize"&&(w.altKey||w.originalEvent.altKey))){switch(i){case 37:aB=-aB;case 39:o=a(y,x);y=d(y,x);x=a(o+aB,y);if(T){al()}break;case 38:aB=-aB;case 40:o=a(aA,ay);aA=d(aA,ay);ay=a(o+aB,aA);if(T){r()}break;default:return}av()}else{y=d(y,x);aA=d(aA,ay);switch(i){case 37:O(a(y-aB,n),aA);break;case 38:O(y,a(aA-aB,p));break;case 39:O(y+d(aB,N-E(x)),aA);break;case 40:O(y,aA+d(aB,j-z(ay)));break;default:return}}return false};function k(h,i){for(option in i){if(S[option]!==undefined){h.css(i[option],S[option])}}}function J(h){if(h.parent){(A=e(h.parent)).append(ar.add(Y))}S=e.extend(S,h);ao();if(h.handles!=null){L.remove();L=e([]);am=h.handles?h.handles=="corners"?4:8:0;while(am--){L=L.add(f())}L.addClass(S.classPrefix+"-handle").css({position:"absolute",fontSize:0,zIndex:B+1||1});if(!parseInt(L.css("width"))){L.width(5).height(5)}if(ag=S.borderWidth){L.css({borderWidth:ag,borderStyle:"solid"})}k(L,{borderColor1:"border-color",borderColor2:"background-color",borderOpacity:"opacity"})}aa=S.imageWidth/N||1;Z=S.imageHeight/j||1;if(h.x1!=null){ae(h.x1,h.y1,h.x2,h.y2);h.show=!h.hide}if(h.keys){S.keys=e.extend({shift:1,ctrl:"resize"},h.keys)}Y.addClass(S.classPrefix+"-outer");af.addClass(S.classPrefix+"-selection");for(am=0;am++<4;){e(H[am-1]).addClass(S.classPrefix+"-border"+am)}k(af,{selectionColor:"background-color",selectionOpacity:"opacity"});k(H,{borderOpacity:"opacity",borderWidth:"border-width"});k(Y,{outerColor:"background-color",outerOpacity:"opacity"});if(ag=S.borderColor1){e(H[0]).css({borderStyle:"solid",borderColor:ag})}if(ag=S.borderColor2){e(H[1]).css({borderStyle:"dashed",borderColor:ag})}ar.append(af.add(H).add(L).add(R));if(e.browser.msie){if(ag=Y.css("filter").match(/opacity=([0-9]+)/)){Y.css("opacity",ag[1]/100)}if(ag=H.css("filter").match(/opacity=([0-9]+)/)){H.css("opacity",ag[1]/100)}}if(h.hide){ah(ar.add(Y))}else{if(h.show&&U){K=true;ar.add(Y).fadeIn(S.fadeSpeed||0);t()}}T=(aq=(S.aspectRatio||"").split(/:/))[0]/aq[1];if(S.disable||S.enable===false){ar.unbind("mousemove",C).unbind("mousedown",s);aw.add(Y).unbind("mousedown",m);e(window).unbind("resize",W);aw.add(aw.parents()).unbind("scroll",W)}else{if(S.enable||S.disable===false){if(S.resizable||S.movable){ar.mousemove(C).mousedown(s)}if(!S.persistent){aw.add(Y).mousedown(m)}e(window).resize(W);aw.add(aw.parents()).scroll(W)}}S.enable=S.disable=undefined}this.getOptions=function(){return S};this.setOptions=J;this.getSelection=D;this.setSelection=ae;this.update=t;l=aw;while(l.length&&!l.is("body")){if(!isNaN(l.css("z-index"))&&l.css("z-index")>B){B=l.css("z-index")}if(l.css("position")=="fixed"){ad="fixed"}l=l.parent()}if(!isNaN(S.zIndex)){B=S.zIndex}if(e.browser.msie){aw.attr("unselectable","on")}e.imgAreaSelect.keyPress=e.browser.msie||e.browser.safari?"keydown":"keypress";if(e.browser.opera){R=f().css({width:"100%",height:"100%",position:"absolute",zIndex:B+2||2})}ar.add(Y).css({visibility:"hidden",position:ad,overflow:"hidden",zIndex:B||"0"});ar.css({zIndex:B+2||2});af.add(H).css({position:"absolute"});q.complete||q.readyState=="complete"||!aw.is("img")?au():aw.one("load",au)};e.fn.imgAreaSelect=function(g){g=g||{};this.each(function(){if(e(this).data("imgAreaSelect")){e(this).data("imgAreaSelect").setOptions(g)}else{if(g.enable===undefined&&g.disable===undefined){g.enable=true}e(this).data("imgAreaSelect",new e.imgAreaSelect(this,g))}});if(g.instance){return e(this).data("imgAreaSelect")}return this}})(jQuery);
Index: /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.css
===================================================================
--- /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.css	(revision 17487)
@@ -0,0 +1,35 @@
+/* Fixes issue here http://code.google.com/p/jcrop/issues/detail?id=1 */
+.jcrop-holder { text-align: left; }
+
+.jcrop-vline, .jcrop-hline
+{
+	font-size: 0;
+	position: absolute;
+	background: white url('Jcrop.gif') top left repeat;
+}
+.jcrop-vline { height: 100%; width: 1px !important; }
+.jcrop-hline { width: 100%; height: 1px !important; }
+.jcrop-handle {
+	font-size: 1px;
+	width: 7px !important;
+	height: 7px !important;
+	border: 1px #eee solid;
+	background-color: #333;
+	*width: 9px;
+	*height: 9px;
+}
+
+.jcrop-tracker { width: 100%; height: 100%; }
+
+.custom .jcrop-vline,
+.custom .jcrop-hline
+{
+	background: yellow;
+}
+.custom .jcrop-handle
+{
+	border-color: black;
+	background-color: #C7BB00;
+	-moz-border-radius: 3px;
+	-webkit-border-radius: 3px;
+}
Index: /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.dev.js	(revision 17487)
@@ -0,0 +1,1197 @@
+/**
+ * jquery.Jcrop.js v0.9.8
+ * jQuery Image Cropping Plugin
+ * @author Kelly Hallman <khallman@gmail.com>
+ * Copyright (c) 2008-2009 Kelly Hallman - released under MIT License {{{
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+
+ * }}}
+ */
+
+(function($) {
+
+$.Jcrop = function(obj,opt)
+{
+	// Initialization {{{
+
+	// Sanitize some options {{{
+	var obj = obj, opt = opt;
+
+	if (typeof(obj) !== 'object') obj = $(obj)[0];
+	if (typeof(opt) !== 'object') opt = { };
+
+	// Some on-the-fly fixes for MSIE...sigh
+	if (!('trackDocument' in opt))
+	{
+		opt.trackDocument = $.browser.msie ? false : true;
+		if ($.browser.msie && $.browser.version.split('.')[0] == '8')
+			opt.trackDocument = true;
+	}
+
+	if (!('keySupport' in opt))
+			opt.keySupport = $.browser.msie ? false : true;
+		
+	// }}}
+	// Extend the default options {{{
+	var defaults = {
+
+		// Basic Settings
+		trackDocument:		false,
+		baseClass:			'jcrop',
+		addClass:			null,
+
+		// Styling Options
+		bgColor:			'black',
+		bgOpacity:			.6,
+		borderOpacity:		.4,
+		handleOpacity:		.5,
+
+		handlePad:			5,
+		handleSize:			9,
+		handleOffset:		5,
+		edgeMargin:			14,
+
+		aspectRatio:		0,
+		keySupport:			true,
+		cornerHandles:		true,
+		sideHandles:		true,
+		drawBorders:		true,
+		dragEdges:			true,
+
+		boxWidth:			0,
+		boxHeight:			0,
+
+		boundary:			8,
+		animationDelay:		20,
+		swingSpeed:			3,
+
+		allowSelect:		true,
+		allowMove:			true,
+		allowResize:		true,
+
+		minSelect:			[ 0, 0 ],
+		maxSize:			[ 0, 0 ],
+		minSize:			[ 0, 0 ],
+
+		// Callbacks / Event Handlers
+		onChange: function() { },
+		onSelect: function() { }
+
+	};
+	var options = defaults;
+	setOptions(opt);
+
+	// }}}
+	// Initialize some jQuery objects {{{
+
+	var $origimg = $(obj);
+	var $img = $origimg.clone().removeAttr('id').css({ position: 'absolute' });
+
+	$img.width($origimg.width());
+	$img.height($origimg.height());
+	$origimg.after($img).hide();
+
+	presize($img,options.boxWidth,options.boxHeight);
+
+	var boundx = $img.width(),
+		boundy = $img.height(),
+
+		$div = $('<div />')
+			.width(boundx).height(boundy)
+			.addClass(cssClass('holder'))
+			.css({
+				position: 'relative',
+				backgroundColor: options.bgColor
+			}).insertAfter($origimg).append($img);
+	;
+	
+	if (options.addClass) $div.addClass(options.addClass);
+	//$img.wrap($div);
+
+	var $img2 = $('<img />')/*{{{*/
+			.attr('src',$img.attr('src'))
+			.css('position','absolute')
+			.width(boundx).height(boundy)
+	;/*}}}*/
+	var $img_holder = $('<div />')/*{{{*/
+		.width(pct(100)).height(pct(100))
+		.css({
+			zIndex: 310,
+			position: 'absolute',
+			overflow: 'hidden'
+		})
+		.append($img2)
+	;/*}}}*/
+	var $hdl_holder = $('<div />')/*{{{*/
+		.width(pct(100)).height(pct(100))
+		.css('zIndex',320);
+	/*}}}*/
+	var $sel = $('<div />')/*{{{*/
+		.css({
+			position: 'absolute',
+			zIndex: 300
+		})
+		.insertBefore($img)
+		.append($img_holder,$hdl_holder)
+	;/*}}}*/
+
+	var bound = options.boundary;
+	var $trk = newTracker().width(boundx+(bound*2)).height(boundy+(bound*2))
+		.css({ position: 'absolute', top: px(-bound), left: px(-bound), zIndex: 290 })
+		.mousedown(newSelection);	
+	
+	/* }}} */
+	// Set more variables {{{
+
+	var xlimit, ylimit, xmin, ymin;
+	var xscale, yscale, enabled = true;
+	var docOffset = getPos($img),
+		// Internal states
+		btndown, lastcurs, dimmed, animating,
+		shift_down;
+
+	// }}}
+		
+
+		// }}}
+	// Internal Modules {{{
+
+	var Coords = function()/*{{{*/
+	{
+		var x1 = 0, y1 = 0, x2 = 0, y2 = 0, ox, oy;
+
+		function setPressed(pos)/*{{{*/
+		{
+			var pos = rebound(pos);
+			x2 = x1 = pos[0];
+			y2 = y1 = pos[1];
+		};
+		/*}}}*/
+		function setCurrent(pos)/*{{{*/
+		{
+			var pos = rebound(pos);
+			ox = pos[0] - x2;
+			oy = pos[1] - y2;
+			x2 = pos[0];
+			y2 = pos[1];
+		};
+		/*}}}*/
+		function getOffset()/*{{{*/
+		{
+			return [ ox, oy ];
+		};
+		/*}}}*/
+		function moveOffset(offset)/*{{{*/
+		{
+			var ox = offset[0], oy = offset[1];
+
+			if (0 > x1 + ox) ox -= ox + x1;
+			if (0 > y1 + oy) oy -= oy + y1;
+
+			if (boundy < y2 + oy) oy += boundy - (y2 + oy);
+			if (boundx < x2 + ox) ox += boundx - (x2 + ox);
+
+			x1 += ox;
+			x2 += ox;
+			y1 += oy;
+			y2 += oy;
+		};
+		/*}}}*/
+		function getCorner(ord)/*{{{*/
+		{
+			var c = getFixed();
+			switch(ord)
+			{
+				case 'ne': return [ c.x2, c.y ];
+				case 'nw': return [ c.x, c.y ];
+				case 'se': return [ c.x2, c.y2 ];
+				case 'sw': return [ c.x, c.y2 ];
+			}
+		};
+		/*}}}*/
+		function getFixed()/*{{{*/
+		{
+			if (!options.aspectRatio) return getRect();
+			// This function could use some optimization I think...
+			var aspect = options.aspectRatio,
+				min_x = options.minSize[0]/xscale, 
+				min_y = options.minSize[1]/yscale,
+				max_x = options.maxSize[0]/xscale, 
+				max_y = options.maxSize[1]/yscale,
+				rw = x2 - x1,
+				rh = y2 - y1,
+				rwa = Math.abs(rw),
+				rha = Math.abs(rh),
+				real_ratio = rwa / rha,
+				xx, yy
+			;
+			if (max_x == 0) { max_x = boundx * 10 }
+			if (max_y == 0) { max_y = boundy * 10 }
+			if (real_ratio < aspect)
+			{
+				yy = y2;
+				w = rha * aspect;
+				xx = rw < 0 ? x1 - w : w + x1;
+
+				if (xx < 0)
+				{
+					xx = 0;
+					h = Math.abs((xx - x1) / aspect);
+					yy = rh < 0 ? y1 - h: h + y1;
+				}
+				else if (xx > boundx)
+				{
+					xx = boundx;
+					h = Math.abs((xx - x1) / aspect);
+					yy = rh < 0 ? y1 - h : h + y1;
+				}
+			}
+			else
+			{
+				xx = x2;
+				h = rwa / aspect;
+				yy = rh < 0 ? y1 - h : y1 + h;
+				if (yy < 0)
+				{
+					yy = 0;
+					w = Math.abs((yy - y1) * aspect);
+					xx = rw < 0 ? x1 - w : w + x1;
+				}
+				else if (yy > boundy)
+				{
+					yy = boundy;
+					w = Math.abs(yy - y1) * aspect;
+					xx = rw < 0 ? x1 - w : w + x1;
+				}
+			}
+
+			// Magic %-)
+			if(xx > x1) { // right side
+			  if(xx - x1 < min_x) {
+				xx = x1 + min_x;
+			  } else if (xx - x1 > max_x) {
+				xx = x1 + max_x;
+			  }
+			  if(yy > y1) {
+				yy = y1 + (xx - x1)/aspect;
+			  } else {
+				yy = y1 - (xx - x1)/aspect;
+			  }
+			} else if (xx < x1) { // left side
+			  if(x1 - xx < min_x) {
+				xx = x1 - min_x
+			  } else if (x1 - xx > max_x) {
+				xx = x1 - max_x;
+			  }
+			  if(yy > y1) {
+				yy = y1 + (x1 - xx)/aspect;
+			  } else {
+				yy = y1 - (x1 - xx)/aspect;
+			  }
+			}
+
+			if(xx < 0) {
+				x1 -= xx;
+				xx = 0;
+			} else  if (xx > boundx) {
+				x1 -= xx - boundx;
+				xx = boundx;
+			}
+
+			if(yy < 0) {
+				y1 -= yy;
+				yy = 0;
+			} else  if (yy > boundy) {
+				y1 -= yy - boundy;
+				yy = boundy;
+			}
+
+			return last = makeObj(flipCoords(x1,y1,xx,yy));
+		};
+		/*}}}*/
+		function rebound(p)/*{{{*/
+		{
+			if (p[0] < 0) p[0] = 0;
+			if (p[1] < 0) p[1] = 0;
+
+			if (p[0] > boundx) p[0] = boundx;
+			if (p[1] > boundy) p[1] = boundy;
+
+			return [ p[0], p[1] ];
+		};
+		/*}}}*/
+		function flipCoords(x1,y1,x2,y2)/*{{{*/
+		{
+			var xa = x1, xb = x2, ya = y1, yb = y2;
+			if (x2 < x1)
+			{
+				xa = x2;
+				xb = x1;
+			}
+			if (y2 < y1)
+			{
+				ya = y2;
+				yb = y1;
+			}
+			return [ Math.round(xa), Math.round(ya), Math.round(xb), Math.round(yb) ];
+		};
+		/*}}}*/
+		function getRect()/*{{{*/
+		{
+			var xsize = x2 - x1;
+			var ysize = y2 - y1;
+
+			if (xlimit && (Math.abs(xsize) > xlimit))
+				x2 = (xsize > 0) ? (x1 + xlimit) : (x1 - xlimit);
+			if (ylimit && (Math.abs(ysize) > ylimit))
+				y2 = (ysize > 0) ? (y1 + ylimit) : (y1 - ylimit);
+
+			if (ymin && (Math.abs(ysize) < ymin))
+				y2 = (ysize > 0) ? (y1 + ymin) : (y1 - ymin);
+			if (xmin && (Math.abs(xsize) < xmin))
+				x2 = (xsize > 0) ? (x1 + xmin) : (x1 - xmin);
+
+			if (x1 < 0) { x2 -= x1; x1 -= x1; }
+			if (y1 < 0) { y2 -= y1; y1 -= y1; }
+			if (x2 < 0) { x1 -= x2; x2 -= x2; }
+			if (y2 < 0) { y1 -= y2; y2 -= y2; }
+			if (x2 > boundx) { var delta = x2 - boundx; x1 -= delta; x2 -= delta; }
+			if (y2 > boundy) { var delta = y2 - boundy; y1 -= delta; y2 -= delta; }
+			if (x1 > boundx) { var delta = x1 - boundy; y2 -= delta; y1 -= delta; }
+			if (y1 > boundy) { var delta = y1 - boundy; y2 -= delta; y1 -= delta; }
+
+			return makeObj(flipCoords(x1,y1,x2,y2));
+		};
+		/*}}}*/
+		function makeObj(a)/*{{{*/
+		{
+			return { x: a[0], y: a[1], x2: a[2], y2: a[3],
+				w: a[2] - a[0], h: a[3] - a[1] };
+		};
+		/*}}}*/
+
+		return {
+			flipCoords: flipCoords,
+			setPressed: setPressed,
+			setCurrent: setCurrent,
+			getOffset: getOffset,
+			moveOffset: moveOffset,
+			getCorner: getCorner,
+			getFixed: getFixed
+		};
+	}();
+
+	/*}}}*/
+	var Selection = function()/*{{{*/
+	{
+		var start, end, dragmode, awake, hdep = 370;
+		var borders = { };
+		var handle = { };
+		var seehandles = false;
+		var hhs = options.handleOffset;
+
+		/* Insert draggable elements {{{*/
+
+		// Insert border divs for outline
+		if (options.drawBorders) {
+			borders = {
+					top: insertBorder('hline')
+						.css('top',$.browser.msie?px(-1):px(0)),
+					bottom: insertBorder('hline'),
+					left: insertBorder('vline'),
+					right: insertBorder('vline')
+			};
+		}
+
+		// Insert handles on edges
+		if (options.dragEdges) {
+			handle.t = insertDragbar('n');
+			handle.b = insertDragbar('s');
+			handle.r = insertDragbar('e');
+			handle.l = insertDragbar('w');
+		}
+
+		// Insert side handles
+		options.sideHandles &&
+			createHandles(['n','s','e','w']);
+
+		// Insert corner handles
+		options.cornerHandles &&
+			createHandles(['sw','nw','ne','se']);
+
+		/*}}}*/
+		// Private Methods
+		function insertBorder(type)/*{{{*/
+		{
+			var jq = $('<div />')
+				.css({position: 'absolute', opacity: options.borderOpacity })
+				.addClass(cssClass(type));
+			$img_holder.append(jq);
+			return jq;
+		};
+		/*}}}*/
+		function dragDiv(ord,zi)/*{{{*/
+		{
+			var jq = $('<div />')
+				.mousedown(createDragger(ord))
+				.css({
+					cursor: ord+'-resize',
+					position: 'absolute',
+					zIndex: zi 
+				})
+			;
+			$hdl_holder.append(jq);
+			return jq;
+		};
+		/*}}}*/
+		function insertHandle(ord)/*{{{*/
+		{
+			return dragDiv(ord,hdep++)
+				.css({ top: px(-hhs+1), left: px(-hhs+1), opacity: options.handleOpacity })
+				.addClass(cssClass('handle'));
+		};
+		/*}}}*/
+		function insertDragbar(ord)/*{{{*/
+		{
+			var s = options.handleSize,
+				o = hhs,
+				h = s, w = s,
+				t = o, l = o;
+
+			switch(ord)
+			{
+				case 'n': case 's': w = pct(100); break;
+				case 'e': case 'w': h = pct(100); break;
+			}
+
+			return dragDiv(ord,hdep++).width(w).height(h)
+				.css({ top: px(-t+1), left: px(-l+1)});
+		};
+		/*}}}*/
+		function createHandles(li)/*{{{*/
+		{
+			for(i in li) handle[li[i]] = insertHandle(li[i]);
+		};
+		/*}}}*/
+		function moveHandles(c)/*{{{*/
+		{
+			var midvert  = Math.round((c.h / 2) - hhs),
+				midhoriz = Math.round((c.w / 2) - hhs),
+				north = west = -hhs+1,
+				east = c.w - hhs,
+				south = c.h - hhs,
+				x, y;
+
+			'e' in handle &&
+				handle.e.css({ top: px(midvert), left: px(east) }) &&
+				handle.w.css({ top: px(midvert) }) &&
+				handle.s.css({ top: px(south), left: px(midhoriz) }) &&
+				handle.n.css({ left: px(midhoriz) });
+
+			'ne' in handle &&
+				handle.ne.css({ left: px(east) }) &&
+				handle.se.css({ top: px(south), left: px(east) }) &&
+				handle.sw.css({ top: px(south) });
+
+			'b' in handle &&
+				handle.b.css({ top: px(south) }) &&
+				handle.r.css({ left: px(east) });
+		};
+		/*}}}*/
+		function moveto(x,y)/*{{{*/
+		{
+			$img2.css({ top: px(-y), left: px(-x) });
+			$sel.css({ top: px(y), left: px(x) });
+		};
+		/*}}}*/
+		function resize(w,h)/*{{{*/
+		{
+			$sel.width(w).height(h);
+		};
+		/*}}}*/
+		function refresh()/*{{{*/
+		{
+			var c = Coords.getFixed();
+
+			Coords.setPressed([c.x,c.y]);
+			Coords.setCurrent([c.x2,c.y2]);
+
+			updateVisible();
+		};
+		/*}}}*/
+
+		// Internal Methods
+		function updateVisible()/*{{{*/
+			{ if (awake) return update(); };
+		/*}}}*/
+		function update()/*{{{*/
+		{
+			var c = Coords.getFixed();
+
+			resize(c.w,c.h);
+			moveto(c.x,c.y);
+
+			options.drawBorders &&
+				borders['right'].css({ left: px(c.w-1) }) &&
+					borders['bottom'].css({ top: px(c.h-1) });
+
+			seehandles && moveHandles(c);
+			awake || show();
+
+			options.onChange(unscale(c));
+		};
+		/*}}}*/
+		function show()/*{{{*/
+		{
+			$sel.show();
+			$img.css('opacity',options.bgOpacity);
+			awake = true;
+		};
+		/*}}}*/
+		function release()/*{{{*/
+		{
+			disableHandles();
+			$sel.hide();
+			$img.css('opacity',1);
+			awake = false;
+		};
+		/*}}}*/
+		function showHandles()//{{{
+		{
+			if (seehandles)
+			{
+				moveHandles(Coords.getFixed());
+				$hdl_holder.show();
+			}
+		};
+		//}}}
+		function enableHandles()/*{{{*/
+		{ 
+			seehandles = true;
+			if (options.allowResize)
+			{
+				moveHandles(Coords.getFixed());
+				$hdl_holder.show();
+				return true;
+			}
+		};
+		/*}}}*/
+		function disableHandles()/*{{{*/
+		{
+			seehandles = false;
+			$hdl_holder.hide();
+		};
+		/*}}}*/
+		function animMode(v)/*{{{*/
+		{
+			(animating = v) ? disableHandles(): enableHandles();
+		};
+		/*}}}*/
+		function done()/*{{{*/
+		{
+			animMode(false);
+			refresh();
+		};
+		/*}}}*/
+
+		var $track = newTracker().mousedown(createDragger('move'))
+				.css({ cursor: 'move', position: 'absolute', zIndex: 360 })
+
+		$img_holder.append($track);
+		disableHandles();
+
+		return {
+			updateVisible: updateVisible,
+			update: update,
+			release: release,
+			refresh: refresh,
+			setCursor: function (cursor) { $track.css('cursor',cursor); },
+			enableHandles: enableHandles,
+			enableOnly: function() { seehandles = true; },
+			showHandles: showHandles,
+			disableHandles: disableHandles,
+			animMode: animMode,
+			done: done
+		};
+	}();
+	/*}}}*/
+	var Tracker = function()/*{{{*/
+	{
+		var onMove		= function() { },
+			onDone		= function() { },
+			trackDoc	= options.trackDocument;
+
+		if (!trackDoc)
+		{
+			$trk
+				.mousemove(trackMove)
+				.mouseup(trackUp)
+				.mouseout(trackUp)
+			;
+		}
+
+		function toFront()/*{{{*/
+		{
+			$trk.css({zIndex:450});
+			if (trackDoc)
+			{
+				$(document)
+					.mousemove(trackMove)
+					.mouseup(trackUp)
+				;
+			}
+		}
+		/*}}}*/
+		function toBack()/*{{{*/
+		{
+			$trk.css({zIndex:290});
+			if (trackDoc)
+			{
+				$(document)
+					.unbind('mousemove',trackMove)
+					.unbind('mouseup',trackUp)
+				;
+			}
+		}
+		/*}}}*/
+		function trackMove(e)/*{{{*/
+		{
+			onMove(mouseAbs(e));
+		};
+		/*}}}*/
+		function trackUp(e)/*{{{*/
+		{
+			e.preventDefault();
+			e.stopPropagation();
+
+			if (btndown)
+			{
+				btndown = false;
+
+				onDone(mouseAbs(e));
+				options.onSelect(unscale(Coords.getFixed()));
+				toBack();
+				onMove = function() { };
+				onDone = function() { };
+			}
+
+			return false;
+		};
+		/*}}}*/
+
+		function activateHandlers(move,done)/* {{{ */
+		{
+			btndown = true;
+			onMove = move;
+			onDone = done;
+			toFront();
+			return false;
+		};
+		/* }}} */
+
+		function setCursor(t) { $trk.css('cursor',t); };
+
+		$img.before($trk);
+		return {
+			activateHandlers: activateHandlers,
+			setCursor: setCursor
+		};
+	}();
+	/*}}}*/
+	var KeyManager = function()/*{{{*/
+	{
+		var $keymgr = $('<input type="radio" />')
+				.css({ position: 'absolute', left: '-30px' })
+				.keypress(parseKey)
+				.blur(onBlur),
+
+			$keywrap = $('<div />')
+				.css({
+					position: 'absolute',
+					overflow: 'hidden'
+				})
+				.append($keymgr)
+		;
+
+		function watchKeys()/*{{{*/
+		{
+			if (options.keySupport)
+			{
+				$keymgr.show();
+				$keymgr.focus();
+			}
+		};
+		/*}}}*/
+		function onBlur(e)/*{{{*/
+		{
+			$keymgr.hide();
+		};
+		/*}}}*/
+		function doNudge(e,x,y)/*{{{*/
+		{
+			if (options.allowMove) {
+				Coords.moveOffset([x,y]);
+				Selection.updateVisible();
+			};
+			e.preventDefault();
+			e.stopPropagation();
+		};
+		/*}}}*/
+		function parseKey(e)/*{{{*/
+		{
+			if (e.ctrlKey) return true;
+			shift_down = e.shiftKey ? true : false;
+			var nudge = shift_down ? 10 : 1;
+			switch(e.keyCode)
+			{
+				case 37: doNudge(e,-nudge,0); break;
+				case 39: doNudge(e,nudge,0); break;
+				case 38: doNudge(e,0,-nudge); break;
+				case 40: doNudge(e,0,nudge); break;
+
+				case 27: Selection.release(); break;
+
+				case 9: return true;
+			}
+
+			return nothing(e);
+		};
+		/*}}}*/
+		
+		if (options.keySupport) $keywrap.insertBefore($img);
+		return {
+			watchKeys: watchKeys
+		};
+	}();
+	/*}}}*/
+
+	// }}}
+	// Internal Methods {{{
+
+	function px(n) { return '' + parseInt(n) + 'px'; };
+	function pct(n) { return '' + parseInt(n) + '%'; };
+	function cssClass(cl) { return options.baseClass + '-' + cl; };
+	function getPos(obj)/*{{{*/
+	{
+		// Updated in v0.9.4 to use built-in dimensions plugin
+		var pos = $(obj).offset();
+		return [ pos.left, pos.top ];
+	};
+	/*}}}*/
+	function mouseAbs(e)/*{{{*/
+	{
+		return [ (e.pageX - docOffset[0]), (e.pageY - docOffset[1]) ];
+	};
+	/*}}}*/
+	function myCursor(type)/*{{{*/
+	{
+		if (type != lastcurs)
+		{
+			Tracker.setCursor(type);
+			//Handles.xsetCursor(type);
+			lastcurs = type;
+		}
+	};
+	/*}}}*/
+	function startDragMode(mode,pos)/*{{{*/
+	{
+		docOffset = getPos($img);
+		Tracker.setCursor(mode=='move'?mode:mode+'-resize');
+
+		if (mode == 'move')
+			return Tracker.activateHandlers(createMover(pos), doneSelect);
+
+		var fc = Coords.getFixed();
+		var opp = oppLockCorner(mode);
+		var opc = Coords.getCorner(oppLockCorner(opp));
+
+		Coords.setPressed(Coords.getCorner(opp));
+		Coords.setCurrent(opc);
+
+		Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect);
+	};
+	/*}}}*/
+	function dragmodeHandler(mode,f)/*{{{*/
+	{
+		return function(pos) {
+			if (!options.aspectRatio) switch(mode)
+			{
+				case 'e': pos[1] = f.y2; break;
+				case 'w': pos[1] = f.y2; break;
+				case 'n': pos[0] = f.x2; break;
+				case 's': pos[0] = f.x2; break;
+			}
+			else switch(mode)
+			{
+				case 'e': pos[1] = f.y+1; break;
+				case 'w': pos[1] = f.y+1; break;
+				case 'n': pos[0] = f.x+1; break;
+				case 's': pos[0] = f.x+1; break;
+			}
+			Coords.setCurrent(pos);
+			Selection.update();
+		};
+	};
+	/*}}}*/
+	function createMover(pos)/*{{{*/
+	{
+		var lloc = pos;
+		KeyManager.watchKeys();
+
+		return function(pos)
+		{
+			Coords.moveOffset([pos[0] - lloc[0], pos[1] - lloc[1]]);
+			lloc = pos;
+			
+			Selection.update();
+		};
+	};
+	/*}}}*/
+	function oppLockCorner(ord)/*{{{*/
+	{
+		switch(ord)
+		{
+			case 'n': return 'sw';
+			case 's': return 'nw';
+			case 'e': return 'nw';
+			case 'w': return 'ne';
+			case 'ne': return 'sw';
+			case 'nw': return 'se';
+			case 'se': return 'nw';
+			case 'sw': return 'ne';
+		};
+	};
+	/*}}}*/
+	function createDragger(ord)/*{{{*/
+	{
+		return function(e) {
+			if (options.disabled) return false;
+			if ((ord == 'move') && !options.allowMove) return false;
+			btndown = true;
+			startDragMode(ord,mouseAbs(e));
+			e.stopPropagation();
+			e.preventDefault();
+			return false;
+		};
+	};
+	/*}}}*/
+	function presize($obj,w,h)/*{{{*/
+	{
+		var nw = $obj.width(), nh = $obj.height();
+		if ((nw > w) && w > 0)
+		{
+			nw = w;
+			nh = (w/$obj.width()) * $obj.height();
+		}
+		if ((nh > h) && h > 0)
+		{
+			nh = h;
+			nw = (h/$obj.height()) * $obj.width();
+		}
+		xscale = $obj.width() / nw;
+		yscale = $obj.height() / nh;
+		$obj.width(nw).height(nh);
+	};
+	/*}}}*/
+	function unscale(c)/*{{{*/
+	{
+		return {
+			x: parseInt(c.x * xscale), y: parseInt(c.y * yscale), 
+			x2: parseInt(c.x2 * xscale), y2: parseInt(c.y2 * yscale), 
+			w: parseInt(c.w * xscale), h: parseInt(c.h * yscale)
+		};
+	};
+	/*}}}*/
+	function doneSelect(pos)/*{{{*/
+	{
+		var c = Coords.getFixed();
+		if (c.w > options.minSelect[0] && c.h > options.minSelect[1])
+		{
+			Selection.enableHandles();
+			Selection.done();
+		}
+		else
+		{
+			Selection.release();
+		}
+		Tracker.setCursor( options.allowSelect?'crosshair':'default' );
+	};
+	/*}}}*/
+	function newSelection(e)/*{{{*/
+	{
+		if (options.disabled) return false;
+		if (!options.allowSelect) return false;
+		btndown = true;
+		docOffset = getPos($img);
+		Selection.disableHandles();
+		myCursor('crosshair');
+		var pos = mouseAbs(e);
+		Coords.setPressed(pos);
+		Tracker.activateHandlers(selectDrag,doneSelect);
+		KeyManager.watchKeys();
+		Selection.update();
+
+		e.stopPropagation();
+		e.preventDefault();
+		return false;
+	};
+	/*}}}*/
+	function selectDrag(pos)/*{{{*/
+	{
+		Coords.setCurrent(pos);
+		Selection.update();
+	};
+	/*}}}*/
+	function newTracker()
+	{
+		var trk = $('<div></div>').addClass(cssClass('tracker'));
+		$.browser.msie && trk.css({ opacity: 0, backgroundColor: 'white' });
+		return trk;
+	};
+
+	// }}}
+	// API methods {{{
+		
+	function animateTo(a)/*{{{*/
+	{
+		var x1 = a[0] / xscale,
+			y1 = a[1] / yscale,
+			x2 = a[2] / xscale,
+			y2 = a[3] / yscale;
+
+		if (animating) return;
+
+		var animto = Coords.flipCoords(x1,y1,x2,y2);
+		var c = Coords.getFixed();
+		var animat = initcr = [ c.x, c.y, c.x2, c.y2 ];
+		var interv = options.animationDelay;
+
+		var x = animat[0];
+		var y = animat[1];
+		var x2 = animat[2];
+		var y2 = animat[3];
+		var ix1 = animto[0] - initcr[0];
+		var iy1 = animto[1] - initcr[1];
+		var ix2 = animto[2] - initcr[2];
+		var iy2 = animto[3] - initcr[3];
+		var pcent = 0;
+		var velocity = options.swingSpeed;
+
+		Selection.animMode(true);
+
+		var animator = function()
+		{
+			return function()
+			{
+				pcent += (100 - pcent) / velocity;
+
+				animat[0] = x + ((pcent / 100) * ix1);
+				animat[1] = y + ((pcent / 100) * iy1);
+				animat[2] = x2 + ((pcent / 100) * ix2);
+				animat[3] = y2 + ((pcent / 100) * iy2);
+
+				if (pcent < 100) animateStart();
+					else Selection.done();
+
+				if (pcent >= 99.8) pcent = 100;
+
+				setSelectRaw(animat);
+			};
+		}();
+
+		function animateStart()
+			{ window.setTimeout(animator,interv); };
+
+		animateStart();
+	};
+	/*}}}*/
+	function setSelect(rect)//{{{
+	{
+		setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]);
+	};
+	//}}}
+	function setSelectRaw(l) /*{{{*/
+	{
+		Coords.setPressed([l[0],l[1]]);
+		Coords.setCurrent([l[2],l[3]]);
+		Selection.update();
+	};
+	/*}}}*/
+	function setOptions(opt)/*{{{*/
+	{
+		if (typeof(opt) != 'object') opt = { };
+		options = $.extend(options,opt);
+
+		if (typeof(options.onChange)!=='function')
+			options.onChange = function() { };
+
+		if (typeof(options.onSelect)!=='function')
+			options.onSelect = function() { };
+
+	};
+	/*}}}*/
+	function tellSelect()/*{{{*/
+	{
+		return unscale(Coords.getFixed());
+	};
+	/*}}}*/
+	function tellScaled()/*{{{*/
+	{
+		return Coords.getFixed();
+	};
+	/*}}}*/
+	function setOptionsNew(opt)/*{{{*/
+	{
+		setOptions(opt);
+		interfaceUpdate();
+	};
+	/*}}}*/
+	function disableCrop()//{{{
+	{
+		options.disabled = true;
+		Selection.disableHandles();
+		Selection.setCursor('default');
+		Tracker.setCursor('default');
+	};
+	//}}}
+	function enableCrop()//{{{
+	{
+		options.disabled = false;
+		interfaceUpdate();
+	};
+	//}}}
+	function cancelCrop()//{{{
+	{
+		Selection.done();
+		Tracker.activateHandlers(null,null);
+	};
+	//}}}
+	function destroy()//{{{
+	{
+		$div.remove();
+		$origimg.show();
+	};
+	//}}}
+
+	function interfaceUpdate(alt)//{{{
+	// This method tweaks the interface based on options object.
+	// Called when options are changed and at end of initialization.
+	{
+		options.allowResize ?
+			alt?Selection.enableOnly():Selection.enableHandles():
+			Selection.disableHandles();
+
+		Tracker.setCursor( options.allowSelect? 'crosshair': 'default' );
+		Selection.setCursor( options.allowMove? 'move': 'default' );
+
+		$div.css('backgroundColor',options.bgColor);
+
+		if ('setSelect' in options) {
+			setSelect(opt.setSelect);
+			Selection.done();
+			delete(options.setSelect);
+		}
+
+		if ('trueSize' in options) {
+			xscale = options.trueSize[0] / boundx;
+			yscale = options.trueSize[1] / boundy;
+		}
+
+		xlimit = options.maxSize[0] || 0;
+		ylimit = options.maxSize[1] || 0;
+		xmin = options.minSize[0] || 0;
+		ymin = options.minSize[1] || 0;
+
+		if ('outerImage' in options)
+		{
+			$img.attr('src',options.outerImage);
+			delete(options.outerImage);
+		}
+
+		Selection.refresh();
+	};
+	//}}}
+
+	// }}}
+
+	$hdl_holder.hide();
+	interfaceUpdate(true);
+	
+	var api = {
+		animateTo: animateTo,
+		setSelect: setSelect,
+		setOptions: setOptionsNew,
+		tellSelect: tellSelect,
+		tellScaled: tellScaled,
+
+		disable: disableCrop,
+		enable: enableCrop,
+		cancel: cancelCrop,
+
+		focus: KeyManager.watchKeys,
+
+		getBounds: function() { return [ boundx * xscale, boundy * yscale ]; },
+		getWidgetSize: function() { return [ boundx, boundy ]; },
+
+		release: Selection.release,
+		destroy: destroy
+
+	};
+
+	$origimg.data('Jcrop',api);
+	return api;
+};
+
+$.fn.Jcrop = function(options)/*{{{*/
+{
+	function attachWhenDone(from)/*{{{*/
+	{
+		var loadsrc = options.useImg || from.src;
+		var img = new Image();
+		img.onload = function() { $.Jcrop(from,options); };
+		img.src = loadsrc;
+	};
+	/*}}}*/
+	if (typeof(options) !== 'object') options = { };
+
+	// Iterate over each object, attach Jcrop
+	this.each(function()
+	{
+		// If we've already attached to this object
+		if ($(this).data('Jcrop'))
+		{
+			// The API can be requested this way (undocumented)
+			if (options == 'api') return $(this).data('Jcrop');
+			// Otherwise, we just reset the options...
+			else $(this).data('Jcrop').setOptions(options);
+		}
+		// If we haven't been attached, preload and attach
+		else attachWhenDone(this);
+	});
+
+	// Return "this" so we're chainable a la jQuery plugin-style!
+	return this;
+};
+/*}}}*/
+
+})(jQuery);
Index: /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.js
===================================================================
--- /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jcrop/jquery.Jcrop.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){a.Jcrop=function(d,A){var d=d,A=A;if(typeof(d)!=="object"){d=a(d)[0]}if(typeof(A)!=="object"){A={}}if(!("trackDocument" in A)){A.trackDocument=a.browser.msie?false:true;if(a.browser.msie&&a.browser.version.split(".")[0]=="8"){A.trackDocument=true}}if(!("keySupport" in A)){A.keySupport=a.browser.msie?false:true}var U={trackDocument:false,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:0.6,borderOpacity:0.4,handleOpacity:0.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,allowSelect:true,allowMove:true,allowResize:true,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var H=U;z(A);var W=a(d);var al=W.clone().removeAttr("id").css({position:"absolute"});al.width(W.width());al.height(W.height());W.after(al).hide();T(al,H.boxWidth,H.boxHeight);var Q=al.width(),O=al.height(),Z=a("<div />").width(Q).height(O).addClass(C("holder")).css({position:"relative",backgroundColor:H.bgColor}).insertAfter(W).append(al);if(H.addClass){Z.addClass(H.addClass)}var I=a("<img />").attr("src",al.attr("src")).css("position","absolute").width(Q).height(O);var k=a("<div />").width(K(100)).height(K(100)).css({zIndex:310,position:"absolute",overflow:"hidden"}).append(I);var L=a("<div />").width(K(100)).height(K(100)).css("zIndex",320);var y=a("<div />").css({position:"absolute",zIndex:300}).insertBefore(al).append(k,L);var t=H.boundary;var b=ae().width(Q+(t*2)).height(O+(t*2)).css({position:"absolute",top:l(-t),left:l(-t),zIndex:290}).mousedown(ac);var x,ah,p,S;var M,e,n=true;var ad=D(al),r,an,am,B,ab;var aa=function(){var aq=0,aC=0,ap=0,aB=0,au,ar;function aw(aF){var aF=at(aF);ap=aq=aF[0];aB=aC=aF[1]}function av(aF){var aF=at(aF);au=aF[0]-ap;ar=aF[1]-aB;ap=aF[0];aB=aF[1]}function aE(){return[au,ar]}function ao(aH){var aG=aH[0],aF=aH[1];if(0>aq+aG){aG-=aG+aq}if(0>aC+aF){aF-=aF+aC}if(O<aB+aF){aF+=O-(aB+aF)}if(Q<ap+aG){aG+=Q-(ap+aG)}aq+=aG;ap+=aG;aC+=aF;aB+=aF}function ax(aF){var aG=aD();switch(aF){case"ne":return[aG.x2,aG.y];case"nw":return[aG.x,aG.y];case"se":return[aG.x2,aG.y2];case"sw":return[aG.x,aG.y2]}}function aD(){if(!H.aspectRatio){return aA()}var aH=H.aspectRatio,aO=H.minSize[0]/M,aN=H.minSize[1]/e,aG=H.maxSize[0]/M,aQ=H.maxSize[1]/e,aI=ap-aq,aP=aB-aC,aJ=Math.abs(aI),aK=Math.abs(aP),aL=aJ/aK,aF,aM;if(aG==0){aG=Q*10}if(aQ==0){aQ=O*10}if(aL<aH){aM=aB;w=aK*aH;aF=aI<0?aq-w:w+aq;if(aF<0){aF=0;h=Math.abs((aF-aq)/aH);aM=aP<0?aC-h:h+aC}else{if(aF>Q){aF=Q;h=Math.abs((aF-aq)/aH);aM=aP<0?aC-h:h+aC}}}else{aF=ap;h=aJ/aH;aM=aP<0?aC-h:aC+h;if(aM<0){aM=0;w=Math.abs((aM-aC)*aH);aF=aI<0?aq-w:w+aq}else{if(aM>O){aM=O;w=Math.abs(aM-aC)*aH;aF=aI<0?aq-w:w+aq}}}if(aF>aq){if(aF-aq<aO){aF=aq+aO}else{if(aF-aq>aG){aF=aq+aG}}if(aM>aC){aM=aC+(aF-aq)/aH}else{aM=aC-(aF-aq)/aH}}else{if(aF<aq){if(aq-aF<aO){aF=aq-aO}else{if(aq-aF>aG){aF=aq-aG}}if(aM>aC){aM=aC+(aq-aF)/aH}else{aM=aC-(aq-aF)/aH}}}if(aF<0){aq-=aF;aF=0}else{if(aF>Q){aq-=aF-Q;aF=Q}}if(aM<0){aC-=aM;aM=0}else{if(aM>O){aC-=aM-O;aM=O}}return last=az(ay(aq,aC,aF,aM))}function at(aF){if(aF[0]<0){aF[0]=0}if(aF[1]<0){aF[1]=0}if(aF[0]>Q){aF[0]=Q}if(aF[1]>O){aF[1]=O}return[aF[0],aF[1]]}function ay(aI,aK,aH,aJ){var aM=aI,aL=aH,aG=aK,aF=aJ;if(aH<aI){aM=aH;aL=aI}if(aJ<aK){aG=aJ;aF=aK}return[Math.round(aM),Math.round(aG),Math.round(aL),Math.round(aF)]}function aA(){var aG=ap-aq;var aF=aB-aC;if(x&&(Math.abs(aG)>x)){ap=(aG>0)?(aq+x):(aq-x)}if(ah&&(Math.abs(aF)>ah)){aB=(aF>0)?(aC+ah):(aC-ah)}if(S&&(Math.abs(aF)<S)){aB=(aF>0)?(aC+S):(aC-S)}if(p&&(Math.abs(aG)<p)){ap=(aG>0)?(aq+p):(aq-p)}if(aq<0){ap-=aq;aq-=aq}if(aC<0){aB-=aC;aC-=aC}if(ap<0){aq-=ap;ap-=ap}if(aB<0){aC-=aB;aB-=aB}if(ap>Q){var aH=ap-Q;aq-=aH;ap-=aH}if(aB>O){var aH=aB-O;aC-=aH;aB-=aH}if(aq>Q){var aH=aq-O;aB-=aH;aC-=aH}if(aC>O){var aH=aC-O;aB-=aH;aC-=aH}return az(ay(aq,aC,ap,aB))}function az(aF){return{x:aF[0],y:aF[1],x2:aF[2],y2:aF[3],w:aF[2]-aF[0],h:aF[3]-aF[1]}}return{flipCoords:ay,setPressed:aw,setCurrent:av,getOffset:aE,moveOffset:ao,getCorner:ax,getFixed:aD}}();var X=function(){var aw,ar,aC,aB,aK=370;var av={};var aO={};var aq=false;var aA=H.handleOffset;if(H.drawBorders){av={top:ax("hline").css("top",a.browser.msie?l(-1):l(0)),bottom:ax("hline"),left:ax("vline"),right:ax("vline")}}if(H.dragEdges){aO.t=aJ("n");aO.b=aJ("s");aO.r=aJ("e");aO.l=aJ("w")}H.sideHandles&&aF(["n","s","e","w"]);H.cornerHandles&&aF(["sw","nw","ne","se"]);function ax(aR){var aS=a("<div />").css({position:"absolute",opacity:H.borderOpacity}).addClass(C(aR));k.append(aS);return aS}function ap(aR,aS){var aT=a("<div />").mousedown(c(aR)).css({cursor:aR+"-resize",position:"absolute",zIndex:aS});L.append(aT);return aT}function aD(aR){return ap(aR,aK++).css({top:l(-aA+1),left:l(-aA+1),opacity:H.handleOpacity}).addClass(C("handle"))}function aJ(aT){var aW=H.handleSize,aX=aA,aV=aW,aS=aW,aU=aX,aR=aX;switch(aT){case"n":case"s":aS=K(100);break;case"e":case"w":aV=K(100);break}return ap(aT,aK++).width(aS).height(aV).css({top:l(-aU+1),left:l(-aR+1)})}function aF(aR){for(i in aR){aO[aR[i]]=aD(aR[i])}}function aH(aY){var aT=Math.round((aY.h/2)-aA),aS=Math.round((aY.w/2)-aA),aW=west=-aA+1,aV=aY.w-aA,aU=aY.h-aA,aR,aX;"e" in aO&&aO.e.css({top:l(aT),left:l(aV)})&&aO.w.css({top:l(aT)})&&aO.s.css({top:l(aU),left:l(aS)})&&aO.n.css({left:l(aS)});"ne" in aO&&aO.ne.css({left:l(aV)})&&aO.se.css({top:l(aU),left:l(aV)})&&aO.sw.css({top:l(aU)});"b" in aO&&aO.b.css({top:l(aU)})&&aO.r.css({left:l(aV)})}function az(aR,aS){I.css({top:l(-aS),left:l(-aR)});y.css({top:l(aS),left:l(aR)})}function aQ(aR,aS){y.width(aR).height(aS)}function at(){var aR=aa.getFixed();aa.setPressed([aR.x,aR.y]);aa.setCurrent([aR.x2,aR.y2]);aN()}function aN(){if(aB){return ay()}}function ay(){var aR=aa.getFixed();aQ(aR.w,aR.h);az(aR.x,aR.y);H.drawBorders&&av.right.css({left:l(aR.w-1)})&&av.bottom.css({top:l(aR.h-1)});aq&&aH(aR);aB||aP();H.onChange(Y(aR))}function aP(){y.show();al.css("opacity",H.bgOpacity);aB=true}function aL(){aM();y.hide();al.css("opacity",1);aB=false}function ao(){if(aq){aH(aa.getFixed());L.show()}}function aG(){aq=true;if(H.allowResize){aH(aa.getFixed());L.show();return true}}function aM(){aq=false;L.hide()}function aI(aR){(B=aR)?aM():aG()}function aE(){aI(false);at()}var au=ae().mousedown(c("move")).css({cursor:"move",position:"absolute",zIndex:360});k.append(au);aM();return{updateVisible:aN,update:ay,release:aL,refresh:at,setCursor:function(aR){au.css("cursor",aR)},enableHandles:aG,enableOnly:function(){aq=true},showHandles:ao,disableHandles:aM,animMode:aI,done:aE}}();var P=function(){var ap=function(){},ar=function(){},aq=H.trackDocument;if(!aq){b.mousemove(ao).mouseup(at).mouseout(at)}function ax(){b.css({zIndex:450});if(aq){a(document).mousemove(ao).mouseup(at)}}function aw(){b.css({zIndex:290});if(aq){a(document).unbind("mousemove",ao).unbind("mouseup",at)}}function ao(ay){ap(F(ay))}function at(ay){ay.preventDefault();ay.stopPropagation();if(r){r=false;ar(F(ay));H.onSelect(Y(aa.getFixed()));aw();ap=function(){};ar=function(){}}return false}function au(az,ay){r=true;ap=az;ar=ay;ax();return false}function av(ay){b.css("cursor",ay)}al.before(b);return{activateHandlers:au,setCursor:av}}();var ak=function(){var ar=a('<input type="radio" />').css({position:"absolute",left:"-30px"}).keypress(ao).blur(at),au=a("<div />").css({position:"absolute",overflow:"hidden"}).append(ar);function ap(){if(H.keySupport){ar.show();ar.focus()}}function at(av){ar.hide()}function aq(aw,av,ax){if(H.allowMove){aa.moveOffset([av,ax]);X.updateVisible()}aw.preventDefault();aw.stopPropagation()}function ao(aw){if(aw.ctrlKey){return true}ab=aw.shiftKey?true:false;var av=ab?10:1;switch(aw.keyCode){case 37:aq(aw,-av,0);break;case 39:aq(aw,av,0);break;case 38:aq(aw,0,-av);break;case 40:aq(aw,0,av);break;case 27:X.release();break;case 9:return true}return nothing(aw)}if(H.keySupport){au.insertBefore(al)}return{watchKeys:ap}}();function l(ao){return""+parseInt(ao)+"px"}function K(ao){return""+parseInt(ao)+"%"}function C(ao){return H.baseClass+"-"+ao}function D(ao){var ap=a(ao).offset();return[ap.left,ap.top]}function F(ao){return[(ao.pageX-ad[0]),(ao.pageY-ad[1])]}function E(ao){if(ao!=an){P.setCursor(ao);an=ao}}function f(aq,at){ad=D(al);P.setCursor(aq=="move"?aq:aq+"-resize");if(aq=="move"){return P.activateHandlers(R(at),o)}var ao=aa.getFixed();var ap=q(aq);var ar=aa.getCorner(q(ap));aa.setPressed(aa.getCorner(ap));aa.setCurrent(ar);P.activateHandlers(G(aq,ao),o)}function G(ap,ao){return function(aq){if(!H.aspectRatio){switch(ap){case"e":aq[1]=ao.y2;break;case"w":aq[1]=ao.y2;break;case"n":aq[0]=ao.x2;break;case"s":aq[0]=ao.x2;break}}else{switch(ap){case"e":aq[1]=ao.y+1;break;case"w":aq[1]=ao.y+1;break;case"n":aq[0]=ao.x+1;break;case"s":aq[0]=ao.x+1;break}}aa.setCurrent(aq);X.update()}}function R(ap){var ao=ap;ak.watchKeys();return function(aq){aa.moveOffset([aq[0]-ao[0],aq[1]-ao[1]]);ao=aq;X.update()}}function q(ao){switch(ao){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function c(ao){return function(ap){if(H.disabled){return false}if((ao=="move")&&!H.allowMove){return false}r=true;f(ao,F(ap));ap.stopPropagation();ap.preventDefault();return false}}function T(at,ap,ar){var ao=at.width(),aq=at.height();if((ao>ap)&&ap>0){ao=ap;aq=(ap/at.width())*at.height()}if((aq>ar)&&ar>0){aq=ar;ao=(ar/at.height())*at.width()}M=at.width()/ao;e=at.height()/aq;at.width(ao).height(aq)}function Y(ao){return{x:parseInt(ao.x*M),y:parseInt(ao.y*e),x2:parseInt(ao.x2*M),y2:parseInt(ao.y2*e),w:parseInt(ao.w*M),h:parseInt(ao.h*e)}}function o(ap){var ao=aa.getFixed();if(ao.w>H.minSelect[0]&&ao.h>H.minSelect[1]){X.enableHandles();X.done()}else{X.release()}P.setCursor(H.allowSelect?"crosshair":"default")}function ac(ao){if(H.disabled){return false}if(!H.allowSelect){return false}r=true;ad=D(al);X.disableHandles();E("crosshair");var ap=F(ao);aa.setPressed(ap);P.activateHandlers(aj,o);ak.watchKeys();X.update();ao.stopPropagation();ao.preventDefault();return false}function aj(ao){aa.setCurrent(ao);X.update()}function ae(){var ao=a("<div></div>").addClass(C("tracker"));a.browser.msie&&ao.css({opacity:0,backgroundColor:"white"});return ao}function s(aG){var aB=aG[0]/M,ap=aG[1]/e,aA=aG[2]/M,ao=aG[3]/e;if(B){return}var az=aa.flipCoords(aB,ap,aA,ao);var aE=aa.getFixed();var ar=initcr=[aE.x,aE.y,aE.x2,aE.y2];var aq=H.animationDelay;var ax=ar[0];var aw=ar[1];var aA=ar[2];var ao=ar[3];var aD=az[0]-initcr[0];var au=az[1]-initcr[1];var aC=az[2]-initcr[2];var at=az[3]-initcr[3];var ay=0;var av=H.swingSpeed;X.animMode(true);var aF=function(){return function(){ay+=(100-ay)/av;ar[0]=ax+((ay/100)*aD);ar[1]=aw+((ay/100)*au);ar[2]=aA+((ay/100)*aC);ar[3]=ao+((ay/100)*at);if(ay<100){aH()}else{X.done()}if(ay>=99.8){ay=100}ai(ar)}}();function aH(){window.setTimeout(aF,aq)}aH()}function J(ao){ai([ao[0]/M,ao[1]/e,ao[2]/M,ao[3]/e])}function ai(ao){aa.setPressed([ao[0],ao[1]]);aa.setCurrent([ao[2],ao[3]]);X.update()}function z(ao){if(typeof(ao)!="object"){ao={}}H=a.extend(H,ao);if(typeof(H.onChange)!=="function"){H.onChange=function(){}}if(typeof(H.onSelect)!=="function"){H.onSelect=function(){}}}function j(){return Y(aa.getFixed())}function ag(){return aa.getFixed()}function u(ao){z(ao);N()}function v(){H.disabled=true;X.disableHandles();X.setCursor("default");P.setCursor("default")}function V(){H.disabled=false;N()}function m(){X.done();P.activateHandlers(null,null)}function af(){Z.remove();W.show()}function N(ao){H.allowResize?ao?X.enableOnly():X.enableHandles():X.disableHandles();P.setCursor(H.allowSelect?"crosshair":"default");X.setCursor(H.allowMove?"move":"default");Z.css("backgroundColor",H.bgColor);if("setSelect" in H){J(A.setSelect);X.done();delete (H.setSelect)}if("trueSize" in H){M=H.trueSize[0]/Q;e=H.trueSize[1]/O}x=H.maxSize[0]||0;ah=H.maxSize[1]||0;p=H.minSize[0]||0;S=H.minSize[1]||0;if("outerImage" in H){al.attr("src",H.outerImage);delete (H.outerImage)}X.refresh()}L.hide();N(true);var g={animateTo:s,setSelect:J,setOptions:u,tellSelect:j,tellScaled:ag,disable:v,enable:V,cancel:m,focus:ak.watchKeys,getBounds:function(){return[Q*M,O*e]},getWidgetSize:function(){return[Q,O]},release:X.release,destroy:af};W.data("Jcrop",g);return g};a.fn.Jcrop=function(c){function b(f){var e=c.useImg||f.src;var d=new Image();d.onload=function(){a.Jcrop(f,c)};d.src=e}if(typeof(c)!=="object"){c={}}this.each(function(){if(a(this).data("Jcrop")){if(c=="api"){return a(this).data("Jcrop")}else{a(this).data("Jcrop").setOptions(c)}}else{b(this)}});return this}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.color.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.color.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.color.dev.js	(revision 17487)
@@ -0,0 +1,128 @@
+/*
+ * jQuery Color Animations
+ * Copyright 2007 John Resig
+ * Released under the MIT and GPL licenses.
+ */
+
+(function(jQuery){
+
+    // We override the animation for all of these color styles
+    jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
+        jQuery.fx.step[attr] = function(fx){
+            if ( fx.state == 0 ) {
+                fx.start = getColor( fx.elem, attr );
+                fx.end = getRGB( fx.end );
+            }
+
+            fx.elem.style[attr] = "rgb(" + [
+                Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
+                Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
+                Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
+            ].join(",") + ")";
+        }
+    });
+
+    // Color Conversion functions from highlightFade
+    // By Blair Mitchelmore
+    // http://jquery.offput.ca/highlightFade/
+
+    // Parse strings looking for color tuples [255,255,255]
+    function getRGB(color) {
+        var result;
+
+        // Check if we're already dealing with an array of colors
+        if ( color && color.constructor == Array && color.length == 3 )
+            return color;
+
+        // Look for rgb(num,num,num)
+        if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
+            return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
+
+        // Look for rgb(num%,num%,num%)
+        if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
+            return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
+
+        // Look for #a0b1c2
+        if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
+            return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
+
+        // Look for #fff
+        if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
+            return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
+
+        // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
+        if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
+            return colors['transparent']
+
+        // Otherwise, we're most likely dealing with a named color
+        return colors[jQuery.trim(color).toLowerCase()];
+    }
+
+    function getColor(elem, attr) {
+        var color;
+
+        do {
+            color = jQuery.curCSS(elem, attr);
+
+            // Keep going until we find an element that has color, or we hit the body
+            if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
+                break;
+
+            attr = "backgroundColor";
+        } while ( elem = elem.parentNode );
+
+        return getRGB(color);
+    };
+
+    // Some named colors to work with
+    // From Interface by Stefan Petre
+    // http://interface.eyecon.ro/
+
+    var colors = {
+        aqua:[0,255,255],
+        azure:[240,255,255],
+        beige:[245,245,220],
+        black:[0,0,0],
+        blue:[0,0,255],
+        brown:[165,42,42],
+        cyan:[0,255,255],
+        darkblue:[0,0,139],
+        darkcyan:[0,139,139],
+        darkgrey:[169,169,169],
+        darkgreen:[0,100,0],
+        darkkhaki:[189,183,107],
+        darkmagenta:[139,0,139],
+        darkolivegreen:[85,107,47],
+        darkorange:[255,140,0],
+        darkorchid:[153,50,204],
+        darkred:[139,0,0],
+        darksalmon:[233,150,122],
+        darkviolet:[148,0,211],
+        fuchsia:[255,0,255],
+        gold:[255,215,0],
+        green:[0,128,0],
+        indigo:[75,0,130],
+        khaki:[240,230,140],
+        lightblue:[173,216,230],
+        lightcyan:[224,255,255],
+        lightgreen:[144,238,144],
+        lightgrey:[211,211,211],
+        lightpink:[255,182,193],
+        lightyellow:[255,255,224],
+        lime:[0,255,0],
+        magenta:[255,0,255],
+        maroon:[128,0,0],
+        navy:[0,0,128],
+        olive:[128,128,0],
+        orange:[255,165,0],
+        pink:[255,192,203],
+        purple:[128,0,128],
+        violet:[128,0,128],
+        red:[255,0,0],
+        silver:[192,192,192],
+        white:[255,255,255],
+        yellow:[255,255,0],
+        transparent: [255,255,255]
+    };
+
+})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.color.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.color.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.color.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(g.state==0){g.start=c(g.elem,e);g.end=b(g.end)}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.form.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.form.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.form.dev.js	(revision 17487)
@@ -0,0 +1,872 @@
+/*
+ * jQuery Form Plugin
+ * version: 2.02 (12/16/2007)
+ * @requires jQuery v1.1 or later
+ *
+ * Examples at: http://malsup.com/jquery/form/
+ * Dual licensed under the MIT and GPL licenses:
+ *   http://www.opensource.org/licenses/mit-license.php
+ *   http://www.gnu.org/licenses/gpl.html
+ *
+ * Revision: $Id$
+ */
+ (function($) {
+/**
+ * ajaxSubmit() provides a mechanism for submitting an HTML form using AJAX.
+ *
+ * ajaxSubmit accepts a single argument which can be either a success callback function
+ * or an options Object.  If a function is provided it will be invoked upon successful
+ * completion of the submit and will be passed the response from the server.
+ * If an options Object is provided, the following attributes are supported:
+ *
+ *  target:   Identifies the element(s) in the page to be updated with the server response.
+ *            This value may be specified as a jQuery selection string, a jQuery object,
+ *            or a DOM element.
+ *            default value: null
+ *
+ *  url:      URL to which the form data will be submitted.
+ *            default value: value of form's 'action' attribute
+ *
+ *  type:     The method in which the form data should be submitted, 'GET' or 'POST'.
+ *            default value: value of form's 'method' attribute (or 'GET' if none found)
+ *
+ *  data:     Additional data to add to the request, specified as key/value pairs (see $.ajax).
+ *
+ *  beforeSubmit:  Callback method to be invoked before the form is submitted.
+ *            default value: null
+ *
+ *  success:  Callback method to be invoked after the form has been successfully submitted
+ *            and the response has been returned from the server
+ *            default value: null
+ *
+ *  dataType: Expected dataType of the response.  One of: null, 'xml', 'script', or 'json'
+ *            default value: null
+ *
+ *  semantic: Boolean flag indicating whether data must be submitted in semantic order (slower).
+ *            default value: false
+ *
+ *  resetForm: Boolean flag indicating whether the form should be reset if the submit is successful
+ *
+ *  clearForm: Boolean flag indicating whether the form should be cleared if the submit is successful
+ *
+ *
+ * The 'beforeSubmit' callback can be provided as a hook for running pre-submit logic or for
+ * validating the form data.  If the 'beforeSubmit' callback returns false then the form will
+ * not be submitted. The 'beforeSubmit' callback is invoked with three arguments: the form data
+ * in array format, the jQuery object, and the options object passed into ajaxSubmit.
+ * The form data array takes the following form:
+ *
+ *     [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
+ *
+ * If a 'success' callback method is provided it is invoked after the response has been returned
+ * from the server.  It is passed the responseText or responseXML value (depending on dataType).
+ * See jQuery.ajax for further details.
+ *
+ *
+ * The dataType option provides a means for specifying how the server response should be handled.
+ * This maps directly to the jQuery.httpData method.  The following values are supported:
+ *
+ *      'xml':    if dataType == 'xml' the server response is treated as XML and the 'success'
+ *                   callback method, if specified, will be passed the responseXML value
+ *      'json':   if dataType == 'json' the server response will be evaluted and passed to
+ *                   the 'success' callback, if specified
+ *      'script': if dataType == 'script' the server response is evaluated in the global context
+ *
+ *
+ * Note that it does not make sense to use both the 'target' and 'dataType' options.  If both
+ * are provided the target will be ignored.
+ *
+ * The semantic argument can be used to force form serialization in semantic order.
+ * This is normally true anyway, unless the form contains input elements of type='image'.
+ * If your form must be submitted with name/value pairs in semantic order and your form
+ * contains an input of type='image" then pass true for this arg, otherwise pass false
+ * (or nothing) to avoid the overhead for this logic.
+ *
+ *
+ * When used on its own, ajaxSubmit() is typically bound to a form's submit event like this:
+ *
+ * $("#form-id").submit(function() {
+ *     $(this).ajaxSubmit(options);
+ *     return false; // cancel conventional submit
+ * });
+ *
+ * When using ajaxForm(), however, this is done for you.
+ *
+ * @example
+ * $('#myForm').ajaxSubmit(function(data) {
+ *     alert('Form submit succeeded! Server returned: ' + data);
+ * });
+ * @desc Submit form and alert server response
+ *
+ *
+ * @example
+ * var options = {
+ *     target: '#myTargetDiv'
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc Submit form and update page element with server response
+ *
+ *
+ * @example
+ * var options = {
+ *     success: function(responseText) {
+ *         alert(responseText);
+ *     }
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc Submit form and alert the server response
+ *
+ *
+ * @example
+ * var options = {
+ *     beforeSubmit: function(formArray, jqForm) {
+ *         if (formArray.length == 0) {
+ *             alert('Please enter data.');
+ *             return false;
+ *         }
+ *     }
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc Pre-submit validation which aborts the submit operation if form data is empty
+ *
+ *
+ * @example
+ * var options = {
+ *     url: myJsonUrl.php,
+ *     dataType: 'json',
+ *     success: function(data) {
+ *        // 'data' is an object representing the the evaluated json data
+ *     }
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc json data returned and evaluated
+ *
+ *
+ * @example
+ * var options = {
+ *     url: myXmlUrl.php,
+ *     dataType: 'xml',
+ *     success: function(responseXML) {
+ *        // responseXML is XML document object
+ *        var data = $('myElement', responseXML).text();
+ *     }
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc XML data returned from server
+ *
+ *
+ * @example
+ * var options = {
+ *     resetForm: true
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc submit form and reset it if successful
+ *
+ * @example
+ * $('#myForm).submit(function() {
+ *    $(this).ajaxSubmit();
+ *    return false;
+ * });
+ * @desc Bind form's submit event to use ajaxSubmit
+ *
+ *
+ * @name ajaxSubmit
+ * @type jQuery
+ * @param options  object literal containing options which control the form submission process
+ * @cat Plugins/Form
+ * @return jQuery
+ */
+$.fn.ajaxSubmit = function(options) {
+    if (typeof options == 'function')
+        options = { success: options };
+
+    options = $.extend({
+        url:  this.attr('action') || window.location.toString(),
+        type: this.attr('method') || 'GET'
+    }, options || {});
+
+    // hook for manipulating the form data before it is extracted;
+    // convenient for use with rich editors like tinyMCE or FCKEditor
+    var veto = {};
+    $.event.trigger('form.pre.serialize', [this, options, veto]);
+    if (veto.veto) return this;
+
+    var a = this.formToArray(options.semantic);
+	if (options.data) {
+	    for (var n in options.data)
+	        a.push( { name: n, value: options.data[n] } );
+	}
+
+    // give pre-submit callback an opportunity to abort the submit
+    if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) return this;
+
+    // fire vetoable 'validate' event
+    $.event.trigger('form.submit.validate', [a, this, options, veto]);
+    if (veto.veto) return this;
+
+    var q = $.param(a);//.replace(/%20/g,'+');
+
+    if (options.type.toUpperCase() == 'GET') {
+        options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
+        options.data = null;  // data is null for 'get'
+    }
+    else
+        options.data = q; // data is the query string for 'post'
+
+    var $form = this, callbacks = [];
+    if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
+    if (options.clearForm) callbacks.push(function() { $form.clearForm(); });
+
+    // perform a load on the target only if dataType is not provided
+    if (!options.dataType && options.target) {
+        var oldSuccess = options.success || function(){};
+        callbacks.push(function(data) {
+            if (this.evalScripts)
+                $(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, arguments);
+            else // jQuery v1.1.4
+                $(options.target).html(data).each(oldSuccess, arguments);
+        });
+    }
+    else if (options.success)
+        callbacks.push(options.success);
+
+    options.success = function(data, status) {
+        for (var i=0, max=callbacks.length; i < max; i++)
+            callbacks[i](data, status, $form);
+    };
+
+    // are there files to upload?
+    var files = $('input:file', this).fieldValue();
+    var found = false;
+    for (var j=0; j < files.length; j++)
+        if (files[j])
+            found = true;
+
+    // options.iframe allows user to force iframe mode
+   if (options.iframe || found) { 
+       // hack to fix Safari hang (thanks to Tim Molendijk for this)
+       // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
+       if ($.browser.safari && options.closeKeepAlive)
+           $.get(options.closeKeepAlive, fileUpload);
+       else
+           fileUpload();
+       }
+   else
+       $.ajax(options);
+
+    // fire 'notify' event
+    $.event.trigger('form.submit.notify', [this, options]);
+    return this;
+
+
+    // private function for handling file uploads (hat tip to YAHOO!)
+    function fileUpload() {
+        var form = $form[0];
+        var opts = $.extend({}, $.ajaxSettings, options);
+
+        var id = 'jqFormIO' + $.fn.ajaxSubmit.counter++;
+        var $io = $('<iframe id="' + id + '" name="' + id + '" />');
+        var io = $io[0];
+        var op8 = $.browser.opera && window.opera.version() < 9;
+        if ($.browser.msie || op8) io.src = 'javascript:false;document.write("");';
+        $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
+
+        var xhr = { // mock object
+            responseText: null,
+            responseXML: null,
+            status: 0,
+            statusText: 'n/a',
+            getAllResponseHeaders: function() {},
+            getResponseHeader: function() {},
+            setRequestHeader: function() {}
+        };
+
+        var g = opts.global;
+        // trigger ajax global events so that activity/block indicators work like normal
+        if (g && ! $.active++) $.event.trigger("ajaxStart");
+        if (g) $.event.trigger("ajaxSend", [xhr, opts]);
+
+        var cbInvoked = 0;
+        var timedOut = 0;
+
+        // take a breath so that pending repaints get some cpu time before the upload starts
+        setTimeout(function() {
+            // make sure form attrs are set
+            var encAttr = form.encoding ? 'encoding' : 'enctype';
+            var t = $form.attr('target');
+            $form.attr({
+                target:   id,
+                method:  'POST',
+                action:   opts.url
+            });
+            form[encAttr] = 'multipart/form-data';
+
+            // support timout
+            if (opts.timeout)
+                setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
+
+            // add iframe to doc and submit the form
+            $io.appendTo('body');
+            io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
+            form.submit();
+            $form.attr('target', t); // reset target
+        }, 10);
+
+        function cb() {
+            if (cbInvoked++) return;
+
+            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
+
+            var ok = true;
+            try {
+                if (timedOut) throw 'timeout';
+                // extract the server response from the iframe
+                var data, doc;
+                doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
+                xhr.responseText = doc.body ? doc.body.innerHTML : null;
+                xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
+
+                if (opts.dataType == 'json' || opts.dataType == 'script') {
+                    var ta = doc.getElementsByTagName('textarea')[0];
+                    data = ta ? ta.value : xhr.responseText;
+                    if (opts.dataType == 'json')
+                        eval("data = " + data);
+                    else
+                        $.globalEval(data);
+                }
+                else if (opts.dataType == 'xml') {
+                    data = xhr.responseXML;
+                    if (!data && xhr.responseText != null)
+                        data = toXml(xhr.responseText);
+                }
+                else {
+                    data = xhr.responseText;
+                }
+            }
+            catch(e){
+                ok = false;
+                $.handleError(opts, xhr, 'error', e);
+            }
+
+            // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
+            if (ok) {
+                opts.success(data, 'success');
+                if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
+            }
+            if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
+            if (g && ! --$.active) $.event.trigger("ajaxStop");
+            if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
+
+            // clean up
+            setTimeout(function() {
+                $io.remove();
+                xhr.responseXML = null;
+            }, 100);
+        };
+
+        function toXml(s, doc) {
+            if (window.ActiveXObject) {
+                doc = new ActiveXObject('Microsoft.XMLDOM');
+                doc.async = 'false';
+                doc.loadXML(s);
+            }
+            else
+                doc = (new DOMParser()).parseFromString(s, 'text/xml');
+            return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
+        };
+    };
+};
+$.fn.ajaxSubmit.counter = 0; // used to create unique iframe ids
+
+/**
+ * ajaxForm() provides a mechanism for fully automating form submission.
+ *
+ * The advantages of using this method instead of ajaxSubmit() are:
+ *
+ * 1: This method will include coordinates for <input type="image" /> elements (if the element
+ *    is used to submit the form).
+ * 2. This method will include the submit element's name/value data (for the element that was
+ *    used to submit the form).
+ * 3. This method binds the submit() method to the form for you.
+ *
+ * Note that for accurate x/y coordinates of image submit elements in all browsers
+ * you need to also use the "dimensions" plugin (this method will auto-detect its presence).
+ *
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
+ * passes the options argument along after properly binding events for submit elements and
+ * the form itself.  See ajaxSubmit for a full description of the options argument.
+ *
+ *
+ * @example
+ * var options = {
+ *     target: '#myTargetDiv'
+ * };
+ * $('#myForm').ajaxSForm(options);
+ * @desc Bind form's submit event so that 'myTargetDiv' is updated with the server response
+ *       when the form is submitted.
+ *
+ *
+ * @example
+ * var options = {
+ *     success: function(responseText) {
+ *         alert(responseText);
+ *     }
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc Bind form's submit event so that server response is alerted after the form is submitted.
+ *
+ *
+ * @example
+ * var options = {
+ *     beforeSubmit: function(formArray, jqForm) {
+ *         if (formArray.length == 0) {
+ *             alert('Please enter data.');
+ *             return false;
+ *         }
+ *     }
+ * };
+ * $('#myForm').ajaxSubmit(options);
+ * @desc Bind form's submit event so that pre-submit callback is invoked before the form
+ *       is submitted.
+ *
+ *
+ * @name   ajaxForm
+ * @param  options  object literal containing options which control the form submission process
+ * @return jQuery
+ * @cat    Plugins/Form
+ * @type   jQuery
+ */
+$.fn.ajaxForm = function(options) {
+    return this.ajaxFormUnbind().submit(submitHandler).each(function() {
+        // store options in hash
+        this.formPluginId = $.fn.ajaxForm.counter++;
+        $.fn.ajaxForm.optionHash[this.formPluginId] = options;
+        $(":submit,input:image", this).click(clickHandler);
+    });
+};
+
+$.fn.ajaxForm.counter = 1;
+$.fn.ajaxForm.optionHash = {};
+
+function clickHandler(e) {
+    var $form = this.form;
+    $form.clk = this;
+    if (this.type == 'image') {
+        if (e.offsetX != undefined) {
+            $form.clk_x = e.offsetX;
+            $form.clk_y = e.offsetY;
+        } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
+            var offset = $(this).offset();
+            $form.clk_x = e.pageX - offset.left;
+            $form.clk_y = e.pageY - offset.top;
+        } else {
+            $form.clk_x = e.pageX - this.offsetLeft;
+            $form.clk_y = e.pageY - this.offsetTop;
+        }
+    }
+    // clear form vars
+    setTimeout(function() { $form.clk = $form.clk_x = $form.clk_y = null; }, 10);
+};
+
+function submitHandler() {
+    // retrieve options from hash
+    var id = this.formPluginId;
+    var options = $.fn.ajaxForm.optionHash[id];
+    $(this).ajaxSubmit(options);
+    return false;
+};
+
+/**
+ * ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
+ *
+ * @name   ajaxFormUnbind
+ * @return jQuery
+ * @cat    Plugins/Form
+ * @type   jQuery
+ */
+$.fn.ajaxFormUnbind = function() {
+    this.unbind('submit', submitHandler);
+    return this.each(function() {
+        $(":submit,input:image", this).unbind('click', clickHandler);
+    });
+
+};
+
+/**
+ * formToArray() gathers form element data into an array of objects that can
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
+ * Each object in the array has both a 'name' and 'value' property.  An example of
+ * an array for a simple login form might be:
+ *
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
+ *
+ * It is this array that is passed to pre-submit callback functions provided to the
+ * ajaxSubmit() and ajaxForm() methods.
+ *
+ * The semantic argument can be used to force form serialization in semantic order.
+ * This is normally true anyway, unless the form contains input elements of type='image'.
+ * If your form must be submitted with name/value pairs in semantic order and your form
+ * contains an input of type='image" then pass true for this arg, otherwise pass false
+ * (or nothing) to avoid the overhead for this logic.
+ *
+ * @example var data = $("#myForm").formToArray();
+ * $.post( "myscript.cgi", data );
+ * @desc Collect all the data from a form and submit it to the server.
+ *
+ * @name formToArray
+ * @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
+ * @type Array<Object>
+ * @cat Plugins/Form
+ */
+$.fn.formToArray = function(semantic) {
+    var a = [];
+    if (this.length == 0) return a;
+
+    var form = this[0];
+    var els = semantic ? form.getElementsByTagName('*') : form.elements;
+    if (!els) return a;
+    for(var i=0, max=els.length; i < max; i++) {
+        var el = els[i];
+        var n = el.name;
+        if (!n) continue;
+
+        if (semantic && form.clk && el.type == "image") {
+            // handle image inputs on the fly when semantic == true
+            if(!el.disabled && form.clk == el)
+                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+            continue;
+        }
+
+        var v = $.fieldValue(el, true);
+        if (v && v.constructor == Array) {
+            for(var j=0, jmax=v.length; j < jmax; j++)
+                a.push({name: n, value: v[j]});
+        }
+        else if (v !== null && typeof v != 'undefined')
+            a.push({name: n, value: v});
+    }
+
+    if (!semantic && form.clk) {
+        // input type=='image' are not found in elements array! handle them here
+        var inputs = form.getElementsByTagName("input");
+        for(var i=0, max=inputs.length; i < max; i++) {
+            var input = inputs[i];
+            var n = input.name;
+            if(n && !input.disabled && input.type == "image" && form.clk == input)
+                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+        }
+    }
+    return a;
+};
+
+
+/**
+ * Serializes form data into a 'submittable' string. This method will return a string
+ * in the format: name1=value1&amp;name2=value2
+ *
+ * The semantic argument can be used to force form serialization in semantic order.
+ * If your form must be submitted with name/value pairs in semantic order then pass
+ * true for this arg, otherwise pass false (or nothing) to avoid the overhead for
+ * this logic (which can be significant for very large forms).
+ *
+ * @example var data = $("#myForm").formSerialize();
+ * $.ajax('POST', "myscript.cgi", data);
+ * @desc Collect all the data from a form into a single string
+ *
+ * @name formSerialize
+ * @param semantic true if serialization must maintain strict semantic ordering of elements (slower)
+ * @type String
+ * @cat Plugins/Form
+ */
+$.fn.formSerialize = function(semantic) {
+    //hand off to jQuery.param for proper encoding
+    return $.param(this.formToArray(semantic));
+};
+
+
+/**
+ * Serializes all field elements in the jQuery object into a query string.
+ * This method will return a string in the format: name1=value1&amp;name2=value2
+ *
+ * The successful argument controls whether or not serialization is limited to
+ * 'successful' controls (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
+ * The default value of the successful argument is true.
+ *
+ * @example var data = $("input").formSerialize();
+ * @desc Collect the data from all successful input elements into a query string
+ *
+ * @example var data = $(":radio").formSerialize();
+ * @desc Collect the data from all successful radio input elements into a query string
+ *
+ * @example var data = $("#myForm :checkbox").formSerialize();
+ * @desc Collect the data from all successful checkbox input elements in myForm into a query string
+ *
+ * @example var data = $("#myForm :checkbox").formSerialize(false);
+ * @desc Collect the data from all checkbox elements in myForm (even the unchecked ones) into a query string
+ *
+ * @example var data = $(":input").formSerialize();
+ * @desc Collect the data from all successful input, select, textarea and button elements into a query string
+ *
+ * @name fieldSerialize
+ * @param successful true if only successful controls should be serialized (default is true)
+ * @type String
+ * @cat Plugins/Form
+ */
+$.fn.fieldSerialize = function(successful) {
+    var a = [];
+    this.each(function() {
+        var n = this.name;
+        if (!n) return;
+        var v = $.fieldValue(this, successful);
+        if (v && v.constructor == Array) {
+            for (var i=0,max=v.length; i < max; i++)
+                a.push({name: n, value: v[i]});
+        }
+        else if (v !== null && typeof v != 'undefined')
+            a.push({name: this.name, value: v});
+    });
+    //hand off to jQuery.param for proper encoding
+    return $.param(a);
+};
+
+
+/**
+ * Returns the value(s) of the element in the matched set.  For example, consider the following form:
+ *
+ *  <form><fieldset>
+ *      <input name="A" type="text" />
+ *      <input name="A" type="text" />
+ *      <input name="B" type="checkbox" value="B1" />
+ *      <input name="B" type="checkbox" value="B2"/>
+ *      <input name="C" type="radio" value="C1" />
+ *      <input name="C" type="radio" value="C2" />
+ *  </fieldset></form>
+ *
+ *  var v = $(':text').fieldValue();
+ *  // if no values are entered into the text inputs
+ *  v == ['','']
+ *  // if values entered into the text inputs are 'foo' and 'bar'
+ *  v == ['foo','bar']
+ *
+ *  var v = $(':checkbox').fieldValue();
+ *  // if neither checkbox is checked
+ *  v === undefined
+ *  // if both checkboxes are checked
+ *  v == ['B1', 'B2']
+ *
+ *  var v = $(':radio').fieldValue();
+ *  // if neither radio is checked
+ *  v === undefined
+ *  // if first radio is checked
+ *  v == ['C1']
+ *
+ * The successful argument controls whether or not the field element must be 'successful'
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
+ * The default value of the successful argument is true.  If this value is false the value(s)
+ * for each element is returned.
+ *
+ * Note: This method *always* returns an array.  If no valid value can be determined the
+ *       array will be empty, otherwise it will contain one or more values.
+ *
+ * @example var data = $("#myPasswordElement").fieldValue();
+ * alert(data[0]);
+ * @desc Alerts the current value of the myPasswordElement element
+ *
+ * @example var data = $("#myForm :input").fieldValue();
+ * @desc Get the value(s) of the form elements in myForm
+ *
+ * @example var data = $("#myForm :checkbox").fieldValue();
+ * @desc Get the value(s) for the successful checkbox element(s) in the jQuery object.
+ *
+ * @example var data = $("#mySingleSelect").fieldValue();
+ * @desc Get the value(s) of the select control
+ *
+ * @example var data = $(':text').fieldValue();
+ * @desc Get the value(s) of the text input or textarea elements
+ *
+ * @example var data = $("#myMultiSelect").fieldValue();
+ * @desc Get the values for the select-multiple control
+ *
+ * @name fieldValue
+ * @param Boolean successful true if only the values for successful controls should be returned (default is true)
+ * @type Array<String>
+ * @cat Plugins/Form
+ */
+$.fn.fieldValue = function(successful) {
+    for (var val=[], i=0, max=this.length; i < max; i++) {
+        var el = this[i];
+        var v = $.fieldValue(el, successful);
+        if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
+            continue;
+        v.constructor == Array ? $.merge(val, v) : val.push(v);
+    }
+    return val;
+};
+
+/**
+ * Returns the value of the field element.
+ *
+ * The successful argument controls whether or not the field element must be 'successful'
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
+ * The default value of the successful argument is true.  If the given element is not
+ * successful and the successful arg is not false then the returned value will be null.
+ *
+ * Note: If the successful flag is true (default) but the element is not successful, the return will be null
+ * Note: The value returned for a successful select-multiple element will always be an array.
+ * Note: If the element has no value the return value will be undefined.
+ *
+ * @example var data = jQuery.fieldValue($("#myPasswordElement")[0]);
+ * @desc Gets the current value of the myPasswordElement element
+ *
+ * @name fieldValue
+ * @param Element el The DOM element for which the value will be returned
+ * @param Boolean successful true if value returned must be for a successful controls (default is true)
+ * @type String or Array<String> or null or undefined
+ * @cat Plugins/Form
+ */
+$.fieldValue = function(el, successful) {
+    var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
+    if (typeof successful == 'undefined') successful = true;
+
+    if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
+        (t == 'checkbox' || t == 'radio') && !el.checked ||
+        (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
+        tag == 'select' && el.selectedIndex == -1))
+            return null;
+
+    if (tag == 'select') {
+        var index = el.selectedIndex;
+        if (index < 0) return null;
+        var a = [], ops = el.options;
+        var one = (t == 'select-one');
+        var max = (one ? index+1 : ops.length);
+        for(var i=(one ? index : 0); i < max; i++) {
+            var op = ops[i];
+            if (op.selected) {
+                // extra pain for IE...
+                var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;
+                if (one) return v;
+                a.push(v);
+            }
+        }
+        return a;
+    }
+    return el.value;
+};
+
+
+/**
+ * Clears the form data.  Takes the following actions on the form's input fields:
+ *  - input text fields will have their 'value' property set to the empty string
+ *  - select elements will have their 'selectedIndex' property set to -1
+ *  - checkbox and radio inputs will have their 'checked' property set to false
+ *  - inputs of type submit, button, reset, and hidden will *not* be effected
+ *  - button elements will *not* be effected
+ *
+ * @example $('form').clearForm();
+ * @desc Clears all forms on the page.
+ *
+ * @name clearForm
+ * @type jQuery
+ * @cat Plugins/Form
+ */
+$.fn.clearForm = function() {
+    return this.each(function() {
+        $('input,select,textarea', this).clearFields();
+    });
+};
+
+/**
+ * Clears the selected form elements.  Takes the following actions on the matched elements:
+ *  - input text fields will have their 'value' property set to the empty string
+ *  - select elements will have their 'selectedIndex' property set to -1
+ *  - checkbox and radio inputs will have their 'checked' property set to false
+ *  - inputs of type submit, button, reset, and hidden will *not* be effected
+ *  - button elements will *not* be effected
+ *
+ * @example $('.myInputs').clearFields();
+ * @desc Clears all inputs with class myInputs
+ *
+ * @name clearFields
+ * @type jQuery
+ * @cat Plugins/Form
+ */
+$.fn.clearFields = $.fn.clearInputs = function() {
+    return this.each(function() {
+        var t = this.type, tag = this.tagName.toLowerCase();
+        if (t == 'text' || t == 'password' || tag == 'textarea')
+            this.value = '';
+        else if (t == 'checkbox' || t == 'radio')
+            this.checked = false;
+        else if (tag == 'select')
+            this.selectedIndex = -1;
+    });
+};
+
+
+/**
+ * Resets the form data.  Causes all form elements to be reset to their original value.
+ *
+ * @example $('form').resetForm();
+ * @desc Resets all forms on the page.
+ *
+ * @name resetForm
+ * @type jQuery
+ * @cat Plugins/Form
+ */
+$.fn.resetForm = function() {
+    return this.each(function() {
+        // guard against an input with the name of 'reset'
+        // note that IE reports the reset function as an 'object'
+        if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
+            this.reset();
+    });
+};
+
+
+/**
+ * Enables or disables any matching elements.
+ *
+ * @example $(':radio').enabled(false);
+ * @desc Disables all radio buttons
+ *
+ * @name select
+ * @type jQuery
+ * @cat Plugins/Form
+ */
+$.fn.enable = function(b) { 
+    if (b == undefined) b = true;
+    return this.each(function() { 
+        this.disabled = !b 
+    });
+};
+
+/**
+ * Checks/unchecks any matching checkboxes or radio buttons and
+ * selects/deselects and matching option elements.
+ *
+ * @example $(':checkbox').selected();
+ * @desc Checks all checkboxes
+ *
+ * @name select
+ * @type jQuery
+ * @cat Plugins/Form
+ */
+$.fn.select = function(select) {
+    if (select == undefined) select = true;
+    return this.each(function() { 
+        var t = this.type;
+        if (t == 'checkbox' || t == 'radio')
+            this.checked = select;
+        else if (this.tagName.toLowerCase() == 'option') {
+            var $sel = $(this).parent('select');
+            if (select && $sel[0] && $sel[0].type == 'select-one') {
+                // deselect all other options
+                $sel.find('option').select(false);
+            }
+            this.selected = select;
+        }
+    });
+};
+
+})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.form.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.form.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.form.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function($){$.fn.ajaxSubmit=function(options){if(typeof options=="function"){options={success:options}}options=$.extend({url:this.attr("action")||window.location.toString(),type:this.attr("method")||"GET"},options||{});var veto={};$.event.trigger("form.pre.serialize",[this,options,veto]);if(veto.veto){return this}var a=this.formToArray(options.semantic);if(options.data){for(var n in options.data){a.push({name:n,value:options.data[n]})}}if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){return this}$.event.trigger("form.submit.validate",[a,this,options,veto]);if(veto.veto){return this}var q=$.param(a);if(options.type.toUpperCase()=="GET"){options.url+=(options.url.indexOf("?")>=0?"&":"?")+q;options.data=null}else{options.data=q}var $form=this,callbacks=[];if(options.resetForm){callbacks.push(function(){$form.resetForm()})}if(options.clearForm){callbacks.push(function(){$form.clearForm()})}if(!options.dataType&&options.target){var oldSuccess=options.success||function(){};callbacks.push(function(data){if(this.evalScripts){$(options.target).attr("innerHTML",data).evalScripts().each(oldSuccess,arguments)}else{$(options.target).html(data).each(oldSuccess,arguments)}})}else{if(options.success){callbacks.push(options.success)}}options.success=function(data,status){for(var i=0,max=callbacks.length;i<max;i++){callbacks[i](data,status,$form)}};var files=$("input:file",this).fieldValue();var found=false;for(var j=0;j<files.length;j++){if(files[j]){found=true}}if(options.iframe||found){if($.browser.safari&&options.closeKeepAlive){$.get(options.closeKeepAlive,fileUpload)}else{fileUpload()}}else{$.ajax(options)}$.event.trigger("form.submit.notify",[this,options]);return this;function fileUpload(){var form=$form[0];var opts=$.extend({},$.ajaxSettings,options);var id="jqFormIO"+$.fn.ajaxSubmit.counter++;var $io=$('<iframe id="'+id+'" name="'+id+'" />');var io=$io[0];var op8=$.browser.opera&&window.opera.version()<9;if($.browser.msie||op8){io.src='javascript:false;document.write("");'}$io.css({position:"absolute",top:"-1000px",left:"-1000px"});var xhr={responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){}};var g=opts.global;if(g&&!$.active++){$.event.trigger("ajaxStart")}if(g){$.event.trigger("ajaxSend",[xhr,opts])}var cbInvoked=0;var timedOut=0;setTimeout(function(){var encAttr=form.encoding?"encoding":"enctype";var t=$form.attr("target");$form.attr({target:id,method:"POST",action:opts.url});form[encAttr]="multipart/form-data";if(opts.timeout){setTimeout(function(){timedOut=true;cb()},opts.timeout)}$io.appendTo("body");io.attachEvent?io.attachEvent("onload",cb):io.addEventListener("load",cb,false);form.submit();$form.attr("target",t)},10);function cb(){if(cbInvoked++){return}io.detachEvent?io.detachEvent("onload",cb):io.removeEventListener("load",cb,false);var ok=true;try{if(timedOut){throw"timeout"}var data,doc;doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;xhr.responseText=doc.body?doc.body.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;if(opts.dataType=="json"||opts.dataType=="script"){var ta=doc.getElementsByTagName("textarea")[0];data=ta?ta.value:xhr.responseText;if(opts.dataType=="json"){eval("data = "+data)}else{$.globalEval(data)}}else{if(opts.dataType=="xml"){data=xhr.responseXML;if(!data&&xhr.responseText!=null){data=toXml(xhr.responseText)}}else{data=xhr.responseText}}}catch(e){ok=false;$.handleError(opts,xhr,"error",e)}if(ok){opts.success(data,"success");if(g){$.event.trigger("ajaxSuccess",[xhr,opts])}}if(g){$.event.trigger("ajaxComplete",[xhr,opts])}if(g&&!--$.active){$.event.trigger("ajaxStop")}if(opts.complete){opts.complete(xhr,ok?"success":"error")}setTimeout(function(){$io.remove();xhr.responseXML=null},100)}function toXml(s,doc){if(window.ActiveXObject){doc=new ActiveXObject("Microsoft.XMLDOM");doc.async="false";doc.loadXML(s)}else{doc=(new DOMParser()).parseFromString(s,"text/xml")}return(doc&&doc.documentElement&&doc.documentElement.tagName!="parsererror")?doc:null}}};$.fn.ajaxSubmit.counter=0;$.fn.ajaxForm=function(options){return this.ajaxFormUnbind().submit(submitHandler).each(function(){this.formPluginId=$.fn.ajaxForm.counter++;$.fn.ajaxForm.optionHash[this.formPluginId]=options;$(":submit,input:image",this).click(clickHandler)})};$.fn.ajaxForm.counter=1;$.fn.ajaxForm.optionHash={};function clickHandler(e){var $form=this.form;$form.clk=this;if(this.type=="image"){if(e.offsetX!=undefined){$form.clk_x=e.offsetX;$form.clk_y=e.offsetY}else{if(typeof $.fn.offset=="function"){var offset=$(this).offset();$form.clk_x=e.pageX-offset.left;$form.clk_y=e.pageY-offset.top}else{$form.clk_x=e.pageX-this.offsetLeft;$form.clk_y=e.pageY-this.offsetTop}}}setTimeout(function(){$form.clk=$form.clk_x=$form.clk_y=null},10)}function submitHandler(){var id=this.formPluginId;var options=$.fn.ajaxForm.optionHash[id];$(this).ajaxSubmit(options);return false}$.fn.ajaxFormUnbind=function(){this.unbind("submit",submitHandler);return this.each(function(){$(":submit,input:image",this).unbind("click",clickHandler)})};$.fn.formToArray=function(semantic){var a=[];if(this.length==0){return a}var form=this[0];var els=semantic?form.getElementsByTagName("*"):form.elements;if(!els){return a}for(var i=0,max=els.length;i<max;i++){var el=els[i];var n=el.name;if(!n){continue}if(semantic&&form.clk&&el.type=="image"){if(!el.disabled&&form.clk==el){a.push({name:n+".x",value:form.clk_x},{name:n+".y",value:form.clk_y})}continue}var v=$.fieldValue(el,true);if(v&&v.constructor==Array){for(var j=0,jmax=v.length;j<jmax;j++){a.push({name:n,value:v[j]})}}else{if(v!==null&&typeof v!="undefined"){a.push({name:n,value:v})}}}if(!semantic&&form.clk){var inputs=form.getElementsByTagName("input");for(var i=0,max=inputs.length;i<max;i++){var input=inputs[i];var n=input.name;if(n&&!input.disabled&&input.type=="image"&&form.clk==input){a.push({name:n+".x",value:form.clk_x},{name:n+".y",value:form.clk_y})}}}return a};$.fn.formSerialize=function(semantic){return $.param(this.formToArray(semantic))};$.fn.fieldSerialize=function(successful){var a=[];this.each(function(){var n=this.name;if(!n){return}var v=$.fieldValue(this,successful);if(v&&v.constructor==Array){for(var i=0,max=v.length;i<max;i++){a.push({name:n,value:v[i]})}}else{if(v!==null&&typeof v!="undefined"){a.push({name:this.name,value:v})}}});return $.param(a)};$.fn.fieldValue=function(successful){for(var val=[],i=0,max=this.length;i<max;i++){var el=this[i];var v=$.fieldValue(el,successful);if(v===null||typeof v=="undefined"||(v.constructor==Array&&!v.length)){continue}v.constructor==Array?$.merge(val,v):val.push(v)}return val};$.fieldValue=function(el,successful){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(typeof successful=="undefined"){successful=true}if(successful&&(!n||el.disabled||t=="reset"||t=="button"||(t=="checkbox"||t=="radio")&&!el.checked||(t=="submit"||t=="image")&&el.form&&el.form.clk!=el||tag=="select"&&el.selectedIndex==-1)){return null}if(tag=="select"){var index=el.selectedIndex;if(index<0){return null}var a=[],ops=el.options;var one=(t=="select-one");var max=(one?index+1:ops.length);for(var i=(one?index:0);i<max;i++){var op=ops[i];if(op.selected){var v=$.browser.msie&&!(op.attributes.value.specified)?op.text:op.value;if(one){return v}a.push(v)}}return a}return el.value};$.fn.clearForm=function(){return this.each(function(){$("input,select,textarea",this).clearFields()})};$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();if(t=="text"||t=="password"||tag=="textarea"){this.value=""}else{if(t=="checkbox"||t=="radio"){this.checked=false}else{if(tag=="select"){this.selectedIndex=-1}}}})};$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};$.fn.enable=function(b){if(b==undefined){b=true}return this.each(function(){this.disabled=!b})};$.fn.select=function(select){if(select==undefined){select=true}return this.each(function(){var t=this.type;if(t=="checkbox"||t=="radio"){this.checked=select}else{if(this.tagName.toLowerCase()=="option"){var $sel=$(this).parent("select");if(select&&$sel[0]&&$sel[0].type=="select-one"){$sel.find("option").select(false)}this.selected=select}}})}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.hotkeys.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.hotkeys.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.hotkeys.dev.js	(revision 17487)
@@ -0,0 +1,128 @@
+/******************************************************************************************************************************
+
+ * @ Original idea by by Binny V A, Original version: 2.00.A 
+ * @ http://www.openjs.com/scripts/events/keyboard_shortcuts/
+ * @ Original License : BSD
+ 
+ * @ jQuery Plugin by Tzury Bar Yochay 
+        mail: tzury.by@gmail.com
+        blog: evalinux.wordpress.com
+        face: facebook.com/profile.php?id=513676303
+        
+        (c) Copyrights 2007
+        
+ * @ jQuery Plugin version Beta (0.0.2)
+ * @ License: jQuery-License.
+ 
+TODO:
+    add queue support (as in gmail) e.g. 'x' then 'y', etc.
+    add mouse + mouse wheel events.
+
+USAGE:
+    $.hotkeys.add('Ctrl+c', function(){ alert('copy anyone?');});
+    $.hotkeys.add('Ctrl+c', {target:'div#editor', type:'keyup', propagate: true},function(){ alert('copy anyone?');});>
+    $.hotkeys.remove('Ctrl+c'); 
+    $.hotkeys.remove('Ctrl+c', {target:'div#editor', type:'keypress'}); 
+    
+******************************************************************************************************************************/
+(function (jQuery){
+    this.version = '(beta)(0.0.3)';
+	this.all = {};
+    this.special_keys = {
+        27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 20: 'capslock', 
+        144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',35:'end', 33: 'pageup', 
+        34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 112:'f1',113:'f2', 114:'f3', 
+        115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 120:'f9', 121:'f10', 122:'f11', 123:'f12'};
+        
+    this.shift_nums = { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", 
+        "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<", 
+        ".":">",  "/":"?",  "\\":"|" };
+        
+    this.add = function(combi, options, callback) {
+        if (jQuery.isFunction(options)){
+            callback = options;
+            options = {};
+        }
+        var opt = {},
+            defaults = {type: 'keydown', propagate: false, disableInInput: false, target: jQuery('html')[0]},
+            that = this;
+        opt = jQuery.extend( opt , defaults, options || {} );
+        combi = combi.toLowerCase();        
+        
+        // inspect if keystroke matches
+        var inspector = function(event) {
+            event = jQuery.event.fix(event); // jQuery event normalization.
+            var element = event.target;
+            // @ TextNode -> nodeType == 3
+            element = (element.nodeType==3) ? element.parentNode : element;
+            
+            if(opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
+                var target = jQuery(element);
+                if( target.is("input") || target.is("textarea")){
+                    return;
+                }
+            }
+            var code = event.which,
+                type = event.type,
+                character = String.fromCharCode(code).toLowerCase(),
+                special = that.special_keys[code],
+                shift = event.shiftKey,
+                ctrl = event.ctrlKey,
+                alt= event.altKey,
+                meta = event.metaKey,
+                propagate = true, // default behaivour
+                mapPoint = null;
+            
+            // in opera + safari, the event.target is unpredictable.
+            // for example: 'keydown' might be associated with HtmlBodyElement 
+            // or the element where you last clicked with your mouse.
+            if (jQuery.browser.opera || jQuery.browser.safari){
+                while (!that.all[element] && element.parentNode){
+                    element = element.parentNode;
+                }
+            }
+            var cbMap = that.all[element].events[type].callbackMap;
+            if(!shift && !ctrl && !alt && !meta) { // No Modifiers
+                mapPoint = cbMap[special] ||  cbMap[character]
+			}
+            // deals with combinaitons (alt|ctrl|shift+anything)
+            else{
+                var modif = '';
+                if(alt) modif +='alt+';
+                if(ctrl) modif+= 'ctrl+';
+                if(shift) modif += 'shift+';
+                if(meta) modif += 'meta+';
+                // modifiers + special keys or modifiers + characters or modifiers + shift characters
+                mapPoint = cbMap[modif+special] || cbMap[modif+character] || cbMap[modif+that.shift_nums[character]]
+            }
+            if (mapPoint){
+                mapPoint.cb(event);
+                if(!mapPoint.propagate) {
+                    event.stopPropagation();
+                    event.preventDefault();
+                    return false;
+                }
+            }
+		};        
+        // first hook for this element
+        if (!this.all[opt.target]){
+            this.all[opt.target] = {events:{}};
+        }
+        if (!this.all[opt.target].events[opt.type]){
+            this.all[opt.target].events[opt.type] = {callbackMap: {}}
+            jQuery.event.add(opt.target, opt.type, inspector);
+        }        
+        this.all[opt.target].events[opt.type].callbackMap[combi] =  {cb: callback, propagate:opt.propagate};                
+        return jQuery;
+	};    
+    this.remove = function(exp, opt) {
+        opt = opt || {};
+        target = opt.target || jQuery('html')[0];
+        type = opt.type || 'keydown';
+		exp = exp.toLowerCase();        
+        delete this.all[target].events[type].callbackMap[exp]        
+        return jQuery;
+	};
+    jQuery.hotkeys = this;
+    return jQuery;    
+})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.hotkeys.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.hotkeys.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.hotkeys.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){this.version="(beta)(0.0.3)";this.all={};this.special_keys={27:"esc",9:"tab",32:"space",13:"return",8:"backspace",145:"scroll",20:"capslock",144:"numlock",19:"pause",45:"insert",36:"home",46:"del",35:"end",33:"pageup",34:"pagedown",37:"left",38:"up",39:"right",40:"down",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"};this.shift_nums={"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|"};this.add=function(c,b,h){if(a.isFunction(b)){h=b;b={}}var d={},f={type:"keydown",propagate:false,disableInInput:false,target:a("html")[0]},e=this;d=a.extend(d,f,b||{});c=c.toLowerCase();var g=function(j){j=a.event.fix(j);var o=j.target;o=(o.nodeType==3)?o.parentNode:o;if(d.disableInInput){var s=a(o);if(s.is("input")||s.is("textarea")){return}}var l=j.which,u=j.type,r=String.fromCharCode(l).toLowerCase(),t=e.special_keys[l],m=j.shiftKey,i=j.ctrlKey,p=j.altKey,w=j.metaKey,q=true,k=null;if(a.browser.opera||a.browser.safari){while(!e.all[o]&&o.parentNode){o=o.parentNode}}var v=e.all[o].events[u].callbackMap;if(!m&&!i&&!p&&!w){k=v[t]||v[r]}else{var n="";if(p){n+="alt+"}if(i){n+="ctrl+"}if(m){n+="shift+"}if(w){n+="meta+"}k=v[n+t]||v[n+r]||v[n+e.shift_nums[r]]}if(k){k.cb(j);if(!k.propagate){j.stopPropagation();j.preventDefault();return false}}};if(!this.all[d.target]){this.all[d.target]={events:{}}}if(!this.all[d.target].events[d.type]){this.all[d.target].events[d.type]={callbackMap:{}};a.event.add(d.target,d.type,g)}this.all[d.target].events[d.type].callbackMap[c]={cb:h,propagate:d.propagate};return a};this.remove=function(c,b){b=b||{};target=b.target||a("html")[0];type=b.type||"keydown";c=c.toLowerCase();delete this.all[target].events[type].callbackMap[c];return a};a.hotkeys=this;return a})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.js	(revision 17487)
@@ -0,0 +1,167 @@
+/*!
+ * jQuery JavaScript Library v1.4.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Thu Nov 11 19:04:53 2010 -0500
+ */
+(function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h=
+h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;k<J.length;k++){h=J[k];h.origType.replace(X,"")===a.type?f.push(h.selector):J.splice(k--,1)}f=c(a.target).closest(f,a.currentTarget);o=0;for(x=f.length;o<x;o++){r=f[o];for(k=0;k<J.length;k++){h=J[k];if(r.selector===h.selector&&(!A||A.test(h.namespace))){l=r.elem;e=null;if(h.preType==="mouseenter"||
+h.preType==="mouseleave"){a.type=h.preType;e=c(a.relatedTarget).closest(h.selector)[0]}if(!e||e!==l)C.push({elem:l,handleObj:h,level:r.level})}}}o=0;for(x=C.length;o<x;o++){f=C[o];if(d&&f.level>d)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La,
+"`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this,
+e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a,
+"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+
+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j,
+s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this,
+j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length},
+toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j===
+-1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false;
+if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K<Q;K++)if((j=arguments[K])!=null)for(s in j){v=G[s];z=j[s];if(G!==z)if(ga&&z&&(b.isPlainObject(z)||(H=b.isArray(z)))){if(H){H=false;v=v&&b.isArray(v)?v:[]}else v=v&&b.isPlainObject(v)?v:{};G[s]=b.extend(ga,v,z)}else if(z!==B)G[s]=z}return G};b.extend({noConflict:function(j){E.$=e;if(j)E.jQuery=d;return b},isReady:false,readyWait:1,ready:function(j){j===true&&b.readyWait--;
+if(!b.readyWait||j!==true&&!b.isReady){if(!t.body)return setTimeout(b.ready,1);b.isReady=true;if(!(j!==true&&--b.readyWait>0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload",
+b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&&
+!F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&&
+l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H<G;){if(s.apply(j[H++],v)===false)break}else if(K)for(z in j){if(s.call(j[z],
+z,j[z])===false)break}else for(v=j[0];H<G&&s.call(v,H,v)!==false;v=j[++H]);return j},trim:O?function(j){return j==null?"":O.call(j)}:function(j){return j==null?"":j.toString().replace(k,"").replace(o,"")},makeArray:function(j,s){var v=s||[];if(j!=null){var z=b.type(j);j.length==null||z==="string"||z==="function"||z==="regexp"||b.isWindow(j)?M.call(v,j):b.merge(v,j)}return v},inArray:function(j,s){if(s.indexOf)return s.indexOf(j);for(var v=0,z=s.length;v<z;v++)if(s[v]===j)return v;return-1},merge:function(j,
+s){var v=j.length,z=0;if(typeof s.length==="number")for(var H=s.length;z<H;z++)j[v++]=s[z];else for(;s[z]!==B;)j[v++]=s[z++];j.length=v;return j},grep:function(j,s,v){var z=[],H;v=!!v;for(var G=0,K=j.length;G<K;G++){H=!!s(j[G],G);v!==H&&z.push(j[G])}return z},map:function(j,s,v){for(var z=[],H,G=0,K=j.length;G<K;G++){H=s(j[G],G,v);if(H!=null)z[z.length]=H}return z.concat.apply([],z)},guid:1,proxy:function(j,s,v){if(arguments.length===2)if(typeof s==="string"){v=j;j=v[s];s=B}else if(s&&!b.isFunction(s)){v=
+s;s=B}if(!s&&j)s=function(){return j.apply(v||this,arguments)};if(j)s.guid=j.guid=j.guid||s.guid||b.guid++;return s},access:function(j,s,v,z,H,G){var K=j.length;if(typeof s==="object"){for(var Q in s)b.access(j,Q,s[Q],z,H,v);return j}if(v!==B){z=!G&&z&&b.isFunction(v);for(Q=0;Q<K;Q++)H(j[Q],s,z?v.call(j[Q],Q,H(j[Q],s)):v,G);return j}return K?H(j[0],s):B},now:function(){return(new Date).getTime()},uaMatch:function(j){j=j.toLowerCase();j=L.exec(j)||g.exec(j)||i.exec(j)||j.indexOf("compatible")<0&&n.exec(j)||
+[];return{browser:j[1]||"",version:j[2]||"0"}},browser:{}});b.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(j,s){R["[object "+s+"]"]=s.toLowerCase()});m=b.uaMatch(m);if(m.browser){b.browser[m.browser]=true;b.browser.version=m.version}if(b.browser.webkit)b.browser.safari=true;if(D)b.inArray=function(j,s){return D.call(s,j)};if(!/\s/.test("\u00a0")){k=/^[\s\xA0]+/;o=/[\s\xA0]+$/}f=b(t);if(t.addEventListener)u=function(){t.removeEventListener("DOMContentLoaded",u,
+false);b.ready()};else if(t.attachEvent)u=function(){if(t.readyState==="complete"){t.detachEvent("onreadystatechange",u);b.ready()}};return E.jQuery=E.$=b}();(function(){c.support={};var a=t.documentElement,b=t.createElement("script"),d=t.createElement("div"),e="script"+c.now();d.style.display="none";d.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"),
+k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false,
+scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent=
+false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom=
+1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="<div style='width:4px;'></div>";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display=
+"none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h=
+c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando);
+else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h<l;h++){f=e[h].name;if(f.indexOf("data-")===0){f=f.substr(5);ka(this[0],f,d[f])}}}return d}else if(typeof a==="object")return this.each(function(){c.data(this,
+a)});var k=a.split(".");k[1]=k[1]?"."+k[1]:"";if(b===B){d=this.triggerHandler("getData"+k[1]+"!",[k[0]]);if(d===B&&this.length){d=c.data(this[0],a);d=ka(this[0],a,d)}return d===B&&k[1]?this.data(k[0]):d}else return this.each(function(){var o=c(this),x=[k[0],b];o.triggerHandler("setData"+k[1]+"!",x);c.data(this,a,b);o.triggerHandler("changeData"+k[1]+"!",x)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var e=
+c.data(a,b);if(!d)return e||[];if(!e||c.isArray(d))e=c.data(a,b,c.makeArray(d));else e.push(d);return e}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),e=d.shift();if(e==="inprogress")e=d.shift();if(e){b==="fx"&&d.unshift("inprogress");e.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===B)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,
+a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var sa=/[\n\t]/g,ha=/\s+/,Sa=/\r/g,Ta=/^(?:href|src|style)$/,Ua=/^(?:button|input)$/i,Va=/^(?:button|input|object|select|textarea)$/i,Wa=/^a(?:rea)?$/i,ta=/^(?:radio|checkbox)$/i;c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",
+colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};c.fn.extend({attr:function(a,b){return c.access(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(x){var r=c(this);r.addClass(a.call(this,x,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ha),d=0,e=this.length;d<e;d++){var f=this[d];if(f.nodeType===
+1)if(f.className){for(var h=" "+f.className+" ",l=f.className,k=0,o=b.length;k<o;k++)if(h.indexOf(" "+b[k]+" ")<0)l+=" "+b[k];f.className=c.trim(l)}else f.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(o){var x=c(this);x.removeClass(a.call(this,o,x.attr("class")))});if(a&&typeof a==="string"||a===B)for(var b=(a||"").split(ha),d=0,e=this.length;d<e;d++){var f=this[d];if(f.nodeType===1&&f.className)if(a){for(var h=(" "+f.className+" ").replace(sa," "),
+l=0,k=b.length;l<k;l++)h=h.replace(" "+b[l]+" "," ");f.className=c.trim(h)}else f.className=""}return this},toggleClass:function(a,b){var d=typeof a,e=typeof b==="boolean";if(c.isFunction(a))return this.each(function(f){var h=c(this);h.toggleClass(a.call(this,f,h.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var f,h=0,l=c(this),k=b,o=a.split(ha);f=o[h++];){k=e?k:!l.hasClass(f);l[k?"addClass":"removeClass"](f)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,
+"__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(sa," ").indexOf(a)>-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one";
+if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h<e;h++){var l=f[h];if(l.selected&&(c.support.optDisabled?!l.disabled:l.getAttribute("disabled")===null)&&(!l.parentNode.disabled||!c.nodeName(l.parentNode,"optgroup"))){a=c(l).val();if(b)return a;d.push(a)}}return d}if(ta.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Sa,"")}return B}var k=c.isFunction(a);return this.each(function(o){var x=c(this),r=a;if(this.nodeType===1){if(k)r=
+a.call(this,o,x.val());if(r==null)r="";else if(typeof r==="number")r+="";else if(c.isArray(r))r=c.map(r,function(C){return C==null?"":C+""});if(c.isArray(r)&&ta.test(this.type))this.checked=c.inArray(x.val(),r)>=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},
+attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&
+b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0};
+c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,
+arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid=
+d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+
+c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h<A.length;h++){C=A[h];if(d.guid===C.guid){if(k||x.test(C.namespace)){e==null&&A.splice(h--,1);r.remove&&r.remove.call(a,C)}if(e!=null)break}}if(A.length===0||e!=null&&A.length===1){if(!r.teardown||r.teardown.call(a,o)===false)c.removeEvent(a,f,w.handle);delete I[f]}}else for(h=0;h<A.length;h++){C=A[h];if(k||x.test(C.namespace)){c.event.remove(a,r,C.handler,h);A.splice(h--,1)}}}if(c.isEmptyObject(I)){if(b=
+w.handle)b.elem=null;delete w.events;delete w.handle;if(typeof w==="function")c.removeData(a,J);else c.isEmptyObject(w)&&c.removeData(a)}}}}},trigger:function(a,b,d,e){var f=a.type||a;if(!e){a=typeof a==="object"?a[c.expando]?a:c.extend(c.Event(f),a):c.Event(f);if(f.indexOf("!")>=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===
+8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k===
+"click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+
+d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f<l;f++){var k=d[f];if(b||e.test(k.namespace)){a.handler=k.handler;a.data=k.data;a.handleObj=k;k=k.handler.apply(this,h);if(k!==B){a.result=k;if(k===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+fix:function(a){if(a[c.expando])return a;var b=a;a=c.Event(b);for(var d=this.props.length,e;d;){e=this.props[--d];a[e]=b[e]}if(!a.target)a.target=a.srcElement||t;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=t.documentElement;d=t.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
+d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(a.which==null&&(a.charCode!=null||a.keyCode!=null))a.which=a.charCode!=null?a.charCode:a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==B)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,Y(a.origType,a.selector),c.extend({},a,{handler:Ka,guid:a.handler.guid}))},remove:function(a){c.event.remove(this,
+Y(a.origType,a.selector),a)}},beforeunload:{setup:function(a,b,d){if(c.isWindow(this))this.onbeforeunload=d},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.removeEvent=t.removeEventListener?function(a,b,d){a.removeEventListener&&a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent&&a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=
+c.now();this[c.expando]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=ca;var a=this.originalEvent;if(a)if(a.preventDefault)a.preventDefault();else a.returnValue=false},stopPropagation:function(){this.isPropagationStopped=ca;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ca;this.stopPropagation()},isDefaultPrevented:U,isPropagationStopped:U,isImmediatePropagationStopped:U};
+var va=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},wa=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?wa:va,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?wa:va)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(){if(this.nodeName.toLowerCase()!==
+"form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length){a.liveFired=B;return la("submit",this,arguments)}});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13){a.liveFired=B;return la("submit",this,arguments)}})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};if(!c.support.changeBubbles){var V,
+xa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired=
+B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type===
+"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]===
+0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h<k;h++)c.event.add(this[h],d,l,e)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&!a.preventDefault)for(var d in a)this.unbind(d,
+a[d]);else{d=0;for(var e=this.length;d<e;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,e){return this.live(b,d,e,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){var d=c.Event(a);d.preventDefault();d.stopPropagation();c.event.trigger(d,b,this[0]);return d.result}},toggle:function(a){for(var b=arguments,d=
+1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(e){var f=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,f+1);e.preventDefault();return b[f].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var ya={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,e,f,h){var l,k=0,o,x,r=h||this.selector;h=h?this:c(this.context);if(typeof d===
+"object"&&!d.preventDefault){for(l in d)h[b](l,e,d[l],r);return this}if(c.isFunction(e)){f=e;e=B}for(d=(d||"").split(" ");(l=d[k++])!=null;){o=X.exec(l);x="";if(o){x=o[0];l=l.replace(X,"")}if(l==="hover")d.push("mouseenter"+x,"mouseleave"+x);else{o=l;if(l==="focus"||l==="blur"){d.push(ya[l]+x);l+=x}else l=(ya[l]||l)+x;if(b==="live"){x=0;for(var A=h.length;x<A;x++)c.event.add(h[x],"live."+Y(l,r),{data:e,selector:r,handler:f,origType:l,origHandler:f,preType:o})}else h.unbind("live."+Y(l,r),f)}}return this}});
+c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d,e){if(e==null){e=d;d=null}return arguments.length>0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});
+(function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p<u;p++){var y=m[p];if(y){var F=false;for(y=y[g];y;){if(y.sizcache===n){F=m[y.sizset];break}if(y.nodeType===1&&!q){y.sizcache=n;y.sizset=p}if(y.nodeName.toLowerCase()===i){F=y;break}y=y[g]}m[p]=F}}}function b(g,i,n,m,p,q){p=0;for(var u=m.length;p<u;p++){var y=m[p];if(y){var F=false;for(y=y[g];y;){if(y.sizcache===n){F=m[y.sizset];break}if(y.nodeType===1){if(!q){y.sizcache=n;y.sizset=p}if(typeof i!=="string"){if(y===i){F=true;break}}else if(k.filter(i,
+[y]).length>0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3];
+break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr,
+q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h=
+l;g.sort(w);if(h)for(var i=1;i<g.length;i++)g[i]===g[i-1]&&g.splice(i--,1)}return g};k.matches=function(g,i){return k(g,null,null,i)};k.matchesSelector=function(g,i){return k(i,null,null,[g]).length>0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p<q;p++){var u,y=o.order[p];if(u=o.leftMatch[y].exec(g)){var F=u[1];u.splice(1,1);if(F.substr(F.length-1)!=="\\"){u[1]=(u[1]||"").replace(/\\/g,"");m=o.find[y](u,i,n);if(m!=null){g=g.replace(o.match[y],"");break}}}}m||(m=i.getElementsByTagName("*"));
+return{set:m,expr:g}};k.filter=function(g,i,n,m){for(var p,q,u=g,y=[],F=i,M=i&&i[0]&&k.isXML(i[0]);g&&i.length;){for(var N in o.filter)if((p=o.leftMatch[N].exec(g))!=null&&p[2]){var O,D,R=o.filter[N];D=p[1];q=false;p.splice(1,1);if(D.substr(D.length-1)!=="\\"){if(F===y)y=[];if(o.preFilter[N])if(p=o.preFilter[N](p,F,n,y,m,M)){if(p===true)continue}else q=O=true;if(p)for(var j=0;(D=F[j])!=null;j++)if(D){O=R(D,p,j,F);var s=m^!!O;if(n&&O!=null)if(s)q=true;else F[j]=false;else if(s){y.push(D);q=true}}if(O!==
+B){n||(F=y);g=g.replace(o.match[N],"");if(!q)return[];break}}}if(g===u)if(q==null)k.error(g);else break;u=g}return F};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var o=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
+POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},relative:{"+":function(g,i){var n=typeof i==="string",m=n&&!/\W/.test(i);n=n&&!m;if(m)i=i.toLowerCase();m=0;for(var p=g.length,q;m<p;m++)if(q=g[m]){for(;(q=q.previousSibling)&&q.nodeType!==1;);g[m]=n||q&&q.nodeName.toLowerCase()===
+i?q||false:q===i}n&&k.filter(i,g,true)},">":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p<q;p++){if(n=g[p]){n=n.parentNode;g[p]=n.nodeName.toLowerCase()===i?n:false}}else{for(;p<q;p++)if(n=g[p])g[p]=m?n.parentNode:n.parentNode===i;m&&k.filter(i,g,true)}},"":function(g,i,n){var m,p=e++,q=b;if(typeof i==="string"&&!/\W/.test(i)){m=i=i.toLowerCase();q=a}q("parentNode",i,p,g,m,n)},"~":function(g,i,n){var m,p=e++,q=b;if(typeof i==="string"&&!/\W/.test(i)){m=
+i=i.toLowerCase();q=a}q("previousSibling",i,p,g,m,n)}},find:{ID:function(g,i,n){if(typeof i.getElementById!=="undefined"&&!n)return(g=i.getElementById(g[1]))&&g.parentNode?[g]:[]},NAME:function(g,i){if(typeof i.getElementsByName!=="undefined"){for(var n=[],m=i.getElementsByName(g[1]),p=0,q=m.length;p<q;p++)m[p].getAttribute("name")===g[1]&&n.push(m[p]);return n.length===0?null:n}},TAG:function(g,i){return i.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,i,n,m,p,q){g=" "+g[1].replace(/\\/g,
+"")+" ";if(q)return g;q=0;for(var u;(u=i[q])!=null;q++)if(u)if(p^(u.className&&(" "+u.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n,
+m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===
+true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===
+g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return i<n[3]-0},gt:function(g,i,n){return i>n[3]-0},nth:function(g,i,n){return n[3]-
+0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n<m;n++)if(i[n]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+p)},CHILD:function(g,i){var n=i[1],m=g;switch(n){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(n===
+"first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":n=i[2];var p=i[3];if(n===1&&p===0)return true;var q=i[0],u=g.parentNode;if(u&&(u.sizcache!==q||!g.nodeIndex)){var y=0;for(m=u.firstChild;m;m=m.nextSibling)if(m.nodeType===1)m.nodeIndex=++y;u.sizcache=q}m=g.nodeIndex-p;return n===0?m===0:m%n===0&&m/n>=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===
+i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]];
+if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m,
+g);else if(typeof g.length==="number")for(var p=g.length;n<p;n++)m.push(g[n]);else for(;g[n];n++)m.push(g[n]);return m}}var w,I;if(t.documentElement.compareDocumentPosition)w=function(g,i){if(g===i){h=true;return 0}if(!g.compareDocumentPosition||!i.compareDocumentPosition)return g.compareDocumentPosition?-1:1;return g.compareDocumentPosition(i)&4?-1:1};else{w=function(g,i){var n,m,p=[],q=[];n=g.parentNode;m=i.parentNode;var u=n;if(g===i){h=true;return 0}else if(n===m)return I(g,i);else if(n){if(!m)return 1}else return-1;
+for(;u;){p.unshift(u);u=u.parentNode}for(u=m;u;){q.unshift(u);u=u.parentNode}n=p.length;m=q.length;for(u=0;u<n&&u<m;u++)if(p[u]!==q[u])return I(p[u],q[u]);return u===n?I(g,q[u],-1):I(p[u],i,1)};I=function(g,i,n){if(g===i)return n;for(g=g.nextSibling;g;){if(g===i)return-1;g=g.nextSibling}return 1}}k.getText=function(g){for(var i="",n,m=0;g[m];m++){n=g[m];if(n.nodeType===3||n.nodeType===4)i+=n.nodeValue;else if(n.nodeType!==8)i+=k.getText(n.childNodes)}return i};(function(){var g=t.createElement("div"),
+i="script"+(new Date).getTime(),n=t.documentElement;g.innerHTML="<a name='"+i+"'/>";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g);
+n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="<a href='#'></a>";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&&
+function(){var g=k,i=t.createElement("div");i.innerHTML="<p class='TEST'></p>";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F||
+p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g=
+t.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition?
+function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n<u;n++)k(g,q[n],m);return k.filter(p,m)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=k.getText;c.isXMLDoc=k.isXML;
+c.contains=k.contains})();var Za=/Until$/,$a=/^(?:parents|prevUntil|prevAll)/,ab=/,/,Na=/^.[^:#\[\.,]*$/,bb=Array.prototype.slice,cb=c.expr.match.POS;c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,e=0,f=this.length;e<f;e++){d=b.length;c.find(a,this[e],b);if(e>0)for(var h=d;h<b.length;h++)for(var l=0;l<d;l++)if(b[l]===b[h]){b.splice(h--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,e=b.length;d<e;d++)if(c.contains(this,b[d]))return true})},
+not:function(a){return this.pushStack(ma(this,a,false),"not",a)},filter:function(a){return this.pushStack(ma(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e<f;e++){l=a[e];k[l]||(k[l]=c.expr.match.POS.test(l)?c(l,b||this.context):l)}for(;h&&h.ownerDocument&&h!==b;){for(l in k){e=k[l];if(e.jquery?e.index(h)>-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h=
+h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e<f;e++)for(h=this[e];h;)if(l?l.index(h)>-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context):
+c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,
+2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,
+b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&
+e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/<tbody/i,eb=/<|&#?\w+;/,Ca=/<(?:script|object|embed|option|style)/i,Da=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/\=([^="'>\s]+\/)>/g,P={option:[1,
+"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
+c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
+wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
+prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
+this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
+return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null;
+else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1></$2>");try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(e){this.empty().append(a)}}else c.isFunction(a)?this.each(function(f){var h=c(this);h.html(a.call(this,f,h.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=
+c(this),e=d.html();d.replaceWith(a.call(this,b,e))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){var e,f,h,l=a[0],k=[];if(!c.support.checkClone&&arguments.length===3&&typeof l==="string"&&Da.test(l))return this.each(function(){c(this).domManip(a,
+b,d,true)});if(c.isFunction(l))return this.each(function(x){var r=c(this);a[0]=l.call(this,x,b?r.html():B);r.domManip(a,b,d)});if(this[0]){e=l&&l.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:c.buildFragment(a,this,k);h=e.fragment;if(f=h.childNodes.length===1?h=h.firstChild:h.firstChild){b=b&&c.nodeName(f,"tr");f=0;for(var o=this.length;f<o;f++)d.call(b?c.nodeName(this[f],"table")?this[f].getElementsByTagName("tbody")[0]||this[f].appendChild(this[f].ownerDocument.createElement("tbody")):
+this[f]:this[f],f>0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append",
+prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f<h;f++){var l=(f>0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument||
+b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1></$2>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]==="<table>"&&!x?r.childNodes:[];for(o=k.length-
+1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script"))));
+d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i,
+jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true,
+zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b),
+h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b);
+if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f=
+d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left;
+e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
+ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b===
+"object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("<div>").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&
+!this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})},
+getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html",
+script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data||
+!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache=
+false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset;
+A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type",
+b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&&
+c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d||
+c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]=
+encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess",
+[b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),
+e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}});
+if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show",
+3),a,b,d);else{d=0;for(var e=this.length;d<e;d++){a=this[d];b=a.style.display;if(!c.data(a,"olddisplay")&&b==="none")b=a.style.display="";b===""&&c.css(a,"display")==="none"&&c.data(a,"olddisplay",qa(a.nodeName))}for(d=0;d<e;d++){a=this[d];b=a.style.display;if(b===""||b==="none")a.style.display=c.data(a,"olddisplay")||""}return this}},hide:function(a,b,d){if(a||a===0)return this.animate(S("hide",3),a,b,d);else{a=0;for(b=this.length;a<b;a++){d=c.css(this[a],"display");d!=="none"&&c.data(this[a],"olddisplay",
+d)}for(a=0;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b,d){var e=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||e?this.each(function(){var f=e?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(S("toggle",3),a,b,d);return this},fadeTo:function(a,b,d,e){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d,e)},animate:function(a,b,d,e){var f=c.speed(b,
+d,e);if(c.isEmptyObject(a))return this.each(f.complete);return this[f.queue===false?"each":"queue"](function(){var h=c.extend({},f),l,k=this.nodeType===1,o=k&&c(this).is(":hidden"),x=this;for(l in a){var r=c.camelCase(l);if(l!==r){a[r]=a[l];delete a[l];l=r}if(a[l]==="hide"&&o||a[l]==="show"&&!o)return h.complete.call(this);if(k&&(l==="height"||l==="width")){h.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY];if(c.css(this,"display")==="inline"&&c.css(this,"float")==="none")if(c.support.inlineBlockNeedsLayout)if(qa(this.nodeName)===
+"inline")this.style.display="inline-block";else{this.style.display="inline";this.style.zoom=1}else this.style.display="inline-block"}if(c.isArray(a[l])){(h.specialEasing=h.specialEasing||{})[l]=a[l][1];a[l]=a[l][0]}}if(h.overflow!=null)this.style.overflow="hidden";h.curAnim=c.extend({},a);c.each(a,function(A,C){var J=new c.fx(x,h,A);if(vb.test(C))J[C==="toggle"?o?"show":"hide":C](a);else{var w=wb.exec(C),I=J.cur()||0;if(w){var L=parseFloat(w[2]),g=w[3]||"px";if(g!=="px"){c.style(x,A,(L||1)+g);I=(L||
+1)/J.cur()*I;c.style(x,A,I+g)}if(w[1])L=(w[1]==="-="?-1:1)*L+I;J.custom(I,L,g)}else J.custom(I,C,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var e=d.length-1;e>=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b,
+d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a*
+Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)}
+var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;
+this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide||
+this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=
+c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},interval:13,stop:function(){clearInterval(ba);ba=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===
+b.elem}).length};var xb=/^t(?:able|d|h)$/i,Ia=/^(?:body|html)$/i;c.fn.offset="getBoundingClientRect"in t.documentElement?function(a){var b=this[0],d;if(a)return this.each(function(l){c.offset.setOffset(this,a,l)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);try{d=b.getBoundingClientRect()}catch(e){}var f=b.ownerDocument,h=f.documentElement;if(!d||!c.contains(h,b))return d||{top:0,left:0};b=f.body;f=fa(f);return{top:d.top+(f.pageYOffset||c.support.boxModel&&
+h.scrollTop||b.scrollTop)-(h.clientTop||b.clientTop||0),left:d.left+(f.pageXOffset||c.support.boxModel&&h.scrollLeft||b.scrollLeft)-(h.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(a)return this.each(function(x){c.offset.setOffset(this,a,x)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d,e=b.offsetParent,f=b.ownerDocument,h=f.documentElement,l=f.body;d=(f=f.defaultView)?f.getComputedStyle(b,null):b.currentStyle;
+for(var k=b.offsetTop,o=b.offsetLeft;(b=b.parentNode)&&b!==l&&b!==h;){if(c.offset.supportsFixedPosition&&d.position==="fixed")break;d=f?f.getComputedStyle(b,null):b.currentStyle;k-=b.scrollTop;o-=b.scrollLeft;if(b===e){k+=b.offsetTop;o+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&xb.test(b.nodeName))){k+=parseFloat(d.borderTopWidth)||0;o+=parseFloat(d.borderLeftWidth)||0}e=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&d.overflow!=="visible"){k+=
+parseFloat(d.borderTopWidth)||0;o+=parseFloat(d.borderLeftWidth)||0}d=d}if(d.position==="relative"||d.position==="static"){k+=l.offsetTop;o+=l.offsetLeft}if(c.offset.supportsFixedPosition&&d.position==="fixed"){k+=Math.max(h.scrollTop,l.scrollTop);o+=Math.max(h.scrollLeft,l.scrollLeft)}return{top:k,left:o}};c.offset={initialize:function(){var a=t.body,b=t.createElement("div"),d,e,f,h=parseFloat(c.css(a,"marginTop"))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",
+height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);d=b.firstChild;e=d.firstChild;f=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=e.offsetTop!==5;this.doesAddBorderForTableAndCells=
+f.offsetTop===5;e.style.position="fixed";e.style.top="20px";this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15;e.style.position=e.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==h;a.removeChild(b);c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.css(a,
+"marginTop"))||0;d+=parseFloat(c.css(a,"marginLeft"))||0}return{top:b,left:d}},setOffset:function(a,b,d){var e=c.css(a,"position");if(e==="static")a.style.position="relative";var f=c(a),h=f.offset(),l=c.css(a,"top"),k=c.css(a,"left"),o=e==="absolute"&&c.inArray("auto",[l,k])>-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a,
+e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&&
+c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();
+c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+
+b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window);jQuery.noConflict();
Index: /tags/3.1/wp-includes/js/jquery/jquery.query.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.query.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.query.js	(revision 17487)
@@ -0,0 +1,11 @@
+﻿/**
+ * jQuery.query - Query String Modification and Creation for jQuery
+ * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
+ * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
+ * Date: 2009/8/13
+ *
+ * @author Blair Mitchelmore
+ * @version 2.1.7
+ *
+ **/
+new function(e){var d=e.separator||"&";var c=e.spaces===false?false:true;var a=e.suffix===false?"":"[]";var g=e.prefix===false?false:true;var b=g?e.hash===true?"#":"?":"";var f=e.numbers===false?false:true;jQuery.query=new function(){var h=function(m,l){return m!=undefined&&m!==null&&(!!l?m.constructor==l:true)};var i=function(r){var l,q=/\[([^[]*)\]/g,n=/^([^[]+)(\[.*\])?$/.exec(r),o=n[1],p=[];while(l=q.exec(n[2])){p.push(l[1])}return[o,p]};var k=function(s,r,q){var t,p=r.shift();if(typeof s!="object"){s=null}if(p===""){if(!s){s=[]}if(h(s,Array)){s.push(r.length==0?q:k(null,r.slice(0),q))}else{if(h(s,Object)){var n=0;while(s[n++]!=null){}s[--n]=r.length==0?q:k(s[n],r.slice(0),q)}else{s=[];s.push(r.length==0?q:k(null,r.slice(0),q))}}}else{if(p&&p.match(/^\s*[0-9]+\s*$/)){var m=parseInt(p,10);if(!s){s=[]}s[m]=r.length==0?q:k(s[m],r.slice(0),q)}else{if(p){var m=p.replace(/^\s*|\s*$/g,"");if(!s){s={}}if(h(s,Array)){var l={};for(var n=0;n<s.length;++n){l[n]=s[n]}s=l}s[m]=r.length==0?q:k(s[m],r.slice(0),q)}else{return q}}}return s};var j=function(l){var m=this;m.keys={};if(l.queryObject){jQuery.each(l.get(),function(n,o){m.SET(n,o)})}else{jQuery.each(arguments,function(){var n=""+this;n=n.replace(/^[?#]/,"");n=n.replace(/[;&]$/,"");if(c){n=n.replace(/[+]/g," ")}jQuery.each(n.split(/[&;]/),function(){var o=decodeURIComponent(this.split("=")[0]||"");var p=decodeURIComponent(this.split("=")[1]||"");if(!o){return}if(f){if(/^[+-]?[0-9]+\.[0-9]*$/.test(p)){p=parseFloat(p)}else{if(/^[+-]?[0-9]+$/.test(p)){p=parseInt(p,10)}}}p=(!p&&p!==0)?true:p;if(p!==false&&p!==true&&typeof p!="number"){p=p}m.SET(o,p)})})}return m};j.prototype={queryObject:true,has:function(l,m){var n=this.get(l);return h(n,m)},GET:function(m){if(!h(m)){return this.keys}var l=i(m),n=l[0],p=l[1];var o=this.keys[n];while(o!=null&&p.length!=0){o=o[p.shift()]}return typeof o=="number"?o:o||""},get:function(l){var m=this.GET(l);if(h(m,Object)){return jQuery.extend(true,{},m)}else{if(h(m,Array)){return m.slice(0)}}return m},SET:function(m,r){var o=!h(r)?null:r;var l=i(m),n=l[0],q=l[1];var p=this.keys[n];this.keys[n]=k(p,q.slice(0),o);return this},set:function(l,m){return this.copy().SET(l,m)},REMOVE:function(l){return this.SET(l,null).COMPACT()},remove:function(l){return this.copy().REMOVE(l)},EMPTY:function(){var l=this;jQuery.each(l.keys,function(m,n){delete l.keys[m]});return l},load:function(l){var n=l.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1");var m=l.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new j(l.length==m.length?"":m,l.length==n.length?"":n)},empty:function(){return this.copy().EMPTY()},copy:function(){return new j(this)},COMPACT:function(){function l(o){var n=typeof o=="object"?h(o,Array)?[]:{}:o;if(typeof o=="object"){function m(r,p,q){if(h(r,Array)){r.push(q)}else{r[p]=q}}jQuery.each(o,function(p,q){if(!h(q)){return true}m(n,p,l(q))})}return n}this.keys=l(this.keys);return this},compact:function(){return this.copy().COMPACT()},toString:function(){var n=0,r=[],q=[],m=this;var o=function(s){s=s+"";if(c){s=s.replace(/ /g,"+")}return encodeURIComponent(s)};var l=function(s,t,u){if(!h(u)||u===false){return}var v=[o(t)];if(u!==true){v.push("=");v.push(o(u))}s.push(v.join(""))};var p=function(t,s){var u=function(v){return !s||s==""?[v].join(""):[s,"[",v,"]"].join("")};jQuery.each(t,function(v,w){if(typeof w=="object"){p(w,u(v))}else{l(q,u(v),w)}})};p(this.keys);if(q.length>0){r.push(b)}r.push(q.join(d));return r.join("")}};return new j(location.search,location.hash)}}(jQuery.query||{});
Index: /tags/3.1/wp-includes/js/jquery/jquery.schedule.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.schedule.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.schedule.js	(revision 17487)
@@ -0,0 +1,36 @@
+
+(function($){$.scheduler=function(){this.bucket={};return;};$.scheduler.prototype={schedule:function(){var ctx={"id":null,"time":1000,"repeat":false,"protect":false,"obj":null,"func":function(){},"args":[]};function _isfn(fn){return(!!fn&&typeof fn!="string"&&typeof fn[0]=="undefined"&&RegExp("function","i").test(fn+""));};var i=0;var override=false;if(typeof arguments[i]=="object"&&arguments.length>1){override=true;i++;}
+if(typeof arguments[i]=="object"){for(var option in arguments[i])
+if(typeof ctx[option]!="undefined")
+ctx[option]=arguments[i][option];i++;}
+if(typeof arguments[i]=="number"||(typeof arguments[i]=="string"&&arguments[i].match(RegExp("^[0-9]+[smhdw]$"))))
+ctx["time"]=arguments[i++];if(typeof arguments[i]=="boolean")
+ctx["repeat"]=arguments[i++];if(typeof arguments[i]=="boolean")
+ctx["protect"]=arguments[i++];if(typeof arguments[i]=="object"&&typeof arguments[i+1]=="string"&&_isfn(arguments[i][arguments[i+1]])){ctx["obj"]=arguments[i++];ctx["func"]=arguments[i++];}
+else if(typeof arguments[i]!="undefined"&&(_isfn(arguments[i])||typeof arguments[i]=="string"))
+ctx["func"]=arguments[i++];while(typeof arguments[i]!="undefined")
+ctx["args"].push(arguments[i++]);if(override){if(typeof arguments[1]=="object"){for(var option in arguments[0])
+if(typeof ctx[option]!="undefined"&&typeof arguments[1][option]=="undefined")
+ctx[option]=arguments[0][option];}
+else{for(var option in arguments[0])
+if(typeof ctx[option]!="undefined")
+ctx[option]=arguments[0][option];}
+i++;}
+ctx["_scheduler"]=this;ctx["_handle"]=null;var match=String(ctx["time"]).match(RegExp("^([0-9]+)([smhdw])$"));if(match&&match[0]!="undefined"&&match[1]!="undefined")
+ctx["time"]=String(parseInt(match[1])*{s:1000,m:1000*60,h:1000*60*60,d:1000*60*60*24,w:1000*60*60*24*7}[match[2]]);if(ctx["id"]==null)
+ctx["id"]=(String(ctx["repeat"])+":"
++String(ctx["protect"])+":"
++String(ctx["time"])+":"
++String(ctx["obj"])+":"
++String(ctx["func"])+":"
++String(ctx["args"]));if(ctx["protect"])
+if(typeof this.bucket[ctx["id"]]!="undefined")
+return this.bucket[ctx["id"]];if(!_isfn(ctx["func"])){if(ctx["obj"]!=null&&typeof ctx["obj"]=="object"&&typeof ctx["func"]=="string"&&_isfn(ctx["obj"][ctx["func"]]))
+ctx["func"]=ctx["obj"][ctx["func"]];else
+ctx["func"]=eval("function () { "+ctx["func"]+" }");}
+ctx["_handle"]=this._schedule(ctx);this.bucket[ctx["id"]]=ctx;return ctx;},reschedule:function(ctx){if(typeof ctx=="string")
+ctx=this.bucket[ctx];ctx["_handle"]=this._schedule(ctx);return ctx;},_schedule:function(ctx){var trampoline=function(){var obj=(ctx["obj"]!=null?ctx["obj"]:ctx);(ctx["func"]).apply(obj,ctx["args"]);if(typeof(ctx["_scheduler"]).bucket[ctx["id"]]!="undefined"&&ctx["repeat"])
+(ctx["_scheduler"])._schedule(ctx);else
+delete(ctx["_scheduler"]).bucket[ctx["id"]];};return setTimeout(trampoline,ctx["time"]);},cancel:function(ctx){if(typeof ctx=="string")
+ctx=this.bucket[ctx];if(typeof ctx=="object"){clearTimeout(ctx["_handle"]);delete this.bucket[ctx["id"]];}}};$.extend({scheduler$:new $.scheduler(),schedule:function(){return $.scheduler$.schedule.apply($.scheduler$,arguments)},reschedule:function(){return $.scheduler$.reschedule.apply($.scheduler$,arguments)},cancel:function(){return $.scheduler$.cancel.apply($.scheduler$,arguments)}});$.fn.extend({schedule:function(){var a=[{}];for(var i=0;i<arguments.length;i++)
+a.push(arguments[i]);return this.each(function(){a[0]={"id":this,"obj":this};return $.schedule.apply($,a);});}});})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.serialize-object.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.serialize-object.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.serialize-object.js	(revision 17487)
@@ -0,0 +1,31 @@
+/*!
+ * jQuery serializeObject - v0.2 - 1/20/2010
+ * http://benalman.com/projects/jquery-misc-plugins/
+ * 
+ * Copyright (c) 2010 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+
+// Whereas .serializeArray() serializes a form into an array, .serializeObject()
+// serializes a form into an (arguably more useful) object.
+
+(function($,undefined){
+  '$:nomunge'; // Used by YUI compressor.
+  
+  $.fn.serializeObject = function(){
+    var obj = {};
+    
+    $.each( this.serializeArray(), function(i,o){
+      var n = o.name,
+        v = o.value;
+        
+        obj[n] = obj[n] === undefined ? v
+          : $.isArray( obj[n] ) ? obj[n].concat( v )
+          : [ obj[n], v ];
+    });
+    
+    return obj;
+  };
+  
+})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.table-hotkeys.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.table-hotkeys.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.table-hotkeys.dev.js	(revision 17487)
@@ -0,0 +1,99 @@
+(function($){
+	$.fn.filter_visible = function(depth) {
+		depth = depth || 3;
+		var is_visible = function() {
+			var p = $(this), i;
+			for(i=0; i<depth-1; ++i) {
+				if (!p.is(':visible')) return false;
+				p = p.parent();
+			}
+			return true;
+		}
+		return this.filter(is_visible);
+	};
+	$.table_hotkeys = function(table, keys, opts) {
+		opts = $.extend($.table_hotkeys.defaults, opts);
+		var selected_class, destructive_class, set_current_row, adjacent_row_callback, get_adjacent_row, adjacent_row, prev_row, next_row, check, get_first_row, get_last_row, make_key_callback, first_row;
+		
+		selected_class = opts.class_prefix + opts.selected_suffix;
+		destructive_class = opts.class_prefix + opts.destructive_suffix
+		set_current_row = function (tr) {
+			if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class);
+			tr.addClass(selected_class);
+			tr[0].scrollIntoView(false);
+			$.table_hotkeys.current_row = tr;
+		};
+		adjacent_row_callback = function(which) {
+			if (!adjacent_row(which) && $.isFunction(opts[which+'_page_link_cb'])) {
+				opts[which+'_page_link_cb']();
+			}
+		};
+		get_adjacent_row = function(which) {
+			var first_row, method;
+			
+			if (!$.table_hotkeys.current_row) {
+				first_row = get_first_row();
+				$.table_hotkeys.current_row = first_row;
+				return first_row[0];
+			}
+			method = 'prev' == which? $.fn.prevAll : $.fn.nextAll;
+			return method.call($.table_hotkeys.current_row, opts.cycle_expr).filter_visible()[0];
+		};
+		adjacent_row = function(which) {
+			var adj = get_adjacent_row(which);
+			if (!adj) return false;
+			set_current_row($(adj));
+			return true;
+		};
+		prev_row = function() { return adjacent_row('prev'); };
+		next_row = function() { return adjacent_row('next'); };
+		check = function() {
+			$(opts.checkbox_expr, $.table_hotkeys.current_row).each(function() {
+				this.checked = !this.checked;
+			});
+		};
+		get_first_row = function() {
+			return $(opts.cycle_expr, table).filter_visible().eq(opts.start_row_index);
+		};
+		get_last_row = function() {
+			var rows = $(opts.cycle_expr, table).filter_visible();
+			return rows.eq(rows.length-1);
+		};
+		make_key_callback = function(expr) {
+			return function() {
+				if ( null == $.table_hotkeys.current_row ) return false;
+				var clickable = $(expr, $.table_hotkeys.current_row);
+				if (!clickable.length) return false;
+				if (clickable.is('.'+destructive_class)) next_row() || prev_row();
+				clickable.click();
+			}
+		};
+		first_row = get_first_row();
+		if (!first_row.length) return;
+		if (opts.highlight_first)
+			set_current_row(first_row);
+		else if (opts.highlight_last)
+			set_current_row(get_last_row());
+		$.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev')});
+		$.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next')});
+		$.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check);
+		$.each(keys, function() {
+			var callback, key;
+			
+			if ($.isFunction(this[1])) {
+				callback = this[1];
+				key = this[0];
+				$.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); });
+			} else {
+				key = this;
+				$.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key));
+			}
+		});
+
+	};
+	$.table_hotkeys.current_row = null;
+	$.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current',
+		destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'},
+		checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x',
+		start_row_index: 2, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false};
+})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/jquery.table-hotkeys.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/jquery.table-hotkeys.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/jquery.table-hotkeys.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){a.fn.filter_visible=function(c){c=c||3;var b=function(){var e=a(this),d;for(d=0;d<c-1;++d){if(!e.is(":visible")){return false}e=e.parent()}return true};return this.filter(b)};a.table_hotkeys=function(p,q,b){b=a.extend(a.table_hotkeys.defaults,b);var i,l,e,f,m,d,k,o,c,h,g,n,j;i=b.class_prefix+b.selected_suffix;l=b.class_prefix+b.destructive_suffix;e=function(r){if(a.table_hotkeys.current_row){a.table_hotkeys.current_row.removeClass(i)}r.addClass(i);r[0].scrollIntoView(false);a.table_hotkeys.current_row=r};f=function(r){if(!d(r)&&a.isFunction(b[r+"_page_link_cb"])){b[r+"_page_link_cb"]()}};m=function(s){var r,t;if(!a.table_hotkeys.current_row){r=h();a.table_hotkeys.current_row=r;return r[0]}t="prev"==s?a.fn.prevAll:a.fn.nextAll;return t.call(a.table_hotkeys.current_row,b.cycle_expr).filter_visible()[0]};d=function(s){var r=m(s);if(!r){return false}e(a(r));return true};k=function(){return d("prev")};o=function(){return d("next")};c=function(){a(b.checkbox_expr,a.table_hotkeys.current_row).each(function(){this.checked=!this.checked})};h=function(){return a(b.cycle_expr,p).filter_visible().eq(b.start_row_index)};g=function(){var r=a(b.cycle_expr,p).filter_visible();return r.eq(r.length-1)};n=function(r){return function(){if(null==a.table_hotkeys.current_row){return false}var s=a(r,a.table_hotkeys.current_row);if(!s.length){return false}if(s.is("."+l)){o()||k()}s.click()}};j=h();if(!j.length){return}if(b.highlight_first){e(j)}else{if(b.highlight_last){e(g())}}a.hotkeys.add(b.prev_key,b.hotkeys_opts,function(){return f("prev")});a.hotkeys.add(b.next_key,b.hotkeys_opts,function(){return f("next")});a.hotkeys.add(b.mark_key,b.hotkeys_opts,c);a.each(q,function(){var s,r;if(a.isFunction(this[1])){s=this[1];r=this[0];a.hotkeys.add(r,b.hotkeys_opts,function(t){return s(t,a.table_hotkeys.current_row)})}else{r=this;a.hotkeys.add(r,b.hotkeys_opts,n("."+b.class_prefix+r))}})};a.table_hotkeys.current_row=null;a.table_hotkeys.defaults={cycle_expr:"tr",class_prefix:"vim-",selected_suffix:"current",destructive_suffix:"destructive",hotkeys_opts:{disableInInput:true,type:"keypress"},checkbox_expr:":checkbox",next_key:"j",prev_key:"k",mark_key:"x",start_row_index:2,highlight_first:false,highlight_last:false,next_page_link_cb:false,prev_page_link_cb:false}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/suggest.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/suggest.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/suggest.dev.js	(revision 17487)
@@ -0,0 +1,330 @@
+/*
+ *	jquery.suggest 1.1b - 2007-08-06
+ * Patched by Mark Jaquith with Alexander Dick's "multiple items" patch to allow for auto-suggesting of more than one tag before submitting
+ * See: http://www.vulgarisoip.com/2007/06/29/jquerysuggest-an-alternative-jquery-based-autocomplete-library/#comment-7228
+ *
+ *	Uses code and techniques from following libraries:
+ *	1. http://www.dyve.net/jquery/?autocomplete
+ *	2. http://dev.jquery.com/browser/trunk/plugins/interface/iautocompleter.js
+ *
+ *	All the new stuff written by Peter Vulgaris (www.vulgarisoip.com)
+ *	Feel free to do whatever you want with this file
+ *
+ */
+
+(function($) {
+
+	$.suggest = function(input, options) {
+		var $input, $results, timeout, prevLength, cache, cacheSize;
+
+		$input = $(input).attr("autocomplete", "off");
+		$results = $(document.createElement("ul"));
+
+		timeout = false;		// hold timeout ID for suggestion results to appear
+		prevLength = 0;			// last recorded length of $input.val()
+		cache = [];				// cache MRU list
+		cacheSize = 0;			// size of cache in chars (bytes?)
+
+		$results.addClass(options.resultsClass).appendTo('body');
+
+
+		resetPosition();
+		$(window)
+			.load(resetPosition)		// just in case user is changing size of page while loading
+			.resize(resetPosition);
+
+		$input.blur(function() {
+			setTimeout(function() { $results.hide() }, 200);
+		});
+
+
+		// help IE users if possible
+		if ( $.browser.msie ) {
+			try {
+				$results.bgiframe();
+			} catch(e) { }
+		}
+
+		// I really hate browser detection, but I don't see any other way
+		if ($.browser.mozilla)
+			$input.keypress(processKey);	// onkeypress repeats arrow keys in Mozilla/Opera
+		else
+			$input.keydown(processKey);		// onkeydown repeats arrow keys in IE/Safari
+
+
+
+
+		function resetPosition() {
+			// requires jquery.dimension plugin
+			var offset = $input.offset();
+			$results.css({
+				top: (offset.top + input.offsetHeight) + 'px',
+				left: offset.left + 'px'
+			});
+		}
+
+
+		function processKey(e) {
+
+			// handling up/down/escape requires results to be visible
+			// handling enter/tab requires that AND a result to be selected
+			if ((/27$|38$|40$/.test(e.keyCode) && $results.is(':visible')) ||
+				(/^13$|^9$/.test(e.keyCode) && getCurrentResult())) {
+
+				if (e.preventDefault)
+					e.preventDefault();
+				if (e.stopPropagation)
+					e.stopPropagation();
+
+				e.cancelBubble = true;
+				e.returnValue = false;
+
+				switch(e.keyCode) {
+
+					case 38: // up
+						prevResult();
+						break;
+
+					case 40: // down
+						nextResult();
+						break;
+
+					case 9:  // tab
+					case 13: // return
+						selectCurrentResult();
+						break;
+
+					case 27: //	escape
+						$results.hide();
+						break;
+
+				}
+
+			} else if ($input.val().length != prevLength) {
+
+				if (timeout)
+					clearTimeout(timeout);
+				timeout = setTimeout(suggest, options.delay);
+				prevLength = $input.val().length;
+
+			}
+
+
+		}
+
+
+		function suggest() {
+
+			var q = $.trim($input.val()), multipleSepPos, items;
+
+			if ( options.multiple ) {
+				multipleSepPos = q.lastIndexOf(options.multipleSep);
+				if ( multipleSepPos != -1 ) {
+					q = $.trim(q.substr(multipleSepPos + options.multipleSep.length));
+				}
+			}
+			if (q.length >= options.minchars) {
+
+				cached = checkCache(q);
+
+				if (cached) {
+
+					displayItems(cached['items']);
+
+				} else {
+
+					$.get(options.source, {q: q}, function(txt) {
+
+						$results.hide();
+
+						items = parseTxt(txt, q);
+
+						displayItems(items);
+						addToCache(q, items, txt.length);
+
+					});
+
+				}
+
+			} else {
+
+				$results.hide();
+
+			}
+
+		}
+
+
+		function checkCache(q) {
+			var i;
+			for (i = 0; i < cache.length; i++)
+				if (cache[i]['q'] == q) {
+					cache.unshift(cache.splice(i, 1)[0]);
+					return cache[0];
+				}
+
+			return false;
+
+		}
+
+		function addToCache(q, items, size) {
+			var cached;
+			while (cache.length && (cacheSize + size > options.maxCacheSize)) {
+				cached = cache.pop();
+				cacheSize -= cached['size'];
+			}
+
+			cache.push({
+				q: q,
+				size: size,
+				items: items
+				});
+
+			cacheSize += size;
+
+		}
+
+		function displayItems(items) {
+			var html = '', i;
+			if (!items)
+				return;
+
+			if (!items.length) {
+				$results.hide();
+				return;
+			}
+
+			resetPosition(); // when the form moves after the page has loaded
+
+			for (i = 0; i < items.length; i++)
+				html += '<li>' + items[i] + '</li>';
+
+			$results.html(html).show();
+
+			$results
+				.children('li')
+				.mouseover(function() {
+					$results.children('li').removeClass(options.selectClass);
+					$(this).addClass(options.selectClass);
+				})
+				.click(function(e) {
+					e.preventDefault();
+					e.stopPropagation();
+					selectCurrentResult();
+				});
+
+		}
+
+		function parseTxt(txt, q) {
+
+			var items = [], tokens = txt.split(options.delimiter), i, token;
+
+			// parse returned data for non-empty items
+			for (i = 0; i < tokens.length; i++) {
+				token = $.trim(tokens[i]);
+				if (token) {
+					token = token.replace(
+						new RegExp(q, 'ig'),
+						function(q) { return '<span class="' + options.matchClass + '">' + q + '</span>' }
+						);
+					items[items.length] = token;
+				}
+			}
+
+			return items;
+		}
+
+		function getCurrentResult() {
+			var $currentResult;
+			if (!$results.is(':visible'))
+				return false;
+
+			$currentResult = $results.children('li.' + options.selectClass);
+
+			if (!$currentResult.length)
+				$currentResult = false;
+
+			return $currentResult;
+
+		}
+
+		function selectCurrentResult() {
+
+			$currentResult = getCurrentResult();
+
+			if ($currentResult) {
+				if ( options.multiple ) {
+					if ( $input.val().indexOf(options.multipleSep) != -1 ) {
+						$currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) );
+					} else {
+						$currentVal = "";
+					}
+					$input.val( $currentVal + $currentResult.text() + options.multipleSep);
+					$input.focus();
+				} else {
+					$input.val($currentResult.text());
+				}
+				$results.hide();
+
+				if (options.onSelect)
+					options.onSelect.apply($input[0]);
+
+			}
+
+		}
+
+		function nextResult() {
+
+			$currentResult = getCurrentResult();
+
+			if ($currentResult)
+				$currentResult
+					.removeClass(options.selectClass)
+					.next()
+						.addClass(options.selectClass);
+			else
+				$results.children('li:first-child').addClass(options.selectClass);
+
+		}
+
+		function prevResult() {
+			var $currentResult = getCurrentResult();
+
+			if ($currentResult)
+				$currentResult
+					.removeClass(options.selectClass)
+					.prev()
+						.addClass(options.selectClass);
+			else
+				$results.children('li:last-child').addClass(options.selectClass);
+
+		}
+	}
+
+	$.fn.suggest = function(source, options) {
+
+		if (!source)
+			return;
+
+		options = options || {};
+		options.multiple = options.multiple || false;
+		options.multipleSep = options.multipleSep || ", ";
+		options.source = source;
+		options.delay = options.delay || 100;
+		options.resultsClass = options.resultsClass || 'ac_results';
+		options.selectClass = options.selectClass || 'ac_over';
+		options.matchClass = options.matchClass || 'ac_match';
+		options.minchars = options.minchars || 2;
+		options.delimiter = options.delimiter || '\n';
+		options.onSelect = options.onSelect || false;
+		options.maxCacheSize = options.maxCacheSize || 65536;
+
+		this.each(function() {
+			new $.suggest(this, options);
+		});
+
+		return this;
+
+	};
+
+})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/suggest.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/suggest.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/suggest.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){a.suggest=function(o,g){var c,f,n,d,q,p;c=a(o).attr("autocomplete","off");f=a(document.createElement("ul"));n=false;d=0;q=[];p=0;f.addClass(g.resultsClass).appendTo("body");j();a(window).load(j).resize(j);c.blur(function(){setTimeout(function(){f.hide()},200)});if(a.browser.msie){try{f.bgiframe()}catch(s){}}if(a.browser.mozilla){c.keypress(m)}else{c.keydown(m)}function j(){var e=c.offset();f.css({top:(e.top+o.offsetHeight)+"px",left:e.left+"px"})}function m(w){if((/27$|38$|40$/.test(w.keyCode)&&f.is(":visible"))||(/^13$|^9$/.test(w.keyCode)&&u())){if(w.preventDefault){w.preventDefault()}if(w.stopPropagation){w.stopPropagation()}w.cancelBubble=true;w.returnValue=false;switch(w.keyCode){case 38:k();break;case 40:t();break;case 9:case 13:r();break;case 27:f.hide();break}}else{if(c.val().length!=d){if(n){clearTimeout(n)}n=setTimeout(l,g.delay);d=c.val().length}}}function l(){var x=a.trim(c.val()),w,e;if(g.multiple){w=x.lastIndexOf(g.multipleSep);if(w!=-1){x=a.trim(x.substr(w+g.multipleSep.length))}}if(x.length>=g.minchars){cached=v(x);if(cached){i(cached.items)}else{a.get(g.source,{q:x},function(y){f.hide();e=b(y,x);i(e);h(x,e,y.length)})}}else{f.hide()}}function v(w){var e;for(e=0;e<q.length;e++){if(q[e]["q"]==w){q.unshift(q.splice(e,1)[0]);return q[0]}}return false}function h(y,e,w){var x;while(q.length&&(p+w>g.maxCacheSize)){x=q.pop();p-=x.size}q.push({q:y,size:w,items:e});p+=w}function i(e){var x="",w;if(!e){return}if(!e.length){f.hide();return}j();for(w=0;w<e.length;w++){x+="<li>"+e[w]+"</li>"}f.html(x).show();f.children("li").mouseover(function(){f.children("li").removeClass(g.selectClass);a(this).addClass(g.selectClass)}).click(function(y){y.preventDefault();y.stopPropagation();r()})}function b(e,z){var w=[],A=e.split(g.delimiter),y,x;for(y=0;y<A.length;y++){x=a.trim(A[y]);if(x){x=x.replace(new RegExp(z,"ig"),function(B){return'<span class="'+g.matchClass+'">'+B+"</span>"});w[w.length]=x}}return w}function u(){var e;if(!f.is(":visible")){return false}e=f.children("li."+g.selectClass);if(!e.length){e=false}return e}function r(){$currentResult=u();if($currentResult){if(g.multiple){if(c.val().indexOf(g.multipleSep)!=-1){$currentVal=c.val().substr(0,(c.val().lastIndexOf(g.multipleSep)+g.multipleSep.length))}else{$currentVal=""}c.val($currentVal+$currentResult.text()+g.multipleSep);c.focus()}else{c.val($currentResult.text())}f.hide();if(g.onSelect){g.onSelect.apply(c[0])}}}function t(){$currentResult=u();if($currentResult){$currentResult.removeClass(g.selectClass).next().addClass(g.selectClass)}else{f.children("li:first-child").addClass(g.selectClass)}}function k(){var e=u();if(e){e.removeClass(g.selectClass).prev().addClass(g.selectClass)}else{f.children("li:last-child").addClass(g.selectClass)}}};a.fn.suggest=function(c,b){if(!c){return}b=b||{};b.multiple=b.multiple||false;b.multipleSep=b.multipleSep||", ";b.source=c;b.delay=b.delay||100;b.resultsClass=b.resultsClass||"ac_results";b.selectClass=b.selectClass||"ac_over";b.matchClass=b.matchClass||"ac_match";b.minchars=b.minchars||2;b.delimiter=b.delimiter||"\n";b.onSelect=b.onSelect||false;b.maxCacheSize=b.maxCacheSize||65536;this.each(function(){new a.suggest(this,b)});return this}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.button.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.button.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.button.js	(revision 17487)
@@ -0,0 +1,25 @@
+/*
+ * jQuery UI Button 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Button
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.widget.js
+ */
+(function(a){var g,i=function(b){a(":ui-button",b.target.form).each(function(){var c=a(this).data("button");setTimeout(function(){c.refresh()},1)})},h=function(b){var c=b.name,d=b.form,e=a([]);if(c)e=d?a(d).find("[name='"+c+"']"):a("[name='"+c+"']",b.ownerDocument).filter(function(){return!this.form});return e};a.widget("ui.button",{options:{disabled:null,text:true,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button",
+i);if(typeof this.options.disabled!=="boolean")this.options.disabled=this.element.attr("disabled");this._determineButtonType();this.hasTitle=!!this.buttonElement.attr("title");var b=this,c=this.options,d=this.type==="checkbox"||this.type==="radio",e="ui-state-hover"+(!d?" ui-state-active":"");if(c.label===null)c.label=this.buttonElement.html();if(this.element.is(":disabled"))c.disabled=true;this.buttonElement.addClass("ui-button ui-widget ui-state-default ui-corner-all").attr("role","button").bind("mouseenter.button",
+function(){if(!c.disabled){a(this).addClass("ui-state-hover");this===g&&a(this).addClass("ui-state-active")}}).bind("mouseleave.button",function(){c.disabled||a(this).removeClass(e)}).bind("focus.button",function(){a(this).addClass("ui-state-focus")}).bind("blur.button",function(){a(this).removeClass("ui-state-focus")});d&&this.element.bind("change.button",function(){b.refresh()});if(this.type==="checkbox")this.buttonElement.bind("click.button",function(){if(c.disabled)return false;a(this).toggleClass("ui-state-active");
+b.buttonElement.attr("aria-pressed",b.element[0].checked)});else if(this.type==="radio")this.buttonElement.bind("click.button",function(){if(c.disabled)return false;a(this).addClass("ui-state-active");b.buttonElement.attr("aria-pressed",true);var f=b.element[0];h(f).not(f).map(function(){return a(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed",false)});else{this.buttonElement.bind("mousedown.button",function(){if(c.disabled)return false;a(this).addClass("ui-state-active");
+g=this;a(document).one("mouseup",function(){g=null})}).bind("mouseup.button",function(){if(c.disabled)return false;a(this).removeClass("ui-state-active")}).bind("keydown.button",function(f){if(c.disabled)return false;if(f.keyCode==a.ui.keyCode.SPACE||f.keyCode==a.ui.keyCode.ENTER)a(this).addClass("ui-state-active")}).bind("keyup.button",function(){a(this).removeClass("ui-state-active")});this.buttonElement.is("a")&&this.buttonElement.keyup(function(f){f.keyCode===a.ui.keyCode.SPACE&&a(this).click()})}this._setOption("disabled",
+c.disabled)},_determineButtonType:function(){this.type=this.element.is(":checkbox")?"checkbox":this.element.is(":radio")?"radio":this.element.is("input")?"input":"button";if(this.type==="checkbox"||this.type==="radio"){this.buttonElement=this.element.parents().last().find("label[for="+this.element.attr("id")+"]");this.element.addClass("ui-helper-hidden-accessible");var b=this.element.is(":checked");b&&this.buttonElement.addClass("ui-state-active");this.buttonElement.attr("aria-pressed",b)}else this.buttonElement=
+this.element},widget:function(){return this.buttonElement},destroy:function(){this.element.removeClass("ui-helper-hidden-accessible");this.buttonElement.removeClass("ui-button ui-widget ui-state-default ui-corner-all ui-state-hover ui-state-active  ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only").removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html());this.hasTitle||
+this.buttonElement.removeAttr("title");a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments);if(b==="disabled")c?this.element.attr("disabled",true):this.element.removeAttr("disabled");this._resetButton()},refresh:function(){var b=this.element.is(":disabled");b!==this.options.disabled&&this._setOption("disabled",b);if(this.type==="radio")h(this.element[0]).each(function(){a(this).is(":checked")?a(this).button("widget").addClass("ui-state-active").attr("aria-pressed",
+true):a(this).button("widget").removeClass("ui-state-active").attr("aria-pressed",false)});else if(this.type==="checkbox")this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed",true):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed",false)},_resetButton:function(){if(this.type==="input")this.options.label&&this.element.val(this.options.label);else{var b=this.buttonElement.removeClass("ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only"),
+c=a("<span></span>").addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(),d=this.options.icons,e=d.primary&&d.secondary;if(d.primary||d.secondary){b.addClass("ui-button-text-icon"+(e?"s":d.primary?"-primary":"-secondary"));d.primary&&b.prepend("<span class='ui-button-icon-primary ui-icon "+d.primary+"'></span>");d.secondary&&b.append("<span class='ui-button-icon-secondary ui-icon "+d.secondary+"'></span>");if(!this.options.text){b.addClass(e?"ui-button-icons-only":"ui-button-icon-only").removeClass("ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary");
+this.hasTitle||b.attr("title",c)}}else b.addClass("ui-button-text-only")}}});a.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(b,c){b==="disabled"&&this.buttons.button("option",b,c);a.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass("ui-corner-left").end().filter(":last").addClass("ui-corner-right").end().end()},
+destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy");a.Widget.prototype.destroy.call(this)}})})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.core.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.core.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.core.js	(revision 17487)
@@ -0,0 +1,17 @@
+/*!
+ * jQuery UI 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI
+ */
+(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,
+NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,
+"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");
+if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f,
+"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,
+d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}});
+c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&
+b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.dialog.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.dialog.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.dialog.js	(revision 17487)
@@ -0,0 +1,40 @@
+/*
+ * jQuery UI Dialog 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Dialog
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.widget.js
+ *  jquery.ui.button.js
+ *	jquery.ui.draggable.js
+ *	jquery.ui.mouse.js
+ *	jquery.ui.position.js
+ *	jquery.ui.resizable.js
+ */
+(function(c,j){var k={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},l={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true};c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:{my:"center",at:"center",collision:"fit",using:function(a){var b=c(this).css(a).offset().top;b<0&&
+c(this).css("top",a.top-b)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||"&#160;",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("<div></div>")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",
+-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),h=c('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role",
+"button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c("<span></span>")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c("<span></span>").addClass("ui-dialog-title").attr("id",e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=
+b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");a.uiDialog.remove();a.originalTitle&&
+a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!==b.uiDialog[0]){e=c(this).css("z-index");
+isNaN(e)||(d=Math.max(d,e))}});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.attr("scrollTop"),scrollLeft:d.element.attr("scrollLeft")};c.ui.dialog.maxZ+=1;d.uiDialog.css("z-index",c.ui.dialog.maxZ);
+d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target===f[0]&&e.shiftKey){g.focus(1);return false}}});
+c(a.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();a._isOpen=true;a._trigger("open");return a}},_createButtons:function(a){var b=this,d=false,e=c("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),g=c("<div></div>").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a,function(){return!(d=true)});if(d){c.each(a,function(f,
+h){h=c.isFunction(h)?{click:h,text:f}:h;f=c('<button type="button"></button>').attr(h,true).unbind("click").click(function(){h.click.apply(b.element[0],arguments)}).appendTo(g);c.fn.button&&f.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g=
+d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition,originalSize:f.originalSize,
+position:f.position,size:f.size}}a=a===j?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position");a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize",f,b(h))},stop:function(f,
+h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "):[a[0],a[1]];if(b.length===
+1)b[1]=b[0];c.each(["left","top"],function(g,f){if(+b[g]===b[g]){d[g]=b[g];b[g]=f}});a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")}}a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=false;c.each(a,function(g,f){b._setOption(g,f);if(g in k)e=true;if(g in
+l)d[g]=f});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this,e=d.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"):e.removeClass("ui-dialog-disabled");
+break;case "draggable":var g=e.is(":data(draggable)");g&&!b&&e.draggable("destroy");!g&&b&&d._makeDraggable();break;case "position":d._position(b);break;case "resizable":(g=e.is(":data(resizable)"))&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title",d.uiDialogTitlebar).html(""+(b||"&#160;"));break}c.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var a=this.options,b,d,e=
+this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);if(a.height==="auto")if(c.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();a=this.element.css("height","auto").height();e||this.uiDialog.hide();this.element.height(Math.max(a,d))}else this.element.height(Math.max(a.height-b,0));this.uiDialog.is(":data(resizable)")&&
+this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.9",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),create:function(a){if(this.instances.length===
+0){setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(d){if(c(d.target).zIndex()<c.ui.dialog.overlay.maxZ)return false})},1);c(document).bind("keydown.dialog-overlay",function(d){if(a.options.closeOnEscape&&d.keyCode&&d.keyCode===c.ui.keyCode.ESCAPE){a.close(d);d.preventDefault()}});c(window).bind("resize.dialog-overlay",c.ui.dialog.overlay.resize)}var b=(this.oldInstances.pop()||c("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),
+height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;if(c.browser.msie&&c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);
+b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return a<b?c(window).height()+"px":a+"px"}else return c(document).height()+"px"},width:function(){var a,b;if(c.browser.msie&&c.browser.version<7){a=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);b=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);return a<b?c(window).width()+"px":a+"px"}else return c(document).width()+"px"},resize:function(){var a=c([]);c.each(c.ui.dialog.overlay.instances,
+function(){a=a.add(this)});a.css({width:0,height:0}).css({width:c.ui.dialog.overlay.width(),height:c.ui.dialog.overlay.height()})}});c.extend(c.ui.dialog.overlay.prototype,{destroy:function(){c.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.draggable.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.draggable.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.draggable.js	(revision 17487)
@@ -0,0 +1,50 @@
+/*
+ * jQuery UI Draggable 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Draggables
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.mouse.js
+ *	jquery.ui.widget.js
+ */
+(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
+"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b=
+this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;return true},_mouseStart:function(a){var b=this.options;this.helper=this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-
+this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();
+d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);return true},_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||
+this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b=false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&
+this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle||!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==
+a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone():this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||
+0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],
+this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-
+(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment==
+"parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[(a.containment=="document"?0:d(window).scrollLeft())-this.offset.relative.left-this.offset.parent.left,(a.containment=="document"?0:d(window).scrollTop())-this.offset.relative.top-this.offset.parent.top,(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?
+0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){var b=d(a.containment)[0];if(b){a=d(a.containment).offset();var c=d(b).css("overflow")!="hidden";this.containment=[a.left+(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0)-this.margins.left,a.top+(parseInt(d(b).css("borderTopWidth"),
+10)||0)+(parseInt(d(b).css("paddingTop"),10)||0)-this.margins.top,a.left+(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,a.top+(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}}else if(a.containment.constructor==
+Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():
+f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,g=a.pageY;
+if(this.originalPosition){if(this.containment){if(a.pageX-this.offset.click.left<this.containment[0])e=this.containment[0]+this.offset.click.left;if(a.pageY-this.offset.click.top<this.containment[1])g=this.containment[1]+this.offset.click.top;if(a.pageX-this.offset.click.left>this.containment[2])e=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g-this.originalPageY)/
+b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.top<this.containment[1]||g-this.offset.click.top>this.containment[3])?g:!(g-this.offset.click.top<this.containment[1])?g-b.grid[1]:g+b.grid[1]:g;e=this.originalPageX+Math.round((e-this.originalPageX)/b.grid[0])*b.grid[0];e=this.containment?!(e-this.offset.click.left<this.containment[0]||e-this.offset.click.left>this.containment[2])?e:!(e-this.offset.click.left<this.containment[0])?e-b.grid[0]:e+b.grid[0]:e}}return{top:g-this.offset.click.top-
+this.offset.relative.top-this.offset.parent.top+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop()),left:e-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=
+this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(a,b,c){c=c||this._uiHash();d.ui.plugin.call(this,a,[b,c]);if(a=="drag")this.positionAbs=this._convertPositionTo("absolute");return d.Widget.prototype._trigger.call(this,a,b,c)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});d.extend(d.ui.draggable,{version:"1.8.9"});
+d.ui.plugin.add("draggable","connectToSortable",{start:function(a,b){var c=d(this).data("draggable"),f=c.options,e=d.extend({},b,{item:c.element});c.sortables=[];d(f.connectToSortable).each(function(){var g=d.data(this,"sortable");if(g&&!g.options.disabled){c.sortables.push({instance:g,shouldRevert:g.options.revert});g._refreshItems();g._trigger("activate",a,e)}})},stop:function(a,b){var c=d(this).data("draggable"),f=d.extend({},b,{item:c.element});d.each(c.sortables,function(){if(this.instance.isOver){this.instance.isOver=
+0;c.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(a);this.instance.options.helper=this.instance.options._helper;c.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",a,f)}})},drag:function(a,b){var c=d(this).data("draggable"),f=this;d.each(c.sortables,function(){this.instance.positionAbs=
+c.positionAbs;this.instance.helperProportions=c.helperProportions;this.instance.offset.click=c.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=d(f).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return b.helper[0]};a.target=this.instance.currentItem[0];this.instance._mouseCapture(a,
+true);this.instance._mouseStart(a,true,true);this.instance.offset.click.top=c.offset.click.top;this.instance.offset.click.left=c.offset.click.left;this.instance.offset.parent.left-=c.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=c.offset.parent.top-this.instance.offset.parent.top;c._trigger("toSortable",a);c.dropped=this.instance.element;c.currentItem=c.element;this.instance.fromOutside=c}this.instance.currentItem&&this.instance._mouseDrag(a)}else if(this.instance.isOver){this.instance.isOver=
+0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",a,this.instance._uiHash(this.instance));this.instance._mouseStop(a,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder&&this.instance.placeholder.remove();c._trigger("fromSortable",a);c.dropped=false}})}});d.ui.plugin.add("draggable","cursor",{start:function(){var a=d("body"),b=d(this).data("draggable").options;if(a.css("cursor"))b._cursor=
+a.css("cursor");a.css("cursor",b.cursor)},stop:function(){var a=d(this).data("draggable").options;a._cursor&&d("body").css("cursor",a._cursor)}});d.ui.plugin.add("draggable","iframeFix",{start:function(){var a=d(this).data("draggable").options;d(a.iframeFix===true?"iframe":a.iframeFix).each(function(){d('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")})},
+stop:function(){d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});d.ui.plugin.add("draggable","opacity",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("opacity"))b._opacity=a.css("opacity");a.css("opacity",b.opacity)},stop:function(a,b){a=d(this).data("draggable").options;a._opacity&&d(b.helper).css("opacity",a._opacity)}});d.ui.plugin.add("draggable","scroll",{start:function(){var a=d(this).data("draggable");if(a.scrollParent[0]!=
+document&&a.scrollParent[0].tagName!="HTML")a.overflowOffset=a.scrollParent.offset()},drag:function(a){var b=d(this).data("draggable"),c=b.options,f=false;if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){if(!c.axis||c.axis!="x")if(b.overflowOffset.top+b.scrollParent[0].offsetHeight-a.pageY<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop+c.scrollSpeed;else if(a.pageY-b.overflowOffset.top<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop-
+c.scrollSpeed;if(!c.axis||c.axis!="y")if(b.overflowOffset.left+b.scrollParent[0].offsetWidth-a.pageX<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft+c.scrollSpeed;else if(a.pageX-b.overflowOffset.left<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft-c.scrollSpeed}else{if(!c.axis||c.axis!="x")if(a.pageY-d(document).scrollTop()<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()-c.scrollSpeed);else if(d(window).height()-
+(a.pageY-d(document).scrollTop())<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()+c.scrollSpeed);if(!c.axis||c.axis!="y")if(a.pageX-d(document).scrollLeft()<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()-c.scrollSpeed);else if(d(window).width()-(a.pageX-d(document).scrollLeft())<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()+c.scrollSpeed)}f!==false&&d.ui.ddmanager&&!c.dropBehaviour&&d.ui.ddmanager.prepareOffsets(b,a)}});d.ui.plugin.add("draggable",
+"snap",{start:function(){var a=d(this).data("draggable"),b=a.options;a.snapElements=[];d(b.snap.constructor!=String?b.snap.items||":data(draggable)":b.snap).each(function(){var c=d(this),f=c.offset();this!=a.element[0]&&a.snapElements.push({item:this,width:c.outerWidth(),height:c.outerHeight(),top:f.top,left:f.left})})},drag:function(a,b){for(var c=d(this).data("draggable"),f=c.options,e=f.snapTolerance,g=b.offset.left,n=g+c.helperProportions.width,m=b.offset.top,o=m+c.helperProportions.height,h=
+c.snapElements.length-1;h>=0;h--){var i=c.snapElements[h].left,k=i+c.snapElements[h].width,j=c.snapElements[h].top,l=j+c.snapElements[h].height;if(i-e<g&&g<k+e&&j-e<m&&m<l+e||i-e<g&&g<k+e&&j-e<o&&o<l+e||i-e<n&&n<k+e&&j-e<m&&m<l+e||i-e<n&&n<k+e&&j-e<o&&o<l+e){if(f.snapMode!="inner"){var p=Math.abs(j-o)<=e,q=Math.abs(l-m)<=e,r=Math.abs(i-n)<=e,s=Math.abs(k-g)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:j-c.helperProportions.height,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",
+{top:l,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:i-c.helperProportions.width}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:k}).left-c.margins.left}var t=p||q||r||s;if(f.snapMode!="outer"){p=Math.abs(j-m)<=e;q=Math.abs(l-o)<=e;r=Math.abs(i-g)<=e;s=Math.abs(k-n)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:j,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",{top:l-c.helperProportions.height,
+left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:i}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:k-c.helperProportions.width}).left-c.margins.left}if(!c.snapElements[h].snapping&&(p||q||r||s||t))c.options.snap.snap&&c.options.snap.snap.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[h].item}));c.snapElements[h].snapping=p||q||r||s||t}else{c.snapElements[h].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,
+a,d.extend(c._uiHash(),{snapItem:c.snapElements[h].item}));c.snapElements[h].snapping=false}}}});d.ui.plugin.add("draggable","stack",{start:function(){var a=d(this).data("draggable").options;a=d.makeArray(d(a.stack)).sort(function(c,f){return(parseInt(d(c).css("zIndex"),10)||0)-(parseInt(d(f).css("zIndex"),10)||0)});if(a.length){var b=parseInt(a[0].style.zIndex)||0;d(a).each(function(c){this.style.zIndex=b+c});this[0].style.zIndex=b+a.length}}});d.ui.plugin.add("draggable","zIndex",{start:function(a,
+b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("zIndex"))b._zIndex=a.css("zIndex");a.css("zIndex",b.zIndex)},stop:function(a,b){a=d(this).data("draggable").options;a._zIndex&&d(b.helper).css("zIndex",a._zIndex)}})})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.droppable.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.droppable.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.droppable.js	(revision 17487)
@@ -0,0 +1,26 @@
+/*
+ * jQuery UI Droppable 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Droppables
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.widget.js
+ *	jquery.ui.mouse.js
+ *	jquery.ui.draggable.js
+ */
+(function(d){d.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:false,addClasses:true,greedy:false,hoverClass:false,scope:"default",tolerance:"intersect"},_create:function(){var a=this.options,b=a.accept;this.isover=0;this.isout=1;this.accept=d.isFunction(b)?b:function(c){return c.is(b)};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};d.ui.ddmanager.droppables[a.scope]=d.ui.ddmanager.droppables[a.scope]||[];d.ui.ddmanager.droppables[a.scope].push(this);
+a.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){for(var a=d.ui.ddmanager.droppables[this.options.scope],b=0;b<a.length;b++)a[b]==this&&a.splice(b,1);this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable");return this},_setOption:function(a,b){if(a=="accept")this.accept=d.isFunction(b)?b:function(c){return c.is(b)};d.Widget.prototype._setOption.apply(this,arguments)},_activate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&
+this.element.addClass(this.options.activeClass);b&&this._trigger("activate",a,this.ui(b))},_deactivate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass);b&&this._trigger("deactivate",a,this.ui(b))},_over:function(a){var b=d.ui.ddmanager.current;if(!(!b||(b.currentItem||b.element)[0]==this.element[0]))if(this.accept.call(this.element[0],b.currentItem||b.element)){this.options.hoverClass&&this.element.addClass(this.options.hoverClass);
+this._trigger("over",a,this.ui(b))}},_out:function(a){var b=d.ui.ddmanager.current;if(!(!b||(b.currentItem||b.element)[0]==this.element[0]))if(this.accept.call(this.element[0],b.currentItem||b.element)){this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("out",a,this.ui(b))}},_drop:function(a,b){var c=b||d.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return false;var e=false;this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var g=
+d.data(this,"droppable");if(g.options.greedy&&!g.options.disabled&&g.options.scope==c.options.scope&&g.accept.call(g.element[0],c.currentItem||c.element)&&d.ui.intersect(c,d.extend(g,{offset:g.element.offset()}),g.options.tolerance)){e=true;return false}});if(e)return false;if(this.accept.call(this.element[0],c.currentItem||c.element)){this.options.activeClass&&this.element.removeClass(this.options.activeClass);this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("drop",
+a,this.ui(c));return this.element}return false},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}});d.extend(d.ui.droppable,{version:"1.8.9"});d.ui.intersect=function(a,b,c){if(!b.offset)return false;var e=(a.positionAbs||a.position.absolute).left,g=e+a.helperProportions.width,f=(a.positionAbs||a.position.absolute).top,h=f+a.helperProportions.height,i=b.offset.left,k=i+b.proportions.width,j=b.offset.top,l=j+b.proportions.height;
+switch(c){case "fit":return i<=e&&g<=k&&j<=f&&h<=l;case "intersect":return i<e+a.helperProportions.width/2&&g-a.helperProportions.width/2<k&&j<f+a.helperProportions.height/2&&h-a.helperProportions.height/2<l;case "pointer":return d.ui.isOver((a.positionAbs||a.position.absolute).top+(a.clickOffset||a.offset.click).top,(a.positionAbs||a.position.absolute).left+(a.clickOffset||a.offset.click).left,j,i,b.proportions.height,b.proportions.width);case "touch":return(f>=j&&f<=l||h>=j&&h<=l||f<j&&h>l)&&(e>=
+i&&e<=k||g>=i&&g<=k||e<i&&g>k);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f<c.length;f++)if(!(c[f].options.disabled||a&&!c[f].accept.call(c[f].element[0],a.currentItem||a.element))){for(var h=0;h<g.length;h++)if(g[h]==c[f].element[0]){c[f].proportions.height=0;continue a}c[f].visible=c[f].element.css("display")!=
+"none";if(c[f].visible){c[f].offset=c[f].element.offset();c[f].proportions={width:c[f].element[0].offsetWidth,height:c[f].element[0].offsetHeight};e=="mousedown"&&c[f]._activate.call(c[f],b)}}},drop:function(a,b){var c=false;d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(this.options){if(!this.options.disabled&&this.visible&&d.ui.intersect(a,this,this.options.tolerance))c=c||this._drop.call(this,b);if(!this.options.disabled&&this.visible&&this.accept.call(this.element[0],a.currentItem||
+a.element)){this.isout=1;this.isover=0;this._deactivate.call(this,b)}}});return c},drag:function(a,b){a.options.refreshPositions&&d.ui.ddmanager.prepareOffsets(a,b);d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(!(this.options.disabled||this.greedyChild||!this.visible)){var c=d.ui.intersect(a,this,this.options.tolerance);if(c=!c&&this.isover==1?"isout":c&&this.isover==0?"isover":null){var e;if(this.options.greedy){var g=this.element.parents(":data(droppable):eq(0)");if(g.length){e=
+d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.isover=0;e.isout=1;e._out.call(e,b)}this[c]=1;this[c=="isout"?"isover":"isout"]=0;this[c=="isover"?"_over":"_out"].call(this,b);if(e&&c=="isout"){e.isout=0;e.isover=1;e._over.call(e,b)}}}})}}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.mouse.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.mouse.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.mouse.js	(revision 17487)
@@ -0,0 +1,17 @@
+/*!
+ * jQuery UI Mouse 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Mouse
+ *
+ * Depends:
+ *	jquery.ui.widget.js
+ */
+(function(c){c.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(b){return a._mouseDown(b)}).bind("click."+this.widgetName,function(b){if(true===c.data(b.target,a.widgetName+".preventClickEvent")){c.removeData(b.target,a.widgetName+".preventClickEvent");b.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(a){a.originalEvent=
+a.originalEvent||{};if(!a.originalEvent.mouseHandled){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var b=this,e=a.which==1,f=typeof this.options.cancel=="string"?c(a.target).parents().add(a.target).filter(this.options.cancel).length:false;if(!e||f||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){b.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=
+this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault();return true}}this._mouseMoveDelegate=function(d){return b._mouseMove(d)};this._mouseUpDelegate=function(d){return b._mouseUp(d)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return a.originalEvent.mouseHandled=true}},_mouseMove:function(a){if(c.browser.msie&&!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);
+return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;a.target==this._mouseDownEvent.target&&c.data(a.target,this.widgetName+".preventClickEvent",
+true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.position.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.position.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.position.js	(revision 17487)
@@ -0,0 +1,16 @@
+/*
+ * jQuery UI Position 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Position
+ */
+(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
+left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
+k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
+m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
+d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
+a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
+g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.resizable.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.resizable.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.resizable.js	(revision 17487)
@@ -0,0 +1,47 @@
+/*
+ * jQuery UI Resizable 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Resizables
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.mouse.js
+ *	jquery.ui.widget.js
+ */
+(function(e){e.widget("ui.resizable",e.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1E3},_create:function(){var b=this,a=this.options;this.element.addClass("ui-resizable");e.extend(this,{_aspectRatio:!!a.aspectRatio,aspectRatio:a.aspectRatio,originalElement:this.element,
+_proportionallyResizeElements:[],_helper:a.helper||a.ghost||a.animate?a.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){/relative/.test(this.element.css("position"))&&e.browser.opera&&this.element.css({position:"relative",top:"auto",left:"auto"});this.element.wrap(e('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),
+top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=
+this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!e(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",
+nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var d=0;d<c.length;d++){var f=e.trim(c[d]),g=e('<div class="ui-resizable-handle '+("ui-resizable-"+f)+'"></div>');/sw|se|ne|nw/.test(f)&&g.css({zIndex:++a.zIndex});"se"==f&&g.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(g)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor==
+String)this.handles[i]=e(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=e(this.handles[i],this.element),k=0;k=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,k);this._proportionallyResize()}e(this.handles[i])}};this._renderAxis(this.element);this._handles=e(".ui-resizable-handle",this.element).disableSelection();
+this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();e(this.element).addClass("ui-resizable-autohide").hover(function(){e(this).removeClass("ui-resizable-autohide");b._handles.show()},function(){if(!b.resizing){e(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(c){e(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};
+if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a=false;for(var c in this.handles)if(e(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(),
+d=this.element;this.resizing=true;this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:c.top,left:c.left});e.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"});this._renderProxy();c=m(this.helper.css("left"));var f=m(this.helper.css("top"));if(a.containment){c+=e(a.containment).scrollLeft()||0;f+=e(a.containment).scrollTop()||0}this.offset=
+this.helper.offset();this.position={left:c,top:f};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:c,top:f};this.sizeDiff={width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio:
+this.originalSize.width/this.originalSize.height||1;a=e(".ui-resizable-"+this.axis).css("cursor");e("body").css("cursor",a=="auto"?this.axis+"-resize":a);d.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,d=this._change[this.axis];if(!d)return false;c=d.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize",
+b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false},_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var d=this._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName);d=f&&e.ui.hasScroll(d[0],"left")?0:c.sizeDiff.height;
+f={width:c.size.width-(f?0:c.sizeDiff.width),height:c.size.height-d};d=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var g=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(e.extend(f,{top:g,left:d}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}e("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",
+b);this._helper&&this.helper.remove();return false},_updateCache:function(b){this.offset=this.helper.offset();if(l(b.left))this.position.left=b.left;if(l(b.top))this.position.top=b.top;if(l(b.height))this.size.height=b.height;if(l(b.width))this.size.width=b.width},_updateRatio:function(b){var a=this.position,c=this.size,d=this.axis;if(b.height)b.width=c.height*this.aspectRatio;else if(b.width)b.height=c.width/this.aspectRatio;if(d=="sw"){b.left=a.left+(c.width-b.width);b.top=null}if(d=="nw"){b.top=
+a.top+(c.height-b.height);b.left=a.left+(c.width-b.width)}return b},_respectSize:function(b){var a=this.options,c=this.axis,d=l(b.width)&&a.maxWidth&&a.maxWidth<b.width,f=l(b.height)&&a.maxHeight&&a.maxHeight<b.height,g=l(b.width)&&a.minWidth&&a.minWidth>b.width,h=l(b.height)&&a.minHeight&&a.minHeight>b.height;if(g)b.width=a.minWidth;if(h)b.height=a.minHeight;if(d)b.width=a.maxWidth;if(f)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height,
+k=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(g&&k)b.left=i-a.minWidth;if(d&&k)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(f&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left=null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a<this._proportionallyResizeElements.length;a++){var c=this._proportionallyResizeElements[a];if(!this.borderDif){var d=[c.css("borderTopWidth"),
+c.css("borderRightWidth"),c.css("borderBottomWidth"),c.css("borderLeftWidth")],f=[c.css("paddingTop"),c.css("paddingRight"),c.css("paddingBottom"),c.css("paddingLeft")];this.borderDif=e.map(d,function(g,h){g=parseInt(g,10)||0;h=parseInt(f[h],10)||0;return g+h})}e.browser.msie&&(e(b).is(":hidden")||e(b).parents(":hidden").length)||c.css({height:b.height()-this.borderDif[0]-this.borderDif[2]||0,width:b.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var b=this.options;this.elementOffset=
+this.element.offset();if(this._helper){this.helper=this.helper||e('<div style="overflow:hidden;"></div>');var a=e.browser.msie&&e.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+
+a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+c}},se:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return e.extend(this._change.n.apply(this,
+arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){e.ui.plugin.call(this,b,[a,this.ui()]);b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});e.extend(e.ui.resizable,
+{version:"1.8.9"});e.ui.plugin.add("resizable","alsoResize",{start:function(){var b=e(this).data("resizable").options,a=function(c){e(c).each(function(){var d=e(this);d.data("resizable-alsoresize",{width:parseInt(d.width(),10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else e.each(b.alsoResize,
+function(c){a(c)});else a(b.alsoResize)},resize:function(b,a){var c=e(this).data("resizable");b=c.options;var d=c.originalSize,f=c.originalPosition,g={height:c.size.height-d.height||0,width:c.size.width-d.width||0,top:c.position.top-f.top||0,left:c.position.left-f.left||0},h=function(i,j){e(i).each(function(){var k=e(this),q=e(this).data("resizable-alsoresize"),p={},r=j&&j.length?j:k.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(n,o){if((n=
+(q[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(e.browser.opera&&/relative/.test(k.css("position"))){c._revertToRelativePosition=true;k.css({position:"absolute",top:"auto",left:"auto"})}k.css(p)})};typeof b.alsoResize=="object"&&!b.alsoResize.nodeType?e.each(b.alsoResize,function(i,j){h(i,j)}):h(b.alsoResize)},stop:function(){var b=e(this).data("resizable"),a=b.options,c=function(d){e(d).each(function(){var f=e(this);f.css({position:f.data("resizable-alsoresize").position})})};if(b._revertToRelativePosition){b._revertToRelativePosition=
+false;typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?e.each(a.alsoResize,function(d){c(d)}):c(a.alsoResize)}e(this).removeData("resizable-alsoresize")}});e.ui.plugin.add("resizable","animate",{stop:function(b){var a=e(this).data("resizable"),c=a.options,d=a._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName),g=f&&e.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-g};g=parseInt(a.element.css("left"),10)+(a.position.left-
+a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(e.extend(f,h&&g?{top:h,left:g}:{}),{duration:c.animateDuration,easing:c.animateEasing,step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};d&&d.length&&e(d[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize",
+b)}})}});e.ui.plugin.add("resizable","containment",{start:function(){var b=e(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof e?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement=e(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}}else{var d=e(a),f=[];e(["Top",
+"Right","Left","Bottom"]).each(function(i,j){f[i]=m(d.css("padding"+j))});b.containerOffset=d.offset();b.containerPosition=d.position();b.containerSize={height:d.innerHeight()-f[3],width:d.innerWidth()-f[1]};c=b.containerOffset;var g=b.containerSize.height,h=b.containerSize.width;h=e.ui.hasScroll(a,"left")?a.scrollWidth:h;g=e.ui.hasScroll(a)?a.scrollHeight:g;b.parentData={element:a,left:c.left,top:c.top,width:h,height:g}}}},resize:function(b){var a=e(this).data("resizable"),c=a.options,d=a.containerOffset,
+f=a.position;b=a._aspectRatio||b.shiftKey;var g={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))g=d;if(f.left<(a._helper?d.left:0)){a.size.width+=a._helper?a.position.left-d.left:a.position.left-g.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?d.left:0}if(f.top<(a._helper?d.top:0)){a.size.height+=a._helper?a.position.top-d.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?d.top:0}a.offset.left=
+a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-g.left:a.offset.left-g.left)+a.sizeDiff.width);d=Math.abs((a._helper?a.offset.top-g.top:a.offset.top-d.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);g=/relative|absolute/.test(a.containerElement.css("position"));if(f&&g)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(d+
+a.size.height>=a.parentData.height){a.size.height=a.parentData.height-d;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=e(this).data("resizable"),a=b.options,c=b.containerOffset,d=b.containerPosition,f=b.containerElement,g=e(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width;g=g.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g});b._helper&&!a.animate&&/static/.test(f.css("position"))&&
+e(this).css({left:h.left-d.left-c.left,width:i,height:g})}});e.ui.plugin.add("resizable","ghost",{start:function(){var b=e(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25,display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=e(this).data("resizable");b.ghost&&b.ghost.css({position:"relative",
+height:b.size.height,width:b.size.width})},stop:function(){var b=e(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});e.ui.plugin.add("resizable","grid",{resize:function(){var b=e(this).data("resizable"),a=b.options,c=b.size,d=b.originalSize,f=b.originalPosition,g=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-d.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-d.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(g)){b.size.width=
+d.width+h;b.size.height=d.height+a}else if(/^(ne)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}else{if(/^(sw)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}b.position.left=f.left-h}}});var m=function(b){return parseInt(b,10)||0},l=function(b){return!isNaN(parseInt(b,10))}})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.selectable.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.selectable.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.selectable.js	(revision 17487)
@@ -0,0 +1,22 @@
+/*
+ * jQuery UI Selectable 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Selectables
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.mouse.js
+ *	jquery.ui.widget.js
+ */
+(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"),
+selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("<div class='ui-selectable-helper'></div>")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX,
+c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting",
+c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d=
+this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.right<b||a.top>i||a.bottom<g);else if(d.tolerance=="fit")k=a.left>b&&a.right<h&&a.top>g&&a.bottom<i;if(k){if(a.selected){a.$element.removeClass("ui-selected");a.selected=false}if(a.unselecting){a.$element.removeClass("ui-unselecting");
+a.unselecting=false}if(!a.selecting){a.$element.addClass("ui-selecting");a.selecting=true;f._trigger("selecting",c,{selecting:a.element})}}else{if(a.selecting)if(c.metaKey&&a.startselected){a.$element.removeClass("ui-selecting");a.selecting=false;a.$element.addClass("ui-selected");a.selected=true}else{a.$element.removeClass("ui-selecting");a.selecting=false;if(a.startselected){a.$element.addClass("ui-unselecting");a.unselecting=true}f._trigger("unselecting",c,{unselecting:a.element})}if(a.selected)if(!c.metaKey&&
+!a.startselected){a.$element.removeClass("ui-selected");a.selected=false;a.$element.addClass("ui-unselecting");a.unselecting=true;f._trigger("unselecting",c,{unselecting:a.element})}}}});return false}},_mouseStop:function(c){var f=this;this.dragged=false;e(".ui-unselecting",this.element[0]).each(function(){var d=e.data(this,"selectable-item");d.$element.removeClass("ui-unselecting");d.unselecting=false;d.startselected=false;f._trigger("unselected",c,{unselected:d.element})});e(".ui-selecting",this.element[0]).each(function(){var d=
+e.data(this,"selectable-item");d.$element.removeClass("ui-selecting").addClass("ui-selected");d.selecting=false;d.selected=true;d.startselected=true;f._trigger("selected",c,{selected:d.element})});this._trigger("stop",c);this.helper.remove();return false}});e.extend(e.ui.selectable,{version:"1.8.9"})})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.sortable.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.sortable.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.sortable.js	(revision 17487)
@@ -0,0 +1,60 @@
+/*
+ * jQuery UI Sortable 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Sortables
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.mouse.js
+ *	jquery.ui.widget.js
+ */
+(function(d){d.widget("ui.sortable",d.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:false,connectWith:false,containment:false,cursor:"auto",cursorAt:false,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:"> *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){this.containerCache={};this.element.addClass("ui-sortable");
+this.refresh();this.floating=this.items.length?/left|right/.test(this.items[0].item.css("float")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a==="disabled"){this.options[a]=b;this.widget()[b?"addClass":"removeClass"]("ui-sortable-disabled")}else d.Widget.prototype._setOption.apply(this,
+arguments)},_mouseCapture:function(a,b){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(a);var c=null,e=this;d(a.target).parents().each(function(){if(d.data(this,"sortable-item")==e){c=d(this);return false}});if(d.data(a.target,"sortable-item")==e)c=d(a.target);if(!c)return false;if(this.options.handle&&!b){var f=false;d(this.options.handle,c).find("*").andSelf().each(function(){if(this==a.target)f=true});if(!f)return false}this.currentItem=
+c;this._removeCurrentsFromItems();return true},_mouseStart:function(a,b,c){b=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");d.extend(this.offset,
+{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();b.containment&&this._setContainment();
+if(b.cursor){if(d("body").css("cursor"))this._storedCursor=d("body").css("cursor");d("body").css("cursor",b.cursor)}if(b.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",b.opacity)}if(b.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",b.zIndex)}if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start",
+a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!c)for(c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("activate",a,e._uiHash(this));if(d.ui.ddmanager)d.ui.ddmanager.current=this;d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a);return true},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");
+if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var b=this.options,c=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageY<b.scrollSensitivity)this.scrollParent[0].scrollTop=c=this.scrollParent[0].scrollTop+b.scrollSpeed;else if(a.pageY-this.overflowOffset.top<b.scrollSensitivity)this.scrollParent[0].scrollTop=c=this.scrollParent[0].scrollTop-b.scrollSpeed;if(this.overflowOffset.left+
+this.scrollParent[0].offsetWidth-a.pageX<b.scrollSensitivity)this.scrollParent[0].scrollLeft=c=this.scrollParent[0].scrollLeft+b.scrollSpeed;else if(a.pageX-this.overflowOffset.left<b.scrollSensitivity)this.scrollParent[0].scrollLeft=c=this.scrollParent[0].scrollLeft-b.scrollSpeed}else{if(a.pageY-d(document).scrollTop()<b.scrollSensitivity)c=d(document).scrollTop(d(document).scrollTop()-b.scrollSpeed);else if(d(window).height()-(a.pageY-d(document).scrollTop())<b.scrollSensitivity)c=d(document).scrollTop(d(document).scrollTop()+
+b.scrollSpeed);if(a.pageX-d(document).scrollLeft()<b.scrollSensitivity)c=d(document).scrollLeft(d(document).scrollLeft()-b.scrollSpeed);else if(d(window).width()-(a.pageX-d(document).scrollLeft())<b.scrollSensitivity)c=d(document).scrollLeft(d(document).scrollLeft()+b.scrollSpeed)}c!==false&&d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+
+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(b=this.items.length-1;b>=0;b--){c=this.items[b];var e=c.item[0],f=this._intersectsWithPointer(c);if(f)if(e!=this.currentItem[0]&&this.placeholder[f==1?"next":"prev"]()[0]!=e&&!d.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!d.ui.contains(this.element[0],e):true)){this.direction=f==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(c))this._rearrange(a,
+c);else break;this._trigger("change",a,this._uiHash());break}}this._contactContainers(a);d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);this._trigger("sort",a,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(a,b){if(a){d.ui.ddmanager&&!this.options.dropBehaviour&&d.ui.ddmanager.drop(this,a);if(this.options.revert){var c=this;b=c.placeholder.offset();c.reverting=true;d(this.helper).animate({left:b.left-this.offset.parent.left-c.margins.left+(this.offsetParent[0]==
+document.body?0:this.offsetParent[0].scrollLeft),top:b.top-this.offset.parent.top-c.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){c._clear(a)})}else this._clear(a,b);return false}},cancel:function(){var a=this;if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var b=this.containers.length-
+1;b>=0;b--){this.containers[b]._trigger("deactivate",null,a._uiHash(this));if(this.containers[b].containerCache.over){this.containers[b]._trigger("out",null,a._uiHash(this));this.containers[b].containerCache.over=0}}}if(this.placeholder){this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();d.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null});
+this.domPosition.prev?d(this.domPosition.prev).after(this.currentItem):d(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};d(b).each(function(){var e=(d(a.item||this).attr(a.attribute||"id")||"").match(a.expression||/(.+)[-=_](.+)/);if(e)c.push((a.key||e[1]+"[]")+"="+(a.key&&a.expression?e[1]:e[2]))});!c.length&&a.key&&c.push(a.key+"=");return c.join("&")},toArray:function(a){var b=this._getItemsAsjQuery(a&&
+a.connected),c=[];a=a||{};b.each(function(){c.push(d(a.item||this).attr(a.attribute||"id")||"")});return c},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,e=this.positionAbs.top,f=e+this.helperProportions.height,g=a.left,h=g+a.width,i=a.top,k=i+a.height,j=this.offset.click.top,l=this.offset.click.left;j=e+j>i&&e+j<k&&b+l>g&&b+l<h;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?
+"width":"height"]>a[this.floating?"width":"height"]?j:g<b+this.helperProportions.width/2&&c-this.helperProportions.width/2<h&&i<e+this.helperProportions.height/2&&f-this.helperProportions.height/2<k},_intersectsWithPointer:function(a){var b=d.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,a.top,a.height);a=d.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,a.left,a.width);b=b&&a;a=this._getDragVerticalDirection();var c=this._getDragHorizontalDirection();if(!b)return false;return this.floating?
+c&&c=="right"||a=="down"?2:1:a&&(a=="down"?2:1)},_intersectsWithSides:function(a){var b=d.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,a.top+a.height/2,a.height);a=d.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,a.left+a.width/2,a.width);var c=this._getDragVerticalDirection(),e=this._getDragHorizontalDirection();return this.floating&&e?e=="right"&&a||e=="left"&&!a:c&&(c=="down"&&b||c=="up"&&!b)},_getDragVerticalDirection:function(){var a=this.positionAbs.top-this.lastPositionAbs.top;
+return a!=0&&(a>0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a);this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(a){var b=[],c=[],e=this._connectWith();if(e&&a)for(a=e.length-1;a>=0;a--)for(var f=d(e[a]),g=f.length-1;g>=0;g--){var h=
+d.data(f[g],"sortable");if(h&&h!=this&&!h.options.disabled)c.push([d.isFunction(h.options.items)?h.options.items.call(h.element):d(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}c.push([d.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):d(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(a=c.length-1;a>=0;a--)c[a][0].each(function(){b.push(this)});
+return d(b)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),b=0;b<this.items.length;b++)for(var c=0;c<a.length;c++)a[c]==this.items[b].item[0]&&this.items.splice(b,1)},_refreshItems:function(a){this.items=[];this.containers=[this];var b=this.items,c=[[d.isFunction(this.options.items)?this.options.items.call(this.element[0],a,{item:this.currentItem}):d(this.options.items,this.element),this]],e=this._connectWith();if(e)for(var f=e.length-1;f>=0;f--)for(var g=
+d(e[f]),h=g.length-1;h>=0;h--){var i=d.data(g[h],"sortable");if(i&&i!=this&&!i.options.disabled){c.push([d.isFunction(i.options.items)?i.options.items.call(i.element[0],a,{item:this.currentItem}):d(i.options.items,i.element),i]);this.containers.push(i)}}for(f=c.length-1;f>=0;f--){a=c[f][1];e=c[f][0];h=0;for(g=e.length;h<g;h++){i=d(e[h]);i.data("sortable-item",a);b.push({item:i,instance:a,width:0,height:0,left:0,top:0})}}},refreshPositions:function(a){if(this.offsetParent&&this.helper)this.offset.parent=
+this._getParentOffset();for(var b=this.items.length-1;b>=0;b--){var c=this.items[b],e=this.options.toleranceElement?d(this.options.toleranceElement,c.item):c.item;if(!a){c.width=e.outerWidth();c.height=e.outerHeight()}e=e.offset();c.left=e.left;c.top=e.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(b=this.containers.length-1;b>=0;b--){e=this.containers[b].element.offset();this.containers[b].containerCache.left=e.left;this.containers[b].containerCache.top=
+e.top;this.containers[b].containerCache.width=this.containers[b].element.outerWidth();this.containers[b].containerCache.height=this.containers[b].element.outerHeight()}return this},_createPlaceholder:function(a){var b=a||this,c=b.options;if(!c.placeholder||c.placeholder.constructor==String){var e=c.placeholder;c.placeholder={element:function(){var f=d(document.createElement(b.currentItem[0].nodeName)).addClass(e||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];
+if(!e)f.style.visibility="hidden";return f},update:function(f,g){if(!(e&&!c.forcePlaceholderSize)){g.height()||g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10));g.width()||g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||0,10))}}}}b.placeholder=d(c.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder);
+c.placeholder.update(b,b.placeholder)},_contactContainers:function(a){for(var b=null,c=null,e=this.containers.length-1;e>=0;e--)if(!d.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(b&&d.ui.contains(this.containers[e].element[0],b.element[0]))){b=this.containers[e];c=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out",a,this._uiHash(this));this.containers[e].containerCache.over=0}if(b)if(this.containers.length===
+1){this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}else if(this.currentContainer!=this.containers[c]){b=1E4;e=null;for(var f=this.positionAbs[this.containers[c].floating?"left":"top"],g=this.items.length-1;g>=0;g--)if(d.ui.contains(this.containers[c].element[0],this.items[g].item[0])){var h=this.items[g][this.containers[c].floating?"left":"top"];if(Math.abs(h-f)<b){b=Math.abs(h-f);e=this.items[g]}}if(e||this.options.dropOnEmpty){this.currentContainer=
+this.containers[c];e?this._rearrange(a,e,null,true):this._rearrange(a,null,this.containers[c].element,true);this._trigger("change",a,this._uiHash());this.containers[c]._trigger("change",a,this._uiHash(this));this.options.placeholder.update(this.currentContainer,this.placeholder);this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}}},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a,this.currentItem])):
+b.helper=="clone"?this.currentItem.clone():this.currentItem;a.parents("body").length||d(b.appendTo!="parent"?b.appendTo:this.currentItem[0].parentNode)[0].appendChild(a[0]);if(a[0]==this.currentItem[0])this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")};if(a[0].style.width==""||b.forceHelperSize)a.width(this.currentItem.width());if(a[0].style.height==
+""||b.forceHelperSize)a.height(this.currentItem.height());return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=
+this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
+10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions=
+{width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(d(a.containment=="document"?document:window).height()||
+document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)){var b=d(a.containment)[0];a=d(a.containment).offset();var c=d(b).css("overflow")!="hidden";this.containment=[a.left+(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0)-this.margins.left,a.top+(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0)-this.margins.top,a.left+(c?Math.max(b.scrollWidth,
+b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,a.top+(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=
+document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(c[0].tagName);return{top:b.top+this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():
+e?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(c[0].tagName);if(this.cssPosition=="relative"&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0]))this.offset.relative=this._getRelativeOffset();var f=a.pageX,g=a.pageY;if(this.originalPosition){if(this.containment){if(a.pageX-
+this.offset.click.left<this.containment[0])f=this.containment[0]+this.offset.click.left;if(a.pageY-this.offset.click.top<this.containment[1])g=this.containment[1]+this.offset.click.top;if(a.pageX-this.offset.click.left>this.containment[2])f=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g-this.originalPageY)/b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.top<
+this.containment[1]||g-this.offset.click.top>this.containment[3])?g:!(g-this.offset.click.top<this.containment[1])?g-b.grid[1]:g+b.grid[1]:g;f=this.originalPageX+Math.round((f-this.originalPageX)/b.grid[0])*b.grid[0];f=this.containment?!(f-this.offset.click.left<this.containment[0]||f-this.offset.click.left>this.containment[2])?f:!(f-this.offset.click.left<this.containment[0])?f-b.grid[0]:f+b.grid[0]:f}}return{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(d.browser.safari&&
+this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:c.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(d.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:c.scrollLeft())}},_rearrange:function(a,b,c,e){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?b.item[0]:b.item[0].nextSibling);this.counter=
+this.counter?++this.counter:1;var f=this,g=this.counter;window.setTimeout(function(){g==f.counter&&f.refreshPositions(!e)},0)},_clear:function(a,b){this.reverting=false;var c=[];!this._noFinalSort&&this.currentItem[0].parentNode&&this.placeholder.before(this.currentItem);this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var e in this._storedCSS)if(this._storedCSS[e]=="auto"||this._storedCSS[e]=="static")this._storedCSS[e]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();
+this.fromOutside&&!b&&c.push(function(f){this._trigger("receive",f,this._uiHash(this.fromOutside))});if((this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!b)c.push(function(f){this._trigger("update",f,this._uiHash())});if(!d.ui.contains(this.element[0],this.currentItem[0])){b||c.push(function(f){this._trigger("remove",f,this._uiHash())});for(e=this.containers.length-1;e>=0;e--)if(d.ui.contains(this.containers[e].element[0],
+this.currentItem[0])&&!b){c.push(function(f){return function(g){f._trigger("receive",g,this._uiHash(this))}}.call(this,this.containers[e]));c.push(function(f){return function(g){f._trigger("update",g,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){b||c.push(function(f){return function(g){f._trigger("deactivate",g,this._uiHash(this))}}.call(this,this.containers[e]));if(this.containers[e].containerCache.over){c.push(function(f){return function(g){f._trigger("out",
+g,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=0}}this._storedCursor&&d("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!b){this._trigger("beforeStop",a,this._uiHash());for(e=0;e<c.length;e++)c[e].call(this,a);this._trigger("stop",a,this._uiHash())}return false}b||
+this._trigger("beforeStop",a,this._uiHash());this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.helper[0]!=this.currentItem[0]&&this.helper.remove();this.helper=null;if(!b){for(e=0;e<c.length;e++)c[e].call(this,a);this._trigger("stop",a,this._uiHash())}this.fromOutside=false;return true},_trigger:function(){d.Widget.prototype._trigger.apply(this,arguments)===false&&this.cancel()},_uiHash:function(a){var b=a||this;return{helper:b.helper,placeholder:b.placeholder||d([]),position:b.position,
+originalPosition:b.originalPosition,offset:b.positionAbs,item:b.currentItem,sender:a?a.element:null}}});d.extend(d.ui.sortable,{version:"1.8.9"})})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.tabs.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.tabs.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.tabs.js	(revision 17487)
@@ -0,0 +1,35 @@
+/*
+ * jQuery UI Tabs 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Tabs
+ *
+ * Depends:
+ *	jquery.ui.core.js
+ *	jquery.ui.widget.js
+ */
+(function(d,p){function u(){return++v}function w(){return++x}var v=0,x=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading&#8230;</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&&
+e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=
+d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]||
+(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
+this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected=
+this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
+if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));
+this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+
+g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",
+function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")};
+this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected=
+-1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";
+d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=
+d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b,
+e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]);
+j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove();
+if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1<this.anchors.length?1:-1));e.disabled=d.map(d.grep(e.disabled,function(h){return h!=b}),function(h){return h>=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null,
+this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this},
+load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c,
+"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},
+url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.9"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k<a.anchors.length?k:0)},b);j&&j.stopPropagation()});e=a._unrotate||(a._unrotate=!e?function(j){j.clientX&&
+a.rotate(null)}:function(){t=c.selected;h()});if(b){this.element.bind("tabsshow",h);this.anchors.bind(c.event+".tabs",e);h()}else{clearTimeout(a.rotation);this.element.unbind("tabsshow",h);this.anchors.unbind(c.event+".tabs",e);delete this._rotate;delete this._unrotate}return this}})})(jQuery);
Index: /tags/3.1/wp-includes/js/jquery/ui.widget.js
===================================================================
--- /tags/3.1/wp-includes/js/jquery/ui.widget.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/jquery/ui.widget.js	(revision 17487)
@@ -0,0 +1,15 @@
+/*!
+ * jQuery UI Widget 1.8.9
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Widget
+ */
+(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
+a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
+e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
+this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
+widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
+enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
Index: /tags/3.1/wp-includes/js/json2.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/json2.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/json2.dev.js	(revision 17487)
@@ -0,0 +1,481 @@
+/*
+    http://www.JSON.org/json2.js
+    2009-08-17
+
+    Public Domain.
+
+    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+    See http://www.JSON.org/js.html
+
+    This file creates a global JSON object containing two methods: stringify
+    and parse.
+
+        JSON.stringify(value, replacer, space)
+            value       any JavaScript value, usually an object or array.
+
+            replacer    an optional parameter that determines how object
+                        values are stringified for objects. It can be a
+                        function or an array of strings.
+
+            space       an optional parameter that specifies the indentation
+                        of nested structures. If it is omitted, the text will
+                        be packed without extra whitespace. If it is a number,
+                        it will specify the number of spaces to indent at each
+                        level. If it is a string (such as '\t' or '&nbsp;'),
+                        it contains the characters used to indent at each level.
+
+            This method produces a JSON text from a JavaScript value.
+
+            When an object value is found, if the object contains a toJSON
+            method, its toJSON method will be called and the result will be
+            stringified. A toJSON method does not serialize: it returns the
+            value represented by the name/value pair that should be serialized,
+            or undefined if nothing should be serialized. The toJSON method
+            will be passed the key associated with the value, and this will be
+            bound to the value
+
+            For example, this would serialize Dates as ISO strings.
+
+                Date.prototype.toJSON = function (key) {
+                    function f(n) {
+                        // Format integers to have at least two digits.
+                        return n < 10 ? '0' + n : n;
+                    }
+
+                    return this.getUTCFullYear()   + '-' +
+                         f(this.getUTCMonth() + 1) + '-' +
+                         f(this.getUTCDate())      + 'T' +
+                         f(this.getUTCHours())     + ':' +
+                         f(this.getUTCMinutes())   + ':' +
+                         f(this.getUTCSeconds())   + 'Z';
+                };
+
+            You can provide an optional replacer method. It will be passed the
+            key and value of each member, with this bound to the containing
+            object. The value that is returned from your method will be
+            serialized. If your method returns undefined, then the member will
+            be excluded from the serialization.
+
+            If the replacer parameter is an array of strings, then it will be
+            used to select the members to be serialized. It filters the results
+            such that only members with keys listed in the replacer array are
+            stringified.
+
+            Values that do not have JSON representations, such as undefined or
+            functions, will not be serialized. Such values in objects will be
+            dropped; in arrays they will be replaced with null. You can use
+            a replacer function to replace those with JSON values.
+            JSON.stringify(undefined) returns undefined.
+
+            The optional space parameter produces a stringification of the
+            value that is filled with line breaks and indentation to make it
+            easier to read.
+
+            If the space parameter is a non-empty string, then that string will
+            be used for indentation. If the space parameter is a number, then
+            the indentation will be that many spaces.
+
+            Example:
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}]);
+            // text is '["e",{"pluribus":"unum"}]'
+
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+            text = JSON.stringify([new Date()], function (key, value) {
+                return this[key] instanceof Date ?
+                    'Date(' + this[key] + ')' : value;
+            });
+            // text is '["Date(---current time---)"]'
+
+
+        JSON.parse(text, reviver)
+            This method parses a JSON text to produce an object or array.
+            It can throw a SyntaxError exception.
+
+            The optional reviver parameter is a function that can filter and
+            transform the results. It receives each of the keys and values,
+            and its return value is used instead of the original value.
+            If it returns what it received, then the structure is not modified.
+            If it returns undefined then the member is deleted.
+
+            Example:
+
+            // Parse the text. Values that look like ISO date strings will
+            // be converted to Date objects.
+
+            myData = JSON.parse(text, function (key, value) {
+                var a;
+                if (typeof value === 'string') {
+                    a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+                    if (a) {
+                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+                            +a[5], +a[6]));
+                    }
+                }
+                return value;
+            });
+
+            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+                var d;
+                if (typeof value === 'string' &&
+                        value.slice(0, 5) === 'Date(' &&
+                        value.slice(-1) === ')') {
+                    d = new Date(value.slice(5, -1));
+                    if (d) {
+                        return d;
+                    }
+                }
+                return value;
+            });
+
+
+    This is a reference implementation. You are free to copy, modify, or
+    redistribute.
+
+    This code should be minified before deployment.
+    See http://javascript.crockford.com/jsmin.html
+
+    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+    NOT CONTROL.
+*/
+
+/*jslint evil: true */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+    lastIndex, length, parse, prototype, push, replace, slice, stringify,
+    test, toJSON, toString, valueOf
+*/
+
+"use strict";
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+if (!this.JSON) {
+    this.JSON = {};
+}
+
+(function () {
+
+    function f(n) {
+        // Format integers to have at least two digits.
+        return n < 10 ? '0' + n : n;
+    }
+
+    if (typeof Date.prototype.toJSON !== 'function') {
+
+        Date.prototype.toJSON = function (key) {
+
+            return isFinite(this.valueOf()) ?
+                   this.getUTCFullYear()   + '-' +
+                 f(this.getUTCMonth() + 1) + '-' +
+                 f(this.getUTCDate())      + 'T' +
+                 f(this.getUTCHours())     + ':' +
+                 f(this.getUTCMinutes())   + ':' +
+                 f(this.getUTCSeconds())   + 'Z' : null;
+        };
+
+        String.prototype.toJSON =
+        Number.prototype.toJSON =
+        Boolean.prototype.toJSON = function (key) {
+            return this.valueOf();
+        };
+    }
+
+    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+        gap,
+        indent,
+        meta = {    // table of character substitutions
+            '\b': '\\b',
+            '\t': '\\t',
+            '\n': '\\n',
+            '\f': '\\f',
+            '\r': '\\r',
+            '"' : '\\"',
+            '\\': '\\\\'
+        },
+        rep;
+
+
+    function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+        escapable.lastIndex = 0;
+        return escapable.test(string) ?
+            '"' + string.replace(escapable, function (a) {
+                var c = meta[a];
+                return typeof c === 'string' ? c :
+                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+            }) + '"' :
+            '"' + string + '"';
+    }
+
+
+    function str(key, holder) {
+
+// Produce a string from holder[key].
+
+        var i,          // The loop counter.
+            k,          // The member key.
+            v,          // The member value.
+            length,
+            mind = gap,
+            partial,
+            value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+        if (value && typeof value === 'object' &&
+                typeof value.toJSON === 'function') {
+            value = value.toJSON(key);
+        }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+        if (typeof rep === 'function') {
+            value = rep.call(holder, key, value);
+        }
+
+// What happens next depends on the value's type.
+
+        switch (typeof value) {
+        case 'string':
+            return quote(value);
+
+        case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+            return isFinite(value) ? String(value) : 'null';
+
+        case 'boolean':
+        case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+            return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+        case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+            if (!value) {
+                return 'null';
+            }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+            gap += indent;
+            partial = [];
+
+// Is the value an array?
+
+            if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+                length = value.length;
+                for (i = 0; i < length; i += 1) {
+                    partial[i] = str(i, value) || 'null';
+                }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+                v = partial.length === 0 ? '[]' :
+                    gap ? '[\n' + gap +
+                            partial.join(',\n' + gap) + '\n' +
+                                mind + ']' :
+                          '[' + partial.join(',') + ']';
+                gap = mind;
+                return v;
+            }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+            if (rep && typeof rep === 'object') {
+                length = rep.length;
+                for (i = 0; i < length; i += 1) {
+                    k = rep[i];
+                    if (typeof k === 'string') {
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+                for (k in value) {
+                    if (Object.hasOwnProperty.call(value, k)) {
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+            v = partial.length === 0 ? '{}' :
+                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
+                        mind + '}' : '{' + partial.join(',') + '}';
+            gap = mind;
+            return v;
+        }
+    }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+    if (typeof JSON.stringify !== 'function') {
+        JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+            var i;
+            gap = '';
+            indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+            if (typeof space === 'number') {
+                for (i = 0; i < space; i += 1) {
+                    indent += ' ';
+                }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+            } else if (typeof space === 'string') {
+                indent = space;
+            }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+            rep = replacer;
+            if (replacer && typeof replacer !== 'function' &&
+                    (typeof replacer !== 'object' ||
+                     typeof replacer.length !== 'number')) {
+                throw new Error('JSON.stringify');
+            }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+            return str('', {'': value});
+        };
+    }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+    if (typeof JSON.parse !== 'function') {
+        JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+            var j;
+
+            function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+                var k, v, value = holder[key];
+                if (value && typeof value === 'object') {
+                    for (k in value) {
+                        if (Object.hasOwnProperty.call(value, k)) {
+                            v = walk(value, k);
+                            if (v !== undefined) {
+                                value[k] = v;
+                            } else {
+                                delete value[k];
+                            }
+                        }
+                    }
+                }
+                return reviver.call(holder, key, value);
+            }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+            cx.lastIndex = 0;
+            if (cx.test(text)) {
+                text = text.replace(cx, function (a) {
+                    return '\\u' +
+                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+                });
+            }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+            if (/^[\],:{}\s]*$/.
+test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
+replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
+replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+                j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+                return typeof reviver === 'function' ?
+                    walk({'': j}, '') : j;
+            }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+            throw new SyntaxError('JSON.parse');
+        };
+    }
+}());
+
Index: /tags/3.1/wp-includes/js/json2.js
===================================================================
--- /tags/3.1/wp-includes/js/json2.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/json2.js	(revision 17487)
@@ -0,0 +1,1 @@
+"use strict";if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());
Index: /tags/3.1/wp-includes/js/l10n.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/l10n.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/l10n.dev.js	(revision 17487)
@@ -0,0 +1,23 @@
+//Used to ensure that Entities used in L10N strings are correct
+function convertEntities(o) {
+	var c, v;
+	c = function(s) {
+		if (/&[^;]+;/.test(s)) {
+			var e = document.createElement("div");
+			e.innerHTML = s;
+			return !e.firstChild ? s : e.firstChild.nodeValue;
+		}
+		return s;
+	}
+
+	if ( typeof o === 'string' ) {
+		return c(o);
+	} else if ( typeof o === 'object' ) {
+		for (v in o) {
+			if ( typeof o[v] === 'string' ) {
+				o[v] = c(o[v]);
+			}
+		}
+	}
+	return o;
+}
Index: /tags/3.1/wp-includes/js/l10n.js
===================================================================
--- /tags/3.1/wp-includes/js/l10n.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/l10n.js	(revision 17487)
@@ -0,0 +1,1 @@
+function convertEntities(b){var d,a;d=function(c){if(/&[^;]+;/.test(c)){var f=document.createElement("div");f.innerHTML=c;return !f.firstChild?c:f.firstChild.nodeValue}return c};if(typeof b==="string"){return d(b)}else{if(typeof b==="object"){for(a in b){if(typeof b[a]==="string"){b[a]=d(b[a])}}}}return b};
Index: /tags/3.1/wp-includes/js/prototype.js
===================================================================
--- /tags/3.1/wp-includes/js/prototype.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/prototype.js	(revision 17487)
@@ -0,0 +1,4874 @@
+/*  Prototype JavaScript framework, version 1.6.1
+ *  (c) 2005-2009 Sam Stephenson
+ *
+ *  Prototype is freely distributable under the terms of an MIT-style license.
+ *  For details, see the Prototype web site: http://www.prototypejs.org/
+ *
+ *--------------------------------------------------------------------------*/
+
+var Prototype = {
+  Version: '1.6.1',
+
+  Browser: (function(){
+    var ua = navigator.userAgent;
+    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
+    return {
+      IE:             !!window.attachEvent && !isOpera,
+      Opera:          isOpera,
+      WebKit:         ua.indexOf('AppleWebKit/') > -1,
+      Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
+      MobileSafari:   /Apple.*Mobile.*Safari/.test(ua)
+    }
+  })(),
+
+  BrowserFeatures: {
+    XPath: !!document.evaluate,
+    SelectorsAPI: !!document.querySelector,
+    ElementExtensions: (function() {
+      var constructor = window.Element || window.HTMLElement;
+      return !!(constructor && constructor.prototype);
+    })(),
+    SpecificElementExtensions: (function() {
+      if (typeof window.HTMLDivElement !== 'undefined')
+        return true;
+
+      var div = document.createElement('div');
+      var form = document.createElement('form');
+      var isSupported = false;
+
+      if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
+        isSupported = true;
+      }
+
+      div = form = null;
+
+      return isSupported;
+    })()
+  },
+
+  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
+  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
+
+  emptyFunction: function() { },
+  K: function(x) { return x }
+};
+
+if (Prototype.Browser.MobileSafari)
+  Prototype.BrowserFeatures.SpecificElementExtensions = false;
+
+
+var Abstract = { };
+
+
+var Try = {
+  these: function() {
+    var returnValue;
+
+    for (var i = 0, length = arguments.length; i < length; i++) {
+      var lambda = arguments[i];
+      try {
+        returnValue = lambda();
+        break;
+      } catch (e) { }
+    }
+
+    return returnValue;
+  }
+};
+
+/* Based on Alex Arnell's inheritance implementation. */
+
+var Class = (function() {
+  function subclass() {};
+  function create() {
+    var parent = null, properties = $A(arguments);
+    if (Object.isFunction(properties[0]))
+      parent = properties.shift();
+
+    function klass() {
+      this.initialize.apply(this, arguments);
+    }
+
+    Object.extend(klass, Class.Methods);
+    klass.superclass = parent;
+    klass.subclasses = [];
+
+    if (parent) {
+      subclass.prototype = parent.prototype;
+      klass.prototype = new subclass;
+      parent.subclasses.push(klass);
+    }
+
+    for (var i = 0; i < properties.length; i++)
+      klass.addMethods(properties[i]);
+
+    if (!klass.prototype.initialize)
+      klass.prototype.initialize = Prototype.emptyFunction;
+
+    klass.prototype.constructor = klass;
+    return klass;
+  }
+
+  function addMethods(source) {
+    var ancestor   = this.superclass && this.superclass.prototype;
+    var properties = Object.keys(source);
+
+    if (!Object.keys({ toString: true }).length) {
+      if (source.toString != Object.prototype.toString)
+        properties.push("toString");
+      if (source.valueOf != Object.prototype.valueOf)
+        properties.push("valueOf");
+    }
+
+    for (var i = 0, length = properties.length; i < length; i++) {
+      var property = properties[i], value = source[property];
+      if (ancestor && Object.isFunction(value) &&
+          value.argumentNames().first() == "$super") {
+        var method = value;
+        value = (function(m) {
+          return function() { return ancestor[m].apply(this, arguments); };
+        })(property).wrap(method);
+
+        value.valueOf = method.valueOf.bind(method);
+        value.toString = method.toString.bind(method);
+      }
+      this.prototype[property] = value;
+    }
+
+    return this;
+  }
+
+  return {
+    create: create,
+    Methods: {
+      addMethods: addMethods
+    }
+  };
+})();
+(function() {
+
+  var _toString = Object.prototype.toString;
+
+  function extend(destination, source) {
+    for (var property in source)
+      destination[property] = source[property];
+    return destination;
+  }
+
+  function inspect(object) {
+    try {
+      if (isUndefined(object)) return 'undefined';
+      if (object === null) return 'null';
+      return object.inspect ? object.inspect() : String(object);
+    } catch (e) {
+      if (e instanceof RangeError) return '...';
+      throw e;
+    }
+  }
+
+  function toJSON(object) {
+    var type = typeof object;
+    switch (type) {
+      case 'undefined':
+      case 'function':
+      case 'unknown': return;
+      case 'boolean': return object.toString();
+    }
+
+    if (object === null) return 'null';
+    if (object.toJSON) return object.toJSON();
+    if (isElement(object)) return;
+
+    var results = [];
+    for (var property in object) {
+      var value = toJSON(object[property]);
+      if (!isUndefined(value))
+        results.push(property.toJSON() + ': ' + value);
+    }
+
+    return '{' + results.join(', ') + '}';
+  }
+
+  function toQueryString(object) {
+    return $H(object).toQueryString();
+  }
+
+  function toHTML(object) {
+    return object && object.toHTML ? object.toHTML() : String.interpret(object);
+  }
+
+  function keys(object) {
+    var results = [];
+    for (var property in object)
+      results.push(property);
+    return results;
+  }
+
+  function values(object) {
+    var results = [];
+    for (var property in object)
+      results.push(object[property]);
+    return results;
+  }
+
+  function clone(object) {
+    return extend({ }, object);
+  }
+
+  function isElement(object) {
+    return !!(object && object.nodeType == 1);
+  }
+
+  function isArray(object) {
+    return _toString.call(object) == "[object Array]";
+  }
+
+
+  function isHash(object) {
+    return object instanceof Hash;
+  }
+
+  function isFunction(object) {
+    return typeof object === "function";
+  }
+
+  function isString(object) {
+    return _toString.call(object) == "[object String]";
+  }
+
+  function isNumber(object) {
+    return _toString.call(object) == "[object Number]";
+  }
+
+  function isUndefined(object) {
+    return typeof object === "undefined";
+  }
+
+  extend(Object, {
+    extend:        extend,
+    inspect:       inspect,
+    toJSON:        toJSON,
+    toQueryString: toQueryString,
+    toHTML:        toHTML,
+    keys:          keys,
+    values:        values,
+    clone:         clone,
+    isElement:     isElement,
+    isArray:       isArray,
+    isHash:        isHash,
+    isFunction:    isFunction,
+    isString:      isString,
+    isNumber:      isNumber,
+    isUndefined:   isUndefined
+  });
+})();
+Object.extend(Function.prototype, (function() {
+  var slice = Array.prototype.slice;
+
+  function update(array, args) {
+    var arrayLength = array.length, length = args.length;
+    while (length--) array[arrayLength + length] = args[length];
+    return array;
+  }
+
+  function merge(array, args) {
+    array = slice.call(array, 0);
+    return update(array, args);
+  }
+
+  function argumentNames() {
+    var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]
+      .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')
+      .replace(/\s+/g, '').split(',');
+    return names.length == 1 && !names[0] ? [] : names;
+  }
+
+  function bind(context) {
+    if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
+    var __method = this, args = slice.call(arguments, 1);
+    return function() {
+      var a = merge(args, arguments);
+      return __method.apply(context, a);
+    }
+  }
+
+  function bindAsEventListener(context) {
+    var __method = this, args = slice.call(arguments, 1);
+    return function(event) {
+      var a = update([event || window.event], args);
+      return __method.apply(context, a);
+    }
+  }
+
+  function curry() {
+    if (!arguments.length) return this;
+    var __method = this, args = slice.call(arguments, 0);
+    return function() {
+      var a = merge(args, arguments);
+      return __method.apply(this, a);
+    }
+  }
+
+  function delay(timeout) {
+    var __method = this, args = slice.call(arguments, 1);
+    timeout = timeout * 1000
+    return window.setTimeout(function() {
+      return __method.apply(__method, args);
+    }, timeout);
+  }
+
+  function defer() {
+    var args = update([0.01], arguments);
+    return this.delay.apply(this, args);
+  }
+
+  function wrap(wrapper) {
+    var __method = this;
+    return function() {
+      var a = update([__method.bind(this)], arguments);
+      return wrapper.apply(this, a);
+    }
+  }
+
+  function methodize() {
+    if (this._methodized) return this._methodized;
+    var __method = this;
+    return this._methodized = function() {
+      var a = update([this], arguments);
+      return __method.apply(null, a);
+    };
+  }
+
+  return {
+    argumentNames:       argumentNames,
+    bind:                bind,
+    bindAsEventListener: bindAsEventListener,
+    curry:               curry,
+    delay:               delay,
+    defer:               defer,
+    wrap:                wrap,
+    methodize:           methodize
+  }
+})());
+
+
+Date.prototype.toJSON = function() {
+  return '"' + this.getUTCFullYear() + '-' +
+    (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
+    this.getUTCDate().toPaddedString(2) + 'T' +
+    this.getUTCHours().toPaddedString(2) + ':' +
+    this.getUTCMinutes().toPaddedString(2) + ':' +
+    this.getUTCSeconds().toPaddedString(2) + 'Z"';
+};
+
+
+RegExp.prototype.match = RegExp.prototype.test;
+
+RegExp.escape = function(str) {
+  return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
+};
+var PeriodicalExecuter = Class.create({
+  initialize: function(callback, frequency) {
+    this.callback = callback;
+    this.frequency = frequency;
+    this.currentlyExecuting = false;
+
+    this.registerCallback();
+  },
+
+  registerCallback: function() {
+    this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+  },
+
+  execute: function() {
+    this.callback(this);
+  },
+
+  stop: function() {
+    if (!this.timer) return;
+    clearInterval(this.timer);
+    this.timer = null;
+  },
+
+  onTimerEvent: function() {
+    if (!this.currentlyExecuting) {
+      try {
+        this.currentlyExecuting = true;
+        this.execute();
+        this.currentlyExecuting = false;
+      } catch(e) {
+        this.currentlyExecuting = false;
+        throw e;
+      }
+    }
+  }
+});
+Object.extend(String, {
+  interpret: function(value) {
+    return value == null ? '' : String(value);
+  },
+  specialChar: {
+    '\b': '\\b',
+    '\t': '\\t',
+    '\n': '\\n',
+    '\f': '\\f',
+    '\r': '\\r',
+    '\\': '\\\\'
+  }
+});
+
+Object.extend(String.prototype, (function() {
+
+  function prepareReplacement(replacement) {
+    if (Object.isFunction(replacement)) return replacement;
+    var template = new Template(replacement);
+    return function(match) { return template.evaluate(match) };
+  }
+
+  function gsub(pattern, replacement) {
+    var result = '', source = this, match;
+    replacement = prepareReplacement(replacement);
+
+    if (Object.isString(pattern))
+      pattern = RegExp.escape(pattern);
+
+    if (!(pattern.length || pattern.source)) {
+      replacement = replacement('');
+      return replacement + source.split('').join(replacement) + replacement;
+    }
+
+    while (source.length > 0) {
+      if (match = source.match(pattern)) {
+        result += source.slice(0, match.index);
+        result += String.interpret(replacement(match));
+        source  = source.slice(match.index + match[0].length);
+      } else {
+        result += source, source = '';
+      }
+    }
+    return result;
+  }
+
+  function sub(pattern, replacement, count) {
+    replacement = prepareReplacement(replacement);
+    count = Object.isUndefined(count) ? 1 : count;
+
+    return this.gsub(pattern, function(match) {
+      if (--count < 0) return match[0];
+      return replacement(match);
+    });
+  }
+
+  function scan(pattern, iterator) {
+    this.gsub(pattern, iterator);
+    return String(this);
+  }
+
+  function truncate(length, truncation) {
+    length = length || 30;
+    truncation = Object.isUndefined(truncation) ? '...' : truncation;
+    return this.length > length ?
+      this.slice(0, length - truncation.length) + truncation : String(this);
+  }
+
+  function strip() {
+    return this.replace(/^\s+/, '').replace(/\s+$/, '');
+  }
+
+  function stripTags() {
+    return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
+  }
+
+  function stripScripts() {
+    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
+  }
+
+  function extractScripts() {
+    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
+    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
+    return (this.match(matchAll) || []).map(function(scriptTag) {
+      return (scriptTag.match(matchOne) || ['', ''])[1];
+    });
+  }
+
+  function evalScripts() {
+    return this.extractScripts().map(function(script) { return eval(script) });
+  }
+
+  function escapeHTML() {
+    return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
+  }
+
+  function unescapeHTML() {
+    return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
+  }
+
+
+  function toQueryParams(separator) {
+    var match = this.strip().match(/([^?#]*)(#.*)?$/);
+    if (!match) return { };
+
+    return match[1].split(separator || '&').inject({ }, function(hash, pair) {
+      if ((pair = pair.split('='))[0]) {
+        var key = decodeURIComponent(pair.shift());
+        var value = pair.length > 1 ? pair.join('=') : pair[0];
+        if (value != undefined) value = decodeURIComponent(value);
+
+        if (key in hash) {
+          if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
+          hash[key].push(value);
+        }
+        else hash[key] = value;
+      }
+      return hash;
+    });
+  }
+
+  function toArray() {
+    return this.split('');
+  }
+
+  function succ() {
+    return this.slice(0, this.length - 1) +
+      String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
+  }
+
+  function times(count) {
+    return count < 1 ? '' : new Array(count + 1).join(this);
+  }
+
+  function camelize() {
+    var parts = this.split('-'), len = parts.length;
+    if (len == 1) return parts[0];
+
+    var camelized = this.charAt(0) == '-'
+      ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
+      : parts[0];
+
+    for (var i = 1; i < len; i++)
+      camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
+
+    return camelized;
+  }
+
+  function capitalize() {
+    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
+  }
+
+  function underscore() {
+    return this.replace(/::/g, '/')
+               .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
+               .replace(/([a-z\d])([A-Z])/g, '$1_$2')
+               .replace(/-/g, '_')
+               .toLowerCase();
+  }
+
+  function dasherize() {
+    return this.replace(/_/g, '-');
+  }
+
+  function inspect(useDoubleQuotes) {
+    var escapedString = this.replace(/[\x00-\x1f\\]/g, function(character) {
+      if (character in String.specialChar) {
+        return String.specialChar[character];
+      }
+      return '\\u00' + character.charCodeAt().toPaddedString(2, 16);
+    });
+    if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
+    return "'" + escapedString.replace(/'/g, '\\\'') + "'";
+  }
+
+  function toJSON() {
+    return this.inspect(true);
+  }
+
+  function unfilterJSON(filter) {
+    return this.replace(filter || Prototype.JSONFilter, '$1');
+  }
+
+  function isJSON() {
+    var str = this;
+    if (str.blank()) return false;
+    str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
+    return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
+  }
+
+  function evalJSON(sanitize) {
+    var json = this.unfilterJSON();
+    try {
+      if (!sanitize || json.isJSON()) return eval('(' + json + ')');
+    } catch (e) { }
+    throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
+  }
+
+  function include(pattern) {
+    return this.indexOf(pattern) > -1;
+  }
+
+  function startsWith(pattern) {
+    return this.indexOf(pattern) === 0;
+  }
+
+  function endsWith(pattern) {
+    var d = this.length - pattern.length;
+    return d >= 0 && this.lastIndexOf(pattern) === d;
+  }
+
+  function empty() {
+    return this == '';
+  }
+
+  function blank() {
+    return /^\s*$/.test(this);
+  }
+
+  function interpolate(object, pattern) {
+    return new Template(this, pattern).evaluate(object);
+  }
+
+  return {
+    gsub:           gsub,
+    sub:            sub,
+    scan:           scan,
+    truncate:       truncate,
+    strip:          String.prototype.trim ? String.prototype.trim : strip,
+    stripTags:      stripTags,
+    stripScripts:   stripScripts,
+    extractScripts: extractScripts,
+    evalScripts:    evalScripts,
+    escapeHTML:     escapeHTML,
+    unescapeHTML:   unescapeHTML,
+    toQueryParams:  toQueryParams,
+    parseQuery:     toQueryParams,
+    toArray:        toArray,
+    succ:           succ,
+    times:          times,
+    camelize:       camelize,
+    capitalize:     capitalize,
+    underscore:     underscore,
+    dasherize:      dasherize,
+    inspect:        inspect,
+    toJSON:         toJSON,
+    unfilterJSON:   unfilterJSON,
+    isJSON:         isJSON,
+    evalJSON:       evalJSON,
+    include:        include,
+    startsWith:     startsWith,
+    endsWith:       endsWith,
+    empty:          empty,
+    blank:          blank,
+    interpolate:    interpolate
+  };
+})());
+
+var Template = Class.create({
+  initialize: function(template, pattern) {
+    this.template = template.toString();
+    this.pattern = pattern || Template.Pattern;
+  },
+
+  evaluate: function(object) {
+    if (object && Object.isFunction(object.toTemplateReplacements))
+      object = object.toTemplateReplacements();
+
+    return this.template.gsub(this.pattern, function(match) {
+      if (object == null) return (match[1] + '');
+
+      var before = match[1] || '';
+      if (before == '\\') return match[2];
+
+      var ctx = object, expr = match[3];
+      var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
+      match = pattern.exec(expr);
+      if (match == null) return before;
+
+      while (match != null) {
+        var comp = match[1].startsWith('[') ? match[2].replace(/\\\\]/g, ']') : match[1];
+        ctx = ctx[comp];
+        if (null == ctx || '' == match[3]) break;
+        expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
+        match = pattern.exec(expr);
+      }
+
+      return before + String.interpret(ctx);
+    });
+  }
+});
+Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
+
+var $break = { };
+
+var Enumerable = (function() {
+  function each(iterator, context) {
+    var index = 0;
+    try {
+      this._each(function(value) {
+        iterator.call(context, value, index++);
+      });
+    } catch (e) {
+      if (e != $break) throw e;
+    }
+    return this;
+  }
+
+  function eachSlice(number, iterator, context) {
+    var index = -number, slices = [], array = this.toArray();
+    if (number < 1) return array;
+    while ((index += number) < array.length)
+      slices.push(array.slice(index, index+number));
+    return slices.collect(iterator, context);
+  }
+
+  function all(iterator, context) {
+    iterator = iterator || Prototype.K;
+    var result = true;
+    this.each(function(value, index) {
+      result = result && !!iterator.call(context, value, index);
+      if (!result) throw $break;
+    });
+    return result;
+  }
+
+  function any(iterator, context) {
+    iterator = iterator || Prototype.K;
+    var result = false;
+    this.each(function(value, index) {
+      if (result = !!iterator.call(context, value, index))
+        throw $break;
+    });
+    return result;
+  }
+
+  function collect(iterator, context) {
+    iterator = iterator || Prototype.K;
+    var results = [];
+    this.each(function(value, index) {
+      results.push(iterator.call(context, value, index));
+    });
+    return results;
+  }
+
+  function detect(iterator, context) {
+    var result;
+    this.each(function(value, index) {
+      if (iterator.call(context, value, index)) {
+        result = value;
+        throw $break;
+      }
+    });
+    return result;
+  }
+
+  function findAll(iterator, context) {
+    var results = [];
+    this.each(function(value, index) {
+      if (iterator.call(context, value, index))
+        results.push(value);
+    });
+    return results;
+  }
+
+  function grep(filter, iterator, context) {
+    iterator = iterator || Prototype.K;
+    var results = [];
+
+    if (Object.isString(filter))
+      filter = new RegExp(RegExp.escape(filter));
+
+    this.each(function(value, index) {
+      if (filter.match(value))
+        results.push(iterator.call(context, value, index));
+    });
+    return results;
+  }
+
+  function include(object) {
+    if (Object.isFunction(this.indexOf))
+      if (this.indexOf(object) != -1) return true;
+
+    var found = false;
+    this.each(function(value) {
+      if (value == object) {
+        found = true;
+        throw $break;
+      }
+    });
+    return found;
+  }
+
+  function inGroupsOf(number, fillWith) {
+    fillWith = Object.isUndefined(fillWith) ? null : fillWith;
+    return this.eachSlice(number, function(slice) {
+      while(slice.length < number) slice.push(fillWith);
+      return slice;
+    });
+  }
+
+  function inject(memo, iterator, context) {
+    this.each(function(value, index) {
+      memo = iterator.call(context, memo, value, index);
+    });
+    return memo;
+  }
+
+  function invoke(method) {
+    var args = $A(arguments).slice(1);
+    return this.map(function(value) {
+      return value[method].apply(value, args);
+    });
+  }
+
+  function max(iterator, context) {
+    iterator = iterator || Prototype.K;
+    var result;
+    this.each(function(value, index) {
+      value = iterator.call(context, value, index);
+      if (result == null || value >= result)
+        result = value;
+    });
+    return result;
+  }
+
+  function min(iterator, context) {
+    iterator = iterator || Prototype.K;
+    var result;
+    this.each(function(value, index) {
+      value = iterator.call(context, value, index);
+      if (result == null || value < result)
+        result = value;
+    });
+    return result;
+  }
+
+  function partition(iterator, context) {
+    iterator = iterator || Prototype.K;
+    var trues = [], falses = [];
+    this.each(function(value, index) {
+      (iterator.call(context, value, index) ?
+        trues : falses).push(value);
+    });
+    return [trues, falses];
+  }
+
+  function pluck(property) {
+    var results = [];
+    this.each(function(value) {
+      results.push(value[property]);
+    });
+    return results;
+  }
+
+  function reject(iterator, context) {
+    var results = [];
+    this.each(function(value, index) {
+      if (!iterator.call(context, value, index))
+        results.push(value);
+    });
+    return results;
+  }
+
+  function sortBy(iterator, context) {
+    return this.map(function(value, index) {
+      return {
+        value: value,
+        criteria: iterator.call(context, value, index)
+      };
+    }).sort(function(left, right) {
+      var a = left.criteria, b = right.criteria;
+      return a < b ? -1 : a > b ? 1 : 0;
+    }).pluck('value');
+  }
+
+  function toArray() {
+    return this.map();
+  }
+
+  function zip() {
+    var iterator = Prototype.K, args = $A(arguments);
+    if (Object.isFunction(args.last()))
+      iterator = args.pop();
+
+    var collections = [this].concat(args).map($A);
+    return this.map(function(value, index) {
+      return iterator(collections.pluck(index));
+    });
+  }
+
+  function size() {
+    return this.toArray().length;
+  }
+
+  function inspect() {
+    return '#<Enumerable:' + this.toArray().inspect() + '>';
+  }
+
+
+
+
+
+
+
+
+
+  return {
+    each:       each,
+    eachSlice:  eachSlice,
+    all:        all,
+    every:      all,
+    any:        any,
+    some:       any,
+    collect:    collect,
+    map:        collect,
+    detect:     detect,
+    findAll:    findAll,
+    select:     findAll,
+    filter:     findAll,
+    grep:       grep,
+    include:    include,
+    member:     include,
+    inGroupsOf: inGroupsOf,
+    inject:     inject,
+    invoke:     invoke,
+    max:        max,
+    min:        min,
+    partition:  partition,
+    pluck:      pluck,
+    reject:     reject,
+    sortBy:     sortBy,
+    toArray:    toArray,
+    entries:    toArray,
+    zip:        zip,
+    size:       size,
+    inspect:    inspect,
+    find:       detect
+  };
+})();
+function $A(iterable) {
+  if (!iterable) return [];
+  if ('toArray' in Object(iterable)) return iterable.toArray();
+  var length = iterable.length || 0, results = new Array(length);
+  while (length--) results[length] = iterable[length];
+  return results;
+}
+
+function $w(string) {
+  if (!Object.isString(string)) return [];
+  string = string.strip();
+  return string ? string.split(/\s+/) : [];
+}
+
+Array.from = $A;
+
+
+(function() {
+  var arrayProto = Array.prototype,
+      slice = arrayProto.slice,
+      _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available
+
+  function each(iterator) {
+    for (var i = 0, length = this.length; i < length; i++)
+      iterator(this[i]);
+  }
+  if (!_each) _each = each;
+
+  function clear() {
+    this.length = 0;
+    return this;
+  }
+
+  function first() {
+    return this[0];
+  }
+
+  function last() {
+    return this[this.length - 1];
+  }
+
+  function compact() {
+    return this.select(function(value) {
+      return value != null;
+    });
+  }
+
+  function flatten() {
+    return this.inject([], function(array, value) {
+      if (Object.isArray(value))
+        return array.concat(value.flatten());
+      array.push(value);
+      return array;
+    });
+  }
+
+  function without() {
+    var values = slice.call(arguments, 0);
+    return this.select(function(value) {
+      return !values.include(value);
+    });
+  }
+
+  function reverse(inline) {
+    return (inline !== false ? this : this.toArray())._reverse();
+  }
+
+  function uniq(sorted) {
+    return this.inject([], function(array, value, index) {
+      if (0 == index || (sorted ? array.last() != value : !array.include(value)))
+        array.push(value);
+      return array;
+    });
+  }
+
+  function intersect(array) {
+    return this.uniq().findAll(function(item) {
+      return array.detect(function(value) { return item === value });
+    });
+  }
+
+
+  function clone() {
+    return slice.call(this, 0);
+  }
+
+  function size() {
+    return this.length;
+  }
+
+  function inspect() {
+    return '[' + this.map(Object.inspect).join(', ') + ']';
+  }
+
+  function toJSON() {
+    var results = [];
+    this.each(function(object) {
+      var value = Object.toJSON(object);
+      if (!Object.isUndefined(value)) results.push(value);
+    });
+    return '[' + results.join(', ') + ']';
+  }
+
+  function indexOf(item, i) {
+    i || (i = 0);
+    var length = this.length;
+    if (i < 0) i = length + i;
+    for (; i < length; i++)
+      if (this[i] === item) return i;
+    return -1;
+  }
+
+  function lastIndexOf(item, i) {
+    i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
+    var n = this.slice(0, i).reverse().indexOf(item);
+    return (n < 0) ? n : i - n - 1;
+  }
+
+  function concat() {
+    var array = slice.call(this, 0), item;
+    for (var i = 0, length = arguments.length; i < length; i++) {
+      item = arguments[i];
+      if (Object.isArray(item) && !('callee' in item)) {
+        for (var j = 0, arrayLength = item.length; j < arrayLength; j++)
+          array.push(item[j]);
+      } else {
+        array.push(item);
+      }
+    }
+    return array;
+  }
+
+  Object.extend(arrayProto, Enumerable);
+
+  if (!arrayProto._reverse)
+    arrayProto._reverse = arrayProto.reverse;
+
+  Object.extend(arrayProto, {
+    _each:     _each,
+    clear:     clear,
+    first:     first,
+    last:      last,
+    compact:   compact,
+    flatten:   flatten,
+    without:   without,
+    reverse:   reverse,
+    uniq:      uniq,
+    intersect: intersect,
+    clone:     clone,
+    toArray:   clone,
+    size:      size,
+    inspect:   inspect,
+    toJSON:    toJSON
+  });
+
+  var CONCAT_ARGUMENTS_BUGGY = (function() {
+    return [].concat(arguments)[0][0] !== 1;
+  })(1,2)
+
+  if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat;
+
+  if (!arrayProto.indexOf) arrayProto.indexOf = indexOf;
+  if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf;
+})();
+function $H(object) {
+  return new Hash(object);
+};
+
+var Hash = Class.create(Enumerable, (function() {
+  function initialize(object) {
+    this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
+  }
+
+  function _each(iterator) {
+    for (var key in this._object) {
+      var value = this._object[key], pair = [key, value];
+      pair.key = key;
+      pair.value = value;
+      iterator(pair);
+    }
+  }
+
+  function set(key, value) {
+    return this._object[key] = value;
+  }
+
+  function get(key) {
+    if (this._object[key] !== Object.prototype[key])
+      return this._object[key];
+  }
+
+  function unset(key) {
+    var value = this._object[key];
+    delete this._object[key];
+    return value;
+  }
+
+  function toObject() {
+    return Object.clone(this._object);
+  }
+
+  function keys() {
+    return this.pluck('key');
+  }
+
+  function values() {
+    return this.pluck('value');
+  }
+
+  function index(value) {
+    var match = this.detect(function(pair) {
+      return pair.value === value;
+    });
+    return match && match.key;
+  }
+
+  function merge(object) {
+    return this.clone().update(object);
+  }
+
+  function update(object) {
+    return new Hash(object).inject(this, function(result, pair) {
+      result.set(pair.key, pair.value);
+      return result;
+    });
+  }
+
+  function toQueryPair(key, value) {
+    if (Object.isUndefined(value)) return key;
+    return key + '=' + encodeURIComponent(String.interpret(value));
+  }
+
+  function toQueryString() {
+    return this.inject([], function(results, pair) {
+      var key = encodeURIComponent(pair.key), values = pair.value;
+
+      if (values && typeof values == 'object') {
+        if (Object.isArray(values))
+          return results.concat(values.map(toQueryPair.curry(key)));
+      } else results.push(toQueryPair(key, values));
+      return results;
+    }).join('&');
+  }
+
+  function inspect() {
+    return '#<Hash:{' + this.map(function(pair) {
+      return pair.map(Object.inspect).join(': ');
+    }).join(', ') + '}>';
+  }
+
+  function toJSON() {
+    return Object.toJSON(this.toObject());
+  }
+
+  function clone() {
+    return new Hash(this);
+  }
+
+  return {
+    initialize:             initialize,
+    _each:                  _each,
+    set:                    set,
+    get:                    get,
+    unset:                  unset,
+    toObject:               toObject,
+    toTemplateReplacements: toObject,
+    keys:                   keys,
+    values:                 values,
+    index:                  index,
+    merge:                  merge,
+    update:                 update,
+    toQueryString:          toQueryString,
+    inspect:                inspect,
+    toJSON:                 toJSON,
+    clone:                  clone
+  };
+})());
+
+Hash.from = $H;
+Object.extend(Number.prototype, (function() {
+  function toColorPart() {
+    return this.toPaddedString(2, 16);
+  }
+
+  function succ() {
+    return this + 1;
+  }
+
+  function times(iterator, context) {
+    $R(0, this, true).each(iterator, context);
+    return this;
+  }
+
+  function toPaddedString(length, radix) {
+    var string = this.toString(radix || 10);
+    return '0'.times(length - string.length) + string;
+  }
+
+  function toJSON() {
+    return isFinite(this) ? this.toString() : 'null';
+  }
+
+  function abs() {
+    return Math.abs(this);
+  }
+
+  function round() {
+    return Math.round(this);
+  }
+
+  function ceil() {
+    return Math.ceil(this);
+  }
+
+  function floor() {
+    return Math.floor(this);
+  }
+
+  return {
+    toColorPart:    toColorPart,
+    succ:           succ,
+    times:          times,
+    toPaddedString: toPaddedString,
+    toJSON:         toJSON,
+    abs:            abs,
+    round:          round,
+    ceil:           ceil,
+    floor:          floor
+  };
+})());
+
+function $R(start, end, exclusive) {
+  return new ObjectRange(start, end, exclusive);
+}
+
+var ObjectRange = Class.create(Enumerable, (function() {
+  function initialize(start, end, exclusive) {
+    this.start = start;
+    this.end = end;
+    this.exclusive = exclusive;
+  }
+
+  function _each(iterator) {
+    var value = this.start;
+    while (this.include(value)) {
+      iterator(value);
+      value = value.succ();
+    }
+  }
+
+  function include(value) {
+    if (value < this.start)
+      return false;
+    if (this.exclusive)
+      return value < this.end;
+    return value <= this.end;
+  }
+
+  return {
+    initialize: initialize,
+    _each:      _each,
+    include:    include
+  };
+})());
+
+
+
+var Ajax = {
+  getTransport: function() {
+    return Try.these(
+      function() {return new XMLHttpRequest()},
+      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
+      function() {return new ActiveXObject('Microsoft.XMLHTTP')}
+    ) || false;
+  },
+
+  activeRequestCount: 0
+};
+
+Ajax.Responders = {
+  responders: [],
+
+  _each: function(iterator) {
+    this.responders._each(iterator);
+  },
+
+  register: function(responder) {
+    if (!this.include(responder))
+      this.responders.push(responder);
+  },
+
+  unregister: function(responder) {
+    this.responders = this.responders.without(responder);
+  },
+
+  dispatch: function(callback, request, transport, json) {
+    this.each(function(responder) {
+      if (Object.isFunction(responder[callback])) {
+        try {
+          responder[callback].apply(responder, [request, transport, json]);
+        } catch (e) { }
+      }
+    });
+  }
+};
+
+Object.extend(Ajax.Responders, Enumerable);
+
+Ajax.Responders.register({
+  onCreate:   function() { Ajax.activeRequestCount++ },
+  onComplete: function() { Ajax.activeRequestCount-- }
+});
+Ajax.Base = Class.create({
+  initialize: function(options) {
+    this.options = {
+      method:       'post',
+      asynchronous: true,
+      contentType:  'application/x-www-form-urlencoded',
+      encoding:     'UTF-8',
+      parameters:   '',
+      evalJSON:     true,
+      evalJS:       true
+    };
+    Object.extend(this.options, options || { });
+
+    this.options.method = this.options.method.toLowerCase();
+
+    if (Object.isString(this.options.parameters))
+      this.options.parameters = this.options.parameters.toQueryParams();
+    else if (Object.isHash(this.options.parameters))
+      this.options.parameters = this.options.parameters.toObject();
+  }
+});
+Ajax.Request = Class.create(Ajax.Base, {
+  _complete: false,
+
+  initialize: function($super, url, options) {
+    $super(options);
+    this.transport = Ajax.getTransport();
+    this.request(url);
+  },
+
+  request: function(url) {
+    this.url = url;
+    this.method = this.options.method;
+    var params = Object.clone(this.options.parameters);
+
+    if (!['get', 'post'].include(this.method)) {
+      params['_method'] = this.method;
+      this.method = 'post';
+    }
+
+    this.parameters = params;
+
+    if (params = Object.toQueryString(params)) {
+      if (this.method == 'get')
+        this.url += (this.url.include('?') ? '&' : '?') + params;
+      else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
+        params += '&_=';
+    }
+
+    try {
+      var response = new Ajax.Response(this);
+      if (this.options.onCreate) this.options.onCreate(response);
+      Ajax.Responders.dispatch('onCreate', this, response);
+
+      this.transport.open(this.method.toUpperCase(), this.url,
+        this.options.asynchronous);
+
+      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
+
+      this.transport.onreadystatechange = this.onStateChange.bind(this);
+      this.setRequestHeaders();
+
+      this.body = this.method == 'post' ? (this.options.postBody || params) : null;
+      this.transport.send(this.body);
+
+      /* Force Firefox to handle ready state 4 for synchronous requests */
+      if (!this.options.asynchronous && this.transport.overrideMimeType)
+        this.onStateChange();
+
+    }
+    catch (e) {
+      this.dispatchException(e);
+    }
+  },
+
+  onStateChange: function() {
+    var readyState = this.transport.readyState;
+    if (readyState > 1 && !((readyState == 4) && this._complete))
+      this.respondToReadyState(this.transport.readyState);
+  },
+
+  setRequestHeaders: function() {
+    var headers = {
+      'X-Requested-With': 'XMLHttpRequest',
+      'X-Prototype-Version': Prototype.Version,
+      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
+    };
+
+    if (this.method == 'post') {
+      headers['Content-type'] = this.options.contentType +
+        (this.options.encoding ? '; charset=' + this.options.encoding : '');
+
+      /* Force "Connection: close" for older Mozilla browsers to work
+       * around a bug where XMLHttpRequest sends an incorrect
+       * Content-length header. See Mozilla Bugzilla #246651.
+       */
+      if (this.transport.overrideMimeType &&
+          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
+            headers['Connection'] = 'close';
+    }
+
+    if (typeof this.options.requestHeaders == 'object') {
+      var extras = this.options.requestHeaders;
+
+      if (Object.isFunction(extras.push))
+        for (var i = 0, length = extras.length; i < length; i += 2)
+          headers[extras[i]] = extras[i+1];
+      else
+        $H(extras).each(function(pair) { headers[pair.key] = pair.value });
+    }
+
+    for (var name in headers)
+      this.transport.setRequestHeader(name, headers[name]);
+  },
+
+  success: function() {
+    var status = this.getStatus();
+    return !status || (status >= 200 && status < 300);
+  },
+
+  getStatus: function() {
+    try {
+      return this.transport.status || 0;
+    } catch (e) { return 0 }
+  },
+
+  respondToReadyState: function(readyState) {
+    var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
+
+    if (state == 'Complete') {
+      try {
+        this._complete = true;
+        (this.options['on' + response.status]
+         || this.options['on' + (this.success() ? 'Success' : 'Failure')]
+         || Prototype.emptyFunction)(response, response.headerJSON);
+      } catch (e) {
+        this.dispatchException(e);
+      }
+
+      var contentType = response.getHeader('Content-type');
+      if (this.options.evalJS == 'force'
+          || (this.options.evalJS && this.isSameOrigin() && contentType
+          && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
+        this.evalResponse();
+    }
+
+    try {
+      (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
+      Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
+    } catch (e) {
+      this.dispatchException(e);
+    }
+
+    if (state == 'Complete') {
+      this.transport.onreadystatechange = Prototype.emptyFunction;
+    }
+  },
+
+  isSameOrigin: function() {
+    var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
+    return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
+      protocol: location.protocol,
+      domain: document.domain,
+      port: location.port ? ':' + location.port : ''
+    }));
+  },
+
+  getHeader: function(name) {
+    try {
+      return this.transport.getResponseHeader(name) || null;
+    } catch (e) { return null; }
+  },
+
+  evalResponse: function() {
+    try {
+      return eval((this.transport.responseText || '').unfilterJSON());
+    } catch (e) {
+      this.dispatchException(e);
+    }
+  },
+
+  dispatchException: function(exception) {
+    (this.options.onException || Prototype.emptyFunction)(this, exception);
+    Ajax.Responders.dispatch('onException', this, exception);
+  }
+});
+
+Ajax.Request.Events =
+  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
+
+
+
+
+
+
+
+
+Ajax.Response = Class.create({
+  initialize: function(request){
+    this.request = request;
+    var transport  = this.transport  = request.transport,
+        readyState = this.readyState = transport.readyState;
+
+    if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
+      this.status       = this.getStatus();
+      this.statusText   = this.getStatusText();
+      this.responseText = String.interpret(transport.responseText);
+      this.headerJSON   = this._getHeaderJSON();
+    }
+
+    if(readyState == 4) {
+      var xml = transport.responseXML;
+      this.responseXML  = Object.isUndefined(xml) ? null : xml;
+      this.responseJSON = this._getResponseJSON();
+    }
+  },
+
+  status:      0,
+
+  statusText: '',
+
+  getStatus: Ajax.Request.prototype.getStatus,
+
+  getStatusText: function() {
+    try {
+      return this.transport.statusText || '';
+    } catch (e) { return '' }
+  },
+
+  getHeader: Ajax.Request.prototype.getHeader,
+
+  getAllHeaders: function() {
+    try {
+      return this.getAllResponseHeaders();
+    } catch (e) { return null }
+  },
+
+  getResponseHeader: function(name) {
+    return this.transport.getResponseHeader(name);
+  },
+
+  getAllResponseHeaders: function() {
+    return this.transport.getAllResponseHeaders();
+  },
+
+  _getHeaderJSON: function() {
+    var json = this.getHeader('X-JSON');
+    if (!json) return null;
+    json = decodeURIComponent(escape(json));
+    try {
+      return json.evalJSON(this.request.options.sanitizeJSON ||
+        !this.request.isSameOrigin());
+    } catch (e) {
+      this.request.dispatchException(e);
+    }
+  },
+
+  _getResponseJSON: function() {
+    var options = this.request.options;
+    if (!options.evalJSON || (options.evalJSON != 'force' &&
+      !(this.getHeader('Content-type') || '').include('application/json')) ||
+        this.responseText.blank())
+          return null;
+    try {
+      return this.responseText.evalJSON(options.sanitizeJSON ||
+        !this.request.isSameOrigin());
+    } catch (e) {
+      this.request.dispatchException(e);
+    }
+  }
+});
+
+Ajax.Updater = Class.create(Ajax.Request, {
+  initialize: function($super, container, url, options) {
+    this.container = {
+      success: (container.success || container),
+      failure: (container.failure || (container.success ? null : container))
+    };
+
+    options = Object.clone(options);
+    var onComplete = options.onComplete;
+    options.onComplete = (function(response, json) {
+      this.updateContent(response.responseText);
+      if (Object.isFunction(onComplete)) onComplete(response, json);
+    }).bind(this);
+
+    $super(url, options);
+  },
+
+  updateContent: function(responseText) {
+    var receiver = this.container[this.success() ? 'success' : 'failure'],
+        options = this.options;
+
+    if (!options.evalScripts) responseText = responseText.stripScripts();
+
+    if (receiver = $(receiver)) {
+      if (options.insertion) {
+        if (Object.isString(options.insertion)) {
+          var insertion = { }; insertion[options.insertion] = responseText;
+          receiver.insert(insertion);
+        }
+        else options.insertion(receiver, responseText);
+      }
+      else receiver.update(responseText);
+    }
+  }
+});
+
+Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
+  initialize: function($super, container, url, options) {
+    $super(options);
+    this.onComplete = this.options.onComplete;
+
+    this.frequency = (this.options.frequency || 2);
+    this.decay = (this.options.decay || 1);
+
+    this.updater = { };
+    this.container = container;
+    this.url = url;
+
+    this.start();
+  },
+
+  start: function() {
+    this.options.onComplete = this.updateComplete.bind(this);
+    this.onTimerEvent();
+  },
+
+  stop: function() {
+    this.updater.options.onComplete = undefined;
+    clearTimeout(this.timer);
+    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
+  },
+
+  updateComplete: function(response) {
+    if (this.options.decay) {
+      this.decay = (response.responseText == this.lastText ?
+        this.decay * this.options.decay : 1);
+
+      this.lastText = response.responseText;
+    }
+    this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
+  },
+
+  onTimerEvent: function() {
+    this.updater = new Ajax.Updater(this.container, this.url, this.options);
+  }
+});
+
+
+
+function $(element) {
+  if (arguments.length > 1) {
+    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
+      elements.push($(arguments[i]));
+    return elements;
+  }
+  if (Object.isString(element))
+    element = document.getElementById(element);
+  return Element.extend(element);
+}
+
+if (Prototype.BrowserFeatures.XPath) {
+  document._getElementsByXPath = function(expression, parentElement) {
+    var results = [];
+    var query = document.evaluate(expression, $(parentElement) || document,
+      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    for (var i = 0, length = query.snapshotLength; i < length; i++)
+      results.push(Element.extend(query.snapshotItem(i)));
+    return results;
+  };
+}
+
+/*--------------------------------------------------------------------------*/
+
+if (!window.Node) var Node = { };
+
+if (!Node.ELEMENT_NODE) {
+  Object.extend(Node, {
+    ELEMENT_NODE: 1,
+    ATTRIBUTE_NODE: 2,
+    TEXT_NODE: 3,
+    CDATA_SECTION_NODE: 4,
+    ENTITY_REFERENCE_NODE: 5,
+    ENTITY_NODE: 6,
+    PROCESSING_INSTRUCTION_NODE: 7,
+    COMMENT_NODE: 8,
+    DOCUMENT_NODE: 9,
+    DOCUMENT_TYPE_NODE: 10,
+    DOCUMENT_FRAGMENT_NODE: 11,
+    NOTATION_NODE: 12
+  });
+}
+
+
+(function(global) {
+
+  var SETATTRIBUTE_IGNORES_NAME = (function(){
+    var elForm = document.createElement("form");
+    var elInput = document.createElement("input");
+    var root = document.documentElement;
+    elInput.setAttribute("name", "test");
+    elForm.appendChild(elInput);
+    root.appendChild(elForm);
+    var isBuggy = elForm.elements
+      ? (typeof elForm.elements.test == "undefined")
+      : null;
+    root.removeChild(elForm);
+    elForm = elInput = null;
+    return isBuggy;
+  })();
+
+  var element = global.Element;
+  global.Element = function(tagName, attributes) {
+    attributes = attributes || { };
+    tagName = tagName.toLowerCase();
+    var cache = Element.cache;
+    if (SETATTRIBUTE_IGNORES_NAME && attributes.name) {
+      tagName = '<' + tagName + ' name="' + attributes.name + '">';
+      delete attributes.name;
+      return Element.writeAttribute(document.createElement(tagName), attributes);
+    }
+    if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
+    return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
+  };
+  Object.extend(global.Element, element || { });
+  if (element) global.Element.prototype = element.prototype;
+})(this);
+
+Element.cache = { };
+Element.idCounter = 1;
+
+Element.Methods = {
+  visible: function(element) {
+    return $(element).style.display != 'none';
+  },
+
+  toggle: function(element) {
+    element = $(element);
+    Element[Element.visible(element) ? 'hide' : 'show'](element);
+    return element;
+  },
+
+
+  hide: function(element) {
+    element = $(element);
+    element.style.display = 'none';
+    return element;
+  },
+
+  show: function(element) {
+    element = $(element);
+    element.style.display = '';
+    return element;
+  },
+
+  remove: function(element) {
+    element = $(element);
+    element.parentNode.removeChild(element);
+    return element;
+  },
+
+  update: (function(){
+
+    var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){
+      var el = document.createElement("select"),
+          isBuggy = true;
+      el.innerHTML = "<option value=\"test\">test</option>";
+      if (el.options && el.options[0]) {
+        isBuggy = el.options[0].nodeName.toUpperCase() !== "OPTION";
+      }
+      el = null;
+      return isBuggy;
+    })();
+
+    var TABLE_ELEMENT_INNERHTML_BUGGY = (function(){
+      try {
+        var el = document.createElement("table");
+        if (el && el.tBodies) {
+          el.innerHTML = "<tbody><tr><td>test</td></tr></tbody>";
+          var isBuggy = typeof el.tBodies[0] == "undefined";
+          el = null;
+          return isBuggy;
+        }
+      } catch (e) {
+        return true;
+      }
+    })();
+
+    var SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = (function () {
+      var s = document.createElement("script"),
+          isBuggy = false;
+      try {
+        s.appendChild(document.createTextNode(""));
+        isBuggy = !s.firstChild ||
+          s.firstChild && s.firstChild.nodeType !== 3;
+      } catch (e) {
+        isBuggy = true;
+      }
+      s = null;
+      return isBuggy;
+    })();
+
+    function update(element, content) {
+      element = $(element);
+
+      if (content && content.toElement)
+        content = content.toElement();
+
+      if (Object.isElement(content))
+        return element.update().insert(content);
+
+      content = Object.toHTML(content);
+
+      var tagName = element.tagName.toUpperCase();
+
+      if (tagName === 'SCRIPT' && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) {
+        element.text = content;
+        return element;
+      }
+
+      if (SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY) {
+        if (tagName in Element._insertionTranslations.tags) {
+          while (element.firstChild) {
+            element.removeChild(element.firstChild);
+          }
+          Element._getContentFromAnonymousElement(tagName, content.stripScripts())
+            .each(function(node) {
+              element.appendChild(node)
+            });
+        }
+        else {
+          element.innerHTML = content.stripScripts();
+        }
+      }
+      else {
+        element.innerHTML = content.stripScripts();
+      }
+
+      content.evalScripts.bind(content).defer();
+      return element;
+    }
+
+    return update;
+  })(),
+
+  replace: function(element, content) {
+    element = $(element);
+    if (content && content.toElement) content = content.toElement();
+    else if (!Object.isElement(content)) {
+      content = Object.toHTML(content);
+      var range = element.ownerDocument.createRange();
+      range.selectNode(element);
+      content.evalScripts.bind(content).defer();
+      content = range.createContextualFragment(content.stripScripts());
+    }
+    element.parentNode.replaceChild(content, element);
+    return element;
+  },
+
+  insert: function(element, insertions) {
+    element = $(element);
+
+    if (Object.isString(insertions) || Object.isNumber(insertions) ||
+        Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
+          insertions = {bottom:insertions};
+
+    var content, insert, tagName, childNodes;
+
+    for (var position in insertions) {
+      content  = insertions[position];
+      position = position.toLowerCase();
+      insert = Element._insertionTranslations[position];
+
+      if (content && content.toElement) content = content.toElement();
+      if (Object.isElement(content)) {
+        insert(element, content);
+        continue;
+      }
+
+      content = Object.toHTML(content);
+
+      tagName = ((position == 'before' || position == 'after')
+        ? element.parentNode : element).tagName.toUpperCase();
+
+      childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
+
+      if (position == 'top' || position == 'after') childNodes.reverse();
+      childNodes.each(insert.curry(element));
+
+      content.evalScripts.bind(content).defer();
+    }
+
+    return element;
+  },
+
+  wrap: function(element, wrapper, attributes) {
+    element = $(element);
+    if (Object.isElement(wrapper))
+      $(wrapper).writeAttribute(attributes || { });
+    else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
+    else wrapper = new Element('div', wrapper);
+    if (element.parentNode)
+      element.parentNode.replaceChild(wrapper, element);
+    wrapper.appendChild(element);
+    return wrapper;
+  },
+
+  inspect: function(element) {
+    element = $(element);
+    var result = '<' + element.tagName.toLowerCase();
+    $H({'id': 'id', 'className': 'class'}).each(function(pair) {
+      var property = pair.first(), attribute = pair.last();
+      var value = (element[property] || '').toString();
+      if (value) result += ' ' + attribute + '=' + value.inspect(true);
+    });
+    return result + '>';
+  },
+
+  recursivelyCollect: function(element, property) {
+    element = $(element);
+    var elements = [];
+    while (element = element[property])
+      if (element.nodeType == 1)
+        elements.push(Element.extend(element));
+    return elements;
+  },
+
+  ancestors: function(element) {
+    return Element.recursivelyCollect(element, 'parentNode');
+  },
+
+  descendants: function(element) {
+    return Element.select(element, "*");
+  },
+
+  firstDescendant: function(element) {
+    element = $(element).firstChild;
+    while (element && element.nodeType != 1) element = element.nextSibling;
+    return $(element);
+  },
+
+  immediateDescendants: function(element) {
+    if (!(element = $(element).firstChild)) return [];
+    while (element && element.nodeType != 1) element = element.nextSibling;
+    if (element) return [element].concat($(element).nextSiblings());
+    return [];
+  },
+
+  previousSiblings: function(element) {
+    return Element.recursivelyCollect(element, 'previousSibling');
+  },
+
+  nextSiblings: function(element) {
+    return Element.recursivelyCollect(element, 'nextSibling');
+  },
+
+  siblings: function(element) {
+    element = $(element);
+    return Element.previousSiblings(element).reverse()
+      .concat(Element.nextSiblings(element));
+  },
+
+  match: function(element, selector) {
+    if (Object.isString(selector))
+      selector = new Selector(selector);
+    return selector.match($(element));
+  },
+
+  up: function(element, expression, index) {
+    element = $(element);
+    if (arguments.length == 1) return $(element.parentNode);
+    var ancestors = Element.ancestors(element);
+    return Object.isNumber(expression) ? ancestors[expression] :
+      Selector.findElement(ancestors, expression, index);
+  },
+
+  down: function(element, expression, index) {
+    element = $(element);
+    if (arguments.length == 1) return Element.firstDescendant(element);
+    return Object.isNumber(expression) ? Element.descendants(element)[expression] :
+      Element.select(element, expression)[index || 0];
+  },
+
+  previous: function(element, expression, index) {
+    element = $(element);
+    if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
+    var previousSiblings = Element.previousSiblings(element);
+    return Object.isNumber(expression) ? previousSiblings[expression] :
+      Selector.findElement(previousSiblings, expression, index);
+  },
+
+  next: function(element, expression, index) {
+    element = $(element);
+    if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
+    var nextSiblings = Element.nextSiblings(element);
+    return Object.isNumber(expression) ? nextSiblings[expression] :
+      Selector.findElement(nextSiblings, expression, index);
+  },
+
+
+  select: function(element) {
+    var args = Array.prototype.slice.call(arguments, 1);
+    return Selector.findChildElements(element, args);
+  },
+
+  adjacent: function(element) {
+    var args = Array.prototype.slice.call(arguments, 1);
+    return Selector.findChildElements(element.parentNode, args).without(element);
+  },
+
+  identify: function(element) {
+    element = $(element);
+    var id = Element.readAttribute(element, 'id');
+    if (id) return id;
+    do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id));
+    Element.writeAttribute(element, 'id', id);
+    return id;
+  },
+
+  readAttribute: function(element, name) {
+    element = $(element);
+    if (Prototype.Browser.IE) {
+      var t = Element._attributeTranslations.read;
+      if (t.values[name]) return t.values[name](element, name);
+      if (t.names[name]) name = t.names[name];
+      if (name.include(':')) {
+        return (!element.attributes || !element.attributes[name]) ? null :
+         element.attributes[name].value;
+      }
+    }
+    return element.getAttribute(name);
+  },
+
+  writeAttribute: function(element, name, value) {
+    element = $(element);
+    var attributes = { }, t = Element._attributeTranslations.write;
+
+    if (typeof name == 'object') attributes = name;
+    else attributes[name] = Object.isUndefined(value) ? true : value;
+
+    for (var attr in attributes) {
+      name = t.names[attr] || attr;
+      value = attributes[attr];
+      if (t.values[attr]) name = t.values[attr](element, value);
+      if (value === false || value === null)
+        element.removeAttribute(name);
+      else if (value === true)
+        element.setAttribute(name, name);
+      else element.setAttribute(name, value);
+    }
+    return element;
+  },
+
+  getHeight: function(element) {
+    return Element.getDimensions(element).height;
+  },
+
+  getWidth: function(element) {
+    return Element.getDimensions(element).width;
+  },
+
+  classNames: function(element) {
+    return new Element.ClassNames(element);
+  },
+
+  hasClassName: function(element, className) {
+    if (!(element = $(element))) return;
+    var elementClassName = element.className;
+    return (elementClassName.length > 0 && (elementClassName == className ||
+      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
+  },
+
+  addClassName: function(element, className) {
+    if (!(element = $(element))) return;
+    if (!Element.hasClassName(element, className))
+      element.className += (element.className ? ' ' : '') + className;
+    return element;
+  },
+
+  removeClassName: function(element, className) {
+    if (!(element = $(element))) return;
+    element.className = element.className.replace(
+      new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
+    return element;
+  },
+
+  toggleClassName: function(element, className) {
+    if (!(element = $(element))) return;
+    return Element[Element.hasClassName(element, className) ?
+      'removeClassName' : 'addClassName'](element, className);
+  },
+
+  cleanWhitespace: function(element) {
+    element = $(element);
+    var node = element.firstChild;
+    while (node) {
+      var nextNode = node.nextSibling;
+      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
+        element.removeChild(node);
+      node = nextNode;
+    }
+    return element;
+  },
+
+  empty: function(element) {
+    return $(element).innerHTML.blank();
+  },
+
+  descendantOf: function(element, ancestor) {
+    element = $(element), ancestor = $(ancestor);
+
+    if (element.compareDocumentPosition)
+      return (element.compareDocumentPosition(ancestor) & 8) === 8;
+
+    if (ancestor.contains)
+      return ancestor.contains(element) && ancestor !== element;
+
+    while (element = element.parentNode)
+      if (element == ancestor) return true;
+
+    return false;
+  },
+
+  scrollTo: function(element) {
+    element = $(element);
+    var pos = Element.cumulativeOffset(element);
+    window.scrollTo(pos[0], pos[1]);
+    return element;
+  },
+
+  getStyle: function(element, style) {
+    element = $(element);
+    style = style == 'float' ? 'cssFloat' : style.camelize();
+    var value = element.style[style];
+    if (!value || value == 'auto') {
+      var css = document.defaultView.getComputedStyle(element, null);
+      value = css ? css[style] : null;
+    }
+    if (style == 'opacity') return value ? parseFloat(value) : 1.0;
+    return value == 'auto' ? null : value;
+  },
+
+  getOpacity: function(element) {
+    return $(element).getStyle('opacity');
+  },
+
+  setStyle: function(element, styles) {
+    element = $(element);
+    var elementStyle = element.style, match;
+    if (Object.isString(styles)) {
+      element.style.cssText += ';' + styles;
+      return styles.include('opacity') ?
+        element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
+    }
+    for (var property in styles)
+      if (property == 'opacity') element.setOpacity(styles[property]);
+      else
+        elementStyle[(property == 'float' || property == 'cssFloat') ?
+          (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
+            property] = styles[property];
+
+    return element;
+  },
+
+  setOpacity: function(element, value) {
+    element = $(element);
+    element.style.opacity = (value == 1 || value === '') ? '' :
+      (value < 0.00001) ? 0 : value;
+    return element;
+  },
+
+  getDimensions: function(element) {
+    element = $(element);
+    var display = Element.getStyle(element, 'display');
+    if (display != 'none' && display != null) // Safari bug
+      return {width: element.offsetWidth, height: element.offsetHeight};
+
+    var els = element.style;
+    var originalVisibility = els.visibility;
+    var originalPosition = els.position;
+    var originalDisplay = els.display;
+    els.visibility = 'hidden';
+    if (originalPosition != 'fixed') // Switching fixed to absolute causes issues in Safari
+      els.position = 'absolute';
+    els.display = 'block';
+    var originalWidth = element.clientWidth;
+    var originalHeight = element.clientHeight;
+    els.display = originalDisplay;
+    els.position = originalPosition;
+    els.visibility = originalVisibility;
+    return {width: originalWidth, height: originalHeight};
+  },
+
+  makePositioned: function(element) {
+    element = $(element);
+    var pos = Element.getStyle(element, 'position');
+    if (pos == 'static' || !pos) {
+      element._madePositioned = true;
+      element.style.position = 'relative';
+      if (Prototype.Browser.Opera) {
+        element.style.top = 0;
+        element.style.left = 0;
+      }
+    }
+    return element;
+  },
+
+  undoPositioned: function(element) {
+    element = $(element);
+    if (element._madePositioned) {
+      element._madePositioned = undefined;
+      element.style.position =
+        element.style.top =
+        element.style.left =
+        element.style.bottom =
+        element.style.right = '';
+    }
+    return element;
+  },
+
+  makeClipping: function(element) {
+    element = $(element);
+    if (element._overflow) return element;
+    element._overflow = Element.getStyle(element, 'overflow') || 'auto';
+    if (element._overflow !== 'hidden')
+      element.style.overflow = 'hidden';
+    return element;
+  },
+
+  undoClipping: function(element) {
+    element = $(element);
+    if (!element._overflow) return element;
+    element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
+    element._overflow = null;
+    return element;
+  },
+
+  cumulativeOffset: function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+      element = element.offsetParent;
+    } while (element);
+    return Element._returnOffset(valueL, valueT);
+  },
+
+  positionedOffset: function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+      element = element.offsetParent;
+      if (element) {
+        if (element.tagName.toUpperCase() == 'BODY') break;
+        var p = Element.getStyle(element, 'position');
+        if (p !== 'static') break;
+      }
+    } while (element);
+    return Element._returnOffset(valueL, valueT);
+  },
+
+  absolutize: function(element) {
+    element = $(element);
+    if (Element.getStyle(element, 'position') == 'absolute') return element;
+
+    var offsets = Element.positionedOffset(element);
+    var top     = offsets[1];
+    var left    = offsets[0];
+    var width   = element.clientWidth;
+    var height  = element.clientHeight;
+
+    element._originalLeft   = left - parseFloat(element.style.left  || 0);
+    element._originalTop    = top  - parseFloat(element.style.top || 0);
+    element._originalWidth  = element.style.width;
+    element._originalHeight = element.style.height;
+
+    element.style.position = 'absolute';
+    element.style.top    = top + 'px';
+    element.style.left   = left + 'px';
+    element.style.width  = width + 'px';
+    element.style.height = height + 'px';
+    return element;
+  },
+
+  relativize: function(element) {
+    element = $(element);
+    if (Element.getStyle(element, 'position') == 'relative') return element;
+
+    element.style.position = 'relative';
+    var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
+    var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
+
+    element.style.top    = top + 'px';
+    element.style.left   = left + 'px';
+    element.style.height = element._originalHeight;
+    element.style.width  = element._originalWidth;
+    return element;
+  },
+
+  cumulativeScrollOffset: function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.scrollTop  || 0;
+      valueL += element.scrollLeft || 0;
+      element = element.parentNode;
+    } while (element);
+    return Element._returnOffset(valueL, valueT);
+  },
+
+  getOffsetParent: function(element) {
+    if (element.offsetParent) return $(element.offsetParent);
+    if (element == document.body) return $(element);
+
+    while ((element = element.parentNode) && element != document.body)
+      if (Element.getStyle(element, 'position') != 'static')
+        return $(element);
+
+    return $(document.body);
+  },
+
+  viewportOffset: function(forElement) {
+    var valueT = 0, valueL = 0;
+
+    var element = forElement;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+
+      if (element.offsetParent == document.body &&
+        Element.getStyle(element, 'position') == 'absolute') break;
+
+    } while (element = element.offsetParent);
+
+    element = forElement;
+    do {
+      if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) {
+        valueT -= element.scrollTop  || 0;
+        valueL -= element.scrollLeft || 0;
+      }
+    } while (element = element.parentNode);
+
+    return Element._returnOffset(valueL, valueT);
+  },
+
+  clonePosition: function(element, source) {
+    var options = Object.extend({
+      setLeft:    true,
+      setTop:     true,
+      setWidth:   true,
+      setHeight:  true,
+      offsetTop:  0,
+      offsetLeft: 0
+    }, arguments[2] || { });
+
+    source = $(source);
+    var p = Element.viewportOffset(source);
+
+    element = $(element);
+    var delta = [0, 0];
+    var parent = null;
+    if (Element.getStyle(element, 'position') == 'absolute') {
+      parent = Element.getOffsetParent(element);
+      delta = Element.viewportOffset(parent);
+    }
+
+    if (parent == document.body) {
+      delta[0] -= document.body.offsetLeft;
+      delta[1] -= document.body.offsetTop;
+    }
+
+    if (options.setLeft)   element.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
+    if (options.setTop)    element.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
+    if (options.setWidth)  element.style.width = source.offsetWidth + 'px';
+    if (options.setHeight) element.style.height = source.offsetHeight + 'px';
+    return element;
+  }
+};
+
+Object.extend(Element.Methods, {
+  getElementsBySelector: Element.Methods.select,
+
+  childElements: Element.Methods.immediateDescendants
+});
+
+Element._attributeTranslations = {
+  write: {
+    names: {
+      className: 'class',
+      htmlFor:   'for'
+    },
+    values: { }
+  }
+};
+
+if (Prototype.Browser.Opera) {
+  Element.Methods.getStyle = Element.Methods.getStyle.wrap(
+    function(proceed, element, style) {
+      switch (style) {
+        case 'left': case 'top': case 'right': case 'bottom':
+          if (proceed(element, 'position') === 'static') return null;
+        case 'height': case 'width':
+          if (!Element.visible(element)) return null;
+
+          var dim = parseInt(proceed(element, style), 10);
+
+          if (dim !== element['offset' + style.capitalize()])
+            return dim + 'px';
+
+          var properties;
+          if (style === 'height') {
+            properties = ['border-top-width', 'padding-top',
+             'padding-bottom', 'border-bottom-width'];
+          }
+          else {
+            properties = ['border-left-width', 'padding-left',
+             'padding-right', 'border-right-width'];
+          }
+          return properties.inject(dim, function(memo, property) {
+            var val = proceed(element, property);
+            return val === null ? memo : memo - parseInt(val, 10);
+          }) + 'px';
+        default: return proceed(element, style);
+      }
+    }
+  );
+
+  Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
+    function(proceed, element, attribute) {
+      if (attribute === 'title') return element.title;
+      return proceed(element, attribute);
+    }
+  );
+}
+
+else if (Prototype.Browser.IE) {
+  Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
+    function(proceed, element) {
+      element = $(element);
+      try { element.offsetParent }
+      catch(e) { return $(document.body) }
+      var position = element.getStyle('position');
+      if (position !== 'static') return proceed(element);
+      element.setStyle({ position: 'relative' });
+      var value = proceed(element);
+      element.setStyle({ position: position });
+      return value;
+    }
+  );
+
+  $w('positionedOffset viewportOffset').each(function(method) {
+    Element.Methods[method] = Element.Methods[method].wrap(
+      function(proceed, element) {
+        element = $(element);
+        try { element.offsetParent }
+        catch(e) { return Element._returnOffset(0,0) }
+        var position = element.getStyle('position');
+        if (position !== 'static') return proceed(element);
+        var offsetParent = element.getOffsetParent();
+        if (offsetParent && offsetParent.getStyle('position') === 'fixed')
+          offsetParent.setStyle({ zoom: 1 });
+        element.setStyle({ position: 'relative' });
+        var value = proceed(element);
+        element.setStyle({ position: position });
+        return value;
+      }
+    );
+  });
+
+  Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
+    function(proceed, element) {
+      try { element.offsetParent }
+      catch(e) { return Element._returnOffset(0,0) }
+      return proceed(element);
+    }
+  );
+
+  Element.Methods.getStyle = function(element, style) {
+    element = $(element);
+    style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
+    var value = element.style[style];
+    if (!value && element.currentStyle) value = element.currentStyle[style];
+
+    if (style == 'opacity') {
+      if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
+        if (value[1]) return parseFloat(value[1]) / 100;
+      return 1.0;
+    }
+
+    if (value == 'auto') {
+      if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
+        return element['offset' + style.capitalize()] + 'px';
+      return null;
+    }
+    return value;
+  };
+
+  Element.Methods.setOpacity = function(element, value) {
+    function stripAlpha(filter){
+      return filter.replace(/alpha\([^\)]*\)/gi,'');
+    }
+    element = $(element);
+    var currentStyle = element.currentStyle;
+    if ((currentStyle && !currentStyle.hasLayout) ||
+      (!currentStyle && element.style.zoom == 'normal'))
+        element.style.zoom = 1;
+
+    var filter = element.getStyle('filter'), style = element.style;
+    if (value == 1 || value === '') {
+      (filter = stripAlpha(filter)) ?
+        style.filter = filter : style.removeAttribute('filter');
+      return element;
+    } else if (value < 0.00001) value = 0;
+    style.filter = stripAlpha(filter) +
+      'alpha(opacity=' + (value * 100) + ')';
+    return element;
+  };
+
+  Element._attributeTranslations = (function(){
+
+    var classProp = 'className';
+    var forProp = 'for';
+
+    var el = document.createElement('div');
+
+    el.setAttribute(classProp, 'x');
+
+    if (el.className !== 'x') {
+      el.setAttribute('class', 'x');
+      if (el.className === 'x') {
+        classProp = 'class';
+      }
+    }
+    el = null;
+
+    el = document.createElement('label');
+    el.setAttribute(forProp, 'x');
+    if (el.htmlFor !== 'x') {
+      el.setAttribute('htmlFor', 'x');
+      if (el.htmlFor === 'x') {
+        forProp = 'htmlFor';
+      }
+    }
+    el = null;
+
+    return {
+      read: {
+        names: {
+          'class':      classProp,
+          'className':  classProp,
+          'for':        forProp,
+          'htmlFor':    forProp
+        },
+        values: {
+          _getAttr: function(element, attribute) {
+            return element.getAttribute(attribute);
+          },
+          _getAttr2: function(element, attribute) {
+            return element.getAttribute(attribute, 2);
+          },
+          _getAttrNode: function(element, attribute) {
+            var node = element.getAttributeNode(attribute);
+            return node ? node.value : "";
+          },
+          _getEv: (function(){
+
+            var el = document.createElement('div');
+            el.onclick = Prototype.emptyFunction;
+            var value = el.getAttribute('onclick');
+            var f;
+
+            if (String(value).indexOf('{') > -1) {
+              f = function(element, attribute) {
+                attribute = element.getAttribute(attribute);
+                if (!attribute) return null;
+                attribute = attribute.toString();
+                attribute = attribute.split('{')[1];
+                attribute = attribute.split('}')[0];
+                return attribute.strip();
+              };
+            }
+            else if (value === '') {
+              f = function(element, attribute) {
+                attribute = element.getAttribute(attribute);
+                if (!attribute) return null;
+                return attribute.strip();
+              };
+            }
+            el = null;
+            return f;
+          })(),
+          _flag: function(element, attribute) {
+            return $(element).hasAttribute(attribute) ? attribute : null;
+          },
+          style: function(element) {
+            return element.style.cssText.toLowerCase();
+          },
+          title: function(element) {
+            return element.title;
+          }
+        }
+      }
+    }
+  })();
+
+  Element._attributeTranslations.write = {
+    names: Object.extend({
+      cellpadding: 'cellPadding',
+      cellspacing: 'cellSpacing'
+    }, Element._attributeTranslations.read.names),
+    values: {
+      checked: function(element, value) {
+        element.checked = !!value;
+      },
+
+      style: function(element, value) {
+        element.style.cssText = value ? value : '';
+      }
+    }
+  };
+
+  Element._attributeTranslations.has = {};
+
+  $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
+      'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
+    Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
+    Element._attributeTranslations.has[attr.toLowerCase()] = attr;
+  });
+
+  (function(v) {
+    Object.extend(v, {
+      href:        v._getAttr2,
+      src:         v._getAttr2,
+      type:        v._getAttr,
+      action:      v._getAttrNode,
+      disabled:    v._flag,
+      checked:     v._flag,
+      readonly:    v._flag,
+      multiple:    v._flag,
+      onload:      v._getEv,
+      onunload:    v._getEv,
+      onclick:     v._getEv,
+      ondblclick:  v._getEv,
+      onmousedown: v._getEv,
+      onmouseup:   v._getEv,
+      onmouseover: v._getEv,
+      onmousemove: v._getEv,
+      onmouseout:  v._getEv,
+      onfocus:     v._getEv,
+      onblur:      v._getEv,
+      onkeypress:  v._getEv,
+      onkeydown:   v._getEv,
+      onkeyup:     v._getEv,
+      onsubmit:    v._getEv,
+      onreset:     v._getEv,
+      onselect:    v._getEv,
+      onchange:    v._getEv
+    });
+  })(Element._attributeTranslations.read.values);
+
+  if (Prototype.BrowserFeatures.ElementExtensions) {
+    (function() {
+      function _descendants(element) {
+        var nodes = element.getElementsByTagName('*'), results = [];
+        for (var i = 0, node; node = nodes[i]; i++)
+          if (node.tagName !== "!") // Filter out comment nodes.
+            results.push(node);
+        return results;
+      }
+
+      Element.Methods.down = function(element, expression, index) {
+        element = $(element);
+        if (arguments.length == 1) return element.firstDescendant();
+        return Object.isNumber(expression) ? _descendants(element)[expression] :
+          Element.select(element, expression)[index || 0];
+      }
+    })();
+  }
+
+}
+
+else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
+  Element.Methods.setOpacity = function(element, value) {
+    element = $(element);
+    element.style.opacity = (value == 1) ? 0.999999 :
+      (value === '') ? '' : (value < 0.00001) ? 0 : value;
+    return element;
+  };
+}
+
+else if (Prototype.Browser.WebKit) {
+  Element.Methods.setOpacity = function(element, value) {
+    element = $(element);
+    element.style.opacity = (value == 1 || value === '') ? '' :
+      (value < 0.00001) ? 0 : value;
+
+    if (value == 1)
+      if(element.tagName.toUpperCase() == 'IMG' && element.width) {
+        element.width++; element.width--;
+      } else try {
+        var n = document.createTextNode(' ');
+        element.appendChild(n);
+        element.removeChild(n);
+      } catch (e) { }
+
+    return element;
+  };
+
+  Element.Methods.cumulativeOffset = function(element) {
+    var valueT = 0, valueL = 0;
+    do {
+      valueT += element.offsetTop  || 0;
+      valueL += element.offsetLeft || 0;
+      if (element.offsetParent == document.body)
+        if (Element.getStyle(element, 'position') == 'absolute') break;
+
+      element = element.offsetParent;
+    } while (element);
+
+    return Element._returnOffset(valueL, valueT);
+  };
+}
+
+if ('outerHTML' in document.documentElement) {
+  Element.Methods.replace = function(element, content) {
+    element = $(element);
+
+    if (content && content.toElement) content = content.toElement();
+    if (Object.isElement(content)) {
+      element.parentNode.replaceChild(content, element);
+      return element;
+    }
+
+    content = Object.toHTML(content);
+    var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
+
+    if (Element._insertionTranslations.tags[tagName]) {
+      var nextSibling = element.next();
+      var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
+      parent.removeChild(element);
+      if (nextSibling)
+        fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
+      else
+        fragments.each(function(node) { parent.appendChild(node) });
+    }
+    else element.outerHTML = content.stripScripts();
+
+    content.evalScripts.bind(content).defer();
+    return element;
+  };
+}
+
+Element._returnOffset = function(l, t) {
+  var result = [l, t];
+  result.left = l;
+  result.top = t;
+  return result;
+};
+
+Element._getContentFromAnonymousElement = function(tagName, html) {
+  var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
+  if (t) {
+    div.innerHTML = t[0] + html + t[1];
+    t[2].times(function() { div = div.firstChild });
+  } else div.innerHTML = html;
+  return $A(div.childNodes);
+};
+
+Element._insertionTranslations = {
+  before: function(element, node) {
+    element.parentNode.insertBefore(node, element);
+  },
+  top: function(element, node) {
+    element.insertBefore(node, element.firstChild);
+  },
+  bottom: function(element, node) {
+    element.appendChild(node);
+  },
+  after: function(element, node) {
+    element.parentNode.insertBefore(node, element.nextSibling);
+  },
+  tags: {
+    TABLE:  ['<table>',                '</table>',                   1],
+    TBODY:  ['<table><tbody>',         '</tbody></table>',           2],
+    TR:     ['<table><tbody><tr>',     '</tr></tbody></table>',      3],
+    TD:     ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
+    SELECT: ['<select>',               '</select>',                  1]
+  }
+};
+
+(function() {
+  var tags = Element._insertionTranslations.tags;
+  Object.extend(tags, {
+    THEAD: tags.TBODY,
+    TFOOT: tags.TBODY,
+    TH:    tags.TD
+  });
+})();
+
+Element.Methods.Simulated = {
+  hasAttribute: function(element, attribute) {
+    attribute = Element._attributeTranslations.has[attribute] || attribute;
+    var node = $(element).getAttributeNode(attribute);
+    return !!(node && node.specified);
+  }
+};
+
+Element.Methods.ByTag = { };
+
+Object.extend(Element, Element.Methods);
+
+(function(div) {
+
+  if (!Prototype.BrowserFeatures.ElementExtensions && div['__proto__']) {
+    window.HTMLElement = { };
+    window.HTMLElement.prototype = div['__proto__'];
+    Prototype.BrowserFeatures.ElementExtensions = true;
+  }
+
+  div = null;
+
+})(document.createElement('div'))
+
+Element.extend = (function() {
+
+  function checkDeficiency(tagName) {
+    if (typeof window.Element != 'undefined') {
+      var proto = window.Element.prototype;
+      if (proto) {
+        var id = '_' + (Math.random()+'').slice(2);
+        var el = document.createElement(tagName);
+        proto[id] = 'x';
+        var isBuggy = (el[id] !== 'x');
+        delete proto[id];
+        el = null;
+        return isBuggy;
+      }
+    }
+    return false;
+  }
+
+  function extendElementWith(element, methods) {
+    for (var property in methods) {
+      var value = methods[property];
+      if (Object.isFunction(value) && !(property in element))
+        element[property] = value.methodize();
+    }
+  }
+
+  var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY = checkDeficiency('object');
+
+  if (Prototype.BrowserFeatures.SpecificElementExtensions) {
+    if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY) {
+      return function(element) {
+        if (element && typeof element._extendedByPrototype == 'undefined') {
+          var t = element.tagName;
+          if (t && (/^(?:object|applet|embed)$/i.test(t))) {
+            extendElementWith(element, Element.Methods);
+            extendElementWith(element, Element.Methods.Simulated);
+            extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]);
+          }
+        }
+        return element;
+      }
+    }
+    return Prototype.K;
+  }
+
+  var Methods = { }, ByTag = Element.Methods.ByTag;
+
+  var extend = Object.extend(function(element) {
+    if (!element || typeof element._extendedByPrototype != 'undefined' ||
+        element.nodeType != 1 || element == window) return element;
+
+    var methods = Object.clone(Methods),
+        tagName = element.tagName.toUpperCase();
+
+    if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
+
+    extendElementWith(element, methods);
+
+    element._extendedByPrototype = Prototype.emptyFunction;
+    return element;
+
+  }, {
+    refresh: function() {
+      if (!Prototype.BrowserFeatures.ElementExtensions) {
+        Object.extend(Methods, Element.Methods);
+        Object.extend(Methods, Element.Methods.Simulated);
+      }
+    }
+  });
+
+  extend.refresh();
+  return extend;
+})();
+
+Element.hasAttribute = function(element, attribute) {
+  if (element.hasAttribute) return element.hasAttribute(attribute);
+  return Element.Methods.Simulated.hasAttribute(element, attribute);
+};
+
+Element.addMethods = function(methods) {
+  var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
+
+  if (!methods) {
+    Object.extend(Form, Form.Methods);
+    Object.extend(Form.Element, Form.Element.Methods);
+    Object.extend(Element.Methods.ByTag, {
+      "FORM":     Object.clone(Form.Methods),
+      "INPUT":    Object.clone(Form.Element.Methods),
+      "SELECT":   Object.clone(Form.Element.Methods),
+      "TEXTAREA": Object.clone(Form.Element.Methods)
+    });
+  }
+
+  if (arguments.length == 2) {
+    var tagName = methods;
+    methods = arguments[1];
+  }
+
+  if (!tagName) Object.extend(Element.Methods, methods || { });
+  else {
+    if (Object.isArray(tagName)) tagName.each(extend);
+    else extend(tagName);
+  }
+
+  function extend(tagName) {
+    tagName = tagName.toUpperCase();
+    if (!Element.Methods.ByTag[tagName])
+      Element.Methods.ByTag[tagName] = { };
+    Object.extend(Element.Methods.ByTag[tagName], methods);
+  }
+
+  function copy(methods, destination, onlyIfAbsent) {
+    onlyIfAbsent = onlyIfAbsent || false;
+    for (var property in methods) {
+      var value = methods[property];
+      if (!Object.isFunction(value)) continue;
+      if (!onlyIfAbsent || !(property in destination))
+        destination[property] = value.methodize();
+    }
+  }
+
+  function findDOMClass(tagName) {
+    var klass;
+    var trans = {
+      "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
+      "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
+      "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
+      "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
+      "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
+      "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
+      "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
+      "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
+      "FrameSet", "IFRAME": "IFrame"
+    };
+    if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
+    if (window[klass]) return window[klass];
+    klass = 'HTML' + tagName + 'Element';
+    if (window[klass]) return window[klass];
+    klass = 'HTML' + tagName.capitalize() + 'Element';
+    if (window[klass]) return window[klass];
+
+    var element = document.createElement(tagName);
+    var proto = element['__proto__'] || element.constructor.prototype;
+    element = null;
+    return proto;
+  }
+
+  var elementPrototype = window.HTMLElement ? HTMLElement.prototype :
+   Element.prototype;
+
+  if (F.ElementExtensions) {
+    copy(Element.Methods, elementPrototype);
+    copy(Element.Methods.Simulated, elementPrototype, true);
+  }
+
+  if (F.SpecificElementExtensions) {
+    for (var tag in Element.Methods.ByTag) {
+      var klass = findDOMClass(tag);
+      if (Object.isUndefined(klass)) continue;
+      copy(T[tag], klass.prototype);
+    }
+  }
+
+  Object.extend(Element, Element.Methods);
+  delete Element.ByTag;
+
+  if (Element.extend.refresh) Element.extend.refresh();
+  Element.cache = { };
+};
+
+
+document.viewport = {
+
+  getDimensions: function() {
+    return { width: this.getWidth(), height: this.getHeight() };
+  },
+
+  getScrollOffsets: function() {
+    return Element._returnOffset(
+      window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
+      window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop);
+  }
+};
+
+(function(viewport) {
+  var B = Prototype.Browser, doc = document, element, property = {};
+
+  function getRootElement() {
+    if (B.WebKit && !doc.evaluate)
+      return document;
+
+    if (B.Opera && window.parseFloat(window.opera.version()) < 9.5)
+      return document.body;
+
+    return document.documentElement;
+  }
+
+  function define(D) {
+    if (!element) element = getRootElement();
+
+    property[D] = 'client' + D;
+
+    viewport['get' + D] = function() { return element[property[D]] };
+    return viewport['get' + D]();
+  }
+
+  viewport.getWidth  = define.curry('Width');
+
+  viewport.getHeight = define.curry('Height');
+})(document.viewport);
+
+
+Element.Storage = {
+  UID: 1
+};
+
+Element.addMethods({
+  getStorage: function(element) {
+    if (!(element = $(element))) return;
+
+    var uid;
+    if (element === window) {
+      uid = 0;
+    } else {
+      if (typeof element._prototypeUID === "undefined")
+        element._prototypeUID = [Element.Storage.UID++];
+      uid = element._prototypeUID[0];
+    }
+
+    if (!Element.Storage[uid])
+      Element.Storage[uid] = $H();
+
+    return Element.Storage[uid];
+  },
+
+  store: function(element, key, value) {
+    if (!(element = $(element))) return;
+
+    if (arguments.length === 2) {
+      Element.getStorage(element).update(key);
+    } else {
+      Element.getStorage(element).set(key, value);
+    }
+
+    return element;
+  },
+
+  retrieve: function(element, key, defaultValue) {
+    if (!(element = $(element))) return;
+    var hash = Element.getStorage(element), value = hash.get(key);
+
+    if (Object.isUndefined(value)) {
+      hash.set(key, defaultValue);
+      value = defaultValue;
+    }
+
+    return value;
+  },
+
+  clone: function(element, deep) {
+    if (!(element = $(element))) return;
+    var clone = element.cloneNode(deep);
+    clone._prototypeUID = void 0;
+    if (deep) {
+      var descendants = Element.select(clone, '*'),
+          i = descendants.length;
+      while (i--) {
+        descendants[i]._prototypeUID = void 0;
+      }
+    }
+    return Element.extend(clone);
+  }
+});
+/* Portions of the Selector class are derived from Jack Slocum's DomQuery,
+ * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
+ * license.  Please see http://www.yui-ext.com/ for more information. */
+
+var Selector = Class.create({
+  initialize: function(expression) {
+    this.expression = expression.strip();
+
+    if (this.shouldUseSelectorsAPI()) {
+      this.mode = 'selectorsAPI';
+    } else if (this.shouldUseXPath()) {
+      this.mode = 'xpath';
+      this.compileXPathMatcher();
+    } else {
+      this.mode = "normal";
+      this.compileMatcher();
+    }
+
+  },
+
+  shouldUseXPath: (function() {
+
+    var IS_DESCENDANT_SELECTOR_BUGGY = (function(){
+      var isBuggy = false;
+      if (document.evaluate && window.XPathResult) {
+        var el = document.createElement('div');
+        el.innerHTML = '<ul><li></li></ul><div><ul><li></li></ul></div>';
+
+        var xpath = ".//*[local-name()='ul' or local-name()='UL']" +
+          "//*[local-name()='li' or local-name()='LI']";
+
+        var result = document.evaluate(xpath, el, null,
+          XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+
+        isBuggy = (result.snapshotLength !== 2);
+        el = null;
+      }
+      return isBuggy;
+    })();
+
+    return function() {
+      if (!Prototype.BrowserFeatures.XPath) return false;
+
+      var e = this.expression;
+
+      if (Prototype.Browser.WebKit &&
+       (e.include("-of-type") || e.include(":empty")))
+        return false;
+
+      if ((/(\[[\w-]*?:|:checked)/).test(e))
+        return false;
+
+      if (IS_DESCENDANT_SELECTOR_BUGGY) return false;
+
+      return true;
+    }
+
+  })(),
+
+  shouldUseSelectorsAPI: function() {
+    if (!Prototype.BrowserFeatures.SelectorsAPI) return false;
+
+    if (Selector.CASE_INSENSITIVE_CLASS_NAMES) return false;
+
+    if (!Selector._div) Selector._div = new Element('div');
+
+    try {
+      Selector._div.querySelector(this.expression);
+    } catch(e) {
+      return false;
+    }
+
+    return true;
+  },
+
+  compileMatcher: function() {
+    var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
+        c = Selector.criteria, le, p, m, len = ps.length, name;
+
+    if (Selector._cache[e]) {
+      this.matcher = Selector._cache[e];
+      return;
+    }
+
+    this.matcher = ["this.matcher = function(root) {",
+                    "var r = root, h = Selector.handlers, c = false, n;"];
+
+    while (e && le != e && (/\S/).test(e)) {
+      le = e;
+      for (var i = 0; i<len; i++) {
+        p = ps[i].re;
+        name = ps[i].name;
+        if (m = e.match(p)) {
+          this.matcher.push(Object.isFunction(c[name]) ? c[name](m) :
+            new Template(c[name]).evaluate(m));
+          e = e.replace(m[0], '');
+          break;
+        }
+      }
+    }
+
+    this.matcher.push("return h.unique(n);\n}");
+    eval(this.matcher.join('\n'));
+    Selector._cache[this.expression] = this.matcher;
+  },
+
+  compileXPathMatcher: function() {
+    var e = this.expression, ps = Selector.patterns,
+        x = Selector.xpath, le, m, len = ps.length, name;
+
+    if (Selector._cache[e]) {
+      this.xpath = Selector._cache[e]; return;
+    }
+
+    this.matcher = ['.//*'];
+    while (e && le != e && (/\S/).test(e)) {
+      le = e;
+      for (var i = 0; i<len; i++) {
+        name = ps[i].name;
+        if (m = e.match(ps[i].re)) {
+          this.matcher.push(Object.isFunction(x[name]) ? x[name](m) :
+            new Template(x[name]).evaluate(m));
+          e = e.replace(m[0], '');
+          break;
+        }
+      }
+    }
+
+    this.xpath = this.matcher.join('');
+    Selector._cache[this.expression] = this.xpath;
+  },
+
+  findElements: function(root) {
+    root = root || document;
+    var e = this.expression, results;
+
+    switch (this.mode) {
+      case 'selectorsAPI':
+        if (root !== document) {
+          var oldId = root.id, id = $(root).identify();
+          id = id.replace(/([\.:])/g, "\\$1");
+          e = "#" + id + " " + e;
+        }
+
+        results = $A(root.querySelectorAll(e)).map(Element.extend);
+        root.id = oldId;
+
+        return results;
+      case 'xpath':
+        return document._getElementsByXPath(this.xpath, root);
+      default:
+       return this.matcher(root);
+    }
+  },
+
+  match: function(element) {
+    this.tokens = [];
+
+    var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
+    var le, p, m, len = ps.length, name;
+
+    while (e && le !== e && (/\S/).test(e)) {
+      le = e;
+      for (var i = 0; i<len; i++) {
+        p = ps[i].re;
+        name = ps[i].name;
+        if (m = e.match(p)) {
+          if (as[name]) {
+            this.tokens.push([name, Object.clone(m)]);
+            e = e.replace(m[0], '');
+          } else {
+            return this.findElements(document).include(element);
+          }
+        }
+      }
+    }
+
+    var match = true, name, matches;
+    for (var i = 0, token; token = this.tokens[i]; i++) {
+      name = token[0], matches = token[1];
+      if (!Selector.assertions[name](element, matches)) {
+        match = false; break;
+      }
+    }
+
+    return match;
+  },
+
+  toString: function() {
+    return this.expression;
+  },
+
+  inspect: function() {
+    return "#<Selector:" + this.expression.inspect() + ">";
+  }
+});
+
+if (Prototype.BrowserFeatures.SelectorsAPI &&
+ document.compatMode === 'BackCompat') {
+  Selector.CASE_INSENSITIVE_CLASS_NAMES = (function(){
+    var div = document.createElement('div'),
+     span = document.createElement('span');
+
+    div.id = "prototype_test_id";
+    span.className = 'Test';
+    div.appendChild(span);
+    var isIgnored = (div.querySelector('#prototype_test_id .test') !== null);
+    div = span = null;
+    return isIgnored;
+  })();
+}
+
+Object.extend(Selector, {
+  _cache: { },
+
+  xpath: {
+    descendant:   "//*",
+    child:        "/*",
+    adjacent:     "/following-sibling::*[1]",
+    laterSibling: '/following-sibling::*',
+    tagName:      function(m) {
+      if (m[1] == '*') return '';
+      return "[local-name()='" + m[1].toLowerCase() +
+             "' or local-name()='" + m[1].toUpperCase() + "']";
+    },
+    className:    "[contains(concat(' ', @class, ' '), ' #{1} ')]",
+    id:           "[@id='#{1}']",
+    attrPresence: function(m) {
+      m[1] = m[1].toLowerCase();
+      return new Template("[@#{1}]").evaluate(m);
+    },
+    attr: function(m) {
+      m[1] = m[1].toLowerCase();
+      m[3] = m[5] || m[6];
+      return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
+    },
+    pseudo: function(m) {
+      var h = Selector.xpath.pseudos[m[1]];
+      if (!h) return '';
+      if (Object.isFunction(h)) return h(m);
+      return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
+    },
+    operators: {
+      '=':  "[@#{1}='#{3}']",
+      '!=': "[@#{1}!='#{3}']",
+      '^=': "[starts-with(@#{1}, '#{3}')]",
+      '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
+      '*=': "[contains(@#{1}, '#{3}')]",
+      '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
+      '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
+    },
+    pseudos: {
+      'first-child': '[not(preceding-sibling::*)]',
+      'last-child':  '[not(following-sibling::*)]',
+      'only-child':  '[not(preceding-sibling::* or following-sibling::*)]',
+      'empty':       "[count(*) = 0 and (count(text()) = 0)]",
+      'checked':     "[@checked]",
+      'disabled':    "[(@disabled) and (@type!='hidden')]",
+      'enabled':     "[not(@disabled) and (@type!='hidden')]",
+      'not': function(m) {
+        var e = m[6], p = Selector.patterns,
+            x = Selector.xpath, le, v, len = p.length, name;
+
+        var exclusion = [];
+        while (e && le != e && (/\S/).test(e)) {
+          le = e;
+          for (var i = 0; i<len; i++) {
+            name = p[i].name
+            if (m = e.match(p[i].re)) {
+              v = Object.isFunction(x[name]) ? x[name](m) : new Template(x[name]).evaluate(m);
+              exclusion.push("(" + v.substring(1, v.length - 1) + ")");
+              e = e.replace(m[0], '');
+              break;
+            }
+          }
+        }
+        return "[not(" + exclusion.join(" and ") + ")]";
+      },
+      'nth-child':      function(m) {
+        return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
+      },
+      'nth-last-child': function(m) {
+        return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
+      },
+      'nth-of-type':    function(m) {
+        return Selector.xpath.pseudos.nth("position() ", m);
+      },
+      'nth-last-of-type': function(m) {
+        return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
+      },
+      'first-of-type':  function(m) {
+        m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
+      },
+      'last-of-type':   function(m) {
+        m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
+      },
+      'only-of-type':   function(m) {
+        var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
+      },
+      nth: function(fragment, m) {
+        var mm, formula = m[6], predicate;
+        if (formula == 'even') formula = '2n+0';
+        if (formula == 'odd')  formula = '2n+1';
+        if (mm = formula.match(/^(\d+)$/)) // digit only
+          return '[' + fragment + "= " + mm[1] + ']';
+        if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
+          if (mm[1] == "-") mm[1] = -1;
+          var a = mm[1] ? Number(mm[1]) : 1;
+          var b = mm[2] ? Number(mm[2]) : 0;
+          predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
+          "((#{fragment} - #{b}) div #{a} >= 0)]";
+          return new Template(predicate).evaluate({
+            fragment: fragment, a: a, b: b });
+        }
+      }
+    }
+  },
+
+  criteria: {
+    tagName:      'n = h.tagName(n, r, "#{1}", c);      c = false;',
+    className:    'n = h.className(n, r, "#{1}", c);    c = false;',
+    id:           'n = h.id(n, r, "#{1}", c);           c = false;',
+    attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;',
+    attr: function(m) {
+      m[3] = (m[5] || m[6]);
+      return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m);
+    },
+    pseudo: function(m) {
+      if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
+      return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
+    },
+    descendant:   'c = "descendant";',
+    child:        'c = "child";',
+    adjacent:     'c = "adjacent";',
+    laterSibling: 'c = "laterSibling";'
+  },
+
+  patterns: [
+    { name: 'laterSibling', re: /^\s*~\s*/ },
+    { name: 'child',        re: /^\s*>\s*/ },
+    { name: 'adjacent',     re: /^\s*\+\s*/ },
+    { name: 'descendant',   re: /^\s/ },
+
+    { name: 'tagName',      re: /^\s*(\*|[\w\-]+)(\b|$)?/ },
+    { name: 'id',           re: /^#([\w\-\*]+)(\b|$)/ },
+    { name: 'className',    re: /^\.([\w\-\*]+)(\b|$)/ },
+    { name: 'pseudo',       re: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/ },
+    { name: 'attrPresence', re: /^\[((?:[\w-]+:)?[\w-]+)\]/ },
+    { name: 'attr',         re: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ }
+  ],
+
+  assertions: {
+    tagName: function(element, matches) {
+      return matches[1].toUpperCase() == element.tagName.toUpperCase();
+    },
+
+    className: function(element, matches) {
+      return Element.hasClassName(element, matches[1]);
+    },
+
+    id: function(element, matches) {
+      return element.id === matches[1];
+    },
+
+    attrPresence: function(element, matches) {
+      return Element.hasAttribute(element, matches[1]);
+    },
+
+    attr: function(element, matches) {
+      var nodeValue = Element.readAttribute(element, matches[1]);
+      return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]);
+    }
+  },
+
+  handlers: {
+    concat: function(a, b) {
+      for (var i = 0, node; node = b[i]; i++)
+        a.push(node);
+      return a;
+    },
+
+    mark: function(nodes) {
+      var _true = Prototype.emptyFunction;
+      for (var i = 0, node; node = nodes[i]; i++)
+        node._countedByPrototype = _true;
+      return nodes;
+    },
+
+    unmark: (function(){
+
+      var PROPERTIES_ATTRIBUTES_MAP = (function(){
+        var el = document.createElement('div'),
+            isBuggy = false,
+            propName = '_countedByPrototype',
+            value = 'x'
+        el[propName] = value;
+        isBuggy = (el.getAttribute(propName) === value);
+        el = null;
+        return isBuggy;
+      })();
+
+      return PROPERTIES_ATTRIBUTES_MAP ?
+        function(nodes) {
+          for (var i = 0, node; node = nodes[i]; i++)
+            node.removeAttribute('_countedByPrototype');
+          return nodes;
+        } :
+        function(nodes) {
+          for (var i = 0, node; node = nodes[i]; i++)
+            node._countedByPrototype = void 0;
+          return nodes;
+        }
+    })(),
+
+    index: function(parentNode, reverse, ofType) {
+      parentNode._countedByPrototype = Prototype.emptyFunction;
+      if (reverse) {
+        for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
+          var node = nodes[i];
+          if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
+        }
+      } else {
+        for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
+          if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
+      }
+    },
+
+    unique: function(nodes) {
+      if (nodes.length == 0) return nodes;
+      var results = [], n;
+      for (var i = 0, l = nodes.length; i < l; i++)
+        if (typeof (n = nodes[i])._countedByPrototype == 'undefined') {
+          n._countedByPrototype = Prototype.emptyFunction;
+          results.push(Element.extend(n));
+        }
+      return Selector.handlers.unmark(results);
+    },
+
+    descendant: function(nodes) {
+      var h = Selector.handlers;
+      for (var i = 0, results = [], node; node = nodes[i]; i++)
+        h.concat(results, node.getElementsByTagName('*'));
+      return results;
+    },
+
+    child: function(nodes) {
+      var h = Selector.handlers;
+      for (var i = 0, results = [], node; node = nodes[i]; i++) {
+        for (var j = 0, child; child = node.childNodes[j]; j++)
+          if (child.nodeType == 1 && child.tagName != '!') results.push(child);
+      }
+      return results;
+    },
+
+    adjacent: function(nodes) {
+      for (var i = 0, results = [], node; node = nodes[i]; i++) {
+        var next = this.nextElementSibling(node);
+        if (next) results.push(next);
+      }
+      return results;
+    },
+
+    laterSibling: function(nodes) {
+      var h = Selector.handlers;
+      for (var i = 0, results = [], node; node = nodes[i]; i++)
+        h.concat(results, Element.nextSiblings(node));
+      return results;
+    },
+
+    nextElementSibling: function(node) {
+      while (node = node.nextSibling)
+        if (node.nodeType == 1) return node;
+      return null;
+    },
+
+    previousElementSibling: function(node) {
+      while (node = node.previousSibling)
+        if (node.nodeType == 1) return node;
+      return null;
+    },
+
+    tagName: function(nodes, root, tagName, combinator) {
+      var uTagName = tagName.toUpperCase();
+      var results = [], h = Selector.handlers;
+      if (nodes) {
+        if (combinator) {
+          if (combinator == "descendant") {
+            for (var i = 0, node; node = nodes[i]; i++)
+              h.concat(results, node.getElementsByTagName(tagName));
+            return results;
+          } else nodes = this[combinator](nodes);
+          if (tagName == "*") return nodes;
+        }
+        for (var i = 0, node; node = nodes[i]; i++)
+          if (node.tagName.toUpperCase() === uTagName) results.push(node);
+        return results;
+      } else return root.getElementsByTagName(tagName);
+    },
+
+    id: function(nodes, root, id, combinator) {
+      var targetNode = $(id), h = Selector.handlers;
+
+      if (root == document) {
+        if (!targetNode) return [];
+        if (!nodes) return [targetNode];
+      } else {
+        if (!root.sourceIndex || root.sourceIndex < 1) {
+          var nodes = root.getElementsByTagName('*');
+          for (var j = 0, node; node = nodes[j]; j++) {
+            if (node.id === id) return [node];
+          }
+        }
+      }
+
+      if (nodes) {
+        if (combinator) {
+          if (combinator == 'child') {
+            for (var i = 0, node; node = nodes[i]; i++)
+              if (targetNode.parentNode == node) return [targetNode];
+          } else if (combinator == 'descendant') {
+            for (var i = 0, node; node = nodes[i]; i++)
+              if (Element.descendantOf(targetNode, node)) return [targetNode];
+          } else if (combinator == 'adjacent') {
+            for (var i = 0, node; node = nodes[i]; i++)
+              if (Selector.handlers.previousElementSibling(targetNode) == node)
+                return [targetNode];
+          } else nodes = h[combinator](nodes);
+        }
+        for (var i = 0, node; node = nodes[i]; i++)
+          if (node == targetNode) return [targetNode];
+        return [];
+      }
+      return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
+    },
+
+    className: function(nodes, root, className, combinator) {
+      if (nodes && combinator) nodes = this[combinator](nodes);
+      return Selector.handlers.byClassName(nodes, root, className);
+    },
+
+    byClassName: function(nodes, root, className) {
+      if (!nodes) nodes = Selector.handlers.descendant([root]);
+      var needle = ' ' + className + ' ';
+      for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
+        nodeClassName = node.className;
+        if (nodeClassName.length == 0) continue;
+        if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
+          results.push(node);
+      }
+      return results;
+    },
+
+    attrPresence: function(nodes, root, attr, combinator) {
+      if (!nodes) nodes = root.getElementsByTagName("*");
+      if (nodes && combinator) nodes = this[combinator](nodes);
+      var results = [];
+      for (var i = 0, node; node = nodes[i]; i++)
+        if (Element.hasAttribute(node, attr)) results.push(node);
+      return results;
+    },
+
+    attr: function(nodes, root, attr, value, operator, combinator) {
+      if (!nodes) nodes = root.getElementsByTagName("*");
+      if (nodes && combinator) nodes = this[combinator](nodes);
+      var handler = Selector.operators[operator], results = [];
+      for (var i = 0, node; node = nodes[i]; i++) {
+        var nodeValue = Element.readAttribute(node, attr);
+        if (nodeValue === null) continue;
+        if (handler(nodeValue, value)) results.push(node);
+      }
+      return results;
+    },
+
+    pseudo: function(nodes, name, value, root, combinator) {
+      if (nodes && combinator) nodes = this[combinator](nodes);
+      if (!nodes) nodes = root.getElementsByTagName("*");
+      return Selector.pseudos[name](nodes, value, root);
+    }
+  },
+
+  pseudos: {
+    'first-child': function(nodes, value, root) {
+      for (var i = 0, results = [], node; node = nodes[i]; i++) {
+        if (Selector.handlers.previousElementSibling(node)) continue;
+          results.push(node);
+      }
+      return results;
+    },
+    'last-child': function(nodes, value, root) {
+      for (var i = 0, results = [], node; node = nodes[i]; i++) {
+        if (Selector.handlers.nextElementSibling(node)) continue;
+          results.push(node);
+      }
+      return results;
+    },
+    'only-child': function(nodes, value, root) {
+      var h = Selector.handlers;
+      for (var i = 0, results = [], node; node = nodes[i]; i++)
+        if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
+          results.push(node);
+      return results;
+    },
+    'nth-child':        function(nodes, formula, root) {
+      return Selector.pseudos.nth(nodes, formula, root);
+    },
+    'nth-last-child':   function(nodes, formula, root) {
+      return Selector.pseudos.nth(nodes, formula, root, true);
+    },
+    'nth-of-type':      function(nodes, formula, root) {
+      return Selector.pseudos.nth(nodes, formula, root, false, true);
+    },
+    'nth-last-of-type': function(nodes, formula, root) {
+      return Selector.pseudos.nth(nodes, formula, root, true, true);
+    },
+    'first-of-type':    function(nodes, formula, root) {
+      return Selector.pseudos.nth(nodes, "1", root, false, true);
+    },
+    'last-of-type':     function(nodes, formula, root) {
+      return Selector.pseudos.nth(nodes, "1", root, true, true);
+    },
+    'only-of-type':     function(nodes, formula, root) {
+      var p = Selector.pseudos;
+      return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
+    },
+
+    getIndices: function(a, b, total) {
+      if (a == 0) return b > 0 ? [b] : [];
+      return $R(1, total).inject([], function(memo, i) {
+        if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
+        return memo;
+      });
+    },
+
+    nth: function(nodes, formula, root, reverse, ofType) {
+      if (nodes.length == 0) return [];
+      if (formula == 'even') formula = '2n+0';
+      if (formula == 'odd')  formula = '2n+1';
+      var h = Selector.handlers, results = [], indexed = [], m;
+      h.mark(nodes);
+      for (var i = 0, node; node = nodes[i]; i++) {
+        if (!node.parentNode._countedByPrototype) {
+          h.index(node.parentNode, reverse, ofType);
+          indexed.push(node.parentNode);
+        }
+      }
+      if (formula.match(/^\d+$/)) { // just a number
+        formula = Number(formula);
+        for (var i = 0, node; node = nodes[i]; i++)
+          if (node.nodeIndex == formula) results.push(node);
+      } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
+        if (m[1] == "-") m[1] = -1;
+        var a = m[1] ? Number(m[1]) : 1;
+        var b = m[2] ? Number(m[2]) : 0;
+        var indices = Selector.pseudos.getIndices(a, b, nodes.length);
+        for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
+          for (var j = 0; j < l; j++)
+            if (node.nodeIndex == indices[j]) results.push(node);
+        }
+      }
+      h.unmark(nodes);
+      h.unmark(indexed);
+      return results;
+    },
+
+    'empty': function(nodes, value, root) {
+      for (var i = 0, results = [], node; node = nodes[i]; i++) {
+        if (node.tagName == '!' || node.firstChild) continue;
+        results.push(node);
+      }
+      return results;
+    },
+
+    'not': function(nodes, selector, root) {
+      var h = Selector.handlers, selectorType, m;
+      var exclusions = new Selector(selector).findElements(root);
+      h.mark(exclusions);
+      for (var i = 0, results = [], node; node = nodes[i]; i++)
+        if (!node._countedByPrototype) results.push(node);
+      h.unmark(exclusions);
+      return results;
+    },
+
+    'enabled': function(nodes, value, root) {
+      for (var i = 0, results = [], node; node = nodes[i]; i++)
+        if (!node.disabled && (!node.type || node.type !== 'hidden'))
+          results.push(node);
+      return results;
+    },
+
+    'disabled': function(nodes, value, root) {
+      for (var i = 0, results = [], node; node = nodes[i]; i++)
+        if (node.disabled) results.push(node);
+      return results;
+    },
+
+    'checked': function(nodes, value, root) {
+      for (var i = 0, results = [], node; node = nodes[i]; i++)
+        if (node.checked) results.push(node);
+      return results;
+    }
+  },
+
+  operators: {
+    '=':  function(nv, v) { return nv == v; },
+    '!=': function(nv, v) { return nv != v; },
+    '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); },
+    '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); },
+    '*=': function(nv, v) { return nv == v || nv && nv.include(v); },
+    '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
+    '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() +
+     '-').include('-' + (v || "").toUpperCase() + '-'); }
+  },
+
+  split: function(expression) {
+    var expressions = [];
+    expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
+      expressions.push(m[1].strip());
+    });
+    return expressions;
+  },
+
+  matchElements: function(elements, expression) {
+    var matches = $$(expression), h = Selector.handlers;
+    h.mark(matches);
+    for (var i = 0, results = [], element; element = elements[i]; i++)
+      if (element._countedByPrototype) results.push(element);
+    h.unmark(matches);
+    return results;
+  },
+
+  findElement: function(elements, expression, index) {
+    if (Object.isNumber(expression)) {
+      index = expression; expression = false;
+    }
+    return Selector.matchElements(elements, expression || '*')[index || 0];
+  },
+
+  findChildElements: function(element, expressions) {
+    expressions = Selector.split(expressions.join(','));
+    var results = [], h = Selector.handlers;
+    for (var i = 0, l = expressions.length, selector; i < l; i++) {
+      selector = new Selector(expressions[i].strip());
+      h.concat(results, selector.findElements(element));
+    }
+    return (l > 1) ? h.unique(results) : results;
+  }
+});
+
+if (Prototype.Browser.IE) {
+  Object.extend(Selector.handlers, {
+    concat: function(a, b) {
+      for (var i = 0, node; node = b[i]; i++)
+        if (node.tagName !== "!") a.push(node);
+      return a;
+    }
+  });
+}
+
+function $$() {
+  return Selector.findChildElements(document, $A(arguments));
+}
+
+var Form = {
+  reset: function(form) {
+    form = $(form);
+    form.reset();
+    return form;
+  },
+
+  serializeElements: function(elements, options) {
+    if (typeof options != 'object') options = { hash: !!options };
+    else if (Object.isUndefined(options.hash)) options.hash = true;
+    var key, value, submitted = false, submit = options.submit;
+
+    var data = elements.inject({ }, function(result, element) {
+      if (!element.disabled && element.name) {
+        key = element.name; value = $(element).getValue();
+        if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
+            submit !== false && (!submit || key == submit) && (submitted = true)))) {
+          if (key in result) {
+            if (!Object.isArray(result[key])) result[key] = [result[key]];
+            result[key].push(value);
+          }
+          else result[key] = value;
+        }
+      }
+      return result;
+    });
+
+    return options.hash ? data : Object.toQueryString(data);
+  }
+};
+
+Form.Methods = {
+  serialize: function(form, options) {
+    return Form.serializeElements(Form.getElements(form), options);
+  },
+
+  getElements: function(form) {
+    var elements = $(form).getElementsByTagName('*'),
+        element,
+        arr = [ ],
+        serializers = Form.Element.Serializers;
+    for (var i = 0; element = elements[i]; i++) {
+      arr.push(element);
+    }
+    return arr.inject([], function(elements, child) {
+      if (serializers[child.tagName.toLowerCase()])
+        elements.push(Element.extend(child));
+      return elements;
+    })
+  },
+
+  getInputs: function(form, typeName, name) {
+    form = $(form);
+    var inputs = form.getElementsByTagName('input');
+
+    if (!typeName && !name) return $A(inputs).map(Element.extend);
+
+    for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
+      var input = inputs[i];
+      if ((typeName && input.type != typeName) || (name && input.name != name))
+        continue;
+      matchingInputs.push(Element.extend(input));
+    }
+
+    return matchingInputs;
+  },
+
+  disable: function(form) {
+    form = $(form);
+    Form.getElements(form).invoke('disable');
+    return form;
+  },
+
+  enable: function(form) {
+    form = $(form);
+    Form.getElements(form).invoke('enable');
+    return form;
+  },
+
+  findFirstElement: function(form) {
+    var elements = $(form).getElements().findAll(function(element) {
+      return 'hidden' != element.type && !element.disabled;
+    });
+    var firstByIndex = elements.findAll(function(element) {
+      return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
+    }).sortBy(function(element) { return element.tabIndex }).first();
+
+    return firstByIndex ? firstByIndex : elements.find(function(element) {
+      return /^(?:input|select|textarea)$/i.test(element.tagName);
+    });
+  },
+
+  focusFirstElement: function(form) {
+    form = $(form);
+    form.findFirstElement().activate();
+    return form;
+  },
+
+  request: function(form, options) {
+    form = $(form), options = Object.clone(options || { });
+
+    var params = options.parameters, action = form.readAttribute('action') || '';
+    if (action.blank()) action = window.location.href;
+    options.parameters = form.serialize(true);
+
+    if (params) {
+      if (Object.isString(params)) params = params.toQueryParams();
+      Object.extend(options.parameters, params);
+    }
+
+    if (form.hasAttribute('method') && !options.method)
+      options.method = form.method;
+
+    return new Ajax.Request(action, options);
+  }
+};
+
+/*--------------------------------------------------------------------------*/
+
+
+Form.Element = {
+  focus: function(element) {
+    $(element).focus();
+    return element;
+  },
+
+  select: function(element) {
+    $(element).select();
+    return element;
+  }
+};
+
+Form.Element.Methods = {
+
+  serialize: function(element) {
+    element = $(element);
+    if (!element.disabled && element.name) {
+      var value = element.getValue();
+      if (value != undefined) {
+        var pair = { };
+        pair[element.name] = value;
+        return Object.toQueryString(pair);
+      }
+    }
+    return '';
+  },
+
+  getValue: function(element) {
+    element = $(element);
+    var method = element.tagName.toLowerCase();
+    return Form.Element.Serializers[method](element);
+  },
+
+  setValue: function(element, value) {
+    element = $(element);
+    var method = element.tagName.toLowerCase();
+    Form.Element.Serializers[method](element, value);
+    return element;
+  },
+
+  clear: function(element) {
+    $(element).value = '';
+    return element;
+  },
+
+  present: function(element) {
+    return $(element).value != '';
+  },
+
+  activate: function(element) {
+    element = $(element);
+    try {
+      element.focus();
+      if (element.select && (element.tagName.toLowerCase() != 'input' ||
+          !(/^(?:button|reset|submit)$/i.test(element.type))))
+        element.select();
+    } catch (e) { }
+    return element;
+  },
+
+  disable: function(element) {
+    element = $(element);
+    element.disabled = true;
+    return element;
+  },
+
+  enable: function(element) {
+    element = $(element);
+    element.disabled = false;
+    return element;
+  }
+};
+
+/*--------------------------------------------------------------------------*/
+
+var Field = Form.Element;
+
+var $F = Form.Element.Methods.getValue;
+
+/*--------------------------------------------------------------------------*/
+
+Form.Element.Serializers = {
+  input: function(element, value) {
+    switch (element.type.toLowerCase()) {
+      case 'checkbox':
+      case 'radio':
+        return Form.Element.Serializers.inputSelector(element, value);
+      default:
+        return Form.Element.Serializers.textarea(element, value);
+    }
+  },
+
+  inputSelector: function(element, value) {
+    if (Object.isUndefined(value)) return element.checked ? element.value : null;
+    else element.checked = !!value;
+  },
+
+  textarea: function(element, value) {
+    if (Object.isUndefined(value)) return element.value;
+    else element.value = value;
+  },
+
+  select: function(element, value) {
+    if (Object.isUndefined(value))
+      return this[element.type == 'select-one' ?
+        'selectOne' : 'selectMany'](element);
+    else {
+      var opt, currentValue, single = !Object.isArray(value);
+      for (var i = 0, length = element.length; i < length; i++) {
+        opt = element.options[i];
+        currentValue = this.optionValue(opt);
+        if (single) {
+          if (currentValue == value) {
+            opt.selected = true;
+            return;
+          }
+        }
+        else opt.selected = value.include(currentValue);
+      }
+    }
+  },
+
+  selectOne: function(element) {
+    var index = element.selectedIndex;
+    return index >= 0 ? this.optionValue(element.options[index]) : null;
+  },
+
+  selectMany: function(element) {
+    var values, length = element.length;
+    if (!length) return null;
+
+    for (var i = 0, values = []; i < length; i++) {
+      var opt = element.options[i];
+      if (opt.selected) values.push(this.optionValue(opt));
+    }
+    return values;
+  },
+
+  optionValue: function(opt) {
+    return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
+  }
+};
+
+/*--------------------------------------------------------------------------*/
+
+
+Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
+  initialize: function($super, element, frequency, callback) {
+    $super(callback, frequency);
+    this.element   = $(element);
+    this.lastValue = this.getValue();
+  },
+
+  execute: function() {
+    var value = this.getValue();
+    if (Object.isString(this.lastValue) && Object.isString(value) ?
+        this.lastValue != value : String(this.lastValue) != String(value)) {
+      this.callback(this.element, value);
+      this.lastValue = value;
+    }
+  }
+});
+
+Form.Element.Observer = Class.create(Abstract.TimedObserver, {
+  getValue: function() {
+    return Form.Element.getValue(this.element);
+  }
+});
+
+Form.Observer = Class.create(Abstract.TimedObserver, {
+  getValue: function() {
+    return Form.serialize(this.element);
+  }
+});
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.EventObserver = Class.create({
+  initialize: function(element, callback) {
+    this.element  = $(element);
+    this.callback = callback;
+
+    this.lastValue = this.getValue();
+    if (this.element.tagName.toLowerCase() == 'form')
+      this.registerFormCallbacks();
+    else
+      this.registerCallback(this.element);
+  },
+
+  onElementEvent: function() {
+    var value = this.getValue();
+    if (this.lastValue != value) {
+      this.callback(this.element, value);
+      this.lastValue = value;
+    }
+  },
+
+  registerFormCallbacks: function() {
+    Form.getElements(this.element).each(this.registerCallback, this);
+  },
+
+  registerCallback: function(element) {
+    if (element.type) {
+      switch (element.type.toLowerCase()) {
+        case 'checkbox':
+        case 'radio':
+          Event.observe(element, 'click', this.onElementEvent.bind(this));
+          break;
+        default:
+          Event.observe(element, 'change', this.onElementEvent.bind(this));
+          break;
+      }
+    }
+  }
+});
+
+Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
+  getValue: function() {
+    return Form.Element.getValue(this.element);
+  }
+});
+
+Form.EventObserver = Class.create(Abstract.EventObserver, {
+  getValue: function() {
+    return Form.serialize(this.element);
+  }
+});
+(function() {
+
+  var Event = {
+    KEY_BACKSPACE: 8,
+    KEY_TAB:       9,
+    KEY_RETURN:   13,
+    KEY_ESC:      27,
+    KEY_LEFT:     37,
+    KEY_UP:       38,
+    KEY_RIGHT:    39,
+    KEY_DOWN:     40,
+    KEY_DELETE:   46,
+    KEY_HOME:     36,
+    KEY_END:      35,
+    KEY_PAGEUP:   33,
+    KEY_PAGEDOWN: 34,
+    KEY_INSERT:   45,
+
+    cache: {}
+  };
+
+  var docEl = document.documentElement;
+  var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl
+    && 'onmouseleave' in docEl;
+
+  var _isButton;
+  if (Prototype.Browser.IE) {
+    var buttonMap = { 0: 1, 1: 4, 2: 2 };
+    _isButton = function(event, code) {
+      return event.button === buttonMap[code];
+    };
+  } else if (Prototype.Browser.WebKit) {
+    _isButton = function(event, code) {
+      switch (code) {
+        case 0: return event.which == 1 && !event.metaKey;
+        case 1: return event.which == 1 && event.metaKey;
+        default: return false;
+      }
+    };
+  } else {
+    _isButton = function(event, code) {
+      return event.which ? (event.which === code + 1) : (event.button === code);
+    };
+  }
+
+  function isLeftClick(event)   { return _isButton(event, 0) }
+
+  function isMiddleClick(event) { return _isButton(event, 1) }
+
+  function isRightClick(event)  { return _isButton(event, 2) }
+
+  function element(event) {
+    event = Event.extend(event);
+
+    var node = event.target, type = event.type,
+     currentTarget = event.currentTarget;
+
+    if (currentTarget && currentTarget.tagName) {
+      if (type === 'load' || type === 'error' ||
+        (type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
+          && currentTarget.type === 'radio'))
+            node = currentTarget;
+    }
+
+    if (node.nodeType == Node.TEXT_NODE)
+      node = node.parentNode;
+
+    return Element.extend(node);
+  }
+
+  function findElement(event, expression) {
+    var element = Event.element(event);
+    if (!expression) return element;
+    var elements = [element].concat(element.ancestors());
+    return Selector.findElement(elements, expression, 0);
+  }
+
+  function pointer(event) {
+    return { x: pointerX(event), y: pointerY(event) };
+  }
+
+  function pointerX(event) {
+    var docElement = document.documentElement,
+     body = document.body || { scrollLeft: 0 };
+
+    return event.pageX || (event.clientX +
+      (docElement.scrollLeft || body.scrollLeft) -
+      (docElement.clientLeft || 0));
+  }
+
+  function pointerY(event) {
+    var docElement = document.documentElement,
+     body = document.body || { scrollTop: 0 };
+
+    return  event.pageY || (event.clientY +
+       (docElement.scrollTop || body.scrollTop) -
+       (docElement.clientTop || 0));
+  }
+
+
+  function stop(event) {
+    Event.extend(event);
+    event.preventDefault();
+    event.stopPropagation();
+
+    event.stopped = true;
+  }
+
+  Event.Methods = {
+    isLeftClick: isLeftClick,
+    isMiddleClick: isMiddleClick,
+    isRightClick: isRightClick,
+
+    element: element,
+    findElement: findElement,
+
+    pointer: pointer,
+    pointerX: pointerX,
+    pointerY: pointerY,
+
+    stop: stop
+  };
+
+
+  var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
+    m[name] = Event.Methods[name].methodize();
+    return m;
+  });
+
+  if (Prototype.Browser.IE) {
+    function _relatedTarget(event) {
+      var element;
+      switch (event.type) {
+        case 'mouseover': element = event.fromElement; break;
+        case 'mouseout':  element = event.toElement;   break;
+        default: return null;
+      }
+      return Element.extend(element);
+    }
+
+    Object.extend(methods, {
+      stopPropagation: function() { this.cancelBubble = true },
+      preventDefault:  function() { this.returnValue = false },
+      inspect: function() { return '[object Event]' }
+    });
+
+    Event.extend = function(event, element) {
+      if (!event) return false;
+      if (event._extendedByPrototype) return event;
+
+      event._extendedByPrototype = Prototype.emptyFunction;
+      var pointer = Event.pointer(event);
+
+      Object.extend(event, {
+        target: event.srcElement || element,
+        relatedTarget: _relatedTarget(event),
+        pageX:  pointer.x,
+        pageY:  pointer.y
+      });
+
+      return Object.extend(event, methods);
+    };
+  } else {
+    Event.prototype = window.Event.prototype || document.createEvent('HTMLEvents').__proto__;
+    Object.extend(Event.prototype, methods);
+    Event.extend = Prototype.K;
+  }
+
+  function _createResponder(element, eventName, handler) {
+    var registry = Element.retrieve(element, 'prototype_event_registry');
+
+    if (Object.isUndefined(registry)) {
+      CACHE.push(element);
+      registry = Element.retrieve(element, 'prototype_event_registry', $H());
+    }
+
+    var respondersForEvent = registry.get(eventName);
+    if (Object.isUndefined(respondersForEvent)) {
+      respondersForEvent = [];
+      registry.set(eventName, respondersForEvent);
+    }
+
+    if (respondersForEvent.pluck('handler').include(handler)) return false;
+
+    var responder;
+    if (eventName.include(":")) {
+      responder = function(event) {
+        if (Object.isUndefined(event.eventName))
+          return false;
+
+        if (event.eventName !== eventName)
+          return false;
+
+        Event.extend(event, element);
+        handler.call(element, event);
+      };
+    } else {
+      if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED &&
+       (eventName === "mouseenter" || eventName === "mouseleave")) {
+        if (eventName === "mouseenter" || eventName === "mouseleave") {
+          responder = function(event) {
+            Event.extend(event, element);
+
+            var parent = event.relatedTarget;
+            while (parent && parent !== element) {
+              try { parent = parent.parentNode; }
+              catch(e) { parent = element; }
+            }
+
+            if (parent === element) return;
+
+            handler.call(element, event);
+          };
+        }
+      } else {
+        responder = function(event) {
+          Event.extend(event, element);
+          handler.call(element, event);
+        };
+      }
+    }
+
+    responder.handler = handler;
+    respondersForEvent.push(responder);
+    return responder;
+  }
+
+  function _destroyCache() {
+    for (var i = 0, length = CACHE.length; i < length; i++) {
+      Event.stopObserving(CACHE[i]);
+      CACHE[i] = null;
+    }
+  }
+
+  var CACHE = [];
+
+  if (Prototype.Browser.IE)
+    window.attachEvent('onunload', _destroyCache);
+
+  if (Prototype.Browser.WebKit)
+    window.addEventListener('unload', Prototype.emptyFunction, false);
+
+
+  var _getDOMEventName = Prototype.K;
+
+  if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) {
+    _getDOMEventName = function(eventName) {
+      var translations = { mouseenter: "mouseover", mouseleave: "mouseout" };
+      return eventName in translations ? translations[eventName] : eventName;
+    };
+  }
+
+  function observe(element, eventName, handler) {
+    element = $(element);
+
+    var responder = _createResponder(element, eventName, handler);
+
+    if (!responder) return element;
+
+    if (eventName.include(':')) {
+      if (element.addEventListener)
+        element.addEventListener("dataavailable", responder, false);
+      else {
+        element.attachEvent("ondataavailable", responder);
+        element.attachEvent("onfilterchange", responder);
+      }
+    } else {
+      var actualEventName = _getDOMEventName(eventName);
+
+      if (element.addEventListener)
+        element.addEventListener(actualEventName, responder, false);
+      else
+        element.attachEvent("on" + actualEventName, responder);
+    }
+
+    return element;
+  }
+
+  function stopObserving(element, eventName, handler) {
+    element = $(element);
+
+    var registry = Element.retrieve(element, 'prototype_event_registry');
+
+    if (Object.isUndefined(registry)) return element;
+
+    if (eventName && !handler) {
+      var responders = registry.get(eventName);
+
+      if (Object.isUndefined(responders)) return element;
+
+      responders.each( function(r) {
+        Element.stopObserving(element, eventName, r.handler);
+      });
+      return element;
+    } else if (!eventName) {
+      registry.each( function(pair) {
+        var eventName = pair.key, responders = pair.value;
+
+        responders.each( function(r) {
+          Element.stopObserving(element, eventName, r.handler);
+        });
+      });
+      return element;
+    }
+
+    var responders = registry.get(eventName);
+
+    if (!responders) return;
+
+    var responder = responders.find( function(r) { return r.handler === handler; });
+    if (!responder) return element;
+
+    var actualEventName = _getDOMEventName(eventName);
+
+    if (eventName.include(':')) {
+      if (element.removeEventListener)
+        element.removeEventListener("dataavailable", responder, false);
+      else {
+        element.detachEvent("ondataavailable", responder);
+        element.detachEvent("onfilterchange",  responder);
+      }
+    } else {
+      if (element.removeEventListener)
+        element.removeEventListener(actualEventName, responder, false);
+      else
+        element.detachEvent('on' + actualEventName, responder);
+    }
+
+    registry.set(eventName, responders.without(responder));
+
+    return element;
+  }
+
+  function fire(element, eventName, memo, bubble) {
+    element = $(element);
+
+    if (Object.isUndefined(bubble))
+      bubble = true;
+
+    if (element == document && document.createEvent && !element.dispatchEvent)
+      element = document.documentElement;
+
+    var event;
+    if (document.createEvent) {
+      event = document.createEvent('HTMLEvents');
+      event.initEvent('dataavailable', true, true);
+    } else {
+      event = document.createEventObject();
+      event.eventType = bubble ? 'ondataavailable' : 'onfilterchange';
+    }
+
+    event.eventName = eventName;
+    event.memo = memo || { };
+
+    if (document.createEvent)
+      element.dispatchEvent(event);
+    else
+      element.fireEvent(event.eventType, event);
+
+    return Event.extend(event);
+  }
+
+
+  Object.extend(Event, Event.Methods);
+
+  Object.extend(Event, {
+    fire:          fire,
+    observe:       observe,
+    stopObserving: stopObserving
+  });
+
+  Element.addMethods({
+    fire:          fire,
+
+    observe:       observe,
+
+    stopObserving: stopObserving
+  });
+
+  Object.extend(document, {
+    fire:          fire.methodize(),
+
+    observe:       observe.methodize(),
+
+    stopObserving: stopObserving.methodize(),
+
+    loaded:        false
+  });
+
+  if (window.Event) Object.extend(window.Event, Event);
+  else window.Event = Event;
+})();
+
+(function() {
+  /* Support for the DOMContentLoaded event is based on work by Dan Webb,
+     Matthias Miller, Dean Edwards, John Resig, and Diego Perini. */
+
+  var timer;
+
+  function fireContentLoadedEvent() {
+    if (document.loaded) return;
+    if (timer) window.clearTimeout(timer);
+    document.loaded = true;
+    document.fire('dom:loaded');
+  }
+
+  function checkReadyState() {
+    if (document.readyState === 'complete') {
+      document.stopObserving('readystatechange', checkReadyState);
+      fireContentLoadedEvent();
+    }
+  }
+
+  function pollDoScroll() {
+    try { document.documentElement.doScroll('left'); }
+    catch(e) {
+      timer = pollDoScroll.defer();
+      return;
+    }
+    fireContentLoadedEvent();
+  }
+
+  if (document.addEventListener) {
+    document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false);
+  } else {
+    document.observe('readystatechange', checkReadyState);
+    if (window == top)
+      timer = pollDoScroll.defer();
+  }
+
+  Event.observe(window, 'load', fireContentLoadedEvent);
+})();
+
+Element.addMethods();
+
+/*------------------------------- DEPRECATED -------------------------------*/
+
+Hash.toQueryString = Object.toQueryString;
+
+var Toggle = { display: Element.toggle };
+
+Element.Methods.childOf = Element.Methods.descendantOf;
+
+var Insertion = {
+  Before: function(element, content) {
+    return Element.insert(element, {before:content});
+  },
+
+  Top: function(element, content) {
+    return Element.insert(element, {top:content});
+  },
+
+  Bottom: function(element, content) {
+    return Element.insert(element, {bottom:content});
+  },
+
+  After: function(element, content) {
+    return Element.insert(element, {after:content});
+  }
+};
+
+var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
+
+var Position = {
+  includeScrollOffsets: false,
+
+  prepare: function() {
+    this.deltaX =  window.pageXOffset
+                || document.documentElement.scrollLeft
+                || document.body.scrollLeft
+                || 0;
+    this.deltaY =  window.pageYOffset
+                || document.documentElement.scrollTop
+                || document.body.scrollTop
+                || 0;
+  },
+
+  within: function(element, x, y) {
+    if (this.includeScrollOffsets)
+      return this.withinIncludingScrolloffsets(element, x, y);
+    this.xcomp = x;
+    this.ycomp = y;
+    this.offset = Element.cumulativeOffset(element);
+
+    return (y >= this.offset[1] &&
+            y <  this.offset[1] + element.offsetHeight &&
+            x >= this.offset[0] &&
+            x <  this.offset[0] + element.offsetWidth);
+  },
+
+  withinIncludingScrolloffsets: function(element, x, y) {
+    var offsetcache = Element.cumulativeScrollOffset(element);
+
+    this.xcomp = x + offsetcache[0] - this.deltaX;
+    this.ycomp = y + offsetcache[1] - this.deltaY;
+    this.offset = Element.cumulativeOffset(element);
+
+    return (this.ycomp >= this.offset[1] &&
+            this.ycomp <  this.offset[1] + element.offsetHeight &&
+            this.xcomp >= this.offset[0] &&
+            this.xcomp <  this.offset[0] + element.offsetWidth);
+  },
+
+  overlap: function(mode, element) {
+    if (!mode) return 0;
+    if (mode == 'vertical')
+      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
+        element.offsetHeight;
+    if (mode == 'horizontal')
+      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
+        element.offsetWidth;
+  },
+
+
+  cumulativeOffset: Element.Methods.cumulativeOffset,
+
+  positionedOffset: Element.Methods.positionedOffset,
+
+  absolutize: function(element) {
+    Position.prepare();
+    return Element.absolutize(element);
+  },
+
+  relativize: function(element) {
+    Position.prepare();
+    return Element.relativize(element);
+  },
+
+  realOffset: Element.Methods.cumulativeScrollOffset,
+
+  offsetParent: Element.Methods.getOffsetParent,
+
+  page: Element.Methods.viewportOffset,
+
+  clone: function(source, target, options) {
+    options = options || { };
+    return Element.clonePosition(target, source, options);
+  }
+};
+
+/*--------------------------------------------------------------------------*/
+
+if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
+  function iter(name) {
+    return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
+  }
+
+  instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
+  function(element, className) {
+    className = className.toString().strip();
+    var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
+    return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
+  } : function(element, className) {
+    className = className.toString().strip();
+    var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
+    if (!classNames && !className) return elements;
+
+    var nodes = $(element).getElementsByTagName('*');
+    className = ' ' + className + ' ';
+
+    for (var i = 0, child, cn; child = nodes[i]; i++) {
+      if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
+          (classNames && classNames.all(function(name) {
+            return !name.toString().blank() && cn.include(' ' + name + ' ');
+          }))))
+        elements.push(Element.extend(child));
+    }
+    return elements;
+  };
+
+  return function(className, parentElement) {
+    return $(parentElement || document.body).getElementsByClassName(className);
+  };
+}(Element.Methods);
+
+/*--------------------------------------------------------------------------*/
+
+Element.ClassNames = Class.create();
+Element.ClassNames.prototype = {
+  initialize: function(element) {
+    this.element = $(element);
+  },
+
+  _each: function(iterator) {
+    this.element.className.split(/\s+/).select(function(name) {
+      return name.length > 0;
+    })._each(iterator);
+  },
+
+  set: function(className) {
+    this.element.className = className;
+  },
+
+  add: function(classNameToAdd) {
+    if (this.include(classNameToAdd)) return;
+    this.set($A(this).concat(classNameToAdd).join(' '));
+  },
+
+  remove: function(classNameToRemove) {
+    if (!this.include(classNameToRemove)) return;
+    this.set($A(this).without(classNameToRemove).join(' '));
+  },
+
+  toString: function() {
+    return $A(this).join(' ');
+  }
+};
+
+Object.extend(Element.ClassNames.prototype, Enumerable);
+
+/*--------------------------------------------------------------------------*/
Index: /tags/3.1/wp-includes/js/quicktags.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/quicktags.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/quicktags.dev.js	(revision 17487)
@@ -0,0 +1,577 @@
+// new edit toolbar used with permission
+// by Alex King
+// http://www.alexking.org/
+
+var edButtons = new Array(), edLinks = new Array(), edOpenTags = new Array(), now = new Date(), datetime;
+
+function edButton(id, display, tagStart, tagEnd, access, open) {
+	this.id = id;				// used to name the toolbar button
+	this.display = display;		// label on button
+	this.tagStart = tagStart; 	// open tag
+	this.tagEnd = tagEnd;		// close tag
+	this.access = access;		// access key
+	this.open = open;			// set to -1 if tag does not need to be closed
+}
+
+function zeroise(number, threshold) {
+	// FIXME: or we could use an implementation of printf in js here
+	var str = number.toString();
+	if (number < 0) { str = str.substr(1, str.length) }
+	while (str.length < threshold) { str = "0" + str }
+	if (number < 0) { str = '-' + str }
+	return str;
+}
+
+datetime = now.getUTCFullYear() + '-' +
+zeroise(now.getUTCMonth() + 1, 2) + '-' +
+zeroise(now.getUTCDate(), 2) + 'T' +
+zeroise(now.getUTCHours(), 2) + ':' +
+zeroise(now.getUTCMinutes(), 2) + ':' +
+zeroise(now.getUTCSeconds() ,2) +
+'+00:00';
+
+edButtons[edButtons.length] =
+new edButton('ed_strong'
+,'b'
+,'<strong>'
+,'</strong>'
+,'b'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_em'
+,'i'
+,'<em>'
+,'</em>'
+,'i'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_link'
+,'link'
+,''
+,'</a>'
+,'a'
+); // special case
+
+edButtons[edButtons.length] =
+new edButton('ed_block'
+,'b-quote'
+,'\n\n<blockquote>'
+,'</blockquote>\n\n'
+,'q'
+);
+
+
+edButtons[edButtons.length] =
+new edButton('ed_del'
+,'del'
+,'<del datetime="' + datetime + '">'
+,'</del>'
+,'d'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_ins'
+,'ins'
+,'<ins datetime="' + datetime + '">'
+,'</ins>'
+,'s'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_img'
+,'img'
+,''
+,''
+,'m'
+,-1
+); // special case
+
+edButtons[edButtons.length] =
+new edButton('ed_ul'
+,'ul'
+,'<ul>\n'
+,'</ul>\n\n'
+,'u'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_ol'
+,'ol'
+,'<ol>\n'
+,'</ol>\n\n'
+,'o'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_li'
+,'li'
+,'\t<li>'
+,'</li>\n'
+,'l'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_code'
+,'code'
+,'<code>'
+,'</code>'
+,'c'
+);
+
+edButtons[edButtons.length] =
+new edButton('ed_more'
+,'more'
+,'<!--more-->'
+,''
+,'t'
+,-1
+);
+/*
+edButtons[edButtons.length] =
+new edButton('ed_next'
+,'page'
+,'<!--nextpage-->'
+,''
+,'p'
+,-1
+);
+*/
+function edLink() {
+	this.display = '';
+	this.URL = '';
+	this.newWin = 0;
+}
+
+edLinks[edLinks.length] = new edLink('WordPress'
+                                    ,'http://wordpress.org/'
+                                    );
+
+edLinks[edLinks.length] = new edLink('alexking.org'
+                                    ,'http://www.alexking.org/'
+                                    );
+
+function edShowButton(button, i) {
+	if (button.id == 'ed_img') {
+		document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />');
+	}
+	else if (button.id == 'ed_link') {
+		document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
+	}
+	else {
+		document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '"  />');
+	}
+}
+
+function edShowLinks() {
+	var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>' + quicktagsL10n.quickLinks + '</option>', i;
+	for (i = 0; i < edLinks.length; i++) {
+		tempStr += '<option value="' + i + '">' + edLinks[i].display + '</option>';
+	}
+	tempStr += '</select>';
+	document.write(tempStr);
+}
+
+function edAddTag(button) {
+	if (edButtons[button].tagEnd != '') {
+		edOpenTags[edOpenTags.length] = button;
+		document.getElementById(edButtons[button].id).value = '/' + document.getElementById(edButtons[button].id).value;
+	}
+}
+
+function edRemoveTag(button) {
+	for (var i = 0; i < edOpenTags.length; i++) {
+		if (edOpenTags[i] == button) {
+			edOpenTags.splice(i, 1);
+			document.getElementById(edButtons[button].id).value = 		document.getElementById(edButtons[button].id).value.replace('/', '');
+		}
+	}
+}
+
+function edCheckOpenTags(button) {
+	var tag = 0, i;
+	for (i = 0; i < edOpenTags.length; i++) {
+		if (edOpenTags[i] == button) {
+			tag++;
+		}
+	}
+	if (tag > 0) {
+		return true; // tag found
+	}
+	else {
+		return false; // tag not found
+	}
+}
+
+function edCloseAllTags() {
+	var count = edOpenTags.length, o;
+	for (o = 0; o < count; o++) {
+		edInsertTag(edCanvas, edOpenTags[edOpenTags.length - 1]);
+	}
+}
+
+function edQuickLink(i, thisSelect) {
+	if (i > -1) {
+		var newWin = '', tempStr;
+		if (edLinks[i].newWin == 1) {
+			newWin = ' target="_blank"';
+		}
+		tempStr = '<a href="' + edLinks[i].URL + '"' + newWin + '>'
+		            + edLinks[i].display
+		            + '</a>';
+		thisSelect.selectedIndex = 0;
+		edInsertContent(edCanvas, tempStr);
+	}
+	else {
+		thisSelect.selectedIndex = 0;
+	}
+}
+
+function edSpell(myField) {
+	var word = '', sel, startPos, endPos;
+	if (document.selection) {
+		myField.focus();
+	    sel = document.selection.createRange();
+		if (sel.text.length > 0) {
+			word = sel.text;
+		}
+	}
+	else if (myField.selectionStart || myField.selectionStart == '0') {
+		startPos = myField.selectionStart;
+		endPos = myField.selectionEnd;
+		if (startPos != endPos) {
+			word = myField.value.substring(startPos, endPos);
+		}
+	}
+	if (word == '') {
+		word = prompt(quicktagsL10n.wordLookup, '');
+	}
+	if (word !== null && /^\w[\w ]*$/.test(word)) {
+		window.open('http://www.answers.com/' + escape(word));
+	}
+}
+
+function edToolbar() {
+	document.write('<div id="ed_toolbar">');
+	for (var i = 0; i < edButtons.length; i++) {
+		edShowButton(edButtons[i], i);
+	}
+	document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />');
+	document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />');
+//	edShowLinks(); // disabled by default
+	document.write('</div>');
+}
+
+// insertion code
+
+function edInsertTag(myField, i) {
+	//IE support
+	if (document.selection) {
+		myField.focus();
+	    var sel = document.selection.createRange();
+		if (sel.text.length > 0) {
+			sel.text = edButtons[i].tagStart + sel.text + edButtons[i].tagEnd;
+		}
+		else {
+			if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
+				sel.text = edButtons[i].tagStart;
+				edAddTag(i);
+			}
+			else {
+				sel.text = edButtons[i].tagEnd;
+				edRemoveTag(i);
+			}
+		}
+		myField.focus();
+	}
+	//MOZILLA/NETSCAPE support
+	else if (myField.selectionStart || myField.selectionStart == '0') {
+		var startPos = myField.selectionStart, endPos = myField.selectionEnd, cursorPos = endPos, scrollTop = myField.scrollTop;
+
+		if (startPos != endPos) {
+			myField.value = myField.value.substring(0, startPos)
+			              + edButtons[i].tagStart
+			              + myField.value.substring(startPos, endPos)
+			              + edButtons[i].tagEnd
+			              + myField.value.substring(endPos, myField.value.length);
+			cursorPos += edButtons[i].tagStart.length + edButtons[i].tagEnd.length;
+		}
+		else {
+			if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
+				myField.value = myField.value.substring(0, startPos)
+				              + edButtons[i].tagStart
+				              + myField.value.substring(endPos, myField.value.length);
+				edAddTag(i);
+				cursorPos = startPos + edButtons[i].tagStart.length;
+			}
+			else {
+				myField.value = myField.value.substring(0, startPos)
+				              + edButtons[i].tagEnd
+				              + myField.value.substring(endPos, myField.value.length);
+				edRemoveTag(i);
+				cursorPos = startPos + edButtons[i].tagEnd.length;
+			}
+		}
+		myField.focus();
+		myField.selectionStart = cursorPos;
+		myField.selectionEnd = cursorPos;
+		myField.scrollTop = scrollTop;
+	}
+	else {
+		if (!edCheckOpenTags(i) || edButtons[i].tagEnd == '') {
+			myField.value += edButtons[i].tagStart;
+			edAddTag(i);
+		}
+		else {
+			myField.value += edButtons[i].tagEnd;
+			edRemoveTag(i);
+		}
+		myField.focus();
+	}
+}
+
+function edInsertContent(myField, myValue) {
+	var sel, startPos, endPos, scrollTop;
+
+	//IE support
+	if (document.selection) {
+		myField.focus();
+		sel = document.selection.createRange();
+		sel.text = myValue;
+		myField.focus();
+	}
+	//MOZILLA/NETSCAPE support
+	else if (myField.selectionStart || myField.selectionStart == '0') {
+		startPos = myField.selectionStart;
+		endPos = myField.selectionEnd;
+		scrollTop = myField.scrollTop;
+		myField.value = myField.value.substring(0, startPos)
+		              + myValue
+                      + myField.value.substring(endPos, myField.value.length);
+		myField.focus();
+		myField.selectionStart = startPos + myValue.length;
+		myField.selectionEnd = startPos + myValue.length;
+		myField.scrollTop = scrollTop;
+	} else {
+		myField.value += myValue;
+		myField.focus();
+	}
+}
+
+function edInsertLink(myField, i, defaultValue) {
+	if (!defaultValue) {
+		defaultValue = 'http://';
+	}
+	if (!edCheckOpenTags(i)) {
+		var URL = prompt(quicktagsL10n.enterURL, defaultValue);
+		if (URL) {
+			edButtons[i].tagStart = '<a href="' + URL + '">';
+			edInsertTag(myField, i);
+		}
+	}
+	else {
+		edInsertTag(myField, i);
+	}
+}
+
+function edInsertImage(myField) {
+	var myValue = prompt(quicktagsL10n.enterImageURL, 'http://');
+	if (myValue) {
+		myValue = '<img src="'
+				+ myValue
+				+ '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+				+ '" />';
+		edInsertContent(myField, myValue);
+	}
+}
+
+
+// Allow multiple instances.
+// Name = unique value, id = textarea id, container = container div.
+// Can disable some buttons by passing comma delimited string as 4th param.
+var QTags = function(name, id, container, disabled) {
+	var t = this, cont = document.getElementById(container), i, tag, tb, html, sel;
+
+	t.Buttons = [];
+	t.Links = [];
+	t.OpenTags = [];
+	t.Canvas = document.getElementById(id);
+
+	if ( ! t.Canvas || ! cont )
+		return;
+
+	disabled = ( typeof disabled != 'undefined' ) ? ','+disabled+',' : '';
+
+	t.edShowButton = function(button, i) {
+		if ( disabled && (disabled.indexOf(','+button.display+',') != -1) )
+			return '';
+		else if ( button.id == name+'_img' )
+			return '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage('+name+'.Canvas);" value="' + button.display + '" />';
+		else if (button.id == name+'_link')
+			return '<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="'+name+'.edInsertLink('+i+');" value="'+button.display+'" />';
+		else
+			return '<input type="button" id="' + button.id + '" accesskey="'+button.access+'" class="ed_button" onclick="'+name+'.edInsertTag('+i+');" value="'+button.display+'" />';
+	};
+
+	t.edAddTag = function(button) {
+		if ( t.Buttons[button].tagEnd != '' ) {
+			t.OpenTags[t.OpenTags.length] = button;
+			document.getElementById(t.Buttons[button].id).value = '/' + document.getElementById(t.Buttons[button].id).value;
+		}
+	};
+
+	t.edRemoveTag = function(button) {
+		for ( i = 0; i < t.OpenTags.length; i++ ) {
+			if ( t.OpenTags[i] == button ) {
+				t.OpenTags.splice(i, 1);
+				document.getElementById(t.Buttons[button].id).value = document.getElementById(t.Buttons[button].id).value.replace('/', '');
+			}
+		}
+	};
+
+	t.edCheckOpenTags = function(button) {
+		tag = 0;
+		for ( var i = 0; i < t.OpenTags.length; i++ ) {
+			if ( t.OpenTags[i] == button )
+				tag++;
+		}
+		if ( tag > 0 ) return true; // tag found
+		else return false; // tag not found
+	};
+
+	this.edCloseAllTags = function() {
+		var count = t.OpenTags.length;
+		for ( var o = 0; o < count; o++ )
+			t.edInsertTag(t.OpenTags[t.OpenTags.length - 1]);
+	};
+
+	this.edQuickLink = function(i, thisSelect) {
+		if ( i > -1 ) {
+			var newWin = '', tempStr;
+			if ( Links[i].newWin == 1 ) {
+				newWin = ' target="_blank"';
+			}
+			tempStr = '<a href="' + Links[i].URL + '"' + newWin + '>'
+			            + Links[i].display
+			            + '</a>';
+			thisSelect.selectedIndex = 0;
+			edInsertContent(t.Canvas, tempStr);
+		} else {
+			thisSelect.selectedIndex = 0;
+		}
+	};
+
+	// insertion code
+	t.edInsertTag = function(i) {
+		//IE support
+		if ( document.selection ) {
+			t.Canvas.focus();
+		    sel = document.selection.createRange();
+			if ( sel.text.length > 0 ) {
+				sel.text = t.Buttons[i].tagStart + sel.text + t.Buttons[i].tagEnd;
+			} else {
+				if ( ! t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
+					sel.text = t.Buttons[i].tagStart;
+					t.edAddTag(i);
+				} else {
+					sel.text = t.Buttons[i].tagEnd;
+					t.edRemoveTag(i);
+				}
+			}
+			t.Canvas.focus();
+		} else if ( t.Canvas.selectionStart || t.Canvas.selectionStart == '0' ) { //MOZILLA/NETSCAPE support
+			var startPos = t.Canvas.selectionStart, endPos = t.Canvas.selectionEnd, cursorPos = endPos, scrollTop = t.Canvas.scrollTop;
+
+			if ( startPos != endPos ) {
+				t.Canvas.value = t.Canvas.value.substring(0, startPos)
+				              + t.Buttons[i].tagStart
+				              + t.Canvas.value.substring(startPos, endPos)
+				              + t.Buttons[i].tagEnd
+				              + t.Canvas.value.substring(endPos, t.Canvas.value.length);
+				cursorPos += t.Buttons[i].tagStart.length + t.Buttons[i].tagEnd.length;
+			} else {
+				if ( !t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
+					t.Canvas.value = t.Canvas.value.substring(0, startPos)
+					              + t.Buttons[i].tagStart
+					              + t.Canvas.value.substring(endPos, t.Canvas.value.length);
+					t.edAddTag(i);
+					cursorPos = startPos + t.Buttons[i].tagStart.length;
+				} else {
+					t.Canvas.value = t.Canvas.value.substring(0, startPos)
+					              + t.Buttons[i].tagEnd
+					              + t.Canvas.value.substring(endPos, t.Canvas.value.length);
+					t.edRemoveTag(i);
+					cursorPos = startPos + t.Buttons[i].tagEnd.length;
+				}
+			}
+			t.Canvas.focus();
+			t.Canvas.selectionStart = cursorPos;
+			t.Canvas.selectionEnd = cursorPos;
+			t.Canvas.scrollTop = scrollTop;
+		} else {
+			if ( ! t.edCheckOpenTags(i) || t.Buttons[i].tagEnd == '' ) {
+				t.Canvas.value += Buttons[i].tagStart;
+				t.edAddTag(i);
+			} else {
+				t.Canvas.value += Buttons[i].tagEnd;
+				t.edRemoveTag(i);
+			}
+			t.Canvas.focus();
+		}
+	};
+
+	this.edInsertLink = function(i, defaultValue) {
+		if ( ! defaultValue )
+			defaultValue = 'http://';
+
+		if ( ! t.edCheckOpenTags(i) ) {
+			var URL = prompt(quicktagsL10n.enterURL, defaultValue);
+			if ( URL ) {
+				t.Buttons[i].tagStart = '<a href="' + URL + '">';
+				t.edInsertTag(i);
+			}
+		} else {
+			t.edInsertTag(i);
+		}
+	};
+
+	this.edInsertImage = function() {
+		var myValue = prompt(quicktagsL10n.enterImageURL, 'http://');
+		if ( myValue ) {
+			myValue = '<img src="'
+					+ myValue
+					+ '" alt="' + prompt(quicktagsL10n.enterImageDescription, '')
+					+ '" />';
+			edInsertContent(t.Canvas, myValue);
+		}
+	};
+
+	t.Buttons[t.Buttons.length] = new edButton(name+'_strong','b','<strong>','</strong>','b');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_em','i','<em>','</em>','i');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_link','link','','</a>','a'); // special case
+	t.Buttons[t.Buttons.length] = new edButton(name+'_block','b-quote','\n\n<blockquote>','</blockquote>\n\n','q');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_del','del','<del datetime="' + datetime + '">','</del>','d');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_ins','ins','<ins datetime="' + datetime + '">','</ins>','s');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_img','img','','','m',-1); // special case
+	t.Buttons[t.Buttons.length] = new edButton(name+'_ul','ul','<ul>\n','</ul>\n\n','u');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_ol','ol','<ol>\n','</ol>\n\n','o');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_li','li','\t<li>','</li>\n','l');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_code','code','<code>','</code>','c');
+	t.Buttons[t.Buttons.length] = new edButton(name+'_more','more','<!--more-->','','t',-1);
+//	t.Buttons[t.Buttons.length] = new edButton(name+'_next','page','<!--nextpage-->','','p',-1);
+
+	tb = document.createElement('div');
+	tb.id = name+'_qtags';
+
+	html = '<div id="'+name+'_toolbar">';
+	for (i = 0; i < t.Buttons.length; i++)
+		html += t.edShowButton(t.Buttons[i], i);
+
+	html += '<input type="button" id="'+name+'_ed_spell" class="ed_button" onclick="edSpell('+name+'.Canvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />';
+	html += '<input type="button" id="'+name+'_ed_close" class="ed_button" onclick="'+name+'.edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" /></div>';
+
+	tb.innerHTML = html;
+	cont.parentNode.insertBefore(tb, cont);
+
+};
Index: /tags/3.1/wp-includes/js/quicktags.js
===================================================================
--- /tags/3.1/wp-includes/js/quicktags.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/quicktags.js	(revision 17487)
@@ -0,0 +1,1 @@
+var edButtons=new Array(),edLinks=new Array(),edOpenTags=new Array(),now=new Date(),datetime;function edButton(f,e,c,b,a,d){this.id=f;this.display=e;this.tagStart=c;this.tagEnd=b;this.access=a;this.open=d}function zeroise(b,a){var c=b.toString();if(b<0){c=c.substr(1,c.length)}while(c.length<a){c="0"+c}if(b<0){c="-"+c}return c}datetime=now.getUTCFullYear()+"-"+zeroise(now.getUTCMonth()+1,2)+"-"+zeroise(now.getUTCDate(),2)+"T"+zeroise(now.getUTCHours(),2)+":"+zeroise(now.getUTCMinutes(),2)+":"+zeroise(now.getUTCSeconds(),2)+"+00:00";edButtons[edButtons.length]=new edButton("ed_strong","b","<strong>","</strong>","b");edButtons[edButtons.length]=new edButton("ed_em","i","<em>","</em>","i");edButtons[edButtons.length]=new edButton("ed_link","link","","</a>","a");edButtons[edButtons.length]=new edButton("ed_block","b-quote","\n\n<blockquote>","</blockquote>\n\n","q");edButtons[edButtons.length]=new edButton("ed_del","del",'<del datetime="'+datetime+'">',"</del>","d");edButtons[edButtons.length]=new edButton("ed_ins","ins",'<ins datetime="'+datetime+'">',"</ins>","s");edButtons[edButtons.length]=new edButton("ed_img","img","","","m",-1);edButtons[edButtons.length]=new edButton("ed_ul","ul","<ul>\n","</ul>\n\n","u");edButtons[edButtons.length]=new edButton("ed_ol","ol","<ol>\n","</ol>\n\n","o");edButtons[edButtons.length]=new edButton("ed_li","li","\t<li>","</li>\n","l");edButtons[edButtons.length]=new edButton("ed_code","code","<code>","</code>","c");edButtons[edButtons.length]=new edButton("ed_more","more","<!--more-->","","t",-1);function edLink(){this.display="";this.URL="";this.newWin=0}edLinks[edLinks.length]=new edLink("WordPress","http://wordpress.org/");edLinks[edLinks.length]=new edLink("alexking.org","http://www.alexking.org/");function edShowButton(b,a){if(b.id=="ed_img"){document.write('<input type="button" id="'+b.id+'" accesskey="'+b.access+'" class="ed_button" onclick="edInsertImage(edCanvas);" value="'+b.display+'" />')}else{if(b.id=="ed_link"){document.write('<input type="button" id="'+b.id+'" accesskey="'+b.access+'" class="ed_button" onclick="edInsertLink(edCanvas, '+a+');" value="'+b.display+'" />')}else{document.write('<input type="button" id="'+b.id+'" accesskey="'+b.access+'" class="ed_button" onclick="edInsertTag(edCanvas, '+a+');" value="'+b.display+'"  />')}}}function edShowLinks(){var a='<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>'+quicktagsL10n.quickLinks+"</option>",b;for(b=0;b<edLinks.length;b++){a+='<option value="'+b+'">'+edLinks[b].display+"</option>"}a+="</select>";document.write(a)}function edAddTag(a){if(edButtons[a].tagEnd!=""){edOpenTags[edOpenTags.length]=a;document.getElementById(edButtons[a].id).value="/"+document.getElementById(edButtons[a].id).value}}function edRemoveTag(b){for(var a=0;a<edOpenTags.length;a++){if(edOpenTags[a]==b){edOpenTags.splice(a,1);document.getElementById(edButtons[b].id).value=document.getElementById(edButtons[b].id).value.replace("/","")}}}function edCheckOpenTags(c){var a=0,b;for(b=0;b<edOpenTags.length;b++){if(edOpenTags[b]==c){a++}}if(a>0){return true}else{return false}}function edCloseAllTags(){var a=edOpenTags.length,b;for(b=0;b<a;b++){edInsertTag(edCanvas,edOpenTags[edOpenTags.length-1])}}function edQuickLink(c,d){if(c>-1){var b="",a;if(edLinks[c].newWin==1){b=' target="_blank"'}a='<a href="'+edLinks[c].URL+'"'+b+">"+edLinks[c].display+"</a>";d.selectedIndex=0;edInsertContent(edCanvas,a)}else{d.selectedIndex=0}}function edSpell(c){var e="",d,b,a;if(document.selection){c.focus();d=document.selection.createRange();if(d.text.length>0){e=d.text}}else{if(c.selectionStart||c.selectionStart=="0"){b=c.selectionStart;a=c.selectionEnd;if(b!=a){e=c.value.substring(b,a)}}}if(e==""){e=prompt(quicktagsL10n.wordLookup,"")}if(e!==null&&/^\w[\w ]*$/.test(e)){window.open("http://www.answers.com/"+escape(e))}}function edToolbar(){document.write('<div id="ed_toolbar">');for(var a=0;a<edButtons.length;a++){edShowButton(edButtons[a],a)}document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="'+quicktagsL10n.dictionaryLookup+'" value="'+quicktagsL10n.lookup+'" />');document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="'+quicktagsL10n.closeAllOpenTags+'" value="'+quicktagsL10n.closeTags+'" />');document.write("</div>")}function edInsertTag(d,c){if(document.selection){d.focus();var e=document.selection.createRange();if(e.text.length>0){e.text=edButtons[c].tagStart+e.text+edButtons[c].tagEnd}else{if(!edCheckOpenTags(c)||edButtons[c].tagEnd==""){e.text=edButtons[c].tagStart;edAddTag(c)}else{e.text=edButtons[c].tagEnd;edRemoveTag(c)}}d.focus()}else{if(d.selectionStart||d.selectionStart=="0"){var b=d.selectionStart,a=d.selectionEnd,g=a,f=d.scrollTop;if(b!=a){d.value=d.value.substring(0,b)+edButtons[c].tagStart+d.value.substring(b,a)+edButtons[c].tagEnd+d.value.substring(a,d.value.length);g+=edButtons[c].tagStart.length+edButtons[c].tagEnd.length}else{if(!edCheckOpenTags(c)||edButtons[c].tagEnd==""){d.value=d.value.substring(0,b)+edButtons[c].tagStart+d.value.substring(a,d.value.length);edAddTag(c);g=b+edButtons[c].tagStart.length}else{d.value=d.value.substring(0,b)+edButtons[c].tagEnd+d.value.substring(a,d.value.length);edRemoveTag(c);g=b+edButtons[c].tagEnd.length}}d.focus();d.selectionStart=g;d.selectionEnd=g;d.scrollTop=f}else{if(!edCheckOpenTags(c)||edButtons[c].tagEnd==""){d.value+=edButtons[c].tagStart;edAddTag(c)}else{d.value+=edButtons[c].tagEnd;edRemoveTag(c)}d.focus()}}}function edInsertContent(d,c){var e,b,a,f;if(document.selection){d.focus();e=document.selection.createRange();e.text=c;d.focus()}else{if(d.selectionStart||d.selectionStart=="0"){b=d.selectionStart;a=d.selectionEnd;f=d.scrollTop;d.value=d.value.substring(0,b)+c+d.value.substring(a,d.value.length);d.focus();d.selectionStart=b+c.length;d.selectionEnd=b+c.length;d.scrollTop=f}else{d.value+=c;d.focus()}}}function edInsertLink(d,c,b){if(!b){b="http://"}if(!edCheckOpenTags(c)){var a=prompt(quicktagsL10n.enterURL,b);if(a){edButtons[c].tagStart='<a href="'+a+'">';edInsertTag(d,c)}}else{edInsertTag(d,c)}}function edInsertImage(b){var a=prompt(quicktagsL10n.enterImageURL,"http://");if(a){a='<img src="'+a+'" alt="'+prompt(quicktagsL10n.enterImageDescription,"")+'" />';edInsertContent(b,a)}}var QTags=function(a,c,b,f){var j=this,k=document.getElementById(b),g,l,e,h,d;j.Buttons=[];j.Links=[];j.OpenTags=[];j.Canvas=document.getElementById(c);if(!j.Canvas||!k){return}f=(typeof f!="undefined")?","+f+",":"";j.edShowButton=function(n,m){if(f&&(f.indexOf(","+n.display+",")!=-1)){return""}else{if(n.id==a+"_img"){return'<input type="button" id="'+n.id+'" accesskey="'+n.access+'" class="ed_button" onclick="edInsertImage('+a+'.Canvas);" value="'+n.display+'" />'}else{if(n.id==a+"_link"){return'<input type="button" id="'+n.id+'" accesskey="'+n.access+'" class="ed_button" onclick="'+a+".edInsertLink("+m+');" value="'+n.display+'" />'}else{return'<input type="button" id="'+n.id+'" accesskey="'+n.access+'" class="ed_button" onclick="'+a+".edInsertTag("+m+');" value="'+n.display+'" />'}}}};j.edAddTag=function(i){if(j.Buttons[i].tagEnd!=""){j.OpenTags[j.OpenTags.length]=i;document.getElementById(j.Buttons[i].id).value="/"+document.getElementById(j.Buttons[i].id).value}};j.edRemoveTag=function(i){for(g=0;g<j.OpenTags.length;g++){if(j.OpenTags[g]==i){j.OpenTags.splice(g,1);document.getElementById(j.Buttons[i].id).value=document.getElementById(j.Buttons[i].id).value.replace("/","")}}};j.edCheckOpenTags=function(n){l=0;for(var m=0;m<j.OpenTags.length;m++){if(j.OpenTags[m]==n){l++}}if(l>0){return true}else{return false}};this.edCloseAllTags=function(){var i=j.OpenTags.length;for(var m=0;m<i;m++){j.edInsertTag(j.OpenTags[j.OpenTags.length-1])}};this.edQuickLink=function(o,p){if(o>-1){var n="",m;if(Links[o].newWin==1){n=' target="_blank"'}m='<a href="'+Links[o].URL+'"'+n+">"+Links[o].display+"</a>";p.selectedIndex=0;edInsertContent(j.Canvas,m)}else{p.selectedIndex=0}};j.edInsertTag=function(o){if(document.selection){j.Canvas.focus();d=document.selection.createRange();if(d.text.length>0){d.text=j.Buttons[o].tagStart+d.text+j.Buttons[o].tagEnd}else{if(!j.edCheckOpenTags(o)||j.Buttons[o].tagEnd==""){d.text=j.Buttons[o].tagStart;j.edAddTag(o)}else{d.text=j.Buttons[o].tagEnd;j.edRemoveTag(o)}}j.Canvas.focus()}else{if(j.Canvas.selectionStart||j.Canvas.selectionStart=="0"){var n=j.Canvas.selectionStart,m=j.Canvas.selectionEnd,q=m,p=j.Canvas.scrollTop;if(n!=m){j.Canvas.value=j.Canvas.value.substring(0,n)+j.Buttons[o].tagStart+j.Canvas.value.substring(n,m)+j.Buttons[o].tagEnd+j.Canvas.value.substring(m,j.Canvas.value.length);q+=j.Buttons[o].tagStart.length+j.Buttons[o].tagEnd.length}else{if(!j.edCheckOpenTags(o)||j.Buttons[o].tagEnd==""){j.Canvas.value=j.Canvas.value.substring(0,n)+j.Buttons[o].tagStart+j.Canvas.value.substring(m,j.Canvas.value.length);j.edAddTag(o);q=n+j.Buttons[o].tagStart.length}else{j.Canvas.value=j.Canvas.value.substring(0,n)+j.Buttons[o].tagEnd+j.Canvas.value.substring(m,j.Canvas.value.length);j.edRemoveTag(o);q=n+j.Buttons[o].tagEnd.length}}j.Canvas.focus();j.Canvas.selectionStart=q;j.Canvas.selectionEnd=q;j.Canvas.scrollTop=p}else{if(!j.edCheckOpenTags(o)||j.Buttons[o].tagEnd==""){j.Canvas.value+=Buttons[o].tagStart;j.edAddTag(o)}else{j.Canvas.value+=Buttons[o].tagEnd;j.edRemoveTag(o)}j.Canvas.focus()}}};this.edInsertLink=function(o,n){if(!n){n="http://"}if(!j.edCheckOpenTags(o)){var m=prompt(quicktagsL10n.enterURL,n);if(m){j.Buttons[o].tagStart='<a href="'+m+'">';j.edInsertTag(o)}}else{j.edInsertTag(o)}};this.edInsertImage=function(){var i=prompt(quicktagsL10n.enterImageURL,"http://");if(i){i='<img src="'+i+'" alt="'+prompt(quicktagsL10n.enterImageDescription,"")+'" />';edInsertContent(j.Canvas,i)}};j.Buttons[j.Buttons.length]=new edButton(a+"_strong","b","<strong>","</strong>","b");j.Buttons[j.Buttons.length]=new edButton(a+"_em","i","<em>","</em>","i");j.Buttons[j.Buttons.length]=new edButton(a+"_link","link","","</a>","a");j.Buttons[j.Buttons.length]=new edButton(a+"_block","b-quote","\n\n<blockquote>","</blockquote>\n\n","q");j.Buttons[j.Buttons.length]=new edButton(a+"_del","del",'<del datetime="'+datetime+'">',"</del>","d");j.Buttons[j.Buttons.length]=new edButton(a+"_ins","ins",'<ins datetime="'+datetime+'">',"</ins>","s");j.Buttons[j.Buttons.length]=new edButton(a+"_img","img","","","m",-1);j.Buttons[j.Buttons.length]=new edButton(a+"_ul","ul","<ul>\n","</ul>\n\n","u");j.Buttons[j.Buttons.length]=new edButton(a+"_ol","ol","<ol>\n","</ol>\n\n","o");j.Buttons[j.Buttons.length]=new edButton(a+"_li","li","\t<li>","</li>\n","l");j.Buttons[j.Buttons.length]=new edButton(a+"_code","code","<code>","</code>","c");j.Buttons[j.Buttons.length]=new edButton(a+"_more","more","<!--more-->","","t",-1);e=document.createElement("div");e.id=a+"_qtags";h='<div id="'+a+'_toolbar">';for(g=0;g<j.Buttons.length;g++){h+=j.edShowButton(j.Buttons[g],g)}h+='<input type="button" id="'+a+'_ed_spell" class="ed_button" onclick="edSpell('+a+'.Canvas);" title="'+quicktagsL10n.dictionaryLookup+'" value="'+quicktagsL10n.lookup+'" />';h+='<input type="button" id="'+a+'_ed_close" class="ed_button" onclick="'+a+'.edCloseAllTags();" title="'+quicktagsL10n.closeAllOpenTags+'" value="'+quicktagsL10n.closeTags+'" /></div>';e.innerHTML=h;k.parentNode.insertBefore(e,k)};
Index: /tags/3.1/wp-includes/js/scriptaculous/MIT-LICENSE
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/MIT-LICENSE	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/MIT-LICENSE	(revision 17487)
@@ -0,0 +1,20 @@
+Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index: /tags/3.1/wp-includes/js/scriptaculous/builder.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/builder.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/builder.js	(revision 17487)
@@ -0,0 +1,136 @@
+// script.aculo.us builder.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+var Builder = {
+  NODEMAP: {
+    AREA: 'map',
+    CAPTION: 'table',
+    COL: 'table',
+    COLGROUP: 'table',
+    LEGEND: 'fieldset',
+    OPTGROUP: 'select',
+    OPTION: 'select',
+    PARAM: 'object',
+    TBODY: 'table',
+    TD: 'table',
+    TFOOT: 'table',
+    TH: 'table',
+    THEAD: 'table',
+    TR: 'table'
+  },
+  // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
+  //       due to a Firefox bug
+  node: function(elementName) {
+    elementName = elementName.toUpperCase();
+
+    // try innerHTML approach
+    var parentTag = this.NODEMAP[elementName] || 'div';
+    var parentElement = document.createElement(parentTag);
+    try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+      parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
+    } catch(e) {}
+    var element = parentElement.firstChild || null;
+
+    // see if browser added wrapping tags
+    if(element && (element.tagName.toUpperCase() != elementName))
+      element = element.getElementsByTagName(elementName)[0];
+
+    // fallback to createElement approach
+    if(!element) element = document.createElement(elementName);
+
+    // abort if nothing could be created
+    if(!element) return;
+
+    // attributes (or text)
+    if(arguments[1])
+      if(this._isStringOrNumber(arguments[1]) ||
+        (arguments[1] instanceof Array) ||
+        arguments[1].tagName) {
+          this._children(element, arguments[1]);
+        } else {
+          var attrs = this._attributes(arguments[1]);
+          if(attrs.length) {
+            try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
+              parentElement.innerHTML = "<" +elementName + " " +
+                attrs + "></" + elementName + ">";
+            } catch(e) {}
+            element = parentElement.firstChild || null;
+            // workaround firefox 1.0.X bug
+            if(!element) {
+              element = document.createElement(elementName);
+              for(attr in arguments[1])
+                element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
+            }
+            if(element.tagName.toUpperCase() != elementName)
+              element = parentElement.getElementsByTagName(elementName)[0];
+          }
+        }
+
+    // text, or array of children
+    if(arguments[2])
+      this._children(element, arguments[2]);
+
+     return $(element);
+  },
+  _text: function(text) {
+     return document.createTextNode(text);
+  },
+
+  ATTR_MAP: {
+    'className': 'class',
+    'htmlFor': 'for'
+  },
+
+  _attributes: function(attributes) {
+    var attrs = [];
+    for(attribute in attributes)
+      attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
+          '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
+    return attrs.join(" ");
+  },
+  _children: function(element, children) {
+    if(children.tagName) {
+      element.appendChild(children);
+      return;
+    }
+    if(typeof children=='object') { // array can hold nodes and text
+      children.flatten().each( function(e) {
+        if(typeof e=='object')
+          element.appendChild(e);
+        else
+          if(Builder._isStringOrNumber(e))
+            element.appendChild(Builder._text(e));
+      });
+    } else
+      if(Builder._isStringOrNumber(children))
+        element.appendChild(Builder._text(children));
+  },
+  _isStringOrNumber: function(param) {
+    return(typeof param=='string' || typeof param=='number');
+  },
+  build: function(html) {
+    var element = this.node('div');
+    $(element).update(html.strip());
+    return element.down();
+  },
+  dump: function(scope) {
+    if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
+
+    var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
+      "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
+      "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
+      "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
+      "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
+      "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
+
+    tags.each( function(tag){
+      scope[tag] = function() {
+        return Builder.node.apply(Builder, [tag].concat($A(arguments)));
+      };
+    });
+  }
+};
Index: /tags/3.1/wp-includes/js/scriptaculous/controls.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/controls.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/controls.js	(revision 17487)
@@ -0,0 +1,965 @@
+// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//           (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+//           (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
+// Contributors:
+//  Richard Livsey
+//  Rahul Bhargava
+//  Rob Wills
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// Autocompleter.Base handles all the autocompletion functionality
+// that's independent of the data source for autocompletion. This
+// includes drawing the autocompletion menu, observing keyboard
+// and mouse events, and similar.
+//
+// Specific autocompleters need to provide, at the very least,
+// a getUpdatedChoices function that will be invoked every time
+// the text inside the monitored textbox changes. This method
+// should get the text for which to provide autocompletion by
+// invoking this.getToken(), NOT by directly accessing
+// this.element.value. This is to allow incremental tokenized
+// autocompletion. Specific auto-completion logic (AJAX, etc)
+// belongs in getUpdatedChoices.
+//
+// Tokenized incremental autocompletion is enabled automatically
+// when an autocompleter is instantiated with the 'tokens' option
+// in the options parameter, e.g.:
+// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
+// will incrementally autocomplete with a comma as the token.
+// Additionally, ',' in the above example can be replaced with
+// a token array, e.g. { tokens: [',', '\n'] } which
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
+// allows smart autocompletion after linebreaks.
+
+if(typeof Effect == 'undefined')
+  throw("controls.js requires including script.aculo.us' effects.js library");
+
+var Autocompleter = { };
+Autocompleter.Base = Class.create({
+  baseInitialize: function(element, update, options) {
+    element          = $(element);
+    this.element     = element;
+    this.update      = $(update);
+    this.hasFocus    = false;
+    this.changed     = false;
+    this.active      = false;
+    this.index       = 0;
+    this.entryCount  = 0;
+    this.oldElementValue = this.element.value;
+
+    if(this.setOptions)
+      this.setOptions(options);
+    else
+      this.options = options || { };
+
+    this.options.paramName    = this.options.paramName || this.element.name;
+    this.options.tokens       = this.options.tokens || [];
+    this.options.frequency    = this.options.frequency || 0.4;
+    this.options.minChars     = this.options.minChars || 1;
+    this.options.onShow       = this.options.onShow ||
+      function(element, update){
+        if(!update.style.position || update.style.position=='absolute') {
+          update.style.position = 'absolute';
+          Position.clone(element, update, {
+            setHeight: false,
+            offsetTop: element.offsetHeight
+          });
+        }
+        Effect.Appear(update,{duration:0.15});
+      };
+    this.options.onHide = this.options.onHide ||
+      function(element, update){ new Effect.Fade(update,{duration:0.15}) };
+
+    if(typeof(this.options.tokens) == 'string')
+      this.options.tokens = new Array(this.options.tokens);
+    // Force carriage returns as token delimiters anyway
+    if (!this.options.tokens.include('\n'))
+      this.options.tokens.push('\n');
+
+    this.observer = null;
+
+    this.element.setAttribute('autocomplete','off');
+
+    Element.hide(this.update);
+
+    Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
+    Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
+  },
+
+  show: function() {
+    if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
+    if(!this.iefix &&
+      (Prototype.Browser.IE) &&
+      (Element.getStyle(this.update, 'position')=='absolute')) {
+      new Insertion.After(this.update,
+       '<iframe id="' + this.update.id + '_iefix" '+
+       'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
+       'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
+      this.iefix = $(this.update.id+'_iefix');
+    }
+    if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
+  },
+
+  fixIEOverlapping: function() {
+    Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
+    this.iefix.style.zIndex = 1;
+    this.update.style.zIndex = 2;
+    Element.show(this.iefix);
+  },
+
+  hide: function() {
+    this.stopIndicator();
+    if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
+    if(this.iefix) Element.hide(this.iefix);
+  },
+
+  startIndicator: function() {
+    if(this.options.indicator) Element.show(this.options.indicator);
+  },
+
+  stopIndicator: function() {
+    if(this.options.indicator) Element.hide(this.options.indicator);
+  },
+
+  onKeyPress: function(event) {
+    if(this.active)
+      switch(event.keyCode) {
+       case Event.KEY_TAB:
+       case Event.KEY_RETURN:
+         this.selectEntry();
+         Event.stop(event);
+       case Event.KEY_ESC:
+         this.hide();
+         this.active = false;
+         Event.stop(event);
+         return;
+       case Event.KEY_LEFT:
+       case Event.KEY_RIGHT:
+         return;
+       case Event.KEY_UP:
+         this.markPrevious();
+         this.render();
+         Event.stop(event);
+         return;
+       case Event.KEY_DOWN:
+         this.markNext();
+         this.render();
+         Event.stop(event);
+         return;
+      }
+     else
+       if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+         (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
+
+    this.changed = true;
+    this.hasFocus = true;
+
+    if(this.observer) clearTimeout(this.observer);
+      this.observer =
+        setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
+  },
+
+  activate: function() {
+    this.changed = false;
+    this.hasFocus = true;
+    this.getUpdatedChoices();
+  },
+
+  onHover: function(event) {
+    var element = Event.findElement(event, 'LI');
+    if(this.index != element.autocompleteIndex)
+    {
+        this.index = element.autocompleteIndex;
+        this.render();
+    }
+    Event.stop(event);
+  },
+
+  onClick: function(event) {
+    var element = Event.findElement(event, 'LI');
+    this.index = element.autocompleteIndex;
+    this.selectEntry();
+    this.hide();
+  },
+
+  onBlur: function(event) {
+    // needed to make click events working
+    setTimeout(this.hide.bind(this), 250);
+    this.hasFocus = false;
+    this.active = false;
+  },
+
+  render: function() {
+    if(this.entryCount > 0) {
+      for (var i = 0; i < this.entryCount; i++)
+        this.index==i ?
+          Element.addClassName(this.getEntry(i),"selected") :
+          Element.removeClassName(this.getEntry(i),"selected");
+      if(this.hasFocus) {
+        this.show();
+        this.active = true;
+      }
+    } else {
+      this.active = false;
+      this.hide();
+    }
+  },
+
+  markPrevious: function() {
+    if(this.index > 0) this.index--;
+      else this.index = this.entryCount-1;
+    this.getEntry(this.index).scrollIntoView(true);
+  },
+
+  markNext: function() {
+    if(this.index < this.entryCount-1) this.index++;
+      else this.index = 0;
+    this.getEntry(this.index).scrollIntoView(false);
+  },
+
+  getEntry: function(index) {
+    return this.update.firstChild.childNodes[index];
+  },
+
+  getCurrentEntry: function() {
+    return this.getEntry(this.index);
+  },
+
+  selectEntry: function() {
+    this.active = false;
+    this.updateElement(this.getCurrentEntry());
+  },
+
+  updateElement: function(selectedElement) {
+    if (this.options.updateElement) {
+      this.options.updateElement(selectedElement);
+      return;
+    }
+    var value = '';
+    if (this.options.select) {
+      var nodes = $(selectedElement).select('.' + this.options.select) || [];
+      if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
+    } else
+      value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
+
+    var bounds = this.getTokenBounds();
+    if (bounds[0] != -1) {
+      var newValue = this.element.value.substr(0, bounds[0]);
+      var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
+      if (whitespace)
+        newValue += whitespace[0];
+      this.element.value = newValue + value + this.element.value.substr(bounds[1]);
+    } else {
+      this.element.value = value;
+    }
+    this.oldElementValue = this.element.value;
+    this.element.focus();
+
+    if (this.options.afterUpdateElement)
+      this.options.afterUpdateElement(this.element, selectedElement);
+  },
+
+  updateChoices: function(choices) {
+    if(!this.changed && this.hasFocus) {
+      this.update.innerHTML = choices;
+      Element.cleanWhitespace(this.update);
+      Element.cleanWhitespace(this.update.down());
+
+      if(this.update.firstChild && this.update.down().childNodes) {
+        this.entryCount =
+          this.update.down().childNodes.length;
+        for (var i = 0; i < this.entryCount; i++) {
+          var entry = this.getEntry(i);
+          entry.autocompleteIndex = i;
+          this.addObservers(entry);
+        }
+      } else {
+        this.entryCount = 0;
+      }
+
+      this.stopIndicator();
+      this.index = 0;
+
+      if(this.entryCount==1 && this.options.autoSelect) {
+        this.selectEntry();
+        this.hide();
+      } else {
+        this.render();
+      }
+    }
+  },
+
+  addObservers: function(element) {
+    Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
+    Event.observe(element, "click", this.onClick.bindAsEventListener(this));
+  },
+
+  onObserverEvent: function() {
+    this.changed = false;
+    this.tokenBounds = null;
+    if(this.getToken().length>=this.options.minChars) {
+      this.getUpdatedChoices();
+    } else {
+      this.active = false;
+      this.hide();
+    }
+    this.oldElementValue = this.element.value;
+  },
+
+  getToken: function() {
+    var bounds = this.getTokenBounds();
+    return this.element.value.substring(bounds[0], bounds[1]).strip();
+  },
+
+  getTokenBounds: function() {
+    if (null != this.tokenBounds) return this.tokenBounds;
+    var value = this.element.value;
+    if (value.strip().empty()) return [-1, 0];
+    var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
+    var offset = (diff == this.oldElementValue.length ? 1 : 0);
+    var prevTokenPos = -1, nextTokenPos = value.length;
+    var tp;
+    for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
+      tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
+      if (tp > prevTokenPos) prevTokenPos = tp;
+      tp = value.indexOf(this.options.tokens[index], diff + offset);
+      if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
+    }
+    return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
+  }
+});
+
+Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
+  var boundary = Math.min(newS.length, oldS.length);
+  for (var index = 0; index < boundary; ++index)
+    if (newS[index] != oldS[index])
+      return index;
+  return boundary;
+};
+
+Ajax.Autocompleter = Class.create(Autocompleter.Base, {
+  initialize: function(element, update, url, options) {
+    this.baseInitialize(element, update, options);
+    this.options.asynchronous  = true;
+    this.options.onComplete    = this.onComplete.bind(this);
+    this.options.defaultParams = this.options.parameters || null;
+    this.url                   = url;
+  },
+
+  getUpdatedChoices: function() {
+    this.startIndicator();
+
+    var entry = encodeURIComponent(this.options.paramName) + '=' +
+      encodeURIComponent(this.getToken());
+
+    this.options.parameters = this.options.callback ?
+      this.options.callback(this.element, entry) : entry;
+
+    if(this.options.defaultParams)
+      this.options.parameters += '&' + this.options.defaultParams;
+
+    new Ajax.Request(this.url, this.options);
+  },
+
+  onComplete: function(request) {
+    this.updateChoices(request.responseText);
+  }
+});
+
+// The local array autocompleter. Used when you'd prefer to
+// inject an array of autocompletion options into the page, rather
+// than sending out Ajax queries, which can be quite slow sometimes.
+//
+// The constructor takes four parameters. The first two are, as usual,
+// the id of the monitored textbox, and id of the autocompletion menu.
+// The third is the array you want to autocomplete from, and the fourth
+// is the options block.
+//
+// Extra local autocompletion options:
+// - choices - How many autocompletion choices to offer
+//
+// - partialSearch - If false, the autocompleter will match entered
+//                    text only at the beginning of strings in the
+//                    autocomplete array. Defaults to true, which will
+//                    match text at the beginning of any *word* in the
+//                    strings in the autocomplete array. If you want to
+//                    search anywhere in the string, additionally set
+//                    the option fullSearch to true (default: off).
+//
+// - fullSsearch - Search anywhere in autocomplete array strings.
+//
+// - partialChars - How many characters to enter before triggering
+//                   a partial match (unlike minChars, which defines
+//                   how many characters are required to do any match
+//                   at all). Defaults to 2.
+//
+// - ignoreCase - Whether to ignore case when autocompleting.
+//                 Defaults to true.
+//
+// It's possible to pass in a custom function as the 'selector'
+// option, if you prefer to write your own autocompletion logic.
+// In that case, the other options above will not apply unless
+// you support them.
+
+Autocompleter.Local = Class.create(Autocompleter.Base, {
+  initialize: function(element, update, array, options) {
+    this.baseInitialize(element, update, options);
+    this.options.array = array;
+  },
+
+  getUpdatedChoices: function() {
+    this.updateChoices(this.options.selector(this));
+  },
+
+  setOptions: function(options) {
+    this.options = Object.extend({
+      choices: 10,
+      partialSearch: true,
+      partialChars: 2,
+      ignoreCase: true,
+      fullSearch: false,
+      selector: function(instance) {
+        var ret       = []; // Beginning matches
+        var partial   = []; // Inside matches
+        var entry     = instance.getToken();
+        var count     = 0;
+
+        for (var i = 0; i < instance.options.array.length &&
+          ret.length < instance.options.choices ; i++) {
+
+          var elem = instance.options.array[i];
+          var foundPos = instance.options.ignoreCase ?
+            elem.toLowerCase().indexOf(entry.toLowerCase()) :
+            elem.indexOf(entry);
+
+          while (foundPos != -1) {
+            if (foundPos == 0 && elem.length != entry.length) {
+              ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
+                elem.substr(entry.length) + "</li>");
+              break;
+            } else if (entry.length >= instance.options.partialChars &&
+              instance.options.partialSearch && foundPos != -1) {
+              if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
+                partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
+                  elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
+                  foundPos + entry.length) + "</li>");
+                break;
+              }
+            }
+
+            foundPos = instance.options.ignoreCase ?
+              elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+              elem.indexOf(entry, foundPos + 1);
+
+          }
+        }
+        if (partial.length)
+          ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));
+        return "<ul>" + ret.join('') + "</ul>";
+      }
+    }, options || { });
+  }
+});
+
+// AJAX in-place editor and collection editor
+// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).
+
+// Use this if you notice weird scrolling problems on some browsers,
+// the DOM might be a bit confused when this gets called so do this
+// waits 1 ms (with setTimeout) until it does the activation
+Field.scrollFreeActivate = function(field) {
+  setTimeout(function() {
+    Field.activate(field);
+  }, 1);
+};
+
+Ajax.InPlaceEditor = Class.create({
+  initialize: function(element, url, options) {
+    this.url = url;
+    this.element = element = $(element);
+    this.prepareOptions();
+    this._controls = { };
+    arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
+    Object.extend(this.options, options || { });
+    if (!this.options.formId && this.element.id) {
+      this.options.formId = this.element.id + '-inplaceeditor';
+      if ($(this.options.formId))
+        this.options.formId = '';
+    }
+    if (this.options.externalControl)
+      this.options.externalControl = $(this.options.externalControl);
+    if (!this.options.externalControl)
+      this.options.externalControlOnly = false;
+    this._originalBackground = this.element.getStyle('background-color') || 'transparent';
+    this.element.title = this.options.clickToEditText;
+    this._boundCancelHandler = this.handleFormCancellation.bind(this);
+    this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
+    this._boundFailureHandler = this.handleAJAXFailure.bind(this);
+    this._boundSubmitHandler = this.handleFormSubmission.bind(this);
+    this._boundWrapperHandler = this.wrapUp.bind(this);
+    this.registerListeners();
+  },
+  checkForEscapeOrReturn: function(e) {
+    if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
+    if (Event.KEY_ESC == e.keyCode)
+      this.handleFormCancellation(e);
+    else if (Event.KEY_RETURN == e.keyCode)
+      this.handleFormSubmission(e);
+  },
+  createControl: function(mode, handler, extraClasses) {
+    var control = this.options[mode + 'Control'];
+    var text = this.options[mode + 'Text'];
+    if ('button' == control) {
+      var btn = document.createElement('input');
+      btn.type = 'submit';
+      btn.value = text;
+      btn.className = 'editor_' + mode + '_button';
+      if ('cancel' == mode)
+        btn.onclick = this._boundCancelHandler;
+      this._form.appendChild(btn);
+      this._controls[mode] = btn;
+    } else if ('link' == control) {
+      var link = document.createElement('a');
+      link.href = '#';
+      link.appendChild(document.createTextNode(text));
+      link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
+      link.className = 'editor_' + mode + '_link';
+      if (extraClasses)
+        link.className += ' ' + extraClasses;
+      this._form.appendChild(link);
+      this._controls[mode] = link;
+    }
+  },
+  createEditField: function() {
+    var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
+    var fld;
+    if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
+      fld = document.createElement('input');
+      fld.type = 'text';
+      var size = this.options.size || this.options.cols || 0;
+      if (0 < size) fld.size = size;
+    } else {
+      fld = document.createElement('textarea');
+      fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
+      fld.cols = this.options.cols || 40;
+    }
+    fld.name = this.options.paramName;
+    fld.value = text; // No HTML breaks conversion anymore
+    fld.className = 'editor_field';
+    if (this.options.submitOnBlur)
+      fld.onblur = this._boundSubmitHandler;
+    this._controls.editor = fld;
+    if (this.options.loadTextURL)
+      this.loadExternalText();
+    this._form.appendChild(this._controls.editor);
+  },
+  createForm: function() {
+    var ipe = this;
+    function addText(mode, condition) {
+      var text = ipe.options['text' + mode + 'Controls'];
+      if (!text || condition === false) return;
+      ipe._form.appendChild(document.createTextNode(text));
+    };
+    this._form = $(document.createElement('form'));
+    this._form.id = this.options.formId;
+    this._form.addClassName(this.options.formClassName);
+    this._form.onsubmit = this._boundSubmitHandler;
+    this.createEditField();
+    if ('textarea' == this._controls.editor.tagName.toLowerCase())
+      this._form.appendChild(document.createElement('br'));
+    if (this.options.onFormCustomization)
+      this.options.onFormCustomization(this, this._form);
+    addText('Before', this.options.okControl || this.options.cancelControl);
+    this.createControl('ok', this._boundSubmitHandler);
+    addText('Between', this.options.okControl && this.options.cancelControl);
+    this.createControl('cancel', this._boundCancelHandler, 'editor_cancel');
+    addText('After', this.options.okControl || this.options.cancelControl);
+  },
+  destroy: function() {
+    if (this._oldInnerHTML)
+      this.element.innerHTML = this._oldInnerHTML;
+    this.leaveEditMode();
+    this.unregisterListeners();
+  },
+  enterEditMode: function(e) {
+    if (this._saving || this._editing) return;
+    this._editing = true;
+    this.triggerCallback('onEnterEditMode');
+    if (this.options.externalControl)
+      this.options.externalControl.hide();
+    this.element.hide();
+    this.createForm();
+    this.element.parentNode.insertBefore(this._form, this.element);
+    if (!this.options.loadTextURL)
+      this.postProcessEditField();
+    if (e) Event.stop(e);
+  },
+  enterHover: function(e) {
+    if (this.options.hoverClassName)
+      this.element.addClassName(this.options.hoverClassName);
+    if (this._saving) return;
+    this.triggerCallback('onEnterHover');
+  },
+  getText: function() {
+    return this.element.innerHTML.unescapeHTML();
+  },
+  handleAJAXFailure: function(transport) {
+    this.triggerCallback('onFailure', transport);
+    if (this._oldInnerHTML) {
+      this.element.innerHTML = this._oldInnerHTML;
+      this._oldInnerHTML = null;
+    }
+  },
+  handleFormCancellation: function(e) {
+    this.wrapUp();
+    if (e) Event.stop(e);
+  },
+  handleFormSubmission: function(e) {
+    var form = this._form;
+    var value = $F(this._controls.editor);
+    this.prepareSubmission();
+    var params = this.options.callback(form, value) || '';
+    if (Object.isString(params))
+      params = params.toQueryParams();
+    params.editorId = this.element.id;
+    if (this.options.htmlResponse) {
+      var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);
+      Object.extend(options, {
+        parameters: params,
+        onComplete: this._boundWrapperHandler,
+        onFailure: this._boundFailureHandler
+      });
+      new Ajax.Updater({ success: this.element }, this.url, options);
+    } else {
+      var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+      Object.extend(options, {
+        parameters: params,
+        onComplete: this._boundWrapperHandler,
+        onFailure: this._boundFailureHandler
+      });
+      new Ajax.Request(this.url, options);
+    }
+    if (e) Event.stop(e);
+  },
+  leaveEditMode: function() {
+    this.element.removeClassName(this.options.savingClassName);
+    this.removeForm();
+    this.leaveHover();
+    this.element.style.backgroundColor = this._originalBackground;
+    this.element.show();
+    if (this.options.externalControl)
+      this.options.externalControl.show();
+    this._saving = false;
+    this._editing = false;
+    this._oldInnerHTML = null;
+    this.triggerCallback('onLeaveEditMode');
+  },
+  leaveHover: function(e) {
+    if (this.options.hoverClassName)
+      this.element.removeClassName(this.options.hoverClassName);
+    if (this._saving) return;
+    this.triggerCallback('onLeaveHover');
+  },
+  loadExternalText: function() {
+    this._form.addClassName(this.options.loadingClassName);
+    this._controls.editor.disabled = true;
+    var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+    Object.extend(options, {
+      parameters: 'editorId=' + encodeURIComponent(this.element.id),
+      onComplete: Prototype.emptyFunction,
+      onSuccess: function(transport) {
+        this._form.removeClassName(this.options.loadingClassName);
+        var text = transport.responseText;
+        if (this.options.stripLoadedTextTags)
+          text = text.stripTags();
+        this._controls.editor.value = text;
+        this._controls.editor.disabled = false;
+        this.postProcessEditField();
+      }.bind(this),
+      onFailure: this._boundFailureHandler
+    });
+    new Ajax.Request(this.options.loadTextURL, options);
+  },
+  postProcessEditField: function() {
+    var fpc = this.options.fieldPostCreation;
+    if (fpc)
+      $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate']();
+  },
+  prepareOptions: function() {
+    this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);
+    Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);
+    [this._extraDefaultOptions].flatten().compact().each(function(defs) {
+      Object.extend(this.options, defs);
+    }.bind(this));
+  },
+  prepareSubmission: function() {
+    this._saving = true;
+    this.removeForm();
+    this.leaveHover();
+    this.showSaving();
+  },
+  registerListeners: function() {
+    this._listeners = { };
+    var listener;
+    $H(Ajax.InPlaceEditor.Listeners).each(function(pair) {
+      listener = this[pair.value].bind(this);
+      this._listeners[pair.key] = listener;
+      if (!this.options.externalControlOnly)
+        this.element.observe(pair.key, listener);
+      if (this.options.externalControl)
+        this.options.externalControl.observe(pair.key, listener);
+    }.bind(this));
+  },
+  removeForm: function() {
+    if (!this._form) return;
+    this._form.remove();
+    this._form = null;
+    this._controls = { };
+  },
+  showSaving: function() {
+    this._oldInnerHTML = this.element.innerHTML;
+    this.element.innerHTML = this.options.savingText;
+    this.element.addClassName(this.options.savingClassName);
+    this.element.style.backgroundColor = this._originalBackground;
+    this.element.show();
+  },
+  triggerCallback: function(cbName, arg) {
+    if ('function' == typeof this.options[cbName]) {
+      this.options[cbName](this, arg);
+    }
+  },
+  unregisterListeners: function() {
+    $H(this._listeners).each(function(pair) {
+      if (!this.options.externalControlOnly)
+        this.element.stopObserving(pair.key, pair.value);
+      if (this.options.externalControl)
+        this.options.externalControl.stopObserving(pair.key, pair.value);
+    }.bind(this));
+  },
+  wrapUp: function(transport) {
+    this.leaveEditMode();
+    // Can't use triggerCallback due to backward compatibility: requires
+    // binding + direct element
+    this._boundComplete(transport, this.element);
+  }
+});
+
+Object.extend(Ajax.InPlaceEditor.prototype, {
+  dispose: Ajax.InPlaceEditor.prototype.destroy
+});
+
+Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
+  initialize: function($super, element, url, options) {
+    this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
+    $super(element, url, options);
+  },
+
+  createEditField: function() {
+    var list = document.createElement('select');
+    list.name = this.options.paramName;
+    list.size = 1;
+    this._controls.editor = list;
+    this._collection = this.options.collection || [];
+    if (this.options.loadCollectionURL)
+      this.loadCollection();
+    else
+      this.checkForExternalText();
+    this._form.appendChild(this._controls.editor);
+  },
+
+  loadCollection: function() {
+    this._form.addClassName(this.options.loadingClassName);
+    this.showLoadingText(this.options.loadingCollectionText);
+    var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+    Object.extend(options, {
+      parameters: 'editorId=' + encodeURIComponent(this.element.id),
+      onComplete: Prototype.emptyFunction,
+      onSuccess: function(transport) {
+        var js = transport.responseText.strip();
+        if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
+          throw('Server returned an invalid collection representation.');
+        this._collection = eval(js);
+        this.checkForExternalText();
+      }.bind(this),
+      onFailure: this.onFailure
+    });
+    new Ajax.Request(this.options.loadCollectionURL, options);
+  },
+
+  showLoadingText: function(text) {
+    this._controls.editor.disabled = true;
+    var tempOption = this._controls.editor.firstChild;
+    if (!tempOption) {
+      tempOption = document.createElement('option');
+      tempOption.value = '';
+      this._controls.editor.appendChild(tempOption);
+      tempOption.selected = true;
+    }
+    tempOption.update((text || '').stripScripts().stripTags());
+  },
+
+  checkForExternalText: function() {
+    this._text = this.getText();
+    if (this.options.loadTextURL)
+      this.loadExternalText();
+    else
+      this.buildOptionList();
+  },
+
+  loadExternalText: function() {
+    this.showLoadingText(this.options.loadingText);
+    var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
+    Object.extend(options, {
+      parameters: 'editorId=' + encodeURIComponent(this.element.id),
+      onComplete: Prototype.emptyFunction,
+      onSuccess: function(transport) {
+        this._text = transport.responseText.strip();
+        this.buildOptionList();
+      }.bind(this),
+      onFailure: this.onFailure
+    });
+    new Ajax.Request(this.options.loadTextURL, options);
+  },
+
+  buildOptionList: function() {
+    this._form.removeClassName(this.options.loadingClassName);
+    this._collection = this._collection.map(function(entry) {
+      return 2 === entry.length ? entry : [entry, entry].flatten();
+    });
+    var marker = ('value' in this.options) ? this.options.value : this._text;
+    var textFound = this._collection.any(function(entry) {
+      return entry[0] == marker;
+    }.bind(this));
+    this._controls.editor.update('');
+    var option;
+    this._collection.each(function(entry, index) {
+      option = document.createElement('option');
+      option.value = entry[0];
+      option.selected = textFound ? entry[0] == marker : 0 == index;
+      option.appendChild(document.createTextNode(entry[1]));
+      this._controls.editor.appendChild(option);
+    }.bind(this));
+    this._controls.editor.disabled = false;
+    Field.scrollFreeActivate(this._controls.editor);
+  }
+});
+
+//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! ****
+//**** This only  exists for a while,  in order to  let ****
+//**** users adapt to  the new API.  Read up on the new ****
+//**** API and convert your code to it ASAP!            ****
+
+Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {
+  if (!options) return;
+  function fallback(name, expr) {
+    if (name in options || expr === undefined) return;
+    options[name] = expr;
+  };
+  fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' :
+    options.cancelLink == options.cancelButton == false ? false : undefined)));
+  fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' :
+    options.okLink == options.okButton == false ? false : undefined)));
+  fallback('highlightColor', options.highlightcolor);
+  fallback('highlightEndColor', options.highlightendcolor);
+};
+
+Object.extend(Ajax.InPlaceEditor, {
+  DefaultOptions: {
+    ajaxOptions: { },
+    autoRows: 3,                                // Use when multi-line w/ rows == 1
+    cancelControl: 'link',                      // 'link'|'button'|false
+    cancelText: 'cancel',
+    clickToEditText: 'Click to edit',
+    externalControl: null,                      // id|elt
+    externalControlOnly: false,
+    fieldPostCreation: 'activate',              // 'activate'|'focus'|false
+    formClassName: 'inplaceeditor-form',
+    formId: null,                               // id|elt
+    highlightColor: '#ffff99',
+    highlightEndColor: '#ffffff',
+    hoverClassName: '',
+    htmlResponse: true,
+    loadingClassName: 'inplaceeditor-loading',
+    loadingText: 'Loading...',
+    okControl: 'button',                        // 'link'|'button'|false
+    okText: 'ok',
+    paramName: 'value',
+    rows: 1,                                    // If 1 and multi-line, uses autoRows
+    savingClassName: 'inplaceeditor-saving',
+    savingText: 'Saving...',
+    size: 0,
+    stripLoadedTextTags: false,
+    submitOnBlur: false,
+    textAfterControls: '',
+    textBeforeControls: '',
+    textBetweenControls: ''
+  },
+  DefaultCallbacks: {
+    callback: function(form) {
+      return Form.serialize(form);
+    },
+    onComplete: function(transport, element) {
+      // For backward compatibility, this one is bound to the IPE, and passes
+      // the element directly.  It was too often customized, so we don't break it.
+      new Effect.Highlight(element, {
+        startcolor: this.options.highlightColor, keepBackgroundImage: true });
+    },
+    onEnterEditMode: null,
+    onEnterHover: function(ipe) {
+      ipe.element.style.backgroundColor = ipe.options.highlightColor;
+      if (ipe._effect)
+        ipe._effect.cancel();
+    },
+    onFailure: function(transport, ipe) {
+      alert('Error communication with the server: ' + transport.responseText.stripTags());
+    },
+    onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.
+    onLeaveEditMode: null,
+    onLeaveHover: function(ipe) {
+      ipe._effect = new Effect.Highlight(ipe.element, {
+        startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,
+        restorecolor: ipe._originalBackground, keepBackgroundImage: true
+      });
+    }
+  },
+  Listeners: {
+    click: 'enterEditMode',
+    keydown: 'checkForEscapeOrReturn',
+    mouseover: 'enterHover',
+    mouseout: 'leaveHover'
+  }
+});
+
+Ajax.InPlaceCollectionEditor.DefaultOptions = {
+  loadingCollectionText: 'Loading options...'
+};
+
+// Delayed observer, like Form.Element.Observer,
+// but waits for delay after last key input
+// Ideal for live-search fields
+
+Form.Element.DelayedObserver = Class.create({
+  initialize: function(element, delay, callback) {
+    this.delay     = delay || 0.5;
+    this.element   = $(element);
+    this.callback  = callback;
+    this.timer     = null;
+    this.lastValue = $F(this.element);
+    Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
+  },
+  delayedListener: function(event) {
+    if(this.lastValue == $F(this.element)) return;
+    if(this.timer) clearTimeout(this.timer);
+    this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
+    this.lastValue = $F(this.element);
+  },
+  onTimerEvent: function() {
+    this.timer = null;
+    this.callback(this.element, $F(this.element));
+  }
+});
Index: /tags/3.1/wp-includes/js/scriptaculous/dragdrop.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/dragdrop.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/dragdrop.js	(revision 17487)
@@ -0,0 +1,974 @@
+// script.aculo.us dragdrop.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+if(Object.isUndefined(Effect))
+  throw("dragdrop.js requires including script.aculo.us' effects.js library");
+
+var Droppables = {
+  drops: [],
+
+  remove: function(element) {
+    this.drops = this.drops.reject(function(d) { return d.element==$(element) });
+  },
+
+  add: function(element) {
+    element = $(element);
+    var options = Object.extend({
+      greedy:     true,
+      hoverclass: null,
+      tree:       false
+    }, arguments[1] || { });
+
+    // cache containers
+    if(options.containment) {
+      options._containers = [];
+      var containment = options.containment;
+      if(Object.isArray(containment)) {
+        containment.each( function(c) { options._containers.push($(c)) });
+      } else {
+        options._containers.push($(containment));
+      }
+    }
+
+    if(options.accept) options.accept = [options.accept].flatten();
+
+    Element.makePositioned(element); // fix IE
+    options.element = element;
+
+    this.drops.push(options);
+  },
+
+  findDeepestChild: function(drops) {
+    deepest = drops[0];
+
+    for (i = 1; i < drops.length; ++i)
+      if (Element.isParent(drops[i].element, deepest.element))
+        deepest = drops[i];
+
+    return deepest;
+  },
+
+  isContained: function(element, drop) {
+    var containmentNode;
+    if(drop.tree) {
+      containmentNode = element.treeNode;
+    } else {
+      containmentNode = element.parentNode;
+    }
+    return drop._containers.detect(function(c) { return containmentNode == c });
+  },
+
+  isAffected: function(point, element, drop) {
+    return (
+      (drop.element!=element) &&
+      ((!drop._containers) ||
+        this.isContained(element, drop)) &&
+      ((!drop.accept) ||
+        (Element.classNames(element).detect(
+          function(v) { return drop.accept.include(v) } ) )) &&
+      Position.within(drop.element, point[0], point[1]) );
+  },
+
+  deactivate: function(drop) {
+    if(drop.hoverclass)
+      Element.removeClassName(drop.element, drop.hoverclass);
+    this.last_active = null;
+  },
+
+  activate: function(drop) {
+    if(drop.hoverclass)
+      Element.addClassName(drop.element, drop.hoverclass);
+    this.last_active = drop;
+  },
+
+  show: function(point, element) {
+    if(!this.drops.length) return;
+    var drop, affected = [];
+
+    this.drops.each( function(drop) {
+      if(Droppables.isAffected(point, element, drop))
+        affected.push(drop);
+    });
+
+    if(affected.length>0)
+      drop = Droppables.findDeepestChild(affected);
+
+    if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);
+    if (drop) {
+      Position.within(drop.element, point[0], point[1]);
+      if(drop.onHover)
+        drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
+
+      if (drop != this.last_active) Droppables.activate(drop);
+    }
+  },
+
+  fire: function(event, element) {
+    if(!this.last_active) return;
+    Position.prepare();
+
+    if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
+      if (this.last_active.onDrop) {
+        this.last_active.onDrop(element, this.last_active.element, event);
+        return true;
+      }
+  },
+
+  reset: function() {
+    if(this.last_active)
+      this.deactivate(this.last_active);
+  }
+};
+
+var Draggables = {
+  drags: [],
+  observers: [],
+
+  register: function(draggable) {
+    if(this.drags.length == 0) {
+      this.eventMouseUp   = this.endDrag.bindAsEventListener(this);
+      this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
+      this.eventKeypress  = this.keyPress.bindAsEventListener(this);
+
+      Event.observe(document, "mouseup", this.eventMouseUp);
+      Event.observe(document, "mousemove", this.eventMouseMove);
+      Event.observe(document, "keypress", this.eventKeypress);
+    }
+    this.drags.push(draggable);
+  },
+
+  unregister: function(draggable) {
+    this.drags = this.drags.reject(function(d) { return d==draggable });
+    if(this.drags.length == 0) {
+      Event.stopObserving(document, "mouseup", this.eventMouseUp);
+      Event.stopObserving(document, "mousemove", this.eventMouseMove);
+      Event.stopObserving(document, "keypress", this.eventKeypress);
+    }
+  },
+
+  activate: function(draggable) {
+    if(draggable.options.delay) {
+      this._timeout = setTimeout(function() {
+        Draggables._timeout = null;
+        window.focus();
+        Draggables.activeDraggable = draggable;
+      }.bind(this), draggable.options.delay);
+    } else {
+      window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
+      this.activeDraggable = draggable;
+    }
+  },
+
+  deactivate: function() {
+    this.activeDraggable = null;
+  },
+
+  updateDrag: function(event) {
+    if(!this.activeDraggable) return;
+    var pointer = [Event.pointerX(event), Event.pointerY(event)];
+    // Mozilla-based browsers fire successive mousemove events with
+    // the same coordinates, prevent needless redrawing (moz bug?)
+    if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
+    this._lastPointer = pointer;
+
+    this.activeDraggable.updateDrag(event, pointer);
+  },
+
+  endDrag: function(event) {
+    if(this._timeout) {
+      clearTimeout(this._timeout);
+      this._timeout = null;
+    }
+    if(!this.activeDraggable) return;
+    this._lastPointer = null;
+    this.activeDraggable.endDrag(event);
+    this.activeDraggable = null;
+  },
+
+  keyPress: function(event) {
+    if(this.activeDraggable)
+      this.activeDraggable.keyPress(event);
+  },
+
+  addObserver: function(observer) {
+    this.observers.push(observer);
+    this._cacheObserverCallbacks();
+  },
+
+  removeObserver: function(element) {  // element instead of observer fixes mem leaks
+    this.observers = this.observers.reject( function(o) { return o.element==element });
+    this._cacheObserverCallbacks();
+  },
+
+  notify: function(eventName, draggable, event) {  // 'onStart', 'onEnd', 'onDrag'
+    if(this[eventName+'Count'] > 0)
+      this.observers.each( function(o) {
+        if(o[eventName]) o[eventName](eventName, draggable, event);
+      });
+    if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
+  },
+
+  _cacheObserverCallbacks: function() {
+    ['onStart','onEnd','onDrag'].each( function(eventName) {
+      Draggables[eventName+'Count'] = Draggables.observers.select(
+        function(o) { return o[eventName]; }
+      ).length;
+    });
+  }
+};
+
+/*--------------------------------------------------------------------------*/
+
+var Draggable = Class.create({
+  initialize: function(element) {
+    var defaults = {
+      handle: false,
+      reverteffect: function(element, top_offset, left_offset) {
+        var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
+        new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
+          queue: {scope:'_draggable', position:'end'}
+        });
+      },
+      endeffect: function(element) {
+        var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
+        new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
+          queue: {scope:'_draggable', position:'end'},
+          afterFinish: function(){
+            Draggable._dragging[element] = false
+          }
+        });
+      },
+      zindex: 1000,
+      revert: false,
+      quiet: false,
+      scroll: false,
+      scrollSensitivity: 20,
+      scrollSpeed: 15,
+      snap: false,  // false, or xy or [x,y] or function(x,y){ return [x,y] }
+      delay: 0
+    };
+
+    if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
+      Object.extend(defaults, {
+        starteffect: function(element) {
+          element._opacity = Element.getOpacity(element);
+          Draggable._dragging[element] = true;
+          new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
+        }
+      });
+
+    var options = Object.extend(defaults, arguments[1] || { });
+
+    this.element = $(element);
+
+    if(options.handle && Object.isString(options.handle))
+      this.handle = this.element.down('.'+options.handle, 0);
+
+    if(!this.handle) this.handle = $(options.handle);
+    if(!this.handle) this.handle = this.element;
+
+    if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
+      options.scroll = $(options.scroll);
+      this._isScrollChild = Element.childOf(this.element, options.scroll);
+    }
+
+    Element.makePositioned(this.element); // fix IE
+
+    this.options  = options;
+    this.dragging = false;
+
+    this.eventMouseDown = this.initDrag.bindAsEventListener(this);
+    Event.observe(this.handle, "mousedown", this.eventMouseDown);
+
+    Draggables.register(this);
+  },
+
+  destroy: function() {
+    Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
+    Draggables.unregister(this);
+  },
+
+  currentDelta: function() {
+    return([
+      parseInt(Element.getStyle(this.element,'left') || '0'),
+      parseInt(Element.getStyle(this.element,'top') || '0')]);
+  },
+
+  initDrag: function(event) {
+    if(!Object.isUndefined(Draggable._dragging[this.element]) &&
+      Draggable._dragging[this.element]) return;
+    if(Event.isLeftClick(event)) {
+      // abort on form elements, fixes a Firefox issue
+      var src = Event.element(event);
+      if((tag_name = src.tagName.toUpperCase()) && (
+        tag_name=='INPUT' ||
+        tag_name=='SELECT' ||
+        tag_name=='OPTION' ||
+        tag_name=='BUTTON' ||
+        tag_name=='TEXTAREA')) return;
+
+      var pointer = [Event.pointerX(event), Event.pointerY(event)];
+      var pos     = this.element.cumulativeOffset();
+      this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
+
+      Draggables.activate(this);
+      Event.stop(event);
+    }
+  },
+
+  startDrag: function(event) {
+    this.dragging = true;
+    if(!this.delta)
+      this.delta = this.currentDelta();
+
+    if(this.options.zindex) {
+      this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
+      this.element.style.zIndex = this.options.zindex;
+    }
+
+    if(this.options.ghosting) {
+      this._clone = this.element.cloneNode(true);
+      this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
+      if (!this._originallyAbsolute)
+        Position.absolutize(this.element);
+      this.element.parentNode.insertBefore(this._clone, this.element);
+    }
+
+    if(this.options.scroll) {
+      if (this.options.scroll == window) {
+        var where = this._getWindowScroll(this.options.scroll);
+        this.originalScrollLeft = where.left;
+        this.originalScrollTop = where.top;
+      } else {
+        this.originalScrollLeft = this.options.scroll.scrollLeft;
+        this.originalScrollTop = this.options.scroll.scrollTop;
+      }
+    }
+
+    Draggables.notify('onStart', this, event);
+
+    if(this.options.starteffect) this.options.starteffect(this.element);
+  },
+
+  updateDrag: function(event, pointer) {
+    if(!this.dragging) this.startDrag(event);
+
+    if(!this.options.quiet){
+      Position.prepare();
+      Droppables.show(pointer, this.element);
+    }
+
+    Draggables.notify('onDrag', this, event);
+
+    this.draw(pointer);
+    if(this.options.change) this.options.change(this);
+
+    if(this.options.scroll) {
+      this.stopScrolling();
+
+      var p;
+      if (this.options.scroll == window) {
+        with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
+      } else {
+        p = Position.page(this.options.scroll);
+        p[0] += this.options.scroll.scrollLeft + Position.deltaX;
+        p[1] += this.options.scroll.scrollTop + Position.deltaY;
+        p.push(p[0]+this.options.scroll.offsetWidth);
+        p.push(p[1]+this.options.scroll.offsetHeight);
+      }
+      var speed = [0,0];
+      if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity);
+      if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity);
+      if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity);
+      if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
+      this.startScrolling(speed);
+    }
+
+    // fix AppleWebKit rendering
+    if(Prototype.Browser.WebKit) window.scrollBy(0,0);
+
+    Event.stop(event);
+  },
+
+  finishDrag: function(event, success) {
+    this.dragging = false;
+
+    if(this.options.quiet){
+      Position.prepare();
+      var pointer = [Event.pointerX(event), Event.pointerY(event)];
+      Droppables.show(pointer, this.element);
+    }
+
+    if(this.options.ghosting) {
+      if (!this._originallyAbsolute)
+        Position.relativize(this.element);
+      delete this._originallyAbsolute;
+      Element.remove(this._clone);
+      this._clone = null;
+    }
+
+    var dropped = false;
+    if(success) {
+      dropped = Droppables.fire(event, this.element);
+      if (!dropped) dropped = false;
+    }
+    if(dropped && this.options.onDropped) this.options.onDropped(this.element);
+    Draggables.notify('onEnd', this, event);
+
+    var revert = this.options.revert;
+    if(revert && Object.isFunction(revert)) revert = revert(this.element);
+
+    var d = this.currentDelta();
+    if(revert && this.options.reverteffect) {
+      if (dropped == 0 || revert != 'failure')
+        this.options.reverteffect(this.element,
+          d[1]-this.delta[1], d[0]-this.delta[0]);
+    } else {
+      this.delta = d;
+    }
+
+    if(this.options.zindex)
+      this.element.style.zIndex = this.originalZ;
+
+    if(this.options.endeffect)
+      this.options.endeffect(this.element);
+
+    Draggables.deactivate(this);
+    Droppables.reset();
+  },
+
+  keyPress: function(event) {
+    if(event.keyCode!=Event.KEY_ESC) return;
+    this.finishDrag(event, false);
+    Event.stop(event);
+  },
+
+  endDrag: function(event) {
+    if(!this.dragging) return;
+    this.stopScrolling();
+    this.finishDrag(event, true);
+    Event.stop(event);
+  },
+
+  draw: function(point) {
+    var pos = this.element.cumulativeOffset();
+    if(this.options.ghosting) {
+      var r   = Position.realOffset(this.element);
+      pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
+    }
+
+    var d = this.currentDelta();
+    pos[0] -= d[0]; pos[1] -= d[1];
+
+    if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
+      pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
+      pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
+    }
+
+    var p = [0,1].map(function(i){
+      return (point[i]-pos[i]-this.offset[i])
+    }.bind(this));
+
+    if(this.options.snap) {
+      if(Object.isFunction(this.options.snap)) {
+        p = this.options.snap(p[0],p[1],this);
+      } else {
+      if(Object.isArray(this.options.snap)) {
+        p = p.map( function(v, i) {
+          return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
+      } else {
+        p = p.map( function(v) {
+          return (v/this.options.snap).round()*this.options.snap }.bind(this));
+      }
+    }}
+
+    var style = this.element.style;
+    if((!this.options.constraint) || (this.options.constraint=='horizontal'))
+      style.left = p[0] + "px";
+    if((!this.options.constraint) || (this.options.constraint=='vertical'))
+      style.top  = p[1] + "px";
+
+    if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+  },
+
+  stopScrolling: function() {
+    if(this.scrollInterval) {
+      clearInterval(this.scrollInterval);
+      this.scrollInterval = null;
+      Draggables._lastScrollPointer = null;
+    }
+  },
+
+  startScrolling: function(speed) {
+    if(!(speed[0] || speed[1])) return;
+    this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
+    this.lastScrolled = new Date();
+    this.scrollInterval = setInterval(this.scroll.bind(this), 10);
+  },
+
+  scroll: function() {
+    var current = new Date();
+    var delta = current - this.lastScrolled;
+    this.lastScrolled = current;
+    if(this.options.scroll == window) {
+      with (this._getWindowScroll(this.options.scroll)) {
+        if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
+          var d = delta / 1000;
+          this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] );
+        }
+      }
+    } else {
+      this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
+      this.options.scroll.scrollTop  += this.scrollSpeed[1] * delta / 1000;
+    }
+
+    Position.prepare();
+    Droppables.show(Draggables._lastPointer, this.element);
+    Draggables.notify('onDrag', this);
+    if (this._isScrollChild) {
+      Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);
+      Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;
+      Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;
+      if (Draggables._lastScrollPointer[0] < 0)
+        Draggables._lastScrollPointer[0] = 0;
+      if (Draggables._lastScrollPointer[1] < 0)
+        Draggables._lastScrollPointer[1] = 0;
+      this.draw(Draggables._lastScrollPointer);
+    }
+
+    if(this.options.change) this.options.change(this);
+  },
+
+  _getWindowScroll: function(w) {
+    var T, L, W, H;
+    with (w.document) {
+      if (w.document.documentElement && documentElement.scrollTop) {
+        T = documentElement.scrollTop;
+        L = documentElement.scrollLeft;
+      } else if (w.document.body) {
+        T = body.scrollTop;
+        L = body.scrollLeft;
+      }
+      if (w.innerWidth) {
+        W = w.innerWidth;
+        H = w.innerHeight;
+      } else if (w.document.documentElement && documentElement.clientWidth) {
+        W = documentElement.clientWidth;
+        H = documentElement.clientHeight;
+      } else {
+        W = body.offsetWidth;
+        H = body.offsetHeight;
+      }
+    }
+    return { top: T, left: L, width: W, height: H };
+  }
+});
+
+Draggable._dragging = { };
+
+/*--------------------------------------------------------------------------*/
+
+var SortableObserver = Class.create({
+  initialize: function(element, observer) {
+    this.element   = $(element);
+    this.observer  = observer;
+    this.lastValue = Sortable.serialize(this.element);
+  },
+
+  onStart: function() {
+    this.lastValue = Sortable.serialize(this.element);
+  },
+
+  onEnd: function() {
+    Sortable.unmark();
+    if(this.lastValue != Sortable.serialize(this.element))
+      this.observer(this.element)
+  }
+});
+
+var Sortable = {
+  SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
+
+  sortables: { },
+
+  _findRootElement: function(element) {
+    while (element.tagName.toUpperCase() != "BODY") {
+      if(element.id && Sortable.sortables[element.id]) return element;
+      element = element.parentNode;
+    }
+  },
+
+  options: function(element) {
+    element = Sortable._findRootElement($(element));
+    if(!element) return;
+    return Sortable.sortables[element.id];
+  },
+
+  destroy: function(element){
+    element = $(element);
+    var s = Sortable.sortables[element.id];
+
+    if(s) {
+      Draggables.removeObserver(s.element);
+      s.droppables.each(function(d){ Droppables.remove(d) });
+      s.draggables.invoke('destroy');
+
+      delete Sortable.sortables[s.element.id];
+    }
+  },
+
+  create: function(element) {
+    element = $(element);
+    var options = Object.extend({
+      element:     element,
+      tag:         'li',       // assumes li children, override with tag: 'tagname'
+      dropOnEmpty: false,
+      tree:        false,
+      treeTag:     'ul',
+      overlap:     'vertical', // one of 'vertical', 'horizontal'
+      constraint:  'vertical', // one of 'vertical', 'horizontal', false
+      containment: element,    // also takes array of elements (or id's); or false
+      handle:      false,      // or a CSS class
+      only:        false,
+      delay:       0,
+      hoverclass:  null,
+      ghosting:    false,
+      quiet:       false,
+      scroll:      false,
+      scrollSensitivity: 20,
+      scrollSpeed: 15,
+      format:      this.SERIALIZE_RULE,
+
+      // these take arrays of elements or ids and can be
+      // used for better initialization performance
+      elements:    false,
+      handles:     false,
+
+      onChange:    Prototype.emptyFunction,
+      onUpdate:    Prototype.emptyFunction
+    }, arguments[1] || { });
+
+    // clear any old sortable with same element
+    this.destroy(element);
+
+    // build options for the draggables
+    var options_for_draggable = {
+      revert:      true,
+      quiet:       options.quiet,
+      scroll:      options.scroll,
+      scrollSpeed: options.scrollSpeed,
+      scrollSensitivity: options.scrollSensitivity,
+      delay:       options.delay,
+      ghosting:    options.ghosting,
+      constraint:  options.constraint,
+      handle:      options.handle };
+
+    if(options.starteffect)
+      options_for_draggable.starteffect = options.starteffect;
+
+    if(options.reverteffect)
+      options_for_draggable.reverteffect = options.reverteffect;
+    else
+      if(options.ghosting) options_for_draggable.reverteffect = function(element) {
+        element.style.top  = 0;
+        element.style.left = 0;
+      };
+
+    if(options.endeffect)
+      options_for_draggable.endeffect = options.endeffect;
+
+    if(options.zindex)
+      options_for_draggable.zindex = options.zindex;
+
+    // build options for the droppables
+    var options_for_droppable = {
+      overlap:     options.overlap,
+      containment: options.containment,
+      tree:        options.tree,
+      hoverclass:  options.hoverclass,
+      onHover:     Sortable.onHover
+    };
+
+    var options_for_tree = {
+      onHover:      Sortable.onEmptyHover,
+      overlap:      options.overlap,
+      containment:  options.containment,
+      hoverclass:   options.hoverclass
+    };
+
+    // fix for gecko engine
+    Element.cleanWhitespace(element);
+
+    options.draggables = [];
+    options.droppables = [];
+
+    // drop on empty handling
+    if(options.dropOnEmpty || options.tree) {
+      Droppables.add(element, options_for_tree);
+      options.droppables.push(element);
+    }
+
+    (options.elements || this.findElements(element, options) || []).each( function(e,i) {
+      var handle = options.handles ? $(options.handles[i]) :
+        (options.handle ? $(e).select('.' + options.handle)[0] : e);
+      options.draggables.push(
+        new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
+      Droppables.add(e, options_for_droppable);
+      if(options.tree) e.treeNode = element;
+      options.droppables.push(e);
+    });
+
+    if(options.tree) {
+      (Sortable.findTreeElements(element, options) || []).each( function(e) {
+        Droppables.add(e, options_for_tree);
+        e.treeNode = element;
+        options.droppables.push(e);
+      });
+    }
+
+    // keep reference
+    this.sortables[element.identify()] = options;
+
+    // for onupdate
+    Draggables.addObserver(new SortableObserver(element, options.onUpdate));
+
+  },
+
+  // return all suitable-for-sortable elements in a guaranteed order
+  findElements: function(element, options) {
+    return Element.findChildren(
+      element, options.only, options.tree ? true : false, options.tag);
+  },
+
+  findTreeElements: function(element, options) {
+    return Element.findChildren(
+      element, options.only, options.tree ? true : false, options.treeTag);
+  },
+
+  onHover: function(element, dropon, overlap) {
+    if(Element.isParent(dropon, element)) return;
+
+    if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) {
+      return;
+    } else if(overlap>0.5) {
+      Sortable.mark(dropon, 'before');
+      if(dropon.previousSibling != element) {
+        var oldParentNode = element.parentNode;
+        element.style.visibility = "hidden"; // fix gecko rendering
+        dropon.parentNode.insertBefore(element, dropon);
+        if(dropon.parentNode!=oldParentNode)
+          Sortable.options(oldParentNode).onChange(element);
+        Sortable.options(dropon.parentNode).onChange(element);
+      }
+    } else {
+      Sortable.mark(dropon, 'after');
+      var nextElement = dropon.nextSibling || null;
+      if(nextElement != element) {
+        var oldParentNode = element.parentNode;
+        element.style.visibility = "hidden"; // fix gecko rendering
+        dropon.parentNode.insertBefore(element, nextElement);
+        if(dropon.parentNode!=oldParentNode)
+          Sortable.options(oldParentNode).onChange(element);
+        Sortable.options(dropon.parentNode).onChange(element);
+      }
+    }
+  },
+
+  onEmptyHover: function(element, dropon, overlap) {
+    var oldParentNode = element.parentNode;
+    var droponOptions = Sortable.options(dropon);
+
+    if(!Element.isParent(dropon, element)) {
+      var index;
+
+      var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
+      var child = null;
+
+      if(children) {
+        var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
+
+        for (index = 0; index < children.length; index += 1) {
+          if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
+            offset -= Element.offsetSize (children[index], droponOptions.overlap);
+          } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {
+            child = index + 1 < children.length ? children[index + 1] : null;
+            break;
+          } else {
+            child = children[index];
+            break;
+          }
+        }
+      }
+
+      dropon.insertBefore(element, child);
+
+      Sortable.options(oldParentNode).onChange(element);
+      droponOptions.onChange(element);
+    }
+  },
+
+  unmark: function() {
+    if(Sortable._marker) Sortable._marker.hide();
+  },
+
+  mark: function(dropon, position) {
+    // mark on ghosting only
+    var sortable = Sortable.options(dropon.parentNode);
+    if(sortable && !sortable.ghosting) return;
+
+    if(!Sortable._marker) {
+      Sortable._marker =
+        ($('dropmarker') || Element.extend(document.createElement('DIV'))).
+          hide().addClassName('dropmarker').setStyle({position:'absolute'});
+      document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
+    }
+    var offsets = dropon.cumulativeOffset();
+    Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
+
+    if(position=='after')
+      if(sortable.overlap == 'horizontal')
+        Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
+      else
+        Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
+
+    Sortable._marker.show();
+  },
+
+  _tree: function(element, options, parent) {
+    var children = Sortable.findElements(element, options) || [];
+
+    for (var i = 0; i < children.length; ++i) {
+      var match = children[i].id.match(options.format);
+
+      if (!match) continue;
+
+      var child = {
+        id: encodeURIComponent(match ? match[1] : null),
+        element: element,
+        parent: parent,
+        children: [],
+        position: parent.children.length,
+        container: $(children[i]).down(options.treeTag)
+      };
+
+      /* Get the element containing the children and recurse over it */
+      if (child.container)
+        this._tree(child.container, options, child);
+
+      parent.children.push (child);
+    }
+
+    return parent;
+  },
+
+  tree: function(element) {
+    element = $(element);
+    var sortableOptions = this.options(element);
+    var options = Object.extend({
+      tag: sortableOptions.tag,
+      treeTag: sortableOptions.treeTag,
+      only: sortableOptions.only,
+      name: element.id,
+      format: sortableOptions.format
+    }, arguments[1] || { });
+
+    var root = {
+      id: null,
+      parent: null,
+      children: [],
+      container: element,
+      position: 0
+    };
+
+    return Sortable._tree(element, options, root);
+  },
+
+  /* Construct a [i] index for a particular node */
+  _constructIndex: function(node) {
+    var index = '';
+    do {
+      if (node.id) index = '[' + node.position + ']' + index;
+    } while ((node = node.parent) != null);
+    return index;
+  },
+
+  sequence: function(element) {
+    element = $(element);
+    var options = Object.extend(this.options(element), arguments[1] || { });
+
+    return $(this.findElements(element, options) || []).map( function(item) {
+      return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
+    });
+  },
+
+  setSequence: function(element, new_sequence) {
+    element = $(element);
+    var options = Object.extend(this.options(element), arguments[2] || { });
+
+    var nodeMap = { };
+    this.findElements(element, options).each( function(n) {
+        if (n.id.match(options.format))
+            nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
+        n.parentNode.removeChild(n);
+    });
+
+    new_sequence.each(function(ident) {
+      var n = nodeMap[ident];
+      if (n) {
+        n[1].appendChild(n[0]);
+        delete nodeMap[ident];
+      }
+    });
+  },
+
+  serialize: function(element) {
+    element = $(element);
+    var options = Object.extend(Sortable.options(element), arguments[1] || { });
+    var name = encodeURIComponent(
+      (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
+
+    if (options.tree) {
+      return Sortable.tree(element, arguments[1]).children.map( function (item) {
+        return [name + Sortable._constructIndex(item) + "[id]=" +
+                encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
+      }).flatten().join('&');
+    } else {
+      return Sortable.sequence(element, arguments[1]).map( function(item) {
+        return name + "[]=" + encodeURIComponent(item);
+      }).join('&');
+    }
+  }
+};
+
+// Returns true if child is contained within element
+Element.isParent = function(child, element) {
+  if (!child.parentNode || child == element) return false;
+  if (child.parentNode == element) return true;
+  return Element.isParent(child.parentNode, element);
+};
+
+Element.findChildren = function(element, only, recursive, tagName) {
+  if(!element.hasChildNodes()) return null;
+  tagName = tagName.toUpperCase();
+  if(only) only = [only].flatten();
+  var elements = [];
+  $A(element.childNodes).each( function(e) {
+    if(e.tagName && e.tagName.toUpperCase()==tagName &&
+      (!only || (Element.classNames(e).detect(function(v) { return only.include(v) }))))
+        elements.push(e);
+    if(recursive) {
+      var grandchildren = Element.findChildren(e, only, recursive, tagName);
+      if(grandchildren) elements.push(grandchildren);
+    }
+  });
+
+  return (elements.length>0 ? elements.flatten() : []);
+};
+
+Element.offsetSize = function (element, type) {
+  return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
+};
Index: /tags/3.1/wp-includes/js/scriptaculous/effects.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/effects.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/effects.js	(revision 17487)
@@ -0,0 +1,1123 @@
+// script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Contributors:
+//  Justin Palmer (http://encytemedia.com/)
+//  Mark Pilgrim (http://diveintomark.org/)
+//  Martin Bialasinki
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// converts rgb() and #xxx to #xxxxxx format,
+// returns self (or first argument) if not convertable
+String.prototype.parseColor = function() {
+  var color = '#';
+  if (this.slice(0,4) == 'rgb(') {
+    var cols = this.slice(4,this.length-1).split(',');
+    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
+  } else {
+    if (this.slice(0,1) == '#') {
+      if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
+      if (this.length==7) color = this.toLowerCase();
+    }
+  }
+  return (color.length==7 ? color : (arguments[0] || this));
+};
+
+/*--------------------------------------------------------------------------*/
+
+Element.collectTextNodes = function(element) {
+  return $A($(element).childNodes).collect( function(node) {
+    return (node.nodeType==3 ? node.nodeValue :
+      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
+  }).flatten().join('');
+};
+
+Element.collectTextNodesIgnoreClass = function(element, className) {
+  return $A($(element).childNodes).collect( function(node) {
+    return (node.nodeType==3 ? node.nodeValue :
+      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
+        Element.collectTextNodesIgnoreClass(node, className) : ''));
+  }).flatten().join('');
+};
+
+Element.setContentZoom = function(element, percent) {
+  element = $(element);
+  element.setStyle({fontSize: (percent/100) + 'em'});
+  if (Prototype.Browser.WebKit) window.scrollBy(0,0);
+  return element;
+};
+
+Element.getInlineOpacity = function(element){
+  return $(element).style.opacity || '';
+};
+
+Element.forceRerendering = function(element) {
+  try {
+    element = $(element);
+    var n = document.createTextNode(' ');
+    element.appendChild(n);
+    element.removeChild(n);
+  } catch(e) { }
+};
+
+/*--------------------------------------------------------------------------*/
+
+var Effect = {
+  _elementDoesNotExistError: {
+    name: 'ElementDoesNotExistError',
+    message: 'The specified DOM element does not exist, but is required for this effect to operate'
+  },
+  Transitions: {
+    linear: Prototype.K,
+    sinoidal: function(pos) {
+      return (-Math.cos(pos*Math.PI)/2) + .5;
+    },
+    reverse: function(pos) {
+      return 1-pos;
+    },
+    flicker: function(pos) {
+      var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4;
+      return pos > 1 ? 1 : pos;
+    },
+    wobble: function(pos) {
+      return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5;
+    },
+    pulse: function(pos, pulses) {
+      return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5;
+    },
+    spring: function(pos) {
+      return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6));
+    },
+    none: function(pos) {
+      return 0;
+    },
+    full: function(pos) {
+      return 1;
+    }
+  },
+  DefaultOptions: {
+    duration:   1.0,   // seconds
+    fps:        100,   // 100= assume 66fps max.
+    sync:       false, // true for combining
+    from:       0.0,
+    to:         1.0,
+    delay:      0.0,
+    queue:      'parallel'
+  },
+  tagifyText: function(element) {
+    var tagifyStyle = 'position:relative';
+    if (Prototype.Browser.IE) tagifyStyle += ';zoom:1';
+
+    element = $(element);
+    $A(element.childNodes).each( function(child) {
+      if (child.nodeType==3) {
+        child.nodeValue.toArray().each( function(character) {
+          element.insertBefore(
+            new Element('span', {style: tagifyStyle}).update(
+              character == ' ' ? String.fromCharCode(160) : character),
+              child);
+        });
+        Element.remove(child);
+      }
+    });
+  },
+  multiple: function(element, effect) {
+    var elements;
+    if (((typeof element == 'object') ||
+        Object.isFunction(element)) &&
+       (element.length))
+      elements = element;
+    else
+      elements = $(element).childNodes;
+
+    var options = Object.extend({
+      speed: 0.1,
+      delay: 0.0
+    }, arguments[2] || { });
+    var masterDelay = options.delay;
+
+    $A(elements).each( function(element, index) {
+      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
+    });
+  },
+  PAIRS: {
+    'slide':  ['SlideDown','SlideUp'],
+    'blind':  ['BlindDown','BlindUp'],
+    'appear': ['Appear','Fade']
+  },
+  toggle: function(element, effect, options) {
+    element = $(element);
+    effect  = (effect || 'appear').toLowerCase();
+    
+    return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
+      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
+    }, options || {}));
+  }
+};
+
+Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;
+
+/* ------------- core effects ------------- */
+
+Effect.ScopedQueue = Class.create(Enumerable, {
+  initialize: function() {
+    this.effects  = [];
+    this.interval = null;
+  },
+  _each: function(iterator) {
+    this.effects._each(iterator);
+  },
+  add: function(effect) {
+    var timestamp = new Date().getTime();
+
+    var position = Object.isString(effect.options.queue) ?
+      effect.options.queue : effect.options.queue.position;
+
+    switch(position) {
+      case 'front':
+        // move unstarted effects after this effect
+        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
+            e.startOn  += effect.finishOn;
+            e.finishOn += effect.finishOn;
+          });
+        break;
+      case 'with-last':
+        timestamp = this.effects.pluck('startOn').max() || timestamp;
+        break;
+      case 'end':
+        // start effect after last queued effect has finished
+        timestamp = this.effects.pluck('finishOn').max() || timestamp;
+        break;
+    }
+
+    effect.startOn  += timestamp;
+    effect.finishOn += timestamp;
+
+    if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
+      this.effects.push(effect);
+
+    if (!this.interval)
+      this.interval = setInterval(this.loop.bind(this), 15);
+  },
+  remove: function(effect) {
+    this.effects = this.effects.reject(function(e) { return e==effect });
+    if (this.effects.length == 0) {
+      clearInterval(this.interval);
+      this.interval = null;
+    }
+  },
+  loop: function() {
+    var timePos = new Date().getTime();
+    for(var i=0, len=this.effects.length;i<len;i++)
+      this.effects[i] && this.effects[i].loop(timePos);
+  }
+});
+
+Effect.Queues = {
+  instances: $H(),
+  get: function(queueName) {
+    if (!Object.isString(queueName)) return queueName;
+
+    return this.instances.get(queueName) ||
+      this.instances.set(queueName, new Effect.ScopedQueue());
+  }
+};
+Effect.Queue = Effect.Queues.get('global');
+
+Effect.Base = Class.create({
+  position: null,
+  start: function(options) {
+    if (options && options.transition === false) options.transition = Effect.Transitions.linear;
+    this.options      = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
+    this.currentFrame = 0;
+    this.state        = 'idle';
+    this.startOn      = this.options.delay*1000;
+    this.finishOn     = this.startOn+(this.options.duration*1000);
+    this.fromToDelta  = this.options.to-this.options.from;
+    this.totalTime    = this.finishOn-this.startOn;
+    this.totalFrames  = this.options.fps*this.options.duration;
+
+    this.render = (function() {
+      function dispatch(effect, eventName) {
+        if (effect.options[eventName + 'Internal'])
+          effect.options[eventName + 'Internal'](effect);
+        if (effect.options[eventName])
+          effect.options[eventName](effect);
+      }
+
+      return function(pos) {
+        if (this.state === "idle") {
+          this.state = "running";
+          dispatch(this, 'beforeSetup');
+          if (this.setup) this.setup();
+          dispatch(this, 'afterSetup');
+        }
+        if (this.state === "running") {
+          pos = (this.options.transition(pos) * this.fromToDelta) + this.options.from;
+          this.position = pos;
+          dispatch(this, 'beforeUpdate');
+          if (this.update) this.update(pos);
+          dispatch(this, 'afterUpdate');
+        }
+      };
+    })();
+
+    this.event('beforeStart');
+    if (!this.options.sync)
+      Effect.Queues.get(Object.isString(this.options.queue) ?
+        'global' : this.options.queue.scope).add(this);
+  },
+  loop: function(timePos) {
+    if (timePos >= this.startOn) {
+      if (timePos >= this.finishOn) {
+        this.render(1.0);
+        this.cancel();
+        this.event('beforeFinish');
+        if (this.finish) this.finish();
+        this.event('afterFinish');
+        return;
+      }
+      var pos   = (timePos - this.startOn) / this.totalTime,
+          frame = (pos * this.totalFrames).round();
+      if (frame > this.currentFrame) {
+        this.render(pos);
+        this.currentFrame = frame;
+      }
+    }
+  },
+  cancel: function() {
+    if (!this.options.sync)
+      Effect.Queues.get(Object.isString(this.options.queue) ?
+        'global' : this.options.queue.scope).remove(this);
+    this.state = 'finished';
+  },
+  event: function(eventName) {
+    if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
+    if (this.options[eventName]) this.options[eventName](this);
+  },
+  inspect: function() {
+    var data = $H();
+    for(property in this)
+      if (!Object.isFunction(this[property])) data.set(property, this[property]);
+    return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
+  }
+});
+
+Effect.Parallel = Class.create(Effect.Base, {
+  initialize: function(effects) {
+    this.effects = effects || [];
+    this.start(arguments[1]);
+  },
+  update: function(position) {
+    this.effects.invoke('render', position);
+  },
+  finish: function(position) {
+    this.effects.each( function(effect) {
+      effect.render(1.0);
+      effect.cancel();
+      effect.event('beforeFinish');
+      if (effect.finish) effect.finish(position);
+      effect.event('afterFinish');
+    });
+  }
+});
+
+Effect.Tween = Class.create(Effect.Base, {
+  initialize: function(object, from, to) {
+    object = Object.isString(object) ? $(object) : object;
+    var args = $A(arguments), method = args.last(),
+      options = args.length == 5 ? args[3] : null;
+    this.method = Object.isFunction(method) ? method.bind(object) :
+      Object.isFunction(object[method]) ? object[method].bind(object) :
+      function(value) { object[method] = value };
+    this.start(Object.extend({ from: from, to: to }, options || { }));
+  },
+  update: function(position) {
+    this.method(position);
+  }
+});
+
+Effect.Event = Class.create(Effect.Base, {
+  initialize: function() {
+    this.start(Object.extend({ duration: 0 }, arguments[0] || { }));
+  },
+  update: Prototype.emptyFunction
+});
+
+Effect.Opacity = Class.create(Effect.Base, {
+  initialize: function(element) {
+    this.element = $(element);
+    if (!this.element) throw(Effect._elementDoesNotExistError);
+    // make this work on IE on elements without 'layout'
+    if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
+      this.element.setStyle({zoom: 1});
+    var options = Object.extend({
+      from: this.element.getOpacity() || 0.0,
+      to:   1.0
+    }, arguments[1] || { });
+    this.start(options);
+  },
+  update: function(position) {
+    this.element.setOpacity(position);
+  }
+});
+
+Effect.Move = Class.create(Effect.Base, {
+  initialize: function(element) {
+    this.element = $(element);
+    if (!this.element) throw(Effect._elementDoesNotExistError);
+    var options = Object.extend({
+      x:    0,
+      y:    0,
+      mode: 'relative'
+    }, arguments[1] || { });
+    this.start(options);
+  },
+  setup: function() {
+    this.element.makePositioned();
+    this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
+    this.originalTop  = parseFloat(this.element.getStyle('top')  || '0');
+    if (this.options.mode == 'absolute') {
+      this.options.x = this.options.x - this.originalLeft;
+      this.options.y = this.options.y - this.originalTop;
+    }
+  },
+  update: function(position) {
+    this.element.setStyle({
+      left: (this.options.x  * position + this.originalLeft).round() + 'px',
+      top:  (this.options.y  * position + this.originalTop).round()  + 'px'
+    });
+  }
+});
+
+// for backwards compatibility
+Effect.MoveBy = function(element, toTop, toLeft) {
+  return new Effect.Move(element,
+    Object.extend({ x: toLeft, y: toTop }, arguments[3] || { }));
+};
+
+Effect.Scale = Class.create(Effect.Base, {
+  initialize: function(element, percent) {
+    this.element = $(element);
+    if (!this.element) throw(Effect._elementDoesNotExistError);
+    var options = Object.extend({
+      scaleX: true,
+      scaleY: true,
+      scaleContent: true,
+      scaleFromCenter: false,
+      scaleMode: 'box',        // 'box' or 'contents' or { } with provided values
+      scaleFrom: 100.0,
+      scaleTo:   percent
+    }, arguments[2] || { });
+    this.start(options);
+  },
+  setup: function() {
+    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
+    this.elementPositioning = this.element.getStyle('position');
+
+    this.originalStyle = { };
+    ['top','left','width','height','fontSize'].each( function(k) {
+      this.originalStyle[k] = this.element.style[k];
+    }.bind(this));
+
+    this.originalTop  = this.element.offsetTop;
+    this.originalLeft = this.element.offsetLeft;
+
+    var fontSize = this.element.getStyle('font-size') || '100%';
+    ['em','px','%','pt'].each( function(fontSizeType) {
+      if (fontSize.indexOf(fontSizeType)>0) {
+        this.fontSize     = parseFloat(fontSize);
+        this.fontSizeType = fontSizeType;
+      }
+    }.bind(this));
+
+    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
+
+    this.dims = null;
+    if (this.options.scaleMode=='box')
+      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
+    if (/^content/.test(this.options.scaleMode))
+      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
+    if (!this.dims)
+      this.dims = [this.options.scaleMode.originalHeight,
+                   this.options.scaleMode.originalWidth];
+  },
+  update: function(position) {
+    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
+    if (this.options.scaleContent && this.fontSize)
+      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
+    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
+  },
+  finish: function(position) {
+    if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
+  },
+  setDimensions: function(height, width) {
+    var d = { };
+    if (this.options.scaleX) d.width = width.round() + 'px';
+    if (this.options.scaleY) d.height = height.round() + 'px';
+    if (this.options.scaleFromCenter) {
+      var topd  = (height - this.dims[0])/2;
+      var leftd = (width  - this.dims[1])/2;
+      if (this.elementPositioning == 'absolute') {
+        if (this.options.scaleY) d.top = this.originalTop-topd + 'px';
+        if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
+      } else {
+        if (this.options.scaleY) d.top = -topd + 'px';
+        if (this.options.scaleX) d.left = -leftd + 'px';
+      }
+    }
+    this.element.setStyle(d);
+  }
+});
+
+Effect.Highlight = Class.create(Effect.Base, {
+  initialize: function(element) {
+    this.element = $(element);
+    if (!this.element) throw(Effect._elementDoesNotExistError);
+    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { });
+    this.start(options);
+  },
+  setup: function() {
+    // Prevent executing on elements not in the layout flow
+    if (this.element.getStyle('display')=='none') { this.cancel(); return; }
+    // Disable background image during the effect
+    this.oldStyle = { };
+    if (!this.options.keepBackgroundImage) {
+      this.oldStyle.backgroundImage = this.element.getStyle('background-image');
+      this.element.setStyle({backgroundImage: 'none'});
+    }
+    if (!this.options.endcolor)
+      this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
+    if (!this.options.restorecolor)
+      this.options.restorecolor = this.element.getStyle('background-color');
+    // init color calculations
+    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
+    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
+  },
+  update: function(position) {
+    this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
+      return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) });
+  },
+  finish: function() {
+    this.element.setStyle(Object.extend(this.oldStyle, {
+      backgroundColor: this.options.restorecolor
+    }));
+  }
+});
+
+Effect.ScrollTo = function(element) {
+  var options = arguments[1] || { },
+  scrollOffsets = document.viewport.getScrollOffsets(),
+  elementOffsets = $(element).cumulativeOffset();
+
+  if (options.offset) elementOffsets[1] += options.offset;
+
+  return new Effect.Tween(null,
+    scrollOffsets.top,
+    elementOffsets[1],
+    options,
+    function(p){ scrollTo(scrollOffsets.left, p.round()); }
+  );
+};
+
+/* ------------- combination effects ------------- */
+
+Effect.Fade = function(element) {
+  element = $(element);
+  var oldOpacity = element.getInlineOpacity();
+  var options = Object.extend({
+    from: element.getOpacity() || 1.0,
+    to:   0.0,
+    afterFinishInternal: function(effect) {
+      if (effect.options.to!=0) return;
+      effect.element.hide().setStyle({opacity: oldOpacity});
+    }
+  }, arguments[1] || { });
+  return new Effect.Opacity(element,options);
+};
+
+Effect.Appear = function(element) {
+  element = $(element);
+  var options = Object.extend({
+  from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
+  to:   1.0,
+  // force Safari to render floated elements properly
+  afterFinishInternal: function(effect) {
+    effect.element.forceRerendering();
+  },
+  beforeSetup: function(effect) {
+    effect.element.setOpacity(effect.options.from).show();
+  }}, arguments[1] || { });
+  return new Effect.Opacity(element,options);
+};
+
+Effect.Puff = function(element) {
+  element = $(element);
+  var oldStyle = {
+    opacity: element.getInlineOpacity(),
+    position: element.getStyle('position'),
+    top:  element.style.top,
+    left: element.style.left,
+    width: element.style.width,
+    height: element.style.height
+  };
+  return new Effect.Parallel(
+   [ new Effect.Scale(element, 200,
+      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
+     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
+     Object.extend({ duration: 1.0,
+      beforeSetupInternal: function(effect) {
+        Position.absolutize(effect.effects[0].element);
+      },
+      afterFinishInternal: function(effect) {
+         effect.effects[0].element.hide().setStyle(oldStyle); }
+     }, arguments[1] || { })
+   );
+};
+
+Effect.BlindUp = function(element) {
+  element = $(element);
+  element.makeClipping();
+  return new Effect.Scale(element, 0,
+    Object.extend({ scaleContent: false,
+      scaleX: false,
+      restoreAfterFinish: true,
+      afterFinishInternal: function(effect) {
+        effect.element.hide().undoClipping();
+      }
+    }, arguments[1] || { })
+  );
+};
+
+Effect.BlindDown = function(element) {
+  element = $(element);
+  var elementDimensions = element.getDimensions();
+  return new Effect.Scale(element, 100, Object.extend({
+    scaleContent: false,
+    scaleX: false,
+    scaleFrom: 0,
+    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+    restoreAfterFinish: true,
+    afterSetup: function(effect) {
+      effect.element.makeClipping().setStyle({height: '0px'}).show();
+    },
+    afterFinishInternal: function(effect) {
+      effect.element.undoClipping();
+    }
+  }, arguments[1] || { }));
+};
+
+Effect.SwitchOff = function(element) {
+  element = $(element);
+  var oldOpacity = element.getInlineOpacity();
+  return new Effect.Appear(element, Object.extend({
+    duration: 0.4,
+    from: 0,
+    transition: Effect.Transitions.flicker,
+    afterFinishInternal: function(effect) {
+      new Effect.Scale(effect.element, 1, {
+        duration: 0.3, scaleFromCenter: true,
+        scaleX: false, scaleContent: false, restoreAfterFinish: true,
+        beforeSetup: function(effect) {
+          effect.element.makePositioned().makeClipping();
+        },
+        afterFinishInternal: function(effect) {
+          effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
+        }
+      });
+    }
+  }, arguments[1] || { }));
+};
+
+Effect.DropOut = function(element) {
+  element = $(element);
+  var oldStyle = {
+    top: element.getStyle('top'),
+    left: element.getStyle('left'),
+    opacity: element.getInlineOpacity() };
+  return new Effect.Parallel(
+    [ new Effect.Move(element, {x: 0, y: 100, sync: true }),
+      new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
+    Object.extend(
+      { duration: 0.5,
+        beforeSetup: function(effect) {
+          effect.effects[0].element.makePositioned();
+        },
+        afterFinishInternal: function(effect) {
+          effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
+        }
+      }, arguments[1] || { }));
+};
+
+Effect.Shake = function(element) {
+  element = $(element);
+  var options = Object.extend({
+    distance: 20,
+    duration: 0.5
+  }, arguments[1] || {});
+  var distance = parseFloat(options.distance);
+  var split = parseFloat(options.duration) / 10.0;
+  var oldStyle = {
+    top: element.getStyle('top'),
+    left: element.getStyle('left') };
+    return new Effect.Move(element,
+      { x:  distance, y: 0, duration: split, afterFinishInternal: function(effect) {
+    new Effect.Move(effect.element,
+      { x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
+    new Effect.Move(effect.element,
+      { x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
+    new Effect.Move(effect.element,
+      { x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
+    new Effect.Move(effect.element,
+      { x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
+    new Effect.Move(effect.element,
+      { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) {
+        effect.element.undoPositioned().setStyle(oldStyle);
+  }}); }}); }}); }}); }}); }});
+};
+
+Effect.SlideDown = function(element) {
+  element = $(element).cleanWhitespace();
+  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
+  var oldInnerBottom = element.down().getStyle('bottom');
+  var elementDimensions = element.getDimensions();
+  return new Effect.Scale(element, 100, Object.extend({
+    scaleContent: false,
+    scaleX: false,
+    scaleFrom: window.opera ? 0 : 1,
+    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+    restoreAfterFinish: true,
+    afterSetup: function(effect) {
+      effect.element.makePositioned();
+      effect.element.down().makePositioned();
+      if (window.opera) effect.element.setStyle({top: ''});
+      effect.element.makeClipping().setStyle({height: '0px'}).show();
+    },
+    afterUpdateInternal: function(effect) {
+      effect.element.down().setStyle({bottom:
+        (effect.dims[0] - effect.element.clientHeight) + 'px' });
+    },
+    afterFinishInternal: function(effect) {
+      effect.element.undoClipping().undoPositioned();
+      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
+    }, arguments[1] || { })
+  );
+};
+
+Effect.SlideUp = function(element) {
+  element = $(element).cleanWhitespace();
+  var oldInnerBottom = element.down().getStyle('bottom');
+  var elementDimensions = element.getDimensions();
+  return new Effect.Scale(element, window.opera ? 0 : 1,
+   Object.extend({ scaleContent: false,
+    scaleX: false,
+    scaleMode: 'box',
+    scaleFrom: 100,
+    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+    restoreAfterFinish: true,
+    afterSetup: function(effect) {
+      effect.element.makePositioned();
+      effect.element.down().makePositioned();
+      if (window.opera) effect.element.setStyle({top: ''});
+      effect.element.makeClipping().show();
+    },
+    afterUpdateInternal: function(effect) {
+      effect.element.down().setStyle({bottom:
+        (effect.dims[0] - effect.element.clientHeight) + 'px' });
+    },
+    afterFinishInternal: function(effect) {
+      effect.element.hide().undoClipping().undoPositioned();
+      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom});
+    }
+   }, arguments[1] || { })
+  );
+};
+
+// Bug in opera makes the TD containing this element expand for a instance after finish
+Effect.Squish = function(element) {
+  return new Effect.Scale(element, window.opera ? 1 : 0, {
+    restoreAfterFinish: true,
+    beforeSetup: function(effect) {
+      effect.element.makeClipping();
+    },
+    afterFinishInternal: function(effect) {
+      effect.element.hide().undoClipping();
+    }
+  });
+};
+
+Effect.Grow = function(element) {
+  element = $(element);
+  var options = Object.extend({
+    direction: 'center',
+    moveTransition: Effect.Transitions.sinoidal,
+    scaleTransition: Effect.Transitions.sinoidal,
+    opacityTransition: Effect.Transitions.full
+  }, arguments[1] || { });
+  var oldStyle = {
+    top: element.style.top,
+    left: element.style.left,
+    height: element.style.height,
+    width: element.style.width,
+    opacity: element.getInlineOpacity() };
+
+  var dims = element.getDimensions();
+  var initialMoveX, initialMoveY;
+  var moveX, moveY;
+
+  switch (options.direction) {
+    case 'top-left':
+      initialMoveX = initialMoveY = moveX = moveY = 0;
+      break;
+    case 'top-right':
+      initialMoveX = dims.width;
+      initialMoveY = moveY = 0;
+      moveX = -dims.width;
+      break;
+    case 'bottom-left':
+      initialMoveX = moveX = 0;
+      initialMoveY = dims.height;
+      moveY = -dims.height;
+      break;
+    case 'bottom-right':
+      initialMoveX = dims.width;
+      initialMoveY = dims.height;
+      moveX = -dims.width;
+      moveY = -dims.height;
+      break;
+    case 'center':
+      initialMoveX = dims.width / 2;
+      initialMoveY = dims.height / 2;
+      moveX = -dims.width / 2;
+      moveY = -dims.height / 2;
+      break;
+  }
+
+  return new Effect.Move(element, {
+    x: initialMoveX,
+    y: initialMoveY,
+    duration: 0.01,
+    beforeSetup: function(effect) {
+      effect.element.hide().makeClipping().makePositioned();
+    },
+    afterFinishInternal: function(effect) {
+      new Effect.Parallel(
+        [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
+          new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
+          new Effect.Scale(effect.element, 100, {
+            scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
+            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
+        ], Object.extend({
+             beforeSetup: function(effect) {
+               effect.effects[0].element.setStyle({height: '0px'}).show();
+             },
+             afterFinishInternal: function(effect) {
+               effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
+             }
+           }, options)
+      );
+    }
+  });
+};
+
+Effect.Shrink = function(element) {
+  element = $(element);
+  var options = Object.extend({
+    direction: 'center',
+    moveTransition: Effect.Transitions.sinoidal,
+    scaleTransition: Effect.Transitions.sinoidal,
+    opacityTransition: Effect.Transitions.none
+  }, arguments[1] || { });
+  var oldStyle = {
+    top: element.style.top,
+    left: element.style.left,
+    height: element.style.height,
+    width: element.style.width,
+    opacity: element.getInlineOpacity() };
+
+  var dims = element.getDimensions();
+  var moveX, moveY;
+
+  switch (options.direction) {
+    case 'top-left':
+      moveX = moveY = 0;
+      break;
+    case 'top-right':
+      moveX = dims.width;
+      moveY = 0;
+      break;
+    case 'bottom-left':
+      moveX = 0;
+      moveY = dims.height;
+      break;
+    case 'bottom-right':
+      moveX = dims.width;
+      moveY = dims.height;
+      break;
+    case 'center':
+      moveX = dims.width / 2;
+      moveY = dims.height / 2;
+      break;
+  }
+
+  return new Effect.Parallel(
+    [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
+      new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
+      new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
+    ], Object.extend({
+         beforeStartInternal: function(effect) {
+           effect.effects[0].element.makePositioned().makeClipping();
+         },
+         afterFinishInternal: function(effect) {
+           effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
+       }, options)
+  );
+};
+
+Effect.Pulsate = function(element) {
+  element = $(element);
+  var options    = arguments[1] || { },
+    oldOpacity = element.getInlineOpacity(),
+    transition = options.transition || Effect.Transitions.linear,
+    reverser   = function(pos){
+      return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5);
+    };
+
+  return new Effect.Opacity(element,
+    Object.extend(Object.extend({  duration: 2.0, from: 0,
+      afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
+    }, options), {transition: reverser}));
+};
+
+Effect.Fold = function(element) {
+  element = $(element);
+  var oldStyle = {
+    top: element.style.top,
+    left: element.style.left,
+    width: element.style.width,
+    height: element.style.height };
+  element.makeClipping();
+  return new Effect.Scale(element, 5, Object.extend({
+    scaleContent: false,
+    scaleX: false,
+    afterFinishInternal: function(effect) {
+    new Effect.Scale(element, 1, {
+      scaleContent: false,
+      scaleY: false,
+      afterFinishInternal: function(effect) {
+        effect.element.hide().undoClipping().setStyle(oldStyle);
+      } });
+  }}, arguments[1] || { }));
+};
+
+Effect.Morph = Class.create(Effect.Base, {
+  initialize: function(element) {
+    this.element = $(element);
+    if (!this.element) throw(Effect._elementDoesNotExistError);
+    var options = Object.extend({
+      style: { }
+    }, arguments[1] || { });
+
+    if (!Object.isString(options.style)) this.style = $H(options.style);
+    else {
+      if (options.style.include(':'))
+        this.style = options.style.parseStyle();
+      else {
+        this.element.addClassName(options.style);
+        this.style = $H(this.element.getStyles());
+        this.element.removeClassName(options.style);
+        var css = this.element.getStyles();
+        this.style = this.style.reject(function(style) {
+          return style.value == css[style.key];
+        });
+        options.afterFinishInternal = function(effect) {
+          effect.element.addClassName(effect.options.style);
+          effect.transforms.each(function(transform) {
+            effect.element.style[transform.style] = '';
+          });
+        };
+      }
+    }
+    this.start(options);
+  },
+
+  setup: function(){
+    function parseColor(color){
+      if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
+      color = color.parseColor();
+      return $R(0,2).map(function(i){
+        return parseInt( color.slice(i*2+1,i*2+3), 16 );
+      });
+    }
+    this.transforms = this.style.map(function(pair){
+      var property = pair[0], value = pair[1], unit = null;
+
+      if (value.parseColor('#zzzzzz') != '#zzzzzz') {
+        value = value.parseColor();
+        unit  = 'color';
+      } else if (property == 'opacity') {
+        value = parseFloat(value);
+        if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
+          this.element.setStyle({zoom: 1});
+      } else if (Element.CSS_LENGTH.test(value)) {
+          var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
+          value = parseFloat(components[1]);
+          unit = (components.length == 3) ? components[2] : null;
+      }
+
+      var originalValue = this.element.getStyle(property);
+      return {
+        style: property.camelize(),
+        originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0),
+        targetValue: unit=='color' ? parseColor(value) : value,
+        unit: unit
+      };
+    }.bind(this)).reject(function(transform){
+      return (
+        (transform.originalValue == transform.targetValue) ||
+        (
+          transform.unit != 'color' &&
+          (isNaN(transform.originalValue) || isNaN(transform.targetValue))
+        )
+      );
+    });
+  },
+  update: function(position) {
+    var style = { }, transform, i = this.transforms.length;
+    while(i--)
+      style[(transform = this.transforms[i]).style] =
+        transform.unit=='color' ? '#'+
+          (Math.round(transform.originalValue[0]+
+            (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() +
+          (Math.round(transform.originalValue[1]+
+            (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
+          (Math.round(transform.originalValue[2]+
+            (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
+        (transform.originalValue +
+          (transform.targetValue - transform.originalValue) * position).toFixed(3) +
+            (transform.unit === null ? '' : transform.unit);
+    this.element.setStyle(style, true);
+  }
+});
+
+Effect.Transform = Class.create({
+  initialize: function(tracks){
+    this.tracks  = [];
+    this.options = arguments[1] || { };
+    this.addTracks(tracks);
+  },
+  addTracks: function(tracks){
+    tracks.each(function(track){
+      track = $H(track);
+      var data = track.values().first();
+      this.tracks.push($H({
+        ids:     track.keys().first(),
+        effect:  Effect.Morph,
+        options: { style: data }
+      }));
+    }.bind(this));
+    return this;
+  },
+  play: function(){
+    return new Effect.Parallel(
+      this.tracks.map(function(track){
+        var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options');
+        var elements = [$(ids) || $$(ids)].flatten();
+        return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) });
+      }).flatten(),
+      this.options
+    );
+  }
+});
+
+Element.CSS_PROPERTIES = $w(
+  'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' +
+  'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' +
+  'borderRightColor borderRightStyle borderRightWidth borderSpacing ' +
+  'borderTopColor borderTopStyle borderTopWidth bottom clip color ' +
+  'fontSize fontWeight height left letterSpacing lineHeight ' +
+  'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+
+  'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' +
+  'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' +
+  'right textIndent top width wordSpacing zIndex');
+
+Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
+
+String.__parseStyleElement = document.createElement('div');
+String.prototype.parseStyle = function(){
+  var style, styleRules = $H();
+  if (Prototype.Browser.WebKit)
+    style = new Element('div',{style:this}).style;
+  else {
+    String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>';
+    style = String.__parseStyleElement.childNodes[0].style;
+  }
+
+  Element.CSS_PROPERTIES.each(function(property){
+    if (style[property]) styleRules.set(property, style[property]);
+  });
+
+  if (Prototype.Browser.IE && this.include('opacity'))
+    styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);
+
+  return styleRules;
+};
+
+if (document.defaultView && document.defaultView.getComputedStyle) {
+  Element.getStyles = function(element) {
+    var css = document.defaultView.getComputedStyle($(element), null);
+    return Element.CSS_PROPERTIES.inject({ }, function(styles, property) {
+      styles[property] = css[property];
+      return styles;
+    });
+  };
+} else {
+  Element.getStyles = function(element) {
+    element = $(element);
+    var css = element.currentStyle, styles;
+    styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) {
+      results[property] = css[property];
+      return results;
+    });
+    if (!styles.opacity) styles.opacity = element.getOpacity();
+    return styles;
+  };
+}
+
+Effect.Methods = {
+  morph: function(element, style) {
+    element = $(element);
+    new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { }));
+    return element;
+  },
+  visualEffect: function(element, effect, options) {
+    element = $(element);
+    var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1);
+    new Effect[klass](element, options);
+    return element;
+  },
+  highlight: function(element, options) {
+    element = $(element);
+    new Effect.Highlight(element, options);
+    return element;
+  }
+};
+
+$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+
+  'pulsate shake puff squish switchOff dropOut').each(
+  function(effect) {
+    Effect.Methods[effect] = function(element, options){
+      element = $(element);
+      Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options);
+      return element;
+    };
+  }
+);
+
+$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(
+  function(f) { Effect.Methods[f] = Element[f]; }
+);
+
+Element.addMethods(Effect.Methods);
Index: /tags/3.1/wp-includes/js/scriptaculous/scriptaculous.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/scriptaculous.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/scriptaculous.js	(revision 17487)
@@ -0,0 +1,68 @@
+// script.aculo.us scriptaculous.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+var Scriptaculous = {
+  Version: '1.8.3',
+  require: function(libraryName) {
+    try{
+      // inserting via DOM fails in Safari 2.0, so brute force approach
+      document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
+    } catch(e) {
+      // for xhtml+xml served content, fall back to DOM methods
+      var script = document.createElement('script');
+      script.type = 'text/javascript';
+      script.src = libraryName;
+      document.getElementsByTagName('head')[0].appendChild(script);
+    }
+  },
+  REQUIRED_PROTOTYPE: '1.6.0.3',
+  load: function() {
+    function convertVersionString(versionString) {
+      var v = versionString.replace(/_.*|\./g, '');
+      v = parseInt(v + '0'.times(4-v.length));
+      return versionString.indexOf('_') > -1 ? v-1 : v;
+    }
+
+    if((typeof Prototype=='undefined') ||
+       (typeof Element == 'undefined') ||
+       (typeof Element.Methods=='undefined') ||
+       (convertVersionString(Prototype.Version) <
+        convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
+       throw("script.aculo.us requires the Prototype JavaScript framework >= " +
+        Scriptaculous.REQUIRED_PROTOTYPE);
+
+    var js = /scriptaculous\.js(\?.*)?$/;
+    $$('head script[src]').findAll(function(s) {
+      return s.src.match(js);
+    }).each(function(s) {
+      var path = s.src.replace(js, ''),
+      includes = s.src.match(/\?.*load=([a-z,]*)/);
+      (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
+       function(include) { Scriptaculous.require(path+include+'.js') });
+    });
+  }
+};
+
+Scriptaculous.load();
Index: /tags/3.1/wp-includes/js/scriptaculous/slider.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/slider.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/slider.js	(revision 17487)
@@ -0,0 +1,275 @@
+// script.aculo.us slider.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Marty Haught, Thomas Fuchs
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+if (!Control) var Control = { };
+
+// options:
+//  axis: 'vertical', or 'horizontal' (default)
+//
+// callbacks:
+//  onChange(value)
+//  onSlide(value)
+Control.Slider = Class.create({
+  initialize: function(handle, track, options) {
+    var slider = this;
+
+    if (Object.isArray(handle)) {
+      this.handles = handle.collect( function(e) { return $(e) });
+    } else {
+      this.handles = [$(handle)];
+    }
+
+    this.track   = $(track);
+    this.options = options || { };
+
+    this.axis      = this.options.axis || 'horizontal';
+    this.increment = this.options.increment || 1;
+    this.step      = parseInt(this.options.step || '1');
+    this.range     = this.options.range || $R(0,1);
+
+    this.value     = 0; // assure backwards compat
+    this.values    = this.handles.map( function() { return 0 });
+    this.spans     = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
+    this.options.startSpan = $(this.options.startSpan || null);
+    this.options.endSpan   = $(this.options.endSpan || null);
+
+    this.restricted = this.options.restricted || false;
+
+    this.maximum   = this.options.maximum || this.range.end;
+    this.minimum   = this.options.minimum || this.range.start;
+
+    // Will be used to align the handle onto the track, if necessary
+    this.alignX = parseInt(this.options.alignX || '0');
+    this.alignY = parseInt(this.options.alignY || '0');
+
+    this.trackLength = this.maximumOffset() - this.minimumOffset();
+
+    this.handleLength = this.isVertical() ?
+      (this.handles[0].offsetHeight != 0 ?
+        this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
+      (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
+        this.handles[0].style.width.replace(/px$/,""));
+
+    this.active   = false;
+    this.dragging = false;
+    this.disabled = false;
+
+    if (this.options.disabled) this.setDisabled();
+
+    // Allowed values array
+    this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
+    if (this.allowedValues) {
+      this.minimum = this.allowedValues.min();
+      this.maximum = this.allowedValues.max();
+    }
+
+    this.eventMouseDown = this.startDrag.bindAsEventListener(this);
+    this.eventMouseUp   = this.endDrag.bindAsEventListener(this);
+    this.eventMouseMove = this.update.bindAsEventListener(this);
+
+    // Initialize handles in reverse (make sure first handle is active)
+    this.handles.each( function(h,i) {
+      i = slider.handles.length-1-i;
+      slider.setValue(parseFloat(
+        (Object.isArray(slider.options.sliderValue) ?
+          slider.options.sliderValue[i] : slider.options.sliderValue) ||
+         slider.range.start), i);
+      h.makePositioned().observe("mousedown", slider.eventMouseDown);
+    });
+
+    this.track.observe("mousedown", this.eventMouseDown);
+    document.observe("mouseup", this.eventMouseUp);
+    document.observe("mousemove", this.eventMouseMove);
+
+    this.initialized = true;
+  },
+  dispose: function() {
+    var slider = this;
+    Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
+    Event.stopObserving(document, "mouseup", this.eventMouseUp);
+    Event.stopObserving(document, "mousemove", this.eventMouseMove);
+    this.handles.each( function(h) {
+      Event.stopObserving(h, "mousedown", slider.eventMouseDown);
+    });
+  },
+  setDisabled: function(){
+    this.disabled = true;
+  },
+  setEnabled: function(){
+    this.disabled = false;
+  },
+  getNearestValue: function(value){
+    if (this.allowedValues){
+      if (value >= this.allowedValues.max()) return(this.allowedValues.max());
+      if (value <= this.allowedValues.min()) return(this.allowedValues.min());
+
+      var offset = Math.abs(this.allowedValues[0] - value);
+      var newValue = this.allowedValues[0];
+      this.allowedValues.each( function(v) {
+        var currentOffset = Math.abs(v - value);
+        if (currentOffset <= offset){
+          newValue = v;
+          offset = currentOffset;
+        }
+      });
+      return newValue;
+    }
+    if (value > this.range.end) return this.range.end;
+    if (value < this.range.start) return this.range.start;
+    return value;
+  },
+  setValue: function(sliderValue, handleIdx){
+    if (!this.active) {
+      this.activeHandleIdx = handleIdx || 0;
+      this.activeHandle    = this.handles[this.activeHandleIdx];
+      this.updateStyles();
+    }
+    handleIdx = handleIdx || this.activeHandleIdx || 0;
+    if (this.initialized && this.restricted) {
+      if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
+        sliderValue = this.values[handleIdx-1];
+      if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
+        sliderValue = this.values[handleIdx+1];
+    }
+    sliderValue = this.getNearestValue(sliderValue);
+    this.values[handleIdx] = sliderValue;
+    this.value = this.values[0]; // assure backwards compat
+
+    this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+      this.translateToPx(sliderValue);
+
+    this.drawSpans();
+    if (!this.dragging || !this.event) this.updateFinished();
+  },
+  setValueBy: function(delta, handleIdx) {
+    this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
+      handleIdx || this.activeHandleIdx || 0);
+  },
+  translateToPx: function(value) {
+    return Math.round(
+      ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
+      (value - this.range.start)) + "px";
+  },
+  translateToValue: function(offset) {
+    return ((offset/(this.trackLength-this.handleLength) *
+      (this.range.end-this.range.start)) + this.range.start);
+  },
+  getRange: function(range) {
+    var v = this.values.sortBy(Prototype.K);
+    range = range || 0;
+    return $R(v[range],v[range+1]);
+  },
+  minimumOffset: function(){
+    return(this.isVertical() ? this.alignY : this.alignX);
+  },
+  maximumOffset: function(){
+    return(this.isVertical() ?
+      (this.track.offsetHeight != 0 ? this.track.offsetHeight :
+        this.track.style.height.replace(/px$/,"")) - this.alignY :
+      (this.track.offsetWidth != 0 ? this.track.offsetWidth :
+        this.track.style.width.replace(/px$/,"")) - this.alignX);
+  },
+  isVertical:  function(){
+    return (this.axis == 'vertical');
+  },
+  drawSpans: function() {
+    var slider = this;
+    if (this.spans)
+      $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
+    if (this.options.startSpan)
+      this.setSpan(this.options.startSpan,
+        $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
+    if (this.options.endSpan)
+      this.setSpan(this.options.endSpan,
+        $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
+  },
+  setSpan: function(span, range) {
+    if (this.isVertical()) {
+      span.style.top = this.translateToPx(range.start);
+      span.style.height = this.translateToPx(range.end - range.start + this.range.start);
+    } else {
+      span.style.left = this.translateToPx(range.start);
+      span.style.width = this.translateToPx(range.end - range.start + this.range.start);
+    }
+  },
+  updateStyles: function() {
+    this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
+    Element.addClassName(this.activeHandle, 'selected');
+  },
+  startDrag: function(event) {
+    if (Event.isLeftClick(event)) {
+      if (!this.disabled){
+        this.active = true;
+
+        var handle = Event.element(event);
+        var pointer  = [Event.pointerX(event), Event.pointerY(event)];
+        var track = handle;
+        if (track==this.track) {
+          var offsets  = this.track.cumulativeOffset();
+          this.event = event;
+          this.setValue(this.translateToValue(
+           (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
+          ));
+          var offsets  = this.activeHandle.cumulativeOffset();
+          this.offsetX = (pointer[0] - offsets[0]);
+          this.offsetY = (pointer[1] - offsets[1]);
+        } else {
+          // find the handle (prevents issues with Safari)
+          while((this.handles.indexOf(handle) == -1) && handle.parentNode)
+            handle = handle.parentNode;
+
+          if (this.handles.indexOf(handle)!=-1) {
+            this.activeHandle    = handle;
+            this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+            this.updateStyles();
+
+            var offsets  = this.activeHandle.cumulativeOffset();
+            this.offsetX = (pointer[0] - offsets[0]);
+            this.offsetY = (pointer[1] - offsets[1]);
+          }
+        }
+      }
+      Event.stop(event);
+    }
+  },
+  update: function(event) {
+   if (this.active) {
+      if (!this.dragging) this.dragging = true;
+      this.draw(event);
+      if (Prototype.Browser.WebKit) window.scrollBy(0,0);
+      Event.stop(event);
+   }
+  },
+  draw: function(event) {
+    var pointer = [Event.pointerX(event), Event.pointerY(event)];
+    var offsets = this.track.cumulativeOffset();
+    pointer[0] -= this.offsetX + offsets[0];
+    pointer[1] -= this.offsetY + offsets[1];
+    this.event = event;
+    this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
+    if (this.initialized && this.options.onSlide)
+      this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
+  },
+  endDrag: function(event) {
+    if (this.active && this.dragging) {
+      this.finishDrag(event, true);
+      Event.stop(event);
+    }
+    this.active = false;
+    this.dragging = false;
+  },
+  finishDrag: function(event, success) {
+    this.active = false;
+    this.dragging = false;
+    this.updateFinished();
+  },
+  updateFinished: function() {
+    if (this.initialized && this.options.onChange)
+      this.options.onChange(this.values.length>1 ? this.values : this.value, this);
+    this.event = null;
+  }
+});
Index: /tags/3.1/wp-includes/js/scriptaculous/sound.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/sound.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/sound.js	(revision 17487)
@@ -0,0 +1,59 @@
+// script.aculo.us sound.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Based on code created by Jules Gravinese (http://www.webveteran.com/)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+Sound = {
+  tracks: {},
+  _enabled: true,
+  template:
+    new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
+  enable: function(){
+    Sound._enabled = true;
+  },
+  disable: function(){
+    Sound._enabled = false;
+  },
+  play: function(url){
+    if(!Sound._enabled) return;
+    var options = Object.extend({
+      track: 'global', url: url, replace: false
+    }, arguments[1] || {});
+
+    if(options.replace && this.tracks[options.track]) {
+      $R(0, this.tracks[options.track].id).each(function(id){
+        var sound = $('sound_'+options.track+'_'+id);
+        sound.Stop && sound.Stop();
+        sound.remove();
+      });
+      this.tracks[options.track] = null;
+    }
+
+    if(!this.tracks[options.track])
+      this.tracks[options.track] = { id: 0 };
+    else
+      this.tracks[options.track].id++;
+
+    options.id = this.tracks[options.track].id;
+    $$('body')[0].insert(
+      Prototype.Browser.IE ? new Element('bgsound',{
+        id: 'sound_'+options.track+'_'+options.id,
+        src: options.url, loop: 1, autostart: true
+      }) : Sound.template.evaluate(options));
+  }
+};
+
+if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
+  if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
+    Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>');
+  else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('Windows Media') != -1 }))
+    Sound.template = new Template('<object id="sound_#{track}_#{id}" type="application/x-mplayer2" data="#{url}"></object>');
+  else if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('RealPlayer') != -1 }))
+    Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>');
+  else
+    Sound.play = function(){};
+} 
Index: /tags/3.1/wp-includes/js/scriptaculous/unittest.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/unittest.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/unittest.js	(revision 17487)
@@ -0,0 +1,568 @@
+// script.aculo.us unittest.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//           (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
+//           (c) 2005-2009 Michael Schuerig (http://www.schuerig.de/michael/)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// experimental, Firefox-only
+Event.simulateMouse = function(element, eventName) {
+  var options = Object.extend({
+    pointerX: 0,
+    pointerY: 0,
+    buttons:  0,
+    ctrlKey:  false,
+    altKey:   false,
+    shiftKey: false,
+    metaKey:  false
+  }, arguments[2] || {});
+  var oEvent = document.createEvent("MouseEvents");
+  oEvent.initMouseEvent(eventName, true, true, document.defaultView, 
+    options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY, 
+    options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, 0, $(element));
+  
+  if(this.mark) Element.remove(this.mark);
+  this.mark = document.createElement('div');
+  this.mark.appendChild(document.createTextNode(" "));
+  document.body.appendChild(this.mark);
+  this.mark.style.position = 'absolute';
+  this.mark.style.top = options.pointerY + "px";
+  this.mark.style.left = options.pointerX + "px";
+  this.mark.style.width = "5px";
+  this.mark.style.height = "5px;";
+  this.mark.style.borderTop = "1px solid red;";
+  this.mark.style.borderLeft = "1px solid red;";
+  
+  if(this.step)
+    alert('['+new Date().getTime().toString()+'] '+eventName+'/'+Test.Unit.inspect(options));
+  
+  $(element).dispatchEvent(oEvent);
+};
+
+// Note: Due to a fix in Firefox 1.0.5/6 that probably fixed "too much", this doesn't work in 1.0.6 or DP2.
+// You need to downgrade to 1.0.4 for now to get this working
+// See https://bugzilla.mozilla.org/show_bug.cgi?id=289940 for the fix that fixed too much
+Event.simulateKey = function(element, eventName) {
+  var options = Object.extend({
+    ctrlKey: false,
+    altKey: false,
+    shiftKey: false,
+    metaKey: false,
+    keyCode: 0,
+    charCode: 0
+  }, arguments[2] || {});
+
+  var oEvent = document.createEvent("KeyEvents");
+  oEvent.initKeyEvent(eventName, true, true, window, 
+    options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
+    options.keyCode, options.charCode );
+  $(element).dispatchEvent(oEvent);
+};
+
+Event.simulateKeys = function(element, command) {
+  for(var i=0; i<command.length; i++) {
+    Event.simulateKey(element,'keypress',{charCode:command.charCodeAt(i)});
+  }
+};
+
+var Test = {};
+Test.Unit = {};
+
+// security exception workaround
+Test.Unit.inspect = Object.inspect;
+
+Test.Unit.Logger = Class.create();
+Test.Unit.Logger.prototype = {
+  initialize: function(log) {
+    this.log = $(log);
+    if (this.log) {
+      this._createLogTable();
+    }
+  },
+  start: function(testName) {
+    if (!this.log) return;
+    this.testName = testName;
+    this.lastLogLine = document.createElement('tr');
+    this.statusCell = document.createElement('td');
+    this.nameCell = document.createElement('td');
+    this.nameCell.className = "nameCell";
+    this.nameCell.appendChild(document.createTextNode(testName));
+    this.messageCell = document.createElement('td');
+    this.lastLogLine.appendChild(this.statusCell);
+    this.lastLogLine.appendChild(this.nameCell);
+    this.lastLogLine.appendChild(this.messageCell);
+    this.loglines.appendChild(this.lastLogLine);
+  },
+  finish: function(status, summary) {
+    if (!this.log) return;
+    this.lastLogLine.className = status;
+    this.statusCell.innerHTML = status;
+    this.messageCell.innerHTML = this._toHTML(summary);
+    this.addLinksToResults();
+  },
+  message: function(message) {
+    if (!this.log) return;
+    this.messageCell.innerHTML = this._toHTML(message);
+  },
+  summary: function(summary) {
+    if (!this.log) return;
+    this.logsummary.innerHTML = this._toHTML(summary);
+  },
+  _createLogTable: function() {
+    this.log.innerHTML =
+    '<div id="logsummary"></div>' +
+    '<table id="logtable">' +
+    '<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' +
+    '<tbody id="loglines"></tbody>' +
+    '</table>';
+    this.logsummary = $('logsummary');
+    this.loglines = $('loglines');
+  },
+  _toHTML: function(txt) {
+    return txt.escapeHTML().replace(/\n/g,"<br/>");
+  },
+  addLinksToResults: function(){ 
+    $$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log
+      td.title = "Run only this test";
+      Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;});
+    });
+    $$("tr.passed .nameCell").each( function(td){ // todo: limit to children of this.log
+      td.title = "Run all tests";
+      Event.observe(td, 'click', function(){ window.location.search = "";});
+    });
+  }
+};
+
+Test.Unit.Runner = Class.create();
+Test.Unit.Runner.prototype = {
+  initialize: function(testcases) {
+    this.options = Object.extend({
+      testLog: 'testlog'
+    }, arguments[1] || {});
+    this.options.resultsURL = this.parseResultsURLQueryParameter();
+    this.options.tests      = this.parseTestsQueryParameter();
+    if (this.options.testLog) {
+      this.options.testLog = $(this.options.testLog) || null;
+    }
+    if(this.options.tests) {
+      this.tests = [];
+      for(var i = 0; i < this.options.tests.length; i++) {
+        if(/^test/.test(this.options.tests[i])) {
+          this.tests.push(new Test.Unit.Testcase(this.options.tests[i], testcases[this.options.tests[i]], testcases["setup"], testcases["teardown"]));
+        }
+      }
+    } else {
+      if (this.options.test) {
+        this.tests = [new Test.Unit.Testcase(this.options.test, testcases[this.options.test], testcases["setup"], testcases["teardown"])];
+      } else {
+        this.tests = [];
+        for(var testcase in testcases) {
+          if(/^test/.test(testcase)) {
+            this.tests.push(
+               new Test.Unit.Testcase(
+                 this.options.context ? ' -> ' + this.options.titles[testcase] : testcase, 
+                 testcases[testcase], testcases["setup"], testcases["teardown"]
+               ));
+          }
+        }
+      }
+    }
+    this.currentTest = 0;
+    this.logger = new Test.Unit.Logger(this.options.testLog);
+    setTimeout(this.runTests.bind(this), 1000);
+  },
+  parseResultsURLQueryParameter: function() {
+    return window.location.search.parseQuery()["resultsURL"];
+  },
+  parseTestsQueryParameter: function(){
+    if (window.location.search.parseQuery()["tests"]){
+        return window.location.search.parseQuery()["tests"].split(',');
+    };
+  },
+  // Returns:
+  //  "ERROR" if there was an error,
+  //  "FAILURE" if there was a failure, or
+  //  "SUCCESS" if there was neither
+  getResult: function() {
+    var hasFailure = false;
+    for(var i=0;i<this.tests.length;i++) {
+      if (this.tests[i].errors > 0) {
+        return "ERROR";
+      }
+      if (this.tests[i].failures > 0) {
+        hasFailure = true;
+      }
+    }
+    if (hasFailure) {
+      return "FAILURE";
+    } else {
+      return "SUCCESS";
+    }
+  },
+  postResults: function() {
+    if (this.options.resultsURL) {
+      new Ajax.Request(this.options.resultsURL, 
+        { method: 'get', parameters: 'result=' + this.getResult(), asynchronous: false });
+    }
+  },
+  runTests: function() {
+    var test = this.tests[this.currentTest];
+    if (!test) {
+      // finished!
+      this.postResults();
+      this.logger.summary(this.summary());
+      return;
+    }
+    if(!test.isWaiting) {
+      this.logger.start(test.name);
+    }
+    test.run();
+    if(test.isWaiting) {
+      this.logger.message("Waiting for " + test.timeToWait + "ms");
+      setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
+    } else {
+      this.logger.finish(test.status(), test.summary());
+      this.currentTest++;
+      // tail recursive, hopefully the browser will skip the stackframe
+      this.runTests();
+    }
+  },
+  summary: function() {
+    var assertions = 0;
+    var failures = 0;
+    var errors = 0;
+    var messages = [];
+    for(var i=0;i<this.tests.length;i++) {
+      assertions +=   this.tests[i].assertions;
+      failures   +=   this.tests[i].failures;
+      errors     +=   this.tests[i].errors;
+    }
+    return (
+      (this.options.context ? this.options.context + ': ': '') + 
+      this.tests.length + " tests, " + 
+      assertions + " assertions, " + 
+      failures   + " failures, " +
+      errors     + " errors");
+  }
+};
+
+Test.Unit.Assertions = Class.create();
+Test.Unit.Assertions.prototype = {
+  initialize: function() {
+    this.assertions = 0;
+    this.failures   = 0;
+    this.errors     = 0;
+    this.messages   = [];
+  },
+  summary: function() {
+    return (
+      this.assertions + " assertions, " + 
+      this.failures   + " failures, " +
+      this.errors     + " errors" + "\n" +
+      this.messages.join("\n"));
+  },
+  pass: function() {
+    this.assertions++;
+  },
+  fail: function(message) {
+    this.failures++;
+    this.messages.push("Failure: " + message);
+  },
+  info: function(message) {
+    this.messages.push("Info: " + message);
+  },
+  error: function(error) {
+    this.errors++;
+    this.messages.push(error.name + ": "+ error.message + "(" + Test.Unit.inspect(error) +")");
+  },
+  status: function() {
+    if (this.failures > 0) return 'failed';
+    if (this.errors > 0) return 'error';
+    return 'passed';
+  },
+  assert: function(expression) {
+    var message = arguments[1] || 'assert: got "' + Test.Unit.inspect(expression) + '"';
+    try { expression ? this.pass() : 
+      this.fail(message); }
+    catch(e) { this.error(e); }
+  },
+  assertEqual: function(expected, actual) {
+    var message = arguments[2] || "assertEqual";
+    try { (expected == actual) ? this.pass() :
+      this.fail(message + ': expected "' + Test.Unit.inspect(expected) + 
+        '", actual "' + Test.Unit.inspect(actual) + '"'); }
+    catch(e) { this.error(e); }
+  },
+  assertInspect: function(expected, actual) {
+    var message = arguments[2] || "assertInspect";
+    try { (expected == actual.inspect()) ? this.pass() :
+      this.fail(message + ': expected "' + Test.Unit.inspect(expected) + 
+        '", actual "' + Test.Unit.inspect(actual) + '"'); }
+    catch(e) { this.error(e); }
+  },
+  assertEnumEqual: function(expected, actual) {
+    var message = arguments[2] || "assertEnumEqual";
+    try { $A(expected).length == $A(actual).length && 
+      expected.zip(actual).all(function(pair) { return pair[0] == pair[1] }) ?
+        this.pass() : this.fail(message + ': expected ' + Test.Unit.inspect(expected) + 
+          ', actual ' + Test.Unit.inspect(actual)); }
+    catch(e) { this.error(e); }
+  },
+  assertNotEqual: function(expected, actual) {
+    var message = arguments[2] || "assertNotEqual";
+    try { (expected != actual) ? this.pass() : 
+      this.fail(message + ': got "' + Test.Unit.inspect(actual) + '"'); }
+    catch(e) { this.error(e); }
+  },
+  assertIdentical: function(expected, actual) { 
+    var message = arguments[2] || "assertIdentical"; 
+    try { (expected === actual) ? this.pass() : 
+      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +  
+        '", actual "' + Test.Unit.inspect(actual) + '"'); } 
+    catch(e) { this.error(e); } 
+  },
+  assertNotIdentical: function(expected, actual) { 
+    var message = arguments[2] || "assertNotIdentical"; 
+    try { !(expected === actual) ? this.pass() : 
+      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +  
+        '", actual "' + Test.Unit.inspect(actual) + '"'); } 
+    catch(e) { this.error(e); } 
+  },
+  assertNull: function(obj) {
+    var message = arguments[1] || 'assertNull';
+    try { (obj==null) ? this.pass() : 
+      this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); }
+    catch(e) { this.error(e); }
+  },
+  assertMatch: function(expected, actual) {
+    var message = arguments[2] || 'assertMatch';
+    var regex = new RegExp(expected);
+    try { (regex.exec(actual)) ? this.pass() :
+      this.fail(message + ' : regex: "' +  Test.Unit.inspect(expected) + ' did not match: ' + Test.Unit.inspect(actual) + '"'); }
+    catch(e) { this.error(e); }
+  },
+  assertHidden: function(element) {
+    var message = arguments[1] || 'assertHidden';
+    this.assertEqual("none", element.style.display, message);
+  },
+  assertNotNull: function(object) {
+    var message = arguments[1] || 'assertNotNull';
+    this.assert(object != null, message);
+  },
+  assertType: function(expected, actual) {
+    var message = arguments[2] || 'assertType';
+    try { 
+      (actual.constructor == expected) ? this.pass() : 
+      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +  
+        '", actual "' + (actual.constructor) + '"'); }
+    catch(e) { this.error(e); }
+  },
+  assertNotOfType: function(expected, actual) {
+    var message = arguments[2] || 'assertNotOfType';
+    try { 
+      (actual.constructor != expected) ? this.pass() : 
+      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +  
+        '", actual "' + (actual.constructor) + '"'); }
+    catch(e) { this.error(e); }
+  },
+  assertInstanceOf: function(expected, actual) {
+    var message = arguments[2] || 'assertInstanceOf';
+    try { 
+      (actual instanceof expected) ? this.pass() : 
+      this.fail(message + ": object was not an instance of the expected type"); }
+    catch(e) { this.error(e); } 
+  },
+  assertNotInstanceOf: function(expected, actual) {
+    var message = arguments[2] || 'assertNotInstanceOf';
+    try { 
+      !(actual instanceof expected) ? this.pass() : 
+      this.fail(message + ": object was an instance of the not expected type"); }
+    catch(e) { this.error(e); } 
+  },
+  assertRespondsTo: function(method, obj) {
+    var message = arguments[2] || 'assertRespondsTo';
+    try {
+      (obj[method] && typeof obj[method] == 'function') ? this.pass() : 
+      this.fail(message + ": object doesn't respond to [" + method + "]"); }
+    catch(e) { this.error(e); }
+  },
+  assertReturnsTrue: function(method, obj) {
+    var message = arguments[2] || 'assertReturnsTrue';
+    try {
+      var m = obj[method];
+      if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
+      m() ? this.pass() : 
+      this.fail(message + ": method returned false"); }
+    catch(e) { this.error(e); }
+  },
+  assertReturnsFalse: function(method, obj) {
+    var message = arguments[2] || 'assertReturnsFalse';
+    try {
+      var m = obj[method];
+      if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)];
+      !m() ? this.pass() : 
+      this.fail(message + ": method returned true"); }
+    catch(e) { this.error(e); }
+  },
+  assertRaise: function(exceptionName, method) {
+    var message = arguments[2] || 'assertRaise';
+    try { 
+      method();
+      this.fail(message + ": exception expected but none was raised"); }
+    catch(e) {
+      ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e); 
+    }
+  },
+  assertElementsMatch: function() {
+    var expressions = $A(arguments), elements = $A(expressions.shift());
+    if (elements.length != expressions.length) {
+      this.fail('assertElementsMatch: size mismatch: ' + elements.length + ' elements, ' + expressions.length + ' expressions');
+      return false;
+    }
+    elements.zip(expressions).all(function(pair, index) {
+      var element = $(pair.first()), expression = pair.last();
+      if (element.match(expression)) return true;
+      this.fail('assertElementsMatch: (in index ' + index + ') expected ' + expression.inspect() + ' but got ' + element.inspect());
+    }.bind(this)) && this.pass();
+  },
+  assertElementMatches: function(element, expression) {
+    this.assertElementsMatch([element], expression);
+  },
+  benchmark: function(operation, iterations) {
+    var startAt = new Date();
+    (iterations || 1).times(operation);
+    var timeTaken = ((new Date())-startAt);
+    this.info((arguments[2] || 'Operation') + ' finished ' + 
+       iterations + ' iterations in ' + (timeTaken/1000)+'s' );
+    return timeTaken;
+  },
+  _isVisible: function(element) {
+    element = $(element);
+    if(!element.parentNode) return true;
+    this.assertNotNull(element);
+    if(element.style && Element.getStyle(element, 'display') == 'none')
+      return false;
+    
+    return this._isVisible(element.parentNode);
+  },
+  assertNotVisible: function(element) {
+    this.assert(!this._isVisible(element), Test.Unit.inspect(element) + " was not hidden and didn't have a hidden parent either. " + ("" || arguments[1]));
+  },
+  assertVisible: function(element) {
+    this.assert(this._isVisible(element), Test.Unit.inspect(element) + " was not visible. " + ("" || arguments[1]));
+  },
+  benchmark: function(operation, iterations) {
+    var startAt = new Date();
+    (iterations || 1).times(operation);
+    var timeTaken = ((new Date())-startAt);
+    this.info((arguments[2] || 'Operation') + ' finished ' + 
+       iterations + ' iterations in ' + (timeTaken/1000)+'s' );
+    return timeTaken;
+  }
+};
+
+Test.Unit.Testcase = Class.create();
+Object.extend(Object.extend(Test.Unit.Testcase.prototype, Test.Unit.Assertions.prototype), {
+  initialize: function(name, test, setup, teardown) {
+    Test.Unit.Assertions.prototype.initialize.bind(this)();
+    this.name           = name;
+    
+    if(typeof test == 'string') {
+      test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,');
+      test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)');
+      this.test = function() {
+        eval('with(this){'+test+'}');
+      }
+    } else {
+      this.test = test || function() {};
+    }
+    
+    this.setup          = setup || function() {};
+    this.teardown       = teardown || function() {};
+    this.isWaiting      = false;
+    this.timeToWait     = 1000;
+  },
+  wait: function(time, nextPart) {
+    this.isWaiting = true;
+    this.test = nextPart;
+    this.timeToWait = time;
+  },
+  run: function() {
+    try {
+      try {
+        if (!this.isWaiting) this.setup.bind(this)();
+        this.isWaiting = false;
+        this.test.bind(this)();
+      } finally {
+        if(!this.isWaiting) {
+          this.teardown.bind(this)();
+        }
+      }
+    }
+    catch(e) { this.error(e); }
+  }
+});
+
+// *EXPERIMENTAL* BDD-style testing to please non-technical folk
+// This draws many ideas from RSpec http://rspec.rubyforge.org/
+
+Test.setupBDDExtensionMethods = function(){
+  var METHODMAP = {
+    shouldEqual:     'assertEqual',
+    shouldNotEqual:  'assertNotEqual',
+    shouldEqualEnum: 'assertEnumEqual',
+    shouldBeA:       'assertType',
+    shouldNotBeA:    'assertNotOfType',
+    shouldBeAn:      'assertType',
+    shouldNotBeAn:   'assertNotOfType',
+    shouldBeNull:    'assertNull',
+    shouldNotBeNull: 'assertNotNull',
+    
+    shouldBe:        'assertReturnsTrue',
+    shouldNotBe:     'assertReturnsFalse',
+    shouldRespondTo: 'assertRespondsTo'
+  };
+  var makeAssertion = function(assertion, args, object) { 
+   	this[assertion].apply(this,(args || []).concat([object]));
+  };
+  
+  Test.BDDMethods = {};   
+  $H(METHODMAP).each(function(pair) { 
+    Test.BDDMethods[pair.key] = function() { 
+       var args = $A(arguments); 
+       var scope = args.shift(); 
+       makeAssertion.apply(scope, [pair.value, args, this]); }; 
+  });
+  
+  [Array.prototype, String.prototype, Number.prototype, Boolean.prototype].each(
+    function(p){ Object.extend(p, Test.BDDMethods) }
+  );
+};
+
+Test.context = function(name, spec, log){
+  Test.setupBDDExtensionMethods();
+  
+  var compiledSpec = {};
+  var titles = {};
+  for(specName in spec) {
+    switch(specName){
+      case "setup":
+      case "teardown":
+        compiledSpec[specName] = spec[specName];
+        break;
+      default:
+        var testName = 'test'+specName.gsub(/\s+/,'-').camelize();
+        var body = spec[specName].toString().split('\n').slice(1);
+        if(/^\{/.test(body[0])) body = body.slice(1);
+        body.pop();
+        body = body.map(function(statement){ 
+          return statement.strip()
+        });
+        compiledSpec[testName] = body.join('\n');
+        titles[testName] = specName;
+    }
+  }
+  new Test.Unit.Runner(compiledSpec, { titles: titles, testLog: log || 'testlog', context: name });
+};
Index: /tags/3.1/wp-includes/js/scriptaculous/wp-scriptaculous.js
===================================================================
--- /tags/3.1/wp-includes/js/scriptaculous/wp-scriptaculous.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/scriptaculous/wp-scriptaculous.js	(revision 17487)
@@ -0,0 +1,73 @@
+// script.aculo.us scriptaculous.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
+
+// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+var Scriptaculous = {
+  Version: '1.8.3',
+  require: function(libraryName) {
+    try{
+      // inserting via DOM fails in Safari 2.0, so brute force approach
+      document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
+    } catch(e) {
+      // for xhtml+xml served content, fall back to DOM methods
+      var script = document.createElement('script');
+      script.type = 'text/javascript';
+      script.src = libraryName;
+      document.getElementsByTagName('head')[0].appendChild(script);
+    }
+  },
+  REQUIRED_PROTOTYPE: '1.6.0.3',
+  load: function() {
+    function convertVersionString(versionString) {
+      var v = versionString.replace(/_.*|\./g, '');
+      v = parseInt(v + '0'.times(4-v.length));
+      return versionString.indexOf('_') > -1 ? v-1 : v;
+    }
+
+    if((typeof Prototype=='undefined') ||
+       (typeof Element == 'undefined') ||
+       (typeof Element.Methods=='undefined') ||
+       (convertVersionString(Prototype.Version) <
+        convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
+       throw("script.aculo.us requires the Prototype JavaScript framework >= " +
+        Scriptaculous.REQUIRED_PROTOTYPE);
+
+    var js = /scriptaculous\.js(\?.*)?$/;
+    $$('head script[src]').findAll(function(s) {
+      return s.src.match(js);
+    }).each(function(s) {
+		var path = s.src.replace(js, ''),
+		includes = s.src.match(/\?.*load=([a-z,]*)/);
+
+		// Modified for WordPress to work with enqueue_script
+		if ( includes ) {
+			includes[1].split(',').each( function(include) {
+				Scriptaculous.require(path+include+'.js')
+			});
+		}
+    });
+  }
+};
+
+Scriptaculous.load();
Index: /tags/3.1/wp-includes/js/swfobject.js
===================================================================
--- /tags/3.1/wp-includes/js/swfobject.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfobject.js	(revision 17487)
@@ -0,0 +1,4 @@
+/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
+	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
+*/
+var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
Index: /tags/3.1/wp-includes/js/swfupload/handlers.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/handlers.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/handlers.dev.js	(revision 17487)
@@ -0,0 +1,370 @@
+var topWin = window.dialogArguments || opener || parent || top;
+
+function fileDialogStart() {
+	jQuery("#media-upload-error").empty();
+}
+
+// progress and success handlers for media multi uploads
+function fileQueued(fileObj) {
+	// Get rid of unused form
+	jQuery('.media-blank').remove();
+	// Collapse a single item
+	if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) {
+		jQuery('.describe-toggle-on').show();
+		jQuery('.describe-toggle-off').hide();
+		jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
+	}
+	// Create a progress bar containing the filename
+	jQuery('#media-items').append('<div id="media-item-' + fileObj.id + '" class="media-item child-of-' + post_id + '"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> ' + fileObj.name + '</div></div>');
+	// Display the progress div
+	jQuery('.progress', '#media-item-' + fileObj.id).show();
+
+	// Disable submit and enable cancel
+	jQuery('#insert-gallery').attr('disabled', 'disabled');
+	jQuery('#cancel-upload').attr('disabled', '');
+}
+
+function uploadStart(fileObj) {
+	try {
+		if ( typeof topWin.tb_remove != 'undefined' )
+			topWin.jQuery('#TB_overlay').unbind('click', topWin.tb_remove); 
+	} catch(e){}
+
+	return true;
+}
+
+function uploadProgress(fileObj, bytesDone, bytesTotal) {
+	// Lengthen the progress bar
+	var w = jQuery('#media-items').width() - 2, item = jQuery('#media-item-' + fileObj.id);
+	jQuery('.bar', item).width( w * bytesDone / bytesTotal );
+	jQuery('.percent', item).html( Math.ceil(bytesDone / bytesTotal * 100) + '%' );
+
+	if ( bytesDone == bytesTotal )
+		jQuery('.bar', item).html('<strong class="crunching">' + swfuploadL10n.crunching + '</strong>');
+}
+
+function prepareMediaItem(fileObj, serverData) {
+	var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
+	// Move the progress bar to 100%
+	jQuery('.bar', item).remove();
+	jQuery('.progress', item).hide();
+
+	try {
+		if ( typeof topWin.tb_remove != 'undefined' )
+			topWin.jQuery('#TB_overlay').click(topWin.tb_remove);
+	} catch(e){}
+
+	// Old style: Append the HTML returned by the server -- thumbnail and form inputs
+	if ( isNaN(serverData) || !serverData ) {
+		item.append(serverData);
+		prepareMediaItemInit(fileObj);
+	}
+	// New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
+	else {
+		item.load('async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
+	}
+}
+
+function prepareMediaItemInit(fileObj) {
+	var item = jQuery('#media-item-' + fileObj.id);
+	// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
+	jQuery('.thumbnail', item).clone().attr('className', 'pinkynail toggle').prependTo(item);
+
+	// Replace the original filename with the new (unique) one assigned during upload
+	jQuery('.filename.original', item).replaceWith( jQuery('.filename.new', item) );
+
+	// Also bind toggle to the links
+	jQuery('a.toggle', item).click(function(){
+		jQuery(this).siblings('.slidetoggle').slideToggle(350, function(){
+			var w = jQuery(window).height(), t = jQuery(this).offset().top, h = jQuery(this).height(), b;
+
+			if ( w && t && h ) {
+                b = t + h;
+
+                if ( b > w && (h + 48) < w )
+                    window.scrollBy(0, b - w + 13);
+                else if ( b > w )
+                    window.scrollTo(0, t - 36);
+            }
+		});
+		jQuery(this).siblings('.toggle').andSelf().toggle();
+		jQuery(this).siblings('a.toggle').focus();
+		return false;
+	});
+
+	// Bind AJAX to the new Delete button
+	jQuery('a.delete', item).click(function(){
+		// Tell the server to delete it. TODO: handle exceptions
+		jQuery.ajax({
+			url: 'admin-ajax.php',
+			type: 'post',
+			success: deleteSuccess,
+			error: deleteError,
+			id: fileObj.id,
+			data: {
+				id : this.id.replace(/[^0-9]/g, ''),
+				action : 'trash-post',
+				_ajax_nonce : this.href.replace(/^.*wpnonce=/,'')
+			}
+		});
+		return false;
+	});
+
+	// Bind AJAX to the new Undo button
+	jQuery('a.undo', item).click(function(){
+		// Tell the server to untrash it. TODO: handle exceptions
+		jQuery.ajax({
+			url: 'admin-ajax.php',
+			type: 'post',
+			id: fileObj.id,
+			data: {
+				id : this.id.replace(/[^0-9]/g,''),
+				action: 'untrash-post',
+				_ajax_nonce: this.href.replace(/^.*wpnonce=/,'')
+			},
+			success: function(data, textStatus){
+				var item = jQuery('#media-item-' + fileObj.id);
+
+				if ( type = jQuery('#type-of-' + fileObj.id).val() )
+					jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1);
+				if ( item.hasClass('child-of-'+post_id) )
+					jQuery('#attachments-count').text(jQuery('#attachments-count').text()-0+1);
+
+				jQuery('.filename .trashnotice', item).remove();
+				jQuery('.filename .title', item).css('font-weight','normal');
+				jQuery('a.undo', item).addClass('hidden');
+				jQuery('a.describe-toggle-on, .menu_order_input', item).show();
+				item.css( {backgroundColor:'#ceb'} ).animate( {backgroundColor: '#fff'}, { queue: false, duration: 500, complete: function(){ jQuery(this).css({backgroundColor:''}); } }).removeClass('undo');
+			}
+		});
+		return false;
+	});
+
+	// Open this item if it says to start open (e.g. to display an error)
+	jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').slideToggle(500).siblings('.toggle').toggle();
+}
+
+function itemAjaxError(id, html) {
+	var item = jQuery('#media-item-' + id);
+	var filename = jQuery('.filename', item).text();
+
+	item.html('<div class="error-div">'
+				+ '<a class="dismiss" href="#">' + swfuploadL10n.dismiss + '</a>'
+				+ '<strong>' + swfuploadL10n.error_uploading.replace('%s', filename) + '</strong><br />'
+				+ html
+				+ '</div>');
+	item.find('a.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
+}
+
+function deleteSuccess(data, textStatus) {
+	if ( data == '-1' )
+		return itemAjaxError(this.id, 'You do not have permission. Has your session expired?');
+	if ( data == '0' )
+		return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?');
+
+	var id = this.id, item = jQuery('#media-item-' + id);
+
+	// Decrement the counters.
+	if ( type = jQuery('#type-of-' + id).val() )
+		jQuery('#' + type + '-counter').text( jQuery('#' + type + '-counter').text() - 1 );
+	if ( item.hasClass('child-of-'+post_id) )
+		jQuery('#attachments-count').text( jQuery('#attachments-count').text() - 1 );
+
+	if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) {
+		jQuery('.toggle').toggle();
+		jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
+	}
+
+	// Vanish it.
+	jQuery('.toggle', item).toggle();
+	jQuery('.slidetoggle', item).slideUp(200).siblings().removeClass('hidden');
+	item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass('undo');
+
+	jQuery('.filename:empty', item).remove();
+	jQuery('.filename .title', item).css('font-weight','bold');
+	jQuery('.filename', item).append('<span class="trashnotice"> ' + swfuploadL10n.deleted + ' </span>').siblings('a.toggle').hide();
+	jQuery('.filename', item).append( jQuery('a.undo', item).removeClass('hidden') );
+	jQuery('.menu_order_input', item).hide();
+
+	return;
+}
+
+function deleteError(X, textStatus, errorThrown) {
+	// TODO
+}
+
+function updateMediaForm() {
+	var one = jQuery('form.type-form #media-items').children(), items = jQuery('#media-items').children();
+
+	// Just one file, no need for collapsible part
+	if ( one.length == 1 ) {
+		jQuery('.slidetoggle', one).slideDown(500).siblings().addClass('hidden').filter('.toggle').toggle();
+	}
+
+	// Only show Save buttons when there is at least one file.
+	if ( items.not('.media-blank').length > 0 )
+		jQuery('.savebutton').show();
+	else
+		jQuery('.savebutton').hide();
+
+	// Only show Gallery button when there are at least two files.
+	if ( items.length > 1 )
+		jQuery('.insert-gallery').show();
+	else
+		jQuery('.insert-gallery').hide();
+}
+
+function uploadSuccess(fileObj, serverData) {
+	// if async-upload returned an error message, place it in the media item div and return
+	if ( serverData.match('media-upload-error') ) {
+		jQuery('#media-item-' + fileObj.id).html(serverData);
+		return;
+	}
+
+	prepareMediaItem(fileObj, serverData);
+	updateMediaForm();
+
+	// Increment the counter.
+	if ( jQuery('#media-item-' + fileObj.id).hasClass('child-of-' + post_id) )
+		jQuery('#attachments-count').text(1 * jQuery('#attachments-count').text() + 1);
+}
+
+function uploadComplete(fileObj) {
+	// If no more uploads queued, enable the submit button
+	if ( swfu.getStats().files_queued == 0 ) {
+		jQuery('#cancel-upload').attr('disabled', 'disabled');
+		jQuery('#insert-gallery').attr('disabled', '');
+	}
+}
+
+
+// wp-specific error handlers
+
+// generic message
+function wpQueueError(message) {
+	jQuery('#media-upload-error').show().text(message);
+}
+
+// file-specific message
+function wpFileError(fileObj, message) {
+	var item = jQuery('#media-item-' + fileObj.id);
+	var filename = jQuery('.filename', item).text();
+
+	item.html('<div class="error-div">'
+				+ '<a class="dismiss" href="#">' + swfuploadL10n.dismiss + '</a>'
+				+ '<strong>' + swfuploadL10n.error_uploading.replace('%s', filename) + '</strong><br />'
+				+ message
+				+ '</div>');
+	item.find('a.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
+}
+
+function fileQueueError(fileObj, error_code, message)  {
+	// Handle this error separately because we don't want to create a FileProgress element for it.
+	if ( error_code == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED ) {
+		wpQueueError(swfuploadL10n.queue_limit_exceeded);
+	}
+	else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) {
+		fileQueued(fileObj);
+		wpFileError(fileObj, swfuploadL10n.file_exceeds_size_limit);
+	}
+	else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) {
+		fileQueued(fileObj);
+		wpFileError(fileObj, swfuploadL10n.zero_byte_file);
+	}
+	else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) {
+		fileQueued(fileObj);
+		wpFileError(fileObj, swfuploadL10n.invalid_filetype);
+	}
+	else {
+		wpQueueError(swfuploadL10n.default_error);
+	}
+}
+
+function fileDialogComplete(num_files_queued) {
+	try {
+		if (num_files_queued > 0) {
+			this.startUpload();
+		}
+	} catch (ex) {
+		this.debug(ex);
+	}
+}
+
+function switchUploader(s) {
+	var f = document.getElementById(swfu.customSettings.swfupload_element_id), h = document.getElementById(swfu.customSettings.degraded_element_id);
+	if ( s ) {
+		f.style.display = 'block';
+		h.style.display = 'none';
+	} else {
+		f.style.display = 'none';
+		h.style.display = 'block';
+	}
+}
+
+function swfuploadPreLoad() {
+	if ( !uploaderMode ) {
+		switchUploader(1);
+	} else {
+		switchUploader(0);
+	}
+}
+
+function swfuploadLoadFailed() {
+	switchUploader(0);
+	jQuery('.upload-html-bypass').hide();
+}
+
+function uploadError(fileObj, errorCode, message) {
+
+	switch (errorCode) {
+		case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
+			wpFileError(fileObj, swfuploadL10n.missing_upload_url);
+			break;
+		case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
+			wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded);
+			break;
+		case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
+			wpQueueError(swfuploadL10n.http_error);
+			break;
+		case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
+			wpQueueError(swfuploadL10n.upload_failed);
+			break;
+		case SWFUpload.UPLOAD_ERROR.IO_ERROR:
+			wpQueueError(swfuploadL10n.io_error);
+			break;
+		case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
+			wpQueueError(swfuploadL10n.security_error);
+			break;
+		case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
+		case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
+			jQuery('#media-item-' + fileObj.id).remove();
+			break;
+		default:
+			wpFileError(fileObj, swfuploadL10n.default_error);
+	}
+}
+
+function cancelUpload() {
+	swfu.cancelQueue();
+}
+
+// remember the last used image size, alignment and url
+jQuery(document).ready(function($){
+	$('input[type="radio"]', '#media-items').live('click', function(){
+		var tr = $(this).closest('tr');
+
+		if ( $(tr).hasClass('align') )
+			setUserSetting('align', $(this).val());
+		else if ( $(tr).hasClass('image-size') )
+			setUserSetting('imgsize', $(this).val());
+	});
+
+	$('button.button', '#media-items').live('click', function(){
+		var c = this.className || '';
+		c = c.match(/url([^ '"]+)/);
+		if ( c && c[1] ) {
+			setUserSetting('urlbutton', c[1]);
+			$(this).siblings('.urlfield').val( $(this).attr('title') );
+		}
+	});
+});
Index: /tags/3.1/wp-includes/js/swfupload/handlers.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/handlers.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/handlers.js	(revision 17487)
@@ -0,0 +1,1 @@
+var topWin=window.dialogArguments||opener||parent||top;function fileDialogStart(){jQuery("#media-upload-error").empty()}function fileQueued(a){jQuery(".media-blank").remove();if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".describe-toggle-on").show();jQuery(".describe-toggle-off").hide();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-items").append('<div id="media-item-'+a.id+'" class="media-item child-of-'+post_id+'"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> '+a.name+"</div></div>");jQuery(".progress","#media-item-"+a.id).show();jQuery("#insert-gallery").attr("disabled","disabled");jQuery("#cancel-upload").attr("disabled","")}function uploadStart(a){try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}}catch(b){}return true}function uploadProgress(e,b,d){var a=jQuery("#media-items").width()-2,c=jQuery("#media-item-"+e.id);jQuery(".bar",c).width(a*b/d);jQuery(".percent",c).html(Math.ceil(b/d*100)+"%");if(b==d){jQuery(".bar",c).html('<strong class="crunching">'+swfuploadL10n.crunching+"</strong>")}}function prepareMediaItem(c,a){var d=(typeof shortform=="undefined")?1:2,b=jQuery("#media-item-"+c.id);jQuery(".bar",b).remove();jQuery(".progress",b).hide();try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}}catch(g){}if(isNaN(a)||!a){b.append(a);prepareMediaItemInit(c)}else{b.load("async-upload.php",{attachment_id:a,fetch:d},function(){prepareMediaItemInit(c);updateMediaForm()})}}function prepareMediaItemInit(b){var a=jQuery("#media-item-"+b.id);jQuery(".thumbnail",a).clone().attr("className","pinkynail toggle").prependTo(a);jQuery(".filename.original",a).replaceWith(jQuery(".filename.new",a));jQuery("a.toggle",a).click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(350,function(){var d=jQuery(window).height(),e=jQuery(this).offset().top,f=jQuery(this).height(),c;if(d&&e&&f){c=e+f;if(c>d&&(f+48)<d){window.scrollBy(0,c-d+13)}else{if(c>d){window.scrollTo(0,e-36)}}}});jQuery(this).siblings(".toggle").andSelf().toggle();jQuery(this).siblings("a.toggle").focus();return false});jQuery("a.delete",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",success:deleteSuccess,error:deleteError,id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}});return false});jQuery("a.undo",a).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",id:b.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(d,e){var c=jQuery("#media-item-"+b.id);if(type=jQuery("#type-of-"+b.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-0+1)}if(c.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1)}jQuery(".filename .trashnotice",c).remove();jQuery(".filename .title",c).css("font-weight","normal");jQuery("a.undo",c).addClass("hidden");jQuery("a.describe-toggle-on, .menu_order_input",c).show();c.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:false,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}});return false});jQuery("#media-item-"+b.id+".startopen").removeClass("startopen").slideToggle(500).siblings(".toggle").toggle()}function itemAjaxError(d,b){var c=jQuery("#media-item-"+d);var a=jQuery(".filename",c).text();c.html('<div class="error-div"><a class="dismiss" href="#">'+swfuploadL10n.dismiss+"</a><strong>"+swfuploadL10n.error_uploading.replace("%s",a)+"</strong><br />"+b+"</div>");c.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function deleteSuccess(b,d){if(b=="-1"){return itemAjaxError(this.id,"You do not have permission. Has your session expired?")}if(b=="0"){return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?")}var c=this.id,a=jQuery("#media-item-"+c);if(type=jQuery("#type-of-"+c).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1)}if(a.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1)}if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".toggle").toggle();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery(".toggle",a).toggle();jQuery(".slidetoggle",a).slideUp(200).siblings().removeClass("hidden");a.css({backgroundColor:"#faa"}).animate({backgroundColor:"#f4f4f4"},{queue:false,duration:500}).addClass("undo");jQuery(".filename:empty",a).remove();jQuery(".filename .title",a).css("font-weight","bold");jQuery(".filename",a).append('<span class="trashnotice"> '+swfuploadL10n.deleted+" </span>").siblings("a.toggle").hide();jQuery(".filename",a).append(jQuery("a.undo",a).removeClass("hidden"));jQuery(".menu_order_input",a).hide();return}function deleteError(c,b,a){}function updateMediaForm(){var b=jQuery("form.type-form #media-items").children(),a=jQuery("#media-items").children();if(b.length==1){jQuery(".slidetoggle",b).slideDown(500).siblings().addClass("hidden").filter(".toggle").toggle()}if(a.not(".media-blank").length>0){jQuery(".savebutton").show()}else{jQuery(".savebutton").hide()}if(a.length>1){jQuery(".insert-gallery").show()}else{jQuery(".insert-gallery").hide()}}function uploadSuccess(b,a){if(a.match("media-upload-error")){jQuery("#media-item-"+b.id).html(a);return}prepareMediaItem(b,a);updateMediaForm();if(jQuery("#media-item-"+b.id).hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)}}function uploadComplete(a){if(swfu.getStats().files_queued==0){jQuery("#cancel-upload").attr("disabled","disabled");jQuery("#insert-gallery").attr("disabled","")}}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}function wpFileError(d,c){var b=jQuery("#media-item-"+d.id);var a=jQuery(".filename",b).text();b.html('<div class="error-div"><a class="dismiss" href="#">'+swfuploadL10n.dismiss+"</a><strong>"+swfuploadL10n.error_uploading.replace("%s",a)+"</strong><br />"+c+"</div>");b.find("a.dismiss").click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function fileQueueError(c,a,b){if(a==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){wpQueueError(swfuploadL10n.queue_limit_exceeded)}else{if(a==SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT){fileQueued(c);wpFileError(c,swfuploadL10n.file_exceeds_size_limit)}else{if(a==SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){fileQueued(c);wpFileError(c,swfuploadL10n.zero_byte_file)}else{if(a==SWFUpload.QUEUE_ERROR.INVALID_FILETYPE){fileQueued(c);wpFileError(c,swfuploadL10n.invalid_filetype)}else{wpQueueError(swfuploadL10n.default_error)}}}}}function fileDialogComplete(b){try{if(b>0){this.startUpload()}}catch(a){this.debug(a)}}function switchUploader(b){var c=document.getElementById(swfu.customSettings.swfupload_element_id),a=document.getElementById(swfu.customSettings.degraded_element_id);if(b){c.style.display="block";a.style.display="none"}else{c.style.display="none";a.style.display="block"}}function swfuploadPreLoad(){if(!uploaderMode){switchUploader(1)}else{switchUploader(0)}}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}function uploadError(b,c,a){switch(c){case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:wpFileError(b,swfuploadL10n.missing_upload_url);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:wpFileError(b,swfuploadL10n.upload_limit_exceeded);break;case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:wpQueueError(swfuploadL10n.http_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:wpQueueError(swfuploadL10n.upload_failed);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:wpQueueError(swfuploadL10n.io_error);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:wpQueueError(swfuploadL10n.security_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:jQuery("#media-item-"+b.id).remove();break;default:wpFileError(b,swfuploadL10n.default_error)}}function cancelUpload(){swfu.cancelQueue()}jQuery(document).ready(function(a){a('input[type="radio"]',"#media-items").live("click",function(){var b=a(this).closest("tr");if(a(b).hasClass("align")){setUserSetting("align",a(this).val())}else{if(a(b).hasClass("image-size")){setUserSetting("imgsize",a(this).val())}}});a("button.button","#media-items").live("click",function(){var b=this.className||"";b=b.match(/url([^ '"]+)/);if(b&&b[1]){setUserSetting("urlbutton",b[1]);a(this).siblings(".urlfield").val(a(this).attr("title"))}})});
Index: /tags/3.1/wp-includes/js/swfupload/license.txt
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/license.txt	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/license.txt	(revision 17487)
@@ -0,0 +1,32 @@
+/**
+ * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
+ *
+ * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/,  http://www.vinterwebb.se/
+ *
+ * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ */
+
+The MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
Index: /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.cookies.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.cookies.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.cookies.js	(revision 17487)
@@ -0,0 +1,53 @@
+/*
+	Cookie Plug-in
+	
+	This plug in automatically gets all the cookies for this site and adds them to the post_params.
+	Cookies are loaded only on initialization.  The refreshCookies function can be called to update the post_params.
+	The cookies will override any other post params with the same name.
+*/
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+	SWFUpload.prototype.initSettings = function (oldInitSettings) {
+		return function () {
+			if (typeof(oldInitSettings) === "function") {
+				oldInitSettings.call(this);
+			}
+			
+			this.refreshCookies(false);	// The false parameter must be sent since SWFUpload has not initialzed at this point
+		};
+	}(SWFUpload.prototype.initSettings);
+	
+	// refreshes the post_params and updates SWFUpload.  The sendToFlash parameters is optional and defaults to True
+	SWFUpload.prototype.refreshCookies = function (sendToFlash) {
+		if (sendToFlash === undefined) {
+			sendToFlash = true;
+		}
+		sendToFlash = !!sendToFlash;
+		
+		// Get the post_params object
+		var postParams = this.settings.post_params;
+		
+		// Get the cookies
+		var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
+		for (i = 0; i < caLength; i++) {
+			c = cookieArray[i];
+			
+			// Left Trim spaces
+			while (c.charAt(0) === " ") {
+				c = c.substring(1, c.length);
+			}
+			eqIndex = c.indexOf("=");
+			if (eqIndex > 0) {
+				name = c.substring(0, eqIndex);
+				value = c.substring(eqIndex + 1);
+				postParams[name] = value;
+			}
+		}
+		
+		if (sendToFlash) {
+			this.setPostParams(postParams);
+		}
+	};
+
+}
Index: /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.queue.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.queue.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.queue.js	(revision 17487)
@@ -0,0 +1,98 @@
+/*
+	Queue Plug-in
+	
+	Features:
+		*Adds a cancelQueue() method for cancelling the entire queue.
+		*All queued files are uploaded when startUpload() is called.
+		*If false is returned from uploadComplete then the queue upload is stopped.
+		 If false is not returned (strict comparison) then the queue upload is continued.
+		*Adds a QueueComplete event that is fired when all the queued files have finished uploading.
+		 Set the event handler with the queue_complete_handler setting.
+		
+	*/
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+	SWFUpload.queue = {};
+	
+	SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+		return function () {
+			if (typeof(oldInitSettings) === "function") {
+				oldInitSettings.call(this);
+			}
+			
+			this.queueSettings = {};
+			
+			this.queueSettings.queue_cancelled_flag = false;
+			this.queueSettings.queue_upload_count = 0;
+			
+			this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
+			this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
+			this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
+			this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
+			
+			this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
+		};
+	})(SWFUpload.prototype.initSettings);
+
+	SWFUpload.prototype.startUpload = function (fileID) {
+		this.queueSettings.queue_cancelled_flag = false;
+		this.callFlash("StartUpload", [fileID]);
+	};
+
+	SWFUpload.prototype.cancelQueue = function () {
+		this.queueSettings.queue_cancelled_flag = true;
+		this.stopUpload();
+		
+		var stats = this.getStats();
+		while (stats.files_queued > 0) {
+			this.cancelUpload();
+			stats = this.getStats();
+		}
+	};
+	
+	SWFUpload.queue.uploadStartHandler = function (file) {
+		var returnValue;
+		if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
+			returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
+		}
+		
+		// To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
+		returnValue = (returnValue === false) ? false : true;
+		
+		this.queueSettings.queue_cancelled_flag = !returnValue;
+
+		return returnValue;
+	};
+	
+	SWFUpload.queue.uploadCompleteHandler = function (file) {
+		var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
+		var continueUpload;
+		
+		if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
+			this.queueSettings.queue_upload_count++;
+		}
+
+		if (typeof(user_upload_complete_handler) === "function") {
+			continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
+		} else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
+			// If the file was stopped and re-queued don't restart the upload
+			continueUpload = false;
+		} else {
+			continueUpload = true;
+		}
+		
+		if (continueUpload) {
+			var stats = this.getStats();
+			if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
+				this.startUpload();
+			} else if (this.queueSettings.queue_cancelled_flag === false) {
+				this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
+				this.queueSettings.queue_upload_count = 0;
+			} else {
+				this.queueSettings.queue_cancelled_flag = false;
+				this.queueSettings.queue_upload_count = 0;
+			}
+		}
+	};
+}
Index: /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.speed.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.speed.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.speed.js	(revision 17487)
@@ -0,0 +1,342 @@
+/*
+	Speed Plug-in
+	
+	Features:
+		*Adds several properties to the 'file' object indicated upload speed, time left, upload time, etc.
+			- currentSpeed -- String indicating the upload speed, bytes per second
+			- averageSpeed -- Overall average upload speed, bytes per second
+			- movingAverageSpeed -- Speed over averaged over the last several measurements, bytes per second
+			- timeRemaining -- Estimated remaining upload time in seconds
+			- timeElapsed -- Number of seconds passed for this upload
+			- percentUploaded -- Percentage of the file uploaded (0 to 100)
+			- sizeUploaded -- Formatted size uploaded so far, bytes
+		
+		*Adds setting 'moving_average_history_size' for defining the window size used to calculate the moving average speed.
+		
+		*Adds several Formatting functions for formatting that values provided on the file object.
+			- SWFUpload.speed.formatBPS(bps) -- outputs string formatted in the best units (Gbps, Mbps, Kbps, bps)
+			- SWFUpload.speed.formatTime(seconds) -- outputs string formatted in the best units (x Hr y M z S)
+			- SWFUpload.speed.formatSize(bytes) -- outputs string formatted in the best units (w GB x MB y KB z B )
+			- SWFUpload.speed.formatPercent(percent) -- outputs string formatted with a percent sign (x.xx %)
+			- SWFUpload.speed.formatUnits(baseNumber, divisionArray, unitLabelArray, fractionalBoolean)
+				- Formats a number using the division array to determine how to apply the labels in the Label Array
+				- factionalBoolean indicates whether the number should be returned as a single fractional number with a unit (speed)
+				    or as several numbers labeled with units (time)
+	*/
+
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+	SWFUpload.speed = {};
+	
+	SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+		return function () {
+			if (typeof(oldInitSettings) === "function") {
+				oldInitSettings.call(this);
+			}
+			
+			this.ensureDefault = function (settingName, defaultValue) {
+				this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+			};
+
+			// List used to keep the speed stats for the files we are tracking
+			this.fileSpeedStats = {};
+			this.speedSettings = {};
+
+			this.ensureDefault("moving_average_history_size", "10");
+			
+			this.speedSettings.user_file_queued_handler = this.settings.file_queued_handler;
+			this.speedSettings.user_file_queue_error_handler = this.settings.file_queue_error_handler;
+			this.speedSettings.user_upload_start_handler = this.settings.upload_start_handler;
+			this.speedSettings.user_upload_error_handler = this.settings.upload_error_handler;
+			this.speedSettings.user_upload_progress_handler = this.settings.upload_progress_handler;
+			this.speedSettings.user_upload_success_handler = this.settings.upload_success_handler;
+			this.speedSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
+			
+			this.settings.file_queued_handler = SWFUpload.speed.fileQueuedHandler;
+			this.settings.file_queue_error_handler = SWFUpload.speed.fileQueueErrorHandler;
+			this.settings.upload_start_handler = SWFUpload.speed.uploadStartHandler;
+			this.settings.upload_error_handler = SWFUpload.speed.uploadErrorHandler;
+			this.settings.upload_progress_handler = SWFUpload.speed.uploadProgressHandler;
+			this.settings.upload_success_handler = SWFUpload.speed.uploadSuccessHandler;
+			this.settings.upload_complete_handler = SWFUpload.speed.uploadCompleteHandler;
+			
+			delete this.ensureDefault;
+		};
+	})(SWFUpload.prototype.initSettings);
+
+	
+	SWFUpload.speed.fileQueuedHandler = function (file) {
+		if (typeof this.speedSettings.user_file_queued_handler === "function") {
+			file = SWFUpload.speed.extendFile(file);
+			
+			return this.speedSettings.user_file_queued_handler.call(this, file);
+		}
+	};
+	
+	SWFUpload.speed.fileQueueErrorHandler = function (file, errorCode, message) {
+		if (typeof this.speedSettings.user_file_queue_error_handler === "function") {
+			file = SWFUpload.speed.extendFile(file);
+			
+			return this.speedSettings.user_file_queue_error_handler.call(this, file, errorCode, message);
+		}
+	};
+
+	SWFUpload.speed.uploadStartHandler = function (file) {
+		if (typeof this.speedSettings.user_upload_start_handler === "function") {
+			file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+			return this.speedSettings.user_upload_start_handler.call(this, file);
+		}
+	};
+	
+	SWFUpload.speed.uploadErrorHandler = function (file, errorCode, message) {
+		file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+		SWFUpload.speed.removeTracking(file, this.fileSpeedStats);
+
+		if (typeof this.speedSettings.user_upload_error_handler === "function") {
+			return this.speedSettings.user_upload_error_handler.call(this, file, errorCode, message);
+		}
+	};
+	SWFUpload.speed.uploadProgressHandler = function (file, bytesComplete, bytesTotal) {
+		this.updateTracking(file, bytesComplete);
+		file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+
+		if (typeof this.speedSettings.user_upload_progress_handler === "function") {
+			return this.speedSettings.user_upload_progress_handler.call(this, file, bytesComplete, bytesTotal);
+		}
+	};
+	
+	SWFUpload.speed.uploadSuccessHandler = function (file, serverData) {
+		if (typeof this.speedSettings.user_upload_success_handler === "function") {
+			file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+			return this.speedSettings.user_upload_success_handler.call(this, file, serverData);
+		}
+	};
+	SWFUpload.speed.uploadCompleteHandler = function (file) {
+		file = SWFUpload.speed.extendFile(file, this.fileSpeedStats);
+		SWFUpload.speed.removeTracking(file, this.fileSpeedStats);
+
+		if (typeof this.speedSettings.user_upload_complete_handler === "function") {
+			return this.speedSettings.user_upload_complete_handler.call(this, file);
+		}
+	};
+	
+	// Private: extends the file object with the speed plugin values
+	SWFUpload.speed.extendFile = function (file, trackingList) {
+		var tracking;
+		
+		if (trackingList) {
+			tracking = trackingList[file.id];
+		}
+		
+		if (tracking) {
+			file.currentSpeed = tracking.currentSpeed;
+			file.averageSpeed = tracking.averageSpeed;
+			file.movingAverageSpeed = tracking.movingAverageSpeed;
+			file.timeRemaining = tracking.timeRemaining;
+			file.timeElapsed = tracking.timeElapsed;
+			file.percentUploaded = tracking.percentUploaded;
+			file.sizeUploaded = tracking.bytesUploaded;
+
+		} else {
+			file.currentSpeed = 0;
+			file.averageSpeed = 0;
+			file.movingAverageSpeed = 0;
+			file.timeRemaining = 0;
+			file.timeElapsed = 0;
+			file.percentUploaded = 0;
+			file.sizeUploaded = 0;
+		}
+		
+		return file;
+	};
+	
+	// Private: Updates the speed tracking object, or creates it if necessary
+	SWFUpload.prototype.updateTracking = function (file, bytesUploaded) {
+		var tracking = this.fileSpeedStats[file.id];
+		if (!tracking) {
+			this.fileSpeedStats[file.id] = tracking = {};
+		}
+		
+		// Sanity check inputs
+		bytesUploaded = bytesUploaded || tracking.bytesUploaded || 0;
+		if (bytesUploaded < 0) {
+			bytesUploaded = 0;
+		}
+		if (bytesUploaded > file.size) {
+			bytesUploaded = file.size;
+		}
+		
+		var tickTime = (new Date()).getTime();
+		if (!tracking.startTime) {
+			tracking.startTime = (new Date()).getTime();
+			tracking.lastTime = tracking.startTime;
+			tracking.currentSpeed = 0;
+			tracking.averageSpeed = 0;
+			tracking.movingAverageSpeed = 0;
+			tracking.movingAverageHistory = [];
+			tracking.timeRemaining = 0;
+			tracking.timeElapsed = 0;
+			tracking.percentUploaded = bytesUploaded / file.size;
+			tracking.bytesUploaded = bytesUploaded;
+		} else if (tracking.startTime > tickTime) {
+			this.debug("When backwards in time");
+		} else {
+			// Get time and deltas
+			var now = (new Date()).getTime();
+			var lastTime = tracking.lastTime;
+			var deltaTime = now - lastTime;
+			var deltaBytes = bytesUploaded - tracking.bytesUploaded;
+			
+			if (deltaBytes === 0 || deltaTime === 0) {
+				return tracking;
+			}
+			
+			// Update tracking object
+			tracking.lastTime = now;
+			tracking.bytesUploaded = bytesUploaded;
+			
+			// Calculate speeds
+			tracking.currentSpeed = (deltaBytes * 8 ) / (deltaTime / 1000);
+			tracking.averageSpeed = (tracking.bytesUploaded * 8) / ((now - tracking.startTime) / 1000);
+
+			// Calculate moving average
+			tracking.movingAverageHistory.push(tracking.currentSpeed);
+			if (tracking.movingAverageHistory.length > this.settings.moving_average_history_size) {
+				tracking.movingAverageHistory.shift();
+			}
+			
+			tracking.movingAverageSpeed = SWFUpload.speed.calculateMovingAverage(tracking.movingAverageHistory);
+			
+			// Update times
+			tracking.timeRemaining = (file.size - tracking.bytesUploaded) * 8 / tracking.movingAverageSpeed;
+			tracking.timeElapsed = (now - tracking.startTime) / 1000;
+			
+			// Update percent
+			tracking.percentUploaded = (tracking.bytesUploaded / file.size * 100);
+		}
+		
+		return tracking;
+	};
+	SWFUpload.speed.removeTracking = function (file, trackingList) {
+		try {
+			trackingList[file.id] = null;
+			delete trackingList[file.id];
+		} catch (ex) {
+		}
+	};
+	
+	SWFUpload.speed.formatUnits = function (baseNumber, unitDivisors, unitLabels, singleFractional) {
+		var i, unit, unitDivisor, unitLabel;
+
+		if (baseNumber === 0) {
+			return "0 " + unitLabels[unitLabels.length - 1];
+		}
+		
+		if (singleFractional) {
+			unit = baseNumber;
+			unitLabel = unitLabels.length >= unitDivisors.length ? unitLabels[unitDivisors.length - 1] : "";
+			for (i = 0; i < unitDivisors.length; i++) {
+				if (baseNumber >= unitDivisors[i]) {
+					unit = (baseNumber / unitDivisors[i]).toFixed(2);
+					unitLabel = unitLabels.length >= i ? " " + unitLabels[i] : "";
+					break;
+				}
+			}
+			
+			return unit + unitLabel;
+		} else {
+			var formattedStrings = [];
+			var remainder = baseNumber;
+			
+			for (i = 0; i < unitDivisors.length; i++) {
+				unitDivisor = unitDivisors[i];
+				unitLabel = unitLabels.length > i ? " " + unitLabels[i] : "";
+				
+				unit = remainder / unitDivisor;
+				if (i < unitDivisors.length -1) {
+					unit = Math.floor(unit);
+				} else {
+					unit = unit.toFixed(2);
+				}
+				if (unit > 0) {
+					remainder = remainder % unitDivisor;
+					
+					formattedStrings.push(unit + unitLabel);
+				}
+			}
+			
+			return formattedStrings.join(" ");
+		}
+	};
+	
+	SWFUpload.speed.formatBPS = function (baseNumber) {
+		var bpsUnits = [1073741824, 1048576, 1024, 1], bpsUnitLabels = ["Gbps", "Mbps", "Kbps", "bps"];
+		return SWFUpload.speed.formatUnits(baseNumber, bpsUnits, bpsUnitLabels, true);
+	
+	};
+	SWFUpload.speed.formatTime = function (baseNumber) {
+		var timeUnits = [86400, 3600, 60, 1], timeUnitLabels = ["d", "h", "m", "s"];
+		return SWFUpload.speed.formatUnits(baseNumber, timeUnits, timeUnitLabels, false);
+	
+	};
+	SWFUpload.speed.formatBytes = function (baseNumber) {
+		var sizeUnits = [1073741824, 1048576, 1024, 1], sizeUnitLabels = ["GB", "MB", "KB", "bytes"];
+		return SWFUpload.speed.formatUnits(baseNumber, sizeUnits, sizeUnitLabels, true);
+	
+	};
+	SWFUpload.speed.formatPercent = function (baseNumber) {
+		return baseNumber.toFixed(2) + " %";
+	};
+	
+	SWFUpload.speed.calculateMovingAverage = function (history) {
+		var vals = [], size, sum = 0.0, mean = 0.0, varianceTemp = 0.0, variance = 0.0, standardDev = 0.0;
+		var i;
+		var mSum = 0, mCount = 0;
+		
+		size = history.length;
+		
+		// Check for sufficient data
+		if (size >= 8) {
+			// Clone the array and Calculate sum of the values 
+			for (i = 0; i < size; i++) {
+				vals[i] = history[i];
+				sum += vals[i];
+			}
+
+			mean = sum / size;
+
+			// Calculate variance for the set
+			for (i = 0; i < size; i++) {
+				varianceTemp += Math.pow((vals[i] - mean), 2);
+			}
+
+			variance = varianceTemp / size;
+			standardDev = Math.sqrt(variance);
+			
+			//Standardize the Data
+			for (i = 0; i < size; i++) {
+				vals[i] = (vals[i] - mean) / standardDev;
+			}
+
+			// Calculate the average excluding outliers
+			var deviationRange = 2.0;
+			for (i = 0; i < size; i++) {
+				
+				if (vals[i] <= deviationRange && vals[i] >= -deviationRange) {
+					mCount++;
+					mSum += history[i];
+				}
+			}
+			
+		} else {
+			// Calculate the average (not enough data points to remove outliers)
+			mCount = size;
+			for (i = 0; i < size; i++) {
+				mSum += history[i];
+			}
+		}
+
+		return mSum / mCount;
+	};
+	
+}
Index: /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.swfobject.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.swfobject.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/plugins/swfupload.swfobject.js	(revision 17487)
@@ -0,0 +1,105 @@
+/*
+	SWFUpload.SWFObject Plugin
+
+	Summary:
+		This plugin uses SWFObject to embed SWFUpload dynamically in the page.  SWFObject provides accurate Flash Player detection and DOM Ready loading.
+		This plugin replaces the Graceful Degradation plugin.
+
+	Features:
+		* swfupload_load_failed_hander event
+		* swfupload_pre_load_handler event
+		* minimum_flash_version setting (default: "9.0.28")
+		* SWFUpload.onload event for early loading
+
+	Usage:
+		Provide handlers and settings as needed.  When using the SWFUpload.SWFObject plugin you should initialize SWFUploading
+		in SWFUpload.onload rather than in window.onload.  When initialized this way SWFUpload can load earlier preventing the UI flicker
+		that was seen using the Graceful Degradation plugin.
+
+		<script type="text/javascript">
+			var swfu;
+			SWFUpload.onload = function () {
+				swfu = new SWFUpload({
+					minimum_flash_version: "9.0.28",
+					swfupload_pre_load_handler: swfuploadPreLoad,
+					swfupload_load_failed_handler: swfuploadLoadFailed
+				});
+			};
+		</script>
+		
+	Notes:
+		You must provide set minimum_flash_version setting to "8" if you are using SWFUpload for Flash Player 8.
+		The swfuploadLoadFailed event is only fired if the minimum version of Flash Player is not met.  Other issues such as missing SWF files, browser bugs
+		 or corrupt Flash Player installations will not trigger this event.
+		The swfuploadPreLoad event is fired as soon as the minimum version of Flash Player is found.  It does not wait for SWFUpload to load and can
+		 be used to prepare the SWFUploadUI and hide alternate content.
+		swfobject's onDomReady event is cross-browser safe but will default to the window.onload event when DOMReady is not supported by the browser.
+		 Early DOM Loading is supported in major modern browsers but cannot be guaranteed for every browser ever made.
+*/
+
+
+// SWFObject v2.1 must be loaded
+	
+var SWFUpload;
+if (typeof(SWFUpload) === "function") {
+	SWFUpload.onload = function () {};
+	
+	swfobject.addDomLoadEvent(function () {
+		if (typeof(SWFUpload.onload) === "function") {
+			SWFUpload.onload.call(window);
+		}
+	});
+	
+	SWFUpload.prototype.initSettings = (function (oldInitSettings) {
+		return function () {
+			if (typeof(oldInitSettings) === "function") {
+				oldInitSettings.call(this);
+			}
+
+			this.ensureDefault = function (settingName, defaultValue) {
+				this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+			};
+
+			this.ensureDefault("minimum_flash_version", "9.0.28");
+			this.ensureDefault("swfupload_pre_load_handler", null);
+			this.ensureDefault("swfupload_load_failed_handler", null);
+
+			delete this.ensureDefault;
+
+		};
+	})(SWFUpload.prototype.initSettings);
+
+
+	SWFUpload.prototype.loadFlash = function (oldLoadFlash) {
+		return function () {
+			var hasFlash = swfobject.hasFlashPlayerVersion(this.settings.minimum_flash_version);
+			
+			if (hasFlash) {
+				this.queueEvent("swfupload_pre_load_handler");
+				if (typeof(oldLoadFlash) === "function") {
+					oldLoadFlash.call(this);
+				}
+			} else {
+				this.queueEvent("swfupload_load_failed_handler");
+			}
+		};
+		
+	}(SWFUpload.prototype.loadFlash);
+			
+	SWFUpload.prototype.displayDebugInfo = function (oldDisplayDebugInfo) {
+		return function () {
+			if (typeof(oldDisplayDebugInfo) === "function") {
+				oldDisplayDebugInfo.call(this);
+			}
+			
+			this.debug(
+				[
+					"SWFUpload.SWFObject Plugin settings:", "\n",
+					"\t", "minimum_flash_version:                      ", this.settings.minimum_flash_version, "\n",
+					"\t", "swfupload_pre_load_handler assigned:     ", (typeof(this.settings.swfupload_pre_load_handler) === "function").toString(), "\n",
+					"\t", "swfupload_load_failed_handler assigned:     ", (typeof(this.settings.swfupload_load_failed_handler) === "function").toString(), "\n",
+				].join("")
+			);
+		};	
+	}(SWFUpload.prototype.displayDebugInfo);
+}
Index: /tags/3.1/wp-includes/js/swfupload/swfupload-all.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/swfupload-all.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/swfupload-all.js	(revision 17487)
@@ -0,0 +1,8 @@
+// swfupload
+var SWFUpload;if(SWFUpload==undefined){SWFUpload=function(a){this.initSWFUpload(a)}}SWFUpload.prototype.initSWFUpload=function(b){try{this.customSettings={};this.settings=b;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash()}catch(a){delete SWFUpload.instances[this.movieName];throw a}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.2.0 2009-03-25";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,SELECT_FILES:-110,START_UPLOAD:-120};SWFUpload.CURSOR={ARROW:-1,HAND:-2};SWFUpload.WINDOW_MODE={WINDOW:"window",TRANSPARENT:"transparent",OPAQUE:"opaque"};SWFUpload.completeURL=function(a){if(typeof(a)!=="string"||a.match(/^https?:\/\//i)||a.match(/^\//)){return a}var c,b;c=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"");b=window.location.pathname.lastIndexOf("/");if(b<=0){path="/"}else{path=window.location.pathname.substr(0,b)+"/"}return path+a};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(b,a){this.settings[b]=(this.settings[b]==undefined)?a:this.settings[b]};this.ensureDefault("upload_url","");this.ensureDefault("preserve_relative_urls",false);this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("http_success",[]);this.ensureDefault("assume_success_timeout",0);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload.swf");this.ensureDefault("prevent_swf_caching",true);this.ensureDefault("button_image_url","");this.ensureDefault("button_width",1);this.ensureDefault("button_height",1);this.ensureDefault("button_text","");this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;");this.ensureDefault("button_text_top_padding",0);this.ensureDefault("button_text_left_padding",0);this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES);this.ensureDefault("button_disabled",false);this.ensureDefault("button_placeholder_id","");this.ensureDefault("button_placeholder",null);this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW);this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW);this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;if(!!this.settings.prevent_swf_caching){this.settings.flash_url=this.settings.flash_url+(this.settings.flash_url.indexOf("?")<0?"?":"&")+"preventswfcaching="+new Date().getTime()}if(!this.settings.preserve_relative_urls){this.settings.upload_url=SWFUpload.completeURL(this.settings.upload_url);this.settings.button_image_url=SWFUpload.completeURL(this.settings.button_image_url)}delete this.ensureDefault};SWFUpload.prototype.loadFlash=function(){var a,b;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added"}a=document.getElementById(this.settings.button_placeholder_id)||this.settings.button_placeholder;if(a==undefined){throw"Could not find the placeholder element: "+this.settings.button_placeholder_id}b=document.createElement("div");b.innerHTML=this.getFlashHTML();a.parentNode.replaceChild(b.firstChild,a);if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement()}};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="',this.settings.button_width,'" height="',this.settings.button_height,'" class="swfupload">','<param name="wmode" value="',this.settings.button_window_mode,'" />','<param name="movie" value="',this.settings.flash_url,'" />','<param name="quality" value="high" />','<param name="menu" value="false" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />',"</object>"].join("")};SWFUpload.prototype.getFlashVars=function(){var b=this.buildParamString(),a=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&amp;uploadURL=",encodeURIComponent(this.settings.upload_url),"&amp;useQueryString=",encodeURIComponent(this.settings.use_query_string),"&amp;requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&amp;httpSuccess=",encodeURIComponent(a),"&amp;assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&amp;params=",encodeURIComponent(b),"&amp;filePostName=",encodeURIComponent(this.settings.file_post_name),"&amp;fileTypes=",encodeURIComponent(this.settings.file_types),"&amp;fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&amp;fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&amp;fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&amp;fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&amp;debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&amp;buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&amp;buttonWidth=",encodeURIComponent(this.settings.button_width),"&amp;buttonHeight=",encodeURIComponent(this.settings.button_height),"&amp;buttonText=",encodeURIComponent(this.settings.button_text),"&amp;buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&amp;buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&amp;buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&amp;buttonAction=",encodeURIComponent(this.settings.button_action),"&amp;buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&amp;buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("")};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName)}if(this.movieElement===null){throw"Could not find Flash element"}return this.movieElement};SWFUpload.prototype.buildParamString=function(){var c=this.settings.post_params,b=[],a;if(typeof(c)==="object"){for(a in c){if(c.hasOwnProperty(a)){b.push(encodeURIComponent(a.toString())+"="+encodeURIComponent(c[a].toString()))}}}return b.join("&amp;")};SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,false);var a=null,c;a=this.getMovieElement();if(a&&typeof(a.CallFunction)==="unknown"){for(c in a){try{if(typeof(a[c])==="function"){a[c]=null}}catch(e){}}try{a.parentNode.removeChild(a)}catch(b){}}window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true}catch(d){return false}};SWFUpload.prototype.addSetting=function(b,c,a){if(c==undefined){return(this.settings[b]=a)}else{return(this.settings[b]=c)}};SWFUpload.prototype.getSetting=function(a){if(this.settings[a]!=undefined){return this.settings[a]}return""};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement(),returnValue,returnString;try{returnString=movieElement.CallFunction('<invoke name="'+functionName+'" returntype="javascript">'+__flash__argumentsToXML(argumentArray,0)+"</invoke>");returnValue=eval(returnString)}catch(ex){throw"Call to "+functionName+" failed"}if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue)}return returnValue};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile")};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles")};SWFUpload.prototype.startUpload=function(a){this.callFlash("StartUpload",[a])};SWFUpload.prototype.cancelUpload=function(a,b){if(b!==false){b=true}this.callFlash("CancelUpload",[a,b])};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload")};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats")};SWFUpload.prototype.setStats=function(a){this.callFlash("SetStats",[a])};SWFUpload.prototype.getFile=function(a){if(typeof(a)==="number"){return this.callFlash("GetFileByIndex",[a])}else{return this.callFlash("GetFile",[a])}};SWFUpload.prototype.addFileParam=function(a,b,c){return this.callFlash("AddFileParam",[a,b,c])};SWFUpload.prototype.removeFileParam=function(a,b){this.callFlash("RemoveFileParam",[a,b])};SWFUpload.prototype.setUploadURL=function(a){this.settings.upload_url=a.toString();this.callFlash("SetUploadURL",[a])};SWFUpload.prototype.setPostParams=function(a){this.settings.post_params=a;this.callFlash("SetPostParams",[a])};SWFUpload.prototype.addPostParam=function(a,b){this.settings.post_params[a]=b;this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.removePostParam=function(a){delete this.settings.post_params[a];this.callFlash("SetPostParams",[this.settings.post_params])};SWFUpload.prototype.setFileTypes=function(a,b){this.settings.file_types=a;this.settings.file_types_description=b;this.callFlash("SetFileTypes",[a,b])};SWFUpload.prototype.setFileSizeLimit=function(a){this.settings.file_size_limit=a;this.callFlash("SetFileSizeLimit",[a])};SWFUpload.prototype.setFileUploadLimit=function(a){this.settings.file_upload_limit=a;this.callFlash("SetFileUploadLimit",[a])};SWFUpload.prototype.setFileQueueLimit=function(a){this.settings.file_queue_limit=a;this.callFlash("SetFileQueueLimit",[a])};SWFUpload.prototype.setFilePostName=function(a){this.settings.file_post_name=a;this.callFlash("SetFilePostName",[a])};SWFUpload.prototype.setUseQueryString=function(a){this.settings.use_query_string=a;this.callFlash("SetUseQueryString",[a])};SWFUpload.prototype.setRequeueOnError=function(a){this.settings.requeue_on_error=a;this.callFlash("SetRequeueOnError",[a])};SWFUpload.prototype.setHTTPSuccess=function(a){if(typeof a==="string"){a=a.replace(" ","").split(",")}this.settings.http_success=a;this.callFlash("SetHTTPSuccess",[a])};SWFUpload.prototype.setAssumeSuccessTimeout=function(a){this.settings.assume_success_timeout=a;this.callFlash("SetAssumeSuccessTimeout",[a])};SWFUpload.prototype.setDebugEnabled=function(a){this.settings.debug_enabled=a;this.callFlash("SetDebugEnabled",[a])};SWFUpload.prototype.setButtonImageURL=function(a){if(a==undefined){a=""}this.settings.button_image_url=a;this.callFlash("SetButtonImageURL",[a])};SWFUpload.prototype.setButtonDimensions=function(c,a){this.settings.button_width=c;this.settings.button_height=a;var b=this.getMovieElement();if(b!=undefined){b.style.width=c+"px";b.style.height=a+"px"}this.callFlash("SetButtonDimensions",[c,a])};SWFUpload.prototype.setButtonText=function(a){this.settings.button_text=a;this.callFlash("SetButtonText",[a])};SWFUpload.prototype.setButtonTextPadding=function(b,a){this.settings.button_text_top_padding=a;this.settings.button_text_left_padding=b;this.callFlash("SetButtonTextPadding",[b,a])};SWFUpload.prototype.setButtonTextStyle=function(a){this.settings.button_text_style=a;this.callFlash("SetButtonTextStyle",[a])};SWFUpload.prototype.setButtonDisabled=function(a){this.settings.button_disabled=a;this.callFlash("SetButtonDisabled",[a])};SWFUpload.prototype.setButtonAction=function(a){this.settings.button_action=a;this.callFlash("SetButtonAction",[a])};SWFUpload.prototype.setButtonCursor=function(a){this.settings.button_cursor=a;this.callFlash("SetButtonCursor",[a])};SWFUpload.prototype.queueEvent=function(b,c){if(c==undefined){c=[]}else{if(!(c instanceof Array)){c=[c]}}var a=this;if(typeof this.settings[b]==="function"){this.eventQueue.push(function(){this.settings[b].apply(this,c)});setTimeout(function(){a.executeNextEvent()},0)}else{if(this.settings[b]!==null){throw"Event handler "+b+" is unknown or is not a function"}}};SWFUpload.prototype.executeNextEvent=function(){var a=this.eventQueue?this.eventQueue.shift():null;if(typeof(a)==="function"){a.apply(this)}};SWFUpload.prototype.unescapeFilePostParams=function(c){var e=/[$]([0-9a-f]{4})/i,f={},d,a,b;if(c!=undefined){for(a in c.post){if(c.post.hasOwnProperty(a)){d=a;while((b=e.exec(d))!==null){d=d.replace(b[0],String.fromCharCode(parseInt("0x"+b[1],16)))}f[d]=c.post[a]}}c.post=f}return c};SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface")}catch(a){return false}};SWFUpload.prototype.flashReady=function(){var a=this.getMovieElement();if(!a){this.debug("Flash called back ready but the flash movie can't be found.");return}this.cleanUp(a);this.queueEvent("swfupload_loaded_handler")};SWFUpload.prototype.cleanUp=function(a){var c;try{if(this.movieElement&&typeof(a.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(c in a){try{if(typeof(a[c])==="function"){a[c]=null}}catch(b){}}}}catch(d){}window.__flash__removeCallback=function(e,f){try{if(e){e[f]=null}}catch(g){}}};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler")};SWFUpload.prototype.fileQueued=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("file_queued_handler",a)};SWFUpload.prototype.fileQueueError=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("file_queue_error_handler",[a,c,b])};SWFUpload.prototype.fileDialogComplete=function(b,c,a){this.queueEvent("file_dialog_complete_handler",[b,c,a])};SWFUpload.prototype.uploadStart=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("return_upload_start_handler",a)};SWFUpload.prototype.returnUploadStart=function(a){var b;if(typeof this.settings.upload_start_handler==="function"){a=this.unescapeFilePostParams(a);b=this.settings.upload_start_handler.call(this,a)}else{if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function"}}if(b===undefined){b=true}b=!!b;this.callFlash("ReturnUploadStart",[b])};SWFUpload.prototype.uploadProgress=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("upload_progress_handler",[a,c,b])};SWFUpload.prototype.uploadError=function(a,c,b){a=this.unescapeFilePostParams(a);this.queueEvent("upload_error_handler",[a,c,b])};SWFUpload.prototype.uploadSuccess=function(b,a,c){b=this.unescapeFilePostParams(b);this.queueEvent("upload_success_handler",[b,a,c])};SWFUpload.prototype.uploadComplete=function(a){a=this.unescapeFilePostParams(a);this.queueEvent("upload_complete_handler",a)};SWFUpload.prototype.debug=function(a){this.queueEvent("debug_handler",a)};
+// swfupload.queue
+var SWFUpload;if(typeof(SWFUpload)==="function"){SWFUpload.queue={};SWFUpload.prototype.initSettings=(function(a){return function(){if(typeof(a)==="function"){a.call(this)}this.queueSettings={};this.queueSettings.queue_cancelled_flag=false;this.queueSettings.queue_upload_count=0;this.queueSettings.user_upload_complete_handler=this.settings.upload_complete_handler;this.queueSettings.user_upload_start_handler=this.settings.upload_start_handler;this.settings.upload_complete_handler=SWFUpload.queue.uploadCompleteHandler;this.settings.upload_start_handler=SWFUpload.queue.uploadStartHandler;this.settings.queue_complete_handler=this.settings.queue_complete_handler||null}})(SWFUpload.prototype.initSettings);SWFUpload.prototype.startUpload=function(a){this.queueSettings.queue_cancelled_flag=false;this.callFlash("StartUpload",[a])};SWFUpload.prototype.cancelQueue=function(){this.queueSettings.queue_cancelled_flag=true;this.stopUpload();var a=this.getStats();while(a.files_queued>0){this.cancelUpload();a=this.getStats()}};SWFUpload.queue.uploadStartHandler=function(a){var b;if(typeof(this.queueSettings.user_upload_start_handler)==="function"){b=this.queueSettings.user_upload_start_handler.call(this,a)}b=(b===false)?false:true;this.queueSettings.queue_cancelled_flag=!b;return b};SWFUpload.queue.uploadCompleteHandler=function(b){var c=this.queueSettings.user_upload_complete_handler,d,a;if(b.filestatus===SWFUpload.FILE_STATUS.COMPLETE){this.queueSettings.queue_upload_count++}if(typeof(c)==="function"){d=(c.call(this,b)===false)?false:true}else{if(b.filestatus===SWFUpload.FILE_STATUS.QUEUED){d=false}else{d=true}}if(d){a=this.getStats();if(a.files_queued>0&&this.queueSettings.queue_cancelled_flag===false){this.startUpload()}else{if(this.queueSettings.queue_cancelled_flag===false){this.queueEvent("queue_complete_handler",[this.queueSettings.queue_upload_count]);this.queueSettings.queue_upload_count=0}else{this.queueSettings.queue_cancelled_flag=false;this.queueSettings.queue_upload_count=0}}}}};
+// swfobject
+var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
+// swfupload.swfobject
+var SWFUpload;if(typeof(SWFUpload)==="function"){SWFUpload.onload=function(){};swfobject.addDomLoadEvent(function(){if(typeof(SWFUpload.onload)==="function"){SWFUpload.onload.call(window)}});SWFUpload.prototype.initSettings=(function(a){return function(){if(typeof(a)==="function"){a.call(this)}this.ensureDefault=function(c,b){this.settings[c]=(this.settings[c]==undefined)?b:this.settings[c]};this.ensureDefault("minimum_flash_version","9.0.28");this.ensureDefault("swfupload_pre_load_handler",null);this.ensureDefault("swfupload_load_failed_handler",null);delete this.ensureDefault}})(SWFUpload.prototype.initSettings);SWFUpload.prototype.loadFlash=function(a){return function(){var b=swfobject.hasFlashPlayerVersion(this.settings.minimum_flash_version);if(b){this.queueEvent("swfupload_pre_load_handler");if(typeof(a)==="function"){a.call(this)}}else{this.queueEvent("swfupload_load_failed_handler")}}}(SWFUpload.prototype.loadFlash)};
Index: /tags/3.1/wp-includes/js/swfupload/swfupload.js
===================================================================
--- /tags/3.1/wp-includes/js/swfupload/swfupload.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/swfupload/swfupload.js	(revision 17487)
@@ -0,0 +1,980 @@
+/**
+ * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
+ *
+ * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/,  http://www.vinterwebb.se/
+ *
+ * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ */
+
+
+/* ******************* */
+/* Constructor & Init  */
+/* ******************* */
+var SWFUpload;
+
+if (SWFUpload == undefined) {
+	SWFUpload = function (settings) {
+		this.initSWFUpload(settings);
+	};
+}
+
+SWFUpload.prototype.initSWFUpload = function (settings) {
+	try {
+		this.customSettings = {};	// A container where developers can place their own settings associated with this instance.
+		this.settings = settings;
+		this.eventQueue = [];
+		this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
+		this.movieElement = null;
+
+
+		// Setup global control tracking
+		SWFUpload.instances[this.movieName] = this;
+
+		// Load the settings.  Load the Flash movie.
+		this.initSettings();
+		this.loadFlash();
+		this.displayDebugInfo();
+	} catch (ex) {
+		delete SWFUpload.instances[this.movieName];
+		throw ex;
+	}
+};
+
+/* *************** */
+/* Static Members  */
+/* *************** */
+SWFUpload.instances = {};
+SWFUpload.movieCount = 0;
+SWFUpload.version = "2.2.0 2009-03-25";
+SWFUpload.QUEUE_ERROR = {
+	QUEUE_LIMIT_EXCEEDED	  		: -100,
+	FILE_EXCEEDS_SIZE_LIMIT  		: -110,
+	ZERO_BYTE_FILE			  		: -120,
+	INVALID_FILETYPE		  		: -130
+};
+SWFUpload.UPLOAD_ERROR = {
+	HTTP_ERROR				  		: -200,
+	MISSING_UPLOAD_URL	      		: -210,
+	IO_ERROR				  		: -220,
+	SECURITY_ERROR			  		: -230,
+	UPLOAD_LIMIT_EXCEEDED	  		: -240,
+	UPLOAD_FAILED			  		: -250,
+	SPECIFIED_FILE_ID_NOT_FOUND		: -260,
+	FILE_VALIDATION_FAILED	  		: -270,
+	FILE_CANCELLED			  		: -280,
+	UPLOAD_STOPPED					: -290
+};
+SWFUpload.FILE_STATUS = {
+	QUEUED		 : -1,
+	IN_PROGRESS	 : -2,
+	ERROR		 : -3,
+	COMPLETE	 : -4,
+	CANCELLED	 : -5
+};
+SWFUpload.BUTTON_ACTION = {
+	SELECT_FILE  : -100,
+	SELECT_FILES : -110,
+	START_UPLOAD : -120
+};
+SWFUpload.CURSOR = {
+	ARROW : -1,
+	HAND : -2
+};
+SWFUpload.WINDOW_MODE = {
+	WINDOW : "window",
+	TRANSPARENT : "transparent",
+	OPAQUE : "opaque"
+};
+
+// Private: takes a URL, determines if it is relative and converts to an absolute URL
+// using the current site. Only processes the URL if it can, otherwise returns the URL untouched
+SWFUpload.completeURL = function(url) {
+	if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
+		return url;
+	}
+	
+	var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
+	
+	var indexSlash = window.location.pathname.lastIndexOf("/");
+	if (indexSlash <= 0) {
+		path = "/";
+	} else {
+		path = window.location.pathname.substr(0, indexSlash) + "/";
+	}
+	
+	return /*currentURL +*/ path + url;
+	
+};
+
+
+/* ******************** */
+/* Instance Members  */
+/* ******************** */
+
+// Private: initSettings ensures that all the
+// settings are set, getting a default value if one was not assigned.
+SWFUpload.prototype.initSettings = function () {
+	this.ensureDefault = function (settingName, defaultValue) {
+		this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
+	};
+	
+	// Upload backend settings
+	this.ensureDefault("upload_url", "");
+	this.ensureDefault("preserve_relative_urls", false);
+	this.ensureDefault("file_post_name", "Filedata");
+	this.ensureDefault("post_params", {});
+	this.ensureDefault("use_query_string", false);
+	this.ensureDefault("requeue_on_error", false);
+	this.ensureDefault("http_success", []);
+	this.ensureDefault("assume_success_timeout", 0);
+	
+	// File Settings
+	this.ensureDefault("file_types", "*.*");
+	this.ensureDefault("file_types_description", "All Files");
+	this.ensureDefault("file_size_limit", 0);	// Default zero means "unlimited"
+	this.ensureDefault("file_upload_limit", 0);
+	this.ensureDefault("file_queue_limit", 0);
+
+	// Flash Settings
+	this.ensureDefault("flash_url", "swfupload.swf");
+	this.ensureDefault("prevent_swf_caching", true);
+	
+	// Button Settings
+	this.ensureDefault("button_image_url", "");
+	this.ensureDefault("button_width", 1);
+	this.ensureDefault("button_height", 1);
+	this.ensureDefault("button_text", "");
+	this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
+	this.ensureDefault("button_text_top_padding", 0);
+	this.ensureDefault("button_text_left_padding", 0);
+	this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
+	this.ensureDefault("button_disabled", false);
+	this.ensureDefault("button_placeholder_id", "");
+	this.ensureDefault("button_placeholder", null);
+	this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
+	this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
+	
+	// Debug Settings
+	this.ensureDefault("debug", false);
+	this.settings.debug_enabled = this.settings.debug;	// Here to maintain v2 API
+	
+	// Event Handlers
+	this.settings.return_upload_start_handler = this.returnUploadStart;
+	this.ensureDefault("swfupload_loaded_handler", null);
+	this.ensureDefault("file_dialog_start_handler", null);
+	this.ensureDefault("file_queued_handler", null);
+	this.ensureDefault("file_queue_error_handler", null);
+	this.ensureDefault("file_dialog_complete_handler", null);
+	
+	this.ensureDefault("upload_start_handler", null);
+	this.ensureDefault("upload_progress_handler", null);
+	this.ensureDefault("upload_error_handler", null);
+	this.ensureDefault("upload_success_handler", null);
+	this.ensureDefault("upload_complete_handler", null);
+	
+	this.ensureDefault("debug_handler", this.debugMessage);
+
+	this.ensureDefault("custom_settings", {});
+
+	// Other settings
+	this.customSettings = this.settings.custom_settings;
+	
+	// Update the flash url if needed
+	if (!!this.settings.prevent_swf_caching) {
+		this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
+	}
+	
+	if (!this.settings.preserve_relative_urls) {
+		//this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url);	// Don't need to do this one since flash doesn't look at it
+		this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
+		this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
+	}
+	
+	delete this.ensureDefault;
+};
+
+// Private: loadFlash replaces the button_placeholder element with the flash movie.
+SWFUpload.prototype.loadFlash = function () {
+	var targetElement, tempParent;
+
+	// Make sure an element with the ID we are going to use doesn't already exist
+	if (document.getElementById(this.movieName) !== null) {
+		throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
+	}
+
+	// Get the element where we will be placing the flash movie
+	targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
+
+	if (targetElement == undefined) {
+		throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
+	}
+
+	// Append the container and load the flash
+	tempParent = document.createElement("div");
+	tempParent.innerHTML = this.getFlashHTML();	// Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
+	targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
+
+	// Fix IE Flash/Form bug
+	if (window[this.movieName] == undefined) {
+		window[this.movieName] = this.getMovieElement();
+	}
+	
+};
+
+// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
+SWFUpload.prototype.getFlashHTML = function () {
+	// Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
+	return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
+				'<param name="wmode" value="', this.settings.button_window_mode, '" />',
+				'<param name="movie" value="', this.settings.flash_url, '" />',
+				'<param name="quality" value="high" />',
+				'<param name="menu" value="false" />',
+				'<param name="allowScriptAccess" value="always" />',
+				'<param name="flashvars" value="' + this.getFlashVars() + '" />',
+				'</object>'].join("");
+};
+
+// Private: getFlashVars builds the parameter string that will be passed
+// to flash in the flashvars param.
+SWFUpload.prototype.getFlashVars = function () {
+	// Build a string from the post param object
+	var paramString = this.buildParamString();
+	var httpSuccessString = this.settings.http_success.join(",");
+	
+	// Build the parameter string
+	return ["movieName=", encodeURIComponent(this.movieName),
+			"&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
+			"&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
+			"&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
+			"&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
+			"&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
+			"&amp;params=", encodeURIComponent(paramString),
+			"&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
+			"&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
+			"&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
+			"&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
+			"&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
+			"&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
+			"&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
+			"&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
+			"&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
+			"&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
+			"&amp;buttonText=", encodeURIComponent(this.settings.button_text),
+			"&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
+			"&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
+			"&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
+			"&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
+			"&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
+			"&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
+		].join("");
+};
+
+// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
+// The element is cached after the first lookup
+SWFUpload.prototype.getMovieElement = function () {
+	if (this.movieElement == undefined) {
+		this.movieElement = document.getElementById(this.movieName);
+	}
+
+	if (this.movieElement === null) {
+		throw "Could not find Flash element";
+	}
+	
+	return this.movieElement;
+};
+
+// Private: buildParamString takes the name/value pairs in the post_params setting object
+// and joins them up in to a string formatted "name=value&amp;name=value"
+SWFUpload.prototype.buildParamString = function () {
+	var postParams = this.settings.post_params; 
+	var paramStringPairs = [];
+
+	if (typeof(postParams) === "object") {
+		for (var name in postParams) {
+			if (postParams.hasOwnProperty(name)) {
+				paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
+			}
+		}
+	}
+
+	return paramStringPairs.join("&amp;");
+};
+
+// Public: Used to remove a SWFUpload instance from the page. This method strives to remove
+// all references to the SWF, and other objects so memory is properly freed.
+// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
+// Credits: Major improvements provided by steffen
+SWFUpload.prototype.destroy = function () {
+	try {
+		// Make sure Flash is done before we try to remove it
+		this.cancelUpload(null, false);
+		
+
+		// Remove the SWFUpload DOM nodes
+		var movieElement = null;
+		movieElement = this.getMovieElement();
+		
+		if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
+			// Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
+			for (var i in movieElement) {
+				try {
+					if (typeof(movieElement[i]) === "function") {
+						movieElement[i] = null;
+					}
+				} catch (ex1) {}
+			}
+
+			// Remove the Movie Element from the page
+			try {
+				movieElement.parentNode.removeChild(movieElement);
+			} catch (ex) {}
+		}
+		
+		// Remove IE form fix reference
+		window[this.movieName] = null;
+
+		// Destroy other references
+		SWFUpload.instances[this.movieName] = null;
+		delete SWFUpload.instances[this.movieName];
+
+		this.movieElement = null;
+		this.settings = null;
+		this.customSettings = null;
+		this.eventQueue = null;
+		this.movieName = null;
+		
+		
+		return true;
+	} catch (ex2) {
+		return false;
+	}
+};
+
+
+// Public: displayDebugInfo prints out settings and configuration
+// information about this SWFUpload instance.
+// This function (and any references to it) can be deleted when placing
+// SWFUpload in production.
+SWFUpload.prototype.displayDebugInfo = function () {
+	this.debug(
+		[
+			"---SWFUpload Instance Info---\n",
+			"Version: ", SWFUpload.version, "\n",
+			"Movie Name: ", this.movieName, "\n",
+			"Settings:\n",
+			"\t", "upload_url:               ", this.settings.upload_url, "\n",
+			"\t", "flash_url:                ", this.settings.flash_url, "\n",
+			"\t", "use_query_string:         ", this.settings.use_query_string.toString(), "\n",
+			"\t", "requeue_on_error:         ", this.settings.requeue_on_error.toString(), "\n",
+			"\t", "http_success:             ", this.settings.http_success.join(", "), "\n",
+			"\t", "assume_success_timeout:   ", this.settings.assume_success_timeout, "\n",
+			"\t", "file_post_name:           ", this.settings.file_post_name, "\n",
+			"\t", "post_params:              ", this.settings.post_params.toString(), "\n",
+			"\t", "file_types:               ", this.settings.file_types, "\n",
+			"\t", "file_types_description:   ", this.settings.file_types_description, "\n",
+			"\t", "file_size_limit:          ", this.settings.file_size_limit, "\n",
+			"\t", "file_upload_limit:        ", this.settings.file_upload_limit, "\n",
+			"\t", "file_queue_limit:         ", this.settings.file_queue_limit, "\n",
+			"\t", "debug:                    ", this.settings.debug.toString(), "\n",
+
+			"\t", "prevent_swf_caching:      ", this.settings.prevent_swf_caching.toString(), "\n",
+
+			"\t", "button_placeholder_id:    ", this.settings.button_placeholder_id.toString(), "\n",
+			"\t", "button_placeholder:       ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
+			"\t", "button_image_url:         ", this.settings.button_image_url.toString(), "\n",
+			"\t", "button_width:             ", this.settings.button_width.toString(), "\n",
+			"\t", "button_height:            ", this.settings.button_height.toString(), "\n",
+			"\t", "button_text:              ", this.settings.button_text.toString(), "\n",
+			"\t", "button_text_style:        ", this.settings.button_text_style.toString(), "\n",
+			"\t", "button_text_top_padding:  ", this.settings.button_text_top_padding.toString(), "\n",
+			"\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
+			"\t", "button_action:            ", this.settings.button_action.toString(), "\n",
+			"\t", "button_disabled:          ", this.settings.button_disabled.toString(), "\n",
+
+			"\t", "custom_settings:          ", this.settings.custom_settings.toString(), "\n",
+			"Event Handlers:\n",
+			"\t", "swfupload_loaded_handler assigned:  ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
+			"\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
+			"\t", "file_queued_handler assigned:       ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
+			"\t", "file_queue_error_handler assigned:  ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
+			"\t", "upload_start_handler assigned:      ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
+			"\t", "upload_progress_handler assigned:   ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
+			"\t", "upload_error_handler assigned:      ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
+			"\t", "upload_success_handler assigned:    ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
+			"\t", "upload_complete_handler assigned:   ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
+			"\t", "debug_handler assigned:             ", (typeof this.settings.debug_handler === "function").toString(), "\n"
+		].join("")
+	);
+};
+
+/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
+	the maintain v2 API compatibility
+*/
+// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
+SWFUpload.prototype.addSetting = function (name, value, default_value) {
+    if (value == undefined) {
+        return (this.settings[name] = default_value);
+    } else {
+        return (this.settings[name] = value);
+	}
+};
+
+// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
+SWFUpload.prototype.getSetting = function (name) {
+    if (this.settings[name] != undefined) {
+        return this.settings[name];
+	}
+
+    return "";
+};
+
+
+
+// Private: callFlash handles function calls made to the Flash element.
+// Calls are made with a setTimeout for some functions to work around
+// bugs in the ExternalInterface library.
+SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
+	argumentArray = argumentArray || [];
+	
+	var movieElement = this.getMovieElement();
+	var returnValue, returnString;
+
+	// Flash's method if calling ExternalInterface methods (code adapted from MooTools).
+	try {
+		returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
+		returnValue = eval(returnString);
+	} catch (ex) {
+		throw "Call to " + functionName + " failed";
+	}
+	
+	// Unescape file post param values
+	if (returnValue != undefined && typeof returnValue.post === "object") {
+		returnValue = this.unescapeFilePostParams(returnValue);
+	}
+
+	return returnValue;
+};
+
+/* *****************************
+	-- Flash control methods --
+	Your UI should use these
+	to operate SWFUpload
+   ***************************** */
+
+// WARNING: this function does not work in Flash Player 10
+// Public: selectFile causes a File Selection Dialog window to appear.  This
+// dialog only allows 1 file to be selected.
+SWFUpload.prototype.selectFile = function () {
+	this.callFlash("SelectFile");
+};
+
+// WARNING: this function does not work in Flash Player 10
+// Public: selectFiles causes a File Selection Dialog window to appear/ This
+// dialog allows the user to select any number of files
+// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
+// If the selection name length is too long the dialog will fail in an unpredictable manner.  There is no work-around
+// for this bug.
+SWFUpload.prototype.selectFiles = function () {
+	this.callFlash("SelectFiles");
+};
+
+
+// Public: startUpload starts uploading the first file in the queue unless
+// the optional parameter 'fileID' specifies the ID 
+SWFUpload.prototype.startUpload = function (fileID) {
+	this.callFlash("StartUpload", [fileID]);
+};
+
+// Public: cancelUpload cancels any queued file.  The fileID parameter may be the file ID or index.
+// If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
+// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
+SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
+	if (triggerErrorEvent !== false) {
+		triggerErrorEvent = true;
+	}
+	this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
+};
+
+// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
+// If nothing is currently uploading then nothing happens.
+SWFUpload.prototype.stopUpload = function () {
+	this.callFlash("StopUpload");
+};
+
+/* ************************
+ * Settings methods
+ *   These methods change the SWFUpload settings.
+ *   SWFUpload settings should not be changed directly on the settings object
+ *   since many of the settings need to be passed to Flash in order to take
+ *   effect.
+ * *********************** */
+
+// Public: getStats gets the file statistics object.
+SWFUpload.prototype.getStats = function () {
+	return this.callFlash("GetStats");
+};
+
+// Public: setStats changes the SWFUpload statistics.  You shouldn't need to 
+// change the statistics but you can.  Changing the statistics does not
+// affect SWFUpload accept for the successful_uploads count which is used
+// by the upload_limit setting to determine how many files the user may upload.
+SWFUpload.prototype.setStats = function (statsObject) {
+	this.callFlash("SetStats", [statsObject]);
+};
+
+// Public: getFile retrieves a File object by ID or Index.  If the file is
+// not found then 'null' is returned.
+SWFUpload.prototype.getFile = function (fileID) {
+	if (typeof(fileID) === "number") {
+		return this.callFlash("GetFileByIndex", [fileID]);
+	} else {
+		return this.callFlash("GetFile", [fileID]);
+	}
+};
+
+// Public: addFileParam sets a name/value pair that will be posted with the
+// file specified by the Files ID.  If the name already exists then the
+// exiting value will be overwritten.
+SWFUpload.prototype.addFileParam = function (fileID, name, value) {
+	return this.callFlash("AddFileParam", [fileID, name, value]);
+};
+
+// Public: removeFileParam removes a previously set (by addFileParam) name/value
+// pair from the specified file.
+SWFUpload.prototype.removeFileParam = function (fileID, name) {
+	this.callFlash("RemoveFileParam", [fileID, name]);
+};
+
+// Public: setUploadUrl changes the upload_url setting.
+SWFUpload.prototype.setUploadURL = function (url) {
+	this.settings.upload_url = url.toString();
+	this.callFlash("SetUploadURL", [url]);
+};
+
+// Public: setPostParams changes the post_params setting
+SWFUpload.prototype.setPostParams = function (paramsObject) {
+	this.settings.post_params = paramsObject;
+	this.callFlash("SetPostParams", [paramsObject]);
+};
+
+// Public: addPostParam adds post name/value pair.  Each name can have only one value.
+SWFUpload.prototype.addPostParam = function (name, value) {
+	this.settings.post_params[name] = value;
+	this.callFlash("SetPostParams", [this.settings.post_params]);
+};
+
+// Public: removePostParam deletes post name/value pair.
+SWFUpload.prototype.removePostParam = function (name) {
+	delete this.settings.post_params[name];
+	this.callFlash("SetPostParams", [this.settings.post_params]);
+};
+
+// Public: setFileTypes changes the file_types setting and the file_types_description setting
+SWFUpload.prototype.setFileTypes = function (types, description) {
+	this.settings.file_types = types;
+	this.settings.file_types_description = description;
+	this.callFlash("SetFileTypes", [types, description]);
+};
+
+// Public: setFileSizeLimit changes the file_size_limit setting
+SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
+	this.settings.file_size_limit = fileSizeLimit;
+	this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
+};
+
+// Public: setFileUploadLimit changes the file_upload_limit setting
+SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
+	this.settings.file_upload_limit = fileUploadLimit;
+	this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
+};
+
+// Public: setFileQueueLimit changes the file_queue_limit setting
+SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
+	this.settings.file_queue_limit = fileQueueLimit;
+	this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
+};
+
+// Public: setFilePostName changes the file_post_name setting
+SWFUpload.prototype.setFilePostName = function (filePostName) {
+	this.settings.file_post_name = filePostName;
+	this.callFlash("SetFilePostName", [filePostName]);
+};
+
+// Public: setUseQueryString changes the use_query_string setting
+SWFUpload.prototype.setUseQueryString = function (useQueryString) {
+	this.settings.use_query_string = useQueryString;
+	this.callFlash("SetUseQueryString", [useQueryString]);
+};
+
+// Public: setRequeueOnError changes the requeue_on_error setting
+SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
+	this.settings.requeue_on_error = requeueOnError;
+	this.callFlash("SetRequeueOnError", [requeueOnError]);
+};
+
+// Public: setHTTPSuccess changes the http_success setting
+SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
+	if (typeof http_status_codes === "string") {
+		http_status_codes = http_status_codes.replace(" ", "").split(",");
+	}
+	
+	this.settings.http_success = http_status_codes;
+	this.callFlash("SetHTTPSuccess", [http_status_codes]);
+};
+
+// Public: setHTTPSuccess changes the http_success setting
+SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
+	this.settings.assume_success_timeout = timeout_seconds;
+	this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
+};
+
+// Public: setDebugEnabled changes the debug_enabled setting
+SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
+	this.settings.debug_enabled = debugEnabled;
+	this.callFlash("SetDebugEnabled", [debugEnabled]);
+};
+
+// Public: setButtonImageURL loads a button image sprite
+SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
+	if (buttonImageURL == undefined) {
+		buttonImageURL = "";
+	}
+	
+	this.settings.button_image_url = buttonImageURL;
+	this.callFlash("SetButtonImageURL", [buttonImageURL]);
+};
+
+// Public: setButtonDimensions resizes the Flash Movie and button
+SWFUpload.prototype.setButtonDimensions = function (width, height) {
+	this.settings.button_width = width;
+	this.settings.button_height = height;
+	
+	var movie = this.getMovieElement();
+	if (movie != undefined) {
+		movie.style.width = width + "px";
+		movie.style.height = height + "px";
+	}
+	
+	this.callFlash("SetButtonDimensions", [width, height]);
+};
+// Public: setButtonText Changes the text overlaid on the button
+SWFUpload.prototype.setButtonText = function (html) {
+	this.settings.button_text = html;
+	this.callFlash("SetButtonText", [html]);
+};
+// Public: setButtonTextPadding changes the top and left padding of the text overlay
+SWFUpload.prototype.setButtonTextPadding = function (left, top) {
+	this.settings.button_text_top_padding = top;
+	this.settings.button_text_left_padding = left;
+	this.callFlash("SetButtonTextPadding", [left, top]);
+};
+
+// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
+SWFUpload.prototype.setButtonTextStyle = function (css) {
+	this.settings.button_text_style = css;
+	this.callFlash("SetButtonTextStyle", [css]);
+};
+// Public: setButtonDisabled disables/enables the button
+SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
+	this.settings.button_disabled = isDisabled;
+	this.callFlash("SetButtonDisabled", [isDisabled]);
+};
+// Public: setButtonAction sets the action that occurs when the button is clicked
+SWFUpload.prototype.setButtonAction = function (buttonAction) {
+	this.settings.button_action = buttonAction;
+	this.callFlash("SetButtonAction", [buttonAction]);
+};
+
+// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
+SWFUpload.prototype.setButtonCursor = function (cursor) {
+	this.settings.button_cursor = cursor;
+	this.callFlash("SetButtonCursor", [cursor]);
+};
+
+/* *******************************
+	Flash Event Interfaces
+	These functions are used by Flash to trigger the various
+	events.
+	
+	All these functions a Private.
+	
+	Because the ExternalInterface library is buggy the event calls
+	are added to a queue and the queue then executed by a setTimeout.
+	This ensures that events are executed in a determinate order and that
+	the ExternalInterface bugs are avoided.
+******************************* */
+
+SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
+	// Warning: Don't call this.debug inside here or you'll create an infinite loop
+	
+	if (argumentArray == undefined) {
+		argumentArray = [];
+	} else if (!(argumentArray instanceof Array)) {
+		argumentArray = [argumentArray];
+	}
+	
+	var self = this;
+	if (typeof this.settings[handlerName] === "function") {
+		// Queue the event
+		this.eventQueue.push(function () {
+			this.settings[handlerName].apply(this, argumentArray);
+		});
+		
+		// Execute the next queued event
+		setTimeout(function () {
+			self.executeNextEvent();
+		}, 0);
+		
+	} else if (this.settings[handlerName] !== null) {
+		throw "Event handler " + handlerName + " is unknown or is not a function";
+	}
+};
+
+// Private: Causes the next event in the queue to be executed.  Since events are queued using a setTimeout
+// we must queue them in order to garentee that they are executed in order.
+SWFUpload.prototype.executeNextEvent = function () {
+	// Warning: Don't call this.debug inside here or you'll create an infinite loop
+
+	var  f = this.eventQueue ? this.eventQueue.shift() : null;
+	if (typeof(f) === "function") {
+		f.apply(this);
+	}
+};
+
+// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
+// properties that contain characters that are not valid for JavaScript identifiers. To work around this
+// the Flash Component escapes the parameter names and we must unescape again before passing them along.
+SWFUpload.prototype.unescapeFilePostParams = function (file) {
+	var reg = /[$]([0-9a-f]{4})/i;
+	var unescapedPost = {};
+	var uk;
+
+	if (file != undefined) {
+		for (var k in file.post) {
+			if (file.post.hasOwnProperty(k)) {
+				uk = k;
+				var match;
+				while ((match = reg.exec(uk)) !== null) {
+					uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
+				}
+				unescapedPost[uk] = file.post[k];
+			}
+		}
+
+		file.post = unescapedPost;
+	}
+
+	return file;
+};
+
+// Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
+SWFUpload.prototype.testExternalInterface = function () {
+	try {
+		return this.callFlash("TestExternalInterface");
+	} catch (ex) {
+		return false;
+	}
+};
+
+// Private: This event is called by Flash when it has finished loading. Don't modify this.
+// Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
+SWFUpload.prototype.flashReady = function () {
+	// Check that the movie element is loaded correctly with its ExternalInterface methods defined
+	var movieElement = this.getMovieElement();
+
+	if (!movieElement) {
+		this.debug("Flash called back ready but the flash movie can't be found.");
+		return;
+	}
+
+	this.cleanUp(movieElement);
+	
+	this.queueEvent("swfupload_loaded_handler");
+};
+
+// Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
+// This function is called by Flash each time the ExternalInterface functions are created.
+SWFUpload.prototype.cleanUp = function (movieElement) {
+	// Pro-actively unhook all the Flash functions
+	try {
+		if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
+			this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
+			for (var key in movieElement) {
+				try {
+					if (typeof(movieElement[key]) === "function") {
+						movieElement[key] = null;
+					}
+				} catch (ex) {
+				}
+			}
+		}
+	} catch (ex1) {
+	
+	}
+
+	// Fix Flashes own cleanup code so if the SWFMovie was removed from the page
+	// it doesn't display errors.
+	window["__flash__removeCallback"] = function (instance, name) {
+		try {
+			if (instance) {
+				instance[name] = null;
+			}
+		} catch (flashEx) {
+		
+		}
+	};
+
+};
+
+
+/* This is a chance to do something before the browse window opens */
+SWFUpload.prototype.fileDialogStart = function () {
+	this.queueEvent("file_dialog_start_handler");
+};
+
+
+/* Called when a file is successfully added to the queue. */
+SWFUpload.prototype.fileQueued = function (file) {
+	file = this.unescapeFilePostParams(file);
+	this.queueEvent("file_queued_handler", file);
+};
+
+
+/* Handle errors that occur when an attempt to queue a file fails. */
+SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
+	file = this.unescapeFilePostParams(file);
+	this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
+};
+
+/* Called after the file dialog has closed and the selected files have been queued.
+	You could call startUpload here if you want the queued files to begin uploading immediately. */
+SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
+	this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
+};
+
+SWFUpload.prototype.uploadStart = function (file) {
+	file = this.unescapeFilePostParams(file);
+	this.queueEvent("return_upload_start_handler", file);
+};
+
+SWFUpload.prototype.returnUploadStart = function (file) {
+	var returnValue;
+	if (typeof this.settings.upload_start_handler === "function") {
+		file = this.unescapeFilePostParams(file);
+		returnValue = this.settings.upload_start_handler.call(this, file);
+	} else if (this.settings.upload_start_handler != undefined) {
+		throw "upload_start_handler must be a function";
+	}
+
+	// Convert undefined to true so if nothing is returned from the upload_start_handler it is
+	// interpretted as 'true'.
+	if (returnValue === undefined) {
+		returnValue = true;
+	}
+	
+	returnValue = !!returnValue;
+	
+	this.callFlash("ReturnUploadStart", [returnValue]);
+};
+
+
+
+SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
+	file = this.unescapeFilePostParams(file);
+	this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
+};
+
+SWFUpload.prototype.uploadError = function (file, errorCode, message) {
+	file = this.unescapeFilePostParams(file);
+	this.queueEvent("upload_error_handler", [file, errorCode, message]);
+};
+
+SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
+	file = this.unescapeFilePostParams(file);
+	this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
+};
+
+SWFUpload.prototype.uploadComplete = function (file) {
+	file = this.unescapeFilePostParams(file);
+	this.queueEvent("upload_complete_handler", file);
+};
+
+/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
+   internal debug console.  You can override this event and have messages written where you want. */
+SWFUpload.prototype.debug = function (message) {
+	this.queueEvent("debug_handler", message);
+};
+
+
+/* **********************************
+	Debug Console
+	The debug console is a self contained, in page location
+	for debug message to be sent.  The Debug Console adds
+	itself to the body if necessary.
+
+	The console is automatically scrolled as messages appear.
+	
+	If you are using your own debug handler or when you deploy to production and
+	have debug disabled you can remove these functions to reduce the file size
+	and complexity.
+********************************** */
+   
+// Private: debugMessage is the default debug_handler.  If you want to print debug messages
+// call the debug() function.  When overriding the function your own function should
+// check to see if the debug setting is true before outputting debug information.
+SWFUpload.prototype.debugMessage = function (message) {
+	if (this.settings.debug) {
+		var exceptionMessage, exceptionValues = [];
+
+		// Check for an exception object and print it nicely
+		if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
+			for (var key in message) {
+				if (message.hasOwnProperty(key)) {
+					exceptionValues.push(key + ": " + message[key]);
+				}
+			}
+			exceptionMessage = exceptionValues.join("\n") || "";
+			exceptionValues = exceptionMessage.split("\n");
+			exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
+			SWFUpload.Console.writeLine(exceptionMessage);
+		} else {
+			SWFUpload.Console.writeLine(message);
+		}
+	}
+};
+
+SWFUpload.Console = {};
+SWFUpload.Console.writeLine = function (message) {
+	var console, documentForm;
+
+	try {
+		console = document.getElementById("SWFUpload_Console");
+
+		if (!console) {
+			documentForm = document.createElement("form");
+			document.getElementsByTagName("body")[0].appendChild(documentForm);
+
+			console = document.createElement("textarea");
+			console.id = "SWFUpload_Console";
+			console.style.fontFamily = "monospace";
+			console.setAttribute("wrap", "off");
+			console.wrap = "off";
+			console.style.overflow = "auto";
+			console.style.width = "700px";
+			console.style.height = "350px";
+			console.style.margin = "5px";
+			documentForm.appendChild(console);
+		}
+
+		console.value += message + "\n";
+
+		console.scrollTop = console.scrollHeight - console.clientHeight;
+	} catch (ex) {
+		alert("Exception: " + ex.name + " Message: " + ex.message);
+	}
+};
Index: /tags/3.1/wp-includes/js/thickbox/thickbox.css
===================================================================
--- /tags/3.1/wp-includes/js/thickbox/thickbox.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/thickbox/thickbox.css	(revision 17487)
@@ -0,0 +1,162 @@
+
+/* ----------------------------------------------------------------------------------------------------------------*/
+/* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/
+/* ----------------------------------------------------------------------------------------------------------------*/
+#TB_window {
+	font: 12px "Lucida Grande", Verdana, Arial, sans-serif;
+	color: #333333;
+}
+
+#TB_secondLine {
+	font: 10px "Lucida Grande", Verdana, Arial, sans-serif;
+	color:#666666;
+}
+
+#TB_window a:link {color: #666666;}
+#TB_window a:visited {color: #666666;}
+#TB_window a:hover {color: #000;}
+#TB_window a:active {color: #666666;}
+#TB_window a:focus{color: #666666;}
+
+/* ----------------------------------------------------------------------------------------------------------------*/
+/* ---------->>> thickbox settings <<<-----------------------------------------------------------------------------*/
+/* ----------------------------------------------------------------------------------------------------------------*/
+#TB_overlay {
+	position: fixed;
+	z-index:100;
+	top: 0px;
+	left: 0px;
+	height:100%;
+	width:100%;
+}
+
+.TB_overlayMacFFBGHack {background: url(macFFBgHack.png) repeat;}
+.TB_overlayBG {
+	background-color:#000;
+	-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";
+	filter:alpha(opacity=75);
+	-moz-opacity: 0.75;
+	opacity: 0.75;
+}
+
+* html #TB_overlay { /* ie6 hack */
+     position: absolute;
+     height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
+}
+
+#TB_window {
+	position: fixed;
+	background: #ffffff;
+	z-index: 102;
+	color:#000000;
+	display:none;
+	text-align:left;
+	top:50%;
+	left:50%;
+	border: 1px solid #555;
+	-moz-box-shadow: rgba(0,0,0,1) 0 4px 30px;
+	-webkit-box-shadow: rgba(0,0,0,1) 0 4px 30px;
+	-khtml-box-shadow: rgba(0,0,0,1) 0 4px 30px;
+	box-shadow: rgba(0,0,0,1) 0 4px 30px;
+}
+
+* html #TB_window { /* ie6 hack */
+position: absolute;
+margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
+}
+
+#TB_window img#TB_Image {
+	display:block;
+	margin: 15px 0 0 15px;
+	border-right: 1px solid #ccc;
+	border-bottom: 1px solid #ccc;
+	border-top: 1px solid #666;
+	border-left: 1px solid #666;
+}
+
+#TB_caption{
+	height:25px;
+	padding:7px 30px 10px 25px;
+	float:left;
+}
+
+#TB_closeWindow{
+	height:25px;
+	padding:11px 25px 10px 0;
+	float:right;
+}
+
+#TB_closeAjaxWindow{
+	padding:6px 10px 0;
+	text-align:right;
+	float:right;
+}
+
+#TB_ajaxWindowTitle{
+	float:left;
+	padding:6px 10px 0;
+}
+
+#TB_title{
+	background-color:#e8e8e8;
+	height:27px;
+}
+
+#TB_ajaxContent{
+	clear:both;
+	padding:2px 15px 15px 15px;
+	overflow:auto;
+	text-align:left;
+	line-height:1.4em;
+}
+
+#TB_ajaxContent.TB_modal{
+	padding:15px;
+}
+
+#TB_ajaxContent p{
+	padding:5px 0px 5px 0px;
+}
+
+#TB_load{
+	position: fixed;
+	display:none;
+	z-index:103;
+	top: 50%;
+	left: 50%;
+	background-color: #E8E8E8;
+	border: 1px solid #555;
+	margin: -45px 0pt 0pt -125px;
+	padding: 40px 15px 15px;
+}
+
+* html #TB_load { /* ie6 hack */
+position: absolute;
+margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
+}
+
+#TB_HideSelect{
+	z-index:99;
+	position:fixed;
+	top: 0;
+	left: 0;
+	background-color:#fff;
+	border:none;
+	filter:alpha(opacity=0);
+	-moz-opacity: 0;
+	opacity: 0;
+	height:100%;
+	width:100%;
+}
+
+* html #TB_HideSelect { /* ie6 hack */
+     position: absolute;
+     height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
+}
+
+#TB_iframeContent{
+	clear:both;
+	border:none;
+	margin-bottom:-1px;
+	_margin-bottom:1px;
+}
Index: /tags/3.1/wp-includes/js/thickbox/thickbox.js
===================================================================
--- /tags/3.1/wp-includes/js/thickbox/thickbox.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/thickbox/thickbox.js	(revision 17487)
@@ -0,0 +1,325 @@
+/*
+ * Thickbox 3.1 - One Box To Rule Them All.
+ * By Cody Lindley (http://www.codylindley.com)
+ * Copyright (c) 2007 cody lindley
+ * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
+*/
+
+if ( typeof tb_pathToImage != 'string' ) {
+	var tb_pathToImage = "../wp-includes/js/thickbox/loadingAnimation.gif";
+}
+if ( typeof tb_closeImage != 'string' ) {
+	var tb_closeImage = "../wp-includes/js/thickbox/tb-close.png";
+}
+
+/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
+
+//on page load call tb_init
+jQuery(document).ready(function(){
+	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
+	imgLoader = new Image();// preload image
+	imgLoader.src = tb_pathToImage;
+});
+
+//add thickbox to href & area elements that have a class of .thickbox
+function tb_init(domChunk){
+	jQuery(domChunk).live('click', tb_click);
+}
+
+function tb_click(){
+	var t = this.title || this.name || null;
+	var a = this.href || this.alt;
+	var g = this.rel || false;
+	tb_show(t,a,g);
+	this.blur();
+	return false;
+}
+
+function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
+
+	try {
+		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
+			jQuery("body","html").css({height: "100%", width: "100%"});
+			jQuery("html").css("overflow","hidden");
+			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
+				jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
+				jQuery("#TB_overlay").click(tb_remove);
+			}
+		}else{//all others
+			if(document.getElementById("TB_overlay") === null){
+				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
+				jQuery("#TB_overlay").click(tb_remove);
+			}
+		}
+
+		if(tb_detectMacXFF()){
+			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
+		}else{
+			jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
+		}
+
+		if(caption===null){caption="";}
+		jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
+		jQuery('#TB_load').show();//show loader
+
+		var baseURL;
+	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
+			baseURL = url.substr(0, url.indexOf("?"));
+	   }else{
+	   		baseURL = url;
+	   }
+
+	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
+	   var urlType = baseURL.toLowerCase().match(urlString);
+
+		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
+
+			TB_PrevCaption = "";
+			TB_PrevURL = "";
+			TB_PrevHTML = "";
+			TB_NextCaption = "";
+			TB_NextURL = "";
+			TB_NextHTML = "";
+			TB_imageCount = "";
+			TB_FoundURL = false;
+			if(imageGroup){
+				TB_TempArray = jQuery("a[rel="+imageGroup+"]").get();
+				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
+					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
+						if (!(TB_TempArray[TB_Counter].href == url)) {
+							if (TB_FoundURL) {
+								TB_NextCaption = TB_TempArray[TB_Counter].title;
+								TB_NextURL = TB_TempArray[TB_Counter].href;
+								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>"+thickboxL10n.next+"</a></span>";
+							} else {
+								TB_PrevCaption = TB_TempArray[TB_Counter].title;
+								TB_PrevURL = TB_TempArray[TB_Counter].href;
+								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>"+thickboxL10n.prev+"</a></span>";
+							}
+						} else {
+							TB_FoundURL = true;
+							TB_imageCount = thickboxL10n.image + ' ' + (TB_Counter + 1) + ' ' + thickboxL10n.of + ' ' + (TB_TempArray.length);
+						}
+				}
+			}
+
+			imgPreloader = new Image();
+			imgPreloader.onload = function(){
+			imgPreloader.onload = null;
+
+			// Resizing large images - orginal by Christian Montoya edited by me.
+			var pagesize = tb_getPageSize();
+			var x = pagesize[0] - 150;
+			var y = pagesize[1] - 150;
+			var imageWidth = imgPreloader.width;
+			var imageHeight = imgPreloader.height;
+			if (imageWidth > x) {
+				imageHeight = imageHeight * (x / imageWidth);
+				imageWidth = x;
+				if (imageHeight > y) {
+					imageWidth = imageWidth * (y / imageHeight);
+					imageHeight = y;
+				}
+			} else if (imageHeight > y) {
+				imageWidth = imageWidth * (y / imageHeight);
+				imageHeight = y;
+				if (imageWidth > x) {
+					imageHeight = imageHeight * (x / imageWidth);
+					imageWidth = x;
+				}
+			}
+			// End Resizing
+
+			TB_WIDTH = imageWidth + 30;
+			TB_HEIGHT = imageHeight + 60;
+			jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='"+thickboxL10n.close+"'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='"+thickboxL10n.close+"'><img src='" + tb_closeImage + "' /></a></div>");
+
+			jQuery("#TB_closeWindowButton").click(tb_remove);
+
+			if (!(TB_PrevHTML === "")) {
+				function goPrev(){
+					if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);}
+					jQuery("#TB_window").remove();
+					jQuery("body").append("<div id='TB_window'></div>");
+					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
+					return false;
+				}
+				jQuery("#TB_prev").click(goPrev);
+			}
+
+			if (!(TB_NextHTML === "")) {
+				function goNext(){
+					jQuery("#TB_window").remove();
+					jQuery("body").append("<div id='TB_window'></div>");
+					tb_show(TB_NextCaption, TB_NextURL, imageGroup);
+					return false;
+				}
+				jQuery("#TB_next").click(goNext);
+
+			}
+
+			document.onkeydown = function(e){
+				if (e == null) { // ie
+					keycode = event.keyCode;
+				} else { // mozilla
+					keycode = e.which;
+				}
+				if(keycode == 27){ // close
+					tb_remove();
+				} else if(keycode == 190){ // display previous image
+					if(!(TB_NextHTML == "")){
+						document.onkeydown = "";
+						goNext();
+					}
+				} else if(keycode == 188){ // display next image
+					if(!(TB_PrevHTML == "")){
+						document.onkeydown = "";
+						goPrev();
+					}
+				}
+			};
+
+			tb_position();
+			jQuery("#TB_load").remove();
+			jQuery("#TB_ImageOff").click(tb_remove);
+			jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show
+			};
+
+			imgPreloader.src = url;
+		}else{//code to show html
+
+			var queryString = url.replace(/^[^\?]+\??/,'');
+			var params = tb_parseQuery( queryString );
+
+			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
+			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
+			ajaxContentW = TB_WIDTH - 30;
+			ajaxContentH = TB_HEIGHT - 45;
+
+			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
+					urlNoQuery = url.split('TB_');
+					jQuery("#TB_iframeContent").remove();
+					if(params['modal'] != "true"){//iframe no modal
+						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='"+thickboxL10n.close+"'><img src='" + tb_closeImage + "' /></a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' >"+thickboxL10n.noiframes+"</iframe>");
+					}else{//iframe modal
+					jQuery("#TB_overlay").unbind();
+						jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'>"+thickboxL10n.noiframes+"</iframe>");
+					}
+			}else{// not an iframe, ajax
+					if(jQuery("#TB_window").css("display") != "block"){
+						if(params['modal'] != "true"){//ajax no modal
+						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'><img src='" + tb_closeImage + "' /></a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
+						}else{//ajax modal
+						jQuery("#TB_overlay").unbind();
+						jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
+						}
+					}else{//this means the window is already up, we are just loading new content via ajax
+						jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
+						jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
+						jQuery("#TB_ajaxContent")[0].scrollTop = 0;
+						jQuery("#TB_ajaxWindowTitle").html(caption);
+					}
+			}
+
+			jQuery("#TB_closeWindowButton").click(tb_remove);
+
+				if(url.indexOf('TB_inline') != -1){
+					jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
+					jQuery("#TB_window").unload(function () {
+						jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
+					});
+					tb_position();
+					jQuery("#TB_load").remove();
+					jQuery("#TB_window").css({display:"block"});
+				}else if(url.indexOf('TB_iframe') != -1){
+					tb_position();
+					if(jQuery.browser.safari){//safari needs help because it will not fire iframe onload
+						jQuery("#TB_load").remove();
+						jQuery("#TB_window").css({display:"block"});
+					}
+				}else{
+					jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
+						tb_position();
+						jQuery("#TB_load").remove();
+						tb_init("#TB_ajaxContent a.thickbox");
+						jQuery("#TB_window").css({display:"block"});
+					});
+				}
+
+		}
+
+		if(!params['modal']){
+			document.onkeyup = function(e){
+				if (e == null) { // ie
+					keycode = event.keyCode;
+				} else { // mozilla
+					keycode = e.which;
+				}
+				if(keycode == 27){ // close
+					tb_remove();
+				}
+			};
+		}
+
+	} catch(e) {
+		//nothing here
+	}
+}
+
+//helper functions below
+function tb_showIframe(){
+	jQuery("#TB_load").remove();
+	jQuery("#TB_window").css({display:"block"});
+}
+
+function tb_remove() {
+ 	jQuery("#TB_imageOff").unbind("click");
+	jQuery("#TB_closeWindowButton").unbind("click");
+	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
+	jQuery("#TB_load").remove();
+	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
+		jQuery("body","html").css({height: "auto", width: "auto"});
+		jQuery("html").css("overflow","");
+	}
+	document.onkeydown = "";
+	document.onkeyup = "";
+	return false;
+}
+
+function tb_position() {
+var isIE6 = typeof document.body.style.maxHeight === "undefined";
+jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
+	if ( ! isIE6 ) { // take away IE6
+		jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
+	}
+}
+
+function tb_parseQuery ( query ) {
+   var Params = {};
+   if ( ! query ) {return Params;}// return empty object
+   var Pairs = query.split(/[;&]/);
+   for ( var i = 0; i < Pairs.length; i++ ) {
+      var KeyVal = Pairs[i].split('=');
+      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
+      var key = unescape( KeyVal[0] );
+      var val = unescape( KeyVal[1] );
+      val = val.replace(/\+/g, ' ');
+      Params[key] = val;
+   }
+   return Params;
+}
+
+function tb_getPageSize(){
+	var de = document.documentElement;
+	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
+	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
+	arrayPageSize = [w,h];
+	return arrayPageSize;
+}
+
+function tb_detectMacXFF() {
+  var userAgent = navigator.userAgent.toLowerCase();
+  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
+    return true;
+  }
+}
Index: /tags/3.1/wp-includes/js/tinymce/langs/wp-langs-en.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/langs/wp-langs-en.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/langs/wp-langs-en.js	(revision 17487)
@@ -0,0 +1,431 @@
+tinyMCE.addI18n({en:{
+common:{
+edit_confirm:"Do you want to use the WYSIWYG mode for this textarea?",
+apply:"Apply",
+insert:"Insert",
+update:"Update",
+cancel:"Cancel",
+close:"Close",
+browse:"Browse",
+class_name:"Class",
+not_set:"-- Not set --",
+clipboard_msg:"Copy/Cut/Paste is not available in Mozilla and Firefox.",
+clipboard_no_support:"Currently not supported by your browser, use keyboard shortcuts instead.",
+popup_blocked:"Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.",
+invalid_data:"Error: Invalid values entered, these are marked in red.",
+more_colors:"More colors"
+},
+contextmenu:{
+align:"Alignment",
+left:"Left",
+center:"Center",
+right:"Right",
+full:"Full"
+},
+insertdatetime:{
+date_fmt:"%Y-%m-%d",
+time_fmt:"%H:%M:%S",
+insertdate_desc:"Insert date",
+inserttime_desc:"Insert time",
+months_long:"January,February,March,April,May,June,July,August,September,October,November,December",
+months_short:"Jan_January_abbreviation,Feb_February_abbreviation,Mar_March_abbreviation,Apr_April_abbreviation,May_May_abbreviation,Jun_June_abbreviation,Jul_July_abbreviation,Aug_August_abbreviation,Sep_September_abbreviation,Oct_October_abbreviation,Nov_November_abbreviation,Dec_December_abbreviation",
+day_long:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",
+day_short:"Sun,Mon,Tue,Wed,Thu,Fri,Sat"
+},
+print:{
+print_desc:"Print"
+},
+preview:{
+preview_desc:"Preview"
+},
+directionality:{
+ltr_desc:"Direction left to right",
+rtl_desc:"Direction right to left"
+},
+layer:{
+insertlayer_desc:"Insert new layer",
+forward_desc:"Move forward",
+backward_desc:"Move backward",
+absolute_desc:"Toggle absolute positioning",
+content:"New layer..."
+},
+save:{
+save_desc:"Save",
+cancel_desc:"Cancel all changes"
+},
+nonbreaking:{
+nonbreaking_desc:"Insert non-breaking space character"
+},
+iespell:{
+iespell_desc:"Run spell checking",
+download:"ieSpell not detected. Do you want to install it now?"
+},
+advhr:{
+advhr_desc:"Horizontale rule"
+},
+emotions:{
+emotions_desc:"Emotions"
+},
+searchreplace:{
+search_desc:"Find",
+replace_desc:"Find/Replace"
+},
+advimage:{
+image_desc:"Insert/edit image"
+},
+advlink:{
+link_desc:"Insert/edit link"
+},
+xhtmlxtras:{
+cite_desc:"Citation",
+abbr_desc:"Abbreviation",
+acronym_desc:"Acronym",
+del_desc:"Deletion",
+ins_desc:"Insertion",
+attribs_desc:"Insert/Edit Attributes"
+},
+style:{
+desc:"Edit CSS Style"
+},
+paste:{
+paste_text_desc:"Paste as Plain Text",
+paste_word_desc:"Paste from Word",
+selectall_desc:"Select All"
+},
+paste_dlg:{
+text_title:"Use CTRL+V on your keyboard to paste the text into the window.",
+text_linebreaks:"Keep linebreaks",
+word_title:"Use CTRL+V on your keyboard to paste the text into the window."
+},
+table:{
+desc:"Inserts a new table",
+row_before_desc:"Insert row before",
+row_after_desc:"Insert row after",
+delete_row_desc:"Delete row",
+col_before_desc:"Insert column before",
+col_after_desc:"Insert column after",
+delete_col_desc:"Remove column",
+split_cells_desc:"Split merged table cells",
+merge_cells_desc:"Merge table cells",
+row_desc:"Table row properties",
+cell_desc:"Table cell properties",
+props_desc:"Table properties",
+paste_row_before_desc:"Paste table row before",
+paste_row_after_desc:"Paste table row after",
+cut_row_desc:"Cut table row",
+copy_row_desc:"Copy table row",
+del:"Delete table",
+row:"Row",
+col:"Column",
+cell:"Cell"
+},
+autosave:{
+unload_msg:"The changes you made will be lost if you navigate away from this page."
+},
+fullscreen:{
+desc:"Toggle fullscreen mode (Alt+Shift+G)"
+},
+media:{
+desc:"Insert / edit embedded media",
+delta_width:"0",
+delta_height:"0",
+edit:"Edit embedded media"
+},
+fullpage:{
+desc:"Document properties"
+},
+template:{
+desc:"Insert predefined template content"
+},
+visualchars:{
+desc:"Visual control characters on/off."
+},
+spellchecker:{
+desc:"Toggle spellchecker (Alt+Shift+N)",
+menu:"Spellchecker settings",
+ignore_word:"Ignore word",
+ignore_words:"Ignore all",
+langs:"Languages",
+wait:"Please wait...",
+sug:"Suggestions",
+no_sug:"No suggestions",
+no_mpell:"No misspellings found."
+},
+pagebreak:{
+desc:"Insert page break."
+}}});
+
+tinyMCE.addI18n("en.advanced",{
+style_select:"Styles",
+font_size:"Font size",
+fontdefault:"Font family",
+block:"Format",
+paragraph:"Paragraph",
+div:"Div",
+address:"Address",
+pre:"Preformatted",
+h1:"Heading 1",
+h2:"Heading 2",
+h3:"Heading 3",
+h4:"Heading 4",
+h5:"Heading 5",
+h6:"Heading 6",
+blockquote:"Blockquote",
+code:"Code",
+samp:"Code sample",
+dt:"Definition term ",
+dd:"Definition description",
+bold_desc:"Bold (Ctrl / Alt+Shift + B)",
+italic_desc:"Italic (Ctrl / Alt+Shift + I)",
+underline_desc:"Underline",
+striketrough_desc:"Strikethrough (Alt+Shift+D)",
+justifyleft_desc:"Align left (Alt+Shift+L)",
+justifycenter_desc:"Align center (Alt+Shift+C)",
+justifyright_desc:"Align right (Alt+Shift+R)",
+justifyfull_desc:"Align full (Alt+Shift+J)",
+bullist_desc:"Unordered list (Alt+Shift+U)",
+numlist_desc:"Ordered list (Alt+Shift+O)",
+outdent_desc:"Outdent",
+indent_desc:"Indent",
+undo_desc:"Undo (Ctrl+Z)",
+redo_desc:"Redo (Ctrl+Y)",
+link_desc:"Insert/edit link (Alt+Shift+A)",
+link_delta_width:"0",
+link_delta_height:"0",
+unlink_desc:"Unlink (Alt+Shift+S)",
+image_desc:"Insert/edit image (Alt+Shift+M)",
+image_delta_width:"0",
+image_delta_height:"0",
+cleanup_desc:"Cleanup messy code",
+code_desc:"Edit HTML Source",
+sub_desc:"Subscript",
+sup_desc:"Superscript",
+hr_desc:"Insert horizontal ruler",
+removeformat_desc:"Remove formatting",
+forecolor_desc:"Select text color",
+backcolor_desc:"Select background color",
+charmap_desc:"Insert custom character",
+visualaid_desc:"Toggle guidelines/invisible elements",
+anchor_desc:"Insert/edit anchor",
+cut_desc:"Cut",
+copy_desc:"Copy",
+paste_desc:"Paste",
+image_props_desc:"Image properties",
+newdocument_desc:"New document",
+help_desc:"Help",
+blockquote_desc:"Blockquote (Alt+Shift+Q)",
+clipboard_msg:"Copy/Cut/Paste is not available in Mozilla and Firefox.",
+path:"Path",
+newdocument:"Are you sure you want to clear all contents?",
+toolbar_focus:"Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X",
+more_colors:"More colors",
+colorpicker_delta_width:"0",
+colorpicker_delta_height:"0"
+});
+
+tinyMCE.addI18n("en.advanced_dlg",{
+about_title:"About TinyMCE",
+about_general:"About",
+about_help:"Help",
+about_license:"License",
+about_plugins:"Plugins",
+about_plugin:"Plugin",
+about_author:"Author",
+about_version:"Version",
+about_loaded:"Loaded plugins",
+anchor_title:"Insert/edit anchor",
+anchor_name:"Anchor name",
+code_title:"HTML Source Editor",
+code_wordwrap:"Word wrap",
+colorpicker_title:"Select a color",
+colorpicker_picker_tab:"Picker",
+colorpicker_picker_title:"Color picker",
+colorpicker_palette_tab:"Palette",
+colorpicker_palette_title:"Palette colors",
+colorpicker_named_tab:"Named",
+colorpicker_named_title:"Named colors",
+colorpicker_color:"Color:",
+colorpicker_name:"Name:",
+charmap_title:"Select custom character",
+image_title:"Insert/edit image",
+image_src:"Image URL",
+image_alt:"Image description",
+image_list:"Image list",
+image_border:"Border",
+image_dimensions:"Dimensions",
+image_vspace:"Vertical space",
+image_hspace:"Horizontal space",
+image_align:"Alignment",
+image_align_baseline:"Baseline",
+image_align_top:"Top",
+image_align_middle:"Middle",
+image_align_bottom:"Bottom",
+image_align_texttop:"Text top",
+image_align_textbottom:"Text bottom",
+image_align_left:"Left",
+image_align_right:"Right",
+link_title:"Insert/edit link",
+link_url:"Link URL",
+link_target:"Target",
+link_target_same:"Open link in the same window",
+link_target_blank:"Open link in a new window",
+link_titlefield:"Title",
+link_is_email:"The URL you entered seems to be an email address, do you want to add the required mailto: prefix?",
+link_is_external:"The URL you entered seems to external link, do you want to add the required http:// prefix?",
+link_list:"Link list"
+});
+
+tinyMCE.addI18n("en.media_dlg",{
+title:"Insert / edit embedded media",
+general:"General",
+advanced:"Advanced",
+file:"File/URL",
+list:"List",
+size:"Dimensions",
+preview:"Preview",
+constrain_proportions:"Constrain proportions",
+type:"Type",
+id:"Id",
+name:"Name",
+class_name:"Class",
+vspace:"V-Space",
+hspace:"H-Space",
+play:"Auto play",
+loop:"Loop",
+menu:"Show menu",
+quality:"Quality",
+scale:"Scale",
+align:"Align",
+salign:"SAlign",
+wmode:"WMode",
+bgcolor:"Background",
+base:"Base",
+flashvars:"Flashvars",
+liveconnect:"SWLiveConnect",
+autohref:"AutoHREF",
+cache:"Cache",
+hidden:"Hidden",
+controller:"Controller",
+kioskmode:"Kiosk mode",
+playeveryframe:"Play every frame",
+targetcache:"Target cache",
+correction:"No correction",
+enablejavascript:"Enable JavaScript",
+starttime:"Start time",
+endtime:"End time",
+href:"Href",
+qtsrcchokespeed:"Choke speed",
+target:"Target",
+volume:"Volume",
+autostart:"Auto start",
+enabled:"Enabled",
+fullscreen:"Fullscreen",
+invokeurls:"Invoke URLs",
+mute:"Mute",
+stretchtofit:"Stretch to fit",
+windowlessvideo:"Windowless video",
+balance:"Balance",
+baseurl:"Base URL",
+captioningid:"Captioning id",
+currentmarker:"Current marker",
+currentposition:"Current position",
+defaultframe:"Default frame",
+playcount:"Play count",
+rate:"Rate",
+uimode:"UI Mode",
+flash_options:"Flash options",
+qt_options:"Quicktime options",
+wmp_options:"Windows media player options",
+rmp_options:"Real media player options",
+shockwave_options:"Shockwave options",
+autogotourl:"Auto goto URL",
+center:"Center",
+imagestatus:"Image status",
+maintainaspect:"Maintain aspect",
+nojava:"No java",
+prefetch:"Prefetch",
+shuffle:"Shuffle",
+console:"Console",
+numloop:"Num loops",
+controls:"Controls",
+scriptcallbacks:"Script callbacks",
+swstretchstyle:"Stretch style",
+swstretchhalign:"Stretch H-Align",
+swstretchvalign:"Stretch V-Align",
+sound:"Sound",
+progress:"Progress",
+qtsrc:"QT Src",
+qt_stream_warn:"Streamed rtsp resources should be added to the QT Src field under the advanced tab.",
+align_top:"Top",
+align_right:"Right",
+align_bottom:"Bottom",
+align_left:"Left",
+align_center:"Center",
+align_top_left:"Top left",
+align_top_right:"Top right",
+align_bottom_left:"Bottom left",
+align_bottom_right:"Bottom right",
+flv_options:"Flash video options",
+flv_scalemode:"Scale mode",
+flv_buffer:"Buffer",
+flv_startimage:"Start image",
+flv_starttime:"Start time",
+flv_defaultvolume:"Default volume",
+flv_hiddengui:"Hidden GUI",
+flv_autostart:"Auto start",
+flv_loop:"Loop",
+flv_showscalemodes:"Show scale modes",
+flv_smoothvideo:"Smooth video",
+flv_jscallback:"JS Callback"
+});
+
+tinyMCE.addI18n("en.wordpress",{
+wp_adv_desc:"Show/Hide Kitchen Sink (Alt+Shift+Z)",
+wp_more_desc:"Insert More tag (Alt+Shift+T)",
+wp_page_desc:"Insert Page break (Alt+Shift+P)",
+wp_help_desc:"Help (Alt+Shift+H)",
+wp_more_alt:"More...",
+wp_page_alt:"Next page...",
+add_media:"Add Media",
+add_image:"Add an Image",
+add_video:"Add Video",
+add_audio:"Add Audio",
+editgallery:"Edit Gallery",
+delgallery:"Delete Gallery"
+});
+
+tinyMCE.addI18n("en.wpeditimage",{
+edit_img:"Edit Image",
+del_img:"Delete Image",
+adv_settings:"Advanced Settings",
+none:"None",
+size:"Size",
+thumbnail:"Thumbnail",
+medium:"Medium",
+full_size:"Full Size",
+current_link:"Current Link",
+link_to_img:"Link to Image",
+link_help:"Enter a link URL or click above for presets.",
+adv_img_settings:"Advanced Image Settings",
+source:"Source",
+width:"Width",
+height:"Height",
+orig_size:"Original Size",
+css:"CSS Class",
+adv_link_settings:"Advanced Link Settings",
+link_rel:"Link Rel",
+height:"Height",
+orig_size:"Original Size",
+css:"CSS Class",
+s60:"60%",
+s70:"70%",
+s80:"80%",
+s90:"90%",
+s100:"100%",
+s110:"110%",
+s120:"120%",
+s130:"130%",
+img_title:"Title",
+caption:"Caption",
+alt:"Alternate Text"
+});
Index: /tags/3.1/wp-includes/js/tinymce/langs/wp-langs.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/langs/wp-langs.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/langs/wp-langs.php	(revision 17487)
@@ -0,0 +1,455 @@
+<?php
+
+function mce_put_file( $path, $content ) {
+	if ( function_exists('file_put_contents') )
+		return @file_put_contents( $path, $content );
+
+	$newfile = false;
+	$fp = @fopen( $path, 'wb' );
+	if ($fp) {
+		$newfile = fwrite( $fp, $content );
+		fclose($fp);
+	}
+	return $newfile;
+}
+
+// escape text only if it needs translating
+function mce_escape($text) {
+	global $language;
+
+	if ( 'en' == $language ) return $text;
+	else return esc_js($text);
+}
+
+$lang = 'tinyMCE.addI18n({' . $language . ':{
+common:{
+edit_confirm:"' . mce_escape( __('Do you want to use the WYSIWYG mode for this textarea?') ) . '",
+apply:"' . mce_escape( __('Apply') ) . '",
+insert:"' . mce_escape( __('Insert') ) . '",
+update:"' . mce_escape( __('Update') ) . '",
+cancel:"' . mce_escape( __('Cancel') ) . '",
+close:"' . mce_escape( __('Close') ) . '",
+browse:"' . mce_escape( __('Browse') ) . '",
+class_name:"' . mce_escape( __('Class') ) . '",
+not_set:"' . mce_escape( __('-- Not set --') ) . '",
+clipboard_msg:"' . mce_escape( __('Copy/Cut/Paste is not available in Mozilla and Firefox.') ) . '",
+clipboard_no_support:"' . mce_escape( __('Currently not supported by your browser, use keyboard shortcuts instead.') ) . '",
+popup_blocked:"' . mce_escape( __('Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.') ) . '",
+invalid_data:"' . mce_escape( __('Error: Invalid values entered, these are marked in red.') ) . '",
+more_colors:"' . mce_escape( __('More colors') ) . '"
+},
+contextmenu:{
+align:"' . mce_escape( /* translators: alignment */ __('Alignment') ) . '",
+left:"' . mce_escape( /* translators: alignment */ __('Left') ) . '",
+center:"' . mce_escape( /* translators: alignment */ __('Center') ) . '",
+right:"' . mce_escape( /* translators: alignment */ __('Right') ) . '",
+full:"' . mce_escape( /* translators: alignment */ __('Full') ) . '"
+},
+insertdatetime:{
+date_fmt:"' . mce_escape( /* translators: year, month, date */ __('%Y-%m-%d') ) . '",
+time_fmt:"' . mce_escape( /* translators: hours, minutes, seconds */ __('%H:%M:%S') ) . '",
+insertdate_desc:"' . mce_escape( __('Insert date') ) . '",
+inserttime_desc:"' . mce_escape( __('Insert time') ) . '",
+months_long:"' . mce_escape( __('January').','.__('February').','.__('March').','.__('April').','.__('May').','.__('June').','.__('July').','.__('August').','.__('September').','.__('October').','.__('November').','.__('December') ) . '",
+months_short:"' . mce_escape( __('Jan_January_abbreviation').','.__('Feb_February_abbreviation').','.__('Mar_March_abbreviation').','.__('Apr_April_abbreviation').','.__('May_May_abbreviation').','.__('Jun_June_abbreviation').','.__('Jul_July_abbreviation').','.__('Aug_August_abbreviation').','.__('Sep_September_abbreviation').','.__('Oct_October_abbreviation').','.__('Nov_November_abbreviation').','.__('Dec_December_abbreviation') ) . '",
+day_long:"' . mce_escape( __('Sunday').','.__('Monday').','.__('Tuesday').','.__('Wednesday').','.__('Thursday').','.__('Friday').','.__('Saturday') ) . '",
+day_short:"' . mce_escape( __('Sun').','.__('Mon').','.__('Tue').','.__('Wed').','.__('Thu').','.__('Fri').','.__('Sat') ) . '"
+},
+print:{
+print_desc:"' . mce_escape( __('Print') ) . '"
+},
+preview:{
+preview_desc:"' . mce_escape( __('Preview') ) . '"
+},
+directionality:{
+ltr_desc:"' . mce_escape( __('Direction left to right') ) . '",
+rtl_desc:"' . mce_escape( __('Direction right to left') ) . '"
+},
+layer:{
+insertlayer_desc:"' . mce_escape( __('Insert new layer') ) . '",
+forward_desc:"' . mce_escape( __('Move forward') ) . '",
+backward_desc:"' . mce_escape( __('Move backward') ) . '",
+absolute_desc:"' . mce_escape( __('Toggle absolute positioning') ) . '",
+content:"' . mce_escape( __('New layer...') ) . '"
+},
+save:{
+save_desc:"' . mce_escape( __('Save') ) . '",
+cancel_desc:"' . mce_escape( __('Cancel all changes') ) . '"
+},
+nonbreaking:{
+nonbreaking_desc:"' . mce_escape( __('Insert non-breaking space character') ) . '"
+},
+iespell:{
+iespell_desc:"' . mce_escape( __('Run spell checking') ) . '",
+download:"' . mce_escape( __('ieSpell not detected. Do you want to install it now?') ) . '"
+},
+advhr:{
+advhr_desc:"' . mce_escape( __('Horizontale rule') ) . '"
+},
+emotions:{
+emotions_desc:"' . mce_escape( __('Emotions') ) . '"
+},
+searchreplace:{
+search_desc:"' . mce_escape( __('Find') ) . '",
+replace_desc:"' . mce_escape( __('Find/Replace') ) . '"
+},
+advimage:{
+image_desc:"' . mce_escape( __('Insert/edit image') ) . '"
+},
+advlink:{
+link_desc:"' . mce_escape( __('Insert/edit link') ) . '"
+},
+xhtmlxtras:{
+cite_desc:"' . mce_escape( __('Citation') ) . '",
+abbr_desc:"' . mce_escape( __('Abbreviation') ) . '",
+acronym_desc:"' . mce_escape( __('Acronym') ) . '",
+del_desc:"' . mce_escape( __('Deletion') ) . '",
+ins_desc:"' . mce_escape( __('Insertion') ) . '",
+attribs_desc:"' . mce_escape( __('Insert/Edit Attributes') ) . '"
+},
+style:{
+desc:"' . mce_escape( __('Edit CSS Style') ) . '"
+},
+paste:{
+paste_text_desc:"' . mce_escape( __('Paste as Plain Text') ) . '",
+paste_word_desc:"' . mce_escape( __('Paste from Word') ) . '",
+selectall_desc:"' . mce_escape( __('Select All') ) . '"
+},
+paste_dlg:{
+text_title:"' . mce_escape( __('Use CTRL+V on your keyboard to paste the text into the window.') ) . '",
+text_linebreaks:"' . mce_escape( __('Keep linebreaks') ) . '",
+word_title:"' . mce_escape( __('Use CTRL+V on your keyboard to paste the text into the window.') ) . '"
+},
+table:{
+desc:"' . mce_escape( __('Inserts a new table') ) . '",
+row_before_desc:"' . mce_escape( __('Insert row before') ) . '",
+row_after_desc:"' . mce_escape( __('Insert row after') ) . '",
+delete_row_desc:"' . mce_escape( __('Delete row') ) . '",
+col_before_desc:"' . mce_escape( __('Insert column before') ) . '",
+col_after_desc:"' . mce_escape( __('Insert column after') ) . '",
+delete_col_desc:"' . mce_escape( __('Remove column') ) . '",
+split_cells_desc:"' . mce_escape( __('Split merged table cells') ) . '",
+merge_cells_desc:"' . mce_escape( __('Merge table cells') ) . '",
+row_desc:"' . mce_escape( __('Table row properties') ) . '",
+cell_desc:"' . mce_escape( __('Table cell properties') ) . '",
+props_desc:"' . mce_escape( __('Table properties') ) . '",
+paste_row_before_desc:"' . mce_escape( __('Paste table row before') ) . '",
+paste_row_after_desc:"' . mce_escape( __('Paste table row after') ) . '",
+cut_row_desc:"' . mce_escape( __('Cut table row') ) . '",
+copy_row_desc:"' . mce_escape( __('Copy table row') ) . '",
+del:"' . mce_escape( __('Delete table') ) . '",
+row:"' . mce_escape( __('Row') ) . '",
+col:"' . mce_escape( __('Column') ) . '",
+cell:"' . mce_escape( __('Cell') ) . '"
+},
+autosave:{
+unload_msg:"' . mce_escape( __('The changes you made will be lost if you navigate away from this page.') ) . '"
+},
+fullscreen:{
+desc:"' . mce_escape( __('Toggle fullscreen mode') ) . ' (Alt+Shift+G)"
+},
+media:{
+desc:"' . mce_escape( __('Insert / edit embedded media') ) . '",
+delta_width:"' . /* translators: Extra width for the media popup in pixels */ mce_escape( _x('0', 'media popup width') ) . '",
+delta_height:"' . /* translators: Extra height for the media popup in pixels */ mce_escape( _x('0', 'media popup height') ) . '",
+edit:"' . mce_escape( __('Edit embedded media') ) . '"
+},
+fullpage:{
+desc:"' . mce_escape( __('Document properties') ) . '"
+},
+template:{
+desc:"' . mce_escape( __('Insert predefined template content') ) . '"
+},
+visualchars:{
+desc:"' . mce_escape( __('Visual control characters on/off.') ) . '"
+},
+spellchecker:{
+desc:"' . mce_escape( __('Toggle spellchecker') ) . ' (Alt+Shift+N)",
+menu:"' . mce_escape( __('Spellchecker settings') ) . '",
+ignore_word:"' . mce_escape( __('Ignore word') ) . '",
+ignore_words:"' . mce_escape( __('Ignore all') ) . '",
+langs:"' . mce_escape( __('Languages') ) . '",
+wait:"' . mce_escape( __('Please wait...') ) . '",
+sug:"' . mce_escape( __('Suggestions') ) . '",
+no_sug:"' . mce_escape( __('No suggestions') ) . '",
+no_mpell:"' . mce_escape( __('No misspellings found.') ) . '"
+},
+pagebreak:{
+desc:"' . mce_escape( __('Insert Page Break') ) . '"
+}}});
+
+tinyMCE.addI18n("' . $language . '.advanced",{
+style_select:"' . mce_escape( /* translators: TinyMCE font styles */ _x('Styles', 'TinyMCE font styles') ) . '",
+font_size:"' . mce_escape( __('Font size') ) . '",
+fontdefault:"' . mce_escape( __('Font family') ) . '",
+block:"' . mce_escape( __('Format') ) . '",
+paragraph:"' . mce_escape( __('Paragraph') ) . '",
+div:"' . mce_escape( __('Div') ) . '",
+address:"' . mce_escape( __('Address') ) . '",
+pre:"' . mce_escape( __('Preformatted') ) . '",
+h1:"' . mce_escape( __('Heading 1') ) . '",
+h2:"' . mce_escape( __('Heading 2') ) . '",
+h3:"' . mce_escape( __('Heading 3') ) . '",
+h4:"' . mce_escape( __('Heading 4') ) . '",
+h5:"' . mce_escape( __('Heading 5') ) . '",
+h6:"' . mce_escape( __('Heading 6') ) . '",
+blockquote:"' . mce_escape( __('Blockquote') ) . '",
+code:"' . mce_escape( __('Code') ) . '",
+samp:"' . mce_escape( __('Code sample') ) . '",
+dt:"' . mce_escape( __('Definition term ') ) . '",
+dd:"' . mce_escape( __('Definition description') ) . '",
+bold_desc:"' . mce_escape( __('Bold') ) . ' (Ctrl / Alt+Shift + B)",
+italic_desc:"' . mce_escape( __('Italic') ) . ' (Ctrl / Alt+Shift + I)",
+underline_desc:"' . mce_escape( __('Underline') ) . '",
+striketrough_desc:"' . mce_escape( __('Strikethrough') ) . ' (Alt+Shift+D)",
+justifyleft_desc:"' . mce_escape( __('Align Left') ) . ' (Alt+Shift+L)",
+justifycenter_desc:"' . mce_escape( __('Align Center') ) . ' (Alt+Shift+C)",
+justifyright_desc:"' . mce_escape( __('Align Right') ) . ' (Alt+Shift+R)",
+justifyfull_desc:"' . mce_escape( __('Align Full') ) . ' (Alt+Shift+J)",
+bullist_desc:"' . mce_escape( __('Unordered list') ) . ' (Alt+Shift+U)",
+numlist_desc:"' . mce_escape( __('Ordered list') ) . ' (Alt+Shift+O)",
+outdent_desc:"' . mce_escape( __('Outdent') ) . '",
+indent_desc:"' . mce_escape( __('Indent') ) . '",
+undo_desc:"' . mce_escape( __('Undo') ) . ' (Ctrl+Z)",
+redo_desc:"' . mce_escape( __('Redo') ) . ' (Ctrl+Y)",
+link_desc:"' . mce_escape( __('Insert/edit link') ) . ' (Alt+Shift+A)",
+link_delta_width:"' . /* translators: Extra width for the link popup in pixels */ mce_escape( _x('0', 'link popup width') ) . '",
+link_delta_height:"' . /* translators: Extra height for the link popup in pixels */ mce_escape( _x('0', 'link popup height') ) . '",
+unlink_desc:"' . mce_escape( __('Unlink') ) . ' (Alt+Shift+S)",
+image_desc:"' . mce_escape( __('Insert/edit image') ) . ' (Alt+Shift+M)",
+image_delta_width:"' . /* translators: Extra width for the image popup in pixels */ mce_escape( _x('0', 'image popup width') ) . '",
+image_delta_height:"' . /* translators: Extra height for the image popup in pixels */ mce_escape( _x('0', 'image popup height') ) . '",
+cleanup_desc:"' . mce_escape( __('Cleanup messy code') ) . '",
+code_desc:"' . mce_escape( __('Edit HTML Source') ) . '",
+sub_desc:"' . mce_escape( __('Subscript') ) . '",
+sup_desc:"' . mce_escape( __('Superscript') ) . '",
+hr_desc:"' . mce_escape( __('Insert horizontal ruler') ) . '",
+removeformat_desc:"' . mce_escape( __('Remove formatting') ) . '",
+forecolor_desc:"' . mce_escape( __('Select text color') ) . '",
+backcolor_desc:"' . mce_escape( __('Select background color') ) . '",
+charmap_desc:"' . mce_escape( __('Insert custom character') ) . '",
+visualaid_desc:"' . mce_escape( __('Toggle guidelines/invisible elements') ) . '",
+anchor_desc:"' . mce_escape( __('Insert/edit anchor') ) . '",
+cut_desc:"' . mce_escape( __('Cut') ) . '",
+copy_desc:"' . mce_escape( __('Copy') ) . '",
+paste_desc:"' . mce_escape( __('Paste') ) . '",
+image_props_desc:"' . mce_escape( __('Image properties') ) . '",
+newdocument_desc:"' . mce_escape( __('New document') ) . '",
+help_desc:"' . mce_escape( __('Help') ) . '",
+blockquote_desc:"' . mce_escape( __('Blockquote') ) . ' (Alt+Shift+Q)",
+clipboard_msg:"' . mce_escape( __('Copy/Cut/Paste is not available in Mozilla and Firefox.') ) . '",
+path:"' . mce_escape( __('Path') ) . '",
+newdocument:"' . mce_escape( __('Are you sure you want to clear all contents?') ) . '",
+toolbar_focus:"' . mce_escape( __('Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X') ) . '",
+more_colors:"' . mce_escape( __('More colors') ) . '",
+colorpicker_delta_width:"' . /* translators: Extra width for the colorpicker popup in pixels */ mce_escape( _x('0', 'colorpicker popup width') ) . '",
+colorpicker_delta_height:"' . /* translators: Extra height for the colorpicker popup in pixels */ mce_escape( _x('0', 'colorpicker popup height') ) . '"
+});
+
+tinyMCE.addI18n("' . $language . '.advanced_dlg",{
+about_title:"' . mce_escape( __('About TinyMCE') ) . '",
+about_general:"' . mce_escape( __('About') ) . '",
+about_help:"' . mce_escape( __('Help') ) . '",
+about_license:"' . mce_escape( __('License') ) . '",
+about_plugins:"' . mce_escape( __('Plugins') ) . '",
+about_plugin:"' . mce_escape( __('Plugin') ) . '",
+about_author:"' . mce_escape( __('Author') ) . '",
+about_version:"' . mce_escape( __('Version') ) . '",
+about_loaded:"' . mce_escape( __('Loaded plugins') ) . '",
+anchor_title:"' . mce_escape( __('Insert/edit anchor') ) . '",
+anchor_name:"' . mce_escape( __('Anchor name') ) . '",
+code_title:"' . mce_escape( __('HTML Source Editor') ) . '",
+code_wordwrap:"' . mce_escape( __('Word wrap') ) . '",
+colorpicker_title:"' . mce_escape( __('Select a color') ) . '",
+colorpicker_picker_tab:"' . mce_escape( __('Picker') ) . '",
+colorpicker_picker_title:"' . mce_escape( __('Color picker') ) . '",
+colorpicker_palette_tab:"' . mce_escape( __('Palette') ) . '",
+colorpicker_palette_title:"' . mce_escape( __('Palette colors') ) . '",
+colorpicker_named_tab:"' . mce_escape( __('Named') ) . '",
+colorpicker_named_title:"' . mce_escape( __('Named colors') ) . '",
+colorpicker_color:"' . mce_escape( __('Color:') ) . '",
+colorpicker_name:"' . mce_escape( __('Name:') ) . '",
+charmap_title:"' . mce_escape( __('Select custom character') ) . '",
+image_title:"' . mce_escape( __('Insert/edit image') ) . '",
+image_src:"' . mce_escape( __('Image URL') ) . '",
+image_alt:"' . mce_escape( __('Image description') ) . '",
+image_list:"' . mce_escape( __('Image list') ) . '",
+image_border:"' . mce_escape( __('Border') ) . '",
+image_dimensions:"' . mce_escape( __('Dimensions') ) . '",
+image_vspace:"' . mce_escape( __('Vertical space') ) . '",
+image_hspace:"' . mce_escape( __('Horizontal space') ) . '",
+image_align:"' . mce_escape( __('Alignment') ) . '",
+image_align_baseline:"' . mce_escape( __('Baseline') ) . '",
+image_align_top:"' . mce_escape( __('Top') ) . '",
+image_align_middle:"' . mce_escape( __('Middle') ) . '",
+image_align_bottom:"' . mce_escape( __('Bottom') ) . '",
+image_align_texttop:"' . mce_escape( __('Text top') ) . '",
+image_align_textbottom:"' . mce_escape( __('Text bottom') ) . '",
+image_align_left:"' . mce_escape( __('Left') ) . '",
+image_align_right:"' . mce_escape( __('Right') ) . '",
+link_title:"' . mce_escape( __('Insert/edit link') ) . '",
+link_url:"' . mce_escape( __('Link URL') ) . '",
+link_target:"' . mce_escape( __('Target') ) . '",
+link_target_same:"' . mce_escape( __('Open link in the same window') ) . '",
+link_target_blank:"' . mce_escape( __('Open link in a new window') ) . '",
+link_titlefield:"' . mce_escape( __('Title') ) . '",
+link_is_email:"' . mce_escape( __('The URL you entered seems to be an email address, do you want to add the required mailto: prefix?') ) . '",
+link_is_external:"' . mce_escape( __('The URL you entered seems to external link, do you want to add the required http:// prefix?') ) . '",
+link_list:"' . mce_escape( __('Link list') ) . '"
+});
+
+tinyMCE.addI18n("' . $language . '.media_dlg",{
+title:"' . mce_escape( __('Insert / edit embedded media') ) . '",
+general:"' . mce_escape( __('General') ) . '",
+advanced:"' . mce_escape( __('Advanced') ) . '",
+file:"' . mce_escape( __('File/URL') ) . '",
+list:"' . mce_escape( __('List') ) . '",
+size:"' . mce_escape( __('Dimensions') ) . '",
+preview:"' . mce_escape( __('Preview') ) . '",
+constrain_proportions:"' . mce_escape( __('Constrain proportions') ) . '",
+type:"' . mce_escape( __('Type') ) . '",
+id:"' . mce_escape( __('Id') ) . '",
+name:"' . mce_escape( __('Name') ) . '",
+class_name:"' . mce_escape( __('Class') ) . '",
+vspace:"' . mce_escape( __('V-Space') ) . '",
+hspace:"' . mce_escape( __('H-Space') ) . '",
+play:"' . mce_escape( __('Auto play') ) . '",
+loop:"' . mce_escape( __('Loop') ) . '",
+menu:"' . mce_escape( __('Show menu') ) . '",
+quality:"' . mce_escape( __('Quality') ) . '",
+scale:"' . mce_escape( __('Scale') ) . '",
+align:"' . mce_escape( __('Align') ) . '",
+salign:"' . mce_escape( __('SAlign') ) . '",
+wmode:"' . mce_escape( __('WMode') ) . '",
+bgcolor:"' . mce_escape( __('Background') ) . '",
+base:"' . mce_escape( __('Base') ) . '",
+flashvars:"' . mce_escape( __('Flashvars') ) . '",
+liveconnect:"' . mce_escape( __('SWLiveConnect') ) . '",
+autohref:"' . mce_escape( __('AutoHREF') ) . '",
+cache:"' . mce_escape( __('Cache') ) . '",
+hidden:"' . mce_escape( __('Hidden') ) . '",
+controller:"' . mce_escape( __('Controller') ) . '",
+kioskmode:"' . mce_escape( __('Kiosk mode') ) . '",
+playeveryframe:"' . mce_escape( __('Play every frame') ) . '",
+targetcache:"' . mce_escape( __('Target cache') ) . '",
+correction:"' . mce_escape( __('No correction') ) . '",
+enablejavascript:"' . mce_escape( __('Enable JavaScript') ) . '",
+starttime:"' . mce_escape( __('Start time') ) . '",
+endtime:"' . mce_escape( __('End time') ) . '",
+href:"' . mce_escape( __('href') ) . '",
+qtsrcchokespeed:"' . mce_escape( __('Choke speed') ) . '",
+target:"' . mce_escape( __('Target') ) . '",
+volume:"' . mce_escape( __('Volume') ) . '",
+autostart:"' . mce_escape( __('Auto start') ) . '",
+enabled:"' . mce_escape( __('Enabled') ) . '",
+fullscreen:"' . mce_escape( __('Fullscreen') ) . '",
+invokeurls:"' . mce_escape( __('Invoke URLs') ) . '",
+mute:"' . mce_escape( __('Mute') ) . '",
+stretchtofit:"' . mce_escape( __('Stretch to fit') ) . '",
+windowlessvideo:"' . mce_escape( __('Windowless video') ) . '",
+balance:"' . mce_escape( __('Balance') ) . '",
+baseurl:"' . mce_escape( __('Base URL') ) . '",
+captioningid:"' . mce_escape( __('Captioning id') ) . '",
+currentmarker:"' . mce_escape( __('Current marker') ) . '",
+currentposition:"' . mce_escape( __('Current position') ) . '",
+defaultframe:"' . mce_escape( __('Default frame') ) . '",
+playcount:"' . mce_escape( __('Play count') ) . '",
+rate:"' . mce_escape( __('Rate') ) . '",
+uimode:"' . mce_escape( __('UI Mode') ) . '",
+flash_options:"' . mce_escape( __('Flash options') ) . '",
+qt_options:"' . mce_escape( __('Quicktime options') ) . '",
+wmp_options:"' . mce_escape( __('Windows media player options') ) . '",
+rmp_options:"' . mce_escape( __('Real media player options') ) . '",
+shockwave_options:"' . mce_escape( __('Shockwave options') ) . '",
+autogotourl:"' . mce_escape( __('Auto goto URL') ) . '",
+center:"' . mce_escape( __('Center') ) . '",
+imagestatus:"' . mce_escape( __('Image status') ) . '",
+maintainaspect:"' . mce_escape( __('Maintain aspect') ) . '",
+nojava:"' . mce_escape( __('No java') ) . '",
+prefetch:"' . mce_escape( __('Prefetch') ) . '",
+shuffle:"' . mce_escape( __('Shuffle') ) . '",
+console:"' . mce_escape( __('Console') ) . '",
+numloop:"' . mce_escape( __('Num loops') ) . '",
+controls:"' . mce_escape( __('Controls') ) . '",
+scriptcallbacks:"' . mce_escape( __('Script callbacks') ) . '",
+swstretchstyle:"' . mce_escape( __('Stretch style') ) . '",
+swstretchhalign:"' . mce_escape( __('Stretch H-Align') ) . '",
+swstretchvalign:"' . mce_escape( __('Stretch V-Align') ) . '",
+sound:"' . mce_escape( __('Sound') ) . '",
+progress:"' . mce_escape( __('Progress') ) . '",
+qtsrc:"' . mce_escape( __('QT Src') ) . '",
+qt_stream_warn:"' . mce_escape( __('Streamed rtsp resources should be added to the QT Src field under the advanced tab.') ) . '",
+align_top:"' . mce_escape( __('Top') ) . '",
+align_right:"' . mce_escape( __('Right') ) . '",
+align_bottom:"' . mce_escape( __('Bottom') ) . '",
+align_left:"' . mce_escape( __('Left') ) . '",
+align_center:"' . mce_escape( __('Center') ) . '",
+align_top_left:"' . mce_escape( __('Top left') ) . '",
+align_top_right:"' . mce_escape( __('Top right') ) . '",
+align_bottom_left:"' . mce_escape( __('Bottom left') ) . '",
+align_bottom_right:"' . mce_escape( __('Bottom right') ) . '",
+flv_options:"' . mce_escape( __('Flash video options') ) . '",
+flv_scalemode:"' . mce_escape( __('Scale mode') ) . '",
+flv_buffer:"' . mce_escape( __('Buffer') ) . '",
+flv_startimage:"' . mce_escape( __('Start image') ) . '",
+flv_starttime:"' . mce_escape( __('Start time') ) . '",
+flv_defaultvolume:"' . mce_escape( __('Default volume') ) . '",
+flv_hiddengui:"' . mce_escape( __('Hidden GUI') ) . '",
+flv_autostart:"' . mce_escape( __('Auto start') ) . '",
+flv_loop:"' . mce_escape( __('Loop') ) . '",
+flv_showscalemodes:"' . mce_escape( __('Show scale modes') ) . '",
+flv_smoothvideo:"' . mce_escape( __('Smooth video') ) . '",
+flv_jscallback:"' . mce_escape( __('JS Callback') ) . '"
+});
+
+tinyMCE.addI18n("' . $language . '.wordpress",{
+wp_adv_desc:"' . mce_escape( __('Show/Hide Kitchen Sink') )  . ' (Alt+Shift+Z)",
+wp_more_desc:"' . mce_escape( __('Insert More Tag') ) . ' (Alt+Shift+T)",
+wp_page_desc:"' . mce_escape( __('Insert Page break') ) . ' (Alt+Shift+P)",
+wp_help_desc:"' . mce_escape( __('Help') ) . ' (Alt+Shift+H)",
+wp_more_alt:"' . mce_escape( __('More...') ) . '",
+wp_page_alt:"' . mce_escape( __('Next page...') ) . '",
+add_media:"' . mce_escape( __('Add Media') ) . '",
+add_image:"' . mce_escape( __('Add an Image') ) . '",
+add_video:"' . mce_escape( __('Add Video') ) . '",
+add_audio:"' . mce_escape( __('Add Audio') ) . '",
+editgallery:"' . mce_escape( __('Edit Gallery') ) . '",
+delgallery:"' . mce_escape( __('Delete Gallery') ) . '"
+});
+
+tinyMCE.addI18n("' . $language . '.wpeditimage",{
+edit_img:"' . mce_escape( __('Edit Image') )  . '",
+del_img:"' . mce_escape( __('Delete Image') )  . '",
+adv_settings:"' . mce_escape( __('Advanced Settings') )  . '",
+none:"' . mce_escape( __('None') )  . '",
+size:"' . mce_escape( __('Size') ) . '",
+thumbnail:"' . mce_escape( __('Thumbnail') ) . '",
+medium:"' . mce_escape( __('Medium') ) . '",
+full_size:"' . mce_escape( __('Full Size') ) . '",
+current_link:"' . mce_escape( __('Current Link') ) . '",
+link_to_img:"' . mce_escape( __('Link to Image') ) . '",
+link_help:"' . mce_escape( __('Enter a link URL or click above for presets.') ) . '",
+adv_img_settings:"' . mce_escape( __('Advanced Image Settings') ) . '",
+source:"' . mce_escape( __('Source') )  . '",
+width:"' . mce_escape( __('Width') ) . '",
+height:"' . mce_escape( __('Height') ) . '",
+orig_size:"' . mce_escape( __('Original Size') ) . '",
+css:"' . mce_escape( __('CSS Class') ) . '",
+adv_link_settings:"' . mce_escape( __('Advanced Link Settings') )  . '",
+link_rel:"' . mce_escape( __('Link Rel') ) . '",
+height:"' . mce_escape( __('Height') ) . '",
+orig_size:"' . mce_escape( __('Original Size') ) . '",
+css:"' . mce_escape( __('CSS Class') ) . '",
+s60:"' . mce_escape( __('60%') ) . '",
+s70:"' . mce_escape( __('70%') ) . '",
+s80:"' . mce_escape( __('80%') ) . '",
+s90:"' . mce_escape( __('90%') ) . '",
+s100:"' . mce_escape( __('100%') ) . '",
+s110:"' . mce_escape( __('110%') ) . '",
+s120:"' . mce_escape( __('120%') ) . '",
+s130:"' . mce_escape( __('130%') ) . '",
+img_title:"' . mce_escape( __('Title') ) . '",
+caption:"' . mce_escape( __('Caption') ) . '",
+alt:"' . mce_escape( __('Alternate Text') ) . '"
+});
+';
Index: /tags/3.1/wp-includes/js/tinymce/license.txt
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/license.txt	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/license.txt	(revision 17487)
@@ -0,0 +1,504 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
Index: /tags/3.1/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){tinymce.create("tinymce.plugins.Directionality",{init:function(a,b){var c=this;c.editor=a;a.addCommand("mceDirectionLTR",function(){var d=a.dom.getParent(a.selection.getNode(),a.dom.isBlock);if(d){if(a.dom.getAttrib(d,"dir")!="ltr"){a.dom.setAttrib(d,"dir","ltr")}else{a.dom.setAttrib(d,"dir","")}}a.nodeChanged()});a.addCommand("mceDirectionRTL",function(){var d=a.dom.getParent(a.selection.getNode(),a.dom.isBlock);if(d){if(a.dom.getAttrib(d,"dir")!="rtl"){a.dom.setAttrib(d,"dir","rtl")}else{a.dom.setAttrib(d,"dir","")}}a.nodeChanged()});a.addButton("ltr",{title:"directionality.ltr_desc",cmd:"mceDirectionLTR"});a.addButton("rtl",{title:"directionality.rtl_desc",cmd:"mceDirectionRTL"});a.onNodeChange.add(c._nodeChange,c)},getInfo:function(){return{longname:"Directionality",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_nodeChange:function(b,a,e){var d=b.dom,c;e=d.getParent(e,d.isBlock);if(!e){a.setDisabled("ltr",1);a.setDisabled("rtl",1);return}c=d.getAttrib(e,"dir");a.setActive("ltr",c=="ltr");a.setDisabled("ltr",0);a.setActive("rtl",c=="rtl");a.setDisabled("rtl",0)}});tinymce.PluginManager.add("directionality",tinymce.plugins.Directionality)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.FullScreenPlugin",{init:function(c,d){var e=this,f={},b;e.editor=c;c.addCommand("mceFullScreen",function(){var h,i=a.doc.documentElement;if(c.getParam("fullscreen_is_enabled")){if(c.getParam("fullscreen_new_window")){closeFullscreen()}else{a.win.setTimeout(function(){tinymce.dom.Event.remove(a.win,"resize",e.resizeFunc);tinyMCE.get(c.getParam("fullscreen_editor_id")).setContent(c.getContent({format:"raw"}),{format:"raw"});tinyMCE.remove(c);a.remove("mce_fullscreen_container");i.style.overflow=c.getParam("fullscreen_html_overflow");a.setStyle(a.doc.body,"overflow",c.getParam("fullscreen_overflow"));a.win.scrollTo(c.getParam("fullscreen_scrollx"),c.getParam("fullscreen_scrolly"));tinyMCE.settings=tinyMCE.oldSettings},10)}return}if(c.getParam("fullscreen_new_window")){h=a.win.open(d+"/fullscreen.htm","mceFullScreenPopup","fullscreen=yes,menubar=no,toolbar=no,scrollbars=no,resizable=yes,left=0,top=0,width="+screen.availWidth+",height="+screen.availHeight);try{h.resizeTo(screen.availWidth,screen.availHeight)}catch(g){}}else{tinyMCE.oldSettings=tinyMCE.settings;f.fullscreen_overflow=a.getStyle(a.doc.body,"overflow",1)||"auto";f.fullscreen_html_overflow=a.getStyle(i,"overflow",1);b=a.getViewPort();f.fullscreen_scrollx=b.x;f.fullscreen_scrolly=b.y;if(tinymce.isOpera&&f.fullscreen_overflow=="visible"){f.fullscreen_overflow="auto"}if(tinymce.isIE&&f.fullscreen_overflow=="scroll"){f.fullscreen_overflow="auto"}if(tinymce.isIE&&(f.fullscreen_html_overflow=="visible"||f.fullscreen_html_overflow=="scroll")){f.fullscreen_html_overflow="auto"}if(f.fullscreen_overflow=="0px"){f.fullscreen_overflow=""}a.setStyle(a.doc.body,"overflow","hidden");i.style.overflow="hidden";b=a.getViewPort();a.win.scrollTo(0,0);if(tinymce.isIE){b.h-=1}n=a.add(a.doc.body,"div",{id:"mce_fullscreen_container",style:"position:"+(tinymce.isIE6||(tinymce.isIE&&!a.boxModel)?"absolute":"fixed")+";top:0;left:0;width:"+b.w+"px;height:"+b.h+"px;z-index:200000;"});a.add(n,"div",{id:"mce_fullscreen"});tinymce.each(c.settings,function(j,k){f[k]=j});f.id="mce_fullscreen";f.width=n.clientWidth;f.height=n.clientHeight-15;f.fullscreen_is_enabled=true;f.fullscreen_editor_id=c.id;f.theme_advanced_resizing=false;f.save_onsavecallback=function(){c.setContent(tinyMCE.get(f.id).getContent({format:"raw"}),{format:"raw"});c.execCommand("mceSave")};tinymce.each(c.getParam("fullscreen_settings"),function(l,j){f[j]=l});if(f.theme_advanced_toolbar_location==="external"){f.theme_advanced_toolbar_location="top"}e.fullscreenEditor=new tinymce.Editor("mce_fullscreen",f);e.fullscreenEditor.onInit.add(function(){e.fullscreenEditor.setContent(c.getContent());e.fullscreenEditor.focus()});e.fullscreenEditor.render();e.fullscreenElement=new tinymce.dom.Element("mce_fullscreen_container");e.fullscreenElement.update();e.resizeFunc=tinymce.dom.Event.add(a.win,"resize",function(){var m=tinymce.DOM.getViewPort(),k=e.fullscreenEditor,j,l;j=k.dom.getSize(k.getContainer().firstChild);l=k.dom.getSize(k.getContainer().getElementsByTagName("iframe")[0]);k.theme.resizeTo(m.w-j.w+l.w,m.h-j.h+l.h)})}});c.addButton("fullscreen",{title:"fullscreen.desc",cmd:"mceFullScreen"});c.onNodeChange.add(function(h,g){g.setActive("fullscreen",h.getParam("fullscreen_is_enabled"))})},getInfo:function(){return{longname:"Fullscreen",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("fullscreen",tinymce.plugins.FullScreenPlugin)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm	(revision 17487)
@@ -0,0 +1,109 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title></title>
+	<script type="text/javascript" src="../../tiny_mce.js?ver=3392"></script>
+	<script type="text/javascript">
+		function patchCallback(settings, key) {
+			if (settings[key])
+				settings[key] = "window.opener." + settings[key];
+		}
+
+		var settings = {}, paSe = window.opener.tinyMCE.activeEditor.settings, oeID = window.opener.tinyMCE.activeEditor.id;
+
+		// Clone array
+		for (var n in paSe)
+			settings[n] = paSe[n];
+
+		// Override options for fullscreen
+		for (var n in paSe.fullscreen_settings)
+			settings[n] = paSe.fullscreen_settings[n];
+
+		// Patch callbacks, make them point to window.opener
+		patchCallback(settings, 'urlconverter_callback');
+		patchCallback(settings, 'insertlink_callback');
+		patchCallback(settings, 'insertimage_callback');
+		patchCallback(settings, 'setupcontent_callback');
+		patchCallback(settings, 'save_callback');
+		patchCallback(settings, 'onchange_callback');
+		patchCallback(settings, 'init_instance_callback');
+		patchCallback(settings, 'file_browser_callback');
+		patchCallback(settings, 'cleanup_callback');
+		patchCallback(settings, 'execcommand_callback');
+		patchCallback(settings, 'oninit');
+
+		// Set options
+		delete settings.id;
+		settings['mode'] = 'exact';
+		settings['elements'] = 'fullscreenarea';
+		settings['add_unload_trigger'] = false;
+		settings['ask'] = false;
+		settings['document_base_url'] = window.opener.tinyMCE.activeEditor.documentBaseURI.getURI();
+		settings['fullscreen_is_enabled'] = true;
+		settings['fullscreen_editor_id'] = oeID;
+		settings['theme_advanced_resizing'] = false;
+		settings['strict_loading_mode'] = true;
+
+		settings.save_onsavecallback = function() {
+			window.opener.tinyMCE.get(oeID).setContent(tinyMCE.get('fullscreenarea').getContent({format : 'raw'}), {format : 'raw'});
+			window.opener.tinyMCE.get(oeID).execCommand('mceSave');
+			window.close();
+		};
+
+		function unloadHandler(e) {
+			moveContent();
+		}
+
+		function moveContent() {
+			window.opener.tinyMCE.get(oeID).setContent(tinyMCE.activeEditor.getContent());
+		}
+
+		function closeFullscreen() {
+			moveContent();
+			window.close();
+		}
+
+		function doParentSubmit() {
+			moveContent();
+
+			if (window.opener.tinyMCE.selectedInstance.formElement.form)
+				window.opener.tinyMCE.selectedInstance.formElement.form.submit();
+
+			window.close();
+
+			return false;
+		}
+
+		function render() {
+			var e = document.getElementById('fullscreenarea'), vp, ed, ow, oh, dom = tinymce.DOM;
+
+			e.value = window.opener.tinyMCE.get(oeID).getContent();
+
+			vp = dom.getViewPort();
+			settings.width = vp.w;
+			settings.height = vp.h - 15;
+
+			tinymce.dom.Event.add(window, 'resize', function() {
+				var vp = dom.getViewPort();
+
+				tinyMCE.activeEditor.theme.resizeTo(vp.w, vp.h);
+			});
+
+			tinyMCE.init(settings);
+		}
+
+		// Add onunload
+		tinymce.dom.Event.add(window, "beforeunload", unloadHandler);
+	</script>
+</head>
+<body style="margin:0;overflow:hidden;width:100%;height:100%" scrolling="no" scroll="no">
+<form onsubmit="doParentSubmit();">
+<textarea id="fullscreenarea" style="width:100%; height:100%"></textarea>
+</form>
+
+<script type="text/javascript">
+	render();
+</script>
+
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){var d=tinymce.DOM,b=tinymce.dom.Element,a=tinymce.dom.Event,e=tinymce.each,c=tinymce.is;tinymce.create("tinymce.plugins.InlinePopups",{init:function(f,g){f.onBeforeRenderUI.add(function(){f.windowManager=new tinymce.InlineWindowManager(f);d.loadCSS(g+"/skins/"+(f.settings.inlinepopups_skin||"clearlooks2")+"/window.css")})},getInfo:function(){return{longname:"InlinePopups",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.create("tinymce.InlineWindowManager:tinymce.WindowManager",{InlineWindowManager:function(f){var g=this;g.parent(f);g.zIndex=300000;g.count=0;g.windows={}},open:function(r,j){var y=this,i,k="",q=y.editor,g=0,s=0,h,m,n,o,l,v,x;r=r||{};j=j||{};if(!r.inline){return y.parent(r,j)}if(!r.type){y.bookmark=q.selection.getBookmark(1)}i=d.uniqueId();h=d.getViewPort();r.width=parseInt(r.width||320);r.height=parseInt(r.height||240)+(tinymce.isIE?8:0);r.min_width=parseInt(r.min_width||150);r.min_height=parseInt(r.min_height||100);r.max_width=parseInt(r.max_width||2000);r.max_height=parseInt(r.max_height||2000);r.left=r.left||Math.round(Math.max(h.x,h.x+(h.w/2)-(r.width/2)));r.top=r.top||Math.round(Math.max(h.y,h.y+(h.h/2)-(r.height/2)));r.movable=r.resizable=true;j.mce_width=r.width;j.mce_height=r.height;j.mce_inline=true;j.mce_window_id=i;j.mce_auto_focus=r.auto_focus;y.features=r;y.params=j;y.onOpen.dispatch(y,r,j);if(r.type){k+=" mceModal";if(r.type){k+=" mce"+r.type.substring(0,1).toUpperCase()+r.type.substring(1)}r.resizable=false}if(r.statusbar){k+=" mceStatusbar"}if(r.resizable){k+=" mceResizable"}if(r.minimizable){k+=" mceMinimizable"}if(r.maximizable){k+=" mceMaximizable"}if(r.movable){k+=" mceMovable"}y._addAll(d.doc.body,["div",{id:i,"class":(q.settings.inlinepopups_skin||"clearlooks2")+(tinymce.isIE&&window.getSelection?" ie9":""),style:"width:100px;height:100px"},["div",{id:i+"_wrapper","class":"mceWrapper"+k},["div",{id:i+"_top","class":"mceTop"},["div",{"class":"mceLeft"}],["div",{"class":"mceCenter"}],["div",{"class":"mceRight"}],["span",{id:i+"_title"},r.title||""]],["div",{id:i+"_middle","class":"mceMiddle"},["div",{id:i+"_left","class":"mceLeft"}],["span",{id:i+"_content"}],["div",{id:i+"_right","class":"mceRight"}]],["div",{id:i+"_bottom","class":"mceBottom"},["div",{"class":"mceLeft"}],["div",{"class":"mceCenter"}],["div",{"class":"mceRight"}],["span",{id:i+"_status"},"Content"]],["a",{"class":"mceMove",tabindex:"-1",href:"javascript:;"}],["a",{"class":"mceMin",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{"class":"mceMax",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{"class":"mceMed",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{"class":"mceClose",tabindex:"-1",href:"javascript:;",onmousedown:"return false;"}],["a",{id:i+"_resize_n","class":"mceResize mceResizeN",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_s","class":"mceResize mceResizeS",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_w","class":"mceResize mceResizeW",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_e","class":"mceResize mceResizeE",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_nw","class":"mceResize mceResizeNW",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_ne","class":"mceResize mceResizeNE",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_sw","class":"mceResize mceResizeSW",tabindex:"-1",href:"javascript:;"}],["a",{id:i+"_resize_se","class":"mceResize mceResizeSE",tabindex:"-1",href:"javascript:;"}]]]);d.setStyles(i,{top:-10000,left:-10000});if(tinymce.isGecko){d.setStyle(i,"overflow","auto")}if(!r.type){g+=d.get(i+"_left").clientWidth;g+=d.get(i+"_right").clientWidth;s+=d.get(i+"_top").clientHeight;s+=d.get(i+"_bottom").clientHeight}d.setStyles(i,{top:r.top,left:r.left,width:r.width+g,height:r.height+s});x=r.url||r.file;if(x){if(tinymce.relaxedDomain){x+=(x.indexOf("?")==-1?"?":"&")+"mce_rdomain="+tinymce.relaxedDomain}x=tinymce._addVer(x)}if(!r.type){d.add(i+"_content","iframe",{id:i+"_ifr",src:'javascript:""',frameBorder:0,style:"border:0;width:10px;height:10px"});d.setStyles(i+"_ifr",{width:r.width,height:r.height});d.setAttrib(i+"_ifr","src",x)}else{d.add(i+"_wrapper","a",{id:i+"_ok","class":"mceButton mceOk",href:"javascript:;",onmousedown:"return false;"},"Ok");if(r.type=="confirm"){d.add(i+"_wrapper","a",{"class":"mceButton mceCancel",href:"javascript:;",onmousedown:"return false;"},"Cancel")}d.add(i+"_middle","div",{"class":"mceIcon"});d.setHTML(i+"_content",r.content.replace("\n","<br />"))}n=a.add(i,"mousedown",function(t){var u=t.target,f,p;f=y.windows[i];y.focus(i);if(u.nodeName=="A"||u.nodeName=="a"){if(u.className=="mceMax"){f.oldPos=f.element.getXY();f.oldSize=f.element.getSize();p=d.getViewPort();p.w-=2;p.h-=2;f.element.moveTo(p.x,p.y);f.element.resizeTo(p.w,p.h);d.setStyles(i+"_ifr",{width:p.w-f.deltaWidth,height:p.h-f.deltaHeight});d.addClass(i+"_wrapper","mceMaximized")}else{if(u.className=="mceMed"){f.element.moveTo(f.oldPos.x,f.oldPos.y);f.element.resizeTo(f.oldSize.w,f.oldSize.h);f.iframeElement.resizeTo(f.oldSize.w-f.deltaWidth,f.oldSize.h-f.deltaHeight);d.removeClass(i+"_wrapper","mceMaximized")}else{if(u.className=="mceMove"){return y._startDrag(i,t,u.className)}else{if(d.hasClass(u,"mceResize")){return y._startDrag(i,t,u.className.substring(13))}}}}}});o=a.add(i,"click",function(f){var p=f.target;y.focus(i);if(p.nodeName=="A"||p.nodeName=="a"){switch(p.className){case"mceClose":y.close(null,i);return a.cancel(f);case"mceButton mceOk":case"mceButton mceCancel":r.button_func(p.className=="mceButton mceOk");return a.cancel(f)}}});v=y.windows[i]={id:i,mousedown_func:n,click_func:o,element:new b(i,{blocker:1,container:q.getContainer()}),iframeElement:new b(i+"_ifr"),features:r,deltaWidth:g,deltaHeight:s};v.iframeElement.on("focus",function(){y.focus(i)});if(y.count==0&&y.editor.getParam("dialog_type","modal")=="modal"){d.add(d.doc.body,"div",{id:"mceModalBlocker","class":(y.editor.settings.inlinepopups_skin||"clearlooks2")+"_modalBlocker",style:{zIndex:y.zIndex-1}});d.show("mceModalBlocker")}else{d.setStyle("mceModalBlocker","z-index",y.zIndex-1)}if(tinymce.isIE6||/Firefox\/2\./.test(navigator.userAgent)||(tinymce.isIE&&!d.boxModel)){d.setStyles("mceModalBlocker",{position:"absolute",left:h.x,top:h.y,width:h.w-2,height:h.h-2})}y.focus(i);y._fixIELayout(i,1);if(d.get(i+"_ok")){d.get(i+"_ok").focus()}y.count++;return v},focus:function(h){var g=this,f;if(f=g.windows[h]){f.zIndex=this.zIndex++;f.element.setStyle("zIndex",f.zIndex);f.element.update();h=h+"_wrapper";d.removeClass(g.lastId,"mceFocus");d.addClass(h,"mceFocus");g.lastId=h}},_addAll:function(k,h){var g,l,f=this,j=tinymce.DOM;if(c(h,"string")){k.appendChild(j.doc.createTextNode(h))}else{if(h.length){k=k.appendChild(j.create(h[0],h[1]));for(g=2;g<h.length;g++){f._addAll(k,h[g])}}}},_startDrag:function(v,G,E){var o=this,u,z,C=d.doc,f,l=o.windows[v],h=l.element,y=h.getXY(),x,q,F,g,A,s,r,j,i,m,k,n,B;g={x:0,y:0};A=d.getViewPort();A.w-=2;A.h-=2;j=G.screenX;i=G.screenY;m=k=n=B=0;u=a.add(C,"mouseup",function(p){a.remove(C,"mouseup",u);a.remove(C,"mousemove",z);if(f){f.remove()}h.moveBy(m,k);h.resizeBy(n,B);q=h.getSize();d.setStyles(v+"_ifr",{width:q.w-l.deltaWidth,height:q.h-l.deltaHeight});o._fixIELayout(v,1);return a.cancel(p)});if(E!="Move"){D()}function D(){if(f){return}o._fixIELayout(v,0);d.add(C.body,"div",{id:"mceEventBlocker","class":"mceEventBlocker "+(o.editor.settings.inlinepopups_skin||"clearlooks2"),style:{zIndex:o.zIndex+1}});if(tinymce.isIE6||(tinymce.isIE&&!d.boxModel)){d.setStyles("mceEventBlocker",{position:"absolute",left:A.x,top:A.y,width:A.w-2,height:A.h-2})}f=new b("mceEventBlocker");f.update();x=h.getXY();q=h.getSize();s=g.x+x.x-A.x;r=g.y+x.y-A.y;d.add(f.get(),"div",{id:"mcePlaceHolder","class":"mcePlaceHolder",style:{left:s,top:r,width:q.w,height:q.h}});F=new b("mcePlaceHolder")}z=a.add(C,"mousemove",function(w){var p,H,t;D();p=w.screenX-j;H=w.screenY-i;switch(E){case"ResizeW":m=p;n=0-p;break;case"ResizeE":n=p;break;case"ResizeN":case"ResizeNW":case"ResizeNE":if(E=="ResizeNW"){m=p;n=0-p}else{if(E=="ResizeNE"){n=p}}k=H;B=0-H;break;case"ResizeS":case"ResizeSW":case"ResizeSE":if(E=="ResizeSW"){m=p;n=0-p}else{if(E=="ResizeSE"){n=p}}B=H;break;case"mceMove":m=p;k=H;break}if(n<(t=l.features.min_width-q.w)){if(m!==0){m+=n-t}n=t}if(B<(t=l.features.min_height-q.h)){if(k!==0){k+=B-t}B=t}n=Math.min(n,l.features.max_width-q.w);B=Math.min(B,l.features.max_height-q.h);m=Math.max(m,A.x-(s+A.x));k=Math.max(k,A.y-(r+A.y));m=Math.min(m,(A.w+A.x)-(s+q.w+A.x));k=Math.min(k,(A.h+A.y)-(r+q.h+A.y));if(m+k!==0){if(s+m<0){m=0}if(r+k<0){k=0}F.moveTo(s+m,r+k)}if(n+B!==0){F.resizeTo(q.w+n,q.h+B)}return a.cancel(w)});return a.cancel(G)},resizeBy:function(g,h,i){var f=this.windows[i];if(f){f.element.resizeBy(g,h);f.iframeElement.resizeBy(g,h)}},close:function(j,l){var h=this,g,k=d.doc,f=0,i,l;l=h._findId(l||j);if(!h.windows[l]){h.parent(j);return}h.count--;if(h.count==0){d.remove("mceModalBlocker")}if(g=h.windows[l]){h.onClose.dispatch(h);a.remove(k,"mousedown",g.mousedownFunc);a.remove(k,"click",g.clickFunc);a.clear(l);a.clear(l+"_ifr");d.setAttrib(l+"_ifr","src",'javascript:""');g.element.remove();delete h.windows[l];e(h.windows,function(m){if(m.zIndex>f){i=m;f=m.zIndex}});if(i){h.focus(i.id)}}},setTitle:function(f,g){var h;f=this._findId(f);if(h=d.get(f+"_title")){h.innerHTML=d.encode(g)}},alert:function(g,f,j){var i=this,h;h=i.open({title:i,type:"alert",button_func:function(k){if(f){f.call(k||i,k)}i.close(null,h.id)},content:d.encode(i.editor.getLang(g,g)),inline:1,width:400,height:130})},confirm:function(g,f,j){var i=this,h;h=i.open({title:i,type:"confirm",button_func:function(k){if(f){f.call(k||i,k)}i.close(null,h.id)},content:d.encode(i.editor.getLang(g,g)),inline:1,width:400,height:130})},_findId:function(f){var g=this;if(typeof(f)=="string"){return f}e(g.windows,function(h){var i=d.get(h.id+"_ifr");if(i&&f==i.contentWindow){f=h.id;return false}});return f},_fixIELayout:function(i,h){var f,g;if(!tinymce.isIE6){return}e(["n","s","w","e","nw","ne","sw","se"],function(j){var k=d.get(i+"_resize_"+j);d.setStyles(k,{width:h?k.clientWidth:"",height:h?k.clientHeight:"",cursor:d.getStyle(k,"cursor",1)});d.setStyle(i+"_bottom","bottom","-1px");k=0});if(f=this.windows[i]){f.element.hide();f.element.show();e(d.select("div,a",i),function(k,j){if(k.currentStyle.backgroundImage!="none"){g=new Image();g.src=k.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/,"$1")}});d.get(i).style.filter=""}}});tinymce.PluginManager.add("inlinepopups",tinymce.plugins.InlinePopups)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css	(revision 17487)
@@ -0,0 +1,136 @@
+/* Clearlooks 2 */
+
+/* Reset */
+.clearlooks2, .clearlooks2 div, .clearlooks2 span, .clearlooks2 a {vertical-align:baseline; text-align:left; position:absolute; border:0; padding:0; margin:0; background:transparent; font-family:Arial,Verdana; font-size:11px; color:#000; text-decoration:none; font-weight:normal; width:auto; height:auto; overflow:hidden; display:block}
+
+/* General */
+.clearlooks2 {position:absolute; direction:ltr}
+.clearlooks2 .mceWrapper {position:static}
+.mceEventBlocker {position:fixed; left:0; top:0; background:url(img/horizontal.gif) no-repeat 0 -75px; width:100%; height:100%}
+.clearlooks2 .mcePlaceHolder {border:1px solid #000; background:#888; top:0; left:0; opacity:0.5; -ms-filter:'alpha(opacity=50)'; filter:alpha(opacity=50)}
+.clearlooks2_modalBlocker {position:fixed; left:0; top:0; width:100%; height:100%; background:#FFF; opacity:0.6; -ms-filter:'alpha(opacity=60)'; filter:alpha(opacity=60); display:none}
+
+/* Top */
+.clearlooks2 .mceTop, 
+.clearlooks2 .mceTop div {
+	top:0; 
+	width:100%; 
+	height:23px
+}
+.clearlooks2 .mceTop .mceLeft {
+	width:55%; 
+	background-image: none;
+	border-style: solid none none solid;
+	border-width: 1px;
+}
+.clearlooks2 .mceTop .mceCenter {
+}
+.clearlooks2 .mceTop .mceRight {
+	right:0; 
+	width:55%; 
+	height:23px; 
+	background-image: none;
+	border-style: solid solid none none;
+	border-width: 1px;
+}
+.clearlooks2 .mceTop span {
+	width:100%;
+	font: 12px/20px bold "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;
+	text-align:center; 
+	vertical-align:middle; 
+	line-height:23px; 
+	font-weight:bold;
+}
+.clearlooks2 .mceFocus .mceTop .mceLeft {
+	background-image: none;
+	border-style: solid none none solid;
+	border-width: 1px;
+}
+.clearlooks2 .mceFocus .mceTop .mceCenter {
+}
+.clearlooks2 .mceFocus .mceTop .mceRight {
+	background-image: none;
+	border-style: solid solid none none;
+	border-width: 1px;
+}
+.clearlooks2 .mceFocus .mceTop span {
+color:#FFF
+}
+
+/* Middle */
+.clearlooks2 .mceMiddle, .clearlooks2 .mceMiddle div {top:0}
+.clearlooks2 .mceMiddle {width:100%; height:100%; clip:rect(23px auto auto auto)}
+.clearlooks2 .mceMiddle .mceLeft {left:0; width:5px; height:100%; background:#E4F2FD;border-left:1px solid #c6d9e9}
+.clearlooks2 .mceMiddle span {top:23px; left:5px; width:100%; height:100%; background:#FFF}
+.clearlooks2 .mceMiddle .mceRight {right:0; width:5px; height:100%; background:#E4F2FD;border-right:1px solid #c6d9e9}
+
+/* Bottom */
+.clearlooks2 .mceBottom, .clearlooks2 .mceBottom div {height:6px}
+.clearlooks2 .mceBottom {left:0; bottom:0; width:100%;background:#E4F2FD;border-bottom:1px solid #c6d9e9}
+.clearlooks2 .mceBottom div {top:0}
+.clearlooks2 .mceBottom .mceLeft {left:0; width:5px; background:#E4F2FD  ;border-left:1px solid #c6d9e9}
+.clearlooks2 .mceBottom .mceCenter {left:5px; width:100%}
+.clearlooks2 .mceBottom .mceRight {right:0; width:6px; background:#E4F2FD url(img/drag.gif) no-repeat;border-right:1px solid #c6d9e9}
+.clearlooks2 .mceBottom span {display:none}
+.clearlooks2 .mceStatusbar .mceBottom, .clearlooks2 .mceStatusbar .mceBottom div {height:23px}
+.clearlooks2 .mceStatusbar .mceBottom .mceLeft {background:url(img/corners.gif) -29px 0}
+.clearlooks2 .mceStatusbar .mceBottom .mceCenter {background:url(img/horizontal.gif) 0 -52px}
+.clearlooks2 .mceStatusbar .mceBottom .mceRight {background:url(img/corners.gif) -24px 0}
+.clearlooks2 .mceStatusbar .mceBottom span {display:block; left:7px; font-family:Arial, Verdana; font-size:11px; line-height:23px}
+
+/* Actions */
+.clearlooks2 a {width:29px; height:16px; top:3px}
+.clearlooks2 .mceClose {right:6px; background:url(img/buttons.gif) -87px 0}
+.clearlooks2 .mceMin {display:none; right:68px; background:url(img/buttons.gif) 0 0}
+.clearlooks2 .mceMed {display:none; right:37px; background:url(img/buttons.gif) -29px 0}
+.clearlooks2 .mceMax {display:none; right:37px; background:url(img/buttons.gif) -58px 0}
+.clearlooks2 .mceMove {display:none;width:100%;cursor:move;background:url(img/corners.gif) no-repeat -100px -100px}
+.clearlooks2 .mceMovable .mceMove {display:block}
+.clearlooks2 .mceFocus .mceClose {right:6px; background:url(img/buttons.gif) -87px -16px}
+.clearlooks2 .mceFocus .mceMin {right:68px; background:url(img/buttons.gif) 0 -16px}
+.clearlooks2 .mceFocus .mceMed {right:37px; background:url(img/buttons.gif) -29px -16px}
+.clearlooks2 .mceFocus .mceMax {right:37px; background:url(img/buttons.gif) -58px -16px}
+.clearlooks2 .mceFocus .mceClose:hover {right:6px; background:url(img/buttons.gif) -87px -32px}
+.clearlooks2 .mceFocus .mceClose:hover {right:6px; background:url(img/buttons.gif) -87px -32px}
+.clearlooks2 .mceFocus .mceMin:hover {right:68px; background:url(img/buttons.gif) 0 -32px}
+.clearlooks2 .mceFocus .mceMed:hover {right:37px; background:url(img/buttons.gif) -29px -32px}
+.clearlooks2 .mceFocus .mceMax:hover {right:37px; background:url(img/buttons.gif) -58px -32px}
+
+/* Resize */
+.clearlooks2 .mceResize {top:auto; left:auto; display:none; width:5px; height:5px; background:url(img/horizontal.gif) no-repeat 0 -75px}
+.clearlooks2 .mceResizable .mceResize {display:block}
+.clearlooks2 .mceResizable .mceMin, .clearlooks2 .mceMax {display:none}
+.clearlooks2 .mceMinimizable .mceMin {display:block}
+.clearlooks2 .mceMaximizable .mceMax {display:block}
+.clearlooks2 .mceMaximized .mceMed {display:block}
+.clearlooks2 .mceMaximized .mceMax {display:none}
+.clearlooks2 a.mceResizeN {top:0; left:0; width:100%; cursor:n-resize}
+.clearlooks2 a.mceResizeNW {top:0; left:0; cursor:nw-resize}
+.clearlooks2 a.mceResizeNE {top:0; right:0; cursor:ne-resize}
+.clearlooks2 a.mceResizeW {top:0; left:0; height:100%; cursor:w-resize}
+.clearlooks2 a.mceResizeE {top:0; right:0; height:100%; cursor:e-resize}
+.clearlooks2 a.mceResizeS {bottom:0; left:0; width:100%; cursor:s-resize}
+.clearlooks2 a.mceResizeSW {bottom:0; left:0; cursor:sw-resize}
+.clearlooks2 a.mceResizeSE {bottom:0; right:0; cursor:se-resize}
+
+/* Alert/Confirm */
+.clearlooks2 .mceButton {font-weight:bold; bottom:10px; width:80px; height:30px; background:url(img/button.gif); line-height:30px; vertical-align:middle; text-align:center; outline:0}
+.clearlooks2 .mceMiddle .mceIcon {left:15px; top:35px; width:32px; height:32px}
+.clearlooks2 .mceAlert .mceMiddle span, .clearlooks2 .mceConfirm .mceMiddle span {background:transparent;left:60px; top:35px; width:320px; height:50px; font-weight:bold; overflow:auto; white-space:normal}
+.clearlooks2 a:hover {font-weight:bold;}
+.clearlooks2 .mceAlert .mceMiddle, .clearlooks2 .mceConfirm .mceMiddle {background:#E4F2FD}
+.clearlooks2 .mceAlert .mceOk {left:50%; top:auto; margin-left: -40px}
+.clearlooks2 .mceAlert .mceIcon {background:url(img/alert.gif)}
+.clearlooks2 .mceConfirm .mceOk {left:50%; top:auto; margin-left: -90px}
+.clearlooks2 .mceConfirm .mceCancel {left:50%; top:auto}
+.clearlooks2 .mceConfirm .mceIcon {background:url(img/confirm.gif)}
+
+/* IE9 fixes */
+.clearlooks2.ie9 .mceTop .mceCenter {clip:auto;}
+.clearlooks2.ie9 .mceMiddle {clip:auto;}
+.clearlooks2.ie9 .mceMiddle .mceLeft, .clearlooks2.ie9 .mceMiddle .mceRight {top: 23px;}
+.clearlooks2.ie9 .mceAlert .mceMiddle span, .clearlooks2.ie9 .mceConfirm .mceMiddle span {top:13px;}
+.clearlooks2.ie9 .mceModal .mceMiddle {top:23px}
+.clearlooks2.ie9 .mceModal .mceMiddle .mceLeft, .clearlooks2.ie9 .mceModal .mceMiddle .mceRight {top: 0}
+.clearlooks2.ie9 .mceMiddle .mceIcon {top:13px}
+.clearlooks2.ie9 .mceTop .mceCenter {top:0; right:auto; left:6px; width:calc(100%-12px)}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/template.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/template.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/inlinepopups/template.htm	(revision 17487)
@@ -0,0 +1,387 @@
+<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -->
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Template for dialogs</title>
+<link rel="stylesheet" type="text/css" href="skins/clearlooks2/window.css?ver=3392" />
+</head>
+<body>
+
+<div class="mceEditor">
+	<div class="clearlooks2" style="width:400px; height:100px; left:10px;">
+		<div class="mceWrapper">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Blured</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:100px; left:420px;">
+		<div class="mceWrapper mceMovable mceFocus">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Focused</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:100px; left:10px; top:120px;">
+		<div class="mceWrapper mceMovable mceFocus mceStatusbar">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:100px; left:420px; top:120px;">
+		<div class="mceWrapper mceMovable mceFocus mceStatusbar mceResizable">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar, Resizable</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:100px; left:10px; top:230px;">
+		<div class="mceWrapper mceMovable mceFocus mceResizable mceMaximizable">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Resizable, Maximizable</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:100px; left:420px; top:230px;">
+		<div class="mceWrapper mceMovable mceStatusbar mceResizable mceMaximizable">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Blurred, Maximizable, Statusbar, Resizable</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:100px; left:10px; top:340px;">
+		<div class="mceWrapper mceMovable mceFocus mceResizable mceMaximized mceMinimizable mceMaximizable">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Maximized, Maximizable, Minimizable</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:100px; left:420px; top:340px;">
+		<div class="mceWrapper mceMovable mceStatusbar mceResizable mceMaximized mceMinimizable mceMaximizable">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Blured</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>Content</span>
+				<div class="mceRight"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Statusbar text.</span>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceMin" href="#"></a>
+			<a class="mceMax" href="#"></a>
+			<a class="mceMed" href="#"></a>
+			<a class="mceClose" href="#"></a>
+			<a class="mceResize mceResizeN" href="#"></a>
+			<a class="mceResize mceResizeS" href="#"></a>
+			<a class="mceResize mceResizeW" href="#"></a>
+			<a class="mceResize mceResizeE" href="#"></a>
+			<a class="mceResize mceResizeNW" href="#"></a>
+			<a class="mceResize mceResizeNE" href="#"></a>
+			<a class="mceResize mceResizeSW" href="#"></a>
+			<a class="mceResize mceResizeSE" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:130px; left:10px; top:450px;">
+		<div class="mceWrapper mceMovable mceFocus mceModal mceAlert">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Alert</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+				</span>
+				<div class="mceRight"></div>
+				<div class="mceIcon"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceButton mceOk" href="#">Ok</a>
+			<a class="mceClose" href="#"></a>
+		</div>
+	</div>
+
+	<div class="clearlooks2" style="width:400px; height:130px; left:420px; top:450px;">
+		<div class="mceWrapper mceMovable mceFocus mceModal mceConfirm">
+			<div class="mceTop">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+				<span>Confirm</span>
+			</div>
+
+			<div class="mceMiddle">
+				<div class="mceLeft"></div>
+				<span>
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					This is a very long error message. This is a very long error message.
+					</span>
+				<div class="mceRight"></div>
+				<div class="mceIcon"></div>
+			</div>
+
+			<div class="mceBottom">
+				<div class="mceLeft"></div>
+				<div class="mceCenter"></div>
+				<div class="mceRight"></div>
+			</div>
+
+			<a class="mceMove" href="#"></a>
+			<a class="mceButton mceOk" href="#">Ok</a>
+			<a class="mceButton mceCancel" href="#">Cancel</a>
+			<a class="mceClose" href="#"></a>
+		</div>
+	</div>
+</div>
+
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/paste/blank.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/paste/blank.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/paste/blank.htm	(revision 17487)
@@ -0,0 +1,21 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>blank_page</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link href="css/blank.css?ver=3223_1087" rel="stylesheet" type="text/css" />
+<script type="text/javascript">
+function init() {
+	if (parent.tinymce.isIE)
+		document.body.contentEditable = true;
+	else
+		document.designMode = 'on';
+
+	parent.initIframe(document);
+	window.focus();
+}
+</script>
+</head>
+<body onload="init();">
+
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/paste/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/paste/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){var c=tinymce.each,d=null,a={paste_auto_cleanup_on_paste:true,paste_block_drop:false,paste_retain_style_properties:"none",paste_strip_class_attributes:"mso",paste_remove_spans:false,paste_remove_styles:false,paste_remove_styles_if_webkit:true,paste_convert_middot_lists:true,paste_convert_headers_to_strong:false,paste_dialog_width:"450",paste_dialog_height:"400",paste_text_use_dialog:false,paste_text_sticky:false,paste_text_notifyalways:false,paste_text_linebreaktype:"p",paste_text_replacements:[[/\u2026/g,"..."],[/[\x93\x94\u201c\u201d]/g,'"'],[/[\x60\x91\x92\u2018\u2019]/g,"'"]]};function b(e,f){return e.getParam(f,a[f])}tinymce.create("tinymce.plugins.PastePlugin",{init:function(e,f){var g=this;g.editor=e;g.url=f;g.onPreProcess=new tinymce.util.Dispatcher(g);g.onPostProcess=new tinymce.util.Dispatcher(g);g.onPreProcess.add(g._preProcess);g.onPostProcess.add(g._postProcess);g.onPreProcess.add(function(j,k){e.execCallback("paste_preprocess",j,k)});g.onPostProcess.add(function(j,k){e.execCallback("paste_postprocess",j,k)});e.pasteAsPlainText=false;function i(l,j){var k=e.dom;g.onPreProcess.dispatch(g,l);l.node=k.create("div",0,l.content);g.onPostProcess.dispatch(g,l);l.content=e.serializer.serialize(l.node,{getInner:1});if((!j)&&(e.pasteAsPlainText)){g._insertPlainText(e,k,l.content);if(!b(e,"paste_text_sticky")){e.pasteAsPlainText=false;e.controlManager.setActive("pastetext",false)}}else{if(/<(p|h[1-6]|ul|ol)/.test(l.content)){g._insertBlockContent(e,k,l.content)}else{g._insert(l.content)}}}e.addCommand("mceInsertClipboardContent",function(j,k){i(k,true)});if(!b(e,"paste_text_use_dialog")){e.addCommand("mcePasteText",function(k,j){var l=tinymce.util.Cookie;e.pasteAsPlainText=!e.pasteAsPlainText;e.controlManager.setActive("pastetext",e.pasteAsPlainText);if((e.pasteAsPlainText)&&(!l.get("tinymcePasteText"))){if(b(e,"paste_text_sticky")){e.windowManager.alert(e.translate("paste.plaintext_mode_sticky"))}else{e.windowManager.alert(e.translate("paste.plaintext_mode_sticky"))}if(!b(e,"paste_text_notifyalways")){l.set("tinymcePasteText","1",new Date(new Date().getFullYear()+1,12,31))}}})}e.addButton("pastetext",{title:"paste.paste_text_desc",cmd:"mcePasteText"});e.addButton("selectall",{title:"paste.selectall_desc",cmd:"selectall"});function h(s){var m,q,k,l=e.selection,p=e.dom,r=e.getBody(),j;if(e.pasteAsPlainText&&(s.clipboardData||p.doc.dataTransfer)){s.preventDefault();i({content:(s.clipboardData||p.doc.dataTransfer).getData("Text").replace(/\r?\n/g,'<br />')});return}if(p.get("_mcePaste")){return}m=p.add(r,"div",{id:"_mcePaste","class":"mcePaste"},'\uFEFF<br _mce_bogus="1">');if(r!=e.getDoc().body){j=p.getPos(e.selection.getStart(),r).y}else{j=r.scrollTop}p.setStyles(m,{position:"absolute",left:-10000,top:j,width:1,height:1,overflow:"hidden"});if(tinymce.isIE){k=p.doc.body.createTextRange();k.moveToElementText(m);k.execCommand("Paste");p.remove(m);if(m.innerHTML==="\uFEFF"){e.execCommand("mcePasteWord");s.preventDefault();return}i({content:m.innerHTML});return tinymce.dom.Event.cancel(s)}else{function o(n){n.preventDefault()}p.bind(e.getDoc(),"mousedown",o);p.bind(e.getDoc(),"keydown",o);q=e.selection.getRng();m=m.firstChild;k=e.getDoc().createRange();k.setStart(m,0);k.setEnd(m,1);l.setRng(k);window.setTimeout(function(){var t="",n=p.select("div.mcePaste");c(n,function(v){var u=v.firstChild;if(u&&u.nodeName=="DIV"&&u.style.marginTop&&u.style.backgroundColor){p.remove(u,1)}c(p.select("div.mcePaste",v),function(w){p.remove(w,1)});c(p.select("span.Apple-style-span",v),function(w){p.remove(w,1)});c(p.select("br[_mce_bogus]",v),function(w){p.remove(w)});t+=v.innerHTML});c(n,function(u){p.remove(u)});if(q){l.setRng(q)}i({content:t});p.unbind(e.getDoc(),"mousedown",o);p.unbind(e.getDoc(),"keydown",o)},0)}}if(b(e,"paste_auto_cleanup_on_paste")){if(tinymce.isOpera||/Firefox\/2/.test(navigator.userAgent)){e.onKeyDown.add(function(j,k){if(((tinymce.isMac?k.metaKey:k.ctrlKey)&&k.keyCode==86)||(k.shiftKey&&k.keyCode==45)){h(k)}})}else{e.onPaste.addToTop(function(j,k){return h(k)})}}if(b(e,"paste_block_drop")){e.onInit.add(function(){e.dom.bind(e.getBody(),["dragend","dragover","draggesture","dragdrop","drop","drag"],function(j){j.preventDefault();j.stopPropagation();return false})})}g._legacySupport()},getInfo:function(){return{longname:"Paste text/word",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_preProcess:function(i,f){var l=this.editor,k=f.content,q=tinymce.grep,p=tinymce.explode,g=tinymce.trim,m,j;function e(h){c(h,function(o){if(o.constructor==RegExp){k=k.replace(o,"")}else{k=k.replace(o[0],o[1])}})}if(/class="?Mso|style="[^"]*\bmso-|w:WordDocument/i.test(k)||f.wordContent){f.wordContent=true;e([/^\s*(&nbsp;)+/gi,/(&nbsp;|<br[^>]*>)+\s*$/gi]);if(b(l,"paste_convert_headers_to_strong")){k=k.replace(/<p [^>]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,"<p><strong>$1</strong></p>")}if(b(l,"paste_convert_middot_lists")){e([[/<!--\[if !supportLists\]-->/gi,"$&__MCE_ITEM__"],[/(<span[^>]+(?:mso-list:|:\s*symbol)[^>]+>)/gi,"$1__MCE_ITEM__"]])}e([/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/&nbsp;/gi,"\u00a0"]]);do{m=k.length;k=k.replace(/(<[a-z][^>]*\s)(?:id|name|language|type|on\w+|\w+:\w+)=(?:"[^"]*"|\w+)\s?/gi,"$1")}while(m!=k.length);if(b(l,"paste_retain_style_properties").replace(/^none$/i,"").length==0){k=k.replace(/<\/?span[^>]*>/gi,"")}else{e([[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(o,h){return(h.length>0)?h.replace(/./," ").slice(Math.floor(h.length/2)).split("").join("\u00a0"):""}],[/(<[a-z][^>]*)\sstyle="([^"]*)"/gi,function(u,h,t){var v=[],o=0,r=p(g(t).replace(/&quot;/gi,"'"),";");c(r,function(s){var w,y,z=p(s,":");function x(A){return A+((A!=="0")&&(/\d$/.test(A)))?"px":""}if(z.length==2){w=z[0].toLowerCase();y=z[1].toLowerCase();switch(w){case"mso-padding-alt":case"mso-padding-top-alt":case"mso-padding-right-alt":case"mso-padding-bottom-alt":case"mso-padding-left-alt":case"mso-margin-alt":case"mso-margin-top-alt":case"mso-margin-right-alt":case"mso-margin-bottom-alt":case"mso-margin-left-alt":case"mso-table-layout-alt":case"mso-height":case"mso-width":case"mso-vertical-align-alt":v[o++]=w.replace(/^mso-|-alt$/g,"")+":"+x(y);return;case"horiz-align":v[o++]="text-align:"+y;return;case"vert-align":v[o++]="vertical-align:"+y;return;case"font-color":case"mso-foreground":v[o++]="color:"+y;return;case"mso-background":case"mso-highlight":v[o++]="background:"+y;return;case"mso-default-height":v[o++]="min-height:"+x(y);return;case"mso-default-width":v[o++]="min-width:"+x(y);return;case"mso-padding-between-alt":v[o++]="border-collapse:separate;border-spacing:"+x(y);return;case"text-line-through":if((y=="single")||(y=="double")){v[o++]="text-decoration:line-through"}return;case"mso-zero-height":if(y=="yes"){v[o++]="display:none"}return}if(/^(mso|column|font-emph|lang|layout|line-break|list-image|nav|panose|punct|row|ruby|sep|size|src|tab-|table-border|text-(?!align|decor|indent|trans)|top-bar|version|vnd|word-break)/.test(w)){return}v[o++]=w+":"+z[1]}});if(o>0){return h+' style="'+v.join(";")+'"'}else{return h}}]])}}if(b(l,"paste_convert_headers_to_strong")){e([[/<h[1-6][^>]*>/gi,"<p><strong>"],[/<\/h[1-6][^>]*>/gi,"</strong></p>"]])}j=b(l,"paste_strip_class_attributes");if(j!=="none"){function n(r,o){if(j==="all"){return""}var h=q(p(o.replace(/^(["'])(.*)\1$/,"$2")," "),function(s){return(/^(?!mso)/i.test(s))});return h.length?' class="'+h.join(" ")+'"':""}k=k.replace(/ class="([^"]+)"/gi,n);k=k.replace(/ class=(\w+)/gi,n)}if(b(l,"paste_remove_spans")){k=k.replace(/<\/?span[^>]*>/gi,"")}f.content=k},_postProcess:function(h,j){var g=this,f=g.editor,i=f.dom,e;if(j.wordContent){c(i.select("a",j.node),function(k){if(!k.href||k.href.indexOf("#_Toc")!=-1){i.remove(k,1)}});if(b(f,"paste_convert_middot_lists")){g._convertLists(h,j)}e=b(f,"paste_retain_style_properties");if((tinymce.is(e,"string"))&&(e!=="all")&&(e!=="*")){e=tinymce.explode(e.replace(/^none$/i,""));c(i.select("*",j.node),function(n){var o={},l=0,m,p,k;if(e){for(m=0;m<e.length;m++){p=e[m];k=i.getStyle(n,p);if(k){o[p]=k;l++}}}i.setAttrib(n,"style","");if(e&&l>0){i.setStyles(n,o)}else{if(n.nodeName=="SPAN"&&!n.className){i.remove(n,true)}}})}}if(b(f,"paste_remove_styles")||(b(f,"paste_remove_styles_if_webkit")&&tinymce.isWebKit)){c(i.select("*[style]",j.node),function(k){k.removeAttribute("style");k.removeAttribute("_mce_style")})}else{if(tinymce.isWebKit){c(i.select("*",j.node),function(k){k.removeAttribute("_mce_style")})}}},_convertLists:function(h,f){var j=h.editor.dom,i,m,e=-1,g,n=[],l,k;c(j.select("p",f.node),function(u){var r,v="",t,s,o,q;for(r=u.firstChild;r&&r.nodeType==3;r=r.nextSibling){v+=r.nodeValue}v=u.innerHTML.replace(/<\/?\w+[^>]*>/gi,"").replace(/&nbsp;/g,"\u00a0");if(/^(__MCE_ITEM__)+[\u2022\u00b7\u00a7\u00d8o]\s*\u00a0*/.test(v)){t="ul"}if(/^__MCE_ITEM__\s*\w+\.\s*\u00a0{2,}/.test(v)){t="ol"}if(t){g=parseFloat(u.style.marginLeft||0);if(g>e){n.push(g)}if(!i||t!=l){i=j.create(t);j.insertAfter(i,u)}else{if(g>e){i=m.appendChild(j.create(t))}else{if(g<e){o=tinymce.inArray(n,g);q=j.getParents(i.parentNode,t);i=q[q.length-1-o]||i}}}c(j.select("span",u),function(w){var p=w.innerHTML.replace(/<\/?\w+[^>]*>/gi,"");if(t=="ul"&&/^[\u2022\u00b7\u00a7\u00d8o]/.test(p)){j.remove(w)}else{if(/^[\s\S]*\w+\.(&nbsp;|\u00a0)*\s*/.test(p)){j.remove(w)}}});s=u.innerHTML;if(t=="ul"){s=u.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^[\u2022\u00b7\u00a7\u00d8o]\s*(&nbsp;|\u00a0)+\s*/,"")}else{s=u.innerHTML.replace(/__MCE_ITEM__/g,"").replace(/^\s*\w+\.(&nbsp;|\u00a0)+\s*/,"")}m=i.appendChild(j.create("li",0,s));j.remove(u);e=g;l=t}else{i=e=0}});k=f.node.innerHTML;if(k.indexOf("__MCE_ITEM__")!=-1){f.node.innerHTML=k.replace(/__MCE_ITEM__/g,"")}},_insertBlockContent:function(l,h,m){var f,j,g=l.selection,q,n,e,o,i,k="mce_marker";function p(t){var s;if(tinymce.isIE){s=l.getDoc().body.createTextRange();s.moveToElementText(t);s.collapse(false);s.select()}else{g.select(t,1);g.collapse(false)}}this._insert('<span id="'+k+'"></span>',1);j=h.get(k);f=h.getParent(j,"p,h1,h2,h3,h4,h5,h6,ul,ol,th,td");if(f&&!/TD|TH/.test(f.nodeName)){j=h.split(f,j);c(h.create("div",0,m).childNodes,function(r){q=j.parentNode.insertBefore(r.cloneNode(true),j)});p(q)}else{h.setOuterHTML(j,m);g.select(l.getBody(),1);g.collapse(0)}while(n=h.get(k)){h.remove(n)}n=g.getStart();e=h.getViewPort(l.getWin());o=l.dom.getPos(n).y;i=n.clientHeight;if(o<e.y||o+i>e.y+e.h){l.getDoc().body.scrollTop=o<e.y?o:o-e.h+25}},_insert:function(g,e){var f=this.editor,i=f.selection.getRng();if(!f.selection.isCollapsed()&&i.startContainer!=i.endContainer){f.getDoc().execCommand("Delete",false,null)}f.execCommand(tinymce.isGecko?"insertHTML":"mceInsertContent",false,g,{skip_undo:e})},_insertPlainText:function(j,x,v){var t,u,l,k,r,e,p,f,n=j.getWin(),z=j.getDoc(),s=j.selection,m=tinymce.is,y=tinymce.inArray,g=b(j,"paste_text_linebreaktype"),o=b(j,"paste_text_replacements");function q(h){c(h,function(i){if(i.constructor==RegExp){v=v.replace(i,"")}else{v=v.replace(i[0],i[1])}})}if((typeof(v)==="string")&&(v.length>0)){if(!d){d=("34,quot,38,amp,39,apos,60,lt,62,gt,"+j.serializer.settings.entities).split(",")}if(/<(?:p|br|h[1-6]|ul|ol|dl|table|t[rdh]|div|blockquote|fieldset|pre|address|center)[^>]*>/i.test(v)){q([/[\n\r]+/g])}else{q([/\r+/g])}q([[/<\/(?:p|h[1-6]|ul|ol|dl|table|div|blockquote|fieldset|pre|address|center)>/gi,"\n\n"],[/<br[^>]*>|<\/tr>/gi,"\n"],[/<\/t[dh]>\s*<t[dh][^>]*>/gi,"\t"],/<[a-z!\/?][^>]*>/gi,[/&nbsp;/gi," "],[/&(#\d+|[a-z0-9]{1,10});/gi,function(i,h){if(h.charAt(0)==="#"){return String.fromCharCode(h.slice(1))}else{return((i=y(d,h))>0)?String.fromCharCode(d[i-1]):" "}}],[/(?:(?!\n)\s)*(\n+)(?:(?!\n)\s)*/gi,"$1"],[/\n{3,}/g,"\n\n"],/^\s+|\s+$/g]);v=x.encode(v);if(!s.isCollapsed()){z.execCommand("Delete",false,null)}if(m(o,"array")||(m(o,"array"))){q(o)}else{if(m(o,"string")){q(new RegExp(o,"gi"))}}if(g=="none"){q([[/\n+/g," "]])}else{if(g=="br"){q([[/\n/g,"<br />"]])}else{q([/^\s+|\s+$/g,[/\n\n/g,"</p><p>"],[/\n/g,"<br />"]])}}if((l=v.indexOf("</p><p>"))!=-1){k=v.lastIndexOf("</p><p>");r=s.getNode();e=[];do{if(r.nodeType==1){if(r.nodeName=="TD"||r.nodeName=="BODY"){break}e[e.length]=r}}while(r=r.parentNode);if(e.length>0){p=v.substring(0,l);f="";for(t=0,u=e.length;t<u;t++){p+="</"+e[t].nodeName.toLowerCase()+">";f+="<"+e[e.length-t-1].nodeName.toLowerCase()+">"}if(l==k){v=p+f+v.substring(l+7)}else{v=p+v.substring(l+4,k+4)+f+v.substring(k+7)}}}j.execCommand("mceInsertRawHTML",false,v+'<span id="_plain_text_marker">&nbsp;</span>');window.setTimeout(function(){var h=x.get("_plain_text_marker"),B,i,A,w;s.select(h,false);z.execCommand("Delete",false,null);h=null;B=s.getStart();i=x.getViewPort(n);A=x.getPos(B).y;w=B.clientHeight;if((A<i.y)||(A+w>i.y+i.h)){z.body.scrollTop=A<i.y?A:A-i.h+25}},0)}},_legacySupport:function(){var f=this,e=f.editor;e.addCommand("mcePasteWord",function(){e.windowManager.open({file:f.url+"/pasteword.htm",width:parseInt(b(e,"paste_dialog_width")),height:parseInt(b(e,"paste_dialog_height")),inline:1})});if(b(e,"paste_text_use_dialog")){e.addCommand("mcePasteText",function(){e.windowManager.open({file:f.url+"/pastetext.htm",width:parseInt(b(e,"paste_dialog_width")),height:parseInt(b(e,"paste_dialog_height")),inline:1})})}e.addButton("pasteword",{title:"paste.paste_word_desc",cmd:"mcePasteWord"})}});tinymce.PluginManager.add("paste",tinymce.plugins.PastePlugin)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/paste/js/pastetext.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/paste/js/pastetext.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/paste/js/pastetext.js	(revision 17487)
@@ -0,0 +1,36 @@
+tinyMCEPopup.requireLangPack();
+
+var PasteTextDialog = {
+	init : function() {
+		this.resize();
+	},
+
+	insert : function() {
+		var h = tinyMCEPopup.dom.encode(document.getElementById('content').value), lines;
+
+		// Convert linebreaks into paragraphs
+		if (document.getElementById('linebreaks').checked) {
+			lines = h.split(/\r?\n/);
+			if (lines.length > 1) {
+				h = '';
+				tinymce.each(lines, function(row) {
+					h += '<p>' + row + '</p>';
+				});
+			}
+		}
+
+		tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, {content : h});
+		tinyMCEPopup.close();
+	},
+
+	resize : function() {
+		var vp = tinyMCEPopup.dom.getViewPort(window), el;
+
+		el = document.getElementById('content');
+
+		el.style.width  = (vp.w - 20) + 'px';
+		el.style.height = (vp.h - 90) + 'px';
+	}
+};
+
+tinyMCEPopup.onInit.add(PasteTextDialog.init, PasteTextDialog);
Index: /tags/3.1/wp-includes/js/tinymce/plugins/paste/js/pasteword.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/paste/js/pasteword.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/paste/js/pasteword.js	(revision 17487)
@@ -0,0 +1,51 @@
+tinyMCEPopup.requireLangPack();
+
+var PasteWordDialog = {
+	init : function() {
+		var ed = tinyMCEPopup.editor, el = document.getElementById('iframecontainer'), ifr, doc, css, cssHTML = '';
+
+		// Create iframe
+		el.innerHTML = '<iframe id="iframe" src="javascript:\'\';" frameBorder="0" style="border: 1px solid gray"></iframe>';
+		ifr = document.getElementById('iframe');
+		doc = ifr.contentWindow.document;
+
+		// Force absolute CSS urls
+		css = [ed.baseURI.toAbsolute("themes/" + ed.settings.theme + "/skins/" + ed.settings.skin + "/content.css")];
+		css = css.concat(tinymce.explode(ed.settings.content_css) || []);
+		tinymce.each(css, function(u) {
+			cssHTML += '<link href="' + ed.documentBaseURI.toAbsolute('' + u) + '" rel="stylesheet" type="text/css" />';
+		});
+
+		// Write content into iframe
+		doc.open();
+		doc.write('<html><head>' + cssHTML + '</head><body class="mceContentBody" spellcheck="false"></body></html>');
+		doc.close();
+
+		doc.designMode = 'on';
+		this.resize();
+
+		window.setTimeout(function() {
+			ifr.contentWindow.focus();
+		}, 10);
+	},
+
+	insert : function() {
+		var h = document.getElementById('iframe').contentWindow.document.body.innerHTML;
+
+		tinyMCEPopup.editor.execCommand('mceInsertClipboardContent', false, {content : h, wordContent : true});
+		tinyMCEPopup.close();
+	},
+
+	resize : function() {
+		var vp = tinyMCEPopup.dom.getViewPort(window), el;
+
+		el = document.getElementById('iframe');
+
+		if (el) {
+			el.style.width  = (vp.w - 20) + 'px';
+			el.style.height = (vp.h - 90) + 'px';
+		}
+	}
+};
+
+tinyMCEPopup.onInit.add(PasteWordDialog.init, PasteWordDialog);
Index: /tags/3.1/wp-includes/js/tinymce/plugins/paste/pastetext.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/paste/pastetext.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/paste/pastetext.htm	(revision 17487)
@@ -0,0 +1,32 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>{#paste.paste_text_desc}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="js/pastetext.js?ver=3392"></script>
+</head>
+<body onresize="PasteTextDialog.resize();" style="display:none; overflow:hidden;">
+	<form name="source" onsubmit="return PasteTextDialog.insert();" action="#">
+		<div style="float: left" class="title">{#paste.paste_text_desc}</div>
+
+		<div style="float: right">
+			<input type="checkbox" name="linebreaks" id="linebreaks" class="wordWrapCode" checked="checked" /><label for="linebreaks">{#paste_dlg.text_linebreaks}</label>
+		</div>
+
+		<br style="clear: both" />
+
+		<div>{#paste_dlg.text_title}</div>
+
+		<textarea id="content" name="content" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px;" dir="ltr" wrap="soft" class="mceFocus"></textarea>
+
+		<div class="mceActionPanel">
+			<div style="float: left">
+				<input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
+			</div>
+
+			<div style="float: right">
+				<input type="submit" name="insert" value="{#insert}" id="insert" />
+			</div>
+		</div>
+	</form>
+</body> 
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/paste/pasteword.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/paste/pasteword.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/paste/pasteword.htm	(revision 17487)
@@ -0,0 +1,26 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>{#paste.paste_word_desc}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="js/pasteword.js?ver=3392"></script>
+</head>
+<body onresize="PasteWordDialog.resize();" style="display:none; overflow:hidden;">
+	<form name="source" onsubmit="return PasteWordDialog.insert();" action="#">
+		<div class="title">{#paste.paste_word_desc}</div>
+
+		<div>{#paste_dlg.word_title}</div>
+
+		<div id="iframecontainer"></div>
+
+		<div class="mceActionPanel">
+			<div style="float: left">
+				<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+			</div>
+
+			<div style="float: right">
+				<input type="submit" id="insert" name="insert" value="{#insert}" />
+			</div>
+		</div>
+	</form>
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php	(revision 17487)
@@ -0,0 +1,67 @@
+<?php
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * This class was contributed by Michel Weimerskirch.
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+class EnchantSpell extends SpellChecker {
+	/**
+	 * Spellchecks an array of words.
+	 *
+	 * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
+	 * @param Array $words Array of words to check.
+	 * @return Array of misspelled words.
+	 */
+	function &checkWords($lang, $words) {
+		$r = enchant_broker_init();
+		
+		if (enchant_broker_dict_exists($r,$lang)) {
+			$d = enchant_broker_request_dict($r, $lang);
+			
+			$returnData = array();
+			foreach($words as $key => $value) {
+				$correct = enchant_dict_check($d, $value);
+				if(!$correct) {
+					$returnData[] = trim($value);
+				}
+			}
+	
+			return $returnData;
+			enchant_broker_free_dict($d);
+		} else {
+
+		}
+		enchant_broker_free($r);
+	}
+
+	/**
+	 * Returns suggestions for a specific word.
+	 *
+	 * @param String $lang Selected language code (like en_US or de_DE). Shortcodes like "en" and "de" work with enchant >= 1.4.1
+	 * @param String $word Specific word to get suggestions for.
+	 * @return Array of suggestions for the specified word.
+	 */
+	function &getSuggestions($lang, $word) {
+		$r = enchant_broker_init();
+		$suggs = array();
+
+		if (enchant_broker_dict_exists($r,$lang)) {
+			$d = enchant_broker_request_dict($r, $lang);
+			$suggs = enchant_dict_suggest($d, $word);
+
+			enchant_broker_free_dict($d);
+		} else {
+
+		}
+		enchant_broker_free($r);
+
+		return $suggs;
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php	(revision 17487)
@@ -0,0 +1,159 @@
+<?php
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+class GoogleSpell extends SpellChecker {
+	/**
+	 * Spellchecks an array of words.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {Array} $words Array of words to spellcheck.
+	 * @return {Array} Array of misspelled words.
+	 */
+	function &checkWords($lang, $words) {
+		$wordstr = implode(' ', $words);
+		$matches = $this->_getMatches($lang, $wordstr);
+		$words = array();
+
+		for ($i=0; $i<count($matches); $i++)
+			$words[] = $this->_unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8"));
+
+		return $words;
+	}
+
+	/**
+	 * Returns suggestions of for a specific word.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {String} $word Specific word to get suggestions for.
+	 * @return {Array} Array of suggestions for the specified word.
+	 */
+	function &getSuggestions($lang, $word) {
+		$sug = array();
+		$osug = array();
+		$matches = $this->_getMatches($lang, $word);
+
+		if (count($matches) > 0)
+			$sug = explode("\t", utf8_encode($this->_unhtmlentities($matches[0][4])));
+
+		// Remove empty
+		foreach ($sug as $item) {
+			if ($item)
+				$osug[] = $item;
+		}
+
+		return $osug;
+	}
+
+	function &_getMatches($lang, $str) {
+		$server = "www.google.com";
+		$port = 443;
+		$path = "/tbproxy/spell?lang=" . $lang . "&hl=en";
+		$host = "www.google.com";
+		$url = "https://" . $server;
+
+		// Setup XML request
+		$xml = '<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' . $str . '</text></spellrequest>';
+
+		$header  = "POST ".$path." HTTP/1.0 \r\n";
+		$header .= "MIME-Version: 1.0 \r\n";
+		$header .= "Content-type: application/PTI26 \r\n";
+		$header .= "Content-length: ".strlen($xml)." \r\n";
+		$header .= "Content-transfer-encoding: text \r\n";
+		$header .= "Request-number: 1 \r\n";
+		$header .= "Document-type: Request \r\n";
+		$header .= "Interface-Version: Test 1.4 \r\n";
+		$header .= "Connection: close \r\n\r\n";
+		$header .= $xml;
+
+		// Use curl if it exists
+		if (function_exists('curl_init')) {
+			// Use curl
+			$ch = curl_init();
+			curl_setopt($ch, CURLOPT_URL,$url);
+			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
+			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+			$xml = curl_exec($ch);
+			curl_close($ch);
+		} else {
+			// Use raw sockets
+			$fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30);
+			if ($fp) {
+				// Send request
+				fwrite($fp, $header);
+
+				// Read response
+				$xml = "";
+				while (!feof($fp))
+					$xml .= fgets($fp, 128);
+
+				fclose($fp);
+			} else
+				echo "Could not open SSL connection to google.";
+		}
+
+		// Grab and parse content
+		$matches = array();
+		preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER);
+
+		return $matches;
+	}
+
+	function _unhtmlentities($string) {
+		$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
+		$string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
+
+		$trans_tbl = get_html_translation_table(HTML_ENTITIES);
+		$trans_tbl = array_flip($trans_tbl);
+
+		return strtr($string, $trans_tbl);
+	}
+}
+
+// Patch in multibyte support
+if (!function_exists('mb_substr')) {
+	function mb_substr($str, $start, $len = '', $encoding="UTF-8"){
+		$limit = strlen($str);
+
+		for ($s = 0; $start > 0;--$start) {// found the real start
+			if ($s >= $limit)
+				break;
+
+			if ($str[$s] <= "\x7F")
+				++$s;
+			else {
+				++$s; // skip length
+
+				while ($str[$s] >= "\x80" && $str[$s] <= "\xBF")
+					++$s;
+			}
+		}
+
+		if ($len == '')
+			return substr($str, $s);
+		else
+			for ($e = $s; $len > 0; --$len) {//found the real end
+				if ($e >= $limit)
+					break;
+
+				if ($str[$e] <= "\x7F")
+					++$e;
+				else {
+					++$e;//skip length
+
+					while ($str[$e] >= "\x80" && $str[$e] <= "\xBF" && $e < $limit)
+						++$e;
+				}
+			}
+
+		return substr($str, $s, $e - $s);
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php	(revision 17487)
@@ -0,0 +1,82 @@
+<?php
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+class PSpell extends SpellChecker {
+	/**
+	 * Spellchecks an array of words.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {Array} $words Array of words to spellcheck.
+	 * @return {Array} Array of misspelled words.
+	 */
+	function &checkWords($lang, $words) {
+		$plink = $this->_getPLink($lang);
+
+		$outWords = array();
+		foreach ($words as $word) {
+			if (!pspell_check($plink, trim($word)))
+				$outWords[] = utf8_encode($word);
+		}
+
+		return $outWords;
+	}
+
+	/**
+	 * Returns suggestions of for a specific word.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {String} $word Specific word to get suggestions for.
+	 * @return {Array} Array of suggestions for the specified word.
+	 */
+	function &getSuggestions($lang, $word) {
+		$words = pspell_suggest($this->_getPLink($lang), $word);
+
+		for ($i=0; $i<count($words); $i++)
+			$words[$i] = utf8_encode($words[$i]);
+
+		return $words;
+	}
+
+	/**
+	 * Opens a link for pspell.
+	 */
+	function &_getPLink($lang) {
+		// Check for native PSpell support
+		if (!function_exists("pspell_new"))
+			$this->throwError("PSpell support not found in PHP installation.");
+
+		// Setup PSpell link
+		$plink = pspell_new(
+			$lang,
+			$this->_config['PSpell.spelling'],
+			$this->_config['PSpell.jargon'],
+			$this->_config['PSpell.encoding'],
+			$this->_config['PSpell.mode']
+		);
+
+		// Setup PSpell link
+/*		if (!$plink) {
+			$pspellConfig = pspell_config_create(
+				$lang,
+				$this->_config['PSpell.spelling'],
+				$this->_config['PSpell.jargon'],
+				$this->_config['PSpell.encoding']
+			);
+
+			$plink = pspell_new_config($pspell_config);
+		}*/
+
+		if (!$plink)
+			$this->throwError("No PSpell link found opened.");
+
+		return $plink;
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php	(revision 17487)
@@ -0,0 +1,113 @@
+<?php
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+class PSpellShell extends SpellChecker {
+	/**
+	 * Spellchecks an array of words.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {Array} $words Array of words to spellcheck.
+	 * @return {Array} Array of misspelled words.
+	 */
+	function &checkWords($lang, $words) {
+		$cmd = $this->_getCMD($lang);
+
+		if ($fh = fopen($this->_tmpfile, "w")) {
+			fwrite($fh, "!\n");
+
+			foreach($words as $key => $value)
+				fwrite($fh, "^" . $value . "\n");
+
+			fclose($fh);
+		} else
+			$this->throwError("PSpell support was not found.");
+
+		$data = shell_exec($cmd);
+		@unlink($this->_tmpfile);
+
+		$returnData = array();
+		$dataArr = preg_split("/[\r\n]/", $data, -1, PREG_SPLIT_NO_EMPTY);
+
+		foreach ($dataArr as $dstr) {
+			$matches = array();
+
+			// Skip this line.
+			if (strpos($dstr, "@") === 0)
+				continue;
+
+			preg_match("/\& ([^ ]+) .*/i", $dstr, $matches);
+
+			if (!empty($matches[1]))
+				$returnData[] = utf8_encode(trim($matches[1]));
+		}
+
+		return $returnData;
+	}
+
+	/**
+	 * Returns suggestions of for a specific word.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {String} $word Specific word to get suggestions for.
+	 * @return {Array} Array of suggestions for the specified word.
+	 */
+	function &getSuggestions($lang, $word) {
+		$cmd = $this->_getCMD($lang);
+
+        if (function_exists("mb_convert_encoding"))
+            $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8"));
+        else
+            $word = utf8_encode($word);
+
+		if ($fh = fopen($this->_tmpfile, "w")) {
+			fwrite($fh, "!\n");
+			fwrite($fh, "^$word\n");
+			fclose($fh);
+		} else
+			$this->throwError("Error opening tmp file.");
+
+		$data = shell_exec($cmd);
+		@unlink($this->_tmpfile);
+
+		$returnData = array();
+		$dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
+
+		foreach($dataArr as $dstr) {
+			$matches = array();
+
+			// Skip this line.
+			if (strpos($dstr, "@") === 0)
+				continue;
+
+			preg_match("/\&[^:]+:(.*)/i", $dstr, $matches);
+
+			if (!empty($matches[1])) {
+				$words = array_slice(explode(',', $matches[1]), 0, 10);
+
+				for ($i=0; $i<count($words); $i++)
+					$words[$i] = trim($words[$i]);
+
+				return $words;
+			}
+		}
+
+		return array();
+	}
+
+	function _getCMD($lang) {
+		$this->_tmpfile = tempnam($this->_config['PSpellShell.tmp'], "tinyspell");
+
+		if(preg_match("#win#i", php_uname()))
+			return $this->_config['PSpellShell.aspell'] . " -a --lang=". escapeshellarg($lang) . " --encoding=utf-8 -H < " . $this->_tmpfile . " 2>&1";
+
+		return "cat ". $this->_tmpfile ." | " . $this->_config['PSpellShell.aspell'] . " -a --encoding=utf-8 -H --lang=". escapeshellarg($lang);
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php	(revision 17487)
@@ -0,0 +1,62 @@
+<?php
+/**
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+class SpellChecker {
+	/**
+	 * Constructor.
+	 *
+	 * @param $config Configuration name/value array.
+	 */
+	function SpellChecker(&$config) {
+		$this->_config = $config;
+	}
+
+	/**
+	 * Simple loopback function everything that gets in will be send back.
+	 *
+	 * @param $args.. Arguments.
+	 * @return {Array} Array of all input arguments. 
+	 */
+	function &loopback(/* args.. */) {
+		return func_get_args();
+	}
+
+	/**
+	 * Spellchecks an array of words.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {Array} $words Array of words to spellcheck.
+	 * @return {Array} Array of misspelled words.
+	 */
+	function &checkWords($lang, $words) {
+		return $words;
+	}
+
+	/**
+	 * Returns suggestions of for a specific word.
+	 *
+	 * @param {String} $lang Language code like sv or en.
+	 * @param {String} $word Specific word to get suggestions for.
+	 * @return {Array} Array of suggestions for the specified word.
+	 */
+	function &getSuggestions($lang, $word) {
+		return array();
+	}
+
+	/**
+	 * Throws an error message back to the user. This will stop all execution.
+	 *
+	 * @param {String} $str Message to send back to user.
+	 */
+	function throwError($str) {
+		die('{"result":null,"id":null,"error":{"errstr":"' . addslashes($str) . '","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php	(revision 17487)
@@ -0,0 +1,595 @@
+<?php
+/**
+ * $Id: JSON.php 40 2007-06-18 11:43:15Z spocke $
+ *
+ * @package MCManager.utils
+ * @author Moxiecode
+ * @copyright Copyright © 2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+define('JSON_BOOL', 1);
+define('JSON_INT', 2);
+define('JSON_STR', 3);
+define('JSON_FLOAT', 4);
+define('JSON_NULL', 5);
+define('JSON_START_OBJ', 6);
+define('JSON_END_OBJ', 7);
+define('JSON_START_ARRAY', 8);
+define('JSON_END_ARRAY', 9);
+define('JSON_KEY', 10);
+define('JSON_SKIP', 11);
+
+define('JSON_IN_ARRAY', 30);
+define('JSON_IN_OBJECT', 40);
+define('JSON_IN_BETWEEN', 50);
+
+class Moxiecode_JSONReader {
+	var $_data, $_len, $_pos;
+	var $_value, $_token;
+	var $_location, $_lastLocations;
+	var $_needProp;
+
+	function Moxiecode_JSONReader($data) {
+		$this->_data = $data;
+		$this->_len = strlen($data);
+		$this->_pos = -1;
+		$this->_location = JSON_IN_BETWEEN;
+		$this->_lastLocations = array();
+		$this->_needProp = false;
+	}
+
+	function getToken() {
+		return $this->_token;
+	}
+
+	function getLocation() {
+		return $this->_location;
+	}
+
+	function getTokenName() {
+		switch ($this->_token) {
+			case JSON_BOOL:
+				return 'JSON_BOOL';
+
+			case JSON_INT:
+				return 'JSON_INT';
+
+			case JSON_STR:
+				return 'JSON_STR';
+
+			case JSON_FLOAT:
+				return 'JSON_FLOAT';
+
+			case JSON_NULL:
+				return 'JSON_NULL';
+
+			case JSON_START_OBJ:
+				return 'JSON_START_OBJ';
+
+			case JSON_END_OBJ:
+				return 'JSON_END_OBJ';
+
+			case JSON_START_ARRAY:
+				return 'JSON_START_ARRAY';
+
+			case JSON_END_ARRAY:
+				return 'JSON_END_ARRAY';
+
+			case JSON_KEY:
+				return 'JSON_KEY';
+		}
+
+		return 'UNKNOWN';
+	}
+
+	function getValue() {
+		return $this->_value;
+	}
+
+	function readToken() {
+		$chr = $this->read();
+
+		if ($chr != null) {
+			switch ($chr) {
+				case '[':
+					$this->_lastLocation[] = $this->_location;
+					$this->_location = JSON_IN_ARRAY;
+					$this->_token = JSON_START_ARRAY;
+					$this->_value = null;
+					$this->readAway();
+					return true;
+
+				case ']':
+					$this->_location = array_pop($this->_lastLocation);
+					$this->_token = JSON_END_ARRAY;
+					$this->_value = null;
+					$this->readAway();
+
+					if ($this->_location == JSON_IN_OBJECT)
+						$this->_needProp = true;
+
+					return true;
+
+				case '{':
+					$this->_lastLocation[] = $this->_location;
+					$this->_location = JSON_IN_OBJECT;
+					$this->_needProp = true;
+					$this->_token = JSON_START_OBJ;
+					$this->_value = null;
+					$this->readAway();
+					return true;
+
+				case '}':
+					$this->_location = array_pop($this->_lastLocation);
+					$this->_token = JSON_END_OBJ;
+					$this->_value = null;
+					$this->readAway();
+
+					if ($this->_location == JSON_IN_OBJECT)
+						$this->_needProp = true;
+
+					return true;
+
+				// String
+				case '"':
+				case '\'':
+					return $this->_readString($chr);
+
+				// Null
+				case 'n':
+					return $this->_readNull();
+
+				// Bool
+				case 't':
+				case 'f':
+					return $this->_readBool($chr);
+
+				default:
+					// Is number
+					if (is_numeric($chr) || $chr == '-' || $chr == '.')
+						return $this->_readNumber($chr);
+
+					return true;
+			}
+		}
+
+		return false;
+	}
+
+	function _readBool($chr) {
+		$this->_token = JSON_BOOL;
+		$this->_value = $chr == 't';
+
+		if ($chr == 't')
+			$this->skip(3); // rue
+		else
+			$this->skip(4); // alse
+
+		$this->readAway();
+
+		if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+			$this->_needProp = true;
+
+		return true;
+	}
+
+	function _readNull() {
+		$this->_token = JSON_NULL;
+		$this->_value = null;
+
+		$this->skip(3); // ull
+		$this->readAway();
+
+		if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+			$this->_needProp = true;
+
+		return true;
+	}
+
+	function _readString($quote) {
+		$output = "";
+		$this->_token = JSON_STR;
+		$endString = false;
+
+		while (($chr = $this->peek()) != -1) {
+			switch ($chr) {
+				case '\\':
+					// Read away slash
+					$this->read();
+
+					// Read escape code
+					$chr = $this->read();
+					switch ($chr) {
+							case 't':
+								$output .= "\t";
+								break;
+
+							case 'b':
+								$output .= "\b";
+								break;
+
+							case 'f':
+								$output .= "\f";
+								break;
+
+							case 'r':
+								$output .= "\r";
+								break;
+
+							case 'n':
+								$output .= "\n";
+								break;
+
+							case 'u':
+								$output .= $this->_int2utf8(hexdec($this->read(4)));
+								break;
+
+							default:
+								$output .= $chr;
+								break;
+					}
+
+					break;
+
+					case '\'':
+					case '"':
+						if ($chr == $quote)
+							$endString = true;
+
+						$chr = $this->read();
+						if ($chr != -1 && $chr != $quote)
+							$output .= $chr;
+
+						break;
+
+					default:
+						$output .= $this->read();
+			}
+
+			// String terminated
+			if ($endString)
+				break;
+		}
+
+		$this->readAway();
+		$this->_value = $output;
+
+		// Needed a property
+		if ($this->_needProp) {
+			$this->_token = JSON_KEY;
+			$this->_needProp = false;
+			return true;
+		}
+
+		if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+			$this->_needProp = true;
+
+		return true;
+	}
+
+	function _int2utf8($int) {
+		$int = intval($int);
+
+		switch ($int) {
+			case 0:
+				return chr(0);
+
+			case ($int & 0x7F):
+				return chr($int);
+
+			case ($int & 0x7FF):
+				return chr(0xC0 | (($int >> 6) & 0x1F)) . chr(0x80 | ($int & 0x3F));
+
+			case ($int & 0xFFFF):
+				return chr(0xE0 | (($int >> 12) & 0x0F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr (0x80 | ($int & 0x3F));
+
+			case ($int & 0x1FFFFF):
+				return chr(0xF0 | ($int >> 18)) . chr(0x80 | (($int >> 12) & 0x3F)) . chr(0x80 | (($int >> 6) & 0x3F)) . chr(0x80 | ($int & 0x3F));
+		}
+	}
+
+	function _readNumber($start) {
+		$value = "";
+		$isFloat = false;
+
+		$this->_token = JSON_INT;
+		$value .= $start;
+
+		while (($chr = $this->peek()) != -1) {
+			if (is_numeric($chr) || $chr == '-' || $chr == '.') {
+				if ($chr == '.')
+					$isFloat = true;
+
+				$value .= $this->read();
+			} else
+				break;
+		}
+
+		$this->readAway();
+
+		if ($isFloat) {
+			$this->_token = JSON_FLOAT;
+			$this->_value = floatval($value);
+		} else
+			$this->_value = intval($value);
+
+		if ($this->_location == JSON_IN_OBJECT && !$this->_needProp)
+			$this->_needProp = true;
+
+		return true;
+	}
+
+	function readAway() {
+		while (($chr = $this->peek()) != null) {
+			if ($chr != ':' && $chr != ',' && $chr != ' ')
+				return;
+
+			$this->read();
+		}
+	}
+
+	function read($len = 1) {
+		if ($this->_pos < $this->_len) {
+			if ($len > 1) {
+				$str = substr($this->_data, $this->_pos + 1, $len);
+				$this->_pos += $len;
+
+				return $str;
+			} else
+				return $this->_data[++$this->_pos];
+		}
+
+		return null;
+	}
+
+	function skip($len) {
+		$this->_pos += $len;
+	}
+
+	function peek() {
+		if ($this->_pos < $this->_len)
+			return $this->_data[$this->_pos + 1];
+
+		return null;
+	}
+}
+
+/**
+ * This class handles JSON stuff.
+ *
+ * @package MCManager.utils
+ */
+class Moxiecode_JSON {
+	function Moxiecode_JSON() {
+	}
+
+	function decode($input) {
+		$reader = new Moxiecode_JSONReader($input);
+
+		return $this->readValue($reader);
+	}
+
+	function readValue(&$reader) {
+		$this->data = array();
+		$this->parents = array();
+		$this->cur =& $this->data;
+		$key = null;
+		$loc = JSON_IN_ARRAY;
+
+		while ($reader->readToken()) {
+			switch ($reader->getToken()) {
+				case JSON_STR:
+				case JSON_INT:
+				case JSON_BOOL:
+				case JSON_FLOAT:
+				case JSON_NULL:
+					switch ($reader->getLocation()) {
+						case JSON_IN_OBJECT:
+							$this->cur[$key] = $reader->getValue();
+							break;
+
+						case JSON_IN_ARRAY:
+							$this->cur[] = $reader->getValue();
+							break;
+
+						default:
+							return $reader->getValue();
+					}
+					break;
+
+				case JSON_KEY:
+					$key = $reader->getValue();
+					break;
+
+				case JSON_START_OBJ:
+				case JSON_START_ARRAY:
+					if ($loc == JSON_IN_OBJECT)
+						$this->addArray($key);
+					else
+						$this->addArray(null);
+
+					$cur =& $obj;
+
+					$loc = $reader->getLocation();
+					break;
+
+				case JSON_END_OBJ:
+				case JSON_END_ARRAY:
+					$loc = $reader->getLocation();
+
+					if (count($this->parents) > 0) {
+						$this->cur =& $this->parents[count($this->parents) - 1];
+						array_pop($this->parents);
+					}
+					break;
+			}
+		}
+
+		return $this->data[0];
+	}
+
+	// This method was needed since PHP is crapy and doesn't have pointers/references
+	function addArray($key) {
+		$this->parents[] =& $this->cur;
+		$ar = array();
+
+		if ($key)
+			$this->cur[$key] =& $ar;
+		else
+			$this->cur[] =& $ar;
+
+		$this->cur =& $ar;
+	}
+
+	function getDelim($index, &$reader) {
+		switch ($reader->getLocation()) {
+			case JSON_IN_ARRAY:
+			case JSON_IN_OBJECT:
+				if ($index > 0)
+					return ",";
+				break;
+		}
+
+		return "";
+	}
+
+	function encode($input) {
+		switch (gettype($input)) {
+			case 'boolean':
+				return $input ? 'true' : 'false';
+
+			case 'integer':
+				return (int) $input;
+
+			case 'float':
+			case 'double':
+				return (float) $input;
+
+			case 'NULL':
+				return 'null';
+
+			case 'string':
+				return $this->encodeString($input);
+
+			case 'array':
+				return $this->_encodeArray($input);
+
+			case 'object':
+				return $this->_encodeArray(get_object_vars($input));
+		}
+
+		return '';
+	}
+
+	function encodeString($input) {
+		// Needs to be escaped
+		if (preg_match('/[^a-zA-Z0-9]/', $input)) {
+			$output = '';
+
+			for ($i=0; $i<strlen($input); $i++) {
+				switch ($input[$i]) {
+					case "\b":
+						$output .= "\\b";
+						break;
+
+					case "\t":
+						$output .= "\\t";
+						break;
+
+					case "\f":
+						$output .= "\\f";
+						break;
+
+					case "\r":
+						$output .= "\\r";
+						break;
+
+					case "\n":
+						$output .= "\\n";
+						break;
+
+					case '\\':
+						$output .= "\\\\";
+						break;
+
+					case '\'':
+						$output .= "\\'";
+						break;
+
+					case '"':
+						$output .= '\"';
+						break;
+
+					default:
+						$byte = ord($input[$i]);
+
+						if (($byte & 0xE0) == 0xC0) {
+							$char = pack('C*', $byte, ord($input[$i + 1]));
+							$i += 1;
+							$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+						} if (($byte & 0xF0) == 0xE0) {
+							$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]));
+							$i += 2;
+							$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+						} if (($byte & 0xF8) == 0xF0) {
+							$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]), ord($input[$i + 3]));
+							$i += 3;
+							$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+						} if (($byte & 0xFC) == 0xF8) {
+							$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]), ord($input[$i + 3]), ord($input[$i + 4]));
+							$i += 4;
+							$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+						} if (($byte & 0xFE) == 0xFC) {
+							$char = pack('C*', $byte, ord($input[$i + 1]), ord($input[$i + 2]), ord($input[$i + 3]), ord($input[$i + 4]), ord($input[$i + 5]));
+							$i += 5;
+							$output .= sprintf('\u%04s', bin2hex($this->_utf82utf16($char)));
+						} else if ($byte < 128)
+							$output .= $input[$i];
+				}
+			}
+
+			return '"' . $output . '"';
+		}
+
+		return '"' . $input . '"';
+	}
+
+	function _utf82utf16($utf8) {
+		if (function_exists('mb_convert_encoding'))
+			return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
+
+		switch (strlen($utf8)) {
+			case 1:
+				return $utf8;
+
+			case 2:
+				return chr(0x07 & (ord($utf8[0]) >> 2)) . chr((0xC0 & (ord($utf8[0]) << 6)) | (0x3F & ord($utf8[1])));
+
+			case 3:
+				return chr((0xF0 & (ord($utf8[0]) << 4)) | (0x0F & (ord($utf8[1]) >> 2))) . chr((0xC0 & (ord($utf8[1]) << 6)) | (0x7F & ord($utf8[2])));
+		}
+
+		return '';
+	}
+
+	function _encodeArray($input) {
+		$output = '';
+		$isIndexed = true;
+
+		$keys = array_keys($input);
+		for ($i=0; $i<count($keys); $i++) {
+			if (!is_int($keys[$i])) {
+				$output .= $this->encodeString($keys[$i]) . ':' . $this->encode($input[$keys[$i]]);
+				$isIndexed = false;
+			} else
+				$output .= $this->encode($input[$keys[$i]]);
+
+			if ($i != count($keys) - 1)
+				$output .= ',';
+		}
+
+		return $isIndexed ? '[' . $output . ']' : '{' . $output . '}';
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php	(revision 17487)
@@ -0,0 +1,268 @@
+<?php
+/**
+ * $Id: Logger.class.php 10 2007-05-27 10:55:12Z spocke $
+ *
+ * @package MCFileManager.filesystems
+ * @author Moxiecode
+ * @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.
+ */
+
+// File type contstants
+define('MC_LOGGER_DEBUG', 0);
+define('MC_LOGGER_INFO', 10);
+define('MC_LOGGER_WARN', 20);
+define('MC_LOGGER_ERROR', 30);
+define('MC_LOGGER_FATAL', 40);
+
+/**
+ * Logging utility class. This class handles basic logging with levels, log rotation and custom log formats. It's
+ * designed to be compact but still powerful and flexible.
+ */
+class Moxiecode_Logger {
+	// Private fields
+	var $_path;
+	var $_filename;
+	var $_maxSize;
+	var $_maxFiles;
+	var $_maxSizeBytes;
+	var $_level;
+	var $_format;
+
+	/**
+	 * Constructs a new logger instance.
+	 */
+	function Moxiecode_Logger() {
+		$this->_path = "";
+		$this->_filename = "{level}.log";
+		$this->setMaxSize("100k");
+		$this->_maxFiles = 10;
+		$this->_level = MC_LOGGER_DEBUG;
+		$this->_format = "[{time}] [{level}] {message}";
+	}
+
+	/**
+	 * Sets the current log level, use the MC_LOGGER constants.
+	 *
+	 * @param int $level Log level instance for example MC_LOGGER_DEBUG.
+	 */
+	function setLevel($level) {
+		if (is_string($level)) {
+			switch (strtolower($level)) {
+				case "debug":
+					$level = MC_LOGGER_DEBUG;
+					break;
+
+				case "info":
+					$level = MC_LOGGER_INFO;
+					break;
+
+				case "warn":
+				case "warning":
+					$level = MC_LOGGER_WARN;
+					break;
+
+				case "error":
+					$level = MC_LOGGER_ERROR;
+					break;
+
+				case "fatal":
+					$level = MC_LOGGER_FATAL;
+					break;
+
+				default:
+					$level = MC_LOGGER_FATAL;
+			}
+		}
+
+		$this->_level = $level;
+	}
+
+	/**
+	 * Returns the current log level for example MC_LOGGER_DEBUG.
+	 *
+	 * @return int Current log level for example MC_LOGGER_DEBUG.
+	 */
+	function getLevel() {
+		return $this->_level;
+	}
+
+	function setPath($path) {
+		$this->_path = $path;
+	}
+
+	function getPath() {
+		return $this->_path;
+	}
+
+	function setFileName($file_name) {
+		$this->_filename = $file_name;
+	}
+
+	function getFileName() {
+		return $this->_filename;
+	}
+
+	function setFormat($format) {
+		$this->_format = $format;
+	}
+
+	function getFormat() {
+		return $this->_format;
+	}
+
+	function setMaxSize($size) {
+		// Fix log max size
+		$logMaxSizeBytes = intval(preg_replace("/[^0-9]/", "", $size));
+
+		// Is KB
+		if (strpos((strtolower($size)), "k") > 0)
+			$logMaxSizeBytes *= 1024;
+
+		// Is MB
+		if (strpos((strtolower($size)), "m") > 0)
+			$logMaxSizeBytes *= (1024 * 1024);
+
+		$this->_maxSizeBytes = $logMaxSizeBytes;
+		$this->_maxSize = $size;
+	}
+
+	function getMaxSize() {
+		return $this->_maxSize;
+	}
+
+	function setMaxFiles($max_files) {
+		$this->_maxFiles = $max_files;
+	}
+
+	function getMaxFiles() {
+		return $this->_maxFiles;
+	}
+
+	function debug($msg) {
+		$args = func_get_args();
+		$this->_logMsg(MC_LOGGER_DEBUG, implode(', ', $args));
+	}
+
+	function info($msg) {
+		$args = func_get_args();
+		$this->_logMsg(MC_LOGGER_INFO, implode(', ', $args));
+	}
+
+	function warn($msg) {
+		$args = func_get_args();
+		$this->_logMsg(MC_LOGGER_WARN, implode(', ', $args));
+	}
+
+	function error($msg) {
+		$args = func_get_args();
+		$this->_logMsg(MC_LOGGER_ERROR, implode(', ', $args));
+	}
+
+	function fatal($msg) {
+		$args = func_get_args();
+		$this->_logMsg(MC_LOGGER_FATAL, implode(', ', $args));
+	}
+
+	function isDebugEnabled() {
+		return $this->_level >= MC_LOGGER_DEBUG;
+	}
+
+	function isInfoEnabled() {
+		return $this->_level >= MC_LOGGER_INFO;
+	}
+
+	function isWarnEnabled() {
+		return $this->_level >= MC_LOGGER_WARN;
+	}
+
+	function isErrorEnabled() {
+		return $this->_level >= MC_LOGGER_ERROR;
+	}
+
+	function isFatalEnabled() {
+		return $this->_level >= MC_LOGGER_FATAL;
+	}
+
+	function _logMsg($level, $message) {
+		$roll = false;
+
+		if ($level < $this->_level)
+			return;
+
+		$logFile = $this->toOSPath($this->_path . "/" . $this->_filename);
+
+		switch ($level) {
+			case MC_LOGGER_DEBUG:
+				$levelName = "DEBUG";
+				break;
+
+			case MC_LOGGER_INFO:
+				$levelName = "INFO";
+				break;
+
+			case MC_LOGGER_WARN:
+				$levelName = "WARN";
+				break;
+
+			case MC_LOGGER_ERROR:
+				$levelName = "ERROR";
+				break;
+
+			case MC_LOGGER_FATAL:
+				$levelName = "FATAL";
+				break;
+		}
+
+		$logFile = str_replace('{level}', strtolower($levelName), $logFile);
+
+		$text = $this->_format;
+		$text = str_replace('{time}', date("Y-m-d H:i:s"), $text);
+		$text = str_replace('{level}', strtolower($levelName), $text);
+		$text = str_replace('{message}', $message, $text);
+		$message = $text . "\r\n";
+
+		// Check filesize
+		if (file_exists($logFile)) {
+			$size = @filesize($logFile);
+
+			if ($size + strlen($message) > $this->_maxSizeBytes)
+				$roll = true;
+		}
+
+		// Roll if the size is right
+		if ($roll) {
+			for ($i=$this->_maxFiles-1; $i>=1; $i--) {
+				$rfile = $this->toOSPath($logFile . "." . $i);
+				$nfile = $this->toOSPath($logFile . "." . ($i+1));
+
+				if (@file_exists($rfile))
+					@rename($rfile, $nfile);
+			}
+
+			@rename($logFile, $this->toOSPath($logFile . ".1"));
+
+			// Delete last logfile
+			$delfile = $this->toOSPath($logFile . "." . ($this->_maxFiles + 1));
+			if (@file_exists($delfile))
+				@unlink($delfile);
+		}
+
+		// Append log line
+		if (($fp = @fopen($logFile, "a")) != null) {
+			@fputs($fp, $message);
+			@fflush($fp);
+			@fclose($fp);
+		}
+	}
+
+	/**
+	 * Converts a Unix path to OS specific path.
+	 *
+	 * @param String $path Unix path to convert.
+	 */
+	function toOSPath($path) {
+		return str_replace("/", DIRECTORY_SEPARATOR, $path);
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/config.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/config.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/config.php	(revision 17487)
@@ -0,0 +1,27 @@
+<?php
+/**
+ * config.php
+ *
+ * @package MCManager.includes
+ */
+	// General settings
+	$config['general.engine'] = 'GoogleSpell';
+	//$config['general.engine'] = 'PSpell';
+	//$config['general.engine'] = 'PSpellShell';
+	//$config['general.remote_rpc_url'] = 'http://some.other.site/some/url/rpc.php';
+
+	// PSpell settings
+	$config['PSpell.mode'] = PSPELL_FAST;
+	$config['PSpell.spelling'] = "";
+	$config['PSpell.jargon'] = "";
+	$config['PSpell.encoding'] = "";
+
+	// PSpellShell settings
+	$config['PSpellShell.mode'] = PSPELL_FAST;
+	$config['PSpellShell.aspell'] = '/usr/bin/aspell';
+	$config['PSpellShell.tmp'] = '/tmp';
+
+	// Windows PSpellShell settings
+	//$config['PSpellShell.aspell'] = '"c:\Program Files\Aspell\bin\aspell.exe"';
+	//$config['PSpellShell.tmp'] = 'c:/temp';
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/css/content.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/css/content.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/css/content.css	(revision 17487)
@@ -0,0 +1,1 @@
+.mceItemHiddenSpellWord {background:url(../img/wline.gif) repeat-x bottom left; cursor:default;}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){var a=tinymce.util.JSONRequest,c=tinymce.each,b=tinymce.DOM;tinymce.create("tinymce.plugins.SpellcheckerPlugin",{getInfo:function(){return{longname:"Spellchecker",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker",version:tinymce.majorVersion+"."+tinymce.minorVersion}},init:function(e,f){var g=this,d;g.url=f;g.editor=e;g.rpcUrl=e.getParam("spellchecker_rpc_url",this.url+'/rpc.php');if(g.rpcUrl=="{backend}"){if(tinymce.isIE){return}g.hasSupport=true;e.onContextMenu.addToTop(function(h,i){if(g.active){return false}})}e.addCommand("mceSpellCheck",function(){if(g.rpcUrl=="{backend}"){g.editor.getBody().spellcheck=g.active=!g.active;return}if(!g.active){e.setProgressState(1);g._sendRPC("checkWords",[g.selectedLang,g._getWords()],function(h){if(h.length>0){g.active=1;g._markWords(h);e.setProgressState(0);e.nodeChanged()}else{e.setProgressState(0);if(e.getParam("spellchecker_report_no_misspellings",true)){e.windowManager.alert("spellchecker.no_mpell")}}})}else{g._done()}});e.onInit.add(function(){if(e.settings.content_css!==false){e.dom.loadCSS(f+"/css/content.css")}});e.onClick.add(g._showMenu,g);e.onContextMenu.add(g._showMenu,g);e.onBeforeGetContent.add(function(){if(g.active){g._removeWords()}});e.onNodeChange.add(function(i,h){h.setActive("spellchecker",g.active)});e.onSetContent.add(function(){g._done()});e.onBeforeGetContent.add(function(){g._done()});e.onBeforeExecCommand.add(function(h,i){if(i=="mceFullScreen"){g._done()}});g.languages={};c(e.getParam("spellchecker_languages","+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv","hash"),function(i,h){if(h.indexOf("+")===0){h=h.substring(1);g.selectedLang=i}g.languages[h]=i})},createControl:function(h,d){var f=this,g,e=f.editor;if(h=="spellchecker"){if(f.rpcUrl=="{backend}"){if(f.hasSupport){g=d.createButton(h,{title:"spellchecker.desc",cmd:"mceSpellCheck",scope:f})}return g}g=d.createSplitButton(h,{title:"spellchecker.desc",cmd:"mceSpellCheck",scope:f});g.onRenderMenu.add(function(j,i){i.add({title:"spellchecker.langs","class":"mceMenuItemTitle"}).setDisabled(1);c(f.languages,function(n,m){var p={icon:1},l;p.onclick=function(){l.setSelected(1);f.selectedItem.setSelected(0);f.selectedItem=l;f.selectedLang=n};p.title=m;l=i.add(p);l.setSelected(n==f.selectedLang);if(n==f.selectedLang){f.selectedItem=l}})});return g}},_walk:function(i,g){var h=this.editor.getDoc(),e;if(h.createTreeWalker){e=h.createTreeWalker(i,NodeFilter.SHOW_TEXT,null,false);while((i=e.nextNode())!=null){g.call(this,i)}}else{tinymce.walk(i,g,"childNodes")}},_getSeparators:function(){var e="",d,f=this.editor.getParam("spellchecker_word_separator_chars",'\\s!"#$%&()*+,-./:;<=>?@[]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c');for(d=0;d<f.length;d++){e+="\\"+f.charAt(d)}return e},_getWords:function(){var e=this.editor,g=[],d="",f={},h=[];this._walk(e.getBody(),function(i){if(i.nodeType==3){d+=i.nodeValue+" "}});if(e.getParam("spellchecker_word_pattern")){h=d.match("("+e.getParam("spellchecker_word_pattern")+")","gi")}else{d=d.replace(new RegExp("([0-9]|["+this._getSeparators()+"])","g")," ");d=tinymce.trim(d.replace(/(\s+)/g," "));h=d.split(" ")}c(h,function(i){if(!f[i]){g.push(i);f[i]=1}});return g},_removeWords:function(e){var f=this.editor,h=f.dom,g=f.selection,d=g.getBookmark();c(h.select("span").reverse(),function(i){if(i&&(h.hasClass(i,"mceItemHiddenSpellWord")||h.hasClass(i,"mceItemHidden"))){if(!e||h.decode(i.innerHTML)==e){h.remove(i,1)}}});g.moveToBookmark(d)},_markWords:function(o){var i,h,g,f,e,n="",k=this.editor,p=this._getSeparators(),j=k.dom,d=[];var l=k.selection,m=l.getBookmark();c(o,function(q){n+=(n?"|":"")+q});i=new RegExp("(["+p+"])("+n+")(["+p+"])","g");h=new RegExp("^("+n+")","g");g=new RegExp("("+n+")(["+p+"]?)$","g");f=new RegExp("^("+n+")(["+p+"]?)$","g");e=new RegExp("("+n+")(["+p+"])","g");this._walk(this.editor.getBody(),function(q){if(q.nodeType==3){d.push(q)}});c(d,function(r){var q;if(r.nodeType==3){q=r.nodeValue;if(i.test(q)||h.test(q)||g.test(q)||f.test(q)){q=j.encode(q);q=q.replace(e,'<span class="mceItemHiddenSpellWord">$1</span>$2');q=q.replace(g,'<span class="mceItemHiddenSpellWord">$1</span>$2');j.replace(j.create("span",{"class":"mceItemHidden"},q),r)}}});l.moveToBookmark(m)},_showMenu:function(g,i){var h=this,g=h.editor,d=h._menu,k,j=g.dom,f=j.getViewPort(g.getWin());if(!d){k=b.getPos(g.getContentAreaContainer());d=g.controlManager.createDropMenu("spellcheckermenu",{offset_x:k.x,offset_y:k.y,"class":"mceNoIcons"});h._menu=d}if(j.hasClass(i.target,"mceItemHiddenSpellWord")){d.removeAll();d.add({title:"spellchecker.wait","class":"mceMenuItemTitle"}).setDisabled(1);h._sendRPC("getSuggestions",[h.selectedLang,j.decode(i.target.innerHTML)],function(l){var e;d.removeAll();if(l.length>0){d.add({title:"spellchecker.sug","class":"mceMenuItemTitle"}).setDisabled(1);c(l,function(m){d.add({title:m,onclick:function(){j.replace(g.getDoc().createTextNode(m),i.target);h._checkDone()}})});d.addSeparator()}else{d.add({title:"spellchecker.no_sug","class":"mceMenuItemTitle"}).setDisabled(1)}e=h.editor.getParam("spellchecker_enable_ignore_rpc","");d.add({title:"spellchecker.ignore_word",onclick:function(){var m=i.target.innerHTML;j.remove(i.target,1);h._checkDone();if(ignore_rpc){g.setProgressState(1);h._sendRPC("ignoreWord",[h.selectedLang,m],function(n){g.setProgressState(0)})}}});d.add({title:"spellchecker.ignore_words",onclick:function(){var m=i.target.innerHTML;h._removeWords(j.decode(m));h._checkDone();if(ignore_rpc){g.setProgressState(1);h._sendRPC("ignoreWords",[h.selectedLang,m],function(n){g.setProgressState(0)})}}});if(h.editor.getParam("spellchecker_enable_learn_rpc")){d.add({title:"spellchecker.learn_word",onclick:function(){var m=i.target.innerHTML;j.remove(i.target,1);h._checkDone();g.setProgressState(1);h._sendRPC("learnWord",[h.selectedLang,m],function(n){g.setProgressState(0)})}})}d.update()});g.selection.select(i.target);k=j.getPos(i.target);d.showMenu(k.x,k.y+i.target.offsetHeight-f.y);return tinymce.dom.Event.cancel(i)}else{d.hideMenu()}},_checkDone:function(){var e=this,d=e.editor,g=d.dom,f;c(g.select("span"),function(h){if(h&&g.hasClass(h,"mceItemHiddenSpellWord")){f=true;return false}});if(!f){e._done()}},_done:function(){var d=this,e=d.active;if(d.active){d.active=0;d._removeWords();if(d._menu){d._menu.hideMenu()}if(e){d.editor.nodeChanged()}}},_sendRPC:function(e,g,d){var f=this;a.sendRPC({url:f.rpcUrl,method:e,params:g,success:d,error:function(i,h){f.editor.setProgressState(0);f.editor.windowManager.alert(i.errstr||("Error response: "+h.responseText))}})}});tinymce.PluginManager.add("spellchecker",tinymce.plugins.SpellcheckerPlugin)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php	(revision 17487)
@@ -0,0 +1,98 @@
+<?php
+/**
+ * general.php
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+@error_reporting(E_ALL ^ E_NOTICE);
+$config = array();
+
+require_once(dirname(__FILE__) . "/../classes/utils/Logger.php");
+require_once(dirname(__FILE__) . "/../classes/utils/JSON.php");
+require_once(dirname(__FILE__) . "/../config.php");
+require_once(dirname(__FILE__) . "/../classes/SpellChecker.php");
+
+if (isset($config['general.engine']))
+	require_once(dirname(__FILE__) . "/../classes/" . $config["general.engine"] . ".php");
+
+/**
+ * Returns an request value by name without magic quoting.
+ *
+ * @param String $name Name of parameter to get.
+ * @param String $default_value Default value to return if value not found.
+ * @return String request value by name without magic quoting or default value.
+ */
+function getRequestParam($name, $default_value = false) {
+	if (!isset($_REQUEST[$name]))
+		return $default_value;
+
+	if (is_array($_REQUEST[$name])) {
+		$newarray = array();
+
+		foreach ($_REQUEST[$name] as $name => $value)
+			$newarray[$name] = $value;
+
+		return $newarray;
+	}
+
+	return $_REQUEST[$name];
+}
+
+function &getLogger() {
+	global $mcLogger, $man;
+
+	if (isset($man))
+		$mcLogger = $man->getLogger();
+
+	if (!$mcLogger) {
+		$mcLogger = new Moxiecode_Logger();
+
+		// Set logger options
+		$mcLogger->setPath(dirname(__FILE__) . "/../logs");
+		$mcLogger->setMaxSize("100kb");
+		$mcLogger->setMaxFiles("10");
+		$mcLogger->setFormat("{time} - {message}");
+	}
+
+	return $mcLogger;
+}
+
+function debug($msg) {
+	$args = func_get_args();
+
+	$log = getLogger();
+	$log->debug(implode(', ', $args));
+}
+
+function info($msg) {
+	$args = func_get_args();
+
+	$log = getLogger();
+	$log->info(implode(', ', $args));
+}
+
+function error($msg) {
+	$args = func_get_args();
+
+	$log = getLogger();
+	$log->error(implode(', ', $args));
+}
+
+function warn($msg) {
+	$args = func_get_args();
+
+	$log = getLogger();
+	$log->warn(implode(', ', $args));
+}
+
+function fatal($msg) {
+	$args = func_get_args();
+
+	$log = getLogger();
+	$log->fatal(implode(', ', $args));
+}
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/rpc.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/rpc.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/spellchecker/rpc.php	(revision 17487)
@@ -0,0 +1,112 @@
+<?php
+/**
+ * $Id: rpc.php 915 2008-09-03 08:45:28Z spocke $
+ *
+ * @package MCManager.includes
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
+ */
+
+require_once("./includes/general.php");
+
+// Set RPC response headers
+header('Content-Type: text/plain');
+header('Content-Encoding: UTF-8');
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+header("Cache-Control: no-store, no-cache, must-revalidate");
+header("Cache-Control: post-check=0, pre-check=0", false);
+header("Pragma: no-cache");
+
+$raw = "";
+
+// Try param
+if (isset($_POST["json_data"]))
+	$raw = getRequestParam("json_data");
+
+// Try globals array
+if (!$raw && isset($_GLOBALS) && isset($_GLOBALS["HTTP_RAW_POST_DATA"]))
+	$raw = $_GLOBALS["HTTP_RAW_POST_DATA"];
+
+// Try globals variable
+if (!$raw && isset($HTTP_RAW_POST_DATA))
+	$raw = $HTTP_RAW_POST_DATA;
+
+// Try stream
+if (!$raw) {
+	if (!function_exists('file_get_contents')) {
+		$fp = fopen("php://input", "r");
+		if ($fp) {
+			$raw = "";
+
+			while (!feof($fp))
+				$raw = fread($fp, 1024);
+
+			fclose($fp);
+		}
+	} else
+		$raw = "" . file_get_contents("php://input");
+}
+
+// No input data
+if (!$raw)
+	die('{"result":null,"id":null,"error":{"errstr":"Could not get raw post data.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
+
+// Passthrough request to remote server
+if (isset($config['general.remote_rpc_url'])) {
+	$url = parse_url($config['general.remote_rpc_url']);
+
+	// Setup request
+	$req = "POST " . $url["path"] . " HTTP/1.0\r\n";
+	$req .= "Connection: close\r\n";
+	$req .= "Host: " . $url['host'] . "\r\n";
+	$req .= "Content-Length: " . strlen($raw) . "\r\n";
+	$req .= "\r\n" . $raw;
+
+	if (!isset($url['port']) || !$url['port'])
+		$url['port'] = 80;
+
+	$errno = $errstr = "";
+
+	$socket = fsockopen($url['host'], intval($url['port']), $errno, $errstr, 30);
+	if ($socket) {
+		// Send request headers
+		fputs($socket, $req);
+
+		// Read response headers and data
+		$resp = "";
+		while (!feof($socket))
+				$resp .= fgets($socket, 4096);
+
+		fclose($socket);
+
+		// Split response header/data
+		$resp = explode("\r\n\r\n", $resp);
+		echo $resp[1]; // Output body
+	}
+
+	die();
+}
+
+// Get JSON data
+$json = new Moxiecode_JSON();
+$input = $json->decode($raw);
+
+// Execute RPC
+if (isset($config['general.engine'])) {
+	$spellchecker = new $config['general.engine']($config);
+	$result = call_user_func_array(array($spellchecker, $input['method']), $input['params']);
+} else
+	die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
+
+// Request and response id should always be the same
+$output = array(
+	"id" => $input->id,
+	"result" => $result,
+	"error" => null
+);
+
+// Return JSON encoded string
+echo $json->encode($output);
+
+?>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){var c=tinymce.DOM,a=tinymce.dom.Event,d=tinymce.each,b=tinymce.explode;tinymce.create("tinymce.plugins.TabFocusPlugin",{init:function(f,g){function e(i,j){if(j.keyCode===9){return a.cancel(j)}}function h(l,p){var j,m,o,n,k;function q(i){o=c.getParent(l.id,"form");n=o.elements;if(o){d(n,function(s,r){if(s.id==l.id){j=r;return false}});if(i>0){for(m=j+1;m<n.length;m++){if(n[m].type!="hidden"){return n[m]}}}else{for(m=j-1;m>=0;m--){if(n[m].type!="hidden"){return n[m]}}}}return null}if(p.keyCode===9){k=b(l.getParam("tab_focus",l.getParam("tabfocus_elements",":prev,:next")));if(k.length==1){k[1]=k[0];k[0]=":prev"}if(p.shiftKey){if(k[0]==":prev"){n=q(-1)}else{n=c.get(k[0])}}else{if(k[1]==":next"){n=q(1)}else{n=c.get(k[1])}}if(n){if(l=tinymce.get(n.id||n.name)){l.focus()}else{window.setTimeout(function(){window.focus();n.focus()},10)}return a.cancel(p)}}}f.onKeyUp.add(e);if(tinymce.isGecko){f.onKeyPress.add(h);f.onKeyDown.add(e)}else{f.onKeyDown.add(h)}f.onInit.add(function(){d(c.select("a:first,a:last",f.getContainer()),function(i){a.add(i,"focus",function(){f.focus()})})})},getInfo:function(){return{longname:"Tabfocus",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/tabfocus",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("tabfocus",tinymce.plugins.TabFocusPlugin)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/css/content.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/css/content.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/css/content.css	(revision 17487)
@@ -0,0 +1,29 @@
+
+.mceWPnextpage, .mceWPmore {
+	border: 0px;
+	border-top: 1px dotted #cccccc;
+	display: block;
+	width: 100%;
+	height: 12px;
+	margin-top: 15px;
+}
+.mceWPmore {
+	background: #ffffff url(../img/more_bug.gif) no-repeat right top;
+}
+.mceWPnextpage {
+    background: #ffffff url(../img/page_bug.gif) no-repeat right top;
+}
+
+img.wpGallery {
+	border: 1px dashed #888;
+	background: #f2f8ff url("../../wpgallery/img/gallery.png") no-repeat scroll center center;
+	width: 99%;
+	height: 250px;
+}
+
+img.wp-oembed {
+	border: 1px dashed #888;
+	background: #f7f5f2 url("../img/embedded.png") no-repeat scroll center center;
+	width: 300px;
+	height: 250px;
+}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js	(revision 17487)
@@ -0,0 +1,412 @@
+/**
+ * WordPress plugin.
+ */
+
+(function() {
+	var DOM = tinymce.DOM;
+
+	tinymce.create('tinymce.plugins.WordPress', {
+		mceTout : 0,
+
+		init : function(ed, url) {
+			var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0, moreHTML, nextpageHTML;
+			moreHTML = '<img src="' + url + '/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />';
+			nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />';
+
+			if ( getUserSetting('hidetb', '0') == '1' )
+				ed.settings.wordpress_adv_hidden = 0;
+
+			// Hides the specified toolbar and resizes the iframe
+			ed.onPostRender.add(function() {
+				var adv_toolbar = ed.controlManager.get(tbId);
+				if ( ed.getParam('wordpress_adv_hidden', 1) && adv_toolbar ) {
+					DOM.hide(adv_toolbar.id);
+					t._resizeIframe(ed, tbId, 28);
+				}
+			});
+
+			// Register commands
+			ed.addCommand('WP_More', function() {
+				ed.execCommand('mceInsertContent', 0, moreHTML);
+			});
+
+			ed.addCommand('WP_Page', function() {
+				ed.execCommand('mceInsertContent', 0, nextpageHTML);
+			});
+
+			ed.addCommand('WP_Help', function() {
+				ed.windowManager.open({
+					url : tinymce.baseURL + '/wp-mce-help.php',
+					width : 450,
+					height : 420,
+					inline : 1
+				});
+			});
+
+			ed.addCommand('WP_Adv', function() {
+				var cm = ed.controlManager, id = cm.get(tbId).id;
+
+				if ( 'undefined' == id )
+					return;
+
+				if ( DOM.isHidden(id) ) {
+					cm.setActive('wp_adv', 1);
+					DOM.show(id);
+					t._resizeIframe(ed, tbId, -28);
+					ed.settings.wordpress_adv_hidden = 0;
+					setUserSetting('hidetb', '1');
+				} else {
+					cm.setActive('wp_adv', 0);
+					DOM.hide(id);
+					t._resizeIframe(ed, tbId, 28);
+					ed.settings.wordpress_adv_hidden = 1;
+					setUserSetting('hidetb', '0');
+				}
+			});
+
+			// Register buttons
+			ed.addButton('wp_more', {
+				title : 'wordpress.wp_more_desc',
+				image : url + '/img/more.gif',
+				cmd : 'WP_More'
+			});
+
+			ed.addButton('wp_page', {
+				title : 'wordpress.wp_page_desc',
+				image : url + '/img/page.gif',
+				cmd : 'WP_Page'
+			});
+
+			ed.addButton('wp_help', {
+				title : 'wordpress.wp_help_desc',
+				image : url + '/img/help.gif',
+				cmd : 'WP_Help'
+			});
+
+			ed.addButton('wp_adv', {
+				title : 'wordpress.wp_adv_desc',
+				image : url + '/img/toolbars.gif',
+				cmd : 'WP_Adv'
+			});
+
+			// Add Media buttons
+			ed.addButton('add_media', {
+				title : 'wordpress.add_media',
+				image : url + '/img/media.gif',
+				onclick : function() {
+					tb_show('', tinymce.DOM.get('add_media').href);
+					tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
+				}
+			});
+
+			ed.addButton('add_image', {
+				title : 'wordpress.add_image',
+				image : url + '/img/image.gif',
+				onclick : function() {
+					tb_show('', tinymce.DOM.get('add_image').href);
+					tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
+				}
+			});
+
+			ed.addButton('add_video', {
+				title : 'wordpress.add_video',
+				image : url + '/img/video.gif',
+				onclick : function() {
+					tb_show('', tinymce.DOM.get('add_video').href);
+					tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
+				}
+			});
+
+			ed.addButton('add_audio', {
+				title : 'wordpress.add_audio',
+				image : url + '/img/audio.gif',
+				onclick : function() {
+					tb_show('', tinymce.DOM.get('add_audio').href);
+					tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
+				}
+			});
+
+			// Add Media buttons to fullscreen and handle align buttons for image captions
+			ed.onBeforeExecCommand.add(function(ed, cmd, ui, val, o) {
+				var DOM = tinymce.DOM, n, DL, DIV, cls, a, align;
+				if ( 'mceFullScreen' == cmd ) {
+					if ( 'mce_fullscreen' != ed.id && DOM.get('add_audio') && DOM.get('add_video') && DOM.get('add_image') && DOM.get('add_media') )
+						ed.settings.theme_advanced_buttons1 += ',|,add_image,add_video,add_audio,add_media';
+				}
+
+				if ( 'JustifyLeft' == cmd || 'JustifyRight' == cmd || 'JustifyCenter' == cmd ) {
+					n = ed.selection.getNode();
+
+					if ( n.nodeName == 'IMG' ) {
+						align = cmd.substr(7).toLowerCase();
+						a = 'align' + align;
+						DL = ed.dom.getParent(n, 'dl.wp-caption');
+						DIV = ed.dom.getParent(n, 'div.mceTemp');
+
+						if ( DL && DIV ) {
+							cls = ed.dom.hasClass(DL, a) ? 'alignnone' : a;
+							DL.className = DL.className.replace(/align[^ '"]+\s?/g, '');
+							ed.dom.addClass(DL, cls);
+
+							if (cls == 'aligncenter')
+								ed.dom.addClass(DIV, 'mceIEcenter');
+							else
+								ed.dom.removeClass(DIV, 'mceIEcenter');
+
+							o.terminate = true;
+							ed.execCommand('mceRepaint');
+						} else {
+							if ( ed.dom.hasClass(n, a) )
+								ed.dom.addClass(n, 'alignnone');
+							else
+								ed.dom.removeClass(n, 'alignnone');
+						}
+					}
+				}
+			});
+			
+			ed.onInit.add(function(ed) {
+				// make sure these run last
+				ed.onNodeChange.add( function(ed, cm, e) {
+					var DL;
+
+					if ( e.nodeName == 'IMG' ) {
+						DL = ed.dom.getParent(e, 'dl.wp-caption');
+					} else if ( e.nodeName == 'DIV' && ed.dom.hasClass(e, 'mceTemp') ) {
+						DL = e.firstChild;
+
+						if ( ! ed.dom.hasClass(DL, 'wp-caption') )
+							DL = false;
+					}
+
+					if ( DL ) {
+						if ( ed.dom.hasClass(DL, 'alignleft') )
+							cm.setActive('justifyleft', 1);
+						else if ( ed.dom.hasClass(DL, 'alignright') )
+							cm.setActive('justifyright', 1);
+						else if ( ed.dom.hasClass(DL, 'aligncenter') )
+							cm.setActive('justifycenter', 1);
+					}
+				});
+
+				// remove invalid parent paragraphs when pasting HTML and/or switching to the HTML editor and back
+				ed.onBeforeSetContent.add(function(ed, o) {
+					if ( o.content ) {
+						o.content = o.content.replace(/<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi, '<$1$2>');
+						o.content = o.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, '</$1>');
+					}
+				});
+			});
+
+			// Word count if script is loaded
+			if ( 'undefined' != typeof wpWordCount ) {
+				ed.onKeyUp.add(function(ed, e) {
+					if ( e.keyCode == last ) return;
+					if ( 13 == e.keyCode || 8 == last || 46 == last ) wpWordCount.wc( ed.getContent({format : 'raw'}) );
+					last = e.keyCode;
+				});
+			};
+
+			ed.onSaveContent.add(function(ed, o) {
+				if ( typeof(switchEditors) == 'object' ) {
+					if ( ed.isHidden() )
+						o.content = o.element.value;
+					else
+						o.content = switchEditors.pre_wpautop(o.content);
+				}
+			});
+
+			/* disable for now
+			ed.onBeforeSetContent.add(function(ed, o) {
+				o.content = t._setEmbed(o.content);
+			});
+
+			ed.onPostProcess.add(function(ed, o) {
+				if ( o.get )
+					o.content = t._getEmbed(o.content);
+			});
+			*/
+
+			// Add listeners to handle more break
+			t._handleMoreBreak(ed, url);
+
+			// Add custom shortcuts
+			ed.addShortcut('alt+shift+c', ed.getLang('justifycenter_desc'), 'JustifyCenter');
+			ed.addShortcut('alt+shift+r', ed.getLang('justifyright_desc'), 'JustifyRight');
+			ed.addShortcut('alt+shift+l', ed.getLang('justifyleft_desc'), 'JustifyLeft');
+			ed.addShortcut('alt+shift+j', ed.getLang('justifyfull_desc'), 'JustifyFull');
+			ed.addShortcut('alt+shift+q', ed.getLang('blockquote_desc'), 'mceBlockQuote');
+			ed.addShortcut('alt+shift+u', ed.getLang('bullist_desc'), 'InsertUnorderedList');
+			ed.addShortcut('alt+shift+o', ed.getLang('numlist_desc'), 'InsertOrderedList');
+			ed.addShortcut('alt+shift+d', ed.getLang('striketrough_desc'), 'Strikethrough');
+			ed.addShortcut('alt+shift+n', ed.getLang('spellchecker.desc'), 'mceSpellCheck');
+			ed.addShortcut('alt+shift+a', ed.getLang('link_desc'), 'mceLink');
+			ed.addShortcut('alt+shift+s', ed.getLang('unlink_desc'), 'unlink');
+			ed.addShortcut('alt+shift+m', ed.getLang('image_desc'), 'mceImage');
+			ed.addShortcut('alt+shift+g', ed.getLang('fullscreen.desc'), 'mceFullScreen');
+			ed.addShortcut('alt+shift+z', ed.getLang('wp_adv_desc'), 'WP_Adv');
+			ed.addShortcut('alt+shift+h', ed.getLang('help_desc'), 'WP_Help');
+			ed.addShortcut('alt+shift+t', ed.getLang('wp_more_desc'), 'WP_More');
+			ed.addShortcut('alt+shift+p', ed.getLang('wp_page_desc'), 'WP_Page');
+			ed.addShortcut('ctrl+s', ed.getLang('save_desc'), function(){if('function'==typeof autosave)autosave();});
+
+			if ( tinymce.isWebKit ) {
+				ed.addShortcut('alt+shift+b', ed.getLang('bold_desc'), 'Bold');
+				ed.addShortcut('alt+shift+i', ed.getLang('italic_desc'), 'Italic');
+			}
+
+			ed.onInit.add(function(ed) {
+				tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {
+					ed.plugins.wordpress._hideButtons();
+				});
+				tinymce.dom.Event.add(ed.getBody(), 'dragstart', function(e) {
+					ed.plugins.wordpress._hideButtons();
+				});
+			});
+
+			ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {
+				ed.plugins.wordpress._hideButtons();
+			});
+
+			ed.onSaveContent.add(function(ed, o) {
+				ed.plugins.wordpress._hideButtons();
+			});
+
+			ed.onMouseDown.add(function(ed, e) {
+				if ( e.target.nodeName != 'IMG' )
+					ed.plugins.wordpress._hideButtons();
+			});
+		},
+
+		getInfo : function() {
+			return {
+				longname : 'WordPress Plugin',
+				author : 'WordPress', // add Moxiecode?
+				authorurl : 'http://wordpress.org',
+				infourl : 'http://wordpress.org',
+				version : '3.0'
+			};
+		},
+
+		// Internal functions
+		_setEmbed : function(c) {
+			return c.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g, function(a,b){
+				return '<img width="300" height="200" src="' + tinymce.baseURL + '/plugins/wordpress/img/trans.gif" class="wp-oembed mceItemNoResize" alt="'+b+'" title="'+b+'" />';
+			});
+		},
+
+		_getEmbed : function(c) {
+			return c.replace(/<img[^>]+>/g, function(a) {
+				if ( a.indexOf('class="wp-oembed') != -1 ) {
+					var u = a.match(/alt="([^\"]+)"/);
+					if ( u[1] )
+						a = '[embed]' + u[1] + '[/embed]';
+				}
+				return a;
+			});
+		},
+
+		_showButtons : function(n, id) {
+			var ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;
+
+			vp = ed.dom.getViewPort(ed.getWin());
+			p1 = DOM.getPos(ed.getContentAreaContainer());
+			p2 = ed.dom.getPos(n);
+
+			X = Math.max(p2.x - vp.x, 0) + p1.x;
+			Y = Math.max(p2.y - vp.y, 0) + p1.y;
+
+			DOM.setStyles(id, {
+				'top' : Y+5+'px',
+				'left' : X+5+'px',
+				'display' : 'block'
+			});
+
+			if ( this.mceTout )
+				clearTimeout(this.mceTout);
+
+			this.mceTout = setTimeout( function(){ed.plugins.wordpress._hideButtons();}, 5000 );
+		},
+
+		_hideButtons : function() {
+			if ( !this.mceTout )
+				return;
+
+			if ( document.getElementById('wp_editbtns') )
+				tinymce.DOM.hide('wp_editbtns');
+
+			if ( document.getElementById('wp_gallerybtns') )
+				tinymce.DOM.hide('wp_gallerybtns');
+
+			clearTimeout(this.mceTout);
+			this.mceTout = 0;
+		},
+
+		// Resizes the iframe by a relative height value
+		_resizeIframe : function(ed, tb_id, dy) {
+			var ifr = ed.getContentAreaContainer().firstChild;
+
+			DOM.setStyle(ifr, 'height', ifr.clientHeight + dy); // Resize iframe
+			ed.theme.deltaHeight += dy; // For resize cookie
+		},
+
+		_handleMoreBreak : function(ed, url) {
+			var moreHTML, nextpageHTML;
+
+			moreHTML = '<img src="' + url + '/img/trans.gif" alt="$1" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />';
+			nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />';
+
+			// Load plugin specific CSS into editor
+			ed.onInit.add(function() {
+				ed.dom.loadCSS(url + '/css/content.css');
+			});
+
+			// Display morebreak instead if img in element path
+			ed.onPostRender.add(function() {
+				if (ed.theme.onResolveName) {
+					ed.theme.onResolveName.add(function(th, o) {
+						if (o.node.nodeName == 'IMG') {
+							if ( ed.dom.hasClass(o.node, 'mceWPmore') )
+								o.name = 'wpmore';
+							if ( ed.dom.hasClass(o.node, 'mceWPnextpage') )
+								o.name = 'wppage';
+						}
+
+					});
+				}
+			});
+
+			// Replace morebreak with images
+			ed.onBeforeSetContent.add(function(ed, o) {
+				if ( o.content ) {
+					o.content = o.content.replace(/<!--more(.*?)-->/g, moreHTML);
+					o.content = o.content.replace(/<!--nextpage-->/g, nextpageHTML);
+				}
+			});
+
+			// Replace images with morebreak
+			ed.onPostProcess.add(function(ed, o) {
+				if (o.get)
+					o.content = o.content.replace(/<img[^>]+>/g, function(im) {
+						if (im.indexOf('class="mceWPmore') !== -1) {
+							var m, moretext = (m = im.match(/alt="(.*?)"/)) ? m[1] : '';
+							im = '<!--more'+moretext+'-->';
+						}
+						if (im.indexOf('class="mceWPnextpage') !== -1)
+							im = '<!--nextpage-->';
+
+						return im;
+					});
+			});
+
+			// Set active buttons if user selected pagebreak or more break
+			ed.onNodeChange.add(function(ed, cm, n) {
+				cm.setActive('wp_page', n.nodeName === 'IMG' && ed.dom.hasClass(n, 'mceWPnextpage'));
+				cm.setActive('wp_more', n.nodeName === 'IMG' && ed.dom.hasClass(n, 'mceWPmore'));
+			});
+		}
+	});
+
+	// Register plugin
+	tinymce.PluginManager.add('wordpress', tinymce.plugins.WordPress);
+})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){var a=tinymce.DOM;tinymce.create("tinymce.plugins.WordPress",{mceTout:0,init:function(c,d){var e=this,h=c.getParam("wordpress_adv_toolbar","toolbar2"),g=0,f,b;f='<img src="'+d+'/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+c.getLang("wordpress.wp_more_alt")+'" />';b='<img src="'+d+'/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+c.getLang("wordpress.wp_page_alt")+'" />';if(getUserSetting("hidetb","0")=="1"){c.settings.wordpress_adv_hidden=0}c.onPostRender.add(function(){var i=c.controlManager.get(h);if(c.getParam("wordpress_adv_hidden",1)&&i){a.hide(i.id);e._resizeIframe(c,h,28)}});c.addCommand("WP_More",function(){c.execCommand("mceInsertContent",0,f)});c.addCommand("WP_Page",function(){c.execCommand("mceInsertContent",0,b)});c.addCommand("WP_Help",function(){c.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",width:450,height:420,inline:1})});c.addCommand("WP_Adv",function(){var i=c.controlManager,j=i.get(h).id;if("undefined"==j){return}if(a.isHidden(j)){i.setActive("wp_adv",1);a.show(j);e._resizeIframe(c,h,-28);c.settings.wordpress_adv_hidden=0;setUserSetting("hidetb","1")}else{i.setActive("wp_adv",0);a.hide(j);e._resizeIframe(c,h,28);c.settings.wordpress_adv_hidden=1;setUserSetting("hidetb","0")}});c.addButton("wp_more",{title:"wordpress.wp_more_desc",image:d+"/img/more.gif",cmd:"WP_More"});c.addButton("wp_page",{title:"wordpress.wp_page_desc",image:d+"/img/page.gif",cmd:"WP_Page"});c.addButton("wp_help",{title:"wordpress.wp_help_desc",image:d+"/img/help.gif",cmd:"WP_Help"});c.addButton("wp_adv",{title:"wordpress.wp_adv_desc",image:d+"/img/toolbars.gif",cmd:"WP_Adv"});c.addButton("add_media",{title:"wordpress.add_media",image:d+"/img/media.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_media").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_image",{title:"wordpress.add_image",image:d+"/img/image.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_image").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_video",{title:"wordpress.add_video",image:d+"/img/video.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_video").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.addButton("add_audio",{title:"wordpress.add_audio",image:d+"/img/audio.gif",onclick:function(){tb_show("",tinymce.DOM.get("add_audio").href);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")}});c.onBeforeExecCommand.add(function(p,m,s,l,j){var v=tinymce.DOM,k,i,r,u,t,q;if("mceFullScreen"==m){if("mce_fullscreen"!=p.id&&v.get("add_audio")&&v.get("add_video")&&v.get("add_image")&&v.get("add_media")){p.settings.theme_advanced_buttons1+=",|,add_image,add_video,add_audio,add_media"}}if("JustifyLeft"==m||"JustifyRight"==m||"JustifyCenter"==m){k=p.selection.getNode();if(k.nodeName=="IMG"){q=m.substr(7).toLowerCase();t="align"+q;i=p.dom.getParent(k,"dl.wp-caption");r=p.dom.getParent(k,"div.mceTemp");if(i&&r){u=p.dom.hasClass(i,t)?"alignnone":t;i.className=i.className.replace(/align[^ '"]+\s?/g,"");p.dom.addClass(i,u);if(u=="aligncenter"){p.dom.addClass(r,"mceIEcenter")}else{p.dom.removeClass(r,"mceIEcenter")}j.terminate=true;p.execCommand("mceRepaint")}else{if(p.dom.hasClass(k,t)){p.dom.addClass(k,"alignnone")}else{p.dom.removeClass(k,"alignnone")}}}}});c.onInit.add(function(i){i.onNodeChange.add(function(k,j,m){var l;if(m.nodeName=="IMG"){l=k.dom.getParent(m,"dl.wp-caption")}else{if(m.nodeName=="DIV"&&k.dom.hasClass(m,"mceTemp")){l=m.firstChild;if(!k.dom.hasClass(l,"wp-caption")){l=false}}}if(l){if(k.dom.hasClass(l,"alignleft")){j.setActive("justifyleft",1)}else{if(k.dom.hasClass(l,"alignright")){j.setActive("justifyright",1)}else{if(k.dom.hasClass(l,"aligncenter")){j.setActive("justifycenter",1)}}}}});i.onBeforeSetContent.add(function(j,k){if(k.content){k.content=k.content.replace(/<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi,"<$1$2>");k.content=k.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi,"</$1>")}})});if("undefined"!=typeof wpWordCount){c.onKeyUp.add(function(i,j){if(j.keyCode==g){return}if(13==j.keyCode||8==g||46==g){wpWordCount.wc(i.getContent({format:"raw"}))}g=j.keyCode})}c.onSaveContent.add(function(i,j){if(typeof(switchEditors)=="object"){if(i.isHidden()){j.content=j.element.value}else{j.content=switchEditors.pre_wpautop(j.content)}}});e._handleMoreBreak(c,d);c.addShortcut("alt+shift+c",c.getLang("justifycenter_desc"),"JustifyCenter");c.addShortcut("alt+shift+r",c.getLang("justifyright_desc"),"JustifyRight");c.addShortcut("alt+shift+l",c.getLang("justifyleft_desc"),"JustifyLeft");c.addShortcut("alt+shift+j",c.getLang("justifyfull_desc"),"JustifyFull");c.addShortcut("alt+shift+q",c.getLang("blockquote_desc"),"mceBlockQuote");c.addShortcut("alt+shift+u",c.getLang("bullist_desc"),"InsertUnorderedList");c.addShortcut("alt+shift+o",c.getLang("numlist_desc"),"InsertOrderedList");c.addShortcut("alt+shift+d",c.getLang("striketrough_desc"),"Strikethrough");c.addShortcut("alt+shift+n",c.getLang("spellchecker.desc"),"mceSpellCheck");c.addShortcut("alt+shift+a",c.getLang("link_desc"),"mceLink");c.addShortcut("alt+shift+s",c.getLang("unlink_desc"),"unlink");c.addShortcut("alt+shift+m",c.getLang("image_desc"),"mceImage");c.addShortcut("alt+shift+g",c.getLang("fullscreen.desc"),"mceFullScreen");c.addShortcut("alt+shift+z",c.getLang("wp_adv_desc"),"WP_Adv");c.addShortcut("alt+shift+h",c.getLang("help_desc"),"WP_Help");c.addShortcut("alt+shift+t",c.getLang("wp_more_desc"),"WP_More");c.addShortcut("alt+shift+p",c.getLang("wp_page_desc"),"WP_Page");c.addShortcut("ctrl+s",c.getLang("save_desc"),function(){if("function"==typeof autosave){autosave()}});if(tinymce.isWebKit){c.addShortcut("alt+shift+b",c.getLang("bold_desc"),"Bold");c.addShortcut("alt+shift+i",c.getLang("italic_desc"),"Italic")}c.onInit.add(function(i){tinymce.dom.Event.add(i.getWin(),"scroll",function(j){i.plugins.wordpress._hideButtons()});tinymce.dom.Event.add(i.getBody(),"dragstart",function(j){i.plugins.wordpress._hideButtons()})});c.onBeforeExecCommand.add(function(i,k,j,l){i.plugins.wordpress._hideButtons()});c.onSaveContent.add(function(i,j){i.plugins.wordpress._hideButtons()});c.onMouseDown.add(function(i,j){if(j.target.nodeName!="IMG"){i.plugins.wordpress._hideButtons()}})},getInfo:function(){return{longname:"WordPress Plugin",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"3.0"}},_setEmbed:function(b){return b.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g,function(d,c){return'<img width="300" height="200" src="'+tinymce.baseURL+'/plugins/wordpress/img/trans.gif" class="wp-oembed mceItemNoResize" alt="'+c+'" title="'+c+'" />'})},_getEmbed:function(b){return b.replace(/<img[^>]+>/g,function(c){if(c.indexOf('class="wp-oembed')!=-1){var d=c.match(/alt="([^\"]+)"/);if(d[1]){c="[embed]"+d[1]+"[/embed]"}}return c})},_showButtons:function(f,d){var g=tinyMCE.activeEditor,i,h,b,j=tinymce.DOM,e,c;b=g.dom.getViewPort(g.getWin());i=j.getPos(g.getContentAreaContainer());h=g.dom.getPos(f);e=Math.max(h.x-b.x,0)+i.x;c=Math.max(h.y-b.y,0)+i.y;j.setStyles(d,{top:c+5+"px",left:e+5+"px",display:"block"});if(this.mceTout){clearTimeout(this.mceTout)}this.mceTout=setTimeout(function(){g.plugins.wordpress._hideButtons()},5000)},_hideButtons:function(){if(!this.mceTout){return}if(document.getElementById("wp_editbtns")){tinymce.DOM.hide("wp_editbtns")}if(document.getElementById("wp_gallerybtns")){tinymce.DOM.hide("wp_gallerybtns")}clearTimeout(this.mceTout);this.mceTout=0},_resizeIframe:function(c,e,b){var d=c.getContentAreaContainer().firstChild;a.setStyle(d,"height",d.clientHeight+b);c.theme.deltaHeight+=b},_handleMoreBreak:function(c,d){var e,b;e='<img src="'+d+'/img/trans.gif" alt="$1" class="mceWPmore mceItemNoResize" title="'+c.getLang("wordpress.wp_more_alt")+'" />';b='<img src="'+d+'/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+c.getLang("wordpress.wp_page_alt")+'" />';c.onInit.add(function(){c.dom.loadCSS(d+"/css/content.css")});c.onPostRender.add(function(){if(c.theme.onResolveName){c.theme.onResolveName.add(function(f,g){if(g.node.nodeName=="IMG"){if(c.dom.hasClass(g.node,"mceWPmore")){g.name="wpmore"}if(c.dom.hasClass(g.node,"mceWPnextpage")){g.name="wppage"}}})}});c.onBeforeSetContent.add(function(f,g){if(g.content){g.content=g.content.replace(/<!--more(.*?)-->/g,e);g.content=g.content.replace(/<!--nextpage-->/g,b)}});c.onPostProcess.add(function(f,g){if(g.get){g.content=g.content.replace(/<img[^>]+>/g,function(i){if(i.indexOf('class="mceWPmore')!==-1){var h,j=(h=i.match(/alt="(.*?)"/))?h[1]:"";i="<!--more"+j+"-->"}if(i.indexOf('class="mceWPnextpage')!==-1){i="<!--nextpage-->"}return i})}});c.onNodeChange.add(function(g,f,h){f.setActive("wp_page",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPnextpage"));f.setActive("wp_more",h.nodeName==="IMG"&&g.dom.hasClass(h,"mceWPmore"))})}});tinymce.PluginManager.add("wordpress",tinymce.plugins.WordPress)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js	(revision 17487)
@@ -0,0 +1,97 @@
+/**
+ * editor_plugin_src.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+(function($) {
+	var wpDialogFn = function( fn ) {
+		return function() {
+			if ( this.features.wpDialog )
+				return fn.apply( this, arguments );
+			else
+				return this.parent.apply( this, arguments );
+		};
+	};
+
+	tinymce.create('tinymce.plugins.WPDialogs', {
+		init : function(ed, url) {
+			// Replace window manager
+			ed.onBeforeRenderUI.add(function() {
+				ed.windowManager = new tinymce.WPWindowManager(ed);
+			});
+		},
+
+		getInfo : function() {
+			return {
+				longname : 'WPDialogs',
+				author : 'WordPress',
+				authorurl : 'http://wordpress.org',
+				infourl : 'http://wordpress.org',
+				version : '0.1'
+			};
+		}
+	});
+	
+	$(document).ready(function() {
+		$.widget("wp.wpdialog", $.ui.dialog, {
+			open: function() {
+				// Initialize tinyMCEPopup if it exists.
+				if ( tinyMCEPopup )
+					tinyMCEPopup.init();
+				// Open the dialog.
+				$.ui.dialog.prototype.open.apply( this, arguments );
+				// WebKit leaves focus in the TinyMCE editor unless we shift focus.
+				this.element.focus();
+				this._trigger('refresh');
+			}
+		});
+	});
+
+	tinymce.create('tinymce.WPWindowManager:tinymce.InlineWindowManager', {
+		WPWindowManager : function(ed) {
+			this.parent(ed);
+		},
+
+		open : function(f, p) {
+			var t = this, element;
+			// Can't use wpDialogFn here; this.features isn't set yet.
+			if ( ! f.wpDialog )
+				return this.parent( f, p );
+			else if ( ! f.id )
+				return;
+			
+			element = $('#' + f.id);
+			if ( ! element.length )
+				return;
+			
+			t.features = f;
+			t.params = p;
+			t.onOpen.dispatch(t, f, p);
+			t.element = t.windows[ f.id ] = element;
+			
+			// Store selection
+			t.bookmark = t.editor.selection.getBookmark(1);
+			
+			element.wpdialog({
+				title: f.title,
+				width: f.width,
+				height: f.height,
+				modal: true,
+				dialogClass: 'wp-dialog',
+				zIndex: 300000
+			});
+		},
+		close : wpDialogFn(function() {
+			this.element.wpdialog('close');
+		})
+	});
+
+	// Register plugin
+	tinymce.PluginManager.add('wpdialogs', tinymce.plugins.WPDialogs);
+})(jQuery);
+
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(b){var a=function(c){return function(){if(this.features.wpDialog){return c.apply(this,arguments)}else{return this.parent.apply(this,arguments)}}};tinymce.create("tinymce.plugins.WPDialogs",{init:function(c,d){c.onBeforeRenderUI.add(function(){c.windowManager=new tinymce.WPWindowManager(c)})},getInfo:function(){return{longname:"WPDialogs",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"0.1"}}});b(document).ready(function(){b.widget("wp.wpdialog",b.ui.dialog,{open:function(){if(tinyMCEPopup){tinyMCEPopup.init()}b.ui.dialog.prototype.open.apply(this,arguments);this.element.focus();this._trigger("refresh")}})});tinymce.create("tinymce.WPWindowManager:tinymce.InlineWindowManager",{WPWindowManager:function(c){this.parent(c)},open:function(e,g){var d=this,c;if(!e.wpDialog){return this.parent(e,g)}else{if(!e.id){return}}c=b("#"+e.id);if(!c.length){return}d.features=e;d.params=g;d.onOpen.dispatch(d,e,g);d.element=d.windows[e.id]=c;d.bookmark=d.editor.selection.getBookmark(1);c.wpdialog({title:e.title,width:e.width,height:e.height,modal:true,dialogClass:"wp-dialog",zIndex:300000})},close:a(function(){this.element.wpdialog("close")})});tinymce.PluginManager.add("wpdialogs",tinymce.plugins.WPDialogs)})(jQuery);
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js	(revision 17487)
@@ -0,0 +1,432 @@
+/**
+ * popup.js
+ * 
+ * An altered version of tinyMCEPopup to work in the same window as tinymce.
+ * 
+ * ------------------------------------------------------------------
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+// Some global instances
+
+/**
+ * TinyMCE popup/dialog helper class. This gives you easy access to the
+ * parent editor instance and a bunch of other things. It's higly recommended
+ * that you load this script into your dialogs.
+ *
+ * @static
+ * @class tinyMCEPopup
+ */
+var tinyMCEPopup = {
+	/**
+	 * Initializes the popup this will be called automatically.
+	 *
+	 * @method init
+	 */
+	init : function() {
+		var t = this, w, ti;
+
+		// Find window & API
+		w = t.getWin();
+		tinymce = w.tinymce;
+		tinyMCE = w.tinyMCE;
+		t.editor = tinymce.EditorManager.activeEditor;
+		t.params = t.editor.windowManager.params;
+		t.features = t.editor.windowManager.features;
+		t.dom = tinymce.dom;
+
+		// Setup on init listeners
+		t.listeners = [];
+		t.onInit = {
+			add : function(f, s) {
+				t.listeners.push({func : f, scope : s});
+			}
+		};
+
+		t.isWindow = false;
+		t.id = t.features.id;
+		t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
+	},
+
+	/**
+	 * Returns the reference to the parent window that opened the dialog.
+	 *
+	 * @method getWin
+	 * @return {Window} Reference to the parent window that opened the dialog.
+	 */
+	getWin : function() {
+		return window;
+	},
+
+	/**
+	 * Returns a window argument/parameter by name.
+	 *
+	 * @method getWindowArg
+	 * @param {String} n Name of the window argument to retrive.
+	 * @param {String} dv Optional default value to return.
+	 * @return {String} Argument value or default value if it wasn't found.
+	 */
+	getWindowArg : function(n, dv) {
+		var v = this.params[n];
+
+		return tinymce.is(v) ? v : dv;
+	},
+
+	/**
+	 * Returns a editor parameter/config option value.
+	 *
+	 * @method getParam
+	 * @param {String} n Name of the editor config option to retrive.
+	 * @param {String} dv Optional default value to return.
+	 * @return {String} Parameter value or default value if it wasn't found.
+	 */
+	getParam : function(n, dv) {
+		return this.editor.getParam(n, dv);
+	},
+
+	/**
+	 * Returns a language item by key.
+	 *
+	 * @method getLang
+	 * @param {String} n Language item like mydialog.something.
+	 * @param {String} dv Optional default value to return.
+	 * @return {String} Language value for the item like "my string" or the default value if it wasn't found.
+	 */
+	getLang : function(n, dv) {
+		return this.editor.getLang(n, dv);
+	},
+
+	/**
+	 * Executed a command on editor that opened the dialog/popup.
+	 *
+	 * @method execCommand
+	 * @param {String} cmd Command to execute.
+	 * @param {Boolean} ui Optional boolean value if the UI for the command should be presented or not.
+	 * @param {Object} val Optional value to pass with the comman like an URL.
+	 * @param {Object} a Optional arguments object.
+	 */
+	execCommand : function(cmd, ui, val, a) {
+		a = a || {};
+		a.skip_focus = 1;
+
+		this.restoreSelection();
+		return this.editor.execCommand(cmd, ui, val, a);
+	},
+
+	/**
+	 * Resizes the dialog to the inner size of the window. This is needed since various browsers
+	 * have different border sizes on windows.
+	 *
+	 * @method resizeToInnerSize
+	 */
+	resizeToInnerSize : function() {
+		var t = this;
+
+		// Detach it to workaround a Chrome specific bug
+		// https://sourceforge.net/tracker/?func=detail&atid=635682&aid=2926339&group_id=103281
+		setTimeout(function() {
+			var vp = t.dom.getViewPort(window);
+
+			t.editor.windowManager.resizeBy(
+				t.getWindowArg('mce_width') - vp.w,
+				t.getWindowArg('mce_height') - vp.h,
+				t.id || window
+			);
+		}, 0);
+	},
+
+	/**
+	 * Will executed the specified string when the page has been loaded. This function
+	 * was added for compatibility with the 2.x branch.
+	 *
+	 * @method executeOnLoad
+	 * @param {String} s String to evalutate on init.
+	 */
+	executeOnLoad : function(s) {
+		this.onInit.add(function() {
+			eval(s);
+		});
+	},
+
+	/**
+	 * Stores the current editor selection for later restoration. This can be useful since some browsers
+	 * looses it's selection if a control element is selected/focused inside the dialogs.
+	 *
+	 * @method storeSelection
+	 */
+	storeSelection : function() {
+		this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark(1);
+	},
+
+	/**
+	 * Restores any stored selection. This can be useful since some browsers
+	 * looses it's selection if a control element is selected/focused inside the dialogs.
+	 *
+	 * @method restoreSelection
+	 */
+	restoreSelection : function() {
+		var t = tinyMCEPopup;
+
+		if (!t.isWindow && tinymce.isIE)
+			t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
+	},
+
+	/**
+	 * Loads a specific dialog language pack. If you pass in plugin_url as a arugment
+	 * when you open the window it will load the <plugin url>/langs/<code>_dlg.js lang pack file.
+	 *
+	 * @method requireLangPack
+	 */
+	requireLangPack : function() {
+		var t = this, u = t.getWindowArg('plugin_url') || t.getWindowArg('theme_url');
+
+		if (u && t.editor.settings.language && t.features.translate_i18n !== false) {
+			u += '/langs/' + t.editor.settings.language + '_dlg.js';
+
+			if (!tinymce.ScriptLoader.isDone(u)) {
+				document.write('<script type="text/javascript" src="' + tinymce._addVer(u) + '"></script>');
+				tinymce.ScriptLoader.markDone(u);
+			}
+		}
+	},
+
+	/**
+	 * Executes a color picker on the specified element id. When the user
+	 * then selects a color it will be set as the value of the specified element.
+	 *
+	 * @method pickColor
+	 * @param {DOMEvent} e DOM event object.
+	 * @param {string} element_id Element id to be filled with the color value from the picker.
+	 */
+	pickColor : function(e, element_id) {
+		this.execCommand('mceColorPicker', true, {
+			color : document.getElementById(element_id).value,
+			func : function(c) {
+				document.getElementById(element_id).value = c;
+
+				try {
+					document.getElementById(element_id).onchange();
+				} catch (ex) {
+					// Try fire event, ignore errors
+				}
+			}
+		});
+	},
+
+	/**
+	 * Opens a filebrowser/imagebrowser this will set the output value from
+	 * the browser as a value on the specified element.
+	 *
+	 * @method openBrowser
+	 * @param {string} element_id Id of the element to set value in.
+	 * @param {string} type Type of browser to open image/file/flash.
+	 * @param {string} option Option name to get the file_broswer_callback function name from.
+	 */
+	openBrowser : function(element_id, type, option) {
+		tinyMCEPopup.restoreSelection();
+		this.editor.execCallback('file_browser_callback', element_id, document.getElementById(element_id).value, type, window);
+	},
+
+	/**
+	 * Creates a confirm dialog. Please don't use the blocking behavior of this
+	 * native version use the callback method instead then it can be extended.
+	 *
+	 * @method confirm
+	 * @param {String} t Title for the new confirm dialog.
+	 * @param {function} cb Callback function to be executed after the user has selected ok or cancel.
+	 * @param {Object} s Optional scope to execute the callback in.
+	 */
+	confirm : function(t, cb, s) {
+		this.editor.windowManager.confirm(t, cb, s, window);
+	},
+
+	/**
+	 * Creates a alert dialog. Please don't use the blocking behavior of this
+	 * native version use the callback method instead then it can be extended.
+	 *
+	 * @method alert
+	 * @param {String} t Title for the new alert dialog.
+	 * @param {function} cb Callback function to be executed after the user has selected ok.
+	 * @param {Object} s Optional scope to execute the callback in.
+	 */
+	alert : function(tx, cb, s) {
+		this.editor.windowManager.alert(tx, cb, s, window);
+	},
+
+	/**
+	 * Closes the current window.
+	 *
+	 * @method close
+	 */
+	close : function() {
+		var t = this;
+
+		// To avoid domain relaxing issue in Opera
+		function close() {
+			t.editor.windowManager.close(window);
+			t.editor = null;
+		};
+
+		if (tinymce.isOpera)
+			t.getWin().setTimeout(close, 0);
+		else
+			close();
+	},
+
+	// Internal functions	
+
+	_restoreSelection : function() {
+		var e = window.event.srcElement;
+
+		if (e.nodeName == 'INPUT' && (e.type == 'submit' || e.type == 'button'))
+			tinyMCEPopup.restoreSelection();
+	},
+
+/*	_restoreSelection : function() {
+		var e = window.event.srcElement;
+
+		// If user focus a non text input or textarea
+		if ((e.nodeName != 'INPUT' && e.nodeName != 'TEXTAREA') || e.type != 'text')
+			tinyMCEPopup.restoreSelection();
+	},*/
+
+	_onDOMLoaded : function() {
+		var t = tinyMCEPopup, ti = document.title, bm, h, nv;
+
+		if (t.domLoaded)
+			return;
+
+		t.domLoaded = 1;
+
+		tinyMCEPopup.init();
+
+		// Translate page
+		if (t.features.translate_i18n !== false) {
+			h = document.body.innerHTML;
+
+			// Replace a=x with a="x" in IE
+			if (tinymce.isIE)
+				h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
+
+			document.dir = t.editor.getParam('directionality','');
+
+			if ((nv = t.editor.translate(h)) && nv != h)
+				document.body.innerHTML = nv;
+
+			if ((nv = t.editor.translate(ti)) && nv != ti)
+				document.title = ti = nv;
+		}
+
+		document.body.style.display = '';
+
+		// Restore selection in IE when focus is placed on a non textarea or input element of the type text
+		if (tinymce.isIE) {
+			document.attachEvent('onmouseup', tinyMCEPopup._restoreSelection);
+
+			// Add base target element for it since it would fail with modal dialogs
+			t.dom.add(t.dom.select('head')[0], 'base', {target : '_self'});
+		}
+
+		t.restoreSelection();
+
+		// Set inline title
+		if (!t.isWindow)
+			t.editor.windowManager.setTitle(window, ti);
+		else
+			window.focus();
+
+		if (!tinymce.isIE && !t.isWindow) {
+			tinymce.dom.Event._add(document, 'focus', function() {
+				t.editor.windowManager.focus(t.id);
+			});
+		}
+
+		// Patch for accessibility
+		tinymce.each(t.dom.select('select'), function(e) {
+			e.onkeydown = tinyMCEPopup._accessHandler;
+		});
+
+		// Call onInit
+		// Init must be called before focus so the selection won't get lost by the focus call
+		tinymce.each(t.listeners, function(o) {
+			o.func.call(o.scope, t.editor);
+		});
+
+		// Move focus to window
+		if (t.getWindowArg('mce_auto_focus', true)) {
+			window.focus();
+
+			// Focus element with mceFocus class
+			tinymce.each(document.forms, function(f) {
+				tinymce.each(f.elements, function(e) {
+					if (t.dom.hasClass(e, 'mceFocus') && !e.disabled) {
+						e.focus();
+						return false; // Break loop
+					}
+				});
+			});
+		}
+
+		document.onkeyup = tinyMCEPopup._closeWinKeyHandler;
+	},
+
+	_accessHandler : function(e) {
+		e = e || window.event;
+
+		if (e.keyCode == 13 || e.keyCode == 32) {
+			e = e.target || e.srcElement;
+
+			if (e.onchange)
+				e.onchange();
+
+			return tinymce.dom.Event.cancel(e);
+		}
+	},
+
+	_closeWinKeyHandler : function(e) {
+		e = e || window.event;
+
+		if (e.keyCode == 27)
+			tinyMCEPopup.close();
+	},
+
+	_wait : function() {
+		// Use IE method
+		if (document.attachEvent) {
+			document.attachEvent("onreadystatechange", function() {
+				if (document.readyState === "complete") {
+					document.detachEvent("onreadystatechange", arguments.callee);
+					tinyMCEPopup._onDOMLoaded();
+				}
+			});
+
+			if (document.documentElement.doScroll && window == window.top) {
+				(function() {
+					if (tinyMCEPopup.domLoaded)
+						return;
+
+					try {
+						// If IE is used, use the trick by Diego Perini
+						// http://javascript.nwbox.com/IEContentLoaded/
+						document.documentElement.doScroll("left");
+					} catch (ex) {
+						setTimeout(arguments.callee, 0);
+						return;
+					}
+
+					tinyMCEPopup._onDOMLoaded();
+				})();
+			}
+
+			document.attachEvent('onload', tinyMCEPopup._onDOMLoaded);
+		} else if (document.addEventListener) {
+			window.addEventListener('DOMContentLoaded', tinyMCEPopup._onDOMLoaded, false);
+			window.addEventListener('load', tinyMCEPopup._onDOMLoaded, false);
+		}
+	}
+};
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpdialogs/js/popup.js	(revision 17487)
@@ -0,0 +1,1 @@
+var tinyMCEPopup={init:function(){var b=this,a,c;a=b.getWin();tinymce=a.tinymce;tinyMCE=a.tinyMCE;b.editor=tinymce.EditorManager.activeEditor;b.params=b.editor.windowManager.params;b.features=b.editor.windowManager.features;b.dom=tinymce.dom;b.listeners=[];b.onInit={add:function(e,d){b.listeners.push({func:e,scope:d})}};b.isWindow=false;b.id=b.features.id;b.editor.windowManager.onOpen.dispatch(b.editor.windowManager,window)},getWin:function(){return window},getWindowArg:function(c,b){var a=this.params[c];return tinymce.is(a)?a:b},getParam:function(b,a){return this.editor.getParam(b,a)},getLang:function(b,a){return this.editor.getLang(b,a)},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},resizeToInnerSize:function(){var a=this;setTimeout(function(){var b=a.dom.getViewPort(window);a.editor.windowManager.resizeBy(a.getWindowArg("mce_width")-b.w,a.getWindowArg("mce_height")-b.h,a.id||window)},0)},executeOnLoad:function(s){this.onInit.add(function(){eval(s)})},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark(1)},restoreSelection:function(){var a=tinyMCEPopup;if(!a.isWindow&&tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},requireLangPack:function(){var b=this,a=b.getWindowArg("plugin_url")||b.getWindowArg("theme_url");if(a&&b.editor.settings.language&&b.features.translate_i18n!==false){a+="/langs/"+b.editor.settings.language+"_dlg.js";if(!tinymce.ScriptLoader.isDone(a)){document.write('<script type="text/javascript" src="'+tinymce._addVer(a)+'"><\/script>');tinymce.ScriptLoader.markDone(a)}}},pickColor:function(b,a){this.execCommand("mceColorPicker",true,{color:document.getElementById(a).value,func:function(e){document.getElementById(a).value=e;try{document.getElementById(a).onchange()}catch(d){}}})},openBrowser:function(a,c,b){tinyMCEPopup.restoreSelection();this.editor.execCallback("file_browser_callback",a,document.getElementById(a).value,c,window)},confirm:function(b,a,c){this.editor.windowManager.confirm(b,a,c,window)},alert:function(b,a,c){this.editor.windowManager.alert(b,a,c,window)},close:function(){var a=this;function b(){a.editor.windowManager.close(window);a.editor=null}if(tinymce.isOpera){a.getWin().setTimeout(b,0)}else{b()}},_restoreSelection:function(){var a=window.event.srcElement;if(a.nodeName=="INPUT"&&(a.type=="submit"||a.type=="button")){tinyMCEPopup.restoreSelection()}},_onDOMLoaded:function(){var b=tinyMCEPopup,d=document.title,e,c,a;if(b.domLoaded){return}b.domLoaded=1;tinyMCEPopup.init();if(b.features.translate_i18n!==false){c=document.body.innerHTML;if(tinymce.isIE){c=c.replace(/ (value|title|alt)=([^"][^\s>]+)/gi,' $1="$2"')}document.dir=b.editor.getParam("directionality","");if((a=b.editor.translate(c))&&a!=c){document.body.innerHTML=a}if((a=b.editor.translate(d))&&a!=d){document.title=d=a}}document.body.style.display="";if(tinymce.isIE){document.attachEvent("onmouseup",tinyMCEPopup._restoreSelection);b.dom.add(b.dom.select("head")[0],"base",{target:"_self"})}b.restoreSelection();if(!b.isWindow){b.editor.windowManager.setTitle(window,d)}else{window.focus()}if(!tinymce.isIE&&!b.isWindow){tinymce.dom.Event._add(document,"focus",function(){b.editor.windowManager.focus(b.id)})}tinymce.each(b.dom.select("select"),function(f){f.onkeydown=tinyMCEPopup._accessHandler});tinymce.each(b.listeners,function(f){f.func.call(f.scope,b.editor)});if(b.getWindowArg("mce_auto_focus",true)){window.focus();tinymce.each(document.forms,function(g){tinymce.each(g.elements,function(f){if(b.dom.hasClass(f,"mceFocus")&&!f.disabled){f.focus();return false}})})}document.onkeyup=tinyMCEPopup._closeWinKeyHandler},_accessHandler:function(a){a=a||window.event;if(a.keyCode==13||a.keyCode==32){a=a.target||a.srcElement;if(a.onchange){a.onchange()}return tinymce.dom.Event.cancel(a)}},_closeWinKeyHandler:function(a){a=a||window.event;if(a.keyCode==27){tinyMCEPopup.close()}},_wait:function(){if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);tinyMCEPopup._onDOMLoaded()}});if(document.documentElement.doScroll&&window==window.top){(function(){if(tinyMCEPopup.domLoaded){return}try{document.documentElement.doScroll("left")}catch(a){setTimeout(arguments.callee,0);return}tinyMCEPopup._onDOMLoaded()})()}document.attachEvent("onload",tinyMCEPopup._onDOMLoaded)}else{if(document.addEventListener){window.addEventListener("DOMContentLoaded",tinyMCEPopup._onDOMLoaded,false);window.addEventListener("load",tinyMCEPopup._onDOMLoaded,false)}}}};
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css	(revision 17487)
@@ -0,0 +1,68 @@
+
+body#media-upload ul#sidemenu {
+	left: auto;
+	right: 0;
+}
+
+#basic .align .field label {
+	display: block;
+	float: right;
+	padding: 0 24px 0 0;
+	margin: 5px 3px 5px 5px; 
+}
+
+.align .field input {
+	display: block;
+	float: right;
+	margin: 5px 15px 5px 0;
+}
+
+tr.image-size label {
+	margin: 0;
+}
+
+tr.image-size input {
+	margin: 3px 15px 0 5px;
+}
+
+.image-align-none-label,
+.image-align-left-label,
+.image-align-center-label,
+.image-align-right-label {
+	background-position: center right;
+}
+
+#media-upload .describe th.label {
+	text-align: right;
+}
+
+.show-align,
+.alignright,
+#img_size {
+	float: left;
+}
+
+tr.image-size label,
+tr.image-size input,
+#img_dim label,
+#img_dim input,
+#img_prop label,
+#img_prop input,
+#img_size_div,
+.alignleft {
+	float: right;
+}
+
+#img_dim label,
+#img_prop label {
+	margin: 5px 0pt;
+}
+
+#img_dim input,
+#img_prop input {
+	margin: 0 5px 0 10px;
+}
+
+#img_size_title {
+	text-align: left;
+}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css	(revision 17487)
@@ -0,0 +1,358 @@
+
+html, body {
+	background-color: #fff;
+	margin: 0;
+	padding: 0;
+}
+
+.submit input,
+.button,
+.button-primary,
+.button-secondary,
+.button-highlighted {
+	font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+	text-decoration: none;
+	font-size: 11px !important;
+	line-height: 16px;
+	padding: 2px 8px;
+	cursor: pointer;
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 11px;
+	-khtml-border-radius: 11px;
+	-webkit-border-radius: 11px;
+	border-radius: 11px;
+	-moz-box-sizing: content-box;
+	-webkit-box-sizing: content-box;
+	-khtml-box-sizing: content-box;
+	box-sizing: content-box;
+}
+
+a.button {
+	padding: 4px 8px;
+}
+
+textarea,
+input,
+select {
+	font: 13px Verdana, Arial, Helvetica, sans-serif;
+	margin: 1px;
+	padding: 3px;
+}
+
+p.help {
+	margin: 4px 0;
+	font-size: 12px;
+	font-style: italic;
+}
+
+body, td {
+	font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
+}
+
+abbr.required {
+	color: #FF0000;
+	text-align: left;
+}
+
+img.alignright,
+.alignright {
+	float: right;
+	margin-left: 5px;
+}
+
+img.alignleft,
+.alignleft {
+	float: left;
+	margin-right: 5px;
+}
+
+img.aligncenter {
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+label {
+	cursor: pointer;
+}
+
+th.label {
+	width: 107px;
+}
+
+#media-upload #basic th.label {
+	padding: 5px 5px 5px 0;
+}
+
+.show-align {
+	height: 200px;
+	width: 480px;
+	float: right;
+	background-color: #f1f1f1;
+	cursor: default;
+	-moz-user-select: none;
+	user-select: none;
+	overflow: hidden;
+}
+
+#img-edit {
+	border: 1px solid #dfdfdf;
+	width: 623px;
+	margin: 15px auto;
+}
+
+#media-upload .media-upload-form table.describe {
+	border-top-style: none;
+	border-top-width: 0;
+}
+
+#img_demo_txt {
+	font-size: 9px;
+	line-height: 13px;
+	font-family: Monaco,"Courier New",Courier,monospace;
+	color: #888;
+}
+
+#img_demo {
+	padding: 0;
+}
+
+#saveeditimg {
+	padding: 10px 0 0 5px;
+	border-top: 1px solid #ccc;
+}
+
+#sidemenu,
+#sidemenu li {
+	list-style: none;
+}
+
+#sidemenu li {
+	display: inline;
+}
+
+#sidemenu a {
+	border-bottom-style: solid;
+	border-bottom-width: 1px;
+	border-top-style: solid;
+	border-top-width: 1px;
+	display: block;
+	float: left;
+	height: 28px;
+	line-height: 28px;
+	text-decoration: none;
+	text-align: center;
+	white-space: nowrap;
+	margin: 0;
+	padding: 0pt 7px;
+}
+
+#sidemenu a.current {
+	-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-style: solid;
+	border-width: 1px;
+	font-weight: normal;
+}
+
+#adv_settings .field label {
+	padding: 0 5px 5px;
+}
+
+#media-upload h3 {
+	clear: both;
+	padding: 0pt 0pt 3px;
+	border-bottom-style: solid;
+	border-bottom-width: 1px;
+	font-family: Georgia,"Times New Roman",Times,serif;
+	font-size: 20px;
+	font-weight: normal;
+	line-height: normal;
+	margin: 0 0 10px -4px;
+	padding: 15px 0 3px;
+	border-bottom-color: #DADADA;
+	color: #5A5A5A;
+}
+
+#img_dim #width,
+#img_dim #height,
+#img_prop #border,
+#img_prop #vspace,
+#img_prop #hspace {
+	width: 36px;
+}
+
+#img_dim abbr {
+	padding: 0 4px;
+}
+
+#show_align_sp {
+	width: 115px;
+}
+
+#img_dim input,
+#img_prop input {
+	margin-right: 10px;
+}
+
+#basic .align .field label {
+	padding: 0 0 0 24px;
+}
+
+#basic {
+	padding-top: 2px;
+}
+
+td {
+	padding: 2px 0;
+}
+
+#img_size {
+	float: right;
+	text-align: center;
+	cursor: pointer;
+	background-color: #f1f1f1;
+	padding: 5px 0;
+	width: 45px;
+}
+
+#img_size div {
+	font-size: 10px;
+	padding: 2px;
+	border: 1px solid #f1f1f1;
+	line-height: 15px;
+	height: 15px;
+	-moz-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+	color: #07273E;
+}
+
+#img_size div#s100 {
+	border-color: #A3A3A3;
+	background-color: #E5E5E5;
+}
+
+#img_size_div {
+	width: 100px;
+	float: left;
+	cursor: default;
+}
+
+#img_size_title {
+	margin: 0 7px 5px;
+	text-align: right;
+	font-weight: bold;
+}
+
+#img_align_td {
+	padding: 2px 0 8px;
+}
+
+#media-upload tr.align td.field {
+	text-align: center;
+}
+
+.describe td {
+	vertical-align: middle;
+}
+
+#media-upload .describe th.label {
+	padding-top: .5em;
+	text-align: left;
+}
+
+#media-upload .describe {
+	border-top-width: 1px;
+	border-top-style: solid;
+	padding: 5px;
+	width: 100%;
+	clear: both;
+	cursor: default;
+}
+
+form {
+	margin: 1em;
+}
+
+.describe input[type="text"],
+.describe textarea {
+	width: 460px;
+	border: 1px solid #dfdfdf;
+	-moz-border-radius: 4px;
+ 	-khtml-border-radius: 4px;
+ 	-webkit-border-radius: 4px;
+	border-radius: 4px;
+}
+
+.media-upload-form label,
+.media-upload-form legend {
+	font-weight: bold;
+	font-size: 12px;
+	color: #464646;
+}
+
+.align .field label {
+	display: inline;
+	padding: 0 0 0 28px;
+	margin: 0 1em 0 0;
+}
+.image-align-none-label {
+	background: url(../../../../../../wp-admin/images/align-none.png) no-repeat center left;
+}
+
+.image-align-left-label {
+	background: url(../../../../../../wp-admin/images/align-left.png) no-repeat center left;
+}
+
+.image-align-center-label {
+	background: url(../../../../../../wp-admin/images/align-center.png) no-repeat center left;
+}
+
+.image-align-right-label {
+	background: url(../../../../../../wp-admin/images/align-right.png) no-repeat center left;
+}
+
+div#media-upload-header {
+	margin: 0;
+	padding: 0 5px;
+	font-weight: bold;
+	position: relative;
+	border-bottom-width: 1px;
+	border-bottom-style: solid;
+	height: 2.5em;
+}
+
+body#media-upload ul#sidemenu {
+	font-weight: normal;
+	margin: 0 5px;
+	position: relative;
+	left: 0px;
+	bottom: -4px;
+}
+
+div#media-upload-error {
+	margin: 1em;
+	font-weight: bold;
+}
+
+* html #sidemenu li {
+	zoom: 100%;
+}
+
+* html #sidemenu a {
+	height: 27px;
+	line-height: 26px;
+}
+
+* html input {
+	border: 1px solid #ddd;
+}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html	(revision 17487)
@@ -0,0 +1,275 @@
+<!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" lang="en-US">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title></title>
+
+<script type="text/javascript" src="js/editimage.js?ver=327"></script>
+<script type="text/javascript" src="../../utils/form_utils.js?ver=3223"></script>
+
+<link rel="stylesheet" href="css/editimage.css?ver=327" type="text/css" media="all" />
+
+<script type="text/javascript">
+if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
+	document.write('<link rel="stylesheet" href="css/editimage-rtl.css?ver=3223" type="text/css" media="all" />');
+</script>
+<base target="_self" />
+</head>
+
+<body id="media-upload" style="display:none;">
+<div id="media-upload-header">
+	<ul id="sidemenu">
+	<li><a href="javascript:;" id="tab_basic" class="current" onclick="wpImage.setTabs(this);">{#wpeditimage.edit_img}</a></li>
+	<li><a href="javascript:;" id="tab_advanced" onclick="wpImage.setTabs(this);">{#wpeditimage.adv_settings}</a></li>
+	</ul>
+</div>
+
+<div id="img-edit">
+<form class="media-upload-form" action="" onsubmit="wpImage.update();">
+	<div id="img_size_div">
+		<div id="img_size_title">{#wpeditimage.size}</div>
+		<div id="img_size" onmouseout="wpImage.showSizeRem()">
+			<div id="s130" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s130}</div>
+			<div id="s120" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s120}</div>
+			<div id="s110" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s110}</div>
+			<div id="s100" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s100}</div>
+			<div id="s90" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s90}</div>
+			<div id="s80" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s80}</div>
+			<div id="s70" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s70}</div>
+			<div id="s60" onmouseover="wpImage.showSize(this)" onclick="wpImage.imgEditSize(this)">{#wpeditimage.s60}</div>
+		</div>
+	</div>
+	<div class="show-align" id="show_align">
+		<img id="img_demo" src="img/image.png" alt="" />
+		<span id="img_demo_txt">
+		Lorem ipsum dolor sit amet consectetuer velit pretium euismod ipsum enim. Mi cursus at a mollis senectus id arcu gravida quis urna. Sed et felis id tempus Morbi mauris tincidunt enim In mauris. Pede eu risus velit libero natoque enim lorem adipiscing ipsum consequat. In malesuada et sociis tincidunt tempus pellentesque cursus convallis ipsum Suspendisse. Risus In ac quis ut Nunc convallis laoreet ante Suspendisse Nam. Amet amet urna condimentum Vestibulum sem at Curabitur lorem et cursus. Sodales tortor fermentum leo dui habitant Nunc Sed Vestibulum.
+		Ut lorem In penatibus libero id ipsum sagittis nec elit Sed. Condimentum eget Vivamus vel consectetuer lorem molestie turpis amet tellus id. Condimentum vel ridiculus Fusce sed pede Nam nunc sodales eros tempor. Sit lacus magna dictumst Curabitur fringilla auctor id vitae wisi facilisi. Fermentum eget turpis felis velit leo Nunc Proin orci molestie Praesent. Curabitur tellus scelerisque suscipit ut sem amet cursus mi Morbi eu. Donec libero Vestibulum augue et mollis accumsan ornare condimentum In enim. Leo eget ac consectetuer quis condimentum malesuada.
+		Condimentum commodo et Lorem fringilla malesuada libero volutpat sem tellus enim. Tincidunt sed at Aenean nec nonummy porttitor Nam Sed Nulla ut. Auctor leo In aliquet Curabitur eros et velit Quisque justo morbi. Et vel mauris sit nulla semper vitae et quis at dui. Id at elit laoreet justo eu mauris Quisque et interdum pharetra. Nullam accumsan interdum Maecenas condimentum quis quis Fusce a sollicitudin Sed. Non Quisque Vivamus congue porttitor non semper ipsum porttitor quis vel. Donec eros lacus volutpat et tincidunt sem convallis id venenatis sit. Consectetuer odio.
+		Semper faucibus Morbi nulla convallis orci Aliquam Sed porttitor et Pellentesque. Venenatis laoreet lorem id a a Morbi augue turpis id semper. Arcu volutpat ac mauris Vestibulum fringilla Aenean condimentum nibh sed id. Sagittis eu lacus orci urna tellus tellus pretium Curabitur dui nunc. Et nibh eu eu nibh adipiscing at lorem Vestibulum adipiscing augue. Magna convallis Phasellus dolor malesuada Curabitur ornare adipiscing tellus Aliquam tempus. Id Aliquam Integer augue Nulla consectetuer ac Donec Curabitur tincidunt et. Id vel Nunc amet lacus dui magna ridiculus penatibus laoreet Duis. Enim sagittis nibh quis Nulla nec laoreet vel Maecenas mattis vel.
+		</span>
+	</div>
+
+	<div id="div_basic">
+	<table id="basic" class="describe">
+		<tbody>
+
+		<tr class="align">
+			<th valign="top" scope="row" class="label">
+				<label for="img_align_td">
+				<span class="alignleft">{#contextmenu.align}</span>
+				</label>
+			</th>
+			<td class="field" id="img_align_td">
+				<input type="radio" onclick="wpImage.imgAlignCls('alignnone')" name="img_align" id="alignnone" value="alignnone" />
+				<label for="alignnone" class="align image-align-none-label">{#wpeditimage.none}</label>
+
+				<input type="radio" onclick="wpImage.imgAlignCls('alignleft')" name="img_align" id="alignleft" value="alignleft" />
+				<label for="alignleft" class="align image-align-left-label">{#contextmenu.left}</label>
+
+				<input type="radio" onclick="wpImage.imgAlignCls('aligncenter')" name="img_align" id="aligncenter" value="aligncenter" />
+				<label for="aligncenter" class="align image-align-center-label">{#contextmenu.center}</label>
+
+				<input type="radio" onclick="wpImage.imgAlignCls('alignright')" name="img_align" id="alignright" value="alignright" />
+				<label for="alignright" class="align image-align-right-label">{#contextmenu.right}</label>
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="img_title">
+				<span class="alignleft">{#wpeditimage.img_title}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="img_title" name="img_title" value="" aria-required="true" size="60" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="img_alt">
+				<span class="alignleft">{#wpeditimage.alt}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="img_alt" name="img_alt" value="" size="60" />
+			</td>
+		</tr>
+
+		<tr id="cap_field">
+			<th valign="top" scope="row" class="label">
+				<label for="img_cap">
+				<span class="alignleft">{#wpeditimage.caption}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="img_cap" name="img_cap" value="" size="60" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="link_href">
+				<span class="alignleft" id="lb_link_href">{#advanced_dlg.link_url}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="link_href" name="link_href" value="" size="60" /><br />
+				<input type="button" class="button" onclick="wpImage.I('link_href').value='';" value="{#wpeditimage.none}" />
+				<input type="button" class="button" id="img_url_current" onclick="wpImage.img_seturl('current')" value="{#wpeditimage.current_link}" />
+				<input type="button" class="button" id="img_url_img" onclick="wpImage.img_seturl('link')" value="{#wpeditimage.link_to_img}" />
+				<p class="help">{#wpeditimage.link_help}</p>
+			</td>
+		</tr>
+	</tbody>
+	</table></div>
+
+	<div id="div_advanced" style="display:none;">
+	<h3>{#wpeditimage.adv_img_settings}</h3>
+	<table id="adv_settings_img" class="describe">
+		<tbody>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="img_src">
+				<span class="alignleft">{#wpeditimage.source}</span>
+				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="img_src" name="img_src" value="" onblur="wpImage.checkVal(this)" aria-required="true" size="60" />
+			</td>
+		</tr>
+
+		<tr id="img_dim">
+			<th valign="top" scope="row" class="label">
+				<label>
+				<span class="alignleft">{#wpeditimage.size}</span>
+				</label>
+			</th>
+			<td class="field">
+				<label for="width">{#wpeditimage.width}</label>
+				<input type="text" maxlength="5" id="width" name="width"  value="" />
+
+				<label for="height">{#wpeditimage.height}</label>
+				<input type="text" maxlength="5" id="height" name="height" value="" />
+
+				<input type="button" class="button" id="orig_size" name="orig_size" value="{#wpeditimage.orig_size}" onclick="wpImage.origSize();" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="img_classes">
+				<span class="alignleft">{#wpeditimage.css}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="img_classes" name="img_classes" value="" size="60" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="img_style">
+				<span class="alignleft">{#advanced.style_select}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="img_style" name="img_style" value="" size="60" onblur="wpImage.demoSetStyle();" />
+			</td>
+		</tr>
+
+		<tr id="img_prop">
+			<th valign="top" scope="row" class="label">
+				<label for="img_prop">
+					<span class="alignleft">{#advanced.image_props_desc}</span>
+				</label>
+			</th>
+			<td class="field">
+				<label for="border">{#advanced_dlg.image_border}</label>
+				<input type="text" maxlength="5" id="border" name="border" value="" onblur="wpImage.updateStyle('border')" />
+
+				<label for="vspace">{#advanced_dlg.image_vspace}</label>
+				<input type="text" maxlength="5" id="vspace" name="vspace" value="" onblur="wpImage.updateStyle('vspace')" />
+
+				<label for="hspace">{#advanced_dlg.image_hspace}</label>
+				<input type="text" maxlength="5" id="hspace" name="hspace" value="" onblur="wpImage.updateStyle('hspace')" />
+			</td>
+		</tr>
+		</tbody>
+	</table>
+
+	<h3>{#wpeditimage.adv_link_settings}</h3>
+	<table id="adv_settings_link" class="describe">
+		<tbody>
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="link_title">
+				<span class="alignleft">{#advanced_dlg.link_titlefield}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="link_title" name="link_title" value="" size="60" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="link_rel">
+				<span class="alignleft">{#wpeditimage.link_rel}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="link_rel" name="link_rel" value="" size="60" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="link_classes">
+				<span class="alignleft">{#wpeditimage.css}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="link_classes" name="link_classes" value="" size="60" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label for="link_style">
+				<span class="alignleft">{#advanced.style_select}</span>
+				</label>
+			</th>
+			<td class="field">
+				<input type="text" id="link_style" name="link_style" value="" size="60" />
+			</td>
+		</tr>
+
+		<tr>
+			<th valign="top" scope="row" class="label">
+				<label>
+				<span class="alignleft">{#advanced_dlg.link_target}</span>
+				</label>
+			</th>
+			<td class="field">
+				<label for="link_target">
+				{#advanced_dlg.link_target_blank}
+				</label>
+				<input type="checkbox" id="link_target" name="link_target" value="_blank" />
+			</td>
+		</tr>
+		</tbody>
+	</table></div>
+
+	<div id="saveeditimg">
+		<input type="hidden" id="align" name="align" value="" />
+
+		<input type="submit" id="saveimg" class="button" value="{#update}" />
+		<input type="button" class="button" id="cancelimg" name="cancelimg" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+	</div>
+</form>
+</div>
+
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js	(revision 17487)
@@ -0,0 +1,219 @@
+
+(function() {
+	tinymce.create('tinymce.plugins.wpEditImage', {
+
+		init : function(ed, url) {
+			var t = this;
+
+			t.url = url;
+			t._createButtons();
+
+			// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
+			ed.addCommand('WP_EditImage', function() {
+				var el = ed.selection.getNode(), vp = tinymce.DOM.getViewPort(), H = vp.h, W = ( 720 < vp.w ) ? 720 : vp.w, cls = ed.dom.getAttrib(el, 'class');
+
+				if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' )
+					return;
+
+				tb_show('', url + '/editimage.html?ver=321&TB_iframe=true');
+				tinymce.DOM.setStyles('TB_window', {
+					'width':( W - 50 )+'px',
+					'height':( H - 45 )+'px',
+					'margin-left':'-'+parseInt((( W - 50 ) / 2),10) + 'px'
+				});
+
+				if ( ! tinymce.isIE6 ) {
+					tinymce.DOM.setStyles('TB_window', {
+						'top':'20px',
+						'marginTop':'0'
+					});
+				}
+
+				tinymce.DOM.setStyles('TB_iframeContent', {
+					'width':( W - 50 )+'px',
+					'height':( H - 75 )+'px'
+				});
+				tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
+			});
+
+			ed.onInit.add(function(ed) {
+				tinymce.dom.Event.add(ed.getBody(), 'dragstart', function(e) {
+					if ( !tinymce.isGecko && e.target.nodeName == 'IMG' && ed.dom.getParent(e.target, 'dl.wp-caption') )
+						return tinymce.dom.Event.cancel(e);
+				});
+			});
+
+			// resize the caption <dl> when the image is soft-resized by the user (only possible in Firefox and IE)
+			ed.onMouseUp.add(function(ed, e) {
+				if ( tinymce.isWebKit || tinymce.isOpera )
+					return;
+
+				if ( ed.dom.getParent(e.target, 'div.mceTemp') || ed.dom.is(e.target, 'div.mceTemp') ) {
+					window.setTimeout(function(){
+						var ed = tinyMCE.activeEditor, n = ed.selection.getNode(), DL, width;
+
+						if ( 'IMG' == n.nodeName ) {
+							DL = ed.dom.getParent(n, 'dl.wp-caption');
+							width = ed.dom.getAttrib(n, 'width') || n.width;
+							width = parseInt(width, 10);
+
+							if ( DL && width != ( parseInt(ed.dom.getStyle(DL, 'width'), 10) - 10 ) ) {
+								ed.dom.setStyle(DL, 'width', 10 + width);
+								ed.execCommand('mceRepaint');
+							}
+						}
+					}, 100);
+				}
+			});
+
+			// show editimage buttons
+			ed.onMouseDown.add(function(ed, e) {
+				var p;
+
+				if ( e.target.nodeName == 'IMG' && ed.dom.getAttrib(e.target, 'class').indexOf('mceItem') == -1 ) {
+					ed.plugins.wordpress._showButtons(e.target, 'wp_editbtns');
+					if ( tinymce.isGecko && (p = ed.dom.getParent(e.target, 'dl.wp-caption')) && ed.dom.hasClass(p.parentNode, 'mceTemp') )
+						ed.selection.select(p.parentNode);
+				}
+			});
+
+			// when pressing Return inside a caption move the cursor to a new parapraph under it
+			ed.onKeyPress.add(function(ed, e) {
+				var n, DL, DIV, P;
+
+				if ( e.keyCode == 13 ) {
+					n = ed.selection.getNode();
+					DL = ed.dom.getParent(n, 'dl.wp-caption');
+					DIV = ed.dom.getParent(DL, 'div.mceTemp');
+
+					if ( DL && DIV ) {
+						P = ed.dom.create('p', {}, '&nbsp;');
+						ed.dom.insertAfter( P, DIV );
+						
+						if ( P.firstChild )
+							ed.selection.select(P.firstChild);
+						else
+							ed.selection.select(P);
+						
+						tinymce.dom.Event.cancel(e);
+						return false;
+					}
+				}
+			});
+
+			ed.onBeforeSetContent.add(function(ed, o) {
+				o.content = t._do_shcode(o.content);
+			});
+
+			ed.onPostProcess.add(function(ed, o) {
+				if (o.get)
+					o.content = t._get_shcode(o.content);
+			});
+		},
+
+		_do_shcode : function(co) {
+			return co.replace(/(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?[\s\u00a0]*/g, function(a,b,c){
+				var id, cls, w, cap, div_cls;
+				
+				b = b.replace(/\\'|\\&#39;|\\&#039;/g, '&#39;').replace(/\\"|\\&quot;/g, '&quot;');
+				c = c.replace(/\\&#39;|\\&#039;/g, '&#39;').replace(/\\&quot;/g, '&quot;');
+				id = b.match(/id=['"]([^'"]+)/i);
+				cls = b.match(/align=['"]([^'"]+)/i);
+				w = b.match(/width=['"]([0-9]+)/);
+				cap = b.match(/caption=['"]([^'"]+)/i);
+
+				id = ( id && id[1] ) ? id[1] : '';
+				cls = ( cls && cls[1] ) ? cls[1] : 'alignnone';
+				w = ( w && w[1] ) ? w[1] : '';
+				cap = ( cap && cap[1] ) ? cap[1] : '';
+				if ( ! w || ! cap ) return c;
+				
+				div_cls = (cls == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
+
+				return '<div class="'+div_cls+'" draggable><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+(10+parseInt(w))+
+				'px"><dt class="wp-caption-dt">'+c+'</dt><dd class="wp-caption-dd">'+cap+'</dd></dl></div>';
+			});
+		},
+
+		_get_shcode : function(co) {
+			return co.replace(/<div class="mceTemp[^"]*">\s*<dl([^>]+)>\s*<dt[^>]+>([\s\S]+?)<\/dt>\s*<dd[^>]+>(.+?)<\/dd>\s*<\/dl>\s*<\/div>\s*/gi, function(a,b,c,cap){
+				var id, cls, w;
+				
+				id = b.match(/id=['"]([^'"]+)/i);
+				cls = b.match(/class=['"]([^'"]+)/i);
+				w = c.match(/width=['"]([0-9]+)/);
+
+				id = ( id && id[1] ) ? id[1] : '';
+				cls = ( cls && cls[1] ) ? cls[1] : 'alignnone';
+				w = ( w && w[1] ) ? w[1] : '';
+
+				if ( ! w || ! cap ) return c;
+				cls = cls.match(/align[^ '"]+/) || 'alignnone';
+				cap = cap.replace(/<\S[^<>]*>/gi, '').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
+
+				return '[caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/caption]';
+			});
+		},
+
+		_createButtons : function() {
+			var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM, editButton, dellButton;
+
+			DOM.remove('wp_editbtns');
+
+			DOM.add(document.body, 'div', {
+				id : 'wp_editbtns',
+				style : 'display:none;'
+			});
+
+			editButton = DOM.add('wp_editbtns', 'img', {
+				src : t.url+'/img/image.png',
+				id : 'wp_editimgbtn',
+				width : '24',
+				height : '24',
+				title : ed.getLang('wpeditimage.edit_img')
+			});
+
+			tinymce.dom.Event.add(editButton, 'mousedown', function(e) {
+				var ed = tinyMCE.activeEditor;
+				ed.windowManager.bookmark = ed.selection.getBookmark('simple');
+				ed.execCommand("WP_EditImage");
+			});
+
+			dellButton = DOM.add('wp_editbtns', 'img', {
+				src : t.url+'/img/delete.png',
+				id : 'wp_delimgbtn',
+				width : '24',
+				height : '24',
+				title : ed.getLang('wpeditimage.del_img')
+			});
+
+			tinymce.dom.Event.add(dellButton, 'mousedown', function(e) {
+				var ed = tinyMCE.activeEditor, el = ed.selection.getNode(), p;
+
+				if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('mceItem') == -1 ) {
+					if ( (p = ed.dom.getParent(el, 'div')) && ed.dom.hasClass(p, 'mceTemp') )
+						ed.dom.remove(p);
+					else if ( (p = ed.dom.getParent(el, 'A')) && p.childNodes.length == 1 )
+						ed.dom.remove(p);
+					else
+						ed.dom.remove(el);
+
+					ed.execCommand('mceRepaint');
+					return false;
+				}
+			});
+		},
+
+		getInfo : function() {
+			return {
+				longname : 'Edit Image',
+				author : 'WordPress',
+				authorurl : 'http://wordpress.org',
+				infourl : '',
+				version : "1.0"
+			};
+		}
+	});
+
+	tinymce.PluginManager.add('wpeditimage', tinymce.plugins.wpEditImage);
+})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){tinymce.create("tinymce.plugins.wpEditImage",{init:function(a,b){var c=this;c.url=b;c._createButtons();a.addCommand("WP_EditImage",function(){var h=a.selection.getNode(),f=tinymce.DOM.getViewPort(),g=f.h,d=(720<f.w)?720:f.w,e=a.dom.getAttrib(h,"class");if(e.indexOf("mceItem")!=-1||e.indexOf("wpGallery")!=-1||h.nodeName!="IMG"){return}tb_show("",b+"/editimage.html?ver=321&TB_iframe=true");tinymce.DOM.setStyles("TB_window",{width:(d-50)+"px",height:(g-45)+"px","margin-left":"-"+parseInt(((d-50)/2),10)+"px"});if(!tinymce.isIE6){tinymce.DOM.setStyles("TB_window",{top:"20px",marginTop:"0"})}tinymce.DOM.setStyles("TB_iframeContent",{width:(d-50)+"px",height:(g-75)+"px"});tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")});a.onInit.add(function(d){tinymce.dom.Event.add(d.getBody(),"dragstart",function(f){if(!tinymce.isGecko&&f.target.nodeName=="IMG"&&d.dom.getParent(f.target,"dl.wp-caption")){return tinymce.dom.Event.cancel(f)}})});a.onMouseUp.add(function(d,f){if(tinymce.isWebKit||tinymce.isOpera){return}if(d.dom.getParent(f.target,"div.mceTemp")||d.dom.is(f.target,"div.mceTemp")){window.setTimeout(function(){var e=tinyMCE.activeEditor,i=e.selection.getNode(),g,h;if("IMG"==i.nodeName){g=e.dom.getParent(i,"dl.wp-caption");h=e.dom.getAttrib(i,"width")||i.width;h=parseInt(h,10);if(g&&h!=(parseInt(e.dom.getStyle(g,"width"),10)-10)){e.dom.setStyle(g,"width",10+h);e.execCommand("mceRepaint")}}},100)}});a.onMouseDown.add(function(d,g){var f;if(g.target.nodeName=="IMG"&&d.dom.getAttrib(g.target,"class").indexOf("mceItem")==-1){d.plugins.wordpress._showButtons(g.target,"wp_editbtns");if(tinymce.isGecko&&(f=d.dom.getParent(g.target,"dl.wp-caption"))&&d.dom.hasClass(f.parentNode,"mceTemp")){d.selection.select(f.parentNode)}}});a.onKeyPress.add(function(d,i){var j,f,h,g;if(i.keyCode==13){j=d.selection.getNode();f=d.dom.getParent(j,"dl.wp-caption");h=d.dom.getParent(f,"div.mceTemp");if(f&&h){g=d.dom.create("p",{},"&nbsp;");d.dom.insertAfter(g,h);if(g.firstChild){d.selection.select(g.firstChild)}else{d.selection.select(g)}tinymce.dom.Event.cancel(i);return false}}});a.onBeforeSetContent.add(function(d,e){e.content=c._do_shcode(e.content)});a.onPostProcess.add(function(d,e){if(e.get){e.content=c._get_shcode(e.content)}})},_do_shcode:function(a){return a.replace(/(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?[\s\u00a0]*/g,function(g,d,k){var j,f,e,h,i;d=d.replace(/\\'|\\&#39;|\\&#039;/g,"&#39;").replace(/\\"|\\&quot;/g,"&quot;");k=k.replace(/\\&#39;|\\&#039;/g,"&#39;").replace(/\\&quot;/g,"&quot;");j=d.match(/id=['"]([^'"]+)/i);f=d.match(/align=['"]([^'"]+)/i);e=d.match(/width=['"]([0-9]+)/);h=d.match(/caption=['"]([^'"]+)/i);j=(j&&j[1])?j[1]:"";f=(f&&f[1])?f[1]:"alignnone";e=(e&&e[1])?e[1]:"";h=(h&&h[1])?h[1]:"";if(!e||!h){return k}i=(f=="aligncenter")?"mceTemp mceIEcenter":"mceTemp";return'<div class="'+i+'" draggable><dl id="'+j+'" class="wp-caption '+f+'" style="width: '+(10+parseInt(e))+'px"><dt class="wp-caption-dt">'+k+'</dt><dd class="wp-caption-dd">'+h+"</dd></dl></div>"})},_get_shcode:function(a){return a.replace(/<div class="mceTemp[^"]*">\s*<dl([^>]+)>\s*<dt[^>]+>([\s\S]+?)<\/dt>\s*<dd[^>]+>(.+?)<\/dd>\s*<\/dl>\s*<\/div>\s*/gi,function(g,d,j,h){var i,f,e;i=d.match(/id=['"]([^'"]+)/i);f=d.match(/class=['"]([^'"]+)/i);e=j.match(/width=['"]([0-9]+)/);i=(i&&i[1])?i[1]:"";f=(f&&f[1])?f[1]:"alignnone";e=(e&&e[1])?e[1]:"";if(!e||!h){return j}f=f.match(/align[^ '"]+/)||"alignnone";h=h.replace(/<\S[^<>]*>/gi,"").replace(/'/g,"&#39;").replace(/"/g,"&quot;");return'[caption id="'+i+'" align="'+f+'" width="'+e+'" caption="'+h+'"]'+j+"[/caption]"})},_createButtons:function(){var b=this,a=tinyMCE.activeEditor,d=tinymce.DOM,e,c;d.remove("wp_editbtns");d.add(document.body,"div",{id:"wp_editbtns",style:"display:none;"});e=d.add("wp_editbtns","img",{src:b.url+"/img/image.png",id:"wp_editimgbtn",width:"24",height:"24",title:a.getLang("wpeditimage.edit_img")});tinymce.dom.Event.add(e,"mousedown",function(g){var f=tinyMCE.activeEditor;f.windowManager.bookmark=f.selection.getBookmark("simple");f.execCommand("WP_EditImage")});c=d.add("wp_editbtns","img",{src:b.url+"/img/delete.png",id:"wp_delimgbtn",width:"24",height:"24",title:a.getLang("wpeditimage.del_img")});tinymce.dom.Event.add(c,"mousedown",function(i){var f=tinyMCE.activeEditor,g=f.selection.getNode(),h;if(g.nodeName=="IMG"&&f.dom.getAttrib(g,"class").indexOf("mceItem")==-1){if((h=f.dom.getParent(g,"div"))&&f.dom.hasClass(h,"mceTemp")){f.dom.remove(h)}else{if((h=f.dom.getParent(g,"A"))&&h.childNodes.length==1){f.dom.remove(h)}else{f.dom.remove(g)}}f.execCommand("mceRepaint");return false}})},getInfo:function(){return{longname:"Edit Image",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpeditimage",tinymce.plugins.wpEditImage)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js	(revision 17487)
@@ -0,0 +1,613 @@
+
+var tinymce = null, tinyMCEPopup, tinyMCE, wpImage;
+
+tinyMCEPopup = {
+	init: function() {
+		var t = this, w, li, q, i, it;
+
+		li = ('' + document.location.search).replace(/^\?/, '').split('&');
+		q = {};
+		for ( i = 0; i < li.length; i++ ) {
+			it = li[i].split('=');
+			q[unescape(it[0])] = unescape(it[1]);
+		}
+
+		if (q.mce_rdomain)
+			document.domain = q.mce_rdomain;
+
+		// Find window & API
+		w = t.getWin();
+		tinymce = w.tinymce;
+		tinyMCE = w.tinyMCE;
+		t.editor = tinymce.EditorManager.activeEditor;
+		t.params = t.editor.windowManager.params;
+
+		// Setup local DOM
+		t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
+		t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
+	},
+
+	getWin : function() {
+		return window.dialogArguments || opener || parent || top;
+	},
+
+	getParam : function(n, dv) {
+		return this.editor.getParam(n, dv);
+	},
+
+	close : function() {
+		var t = this, win = t.getWin();
+
+		// To avoid domain relaxing issue in Opera
+		function close() {
+			win.tb_remove();
+			tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup
+		};
+
+		if (tinymce.isOpera)
+			win.setTimeout(close, 0);
+		else
+			close();
+	},
+
+	execCommand : function(cmd, ui, val, a) {
+		a = a || {};
+		a.skip_focus = 1;
+
+		this.restoreSelection();
+		return this.editor.execCommand(cmd, ui, val, a);
+	},
+
+	storeSelection : function() {
+		this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
+	},
+
+	restoreSelection : function() {
+		var t = tinyMCEPopup;
+
+		if (tinymce.isIE)
+			t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
+	}
+}
+tinyMCEPopup.init();
+
+wpImage = {
+	preInit : function() {
+		// import colors stylesheet from parent
+		var win = tinyMCEPopup.getWin(), styles = win.document.styleSheets, url, i;
+
+		for ( i = 0; i < styles.length; i++ ) {
+			url = styles.item(i).href;
+			if ( url && url.indexOf('colors') != -1 )
+				document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );
+		}
+	},
+
+	I : function(e) {
+		return document.getElementById(e);
+	},
+
+	current : '',
+	link : '',
+	link_rel : '',
+	target_value : '',
+	current_size_sel : 's100',
+	width : '',
+	height : '',
+	align : '',
+	img_alt : '',
+
+	setTabs : function(tab) {
+		var t = this;
+
+		if ( 'current' == tab.className ) return false;
+		t.I('div_advanced').style.display = ( 'tab_advanced' == tab.id ) ? 'block' : 'none';
+		t.I('div_basic').style.display = ( 'tab_basic' == tab.id ) ? 'block' : 'none';
+		t.I('tab_basic').className = t.I('tab_advanced').className = '';
+		tab.className = 'current';
+		return false;
+	},
+
+	img_seturl : function(u) {
+		var t = this, rel = t.I('link_rel').value;
+
+		if ( 'current' == u ) {
+			t.I('link_href').value = t.current;
+			t.I('link_rel').value = t.link_rel;
+		} else {
+			t.I('link_href').value = t.link;
+			if ( rel ) {
+				rel = rel.replace( /attachment|wp-att-[0-9]+/gi, '' );
+				t.I('link_rel').value = tinymce.trim(rel);
+			}
+		}
+	},
+
+	imgAlignCls : function(v) {
+		var t = this, cls = t.I('img_classes').value;
+
+		t.I('img_demo').className = t.align = v;
+
+		cls = cls.replace( /align[^ "']+/gi, '' );
+		cls += (' ' + v);
+		cls = cls.replace( /\s+/g, ' ' ).replace( /^\s/, '' );
+
+		if ( 'aligncenter' == v ) {
+			t.I('hspace').value = '';
+			t.updateStyle('hspace');
+		}
+
+		t.I('img_classes').value = cls;
+	},
+
+	showSize : function(el) {
+		var t = this, demo = t.I('img_demo'), w = t.width, h = t.height, id = el.id || 's100', size;
+
+		size = parseInt(id.substring(1)) / 200;
+		demo.width = Math.round(w * size);
+		demo.height = Math.round(h * size);
+
+		t.showSizeClear();
+		el.style.borderColor = '#A3A3A3';
+		el.style.backgroundColor = '#E5E5E5';
+	},
+
+	showSizeSet : function() {
+		var t = this, s130, s120, s110;
+
+		if ( (t.width * 1.3) > parseInt(t.preloadImg.width) ) {
+			s130 = t.I('s130'), s120 = t.I('s120'), s110 = t.I('s110');
+
+			s130.onclick = s120.onclick = s110.onclick = null;
+			s130.onmouseover = s120.onmouseover = s110.onmouseover = null;
+			s130.style.color = s120.style.color = s110.style.color = '#aaa';
+		}
+	},
+
+	showSizeRem : function() {
+		var t = this, demo = t.I('img_demo'), f = document.forms[0];
+
+		demo.width = Math.round(f.width.value * 0.5);
+		demo.height = Math.round(f.height.value * 0.5);
+		t.showSizeClear();
+		t.I(t.current_size_sel).style.borderColor = '#A3A3A3';
+		t.I(t.current_size_sel).style.backgroundColor = '#E5E5E5';
+
+		return false;
+	},
+
+	showSizeClear : function() {
+		var divs = this.I('img_size').getElementsByTagName('div'), i;
+
+		for ( i = 0; i < divs.length; i++ ) {
+			divs[i].style.borderColor = '#f1f1f1';
+			divs[i].style.backgroundColor = '#f1f1f1';
+		}
+	},
+
+	imgEditSize : function(el) {
+		var t = this, f = document.forms[0], W, H, w, h, id;
+
+		if ( ! t.preloadImg || ! t.preloadImg.width || ! t.preloadImg.height )
+			return;
+		
+		W = parseInt(t.preloadImg.width), H = parseInt(t.preloadImg.height), w = t.width || W, h = t.height || H, id = el.id || 's100';
+
+		size = parseInt(id.substring(1)) / 100;
+
+		w = Math.round(w * size);
+		h = Math.round(h * size);
+
+		f.width.value = Math.min(W, w);
+		f.height.value = Math.min(H, h);
+
+		t.current_size_sel = id;
+		t.demoSetSize();
+	},
+
+	demoSetSize : function(img) {
+		var demo = this.I('img_demo'), f = document.forms[0];
+
+		demo.width = f.width.value ? Math.round(f.width.value * 0.5) : '';
+		demo.height = f.height.value ? Math.round(f.height.value * 0.5) : '';
+	},
+
+	demoSetStyle : function() {
+		var f = document.forms[0], demo = this.I('img_demo'), dom = tinyMCEPopup.editor.dom;
+
+		if (demo) {
+			dom.setAttrib(demo, 'style', f.img_style.value);
+			dom.setStyle(demo, 'width', '');
+			dom.setStyle(demo, 'height', '');
+		}
+	},
+
+	origSize : function() {
+		var t = this, f = document.forms[0], el = t.I('s100');
+
+		f.width.value = t.width = t.preloadImg.width;
+		f.height.value = t.height = t.preloadImg.height;
+		t.showSizeSet();
+		t.demoSetSize();
+		t.showSize(el);
+	},
+
+	init : function() {
+		var ed = tinyMCEPopup.editor, h;
+
+		h = document.body.innerHTML;
+		document.body.innerHTML = ed.translate(h);
+		window.setTimeout( function(){wpImage.setup();}, 500 );
+	},
+
+	setup : function() {
+		var t = this, c, el, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor,
+			d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = '', dlc, pa;
+
+		document.dir = tinyMCEPopup.editor.getParam('directionality','');
+
+		if ( tinyMCEPopup.editor.getParam('wpeditimage_disable_captions', false) )
+			t.I('cap_field').style.display = 'none';
+
+		tinyMCEPopup.restoreSelection();
+		el = ed.selection.getNode();
+		if (el.nodeName != 'IMG')
+			return;
+
+		f.img_src.value = d.src = link = ed.dom.getAttrib(el, 'src');
+		ed.dom.setStyle(el, 'float', '');
+		t.getImageData();
+		c = ed.dom.getAttrib(el, 'class');
+
+		if ( DL = dom.getParent(el, 'dl') ) {
+			dlc = ed.dom.getAttrib(DL, 'class');
+			dlc = dlc.match(/align[^ "']+/i);
+			if ( dlc && ! dom.hasClass(el, dlc) ) {
+				c += ' '+dlc;
+				tinymce.trim(c);
+			}
+
+			tinymce.each(DL.childNodes, function(e) {
+				if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) {
+					caption = e.innerHTML;
+					return;
+				}
+			});
+		}
+
+		f.img_cap.value = caption;
+		f.img_title.value = ed.dom.getAttrib(el, 'title');
+		f.img_alt.value = ed.dom.getAttrib(el, 'alt');
+		f.border.value = ed.dom.getAttrib(el, 'border');
+		f.vspace.value = ed.dom.getAttrib(el, 'vspace');
+		f.hspace.value = ed.dom.getAttrib(el, 'hspace');
+		f.align.value = ed.dom.getAttrib(el, 'align');
+		f.width.value = t.width = ed.dom.getAttrib(el, 'width');
+		f.height.value = t.height = ed.dom.getAttrib(el, 'height');
+		f.img_classes.value = c;
+		f.img_style.value = ed.dom.getAttrib(el, 'style');
+
+		// Move attribs to styles
+		if ( dom.getAttrib(el, 'hspace') )
+			t.updateStyle('hspace');
+
+		if ( dom.getAttrib(el, 'border') )
+			t.updateStyle('border');
+
+		if ( dom.getAttrib(el, 'vspace') )
+			t.updateStyle('vspace');
+
+		if ( pa = ed.dom.getParent(el, 'A') ) {
+			f.link_href.value = t.current = ed.dom.getAttrib(pa, 'href');
+			f.link_title.value = ed.dom.getAttrib(pa, 'title');
+			f.link_rel.value = t.link_rel = ed.dom.getAttrib(pa, 'rel');
+			f.link_style.value = ed.dom.getAttrib(pa, 'style');
+			t.target_value = ed.dom.getAttrib(pa, 'target');
+			f.link_classes.value = ed.dom.getAttrib(pa, 'class');
+		}
+
+		f.link_target.checked = ( t.target_value && t.target_value == '_blank' ) ? 'checked' : '';
+
+		fname = link.substring( link.lastIndexOf('/') );
+		fname = fname.replace(/-[0-9]{2,4}x[0-9]{2,4}/, '' );
+		t.link = link.substring( 0, link.lastIndexOf('/') ) + fname;
+
+		if ( c.indexOf('alignleft') != -1 ) {
+			t.I('alignleft').checked = "checked";
+			d.className = t.align = "alignleft";
+		} else if ( c.indexOf('aligncenter') != -1 ) {
+			t.I('aligncenter').checked = "checked";
+			d.className = t.align = "aligncenter";
+		} else if ( c.indexOf('alignright') != -1 ) {
+			t.I('alignright').checked = "checked";
+			d.className = t.align = "alignright";
+		} else if ( c.indexOf('alignnone') != -1 ) {
+			t.I('alignnone').checked = "checked";
+			d.className = t.align = "alignnone";
+		}
+
+		if ( t.width && t.preloadImg.width ) t.showSizeSet();
+		document.body.style.display = '';
+	},
+
+	remove : function() {
+		var ed = tinyMCEPopup.editor, p, el;
+
+		tinyMCEPopup.restoreSelection();
+		el = ed.selection.getNode();
+		if (el.nodeName != 'IMG') return;
+
+		if ( (p = ed.dom.getParent(el, 'div')) && ed.dom.hasClass(p, 'mceTemp') )
+			ed.dom.remove(p);
+		else if ( (p = ed.dom.getParent(el, 'A')) && p.childNodes.length == 1 )
+			ed.dom.remove(p);
+		else ed.dom.remove(el);
+
+		ed.execCommand('mceRepaint');
+		tinyMCEPopup.close();
+		return;
+	},
+
+	update : function() {
+		var t = this, f = document.forms[0], ed = tinyMCEPopup.editor, el, b, fixSafari = null,
+			DL, P, A, DIV, do_caption = null, img_class = f.img_classes.value, html,
+			id, cap_id = '', cap, DT, DD, cap_width, div_cls, lnk = '', pa, aa;
+
+		tinyMCEPopup.restoreSelection();
+		el = ed.selection.getNode();
+
+		if (el.nodeName != 'IMG') return;
+		if (f.img_src.value === '') {
+			t.remove();
+			return;
+		}
+
+		if ( f.img_cap.value != '' && f.width.value != '' ) {
+			do_caption = 1;
+			img_class = img_class.replace( /align[^ "']+\s?/gi, '' );
+		}
+
+		A = ed.dom.getParent(el, 'a');
+		P = ed.dom.getParent(el, 'p');
+		DL = ed.dom.getParent(el, 'dl');
+		DIV = ed.dom.getParent(el, 'div');
+
+		tinyMCEPopup.execCommand("mceBeginUndoLevel");
+
+		ed.dom.setAttribs(el, {
+			src : f.img_src.value,
+			title : f.img_title.value,
+			alt : f.img_alt.value,
+			width : f.width.value,
+			height : f.height.value,
+			style : f.img_style.value,
+			'class' : img_class
+		});
+
+		if ( f.link_href.value ) {
+			// Create new anchor elements
+			if ( A == null ) {
+				if ( ! f.link_href.value.match(/https?:\/\//i) )
+					f.link_href.value = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.link_href.value);
+
+				if ( tinymce.isWebKit && ed.dom.hasClass(el, 'aligncenter') ) {
+					ed.dom.removeClass(el, 'aligncenter');
+					fixSafari = 1;
+				}
+
+				tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
+				if ( fixSafari ) ed.dom.addClass(el, 'aligncenter');
+
+				tinymce.each(ed.dom.select("a"), function(n) {
+					if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
+
+						ed.dom.setAttribs(n, {
+							href : f.link_href.value,
+							title : f.link_title.value,
+							rel : f.link_rel.value,
+							target : (f.link_target.checked == true) ? '_blank' : '',
+							'class' : f.link_classes.value,
+							style : f.link_style.value
+						});
+					}
+				});
+			} else {
+				ed.dom.setAttribs(A, {
+					href : f.link_href.value,
+					title : f.link_title.value,
+					rel : f.link_rel.value,
+					target : (f.link_target.checked == true) ? '_blank' : '',
+					'class' : f.link_classes.value,
+					style : f.link_style.value
+				});
+			}
+		}
+
+		if ( do_caption ) {
+			cap_width = 10 + parseInt(f.width.value);
+			div_cls = (t.align == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
+
+			if ( DL ) {
+				ed.dom.setAttribs(DL, {
+					'class' : 'wp-caption '+t.align,
+					style : 'width: '+cap_width+'px;'
+				});
+
+				if ( DIV )
+					ed.dom.setAttrib(DIV, 'class', div_cls);
+
+				if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp-caption-dd') )
+					ed.dom.setHTML(DD, f.img_cap.value);
+
+			} else {
+				if ( (id = f.img_classes.value.match( /wp-image-([0-9]{1,6})/ )) && id[1] )
+					cap_id = 'attachment_'+id[1];
+
+				if ( f.link_href.value && (lnk = ed.dom.getParent(el, 'a')) ) {
+					if ( lnk.childNodes.length == 1 )
+						html = ed.dom.getOuterHTML(lnk);
+					else {
+						html = ed.dom.getOuterHTML(lnk);
+						html = html.match(/<a[^>]+>/i);
+						html = html+ed.dom.getOuterHTML(el)+'</a>';
+					}
+				} else html = ed.dom.getOuterHTML(el);
+
+				html = '<dl id="'+cap_id+'" class="wp-caption '+t.align+'" style="width: '+cap_width+
+				'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap.value+'</dd></dl>';
+
+				cap = ed.dom.create('div', {'class': div_cls}, html);
+
+				if ( P ) {
+					P.parentNode.insertBefore(cap, P);
+					if ( P.childNodes.length == 1 )
+						ed.dom.remove(P);
+					else if ( lnk && lnk.childNodes.length == 1 )
+						ed.dom.remove(lnk);
+					else ed.dom.remove(el);
+				} else if ( pa = ed.dom.getParent(el, 'TD,TH,LI') ) {
+					pa.appendChild(cap);
+					if ( lnk && lnk.childNodes.length == 1 )
+						ed.dom.remove(lnk);
+					else ed.dom.remove(el);
+				}
+			}
+
+		} else {
+			if ( DL && DIV ) {
+				if ( f.link_href.value && (aa = ed.dom.getParent(el, 'a')) ) html = ed.dom.getOuterHTML(aa);
+				else html = ed.dom.getOuterHTML(el);
+
+				P = ed.dom.create('p', {}, html);
+				DIV.parentNode.insertBefore(P, DIV);
+				ed.dom.remove(DIV);
+			}
+		}
+
+		if ( f.img_classes.value.indexOf('aligncenter') != -1 ) {
+			if ( P && ( ! P.style || P.style.textAlign != 'center' ) )
+				ed.dom.setStyle(P, 'textAlign', 'center');
+		} else {
+			if ( P && P.style && P.style.textAlign == 'center' )
+				ed.dom.setStyle(P, 'textAlign', '');
+		}
+
+		if ( ! f.link_href.value && A ) {
+			b = ed.selection.getBookmark();
+			ed.dom.remove(A, 1);
+			ed.selection.moveToBookmark(b);
+		}
+
+		tinyMCEPopup.execCommand("mceEndUndoLevel");
+		ed.execCommand('mceRepaint');
+		tinyMCEPopup.close();
+	},
+
+	updateStyle : function(ty) {
+		var dom = tinyMCEPopup.dom, v, f = document.forms[0], img = dom.create('img', {style : f.img_style.value});
+
+		if (tinyMCEPopup.editor.settings.inline_styles) {
+			// Handle align
+			if (ty == 'align') {
+				dom.setStyle(img, 'float', '');
+				dom.setStyle(img, 'vertical-align', '');
+
+				v = f.align.value;
+				if (v) {
+					if (v == 'left' || v == 'right')
+						dom.setStyle(img, 'float', v);
+					else
+						img.style.verticalAlign = v;
+				}
+			}
+
+			// Handle border
+			if (ty == 'border') {
+				dom.setStyle(img, 'border', '');
+
+				v = f.border.value;
+				if (v || v == '0') {
+					if (v == '0')
+						img.style.border = '0';
+					else
+						img.style.border = v + 'px solid black';
+				}
+			}
+
+			// Handle hspace
+			if (ty == 'hspace') {
+				dom.setStyle(img, 'marginLeft', '');
+				dom.setStyle(img, 'marginRight', '');
+
+				v = f.hspace.value;
+				if (v) {
+					img.style.marginLeft = v + 'px';
+					img.style.marginRight = v + 'px';
+				}
+			}
+
+			// Handle vspace
+			if (ty == 'vspace') {
+				dom.setStyle(img, 'marginTop', '');
+				dom.setStyle(img, 'marginBottom', '');
+
+				v = f.vspace.value;
+				if (v) {
+					img.style.marginTop = v + 'px';
+					img.style.marginBottom = v + 'px';
+				}
+			}
+
+			// Merge
+			f.img_style.value = dom.serializeStyle(dom.parseStyle(img.style.cssText));
+			this.demoSetStyle();
+		}
+	},
+
+	checkVal : function(f) {
+
+		if ( f.value == '' ) {
+	//		if ( f.id == 'width' ) f.value = this.width || this.preloadImg.width;
+	//		if ( f.id == 'height' ) f.value = this.height || this.preloadImg.height;
+			if ( f.id == 'img_src' ) f.value = this.I('img_demo').src || this.preloadImg.src;
+		}
+	},
+
+	resetImageData : function() {
+		var f = document.forms[0];
+
+		f.width.value = f.height.value = '';
+	},
+
+	updateImageData : function() {
+		var f = document.forms[0], t = wpImage, w = f.width.value, h = f.height.value;
+
+		if ( !w && h )
+			w = f.width.value = t.width = Math.round( t.preloadImg.width / (t.preloadImg.height / h) );
+		else if ( w && !h )
+			h = f.height.value = t.height = Math.round( t.preloadImg.height / (t.preloadImg.width / w) );
+
+		if ( !w )
+			f.width.value = t.width = t.preloadImg.width;
+
+		if ( !h )
+			f.height.value = t.height = t.preloadImg.height;
+
+		t.showSizeSet();
+		t.demoSetSize();
+		if ( f.img_style.value )
+			t.demoSetStyle();
+	},
+
+	getImageData : function() {
+		var t = wpImage, f = document.forms[0];
+
+		t.preloadImg = new Image();
+		t.preloadImg.onload = t.updateImageData;
+		t.preloadImg.onerror = t.resetImageData;
+		t.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.img_src.value);
+	}
+};
+
+window.onload = function(){wpImage.init();}
+wpImage.preInit();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js	(revision 17487)
@@ -0,0 +1,1 @@
+var tinymce=null,tinyMCEPopup,tinyMCE,wpImage;tinyMCEPopup={init:function(){var d=this,b,a,f,c,e;a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}b=d.getWin();tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.params=d.editor.windowManager.params;d.dom=d.editor.windowManager.createInstance("tinymce.dom.DOMUtils",document);d.editor.windowManager.onOpen.dispatch(d.editor.windowManager,window)},getWin:function(){return window.dialogArguments||opener||parent||top},getParam:function(b,a){return this.editor.getParam(b,a)},close:function(){var a=this,b=a.getWin();function c(){b.tb_remove();tinymce=tinyMCE=a.editor=a.dom=a.dom.doc=null}if(tinymce.isOpera){b.setTimeout(c,0)}else{c()}},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark("simple")},restoreSelection:function(){var a=tinyMCEPopup;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}}};tinyMCEPopup.init();wpImage={preInit:function(){var d=tinyMCEPopup.getWin(),c=d.document.styleSheets,a,b;for(b=0;b<c.length;b++){a=c.item(b).href;if(a&&a.indexOf("colors")!=-1){document.write('<link rel="stylesheet" href="'+a+'" type="text/css" media="all" />')}}},I:function(a){return document.getElementById(a)},current:"",link:"",link_rel:"",target_value:"",current_size_sel:"s100",width:"",height:"",align:"",img_alt:"",setTabs:function(b){var a=this;if("current"==b.className){return false}a.I("div_advanced").style.display=("tab_advanced"==b.id)?"block":"none";a.I("div_basic").style.display=("tab_basic"==b.id)?"block":"none";a.I("tab_basic").className=a.I("tab_advanced").className="";b.className="current";return false},img_seturl:function(b){var c=this,a=c.I("link_rel").value;if("current"==b){c.I("link_href").value=c.current;c.I("link_rel").value=c.link_rel}else{c.I("link_href").value=c.link;if(a){a=a.replace(/attachment|wp-att-[0-9]+/gi,"");c.I("link_rel").value=tinymce.trim(a)}}},imgAlignCls:function(b){var c=this,a=c.I("img_classes").value;c.I("img_demo").className=c.align=b;a=a.replace(/align[^ "']+/gi,"");a+=(" "+b);a=a.replace(/\s+/g," ").replace(/^\s/,"");if("aligncenter"==b){c.I("hspace").value="";c.updateStyle("hspace")}c.I("img_classes").value=a},showSize:function(e){var c=this,f=c.I("img_demo"),a=c.width,d=c.height,g=e.id||"s100",b;b=parseInt(g.substring(1))/200;f.width=Math.round(a*b);f.height=Math.round(d*b);c.showSizeClear();e.style.borderColor="#A3A3A3";e.style.backgroundColor="#E5E5E5"},showSizeSet:function(){var b=this,d,c,a;if((b.width*1.3)>parseInt(b.preloadImg.width)){d=b.I("s130"),c=b.I("s120"),a=b.I("s110");d.onclick=c.onclick=a.onclick=null;d.onmouseover=c.onmouseover=a.onmouseover=null;d.style.color=c.style.color=a.style.color="#aaa"}},showSizeRem:function(){var a=this,c=a.I("img_demo"),b=document.forms[0];c.width=Math.round(b.width.value*0.5);c.height=Math.round(b.height.value*0.5);a.showSizeClear();a.I(a.current_size_sel).style.borderColor="#A3A3A3";a.I(a.current_size_sel).style.backgroundColor="#E5E5E5";return false},showSizeClear:function(){var b=this.I("img_size").getElementsByTagName("div"),a;for(a=0;a<b.length;a++){b[a].style.borderColor="#f1f1f1";b[a].style.backgroundColor="#f1f1f1"}},imgEditSize:function(g){var d=this,i=document.forms[0],a,c,b,e,j;if(!d.preloadImg||!d.preloadImg.width||!d.preloadImg.height){return}a=parseInt(d.preloadImg.width),c=parseInt(d.preloadImg.height),b=d.width||a,e=d.height||c,j=g.id||"s100";size=parseInt(j.substring(1))/100;b=Math.round(b*size);e=Math.round(e*size);i.width.value=Math.min(a,b);i.height.value=Math.min(c,e);d.current_size_sel=j;d.demoSetSize()},demoSetSize:function(a){var c=this.I("img_demo"),b=document.forms[0];c.width=b.width.value?Math.round(b.width.value*0.5):"";c.height=b.height.value?Math.round(b.height.value*0.5):""},demoSetStyle:function(){var b=document.forms[0],a=this.I("img_demo"),c=tinyMCEPopup.editor.dom;if(a){c.setAttrib(a,"style",b.img_style.value);c.setStyle(a,"width","");c.setStyle(a,"height","")}},origSize:function(){var a=this,c=document.forms[0],b=a.I("s100");c.width.value=a.width=a.preloadImg.width;c.height.value=a.height=a.preloadImg.height;a.showSizeSet();a.demoSetSize();a.showSize(b)},init:function(){var a=tinyMCEPopup.editor,b;b=document.body.innerHTML;document.body.innerHTML=a.translate(b);window.setTimeout(function(){wpImage.setup()},500)},setup:function(){var p=this,k,b,l,e,i=document.forms[0],h=tinyMCEPopup.editor,j=p.I("img_demo"),g=tinyMCEPopup.dom,a,o="",n,m;document.dir=tinyMCEPopup.editor.getParam("directionality","");if(tinyMCEPopup.editor.getParam("wpeditimage_disable_captions",false)){p.I("cap_field").style.display="none"}tinyMCEPopup.restoreSelection();b=h.selection.getNode();if(b.nodeName!="IMG"){return}i.img_src.value=j.src=l=h.dom.getAttrib(b,"src");h.dom.setStyle(b,"float","");p.getImageData();k=h.dom.getAttrib(b,"class");if(a=g.getParent(b,"dl")){n=h.dom.getAttrib(a,"class");n=n.match(/align[^ "']+/i);if(n&&!g.hasClass(b,n)){k+=" "+n;tinymce.trim(k)}tinymce.each(a.childNodes,function(c){if(c.nodeName=="DD"&&g.hasClass(c,"wp-caption-dd")){o=c.innerHTML;return}})}i.img_cap.value=o;i.img_title.value=h.dom.getAttrib(b,"title");i.img_alt.value=h.dom.getAttrib(b,"alt");i.border.value=h.dom.getAttrib(b,"border");i.vspace.value=h.dom.getAttrib(b,"vspace");i.hspace.value=h.dom.getAttrib(b,"hspace");i.align.value=h.dom.getAttrib(b,"align");i.width.value=p.width=h.dom.getAttrib(b,"width");i.height.value=p.height=h.dom.getAttrib(b,"height");i.img_classes.value=k;i.img_style.value=h.dom.getAttrib(b,"style");if(g.getAttrib(b,"hspace")){p.updateStyle("hspace")}if(g.getAttrib(b,"border")){p.updateStyle("border")}if(g.getAttrib(b,"vspace")){p.updateStyle("vspace")}if(m=h.dom.getParent(b,"A")){i.link_href.value=p.current=h.dom.getAttrib(m,"href");i.link_title.value=h.dom.getAttrib(m,"title");i.link_rel.value=p.link_rel=h.dom.getAttrib(m,"rel");i.link_style.value=h.dom.getAttrib(m,"style");p.target_value=h.dom.getAttrib(m,"target");i.link_classes.value=h.dom.getAttrib(m,"class")}i.link_target.checked=(p.target_value&&p.target_value=="_blank")?"checked":"";e=l.substring(l.lastIndexOf("/"));e=e.replace(/-[0-9]{2,4}x[0-9]{2,4}/,"");p.link=l.substring(0,l.lastIndexOf("/"))+e;if(k.indexOf("alignleft")!=-1){p.I("alignleft").checked="checked";j.className=p.align="alignleft"}else{if(k.indexOf("aligncenter")!=-1){p.I("aligncenter").checked="checked";j.className=p.align="aligncenter"}else{if(k.indexOf("alignright")!=-1){p.I("alignright").checked="checked";j.className=p.align="alignright"}else{if(k.indexOf("alignnone")!=-1){p.I("alignnone").checked="checked";j.className=p.align="alignnone"}}}}if(p.width&&p.preloadImg.width){p.showSizeSet()}document.body.style.display=""},remove:function(){var a=tinyMCEPopup.editor,c,b;tinyMCEPopup.restoreSelection();b=a.selection.getNode();if(b.nodeName!="IMG"){return}if((c=a.dom.getParent(b,"div"))&&a.dom.hasClass(c,"mceTemp")){a.dom.remove(c)}else{if((c=a.dom.getParent(b,"A"))&&c.childNodes.length==1){a.dom.remove(c)}else{a.dom.remove(b)}}a.execCommand("mceRepaint");tinyMCEPopup.close();return},update:function(){var m=this,v=document.forms[0],g=tinyMCEPopup.editor,e,x,d=null,n,h,p,r,o=null,k=v.img_classes.value,l,q,u="",j,i,s,a,z,w="",c,y;tinyMCEPopup.restoreSelection();e=g.selection.getNode();if(e.nodeName!="IMG"){return}if(v.img_src.value===""){m.remove();return}if(v.img_cap.value!=""&&v.width.value!=""){o=1;k=k.replace(/align[^ "']+\s?/gi,"")}p=g.dom.getParent(e,"a");h=g.dom.getParent(e,"p");n=g.dom.getParent(e,"dl");r=g.dom.getParent(e,"div");tinyMCEPopup.execCommand("mceBeginUndoLevel");g.dom.setAttribs(e,{src:v.img_src.value,title:v.img_title.value,alt:v.img_alt.value,width:v.width.value,height:v.height.value,style:v.img_style.value,"class":k});if(v.link_href.value){if(p==null){if(!v.link_href.value.match(/https?:\/\//i)){v.link_href.value=tinyMCEPopup.editor.documentBaseURI.toAbsolute(v.link_href.value)}if(tinymce.isWebKit&&g.dom.hasClass(e,"aligncenter")){g.dom.removeClass(e,"aligncenter");d=1}tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1});if(d){g.dom.addClass(e,"aligncenter")}tinymce.each(g.dom.select("a"),function(b){if(g.dom.getAttrib(b,"href")=="#mce_temp_url#"){g.dom.setAttribs(b,{href:v.link_href.value,title:v.link_title.value,rel:v.link_rel.value,target:(v.link_target.checked==true)?"_blank":"","class":v.link_classes.value,style:v.link_style.value})}})}else{g.dom.setAttribs(p,{href:v.link_href.value,title:v.link_title.value,rel:v.link_rel.value,target:(v.link_target.checked==true)?"_blank":"","class":v.link_classes.value,style:v.link_style.value})}}if(o){a=10+parseInt(v.width.value);z=(m.align=="aligncenter")?"mceTemp mceIEcenter":"mceTemp";if(n){g.dom.setAttribs(n,{"class":"wp-caption "+m.align,style:"width: "+a+"px;"});if(r){g.dom.setAttrib(r,"class",z)}if((i=g.dom.getParent(e,"dt"))&&(s=i.nextSibling)&&g.dom.hasClass(s,"wp-caption-dd")){g.dom.setHTML(s,v.img_cap.value)}}else{if((q=v.img_classes.value.match(/wp-image-([0-9]{1,6})/))&&q[1]){u="attachment_"+q[1]}if(v.link_href.value&&(w=g.dom.getParent(e,"a"))){if(w.childNodes.length==1){l=g.dom.getOuterHTML(w)}else{l=g.dom.getOuterHTML(w);l=l.match(/<a[^>]+>/i);l=l+g.dom.getOuterHTML(e)+"</a>"}}else{l=g.dom.getOuterHTML(e)}l='<dl id="'+u+'" class="wp-caption '+m.align+'" style="width: '+a+'px"><dt class="wp-caption-dt">'+l+'</dt><dd class="wp-caption-dd">'+v.img_cap.value+"</dd></dl>";j=g.dom.create("div",{"class":z},l);if(h){h.parentNode.insertBefore(j,h);if(h.childNodes.length==1){g.dom.remove(h)}else{if(w&&w.childNodes.length==1){g.dom.remove(w)}else{g.dom.remove(e)}}}else{if(c=g.dom.getParent(e,"TD,TH,LI")){c.appendChild(j);if(w&&w.childNodes.length==1){g.dom.remove(w)}else{g.dom.remove(e)}}}}}else{if(n&&r){if(v.link_href.value&&(y=g.dom.getParent(e,"a"))){l=g.dom.getOuterHTML(y)}else{l=g.dom.getOuterHTML(e)}h=g.dom.create("p",{},l);r.parentNode.insertBefore(h,r);g.dom.remove(r)}}if(v.img_classes.value.indexOf("aligncenter")!=-1){if(h&&(!h.style||h.style.textAlign!="center")){g.dom.setStyle(h,"textAlign","center")}}else{if(h&&h.style&&h.style.textAlign=="center"){g.dom.setStyle(h,"textAlign","")}}if(!v.link_href.value&&p){x=g.selection.getBookmark();g.dom.remove(p,1);g.selection.moveToBookmark(x)}tinyMCEPopup.execCommand("mceEndUndoLevel");g.execCommand("mceRepaint");tinyMCEPopup.close()},updateStyle:function(a){var e=tinyMCEPopup.dom,c,d=document.forms[0],b=e.create("img",{style:d.img_style.value});if(tinyMCEPopup.editor.settings.inline_styles){if(a=="align"){e.setStyle(b,"float","");e.setStyle(b,"vertical-align","");c=d.align.value;if(c){if(c=="left"||c=="right"){e.setStyle(b,"float",c)}else{b.style.verticalAlign=c}}}if(a=="border"){e.setStyle(b,"border","");c=d.border.value;if(c||c=="0"){if(c=="0"){b.style.border="0"}else{b.style.border=c+"px solid black"}}}if(a=="hspace"){e.setStyle(b,"marginLeft","");e.setStyle(b,"marginRight","");c=d.hspace.value;if(c){b.style.marginLeft=c+"px";b.style.marginRight=c+"px"}}if(a=="vspace"){e.setStyle(b,"marginTop","");e.setStyle(b,"marginBottom","");c=d.vspace.value;if(c){b.style.marginTop=c+"px";b.style.marginBottom=c+"px"}}d.img_style.value=e.serializeStyle(e.parseStyle(b.style.cssText));this.demoSetStyle()}},checkVal:function(a){if(a.value==""){if(a.id=="img_src"){a.value=this.I("img_demo").src||this.preloadImg.src}}},resetImageData:function(){var a=document.forms[0];a.width.value=a.height.value=""},updateImageData:function(){var d=document.forms[0],b=wpImage,a=d.width.value,c=d.height.value;if(!a&&c){a=d.width.value=b.width=Math.round(b.preloadImg.width/(b.preloadImg.height/c))}else{if(a&&!c){c=d.height.value=b.height=Math.round(b.preloadImg.height/(b.preloadImg.width/a))}}if(!a){d.width.value=b.width=b.preloadImg.width}if(!c){d.height.value=b.height=b.preloadImg.height}b.showSizeSet();b.demoSetSize();if(d.img_style.value){b.demoSetStyle()}},getImageData:function(){var a=wpImage,b=document.forms[0];a.preloadImg=new Image();a.preloadImg.onload=a.updateImageData;a.preloadImg.onerror=a.resetImageData;a.preloadImg.src=tinyMCEPopup.editor.documentBaseURI.toAbsolute(b.img_src.value)}};window.onload=function(){wpImage.init()};wpImage.preInit();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js	(revision 17487)
@@ -0,0 +1,119 @@
+
+(function() {
+	tinymce.create('tinymce.plugins.wpGallery', {
+
+		init : function(ed, url) {
+			var t = this;
+
+			t.url = url;
+			t._createButtons();
+
+			// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
+			ed.addCommand('WP_Gallery', function() {
+				var el = ed.selection.getNode(), post_id, vp = tinymce.DOM.getViewPort(),
+					H = vp.h - 80, W = ( 640 < vp.w ) ? 640 : vp.w;
+
+				if ( el.nodeName != 'IMG' ) return;
+				if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 )	return;
+
+				post_id = tinymce.DOM.get('post_ID').value;
+				tb_show('', tinymce.documentBaseURL + '/media-upload.php?post_id='+post_id+'&tab=gallery&TB_iframe=true&width='+W+'&height='+H);
+
+				tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
+			});
+
+			ed.onMouseDown.add(function(ed, e) {
+				if ( e.target.nodeName == 'IMG' && ed.dom.hasClass(e.target, 'wpGallery') )
+					ed.plugins.wordpress._showButtons(e.target, 'wp_gallerybtns');
+			});
+
+			ed.onBeforeSetContent.add(function(ed, o) {
+				o.content = t._do_gallery(o.content);
+			});
+
+			ed.onPostProcess.add(function(ed, o) {
+				if (o.get)
+					o.content = t._get_gallery(o.content);
+			});
+		},
+
+		_do_gallery : function(co) {
+			return co.replace(/\[gallery([^\]]*)\]/g, function(a,b){
+				return '<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wpGallery mceItem" title="gallery'+tinymce.DOM.encode(b)+'" />';
+			});
+		},
+
+		_get_gallery : function(co) {
+
+			function getAttr(s, n) {
+				n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
+				return n ? tinymce.DOM.decode(n[1]) : '';
+			};
+
+			return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
+				var cls = getAttr(im, 'class');
+
+				if ( cls.indexOf('wpGallery') != -1 )
+					return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
+
+				return a;
+			});
+		},
+
+		_createButtons : function() {
+			var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM, editButton, dellButton;
+
+			DOM.remove('wp_gallerybtns');
+
+			DOM.add(document.body, 'div', {
+				id : 'wp_gallerybtns',
+				style : 'display:none;'
+			});
+
+			editButton = DOM.add('wp_gallerybtns', 'img', {
+				src : t.url+'/img/edit.png',
+				id : 'wp_editgallery',
+				width : '24',
+				height : '24',
+				title : ed.getLang('wordpress.editgallery')
+			});
+
+			tinymce.dom.Event.add(editButton, 'mousedown', function(e) {
+				var ed = tinyMCE.activeEditor;
+				ed.windowManager.bookmark = ed.selection.getBookmark('simple');
+				ed.execCommand("WP_Gallery");
+			});
+
+			dellButton = DOM.add('wp_gallerybtns', 'img', {
+				src : t.url+'/img/delete.png',
+				id : 'wp_delgallery',
+				width : '24',
+				height : '24',
+				title : ed.getLang('wordpress.delgallery')
+			});
+
+			tinymce.dom.Event.add(dellButton, 'mousedown', function(e) {
+				var ed = tinyMCE.activeEditor, el = ed.selection.getNode();
+
+				if ( el.nodeName == 'IMG' && ed.dom.hasClass(el, 'wpGallery') ) {
+					ed.dom.remove(el);
+
+					ed.execCommand('mceRepaint');
+					return false;
+				}
+			});
+		},
+
+		getInfo : function() {
+			return {
+				longname : 'Gallery Settings',
+				author : 'WordPress',
+				authorurl : 'http://wordpress.org',
+				infourl : '',
+				version : "1.0"
+			};
+		}
+	});
+
+	tinymce.PluginManager.add('wpgallery', tinymce.plugins.wpGallery);
+})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){tinymce.create("tinymce.plugins.wpGallery",{init:function(a,b){var c=this;c.url=b;c._createButtons();a.addCommand("WP_Gallery",function(){var h=a.selection.getNode(),f,e=tinymce.DOM.getViewPort(),g=e.h-80,d=(640<e.w)?640:e.w;if(h.nodeName!="IMG"){return}if(a.dom.getAttrib(h,"class").indexOf("wpGallery")==-1){return}f=tinymce.DOM.get("post_ID").value;tb_show("",tinymce.documentBaseURL+"/media-upload.php?post_id="+f+"&tab=gallery&TB_iframe=true&width="+d+"&height="+g);tinymce.DOM.setStyle(["TB_overlay","TB_window","TB_load"],"z-index","999999")});a.onMouseDown.add(function(d,f){if(f.target.nodeName=="IMG"&&d.dom.hasClass(f.target,"wpGallery")){d.plugins.wordpress._showButtons(f.target,"wp_gallerybtns")}});a.onBeforeSetContent.add(function(d,e){e.content=c._do_gallery(e.content)});a.onPostProcess.add(function(d,e){if(e.get){e.content=c._get_gallery(e.content)}})},_do_gallery:function(a){return a.replace(/\[gallery([^\]]*)\]/g,function(d,c){return'<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wpGallery mceItem" title="gallery'+tinymce.DOM.encode(c)+'" />'})},_get_gallery:function(b){function a(c,d){d=new RegExp(d+'="([^"]+)"',"g").exec(c);return d?tinymce.DOM.decode(d[1]):""}return b.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g,function(e,d){var c=a(d,"class");if(c.indexOf("wpGallery")!=-1){return"<p>["+tinymce.trim(a(d,"title"))+"]</p>"}return e})},_createButtons:function(){var b=this,a=tinyMCE.activeEditor,d=tinymce.DOM,e,c;d.remove("wp_gallerybtns");d.add(document.body,"div",{id:"wp_gallerybtns",style:"display:none;"});e=d.add("wp_gallerybtns","img",{src:b.url+"/img/edit.png",id:"wp_editgallery",width:"24",height:"24",title:a.getLang("wordpress.editgallery")});tinymce.dom.Event.add(e,"mousedown",function(g){var f=tinyMCE.activeEditor;f.windowManager.bookmark=f.selection.getBookmark("simple");f.execCommand("WP_Gallery")});c=d.add("wp_gallerybtns","img",{src:b.url+"/img/delete.png",id:"wp_delgallery",width:"24",height:"24",title:a.getLang("wordpress.delgallery")});tinymce.dom.Event.add(c,"mousedown",function(h){var f=tinyMCE.activeEditor,g=f.selection.getNode();if(g.nodeName=="IMG"&&f.dom.hasClass(g,"wpGallery")){f.dom.remove(g);f.execCommand("mceRepaint");return false}})},getInfo:function(){return{longname:"Gallery Settings",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpgallery",tinymce.plugins.wpGallery)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.css	(revision 17487)
@@ -0,0 +1,1 @@
+#wp-link #internal-toggle{padding-right:18px;padding-left:0;}#wp-link label span{text-align:left;padding-left:5px;padding-right:0;}#wp-link .link-search-wrapper span{float:right;}#wp-link .link-search-wrapper input[type="text"]{float:right;}#wp-link .link-search-wrapper img.waiting{margin:8px 4px 0 1px;float:right;}#wp-link .link-target{margin:0 87px 0 0;}#wp-link .item-info{left:5px;right:auto;top:4px;bottom:0;}#wp-link #search-panel{float:right;}#wp-link-cancel{float:right;}#wp-link-update{float:left;}#wp-link .toggle-arrow{background-position:bottom right;}#wp-link .toggle-arrow-active{background-position:center right;}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.dev.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.dev.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink-rtl.dev.css	(revision 17487)
@@ -0,0 +1,54 @@
+#wp-link #internal-toggle {
+	padding-right: 18px;
+	padding-left: 0;
+}
+
+#wp-link label span {
+	text-align: left;
+	padding-left: 5px;
+	padding-right: 0;
+}
+
+#wp-link .link-search-wrapper span {
+	float: right;
+}
+
+#wp-link .link-search-wrapper input[type="text"] {
+	float: right;
+}
+
+#wp-link .link-search-wrapper img.waiting {
+	margin: 8px 4px 0 1px;
+	float: right;
+}
+
+#wp-link .link-target {
+	margin: 0 87px 0 0;
+}
+
+#wp-link .item-info {
+	left: 5px;
+	right: auto;
+	top: 4px;
+	bottom: 0;
+}
+
+#wp-link #search-panel {
+	float: right;
+}
+
+#wp-link-cancel {
+	float: right;
+}
+
+#wp-link-update {
+	float: left;
+}
+
+#wp-link .toggle-arrow {
+	background-position: bottom right;
+}
+
+#wp-link .toggle-arrow-active {
+	background-position: center right;
+}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink.css	(revision 17487)
@@ -0,0 +1,1 @@
+#wp-link{line-height:1.4em;font-size:12px;}#wp-link ol,#wp-link ul{list-style:none;margin:0;padding:0;}#wp-link input[type="text"]{-webkit-box-sizing:border-box;}#wp-link input[type="text"],#wp-link textarea{border-width:1px;border-style:solid;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;font-size:12px;margin:1px;padding:3px;}#wp-link #link-options{padding:10px 0 14px;border-bottom:1px solid #dfdfdf;margin:0 6px 14px;}#wp-link p.howto{margin:3px;}#wp-link #internal-toggle{display:inline-block;cursor:pointer;padding-left:18px;}#wp-link .toggle-arrow{background:transparent url('../img/toggle-arrow.png') top left no-repeat;height:23px;line-height:23px;}#wp-link .toggle-arrow-active{background-position:center left;}#wp-link label input[type="text"]{width:360px;margin-top:5px;}#wp-link label span{display:inline-block;width:80px;text-align:right;padding-right:5px;}#wp-link .link-search-wrapper{margin:5px 6px 9px;display:block;overflow:hidden;}#wp-link .link-search-wrapper span{float:left;margin-top:6px;}#wp-link .link-search-wrapper input[type="text"]{float:left;width:220px;}#wp-link .link-search-wrapper img.waiting{margin:8px 1px 0 4px;float:left;display:none;}#wp-link .link-target{width:auto;padding:3px 0 0;margin:0 0 0 87px;font-size:11px;}#wp-link .query-results{border:1px #dfdfdf solid;margin:0 5px 5px;background:#fff;height:185px;overflow:auto;position:relative;}#wp-link li,#wp-link .query-notice{clear:both;margin-bottom:0;border-bottom:1px solid #f1f1f1;color:#333;padding:4px 6px;cursor:pointer;position:relative;}#wp-link li:hover{background:#eaf2fa;color:#151515;}#wp-link li.unselectable{border-bottom:1px solid #dfdfdf;}#wp-link li.unselectable:hover{background:#fff;cursor:auto;color:#333;}#wp-link li.selected{background:#ddd;color:#333;}#wp-link li.selected .item-title{font-weight:bold;}#wp-link .item-title{display:inline-block;width:80%;}#wp-link .item-info{text-transform:uppercase;color:#666;font-size:11px;position:absolute;right:5px;top:4px;bottom:0;}#wp-link #search-results{display:none;}#wp-link #search-panel{float:left;width:100%;}#wp-link .river-waiting{display:none;padding:10px 0;}#wp-link .river-waiting img.waiting{margin:0 auto;display:block;}#wp-link .submitbox{padding:5px 10px;font-size:11px;overflow:auto;height:29px;}#wp-link-cancel{line-height:25px;float:left;}#wp-link-update{line-height:23px;float:right;}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css	(revision 17487)
@@ -0,0 +1,163 @@
+#wp-link {
+	line-height: 1.4em;
+	font-size: 12px;
+}
+
+#wp-link ol,
+#wp-link ul {
+	list-style: none;
+	margin: 0;
+	padding: 0;
+}
+
+#wp-link input[type="text"] {
+	-webkit-box-sizing: border-box;
+}
+
+#wp-link input[type="text"],
+#wp-link textarea {
+	border-width: 1px;
+	border-style: solid;
+	-moz-border-radius: 4px;
+	-khtml-border-radius: 4px;
+	-webkit-border-radius: 4px;
+	border-radius: 4px;
+	font-size: 12px;
+	margin: 1px;
+	padding: 3px;
+}
+
+#wp-link #link-options {
+	padding: 10px 0 14px;
+	border-bottom: 1px solid #dfdfdf;
+	margin: 0 6px 14px;
+}
+#wp-link p.howto {
+	margin: 3px;
+}
+#wp-link #internal-toggle {
+	display: inline-block;
+	cursor: pointer;
+	padding-left: 18px;
+}
+#wp-link .toggle-arrow {
+	background: transparent url( '../img/toggle-arrow.png' ) top left no-repeat;
+	height: 23px;
+	line-height: 23px;
+}
+#wp-link .toggle-arrow-active {
+	background-position: center left;
+}
+#wp-link label input[type="text"] {
+	width: 360px;
+	margin-top: 5px;
+}
+#wp-link label span {
+	display: inline-block;
+	width: 80px;
+	text-align: right;
+	padding-right: 5px;
+}
+#wp-link .link-search-wrapper {
+	margin: 5px 6px 9px;
+	display: block;
+	overflow: hidden;
+}
+#wp-link .link-search-wrapper span {
+	float: left;
+	margin-top: 6px;
+}
+#wp-link .link-search-wrapper input[type="text"] {
+	float: left;
+	width: 220px;
+}
+#wp-link .link-search-wrapper img.waiting {
+	margin: 8px 1px 0 4px;
+	float: left;
+	display: none;
+}
+#wp-link .link-target {
+	width: auto;
+	padding: 3px 0 0;
+	margin: 0 0 0 87px;
+	font-size: 11px;
+}
+#wp-link .query-results {
+	border: 1px #dfdfdf solid;
+	margin: 0 5px 5px;
+	background: #fff;
+	height: 185px;
+	overflow: auto;
+	position: relative;
+}
+#wp-link li,
+#wp-link .query-notice {
+	clear: both;
+	margin-bottom: 0;
+	border-bottom: 1px solid #f1f1f1;
+	color: #333;
+	padding: 4px 6px;
+	cursor: pointer;
+	position: relative;
+}
+#wp-link li:hover {
+	background: #eaf2fa;
+	color: #151515;
+}
+#wp-link li.unselectable {
+	border-bottom: 1px solid #dfdfdf;
+}
+#wp-link li.unselectable:hover {
+	background: #fff;
+	cursor: auto;
+	color: #333;
+}
+#wp-link li.selected {
+	background: #ddd;
+	color: #333;
+}
+#wp-link li.selected .item-title {
+	font-weight: bold;
+}
+#wp-link .item-title {
+	display: inline-block;
+	width: 80%;
+}
+#wp-link .item-info {
+	text-transform: uppercase;
+	color: #666;
+	font-size: 11px;
+	position: absolute;
+	right: 5px;
+	top: 4px;
+	bottom: 0;
+}
+#wp-link #search-results {
+	display: none;
+}
+#wp-link  #search-panel {
+	float: left;
+	width: 100%;
+}
+#wp-link .river-waiting {
+	display: none;
+	padding: 10px 0;
+}
+#wp-link .river-waiting img.waiting {
+	margin: 0 auto;
+	display: block;
+}
+#wp-link .submitbox {
+	padding: 5px 10px;
+	font-size: 11px;
+	overflow: auto;
+	height: 29px;
+}
+#wp-link-cancel {
+	line-height: 25px;
+	float: left;
+}
+#wp-link-update {
+	line-height: 23px;
+	float: right;
+}
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js	(revision 17487)
@@ -0,0 +1,60 @@
+(function() {
+	tinymce.create('tinymce.plugins.wpLink', {
+		/**
+		 * Initializes the plugin, this will be executed after the plugin has been created.
+		 * This call is done before the editor instance has finished it's initialization so use the onInit event
+		 * of the editor instance to intercept that event.
+		 *
+		 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
+		 * @param {string} url Absolute URL to where the plugin is located.
+		 */
+		init : function(ed, url) {
+			var disabled = true;
+
+			// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
+			ed.addCommand('WP_Link', function() {
+				if ( disabled )
+					return;
+				ed.windowManager.open({
+					id : 'wp-link',
+					width : 480,
+					height : "auto",
+					wpDialog : true,
+					title : ed.getLang('advlink.link_desc')
+				}, {
+					plugin_url : url // Plugin absolute URL
+				});
+			});
+
+			// Register example button
+			ed.addButton('link', {
+				title : ed.getLang('advanced.link_desc'),
+				cmd : 'WP_Link'
+			});
+
+			ed.addShortcut('alt+shift+a', ed.getLang('advanced.link_desc'), 'WP_Link');
+
+			ed.onNodeChange.add(function(ed, cm, n, co) {
+				disabled = co && n.nodeName != 'A';
+			});
+		},
+		/**
+		 * Returns information about the plugin as a name/value array.
+		 * The current keys are longname, author, authorurl, infourl and version.
+		 *
+		 * @return {Object} Name/value array containing information about the plugin.
+		 */
+		getInfo : function() {
+			return {
+				longname : 'WordPress Link Dialog',
+				author : 'WordPress',
+				authorurl : 'http://wordpress.org',
+				infourl : '',
+				version : "1.0"
+			};
+		}
+	});
+
+	// Register plugin
+	tinymce.PluginManager.add('wplink', tinymce.plugins.wpLink);
+})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){var c=true;a.addCommand("WP_Link",function(){if(c){return}a.windowManager.open({id:"wp-link",width:480,height:"auto",wpDialog:true,title:a.getLang("advlink.link_desc")},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(e,d,g,f){c=f&&g.nodeName!="A"})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})();
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js	(revision 17487)
@@ -0,0 +1,455 @@
+var wpLink;
+
+(function($){
+	var inputs = {}, rivers = {}, ed, River, Query;
+
+	wpLink = {
+		timeToTriggerRiver: 150,
+		minRiverAJAXDuration: 200,
+		riverBottomThreshold: 5,
+		keySensitivity: 100,
+		lastSearch: '',
+		init : function() {
+			inputs.dialog = $('#wp-link');
+			inputs.submit = $('#wp-link-submit');
+			// URL
+			inputs.url = $('#url-field');
+			// Secondary options
+			inputs.title = $('#link-title-field');
+			// Advanced Options
+			inputs.openInNewTab = $('#link-target-checkbox');
+			inputs.search = $('#search-field');
+			// Build Rivers
+			rivers.search = new River( $('#search-results') );
+			rivers.recent = new River( $('#most-recent-results') );
+			rivers.elements = $('.query-results', inputs.dialog);
+
+			// Bind event handlers
+			inputs.dialog.keydown( wpLink.keydown );
+			inputs.dialog.keyup( wpLink.keyup );
+			inputs.submit.click( function(e){
+				wpLink.update();
+				e.preventDefault();
+			});
+			$('#wp-link-cancel').click( wpLink.cancel );
+			$('#internal-toggle').click( wpLink.toggleInternalLinking );
+
+			rivers.elements.bind('river-select', wpLink.updateFields );
+
+			inputs.search.keyup( wpLink.searchInternalLinks );
+
+			inputs.dialog.bind('wpdialogrefresh', wpLink.refresh);
+		},
+
+		refresh : function() {
+			var e;
+			ed = tinyMCEPopup.editor;
+
+			// Refresh rivers (clear links, check visibility)
+			rivers.search.refresh();
+			rivers.recent.refresh();
+
+			tinyMCEPopup.restoreSelection();
+
+			// If link exists, select proper values.
+			if ( e = ed.dom.getParent(ed.selection.getNode(), 'A') ) {
+				// Set URL and description.
+				inputs.url.val( e.href );
+				inputs.title.val( ed.dom.getAttrib(e, 'title') );
+				// Set open in new tab.
+				if ( "_blank" == ed.dom.getAttrib(e, 'target') )
+					inputs.openInNewTab.attr('checked','checked');
+				// Update save prompt.
+				inputs.submit.val( wpLinkL10n.update );
+
+			// If there's no link, set the default values.
+			} else {
+				wpLink.setDefaultValues();
+				// Update save prompt.
+				inputs.submit.val( wpLinkL10n.save );
+			}
+
+			tinyMCEPopup.storeSelection();
+			// Focus the URL field and highlight its contents.
+			//     If this is moved above the selection changes,
+			//     IE will show a flashing cursor over the dialog.
+			inputs.url.focus()[0].select();
+			// Load the most recent results if this is the first time opening the panel.
+			if ( ! rivers.recent.ul.children().length )
+				rivers.recent.ajax();
+		},
+
+		cancel : function() {
+			tinyMCEPopup.close();
+		},
+
+		update : function() {
+			var ed = tinyMCEPopup.editor,
+				attrs = {
+					href : inputs.url.val(),
+					title : inputs.title.val(),
+					target : inputs.openInNewTab.attr('checked') ? '_blank' : ''
+				}, e, b;
+
+			tinyMCEPopup.restoreSelection();
+			e = ed.dom.getParent(ed.selection.getNode(), 'A');
+
+			// If the values are empty, unlink and return
+			if ( ! attrs.href || attrs.href == 'http://' ) {
+				if ( e ) {
+					tinyMCEPopup.execCommand("mceBeginUndoLevel");
+					b = ed.selection.getBookmark();
+					ed.dom.remove(e, 1);
+					ed.selection.moveToBookmark(b);
+					tinyMCEPopup.execCommand("mceEndUndoLevel");
+					tinyMCEPopup.close();
+				}
+				return;
+			}
+
+			tinyMCEPopup.execCommand("mceBeginUndoLevel");
+
+			if (e == null) {
+				ed.getDoc().execCommand("unlink", false, null);
+				tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
+
+				tinymce.each(ed.dom.select("a"), function(n) {
+					if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
+						e = n;
+						ed.dom.setAttribs(e, attrs);
+					}
+				});
+
+				// Sometimes WebKit lets a user create a link where
+				// they shouldn't be able to. In this case, CreateLink
+				// injects "#mce_temp_url#" into their content. Fix it.
+				if ( $(e).text() == '#mce_temp_url#' ) {
+					ed.dom.remove(e);
+					e = null;
+				}
+			} else {
+				ed.dom.setAttribs(e, attrs);
+			}
+
+			// Don't move caret if selection was image
+			if ( e && (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') ) {
+				ed.focus();
+				ed.selection.select(e);
+				ed.selection.collapse(0);
+				tinyMCEPopup.storeSelection();
+			}
+
+			tinyMCEPopup.execCommand("mceEndUndoLevel");
+			tinyMCEPopup.close();
+		},
+
+		updateFields : function( e, li, originalEvent ) {
+			inputs.url.val( li.children('.item-permalink').val() );
+			inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() );
+			if ( originalEvent && originalEvent.type == "click" )
+				inputs.url.focus();
+		},
+		setDefaultValues : function() {
+			// Set URL and description to defaults.
+			// Leave the new tab setting as-is.
+			inputs.url.val('http://');
+			inputs.title.val('');
+		},
+
+		searchInternalLinks : function() {
+			var t = $(this), waiting,
+				search = t.val();
+
+			if ( search.length > 2 ) {
+				rivers.recent.hide();
+				rivers.search.show();
+
+				// Don't search if the keypress didn't change the title.
+				if ( wpLink.lastSearch == search )
+					return;
+
+				wpLink.lastSearch = search;
+				waiting = t.siblings('img.waiting').show();
+
+				rivers.search.change( search );
+				rivers.search.ajax( function(){ waiting.hide(); });
+			} else {
+				rivers.search.hide();
+				rivers.recent.show();
+			}
+		},
+
+		next : function() {
+			rivers.search.next();
+			rivers.recent.next();
+		},
+		prev : function() {
+			rivers.search.prev();
+			rivers.recent.prev();
+		},
+
+		keydown : function( event ) {
+			var fn, key = $.ui.keyCode;
+
+			switch( event.which ) {
+				case key.UP:
+					fn = 'prev';
+				case key.DOWN:
+					fn = fn || 'next';
+					clearInterval( wpLink.keyInterval );
+					wpLink[ fn ]();
+					wpLink.keyInterval = setInterval( wpLink[ fn ], wpLink.keySensitivity );
+					break;
+				default:
+					return;
+			}
+			event.preventDefault();
+		},
+		keyup: function( event ) {
+			var key = $.ui.keyCode;
+
+			switch( event.which ) {
+				case key.ESCAPE:
+					wpLink.cancel();
+					break;
+				case key.UP:
+				case key.DOWN:
+					clearInterval( wpLink.keyInterval );
+					break;
+				default:
+					return;
+			}
+			event.preventDefault();
+		},
+
+		delayedCallback : function( func, delay ) {
+			var timeoutTriggered, funcTriggered, funcArgs, funcContext;
+
+			if ( ! delay )
+				return func;
+
+			setTimeout( function() {
+				if ( funcTriggered )
+					return func.apply( funcContext, funcArgs );
+				// Otherwise, wait.
+				timeoutTriggered = true;
+			}, delay);
+
+			return function() {
+				if ( timeoutTriggered )
+					return func.apply( this, arguments );
+				// Otherwise, wait.
+				funcArgs = arguments;
+				funcContext = this;
+				funcTriggered = true;
+			};
+		},
+
+		toggleInternalLinking : function( event ) {
+			var panel = $('#search-panel'),
+				widget = inputs.dialog.wpdialog('widget'),
+				// We're about to toggle visibility; it's currently the opposite
+				visible = !panel.is(':visible'),
+				win = $(window);
+
+			$(this).toggleClass('toggle-arrow-active', visible);
+
+			inputs.dialog.height('auto');
+			panel.slideToggle( 300, function() {
+				setUserSetting('wplink', visible ? '1' : '0');
+				inputs[ visible ? 'search' : 'url' ].focus();
+
+				// Move the box if the box is now expanded, was opened in a collapsed state,
+				// and if it needs to be moved. (Judged by bottom not being positive or
+				// bottom being smaller than top.)
+				var scroll = win.scrollTop(),
+					top = widget.offset().top,
+					bottom = top + widget.outerHeight(),
+					diff = bottom - win.height();
+
+				if ( diff > scroll ) {
+					widget.animate({'top': diff < top ?  top - diff : scroll }, 200);
+				}
+			});
+			event.preventDefault();
+		}
+	}
+
+	River = function( element, search ) {
+		var self = this;
+		this.element = element;
+		this.ul = element.children('ul');
+		this.waiting = element.find('.river-waiting');
+
+		this.change( search );
+		this.refresh();
+
+		element.scroll( function(){ self.maybeLoad(); });
+		element.delegate('li', 'click', function(e){ self.select( $(this), e ); });
+	};
+
+	$.extend( River.prototype, {
+		refresh: function() {
+			this.deselect();
+			this.visible = this.element.is(':visible');
+		},
+		show: function() {
+			if ( ! this.visible ) {
+				this.deselect();
+				this.element.show();
+				this.visible = true;
+			}
+		},
+		hide: function() {
+			this.element.hide();
+			this.visible = false;
+		},
+		// Selects a list item and triggers the river-select event.
+		select: function( li, event ) {
+			var liHeight, elHeight, liTop, elTop;
+
+			if ( li.hasClass('unselectable') || li == this.selected )
+				return;
+
+			this.deselect();
+			this.selected = li.addClass('selected');
+			// Make sure the element is visible
+			liHeight = li.outerHeight();
+			elHeight = this.element.height();
+			liTop = li.position().top;
+			elTop = this.element.scrollTop();
+
+			if ( liTop < 0 ) // Make first visible element
+				this.element.scrollTop( elTop + liTop );
+			else if ( liTop + liHeight > elHeight ) // Make last visible element
+				this.element.scrollTop( elTop + liTop - elHeight + liHeight );
+
+			// Trigger the river-select event
+			this.element.trigger('river-select', [ li, event, this ]);
+		},
+		deselect: function() {
+			if ( this.selected )
+				this.selected.removeClass('selected');
+			this.selected = false;
+		},
+		prev: function() {
+			if ( ! this.visible )
+				return;
+
+			var to;
+			if ( this.selected ) {
+				to = this.selected.prev('li');
+				if ( to.length )
+					this.select( to );
+			}
+		},
+		next: function() {
+			if ( ! this.visible )
+				return;
+
+			var to = this.selected ? this.selected.next('li') : $('li:not(.unselectable):first', this.element);
+			if ( to.length )
+				this.select( to );
+		},
+		ajax: function( callback ) {
+			var self = this,
+				delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration,
+				response = wpLink.delayedCallback( function( results, params ) {
+					self.process( results, params );
+					if ( callback )
+						callback( results, params );
+				}, delay );
+
+			this.query.ajax( response );
+		},
+		change: function( search ) {
+			if ( this.query && this._search == search )
+				return;
+
+			this._search = search;
+			this.query = new Query( search );
+			this.element.scrollTop(0);
+		},
+		process: function( results, params ) {
+			var list = '', alt = true, classes = '',
+				firstPage = params.page == 1;
+
+			if ( !results ) {
+				if ( firstPage ) {
+					list += '<li class="unselectable"><span class="item-title"><em>'
+					+ wpLinkL10n.noMatchesFound
+					+ '</em></span></li>';
+				}
+			} else {
+				$.each( results, function() {
+					classes = alt ? 'alternate' : '';
+					classes += this['title'] ? '' : ' no-title';
+					list += classes ? '<li class="' + classes + '">' : '<li>';
+					list += '<input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />';
+					list += '<span class="item-title">';
+					list += this['title'] ? this['title'] : wpLinkL10n.noTitle;
+					list += '</span><span class="item-info">' + this['info'] + '</span></li>';
+					alt = ! alt;
+				});
+			}
+
+			this.ul[ firstPage ? 'html' : 'append' ]( list );
+		},
+		maybeLoad: function() {
+			var self = this,
+				el = this.element,
+				bottom = el.scrollTop() + el.height();
+
+			if ( ! this.query.ready() || bottom < this.ul.height() - wpLink.riverBottomThreshold )
+				return;
+
+			setTimeout(function() {
+				var newTop = el.scrollTop(),
+					newBottom = newTop + el.height();
+
+				if ( ! self.query.ready() || newBottom < self.ul.height() - wpLink.riverBottomThreshold )
+					return;
+
+				self.waiting.show();
+				el.scrollTop( newTop + self.waiting.outerHeight() );
+
+				self.ajax( function() { self.waiting.hide(); });
+			}, wpLink.timeToTriggerRiver );
+		}
+	});
+
+	Query = function( search ) {
+		this.page = 1;
+		this.allLoaded = false;
+		this.querying = false;
+		this.search = search;
+	};
+
+	$.extend( Query.prototype, {
+		ready: function() {
+			return !( this.querying || this.allLoaded );
+		},
+		ajax: function( callback ) {
+			var self = this,
+				query = {
+					action : 'wp-link-ajax',
+					page : this.page,
+					'_ajax_linking_nonce' : $('#_ajax_linking_nonce').val()
+				};
+
+			if ( this.search )
+				query.search = this.search;
+
+			this.querying = true;
+
+			$.post( ajaxurl, query, function(r) {
+				self.page++;
+				self.querying = false;
+				self.allLoaded = !r;
+				callback( r, query );
+			}, "json" );
+		}
+	});
+
+	$(document).ready( wpLink.init );
+})(jQuery);
Index: /tags/3.1/wp-includes/js/tinymce/plugins/wplink/js/wplink.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/plugins/wplink/js/wplink.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/plugins/wplink/js/wplink.js	(revision 17487)
@@ -0,0 +1,1 @@
+var wpLink;(function(f){var b={},e={},d,a,c;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",init:function(){b.dialog=f("#wp-link");b.submit=f("#wp-link-submit");b.url=f("#url-field");b.title=f("#link-title-field");b.openInNewTab=f("#link-target-checkbox");b.search=f("#search-field");e.search=new a(f("#search-results"));e.recent=new a(f("#most-recent-results"));e.elements=f(".query-results",b.dialog);b.dialog.keydown(wpLink.keydown);b.dialog.keyup(wpLink.keyup);b.submit.click(function(g){wpLink.update();g.preventDefault()});f("#wp-link-cancel").click(wpLink.cancel);f("#internal-toggle").click(wpLink.toggleInternalLinking);e.elements.bind("river-select",wpLink.updateFields);b.search.keyup(wpLink.searchInternalLinks);b.dialog.bind("wpdialogrefresh",wpLink.refresh)},refresh:function(){var g;d=tinyMCEPopup.editor;e.search.refresh();e.recent.refresh();tinyMCEPopup.restoreSelection();if(g=d.dom.getParent(d.selection.getNode(),"A")){b.url.val(g.href);b.title.val(d.dom.getAttrib(g,"title"));if("_blank"==d.dom.getAttrib(g,"target")){b.openInNewTab.attr("checked","checked")}b.submit.val(wpLinkL10n.update)}else{wpLink.setDefaultValues();b.submit.val(wpLinkL10n.save)}tinyMCEPopup.storeSelection();b.url.focus()[0].select();if(!e.recent.ul.children().length){e.recent.ajax()}},cancel:function(){tinyMCEPopup.close()},update:function(){var h=tinyMCEPopup.editor,i={href:b.url.val(),title:b.title.val(),target:b.openInNewTab.attr("checked")?"_blank":""},j,g;tinyMCEPopup.restoreSelection();j=h.dom.getParent(h.selection.getNode(),"A");if(!i.href||i.href=="http://"){if(j){tinyMCEPopup.execCommand("mceBeginUndoLevel");g=h.selection.getBookmark();h.dom.remove(j,1);h.selection.moveToBookmark(g);tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close()}return}tinyMCEPopup.execCommand("mceBeginUndoLevel");if(j==null){h.getDoc().execCommand("unlink",false,null);tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1});tinymce.each(h.dom.select("a"),function(k){if(h.dom.getAttrib(k,"href")=="#mce_temp_url#"){j=k;h.dom.setAttribs(j,i)}});if(f(j).text()=="#mce_temp_url#"){h.dom.remove(j);j=null}}else{h.dom.setAttribs(j,i)}if(j&&(j.childNodes.length!=1||j.firstChild.nodeName!="IMG")){h.focus();h.selection.select(j);h.selection.collapse(0);tinyMCEPopup.storeSelection()}tinyMCEPopup.execCommand("mceEndUndoLevel");tinyMCEPopup.close()},updateFields:function(i,h,g){b.url.val(h.children(".item-permalink").val());b.title.val(h.hasClass("no-title")?"":h.children(".item-title").text());if(g&&g.type=="click"){b.url.focus()}},setDefaultValues:function(){b.url.val("http://");b.title.val("")},searchInternalLinks:function(){var h=f(this),i,g=h.val();if(g.length>2){e.recent.hide();e.search.show();if(wpLink.lastSearch==g){return}wpLink.lastSearch=g;i=h.siblings("img.waiting").show();e.search.change(g);e.search.ajax(function(){i.hide()})}else{e.search.hide();e.recent.show()}},next:function(){e.search.next();e.recent.next()},prev:function(){e.search.prev();e.recent.prev()},keydown:function(i){var h,g=f.ui.keyCode;switch(i.which){case g.UP:h="prev";case g.DOWN:h=h||"next";clearInterval(wpLink.keyInterval);wpLink[h]();wpLink.keyInterval=setInterval(wpLink[h],wpLink.keySensitivity);break;default:return}i.preventDefault()},keyup:function(h){var g=f.ui.keyCode;switch(h.which){case g.ESCAPE:wpLink.cancel();break;case g.UP:case g.DOWN:clearInterval(wpLink.keyInterval);break;default:return}h.preventDefault()},delayedCallback:function(i,g){var l,k,j,h;if(!g){return i}setTimeout(function(){if(k){return i.apply(h,j)}l=true},g);return function(){if(l){return i.apply(this,arguments)}j=arguments;h=this;k=true}},toggleInternalLinking:function(h){var g=f("#search-panel"),i=b.dialog.wpdialog("widget"),k=!g.is(":visible"),j=f(window);f(this).toggleClass("toggle-arrow-active",k);b.dialog.height("auto");g.slideToggle(300,function(){setUserSetting("wplink",k?"1":"0");b[k?"search":"url"].focus();var l=j.scrollTop(),o=i.offset().top,m=o+i.outerHeight(),n=m-j.height();if(n>l){i.animate({top:n<o?o-n:l},200)}});h.preventDefault()}};a=function(i,h){var g=this;this.element=i;this.ul=i.children("ul");this.waiting=i.find(".river-waiting");this.change(h);this.refresh();i.scroll(function(){g.maybeLoad()});i.delegate("li","click",function(j){g.select(f(this),j)})};f.extend(a.prototype,{refresh:function(){this.deselect();this.visible=this.element.is(":visible")},show:function(){if(!this.visible){this.deselect();this.element.show();this.visible=true}},hide:function(){this.element.hide();this.visible=false},select:function(h,k){var j,i,l,g;if(h.hasClass("unselectable")||h==this.selected){return}this.deselect();this.selected=h.addClass("selected");j=h.outerHeight();i=this.element.height();l=h.position().top;g=this.element.scrollTop();if(l<0){this.element.scrollTop(g+l)}else{if(l+j>i){this.element.scrollTop(g+l-i+j)}}this.element.trigger("river-select",[h,k,this])},deselect:function(){if(this.selected){this.selected.removeClass("selected")}this.selected=false},prev:function(){if(!this.visible){return}var g;if(this.selected){g=this.selected.prev("li");if(g.length){this.select(g)}}},next:function(){if(!this.visible){return}var g=this.selected?this.selected.next("li"):f("li:not(.unselectable):first",this.element);if(g.length){this.select(g)}},ajax:function(j){var h=this,i=this.query.page==1?0:wpLink.minRiverAJAXDuration,g=wpLink.delayedCallback(function(k,l){h.process(k,l);if(j){j(k,l)}},i);this.query.ajax(g)},change:function(g){if(this.query&&this._search==g){return}this._search=g;this.query=new c(g);this.element.scrollTop(0)},process:function(h,l){var i="",j=true,g="",k=l.page==1;if(!h){if(k){i+='<li class="unselectable"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"}}else{f.each(h,function(){g=j?"alternate":"";g+=this["title"]?"":" no-title";i+=g?'<li class="'+g+'">':"<li>";i+='<input type="hidden" class="item-permalink" value="'+this["permalink"]+'" />';i+='<span class="item-title">';i+=this["title"]?this["title"]:wpLinkL10n.noTitle;i+='</span><span class="item-info">'+this["info"]+"</span></li>";j=!j})}this.ul[k?"html":"append"](i)},maybeLoad:function(){var h=this,i=this.element,g=i.scrollTop()+i.height();if(!this.query.ready()||g<this.ul.height()-wpLink.riverBottomThreshold){return}setTimeout(function(){var j=i.scrollTop(),k=j+i.height();if(!h.query.ready()||k<h.ul.height()-wpLink.riverBottomThreshold){return}h.waiting.show();i.scrollTop(j+h.waiting.outerHeight());h.ajax(function(){h.waiting.hide()})},wpLink.timeToTriggerRiver)}});c=function(g){this.page=1;this.allLoaded=false;this.querying=false;this.search=g};f.extend(c.prototype,{ready:function(){return !(this.querying||this.allLoaded)},ajax:function(i){var g=this,h={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:f("#_ajax_linking_nonce").val()};if(this.search){h.search=this.search}this.querying=true;f.post(ajaxurl,h,function(j){g.page++;g.querying=false;g.allLoaded=!j;i(j,h)},"json")}});f(document).ready(wpLink.init)})(jQuery);
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/about.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/about.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/about.htm	(revision 17487)
@@ -0,0 +1,56 @@
+<!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>{#advanced_dlg.about_title}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="../../utils/mctabs.js?ver=3392"></script>
+	<script type="text/javascript" src="js/about.js?ver=3392"></script>
+</head>
+<body id="about" style="display: none">
+		<div class="tabs">
+			<ul>
+				<li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#advanced_dlg.about_general}</a></span></li>
+				<li id="help_tab" style="display:none"><span><a href="javascript:mcTabs.displayTab('help_tab','help_panel');" onmousedown="return false;">{#advanced_dlg.about_help}</a></span></li>
+				<li id="plugins_tab"><span><a href="javascript:mcTabs.displayTab('plugins_tab','plugins_panel');" onmousedown="return false;">{#advanced_dlg.about_plugins}</a></span></li>
+			</ul>
+		</div>
+
+		<div class="panel_wrapper">
+			<div id="general_panel" class="panel current">
+				<h3>{#advanced_dlg.about_title}</h3>
+				<p>Version: <span id="version"></span> (<span id="date"></span>)</p>
+				<p>TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under <a href="../../license.txt" target="_blank">LGPL</a>
+				by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.</p>
+				<p>Copyright &copy; 2003-2008, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p>
+				<p>For more information about this software visit the <a href="http://tinymce.moxiecode.com" target="_blank">TinyMCE website</a>.</p>
+
+				<div id="buttoncontainer">
+					<a href="http://www.moxiecode.com" target="_blank"><img src="http://tinymce.moxiecode.com/images/gotmoxie.png" alt="Got Moxie?" border="0" /></a>
+					<a href="http://sourceforge.net/projects/tinymce/" target="_blank"><img src="http://sourceforge.net/sflogo.php?group_id=103281" alt="Hosted By Sourceforge" border="0" /></a>
+					<a href="http://www.freshmeat.net/projects/tinymce" target="_blank"><img src="http://tinymce.moxiecode.com/images/fm.gif" alt="Also on freshmeat" border="0" /></a>
+				</div>
+			</div>
+
+			<div id="plugins_panel" class="panel">
+				<div id="pluginscontainer">
+					<h3>{#advanced_dlg.about_loaded}</h3>
+
+					<div id="plugintablecontainer">
+					</div>
+
+					<p>&nbsp;</p>
+				</div>
+			</div>
+
+			<div id="help_panel" class="panel noscroll" style="overflow: visible;">
+				<div id="iframecontainer"></div>
+			</div>
+		</div>
+
+		<div class="mceActionPanel">
+			<div style="float: right">
+			<input type="button" id="cancel" name="cancel" value="{#close}" onclick="tinyMCEPopup.close();" />
+			</div>
+		</div>
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/anchor.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/anchor.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/anchor.htm	(revision 17487)
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>{#advanced_dlg.anchor_title}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="js/anchor.js?ver=3392"></script>
+</head>
+<body style="display: none">
+<form onsubmit="AnchorDialog.update();return false;" action="#">
+	<table border="0" cellpadding="4" cellspacing="0">
+		<tr>
+			<td colspan="2" class="title">{#advanced_dlg.anchor_title}</td>
+		</tr>
+		<tr>
+			<td class="nowrap">{#advanced_dlg.anchor_name}:</td>
+			<td><input name="anchorName" type="text" class="mceFocus" id="anchorName" value="" style="width: 200px" /></td>
+		</tr>
+	</table>
+
+	<div class="mceActionPanel">
+		<div style="float: left">
+			<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+		</div>
+
+		<div style="float: right">
+			<input type="submit" id="insert" name="insert" value="{#update}" />
+		</div>
+	</div>
+</form>
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/charmap.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/charmap.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/charmap.htm	(revision 17487)
@@ -0,0 +1,52 @@
+<!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>{#advanced_dlg.charmap_title}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="js/charmap.js?ver=3392"></script>
+</head>
+<body id="charmap" style="display:none">
+<table align="center" border="0" cellspacing="0" cellpadding="2">
+    <tr>
+        <td colspan="2" class="title">{#advanced_dlg.charmap_title}</td>
+    </tr>
+    <tr>
+        <td id="charmapView" rowspan="2" align="left" valign="top">
+			<!-- Chars will be rendered here -->
+        </td>
+        <td width="100" align="center" valign="top">
+            <table border="0" cellpadding="0" cellspacing="0" width="100" style="height:100px">
+                <tr>
+                    <td id="codeV">&nbsp;</td>
+                </tr>
+                <tr>
+                    <td id="codeN">&nbsp;</td>
+                </tr>
+            </table>
+        </td>
+    </tr>
+    <tr>
+        <td valign="bottom" style="padding-bottom: 3px;">
+            <table width="100" align="center" border="0" cellpadding="2" cellspacing="0">
+                <tr>
+                    <td align="center" style="border-left: 1px solid #666699; border-top: 1px solid #666699; border-right: 1px solid #666699;">HTML-Code</td>
+                </tr>
+                <tr>
+                    <td style="font-size: 16px; font-weight: bold; border-left: 1px solid #666699; border-bottom: 1px solid #666699; border-right: 1px solid #666699;" id="codeA" align="center">&nbsp;</td>
+                </tr>
+                <tr>
+                    <td style="font-size: 1px;">&nbsp;</td>
+                </tr>
+                <tr>
+                    <td align="center" style="border-left: 1px solid #666699; border-top: 1px solid #666699; border-right: 1px solid #666699;">NUM-Code</td>
+                </tr>
+                <tr>
+                    <td style="font-size: 16px; font-weight: bold; border-left: 1px solid #666699; border-bottom: 1px solid #666699; border-right: 1px solid #666699;" id="codeB" align="center">&nbsp;</td>
+                </tr>
+            </table>
+        </td>
+    </tr>
+</table>
+
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/color_picker.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/color_picker.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/color_picker.htm	(revision 17487)
@@ -0,0 +1,75 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>{#advanced_dlg.colorpicker_title}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="../../utils/mctabs.js?ver=3392"></script>
+	<script type="text/javascript" src="js/color_picker.js?ver=3392"></script>
+</head>
+<body id="colorpicker" style="display: none">
+<form onsubmit="insertAction();return false" action="#">
+	<div class="tabs">
+		<ul>
+			<li id="picker_tab" class="current"><span><a href="javascript:mcTabs.displayTab('picker_tab','picker_panel');" onmousedown="return false;">{#advanced_dlg.colorpicker_picker_tab}</a></span></li>
+			<li id="rgb_tab"><span><a href="javascript:;" onclick="generateWebColors();mcTabs.displayTab('rgb_tab','rgb_panel');" onmousedown="return false;">{#advanced_dlg.colorpicker_palette_tab}</a></span></li>
+			<li id="named_tab"><span><a  href="javascript:;" onclick="generateNamedColors();javascript:mcTabs.displayTab('named_tab','named_panel');" onmousedown="return false;">{#advanced_dlg.colorpicker_named_tab}</a></span></li>
+		</ul>
+	</div>
+
+	<div class="panel_wrapper">
+		<div id="picker_panel" class="panel current">
+			<fieldset>
+				<legend>{#advanced_dlg.colorpicker_picker_title}</legend>
+				<div id="picker">
+					<img id="colors" src="img/colorpicker.jpg" onclick="computeColor(event)" onmousedown="isMouseDown = true;return false;" onmouseup="isMouseDown = false;" onmousemove="if (isMouseDown && isMouseOver) computeColor(event); return false;" onmouseover="isMouseOver=true;" onmouseout="isMouseOver=false;" alt="" />
+
+					<div id="light">
+						<!-- Will be filled with divs -->
+					</div>
+
+					<br style="clear: both" />
+				</div>
+			</fieldset>
+		</div>
+
+		<div id="rgb_panel" class="panel">
+			<fieldset>
+				<legend>{#advanced_dlg.colorpicker_palette_title}</legend>
+				<div id="webcolors">
+					<!-- Gets filled with web safe colors-->
+				</div>
+
+				<br style="clear: both" />
+			</fieldset>
+		</div>
+
+		<div id="named_panel" class="panel">
+			<fieldset>
+				<legend>{#advanced_dlg.colorpicker_named_title}</legend>
+				<div id="namedcolors">
+					<!-- Gets filled with named colors-->
+				</div>
+
+				<br style="clear: both" />
+
+				<div id="colornamecontainer">
+					{#advanced_dlg.colorpicker_name} <span id="colorname"></span>
+				</div>
+			</fieldset>
+		</div>
+	</div>
+
+	<div class="mceActionPanel">
+		<div style="float: left">
+			<input type="submit" id="insert" name="insert" value="{#apply}" />
+		</div>
+
+		<div id="preview"></div>
+
+		<div id="previewblock">
+			<label for="color">{#advanced_dlg.colorpicker_color}</label> <input id="color" type="text" size="8" maxlength="8" class="text mceFocus" />
+		</div>
+	</div>
+</form>
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/editor_template.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/editor_template.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/editor_template.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(e){var d=e.DOM,b=e.dom.Event,h=e.extend,f=e.each,a=e.util.Cookie,g,c=e.explode;e.ThemeManager.requireLangPack("advanced");e.create("tinymce.themes.AdvancedTheme",{sizes:[8,10,12,14,18,24,36],controls:{bold:["bold_desc","Bold"],italic:["italic_desc","Italic"],underline:["underline_desc","Underline"],strikethrough:["striketrough_desc","Strikethrough"],justifyleft:["justifyleft_desc","JustifyLeft"],justifycenter:["justifycenter_desc","JustifyCenter"],justifyright:["justifyright_desc","JustifyRight"],justifyfull:["justifyfull_desc","JustifyFull"],bullist:["bullist_desc","InsertUnorderedList"],numlist:["numlist_desc","InsertOrderedList"],outdent:["outdent_desc","Outdent"],indent:["indent_desc","Indent"],cut:["cut_desc","Cut"],copy:["copy_desc","Copy"],paste:["paste_desc","Paste"],undo:["undo_desc","Undo"],redo:["redo_desc","Redo"],link:["link_desc","mceLink"],unlink:["unlink_desc","unlink"],image:["image_desc","mceImage"],cleanup:["cleanup_desc","mceCleanup"],help:["help_desc","mceHelp"],code:["code_desc","mceCodeEditor"],hr:["hr_desc","InsertHorizontalRule"],removeformat:["removeformat_desc","RemoveFormat"],sub:["sub_desc","subscript"],sup:["sup_desc","superscript"],forecolor:["forecolor_desc","ForeColor"],forecolorpicker:["forecolor_desc","mceForeColor"],backcolor:["backcolor_desc","HiliteColor"],backcolorpicker:["backcolor_desc","mceBackColor"],charmap:["charmap_desc","mceCharMap"],visualaid:["visualaid_desc","mceToggleVisualAid"],anchor:["anchor_desc","mceInsertAnchor"],newdocument:["newdocument_desc","mceNewDocument"],blockquote:["blockquote_desc","mceBlockQuote"]},stateControls:["bold","italic","underline","strikethrough","bullist","numlist","justifyleft","justifycenter","justifyright","justifyfull","sub","sup","blockquote"],init:function(j,k){var l=this,m,i,n;l.editor=j;l.url=k;l.onResolveName=new e.util.Dispatcher(this);l.settings=m=h({theme_advanced_path:true,theme_advanced_toolbar_location:"bottom",theme_advanced_buttons1:"bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,|,sub,sup,|,charmap",theme_advanced_blockformats:"p,address,pre,h1,h2,h3,h4,h5,h6",theme_advanced_toolbar_align:"center",theme_advanced_fonts:"Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",theme_advanced_more_colors:1,theme_advanced_row_height:23,theme_advanced_resize_horizontal:1,theme_advanced_resizing_use_cookie:1,theme_advanced_font_sizes:"1,2,3,4,5,6,7",readonly:j.settings.readonly},j.settings);if(!m.font_size_style_values){m.font_size_style_values="8pt,10pt,12pt,14pt,18pt,24pt,36pt"}if(e.is(m.theme_advanced_font_sizes,"string")){m.font_size_style_values=e.explode(m.font_size_style_values);m.font_size_classes=e.explode(m.font_size_classes||"");n={};j.settings.theme_advanced_font_sizes=m.theme_advanced_font_sizes;f(j.getParam("theme_advanced_font_sizes","","hash"),function(q,p){var o;if(p==q&&q>=1&&q<=7){p=q+" ("+l.sizes[q-1]+"pt)";o=m.font_size_classes[q-1];q=m.font_size_style_values[q-1]||(l.sizes[q-1]+"pt")}if(/^\s*\./.test(q)){o=q.replace(/\./g,"")}n[p]=o?{"class":o}:{fontSize:q}});m.theme_advanced_font_sizes=n}if((i=m.theme_advanced_path_location)&&i!="none"){m.theme_advanced_statusbar_location=m.theme_advanced_path_location}if(m.theme_advanced_statusbar_location=="none"){m.theme_advanced_statusbar_location=0}j.onInit.add(function(){if(!j.settings.readonly){j.onNodeChange.add(l._nodeChanged,l)}if(j.settings.content_css!==false){j.dom.loadCSS(j.baseURI.toAbsolute(k+"/skins/"+j.settings.skin+"/content.css"))}});j.onSetProgressState.add(function(q,o,r){var s,t=q.id,p;if(o){l.progressTimer=setTimeout(function(){s=q.getContainer();s=s.insertBefore(d.create("DIV",{style:"position:relative"}),s.firstChild);p=d.get(q.id+"_tbl");d.add(s,"div",{id:t+"_blocker","class":"mceBlocker",style:{width:p.clientWidth+2,height:p.clientHeight+2}});d.add(s,"div",{id:t+"_progress","class":"mceProgress",style:{left:p.clientWidth/2,top:p.clientHeight/2}})},r||0)}else{d.remove(t+"_blocker");d.remove(t+"_progress");clearTimeout(l.progressTimer)}});d.loadCSS(m.editor_css?j.documentBaseURI.toAbsolute(m.editor_css):k+"/skins/"+j.settings.skin+"/ui.css");if(m.skin_variant){d.loadCSS(k+"/skins/"+j.settings.skin+"/ui_"+m.skin_variant+".css")}},createControl:function(l,i){var j,k;if(k=i.createControl(l)){return k}switch(l){case"styleselect":return this._createStyleSelect();case"formatselect":return this._createBlockFormats();case"fontselect":return this._createFontSelect();case"fontsizeselect":return this._createFontSizeSelect();case"forecolor":return this._createForeColorMenu();case"backcolor":return this._createBackColorMenu()}if((j=this.controls[l])){return i.createButton(l,{title:"advanced."+j[0],cmd:j[1],ui:j[2],value:j[3]})}},execCommand:function(k,j,l){var i=this["_"+k];if(i){i.call(this,j,l);return true}return false},_importClasses:function(k){var i=this.editor,j=i.controlManager.get("styleselect");if(j.getLength()==0){f(i.dom.getClasses(),function(n,l){var m="style_"+l;i.formatter.register(m,{inline:"span",attributes:{"class":n["class"]},selector:"*"});j.add(n["class"],m)})}},_createStyleSelect:function(m){var k=this,i=k.editor,j=i.controlManager,l;l=j.createListBox("styleselect",{title:"advanced.style_select",onselect:function(o){var p,n=[];f(l.items,function(q){n.push(q.value)});i.focus();i.undoManager.add();p=i.formatter.matchAll(n);if(!o||p[0]==o){i.formatter.remove(p[0])}else{i.formatter.apply(o)}i.undoManager.add();i.nodeChanged();return false}});i.onInit.add(function(){var o=0,n=i.getParam("style_formats");if(n){f(n,function(p){var q,r=0;f(p,function(){r++});if(r>1){q=p.name=p.name||"style_"+(o++);i.formatter.register(q,p);l.add(p.title,q)}else{l.add(p.title)}})}else{f(i.getParam("theme_advanced_styles","","hash"),function(r,q){var p;if(r){p="style_"+(o++);i.formatter.register(p,{inline:"span",classes:r,selector:"*"});l.add(k.editor.translate(q),p)}})}});if(l.getLength()==0){l.onPostRender.add(function(o,p){if(!l.NativeListBox){b.add(p.id+"_text","focus",k._importClasses,k);b.add(p.id+"_text","mousedown",k._importClasses,k);b.add(p.id+"_open","focus",k._importClasses,k);b.add(p.id+"_open","mousedown",k._importClasses,k)}else{b.add(p.id,"focus",k._importClasses,k)}})}return l},_createFontSelect:function(){var k,j=this,i=j.editor;k=i.controlManager.createListBox("fontselect",{title:"advanced.fontdefault",onselect:function(l){var m=k.items[k.selectedIndex];if(!l&&m){i.execCommand("FontName",false,m.value);return}i.execCommand("FontName",false,l);k.select(function(n){return l==n});return false}});if(k){f(i.getParam("theme_advanced_fonts",j.settings.theme_advanced_fonts,"hash"),function(m,l){k.add(i.translate(l),m,{style:m.indexOf("dings")==-1?"font-family:"+m:""})})}return k},_createFontSizeSelect:function(){var m=this,k=m.editor,n,l=0,j=[];n=k.controlManager.createListBox("fontsizeselect",{title:"advanced.font_size",onselect:function(i){var o=n.items[n.selectedIndex];if(!i&&o){o=o.value;if(o["class"]){k.formatter.toggle("fontsize_class",{value:o["class"]});k.undoManager.add();k.nodeChanged()}else{k.execCommand("FontSize",false,o.fontSize)}return}if(i["class"]){k.focus();k.undoManager.add();k.formatter.toggle("fontsize_class",{value:i["class"]});k.undoManager.add();k.nodeChanged()}else{k.execCommand("FontSize",false,i.fontSize)}n.select(function(p){return i==p});return false}});if(n){f(m.settings.theme_advanced_font_sizes,function(o,i){var p=o.fontSize;if(p>=1&&p<=7){p=m.sizes[parseInt(p)-1]+"pt"}n.add(i,o,{style:"font-size:"+p,"class":"mceFontSize"+(l++)+(" "+(o["class"]||""))})})}return n},_createBlockFormats:function(){var k,i={p:"advanced.paragraph",address:"advanced.address",pre:"advanced.pre",h1:"advanced.h1",h2:"advanced.h2",h3:"advanced.h3",h4:"advanced.h4",h5:"advanced.h5",h6:"advanced.h6",div:"advanced.div",blockquote:"advanced.blockquote",code:"advanced.code",dt:"advanced.dt",dd:"advanced.dd",samp:"advanced.samp"},j=this;k=j.editor.controlManager.createListBox("formatselect",{title:"advanced.block",cmd:"FormatBlock"});if(k){f(j.editor.getParam("theme_advanced_blockformats",j.settings.theme_advanced_blockformats,"hash"),function(m,l){k.add(j.editor.translate(l!=m?l:i[m]),m,{"class":"mce_formatPreview mce_"+m})})}return k},_createForeColorMenu:function(){var m,j=this,k=j.settings,l={},i;if(k.theme_advanced_more_colors){l.more_colors_func=function(){j._mceColorPicker(0,{color:m.value,func:function(n){m.setColor(n)}})}}if(i=k.theme_advanced_text_colors){l.colors=i}if(k.theme_advanced_default_foreground_color){l.default_color=k.theme_advanced_default_foreground_color}l.title="advanced.forecolor_desc";l.cmd="ForeColor";l.scope=this;m=j.editor.controlManager.createColorSplitButton("forecolor",l);return m},_createBackColorMenu:function(){var m,j=this,k=j.settings,l={},i;if(k.theme_advanced_more_colors){l.more_colors_func=function(){j._mceColorPicker(0,{color:m.value,func:function(n){m.setColor(n)}})}}if(i=k.theme_advanced_background_colors){l.colors=i}if(k.theme_advanced_default_background_color){l.default_color=k.theme_advanced_default_background_color}l.title="advanced.backcolor_desc";l.cmd="HiliteColor";l.scope=this;m=j.editor.controlManager.createColorSplitButton("backcolor",l);return m},renderUI:function(k){var m,l,q,v=this,r=v.editor,w=v.settings,u,j,i;m=j=d.create("span",{id:r.id+"_parent","class":"mceEditor "+r.settings.skin+"Skin"+(w.skin_variant?" "+r.settings.skin+"Skin"+v._ufirst(w.skin_variant):"")});if(!d.boxModel){m=d.add(m,"div",{"class":"mceOldBoxModel"})}m=u=d.add(m,"table",{id:r.id+"_tbl","class":"mceLayout",cellSpacing:0,cellPadding:0});m=q=d.add(m,"tbody");switch((w.theme_advanced_layout_manager||"").toLowerCase()){case"rowlayout":l=v._rowLayout(w,q,k);break;case"customlayout":l=r.execCallback("theme_advanced_custom_layout",w,q,k,j);break;default:l=v._simpleLayout(w,q,k,j)}m=k.targetNode;i=d.stdMode?u.getElementsByTagName("tr"):u.rows;d.addClass(i[0],"mceFirst");d.addClass(i[i.length-1],"mceLast");f(d.select("tr",q),function(o){d.addClass(o.firstChild,"mceFirst");d.addClass(o.childNodes[o.childNodes.length-1],"mceLast")});if(d.get(w.theme_advanced_toolbar_container)){d.get(w.theme_advanced_toolbar_container).appendChild(j)}else{d.insertAfter(j,m)}b.add(r.id+"_path_row","click",function(n){n=n.target;if(n.nodeName=="A"){v._sel(n.className.replace(/^.*mcePath_([0-9]+).*$/,"$1"));return b.cancel(n)}});if(!r.getParam("accessibility_focus")){b.add(d.add(j,"a",{href:"#"},"<!-- IE -->"),"focus",function(){tinyMCE.get(r.id).focus()})}if(w.theme_advanced_toolbar_location=="external"){k.deltaHeight=0}v.deltaHeight=k.deltaHeight;k.targetNode=null;return{iframeContainer:l,editorContainer:r.id+"_parent",sizeContainer:u,deltaHeight:k.deltaHeight}},getInfo:function(){return{longname:"Advanced theme",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",version:e.majorVersion+"."+e.minorVersion}},resizeBy:function(i,j){var k=d.get(this.editor.id+"_tbl");this.resizeTo(k.clientWidth+i,k.clientHeight+j)},resizeTo:function(i,m,k){var j=this.editor,l=this.settings,n=d.get(j.id+"_tbl"),o=d.get(j.id+"_ifr");i=Math.max(l.theme_advanced_resizing_min_width||100,i);m=Math.max(l.theme_advanced_resizing_min_height||100,m);i=Math.min(l.theme_advanced_resizing_max_width||65535,i);m=Math.min(l.theme_advanced_resizing_max_height||65535,m);d.setStyle(n,"height","");d.setStyle(o,"height",m);if(l.theme_advanced_resize_horizontal){d.setStyle(n,"width","");d.setStyle(o,"width",i);if(i<n.clientWidth){i=n.clientWidth;d.setStyle(o,"width",n.clientWidth)}}if(k&&l.theme_advanced_resizing_use_cookie){a.setHash("TinyMCE_"+j.id+"_size",{cw:i,ch:m})}},destroy:function(){var i=this.editor.id;b.clear(i+"_resize");b.clear(i+"_path_row");b.clear(i+"_external_close")},_simpleLayout:function(y,r,k,i){var x=this,u=x.editor,v=y.theme_advanced_toolbar_location,m=y.theme_advanced_statusbar_location,l,j,q,w;if(y.readonly){l=d.add(r,"tr");l=j=d.add(l,"td",{"class":"mceIframeContainer"});return j}if(v=="top"){x._addToolbars(r,k)}if(v=="external"){l=w=d.create("div",{style:"position:relative"});l=d.add(l,"div",{id:u.id+"_external","class":"mceExternalToolbar"});d.add(l,"a",{id:u.id+"_external_close",href:"javascript:;","class":"mceExternalClose"});l=d.add(l,"table",{id:u.id+"_tblext",cellSpacing:0,cellPadding:0});q=d.add(l,"tbody");if(i.firstChild.className=="mceOldBoxModel"){i.firstChild.appendChild(w)}else{i.insertBefore(w,i.firstChild)}x._addToolbars(q,k);u.onMouseUp.add(function(){var o=d.get(u.id+"_external");d.show(o);d.hide(g);var n=b.add(u.id+"_external_close","click",function(){d.hide(u.id+"_external");b.remove(u.id+"_external_close","click",n)});d.show(o);d.setStyle(o,"top",0-d.getRect(u.id+"_tblext").h-1);d.hide(o);d.show(o);o.style.filter="";g=u.id+"_external";o=null})}if(m=="top"){x._addStatusBar(r,k)}if(!y.theme_advanced_toolbar_container){l=d.add(r,"tr");l=j=d.add(l,"td",{"class":"mceIframeContainer"})}if(v=="bottom"){x._addToolbars(r,k)}if(m=="bottom"){x._addStatusBar(r,k)}return j},_rowLayout:function(w,m,k){var v=this,p=v.editor,u,x,i=p.controlManager,l,j,r,q;u=w.theme_advanced_containers_default_class||"";x=w.theme_advanced_containers_default_align||"center";f(c(w.theme_advanced_containers||""),function(s,o){var n=w["theme_advanced_container_"+s]||"";switch(n.toLowerCase()){case"mceeditor":l=d.add(m,"tr");l=j=d.add(l,"td",{"class":"mceIframeContainer"});break;case"mceelementpath":v._addStatusBar(m,k);break;default:q=(w["theme_advanced_container_"+s+"_align"]||x).toLowerCase();q="mce"+v._ufirst(q);l=d.add(d.add(m,"tr"),"td",{"class":"mceToolbar "+(w["theme_advanced_container_"+s+"_class"]||u)+" "+q||x});r=i.createToolbar("toolbar"+o);v._addControls(n,r);d.setHTML(l,r.renderHTML());k.deltaHeight-=w.theme_advanced_row_height}});return j},_addControls:function(j,i){var k=this,l=k.settings,m,n=k.editor.controlManager;if(l.theme_advanced_disable&&!k._disabled){m={};f(c(l.theme_advanced_disable),function(o){m[o]=1});k._disabled=m}else{m=k._disabled}f(c(j),function(p){var o;if(m&&m[p]){return}if(p=="tablecontrols"){f(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"],function(q){q=k.createControl(q,n);if(q){i.add(q)}});return}o=k.createControl(p,n);if(o){i.add(o)}})},_addToolbars:function(w,k){var z=this,p,m,r=z.editor,A=z.settings,y,j=r.controlManager,u,l,q=[],x;x=A.theme_advanced_toolbar_align.toLowerCase();x="mce"+z._ufirst(x);l=d.add(d.add(w,"tr"),"td",{"class":"mceToolbar "+x});if(!r.getParam("accessibility_focus")){q.push(d.createHTML("a",{href:"#",onfocus:"tinyMCE.get('"+r.id+"').focus();"},"<!-- IE -->"))}q.push(d.createHTML("a",{href:"#",accesskey:"q",title:r.getLang("advanced.toolbar_focus")},"<!-- IE -->"));for(p=1;(y=A["theme_advanced_buttons"+p]);p++){m=j.createToolbar("toolbar"+p,{"class":"mceToolbarRow"+p});if(A["theme_advanced_buttons"+p+"_add"]){y+=","+A["theme_advanced_buttons"+p+"_add"]}if(A["theme_advanced_buttons"+p+"_add_before"]){y=A["theme_advanced_buttons"+p+"_add_before"]+","+y}z._addControls(y,m);q.push(m.renderHTML());k.deltaHeight-=A.theme_advanced_row_height}q.push(d.createHTML("a",{href:"#",accesskey:"z",title:r.getLang("advanced.toolbar_focus"),onfocus:"tinyMCE.getInstanceById('"+r.id+"').focus();"},"<!-- IE -->"));d.setHTML(l,q.join(""))},_addStatusBar:function(m,j){var k,v=this,p=v.editor,w=v.settings,i,q,u,l;k=d.add(m,"tr");k=l=d.add(k,"td",{"class":"mceStatusbar"});k=d.add(k,"div",{id:p.id+"_path_row"},w.theme_advanced_path?p.translate("advanced.path")+": ":"&#160;");d.add(k,"a",{href:"#",accesskey:"x"});if(w.theme_advanced_resizing){d.add(l,"a",{id:p.id+"_resize",href:"javascript:;",onclick:"return false;","class":"mceResize"});if(w.theme_advanced_resizing_use_cookie){p.onPostRender.add(function(){var n=a.getHash("TinyMCE_"+p.id+"_size"),r=d.get(p.id+"_tbl");if(!n){return}v.resizeTo(n.cw,n.ch)})}p.onPostRender.add(function(){b.add(p.id+"_resize","click",function(n){n.preventDefault()});b.add(p.id+"_resize","mousedown",function(D){var t,r,s,o,C,z,A,F,n,E,x;function y(G){G.preventDefault();n=A+(G.screenX-C);E=F+(G.screenY-z);v.resizeTo(n,E)}function B(G){b.remove(d.doc,"mousemove",t);b.remove(p.getDoc(),"mousemove",r);b.remove(d.doc,"mouseup",s);b.remove(p.getDoc(),"mouseup",o);n=A+(G.screenX-C);E=F+(G.screenY-z);v.resizeTo(n,E,true)}D.preventDefault();C=D.screenX;z=D.screenY;x=d.get(v.editor.id+"_ifr");A=n=x.clientWidth;F=E=x.clientHeight;t=b.add(d.doc,"mousemove",y);r=b.add(p.getDoc(),"mousemove",y);s=b.add(d.doc,"mouseup",B);o=b.add(p.getDoc(),"mouseup",B)})})}j.deltaHeight-=21;k=m=null},_nodeChanged:function(r,z,l,x,j){var C=this,i,y=0,B,u,D=C.settings,A,k,w,m,q;e.each(C.stateControls,function(n){z.setActive(n,r.queryCommandState(C.controls[n][1]))});function o(p){var s,n=j.parents,t=p;if(typeof(p)=="string"){t=function(v){return v.nodeName==p}}for(s=0;s<n.length;s++){if(t(n[s])){return n[s]}}}z.setActive("visualaid",r.hasVisual);z.setDisabled("undo",!r.undoManager.hasUndo()&&!r.typing);z.setDisabled("redo",!r.undoManager.hasRedo());z.setDisabled("outdent",!r.queryCommandState("Outdent"));i=o("A");if(u=z.get("link")){if(!i||!i.name){u.setDisabled(!i&&x);u.setActive(!!i)}}if(u=z.get("unlink")){u.setDisabled(!i&&x);u.setActive(!!i&&!i.name)}if(u=z.get("anchor")){u.setActive(!!i&&i.name)}i=o("IMG");if(u=z.get("image")){u.setActive(!!i&&l.className.indexOf("mceItem")==-1)}if(u=z.get("styleselect")){C._importClasses();m=[];f(u.items,function(n){m.push(n.value)});q=r.formatter.matchAll(m);u.select(q[0])}if(u=z.get("formatselect")){i=o(d.isBlock);if(i){u.select(i.nodeName.toLowerCase())}}o(function(p){if(p.nodeName==="SPAN"){if(!A&&p.className){A=p.className}if(!k&&p.style.fontSize){k=p.style.fontSize}if(!w&&p.style.fontFamily){w=p.style.fontFamily.replace(/[\"\']+/g,"").replace(/^([^,]+).*/,"$1").toLowerCase()}}return false});if(u=z.get("fontselect")){u.select(function(n){return n.replace(/^([^,]+).*/,"$1").toLowerCase()==w})}if(u=z.get("fontsizeselect")){if(D.theme_advanced_runtime_fontsize&&!k&&!A){k=r.dom.getStyle(l,"fontSize",true)}u.select(function(n){if(n.fontSize&&n.fontSize===k){return true}if(n["class"]&&n["class"]===A){return true}})}if(D.theme_advanced_path&&D.theme_advanced_statusbar_location){i=d.get(r.id+"_path")||d.add(r.id+"_path_row","span",{id:r.id+"_path"});d.setHTML(i,"");o(function(E){var p=E.nodeName.toLowerCase(),s,v,t="";if(E.nodeType!=1||E.nodeName==="BR"||(d.hasClass(E,"mceItemHidden")||d.hasClass(E,"mceItemRemoved"))){return}if(B=d.getAttrib(E,"mce_name")){p=B}if(e.isIE&&E.scopeName!=="HTML"){p=E.scopeName+":"+p}p=p.replace(/mce\:/g,"");switch(p){case"b":p="strong";break;case"i":p="em";break;case"img":if(B=d.getAttrib(E,"src")){t+="src: "+B+" "}break;case"a":if(B=d.getAttrib(E,"name")){t+="name: "+B+" ";p+="#"+B}if(B=d.getAttrib(E,"href")){t+="href: "+B+" "}break;case"font":if(B=d.getAttrib(E,"face")){t+="font: "+B+" "}if(B=d.getAttrib(E,"size")){t+="size: "+B+" "}if(B=d.getAttrib(E,"color")){t+="color: "+B+" "}break;case"span":if(B=d.getAttrib(E,"style")){t+="style: "+B+" "}break}if(B=d.getAttrib(E,"id")){t+="id: "+B+" "}if(B=E.className){B=B.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g,"");if(B){t+="class: "+B+" ";if(d.isBlock(E)||p=="img"||p=="span"){p+="."+B}}}p=p.replace(/(html:)/g,"");p={name:p,node:E,title:t};C.onResolveName.dispatch(C,p);t=p.title;p=p.name;v=d.create("a",{href:"javascript:;",onmousedown:"return false;",title:t,"class":"mcePath_"+(y++)},p);if(i.hasChildNodes()){i.insertBefore(d.doc.createTextNode(" \u00bb "),i.firstChild);i.insertBefore(v,i.firstChild)}else{i.appendChild(v)}},r.getBody())}},_sel:function(i){this.editor.execCommand("mceSelectNodeDepth",false,i)},_mceInsertAnchor:function(k,j){var i=this.editor;i.windowManager.open({url:this.url+"/anchor.htm",width:320+parseInt(i.getLang("advanced.anchor_delta_width",0)),height:90+parseInt(i.getLang("advanced.anchor_delta_height",0)),inline:true},{theme_url:this.url})},_mceCharMap:function(){var i=this.editor;i.windowManager.open({url:this.url+"/charmap.htm",width:550+parseInt(i.getLang("advanced.charmap_delta_width",0)),height:250+parseInt(i.getLang("advanced.charmap_delta_height",0)),inline:true},{theme_url:this.url})},_mceHelp:function(){var i=this.editor;i.windowManager.open({url:this.url+"/about.htm",width:480,height:380,inline:true},{theme_url:this.url})},_mceColorPicker:function(k,j){var i=this.editor;j=j||{};i.windowManager.open({url:this.url+"/color_picker.htm",width:375+parseInt(i.getLang("advanced.colorpicker_delta_width",0)),height:250+parseInt(i.getLang("advanced.colorpicker_delta_height",0)),close_previous:false,inline:true},{input_color:j.color,func:j.func,theme_url:this.url})},_mceCodeEditor:function(j,k){var i=this.editor;i.windowManager.open({url:this.url+"/source_editor.htm",width:parseInt(i.getParam("theme_advanced_source_editor_width",720)),height:parseInt(i.getParam("theme_advanced_source_editor_height",580)),inline:true,resizable:true,maximizable:true},{theme_url:this.url})},_mceImage:function(j,k){var i=this.editor;if(i.dom.getAttrib(i.selection.getNode(),"class").indexOf("mceItem")!=-1){return}i.windowManager.open({url:this.url+"/image.htm",width:355+parseInt(i.getLang("advanced.image_delta_width",0)),height:275+parseInt(i.getLang("advanced.image_delta_height",0)),inline:true},{theme_url:this.url})},_mceLink:function(j,k){var i=this.editor;i.windowManager.open({url:this.url+"/link.htm",width:310+parseInt(i.getLang("advanced.link_delta_width",0)),height:200+parseInt(i.getLang("advanced.link_delta_height",0)),inline:true},{theme_url:this.url})},_mceNewDocument:function(){var i=this.editor;i.windowManager.confirm("advanced.newdocument",function(j){if(j){i.execCommand("mceSetContent",false,"")}})},_mceForeColor:function(){var i=this;this._mceColorPicker(0,{color:i.fgColor,func:function(j){i.fgColor=j;i.editor.execCommand("ForeColor",false,j)}})},_mceBackColor:function(){var i=this;this._mceColorPicker(0,{color:i.bgColor,func:function(j){i.bgColor=j;i.editor.execCommand("HiliteColor",false,j)}})},_ufirst:function(i){return i.substring(0,1).toUpperCase()+i.substring(1)}});e.ThemeManager.add("advanced",e.themes.AdvancedTheme)}(tinymce));
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/image.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/image.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/image.htm	(revision 17487)
@@ -0,0 +1,89 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>{#advanced_dlg.image_title}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="../../utils/mctabs.js?ver=3392"></script>
+	<script type="text/javascript" src="../../utils/form_utils.js?ver=3392"></script>
+	<script type="text/javascript" src="js/image.js?ver=3392"></script>
+</head>
+<body id="image" style="display: none">
+<form onsubmit="ImageDialog.update();return false;" action="#">
+	<div class="tabs">
+		<ul>
+			<li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#advanced_dlg.image_title}</a></span></li>
+		</ul>
+	</div>
+
+	<div class="panel_wrapper">
+		<div id="general_panel" class="panel current">
+     <table border="0" cellpadding="4" cellspacing="0">
+          <tr>
+            <td class="nowrap"><label for="src">{#advanced_dlg.image_src}</label></td>
+            <td><table border="0" cellspacing="0" cellpadding="0">
+                <tr>
+                  <td><input id="src" name="src" type="text" class="mceFocus" value="" style="width: 200px" onchange="ImageDialog.getImageData();" /></td>
+                  <td id="srcbrowsercontainer">&nbsp;</td>
+                </tr>
+              </table></td>
+          </tr>
+		  <tr>
+			<td><label for="image_list">{#advanced_dlg.image_list}</label></td>
+			<td><select id="image_list" name="image_list" onchange="document.getElementById('src').value=this.options[this.selectedIndex].value;document.getElementById('alt').value=this.options[this.selectedIndex].text;"></select></td>
+		  </tr>
+          <tr>
+            <td class="nowrap"><label for="alt">{#advanced_dlg.image_alt}</label></td>
+            <td><input id="alt" name="alt" type="text" value="" style="width: 200px" /></td>
+          </tr>
+          <tr>
+            <td class="nowrap"><label for="align">{#advanced_dlg.image_align}</label></td>
+            <td><select id="align" name="align" onchange="ImageDialog.updateStyle();">
+                <option value="">{#not_set}</option>
+                <option value="baseline">{#advanced_dlg.image_align_baseline}</option>
+                <option value="top">{#advanced_dlg.image_align_top}</option>
+                <option value="middle">{#advanced_dlg.image_align_middle}</option>
+                <option value="bottom">{#advanced_dlg.image_align_bottom}</option>
+                <option value="text-top">{#advanced_dlg.image_align_texttop}</option>
+                <option value="text-bottom">{#advanced_dlg.image_align_textbottom}</option>
+                <option value="left">{#advanced_dlg.image_align_left}</option>
+                <option value="right">{#advanced_dlg.image_align_right}</option>
+              </select></td>
+          </tr>
+          <tr>
+            <td class="nowrap"><label for="width">{#advanced_dlg.image_dimensions}</label></td>
+            <td><input id="width" name="width" type="text" value="" size="3" maxlength="5" />
+              x
+              <input id="height" name="height" type="text" value="" size="3" maxlength="5" /></td>
+          </tr>
+          <tr>
+            <td class="nowrap"><label for="border">{#advanced_dlg.image_border}</label></td>
+            <td><input id="border" name="border" type="text" value="" size="3" maxlength="3" onchange="ImageDialog.updateStyle();" /></td>
+          </tr>
+          <tr>
+            <td class="nowrap"><label for="vspace">{#advanced_dlg.image_vspace}</label></td>
+            <td><input id="vspace" name="vspace" type="text" value="" size="3" maxlength="3" onchange="ImageDialog.updateStyle();" /></td>
+          </tr>
+          <tr>
+            <td class="nowrap"><label for="hspace">{#advanced_dlg.image_hspace}</label></td>
+            <td><input id="hspace" name="hspace" type="text" value="" size="3" maxlength="3" onchange="ImageDialog.updateStyle();" /></td>
+          </tr>
+		  <tr>
+            <td class="nowrap"><label for="class_name">{#class_name}</label></td>
+            <td><input type="text" id="class_name" name="class_name" style="width: 140px" value="" /></td>
+          </tr>
+        </table>
+		</div>
+	</div>
+
+	<div class="mceActionPanel">
+		<div style="float: left">
+			<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+		</div>
+
+		<div style="float: right">
+			<input type="submit" id="insert" name="insert" value="{#insert}" />
+		</div>
+	</div>
+</form>
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/about.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/about.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/about.js	(revision 17487)
@@ -0,0 +1,72 @@
+tinyMCEPopup.requireLangPack();
+
+function init() {
+	var ed, tcont;
+
+	tinyMCEPopup.resizeToInnerSize();
+	ed = tinyMCEPopup.editor;
+
+	// Give FF some time
+	window.setTimeout(insertHelpIFrame, 10);
+
+	tcont = document.getElementById('plugintablecontainer');
+	document.getElementById('plugins_tab').style.display = 'none';
+
+	var html = "";
+	html += '<table id="plugintable">';
+	html += '<thead>';
+	html += '<tr>';
+	html += '<td>' + ed.getLang('advanced_dlg.about_plugin') + '</td>';
+	html += '<td>' + ed.getLang('advanced_dlg.about_author') + '</td>';
+	html += '<td>' + ed.getLang('advanced_dlg.about_version') + '</td>';
+	html += '</tr>';
+	html += '</thead>';
+	html += '<tbody>';
+
+	tinymce.each(ed.plugins, function(p, n) {
+		var info;
+
+		if (!p.getInfo)
+			return;
+
+		html += '<tr>';
+
+		info = p.getInfo();
+
+		if (info.infourl != null && info.infourl != '')
+			html += '<td width="50%" title="' + n + '"><a href="' + info.infourl + '" target="_blank">' + info.longname + '</a></td>';
+		else
+			html += '<td width="50%" title="' + n + '">' + info.longname + '</td>';
+
+		if (info.authorurl != null && info.authorurl != '')
+			html += '<td width="35%"><a href="' + info.authorurl + '" target="_blank">' + info.author + '</a></td>';
+		else
+			html += '<td width="35%">' + info.author + '</td>';
+
+		html += '<td width="15%">' + info.version + '</td>';
+		html += '</tr>';
+
+		document.getElementById('plugins_tab').style.display = '';
+
+	});
+
+	html += '</tbody>';
+	html += '</table>';
+
+	tcont.innerHTML = html;
+
+	tinyMCEPopup.dom.get('version').innerHTML = tinymce.majorVersion + "." + tinymce.minorVersion;
+	tinyMCEPopup.dom.get('date').innerHTML = tinymce.releaseDate;
+}
+
+function insertHelpIFrame() {
+	var html;
+
+	if (tinyMCEPopup.getParam('docs_url')) {
+		html = '<iframe width="100%" height="300" src="' + tinyMCEPopup.editor.baseURI.toAbsolute(tinyMCEPopup.getParam('docs_url')) + '"></iframe>';
+		document.getElementById('iframecontainer').innerHTML = html;
+		document.getElementById('help_tab').style.display = 'block';
+	}
+}
+
+tinyMCEPopup.onInit.add(init);
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/anchor.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/anchor.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/anchor.js	(revision 17487)
@@ -0,0 +1,37 @@
+tinyMCEPopup.requireLangPack();
+
+var AnchorDialog = {
+	init : function(ed) {
+		var action, elm, f = document.forms[0];
+
+		this.editor = ed;
+		elm = ed.dom.getParent(ed.selection.getNode(), 'A');
+		v = ed.dom.getAttrib(elm, 'name');
+
+		if (v) {
+			this.action = 'update';
+			f.anchorName.value = v;
+		}
+
+		f.insert.value = ed.getLang(elm ? 'update' : 'insert');
+	},
+
+	update : function() {
+		var ed = this.editor, elm, name = document.forms[0].anchorName.value;
+
+		tinyMCEPopup.restoreSelection();
+
+		if (this.action != 'update')
+			ed.selection.collapse(1);
+
+		elm = ed.dom.getParent(ed.selection.getNode(), 'A');
+		if (elm)
+			elm.name = name;
+		else
+			ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, ''));
+
+		tinyMCEPopup.close();
+	}
+};
+
+tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog);
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/charmap.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/charmap.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/charmap.js	(revision 17487)
@@ -0,0 +1,335 @@
+/**
+ * charmap.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+tinyMCEPopup.requireLangPack();
+
+var charmap = [
+	['&nbsp;',    '&#160;',  true, 'no-break space'],
+	['&amp;',     '&#38;',   true, 'ampersand'],
+	['&quot;',    '&#34;',   true, 'quotation mark'],
+// finance
+	['&cent;',    '&#162;',  true, 'cent sign'],
+	['&euro;',    '&#8364;', true, 'euro sign'],
+	['&pound;',   '&#163;',  true, 'pound sign'],
+	['&yen;',     '&#165;',  true, 'yen sign'],
+// signs
+	['&copy;',    '&#169;',  true, 'copyright sign'],
+	['&reg;',     '&#174;',  true, 'registered sign'],
+	['&trade;',   '&#8482;', true, 'trade mark sign'],
+	['&permil;',  '&#8240;', true, 'per mille sign'],
+	['&micro;',   '&#181;',  true, 'micro sign'],
+	['&middot;',  '&#183;',  true, 'middle dot'],
+	['&bull;',    '&#8226;', true, 'bullet'],
+	['&hellip;',  '&#8230;', true, 'three dot leader'],
+	['&prime;',   '&#8242;', true, 'minutes / feet'],
+	['&Prime;',   '&#8243;', true, 'seconds / inches'],
+	['&sect;',    '&#167;',  true, 'section sign'],
+	['&para;',    '&#182;',  true, 'paragraph sign'],
+	['&szlig;',   '&#223;',  true, 'sharp s / ess-zed'],
+// quotations
+	['&lsaquo;',  '&#8249;', true, 'single left-pointing angle quotation mark'],
+	['&rsaquo;',  '&#8250;', true, 'single right-pointing angle quotation mark'],
+	['&laquo;',   '&#171;',  true, 'left pointing guillemet'],
+	['&raquo;',   '&#187;',  true, 'right pointing guillemet'],
+	['&lsquo;',   '&#8216;', true, 'left single quotation mark'],
+	['&rsquo;',   '&#8217;', true, 'right single quotation mark'],
+	['&ldquo;',   '&#8220;', true, 'left double quotation mark'],
+	['&rdquo;',   '&#8221;', true, 'right double quotation mark'],
+	['&sbquo;',   '&#8218;', true, 'single low-9 quotation mark'],
+	['&bdquo;',   '&#8222;', true, 'double low-9 quotation mark'],
+	['&lt;',      '&#60;',   true, 'less-than sign'],
+	['&gt;',      '&#62;',   true, 'greater-than sign'],
+	['&le;',      '&#8804;', true, 'less-than or equal to'],
+	['&ge;',      '&#8805;', true, 'greater-than or equal to'],
+	['&ndash;',   '&#8211;', true, 'en dash'],
+	['&mdash;',   '&#8212;', true, 'em dash'],
+	['&macr;',    '&#175;',  true, 'macron'],
+	['&oline;',   '&#8254;', true, 'overline'],
+	['&curren;',  '&#164;',  true, 'currency sign'],
+	['&brvbar;',  '&#166;',  true, 'broken bar'],
+	['&uml;',     '&#168;',  true, 'diaeresis'],
+	['&iexcl;',   '&#161;',  true, 'inverted exclamation mark'],
+	['&iquest;',  '&#191;',  true, 'turned question mark'],
+	['&circ;',    '&#710;',  true, 'circumflex accent'],
+	['&tilde;',   '&#732;',  true, 'small tilde'],
+	['&deg;',     '&#176;',  true, 'degree sign'],
+	['&minus;',   '&#8722;', true, 'minus sign'],
+	['&plusmn;',  '&#177;',  true, 'plus-minus sign'],
+	['&divide;',  '&#247;',  true, 'division sign'],
+	['&frasl;',   '&#8260;', true, 'fraction slash'],
+	['&times;',   '&#215;',  true, 'multiplication sign'],
+	['&sup1;',    '&#185;',  true, 'superscript one'],
+	['&sup2;',    '&#178;',  true, 'superscript two'],
+	['&sup3;',    '&#179;',  true, 'superscript three'],
+	['&frac14;',  '&#188;',  true, 'fraction one quarter'],
+	['&frac12;',  '&#189;',  true, 'fraction one half'],
+	['&frac34;',  '&#190;',  true, 'fraction three quarters'],
+// math / logical
+	['&fnof;',    '&#402;',  true, 'function / florin'],
+	['&int;',     '&#8747;', true, 'integral'],
+	['&sum;',     '&#8721;', true, 'n-ary sumation'],
+	['&infin;',   '&#8734;', true, 'infinity'],
+	['&radic;',   '&#8730;', true, 'square root'],
+	['&sim;',     '&#8764;', false,'similar to'],
+	['&cong;',    '&#8773;', false,'approximately equal to'],
+	['&asymp;',   '&#8776;', true, 'almost equal to'],
+	['&ne;',      '&#8800;', true, 'not equal to'],
+	['&equiv;',   '&#8801;', true, 'identical to'],
+	['&isin;',    '&#8712;', false,'element of'],
+	['&notin;',   '&#8713;', false,'not an element of'],
+	['&ni;',      '&#8715;', false,'contains as member'],
+	['&prod;',    '&#8719;', true, 'n-ary product'],
+	['&and;',     '&#8743;', false,'logical and'],
+	['&or;',      '&#8744;', false,'logical or'],
+	['&not;',     '&#172;',  true, 'not sign'],
+	['&cap;',     '&#8745;', true, 'intersection'],
+	['&cup;',     '&#8746;', false,'union'],
+	['&part;',    '&#8706;', true, 'partial differential'],
+	['&forall;',  '&#8704;', false,'for all'],
+	['&exist;',   '&#8707;', false,'there exists'],
+	['&empty;',   '&#8709;', false,'diameter'],
+	['&nabla;',   '&#8711;', false,'backward difference'],
+	['&lowast;',  '&#8727;', false,'asterisk operator'],
+	['&prop;',    '&#8733;', false,'proportional to'],
+	['&ang;',     '&#8736;', false,'angle'],
+// undefined
+	['&acute;',   '&#180;',  true, 'acute accent'],
+	['&cedil;',   '&#184;',  true, 'cedilla'],
+	['&ordf;',    '&#170;',  true, 'feminine ordinal indicator'],
+	['&ordm;',    '&#186;',  true, 'masculine ordinal indicator'],
+	['&dagger;',  '&#8224;', true, 'dagger'],
+	['&Dagger;',  '&#8225;', true, 'double dagger'],
+// alphabetical special chars
+	['&Agrave;',  '&#192;',  true, 'A - grave'],
+	['&Aacute;',  '&#193;',  true, 'A - acute'],
+	['&Acirc;',   '&#194;',  true, 'A - circumflex'],
+	['&Atilde;',  '&#195;',  true, 'A - tilde'],
+	['&Auml;',    '&#196;',  true, 'A - diaeresis'],
+	['&Aring;',   '&#197;',  true, 'A - ring above'],
+	['&AElig;',   '&#198;',  true, 'ligature AE'],
+	['&Ccedil;',  '&#199;',  true, 'C - cedilla'],
+	['&Egrave;',  '&#200;',  true, 'E - grave'],
+	['&Eacute;',  '&#201;',  true, 'E - acute'],
+	['&Ecirc;',   '&#202;',  true, 'E - circumflex'],
+	['&Euml;',    '&#203;',  true, 'E - diaeresis'],
+	['&Igrave;',  '&#204;',  true, 'I - grave'],
+	['&Iacute;',  '&#205;',  true, 'I - acute'],
+	['&Icirc;',   '&#206;',  true, 'I - circumflex'],
+	['&Iuml;',    '&#207;',  true, 'I - diaeresis'],
+	['&ETH;',     '&#208;',  true, 'ETH'],
+	['&Ntilde;',  '&#209;',  true, 'N - tilde'],
+	['&Ograve;',  '&#210;',  true, 'O - grave'],
+	['&Oacute;',  '&#211;',  true, 'O - acute'],
+	['&Ocirc;',   '&#212;',  true, 'O - circumflex'],
+	['&Otilde;',  '&#213;',  true, 'O - tilde'],
+	['&Ouml;',    '&#214;',  true, 'O - diaeresis'],
+	['&Oslash;',  '&#216;',  true, 'O - slash'],
+	['&OElig;',   '&#338;',  true, 'ligature OE'],
+	['&Scaron;',  '&#352;',  true, 'S - caron'],
+	['&Ugrave;',  '&#217;',  true, 'U - grave'],
+	['&Uacute;',  '&#218;',  true, 'U - acute'],
+	['&Ucirc;',   '&#219;',  true, 'U - circumflex'],
+	['&Uuml;',    '&#220;',  true, 'U - diaeresis'],
+	['&Yacute;',  '&#221;',  true, 'Y - acute'],
+	['&Yuml;',    '&#376;',  true, 'Y - diaeresis'],
+	['&THORN;',   '&#222;',  true, 'THORN'],
+	['&agrave;',  '&#224;',  true, 'a - grave'],
+	['&aacute;',  '&#225;',  true, 'a - acute'],
+	['&acirc;',   '&#226;',  true, 'a - circumflex'],
+	['&atilde;',  '&#227;',  true, 'a - tilde'],
+	['&auml;',    '&#228;',  true, 'a - diaeresis'],
+	['&aring;',   '&#229;',  true, 'a - ring above'],
+	['&aelig;',   '&#230;',  true, 'ligature ae'],
+	['&ccedil;',  '&#231;',  true, 'c - cedilla'],
+	['&egrave;',  '&#232;',  true, 'e - grave'],
+	['&eacute;',  '&#233;',  true, 'e - acute'],
+	['&ecirc;',   '&#234;',  true, 'e - circumflex'],
+	['&euml;',    '&#235;',  true, 'e - diaeresis'],
+	['&igrave;',  '&#236;',  true, 'i - grave'],
+	['&iacute;',  '&#237;',  true, 'i - acute'],
+	['&icirc;',   '&#238;',  true, 'i - circumflex'],
+	['&iuml;',    '&#239;',  true, 'i - diaeresis'],
+	['&eth;',     '&#240;',  true, 'eth'],
+	['&ntilde;',  '&#241;',  true, 'n - tilde'],
+	['&ograve;',  '&#242;',  true, 'o - grave'],
+	['&oacute;',  '&#243;',  true, 'o - acute'],
+	['&ocirc;',   '&#244;',  true, 'o - circumflex'],
+	['&otilde;',  '&#245;',  true, 'o - tilde'],
+	['&ouml;',    '&#246;',  true, 'o - diaeresis'],
+	['&oslash;',  '&#248;',  true, 'o slash'],
+	['&oelig;',   '&#339;',  true, 'ligature oe'],
+	['&scaron;',  '&#353;',  true, 's - caron'],
+	['&ugrave;',  '&#249;',  true, 'u - grave'],
+	['&uacute;',  '&#250;',  true, 'u - acute'],
+	['&ucirc;',   '&#251;',  true, 'u - circumflex'],
+	['&uuml;',    '&#252;',  true, 'u - diaeresis'],
+	['&yacute;',  '&#253;',  true, 'y - acute'],
+	['&thorn;',   '&#254;',  true, 'thorn'],
+	['&yuml;',    '&#255;',  true, 'y - diaeresis'],
+    ['&Alpha;',   '&#913;',  true, 'Alpha'],
+	['&Beta;',    '&#914;',  true, 'Beta'],
+	['&Gamma;',   '&#915;',  true, 'Gamma'],
+	['&Delta;',   '&#916;',  true, 'Delta'],
+	['&Epsilon;', '&#917;',  true, 'Epsilon'],
+	['&Zeta;',    '&#918;',  true, 'Zeta'],
+	['&Eta;',     '&#919;',  true, 'Eta'],
+	['&Theta;',   '&#920;',  true, 'Theta'],
+	['&Iota;',    '&#921;',  true, 'Iota'],
+	['&Kappa;',   '&#922;',  true, 'Kappa'],
+	['&Lambda;',  '&#923;',  true, 'Lambda'],
+	['&Mu;',      '&#924;',  true, 'Mu'],
+	['&Nu;',      '&#925;',  true, 'Nu'],
+	['&Xi;',      '&#926;',  true, 'Xi'],
+	['&Omicron;', '&#927;',  true, 'Omicron'],
+	['&Pi;',      '&#928;',  true, 'Pi'],
+	['&Rho;',     '&#929;',  true, 'Rho'],
+	['&Sigma;',   '&#931;',  true, 'Sigma'],
+	['&Tau;',     '&#932;',  true, 'Tau'],
+	['&Upsilon;', '&#933;',  true, 'Upsilon'],
+	['&Phi;',     '&#934;',  true, 'Phi'],
+	['&Chi;',     '&#935;',  true, 'Chi'],
+	['&Psi;',     '&#936;',  true, 'Psi'],
+	['&Omega;',   '&#937;',  true, 'Omega'],
+	['&alpha;',   '&#945;',  true, 'alpha'],
+	['&beta;',    '&#946;',  true, 'beta'],
+	['&gamma;',   '&#947;',  true, 'gamma'],
+	['&delta;',   '&#948;',  true, 'delta'],
+	['&epsilon;', '&#949;',  true, 'epsilon'],
+	['&zeta;',    '&#950;',  true, 'zeta'],
+	['&eta;',     '&#951;',  true, 'eta'],
+	['&theta;',   '&#952;',  true, 'theta'],
+	['&iota;',    '&#953;',  true, 'iota'],
+	['&kappa;',   '&#954;',  true, 'kappa'],
+	['&lambda;',  '&#955;',  true, 'lambda'],
+	['&mu;',      '&#956;',  true, 'mu'],
+	['&nu;',      '&#957;',  true, 'nu'],
+	['&xi;',      '&#958;',  true, 'xi'],
+	['&omicron;', '&#959;',  true, 'omicron'],
+	['&pi;',      '&#960;',  true, 'pi'],
+	['&rho;',     '&#961;',  true, 'rho'],
+	['&sigmaf;',  '&#962;',  true, 'final sigma'],
+	['&sigma;',   '&#963;',  true, 'sigma'],
+	['&tau;',     '&#964;',  true, 'tau'],
+	['&upsilon;', '&#965;',  true, 'upsilon'],
+	['&phi;',     '&#966;',  true, 'phi'],
+	['&chi;',     '&#967;',  true, 'chi'],
+	['&psi;',     '&#968;',  true, 'psi'],
+	['&omega;',   '&#969;',  true, 'omega'],
+// symbols
+	['&alefsym;', '&#8501;', false,'alef symbol'],
+	['&piv;',     '&#982;',  false,'pi symbol'],
+	['&real;',    '&#8476;', false,'real part symbol'],
+	['&thetasym;','&#977;',  false,'theta symbol'],
+	['&upsih;',   '&#978;',  false,'upsilon - hook symbol'],
+	['&weierp;',  '&#8472;', false,'Weierstrass p'],
+	['&image;',   '&#8465;', false,'imaginary part'],
+// arrows
+	['&larr;',    '&#8592;', true, 'leftwards arrow'],
+	['&uarr;',    '&#8593;', true, 'upwards arrow'],
+	['&rarr;',    '&#8594;', true, 'rightwards arrow'],
+	['&darr;',    '&#8595;', true, 'downwards arrow'],
+	['&harr;',    '&#8596;', true, 'left right arrow'],
+	['&crarr;',   '&#8629;', false,'carriage return'],
+	['&lArr;',    '&#8656;', false,'leftwards double arrow'],
+	['&uArr;',    '&#8657;', false,'upwards double arrow'],
+	['&rArr;',    '&#8658;', false,'rightwards double arrow'],
+	['&dArr;',    '&#8659;', false,'downwards double arrow'],
+	['&hArr;',    '&#8660;', false,'left right double arrow'],
+	['&there4;',  '&#8756;', false,'therefore'],
+	['&sub;',     '&#8834;', false,'subset of'],
+	['&sup;',     '&#8835;', false,'superset of'],
+	['&nsub;',    '&#8836;', false,'not a subset of'],
+	['&sube;',    '&#8838;', false,'subset of or equal to'],
+	['&supe;',    '&#8839;', false,'superset of or equal to'],
+	['&oplus;',   '&#8853;', false,'circled plus'],
+	['&otimes;',  '&#8855;', false,'circled times'],
+	['&perp;',    '&#8869;', false,'perpendicular'],
+	['&sdot;',    '&#8901;', false,'dot operator'],
+	['&lceil;',   '&#8968;', false,'left ceiling'],
+	['&rceil;',   '&#8969;', false,'right ceiling'],
+	['&lfloor;',  '&#8970;', false,'left floor'],
+	['&rfloor;',  '&#8971;', false,'right floor'],
+	['&lang;',    '&#9001;', false,'left-pointing angle bracket'],
+	['&rang;',    '&#9002;', false,'right-pointing angle bracket'],
+	['&loz;',     '&#9674;', true,'lozenge'],
+	['&spades;',  '&#9824;', false,'black spade suit'],
+	['&clubs;',   '&#9827;', true, 'black club suit'],
+	['&hearts;',  '&#9829;', true, 'black heart suit'],
+	['&diams;',   '&#9830;', true, 'black diamond suit'],
+	['&ensp;',    '&#8194;', false,'en space'],
+	['&emsp;',    '&#8195;', false,'em space'],
+	['&thinsp;',  '&#8201;', false,'thin space'],
+	['&zwnj;',    '&#8204;', false,'zero width non-joiner'],
+	['&zwj;',     '&#8205;', false,'zero width joiner'],
+	['&lrm;',     '&#8206;', false,'left-to-right mark'],
+	['&rlm;',     '&#8207;', false,'right-to-left mark'],
+	['&shy;',     '&#173;',  false,'soft hyphen']
+];
+
+tinyMCEPopup.onInit.add(function() {
+	tinyMCEPopup.dom.setHTML('charmapView', renderCharMapHTML());
+});
+
+function renderCharMapHTML() {
+	var charsPerRow = 20, tdWidth=20, tdHeight=20, i;
+	var html = '<table border="0" cellspacing="1" cellpadding="0" width="' + (tdWidth*charsPerRow) + '"><tr height="' + tdHeight + '">';
+	var cols=-1;
+
+	for (i=0; i<charmap.length; i++) {
+		if (charmap[i][2]==true) {
+			cols++;
+			html += ''
+				+ '<td class="charmap">'
+				+ '<a onmouseover="previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');" onfocus="previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');" href="javascript:void(0)" onclick="insertChar(\'' + charmap[i][1].substring(2,charmap[i][1].length-1) + '\');" onclick="return false;" onmousedown="return false;" title="' + charmap[i][3] + '">'
+				+ charmap[i][1]
+				+ '</a></td>';
+			if ((cols+1) % charsPerRow == 0)
+				html += '</tr><tr height="' + tdHeight + '">';
+		}
+	 }
+
+	if (cols % charsPerRow > 0) {
+		var padd = charsPerRow - (cols % charsPerRow);
+		for (var i=0; i<padd-1; i++)
+			html += '<td width="' + tdWidth + '" height="' + tdHeight + '" class="charmap">&nbsp;</td>';
+	}
+
+	html += '</tr></table>';
+
+	return html;
+}
+
+function insertChar(chr) {
+	tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';');
+
+	// Refocus in window
+	if (tinyMCEPopup.isWindow)
+		window.focus();
+
+	tinyMCEPopup.editor.focus();
+	tinyMCEPopup.close();
+}
+
+function previewChar(codeA, codeB, codeN) {
+	var elmA = document.getElementById('codeA');
+	var elmB = document.getElementById('codeB');
+	var elmV = document.getElementById('codeV');
+	var elmN = document.getElementById('codeN');
+
+	if (codeA=='#160;') {
+		elmV.innerHTML = '__';
+	} else {
+		elmV.innerHTML = '&' + codeA;
+	}
+
+	elmB.innerHTML = '&amp;' + codeA;
+	elmA.innerHTML = '&amp;' + codeB;
+	elmN.innerHTML = codeN;
+}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/color_picker.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/color_picker.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/color_picker.js	(revision 17487)
@@ -0,0 +1,253 @@
+tinyMCEPopup.requireLangPack();
+
+var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false;
+
+var colors = [
+	"#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033",
+	"#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099",
+	"#6600cc","#6600ff","#990000","#990033","#990066","#990099","#9900cc","#9900ff",
+	"#cc0000","#cc0033","#cc0066","#cc0099","#cc00cc","#cc00ff","#ff0000","#ff0033",
+	"#ff0066","#ff0099","#ff00cc","#ff00ff","#003300","#003333","#003366","#003399",
+	"#0033cc","#0033ff","#333300","#333333","#333366","#333399","#3333cc","#3333ff",
+	"#663300","#663333","#663366","#663399","#6633cc","#6633ff","#993300","#993333",
+	"#993366","#993399","#9933cc","#9933ff","#cc3300","#cc3333","#cc3366","#cc3399",
+	"#cc33cc","#cc33ff","#ff3300","#ff3333","#ff3366","#ff3399","#ff33cc","#ff33ff",
+	"#006600","#006633","#006666","#006699","#0066cc","#0066ff","#336600","#336633",
+	"#336666","#336699","#3366cc","#3366ff","#666600","#666633","#666666","#666699",
+	"#6666cc","#6666ff","#996600","#996633","#996666","#996699","#9966cc","#9966ff",
+	"#cc6600","#cc6633","#cc6666","#cc6699","#cc66cc","#cc66ff","#ff6600","#ff6633",
+	"#ff6666","#ff6699","#ff66cc","#ff66ff","#009900","#009933","#009966","#009999",
+	"#0099cc","#0099ff","#339900","#339933","#339966","#339999","#3399cc","#3399ff",
+	"#669900","#669933","#669966","#669999","#6699cc","#6699ff","#999900","#999933",
+	"#999966","#999999","#9999cc","#9999ff","#cc9900","#cc9933","#cc9966","#cc9999",
+	"#cc99cc","#cc99ff","#ff9900","#ff9933","#ff9966","#ff9999","#ff99cc","#ff99ff",
+	"#00cc00","#00cc33","#00cc66","#00cc99","#00cccc","#00ccff","#33cc00","#33cc33",
+	"#33cc66","#33cc99","#33cccc","#33ccff","#66cc00","#66cc33","#66cc66","#66cc99",
+	"#66cccc","#66ccff","#99cc00","#99cc33","#99cc66","#99cc99","#99cccc","#99ccff",
+	"#cccc00","#cccc33","#cccc66","#cccc99","#cccccc","#ccccff","#ffcc00","#ffcc33",
+	"#ffcc66","#ffcc99","#ffcccc","#ffccff","#00ff00","#00ff33","#00ff66","#00ff99",
+	"#00ffcc","#00ffff","#33ff00","#33ff33","#33ff66","#33ff99","#33ffcc","#33ffff",
+	"#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#99ff00","#99ff33",
+	"#99ff66","#99ff99","#99ffcc","#99ffff","#ccff00","#ccff33","#ccff66","#ccff99",
+	"#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff"
+];
+
+var named = {
+	'#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige',
+	'#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown',
+	'#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue',
+	'#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod',
+	'#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen',
+	'#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue',
+	'#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue',
+	'#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen',
+	'#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey',
+	'#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory',
+	'#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue',
+	'#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen',
+	'#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey',
+	'#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon',
+	'#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue',
+	'#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin',
+	'#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid',
+	'#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff',
+	'#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue',
+	'#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver',
+	'#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen',
+	'#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet',
+	'#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen'
+};
+
+function init() {
+	var inputColor = convertRGBToHex(tinyMCEPopup.getWindowArg('input_color'));
+
+	tinyMCEPopup.resizeToInnerSize();
+
+	generatePicker();
+
+	if (inputColor) {
+		changeFinalColor(inputColor);
+
+		col = convertHexToRGB(inputColor);
+
+		if (col)
+			updateLight(col.r, col.g, col.b);
+	}
+}
+
+function insertAction() {
+	var color = document.getElementById("color").value, f = tinyMCEPopup.getWindowArg('func');
+
+	tinyMCEPopup.restoreSelection();
+
+	if (f)
+		f(color);
+
+	tinyMCEPopup.close();
+}
+
+function showColor(color, name) {
+	if (name)
+		document.getElementById("colorname").innerHTML = name;
+
+	document.getElementById("preview").style.backgroundColor = color;
+	document.getElementById("color").value = color.toLowerCase();
+}
+
+function convertRGBToHex(col) {
+	var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
+
+	if (!col)
+		return col;
+
+	var rgb = col.replace(re, "$1,$2,$3").split(',');
+	if (rgb.length == 3) {
+		r = parseInt(rgb[0]).toString(16);
+		g = parseInt(rgb[1]).toString(16);
+		b = parseInt(rgb[2]).toString(16);
+
+		r = r.length == 1 ? '0' + r : r;
+		g = g.length == 1 ? '0' + g : g;
+		b = b.length == 1 ? '0' + b : b;
+
+		return "#" + r + g + b;
+	}
+
+	return col;
+}
+
+function convertHexToRGB(col) {
+	if (col.indexOf('#') != -1) {
+		col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
+
+		r = parseInt(col.substring(0, 2), 16);
+		g = parseInt(col.substring(2, 4), 16);
+		b = parseInt(col.substring(4, 6), 16);
+
+		return {r : r, g : g, b : b};
+	}
+
+	return null;
+}
+
+function generatePicker() {
+	var el = document.getElementById('light'), h = '', i;
+
+	for (i = 0; i < detail; i++){
+		h += '<div id="gs'+i+'" style="background-color:#000000; width:15px; height:3px; border-style:none; border-width:0px;"'
+		+ ' onclick="changeFinalColor(this.style.backgroundColor)"'
+		+ ' onmousedown="isMouseDown = true; return false;"'
+		+ ' onmouseup="isMouseDown = false;"'
+		+ ' onmousemove="if (isMouseDown && isMouseOver) changeFinalColor(this.style.backgroundColor); return false;"'
+		+ ' onmouseover="isMouseOver = true;"'
+		+ ' onmouseout="isMouseOver = false;"'
+		+ '></div>';
+	}
+
+	el.innerHTML = h;
+}
+
+function generateWebColors() {
+	var el = document.getElementById('webcolors'), h = '', i;
+
+	if (el.className == 'generated')
+		return;
+
+	h += '<table border="0" cellspacing="1" cellpadding="0">'
+		+ '<tr>';
+
+	for (i=0; i<colors.length; i++) {
+		h += '<td bgcolor="' + colors[i] + '" width="10" height="10">'
+			+ '<a href="javascript:insertAction();" onfocus="showColor(\'' + colors[i] +  '\');" onmouseover="showColor(\'' + colors[i] +  '\');" style="display:block;width:10px;height:10px;overflow:hidden;">'
+			+ '</a></td>';
+		if ((i+1) % 18 == 0)
+			h += '</tr><tr>';
+	}
+
+	h += '</table>';
+
+	el.innerHTML = h;
+	el.className = 'generated';
+}
+
+function generateNamedColors() {
+	var el = document.getElementById('namedcolors'), h = '', n, v, i = 0;
+
+	if (el.className == 'generated')
+		return;
+
+	for (n in named) {
+		v = named[n];
+		h += '<a href="javascript:insertAction();" onmouseover="showColor(\'' + n +  '\',\'' + v + '\');" style="background-color: ' + n + '"><!-- IE --></a>'
+	}
+
+	el.innerHTML = h;
+	el.className = 'generated';
+}
+
+function dechex(n) {
+	return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16);
+}
+
+function computeColor(e) {
+	var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB;
+
+	x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0);
+	y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0);
+
+	partWidth = document.getElementById('colors').width / 6;
+	partDetail = detail / 2;
+	imHeight = document.getElementById('colors').height;
+
+	r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255;
+	g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255	+ (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth);
+	b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth);
+
+	coef = (imHeight - y) / imHeight;
+	r = 128 + (r - 128) * coef;
+	g = 128 + (g - 128) * coef;
+	b = 128 + (b - 128) * coef;
+
+	changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b));
+	updateLight(r, g, b);
+}
+
+function updateLight(r, g, b) {
+	var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color;
+
+	for (i=0; i<detail; i++) {
+		if ((i>=0) && (i<partDetail)) {
+			finalCoef = i / partDetail;
+			finalR = dechex(255 - (255 - r) * finalCoef);
+			finalG = dechex(255 - (255 - g) * finalCoef);
+			finalB = dechex(255 - (255 - b) * finalCoef);
+		} else {
+			finalCoef = 2 - i / partDetail;
+			finalR = dechex(r * finalCoef);
+			finalG = dechex(g * finalCoef);
+			finalB = dechex(b * finalCoef);
+		}
+
+		color = finalR + finalG + finalB;
+
+		setCol('gs' + i, '#'+color);
+	}
+}
+
+function changeFinalColor(color) {
+	if (color.indexOf('#') == -1)
+		color = convertRGBToHex(color);
+
+	setCol('preview', color);
+	document.getElementById('color').value = color;
+}
+
+function setCol(e, c) {
+	try {
+		document.getElementById(e).style.backgroundColor = c;
+	} catch (ex) {
+		// Ignore IE warning
+	}
+}
+
+tinyMCEPopup.onInit.add(init);
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/image.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/image.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/image.js	(revision 17487)
@@ -0,0 +1,254 @@
+var ImageDialog = {
+	preInit : function() {
+		var url;
+
+		tinyMCEPopup.requireLangPack();
+
+		if (url = tinyMCEPopup.getParam("external_image_list_url"))
+			document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
+	},
+
+	init : function() {
+		var f = document.forms[0], ed = tinyMCEPopup.editor;
+
+		// Setup browse button
+		document.getElementById('srcbrowsercontainer').innerHTML = getBrowserHTML('srcbrowser','src','image','theme_advanced_image');
+		if (isVisible('srcbrowser'))
+			document.getElementById('src').style.width = '180px';
+
+		e = ed.selection.getNode();
+
+		this.fillFileList('image_list', 'tinyMCEImageList');
+
+		if (e.nodeName == 'IMG') {
+			f.src.value = ed.dom.getAttrib(e, 'src');
+			f.alt.value = ed.dom.getAttrib(e, 'alt');
+			f.border.value = this.getAttrib(e, 'border');
+			f.vspace.value = this.getAttrib(e, 'vspace');
+			f.hspace.value = this.getAttrib(e, 'hspace');
+			f.width.value = ed.dom.getAttrib(e, 'width');
+			f.height.value = ed.dom.getAttrib(e, 'height');
+			f.insert.value = ed.getLang('update');
+			f.class_name.value = ed.dom.getAttrib(e, 'class');
+			this.styleVal = ed.dom.getAttrib(e, 'style');
+			selectByValue(f, 'image_list', f.src.value);
+			selectByValue(f, 'align', this.getAttrib(e, 'align'));
+			this.updateStyle();
+		}
+	},
+
+	fillFileList : function(id, l) {
+		var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
+
+		l = window[l];
+
+		if (l && l.length > 0) {
+			lst.options[lst.options.length] = new Option('', '');
+
+			tinymce.each(l, function(o) {
+				lst.options[lst.options.length] = new Option(o[0], o[1]);
+			});
+		} else
+			dom.remove(dom.getParent(id, 'tr'));
+	},
+
+	update : function() {
+		var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, args = {}, el;
+
+		tinyMCEPopup.restoreSelection();
+
+		if (f.src.value === '') {
+			if (ed.selection.getNode().nodeName == 'IMG') {
+				ed.dom.remove(ed.selection.getNode());
+				ed.execCommand('mceRepaint');
+			}
+
+			tinyMCEPopup.close();
+			return;
+		}
+
+		if (!ed.settings.inline_styles) {
+			args = tinymce.extend(args, {
+				vspace : nl.vspace.value,
+				hspace : nl.hspace.value,
+				border : nl.border.value,
+				align : getSelectValue(f, 'align')
+			});
+		} else
+			args.style = this.styleVal;
+
+		tinymce.extend(args, {
+			src : f.src.value,
+			alt : f.alt.value,
+			width : f.width.value,
+			height : f.height.value,
+			'class' : f.class_name.value
+		});
+
+		el = ed.selection.getNode();
+
+		if (el && el.nodeName == 'IMG') {
+			ed.dom.setAttribs(el, args);
+		} else {
+			ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" />', {skip_undo : 1});
+			ed.dom.setAttribs('__mce_tmp', args);
+			ed.dom.setAttrib('__mce_tmp', 'id', '');
+			ed.undoManager.add();
+		}
+
+		tinyMCEPopup.close();
+	},
+
+	updateStyle : function() {
+		var dom = tinyMCEPopup.dom, st, v, cls, oldcls, rep, f = document.forms[0];
+
+		if (tinyMCEPopup.editor.settings.inline_styles) {
+			st = tinyMCEPopup.dom.parseStyle(this.styleVal);
+
+			// Handle align
+			v = getSelectValue(f, 'align');
+			cls = f.class_name.value || '';
+			cls = cls ? cls.replace(/alignright\s*|alignleft\s*|aligncenter\s*/g, '') : '';
+			cls = cls ? cls.replace(/^\s*(.+?)\s*$/, '$1') : '';
+			if (v) {
+				if (v == 'left' || v == 'right') {
+					st['float'] = v;
+					delete st['vertical-align'];
+					oldcls = cls ? ' '+cls : '';
+					f.class_name.value = 'align' + v + oldcls;
+				} else {
+					st['vertical-align'] = v;
+					delete st['float'];
+					f.class_name.value = cls;
+				}
+			} else {
+				delete st['float'];
+				delete st['vertical-align'];
+				f.class_name.value = cls;
+			}
+
+			// Handle border
+			v = f.border.value;
+			if (v || v == '0') {
+				if (v == '0')
+					st['border'] = '0';
+				else
+					st['border'] = v + 'px solid black';
+			} else
+				delete st['border'];
+
+			// Handle hspace
+			v = f.hspace.value;
+			if (v) {
+				delete st['margin'];
+				st['margin-left'] = v + 'px';
+				st['margin-right'] = v + 'px';
+			} else {
+				delete st['margin-left'];
+				delete st['margin-right'];
+			}
+
+			// Handle vspace
+			v = f.vspace.value;
+			if (v) {
+				delete st['margin'];
+				st['margin-top'] = v + 'px';
+				st['margin-bottom'] = v + 'px';
+			} else {
+				delete st['margin-top'];
+				delete st['margin-bottom'];
+			}
+
+			// Merge
+			st = tinyMCEPopup.dom.parseStyle(dom.serializeStyle(st), 'img');
+			this.styleVal = dom.serializeStyle(st, 'img');
+		}
+	},
+
+	getAttrib : function(e, at) {
+		var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
+
+		if (ed.settings.inline_styles) {
+			switch (at) {
+				case 'align':
+					if (v = dom.getStyle(e, 'float'))
+						return v;
+
+					if (v = dom.getStyle(e, 'vertical-align'))
+						return v;
+
+					break;
+
+				case 'hspace':
+					v = dom.getStyle(e, 'margin-left')
+					v2 = dom.getStyle(e, 'margin-right');
+					if (v && v == v2)
+						return parseInt(v.replace(/[^0-9]/g, ''));
+
+					break;
+
+				case 'vspace':
+					v = dom.getStyle(e, 'margin-top')
+					v2 = dom.getStyle(e, 'margin-bottom');
+					if (v && v == v2)
+						return parseInt(v.replace(/[^0-9]/g, ''));
+
+					break;
+
+				case 'border':
+					v = 0;
+
+					tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
+						sv = dom.getStyle(e, 'border-' + sv + '-width');
+
+						// False or not the same as prev
+						if (!sv || (sv != v && v !== 0)) {
+							v = 0;
+							return false;
+						}
+
+						if (sv)
+							v = sv;
+					});
+
+					if (v)
+						return parseInt(v.replace(/[^0-9]/g, ''));
+
+					break;
+			}
+		}
+
+		if (v = dom.getAttrib(e, at))
+			return v;
+
+		return '';
+	},
+
+	resetImageData : function() {
+		var f = document.forms[0];
+
+		f.width.value = f.height.value = "";	
+	},
+
+	updateImageData : function() {
+		var f = document.forms[0], t = ImageDialog;
+
+		if (f.width.value == "")
+			f.width.value = t.preloadImg.width;
+
+		if (f.height.value == "")
+			f.height.value = t.preloadImg.height;
+	},
+
+	getImageData : function() {
+		var f = document.forms[0];
+
+		this.preloadImg = new Image();
+		this.preloadImg.onload = this.updateImageData;
+		this.preloadImg.onerror = this.resetImageData;
+		this.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.src.value);
+	}
+};
+
+ImageDialog.preInit();
+tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/link.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/link.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/link.js	(revision 17487)
@@ -0,0 +1,156 @@
+tinyMCEPopup.requireLangPack();
+
+var LinkDialog = {
+	preInit : function() {
+		var url;
+
+		if (url = tinyMCEPopup.getParam("external_link_list_url"))
+			document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
+	},
+
+	init : function() {
+		var f = document.forms[0], ed = tinyMCEPopup.editor;
+
+		// Setup browse button
+		document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link');
+		if (isVisible('hrefbrowser'))
+			document.getElementById('href').style.width = '180px';
+
+		this.fillClassList('class_list');
+		this.fillFileList('link_list', 'tinyMCELinkList');
+		this.fillTargetList('target_list');
+
+		if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) {
+			f.href.value = ed.dom.getAttrib(e, 'href');
+			f.linktitle.value = ed.dom.getAttrib(e, 'title');
+			f.insert.value = ed.getLang('update');
+			selectByValue(f, 'link_list', f.href.value);
+			selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target'));
+			selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class'));
+		}
+	},
+
+	update : function() {
+		var f = document.forms[0], ed = tinyMCEPopup.editor, e, b;
+
+		tinyMCEPopup.restoreSelection();
+		e = ed.dom.getParent(ed.selection.getNode(), 'A');
+
+		// Remove element if there is no href
+		if (!f.href.value) {
+			if (e) {
+				tinyMCEPopup.execCommand("mceBeginUndoLevel");
+				b = ed.selection.getBookmark();
+				ed.dom.remove(e, 1);
+				ed.selection.moveToBookmark(b);
+				tinyMCEPopup.execCommand("mceEndUndoLevel");
+				tinyMCEPopup.close();
+				return;
+			}
+		}
+
+		tinyMCEPopup.execCommand("mceBeginUndoLevel");
+
+		// Create new anchor elements
+		if (e == null) {
+			ed.getDoc().execCommand("unlink", false, null);
+			tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
+
+			tinymce.each(ed.dom.select("a"), function(n) {
+				if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
+					e = n;
+
+					ed.dom.setAttribs(e, {
+						href : f.href.value,
+						title : f.linktitle.value,
+						target : f.target_list ? getSelectValue(f, "target_list") : null,
+						'class' : f.class_list ? getSelectValue(f, "class_list") : null
+					});
+				}
+			});
+		} else {
+			ed.dom.setAttribs(e, {
+				href : f.href.value,
+				title : f.linktitle.value,
+				target : f.target_list ? getSelectValue(f, "target_list") : null,
+				'class' : f.class_list ? getSelectValue(f, "class_list") : null
+			});
+		}
+
+		// Don't move caret if selection was image
+		if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
+			ed.focus();
+			ed.selection.select(e);
+			ed.selection.collapse(0);
+			tinyMCEPopup.storeSelection();
+		}
+
+		tinyMCEPopup.execCommand("mceEndUndoLevel");
+		tinyMCEPopup.close();
+	},
+
+	checkPrefix : function(n) {
+		if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
+			n.value = 'mailto:' + n.value;
+
+		if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
+			n.value = 'http://' + n.value;
+	},
+
+	fillFileList : function(id, l) {
+		var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
+
+		l = window[l];
+
+		if (l && l.length > 0) {
+			lst.options[lst.options.length] = new Option('', '');
+
+			tinymce.each(l, function(o) {
+				lst.options[lst.options.length] = new Option(o[0], o[1]);
+			});
+		} else
+			dom.remove(dom.getParent(id, 'tr'));
+	},
+
+	fillClassList : function(id) {
+		var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
+
+		if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
+			cl = [];
+
+			tinymce.each(v.split(';'), function(v) {
+				var p = v.split('=');
+
+				cl.push({'title' : p[0], 'class' : p[1]});
+			});
+		} else
+			cl = tinyMCEPopup.editor.dom.getClasses();
+
+		if (cl.length > 0) {
+			lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
+
+			tinymce.each(cl, function(o) {
+				lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']);
+			});
+		} else
+			dom.remove(dom.getParent(id, 'tr'));
+	},
+
+	fillTargetList : function(id) {
+		var dom = tinyMCEPopup.dom, lst = dom.get(id), v;
+
+		lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
+		lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self');
+		lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank');
+
+		if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) {
+			tinymce.each(v.split(','), function(v) {
+				v = v.split('=');
+				lst.options[lst.options.length] = new Option(v[0], v[1]);
+			});
+		}
+	}
+};
+
+LinkDialog.preInit();
+tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog);
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/source_editor.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/source_editor.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/js/source_editor.js	(revision 17487)
@@ -0,0 +1,56 @@
+tinyMCEPopup.requireLangPack();
+tinyMCEPopup.onInit.add(onLoadInit);
+
+function saveContent() {
+	tinyMCEPopup.editor.setContent(document.getElementById('htmlSource').value, {source_view : true});
+	tinyMCEPopup.close();
+}
+
+function onLoadInit() {
+	tinyMCEPopup.resizeToInnerSize();
+
+	// Remove Gecko spellchecking
+	if (tinymce.isGecko)
+		document.body.spellcheck = tinyMCEPopup.editor.getParam("gecko_spellcheck");
+
+	document.getElementById('htmlSource').value = tinyMCEPopup.editor.getContent({source_view : true});
+
+	if (tinyMCEPopup.editor.getParam("theme_advanced_source_editor_wrap", true)) {
+		setWrap('soft');
+		document.getElementById('wraped').checked = true;
+	}
+
+	resizeInputs();
+}
+
+function setWrap(val) {
+	var v, n, s = document.getElementById('htmlSource');
+
+	s.wrap = val;
+
+	if (!tinymce.isIE) {
+		v = s.value;
+		n = s.cloneNode(false);
+		n.setAttribute("wrap", val);
+		s.parentNode.replaceChild(n, s);
+		n.value = v;
+	}
+}
+
+function toggleWordWrap(elm) {
+	if (elm.checked)
+		setWrap('soft');
+	else
+		setWrap('off');
+}
+
+function resizeInputs() {
+	var vp = tinyMCEPopup.dom.getViewPort(window), el;
+
+	el = document.getElementById('htmlSource');
+
+	if (el) {
+		el.style.width  = (vp.w - 20) + 'px';
+		el.style.height = (vp.h - 65) + 'px';
+	}
+}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/link.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/link.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/link.htm	(revision 17487)
@@ -0,0 +1,63 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>{#advanced_dlg.link_title}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="../../utils/mctabs.js?ver=3392"></script>
+	<script type="text/javascript" src="../../utils/form_utils.js?ver=3392"></script>
+	<script type="text/javascript" src="../../utils/validate.js?ver=3392"></script>
+	<script type="text/javascript" src="js/link.js?ver=3392"></script>
+</head>
+<body id="link" style="display: none">
+<form onsubmit="LinkDialog.update();return false;" action="#">
+	<div class="tabs">
+		<ul>
+			<li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#advanced_dlg.link_title}</a></span></li>
+		</ul>
+	</div>
+
+	<div class="panel_wrapper">
+		<div id="general_panel" class="panel current">
+
+		<table border="0" cellpadding="4" cellspacing="0">
+          <tr>
+            <td class="nowrap"><label for="href">{#advanced_dlg.link_url}</label></td>
+            <td><table border="0" cellspacing="0" cellpadding="0"> 
+				  <tr> 
+					<td><input id="href" name="href" type="text" class="mceFocus" value="http://" style="width: 200px" onfocus="try{this.select();}catch(e){}" /></td> 
+					<td id="hrefbrowsercontainer">&nbsp;</td>
+				  </tr> 
+				</table></td>
+          </tr>
+		  <tr>
+			<td><label for="link_list">{#advanced_dlg.link_list}</label></td>
+			<td><select id="link_list" name="link_list" onchange="document.getElementById('href').value=this.options[this.selectedIndex].value;"></select></td>
+		  </tr>
+		<tr>
+			<td><label id="targetlistlabel" for="targetlist">{#advanced_dlg.link_target}</label></td>
+			<td><select id="target_list" name="target_list"></select></td>
+		</tr>
+          <tr>
+            <td class="nowrap"><label for="linktitle">{#advanced_dlg.link_titlefield}</label></td>
+            <td><input id="linktitle" name="linktitle" type="text" value="" style="width: 200px" /></td>
+          </tr>
+			<tr>
+				<td><label for="class_list">{#class_name}</label></td>
+				<td><select id="class_list" name="class_list"></select></td>
+			</tr>
+        </table>
+		</div>
+	</div>
+
+	<div class="mceActionPanel">
+		<div style="float: left">
+			<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
+		</div>
+
+		<div style="float: right">
+			<input type="submit" id="insert" name="insert" value="{#insert}" />
+		</div>
+	</div>
+</form>
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/content.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/content.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/content.css	(revision 17487)
@@ -0,0 +1,36 @@
+body, td, pre {color:#000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; margin:8px;}
+body {background:#FFF;}
+body.mceForceColors {background:#FFF; color:#000;}
+h1 {font-size: 2em}
+h2 {font-size: 1.5em}
+h3 {font-size: 1.17em}
+h4 {font-size: 1em}
+h5 {font-size: .83em}
+h6 {font-size: .75em}
+.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;}
+a.mceItemAnchor {display:inline-block; width:11px !important; height:11px  !important; background:url(img/items.gif) no-repeat 0 0;}
+span.mceItemNbsp {background: #DDD}
+td.mceSelected, th.mceSelected {background-color:#3399ff !important}
+img {border:0;}
+table {cursor:default}
+table td, table th {cursor:text}
+ins {border-bottom:1px solid green; text-decoration: none; color:green}
+del {color:red; text-decoration:line-through}
+cite {border-bottom:1px dashed blue}
+acronym {border-bottom:1px dotted #CCC; cursor:help}
+abbr {border-bottom:1px dashed #CCC; cursor:help}
+
+/* IE */
+* html body {
+scrollbar-3dlight-color:#F0F0EE;
+scrollbar-arrow-color:#676662;
+scrollbar-base-color:#F0F0EE;
+scrollbar-darkshadow-color:#DDD;
+scrollbar-face-color:#E0E0DD;
+scrollbar-highlight-color:#F0F0EE;
+scrollbar-shadow-color:#F0F0EE;
+scrollbar-track-color:#F5F5F5;
+}
+
+img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px}
+font[face=mceinline] {font-family:inherit !important}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/dialog.css	(revision 17487)
@@ -0,0 +1,117 @@
+/* Generic */
+body {
+font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;
+scrollbar-3dlight-color:#F0F0EE;
+scrollbar-arrow-color:#676662;
+scrollbar-base-color:#F0F0EE;
+scrollbar-darkshadow-color:#DDDDDD;
+scrollbar-face-color:#E0E0DD;
+scrollbar-highlight-color:#F0F0EE;
+scrollbar-shadow-color:#F0F0EE;
+scrollbar-track-color:#F5F5F5;
+background:#F0F0EE;
+padding:0;
+margin:8px 8px 0 8px;
+}
+
+html {background:#F0F0EE;}
+td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
+textarea {resize:none;outline:none;}
+a:link, a:visited {color:black;}
+a:hover {color:#2B6FB6;}
+.nowrap {white-space: nowrap}
+
+/* Forms */
+fieldset {margin:0; padding:4px; border:1px solid #919B9C; font-family:Verdana, Arial; font-size:10px;}
+legend {color:#2B6FB6; font-weight:bold;}
+label.msg {display:none;}
+label.invalid {color:#EE0000; display:inline;}
+input.invalid {border:1px solid #EE0000;}
+input {background:#FFF; border:1px solid #CCC;}
+input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
+input, select, textarea {border:1px solid #808080;}
+input.radio {border:1px none #000000; background:transparent; vertical-align:middle;}
+input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;}
+.input_noborder {border:0;}
+
+/* Buttons */
+#insert, #cancel, input.button, .updateButton {
+border:0; margin:0; padding:0;
+font-weight:bold;
+width:94px; height:26px;
+background:url(img/buttons.png) 0 -26px;
+cursor:pointer;
+padding-bottom:2px;
+float:left;
+}
+
+#insert {background:url(img/buttons.png) 0 -52px}
+#cancel {background:url(img/buttons.png) 0 0; float:right}
+
+/* Browse */
+a.pickcolor, a.browse {text-decoration:none}
+a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;}
+.mceOldBoxModel a.browse span {width:22px; height:20px;}
+a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;}
+a.browse span.disabled {border:1px solid white; opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
+a.browse:hover span.disabled {border:1px solid white; background-color:transparent;}
+a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;}
+.mceOldBoxModel a.pickcolor span {width:21px; height:17px;}
+a.pickcolor:hover span {background-color:#B2BBD0;}
+a.pickcolor:hover span.disabled {}
+
+/* Charmap */
+table.charmap {border:1px solid #AAA; text-align:center}
+td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;}
+#charmap a {display:block; color:#000; text-decoration:none; border:0}
+#charmap a:hover {background:#CCC;color:#2B6FB6}
+#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center}
+#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center}
+
+/* Source */
+.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;}
+.mceActionPanel {margin-top:5px;}
+
+/* Tabs classes */
+.tabs {width:100%; height:18px; line-height:normal; background:url(img/tabs.gif) repeat-x 0 -72px;}
+.tabs ul {margin:0; padding:0; list-style:none;}
+.tabs li {float:left; background:url(img/tabs.gif) no-repeat 0 0; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;}
+.tabs li.current {background:url(img/tabs.gif) no-repeat 0 -18px; margin-right:2px;}
+.tabs span {float:left; display:block; background:url(img/tabs.gif) no-repeat right -36px; padding:0px 10px 0 0;}
+.tabs .current span {background:url(img/tabs.gif) no-repeat right -54px;}
+.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;}
+.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;}
+
+/* Panels */
+.panel_wrapper div.panel {display:none;}
+.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;}
+.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;}
+
+/* Columns */
+.column {float:left;}
+.properties {width:100%;}
+.properties .column1 {}
+.properties .column2 {text-align:left;}
+
+/* Titles */
+h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;}
+h3 {font-size:14px;}
+.title {font-size:12px; font-weight:bold; color:#2B6FB6;}
+
+/* Dialog specific */
+#link .panel_wrapper, #link div.current {height:125px;}
+#image .panel_wrapper, #image div.current {height:200px;}
+#plugintable thead {font-weight:bold; background:#DDD;}
+#plugintable, #about #plugintable td {border:1px solid #919B9C;}
+#plugintable {width:96%; margin-top:10px;}
+#pluginscontainer {height:290px; overflow:auto;}
+#colorpicker #preview {float:right; width:50px; height:14px;line-height:1px; border:1px solid black; margin-left:5px;}
+#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;}
+#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;}
+#colorpicker #light div {overflow:hidden;}
+#colorpicker #previewblock {float:right; padding-left:10px; height:20px;}
+#colorpicker .panel_wrapper div.current {height:175px;}
+#colorpicker #namedcolors {width:150px;}
+#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;}
+#colorpicker #colornamecontainer {margin-top:5px;}
+#colorpicker #picker_panel fieldset {margin:auto;width:325px;}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/default/ui.css	(revision 17487)
@@ -0,0 +1,213 @@
+/* Reset */
+.defaultSkin table, .defaultSkin tbody, .defaultSkin a, .defaultSkin img, .defaultSkin tr, .defaultSkin div, .defaultSkin td, .defaultSkin iframe, .defaultSkin span, .defaultSkin *, .defaultSkin .mceText {border:0; margin:0; padding:0; background:transparent; white-space:nowrap; text-decoration:none; font-weight:normal; cursor:default; color:#000; vertical-align:baseline; width:auto; border-collapse:separate; text-align:left}
+.defaultSkin a:hover, .defaultSkin a:link, .defaultSkin a:visited, .defaultSkin a:active {text-decoration:none; font-weight:normal; cursor:default; color:#000}
+.defaultSkin table td {vertical-align:middle}
+
+/* Containers */
+.defaultSkin table {direction:ltr; background:#F0F0EE}
+.defaultSkin iframe {display:block; background:#FFF}
+.defaultSkin .mceToolbar {height:26px}
+.defaultSkin .mceLeft {text-align:left}
+.defaultSkin .mceRight {text-align:right}
+
+/* External */
+.defaultSkin .mceExternalToolbar {position:absolute; border:1px solid #CCC; border-bottom:0; display:none;}
+.defaultSkin .mceExternalToolbar td.mceToolbar {padding-right:13px;}
+.defaultSkin .mceExternalClose {position:absolute; top:3px; right:3px; width:7px; height:7px; background:url(../../img/icons.gif) -820px 0}
+
+/* Layout */
+.defaultSkin table.mceLayout {border:0; border-left:1px solid #CCC; border-right:1px solid #CCC}
+.defaultSkin table.mceLayout tr.mceFirst td {border-top:1px solid #CCC}
+.defaultSkin table.mceLayout tr.mceLast td {border-bottom:1px solid #CCC}
+.defaultSkin table.mceToolbar, .defaultSkin tr.mceFirst .mceToolbar tr td, .defaultSkin tr.mceLast .mceToolbar tr td {border:0; margin:0; padding:0;}
+.defaultSkin td.mceToolbar {padding-top:1px; vertical-align:top}
+.defaultSkin .mceIframeContainer {border-top:1px solid #CCC; border-bottom:1px solid #CCC}
+.defaultSkin .mceStatusbar {font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible; color:#000; display:block; height:20px}
+.defaultSkin .mceStatusbar div {float:left; margin:2px}
+.defaultSkin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize; outline:0}
+.defaultSkin .mceStatusbar a:hover {text-decoration:underline}
+.defaultSkin table.mceToolbar {margin-left:3px}
+.defaultSkin span.mceIcon, .defaultSkin img.mceIcon {display:block; width:20px; height:20px}
+.defaultSkin .mceIcon {background:url(../../img/icons.gif) no-repeat 20px 20px}
+.defaultSkin td.mceCenter {text-align:center;}
+.defaultSkin td.mceCenter table {margin:0 auto; text-align:left;}
+.defaultSkin td.mceRight table {margin:0 0 0 auto;}
+
+/* Button */
+.defaultSkin .mceButton {display:block; border:1px solid #F0F0EE; width:20px; height:20px; margin-right:1px}
+.defaultSkin a.mceButtonEnabled:hover {border:1px solid #0A246A; background-color:#B2BBD0}
+.defaultSkin a.mceButtonActive, .defaultSkin a.mceButtonSelected {border:1px solid #0A246A; background-color:#C2CBE0}
+.defaultSkin .mceButtonDisabled .mceIcon {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
+.defaultSkin .mceButtonLabeled {width:auto}
+.defaultSkin .mceButtonLabeled span.mceIcon {float:left}
+.defaultSkin span.mceButtonLabel {display:block; font-size:10px; padding:4px 6px 0 22px; font-family:Tahoma,Verdana,Arial,Helvetica}
+.defaultSkin .mceButtonDisabled .mceButtonLabel {color:#888}
+
+/* Separator */
+.defaultSkin .mceSeparator {display:block; background:url(../../img/icons.gif) -180px 0; width:2px; height:20px; margin:2px 2px 0 4px}
+
+/* ListBox */
+.defaultSkin .mceListBox, .defaultSkin .mceListBox a {display:block}
+.defaultSkin .mceListBox .mceText {padding-left:4px; width:70px; text-align:left; border:1px solid #CCC; border-right:0; background:#FFF; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; height:20px; line-height:20px; overflow:hidden}
+.defaultSkin .mceListBox .mceOpen {width:9px; height:20px; background:url(../../img/icons.gif) -741px 0; margin-right:2px; border:1px solid #CCC;}
+.defaultSkin table.mceListBoxEnabled:hover .mceText, .defaultSkin .mceListBoxHover .mceText, .defaultSkin .mceListBoxSelected .mceText {border:1px solid #A2ABC0; border-right:0; background:#FFF}
+.defaultSkin table.mceListBoxEnabled:hover .mceOpen, .defaultSkin .mceListBoxHover .mceOpen, .defaultSkin .mceListBoxSelected .mceOpen {background-color:#FFF; border:1px solid #A2ABC0}
+.defaultSkin .mceListBoxDisabled a.mceText {color:gray; background-color:transparent;}
+.defaultSkin .mceListBoxMenu {overflow:auto; overflow-x:hidden}
+.defaultSkin .mceOldBoxModel .mceListBox .mceText {height:22px}
+.defaultSkin .mceOldBoxModel .mceListBox .mceOpen {width:11px; height:22px;}
+.defaultSkin select.mceNativeListBox {font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:7pt; background:#F0F0EE; border:1px solid gray; margin-right:2px;}
+
+/* SplitButton */
+.defaultSkin .mceSplitButton {width:32px; height:20px; direction:ltr}
+.defaultSkin .mceSplitButton a, .defaultSkin .mceSplitButton span {height:20px; display:block}
+.defaultSkin .mceSplitButton a.mceAction {width:20px; border:1px solid #F0F0EE; border-right:0;}
+.defaultSkin .mceSplitButton span.mceAction {width:20px; background-image:url(../../img/icons.gif);}
+.defaultSkin .mceSplitButton a.mceOpen {width:9px; background:url(../../img/icons.gif) -741px 0; border:1px solid #F0F0EE;}
+.defaultSkin .mceSplitButton span.mceOpen {display:none}
+.defaultSkin table.mceSplitButtonEnabled:hover a.mceAction, .defaultSkin .mceSplitButtonHover a.mceAction, .defaultSkin .mceSplitButtonSelected a.mceAction {border:1px solid #0A246A; border-right:0; background-color:#B2BBD0}
+.defaultSkin table.mceSplitButtonEnabled:hover a.mceOpen, .defaultSkin .mceSplitButtonHover a.mceOpen, .defaultSkin .mceSplitButtonSelected a.mceOpen {background-color:#B2BBD0; border:1px solid #0A246A;}
+.defaultSkin .mceSplitButtonDisabled .mceAction, .defaultSkin .mceSplitButtonDisabled a.mceOpen {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
+.defaultSkin .mceSplitButtonActive a.mceAction {border:1px solid #0A246A; background-color:#C2CBE0}
+.defaultSkin .mceSplitButtonActive a.mceOpen {border-left:0;}
+
+/* ColorSplitButton */
+.defaultSkin div.mceColorSplitMenu table {background:#FFF; border:1px solid gray}
+.defaultSkin .mceColorSplitMenu td {padding:2px}
+.defaultSkin .mceColorSplitMenu a {display:block; width:9px; height:9px; overflow:hidden; border:1px solid #808080}
+.defaultSkin .mceColorSplitMenu td.mceMoreColors {padding:1px 3px 1px 1px}
+.defaultSkin .mceColorSplitMenu a.mceMoreColors {width:100%; height:auto; text-align:center; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; line-height:20px; border:1px solid #FFF}
+.defaultSkin .mceColorSplitMenu a.mceMoreColors:hover {border:1px solid #0A246A; background-color:#B6BDD2}
+.defaultSkin a.mceMoreColors:hover {border:1px solid #0A246A}
+.defaultSkin .mceColorPreview {margin-left:2px; width:16px; height:4px; overflow:hidden; background:#9a9b9a}
+.defaultSkin .mce_forecolor span.mceAction, .defaultSkin .mce_backcolor span.mceAction {overflow:hidden; height:16px}
+
+/* Menu */
+.defaultSkin .mceMenu {position:absolute; left:0; top:0; z-index:1000; border:1px solid #D4D0C8}
+.defaultSkin .mceNoIcons span.mceIcon {width:0;}
+.defaultSkin .mceNoIcons a .mceText {padding-left:10px}
+.defaultSkin .mceMenu table {background:#FFF}
+.defaultSkin .mceMenu a, .defaultSkin .mceMenu span, .defaultSkin .mceMenu {display:block}
+.defaultSkin .mceMenu td {height:20px}
+.defaultSkin .mceMenu a {position:relative;padding:3px 0 4px 0}
+.defaultSkin .mceMenu .mceText {position:relative; display:block; font-family:Tahoma,Verdana,Arial,Helvetica; color:#000; cursor:default; margin:0; padding:0 25px 0 25px; display:block}
+.defaultSkin .mceMenu span.mceText, .defaultSkin .mceMenu .mcePreview {font-size:11px}
+.defaultSkin .mceMenu pre.mceText {font-family:Monospace}
+.defaultSkin .mceMenu .mceIcon {position:absolute; top:0; left:0; width:22px;}
+.defaultSkin .mceMenu .mceMenuItemEnabled a:hover, .defaultSkin .mceMenu .mceMenuItemActive {background-color:#dbecf3}
+.defaultSkin td.mceMenuItemSeparator {background:#DDD; height:1px}
+.defaultSkin .mceMenuItemTitle a {border:0; background:#EEE; border-bottom:1px solid #DDD}
+.defaultSkin .mceMenuItemTitle span.mceText {color:#000; font-weight:bold; padding-left:4px}
+.defaultSkin .mceMenuItemDisabled .mceText {color:#888}
+.defaultSkin .mceMenuItemSelected .mceIcon {background:url(img/menu_check.gif)}
+.defaultSkin .mceNoIcons .mceMenuItemSelected a {background:url(img/menu_arrow.gif) no-repeat -6px center}
+.defaultSkin .mceMenu span.mceMenuLine {display:none}
+.defaultSkin .mceMenuItemSub a {background:url(img/menu_arrow.gif) no-repeat top right;}
+
+/* Progress,Resize */
+.defaultSkin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; -ms-filter:'alpha(opacity=50)'; filter:alpha(opacity=50); background:#FFF}
+.defaultSkin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px}
+
+/* Formats */
+.defaultSkin .mce_formatPreview a {font-size:10px}
+.defaultSkin .mce_p span.mceText {}
+.defaultSkin .mce_address span.mceText {font-style:italic}
+.defaultSkin .mce_pre span.mceText {font-family:monospace}
+.defaultSkin .mce_h1 span.mceText {font-weight:bolder; font-size: 2em}
+.defaultSkin .mce_h2 span.mceText {font-weight:bolder; font-size: 1.5em}
+.defaultSkin .mce_h3 span.mceText {font-weight:bolder; font-size: 1.17em}
+.defaultSkin .mce_h4 span.mceText {font-weight:bolder; font-size: 1em}
+.defaultSkin .mce_h5 span.mceText {font-weight:bolder; font-size: .83em}
+.defaultSkin .mce_h6 span.mceText {font-weight:bolder; font-size: .75em}
+
+/* Theme */
+.defaultSkin span.mce_bold {background-position:0 0}
+.defaultSkin span.mce_italic {background-position:-60px 0}
+.defaultSkin span.mce_underline {background-position:-140px 0}
+.defaultSkin span.mce_strikethrough {background-position:-120px 0}
+.defaultSkin span.mce_undo {background-position:-160px 0}
+.defaultSkin span.mce_redo {background-position:-100px 0}
+.defaultSkin span.mce_cleanup {background-position:-40px 0}
+.defaultSkin span.mce_bullist {background-position:-20px 0}
+.defaultSkin span.mce_numlist {background-position:-80px 0}
+.defaultSkin span.mce_justifyleft {background-position:-460px 0}
+.defaultSkin span.mce_justifyright {background-position:-480px 0}
+.defaultSkin span.mce_justifycenter {background-position:-420px 0}
+.defaultSkin span.mce_justifyfull {background-position:-440px 0}
+.defaultSkin span.mce_anchor {background-position:-200px 0}
+.defaultSkin span.mce_indent {background-position:-400px 0}
+.defaultSkin span.mce_outdent {background-position:-540px 0}
+.defaultSkin span.mce_link {background-position:-500px 0}
+.defaultSkin span.mce_unlink {background-position:-640px 0}
+.defaultSkin span.mce_sub {background-position:-600px 0}
+.defaultSkin span.mce_sup {background-position:-620px 0}
+.defaultSkin span.mce_removeformat {background-position:-580px 0}
+.defaultSkin span.mce_newdocument {background-position:-520px 0}
+.defaultSkin span.mce_image {background-position:-380px 0}
+.defaultSkin span.mce_help {background-position:-340px 0}
+.defaultSkin span.mce_code {background-position:-260px 0}
+.defaultSkin span.mce_hr {background-position:-360px 0}
+.defaultSkin span.mce_visualaid {background-position:-660px 0}
+.defaultSkin span.mce_charmap {background-position:-240px 0}
+.defaultSkin span.mce_paste {background-position:-560px 0}
+.defaultSkin span.mce_copy {background-position:-700px 0}
+.defaultSkin span.mce_cut {background-position:-680px 0}
+.defaultSkin span.mce_blockquote {background-position:-220px 0}
+.defaultSkin .mce_forecolor span.mceAction {background-position:-720px 0}
+.defaultSkin .mce_backcolor span.mceAction {background-position:-760px 0}
+.defaultSkin span.mce_forecolorpicker {background-position:-720px 0}
+.defaultSkin span.mce_backcolorpicker {background-position:-760px 0}
+
+/* Plugins */
+.defaultSkin span.mce_advhr {background-position:-0px -20px}
+.defaultSkin span.mce_ltr {background-position:-20px -20px}
+.defaultSkin span.mce_rtl {background-position:-40px -20px}
+.defaultSkin span.mce_emotions {background-position:-60px -20px}
+.defaultSkin span.mce_fullpage {background-position:-80px -20px}
+.defaultSkin span.mce_fullscreen {background-position:-100px -20px}
+.defaultSkin span.mce_iespell {background-position:-120px -20px}
+.defaultSkin span.mce_insertdate {background-position:-140px -20px}
+.defaultSkin span.mce_inserttime {background-position:-160px -20px}
+.defaultSkin span.mce_absolute {background-position:-180px -20px}
+.defaultSkin span.mce_backward {background-position:-200px -20px}
+.defaultSkin span.mce_forward {background-position:-220px -20px}
+.defaultSkin span.mce_insert_layer {background-position:-240px -20px}
+.defaultSkin span.mce_insertlayer {background-position:-260px -20px}
+.defaultSkin span.mce_movebackward {background-position:-280px -20px}
+.defaultSkin span.mce_moveforward {background-position:-300px -20px}
+.defaultSkin span.mce_media {background-position:-320px -20px}
+.defaultSkin span.mce_nonbreaking {background-position:-340px -20px}
+.defaultSkin span.mce_pastetext {background-position:-360px -20px}
+.defaultSkin span.mce_pasteword {background-position:-380px -20px}
+.defaultSkin span.mce_selectall {background-position:-400px -20px}
+.defaultSkin span.mce_preview {background-position:-420px -20px}
+.defaultSkin span.mce_print {background-position:-440px -20px}
+.defaultSkin span.mce_cancel {background-position:-460px -20px}
+.defaultSkin span.mce_save {background-position:-480px -20px}
+.defaultSkin span.mce_replace {background-position:-500px -20px}
+.defaultSkin span.mce_search {background-position:-520px -20px}
+.defaultSkin span.mce_styleprops {background-position:-560px -20px}
+.defaultSkin span.mce_table {background-position:-580px -20px}
+.defaultSkin span.mce_cell_props {background-position:-600px -20px}
+.defaultSkin span.mce_delete_table {background-position:-620px -20px}
+.defaultSkin span.mce_delete_col {background-position:-640px -20px}
+.defaultSkin span.mce_delete_row {background-position:-660px -20px}
+.defaultSkin span.mce_col_after {background-position:-680px -20px}
+.defaultSkin span.mce_col_before {background-position:-700px -20px}
+.defaultSkin span.mce_row_after {background-position:-720px -20px}
+.defaultSkin span.mce_row_before {background-position:-740px -20px}
+.defaultSkin span.mce_merge_cells {background-position:-760px -20px}
+.defaultSkin span.mce_table_props {background-position:-980px -20px}
+.defaultSkin span.mce_row_props {background-position:-780px -20px}
+.defaultSkin span.mce_split_cells {background-position:-800px -20px}
+.defaultSkin span.mce_template {background-position:-820px -20px}
+.defaultSkin span.mce_visualchars {background-position:-840px -20px}
+.defaultSkin span.mce_abbr {background-position:-860px -20px}
+.defaultSkin span.mce_acronym {background-position:-880px -20px}
+.defaultSkin span.mce_attribs {background-position:-900px -20px}
+.defaultSkin span.mce_cite {background-position:-920px -20px}
+.defaultSkin span.mce_del {background-position:-940px -20px}
+.defaultSkin span.mce_ins {background-position:-960px -20px}
+.defaultSkin span.mce_pagebreak {background-position:0 -40px}
+.defaultSkin span.mce_restoredraft {background-position:-20px -40px}
+.defaultSkin span.mce_spellchecker {background-position:-540px -20px}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/content.css	(revision 17487)
@@ -0,0 +1,36 @@
+body, td, pre {color:#000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; margin:8px;}
+body {background:#FFF;}
+body.mceForceColors {background:#FFF; color:#000;}
+h1 {font-size: 2em}
+h2 {font-size: 1.5em}
+h3 {font-size: 1.17em}
+h4 {font-size: 1em}
+h5 {font-size: .83em}
+h6 {font-size: .75em}
+.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;}
+a.mceItemAnchor {display:inline-block; width:11px !important; height:11px  !important; background:url(../default/img/items.gif) no-repeat 0 0;}
+span.mceItemNbsp {background: #DDD}
+td.mceSelected, th.mceSelected {background-color:#3399ff !important}
+img {border:0;}
+table {cursor:default}
+table td, table th {cursor:text}
+ins {border-bottom:1px solid green; text-decoration: none; color:green}
+del {color:red; text-decoration:line-through}
+cite {border-bottom:1px dashed blue}
+acronym {border-bottom:1px dotted #CCC; cursor:help}
+abbr {border-bottom:1px dashed #CCC; cursor:help}
+
+/* IE */
+* html body {
+scrollbar-3dlight-color:#F0F0EE;
+scrollbar-arrow-color:#676662;
+scrollbar-base-color:#F0F0EE;
+scrollbar-darkshadow-color:#DDD;
+scrollbar-face-color:#E0E0DD;
+scrollbar-highlight-color:#F0F0EE;
+scrollbar-shadow-color:#F0F0EE;
+scrollbar-track-color:#F5F5F5;
+}
+
+img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px}
+font[face=mceinline] {font-family:inherit !important}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/dialog.css	(revision 17487)
@@ -0,0 +1,116 @@
+/* Generic */
+body {
+font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;
+scrollbar-3dlight-color:#F0F0EE;
+scrollbar-arrow-color:#676662;
+scrollbar-base-color:#F0F0EE;
+scrollbar-darkshadow-color:#DDDDDD;
+scrollbar-face-color:#E0E0DD;
+scrollbar-highlight-color:#F0F0EE;
+scrollbar-shadow-color:#F0F0EE;
+scrollbar-track-color:#F5F5F5;
+background:#F0F0EE;
+padding:0;
+margin:8px 8px 0 8px;
+}
+
+html {background:#F0F0EE;}
+td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
+textarea {resize:none;outline:none;}
+a:link, a:visited {color:black;}
+a:hover {color:#2B6FB6;}
+.nowrap {white-space: nowrap}
+
+/* Forms */
+fieldset {margin:0; padding:4px; border:1px solid #919B9C; font-family:Verdana, Arial; font-size:10px;}
+legend {color:#2B6FB6; font-weight:bold;}
+label.msg {display:none;}
+label.invalid {color:#EE0000; display:inline;}
+input.invalid {border:1px solid #EE0000;}
+input {background:#FFF; border:1px solid #CCC;}
+input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
+input, select, textarea {border:1px solid #808080;}
+input.radio {border:1px none #000000; background:transparent; vertical-align:middle;}
+input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;}
+.input_noborder {border:0;}
+
+/* Buttons */
+#insert, #cancel, input.button, .updateButton {
+border:0; margin:0; padding:0;
+font-weight:bold;
+width:94px; height:26px;
+background:url(../default/img/buttons.png) 0 -26px;
+cursor:pointer;
+padding-bottom:2px;
+float:left;
+}
+
+#insert {background:url(../default/img/buttons.png) 0 -52px}
+#cancel {background:url(../default/img/buttons.png) 0 0; float:right}
+
+/* Browse */
+a.pickcolor, a.browse {text-decoration:none}
+a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;}
+.mceOldBoxModel a.browse span {width:22px; height:20px;}
+a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;}
+a.browse span.disabled {border:1px solid white; opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
+a.browse:hover span.disabled {border:1px solid white; background-color:transparent;}
+a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;}
+.mceOldBoxModel a.pickcolor span {width:21px; height:17px;}
+a.pickcolor:hover span {background-color:#B2BBD0;}
+a.pickcolor:hover span.disabled {}
+
+/* Charmap */
+table.charmap {border:1px solid #AAA; text-align:center}
+td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;}
+#charmap a {display:block; color:#000; text-decoration:none; border:0}
+#charmap a:hover {background:#CCC;color:#2B6FB6}
+#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center}
+#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center}
+
+/* Source */
+.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;}
+.mceActionPanel {margin-top:5px;}
+
+/* Tabs classes */
+.tabs {width:100%; height:18px; line-height:normal; background:url(../default/img/tabs.gif) repeat-x 0 -72px;}
+.tabs ul {margin:0; padding:0; list-style:none;}
+.tabs li {float:left; background:url(../default/img/tabs.gif) no-repeat 0 0; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;}
+.tabs li.current {background:url(../default/img/tabs.gif) no-repeat 0 -18px; margin-right:2px;}
+.tabs span {float:left; display:block; background:url(../default/img/tabs.gif) no-repeat right -36px; padding:0px 10px 0 0;}
+.tabs .current span {background:url(../default/img/tabs.gif) no-repeat right -54px;}
+.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;}
+.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;}
+
+/* Panels */
+.panel_wrapper div.panel {display:none;}
+.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;}
+.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;}
+
+/* Columns */
+.column {float:left;}
+.properties {width:100%;}
+.properties .column1 {}
+.properties .column2 {text-align:left;}
+
+/* Titles */
+h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;}
+h3 {font-size:14px;}
+.title {font-size:12px; font-weight:bold; color:#2B6FB6;}
+
+/* Dialog specific */
+#link .panel_wrapper, #link div.current {height:125px;}
+#image .panel_wrapper, #image div.current {height:200px;}
+#plugintable thead {font-weight:bold; background:#DDD;}
+#plugintable, #about #plugintable td {border:1px solid #919B9C;}
+#plugintable {width:96%; margin-top:10px;}
+#pluginscontainer {height:290px; overflow:auto;}
+#colorpicker #preview {float:right; width:50px; height:14px;line-height:1px; border:1px solid black; margin-left:5px;}
+#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;}
+#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;}
+#colorpicker #light div {overflow:hidden;}
+#colorpicker #previewblock {float:right; padding-left:10px; height:20px;}
+#colorpicker .panel_wrapper div.current {height:175px;}
+#colorpicker #namedcolors {width:150px;}
+#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;}
+#colorpicker #colornamecontainer {margin-top:5px;}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui.css	(revision 17487)
@@ -0,0 +1,215 @@
+/* Reset */
+.o2k7Skin table, .o2k7Skin tbody, .o2k7Skin a, .o2k7Skin img, .o2k7Skin tr, .o2k7Skin div, .o2k7Skin td, .o2k7Skin iframe, .o2k7Skin span, .o2k7Skin *, .o2k7Skin .mceText {border:0; margin:0; padding:0; background:transparent; white-space:nowrap; text-decoration:none; font-weight:normal; cursor:default; color:#000; vertical-align:baseline; width:auto; border-collapse:separate; text-align:left}
+.o2k7Skin a:hover, .o2k7Skin a:link, .o2k7Skin a:visited, .o2k7Skin a:active {text-decoration:none; font-weight:normal; cursor:default; color:#000}
+.o2k7Skin table td {vertical-align:middle}
+
+/* Containers */
+.o2k7Skin table {background:#E5EFFD}
+.o2k7Skin iframe {display:block; background:#FFF}
+.o2k7Skin .mceToolbar {height:26px}
+
+/* External */
+.o2k7Skin .mceExternalToolbar {position:absolute; border:1px solid #ABC6DD; border-bottom:0; display:none}
+.o2k7Skin .mceExternalToolbar td.mceToolbar {padding-right:13px;}
+.o2k7Skin .mceExternalClose {position:absolute; top:3px; right:3px; width:7px; height:7px; background:url(../../img/icons.gif) -820px 0}
+
+/* Layout */
+.o2k7Skin table.mceLayout {border:0; border-left:1px solid #ABC6DD; border-right:1px solid #ABC6DD}
+.o2k7Skin table.mceLayout tr.mceFirst td {border-top:1px solid #ABC6DD}
+.o2k7Skin table.mceLayout tr.mceLast td {border-bottom:1px solid #ABC6DD}
+.o2k7Skin table.mceToolbar, .o2k7Skin tr.mceFirst .mceToolbar tr td, .o2k7Skin tr.mceLast .mceToolbar tr td {border:0; margin:0; padding:0}
+.o2k7Skin .mceIframeContainer {border-top:1px solid #ABC6DD; border-bottom:1px solid #ABC6DD}
+.o2k7Skin .mceStatusbar {display:block; font-family:'MS Sans Serif',sans-serif,Verdana,Arial; font-size:9pt; line-height:16px; overflow:visible; color:#000; height:20px}
+.o2k7Skin .mceStatusbar div {float:left; padding:2px}
+.o2k7Skin .mceStatusbar a.mceResize {display:block; float:right; background:url(../../img/icons.gif) -800px 0; width:20px; height:20px; cursor:se-resize; outline:0}
+.o2k7Skin .mceStatusbar a:hover {text-decoration:underline}
+.o2k7Skin table.mceToolbar {margin-left:3px}
+.o2k7Skin .mceToolbar .mceToolbarStart span {display:block; background:url(img/button_bg.png) -22px 0; width:1px; height:22px; margin-left:3px;}
+.o2k7Skin .mceToolbar td.mceFirst span {margin:0}
+.o2k7Skin .mceToolbar .mceToolbarEnd span {display:block; background:url(img/button_bg.png) -22px 0; width:1px; height:22px}
+.o2k7Skin .mceToolbar .mceToolbarEndListBox span, .o2k7Skin .mceToolbar .mceToolbarStartListBox span {display:none}
+.o2k7Skin span.mceIcon, .o2k7Skin img.mceIcon {display:block; width:20px; height:20px}
+.o2k7Skin .mceIcon {background:url(../../img/icons.gif) no-repeat 20px 20px}
+.o2k7Skin td.mceCenter {text-align:center;}
+.o2k7Skin td.mceCenter table {margin:0 auto; text-align:left;}
+.o2k7Skin td.mceRight table {margin:0 0 0 auto;}
+
+/* Button */
+.o2k7Skin .mceButton {display:block; background:url(img/button_bg.png); width:22px; height:22px}
+.o2k7Skin a.mceButton span, .o2k7Skin a.mceButton img {margin-left:1px}
+.o2k7Skin .mceOldBoxModel a.mceButton span, .o2k7Skin .mceOldBoxModel a.mceButton img {margin:0 0 0 1px}
+.o2k7Skin a.mceButtonEnabled:hover {background-color:#B2BBD0; background-position:0 -22px}
+.o2k7Skin a.mceButtonActive, .o2k7Skin a.mceButtonSelected {background-position:0 -44px}
+.o2k7Skin .mceButtonDisabled .mceIcon {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
+.o2k7Skin .mceButtonLabeled {width:auto}
+.o2k7Skin .mceButtonLabeled span.mceIcon {float:left}
+.o2k7Skin span.mceButtonLabel {display:block; font-size:10px; padding:4px 6px 0 22px; font-family:Tahoma,Verdana,Arial,Helvetica}
+.o2k7Skin .mceButtonDisabled .mceButtonLabel {color:#888}
+
+/* Separator */
+.o2k7Skin .mceSeparator {display:block; background:url(img/button_bg.png) -22px 0; width:5px; height:22px}
+
+/* ListBox */
+.o2k7Skin .mceListBox {margin-left:3px}
+.o2k7Skin .mceListBox, .o2k7Skin .mceListBox a {display:block}
+.o2k7Skin .mceListBox .mceText {padding-left:4px; text-align:left; width:70px; border:1px solid #b3c7e1; border-right:0; background:#eaf2fb; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; height:20px; line-height:20px; overflow:hidden}
+.o2k7Skin .mceListBox .mceOpen {width:14px; height:22px; background:url(img/button_bg.png) -66px 0}
+.o2k7Skin table.mceListBoxEnabled:hover .mceText, .o2k7Skin .mceListBoxHover .mceText, .o2k7Skin .mceListBoxSelected .mceText {background:#FFF}
+.o2k7Skin table.mceListBoxEnabled:hover .mceOpen, .o2k7Skin .mceListBoxHover .mceOpen, .o2k7Skin .mceListBoxSelected .mceOpen {background-position:-66px -22px}
+.o2k7Skin .mceListBoxDisabled .mceText {color:gray}
+.o2k7Skin .mceListBoxMenu {overflow:auto; overflow-x:hidden}
+.o2k7Skin .mceOldBoxModel .mceListBox .mceText {height:22px}
+.o2k7Skin select.mceListBox {font-family:Tahoma,Verdana,Arial,Helvetica; font-size:12px; border:1px solid #b3c7e1; background:#FFF;}
+
+/* SplitButton */
+.o2k7Skin .mceSplitButton, .o2k7Skin .mceSplitButton a, .o2k7Skin .mceSplitButton span {display:block; height:22px}
+.o2k7Skin .mceSplitButton {background:url(img/button_bg.png)}
+.o2k7Skin .mceSplitButton a.mceAction {width:22px}
+.o2k7Skin .mceSplitButton span.mceAction {width:22px; background-image:url(../../img/icons.gif)}
+.o2k7Skin .mceSplitButton a.mceOpen {width:10px; background:url(img/button_bg.png) -44px 0}
+.o2k7Skin .mceSplitButton span.mceOpen {display:none}
+.o2k7Skin table.mceSplitButtonEnabled:hover a.mceAction, .o2k7Skin .mceSplitButtonHover a.mceAction, .o2k7Skin .mceSplitButtonSelected {background:url(img/button_bg.png) 0 -22px}
+.o2k7Skin table.mceSplitButtonEnabled:hover a.mceOpen, .o2k7Skin .mceSplitButtonHover a.mceOpen, .o2k7Skin .mceSplitButtonSelected a.mceOpen {background-position:-44px -44px}
+.o2k7Skin .mceSplitButtonDisabled .mceAction {opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30)}
+.o2k7Skin .mceSplitButtonActive {background-position:0 -44px}
+
+/* ColorSplitButton */
+.o2k7Skin div.mceColorSplitMenu table {background:#FFF; border:1px solid gray}
+.o2k7Skin .mceColorSplitMenu td {padding:2px}
+.o2k7Skin .mceColorSplitMenu a {display:block; width:9px; height:9px; overflow:hidden; border:1px solid #808080}
+.o2k7Skin .mceColorSplitMenu td.mceMoreColors {padding:1px 3px 1px 1px}
+.o2k7Skin .mceColorSplitMenu a.mceMoreColors {width:100%; height:auto; text-align:center; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; line-height:20px; border:1px solid #FFF}
+.o2k7Skin .mceColorSplitMenu a.mceMoreColors:hover {border:1px solid #0A246A; background-color:#B6BDD2}
+.o2k7Skin a.mceMoreColors:hover {border:1px solid #0A246A}
+.o2k7Skin .mceColorPreview {margin-left:2px; width:16px; height:4px; overflow:hidden; background:#9a9b9a;overflow:hidden}
+.o2k7Skin .mce_forecolor span.mceAction, .o2k7Skin .mce_backcolor span.mceAction {height:15px;overflow:hidden}
+
+/* Menu */
+.o2k7Skin .mceMenu {position:absolute; left:0; top:0; z-index:1000; border:1px solid #ABC6DD}
+.o2k7Skin .mceNoIcons span.mceIcon {width:0;}
+.o2k7Skin .mceNoIcons a .mceText {padding-left:10px}
+.o2k7Skin .mceMenu table {background:#FFF}
+.o2k7Skin .mceMenu a, .o2k7Skin .mceMenu span, .o2k7Skin .mceMenu {display:block}
+.o2k7Skin .mceMenu td {height:20px}
+.o2k7Skin .mceMenu a {position:relative;padding:3px 0 4px 0}
+.o2k7Skin .mceMenu .mceText {position:relative; display:block; font-family:Tahoma,Verdana,Arial,Helvetica; color:#000; cursor:default; margin:0; padding:0 25px 0 25px; display:block}
+.o2k7Skin .mceMenu span.mceText, .o2k7Skin .mceMenu .mcePreview {font-size:11px}
+.o2k7Skin .mceMenu pre.mceText {font-family:Monospace}
+.o2k7Skin .mceMenu .mceIcon {position:absolute; top:0; left:0; width:22px;}
+.o2k7Skin .mceMenu .mceMenuItemEnabled a:hover, .o2k7Skin .mceMenu .mceMenuItemActive {background-color:#dbecf3}
+.o2k7Skin td.mceMenuItemSeparator {background:#DDD; height:1px}
+.o2k7Skin .mceMenuItemTitle a {border:0; background:#E5EFFD; border-bottom:1px solid #ABC6DD}
+.o2k7Skin .mceMenuItemTitle span.mceText {color:#000; font-weight:bold; padding-left:4px}
+.o2k7Skin .mceMenuItemDisabled .mceText {color:#888}
+.o2k7Skin .mceMenuItemSelected .mceIcon {background:url(../default/img/menu_check.gif)}
+.o2k7Skin .mceNoIcons .mceMenuItemSelected a {background:url(../default/img/menu_arrow.gif) no-repeat -6px center}
+.o2k7Skin .mceMenu span.mceMenuLine {display:none}
+.o2k7Skin .mceMenuItemSub a {background:url(../default/img/menu_arrow.gif) no-repeat top right;}
+
+/* Progress,Resize */
+.o2k7Skin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=50); background:#FFF}
+.o2k7Skin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(../default/img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px}
+
+/* Formats */
+.o2k7Skin .mce_formatPreview a {font-size:10px}
+.o2k7Skin .mce_p span.mceText {}
+.o2k7Skin .mce_address span.mceText {font-style:italic}
+.o2k7Skin .mce_pre span.mceText {font-family:monospace}
+.o2k7Skin .mce_h1 span.mceText {font-weight:bolder; font-size: 2em}
+.o2k7Skin .mce_h2 span.mceText {font-weight:bolder; font-size: 1.5em}
+.o2k7Skin .mce_h3 span.mceText {font-weight:bolder; font-size: 1.17em}
+.o2k7Skin .mce_h4 span.mceText {font-weight:bolder; font-size: 1em}
+.o2k7Skin .mce_h5 span.mceText {font-weight:bolder; font-size: .83em}
+.o2k7Skin .mce_h6 span.mceText {font-weight:bolder; font-size: .75em}
+
+/* Theme */
+.o2k7Skin span.mce_bold {background-position:0 0}
+.o2k7Skin span.mce_italic {background-position:-60px 0}
+.o2k7Skin span.mce_underline {background-position:-140px 0}
+.o2k7Skin span.mce_strikethrough {background-position:-120px 0}
+.o2k7Skin span.mce_undo {background-position:-160px 0}
+.o2k7Skin span.mce_redo {background-position:-100px 0}
+.o2k7Skin span.mce_cleanup {background-position:-40px 0}
+.o2k7Skin span.mce_bullist {background-position:-20px 0}
+.o2k7Skin span.mce_numlist {background-position:-80px 0}
+.o2k7Skin span.mce_justifyleft {background-position:-460px 0}
+.o2k7Skin span.mce_justifyright {background-position:-480px 0}
+.o2k7Skin span.mce_justifycenter {background-position:-420px 0}
+.o2k7Skin span.mce_justifyfull {background-position:-440px 0}
+.o2k7Skin span.mce_anchor {background-position:-200px 0}
+.o2k7Skin span.mce_indent {background-position:-400px 0}
+.o2k7Skin span.mce_outdent {background-position:-540px 0}
+.o2k7Skin span.mce_link {background-position:-500px 0}
+.o2k7Skin span.mce_unlink {background-position:-640px 0}
+.o2k7Skin span.mce_sub {background-position:-600px 0}
+.o2k7Skin span.mce_sup {background-position:-620px 0}
+.o2k7Skin span.mce_removeformat {background-position:-580px 0}
+.o2k7Skin span.mce_newdocument {background-position:-520px 0}
+.o2k7Skin span.mce_image {background-position:-380px 0}
+.o2k7Skin span.mce_help {background-position:-340px 0}
+.o2k7Skin span.mce_code {background-position:-260px 0}
+.o2k7Skin span.mce_hr {background-position:-360px 0}
+.o2k7Skin span.mce_visualaid {background-position:-660px 0}
+.o2k7Skin span.mce_charmap {background-position:-240px 0}
+.o2k7Skin span.mce_paste {background-position:-560px 0}
+.o2k7Skin span.mce_copy {background-position:-700px 0}
+.o2k7Skin span.mce_cut {background-position:-680px 0}
+.o2k7Skin span.mce_blockquote {background-position:-220px 0}
+.o2k7Skin .mce_forecolor span.mceAction {background-position:-720px 0}
+.o2k7Skin .mce_backcolor span.mceAction {background-position:-760px 0}
+.o2k7Skin span.mce_forecolorpicker {background-position:-720px 0}
+.o2k7Skin span.mce_backcolorpicker {background-position:-760px 0}
+
+/* Plugins */
+.o2k7Skin span.mce_advhr {background-position:-0px -20px}
+.o2k7Skin span.mce_ltr {background-position:-20px -20px}
+.o2k7Skin span.mce_rtl {background-position:-40px -20px}
+.o2k7Skin span.mce_emotions {background-position:-60px -20px}
+.o2k7Skin span.mce_fullpage {background-position:-80px -20px}
+.o2k7Skin span.mce_fullscreen {background-position:-100px -20px}
+.o2k7Skin span.mce_iespell {background-position:-120px -20px}
+.o2k7Skin span.mce_insertdate {background-position:-140px -20px}
+.o2k7Skin span.mce_inserttime {background-position:-160px -20px}
+.o2k7Skin span.mce_absolute {background-position:-180px -20px}
+.o2k7Skin span.mce_backward {background-position:-200px -20px}
+.o2k7Skin span.mce_forward {background-position:-220px -20px}
+.o2k7Skin span.mce_insert_layer {background-position:-240px -20px}
+.o2k7Skin span.mce_insertlayer {background-position:-260px -20px}
+.o2k7Skin span.mce_movebackward {background-position:-280px -20px}
+.o2k7Skin span.mce_moveforward {background-position:-300px -20px}
+.o2k7Skin span.mce_media {background-position:-320px -20px}
+.o2k7Skin span.mce_nonbreaking {background-position:-340px -20px}
+.o2k7Skin span.mce_pastetext {background-position:-360px -20px}
+.o2k7Skin span.mce_pasteword {background-position:-380px -20px}
+.o2k7Skin span.mce_selectall {background-position:-400px -20px}
+.o2k7Skin span.mce_preview {background-position:-420px -20px}
+.o2k7Skin span.mce_print {background-position:-440px -20px}
+.o2k7Skin span.mce_cancel {background-position:-460px -20px}
+.o2k7Skin span.mce_save {background-position:-480px -20px}
+.o2k7Skin span.mce_replace {background-position:-500px -20px}
+.o2k7Skin span.mce_search {background-position:-520px -20px}
+.o2k7Skin span.mce_styleprops {background-position:-560px -20px}
+.o2k7Skin span.mce_table {background-position:-580px -20px}
+.o2k7Skin span.mce_cell_props {background-position:-600px -20px}
+.o2k7Skin span.mce_delete_table {background-position:-620px -20px}
+.o2k7Skin span.mce_delete_col {background-position:-640px -20px}
+.o2k7Skin span.mce_delete_row {background-position:-660px -20px}
+.o2k7Skin span.mce_col_after {background-position:-680px -20px}
+.o2k7Skin span.mce_col_before {background-position:-700px -20px}
+.o2k7Skin span.mce_row_after {background-position:-720px -20px}
+.o2k7Skin span.mce_row_before {background-position:-740px -20px}
+.o2k7Skin span.mce_merge_cells {background-position:-760px -20px}
+.o2k7Skin span.mce_table_props {background-position:-980px -20px}
+.o2k7Skin span.mce_row_props {background-position:-780px -20px}
+.o2k7Skin span.mce_split_cells {background-position:-800px -20px}
+.o2k7Skin span.mce_template {background-position:-820px -20px}
+.o2k7Skin span.mce_visualchars {background-position:-840px -20px}
+.o2k7Skin span.mce_abbr {background-position:-860px -20px}
+.o2k7Skin span.mce_acronym {background-position:-880px -20px}
+.o2k7Skin span.mce_attribs {background-position:-900px -20px}
+.o2k7Skin span.mce_cite {background-position:-920px -20px}
+.o2k7Skin span.mce_del {background-position:-940px -20px}
+.o2k7Skin span.mce_ins {background-position:-960px -20px}
+.o2k7Skin span.mce_pagebreak {background-position:0 -40px}
+.o2k7Skin span.mce_restoredraft {background-position:-20px -40px}
+.o2k7Skin span.mce_spellchecker {background-position:-540px -20px}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_black.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_black.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_black.css	(revision 17487)
@@ -0,0 +1,8 @@
+/* Black */
+.o2k7SkinBlack .mceToolbar .mceToolbarStart span, .o2k7SkinBlack .mceToolbar .mceToolbarEnd span, .o2k7SkinBlack .mceButton, .o2k7SkinBlack .mceSplitButton, .o2k7SkinBlack .mceSeparator, .o2k7SkinBlack .mceSplitButton a.mceOpen, .o2k7SkinBlack .mceListBox a.mceOpen {background-image:url(img/button_bg_black.png)}
+.o2k7SkinBlack table, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack .mceMenuItemTitle span.mceText, .o2k7SkinBlack .mceStatusbar div, .o2k7SkinBlack .mceStatusbar span, .o2k7SkinBlack .mceStatusbar a {background:#535353; color:#FFF}
+.o2k7SkinBlack table.mceListBoxEnabled .mceText, o2k7SkinBlack .mceListBox .mceText {background:#FFF; border:1px solid #CBCFD4; border-bottom-color:#989FA9; border-right:0}
+.o2k7SkinBlack table.mceListBoxEnabled:hover .mceText, .o2k7SkinBlack .mceListBoxHover .mceText, .o2k7SkinBlack .mceListBoxSelected .mceText {background:#FFF; border:1px solid #FFBD69; border-right:0}
+.o2k7SkinBlack .mceExternalToolbar, .o2k7SkinBlack .mceListBox .mceText, .o2k7SkinBlack div.mceMenu, .o2k7SkinBlack table.mceLayout, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack table.mceLayout tr.mceFirst td, .o2k7SkinBlack table.mceLayout, .o2k7SkinBlack .mceMenuItemTitle a, .o2k7SkinBlack table.mceLayout tr.mceLast td, .o2k7SkinBlack .mceIframeContainer {border-color: #535353;}
+.o2k7SkinBlack table.mceSplitButtonEnabled:hover a.mceAction, .o2k7SkinBlack .mceSplitButtonHover a.mceAction, .o2k7SkinBlack .mceSplitButtonSelected {background-image:url(img/button_bg_black.png)}
+.o2k7SkinBlack .mceMenu .mceMenuItemEnabled a:hover, .o2k7SkinBlack .mceMenu .mceMenuItemActive {background-color:#FFE7A1}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_silver.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_silver.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/o2k7/ui_silver.css	(revision 17487)
@@ -0,0 +1,5 @@
+/* Silver */
+.o2k7SkinSilver .mceToolbar .mceToolbarStart span, .o2k7SkinSilver .mceButton, .o2k7SkinSilver .mceSplitButton, .o2k7SkinSilver .mceSeparator, .o2k7SkinSilver .mceSplitButton a.mceOpen, .o2k7SkinSilver .mceListBox a.mceOpen {background-image:url(img/button_bg_silver.png)}
+.o2k7SkinSilver table, .o2k7SkinSilver .mceMenuItemTitle a {background:#eee}
+.o2k7SkinSilver .mceListBox .mceText {background:#FFF}
+.o2k7SkinSilver .mceExternalToolbar, .o2k7SkinSilver .mceListBox .mceText, .o2k7SkinSilver div.mceMenu, .o2k7SkinSilver table.mceLayout, .o2k7SkinSilver .mceMenuItemTitle a, .o2k7SkinSilver table.mceLayout tr.mceFirst td, .o2k7SkinSilver table.mceLayout, .o2k7SkinSilver .mceMenuItemTitle a, .o2k7SkinSilver table.mceLayout tr.mceLast td, .o2k7SkinSilver .mceIframeContainer {border-color: #bbb}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css	(revision 17487)
@@ -0,0 +1,85 @@
+/* default styles */
+body {background:#FFF;}
+body.mceForceColors {background:#FFF; color:#000;}
+h1 {font-size: 2em}
+h2 {font-size: 1.5em}
+h3 {font-size: 1.17em}
+h4 {font-size: 1em}
+h5 {font-size: .83em}
+h6 {font-size: .75em}
+.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;}
+a.mceItemAnchor {width:12px; line-height:6px; overflow:hidden; padding-left:12px; background:url(../default/img/items.gif) no-repeat bottom left;}
+img.mceItemAnchor {width:12px; height:12px; background:url(../default/img/items.gif) no-repeat;}
+img {border:0;}
+table {cursor:default}
+table td, table th {cursor:text}
+ins {border-bottom:1px solid green; text-decoration: none; color:green}
+del {color:red; text-decoration:line-through}
+cite {border-bottom:1px dashed blue}
+acronym {border-bottom:1px dotted #CCC; cursor:help}
+abbr, html\:abbr {border-bottom:1px dashed #CCC; cursor:help}
+
+/* WordPress styles */
+html {
+	background-color: #fff;
+}
+
+.aligncenter,
+dl.aligncenter {
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+}
+
+.alignleft {
+	float: left;
+}
+
+.alignright {
+	float: right;
+}
+
+.wp-caption {
+	border: 1px solid #ddd;
+	text-align: center;
+	background-color: #f3f3f3;
+	padding-top: 4px;
+	margin: 10px;
+	-moz-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+}
+
+.wp-caption img {
+	margin: 0;
+	padding: 0;
+	border: 0 none;
+}
+
+.wp-caption-dd {
+	font-size: 11px;
+	line-height: 17px;
+	padding: 0 4px 5px;
+	margin: 0;
+}
+
+body.mceContentBody {
+	font: 13px/19px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
+	padding: 0.6em;
+	margin: 0;
+}
+
+pre {
+	font: 12px/18px Consolas, Monaco, "Courier New", Courier, monospace;
+}
+
+td {
+	color: #000;
+	font-size: 11px;
+	margin: 8px;
+}
+
+.mceIEcenter {
+	text-align: center;
+}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css	(revision 17487)
@@ -0,0 +1,117 @@
+/* Generic */
+body {
+font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;
+background:#f1f1f1;
+padding:0;
+margin:8px 8px 0 8px;
+}
+
+html {background:#f1f1f1;}
+td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
+textarea {resize:none;outline:none;}
+a:link, a:visited {color:black;}
+a:hover {color:#2B6FB6;}
+.nowrap {white-space: nowrap}
+
+/* Forms */
+fieldset {margin:0; padding:4px; border:1px solid #dfdfdf; font-family:Verdana, Arial; font-size:10px;}
+legend {color:#2B6FB6; font-weight:bold;}
+label.msg {display:none;}
+label.invalid {color:#EE0000; display:inline;}
+input.invalid {border:1px solid #EE0000;}
+input {background:#FFF; border:1px solid #dfdfdf;}
+input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
+input, select, textarea {border:1px solid #dfdfdf;}
+input.radio {border:1px none #000000; background:transparent; vertical-align:middle;}
+input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;}
+.input_noborder {border:0;}
+
+/* Buttons */
+#insert, #cancel, #apply, .mceActionPanel .button, input.mceButton, .updateButton {
+	border: 1px solid #bbb; 
+	margin:0; 
+	padding:0 0 1px;
+	font-weight:bold;
+	font-size: 11px;
+	width:94px; 
+	height:24px;
+	background:url(img/fade-butt.png) 0 0;
+	color:#000;
+	cursor:pointer;
+	-moz-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	border-radius: 3px;
+}
+#insert:hover, #cancel:hover, input.mceButton:hover, .updateButton:hover,
+#insert:focus, #cancel:focus, input.mceButton:focus, .updateButton:focus {
+	border: 1px solid #555;
+}
+
+/* Browse */
+a.browse span {display:block; width:20px; height:18px; background:url(../../img/icons.gif) -860px 0; border:1px solid #FFF; margin-left:1px;}
+.mceOldBoxModel a.browse span {width:22px; height:20px;}
+a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;}
+a.browse span.disabled {border:1px solid white; -moz-opacity:0.3; opacity:0.3; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);}
+a.browse:hover span.disabled {border:1px solid white; background-color:transparent;}
+a.pickcolor span {display:block; width:20px; height:16px; background:url(../../img/icons.gif) -840px 0; margin-left:2px;}
+.mceOldBoxModel a.pickcolor span {width:21px; height:17px;}
+a.pickcolor:hover span {background-color:#B2BBD0;}
+a.pickcolor, a.browse {text-decoration:none}
+
+/* Charmap */
+table.charmap {border:1px solid #AAA; text-align:center}
+td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;}
+#charmap a {display:block; color:#000; text-decoration:none; border:0}
+#charmap a:hover {background:#CCC;color:#2B6FB6}
+#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center}
+#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center}
+#charmap #charmapView {background-color:#fff;}
+
+/* Source */
+.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;}
+.mceActionPanel {margin-top:5px;}
+
+/* Tabs classes */
+.tabs {width:100%; height:18px; line-height:normal; background:url(img/tabs.gif) repeat-x 0 -72px;}
+.tabs ul {margin:0; padding:0; list-style:none;}
+.tabs li {float:left; background:url(img/tabs.gif) no-repeat 0 0; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;}
+.tabs li.current {background:url(img/tabs.gif) no-repeat 0 -18px; margin-right:2px;}
+.tabs span {float:left; display:block; background:url(img/tabs.gif) no-repeat right -36px; padding:0px 10px 0 0;}
+.tabs .current span {background:url(img/tabs.gif) no-repeat right -54px;}
+.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;}
+.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;}
+
+/* Panels */
+.panel_wrapper div.panel {display:none;}
+.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;}
+.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;}
+
+/* Columns */
+.column {float:left;}
+.properties {width:100%;}
+.properties .column1 {}
+.properties .column2 {text-align:left;}
+
+/* Titles */
+h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;}
+h3 {font-size:14px;}
+.title {font-size:12px; font-weight:bold; color:#2B6FB6;}
+
+/* Dialog specific */
+#link .panel_wrapper, #link div.current {height:125px;}
+#image .panel_wrapper, #image div.current {height:200px;}
+#plugintable thead {font-weight:bold; background:#DDD;}
+#plugintable, #about #plugintable td {border:1px solid #919B9C;}
+#plugintable {width:96%; margin-top:10px;}
+#pluginscontainer {height:290px; overflow:auto;}
+#colorpicker #preview {float:right; width:50px; height:14px;line-height:1px; border:1px solid black; margin-left:5px;}
+#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;}
+#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;}
+#colorpicker #light div {overflow:hidden;}
+#colorpicker #previewblock {float:right; padding-left:10px; height:20px;}
+#colorpicker .panel_wrapper div.current {height:175px;}
+#colorpicker #namedcolors {width:150px;}
+#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;}
+#colorpicker #colornamecontainer {margin-top:5px;}
+#colorpicker #picker_panel fieldset {margin:auto;width:325px;}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css	(revision 17487)
@@ -0,0 +1,382 @@
+/* Reset */
+.wp_themeSkin table, .wp_themeSkin tbody, .wp_themeSkin a, .wp_themeSkin img, .wp_themeSkin tr, .wp_themeSkin div, .wp_themeSkin td, .wp_themeSkin iframe, .wp_themeSkin span, .wp_themeSkin *, .wp_themeSkin .mceText {
+border:0; margin:0; padding:0; white-space:nowrap; text-decoration:none; font-weight:normal; cursor:default; vertical-align:baseline; width:auto; border-collapse:separate;
+}
+.wp_themeSkin a:hover, .wp_themeSkin a:link, .wp_themeSkin a:visited, .wp_themeSkin a:active {text-decoration:none; font-weight:normal; cursor:default;}
+.wp_themeSkin table td {vertical-align:middle}
+
+/* Containers */
+.wp_themeSkin table {}
+.wp_themeSkin iframe {display:block;}
+.wp_themeSkin .mceToolbar {padding: 2px;}
+
+/* External */
+.wp_themeSkin .mceExternalToolbar {position:absolute; border-bottom:0; display:none}
+.wp_themeSkin .mceExternalToolbar td.mceToolbar {padding-right:13px;}
+.wp_themeSkin .mceExternalClose {position:absolute; top:3px; right:3px; width:7px; height:7px; background:url(../../img/icons.gif) -820px 0}
+
+/* Layout */
+.wp_themeSkin table.mceToolbar, .wp_themeSkin tr.mceFirst .mceToolbar tr td, .wp_themeSkin tr.mceLast .mceToolbar tr td {border:0; margin:0; padding:0}
+.wp_themeSkin table.mceLayout {border:0;}
+.wp_themeSkin .mceIframeContainer {}
+.wp_themeSkin .mceStatusbar {
+	display: block;
+	font-family: 'MS Sans Serif',sans-serif,Verdana,Arial;
+	font-size: 9pt;
+	line-height: 16px;
+	overflow: visible;
+	height: 20px;
+	border-top-width: 1px;
+	border-top-style: solid;
+}
+.wp_themeSkin .mceStatusbar div {float:left; padding:2px;}
+.wp_themeSkin .mceStatusbar a.mceResize {
+	display: block;
+	float: right;
+	background: url(../../img/icons.gif) -800px 0;
+	width: 20px;
+	height: 20px;
+	cursor: se-resize
+}
+.wp_themeSkin .mceStatusbar a:hover {text-decoration:underline}
+.wp_themeSkin table.mceToolbar {margin: 0 2px 2px;}
+.wp_themeSkin #content_toolbar1 {margin-top: 2px;}
+.wp_themeSkin .mceToolbar .mceToolbarEndListBox span {display:none}
+.wp_themeSkin span.mceIcon, .wp_themeSkin img.mceIcon {display:block; width:20px; height:20px}
+.wp_themeSkin .mceIcon {background:url(../../img/icons.gif) no-repeat 20px 20px}
+
+/* Button */
+.wp_themeSkin .mceButton {
+	display:block; 
+	width: 20px; 
+	height: 20px; 
+	cursor: default; 
+	padding: 1px 2px; 
+	margin: 1px; 
+	background-image: url(img/butt2.png);
+	background-position: left top;
+	background-repeat: repeat-x;
+	-moz-border-radius: 3px;
+	-webkit-border-radius: 3px;
+	-khtml-border-radius: 3px;
+	border-radius: 3px;
+}
+.wp_themeSkin a.mceButton span, .wp_themeSkin a.mceButton img {}
+.wp_themeSkin .mceOldBoxModel a.mceButton span, .wp_themeSkin .mceOldBoxModel a.mceButton img {margin:0 0 0 1px}
+.wp_themeSkin a.mceButtonEnabled:hover {
+	background-position:0 -10px;
+}
+.wp_themeSkin a.mceButtonActive, .wp_themeSkin a.mceButtonSelected {
+	background-image: inherit;
+}
+.wp_themeSkin .mceButtonDisabled .mceIcon {opacity:0.3; filter:alpha(opacity=30);}
+.wp_themeSkin .mceButtonDisabled {}
+
+/* Separator */
+.wp_themeSkin .mceSeparator { 
+	height: 24px; 
+	width: 1px;
+	display: block;
+	background: transparent;
+	overflow: hidden; 
+	margin: 0 2px; 
+}
+
+/* ListBox */
+.wp_themeSkin .mceListBox, .wp_themeSkin .mceListBox a {display:block}
+.wp_themeSkin .mceListBox .mceText {
+	padding: 1px 2px 1px 5px;
+	text-align:left; 
+	text-decoration: none !important;
+	width:70px;  
+	background-image: url(img/butt2.png);
+	background-position: left top;
+	background-repeat: repeat-x;
+	font-family: Tahoma,Verdana,Arial,Helvetica; 
+	font-size: 11px; 
+	height: 20px; 
+	line-height: 20px; 
+	overflow: hidden;
+}
+.wp_themeSkin .mceListBox {
+	margin: 1px;
+	direction: ltr;
+}
+.wp_themeSkin .mceListBox .mceOpen {
+	width: 14px;
+	height: 20px; 
+	border-collapse: separate;
+	background-image: url(img/butt2.png);
+	background-position: left top;
+	background-repeat: repeat-x;
+	padding: 1px;
+	border-left: 0 none !important;
+}
+.wp_themeSkin .mceListBox .mceOpen span {
+	display: block;
+	width:14px;
+	height:20px;
+	background-image: url(img/down_arrow.gif);
+	background-position: 2px 1px;
+	background-repeat: no-repeat;
+}
+.wp_themeSkin table.mceListBoxEnabled:hover .mceText, 
+.wp_themeSkin .mceListBoxHover .mceText, 
+.wp_themeSkin .mceListBoxSelected .mceText,
+.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, 
+.wp_themeSkin .mceListBoxHover .mceOpen, 
+.wp_themeSkin .mceListBoxSelected .mceOpen {
+	background-image: none;
+}
+.wp_themeSkin .mceListBoxDisabled .mceText {color:gray}
+.wp_themeSkin .mceListBoxMenu {overflow:auto; overflow-x:hidden}
+.wp_themeSkin .mceOldBoxModel .mceListBox .mceText {height:22px}
+.wp_themeSkin select.mceListBox {font-family:Tahoma,Verdana,Arial,Helvetica; font-size:12px;}
+
+/* SplitButton */
+.wp_themeSkin .mceSplitButton a, .wp_themeSkin .mceSplitButton span {display:block; height:20px}
+.wp_themeSkin .mceSplitButton { 
+	display:block;
+	margin: 1px;
+	direction: ltr;
+}
+.wp_themeSkin table.mceSplitButton td {
+	padding: 2px;
+	background-image: url(img/butt2.png);
+	background-position: left top;
+	background-repeat: repeat-x;
+}
+.wp_themeSkin .mceSplitButton a.mceAction {
+	height:20px;
+	width:20px;
+	padding: 1px 2px;
+}
+.wp_themeSkin .mceSplitButton span.mceAction {
+	background-image: url(../../img/icons.gif);
+	background-repeat: no-repeat;
+	background-color: transparent;
+	width:20px; 
+}
+.wp_themeSkin .mceSplitButton a.mceOpen {
+	width:10px;
+	height:20px;
+	background-image: url(img/down_arrow.gif);
+	background-position: 1px 2px;
+	background-repeat: no-repeat;
+	padding: 1px;
+	border-left: 0 none !important;
+}
+.wp_themeSkin .mceSplitButton span.mceOpen {display:none}
+.wp_themeSkin .mceSplitButtonDisabled .mceAction {
+	opacity:0.3; filter:alpha(opacity=30);
+}
+.wp_themeSkin .mceListBox a.mceText, .wp_themeSkin .mceSplitButton a.mceAction {
+	-moz-border-radius-bottomleft: 3px;
+	-webkit-border-bottom-left-radius: 3px;
+	-khtml-border-bottom-left-radius: 3px;
+	border-bottom-left-radius: 3px;
+	-moz-border-radius-topleft: 3px;
+	-webkit-border-top-left-radius: 3px;
+	-khtml-border-top-left-radius: 3px;
+	border-top-left-radius: 3px;
+}
+.wp_themeSkin .mceSplitButton a.mceOpen, .wp_themeSkin .mceListBox a.mceOpen {
+	-moz-border-radius-bottomright: 3px;
+	-webkit-border-bottom-right-radius: 3px;
+	-khtml-border-bottom-right-radius: 3px;
+	border-bottom-right-radius: 3px;
+	-moz-border-radius-topright: 3px;
+	-webkit-border-top-right-radius: 3px;
+	-khtml-border-top-right-radius: 3px;
+	border-top-right-radius: 3px;
+}
+
+/* ColorSplitButton */
+.wp_themeSkin div.mceColorSplitMenu table {}
+.wp_themeSkin .mceColorSplitMenu td {padding:2px}
+.wp_themeSkin .mceColorSplitMenu a {display:block; width:9px; height:9px; overflow:hidden;}
+.wp_themeSkin .mceColorSplitMenu td.mceMoreColors {padding:1px 3px 1px 1px}
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors {width:100%; height:auto; text-align:center; font-family:Tahoma,Verdana,Arial,Helvetica; font-size:11px; line-height:20px;}
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {}
+.wp_themeSkin a.mceMoreColors:hover {}
+.wp_themeSkin .mceColorPreview {margin: -4px 0 0 2px; width:16px; height:4px; overflow:hidden}
+
+/* Menu */
+.wp_themeSkin .mceMenu {position:absolute; left:0; top:0; z-index:1000;}
+.wp_themeSkin .mceNoIcons span.mceIcon {width:0;}
+.wp_themeSkin .mceNoIcons a .mceText {padding-left:10px}
+.wp_themeSkin .mceMenu table {}
+.wp_themeSkin .mceMenu a, .wp_themeSkin .mceMenu span, .wp_themeSkin .mceMenu {display:block}
+.wp_themeSkin .mceMenu td {height:20px;overflow:hidden;}
+.wp_themeSkin .mceMenu a {
+	position:relative;
+	padding:3px 0 4px 0;
+	text-decoration: none !important;
+}
+.wp_themeSkin .mceMenu .mceText {
+	position:relative; 
+	display:block; 
+	font-family:Tahoma,Verdana,Arial,Helvetica; 
+	cursor:default; 
+	margin:0; 
+	padding:0 25px;
+}
+.wp_themeSkin .mceMenu span.mceText, .wp_themeSkin .mceMenu .mcePreview {font-size:11px}
+.wp_themeSkin .mceMenu pre.mceText {font-family:Monospace}
+.wp_themeSkin .mceMenu .mceIcon {position:absolute; top:0; left:0; width:22px;}
+.wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover, 
+.wp_themeSkin .mceMenu .mceMenuItemActive {}
+.wp_themeSkin td.mceMenuItemSeparator {height:1px}
+.wp_themeSkin .mceMenuItemTitle a {
+	border-top: 0;
+	border-right: 0;
+	border-left: 0;
+	border-bottom-style: solid;
+	border-bottom-width: 1px;
+	text-decoration: none !important;
+}
+.wp_themeSkin .mceMenuItemTitle span.mceText {font-weight:bold; padding-left:4px}
+.wp_themeSkin .mceMenuItemDisabled .mceText {}
+.wp_themeSkin .mceMenuItemSelected .mceIcon {background:url(../default/img/menu_check.gif)}
+.wp_themeSkin .mceNoIcons .mceMenuItemSelected a {background:url(../default/img/menu_arrow.gif) no-repeat -6px center}
+.wp_themeSkin .mceMenu span.mceMenuLine {display:none}
+.wp_themeSkin .mceMenuItemSub a {background:url(../default/img/menu_arrow.gif) no-repeat top right;}
+
+/* Progress,Resize */
+.wp_themeSkin .mceBlocker {position:absolute; left:0; top:0; z-index:1000; opacity:0.5; filter:alpha(opacity=50); background:#FFF}
+.wp_themeSkin .mceProgress {position:absolute; left:0; top:0; z-index:1001; background:url(../default/img/progress.gif) no-repeat; width:32px; height:32px; margin:-16px 0 0 -16px}
+.wp_themeSkin .mcePlaceHolder {border:1px dotted gray}
+
+/* Formats */
+.wp_themeSkin .mce_formatPreview a {font-size:10px}
+.wp_themeSkin .mce_p span.mceText {}
+.wp_themeSkin .mce_address span.mceText {font-style:italic}
+.wp_themeSkin .mce_pre span.mceText {font-family:monospace}
+.wp_themeSkin .mce_h1 span.mceText {font-weight:bolder; font-size: 2em}
+.wp_themeSkin .mce_h2 span.mceText {font-weight:bolder; font-size: 1.5em}
+.wp_themeSkin .mce_h3 span.mceText {font-weight:bolder; font-size: 1.17em}
+.wp_themeSkin .mce_h4 span.mceText {font-weight:bolder; font-size: 1em}
+.wp_themeSkin .mce_h5 span.mceText {font-weight:bolder; font-size: .83em}
+.wp_themeSkin .mce_h6 span.mceText {font-weight:bolder; font-size: .75em}
+
+/* Theme */
+.wp_themeSkin span.mce_bold {background-position:0 0}
+.wp_themeSkin span.mce_italic {background-position:-60px 0}
+.wp_themeSkin span.mce_underline {background-position:-140px 0}
+.wp_themeSkin span.mce_strikethrough {background-position:-120px 0}
+.wp_themeSkin span.mce_undo {background-position:-160px 0}
+.wp_themeSkin span.mce_redo {background-position:-100px 0}
+.wp_themeSkin span.mce_cleanup {background-position:-40px 0}
+.wp_themeSkin span.mce_bullist {background-position:-20px 0}
+.wp_themeSkin span.mce_numlist {background-position:-80px 0}
+.wp_themeSkin span.mce_justifyleft {background-position:-460px 0}
+.wp_themeSkin span.mce_justifyright {background-position:-480px 0}
+.wp_themeSkin span.mce_justifycenter {background-position:-420px 0}
+.wp_themeSkin span.mce_justifyfull {background-position:-440px 0}
+.wp_themeSkin span.mce_anchor {background-position:-200px 0}
+.wp_themeSkin span.mce_indent {background-position:-400px 0}
+.wp_themeSkin span.mce_outdent {background-position:-540px 0}
+.wp_themeSkin span.mce_link {background-position:-500px 0}
+.wp_themeSkin span.mce_unlink {background-position:-640px 0}
+.wp_themeSkin span.mce_sub {background-position:-600px 0}
+.wp_themeSkin span.mce_sup {background-position:-620px 0}
+.wp_themeSkin span.mce_removeformat {background-position:-580px 0}
+.wp_themeSkin span.mce_newdocument {background-position:-520px 0}
+.wp_themeSkin span.mce_image {background-position:-380px 0}
+.wp_themeSkin span.mce_help {background-position:-340px 0}
+.wp_themeSkin span.mce_code {background-position:-260px 0}
+.wp_themeSkin span.mce_hr {background-position:-360px 0}
+.wp_themeSkin span.mce_visualaid {background-position:-660px 0}
+.wp_themeSkin span.mce_charmap {background-position:-240px 0}
+.wp_themeSkin span.mce_paste {background-position:-560px 0}
+.wp_themeSkin span.mce_copy {background-position:-700px 0}
+.wp_themeSkin span.mce_cut {background-position:-680px 0}
+.wp_themeSkin span.mce_blockquote {background-position:-220px 0}
+.wp_themeSkin .mce_forecolor span.mceAction {background-position:-720px 0}
+.wp_themeSkin .mce_backcolor span.mceAction {background-position:-760px 0}
+.wp_themeSkin .mce_forecolorpicker {background-position:-720px 0}
+.wp_themeSkin .mce_backcolorpicker {background-position:-760px 0}
+
+/* Plugins */
+.wp_themeSkin span.mce_advhr {background-position:-0px -20px}
+.wp_themeSkin span.mce_ltr {background-position:-20px -20px}
+.wp_themeSkin span.mce_rtl {background-position:-40px -20px}
+.wp_themeSkin span.mce_emotions {background-position:-60px -20px}
+.wp_themeSkin span.mce_fullpage {background-position:-80px -20px}
+.wp_themeSkin span.mce_fullscreen {background-position:-100px -20px}
+.wp_themeSkin span.mce_iespell {background-position:-120px -20px}
+.wp_themeSkin span.mce_insertdate {background-position:-140px -20px}
+.wp_themeSkin span.mce_inserttime {background-position:-160px -20px}
+.wp_themeSkin span.mce_absolute {background-position:-180px -20px}
+.wp_themeSkin span.mce_backward {background-position:-200px -20px}
+.wp_themeSkin span.mce_forward {background-position:-220px -20px}
+.wp_themeSkin span.mce_insert_layer {background-position:-240px -20px}
+.wp_themeSkin span.mce_insertlayer {background-position:-260px -20px}
+.wp_themeSkin span.mce_movebackward {background-position:-280px -20px}
+.wp_themeSkin span.mce_moveforward {background-position:-300px -20px}
+.wp_themeSkin span.mce_media {background-position:-320px -20px}
+.wp_themeSkin span.mce_nonbreaking {background-position:-340px -20px}
+.wp_themeSkin span.mce_pastetext {background-position:-360px -20px}
+.wp_themeSkin span.mce_pasteword {background-position:-380px -20px}
+.wp_themeSkin span.mce_selectall {background-position:-400px -20px}
+.wp_themeSkin span.mce_preview {background-position:-420px -20px}
+.wp_themeSkin span.mce_print {background-position:-440px -20px}
+.wp_themeSkin span.mce_cancel {background-position:-460px -20px}
+.wp_themeSkin span.mce_save {background-position:-480px -20px}
+.wp_themeSkin span.mce_replace {background-position:-500px -20px}
+.wp_themeSkin span.mce_search {background-position:-520px -20px}
+.wp_themeSkin span.mce_styleprops {background-position:-560px -20px}
+.wp_themeSkin span.mce_table {background-position:-580px -20px}
+.wp_themeSkin span.mce_cell_props {background-position:-600px -20px}
+.wp_themeSkin span.mce_delete_table {background-position:-620px -20px}
+.wp_themeSkin span.mce_delete_col {background-position:-640px -20px}
+.wp_themeSkin span.mce_delete_row {background-position:-660px -20px}
+.wp_themeSkin span.mce_col_after {background-position:-680px -20px}
+.wp_themeSkin span.mce_col_before {background-position:-700px -20px}
+.wp_themeSkin span.mce_row_after {background-position:-720px -20px}
+.wp_themeSkin span.mce_row_before {background-position:-740px -20px}
+.wp_themeSkin span.mce_merge_cells {background-position:-760px -20px}
+.wp_themeSkin span.mce_table_props {background-position:-980px -20px}
+.wp_themeSkin span.mce_row_props {background-position:-780px -20px}
+.wp_themeSkin span.mce_split_cells {background-position:-800px -20px}
+.wp_themeSkin span.mce_template {background-position:-820px -20px}
+.wp_themeSkin span.mce_visualchars {background-position:-840px -20px}
+.wp_themeSkin span.mce_abbr {background-position:-860px -20px}
+.wp_themeSkin span.mce_acronym {background-position:-880px -20px}
+.wp_themeSkin span.mce_attribs {background-position:-900px -20px}
+.wp_themeSkin span.mce_cite {background-position:-920px -20px}
+.wp_themeSkin span.mce_del {background-position:-940px -20px}
+.wp_themeSkin span.mce_ins {background-position:-960px -20px}
+.wp_themeSkin span.mce_pagebreak {background-position:0 -40px}
+.wp_themeSkin span.mce_spellchecker {background-position:-540px -20px}
+
+/* border */
+.wp_themeSkin .mceExternalToolbar, 
+.wp_themeSkin .mceButton, 
+.wp_themeSkin a.mceButtonEnabled:hover, 
+.wp_themeSkin a.mceButtonActive, 
+.wp_themeSkin a.mceButtonSelected, 
+.wp_themeSkin .mceListBox .mceText, 
+.wp_themeSkin .mceListBox .mceOpen, 
+.wp_themeSkin table.mceListBoxEnabled:hover .mceText, 
+.wp_themeSkin .mceListBoxHover .mceText, 
+.wp_themeSkin .mceListBoxSelected .mceText, 
+.wp_themeSkin table.mceListBoxEnabled:hover .mceOpen, 
+.wp_themeSkin .mceListBoxHover .mceOpen, 
+.wp_themeSkin .mceListBoxSelected .mceOpen, 
+.wp_themeSkin select.mceListBox, 
+.wp_themeSkin .mceSplitButton a.mceAction, 
+.wp_themeSkin .mceSplitButton a.mceOpen,
+.wp_themeSkin .mceSplitButton a.mceOpen:hover, 
+.wp_themeSkin .mceSplitButtonSelected a.mceOpen, 
+.wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction, 
+.wp_themeSkin .mceSplitButton a.mceAction:hover, 
+.wp_themeSkin div.mceColorSplitMenu table, 
+.wp_themeSkin .mceColorSplitMenu a, 
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors, 
+.wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover, 
+.wp_themeSkin a.mceMoreColors:hover, 
+.wp_themeSkin .mceMenu {
+	border-style: solid; 
+	border-width: 1px;
+}
Index: /tags/3.1/wp-includes/js/tinymce/themes/advanced/source_editor.htm
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/themes/advanced/source_editor.htm	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/themes/advanced/source_editor.htm	(revision 17487)
@@ -0,0 +1,30 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>{#advanced_dlg.code_title}</title>
+	<script type="text/javascript" src="../../tiny_mce_popup.js?ver=3392"></script>
+	<script type="text/javascript" src="js/source_editor.js?ver=3392"></script>
+</head>
+<body onresize="resizeInputs();" style="display:none; overflow:hidden;">
+	<form name="source" onsubmit="saveContent();return false;" action="#">
+		<div style="float: left" class="title">{#advanced_dlg.code_title}</div>
+
+		<div id="wrapline" style="float: right">
+			<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{#advanced_dlg.code_wordwrap}</label>
+		</div>
+
+		<br style="clear: both" />
+
+		<textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,monospace; font-size: 12px;" dir="ltr" wrap="off" class="mceFocus"></textarea>
+
+		<div class="mceActionPanel">
+			<div style="float: left">
+				<input type="button" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
+			</div>
+
+			<div style="float: right">
+				<input type="submit" name="insert" value="{#update}" id="insert" />
+			</div>
+		</div>
+	</form>
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/tiny_mce.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/tiny_mce.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/tiny_mce.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(d){var a=/^\s*|\s*$/g,e,c="B".replace(/A(.)|B/,"$1")==="$1";var b={majorVersion:"@@tinymce_major_version@@",minorVersion:"@@tinymce_minor_version@@",releaseDate:"@@tinymce_release_date@@",_init:function(){var s=this,q=document,o=navigator,g=o.userAgent,m,f,l,k,j,r;s.isOpera=d.opera&&opera.buildNumber;s.isWebKit=/WebKit/.test(g);s.isIE=!s.isWebKit&&!s.isOpera&&(/MSIE/gi).test(g)&&(/Explorer/gi).test(o.appName);s.isIE6=s.isIE&&/MSIE [56]/.test(g);s.isGecko=!s.isWebKit&&/Gecko/.test(g);s.isMac=g.indexOf("Mac")!=-1;s.isAir=/adobeair/i.test(g);s.isIDevice=/(iPad|iPhone)/.test(g);if(d.tinyMCEPreInit){s.suffix=tinyMCEPreInit.suffix;s.baseURL=tinyMCEPreInit.base;s.query=tinyMCEPreInit.query;return}s.suffix="";f=q.getElementsByTagName("base");for(m=0;m<f.length;m++){if(r=f[m].href){if(/^https?:\/\/[^\/]+$/.test(r)){r+="/"}k=r?r.match(/.*\//)[0]:""}}function h(i){if(i.src&&/tiny_mce(|_gzip|_jquery|_prototype|_full)(_dev|_src)?.js/.test(i.src)){if(/_(src|dev)\.js/g.test(i.src)){s.suffix="_src"}if((j=i.src.indexOf("?"))!=-1){s.query=i.src.substring(j+1)}s.baseURL=i.src.substring(0,i.src.lastIndexOf("/"));if(k&&s.baseURL.indexOf("://")==-1&&s.baseURL.indexOf("/")!==0){s.baseURL=k+s.baseURL}return s.baseURL}return null}f=q.getElementsByTagName("script");for(m=0;m<f.length;m++){if(h(f[m])){return}}l=q.getElementsByTagName("head")[0];if(l){f=l.getElementsByTagName("script");for(m=0;m<f.length;m++){if(h(f[m])){return}}}return},is:function(g,f){if(!f){return g!==e}if(f=="array"&&(g.hasOwnProperty&&g instanceof Array)){return true}return typeof(g)==f},each:function(i,f,h){var j,g;if(!i){return 0}h=h||i;if(i.length!==e){for(j=0,g=i.length;j<g;j++){if(f.call(h,i[j],j,i)===false){return 0}}}else{for(j in i){if(i.hasOwnProperty(j)){if(f.call(h,i[j],j,i)===false){return 0}}}}return 1},map:function(g,h){var i=[];b.each(g,function(f){i.push(h(f))});return i},grep:function(g,h){var i=[];b.each(g,function(f){if(!h||h(f)){i.push(f)}});return i},inArray:function(g,h){var j,f;if(g){for(j=0,f=g.length;j<f;j++){if(g[j]===h){return j}}}return -1},extend:function(k,j){var h,g,f=arguments;for(h=1,g=f.length;h<g;h++){j=f[h];b.each(j,function(i,l){if(i!==e){k[l]=i}})}return k},trim:function(f){return(f?""+f:"").replace(a,"")},create:function(n,f){var m=this,g,i,j,k,h,l=0;n=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(n);j=n[3].match(/(^|\.)(\w+)$/i)[2];i=m.createNS(n[3].replace(/\.\w+$/,""));if(i[j]){return}if(n[2]=="static"){i[j]=f;if(this.onCreate){this.onCreate(n[2],n[3],i[j])}return}if(!f[j]){f[j]=function(){};l=1}i[j]=f[j];m.extend(i[j].prototype,f);if(n[5]){g=m.resolve(n[5]).prototype;k=n[5].match(/\.(\w+)$/i)[1];h=i[j];if(l){i[j]=function(){return g[k].apply(this,arguments)}}else{i[j]=function(){this.parent=g[k];return h.apply(this,arguments)}}i[j].prototype[j]=i[j];m.each(g,function(o,p){i[j].prototype[p]=g[p]});m.each(f,function(o,p){if(g[p]){i[j].prototype[p]=function(){this.parent=g[p];return o.apply(this,arguments)}}else{if(p!=j){i[j].prototype[p]=o}}})}m.each(f["static"],function(o,p){i[j][p]=o});if(this.onCreate){this.onCreate(n[2],n[3],i[j].prototype)}},walk:function(i,h,j,g){g=g||this;if(i){if(j){i=i[j]}b.each(i,function(k,f){if(h.call(g,k,f,j)===false){return false}b.walk(k,h,j,g)})}},createNS:function(j,h){var g,f;h=h||d;j=j.split(".");for(g=0;g<j.length;g++){f=j[g];if(!h[f]){h[f]={}}h=h[f]}return h},resolve:function(j,h){var g,f;h=h||d;j=j.split(".");for(g=0,f=j.length;g<f;g++){h=h[j[g]];if(!h){break}}return h},addUnload:function(j,i){var h=this;j={func:j,scope:i||this};if(!h.unloads){function g(){var f=h.unloads,l,m;if(f){for(m in f){l=f[m];if(l&&l.func){l.func.call(l.scope,1)}}if(d.detachEvent){d.detachEvent("onbeforeunload",k);d.detachEvent("onunload",g)}else{if(d.removeEventListener){d.removeEventListener("unload",g,false)}}h.unloads=l=f=w=g=0;if(d.CollectGarbage){CollectGarbage()}}}function k(){var l=document;if(l.readyState=="interactive"){function f(){l.detachEvent("onstop",f);if(g){g()}l=0}if(l){l.attachEvent("onstop",f)}d.setTimeout(function(){if(l){l.detachEvent("onstop",f)}},0)}}if(d.attachEvent){d.attachEvent("onunload",g);d.attachEvent("onbeforeunload",k)}else{if(d.addEventListener){d.addEventListener("unload",g,false)}}h.unloads=[j]}else{h.unloads.push(j)}return j},removeUnload:function(i){var g=this.unloads,h=null;b.each(g,function(j,f){if(j&&j.func==i){g.splice(f,1);h=i;return false}});return h},explode:function(f,g){return f?b.map(f.split(g||","),b.trim):f},_addVer:function(g){var f;if(!this.query){return g}f=(g.indexOf("?")==-1?"?":"&")+this.query;if(g.indexOf("#")==-1){return g+f}return g.replace("#",f+"#")},_replace:function(h,f,g){if(c){return g.replace(h,function(){var l=f,j=arguments,k;for(k=0;k<j.length-2;k++){if(j[k]===e){l=l.replace(new RegExp("\\$"+k,"g"),"")}else{l=l.replace(new RegExp("\\$"+k,"g"),j[k])}}return l})}return g.replace(h,f)}};b._init();d.tinymce=d.tinyMCE=b})(window);tinymce.create("tinymce.util.Dispatcher",{scope:null,listeners:null,Dispatcher:function(a){this.scope=a||this;this.listeners=[]},add:function(a,b){this.listeners.push({cb:a,scope:b||this.scope});return a},addToTop:function(a,b){this.listeners.unshift({cb:a,scope:b||this.scope});return a},remove:function(a){var b=this.listeners,c=null;tinymce.each(b,function(e,d){if(a==e.cb){c=a;b.splice(d,1);return false}});return c},dispatch:function(){var f,d=arguments,e,b=this.listeners,g;for(e=0;e<b.length;e++){g=b[e];f=g.cb.apply(g.scope,d);if(f===false){break}}return f}});(function(){var a=tinymce.each;tinymce.create("tinymce.util.URI",{URI:function(e,g){var f=this,h,d,c;e=tinymce.trim(e);g=f.settings=g||{};if(/^(mailto|tel|news|javascript|about|data):/i.test(e)||/^\s*#/.test(e)){f.source=e;return}if(e.indexOf("/")===0&&e.indexOf("//")!==0){e=(g.base_uri?g.base_uri.protocol||"http":"http")+"://mce_host"+e}if(!/^\w*:?\/\//.test(e)){e=(g.base_uri.protocol||"http")+"://mce_host"+f.toAbsPath(g.base_uri.path,e)}e=e.replace(/@@/g,"(mce_at)");e=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);a(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],function(b,j){var k=e[j];if(k){k=k.replace(/\(mce_at\)/g,"@@")}f[b]=k});if(c=g.base_uri){if(!f.protocol){f.protocol=c.protocol}if(!f.userInfo){f.userInfo=c.userInfo}if(!f.port&&f.host=="mce_host"){f.port=c.port}if(!f.host||f.host=="mce_host"){f.host=c.host}f.source=""}},setPath:function(c){var b=this;c=/^(.*?)\/?(\w+)?$/.exec(c);b.path=c[0];b.directory=c[1];b.file=c[2];b.source="";b.getURI()},toRelative:function(b){var c=this,d;if(b==="./"){return b}b=new tinymce.util.URI(b,{base_uri:c});if((b.host!="mce_host"&&c.host!=b.host&&b.host)||c.port!=b.port||c.protocol!=b.protocol){return b.getURI()}d=c.toRelPath(c.path,b.path);if(b.query){d+="?"+b.query}if(b.anchor){d+="#"+b.anchor}return d},toAbsolute:function(b,c){var b=new tinymce.util.URI(b,{base_uri:this});return b.getURI(this.host==b.host&&this.protocol==b.protocol?c:0)},toRelPath:function(g,h){var c,f=0,d="",e,b;g=g.substring(0,g.lastIndexOf("/"));g=g.split("/");c=h.split("/");if(g.length>=c.length){for(e=0,b=g.length;e<b;e++){if(e>=c.length||g[e]!=c[e]){f=e+1;break}}}if(g.length<c.length){for(e=0,b=c.length;e<b;e++){if(e>=g.length||g[e]!=c[e]){f=e+1;break}}}if(f==1){return h}for(e=0,b=g.length-(f-1);e<b;e++){d+="../"}for(e=f-1,b=c.length;e<b;e++){if(e!=f-1){d+="/"+c[e]}else{d+=c[e]}}return d},toAbsPath:function(e,f){var c,b=0,h=[],d,g;d=/\/$/.test(f)?"/":"";e=e.split("/");f=f.split("/");a(e,function(i){if(i){h.push(i)}});e=h;for(c=f.length-1,h=[];c>=0;c--){if(f[c].length==0||f[c]=="."){continue}if(f[c]==".."){b++;continue}if(b>0){b--;continue}h.push(f[c])}c=e.length-b;if(c<=0){g=h.reverse().join("/")}else{g=e.slice(0,c).join("/")+"/"+h.reverse().join("/")}if(g.indexOf("/")!==0){g="/"+g}if(d&&g.lastIndexOf("/")!==g.length-1){g+=d}return g},getURI:function(d){var c,b=this;if(!b.source||d){c="";if(!d){if(b.protocol){c+=b.protocol+"://"}if(b.userInfo){c+=b.userInfo+"@"}if(b.host){c+=b.host}if(b.port){c+=":"+b.port}}if(b.path){c+=b.path}if(b.query){c+="?"+b.query}if(b.anchor){c+="#"+b.anchor}b.source=c}return b.source}})})();(function(){var a=tinymce.each;tinymce.create("static tinymce.util.Cookie",{getHash:function(d){var b=this.get(d),c;if(b){a(b.split("&"),function(e){e=e.split("=");c=c||{};c[unescape(e[0])]=unescape(e[1])})}return c},setHash:function(j,b,g,f,i,c){var h="";a(b,function(e,d){h+=(!h?"":"&")+escape(d)+"="+escape(e)});this.set(j,h,g,f,i,c)},get:function(i){var h=document.cookie,g,f=i+"=",d;if(!h){return}d=h.indexOf("; "+f);if(d==-1){d=h.indexOf(f);if(d!=0){return null}}else{d+=2}g=h.indexOf(";",d);if(g==-1){g=h.length}return unescape(h.substring(d+f.length,g))},set:function(i,b,g,f,h,c){document.cookie=i+"="+escape(b)+((g)?"; expires="+g.toGMTString():"")+((f)?"; path="+escape(f):"")+((h)?"; domain="+h:"")+((c)?"; secure":"")},remove:function(e,b){var c=new Date();c.setTime(c.getTime()-1000);this.set(e,"",c,b,c)}})})();tinymce.create("static tinymce.util.JSON",{serialize:function(e){var c,a,d=tinymce.util.JSON.serialize,b;if(e==null){return"null"}b=typeof e;if(b=="string"){a="\bb\tt\nn\ff\rr\"\"''\\\\";return'"'+e.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g,function(g,f){c=a.indexOf(f);if(c+1){return"\\"+a.charAt(c+1)}g=f.charCodeAt().toString(16);return"\\u"+"0000".substring(g.length)+g})+'"'}if(b=="object"){if(e.hasOwnProperty&&e instanceof Array){for(c=0,a="[";c<e.length;c++){a+=(c>0?",":"")+d(e[c])}return a+"]"}a="{";for(c in e){a+=typeof e[c]!="function"?(a.length>1?',"':'"')+c+'":'+d(e[c]):""}return a+"}"}return""+e},parse:function(s){try{return eval("("+s+")")}catch(ex){}}});tinymce.create("static tinymce.util.XHR",{send:function(g){var a,e,b=window,h=0;g.scope=g.scope||this;g.success_scope=g.success_scope||g.scope;g.error_scope=g.error_scope||g.scope;g.async=g.async===false?false:true;g.data=g.data||"";function d(i){a=0;try{a=new ActiveXObject(i)}catch(c){}return a}a=b.XMLHttpRequest?new XMLHttpRequest():d("Microsoft.XMLHTTP")||d("Msxml2.XMLHTTP");if(a){if(a.overrideMimeType){a.overrideMimeType(g.content_type)}a.open(g.type||(g.data?"POST":"GET"),g.url,g.async);if(g.content_type){a.setRequestHeader("Content-Type",g.content_type)}a.setRequestHeader("X-Requested-With","XMLHttpRequest");a.send(g.data);function f(){if(!g.async||a.readyState==4||h++>10000){if(g.success&&h<10000&&a.status==200){g.success.call(g.success_scope,""+a.responseText,a,g)}else{if(g.error){g.error.call(g.error_scope,h>10000?"TIMED_OUT":"GENERAL",a,g)}}a=null}else{b.setTimeout(f,10)}}if(!g.async){return f()}e=b.setTimeout(f,10)}}});(function(){var c=tinymce.extend,b=tinymce.util.JSON,a=tinymce.util.XHR;tinymce.create("tinymce.util.JSONRequest",{JSONRequest:function(d){this.settings=c({},d);this.count=0},send:function(f){var e=f.error,d=f.success;f=c(this.settings,f);f.success=function(h,g){h=b.parse(h);if(typeof(h)=="undefined"){h={error:"JSON Parse error."}}if(h.error){e.call(f.error_scope||f.scope,h.error,g)}else{d.call(f.success_scope||f.scope,h.result)}};f.error=function(h,g){e.call(f.error_scope||f.scope,h,g)};f.data=b.serialize({id:f.id||"c"+(this.count++),method:f.method,params:f.params});f.content_type="application/json";a.send(f)},"static":{sendRPC:function(d){return new tinymce.util.JSONRequest().send(d)}}})}());(function(m){var k=m.each,j=m.is,i=m.isWebKit,d=m.isIE,a=/^(H[1-6R]|P|DIV|ADDRESS|PRE|FORM|T(ABLE|BODY|HEAD|FOOT|H|R|D)|LI|OL|UL|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|MENU|ISINDEX|SAMP)$/,e=g("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"),f=g("src,href,style,coords,shape"),c={"&":"&amp;",'"':"&quot;","<":"&lt;",">":"&gt;"},n=/[<>&\"]/g,b=/^([a-z0-9],?)+$/i,h=/<(\w+)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)(\s*\/?)>/g,l=/(\w+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;function g(q){var p={},o;q=q.split(",");for(o=q.length;o>=0;o--){p[q[o]]=1}return p}m.create("tinymce.dom.DOMUtils",{doc:null,root:null,files:null,pixelStyles:/^(top|left|bottom|right|width|height|borderWidth)$/,props:{"for":"htmlFor","class":"className",className:"className",checked:"checked",disabled:"disabled",maxlength:"maxLength",readonly:"readOnly",selected:"selected",value:"value",id:"id",name:"name",type:"type"},DOMUtils:function(u,q){var p=this,o;p.doc=u;p.win=window;p.files={};p.cssFlicker=false;p.counter=0;p.stdMode=u.documentMode>=8;p.boxModel=!m.isIE||u.compatMode=="CSS1Compat"||p.stdMode;p.settings=q=m.extend({keep_values:false,hex_colors:1,process_html:1},q);if(m.isIE6){try{u.execCommand("BackgroundImageCache",false,true)}catch(r){p.cssFlicker=true}}if(q.valid_styles){p._styles={};k(q.valid_styles,function(t,s){p._styles[s]=m.explode(t)})}m.addUnload(p.destroy,p)},getRoot:function(){var o=this,p=o.settings;return(p&&o.get(p.root_element))||o.doc.body},getViewPort:function(p){var q,o;p=!p?this.win:p;q=p.document;o=this.boxModel?q.documentElement:q.body;return{x:p.pageXOffset||o.scrollLeft,y:p.pageYOffset||o.scrollTop,w:p.innerWidth||o.clientWidth,h:p.innerHeight||o.clientHeight}},getRect:function(s){var r,o=this,q;s=o.get(s);r=o.getPos(s);q=o.getSize(s);return{x:r.x,y:r.y,w:q.w,h:q.h}},getSize:function(r){var p=this,o,q;r=p.get(r);o=p.getStyle(r,"width");q=p.getStyle(r,"height");if(o.indexOf("px")===-1){o=0}if(q.indexOf("px")===-1){q=0}return{w:parseInt(o)||r.offsetWidth||r.clientWidth,h:parseInt(q)||r.offsetHeight||r.clientHeight}},getParent:function(q,p,o){return this.getParents(q,p,o,false)},getParents:function(z,v,s,y){var q=this,p,u=q.settings,x=[];z=q.get(z);y=y===undefined;if(u.strict_root){s=s||q.getRoot()}if(j(v,"string")){p=v;if(v==="*"){v=function(o){return o.nodeType==1}}else{v=function(o){return q.is(o,p)}}}while(z){if(z==s||!z.nodeType||z.nodeType===9){break}if(!v||v(z)){if(y){x.push(z)}else{return z}}z=z.parentNode}return y?x:null},get:function(o){var p;if(o&&this.doc&&typeof(o)=="string"){p=o;o=this.doc.getElementById(o);if(o&&o.id!==p){return this.doc.getElementsByName(p)[1]}}return o},getNext:function(p,o){return this._findSib(p,o,"nextSibling")},getPrev:function(p,o){return this._findSib(p,o,"previousSibling")},select:function(q,p){var o=this;return m.dom.Sizzle(q,o.get(p)||o.get(o.settings.root_element)||o.doc,[])},is:function(q,o){var p;if(q.length===undefined){if(o==="*"){return q.nodeType==1}if(b.test(o)){o=o.toLowerCase().split(/,/);q=q.nodeName.toLowerCase();for(p=o.length-1;p>=0;p--){if(o[p]==q){return true}}return false}}return m.dom.Sizzle.matches(o,q.nodeType?[q]:q).length>0},add:function(s,v,o,r,u){var q=this;return this.run(s,function(y){var x,t;x=j(v,"string")?q.doc.createElement(v):v;q.setAttribs(x,o);if(r){if(r.nodeType){x.appendChild(r)}else{q.setHTML(x,r)}}return !u?y.appendChild(x):x})},create:function(q,o,p){return this.add(this.doc.createElement(q),q,o,p,1)},createHTML:function(v,p,s){var u="",r=this,q;u+="<"+v;for(q in p){if(p.hasOwnProperty(q)){u+=" "+q+'="'+r.encode(p[q])+'"'}}if(typeof(s)!="undefined"){return u+">"+s+"</"+v+">"}return u+" />"},remove:function(o,p){return this.run(o,function(r){var q,s;q=r.parentNode;if(!q){return null}if(p){while(s=r.firstChild){if(!m.isIE||s.nodeType!==3||s.nodeValue){q.insertBefore(s,r)}else{r.removeChild(s)}}}return q.removeChild(r)})},setStyle:function(r,o,p){var q=this;return q.run(r,function(v){var u,t;u=v.style;o=o.replace(/-(\D)/g,function(x,s){return s.toUpperCase()});if(q.pixelStyles.test(o)&&(m.is(p,"number")||/^[\-0-9\.]+$/.test(p))){p+="px"}switch(o){case"opacity":if(d){u.filter=p===""?"":"alpha(opacity="+(p*100)+")";if(!r.currentStyle||!r.currentStyle.hasLayout){u.display="inline-block"}}u[o]=u["-moz-opacity"]=u["-khtml-opacity"]=p||"";break;case"float":d?u.styleFloat=p:u.cssFloat=p;break;default:u[o]=p||""}if(q.settings.update_styles){q.setAttrib(v,"_mce_style")}})},getStyle:function(r,o,q){r=this.get(r);if(!r){return false}if(this.doc.defaultView&&q){o=o.replace(/[A-Z]/g,function(s){return"-"+s});try{return this.doc.defaultView.getComputedStyle(r,null).getPropertyValue(o)}catch(p){return null}}o=o.replace(/-(\D)/g,function(t,s){return s.toUpperCase()});if(o=="float"){o=d?"styleFloat":"cssFloat"}if(r.currentStyle&&q){return r.currentStyle[o]}return r.style[o]},setStyles:function(u,v){var q=this,r=q.settings,p;p=r.update_styles;r.update_styles=0;k(v,function(o,s){q.setStyle(u,s,o)});r.update_styles=p;if(r.update_styles){q.setAttrib(u,r.cssText)}},setAttrib:function(q,r,o){var p=this;if(!q||!r){return}if(p.settings.strict){r=r.toLowerCase()}return this.run(q,function(u){var t=p.settings;switch(r){case"style":if(!j(o,"string")){k(o,function(s,x){p.setStyle(u,x,s)});return}if(t.keep_values){if(o&&!p._isRes(o)){u.setAttribute("_mce_style",o,2)}else{u.removeAttribute("_mce_style",2)}}u.style.cssText=o;break;case"class":u.className=o||"";break;case"src":case"href":if(t.keep_values){if(t.url_converter){o=t.url_converter.call(t.url_converter_scope||p,o,r,u)}p.setAttrib(u,"_mce_"+r,o,2)}break;case"shape":u.setAttribute("_mce_style",o);break}if(j(o)&&o!==null&&o.length!==0){u.setAttribute(r,""+o,2)}else{u.removeAttribute(r,2)}})},setAttribs:function(q,r){var p=this;return this.run(q,function(o){k(r,function(s,t){p.setAttrib(o,t,s)})})},getAttrib:function(r,s,q){var o,p=this;r=p.get(r);if(!r||r.nodeType!==1){return false}if(!j(q)){q=""}if(/^(src|href|style|coords|shape)$/.test(s)){o=r.getAttribute("_mce_"+s);if(o){return o}}if(d&&p.props[s]){o=r[p.props[s]];o=o&&o.nodeValue?o.nodeValue:o}if(!o){o=r.getAttribute(s,2)}if(/^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)$/.test(s)){if(r[p.props[s]]===true&&o===""){return s}return o?s:""}if(r.nodeName==="FORM"&&r.getAttributeNode(s)){return r.getAttributeNode(s).nodeValue}if(s==="style"){o=o||r.style.cssText;if(o){o=p.serializeStyle(p.parseStyle(o),r.nodeName);if(p.settings.keep_values&&!p._isRes(o)){r.setAttribute("_mce_style",o)}}}if(i&&s==="class"&&o){o=o.replace(/(apple|webkit)\-[a-z\-]+/gi,"")}if(d){switch(s){case"rowspan":case"colspan":if(o===1){o=""}break;case"size":if(o==="+0"||o===20||o===0){o=""}break;case"width":case"height":case"vspace":case"checked":case"disabled":case"readonly":if(o===0){o=""}break;case"hspace":if(o===-1){o=""}break;case"maxlength":case"tabindex":if(o===32768||o===2147483647||o==="32768"){o=""}break;case"multiple":case"compact":case"noshade":case"nowrap":if(o===65535){return s}return q;case"shape":o=o.toLowerCase();break;default:if(s.indexOf("on")===0&&o){o=m._replace(/^function\s+\w+\(\)\s+\{\s+(.*)\s+\}$/,"$1",""+o)}}}return(o!==undefined&&o!==null&&o!=="")?""+o:q},getPos:function(A,s){var p=this,o=0,z=0,u,v=p.doc,q;A=p.get(A);s=s||v.body;if(A){if(d&&!p.stdMode){A=A.getBoundingClientRect();u=p.boxModel?v.documentElement:v.body;o=p.getStyle(p.select("html")[0],"borderWidth");o=(o=="medium"||p.boxModel&&!p.isIE6)&&2||o;return{x:A.left+u.scrollLeft-o,y:A.top+u.scrollTop-o}}q=A;while(q&&q!=s&&q.nodeType){o+=q.offsetLeft||0;z+=q.offsetTop||0;q=q.offsetParent}q=A.parentNode;while(q&&q!=s&&q.nodeType){o-=q.scrollLeft||0;z-=q.scrollTop||0;q=q.parentNode}}return{x:o,y:z}},parseStyle:function(r){var u=this,v=u.settings,x={};if(!r){return x}function p(D,A,C){var z,B,o,y;z=x[D+"-top"+A];if(!z){return}B=x[D+"-right"+A];if(z!=B){return}o=x[D+"-bottom"+A];if(B!=o){return}y=x[D+"-left"+A];if(o!=y){return}x[C]=y;delete x[D+"-top"+A];delete x[D+"-right"+A];delete x[D+"-bottom"+A];delete x[D+"-left"+A]}function q(y,s,o,A){var z;z=x[s];if(!z){return}z=x[o];if(!z){return}z=x[A];if(!z){return}x[y]=x[s]+" "+x[o]+" "+x[A];delete x[s];delete x[o];delete x[A]}r=r.replace(/&(#?[a-z0-9]+);/g,"&$1_MCE_SEMI_");k(r.split(";"),function(s){var o,t=[];if(s){s=s.replace(/_MCE_SEMI_/g,";");s=s.replace(/url\([^\)]+\)/g,function(y){t.push(y);return"url("+t.length+")"});s=s.split(":");o=m.trim(s[1]);o=o.replace(/url\(([^\)]+)\)/g,function(z,y){return t[parseInt(y)-1]});o=o.replace(/rgb\([^\)]+\)/g,function(y){return u.toHex(y)});if(v.url_converter){o=o.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g,function(y,z){return"url("+v.url_converter.call(v.url_converter_scope||u,u.decode(z),"style",null)+")"})}x[m.trim(s[0]).toLowerCase()]=o}});p("border","","border");p("border","-width","border-width");p("border","-color","border-color");p("border","-style","border-style");p("padding","","padding");p("margin","","margin");q("border","border-width","border-style","border-color");if(d){if(x.border=="medium none"){x.border=""}}return x},serializeStyle:function(v,p){var q=this,r="";function u(s,o){if(o&&s){if(o.indexOf("-")===0){return}switch(o){case"font-weight":if(s==700){s="bold"}break;case"color":case"background-color":s=s.toLowerCase();break}r+=(r?" ":"")+o+": "+s+";"}}if(p&&q._styles){k(q._styles["*"],function(o){u(v[o],o)});k(q._styles[p.toLowerCase()],function(o){u(v[o],o)})}else{k(v,u)}return r},loadCSS:function(o){var q=this,r=q.doc,p;if(!o){o=""}p=q.select("head")[0];k(o.split(","),function(s){var t;if(q.files[s]){return}q.files[s]=true;t=q.create("link",{rel:"stylesheet",href:m._addVer(s)});if(d&&r.documentMode&&r.recalc){t.onload=function(){r.recalc();t.onload=null}}p.appendChild(t)})},addClass:function(o,p){return this.run(o,function(q){var r;if(!p){return 0}if(this.hasClass(q,p)){return q.className}r=this.removeClass(q,p);return q.className=(r!=""?(r+" "):"")+p})},removeClass:function(q,r){var o=this,p;return o.run(q,function(t){var s;if(o.hasClass(t,r)){if(!p){p=new RegExp("(^|\\s+)"+r+"(\\s+|$)","g")}s=t.className.replace(p," ");s=m.trim(s!=" "?s:"");t.className=s;if(!s){t.removeAttribute("class");t.removeAttribute("className")}return s}return t.className})},hasClass:function(p,o){p=this.get(p);if(!p||!o){return false}return(" "+p.className+" ").indexOf(" "+o+" ")!==-1},show:function(o){return this.setStyle(o,"display","block")},hide:function(o){return this.setStyle(o,"display","none")},isHidden:function(o){o=this.get(o);return !o||o.style.display=="none"||this.getStyle(o,"display")=="none"},uniqueId:function(o){return(!o?"mce_":o)+(this.counter++)},setHTML:function(q,p){var o=this;return this.run(q,function(v){var r,t,s,z,u,r;p=o.processHTML(p);if(d){function y(){while(v.firstChild){v.firstChild.removeNode()}try{v.innerHTML="<br />"+p;v.removeChild(v.firstChild)}catch(x){r=o.create("div");r.innerHTML="<br />"+p;k(r.childNodes,function(B,A){if(A){v.appendChild(B)}})}}if(o.settings.fix_ie_paragraphs){p=p.replace(/<p><\/p>|<p([^>]+)><\/p>|<p[^\/+]\/>/gi,'<p$1 _mce_keep="true">&nbsp;</p>')}y();if(o.settings.fix_ie_paragraphs){s=v.getElementsByTagName("p");for(t=s.length-1,r=0;t>=0;t--){z=s[t];if(!z.hasChildNodes()){if(!z._mce_keep){r=1;break}z.removeAttribute("_mce_keep")}}}if(r){p=p.replace(/<p ([^>]+)>|<p>/ig,'<div $1 _mce_tmp="1">');p=p.replace(/<\/p>/gi,"</div>");y();if(o.settings.fix_ie_paragraphs){s=v.getElementsByTagName("DIV");for(t=s.length-1;t>=0;t--){z=s[t];if(z._mce_tmp){u=o.doc.createElement("p");z.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi,function(A,x){var B;if(x!=="_mce_tmp"){B=z.getAttribute(x);if(!B&&x==="class"){B=z.className}u.setAttribute(x,B)}});for(r=0;r<z.childNodes.length;r++){u.appendChild(z.childNodes[r].cloneNode(true))}z.swapNode(u)}}}}}else{v.innerHTML=p}return p})},processHTML:function(r){var p=this,q=p.settings,v=[];if(!q.process_html){return r}if(d){r=r.replace(/&apos;/g,"&#39;");r=r.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/gi,"")}r=m._replace(/<a( )([^>]+)\/>|<a\/>/gi,"<a$1$2></a>",r);if(q.keep_values){if(/<script|noscript|style/i.test(r)){function o(t){t=t.replace(/(<!--\[CDATA\[|\]\]-->)/g,"\n");t=t.replace(/^[\r\n]*|[\r\n]*$/g,"");t=t.replace(/^\s*(\/\/\s*<!--|\/\/\s*<!\[CDATA\[|<!--|<!\[CDATA\[)[\r\n]*/g,"");t=t.replace(/\s*(\/\/\s*\]\]>|\/\/\s*-->|\]\]>|-->|\]\]-->)\s*$/g,"");return t}r=r.replace(/<script([^>]+|)>([\s\S]*?)<\/script>/gi,function(s,x,t){if(!x){x=' type="text/javascript"'}x=x.replace(/src=\"([^\"]+)\"?/i,function(y,z){if(q.url_converter){z=p.encode(q.url_converter.call(q.url_converter_scope||p,p.decode(z),"src","script"))}return'_mce_src="'+z+'"'});if(m.trim(t)){v.push(o(t));t="<!--\nMCE_SCRIPT:"+(v.length-1)+"\n// -->"}return"<mce:script"+x+">"+t+"</mce:script>"});r=r.replace(/<style([^>]+|)>([\s\S]*?)<\/style>/gi,function(s,x,t){if(t){v.push(o(t));t="<!--\nMCE_SCRIPT:"+(v.length-1)+"\n-->"}return"<mce:style"+x+">"+t+"</mce:style><style "+x+' _mce_bogus="1">'+t+"</style>"});r=r.replace(/<noscript([^>]+|)>([\s\S]*?)<\/noscript>/g,function(s,x,t){return"<mce:noscript"+x+"><!--"+p.encode(t).replace(/--/g,"&#45;&#45;")+"--></mce:noscript>"})}r=m._replace(/<!\[CDATA\[([\s\S]+)\]\]>/g,"<!--[CDATA[$1]]-->",r);function u(s){return s.replace(h,function(y,z,x,t){return"<"+z+x.replace(l,function(B,A,E,D,C){var F;A=A.toLowerCase();E=E||D||C||"";if(e[A]){if(E==="false"||E==="0"){return}return A+'="'+A+'"'}if(f[A]&&x.indexOf("_mce_"+A)==-1){F=p.decode(E);if(q.url_converter&&(A=="src"||A=="href")){F=q.url_converter.call(q.url_converter_scope||p,F,A,z)}if(A=="style"){F=p.serializeStyle(p.parseStyle(F),A)}return A+'="'+E+'" _mce_'+A+'="'+p.encode(F)+'"'}return B})+t+">"})}r=u(r);r=r.replace(/MCE_SCRIPT:([0-9]+)/g,function(t,s){return v[s]})}return r},getOuterHTML:function(o){var p;o=this.get(o);if(!o){return null}if(o.outerHTML!==undefined){return o.outerHTML}p=(o.ownerDocument||this.doc).createElement("body");p.appendChild(o.cloneNode(true));return p.innerHTML},setOuterHTML:function(r,p,s){var o=this;function q(u,t,x){var y,v;v=x.createElement("body");v.innerHTML=t;y=v.lastChild;while(y){o.insertAfter(y.cloneNode(true),u);y=y.previousSibling}o.remove(u)}return this.run(r,function(u){u=o.get(u);if(u.nodeType==1){s=s||u.ownerDocument||o.doc;if(d){try{if(d&&u.nodeType==1){u.outerHTML=p}else{q(u,p,s)}}catch(t){q(u,p,s)}}else{q(u,p,s)}}})},decode:function(p){var q,r,o;if(/&[\w#]+;/.test(p)){q=this.doc.createElement("div");q.innerHTML=p;r=q.firstChild;o="";if(r){do{o+=r.nodeValue}while(r=r.nextSibling)}return o||p}return p},encode:function(o){return(""+o).replace(n,function(p){return c[p]})},insertAfter:function(o,p){p=this.get(p);return this.run(o,function(r){var q,s;q=p.parentNode;s=p.nextSibling;if(s){q.insertBefore(r,s)}else{q.appendChild(r)}return r})},isBlock:function(o){if(o.nodeType&&o.nodeType!==1){return false}o=o.nodeName||o;return a.test(o)},replace:function(s,r,p){var q=this;if(j(r,"array")){s=s.cloneNode(true)}return q.run(r,function(t){if(p){k(m.grep(t.childNodes),function(o){s.appendChild(o)})}return t.parentNode.replaceChild(s,t)})},rename:function(r,o){var q=this,p;if(r.nodeName!=o.toUpperCase()){p=q.create(o);k(q.getAttribs(r),function(s){q.setAttrib(p,s.nodeName,q.getAttrib(r,s.nodeName))});q.replace(p,r,1)}return p||r},findCommonAncestor:function(q,o){var r=q,p;while(r){p=o;while(p&&r!=p){p=p.parentNode}if(r==p){break}r=r.parentNode}if(!r&&q.ownerDocument){return q.ownerDocument.documentElement}return r},toHex:function(o){var q=/^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(o);function p(r){r=parseInt(r).toString(16);return r.length>1?r:"0"+r}if(q){o="#"+p(q[1])+p(q[2])+p(q[3]);return o}return o},getClasses:function(){var s=this,o=[],r,u={},v=s.settings.class_filter,q;if(s.classes){return s.classes}function x(t){k(t.imports,function(y){x(y)});k(t.cssRules||t.rules,function(y){switch(y.type||1){case 1:if(y.selectorText){k(y.selectorText.split(","),function(z){z=z.replace(/^\s*|\s*$|^\s\./g,"");if(/\.mce/.test(z)||!/\.[\w\-]+$/.test(z)){return}q=z;z=m._replace(/.*\.([a-z0-9_\-]+).*/i,"$1",z);if(v&&!(z=v(z,q))){return}if(!u[z]){o.push({"class":z});u[z]=1}})}break;case 3:x(y.styleSheet);break}})}try{k(s.doc.styleSheets,x)}catch(p){}if(o.length>0){s.classes=o}return o},run:function(u,r,q){var p=this,v;if(p.doc&&typeof(u)==="string"){u=p.get(u)}if(!u){return false}q=q||this;if(!u.nodeType&&(u.length||u.length===0)){v=[];k(u,function(s,o){if(s){if(typeof(s)=="string"){s=p.doc.getElementById(s)}v.push(r.call(q,s,o))}});return v}return r.call(q,u)},getAttribs:function(q){var p;q=this.get(q);if(!q){return[]}if(d){p=[];if(q.nodeName=="OBJECT"){return q.attributes}if(q.nodeName==="OPTION"&&this.getAttrib(q,"selected")){p.push({specified:1,nodeName:"selected"})}q.cloneNode(false).outerHTML.replace(/<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi,"").replace(/[\w:\-]+/gi,function(o){p.push({specified:1,nodeName:o})});return p}return q.attributes},destroy:function(p){var o=this;if(o.events){o.events.destroy()}o.win=o.doc=o.root=o.events=null;if(!p){m.removeUnload(o.destroy)}},createRng:function(){var o=this.doc;return o.createRange?o.createRange():new m.dom.Range(this)},nodeIndex:function(s,t){var o=0,q,r,p;if(s){for(q=s.nodeType,s=s.previousSibling,r=s;s;s=s.previousSibling){p=s.nodeType;if(t&&p==3){if(p==q||!s.nodeValue.length){continue}}o++;q=p}}return o},split:function(u,s,y){var z=this,o=z.createRng(),v,q,x;function p(A){var t,r=A.childNodes;if(A.nodeType==1&&A.getAttribute("_mce_type")=="bookmark"){return}for(t=r.length-1;t>=0;t--){p(r[t])}if(A.nodeType!=9){if(A.nodeType==3&&A.nodeValue.length>0){if(!z.isBlock(A.parentNode)||m.trim(A.nodeValue).length>0){return}}if(A.nodeType==1){r=A.childNodes;if(r.length==1&&r[0]&&r[0].nodeType==1&&r[0].getAttribute("_mce_type")=="bookmark"){A.parentNode.insertBefore(r[0],A)}if(r.length||/^(br|hr|input|img)$/i.test(A.nodeName)){return}}z.remove(A)}return A}if(u&&s){o.setStart(u.parentNode,z.nodeIndex(u));o.setEnd(s.parentNode,z.nodeIndex(s));v=o.extractContents();o=z.createRng();o.setStart(s.parentNode,z.nodeIndex(s)+1);o.setEnd(u.parentNode,z.nodeIndex(u)+1);q=o.extractContents();x=u.parentNode;x.insertBefore(p(v),u);if(y){x.replaceChild(y,s)}else{x.insertBefore(s,u)}x.insertBefore(p(q),u);z.remove(u);return y||s}},bind:function(s,o,r,q){var p=this;if(!p.events){p.events=new m.dom.EventUtils()}return p.events.add(s,o,r,q||this)},unbind:function(r,o,q){var p=this;if(!p.events){p.events=new m.dom.EventUtils()}return p.events.remove(r,o,q)},_findSib:function(r,o,p){var q=this,s=o;if(r){if(j(s,"string")){s=function(t){return q.is(t,o)}}for(r=r[p];r;r=r[p]){if(s(r)){return r}}}return null},_isRes:function(o){return/^(top|left|bottom|right|width|height)/i.test(o)||/;\s*(top|left|bottom|right|width|height)/i.test(o)}});m.DOM=new m.dom.DOMUtils(document,{process_html:0})})(tinymce);(function(a){function b(c){var N=this,e=c.doc,S=0,E=1,j=2,D=true,R=false,U="startOffset",h="startContainer",P="endContainer",z="endOffset",k=tinymce.extend,n=c.nodeIndex;k(N,{startContainer:e,startOffset:0,endContainer:e,endOffset:0,collapsed:D,commonAncestorContainer:e,START_TO_START:0,START_TO_END:1,END_TO_END:2,END_TO_START:3,setStart:q,setEnd:s,setStartBefore:g,setStartAfter:I,setEndBefore:J,setEndAfter:u,collapse:A,selectNode:x,selectNodeContents:F,compareBoundaryPoints:v,deleteContents:p,extractContents:H,cloneContents:d,insertNode:C,surroundContents:M,cloneRange:K});function q(V,t){B(D,V,t)}function s(V,t){B(R,V,t)}function g(t){q(t.parentNode,n(t))}function I(t){q(t.parentNode,n(t)+1)}function J(t){s(t.parentNode,n(t))}function u(t){s(t.parentNode,n(t)+1)}function A(t){if(t){N[P]=N[h];N[z]=N[U]}else{N[h]=N[P];N[U]=N[z]}N.collapsed=D}function x(t){g(t);u(t)}function F(t){q(t,0);s(t,t.nodeType===1?t.childNodes.length:t.nodeValue.length)}function v(W,X){var Z=N[h],Y=N[U],V=N[P],t=N[z];if(W===0){return G(Z,Y,Z,Y)}if(W===1){return G(Z,Y,V,t)}if(W===2){return G(V,t,V,t)}if(W===3){return G(V,t,Z,Y)}}function p(){m(j)}function H(){return m(S)}function d(){return m(E)}function C(Y){var V=this[h],t=this[U],X,W;if((V.nodeType===3||V.nodeType===4)&&V.nodeValue){if(!t){V.parentNode.insertBefore(Y,V)}else{if(t>=V.nodeValue.length){c.insertAfter(Y,V)}else{X=V.splitText(t);V.parentNode.insertBefore(Y,X)}}}else{if(V.childNodes.length>0){W=V.childNodes[t]}if(W){V.insertBefore(Y,W)}else{V.appendChild(Y)}}}function M(V){var t=N.extractContents();N.insertNode(V);V.appendChild(t);N.selectNode(V)}function K(){return k(new b(c),{startContainer:N[h],startOffset:N[U],endContainer:N[P],endOffset:N[z],collapsed:N.collapsed,commonAncestorContainer:N.commonAncestorContainer})}function O(t,V){var W;if(t.nodeType==3){return t}if(V<0){return t}W=t.firstChild;while(W&&V>0){--V;W=W.nextSibling}if(W){return W}return t}function l(){return(N[h]==N[P]&&N[U]==N[z])}function G(X,Z,V,Y){var aa,W,t,ab,ad,ac;if(X==V){if(Z==Y){return 0}if(Z<Y){return -1}return 1}aa=V;while(aa&&aa.parentNode!=X){aa=aa.parentNode}if(aa){W=0;t=X.firstChild;while(t!=aa&&W<Z){W++;t=t.nextSibling}if(Z<=W){return -1}return 1}aa=X;while(aa&&aa.parentNode!=V){aa=aa.parentNode}if(aa){W=0;t=V.firstChild;while(t!=aa&&W<Y){W++;t=t.nextSibling}if(W<Y){return -1}return 1}ab=c.findCommonAncestor(X,V);ad=X;while(ad&&ad.parentNode!=ab){ad=ad.parentNode}if(!ad){ad=ab}ac=V;while(ac&&ac.parentNode!=ab){ac=ac.parentNode}if(!ac){ac=ab}if(ad==ac){return 0}t=ab.firstChild;while(t){if(t==ad){return -1}if(t==ac){return 1}t=t.nextSibling}}function B(V,Y,X){var t,W;if(V){N[h]=Y;N[U]=X}else{N[P]=Y;N[z]=X}t=N[P];while(t.parentNode){t=t.parentNode}W=N[h];while(W.parentNode){W=W.parentNode}if(W==t){if(G(N[h],N[U],N[P],N[z])>0){N.collapse(V)}}else{N.collapse(V)}N.collapsed=l();N.commonAncestorContainer=c.findCommonAncestor(N[h],N[P])}function m(ab){var aa,X=0,ad=0,V,Z,W,Y,t,ac;if(N[h]==N[P]){return f(ab)}for(aa=N[P],V=aa.parentNode;V;aa=V,V=V.parentNode){if(V==N[h]){return r(aa,ab)}++X}for(aa=N[h],V=aa.parentNode;V;aa=V,V=V.parentNode){if(V==N[P]){return T(aa,ab)}++ad}Z=ad-X;W=N[h];while(Z>0){W=W.parentNode;Z--}Y=N[P];while(Z<0){Y=Y.parentNode;Z++}for(t=W.parentNode,ac=Y.parentNode;t!=ac;t=t.parentNode,ac=ac.parentNode){W=t;Y=ac}return o(W,Y,ab)}function f(Z){var ab,Y,X,aa,t,W,V;if(Z!=j){ab=e.createDocumentFragment()}if(N[U]==N[z]){return ab}if(N[h].nodeType==3){Y=N[h].nodeValue;X=Y.substring(N[U],N[z]);if(Z!=E){N[h].deleteData(N[U],N[z]-N[U]);N.collapse(D)}if(Z==j){return}ab.appendChild(e.createTextNode(X));return ab}aa=O(N[h],N[U]);t=N[z]-N[U];while(t>0){W=aa.nextSibling;V=y(aa,Z);if(ab){ab.appendChild(V)}--t;aa=W}if(Z!=E){N.collapse(D)}return ab}function r(ab,Y){var aa,Z,V,t,X,W;if(Y!=j){aa=e.createDocumentFragment()}Z=i(ab,Y);if(aa){aa.appendChild(Z)}V=n(ab);t=V-N[U];if(t<=0){if(Y!=E){N.setEndBefore(ab);N.collapse(R)}return aa}Z=ab.previousSibling;while(t>0){X=Z.previousSibling;W=y(Z,Y);if(aa){aa.insertBefore(W,aa.firstChild)}--t;Z=X}if(Y!=E){N.setEndBefore(ab);N.collapse(R)}return aa}function T(Z,Y){var ab,V,aa,t,X,W;if(Y!=j){ab=e.createDocumentFragment()}aa=Q(Z,Y);if(ab){ab.appendChild(aa)}V=n(Z);++V;t=N[z]-V;aa=Z.nextSibling;while(t>0){X=aa.nextSibling;W=y(aa,Y);if(ab){ab.appendChild(W)}--t;aa=X}if(Y!=E){N.setStartAfter(Z);N.collapse(D)}return ab}function o(Z,t,ac){var W,ae,Y,aa,ab,V,ad,X;if(ac!=j){ae=e.createDocumentFragment()}W=Q(Z,ac);if(ae){ae.appendChild(W)}Y=Z.parentNode;aa=n(Z);ab=n(t);++aa;V=ab-aa;ad=Z.nextSibling;while(V>0){X=ad.nextSibling;W=y(ad,ac);if(ae){ae.appendChild(W)}ad=X;--V}W=i(t,ac);if(ae){ae.appendChild(W)}if(ac!=E){N.setStartAfter(Z);N.collapse(D)}return ae}function i(aa,ab){var W=O(N[P],N[z]-1),ac,Z,Y,t,V,X=W!=N[P];if(W==aa){return L(W,X,R,ab)}ac=W.parentNode;Z=L(ac,R,R,ab);while(ac){while(W){Y=W.previousSibling;t=L(W,X,R,ab);if(ab!=j){Z.insertBefore(t,Z.firstChild)}X=D;W=Y}if(ac==aa){return Z}W=ac.previousSibling;ac=ac.parentNode;V=L(ac,R,R,ab);if(ab!=j){V.appendChild(Z)}Z=V}}function Q(aa,ab){var X=O(N[h],N[U]),Y=X!=N[h],ac,Z,W,t,V;if(X==aa){return L(X,Y,D,ab)}ac=X.parentNode;Z=L(ac,R,D,ab);while(ac){while(X){W=X.nextSibling;t=L(X,Y,D,ab);if(ab!=j){Z.appendChild(t)}Y=D;X=W}if(ac==aa){return Z}X=ac.nextSibling;ac=ac.parentNode;V=L(ac,R,D,ab);if(ab!=j){V.appendChild(Z)}Z=V}}function L(t,Y,ab,ac){var X,W,Z,V,aa;if(Y){return y(t,ac)}if(t.nodeType==3){X=t.nodeValue;if(ab){V=N[U];W=X.substring(V);Z=X.substring(0,V)}else{V=N[z];W=X.substring(0,V);Z=X.substring(V)}if(ac!=E){t.nodeValue=Z}if(ac==j){return}aa=t.cloneNode(R);aa.nodeValue=W;return aa}if(ac==j){return}return t.cloneNode(R)}function y(V,t){if(t!=j){return t==E?V.cloneNode(D):V}V.parentNode.removeChild(V)}}a.Range=b})(tinymce.dom);(function(){function a(g){var i=this,j="\uFEFF",e,h,d=g.dom,c=true,f=false;function b(){var n=g.getRng(),k=d.createRng(),m,o;m=n.item?n.item(0):n.parentElement();if(m.ownerDocument!=d.doc){return k}if(n.item||!m.hasChildNodes()){k.setStart(m.parentNode,d.nodeIndex(m));k.setEnd(k.startContainer,k.startOffset+1);return k}o=g.isCollapsed();function l(s){var u,q,t,p,A=0,x,y,z,r,v;r=n.duplicate();r.collapse(s);u=d.create("a");z=r.parentElement();if(!z.hasChildNodes()){k[s?"setStart":"setEnd"](z,0);return}z.appendChild(u);r.moveToElementText(u);v=n.compareEndPoints(s?"StartToStart":"EndToEnd",r);if(v>0){k[s?"setStartAfter":"setEndAfter"](z);d.remove(u);return}p=tinymce.grep(z.childNodes);x=p.length-1;while(A<=x){y=Math.floor((A+x)/2);z.insertBefore(u,p[y]);r.moveToElementText(u);v=n.compareEndPoints(s?"StartToStart":"EndToEnd",r);if(v>0){A=y+1}else{if(v<0){x=y-1}else{found=true;break}}}q=v>0||y==0?u.nextSibling:u.previousSibling;if(q.nodeType==1){d.remove(u);t=d.nodeIndex(q);q=q.parentNode;if(!s||y>0){t++}}else{if(v>0||y==0){r.setEndPoint(s?"StartToStart":"EndToEnd",n);t=r.text.length}else{r.setEndPoint(s?"StartToStart":"EndToEnd",n);t=q.nodeValue.length-r.text.length}d.remove(u)}k[s?"setStart":"setEnd"](q,t)}l(true);if(!o){l()}return k}this.addRange=function(k){var p,n,m,r,u,s,t=g.dom.doc,o=t.body;function l(B){var x,A,v,z,y;v=d.create("a");x=B?m:u;A=B?r:s;z=p.duplicate();if(x==t){x=o;A=0}if(x.nodeType==3){x.parentNode.insertBefore(v,x);z.moveToElementText(v);z.moveStart("character",A);d.remove(v);p.setEndPoint(B?"StartToStart":"EndToEnd",z)}else{y=x.childNodes;if(y.length){if(A>=y.length){d.insertAfter(v,y[y.length-1])}else{x.insertBefore(v,y[A])}z.moveToElementText(v)}else{v=t.createTextNode(j);x.appendChild(v);z.moveToElementText(v.parentNode);z.collapse(c)}p.setEndPoint(B?"StartToStart":"EndToEnd",z);d.remove(v)}}this.destroy();m=k.startContainer;r=k.startOffset;u=k.endContainer;s=k.endOffset;p=o.createTextRange();if(m==u&&m.nodeType==1&&r==s-1){if(r==s-1){try{n=o.createControlRange();n.addElement(m.childNodes[r]);n.select();n.scrollIntoView();return}catch(q){}}}l(true);l();p.select();p.scrollIntoView()};this.getRangeAt=function(){if(!e||!tinymce.dom.RangeUtils.compareRanges(h,g.getRng())){e=b();h=g.getRng()}try{e.startContainer.nextSibling}catch(k){e=b();h=null}return e};this.destroy=function(){h=e=null}}tinymce.dom.TridentSelection=a})();(function(){var p=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,j=0,d=Object.prototype.toString,o=false,i=true;[0,0].sort(function(){i=false;return 0});var b=function(v,e,z,A){z=z||[];e=e||document;var C=e;if(e.nodeType!==1&&e.nodeType!==9){return[]}if(!v||typeof v!=="string"){return z}var x=[],s,E,H,r,u=true,t=b.isXML(e),B=v,D,G,F,y;do{p.exec("");s=p.exec(B);if(s){B=s[3];x.push(s[1]);if(s[2]){r=s[3];break}}}while(s);if(x.length>1&&k.exec(v)){if(x.length===2&&f.relative[x[0]]){E=h(x[0]+x[1],e)}else{E=f.relative[x[0]]?[e]:b(x.shift(),e);while(x.length){v=x.shift();if(f.relative[v]){v+=x.shift()}E=h(v,E)}}}else{if(!A&&x.length>1&&e.nodeType===9&&!t&&f.match.ID.test(x[0])&&!f.match.ID.test(x[x.length-1])){D=b.find(x.shift(),e,t);e=D.expr?b.filter(D.expr,D.set)[0]:D.set[0]}if(e){D=A?{expr:x.pop(),set:a(A)}:b.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&e.parentNode?e.parentNode:e,t);E=D.expr?b.filter(D.expr,D.set):D.set;if(x.length>0){H=a(E)}else{u=false}while(x.length){G=x.pop();F=G;if(!f.relative[G]){G=""}else{F=x.pop()}if(F==null){F=e}f.relative[G](H,F,t)}}else{H=x=[]}}if(!H){H=E}if(!H){b.error(G||v)}if(d.call(H)==="[object Array]"){if(!u){z.push.apply(z,H)}else{if(e&&e.nodeType===1){for(y=0;H[y]!=null;y++){if(H[y]&&(H[y]===true||H[y].nodeType===1&&b.contains(e,H[y]))){z.push(E[y])}}}else{for(y=0;H[y]!=null;y++){if(H[y]&&H[y].nodeType===1){z.push(E[y])}}}}}else{a(H,z)}if(r){b(r,C,z,A);b.uniqueSort(z)}return z};b.uniqueSort=function(r){if(c){o=i;r.sort(c);if(o){for(var e=1;e<r.length;e++){if(r[e]===r[e-1]){r.splice(e--,1)}}}}return r};b.matches=function(e,r){return b(e,null,null,r)};b.find=function(y,e,z){var x;if(!y){return[]}for(var t=0,s=f.order.length;t<s;t++){var v=f.order[t],u;if((u=f.leftMatch[v].exec(y))){var r=u[1];u.splice(1,1);if(r.substr(r.length-1)!=="\\"){u[1]=(u[1]||"").replace(/\\/g,"");x=f.find[v](u,e,z);if(x!=null){y=y.replace(f.match[v],"");break}}}}if(!x){x=e.getElementsByTagName("*")}return{set:x,expr:y}};b.filter=function(C,B,F,u){var s=C,H=[],z=B,x,e,y=B&&B[0]&&b.isXML(B[0]);while(C&&B.length){for(var A in f.filter){if((x=f.leftMatch[A].exec(C))!=null&&x[2]){var r=f.filter[A],G,E,t=x[1];e=false;x.splice(1,1);if(t.substr(t.length-1)==="\\"){continue}if(z===H){H=[]}if(f.preFilter[A]){x=f.preFilter[A](x,z,F,H,u,y);if(!x){e=G=true}else{if(x===true){continue}}}if(x){for(var v=0;(E=z[v])!=null;v++){if(E){G=r(E,x,v,z);var D=u^!!G;if(F&&G!=null){if(D){e=true}else{z[v]=false}}else{if(D){H.push(E);e=true}}}}}if(G!==undefined){if(!F){z=H}C=C.replace(f.match[A],"");if(!e){return[]}break}}}if(C===s){if(e==null){b.error(C)}else{break}}s=C}return z};b.error=function(e){throw"Syntax error, unrecognized expression: "+e};var f=b.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")}},relative:{"+":function(x,r){var t=typeof r==="string",v=t&&!/\W/.test(r),y=t&&!v;if(v){r=r.toLowerCase()}for(var s=0,e=x.length,u;s<e;s++){if((u=x[s])){while((u=u.previousSibling)&&u.nodeType!==1){}x[s]=y||u&&u.nodeName.toLowerCase()===r?u||false:u===r}}if(y){b.filter(r,x,true)}},">":function(x,r){var u=typeof r==="string",v,s=0,e=x.length;if(u&&!/\W/.test(r)){r=r.toLowerCase();for(;s<e;s++){v=x[s];if(v){var t=v.parentNode;x[s]=t.nodeName.toLowerCase()===r?t:false}}}else{for(;s<e;s++){v=x[s];if(v){x[s]=u?v.parentNode:v.parentNode===r}}if(u){b.filter(r,x,true)}}},"":function(t,r,v){var s=j++,e=q,u;if(typeof r==="string"&&!/\W/.test(r)){r=r.toLowerCase();u=r;e=n}e("parentNode",r,s,t,u,v)},"~":function(t,r,v){var s=j++,e=q,u;if(typeof r==="string"&&!/\W/.test(r)){r=r.toLowerCase();u=r;e=n}e("previousSibling",r,s,t,u,v)}},find:{ID:function(r,s,t){if(typeof s.getElementById!=="undefined"&&!t){var e=s.getElementById(r[1]);return e?[e]:[]}},NAME:function(s,v){if(typeof v.getElementsByName!=="undefined"){var r=[],u=v.getElementsByName(s[1]);for(var t=0,e=u.length;t<e;t++){if(u[t].getAttribute("name")===s[1]){r.push(u[t])}}return r.length===0?null:r}},TAG:function(e,r){return r.getElementsByTagName(e[1])}},preFilter:{CLASS:function(t,r,s,e,x,y){t=" "+t[1].replace(/\\/g,"")+" ";if(y){return t}for(var u=0,v;(v=r[u])!=null;u++){if(v){if(x^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(t)>=0)){if(!s){e.push(v)}}else{if(s){r[u]=false}}}}return false},ID:function(e){return e[1].replace(/\\/g,"")},TAG:function(r,e){return r[1].toLowerCase()},CHILD:function(e){if(e[1]==="nth"){var r=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(e[2]==="even"&&"2n"||e[2]==="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(r[1]+(r[2]||1))-0;e[3]=r[3]-0}e[0]=j++;return e},ATTR:function(u,r,s,e,v,x){var t=u[1].replace(/\\/g,"");if(!x&&f.attrMap[t]){u[1]=f.attrMap[t]}if(u[2]==="~="){u[4]=" "+u[4]+" "}return u},PSEUDO:function(u,r,s,e,v){if(u[1]==="not"){if((p.exec(u[3])||"").length>1||/^\w/.test(u[3])){u[3]=b(u[3],null,null,r)}else{var t=b.filter(u[3],r,s,true^v);if(!s){e.push.apply(e,t)}return false}}else{if(f.match.POS.test(u[0])||f.match.CHILD.test(u[0])){return true}}return u},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){e.parentNode.selectedIndex;return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(s,r,e){return !!b(e[3],s).length},header:function(e){return(/h\d/i).test(e.nodeName)},text:function(e){return"text"===e.type},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toLowerCase()==="button"},input:function(e){return(/input|select|textarea|button/i).test(e.nodeName)}},setFilters:{first:function(r,e){return e===0},last:function(s,r,e,t){return r===t.length-1},even:function(r,e){return e%2===0},odd:function(r,e){return e%2===1},lt:function(s,r,e){return r<e[3]-0},gt:function(s,r,e){return r>e[3]-0},nth:function(s,r,e){return e[3]-0===r},eq:function(s,r,e){return e[3]-0===r}},filter:{PSEUDO:function(s,y,x,z){var e=y[1],r=f.filters[e];if(r){return r(s,x,y,z)}else{if(e==="contains"){return(s.textContent||s.innerText||b.getText([s])||"").indexOf(y[3])>=0}else{if(e==="not"){var t=y[3];for(var v=0,u=t.length;v<u;v++){if(t[v]===s){return false}}return true}else{b.error("Syntax error, unrecognized expression: "+e)}}}},CHILD:function(e,t){var x=t[1],r=e;switch(x){case"only":case"first":while((r=r.previousSibling)){if(r.nodeType===1){return false}}if(x==="first"){return true}r=e;case"last":while((r=r.nextSibling)){if(r.nodeType===1){return false}}return true;case"nth":var s=t[2],A=t[3];if(s===1&&A===0){return true}var v=t[0],z=e.parentNode;if(z&&(z.sizcache!==v||!e.nodeIndex)){var u=0;for(r=z.firstChild;r;r=r.nextSibling){if(r.nodeType===1){r.nodeIndex=++u}}z.sizcache=v}var y=e.nodeIndex-A;if(s===0){return y===0}else{return(y%s===0&&y/s>=0)}}},ID:function(r,e){return r.nodeType===1&&r.getAttribute("id")===e},TAG:function(r,e){return(e==="*"&&r.nodeType===1)||r.nodeName.toLowerCase()===e},CLASS:function(r,e){return(" "+(r.className||r.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(v,t){var s=t[1],e=f.attrHandle[s]?f.attrHandle[s](v):v[s]!=null?v[s]:v.getAttribute(s),x=e+"",u=t[2],r=t[4];return e==null?u==="!=":u==="="?x===r:u==="*="?x.indexOf(r)>=0:u==="~="?(" "+x+" ").indexOf(r)>=0:!r?x&&e!==false:u==="!="?x!==r:u==="^="?x.indexOf(r)===0:u==="$="?x.substr(x.length-r.length)===r:u==="|="?x===r||x.substr(0,r.length+1)===r+"-":false},POS:function(u,r,s,v){var e=r[2],t=f.setFilters[e];if(t){return t(u,s,r,v)}}}};var k=f.match.POS,g=function(r,e){return"\\"+(e-0+1)};for(var m in f.match){f.match[m]=new RegExp(f.match[m].source+(/(?![^\[]*\])(?![^\(]*\))/.source));f.leftMatch[m]=new RegExp(/(^(?:.|\r|\n)*?)/.source+f.match[m].source.replace(/\\(\d+)/g,g))}var a=function(r,e){r=Array.prototype.slice.call(r,0);if(e){e.push.apply(e,r);return e}return r};try{Array.prototype.slice.call(document.documentElement.childNodes,0)[0].nodeType}catch(l){a=function(u,t){var r=t||[],s=0;if(d.call(u)==="[object Array]"){Array.prototype.push.apply(r,u)}else{if(typeof u.length==="number"){for(var e=u.length;s<e;s++){r.push(u[s])}}else{for(;u[s];s++){r.push(u[s])}}}return r}}var c;if(document.documentElement.compareDocumentPosition){c=function(r,e){if(!r.compareDocumentPosition||!e.compareDocumentPosition){if(r==e){o=true}return r.compareDocumentPosition?-1:1}var s=r.compareDocumentPosition(e)&4?-1:r===e?0:1;if(s===0){o=true}return s}}else{if("sourceIndex" in document.documentElement){c=function(r,e){if(!r.sourceIndex||!e.sourceIndex){if(r==e){o=true}return r.sourceIndex?-1:1}var s=r.sourceIndex-e.sourceIndex;if(s===0){o=true}return s}}else{if(document.createRange){c=function(t,r){if(!t.ownerDocument||!r.ownerDocument){if(t==r){o=true}return t.ownerDocument?-1:1}var s=t.ownerDocument.createRange(),e=r.ownerDocument.createRange();s.setStart(t,0);s.setEnd(t,0);e.setStart(r,0);e.setEnd(r,0);var u=s.compareBoundaryPoints(Range.START_TO_END,e);if(u===0){o=true}return u}}}}b.getText=function(e){var r="",t;for(var s=0;e[s];s++){t=e[s];if(t.nodeType===3||t.nodeType===4){r+=t.nodeValue}else{if(t.nodeType!==8){r+=b.getText(t.childNodes)}}}return r};(function(){var r=document.createElement("div"),s="script"+(new Date()).getTime();r.innerHTML="<a name='"+s+"'/>";var e=document.documentElement;e.insertBefore(r,e.firstChild);if(document.getElementById(s)){f.find.ID=function(u,v,x){if(typeof v.getElementById!=="undefined"&&!x){var t=v.getElementById(u[1]);return t?t.id===u[1]||typeof t.getAttributeNode!=="undefined"&&t.getAttributeNode("id").nodeValue===u[1]?[t]:undefined:[]}};f.filter.ID=function(v,t){var u=typeof v.getAttributeNode!=="undefined"&&v.getAttributeNode("id");return v.nodeType===1&&u&&u.nodeValue===t}}e.removeChild(r);e=r=null})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){f.find.TAG=function(r,v){var u=v.getElementsByTagName(r[1]);if(r[1]==="*"){var t=[];for(var s=0;u[s];s++){if(u[s].nodeType===1){t.push(u[s])}}u=t}return u}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){f.attrHandle.href=function(r){return r.getAttribute("href",2)}}e=null})();if(document.querySelectorAll){(function(){var e=b,s=document.createElement("div");s.innerHTML="<p class='TEST'></p>";if(s.querySelectorAll&&s.querySelectorAll(".TEST").length===0){return}b=function(x,v,t,u){v=v||document;if(!u&&v.nodeType===9&&!b.isXML(v)){try{return a(v.querySelectorAll(x),t)}catch(y){}}return e(x,v,t,u)};for(var r in e){b[r]=e[r]}s=null})()}(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(!e.getElementsByClassName||e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}f.order.splice(1,0,"CLASS");f.find.CLASS=function(r,s,t){if(typeof s.getElementsByClassName!=="undefined"&&!t){return s.getElementsByClassName(r[1])}};e=null})();function n(r,x,v,A,y,z){for(var t=0,s=A.length;t<s;t++){var e=A[t];if(e){e=e[r];var u=false;while(e){if(e.sizcache===v){u=A[e.sizset];break}if(e.nodeType===1&&!z){e.sizcache=v;e.sizset=t}if(e.nodeName.toLowerCase()===x){u=e;break}e=e[r]}A[t]=u}}}function q(r,x,v,A,y,z){for(var t=0,s=A.length;t<s;t++){var e=A[t];if(e){e=e[r];var u=false;while(e){if(e.sizcache===v){u=A[e.sizset];break}if(e.nodeType===1){if(!z){e.sizcache=v;e.sizset=t}if(typeof x!=="string"){if(e===x){u=true;break}}else{if(b.filter(x,[e]).length>0){u=e;break}}}e=e[r]}A[t]=u}}}b.contains=document.compareDocumentPosition?function(r,e){return !!(r.compareDocumentPosition(e)&16)}:function(r,e){return r!==e&&(r.contains?r.contains(e):true)};b.isXML=function(e){var r=(e?e.ownerDocument||e:0).documentElement;return r?r.nodeName!=="HTML":false};var h=function(e,y){var t=[],u="",v,s=y.nodeType?[y]:y;while((v=f.match.PSEUDO.exec(e))){u+=v[0];e=e.replace(f.match.PSEUDO,"")}e=f.relative[e]?e+"*":e;for(var x=0,r=s.length;x<r;x++){b(e,s[x],t)}return b.filter(u,t)};window.tinymce.dom.Sizzle=b})();(function(d){var f=d.each,c=d.DOM,b=d.isIE,e=d.isWebKit,a;d.create("tinymce.dom.EventUtils",{EventUtils:function(){this.inits=[];this.events=[]},add:function(m,p,l,j){var g,h=this,i=h.events,k;if(p instanceof Array){k=[];f(p,function(o){k.push(h.add(m,o,l,j))});return k}if(m&&m.hasOwnProperty&&m instanceof Array){k=[];f(m,function(n){n=c.get(n);k.push(h.add(n,p,l,j))});return k}m=c.get(m);if(!m){return}g=function(n){if(h.disabled){return}n=n||window.event;if(n&&b){if(!n.target){n.target=n.srcElement}d.extend(n,h._stoppers)}if(!j){return l(n)}return l.call(j,n)};if(p=="unload"){d.unloads.unshift({func:g});return g}if(p=="init"){if(h.domLoaded){g()}else{h.inits.push(g)}return g}i.push({obj:m,name:p,func:l,cfunc:g,scope:j});h._add(m,p,g);return l},remove:function(l,m,k){var h=this,g=h.events,i=false,j;if(l&&l.hasOwnProperty&&l instanceof Array){j=[];f(l,function(n){n=c.get(n);j.push(h.remove(n,m,k))});return j}l=c.get(l);f(g,function(o,n){if(o.obj==l&&o.name==m&&(!k||(o.func==k||o.cfunc==k))){g.splice(n,1);h._remove(l,m,o.cfunc);i=true;return false}});return i},clear:function(l){var j=this,g=j.events,h,k;if(l){l=c.get(l);for(h=g.length-1;h>=0;h--){k=g[h];if(k.obj===l){j._remove(k.obj,k.name,k.cfunc);k.obj=k.cfunc=null;g.splice(h,1)}}}},cancel:function(g){if(!g){return false}this.stop(g);return this.prevent(g)},stop:function(g){if(g.stopPropagation){g.stopPropagation()}else{g.cancelBubble=true}return false},prevent:function(g){if(g.preventDefault){g.preventDefault()}else{g.returnValue=false}return false},destroy:function(){var g=this;f(g.events,function(j,h){g._remove(j.obj,j.name,j.cfunc);j.obj=j.cfunc=null});g.events=[];g=null},_add:function(h,i,g){if(h.attachEvent){h.attachEvent("on"+i,g)}else{if(h.addEventListener){h.addEventListener(i,g,false)}else{h["on"+i]=g}}},_remove:function(i,j,h){if(i){try{if(i.detachEvent){i.detachEvent("on"+j,h)}else{if(i.removeEventListener){i.removeEventListener(j,h,false)}else{i["on"+j]=null}}}catch(g){}}},_pageInit:function(h){var g=this;if(g.domLoaded){return}g.domLoaded=true;f(g.inits,function(i){i()});g.inits=[]},_wait:function(i){var g=this,h=i.document;if(i.tinyMCE_GZ&&tinyMCE_GZ.loaded){g.domLoaded=1;return}if(h.attachEvent){h.attachEvent("onreadystatechange",function(){if(h.readyState==="complete"){h.detachEvent("onreadystatechange",arguments.callee);g._pageInit(i)}});if(h.documentElement.doScroll&&i==i.top){(function(){if(g.domLoaded){return}try{h.documentElement.doScroll("left")}catch(j){setTimeout(arguments.callee,0);return}g._pageInit(i)})()}}else{if(h.addEventListener){g._add(i,"DOMContentLoaded",function(){g._pageInit(i)})}}g._add(i,"load",function(){g._pageInit(i)})},_stoppers:{preventDefault:function(){this.returnValue=false},stopPropagation:function(){this.cancelBubble=true}}});a=d.dom.Event=new d.dom.EventUtils();a._wait(window);d.addUnload(function(){a.destroy()})})(tinymce);(function(a){a.dom.Element=function(f,d){var b=this,e,c;b.settings=d=d||{};b.id=f;b.dom=e=d.dom||a.DOM;if(!a.isIE){c=e.get(b.id)}a.each(("getPos,getRect,getParent,add,setStyle,getStyle,setStyles,setAttrib,setAttribs,getAttrib,addClass,removeClass,hasClass,getOuterHTML,setOuterHTML,remove,show,hide,isHidden,setHTML,get").split(/,/),function(g){b[g]=function(){var h=[f],j;for(j=0;j<arguments.length;j++){h.push(arguments[j])}h=e[g].apply(e,h);b.update(g);return h}});a.extend(b,{on:function(i,h,g){return a.dom.Event.add(b.id,i,h,g)},getXY:function(){return{x:parseInt(b.getStyle("left")),y:parseInt(b.getStyle("top"))}},getSize:function(){var g=e.get(b.id);return{w:parseInt(b.getStyle("width")||g.clientWidth),h:parseInt(b.getStyle("height")||g.clientHeight)}},moveTo:function(g,h){b.setStyles({left:g,top:h})},moveBy:function(g,i){var h=b.getXY();b.moveTo(h.x+g,h.y+i)},resizeTo:function(g,i){b.setStyles({width:g,height:i})},resizeBy:function(g,j){var i=b.getSize();b.resizeTo(i.w+g,i.h+j)},update:function(h){var g;if(a.isIE6&&d.blocker){h=h||"";if(h.indexOf("get")===0||h.indexOf("has")===0||h.indexOf("is")===0){return}if(h=="remove"){e.remove(b.blocker);return}if(!b.blocker){b.blocker=e.uniqueId();g=e.add(d.container||e.getRoot(),"iframe",{id:b.blocker,style:"position:absolute;",frameBorder:0,src:'javascript:""'});e.setStyle(g,"opacity",0)}else{g=e.get(b.blocker)}e.setStyles(g,{left:b.getStyle("left",1),top:b.getStyle("top",1),width:b.getStyle("width",1),height:b.getStyle("height",1),display:b.getStyle("display",1),zIndex:parseInt(b.getStyle("zIndex",1)||0)-1})}}})}})(tinymce);(function(c){function e(f){return f.replace(/[\n\r]+/g,"")}var b=c.is,a=c.isIE,d=c.each;c.create("tinymce.dom.Selection",{Selection:function(i,h,g){var f=this;f.dom=i;f.win=h;f.serializer=g;d(["onBeforeSetContent","onBeforeGetContent","onSetContent","onGetContent"],function(j){f[j]=new c.util.Dispatcher(f)});if(!f.win.getSelection){f.tridentSel=new c.dom.TridentSelection(f)}if(c.isIE&&i.boxModel){this._fixIESelection()}c.addUnload(f.destroy,f)},getContent:function(g){var f=this,h=f.getRng(),l=f.dom.create("body"),j=f.getSel(),i,k,m;g=g||{};i=k="";g.get=true;g.format=g.format||"html";f.onBeforeGetContent.dispatch(f,g);if(g.format=="text"){return f.isCollapsed()?"":(h.text||(j.toString?j.toString():""))}if(h.cloneContents){m=h.cloneContents();if(m){l.appendChild(m)}}else{if(b(h.item)||b(h.htmlText)){l.innerHTML=h.item?h.item(0).outerHTML:h.htmlText}else{l.innerHTML=h.toString()}}if(/^\s/.test(l.innerHTML)){i=" "}if(/\s+$/.test(l.innerHTML)){k=" "}g.getInner=true;g.content=f.isCollapsed()?"":i+f.serializer.serialize(l,g)+k;f.onGetContent.dispatch(f,g);return g.content},setContent:function(j,i){var g=this,k=g.getRng(),n,l=g.win.document;i=i||{format:"html"};i.set=true;j=i.content=g.dom.processHTML(j);g.onBeforeSetContent.dispatch(g,i);j=i.content;if(k.insertNode){j+='<span id="__caret">_</span>';if(k.startContainer==l&&k.endContainer==l){l.body.innerHTML=j}else{k.deleteContents();if(l.body.childNodes.length==0){l.body.innerHTML=j}else{if(k.createContextualFragment){k.insertNode(k.createContextualFragment(j))}else{var m=l.createDocumentFragment(),f=l.createElement("div");m.appendChild(f);f.outerHTML=j;k.insertNode(m)}}}n=g.dom.get("__caret");k=l.createRange();k.setStartBefore(n);k.setEndBefore(n);g.setRng(k);g.dom.remove("__caret")}else{if(k.item){l.execCommand("Delete",false,null);k=g.getRng()}k.pasteHTML(j)}g.onSetContent.dispatch(g,i)},getStart:function(){var g=this.getRng(),h,f,j,i;if(g.duplicate||g.item){if(g.item){return g.item(0)}j=g.duplicate();j.collapse(1);h=j.parentElement();f=i=g.parentElement();while(i=i.parentNode){if(i==h){h=f;break}}if(h&&h.nodeName=="BODY"){return h.firstChild||h}return h}else{h=g.startContainer;if(h.nodeType==1&&h.hasChildNodes()){h=h.childNodes[Math.min(h.childNodes.length-1,g.startOffset)]}if(h&&h.nodeType==3){return h.parentNode}return h}},getEnd:function(){var g=this,h=g.getRng(),i,f;if(h.duplicate||h.item){if(h.item){return h.item(0)}h=h.duplicate();h.collapse(0);i=h.parentElement();if(i&&i.nodeName=="BODY"){return i.lastChild||i}return i}else{i=h.endContainer;f=h.endOffset;if(i.nodeType==1&&i.hasChildNodes()){i=i.childNodes[f>0?f-1:f]}if(i&&i.nodeType==3){return i.parentNode}return i}},getBookmark:function(q,r){var u=this,m=u.dom,g,j,i,n,h,o,p,l="\uFEFF",s;function f(v,x){var t=0;d(m.select(v),function(z,y){if(z==x){t=y}});return t}if(q==2){function k(){var v=u.getRng(true),t=m.getRoot(),x={};function y(B,G){var A=B[G?"startContainer":"endContainer"],F=B[G?"startOffset":"endOffset"],z=[],C,E,D=0;if(A.nodeType==3){if(r){for(C=A.previousSibling;C&&C.nodeType==3;C=C.previousSibling){F+=C.nodeValue.length}}z.push(F)}else{E=A.childNodes;if(F>=E.length&&E.length){D=1;F=Math.max(0,E.length-1)}z.push(u.dom.nodeIndex(E[F],r)+D)}for(;A&&A!=t;A=A.parentNode){z.push(u.dom.nodeIndex(A,r))}return z}x.start=y(v,true);if(!u.isCollapsed()){x.end=y(v)}return x}return k()}if(q){return{rng:u.getRng()}}g=u.getRng();i=m.uniqueId();n=tinyMCE.activeEditor.selection.isCollapsed();s="overflow:hidden;line-height:0px";if(g.duplicate||g.item){if(!g.item){j=g.duplicate();g.collapse();g.pasteHTML('<span _mce_type="bookmark" id="'+i+'_start" style="'+s+'">'+l+"</span>");if(!n){j.collapse(false);j.pasteHTML('<span _mce_type="bookmark" id="'+i+'_end" style="'+s+'">'+l+"</span>")}}else{o=g.item(0);h=o.nodeName;return{name:h,index:f(h,o)}}}else{o=u.getNode();h=o.nodeName;if(h=="IMG"){return{name:h,index:f(h,o)}}j=g.cloneRange();if(!n){j.collapse(false);j.insertNode(m.create("span",{_mce_type:"bookmark",id:i+"_end",style:s},l))}g.collapse(true);g.insertNode(m.create("span",{_mce_type:"bookmark",id:i+"_start",style:s},l))}u.moveToBookmark({id:i,keep:1});return{id:i}},moveToBookmark:function(n){var r=this,l=r.dom,i,h,f,q,j,s,o,p;if(r.tridentSel){r.tridentSel.destroy()}if(n){if(n.start){f=l.createRng();q=l.getRoot();function g(z){var t=n[z?"start":"end"],v,x,y,u;if(t){for(x=q,v=t.length-1;v>=1;v--){u=x.childNodes;if(u.length){x=u[t[v]]}}if(z){f.setStart(x,t[0])}else{f.setEnd(x,t[0])}}}g(true);g();r.setRng(f)}else{if(n.id){function k(A){var u=l.get(n.id+"_"+A),z,t,x,y,v=n.keep;if(u){z=u.parentNode;if(A=="start"){if(!v){t=l.nodeIndex(u)}else{z=u.firstChild;t=1}j=s=z;o=p=t}else{if(!v){t=l.nodeIndex(u)}else{z=u.firstChild;t=1}s=z;p=t}if(!v){y=u.previousSibling;x=u.nextSibling;d(c.grep(u.childNodes),function(B){if(B.nodeType==3){B.nodeValue=B.nodeValue.replace(/\uFEFF/g,"")}});while(u=l.get(n.id+"_"+A)){l.remove(u,1)}if(y&&x&&y.nodeType==x.nodeType&&y.nodeType==3&&!c.isOpera){t=y.nodeValue.length;y.appendData(x.nodeValue);l.remove(x);if(A=="start"){j=s=y;o=p=t}else{s=y;p=t}}}}}function m(t){if(!a&&l.isBlock(t)&&!t.innerHTML){t.innerHTML='<br _mce_bogus="1" />'}return t}k("start");k("end");if(j){f=l.createRng();f.setStart(m(j),o);f.setEnd(m(s),p);r.setRng(f)}}else{if(n.name){r.select(l.select(n.name)[n.index])}else{if(n.rng){r.setRng(n.rng)}}}}}},select:function(k,j){var i=this,l=i.dom,g=l.createRng(),f;f=l.nodeIndex(k);g.setStart(k.parentNode,f);g.setEnd(k.parentNode,f+1);if(j){function h(m,o){var n=new c.dom.TreeWalker(m,m);do{if(m.nodeType==3&&c.trim(m.nodeValue).length!=0){if(o){g.setStart(m,0)}else{g.setEnd(m,m.nodeValue.length)}return}if(m.nodeName=="BR"){if(o){g.setStartBefore(m)}else{g.setEndBefore(m)}return}}while(m=(o?n.next():n.prev()))}h(k,1);h(k)}i.setRng(g);return k},isCollapsed:function(){var f=this,h=f.getRng(),g=f.getSel();if(!h||h.item){return false}if(h.compareEndPoints){return h.compareEndPoints("StartToEnd",h)===0}return !g||h.collapsed},collapse:function(f){var g=this,h=g.getRng(),i;if(h.item){i=h.item(0);h=this.win.document.body.createTextRange();h.moveToElementText(i)}h.collapse(!!f);g.setRng(h)},getSel:function(){var g=this,f=this.win;return f.getSelection?f.getSelection():f.document.selection},getRng:function(l){var g=this,h,i,k,j=g.win.document;if(l&&g.tridentSel){return g.tridentSel.getRangeAt(0)}try{if(h=g.getSel()){i=h.rangeCount>0?h.getRangeAt(0):(h.createRange?h.createRange():j.createRange())}}catch(f){}if(c.isIE&&i.setStart&&j.selection.createRange().item){k=j.selection.createRange().item(0);i=j.createRange();i.setStartBefore(k);i.setEndAfter(k)}if(!i){i=j.createRange?j.createRange():j.body.createTextRange()}if(g.selectedRange&&g.explicitRange){if(i.compareBoundaryPoints(i.START_TO_START,g.selectedRange)===0&&i.compareBoundaryPoints(i.END_TO_END,g.selectedRange)===0){i=g.explicitRange}else{g.selectedRange=null;g.explicitRange=null}}return i},setRng:function(i){var h,g=this;if(!g.tridentSel){h=g.getSel();if(h){g.explicitRange=i;h.removeAllRanges();h.addRange(i);g.selectedRange=h.getRangeAt(0)}}else{if(i.cloneRange){g.tridentSel.addRange(i);return}try{i.select()}catch(f){}}},setNode:function(g){var f=this;f.setContent(f.dom.getOuterHTML(g));return g},getNode:function(){var g=this,f=g.getRng(),h=g.getSel(),i;if(f.setStart){if(!f){return g.dom.getRoot()}i=f.commonAncestorContainer;if(!f.collapsed){if(f.startContainer==f.endContainer){if(f.startOffset-f.endOffset<2){if(f.startContainer.hasChildNodes()){i=f.startContainer.childNodes[f.startOffset]}}}if(c.isWebKit&&h.anchorNode&&h.anchorNode.nodeType==1){return h.anchorNode.childNodes[h.anchorOffset]}}if(i&&i.nodeType==3){return i.parentNode}return i}return f.item?f.item(0):f.parentElement()},getSelectedBlocks:function(g,f){var i=this,j=i.dom,m,h,l,k=[];m=j.getParent(g||i.getStart(),j.isBlock);h=j.getParent(f||i.getEnd(),j.isBlock);if(m){k.push(m)}if(m&&h&&m!=h){l=m;while((l=l.nextSibling)&&l!=h){if(j.isBlock(l)){k.push(l)}}}if(h&&m!=h){k.push(h)}return k},destroy:function(g){var f=this;f.win=null;if(f.tridentSel){f.tridentSel.destroy()}if(!g){c.removeUnload(f.destroy)}},_fixIESelection:function(){var m=this.dom,l=m.doc,g=l.body,i,j;l.documentElement.unselectable=true;function k(n,q){var o=g.createTextRange();try{o.moveToPoint(n,q)}catch(p){o=null}return o}function h(o){var n;if(o.button){n=k(o.x,o.y);if(n){if(n.compareEndPoints("StartToStart",j)>0){n.setEndPoint("StartToStart",j)}else{n.setEndPoint("EndToEnd",j)}n.select()}}else{f()}}function f(){m.unbind(l,"mouseup",f);m.unbind(l,"mousemove",h);i=0}m.bind(l,"mousedown",function(n){if(n.target.nodeName==="HTML"){if(i){f()}i=1;j=k(n.x,n.y);if(j){m.bind(l,"mouseup",f);m.bind(l,"mousemove",h);m.win.focus();j.select()}}})}})})(tinymce);(function(a){a.create("tinymce.dom.XMLWriter",{node:null,XMLWriter:function(c){function b(){var e=document.implementation;if(!e||!e.createDocument){try{return new ActiveXObject("MSXML2.DOMDocument")}catch(d){}try{return new ActiveXObject("Microsoft.XmlDom")}catch(d){}}else{return e.createDocument("","",null)}}this.doc=b();this.valid=a.isOpera||a.isWebKit;this.reset()},reset:function(){var b=this,c=b.doc;if(c.firstChild){c.removeChild(c.firstChild)}b.node=c.appendChild(c.createElement("html"))},writeStartElement:function(c){var b=this;b.node=b.node.appendChild(b.doc.createElement(c))},writeAttribute:function(c,b){if(this.valid){b=b.replace(/>/g,"%MCGT%")}this.node.setAttribute(c,b)},writeEndElement:function(){this.node=this.node.parentNode},writeFullEndElement:function(){var b=this,c=b.node;c.appendChild(b.doc.createTextNode(""));b.node=c.parentNode},writeText:function(b){if(this.valid){b=b.replace(/>/g,"%MCGT%")}this.node.appendChild(this.doc.createTextNode(b))},writeCDATA:function(b){this.node.appendChild(this.doc.createCDATASection(b))},writeComment:function(b){if(a.isIE){b=b.replace(/^\-|\-$/g," ")}this.node.appendChild(this.doc.createComment(b.replace(/\-\-/g," ")))},getContent:function(){var b;b=this.doc.xml||new XMLSerializer().serializeToString(this.doc);b=b.replace(/<\?[^?]+\?>|<html[^>]*>|<\/html>|<html\/>|<!DOCTYPE[^>]+>/g,"");b=b.replace(/ ?\/>/g," />");if(this.valid){b=b.replace(/\%MCGT%/g,"&gt;")}return b}})})(tinymce);(function(c){var d=/[&\"<>]/g,b=/[<>&]/g,a={"&":"&amp;",'"':"&quot;","<":"&lt;",">":"&gt;"};c.create("tinymce.dom.StringWriter",{str:null,tags:null,count:0,settings:null,indent:null,StringWriter:function(e){this.settings=c.extend({indent_char:" ",indentation:0},e);this.reset()},reset:function(){this.indent="";this.str="";this.tags=[];this.count=0},writeStartElement:function(e){this._writeAttributesEnd();this.writeRaw("<"+e);this.tags.push(e);this.inAttr=true;this.count++;this.elementCount=this.count;this.attrs={}},writeAttribute:function(g,e){var f=this;if(!f.attrs[g]){f.writeRaw(" "+f.encode(g,true)+'="'+f.encode(e,true)+'"');f.attrs[g]=e}},writeEndElement:function(){var e;if(this.tags.length>0){e=this.tags.pop();if(this._writeAttributesEnd(1)){this.writeRaw("</"+e+">")}if(this.settings.indentation>0){this.writeRaw("\n")}}},writeFullEndElement:function(){if(this.tags.length>0){this._writeAttributesEnd();this.writeRaw("</"+this.tags.pop()+">");if(this.settings.indentation>0){this.writeRaw("\n")}}},writeText:function(e){this._writeAttributesEnd();this.writeRaw(this.encode(e));this.count++},writeCDATA:function(e){this._writeAttributesEnd();this.writeRaw("<![CDATA["+e+"]]>");this.count++},writeComment:function(e){this._writeAttributesEnd();this.writeRaw("<!--"+e+"-->");this.count++},writeRaw:function(e){this.str+=e},encode:function(f,e){return f.replace(e?d:b,function(g){return a[g]})},getContent:function(){return this.str},_writeAttributesEnd:function(e){if(!this.inAttr){return}this.inAttr=false;if(e&&this.elementCount==this.count){this.writeRaw(" />");return false}this.writeRaw(">");return true}})})(tinymce);(function(e){var g=e.extend,f=e.each,b=e.util.Dispatcher,d=e.isIE,a=e.isGecko;function c(h){return h.replace(/([?+*])/g,".$1")}e.create("tinymce.dom.Serializer",{Serializer:function(j){var i=this;i.key=0;i.onPreProcess=new b(i);i.onPostProcess=new b(i);try{i.writer=new e.dom.XMLWriter()}catch(h){i.writer=new e.dom.StringWriter()}if(e.isIE&&document.documentMode>8){i.writer=new e.dom.StringWriter()}i.settings=j=g({dom:e.DOM,valid_nodes:0,node_filter:0,attr_filter:0,invalid_attrs:/^(_mce_|_moz_|sizset|sizcache)/,closed:/^(br|hr|input|meta|img|link|param|area)$/,entity_encoding:"named",entities:"160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro",valid_elements:"*[*]",extended_valid_elements:0,invalid_elements:0,fix_table_elements:1,fix_list_elements:true,fix_content_duplication:true,convert_fonts_to_spans:false,font_size_classes:0,apply_source_formatting:0,indent_mode:"simple",indent_char:"\t",indent_levels:1,remove_linebreaks:1,remove_redundant_brs:1,element_format:"xhtml"},j);i.dom=j.dom;i.schema=j.schema;if(j.entity_encoding=="named"&&!j.entities){j.entity_encoding="raw"}if(j.remove_redundant_brs){i.onPostProcess.add(function(k,l){l.content=l.content.replace(/(<br \/>\s*)+<\/(p|h[1-6]|div|li)>/gi,function(n,m,o){if(/^<br \/>\s*<\//.test(n)){return"</"+o+">"}return n})})}if(j.element_format=="html"){i.onPostProcess.add(function(k,l){l.content=l.content.replace(/<([^>]+) \/>/g,"<$1>")})}if(j.fix_list_elements){i.onPreProcess.add(function(v,s){var l,z,y=["ol","ul"],u,t,q,k=/^(OL|UL)$/,A;function m(r,x){var o=x.split(","),p;while((r=r.previousSibling)!=null){for(p=0;p<o.length;p++){if(r.nodeName==o[p]){return r}}}return null}for(z=0;z<y.length;z++){l=i.dom.select(y[z],s.node);for(u=0;u<l.length;u++){t=l[u];q=t.parentNode;if(k.test(q.nodeName)){A=m(t,"LI");if(!A){A=i.dom.create("li");A.innerHTML="&nbsp;";A.appendChild(t);q.insertBefore(A,q.firstChild)}else{A.appendChild(t)}}}}})}if(j.fix_table_elements){i.onPreProcess.add(function(k,l){f(i.dom.select("p table",l.node).reverse(),function(p){var o=i.dom.getParent(p.parentNode,"table,p");if(o.nodeName!="TABLE"){try{i.dom.split(o,p)}catch(m){}}})})}},setEntities:function(o){var n=this,j,m,h={},k;if(n.entityLookup){return}j=o.split(",");for(m=0;m<j.length;m+=2){k=j[m];if(k==34||k==38||k==60||k==62){continue}h[String.fromCharCode(j[m])]=j[m+1];k=parseInt(j[m]).toString(16)}n.entityLookup=h},setRules:function(i){var h=this;h._setup();h.rules={};h.wildRules=[];h.validElements={};return h.addRules(i)},addRules:function(i){var h=this,j;if(!i){return}h._setup();f(i.split(","),function(m){var q=m.split(/\[|\]/),l=q[0].split("/"),r,k,o,n=[];if(j){k=e.extend([],j.attribs)}if(q.length>1){f(q[1].split("|"),function(u){var p={},t;k=k||[];u=u.replace(/::/g,"~");u=/^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(u);u[2]=u[2].replace(/~/g,":");if(u[1]=="!"){r=r||[];r.push(u[2])}if(u[1]=="-"){for(t=0;t<k.length;t++){if(k[t].name==u[2]){k.splice(t,1);return}}}switch(u[3]){case"=":p.defaultVal=u[4]||"";break;case":":p.forcedVal=u[4];break;case"<":p.validVals=u[4].split("?");break}if(/[*.?]/.test(u[2])){o=o||[];p.nameRE=new RegExp("^"+c(u[2])+"$");o.push(p)}else{p.name=u[2];k.push(p)}n.push(u[2])})}f(l,function(v,u){var y=v.charAt(0),t=1,p={};if(j){if(j.noEmpty){p.noEmpty=j.noEmpty}if(j.fullEnd){p.fullEnd=j.fullEnd}if(j.padd){p.padd=j.padd}}switch(y){case"-":p.noEmpty=true;break;case"+":p.fullEnd=true;break;case"#":p.padd=true;break;default:t=0}l[u]=v=v.substring(t);h.validElements[v]=1;if(/[*.?]/.test(l[0])){p.nameRE=new RegExp("^"+c(l[0])+"$");h.wildRules=h.wildRules||{};h.wildRules.push(p)}else{p.name=l[0];if(l[0]=="@"){j=p}h.rules[v]=p}p.attribs=k;if(r){p.requiredAttribs=r}if(o){v="";f(n,function(s){if(v){v+="|"}v+="("+c(s)+")"});p.validAttribsRE=new RegExp("^"+v.toLowerCase()+"$");p.wildAttribs=o}})});i="";f(h.validElements,function(m,l){if(i){i+="|"}if(l!="@"){i+=l}});h.validElementsRE=new RegExp("^("+c(i.toLowerCase())+")$")},findRule:function(m){var j=this,l=j.rules,h,k;j._setup();k=l[m];if(k){return k}l=j.wildRules;for(h=0;h<l.length;h++){if(l[h].nameRE.test(m)){return l[h]}}return null},findAttribRule:function(h,l){var j,k=h.wildAttribs;for(j=0;j<k.length;j++){if(k[j].nameRE.test(l)){return k[j]}}return null},serialize:function(r,q){var m,k=this,p,i,j,l;k._setup();q=q||{};q.format=q.format||"html";k.processObj=q;if(d){l=[];f(r.getElementsByTagName("option"),function(o){var h=k.dom.getAttrib(o,"selected");l.push(h?h:null)})}r=r.cloneNode(true);if(d){f(r.getElementsByTagName("option"),function(o,h){k.dom.setAttrib(o,"selected",l[h])})}j=r.ownerDocument.implementation;if(j.createHTMLDocument){p=j.createHTMLDocument("");f(r.nodeName=="BODY"?r.childNodes:[r],function(h){p.body.appendChild(p.importNode(h,true))});if(r.nodeName!="BODY"){r=p.body.firstChild}else{r=p.body}i=k.dom.doc;k.dom.doc=p}k.key=""+(parseInt(k.key)+1);if(!q.no_events){q.node=r;k.onPreProcess.dispatch(k,q)}k.writer.reset();k._info=q;k._serializeNode(r,q.getInner);q.content=k.writer.getContent();if(i){k.dom.doc=i}if(!q.no_events){k.onPostProcess.dispatch(k,q)}k._postProcess(q);q.node=null;return e.trim(q.content)},_postProcess:function(n){var i=this,k=i.settings,j=n.content,m=[],l;if(n.format=="html"){l=i._protect({content:j,patterns:[{pattern:/(<script[^>]*>)(.*?)(<\/script>)/g},{pattern:/(<noscript[^>]*>)(.*?)(<\/noscript>)/g},{pattern:/(<style[^>]*>)(.*?)(<\/style>)/g},{pattern:/(<pre[^>]*>)(.*?)(<\/pre>)/g,encode:1},{pattern:/(<!--\[CDATA\[)(.*?)(\]\]-->)/g}]});j=l.content;if(k.entity_encoding!=="raw"){j=i._encode(j)}if(!n.set){j=e._replace(/<p>\s+<\/p>|<p([^>]+)>\s+<\/p>/g,k.entity_encoding=="numeric"?"<p$1>&#160;</p>":"<p$1>&nbsp;</p>",j);if(k.remove_linebreaks){j=j.replace(/\r?\n|\r/g," ");j=e._replace(/(<[^>]+>)\s+/g,"$1 ",j);j=e._replace(/\s+(<\/[^>]+>)/g," $1",j);j=e._replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g,"<$1 $2>",j);j=e._replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g,"<$1>",j);j=e._replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g,"</$1>",j)}if(k.apply_source_formatting&&k.indent_mode=="simple"){j=e._replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g,"\n<$1$2$3>\n",j);j=e._replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g,"\n<$1$2>",j);j=e._replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g,"</$1>\n",j);j=j.replace(/\n\n/g,"\n")}}j=i._unprotect(j,l);j=e._replace(/<!--\[CDATA\[([\s\S]+)\]\]-->/g,"<![CDATA[$1]]>",j);if(k.entity_encoding=="raw"){j=e._replace(/<p>&nbsp;<\/p>|<p([^>]+)>&nbsp;<\/p>/g,"<p$1>\u00a0</p>",j)}j=j.replace(/<noscript([^>]+|)>([\s\S]*?)<\/noscript>/g,function(h,p,o){return"<noscript"+p+">"+i.dom.decode(o.replace(/<!--|-->/g,""))+"</noscript>"})}n.content=j},_serializeNode:function(E,J){var A=this,B=A.settings,y=A.writer,q,j,u,G,F,I,C,h,z,k,r,D,p,m,H,o,x;if(!B.node_filter||B.node_filter(E)){switch(E.nodeType){case 1:if(E.hasAttribute?E.hasAttribute("_mce_bogus"):E.getAttribute("_mce_bogus")){return}p=H=false;q=E.hasChildNodes();k=E.getAttribute("_mce_name")||E.nodeName.toLowerCase();o=E.getAttribute("_mce_type");if(o){if(!A._info.cleanup){p=true;return}else{H=1}}if(d){x=E.scopeName;if(x&&x!=="HTML"&&x!=="html"){k=x+":"+k}}if(k.indexOf("mce:")===0){k=k.substring(4)}if(!H){if(!A.validElementsRE||!A.validElementsRE.test(k)||(A.invalidElementsRE&&A.invalidElementsRE.test(k))||J){p=true;break}}if(d){if(B.fix_content_duplication){if(E._mce_serialized==A.key){return}E._mce_serialized=A.key}if(k.charAt(0)=="/"){k=k.substring(1)}}else{if(a){if(E.nodeName==="BR"&&E.getAttribute("type")=="_moz"){return}}}if(B.validate_children){if(A.elementName&&!A.schema.isValid(A.elementName,k)){p=true;break}A.elementName=k}r=A.findRule(k);if(!r){p=true;break}k=r.name||k;m=B.closed.test(k);if((!q&&r.noEmpty)||(d&&!k)){p=true;break}if(r.requiredAttribs){I=r.requiredAttribs;for(G=I.length-1;G>=0;G--){if(this.dom.getAttrib(E,I[G])!==""){break}}if(G==-1){p=true;break}}y.writeStartElement(k);if(r.attribs){for(G=0,C=r.attribs,F=C.length;G<F;G++){I=C[G];z=A._getAttrib(E,I);if(z!==null){y.writeAttribute(I.name,z)}}}if(r.validAttribsRE){C=A.dom.getAttribs(E);for(G=C.length-1;G>-1;G--){h=C[G];if(h.specified){I=h.nodeName.toLowerCase();if(B.invalid_attrs.test(I)||!r.validAttribsRE.test(I)){continue}D=A.findAttribRule(r,I);z=A._getAttrib(E,D,I);if(z!==null){y.writeAttribute(I,z)}}}}if(o&&H){y.writeAttribute("_mce_type",o)}if(k==="script"&&e.trim(E.innerHTML)){y.writeText("// ");y.writeCDATA(E.innerHTML.replace(/<!--|-->|<\[CDATA\[|\]\]>/g,""));q=false;break}if(r.padd){if(q&&(u=E.firstChild)&&u.nodeType===1&&E.childNodes.length===1){if(u.hasAttribute?u.hasAttribute("_mce_bogus"):u.getAttribute("_mce_bogus")){y.writeText("\u00a0")}}else{if(!q){y.writeText("\u00a0")}}}break;case 3:if(B.validate_children&&A.elementName&&!A.schema.isValid(A.elementName,"#text")){return}return y.writeText(E.nodeValue);case 4:return y.writeCDATA(E.nodeValue);case 8:return y.writeComment(E.nodeValue)}}else{if(E.nodeType==1){q=E.hasChildNodes()}}if(q&&!m){u=E.firstChild;while(u){A._serializeNode(u);A.elementName=k;u=u.nextSibling}}if(!p){if(!m){y.writeFullEndElement()}else{y.writeEndElement()}}},_protect:function(j){var i=this;j.items=j.items||[];function h(l){return l.replace(/[\r\n\\]/g,function(m){if(m==="\n"){return"\\n"}else{if(m==="\\"){return"\\\\"}}return"\\r"})}function k(l){return l.replace(/\\[\\rn]/g,function(m){if(m==="\\n"){return"\n"}else{if(m==="\\\\"){return"\\"}}return"\r"})}f(j.patterns,function(l){j.content=k(h(j.content).replace(l.pattern,function(n,o,m,p){m=k(m);if(l.encode){m=i._encode(m)}j.items.push(m);return o+"<!--mce:"+(j.items.length-1)+"-->"+p}))});return j},_unprotect:function(i,j){i=i.replace(/\<!--mce:([0-9]+)--\>/g,function(k,h){return j.items[parseInt(h)]});j.items=[];return i},_encode:function(m){var j=this,k=j.settings,i;if(k.entity_encoding!=="raw"){if(k.entity_encoding.indexOf("named")!=-1){j.setEntities(k.entities);i=j.entityLookup;m=m.replace(/[\u007E-\uFFFF]/g,function(h){var l;if(l=i[h]){h="&"+l+";"}return h})}if(k.entity_encoding.indexOf("numeric")!=-1){m=m.replace(/[\u007E-\uFFFF]/g,function(h){return"&#"+h.charCodeAt(0)+";"})}}return m},_setup:function(){var h=this,i=this.settings;if(h.done){return}h.done=1;h.setRules(i.valid_elements);h.addRules(i.extended_valid_elements);if(i.invalid_elements){h.invalidElementsRE=new RegExp("^("+c(i.invalid_elements.replace(/,/g,"|").toLowerCase())+")$")}if(i.attrib_value_filter){h.attribValueFilter=i.attribValueFilter}},_getAttrib:function(m,j,h){var l,k;h=h||j.name;if(j.forcedVal&&(k=j.forcedVal)){if(k==="{$uid}"){return this.dom.uniqueId()}return k}k=this.dom.getAttrib(m,h);switch(h){case"rowspan":case"colspan":if(k=="1"){k=""}break}if(this.attribValueFilter){k=this.attribValueFilter(h,k,m)}if(j.validVals){for(l=j.validVals.length-1;l>=0;l--){if(k==j.validVals[l]){break}}if(l==-1){return null}}if(k===""&&typeof(j.defaultVal)!="undefined"){k=j.defaultVal;if(k==="{$uid}"){return this.dom.uniqueId()}return k}else{if(h=="class"&&this.processObj.get){k=k.replace(/\s?mceItem\w+\s?/g,"")}}if(k===""){return null}return k}})})(tinymce);(function(a){a.dom.ScriptLoader=function(h){var c=0,k=1,i=2,l={},j=[],f={},d=[],g=0,e;function b(m,u){var v=this,q=a.DOM,s,o,r,n;function p(){q.remove(n);if(s){s.onreadystatechange=s.onload=s=null}u()}n=q.uniqueId();if(a.isIE6){o=new a.util.URI(m);r=location;if(o.host==r.hostname&&o.port==r.port&&(o.protocol+":")==r.protocol){a.util.XHR.send({url:a._addVer(o.getURI()),success:function(x){var t=q.create("script",{type:"text/javascript"});t.text=x;document.getElementsByTagName("head")[0].appendChild(t);q.remove(t);p()}});return}}s=q.create("script",{id:n,type:"text/javascript",src:a._addVer(m)});if(!a.isIE){s.onload=p}s.onreadystatechange=function(){var t=s.readyState;if(t=="complete"||t=="loaded"){p()}};(document.getElementsByTagName("head")[0]||document.body).appendChild(s)}this.isDone=function(m){return l[m]==i};this.markDone=function(m){l[m]=i};this.add=this.load=function(m,q,n){var o,p=l[m];if(p==e){j.push(m);l[m]=c}if(q){if(!f[m]){f[m]=[]}f[m].push({func:q,scope:n||this})}};this.loadQueue=function(n,m){this.loadScripts(j,n,m)};this.loadScripts=function(m,q,p){var o;function n(r){a.each(f[r],function(s){s.func.call(s.scope)});f[r]=e}d.push({func:q,scope:p||this});o=function(){var r=a.grep(m);m.length=0;a.each(r,function(s){if(l[s]==i){n(s);return}if(l[s]!=k){l[s]=k;g++;b(s,function(){l[s]=i;g--;n(s);o()})}});if(!g){a.each(d,function(s){s.func.call(s.scope)});d.length=0}};o()}};a.ScriptLoader=new a.dom.ScriptLoader()})(tinymce);tinymce.dom.TreeWalker=function(a,c){var b=a;function d(i,f,e,j){var h,g;if(i){if(!j&&i[f]){return i[f]}if(i!=c){h=i[e];if(h){return h}for(g=i.parentNode;g&&g!=c;g=g.parentNode){h=g[e];if(h){return h}}}}}this.current=function(){return b};this.next=function(e){return(b=d(b,"firstChild","nextSibling",e))};this.prev=function(e){return(b=d(b,"lastChild","lastSibling",e))}};(function(){var a={};function b(f,e){var d;function c(g){return g.replace(/[A-Z]+/g,function(h){return c(f[h])})}for(d in f){if(f.hasOwnProperty(d)){f[d]=c(f[d])}}c(e).replace(/#/g,"#text").replace(/(\w+)\[([^\]]+)\]/g,function(l,g,j){var h,k={};j=j.split(/\|/);for(h=j.length-1;h>=0;h--){k[j[h]]=1}a[g]=k})}b({Z:"#|H|K|N|O|P",Y:"#|X|form|R|Q",X:"p|T|div|U|W|isindex|fieldset|table",W:"pre|hr|blockquote|address|center|noframes",U:"ul|ol|dl|menu|dir",ZC:"#|p|Y|div|U|W|table|br|span|bdo|object|applet|img|map|K|N|Q",T:"h1|h2|h3|h4|h5|h6",ZB:"#|X|S|Q",S:"R|P",ZA:"#|a|G|J|M|O|P",R:"#|a|H|K|N|O",Q:"noscript|P",P:"ins|del|script",O:"input|select|textarea|label|button",N:"M|L",M:"em|strong|dfn|code|q|samp|kbd|var|cite|abbr|acronym",L:"sub|sup",K:"J|I",J:"tt|i|b|u|s|strike",I:"big|small|font|basefont",H:"G|F",G:"br|span|bdo",F:"object|applet|img|map|iframe"},"script[]style[]object[#|param|X|form|a|H|K|N|O|Q]param[]p[S]a[Z]br[]span[S]bdo[S]applet[#|param|X|form|a|H|K|N|O|Q]h1[S]img[]map[X|form|Q|area]h2[S]iframe[#|X|form|a|H|K|N|O|Q]h3[S]tt[S]i[S]b[S]u[S]s[S]strike[S]big[S]small[S]font[S]basefont[]em[S]strong[S]dfn[S]code[S]q[S]samp[S]kbd[S]var[S]cite[S]abbr[S]acronym[S]sub[S]sup[S]input[]select[optgroup|option]optgroup[option]option[]textarea[]label[S]button[#|p|T|div|U|W|table|G|object|applet|img|map|K|N|Q]h4[S]ins[#|X|form|a|H|K|N|O|Q]h5[S]del[#|X|form|a|H|K|N|O|Q]h6[S]div[#|X|form|a|H|K|N|O|Q]ul[li]li[#|X|form|a|H|K|N|O|Q]ol[li]dl[dt|dd]dt[S]dd[#|X|form|a|H|K|N|O|Q]menu[li]dir[li]pre[ZA]hr[]blockquote[#|X|form|a|H|K|N|O|Q]address[S|p]center[#|X|form|a|H|K|N|O|Q]noframes[#|X|form|a|H|K|N|O|Q]isindex[]fieldset[#|legend|X|form|a|H|K|N|O|Q]legend[S]table[caption|col|colgroup|thead|tfoot|tbody|tr]caption[S]col[]colgroup[col]thead[tr]tr[th|td]th[#|X|form|a|H|K|N|O|Q]form[#|X|a|H|K|N|O|Q]noscript[#|X|form|a|H|K|N|O|Q]td[#|X|form|a|H|K|N|O|Q]tfoot[tr]tbody[tr]area[]base[]body[#|X|form|a|H|K|N|O|Q]");tinymce.dom.Schema=function(){var c=this,d=a;c.isValid=function(f,e){var g=d[f];return !!(g&&(!e||g[e]))}}})();(function(a){a.dom.RangeUtils=function(c){var b="\uFEFF";this.walk=function(d,r){var h=d.startContainer,k=d.startOffset,s=d.endContainer,l=d.endOffset,i,f,n,g,q,p,e;e=c.select("td.mceSelected,th.mceSelected");if(e.length>0){a.each(e,function(t){r([t])});return}function o(v,u,t){var x=[];for(;v&&v!=t;v=v[u]){x.push(v)}return x}function m(u,t){do{if(u.parentNode==t){return u}u=u.parentNode}while(u)}function j(v,u,x){var t=x?"nextSibling":"previousSibling";for(g=v,q=g.parentNode;g&&g!=u;g=q){q=g.parentNode;p=o(g==v?g:g[t],t);if(p.length){if(!x){p.reverse()}r(p)}}}if(h.nodeType==1&&h.hasChildNodes()){h=h.childNodes[k]}if(s.nodeType==1&&s.hasChildNodes()){s=s.childNodes[Math.min(k==l?l:l-1,s.childNodes.length-1)]}i=c.findCommonAncestor(h,s);if(h==s){return r([h])}for(g=h;g;g=g.parentNode){if(g==s){return j(h,i,true)}if(g==i){break}}for(g=s;g;g=g.parentNode){if(g==h){return j(s,i)}if(g==i){break}}f=m(h,i)||h;n=m(s,i)||s;j(h,f,true);p=o(f==h?f:f.nextSibling,"nextSibling",n==s?n.nextSibling:n);if(p.length){r(p)}j(s,n)}};a.dom.RangeUtils.compareRanges=function(c,b){if(c&&b){if(c.item||c.duplicate){if(c.item&&b.item&&c.item(0)===b.item(0)){return true}if(c.isEqual&&b.isEqual&&b.isEqual(c)){return true}}else{return c.startContainer==b.startContainer&&c.startOffset==b.startOffset}}return false}})(tinymce);(function(c){var b=c.DOM,a=c.is;c.create("tinymce.ui.Control",{Control:function(e,d){this.id=e;this.settings=d=d||{};this.rendered=false;this.onRender=new c.util.Dispatcher(this);this.classPrefix="";this.scope=d.scope||this;this.disabled=0;this.active=0},setDisabled:function(d){var f;if(d!=this.disabled){f=b.get(this.id);if(f&&this.settings.unavailable_prefix){if(d){this.prevTitle=f.title;f.title=this.settings.unavailable_prefix+": "+f.title}else{f.title=this.prevTitle}}this.setState("Disabled",d);this.setState("Enabled",!d);this.disabled=d}},isDisabled:function(){return this.disabled},setActive:function(d){if(d!=this.active){this.setState("Active",d);this.active=d}},isActive:function(){return this.active},setState:function(f,d){var e=b.get(this.id);f=this.classPrefix+f;if(d){b.addClass(e,f)}else{b.removeClass(e,f)}},isRendered:function(){return this.rendered},renderHTML:function(){},renderTo:function(d){b.setHTML(d,this.renderHTML())},postRender:function(){var e=this,d;if(a(e.disabled)){d=e.disabled;e.disabled=-1;e.setDisabled(d)}if(a(e.active)){d=e.active;e.active=-1;e.setActive(d)}},remove:function(){b.remove(this.id);this.destroy()},destroy:function(){c.dom.Event.clear(this.id)}})})(tinymce);tinymce.create("tinymce.ui.Container:tinymce.ui.Control",{Container:function(b,a){this.parent(b,a);this.controls=[];this.lookup={}},add:function(a){this.lookup[a.id]=a;this.controls.push(a);return a},get:function(a){return this.lookup[a]}});tinymce.create("tinymce.ui.Separator:tinymce.ui.Control",{Separator:function(b,a){this.parent(b,a);this.classPrefix="mceSeparator"},renderHTML:function(){return tinymce.DOM.createHTML("span",{"class":this.classPrefix})}});(function(d){var c=d.is,b=d.DOM,e=d.each,a=d.walk;d.create("tinymce.ui.MenuItem:tinymce.ui.Control",{MenuItem:function(g,f){this.parent(g,f);this.classPrefix="mceMenuItem"},setSelected:function(f){this.setState("Selected",f);this.selected=f},isSelected:function(){return this.selected},postRender:function(){var f=this;f.parent();if(c(f.selected)){f.setSelected(f.selected)}}})})(tinymce);(function(d){var c=d.is,b=d.DOM,e=d.each,a=d.walk;d.create("tinymce.ui.Menu:tinymce.ui.MenuItem",{Menu:function(h,g){var f=this;f.parent(h,g);f.items={};f.collapsed=false;f.menuCount=0;f.onAddItem=new d.util.Dispatcher(this)},expand:function(g){var f=this;if(g){a(f,function(h){if(h.expand){h.expand()}},"items",f)}f.collapsed=false},collapse:function(g){var f=this;if(g){a(f,function(h){if(h.collapse){h.collapse()}},"items",f)}f.collapsed=true},isCollapsed:function(){return this.collapsed},add:function(f){if(!f.settings){f=new d.ui.MenuItem(f.id||b.uniqueId(),f)}this.onAddItem.dispatch(this,f);return this.items[f.id]=f},addSeparator:function(){return this.add({separator:true})},addMenu:function(f){if(!f.collapse){f=this.createMenu(f)}this.menuCount++;return this.add(f)},hasMenus:function(){return this.menuCount!==0},remove:function(f){delete this.items[f.id]},removeAll:function(){var f=this;a(f,function(g){if(g.removeAll){g.removeAll()}else{g.remove()}g.destroy()},"items",f);f.items={}},createMenu:function(g){var f=new d.ui.Menu(g.id||b.uniqueId(),g);f.onAddItem.add(this.onAddItem.dispatch,this.onAddItem);return f}})})(tinymce);(function(e){var d=e.is,c=e.DOM,f=e.each,a=e.dom.Event,b=e.dom.Element;e.create("tinymce.ui.DropMenu:tinymce.ui.Menu",{DropMenu:function(h,g){g=g||{};g.container=g.container||c.doc.body;g.offset_x=g.offset_x||0;g.offset_y=g.offset_y||0;g.vp_offset_x=g.vp_offset_x||0;g.vp_offset_y=g.vp_offset_y||0;if(d(g.icons)&&!g.icons){g["class"]+=" mceNoIcons"}this.parent(h,g);this.onShowMenu=new e.util.Dispatcher(this);this.onHideMenu=new e.util.Dispatcher(this);this.classPrefix="mceMenu"},createMenu:function(j){var h=this,i=h.settings,g;j.container=j.container||i.container;j.parent=h;j.constrain=j.constrain||i.constrain;j["class"]=j["class"]||i["class"];j.vp_offset_x=j.vp_offset_x||i.vp_offset_x;j.vp_offset_y=j.vp_offset_y||i.vp_offset_y;g=new e.ui.DropMenu(j.id||c.uniqueId(),j);g.onAddItem.add(h.onAddItem.dispatch,h.onAddItem);return g},update:function(){var i=this,j=i.settings,g=c.get("menu_"+i.id+"_tbl"),l=c.get("menu_"+i.id+"_co"),h,k;h=j.max_width?Math.min(g.clientWidth,j.max_width):g.clientWidth;k=j.max_height?Math.min(g.clientHeight,j.max_height):g.clientHeight;if(!c.boxModel){i.element.setStyles({width:h+2,height:k+2})}else{i.element.setStyles({width:h,height:k})}if(j.max_width){c.setStyle(l,"width",h)}if(j.max_height){c.setStyle(l,"height",k);if(g.clientHeight<j.max_height){c.setStyle(l,"overflow","hidden")}}},showMenu:function(p,n,r){var z=this,A=z.settings,o,g=c.getViewPort(),u,l,v,q,i=2,k,j,m=z.classPrefix;z.collapse(1);if(z.isMenuVisible){return}if(!z.rendered){o=c.add(z.settings.container,z.renderNode());f(z.items,function(h){h.postRender()});z.element=new b("menu_"+z.id,{blocker:1,container:A.container})}else{o=c.get("menu_"+z.id)}if(!e.isOpera){c.setStyles(o,{left:-65535,top:-65535})}c.show(o);z.update();p+=A.offset_x||0;n+=A.offset_y||0;g.w-=4;g.h-=4;if(A.constrain){u=o.clientWidth-i;l=o.clientHeight-i;v=g.x+g.w;q=g.y+g.h;if((p+A.vp_offset_x+u)>v){p=r?r-u:Math.max(0,(v-A.vp_offset_x)-u)}if((n+A.vp_offset_y+l)>q){n=Math.max(0,(q-A.vp_offset_y)-l)}}c.setStyles(o,{left:p,top:n});z.element.update();z.isMenuVisible=1;z.mouseClickFunc=a.add(o,"click",function(s){var h;s=s.target;if(s&&(s=c.getParent(s,"tr"))&&!c.hasClass(s,m+"ItemSub")){h=z.items[s.id];if(h.isDisabled()){return}k=z;while(k){if(k.hideMenu){k.hideMenu()}k=k.settings.parent}if(h.settings.onclick){h.settings.onclick(s)}return a.cancel(s)}});if(z.hasMenus()){z.mouseOverFunc=a.add(o,"mouseover",function(x){var h,t,s;x=x.target;if(x&&(x=c.getParent(x,"tr"))){h=z.items[x.id];if(z.lastMenu){z.lastMenu.collapse(1)}if(h.isDisabled()){return}if(x&&c.hasClass(x,m+"ItemSub")){t=c.getRect(x);h.showMenu((t.x+t.w-i),t.y-i,t.x);z.lastMenu=h;c.addClass(c.get(h.id).firstChild,m+"ItemActive")}}})}z.onShowMenu.dispatch(z);if(A.keyboard_focus){a.add(o,"keydown",z._keyHandler,z);c.select("a","menu_"+z.id)[0].focus();z._focusIdx=0}},hideMenu:function(j){var g=this,i=c.get("menu_"+g.id),h;if(!g.isMenuVisible){return}a.remove(i,"mouseover",g.mouseOverFunc);a.remove(i,"click",g.mouseClickFunc);a.remove(i,"keydown",g._keyHandler);c.hide(i);g.isMenuVisible=0;if(!j){g.collapse(1)}if(g.element){g.element.hide()}if(h=c.get(g.id)){c.removeClass(h.firstChild,g.classPrefix+"ItemActive")}g.onHideMenu.dispatch(g)},add:function(i){var g=this,h;i=g.parent(i);if(g.isRendered&&(h=c.get("menu_"+g.id))){g._add(c.select("tbody",h)[0],i)}return i},collapse:function(g){this.parent(g);this.hideMenu(1)},remove:function(g){c.remove(g.id);this.destroy();return this.parent(g)},destroy:function(){var g=this,h=c.get("menu_"+g.id);a.remove(h,"mouseover",g.mouseOverFunc);a.remove(h,"click",g.mouseClickFunc);if(g.element){g.element.remove()}c.remove(h)},renderNode:function(){var i=this,j=i.settings,l,h,k,g;g=c.create("div",{id:"menu_"+i.id,"class":j["class"],style:"position:absolute;left:0;top:0;z-index:200000"});k=c.add(g,"div",{id:"menu_"+i.id+"_co","class":i.classPrefix+(j["class"]?" "+j["class"]:"")});i.element=new b("menu_"+i.id,{blocker:1,container:j.container});if(j.menu_line){c.add(k,"span",{"class":i.classPrefix+"Line"})}l=c.add(k,"table",{id:"menu_"+i.id+"_tbl",border:0,cellPadding:0,cellSpacing:0});h=c.add(l,"tbody");f(i.items,function(m){i._add(h,m)});i.rendered=true;return g},_keyHandler:function(j){var i=this,h=j.keyCode;function g(m){var k=i._focusIdx+m,l=c.select("a","menu_"+i.id)[k];if(l){i._focusIdx=k;l.focus()}}switch(h){case 38:g(-1);return;case 40:g(1);return;case 13:return;case 27:return this.hideMenu()}},_add:function(j,h){var i,q=h.settings,p,l,k,m=this.classPrefix,g;if(q.separator){l=c.add(j,"tr",{id:h.id,"class":m+"ItemSeparator"});c.add(l,"td",{"class":m+"ItemSeparator"});if(i=l.previousSibling){c.addClass(i,"mceLast")}return}i=l=c.add(j,"tr",{id:h.id,"class":m+"Item "+m+"ItemEnabled"});i=k=c.add(i,"td");i=p=c.add(i,"a",{href:"javascript:;",onclick:"return false;",onmousedown:"return false;"});c.addClass(k,q["class"]);g=c.add(i,"span",{"class":"mceIcon"+(q.icon?" mce_"+q.icon:"")});if(q.icon_src){c.add(g,"img",{src:q.icon_src})}i=c.add(i,q.element||"span",{"class":"mceText",title:h.settings.title},h.settings.title);if(h.settings.style){c.setAttrib(i,"style",h.settings.style)}if(j.childNodes.length==1){c.addClass(l,"mceFirst")}if((i=l.previousSibling)&&c.hasClass(i,m+"ItemSeparator")){c.addClass(l,"mceFirst")}if(h.collapse){c.addClass(l,m+"ItemSub")}if(i=l.previousSibling){c.removeClass(i,"mceLast")}c.addClass(l,"mceLast")}})})(tinymce);(function(b){var a=b.DOM;b.create("tinymce.ui.Button:tinymce.ui.Control",{Button:function(d,c){this.parent(d,c);this.classPrefix="mceButton"},renderHTML:function(){var f=this.classPrefix,e=this.settings,d,c;c=a.encode(e.label||"");d='<a id="'+this.id+'" href="javascript:;" class="'+f+" "+f+"Enabled "+e["class"]+(c?" "+f+"Labeled":"")+'" onmousedown="return false;" onclick="return false;" title="'+a.encode(e.title)+'">';if(e.image){d+='<img class="mceIcon" src="'+e.image+'" />'+c+"</a>"}else{d+='<span class="mceIcon '+e["class"]+'"></span>'+(c?'<span class="'+f+'Label">'+c+"</span>":"")+"</a>"}return d},postRender:function(){var c=this,d=c.settings;b.dom.Event.add(c.id,"click",function(f){if(!c.isDisabled()){return d.onclick.call(d.scope,f)}})}})})(tinymce);(function(d){var c=d.DOM,b=d.dom.Event,e=d.each,a=d.util.Dispatcher;d.create("tinymce.ui.ListBox:tinymce.ui.Control",{ListBox:function(h,g){var f=this;f.parent(h,g);f.items=[];f.onChange=new a(f);f.onPostRender=new a(f);f.onAdd=new a(f);f.onRenderMenu=new d.util.Dispatcher(this);f.classPrefix="mceListBox"},select:function(h){var g=this,j,i;if(h==undefined){return g.selectByIndex(-1)}if(h&&h.call){i=h}else{i=function(f){return f==h}}if(h!=g.selectedValue){e(g.items,function(k,f){if(i(k.value)){j=1;g.selectByIndex(f);return false}});if(!j){g.selectByIndex(-1)}}},selectByIndex:function(f){var g=this,h,i;if(f!=g.selectedIndex){h=c.get(g.id+"_text");i=g.items[f];if(i){g.selectedValue=i.value;g.selectedIndex=f;c.setHTML(h,c.encode(i.title));c.removeClass(h,"mceTitle")}else{c.setHTML(h,c.encode(g.settings.title));c.addClass(h,"mceTitle");g.selectedValue=g.selectedIndex=null}h=0}},add:function(i,f,h){var g=this;h=h||{};h=d.extend(h,{title:i,value:f});g.items.push(h);g.onAdd.dispatch(g,h)},getLength:function(){return this.items.length},renderHTML:function(){var i="",f=this,g=f.settings,j=f.classPrefix;i='<table id="'+f.id+'" cellpadding="0" cellspacing="0" class="'+j+" "+j+"Enabled"+(g["class"]?(" "+g["class"]):"")+'"><tbody><tr>';i+="<td>"+c.createHTML("a",{id:f.id+"_text",href:"javascript:;","class":"mceText",onclick:"return false;",onmousedown:"return false;"},c.encode(f.settings.title))+"</td>";i+="<td>"+c.createHTML("a",{id:f.id+"_open",tabindex:-1,href:"javascript:;","class":"mceOpen",onclick:"return false;",onmousedown:"return false;"},"<span></span>")+"</td>";i+="</tr></tbody></table>";return i},showMenu:function(){var g=this,j,i,h=c.get(this.id),f;if(g.isDisabled()||g.items.length==0){return}if(g.menu&&g.menu.isMenuVisible){return g.hideMenu()}if(!g.isMenuRendered){g.renderMenu();g.isMenuRendered=true}j=c.getPos(this.settings.menu_container);i=c.getPos(h);f=g.menu;f.settings.offset_x=i.x;f.settings.offset_y=i.y;f.settings.keyboard_focus=!d.isOpera;if(g.oldID){f.items[g.oldID].setSelected(0)}e(g.items,function(k){if(k.value===g.selectedValue){f.items[k.id].setSelected(1);g.oldID=k.id}});f.showMenu(0,h.clientHeight);b.add(c.doc,"mousedown",g.hideMenu,g);c.addClass(g.id,g.classPrefix+"Selected")},hideMenu:function(g){var f=this;if(f.menu&&f.menu.isMenuVisible){if(g&&g.type=="mousedown"&&(g.target.id==f.id+"_text"||g.target.id==f.id+"_open")){return}if(!g||!c.getParent(g.target,".mceMenu")){c.removeClass(f.id,f.classPrefix+"Selected");b.remove(c.doc,"mousedown",f.hideMenu,f);f.menu.hideMenu()}}},renderMenu:function(){var g=this,f;f=g.settings.control_manager.createDropMenu(g.id+"_menu",{menu_line:1,"class":g.classPrefix+"Menu mceNoIcons",max_width:150,max_height:150});f.onHideMenu.add(g.hideMenu,g);f.add({title:g.settings.title,"class":"mceMenuItemTitle",onclick:function(){if(g.settings.onselect("")!==false){g.select("")}}});e(g.items,function(h){if(h.value===undefined){f.add({title:h.title,"class":"mceMenuItemTitle",onclick:function(){if(g.settings.onselect("")!==false){g.select("")}}})}else{h.id=c.uniqueId();h.onclick=function(){if(g.settings.onselect(h.value)!==false){g.select(h.value)}};f.add(h)}});g.onRenderMenu.dispatch(g,f);g.menu=f},postRender:function(){var f=this,g=f.classPrefix;b.add(f.id,"click",f.showMenu,f);b.add(f.id+"_text","focus",function(){if(!f._focused){f.keyDownHandler=b.add(f.id+"_text","keydown",function(k){var h=-1,i,j=k.keyCode;e(f.items,function(l,m){if(f.selectedValue==l.value){h=m}});if(j==38){i=f.items[h-1]}else{if(j==40){i=f.items[h+1]}else{if(j==13){i=f.selectedValue;f.selectedValue=null;f.settings.onselect(i);return b.cancel(k)}}}if(i){f.hideMenu();f.select(i.value)}})}f._focused=1});b.add(f.id+"_text","blur",function(){b.remove(f.id+"_text","keydown",f.keyDownHandler);f._focused=0});if(d.isIE6||!c.boxModel){b.add(f.id,"mouseover",function(){if(!c.hasClass(f.id,g+"Disabled")){c.addClass(f.id,g+"Hover")}});b.add(f.id,"mouseout",function(){if(!c.hasClass(f.id,g+"Disabled")){c.removeClass(f.id,g+"Hover")}})}f.onPostRender.dispatch(f,c.get(f.id))},destroy:function(){this.parent();b.clear(this.id+"_text");b.clear(this.id+"_open")}})})(tinymce);(function(d){var c=d.DOM,b=d.dom.Event,e=d.each,a=d.util.Dispatcher;d.create("tinymce.ui.NativeListBox:tinymce.ui.ListBox",{NativeListBox:function(g,f){this.parent(g,f);this.classPrefix="mceNativeListBox"},setDisabled:function(f){c.get(this.id).disabled=f},isDisabled:function(){return c.get(this.id).disabled},select:function(h){var g=this,j,i;if(h==undefined){return g.selectByIndex(-1)}if(h&&h.call){i=h}else{i=function(f){return f==h}}if(h!=g.selectedValue){e(g.items,function(k,f){if(i(k.value)){j=1;g.selectByIndex(f);return false}});if(!j){g.selectByIndex(-1)}}},selectByIndex:function(f){c.get(this.id).selectedIndex=f+1;this.selectedValue=this.items[f]?this.items[f].value:null},add:function(j,g,f){var i,h=this;f=f||{};f.value=g;if(h.isRendered()){c.add(c.get(this.id),"option",f,j)}i={title:j,value:g,attribs:f};h.items.push(i);h.onAdd.dispatch(h,i)},getLength:function(){return this.items.length},renderHTML:function(){var g,f=this;g=c.createHTML("option",{value:""},"-- "+f.settings.title+" --");e(f.items,function(h){g+=c.createHTML("option",{value:h.value},h.title)});g=c.createHTML("select",{id:f.id,"class":"mceNativeListBox"},g);return g},postRender:function(){var g=this,h;g.rendered=true;function f(j){var i=g.items[j.target.selectedIndex-1];if(i&&(i=i.value)){g.onChange.dispatch(g,i);if(g.settings.onselect){g.settings.onselect(i)}}}b.add(g.id,"change",f);b.add(g.id,"keydown",function(j){var i;b.remove(g.id,"change",h);i=b.add(g.id,"blur",function(){b.add(g.id,"change",f);b.remove(g.id,"blur",i)});if(j.keyCode==13||j.keyCode==32){f(j);return b.cancel(j)}});g.onPostRender.dispatch(g,c.get(g.id))}})})(tinymce);(function(c){var b=c.DOM,a=c.dom.Event,d=c.each;c.create("tinymce.ui.MenuButton:tinymce.ui.Button",{MenuButton:function(f,e){this.parent(f,e);this.onRenderMenu=new c.util.Dispatcher(this);e.menu_container=e.menu_container||b.doc.body},showMenu:function(){var g=this,j,i,h=b.get(g.id),f;if(g.isDisabled()){return}if(!g.isMenuRendered){g.renderMenu();g.isMenuRendered=true}if(g.isMenuVisible){return g.hideMenu()}j=b.getPos(g.settings.menu_container);i=b.getPos(h);f=g.menu;f.settings.offset_x=i.x;f.settings.offset_y=i.y;f.settings.vp_offset_x=i.x;f.settings.vp_offset_y=i.y;f.settings.keyboard_focus=g._focused;f.showMenu(0,h.clientHeight);a.add(b.doc,"mousedown",g.hideMenu,g);g.setState("Selected",1);g.isMenuVisible=1},renderMenu:function(){var f=this,e;e=f.settings.control_manager.createDropMenu(f.id+"_menu",{menu_line:1,"class":this.classPrefix+"Menu",icons:f.settings.icons});e.onHideMenu.add(f.hideMenu,f);f.onRenderMenu.dispatch(f,e);f.menu=e},hideMenu:function(g){var f=this;if(g&&g.type=="mousedown"&&b.getParent(g.target,function(h){return h.id===f.id||h.id===f.id+"_open"})){return}if(!g||!b.getParent(g.target,".mceMenu")){f.setState("Selected",0);a.remove(b.doc,"mousedown",f.hideMenu,f);if(f.menu){f.menu.hideMenu()}}f.isMenuVisible=0},postRender:function(){var e=this,f=e.settings;a.add(e.id,"click",function(){if(!e.isDisabled()){if(f.onclick){f.onclick(e.value)}e.showMenu()}})}})})(tinymce);(function(c){var b=c.DOM,a=c.dom.Event,d=c.each;c.create("tinymce.ui.SplitButton:tinymce.ui.MenuButton",{SplitButton:function(f,e){this.parent(f,e);this.classPrefix="mceSplitButton"},renderHTML:function(){var i,f=this,g=f.settings,e;i="<tbody><tr>";if(g.image){e=b.createHTML("img ",{src:g.image,"class":"mceAction "+g["class"]})}else{e=b.createHTML("span",{"class":"mceAction "+g["class"]},"")}i+="<td>"+b.createHTML("a",{id:f.id+"_action",href:"javascript:;","class":"mceAction "+g["class"],onclick:"return false;",onmousedown:"return false;",title:g.title},e)+"</td>";e=b.createHTML("span",{"class":"mceOpen "+g["class"]});i+="<td>"+b.createHTML("a",{id:f.id+"_open",href:"javascript:;","class":"mceOpen "+g["class"],onclick:"return false;",onmousedown:"return false;",title:g.title},e)+"</td>";i+="</tr></tbody>";return b.createHTML("table",{id:f.id,"class":"mceSplitButton mceSplitButtonEnabled "+g["class"],cellpadding:"0",cellspacing:"0",onmousedown:"return false;",title:g.title},i)},postRender:function(){var e=this,f=e.settings;if(f.onclick){a.add(e.id+"_action","click",function(){if(!e.isDisabled()){f.onclick(e.value)}})}a.add(e.id+"_open","click",e.showMenu,e);a.add(e.id+"_open","focus",function(){e._focused=1});a.add(e.id+"_open","blur",function(){e._focused=0});if(c.isIE6||!b.boxModel){a.add(e.id,"mouseover",function(){if(!b.hasClass(e.id,"mceSplitButtonDisabled")){b.addClass(e.id,"mceSplitButtonHover")}});a.add(e.id,"mouseout",function(){if(!b.hasClass(e.id,"mceSplitButtonDisabled")){b.removeClass(e.id,"mceSplitButtonHover")}})}},destroy:function(){this.parent();a.clear(this.id+"_action");a.clear(this.id+"_open")}})})(tinymce);(function(d){var c=d.DOM,a=d.dom.Event,b=d.is,e=d.each;d.create("tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton",{ColorSplitButton:function(h,g){var f=this;f.parent(h,g);f.settings=g=d.extend({colors:"000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF",grid_width:8,default_color:"#888888"},f.settings);f.onShowMenu=new d.util.Dispatcher(f);f.onHideMenu=new d.util.Dispatcher(f);f.value=g.default_color},showMenu:function(){var f=this,g,j,i,h;if(f.isDisabled()){return}if(!f.isMenuRendered){f.renderMenu();f.isMenuRendered=true}if(f.isMenuVisible){return f.hideMenu()}i=c.get(f.id);c.show(f.id+"_menu");c.addClass(i,"mceSplitButtonSelected");h=c.getPos(i);c.setStyles(f.id+"_menu",{left:h.x,top:h.y+i.clientHeight,zIndex:200000});i=0;a.add(c.doc,"mousedown",f.hideMenu,f);f.onShowMenu.dispatch(f);if(f._focused){f._keyHandler=a.add(f.id+"_menu","keydown",function(k){if(k.keyCode==27){f.hideMenu()}});c.select("a",f.id+"_menu")[0].focus()}f.isMenuVisible=1},hideMenu:function(g){var f=this;if(g&&g.type=="mousedown"&&c.getParent(g.target,function(h){return h.id===f.id+"_open"})){return}if(!g||!c.getParent(g.target,".mceSplitButtonMenu")){c.removeClass(f.id,"mceSplitButtonSelected");a.remove(c.doc,"mousedown",f.hideMenu,f);a.remove(f.id+"_menu","keydown",f._keyHandler);c.hide(f.id+"_menu")}f.onHideMenu.dispatch(f);f.isMenuVisible=0},renderMenu:function(){var k=this,f,j=0,l=k.settings,p,h,o,g;g=c.add(l.menu_container,"div",{id:k.id+"_menu","class":l.menu_class+" "+l["class"],style:"position:absolute;left:0;top:-1000px;"});f=c.add(g,"div",{"class":l["class"]+" mceSplitButtonMenu"});c.add(f,"span",{"class":"mceMenuLine"});p=c.add(f,"table",{"class":"mceColorSplitMenu"});h=c.add(p,"tbody");j=0;e(b(l.colors,"array")?l.colors:l.colors.split(","),function(i){i=i.replace(/^#/,"");if(!j--){o=c.add(h,"tr");j=l.grid_width-1}p=c.add(o,"td");p=c.add(p,"a",{href:"javascript:;",style:{backgroundColor:"#"+i},_mce_color:"#"+i})});if(l.more_colors_func){p=c.add(h,"tr");p=c.add(p,"td",{colspan:l.grid_width,"class":"mceMoreColors"});p=c.add(p,"a",{id:k.id+"_more",href:"javascript:;",onclick:"return false;","class":"mceMoreColors"},l.more_colors_title);a.add(p,"click",function(i){l.more_colors_func.call(l.more_colors_scope||this);return a.cancel(i)})}c.addClass(f,"mceColorSplitMenu");a.add(k.id+"_menu","click",function(i){var m;i=i.target;if(i.nodeName=="A"&&(m=i.getAttribute("_mce_color"))){k.setColor(m)}return a.cancel(i)});return g},setColor:function(g){var f=this;c.setStyle(f.id+"_preview","backgroundColor",g);f.value=g;f.hideMenu();f.settings.onselect(g)},postRender:function(){var f=this,g=f.id;f.parent();c.add(g+"_action","div",{id:g+"_preview","class":"mceColorPreview"});c.setStyle(f.id+"_preview","backgroundColor",f.value)},destroy:function(){this.parent();a.clear(this.id+"_menu");a.clear(this.id+"_more");c.remove(this.id+"_menu")}})})(tinymce);tinymce.create("tinymce.ui.Toolbar:tinymce.ui.Container",{renderHTML:function(){var l=this,e="",g,j,b=tinymce.DOM,m=l.settings,d,a,f,k;k=l.controls;for(d=0;d<k.length;d++){j=k[d];a=k[d-1];f=k[d+1];if(d===0){g="mceToolbarStart";if(j.Button){g+=" mceToolbarStartButton"}else{if(j.SplitButton){g+=" mceToolbarStartSplitButton"}else{if(j.ListBox){g+=" mceToolbarStartListBox"}}}e+=b.createHTML("td",{"class":g},b.createHTML("span",null,"<!-- IE -->"))}if(a&&j.ListBox){if(a.Button||a.SplitButton){e+=b.createHTML("td",{"class":"mceToolbarEnd"},b.createHTML("span",null,"<!-- IE -->"))}}if(b.stdMode){e+='<td style="position: relative">'+j.renderHTML()+"</td>"}else{e+="<td>"+j.renderHTML()+"</td>"}if(f&&j.ListBox){if(f.Button||f.SplitButton){e+=b.createHTML("td",{"class":"mceToolbarStart"},b.createHTML("span",null,"<!-- IE -->"))}}}g="mceToolbarEnd";if(j.Button){g+=" mceToolbarEndButton"}else{if(j.SplitButton){g+=" mceToolbarEndSplitButton"}else{if(j.ListBox){g+=" mceToolbarEndListBox"}}}e+=b.createHTML("td",{"class":g},b.createHTML("span",null,"<!-- IE -->"));return b.createHTML("table",{id:l.id,"class":"mceToolbar"+(m["class"]?" "+m["class"]:""),cellpadding:"0",cellspacing:"0",align:l.settings.align||""},"<tbody><tr>"+e+"</tr></tbody>")}});(function(b){var a=b.util.Dispatcher,c=b.each;b.create("tinymce.AddOnManager",{AddOnManager:function(){var d=this;d.items=[];d.urls={};d.lookup={};d.onAdd=new a(d)},get:function(d){return this.lookup[d]},requireLangPack:function(e){var d=b.settings;if(d&&d.language){b.ScriptLoader.add(this.urls[e]+"/langs/"+d.language+".js")}},add:function(e,d){this.items.push(d);this.lookup[e]=d;this.onAdd.dispatch(this,e,d);return d},load:function(h,e,d,g){var f=this;if(f.urls[h]){return}if(e.indexOf("/")!=0&&e.indexOf("://")==-1){e=b.baseURL+"/"+e}f.urls[h]=e.substring(0,e.lastIndexOf("/"));if(!f.lookup[h]){b.ScriptLoader.add(e,d,g)}}});b.PluginManager=new b.AddOnManager();b.ThemeManager=new b.AddOnManager()}(tinymce));(function(j){var g=j.each,d=j.extend,k=j.DOM,i=j.dom.Event,f=j.ThemeManager,b=j.PluginManager,e=j.explode,h=j.util.Dispatcher,a,c=0;j.documentBaseURL=window.location.href.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,"");if(!/[\/\\]$/.test(j.documentBaseURL)){j.documentBaseURL+="/"}j.baseURL=new j.util.URI(j.documentBaseURL).toAbsolute(j.baseURL);j.baseURI=new j.util.URI(j.baseURL);j.onBeforeUnload=new h(j);i.add(window,"beforeunload",function(l){j.onBeforeUnload.dispatch(j,l)});j.onAddEditor=new h(j);j.onRemoveEditor=new h(j);j.EditorManager=d(j,{editors:[],i18n:{},activeEditor:null,init:function(q){var n=this,p,l=j.ScriptLoader,u,o=[],m;function r(x,y,t){var v=x[y];if(!v){return}if(j.is(v,"string")){t=v.replace(/\.\w+$/,"");t=t?j.resolve(t):0;v=j.resolve(v)}return v.apply(t||this,Array.prototype.slice.call(arguments,2))}q=d({theme:"simple",language:"en"},q);n.settings=q;i.add(document,"init",function(){var s,v;r(q,"onpageload");switch(q.mode){case"exact":s=q.elements||"";if(s.length>0){g(e(s),function(x){if(k.get(x)){m=new j.Editor(x,q);o.push(m);m.render(1)}else{g(document.forms,function(y){g(y.elements,function(z){if(z.name===x){x="mce_editor_"+c++;k.setAttrib(z,"id",x);m=new j.Editor(x,q);o.push(m);m.render(1)}})})}})}break;case"textareas":case"specific_textareas":function t(y,x){return x.constructor===RegExp?x.test(y.className):k.hasClass(y,x)}g(k.select("textarea"),function(x){if(q.editor_deselector&&t(x,q.editor_deselector)){return}if(!q.editor_selector||t(x,q.editor_selector)){u=k.get(x.name);if(!x.id&&!u){x.id=x.name}if(!x.id||n.get(x.id)){x.id=k.uniqueId()}m=new j.Editor(x.id,q);o.push(m);m.render(1)}});break}if(q.oninit){s=v=0;g(o,function(x){v++;if(!x.initialized){x.onInit.add(function(){s++;if(s==v){r(q,"oninit")}})}else{s++}if(s==v){r(q,"oninit")}})}})},get:function(l){if(l===a){return this.editors}return this.editors[l]},getInstanceById:function(l){return this.get(l)},add:function(m){var l=this,n=l.editors;n[m.id]=m;n.push(m);l._setActive(m);l.onAddEditor.dispatch(l,m);return m},remove:function(n){var m=this,l,o=m.editors;if(!o[n.id]){return null}delete o[n.id];for(l=0;l<o.length;l++){if(o[l]==n){o.splice(l,1);break}}if(m.activeEditor==n){m._setActive(o[0])}n.destroy();m.onRemoveEditor.dispatch(m,n);return n},execCommand:function(r,p,o){var q=this,n=q.get(o),l;switch(r){case"mceFocus":n.focus();return true;case"mceAddEditor":case"mceAddControl":if(!q.get(o)){new j.Editor(o,q.settings).render()}return true;case"mceAddFrameControl":l=o.window;l.tinyMCE=tinyMCE;l.tinymce=j;j.DOM.doc=l.document;j.DOM.win=l;n=new j.Editor(o.element_id,o);n.render();if(j.isIE){function m(){n.destroy();l.detachEvent("onunload",m);l=l.tinyMCE=l.tinymce=null}l.attachEvent("onunload",m)}o.page_window=null;return true;case"mceRemoveEditor":case"mceRemoveControl":if(n){n.remove()}return true;case"mceToggleEditor":if(!n){q.execCommand("mceAddControl",0,o);return true}if(n.isHidden()){n.show()}else{n.hide()}return true}if(q.activeEditor){return q.activeEditor.execCommand(r,p,o)}return false},execInstanceCommand:function(p,o,n,m){var l=this.get(p);if(l){return l.execCommand(o,n,m)}return false},triggerSave:function(){g(this.editors,function(l){l.save()})},addI18n:function(n,q){var l,m=this.i18n;if(!j.is(n,"string")){g(n,function(r,p){g(r,function(t,s){g(t,function(v,u){if(s==="common"){m[p+"."+u]=v}else{m[p+"."+s+"."+u]=v}})})})}else{g(q,function(r,p){m[n+"."+p]=r})}},_setActive:function(l){this.selectedInstance=this.activeEditor=l}})})(tinymce);(function(m){var n=m.DOM,j=m.dom.Event,f=m.extend,k=m.util.Dispatcher,i=m.each,a=m.isGecko,b=m.isIE,e=m.isWebKit,d=m.is,h=m.ThemeManager,c=m.PluginManager,o=m.inArray,l=m.grep,g=m.explode;m.create("tinymce.Editor",{Editor:function(r,q){var p=this;p.id=p.editorId=r;p.execCommands={};p.queryStateCommands={};p.queryValueCommands={};p.isNotDirty=false;p.plugins={};i(["onPreInit","onBeforeRenderUI","onPostRender","onInit","onRemove","onActivate","onDeactivate","onClick","onEvent","onMouseUp","onMouseDown","onDblClick","onKeyDown","onKeyUp","onKeyPress","onContextMenu","onSubmit","onReset","onPaste","onPreProcess","onPostProcess","onBeforeSetContent","onBeforeGetContent","onSetContent","onGetContent","onLoadContent","onSaveContent","onNodeChange","onChange","onBeforeExecCommand","onExecCommand","onUndo","onRedo","onVisualAid","onSetProgressState"],function(s){p[s]=new k(p)});p.settings=q=f({id:r,language:"en",docs_language:"en",theme:"simple",skin:"default",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:m.documentBaseURL,add_form_submit_trigger:1,submit_patch:1,add_unload_trigger:1,convert_urls:1,relative_urls:1,remove_script_host:1,table_inline_editing:0,object_resizing:1,cleanup:1,accessibility_focus:1,custom_shortcuts:1,custom_undo_redo_keyboard_shortcuts:1,custom_undo_redo_restore_selection:1,custom_undo_redo:1,doctype:m.isIE6?'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">':"<!DOCTYPE>",visual_table_class:"mceItemTable",visual:1,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",apply_source_formatting:1,directionality:"ltr",forced_root_block:"p",valid_elements:"@[id|class|style|title|dir<ltr?rtl|lang|xml::lang|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur],strong/b,em/i,strike,u,#p,-ol[type|compact],-ul[type|compact],-li,br,img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],-sub,-sup,-blockquote[cite],-table[border|cellspacing|cellpadding|width|frame|rules|height|align|summary|bgcolor|background|bordercolor],-tr[rowspan|width|height|align|valign|bgcolor|background|bordercolor],tbody,thead,tfoot,#td[colspan|rowspan|width|height|align|valign|bgcolor|background|bordercolor|scope],#th[colspan|rowspan|width|height|align|valign|scope],caption,-div,-span,-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr[size|noshade],-font[face|size|color],dd,dl,dt,cite,abbr,acronym,del[datetime|cite],ins[datetime|cite],object[classid|width|height|codebase|*],param[name|value],embed[type|width|height|src|*],script[src|type],map[name],area[shape|coords|href|alt|target],bdo,button,col[align|char|charoff|span|valign|width],colgroup[align|char|charoff|span|valign|width],dfn,fieldset,form[action|accept|accept-charset|enctype|method],input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value|tabindex|accesskey],kbd,label[for],legend,noscript,optgroup[label|disabled],option[disabled|label|selected|value],q[cite],samp,select[disabled|multiple|name|size],small,textarea[cols|rows|disabled|name|readonly],tt,var,big",hidden_input:1,padd_empty_editor:1,render_ui:1,init_theme:1,force_p_newlines:1,indentation:"30px",keep_styles:1,fix_table_elements:1,inline_styles:1,convert_fonts_to_spans:true},q);p.documentBaseURI=new m.util.URI(q.document_base_url||m.documentBaseURL,{base_uri:tinyMCE.baseURI});p.baseURI=m.baseURI;p.execCallback("setup",p)},render:function(r){var u=this,v=u.settings,x=u.id,p=m.ScriptLoader;if(!j.domLoaded){j.add(document,"init",function(){u.render()});return}tinyMCE.settings=v;if(!u.getElement()){return}if(m.isIDevice){return}if(!/TEXTAREA|INPUT/i.test(u.getElement().nodeName)&&v.hidden_input&&n.getParent(x,"form")){n.insertAfter(n.create("input",{type:"hidden",name:x}),x)}if(m.WindowManager){u.windowManager=new m.WindowManager(u)}if(v.encoding=="xml"){u.onGetContent.add(function(s,t){if(t.save){t.content=n.encode(t.content)}})}if(v.add_form_submit_trigger){u.onSubmit.addToTop(function(){if(u.initialized){u.save();u.isNotDirty=1}})}if(v.add_unload_trigger){u._beforeUnload=tinyMCE.onBeforeUnload.add(function(){if(u.initialized&&!u.destroyed&&!u.isHidden()){u.save({format:"raw",no_events:true})}})}m.addUnload(u.destroy,u);if(v.submit_patch){u.onBeforeRenderUI.add(function(){var s=u.getElement().form;if(!s){return}if(s._mceOldSubmit){return}if(!s.submit.nodeType&&!s.submit.length){u.formElement=s;s._mceOldSubmit=s.submit;s.submit=function(){m.triggerSave();u.isNotDirty=1;return u.formElement._mceOldSubmit(u.formElement)}}s=null})}function q(){if(v.language){p.add(m.baseURL+"/langs/"+v.language+".js")}if(v.theme&&v.theme.charAt(0)!="-"&&!h.urls[v.theme]){h.load(v.theme,"themes/"+v.theme+"/editor_template"+m.suffix+".js")}i(g(v.plugins),function(s){if(s&&s.charAt(0)!="-"&&!c.urls[s]){if(s=="safari"){return}c.load(s,"plugins/"+s+"/editor_plugin"+m.suffix+".js")}});p.loadQueue(function(){if(!u.removed){u.init()}})}q()},init:function(){var r,E=this,F=E.settings,B,y,A=E.getElement(),q,p,C,x,z,D;m.add(E);if(F.theme){F.theme=F.theme.replace(/-/,"");q=h.get(F.theme);E.theme=new q();if(E.theme.init&&F.init_theme){E.theme.init(E,h.urls[F.theme]||m.documentBaseURL.replace(/\/$/,""))}}i(g(F.plugins.replace(/\-/g,"")),function(G){var H=c.get(G),t=c.urls[G]||m.documentBaseURL.replace(/\/$/,""),s;if(H){s=new H(E,t);E.plugins[G]=s;if(s.init){s.init(E,t)}}});if(F.popup_css!==false){if(F.popup_css){F.popup_css=E.documentBaseURI.toAbsolute(F.popup_css)}else{F.popup_css=E.baseURI.toAbsolute("themes/"+F.theme+"/skins/"+F.skin+"/dialog.css")}}if(F.popup_css_add){F.popup_css+=","+E.documentBaseURI.toAbsolute(F.popup_css_add)}E.controlManager=new m.ControlManager(E);if(F.custom_undo_redo){E.onBeforeExecCommand.add(function(t,G,u,H,s){if(G!="Undo"&&G!="Redo"&&G!="mceRepaint"&&(!s||!s.skip_undo)){if(!E.undoManager.hasUndo()){E.undoManager.add()}}});E.onExecCommand.add(function(t,G,u,H,s){if(G!="Undo"&&G!="Redo"&&G!="mceRepaint"&&(!s||!s.skip_undo)){E.undoManager.add()}})}E.onExecCommand.add(function(s,t){if(!/^(FontName|FontSize)$/.test(t)){E.nodeChanged()}});if(a){function v(s,t){if(!t||!t.initial){E.execCommand("mceRepaint")}}E.onUndo.add(v);E.onRedo.add(v);E.onSetContent.add(v)}E.onBeforeRenderUI.dispatch(E,E.controlManager);if(F.render_ui){B=F.width||A.style.width||A.offsetWidth;y=F.height||A.style.height||A.offsetHeight;E.orgDisplay=A.style.display;D=/^[0-9\.]+(|px)$/i;if(D.test(""+B)){B=Math.max(parseInt(B)+(q.deltaWidth||0),100)}if(D.test(""+y)){y=Math.max(parseInt(y)+(q.deltaHeight||0),100)}q=E.theme.renderUI({targetNode:A,width:B,height:y,deltaWidth:F.delta_width,deltaHeight:F.delta_height});E.editorContainer=q.editorContainer}if(document.domain&&location.hostname!=document.domain){m.relaxedDomain=document.domain}n.setStyles(q.sizeContainer||q.editorContainer,{width:B,height:y});y=(q.iframeHeight||y)+(typeof(y)=="number"?(q.deltaHeight||0):"");if(y<100){y=100}E.iframeHTML=F.doctype+'<html><head xmlns="http://www.w3.org/1999/xhtml">';if(F.document_base_url!=m.documentBaseURL){E.iframeHTML+='<base href="'+E.documentBaseURI.getURI()+'" />'}E.iframeHTML+='<meta http-equiv="X-UA-Compatible" content="IE=7" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';if(m.relaxedDomain){E.iframeHTML+='<script type="text/javascript">document.domain = "'+m.relaxedDomain+'";<\/script>'}x=F.body_id||"tinymce";if(x.indexOf("=")!=-1){x=E.getParam("body_id","","hash");x=x[E.id]||x}z=F.body_class||"";if(z.indexOf("=")!=-1){z=E.getParam("body_class","","hash");z=z[E.id]||""}E.iframeHTML+='</head><body id="'+x+'" class="mceContentBody '+z+'"></body></html>';if(m.relaxedDomain){if(b||(m.isOpera&&parseFloat(opera.version())>=9.5)){C='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinyMCE.get("'+E.id+'");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()'}else{if(m.isOpera){C='javascript:(function(){document.open();document.domain="'+document.domain+'";document.close();ed.setupIframe();})()'}}}r=n.add(q.iframeContainer,"iframe",{id:E.id+"_ifr",src:C||'javascript:""',frameBorder:"0",style:{width:"100%",height:y}});E.contentAreaContainer=q.iframeContainer;n.get(q.editorContainer).style.display=E.orgDisplay;n.get(E.id).style.display="none";if(!b||!m.relaxedDomain){E.setupIframe()}A=r=q=null},setupIframe:function(){var z=this,A=z.settings,r=n.get(z.id),u=z.getDoc(),q,x;if(!b||!m.relaxedDomain){u.open();u.write(z.iframeHTML);u.close()}if(!b){try{if(!A.readonly){u.designMode="On"}}catch(v){}}if(b){x=z.getBody();n.hide(x);if(!A.readonly){x.contentEditable=true}n.show(x)}z.dom=new m.dom.DOMUtils(z.getDoc(),{keep_values:true,url_converter:z.convertURL,url_converter_scope:z,hex_colors:A.force_hex_style_colors,class_filter:A.class_filter,update_styles:1,fix_ie_paragraphs:1,valid_styles:A.valid_styles});z.schema=new m.dom.Schema();z.serializer=new m.dom.Serializer(f(A,{valid_elements:A.verify_html===false?"*[*]":A.valid_elements,dom:z.dom,schema:z.schema}));z.selection=new m.dom.Selection(z.dom,z.getWin(),z.serializer);z.formatter=new m.Formatter(this);z.formatter.register({alignleft:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"left"}},{selector:"img,table",styles:{"float":"left"}}],aligncenter:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"center"}},{selector:"img",styles:{display:"block",marginLeft:"auto",marginRight:"auto"}},{selector:"table",styles:{marginLeft:"auto",marginRight:"auto"}}],alignright:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"right"}},{selector:"img,table",styles:{"float":"right"}}],alignfull:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"justify"}}],bold:[{inline:"strong"},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b"}],italic:[{inline:"em"},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i"}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:true},{inline:"u"}],strikethrough:[{inline:"span",styles:{textDecoration:"line-through"},exact:true},{inline:"u"}],forecolor:{inline:"span",styles:{color:"%value"},wrap_links:false},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},wrap_links:false},fontname:{inline:"span",styles:{fontFamily:"%value"}},fontsize:{inline:"span",styles:{fontSize:"%value"}},fontsize_class:{inline:"span",attributes:{"class":"%value"}},blockquote:{block:"blockquote",wrapper:1,remove:"all"},removeformat:[{selector:"b,strong,em,i,font,u,strike",remove:"all",split:true,expand:false,block_expand:true,deep:true},{selector:"span",attributes:["style","class"],remove:"empty",split:true,expand:false,deep:true},{selector:"*",attributes:["style","class"],split:false,expand:false,deep:true}]});i("p h1 h2 h3 h4 h5 h6 div address pre div code dt dd samp".split(/\s/),function(s){z.formatter.register(s,{block:s,remove:"all"})});z.formatter.register(z.settings.formats);z.undoManager=new m.UndoManager(z);z.undoManager.onAdd.add(function(t,s){if(!s.initial){return z.onChange.dispatch(z,s,t)}});z.undoManager.onUndo.add(function(t,s){return z.onUndo.dispatch(z,s,t)});z.undoManager.onRedo.add(function(t,s){return z.onRedo.dispatch(z,s,t)});z.forceBlocks=new m.ForceBlocks(z,{forced_root_block:A.forced_root_block});z.editorCommands=new m.EditorCommands(z);z.serializer.onPreProcess.add(function(s,t){return z.onPreProcess.dispatch(z,t,s)});z.serializer.onPostProcess.add(function(s,t){return z.onPostProcess.dispatch(z,t,s)});z.onPreInit.dispatch(z);if(!A.gecko_spellcheck){z.getBody().spellcheck=0}if(!A.readonly){z._addEvents()}z.controlManager.onPostRender.dispatch(z,z.controlManager);z.onPostRender.dispatch(z);if(A.directionality){z.getBody().dir=A.directionality}if(A.nowrap){z.getBody().style.whiteSpace="nowrap"}if(A.custom_elements){function y(s,t){i(g(A.custom_elements),function(B){var C;if(B.indexOf("~")===0){B=B.substring(1);C="span"}else{C="div"}t.content=t.content.replace(new RegExp("<("+B+")([^>]*)>","g"),"<"+C+' _mce_name="$1"$2>');t.content=t.content.replace(new RegExp("</("+B+")>","g"),"</"+C+">")})}z.onBeforeSetContent.add(y);z.onPostProcess.add(function(s,t){if(t.set){y(s,t)}})}if(A.handle_node_change_callback){z.onNodeChange.add(function(t,s,B){z.execCallback("handle_node_change_callback",z.id,B,-1,-1,true,z.selection.isCollapsed())})}if(A.save_callback){z.onSaveContent.add(function(s,B){var t=z.execCallback("save_callback",z.id,B.content,z.getBody());if(t){B.content=t}})}if(A.onchange_callback){z.onChange.add(function(t,s){z.execCallback("onchange_callback",z,s)})}if(A.convert_newlines_to_brs){z.onBeforeSetContent.add(function(s,t){if(t.initial){t.content=t.content.replace(/\r?\n/g,"<br />")}})}if(A.fix_nesting&&b){z.onBeforeSetContent.add(function(s,t){t.content=z._fixNesting(t.content)})}if(A.preformatted){z.onPostProcess.add(function(s,t){t.content=t.content.replace(/^\s*<pre.*?>/,"");t.content=t.content.replace(/<\/pre>\s*$/,"");if(t.set){t.content='<pre class="mceItemHidden">'+t.content+"</pre>"}})}if(A.verify_css_classes){z.serializer.attribValueFilter=function(D,B){var C,t;if(D=="class"){if(!z.classesRE){t=z.dom.getClasses();if(t.length>0){C="";i(t,function(s){C+=(C?"|":"")+s["class"]});z.classesRE=new RegExp("("+C+")","gi")}}return !z.classesRE||/(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(B)||z.classesRE.test(B)?B:""}return B}}if(A.cleanup_callback){z.onBeforeSetContent.add(function(s,t){t.content=z.execCallback("cleanup_callback","insert_to_editor",t.content,t)});z.onPreProcess.add(function(s,t){if(t.set){z.execCallback("cleanup_callback","insert_to_editor_dom",t.node,t)}if(t.get){z.execCallback("cleanup_callback","get_from_editor_dom",t.node,t)}});z.onPostProcess.add(function(s,t){if(t.set){t.content=z.execCallback("cleanup_callback","insert_to_editor",t.content,t)}if(t.get){t.content=z.execCallback("cleanup_callback","get_from_editor",t.content,t)}})}if(A.save_callback){z.onGetContent.add(function(s,t){if(t.save){t.content=z.execCallback("save_callback",z.id,t.content,z.getBody())}})}if(A.handle_event_callback){z.onEvent.add(function(s,t,B){if(z.execCallback("handle_event_callback",t,s,B)===false){j.cancel(t)}})}z.onSetContent.add(function(){z.addVisual(z.getBody())});if(A.padd_empty_editor){z.onPostProcess.add(function(s,t){t.content=t.content.replace(/^(<p[^>]*>(&nbsp;|&#160;|\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/,"")})}if(a){function p(s,t){i(s.dom.select("a"),function(C){var B=C.parentNode;if(s.dom.isBlock(B)&&B.lastChild===C){s.dom.add(B,"br",{_mce_bogus:1})}})}z.onExecCommand.add(function(s,t){if(t==="CreateLink"){p(s)}});z.onSetContent.add(z.selection.onSetContent.add(p));if(!A.readonly){try{u.designMode="Off";u.designMode="On"}catch(v){}}}setTimeout(function(){if(z.removed){return}z.load({initial:true,format:(A.cleanup_on_startup?"html":"raw")});z.startContent=z.getContent({format:"raw"});z.initialized=true;z.onInit.dispatch(z);z.execCallback("setupcontent_callback",z.id,z.getBody(),z.getDoc());z.execCallback("init_instance_callback",z);z.focus(true);z.nodeChanged({initial:1});if(A.content_css){m.each(g(A.content_css),function(s){z.dom.loadCSS(z.documentBaseURI.toAbsolute(s))})}if(A.auto_focus){setTimeout(function(){var s=m.get(A.auto_focus);s.selection.select(s.getBody(),1);s.selection.collapse(1);s.getWin().focus()},100)}},1);r=null},focus:function(s){var x,q=this,v=q.settings.content_editable,r,p,u=q.getDoc();if(!s){r=q.selection.getRng();if(r.item){p=r.item(0)}if(!v){q.getWin().focus()}if(p&&p.ownerDocument==u){r=u.body.createControlRange();r.addElement(p);r.select()}}if(m.activeEditor!=q){if((x=m.activeEditor)!=null){x.onDeactivate.dispatch(x,q)}q.onActivate.dispatch(q,x)}m._setActive(q)},execCallback:function(u){var p=this,r=p.settings[u],q;if(!r){return}if(p.callbackLookup&&(q=p.callbackLookup[u])){r=q.func;q=q.scope}if(d(r,"string")){q=r.replace(/\.\w+$/,"");q=q?m.resolve(q):0;r=m.resolve(r);p.callbackLookup=p.callbackLookup||{};p.callbackLookup[u]={func:r,scope:q}}return r.apply(q||p,Array.prototype.slice.call(arguments,1))},translate:function(p){var r=this.settings.language||"en",q=m.i18n;if(!p){return""}return q[r+"."+p]||p.replace(/{\#([^}]+)\}/g,function(t,s){return q[r+"."+s]||"{#"+s+"}"})},getLang:function(q,p){return m.i18n[(this.settings.language||"en")+"."+q]||(d(p)?p:"{#"+q+"}")},getParam:function(u,r,p){var s=m.trim,q=d(this.settings[u])?this.settings[u]:r,t;if(p==="hash"){t={};if(d(q,"string")){i(q.indexOf("=")>0?q.split(/[;,](?![^=;,]*(?:[;,]|$))/):q.split(","),function(x){x=x.split("=");if(x.length>1){t[s(x[0])]=s(x[1])}else{t[s(x[0])]=s(x)}})}else{t=q}return t}return q},nodeChanged:function(r){var p=this,q=p.selection,u=(b?q.getNode():q.getStart())||p.getBody();if(p.initialized){r=r||{};u=b&&u.ownerDocument!=p.getDoc()?p.getBody():u;r.parents=[];p.dom.getParent(u,function(s){if(s.nodeName=="BODY"){return true}r.parents.push(s)});p.onNodeChange.dispatch(p,r?r.controlManager||p.controlManager:p.controlManager,u,q.isCollapsed(),r)}},addButton:function(r,q){var p=this;p.buttons=p.buttons||{};p.buttons[r]=q},addCommand:function(r,q,p){this.execCommands[r]={func:q,scope:p||this}},addQueryStateHandler:function(r,q,p){this.queryStateCommands[r]={func:q,scope:p||this}},addQueryValueHandler:function(r,q,p){this.queryValueCommands[r]={func:q,scope:p||this}},addShortcut:function(r,u,p,s){var q=this,v;if(!q.settings.custom_shortcuts){return false}q.shortcuts=q.shortcuts||{};if(d(p,"string")){v=p;p=function(){q.execCommand(v,false,null)}}if(d(p,"object")){v=p;p=function(){q.execCommand(v[0],v[1],v[2])}}i(g(r),function(t){var x={func:p,scope:s||this,desc:u,alt:false,ctrl:false,shift:false};i(g(t,"+"),function(y){switch(y){case"alt":case"ctrl":case"shift":x[y]=true;break;default:x.charCode=y.charCodeAt(0);x.keyCode=y.toUpperCase().charCodeAt(0)}});q.shortcuts[(x.ctrl?"ctrl":"")+","+(x.alt?"alt":"")+","+(x.shift?"shift":"")+","+x.keyCode]=x});return true},execCommand:function(x,v,z,p){var r=this,u=0,y,q;if(!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(x)&&(!p||!p.skip_focus)){r.focus()}y={};r.onBeforeExecCommand.dispatch(r,x,v,z,y);if(y.terminate){return false}if(r.execCallback("execcommand_callback",r.id,r.selection.getNode(),x,v,z)){r.onExecCommand.dispatch(r,x,v,z,p);return true}if(y=r.execCommands[x]){q=y.func.call(y.scope,v,z);if(q!==true){r.onExecCommand.dispatch(r,x,v,z,p);return q}}i(r.plugins,function(s){if(s.execCommand&&s.execCommand(x,v,z)){r.onExecCommand.dispatch(r,x,v,z,p);u=1;return false}});if(u){return true}if(r.theme&&r.theme.execCommand&&r.theme.execCommand(x,v,z)){r.onExecCommand.dispatch(r,x,v,z,p);return true}if(m.GlobalCommands.execCommand(r,x,v,z)){r.onExecCommand.dispatch(r,x,v,z,p);return true}if(r.editorCommands.execCommand(x,v,z)){r.onExecCommand.dispatch(r,x,v,z,p);return true}r.getDoc().execCommand(x,v,z);r.onExecCommand.dispatch(r,x,v,z,p)},queryCommandState:function(u){var q=this,v,r;if(q._isHidden()){return}if(v=q.queryStateCommands[u]){r=v.func.call(v.scope);if(r!==true){return r}}v=q.editorCommands.queryCommandState(u);if(v!==-1){return v}try{return this.getDoc().queryCommandState(u)}catch(p){}},queryCommandValue:function(v){var q=this,u,r;if(q._isHidden()){return}if(u=q.queryValueCommands[v]){r=u.func.call(u.scope);if(r!==true){return r}}u=q.editorCommands.queryCommandValue(v);if(d(u)){return u}try{return this.getDoc().queryCommandValue(v)}catch(p){}},show:function(){var p=this;n.show(p.getContainer());n.hide(p.id);p.load()},hide:function(){var p=this,q=p.getDoc();if(b&&q){q.execCommand("SelectAll")}p.save();n.hide(p.getContainer());n.setStyle(p.id,"display",p.orgDisplay)},isHidden:function(){return !n.isHidden(this.id)},setProgressState:function(p,q,r){this.onSetProgressState.dispatch(this,p,q,r);return p},load:function(s){var p=this,r=p.getElement(),q;if(r){s=s||{};s.load=true;q=p.setContent(d(r.value)?r.value:r.innerHTML,s);s.element=r;if(!s.no_events){p.onLoadContent.dispatch(p,s)}s.element=r=null;return q}},save:function(u){var p=this,s=p.getElement(),q,r;if(!s||!p.initialized){return}u=u||{};u.save=true;if(!u.no_events){p.undoManager.typing=0;p.undoManager.add()}u.element=s;q=u.content=p.getContent(u);if(!u.no_events){p.onSaveContent.dispatch(p,u)}q=u.content;if(!/TEXTAREA|INPUT/i.test(s.nodeName)){s.innerHTML=q;if(r=n.getParent(p.id,"form")){i(r.elements,function(t){if(t.name==p.id){t.value=q;return false}})}}else{s.value=q}u.element=s=null;return q},setContent:function(q,r){var p=this;r=r||{};r.format=r.format||"html";r.set=true;r.content=q;if(!r.no_events){p.onBeforeSetContent.dispatch(p,r)}if(!m.isIE&&(q.length===0||/^\s+$/.test(q))){r.content=p.dom.setHTML(p.getBody(),'<br _mce_bogus="1" />');r.format="raw"}r.content=p.dom.setHTML(p.getBody(),m.trim(r.content));if(r.format!="raw"&&p.settings.cleanup){r.getInner=true;r.content=p.dom.setHTML(p.getBody(),p.serializer.serialize(p.getBody(),r))}if(!r.no_events){p.onSetContent.dispatch(p,r)}return r.content},getContent:function(r){var p=this,q;r=r||{};r.format=r.format||"html";r.get=true;if(!r.no_events){p.onBeforeGetContent.dispatch(p,r)}if(r.format!="raw"&&p.settings.cleanup){r.getInner=true;q=p.serializer.serialize(p.getBody(),r)}else{q=p.getBody().innerHTML}q=q.replace(/^\s*|\s*$/g,"");r.content=q;if(!r.no_events){p.onGetContent.dispatch(p,r)}return r.content},isDirty:function(){var p=this;return m.trim(p.startContent)!=m.trim(p.getContent({format:"raw",no_events:1}))&&!p.isNotDirty},getContainer:function(){var p=this;if(!p.container){p.container=n.get(p.editorContainer||p.id+"_parent")}return p.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return n.get(this.settings.content_element||this.id)},getWin:function(){var p=this,q;if(!p.contentWindow){q=n.get(p.id+"_ifr");if(q){p.contentWindow=q.contentWindow}}return p.contentWindow},getDoc:function(){var q=this,p;if(!q.contentDocument){p=q.getWin();if(p){q.contentDocument=p.document}}return q.contentDocument},getBody:function(){return this.bodyElement||this.getDoc().body},convertURL:function(p,x,v){var q=this,r=q.settings;if(r.urlconverter_callback){return q.execCallback("urlconverter_callback",p,v,true,x)}if(!r.convert_urls||(v&&v.nodeName=="LINK")||p.indexOf("file:")===0){return p}if(r.relative_urls){return q.documentBaseURI.toRelative(p)}p=q.documentBaseURI.toAbsolute(p,r.remove_script_host);return p},addVisual:function(r){var p=this,q=p.settings;r=r||p.getBody();if(!d(p.hasVisual)){p.hasVisual=q.visual}i(p.dom.select("table,a",r),function(t){var s;switch(t.nodeName){case"TABLE":s=p.dom.getAttrib(t,"border");if(!s||s=="0"){if(p.hasVisual){p.dom.addClass(t,q.visual_table_class)}else{p.dom.removeClass(t,q.visual_table_class)}}return;case"A":s=p.dom.getAttrib(t,"name");if(s){if(p.hasVisual){p.dom.addClass(t,"mceItemAnchor")}else{p.dom.removeClass(t,"mceItemAnchor")}}return}});p.onVisualAid.dispatch(p,r,p.hasVisual)},remove:function(){var p=this,q=p.getContainer();p.removed=1;p.hide();p.execCallback("remove_instance_callback",p);p.onRemove.dispatch(p);p.onExecCommand.listeners=[];m.remove(p);n.remove(q)},destroy:function(q){var p=this;if(p.destroyed){return}if(!q){m.removeUnload(p.destroy);tinyMCE.onBeforeUnload.remove(p._beforeUnload);if(p.theme&&p.theme.destroy){p.theme.destroy()}p.controlManager.destroy();p.selection.destroy();p.dom.destroy();if(!p.settings.content_editable){j.clear(p.getWin());j.clear(p.getDoc())}j.clear(p.getBody());j.clear(p.formElement)}if(p.formElement){p.formElement.submit=p.formElement._mceOldSubmit;p.formElement._mceOldSubmit=null}p.contentAreaContainer=p.formElement=p.container=p.settings.content_element=p.bodyElement=p.contentDocument=p.contentWindow=null;if(p.selection){p.selection=p.selection.win=p.selection.dom=p.selection.dom.doc=null}p.destroyed=1},_addEvents:function(){var z=this,r,A=z.settings,q=z.dom,x={mouseup:"onMouseUp",mousedown:"onMouseDown",click:"onClick",keyup:"onKeyUp",keydown:"onKeyDown",keypress:"onKeyPress",submit:"onSubmit",reset:"onReset",contextmenu:"onContextMenu",dblclick:"onDblClick",paste:"onPaste"};function p(t,B){var s=t.type;if(z.removed){return}if(z.onEvent.dispatch(z,t,B)!==false){z[x[t.fakeType||t.type]].dispatch(z,t,B)}}i(x,function(t,s){switch(s){case"contextmenu":if(m.isOpera){q.bind(z.getBody(),"mousedown",function(B){if(B.ctrlKey){B.fakeType="contextmenu";p(B)}})}else{q.bind(z.getBody(),s,p)}break;case"paste":q.bind(z.getBody(),s,function(B){p(B)});break;case"submit":case"reset":q.bind(z.getElement().form||n.getParent(z.id,"form"),s,p);break;default:q.bind(A.content_editable?z.getBody():z.getDoc(),s,p)}});q.bind(A.content_editable?z.getBody():(a?z.getDoc():z.getWin()),"focus",function(s){z.focus(true)});if(m.isGecko){q.bind(z.getDoc(),"DOMNodeInserted",function(t){var s;t=t.target;if(t.nodeType===1&&t.nodeName==="IMG"&&(s=t.getAttribute("_mce_src"))){t.src=z.documentBaseURI.toAbsolute(s)}})}if(a){function u(){var C=this,E=C.getDoc(),D=C.settings;if(a&&!D.readonly){if(C._isHidden()){try{if(!D.content_editable){E.designMode="On"}}catch(B){}}try{E.execCommand("styleWithCSS",0,false)}catch(B){if(!C._isHidden()){try{E.execCommand("useCSS",0,true)}catch(B){}}}if(!D.table_inline_editing){try{E.execCommand("enableInlineTableEditing",false,false)}catch(B){}}if(!D.object_resizing){try{E.execCommand("enableObjectResizing",false,false)}catch(B){}}}}z.onBeforeExecCommand.add(u);z.onMouseDown.add(u)}if(m.isWebKit){z.onClick.add(function(s,t){t=t.target;if(t.nodeName=="IMG"||(t.nodeName=="A"&&q.hasClass(t,"mceItemAnchor"))){z.selection.getSel().setBaseAndExtent(t,0,t,1);z.nodeChanged()}})}z.onMouseUp.add(z.nodeChanged);z.onKeyUp.add(function(s,t){var B=t.keyCode;if((B>=33&&B<=36)||(B>=37&&B<=40)||B==13||B==45||B==46||B==8||(m.isMac&&(B==91||B==93))||t.ctrlKey){z.nodeChanged()}});z.onReset.add(function(){z.setContent(z.startContent,{format:"raw"})});if(A.custom_shortcuts){if(A.custom_undo_redo_keyboard_shortcuts){z.addShortcut("ctrl+z",z.getLang("undo_desc"),"Undo");z.addShortcut("ctrl+y",z.getLang("redo_desc"),"Redo")}z.addShortcut("ctrl+b",z.getLang("bold_desc"),"Bold");z.addShortcut("ctrl+i",z.getLang("italic_desc"),"Italic");z.addShortcut("ctrl+u",z.getLang("underline_desc"),"Underline");for(r=1;r<=6;r++){z.addShortcut("ctrl+"+r,"",["FormatBlock",false,"h"+r])}z.addShortcut("ctrl+7","",["FormatBlock",false,"<p>"]);z.addShortcut("ctrl+8","",["FormatBlock",false,"<div>"]);z.addShortcut("ctrl+9","",["FormatBlock",false,"<address>"]);function v(t){var s=null;if(!t.altKey&&!t.ctrlKey&&!t.metaKey){return s}i(z.shortcuts,function(B){if(m.isMac&&B.ctrl!=t.metaKey){return}else{if(!m.isMac&&B.ctrl!=t.ctrlKey){return}}if(B.alt!=t.altKey){return}if(B.shift!=t.shiftKey){return}if(t.keyCode==B.keyCode||(t.charCode&&t.charCode==B.charCode)){s=B;return false}});return s}z.onKeyUp.add(function(s,t){var B=v(t);if(B){return j.cancel(t)}});z.onKeyPress.add(function(s,t){var B=v(t);if(B){return j.cancel(t)}});z.onKeyDown.add(function(s,t){var B=v(t);if(B){B.func.call(B.scope);return j.cancel(t)}})}if(m.isIE){q.bind(z.getDoc(),"controlselect",function(B){var t=z.resizeInfo,s;B=B.target;if(B.nodeName!=="IMG"){return}if(t){q.unbind(t.node,t.ev,t.cb)}if(!q.hasClass(B,"mceItemNoResize")){ev="resizeend";s=q.bind(B,ev,function(D){var C;D=D.target;if(C=q.getStyle(D,"width")){q.setAttrib(D,"width",C.replace(/[^0-9%]+/g,""));q.setStyle(D,"width","")}if(C=q.getStyle(D,"height")){q.setAttrib(D,"height",C.replace(/[^0-9%]+/g,""));q.setStyle(D,"height","")}})}else{ev="resizestart";s=q.bind(B,"resizestart",j.cancel,j)}t=z.resizeInfo={node:B,ev:ev,cb:s}});z.onKeyDown.add(function(s,t){switch(t.keyCode){case 8:if(z.selection.getRng().item){s.dom.remove(z.selection.getRng().item(0));return j.cancel(t)}}})}if(m.isOpera){z.onClick.add(function(s,t){j.prevent(t)})}if(A.custom_undo_redo){function y(){z.undoManager.typing=0;z.undoManager.add()}q.bind(z.getDoc(),"focusout",function(s){if(!z.removed&&z.undoManager.typing){y()}});z.onKeyUp.add(function(s,t){if((t.keyCode>=33&&t.keyCode<=36)||(t.keyCode>=37&&t.keyCode<=40)||t.keyCode==13||t.keyCode==45||t.ctrlKey){y()}});z.onKeyDown.add(function(t,E){var s,D,C;if(b&&E.keyCode==46){s=z.selection.getRng();if(s.parentElement){D=s.parentElement();if(E.ctrlKey){s.moveEnd("word",1);s.select()}z.selection.getSel().clear();if(s.parentElement()==D){C=z.selection.getBookmark();try{D.innerHTML=D.innerHTML}catch(B){}z.selection.moveToBookmark(C)}E.preventDefault();return}}if((E.keyCode>=33&&E.keyCode<=36)||(E.keyCode>=37&&E.keyCode<=40)||E.keyCode==13||E.keyCode==45){if(z.undoManager.typing){y()}return}if(!z.undoManager.typing){z.undoManager.add();z.undoManager.typing=1}});z.onMouseDown.add(function(){if(z.undoManager.typing){y()}})}},_isHidden:function(){var p;if(!a){return 0}p=this.selection.getSel();return(!p||!p.rangeCount||p.rangeCount==0)},_fixNesting:function(q){var r=[],p;q=q.replace(/<(\/)?([^\s>]+)[^>]*?>/g,function(t,s,v){var u;if(s==="/"){if(!r.length){return""}if(v!==r[r.length-1].tag){for(p=r.length-1;p>=0;p--){if(r[p].tag===v){r[p].close=1;break}}return""}else{r.pop();if(r.length&&r[r.length-1].close){t=t+"</"+r[r.length-1].tag+">";r.pop()}}}else{if(/^(br|hr|input|meta|img|link|param)$/i.test(v)){return t}if(/\/>$/.test(t)){return t}r.push({tag:v})}return t});for(p=r.length-1;p>=0;p--){q+="</"+r[p].tag+">"}return q}})})(tinymce);(function(c){var d=c.each,e,a=true,b=false;c.EditorCommands=function(n){var l=n.dom,p=n.selection,j={state:{},exec:{},value:{}},k=n.settings,o;function q(y,x,v){var u;y=y.toLowerCase();if(u=j.exec[y]){u(y,x,v);return a}return b}function m(v){var u;v=v.toLowerCase();if(u=j.state[v]){return u(v)}return -1}function h(v){var u;v=v.toLowerCase();if(u=j.value[v]){return u(v)}return b}function t(u,v){v=v||"exec";d(u,function(y,x){d(x.toLowerCase().split(","),function(z){j[v][z]=y})})}c.extend(this,{execCommand:q,queryCommandState:m,queryCommandValue:h,addCommands:t});function f(x,v,u){if(v===e){v=b}if(u===e){u=null}return n.getDoc().execCommand(x,v,u)}function s(u){return n.formatter.match(u)}function r(u,v){n.formatter.toggle(u,v?{value:v}:e)}function i(u){o=p.getBookmark(u)}function g(){p.moveToBookmark(o)}t({"mceResetDesignMode,mceBeginUndoLevel":function(){},"mceEndUndoLevel,mceAddUndoLevel":function(){n.undoManager.add()},"Cut,Copy,Paste":function(y){var x=n.getDoc(),u;try{f(y)}catch(v){u=a}if(u||!x.queryCommandSupported(y)){if(c.isGecko){n.windowManager.confirm(n.getLang("clipboard_msg"),function(z){if(z){open("http://www.mozilla.org/editor/midasdemo/securityprefs.html","_blank")}})}else{n.windowManager.alert(n.getLang("clipboard_no_support"))}}},unlink:function(u){if(p.isCollapsed()){p.select(p.getNode())}f(u);p.collapse(b)},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(u){var v=u.substring(7);d("left,center,right,full".split(","),function(x){if(v!=x){n.formatter.remove("align"+x)}});r("align"+v)},"InsertUnorderedList,InsertOrderedList":function(x){var u,v;f(x);u=l.getParent(p.getNode(),"ol,ul");if(u){v=u.parentNode;if(/^(H[1-6]|P|ADDRESS|PRE)$/.test(v.nodeName)){i();l.split(v,u);g()}}},"Bold,Italic,Underline,Strikethrough":function(u){r(u)},"ForeColor,HiliteColor,FontName":function(x,v,u){r(x,u)},FontSize:function(y,x,v){var u,z;if(v>=1&&v<=7){z=c.explode(k.font_size_style_values);u=c.explode(k.font_size_classes);if(u){v=u[v-1]||v}else{v=z[v-1]||v}}r(y,v)},RemoveFormat:function(u){n.formatter.remove(u)},mceBlockQuote:function(u){r("blockquote")},FormatBlock:function(x,v,u){return r(u||"p")},mceCleanup:function(){var u=p.getBookmark();n.setContent(n.getContent({cleanup:a}),{cleanup:a});p.moveToBookmark(u)},mceRemoveNode:function(y,x,v){var u=v||p.getNode();if(u!=n.getBody()){i();n.dom.remove(u,a);g()}},mceSelectNodeDepth:function(y,x,v){var u=0;l.getParent(p.getNode(),function(z){if(z.nodeType==1&&u++==v){p.select(z);return b}},n.getBody())},mceSelectNode:function(x,v,u){p.select(u)},mceInsertContent:function(x,v,u){p.setContent(u)},mceInsertRawHTML:function(x,v,u){p.setContent("tiny_mce_marker");n.setContent(n.getContent().replace(/tiny_mce_marker/g,function(){return u}))},mceSetContent:function(x,v,u){n.setContent(u)},"Indent,Outdent":function(y){var v,u,x;v=k.indentation;u=/[a-z%]+$/i.exec(v);v=parseInt(v);if(!m("InsertUnorderedList")&&!m("InsertOrderedList")){d(p.getSelectedBlocks(),function(z){if(y=="outdent"){x=Math.max(0,parseInt(z.style.paddingLeft||0)-v);l.setStyle(z,"paddingLeft",x?x+u:"")}else{l.setStyle(z,"paddingLeft",(parseInt(z.style.paddingLeft||0)+v)+u)}})}else{f(y)}},mceRepaint:function(){var v;if(c.isGecko){try{i(a);if(p.getSel()){p.getSel().selectAllChildren(n.getBody())}p.collapse(a);g()}catch(u){}}},mceToggleFormat:function(x,v,u){n.formatter.toggle(u)},InsertHorizontalRule:function(){p.setContent("<hr />")},mceToggleVisualAid:function(){n.hasVisual=!n.hasVisual;n.addVisual()},mceReplaceContent:function(x,v,u){p.setContent(u.replace(/\{\$selection\}/g,p.getContent({format:"text"})))},mceInsertLink:function(y,x,v){var u=l.getParent(p.getNode(),"a");if(c.is(v,"string")){v={href:v}}if(!u){f("CreateLink",b,"javascript:mctmp(0);");d(l.select("a[href=javascript:mctmp(0);]"),function(z){l.setAttribs(z,v)})}else{if(v.href){l.setAttribs(u,v)}else{n.dom.remove(u,a)}}},selectAll:function(){var v=l.getRoot(),u=l.createRng();u.setStart(v,0);u.setEnd(v,v.childNodes.length);n.selection.setRng(u)}});t({"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(u){return s("align"+u.substring(7))},"Bold,Italic,Underline,Strikethrough":function(u){return s(u)},mceBlockQuote:function(){return s("blockquote")},Outdent:function(){var u;if(k.inline_styles){if((u=l.getParent(p.getStart(),l.isBlock))&&parseInt(u.style.paddingLeft)>0){return a}if((u=l.getParent(p.getEnd(),l.isBlock))&&parseInt(u.style.paddingLeft)>0){return a}}return m("InsertUnorderedList")||m("InsertOrderedList")||(!k.inline_styles&&!!l.getParent(p.getNode(),"BLOCKQUOTE"))},"InsertUnorderedList,InsertOrderedList":function(u){return l.getParent(p.getNode(),u=="insertunorderedlist"?"UL":"OL")}},"state");t({"FontSize,FontName":function(x){var v=0,u;if(u=l.getParent(p.getNode(),"span")){if(x=="fontsize"){v=u.style.fontSize}else{v=u.style.fontFamily.replace(/, /g,",").replace(/[\'\"]/g,"").toLowerCase()}}return v}},"value");if(k.custom_undo_redo){t({Undo:function(){n.undoManager.undo()},Redo:function(){n.undoManager.redo()}})}}})(tinymce);(function(b){var a=b.util.Dispatcher;b.UndoManager=function(e){var c,d=0,g=[];function f(){return b.trim(e.getContent({format:"raw",no_events:1}))}return c={typing:0,onAdd:new a(c),onUndo:new a(c),onRedo:new a(c),add:function(l){var h,j=e.settings,k;l=l||{};l.content=f();k=g[d];if(k&&k.content==l.content){if(d>0||g.length==1){return null}}if(j.custom_undo_redo_levels){if(g.length>j.custom_undo_redo_levels){for(h=0;h<g.length-1;h++){g[h]=g[h+1]}g.length--;d=g.length}}l.bookmark=e.selection.getBookmark(2,true);if(d<g.length-1){if(d==0){g=[]}else{g.length=d+1}}g.push(l);d=g.length-1;c.onAdd.dispatch(c,l);e.isNotDirty=0;return l},undo:function(){var j,h;if(c.typing){c.add();c.typing=0}if(d>0){j=g[--d];e.setContent(j.content,{format:"raw"});e.selection.moveToBookmark(j.bookmark);c.onUndo.dispatch(c,j)}return j},redo:function(){var h;if(d<g.length-1){h=g[++d];e.setContent(h.content,{format:"raw"});e.selection.moveToBookmark(h.bookmark);c.onRedo.dispatch(c,h)}return h},clear:function(){g=[];d=c.typing=0},hasUndo:function(){return d>0||c.typing},hasRedo:function(){return d<g.length-1}}}})(tinymce);(function(m){var k=m.dom.Event,c=m.isIE,a=m.isGecko,b=m.isOpera,j=m.each,i=m.extend,d=true,h=false;function l(p){var q,o,n;do{if(/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(p.nodeName)){if(q){o=p.cloneNode(false);o.appendChild(q);q=o}else{q=n=p.cloneNode(false)}q.removeAttribute("id")}}while(p=p.parentNode);if(q){return{wrapper:q,inner:n}}}function g(o,p){var n=p.ownerDocument.createRange();n.setStart(o.endContainer,o.endOffset);n.setEndAfter(p);return n.cloneContents().textContent.length==0}function f(o){o=o.innerHTML;o=o.replace(/<(img|hr|table|input|select|textarea)[ \>]/gi,"-");o=o.replace(/<[^>]+>/g,"");return o.replace(/[ \u00a0\t\r\n]+/g,"")==""}function e(p,r,n){var o,q;if(f(n)){o=r.getParent(n,"ul,ol");if(!r.getParent(o.parentNode,"ul,ol")){r.split(o,n);q=r.create("p",0,'<br _mce_bogus="1" />');r.replace(q,n);p.select(q,1)}return h}return d}m.create("tinymce.ForceBlocks",{ForceBlocks:function(o){var p=this,q=o.settings,r;p.editor=o;p.dom=o.dom;r=(q.forced_root_block||"p").toLowerCase();q.element=r.toUpperCase();o.onPreInit.add(p.setup,p);p.reOpera=new RegExp("(\\u00a0|&#160;|&nbsp;)</"+r+">","gi");p.rePadd=new RegExp("<p( )([^>]+)><\\/p>|<p( )([^>]+)\\/>|<p( )([^>]+)>\\s+<\\/p>|<p><\\/p>|<p\\/>|<p>\\s+<\\/p>".replace(/p/g,r),"gi");p.reNbsp2BR1=new RegExp("<p( )([^>]+)>[\\s\\u00a0]+<\\/p>|<p>[\\s\\u00a0]+<\\/p>".replace(/p/g,r),"gi");p.reNbsp2BR2=new RegExp("<%p()([^>]+)>(&nbsp;|&#160;)<\\/%p>|<%p>(&nbsp;|&#160;)<\\/%p>".replace(/%p/g,r),"gi");p.reBR2Nbsp=new RegExp("<p( )([^>]+)>\\s*<br \\/>\\s*<\\/p>|<p>\\s*<br \\/>\\s*<\\/p>".replace(/p/g,r),"gi");function n(s,t){if(b){t.content=t.content.replace(p.reOpera,"</"+r+">")}t.content=m._replace(p.rePadd,"<"+r+"$1$2$3$4$5$6>\u00a0</"+r+">",t.content);if(!c&&!b&&t.set){t.content=t.content.replace(p.reNbsp2BR1,"<"+r+"$1$2><br /></"+r+">");t.content=t.content.replace(p.reNbsp2BR2,"<"+r+"$1$2><br /></"+r+">")}else{t.content=m._replace(p.reBR2Nbsp,"<"+r+"$1$2>\u00a0</"+r+">",t.content)}}o.onBeforeSetContent.add(n);o.onPostProcess.add(n);if(q.forced_root_block){o.onInit.add(p.forceRoots,p);o.onSetContent.add(p.forceRoots,p);o.onBeforeGetContent.add(p.forceRoots,p)}},setup:function(){var o=this,n=o.editor,q=n.settings,u=n.dom,p=n.selection;if(q.forced_root_block){n.onBeforeExecCommand.add(o.forceRoots,o);n.onKeyUp.add(o.forceRoots,o);n.onPreProcess.add(o.forceRoots,o)}if(q.force_br_newlines){if(c){n.onKeyPress.add(function(s,t){var v;if(t.keyCode==13&&p.getNode().nodeName!="LI"){p.setContent('<br id="__" /> ',{format:"raw"});v=u.get("__");v.removeAttribute("id");p.select(v);p.collapse();return k.cancel(t)}})}}if(q.force_p_newlines){if(!c){n.onKeyPress.add(function(s,t){if(t.keyCode==13&&!t.shiftKey&&!o.insertPara(t)){k.cancel(t)}})}else{m.addUnload(function(){o._previousFormats=0});n.onKeyPress.add(function(s,t){o._previousFormats=0;if(t.keyCode==13&&!t.shiftKey&&s.selection.isCollapsed()&&q.keep_styles){o._previousFormats=l(s.selection.getStart())}});n.onKeyUp.add(function(t,x){if(x.keyCode==13&&!x.shiftKey){var v=t.selection.getStart(),s=o._previousFormats;if(!v.hasChildNodes()&&s){v=u.getParent(v,u.isBlock);if(v&&v.nodeName!="LI"){v.innerHTML="";if(o._previousFormats){v.appendChild(s.wrapper);s.inner.innerHTML="\uFEFF"}else{v.innerHTML="\uFEFF"}p.select(v,1);t.getDoc().execCommand("Delete",false,null);o._previousFormats=0}}}})}if(a){n.onKeyDown.add(function(s,t){if((t.keyCode==8||t.keyCode==46)&&!t.shiftKey){o.backspaceDelete(t,t.keyCode==8)}})}}if(m.isWebKit){function r(t){var s=p.getRng(),v,z=u.create("div",null," "),y,x=u.getViewPort(t.getWin()).h;s.insertNode(v=u.create("br"));s.setStartAfter(v);s.setEndAfter(v);p.setRng(s);if(p.getSel().focusNode==v.previousSibling){p.select(u.insertAfter(u.doc.createTextNode("\u00a0"),v));p.collapse(d)}u.insertAfter(z,v);y=u.getPos(z).y;u.remove(z);if(y>x){t.getWin().scrollTo(0,y)}}n.onKeyPress.add(function(s,t){if(t.keyCode==13&&(t.shiftKey||(q.force_br_newlines&&!u.getParent(p.getNode(),"h1,h2,h3,h4,h5,h6,ol,ul")))){r(s);k.cancel(t)}})}n.onPreProcess.add(function(s,t){j(u.select("p,h1,h2,h3,h4,h5,h6,div",t.node),function(v){if(f(v)){j(u.select("span,em,strong,b,i",t.node),function(x){if(!x.hasChildNodes()){x.appendChild(s.getDoc().createTextNode("\u00a0"));return h}})}})});if(c){if(q.element!="P"){n.onKeyPress.add(function(s,t){o.lastElm=p.getNode().nodeName});n.onKeyUp.add(function(t,v){var y,x=p.getNode(),s=t.getBody();if(s.childNodes.length===1&&x.nodeName=="P"){x=u.rename(x,q.element);p.select(x);p.collapse();t.nodeChanged()}else{if(v.keyCode==13&&!v.shiftKey&&o.lastElm!="P"){y=u.getParent(x,"p");if(y){u.rename(y,q.element);t.nodeChanged()}}}})}}},find:function(v,q,r){var p=this.editor,o=p.getDoc().createTreeWalker(v,4,null,h),u=-1;while(v=o.nextNode()){u++;if(q==0&&v==r){return u}if(q==1&&u==r){return v}}return -1},forceRoots:function(x,I){var z=this,x=z.editor,M=x.getBody(),J=x.getDoc(),P=x.selection,A=P.getSel(),B=P.getRng(),N=-2,v,G,o,p,K=-16777215;var L,q,O,F,C,u=M.childNodes,E,D,y;for(E=u.length-1;E>=0;E--){L=u[E];if(L.nodeType===1&&L.getAttribute("_mce_type")){q=null;continue}if(L.nodeType===3||(!z.dom.isBlock(L)&&L.nodeType!==8&&!/^(script|mce:script|style|mce:style)$/i.test(L.nodeName))){if(!q){if(L.nodeType!=3||/[^\s]/g.test(L.nodeValue)){if(N==-2&&B){if(!c||B.setStart){if(B.startContainer.nodeType==1&&(D=B.startContainer.childNodes[B.startOffset])&&D.nodeType==1){y=D.getAttribute("id");D.setAttribute("id","__mce")}else{if(x.dom.getParent(B.startContainer,function(n){return n===M})){G=B.startOffset;o=B.endOffset;N=z.find(M,0,B.startContainer);v=z.find(M,0,B.endContainer)}}}else{if(B.item){p=J.body.createTextRange();p.moveToElementText(B.item(0));B=p}p=J.body.createTextRange();p.moveToElementText(M);p.collapse(1);O=p.move("character",K)*-1;p=B.duplicate();p.collapse(1);F=p.move("character",K)*-1;p=B.duplicate();p.collapse(0);C=(p.move("character",K)*-1)-F;N=F-O;v=C}}q=x.dom.create(x.settings.forced_root_block);L.parentNode.replaceChild(q,L);q.appendChild(L)}}else{if(q.hasChildNodes()){q.insertBefore(L,q.firstChild)}else{q.appendChild(L)}}}else{q=null}}if(N!=-2){if(!c||B.setStart){q=M.getElementsByTagName(x.settings.element)[0];B=J.createRange();if(N!=-1){B.setStart(z.find(M,1,N),G)}else{B.setStart(q,0)}if(v!=-1){B.setEnd(z.find(M,1,v),o)}else{B.setEnd(q,0)}if(A){A.removeAllRanges();A.addRange(B)}}else{try{B=A.createRange();B.moveToElementText(M);B.collapse(1);B.moveStart("character",N);B.moveEnd("character",v);B.select()}catch(H){}}}else{if((!c||B.setStart)&&(D=x.dom.get("__mce"))){if(y){D.setAttribute("id",y)}else{D.removeAttribute("id")}B=J.createRange();B.setStartBefore(D);B.setEndBefore(D);P.setRng(B)}}},getParentBlock:function(p){var o=this.dom;return o.getParent(p,o.isBlock)},insertPara:function(S){var G=this,x=G.editor,O=x.dom,T=x.getDoc(),X=x.settings,H=x.selection.getSel(),I=H.getRangeAt(0),W=T.body;var L,M,J,Q,P,u,p,v,A,o,E,V,q,z,K,N=O.getViewPort(x.getWin()),D,F,C;L=T.createRange();L.setStart(H.anchorNode,H.anchorOffset);L.collapse(d);M=T.createRange();M.setStart(H.focusNode,H.focusOffset);M.collapse(d);J=L.compareBoundaryPoints(L.START_TO_END,M)<0;Q=J?H.anchorNode:H.focusNode;P=J?H.anchorOffset:H.focusOffset;u=J?H.focusNode:H.anchorNode;p=J?H.focusOffset:H.anchorOffset;if(Q===u&&/^(TD|TH)$/.test(Q.nodeName)){if(Q.firstChild.nodeName=="BR"){O.remove(Q.firstChild)}if(Q.childNodes.length==0){x.dom.add(Q,X.element,null,"<br />");V=x.dom.add(Q,X.element,null,"<br />")}else{K=Q.innerHTML;Q.innerHTML="";x.dom.add(Q,X.element,null,K);V=x.dom.add(Q,X.element,null,"<br />")}I=T.createRange();I.selectNodeContents(V);I.collapse(1);x.selection.setRng(I);return h}if(Q==W&&u==W&&W.firstChild&&x.dom.isBlock(W.firstChild)){Q=u=Q.firstChild;P=p=0;L=T.createRange();L.setStart(Q,0);M=T.createRange();M.setStart(u,0)}Q=Q.nodeName=="HTML"?T.body:Q;Q=Q.nodeName=="BODY"?Q.firstChild:Q;u=u.nodeName=="HTML"?T.body:u;u=u.nodeName=="BODY"?u.firstChild:u;v=G.getParentBlock(Q);A=G.getParentBlock(u);o=v?v.nodeName:X.element;if(K=G.dom.getParent(v,"li,pre")){if(K.nodeName=="LI"){return e(x.selection,G.dom,K)}return d}if(v&&(v.nodeName=="CAPTION"||/absolute|relative|fixed/gi.test(O.getStyle(v,"position",1)))){o=X.element;v=null}if(A&&(A.nodeName=="CAPTION"||/absolute|relative|fixed/gi.test(O.getStyle(v,"position",1)))){o=X.element;A=null}if(/(TD|TABLE|TH|CAPTION)/.test(o)||(v&&o=="DIV"&&/left|right/gi.test(O.getStyle(v,"float",1)))){o=X.element;v=A=null}E=(v&&v.nodeName==o)?v.cloneNode(0):x.dom.create(o);V=(A&&A.nodeName==o)?A.cloneNode(0):x.dom.create(o);V.removeAttribute("id");if(/^(H[1-6])$/.test(o)&&g(I,v)){V=x.dom.create(X.element)}K=q=Q;do{if(K==W||K.nodeType==9||G.dom.isBlock(K)||/(TD|TABLE|TH|CAPTION)/.test(K.nodeName)){break}q=K}while((K=K.previousSibling?K.previousSibling:K.parentNode));K=z=u;do{if(K==W||K.nodeType==9||G.dom.isBlock(K)||/(TD|TABLE|TH|CAPTION)/.test(K.nodeName)){break}z=K}while((K=K.nextSibling?K.nextSibling:K.parentNode));if(q.nodeName==o){L.setStart(q,0)}else{L.setStartBefore(q)}L.setEnd(Q,P);E.appendChild(L.cloneContents()||T.createTextNode(""));try{M.setEndAfter(z)}catch(R){}M.setStart(u,p);V.appendChild(M.cloneContents()||T.createTextNode(""));I=T.createRange();if(!q.previousSibling&&q.parentNode.nodeName==o){I.setStartBefore(q.parentNode)}else{if(L.startContainer.nodeName==o&&L.startOffset==0){I.setStartBefore(L.startContainer)}else{I.setStart(L.startContainer,L.startOffset)}}if(!z.nextSibling&&z.parentNode.nodeName==o){I.setEndAfter(z.parentNode)}else{I.setEnd(M.endContainer,M.endOffset)}I.deleteContents();if(b){x.getWin().scrollTo(0,N.y)}if(E.firstChild&&E.firstChild.nodeName==o){E.innerHTML=E.firstChild.innerHTML}if(V.firstChild&&V.firstChild.nodeName==o){V.innerHTML=V.firstChild.innerHTML}if(f(E)){E.innerHTML="<br />"}function U(y,s){var r=[],Z,Y,t;y.innerHTML="";if(X.keep_styles){Y=s;do{if(/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(Y.nodeName)){Z=Y.cloneNode(h);O.setAttrib(Z,"id","");r.push(Z)}}while(Y=Y.parentNode)}if(r.length>0){for(t=r.length-1,Z=y;t>=0;t--){Z=Z.appendChild(r[t])}r[0].innerHTML=b?"&nbsp;":"<br />";return r[0]}else{y.innerHTML=b?"&nbsp;":"<br />"}}if(f(V)){C=U(V,u)}if(b&&parseFloat(opera.version())<9.5){I.insertNode(E);I.insertNode(V)}else{I.insertNode(V);I.insertNode(E)}V.normalize();E.normalize();function B(r){return T.createTreeWalker(r,NodeFilter.SHOW_TEXT,null,h).nextNode()||r}I=T.createRange();I.selectNodeContents(a?B(C||V):C||V);I.collapse(1);H.removeAllRanges();H.addRange(I);D=x.dom.getPos(V).y;F=V.clientHeight;if(D<N.y||D+F>N.y+N.h){x.getWin().scrollTo(0,D<N.y?D:D-N.h+25)}return h},backspaceDelete:function(v,C){var D=this,u=D.editor,z=u.getBody(),s=u.dom,q,x=u.selection,p=x.getRng(),y=p.startContainer,q,A,B,o;if(!C&&p.collapsed&&y.nodeType==1&&p.startOffset==y.childNodes.length){o=new m.dom.TreeWalker(y.lastChild,y);for(q=y.lastChild;q;q=o.prev()){if(q.nodeType==3){p.setStart(q,q.nodeValue.length);p.collapse(true);x.setRng(p);return}}}if(y&&u.dom.isBlock(y)&&!/^(TD|TH)$/.test(y.nodeName)&&C){if(y.childNodes.length==0||(y.childNodes.length==1&&y.firstChild.nodeName=="BR")){q=y;while((q=q.previousSibling)&&!u.dom.isBlock(q)){}if(q){if(y!=z.firstChild){A=u.dom.doc.createTreeWalker(q,NodeFilter.SHOW_TEXT,null,h);while(B=A.nextNode()){q=B}p=u.getDoc().createRange();p.setStart(q,q.nodeValue?q.nodeValue.length:0);p.setEnd(q,q.nodeValue?q.nodeValue.length:0);x.setRng(p);u.dom.remove(y)}return k.cancel(v)}}}}})})(tinymce);(function(c){var b=c.DOM,a=c.dom.Event,d=c.each,e=c.extend;c.create("tinymce.ControlManager",{ControlManager:function(f,j){var h=this,g;j=j||{};h.editor=f;h.controls={};h.onAdd=new c.util.Dispatcher(h);h.onPostRender=new c.util.Dispatcher(h);h.prefix=j.prefix||f.id+"_";h._cls={};h.onPostRender.add(function(){d(h.controls,function(i){i.postRender()})})},get:function(f){return this.controls[this.prefix+f]||this.controls[f]},setActive:function(h,f){var g=null;if(g=this.get(h)){g.setActive(f)}return g},setDisabled:function(h,f){var g=null;if(g=this.get(h)){g.setDisabled(f)}return g},add:function(g){var f=this;if(g){f.controls[g.id]=g;f.onAdd.dispatch(g,f)}return g},createControl:function(i){var h,g=this,f=g.editor;d(f.plugins,function(j){if(j.createControl){h=j.createControl(i,g);if(h){return false}}});switch(i){case"|":case"separator":return g.createSeparator()}if(!h&&f.buttons&&(h=f.buttons[i])){return g.createButton(i,h)}return g.add(h)},createDropMenu:function(f,n,h){var m=this,i=m.editor,j,g,k,l;n=e({"class":"mceDropDown",constrain:i.settings.constrain_menus},n);n["class"]=n["class"]+" "+i.getParam("skin")+"Skin";if(k=i.getParam("skin_variant")){n["class"]+=" "+i.getParam("skin")+"Skin"+k.substring(0,1).toUpperCase()+k.substring(1)}f=m.prefix+f;l=h||m._cls.dropmenu||c.ui.DropMenu;j=m.controls[f]=new l(f,n);j.onAddItem.add(function(r,q){var p=q.settings;p.title=i.getLang(p.title,p.title);if(!p.onclick){p.onclick=function(o){if(p.cmd){i.execCommand(p.cmd,p.ui||false,p.value)}}}});i.onRemove.add(function(){j.destroy()});if(c.isIE){j.onShowMenu.add(function(){i.focus();g=i.selection.getBookmark(1)});j.onHideMenu.add(function(){if(g){i.selection.moveToBookmark(g);g=0}})}return m.add(j)},createListBox:function(m,i,l){var h=this,g=h.editor,j,k,f;if(h.get(m)){return null}i.title=g.translate(i.title);i.scope=i.scope||g;if(!i.onselect){i.onselect=function(n){g.execCommand(i.cmd,i.ui||false,n||i.value)}}i=e({title:i.title,"class":"mce_"+m,scope:i.scope,control_manager:h},i);m=h.prefix+m;if(g.settings.use_native_selects){k=new c.ui.NativeListBox(m,i)}else{f=l||h._cls.listbox||c.ui.ListBox;k=new f(m,i)}h.controls[m]=k;if(c.isWebKit){k.onPostRender.add(function(p,o){a.add(o,"mousedown",function(){g.bookmark=g.selection.getBookmark(1)});a.add(o,"focus",function(){g.selection.moveToBookmark(g.bookmark);g.bookmark=null})})}if(k.hideMenu){g.onMouseDown.add(k.hideMenu,k)}return h.add(k)},createButton:function(m,i,l){var h=this,g=h.editor,j,k,f;if(h.get(m)){return null}i.title=g.translate(i.title);i.label=g.translate(i.label);i.scope=i.scope||g;if(!i.onclick&&!i.menu_button){i.onclick=function(){g.execCommand(i.cmd,i.ui||false,i.value)}}i=e({title:i.title,"class":"mce_"+m,unavailable_prefix:g.getLang("unavailable",""),scope:i.scope,control_manager:h},i);m=h.prefix+m;if(i.menu_button){f=l||h._cls.menubutton||c.ui.MenuButton;k=new f(m,i);g.onMouseDown.add(k.hideMenu,k)}else{f=h._cls.button||c.ui.Button;k=new f(m,i)}return h.add(k)},createMenuButton:function(h,f,g){f=f||{};f.menu_button=1;return this.createButton(h,f,g)},createSplitButton:function(m,i,l){var h=this,g=h.editor,j,k,f;if(h.get(m)){return null}i.title=g.translate(i.title);i.scope=i.scope||g;if(!i.onclick){i.onclick=function(n){g.execCommand(i.cmd,i.ui||false,n||i.value)}}if(!i.onselect){i.onselect=function(n){g.execCommand(i.cmd,i.ui||false,n||i.value)}}i=e({title:i.title,"class":"mce_"+m,scope:i.scope,control_manager:h},i);m=h.prefix+m;f=l||h._cls.splitbutton||c.ui.SplitButton;k=h.add(new f(m,i));g.onMouseDown.add(k.hideMenu,k);return k},createColorSplitButton:function(f,n,h){var l=this,j=l.editor,i,k,m,g;if(l.get(f)){return null}n.title=j.translate(n.title);n.scope=n.scope||j;if(!n.onclick){n.onclick=function(o){if(c.isIE){g=j.selection.getBookmark(1)}j.execCommand(n.cmd,n.ui||false,o||n.value)}}if(!n.onselect){n.onselect=function(o){j.execCommand(n.cmd,n.ui||false,o||n.value)}}n=e({title:n.title,"class":"mce_"+f,menu_class:j.getParam("skin")+"Skin",scope:n.scope,more_colors_title:j.getLang("more_colors")},n);f=l.prefix+f;m=h||l._cls.colorsplitbutton||c.ui.ColorSplitButton;k=new m(f,n);j.onMouseDown.add(k.hideMenu,k);j.onRemove.add(function(){k.destroy()});if(c.isIE){k.onShowMenu.add(function(){j.focus();g=j.selection.getBookmark(1)});k.onHideMenu.add(function(){if(g){j.selection.moveToBookmark(g);g=0}})}return l.add(k)},createToolbar:function(k,h,j){var i,g=this,f;k=g.prefix+k;f=j||g._cls.toolbar||c.ui.Toolbar;i=new f(k,h);if(g.get(k)){return null}return g.add(i)},createSeparator:function(g){var f=g||this._cls.separator||c.ui.Separator;return new f()},setControlType:function(g,f){return this._cls[g.toLowerCase()]=f},destroy:function(){d(this.controls,function(f){f.destroy()});this.controls=null}})})(tinymce);(function(d){var a=d.util.Dispatcher,e=d.each,c=d.isIE,b=d.isOpera;d.create("tinymce.WindowManager",{WindowManager:function(f){var g=this;g.editor=f;g.onOpen=new a(g);g.onClose=new a(g);g.params={};g.features={}},open:function(z,h){var v=this,k="",n,m,i=v.editor.settings.dialog_type=="modal",q,o,j,g=d.DOM.getViewPort(),r;z=z||{};h=h||{};o=b?g.w:screen.width;j=b?g.h:screen.height;z.name=z.name||"mc_"+new Date().getTime();z.width=parseInt(z.width||320);z.height=parseInt(z.height||240);z.resizable=true;z.left=z.left||parseInt(o/2)-(z.width/2);z.top=z.top||parseInt(j/2)-(z.height/2);h.inline=false;h.mce_width=z.width;h.mce_height=z.height;h.mce_auto_focus=z.auto_focus;if(i){if(c){z.center=true;z.help=false;z.dialogWidth=z.width+"px";z.dialogHeight=z.height+"px";z.scroll=z.scrollbars||false}}e(z,function(p,f){if(d.is(p,"boolean")){p=p?"yes":"no"}if(!/^(name|url)$/.test(f)){if(c&&i){k+=(k?";":"")+f+":"+p}else{k+=(k?",":"")+f+"="+p}}});v.features=z;v.params=h;v.onOpen.dispatch(v,z,h);r=z.url||z.file;r=d._addVer(r);try{if(c&&i){q=1;window.showModalDialog(r,window,k)}else{q=window.open(r,z.name,k)}}catch(l){}if(!q){alert(v.editor.getLang("popup_blocked"))}},close:function(f){f.close();this.onClose.dispatch(this)},createInstance:function(i,h,g,m,l,k){var j=d.resolve(i);return new j(h,g,m,l,k)},confirm:function(h,f,i,g){g=g||window;f.call(i||this,g.confirm(this._decode(this.editor.getLang(h,h))))},alert:function(h,f,j,g){var i=this;g=g||window;g.alert(i._decode(i.editor.getLang(h,h)));if(f){f.call(j||i)}},resizeBy:function(f,g,h){h.resizeBy(f,g)},_decode:function(f){return d.DOM.decode(f).replace(/\\n/g,"\n")}})}(tinymce));(function(a){function b(){var d={},c={},e={};function f(j,i,h,g){if(typeof(i)=="string"){i=[i]}a.each(i,function(k){j[k.toLowerCase()]={func:h,scope:g}})}a.extend(this,{add:function(i,h,g){f(d,i,h,g)},addQueryStateHandler:function(i,h,g){f(c,i,h,g)},addQueryValueHandler:function(i,h,g){f(e,i,h,g)},execCommand:function(h,k,j,i,g){if(k=d[k.toLowerCase()]){if(k.func.call(h||k.scope,j,i,g)!==false){return true}}},queryCommandValue:function(){if(cmd=e[cmd.toLowerCase()]){return cmd.func.call(scope||cmd.scope,ui,value,args)}},queryCommandState:function(){if(cmd=c[cmd.toLowerCase()]){return cmd.func.call(scope||cmd.scope,ui,value,args)}}})}a.GlobalCommands=new b()})(tinymce);(function(a){a.Formatter=function(T){var K={},M=a.each,c=T.dom,p=T.selection,s=a.dom.TreeWalker,I=new a.dom.RangeUtils(c),d=T.schema.isValid,E=c.isBlock,k=T.settings.forced_root_block,r=c.nodeIndex,D="\uFEFF",e=/^(src|href|style)$/,Q=false,A=true,o,N={apply:[],remove:[]};function y(U){return U instanceof Array}function l(V,U){return c.getParents(V,U,c.getRoot())}function b(U){return U.nodeType===1&&(U.face==="mceinline"||U.style.fontFamily==="mceinline")}function P(U){return U?K[U]:K}function j(U,V){if(U){if(typeof(U)!=="string"){M(U,function(X,W){j(W,X)})}else{V=V.length?V:[V];M(V,function(W){if(W.deep===o){W.deep=!W.selector}if(W.split===o){W.split=!W.selector||W.inline}if(W.remove===o&&W.selector&&!W.inline){W.remove="none"}if(W.selector&&W.inline){W.mixed=true;W.block_expand=true}if(typeof(W.classes)==="string"){W.classes=W.classes.split(/\s+/)}});K[U]=V}}}function R(W,ac,Y){var Z=P(W),ad=Z[0],ab,V,aa;function X(ag){var af=ag.startContainer,aj=ag.startOffset,ai,ah;if(af.nodeType==1||af.nodeValue===""){af=af.nodeType==1?af.childNodes[aj]:af;if(af){ai=new s(af,af.parentNode);for(ah=ai.current();ah;ah=ai.next()){if(ah.nodeType==3&&!f(ah)){ag.setStart(ah,0);break}}}}return ag}function U(ag,af){af=af||ad;if(ag){M(af.styles,function(ai,ah){c.setStyle(ag,ah,q(ai,ac))});M(af.attributes,function(ai,ah){c.setAttrib(ag,ah,q(ai,ac))});M(af.classes,function(ah){ah=q(ah,ac);if(!c.hasClass(ag,ah)){c.addClass(ag,ah)}})}}function ae(ag){var af=[],ai,ah;ai=ad.inline||ad.block;ah=c.create(ai);U(ah);I.walk(ag,function(aj){var ak;function al(am){var ap=am.nodeName.toLowerCase(),ao=am.parentNode.nodeName.toLowerCase(),an;if(g(ap,"br")){ak=0;if(ad.block){c.remove(am)}return}if(ad.wrapper&&v(am,W,ac)){ak=0;return}if(ad.block&&!ad.wrapper&&F(ap)){am=c.rename(am,ai);U(am);af.push(am);ak=0;return}if(ad.selector){M(Z,function(aq){if(c.is(am,aq.selector)&&!b(am)){U(am,aq);an=true}});if(!ad.inline||an){ak=0;return}}if((ad.wrap_links!==false||ap!="a")&&d(ai,ap)&&d(ao,ai)){if(!ak){ak=ah.cloneNode(Q);am.parentNode.insertBefore(ak,am);af.push(ak)}ak.appendChild(am)}else{ak=0;M(a.grep(am.childNodes),al);ak=0}}M(aj,al)});M(af,function(al){var aj;function am(ao){var an=0;M(ao.childNodes,function(ap){if(!f(ap)&&!G(ap)){an++}});return an}function ak(an){var ap,ao;M(an.childNodes,function(aq){if(aq.nodeType==1&&!G(aq)&&!b(aq)){ap=aq;return Q}});if(ap&&h(ap,ad)){ao=ap.cloneNode(Q);U(ao);c.replace(ao,an,A);c.remove(ap,1)}return ao||an}aj=am(al);if(aj===0){c.remove(al,1);return}if(ad.inline||ad.wrapper){if(!ad.exact&&aj===1){al=ak(al)}M(Z,function(an){M(c.select(an.inline,al),function(ao){S(an,ac,ao,an.exact?ao:null)})});if(v(al.parentNode,W,ac)){c.remove(al,1);al=0;return A}if(ad.merge_with_parents){c.getParent(al.parentNode,function(an){if(v(an,W,ac)){c.remove(al,1);al=0;return A}})}if(al){al=t(B(al),al);al=t(al,B(al,A))}}})}if(ad){if(Y){V=c.createRng();V.setStartBefore(Y);V.setEndAfter(Y);ae(n(V,Z))}else{if(!p.isCollapsed()||!ad.inline){ab=p.getBookmark();ae(n(p.getRng(A),Z));p.moveToBookmark(ab);p.setRng(X(p.getRng(A)));T.nodeChanged()}else{O("apply",W,ac)}}}}function z(W,af,Z){var aa=P(W),ah=aa[0],ae,ad,V;function Y(ak){var aj=ak.startContainer,ap=ak.startOffset,ao,an,al,am;if(aj.nodeType==3&&ap>=aj.nodeValue.length-1){aj=aj.parentNode;ap=r(aj)+1}if(aj.nodeType==1){al=aj.childNodes;aj=al[Math.min(ap,al.length-1)];ao=new s(aj);if(ap>al.length-1){ao.next()}for(an=ao.current();an;an=ao.next()){if(an.nodeType==3&&!f(an)){am=c.create("a",null,D);an.parentNode.insertBefore(am,an);ak.setStart(an,0);p.setRng(ak);c.remove(am);return}}}}function X(am){var al,ak,aj;al=a.grep(am.childNodes);for(ak=0,aj=aa.length;ak<aj;ak++){if(S(aa[ak],af,am,am)){break}}if(ah.deep){for(ak=0,aj=al.length;ak<aj;ak++){X(al[ak])}}}function ab(aj){var ak;M(l(aj.parentNode).reverse(),function(al){var am;if(!ak&&al.id!="_start"&&al.id!="_end"){am=v(al,W,af);if(am&&am.split!==false){ak=al}}});return ak}function U(am,aj,ao,ar){var at,aq,ap,al,an,ak;if(am){ak=am.parentNode;for(at=aj.parentNode;at&&at!=ak;at=at.parentNode){aq=at.cloneNode(Q);for(an=0;an<aa.length;an++){if(S(aa[an],af,aq,aq)){aq=0;break}}if(aq){if(ap){aq.appendChild(ap)}if(!al){al=aq}ap=aq}}if(ar&&(!ah.mixed||!E(am))){aj=c.split(am,aj)}if(ap){ao.parentNode.insertBefore(ap,ao);al.appendChild(ao)}}return aj}function ag(aj){return U(ab(aj),aj,aj,true)}function ac(al){var ak=c.get(al?"_start":"_end"),aj=ak[al?"firstChild":"lastChild"];if(G(aj)){aj=aj[al?"firstChild":"lastChild"]}c.remove(ak,true);return aj}function ai(aj){var ak,al;aj=n(aj,aa,A);if(ah.split){ak=H(aj,A);al=H(aj);if(ak!=al){ak=L(ak,"span",{id:"_start",_mce_type:"bookmark"});al=L(al,"span",{id:"_end",_mce_type:"bookmark"});ag(ak);ag(al);ak=ac(A);al=ac()}else{ak=al=ag(ak)}aj.startContainer=ak.parentNode;aj.startOffset=r(ak);aj.endContainer=al.parentNode;aj.endOffset=r(al)+1}I.walk(aj,function(am){M(am,function(an){X(an)})})}if(Z){V=c.createRng();V.setStartBefore(Z);V.setEndAfter(Z);ai(V);return}if(!p.isCollapsed()||!ah.inline){ae=p.getBookmark();ai(p.getRng(A));p.moveToBookmark(ae);if(i(W,af,p.getStart())){Y(p.getRng(true))}T.nodeChanged()}else{O("remove",W,af)}}function C(U,W,V){if(i(U,W,V)){z(U,W,V)}else{R(U,W,V)}}function v(V,U,aa,Y){var W=P(U),ab,Z,X;function ac(ag,ai,aj){var af,ah,ad=ai[aj],ae;if(ad){if(ad.length===o){for(af in ad){if(ad.hasOwnProperty(af)){if(aj==="attributes"){ah=c.getAttrib(ag,af)}else{ah=J(ag,af)}if(Y&&!ah&&!ai.exact){return}if((!Y||ai.exact)&&!g(ah,q(ad[af],aa))){return}}}}else{for(ae=0;ae<ad.length;ae++){if(aj==="attributes"?c.getAttrib(ag,ad[ae]):J(ag,ad[ae])){return ai}}}}return ai}if(W&&V){for(Z=0;Z<W.length;Z++){ab=W[Z];if(h(V,ab)&&ac(V,ab,"attributes")&&ac(V,ab,"styles")){if(X=ab.classes){for(Z=0;Z<X.length;Z++){if(!c.hasClass(V,X[Z])){return}}}return ab}}}}function i(W,Z,Y){var V,X;function U(aa){aa=c.getParent(aa,function(ab){return !!v(ab,W,Z,true)});return v(aa,W,Z)}if(Y){return U(Y)}if(p.isCollapsed()){for(X=N.apply.length-1;X>=0;X--){if(N.apply[X].name==W){return true}}for(X=N.remove.length-1;X>=0;X--){if(N.remove[X].name==W){return false}}return U(p.getNode())}Y=p.getNode();if(U(Y)){return A}V=p.getStart();if(V!=Y){if(U(V)){return A}}return Q}function u(ab,aa){var Y,Z=[],X={},W,V,U;if(p.isCollapsed()){for(V=0;V<ab.length;V++){for(W=N.remove.length-1;W>=0;W--){U=ab[V];if(N.remove[W].name==U){X[U]=true;break}}}for(W=N.apply.length-1;W>=0;W--){for(V=0;V<ab.length;V++){U=ab[V];if(!X[U]&&N.apply[W].name==U){X[U]=true;Z.push(U)}}}}Y=p.getStart();c.getParent(Y,function(ae){var ad,ac;for(ad=0;ad<ab.length;ad++){ac=ab[ad];if(!X[ac]&&v(ae,ac,aa)){X[ac]=true;Z.push(ac)}}});return Z}function x(Y){var aa=P(Y),X,W,Z,V,U;if(aa){X=p.getStart();W=l(X);for(V=aa.length-1;V>=0;V--){U=aa[V].selector;if(!U){return A}for(Z=W.length-1;Z>=0;Z--){if(c.is(W[Z],U)){return A}}}}return Q}a.extend(this,{get:P,register:j,apply:R,remove:z,toggle:C,match:i,matchAll:u,matchNode:v,canApply:x});function h(U,V){if(g(U,V.inline)){return A}if(g(U,V.block)){return A}if(V.selector){return c.is(U,V.selector)}}function g(V,U){V=V||"";U=U||"";V=""+(V.nodeName||V);U=""+(U.nodeName||U);return V.toLowerCase()==U.toLowerCase()}function J(V,U){var W=c.getStyle(V,U);if(U=="color"||U=="backgroundColor"){W=c.toHex(W)}if(U=="fontWeight"&&W==700){W="bold"}return""+W}function q(U,V){if(typeof(U)!="string"){U=U(V)}else{if(V){U=U.replace(/%(\w+)/g,function(X,W){return V[W]||X})}}return U}function f(U){return U&&U.nodeType===3&&/^([\s\r\n]+|)$/.test(U.nodeValue)}function L(W,V,U){var X=c.create(V,U);W.parentNode.insertBefore(X,W);X.appendChild(W);return X}function n(U,ac,X){var W=U.startContainer,Z=U.startOffset,af=U.endContainer,aa=U.endOffset,ae,ab;function ad(ai,aj,ag,ah){var ak,al;ah=ah||c.getRoot();for(;;){ak=ai.parentNode;if(ak==ah||(!ac[0].block_expand&&E(ak))){return ai}for(ae=ak[aj];ae&&ae!=ai;ae=ae[ag]){if(ae.nodeType==1&&!G(ae)){return ai}if(ae.nodeType==3&&!f(ae)){return ai}}ai=ai.parentNode}return ai}if(W.nodeType==1&&W.hasChildNodes()){ab=W.childNodes.length-1;W=W.childNodes[Z>ab?ab:Z];if(W.nodeType==3){Z=0}}if(af.nodeType==1&&af.hasChildNodes()){ab=af.childNodes.length-1;af=af.childNodes[aa>ab?ab:aa-1];if(af.nodeType==3){aa=af.nodeValue.length}}if(G(W.parentNode)){W=W.parentNode}if(G(W)){W=W.nextSibling||W}if(G(af.parentNode)){af=af.parentNode}if(G(af)){af=af.previousSibling||af}if(ac[0].inline||ac[0].block_expand){W=ad(W,"firstChild","nextSibling");af=ad(af,"lastChild","previousSibling")}if(ac[0].selector&&ac[0].expand!==Q&&!ac[0].inline){function Y(ah,ag){var ai,aj,ak;if(ah.nodeType==3&&ah.nodeValue.length==0&&ah[ag]){ah=ah[ag]}ai=l(ah);for(aj=0;aj<ai.length;aj++){for(ak=0;ak<ac.length;ak++){if(c.is(ai[aj],ac[ak].selector)){return ai[aj]}}}return ah}W=Y(W,"previousSibling");af=Y(af,"nextSibling")}if(ac[0].block||ac[0].selector){function V(ah,ag,aj){var ai;if(!ac[0].wrapper){ai=c.getParent(ah,ac[0].block)}if(!ai){ai=c.getParent(ah.nodeType==3?ah.parentNode:ah,E)}if(ai&&ac[0].wrapper){ai=l(ai,"ul,ol").reverse()[0]||ai}if(!ai){ai=ah;while(ai[ag]&&!E(ai[ag])){ai=ai[ag];if(g(ai,"br")){break}}}return ai||ah}W=V(W,"previousSibling");af=V(af,"nextSibling");if(ac[0].block){if(!E(W)){W=ad(W,"firstChild","nextSibling")}if(!E(af)){af=ad(af,"lastChild","previousSibling")}}}if(W.nodeType==1){Z=r(W);W=W.parentNode}if(af.nodeType==1){aa=r(af)+1;af=af.parentNode}return{startContainer:W,startOffset:Z,endContainer:af,endOffset:aa}}function S(aa,Z,X,U){var W,V,Y;if(!h(X,aa)){return Q}if(aa.remove!="all"){M(aa.styles,function(ac,ab){ac=q(ac,Z);if(typeof(ab)==="number"){ab=ac;U=0}if(!U||g(J(U,ab),ac)){c.setStyle(X,ab,"")}Y=1});if(Y&&c.getAttrib(X,"style")==""){X.removeAttribute("style");X.removeAttribute("_mce_style")}M(aa.attributes,function(ad,ab){var ac;ad=q(ad,Z);if(typeof(ab)==="number"){ab=ad;U=0}if(!U||g(c.getAttrib(U,ab),ad)){if(ab=="class"){ad=c.getAttrib(X,ab);if(ad){ac="";M(ad.split(/\s+/),function(ae){if(/mce\w+/.test(ae)){ac+=(ac?" ":"")+ae}});if(ac){c.setAttrib(X,ab,ac);return}}}if(ab=="class"){X.removeAttribute("className")}if(e.test(ab)){X.removeAttribute("_mce_"+ab)}X.removeAttribute(ab)}});M(aa.classes,function(ab){ab=q(ab,Z);if(!U||c.hasClass(U,ab)){c.removeClass(X,ab)}});V=c.getAttribs(X);for(W=0;W<V.length;W++){if(V[W].nodeName.indexOf("_")!==0){return Q}}}if(aa.remove!="none"){m(X,aa);return A}}function m(W,X){var U=W.parentNode,V;if(X.block){if(!k){function Y(aa,Z,ab){aa=B(aa,Z,ab);return !aa||(aa.nodeName=="BR"||E(aa))}if(E(W)&&!E(U)){if(!Y(W,Q)&&!Y(W.firstChild,A,1)){W.insertBefore(c.create("br"),W.firstChild)}if(!Y(W,A)&&!Y(W.lastChild,Q,1)){W.appendChild(c.create("br"))}}}else{if(U==c.getRoot()){if(!X.list_block||!g(W,X.list_block)){M(a.grep(W.childNodes),function(Z){if(d(k,Z.nodeName.toLowerCase())){if(!V){V=L(Z,k)}else{V.appendChild(Z)}}else{V=0}})}}}}if(X.selector&&X.inline&&!g(X.inline,W)){return}c.remove(W,1)}function B(V,U,W){if(V){U=U?"nextSibling":"previousSibling";for(V=W?V:V[U];V;V=V[U]){if(V.nodeType==1||!f(V)){return V}}}}function G(U){return U&&U.nodeType==1&&U.getAttribute("_mce_type")=="bookmark"}function t(Y,X){var U,W,V;function aa(ad,ac){if(ad.nodeName!=ac.nodeName){return Q}function ab(af){var ag={};M(c.getAttribs(af),function(ah){var ai=ah.nodeName.toLowerCase();if(ai.indexOf("_")!==0&&ai!=="style"){ag[ai]=c.getAttrib(af,ai)}});return ag}function ae(ai,ah){var ag,af;for(af in ai){if(ai.hasOwnProperty(af)){ag=ah[af];if(ag===o){return Q}if(ai[af]!=ag){return Q}delete ah[af]}}for(af in ah){if(ah.hasOwnProperty(af)){return Q}}return A}if(!ae(ab(ad),ab(ac))){return Q}if(!ae(c.parseStyle(c.getAttrib(ad,"style")),c.parseStyle(c.getAttrib(ac,"style")))){return Q}return A}if(Y&&X){function Z(ac,ab){for(W=ac;W;W=W[ab]){if(W.nodeType==3&&!f(W)){return ac}if(W.nodeType==1&&!G(W)){return W}}return ac}Y=Z(Y,"previousSibling");X=Z(X,"nextSibling");if(aa(Y,X)){for(W=Y.nextSibling;W&&W!=X;){V=W;W=W.nextSibling;Y.appendChild(V)}c.remove(X);M(a.grep(X.childNodes),function(ab){Y.appendChild(ab)});return Y}}return X}function F(U){return/^(h[1-6]|p|div|pre|address|dl|dt|dd)$/.test(U)}function H(V,Y){var U,X,W;U=V[Y?"startContainer":"endContainer"];X=V[Y?"startOffset":"endOffset"];if(U.nodeType==1){W=U.childNodes.length-1;if(!Y&&X){X--}U=U.childNodes[X>W?W:X]}return U}function O(Z,V,Y){var W,U=N[Z],aa=N[Z=="apply"?"remove":"apply"];function ab(){return N.apply.length||N.remove.length}function X(){N.apply=[];N.remove=[]}function ac(ad){M(N.apply.reverse(),function(ae){R(ae.name,ae.vars,ad)});M(N.remove.reverse(),function(ae){z(ae.name,ae.vars,ad)});c.remove(ad,1);X()}for(W=U.length-1;W>=0;W--){if(U[W].name==V){return}}U.push({name:V,vars:Y});for(W=aa.length-1;W>=0;W--){if(aa[W].name==V){aa.splice(W,1)}}if(ab()){T.getDoc().execCommand("FontName",false,"mceinline");N.lastRng=p.getRng();M(c.select("font,span"),function(ae){var ad;if(b(ae)){ad=p.getBookmark();ac(ae);p.moveToBookmark(ad);T.nodeChanged()}});if(!N.isListening&&ab()){N.isListening=true;M("onKeyDown,onKeyUp,onKeyPress,onMouseUp".split(","),function(ad){T[ad].addToTop(function(ae,af){if(ab()&&!a.dom.RangeUtils.compareRanges(N.lastRng,p.getRng())){M(c.select("font,span"),function(ah){var ai,ag;if(b(ah)){ai=ah.firstChild;if(ai){ac(ah);ag=c.createRng();ag.setStart(ai,ai.nodeValue.length);ag.setEnd(ai,ai.nodeValue.length);p.setRng(ag);ae.nodeChanged()}else{c.remove(ah)}}});if(af.type=="keyup"||af.type=="mouseup"){X()}}})})}}}}})(tinymce);tinymce.onAddEditor.add(function(e,a){var d,h,g,c=a.settings;if(c.inline_styles){h=e.explode(c.font_size_style_values);function b(j,i){e.each(i,function(l,k){if(l){g.setStyle(j,k,l)}});g.rename(j,"span")}d={font:function(j,i){b(i,{backgroundColor:i.style.backgroundColor,color:i.color,fontFamily:i.face,fontSize:h[parseInt(i.size)-1]})},u:function(j,i){b(i,{textDecoration:"underline"})},strike:function(j,i){b(i,{textDecoration:"line-through"})}};function f(i,j){g=i.dom;if(c.convert_fonts_to_spans){e.each(g.select("font,u,strike",j.node),function(k){d[k.nodeName.toLowerCase()](a.dom,k)})}}a.onPreProcess.add(f);a.onInit.add(function(){a.selection.onSetContent.add(f)})}});
Index: /tags/3.1/wp-includes/js/tinymce/tiny_mce_popup.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/tiny_mce_popup.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/tiny_mce_popup.js	(revision 17487)
@@ -0,0 +1,5 @@
+
+// Uncomment and change this document.domain value if you are loading the script cross subdomains
+// document.domain = 'moxiecode.com';
+
+var tinymce=null,tinyMCEPopup,tinyMCE;tinyMCEPopup={init:function(){var b=this,a,c;a=b.getWin();tinymce=a.tinymce;tinyMCE=a.tinyMCE;b.editor=tinymce.EditorManager.activeEditor;b.params=b.editor.windowManager.params;b.features=b.editor.windowManager.features;b.dom=b.editor.windowManager.createInstance("tinymce.dom.DOMUtils",document);if(b.features.popup_css!==false){b.dom.loadCSS(b.features.popup_css||b.editor.settings.popup_css)}b.listeners=[];b.onInit={add:function(e,d){b.listeners.push({func:e,scope:d})}};b.isWindow=!b.getWindowArg("mce_inline");b.id=b.getWindowArg("mce_window_id");b.editor.windowManager.onOpen.dispatch(b.editor.windowManager,window)},getWin:function(){return(!window.frameElement&&window.dialogArguments)||opener||parent||top},getWindowArg:function(c,b){var a=this.params[c];return tinymce.is(a)?a:b},getParam:function(b,a){return this.editor.getParam(b,a)},getLang:function(b,a){return this.editor.getLang(b,a)},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},resizeToInnerSize:function(){var a=this;setTimeout(function(){var b=a.dom.getViewPort(window);a.editor.windowManager.resizeBy(a.getWindowArg("mce_width")-b.w,a.getWindowArg("mce_height")-b.h,a.id||window)},0)},executeOnLoad:function(s){this.onInit.add(function(){eval(s)})},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark(1)},restoreSelection:function(){var a=tinyMCEPopup;if(!a.isWindow&&tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},requireLangPack:function(){var b=this,a=b.getWindowArg("plugin_url")||b.getWindowArg("theme_url");if(a&&b.editor.settings.language&&b.features.translate_i18n!==false){a+="/langs/"+b.editor.settings.language+"_dlg.js";if(!tinymce.ScriptLoader.isDone(a)){document.write('<script type="text/javascript" src="'+tinymce._addVer(a)+'"><\/script>');tinymce.ScriptLoader.markDone(a)}}},pickColor:function(b,a){this.execCommand("mceColorPicker",true,{color:document.getElementById(a).value,func:function(e){document.getElementById(a).value=e;try{document.getElementById(a).onchange()}catch(d){}}})},openBrowser:function(a,c,b){tinyMCEPopup.restoreSelection();this.editor.execCallback("file_browser_callback",a,document.getElementById(a).value,c,window)},confirm:function(b,a,c){this.editor.windowManager.confirm(b,a,c,window)},alert:function(b,a,c){this.editor.windowManager.alert(b,a,c,window)},close:function(){var a=this;function b(){a.editor.windowManager.close(window);tinymce=tinyMCE=a.editor=a.params=a.dom=a.dom.doc=null}if(tinymce.isOpera){a.getWin().setTimeout(b,0)}else{b()}},_restoreSelection:function(){var a=window.event.srcElement;if(a.nodeName=="INPUT"&&(a.type=="submit"||a.type=="button")){tinyMCEPopup.restoreSelection()}},_onDOMLoaded:function(){var b=tinyMCEPopup,d=document.title,e,c,a;if(b.domLoaded){return}b.domLoaded=1;if(b.features.translate_i18n!==false){c=document.body.innerHTML;if(tinymce.isIE){c=c.replace(/ (value|title|alt)=([^"][^\s>]+)/gi,' $1="$2"')}document.dir=b.editor.getParam("directionality","");if((a=b.editor.translate(c))&&a!=c){document.body.innerHTML=a}if((a=b.editor.translate(d))&&a!=d){document.title=d=a}}document.body.style.display="";if(tinymce.isIE){document.attachEvent("onmouseup",tinyMCEPopup._restoreSelection);b.dom.add(b.dom.select("head")[0],"base",{target:"_self"})}b.restoreSelection();b.resizeToInnerSize();if(!b.isWindow){b.editor.windowManager.setTitle(window,d)}else{window.focus()}if(!tinymce.isIE&&!b.isWindow){tinymce.dom.Event._add(document,"focus",function(){b.editor.windowManager.focus(b.id)})}tinymce.each(b.dom.select("select"),function(f){f.onkeydown=tinyMCEPopup._accessHandler});tinymce.each(b.listeners,function(f){f.func.call(f.scope,b.editor)});if(b.getWindowArg("mce_auto_focus",true)){window.focus();tinymce.each(document.forms,function(g){tinymce.each(g.elements,function(f){if(b.dom.hasClass(f,"mceFocus")&&!f.disabled){f.focus();return false}})})}document.onkeyup=tinyMCEPopup._closeWinKeyHandler},_accessHandler:function(a){a=a||window.event;if(a.keyCode==13||a.keyCode==32){a=a.target||a.srcElement;if(a.onchange){a.onchange()}return tinymce.dom.Event.cancel(a)}},_closeWinKeyHandler:function(a){a=a||window.event;if(a.keyCode==27){tinyMCEPopup.close()}},_wait:function(){if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);tinyMCEPopup._onDOMLoaded()}});if(document.documentElement.doScroll&&window==window.top){(function(){if(tinyMCEPopup.domLoaded){return}try{document.documentElement.doScroll("left")}catch(a){setTimeout(arguments.callee,0);return}tinyMCEPopup._onDOMLoaded()})()}document.attachEvent("onload",tinyMCEPopup._onDOMLoaded)}else{if(document.addEventListener){window.addEventListener("DOMContentLoaded",tinyMCEPopup._onDOMLoaded,false);window.addEventListener("load",tinyMCEPopup._onDOMLoaded,false)}}}};tinyMCEPopup.init();tinyMCEPopup._wait();
Index: /tags/3.1/wp-includes/js/tinymce/utils/editable_selects.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/utils/editable_selects.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/utils/editable_selects.js	(revision 17487)
@@ -0,0 +1,70 @@
+/**
+ * editable_selects.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+var TinyMCE_EditableSelects = {
+	editSelectElm : null,
+
+	init : function() {
+		var nl = document.getElementsByTagName("select"), i, d = document, o;
+
+		for (i=0; i<nl.length; i++) {
+			if (nl[i].className.indexOf('mceEditableSelect') != -1) {
+				o = new Option('(value)', '__mce_add_custom__');
+
+				o.className = 'mceAddSelectValue';
+
+				nl[i].options[nl[i].options.length] = o;
+				nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect;
+			}
+		}
+	},
+
+	onChangeEditableSelect : function(e) {
+		var d = document, ne, se = window.event ? window.event.srcElement : e.target;
+
+		if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
+			ne = d.createElement("input");
+			ne.id = se.id + "_custom";
+			ne.name = se.name + "_custom";
+			ne.type = "text";
+
+			ne.style.width = se.offsetWidth + 'px';
+			se.parentNode.insertBefore(ne, se);
+			se.style.display = 'none';
+			ne.focus();
+			ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
+			ne.onkeydown = TinyMCE_EditableSelects.onKeyDown;
+			TinyMCE_EditableSelects.editSelectElm = se;
+		}
+	},
+
+	onBlurEditableSelectInput : function() {
+		var se = TinyMCE_EditableSelects.editSelectElm;
+
+		if (se) {
+			if (se.previousSibling.value != '') {
+				addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value);
+				selectByValue(document.forms[0], se.id, se.previousSibling.value);
+			} else
+				selectByValue(document.forms[0], se.id, '');
+
+			se.style.display = 'inline';
+			se.parentNode.removeChild(se.previousSibling);
+			TinyMCE_EditableSelects.editSelectElm = null;
+		}
+	},
+
+	onKeyDown : function(e) {
+		e = e || window.event;
+
+		if (e.keyCode == 13)
+			TinyMCE_EditableSelects.onBlurEditableSelectInput();
+	}
+};
Index: /tags/3.1/wp-includes/js/tinymce/utils/form_utils.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/utils/form_utils.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/utils/form_utils.js	(revision 17487)
@@ -0,0 +1,200 @@
+/**
+ * form_utils.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
+
+function getColorPickerHTML(id, target_form_element) {
+	var h = "";
+
+	h += '<a id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
+	h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';
+
+	return h;
+}
+
+function updateColor(img_id, form_element_id) {
+	document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value;
+}
+
+function setBrowserDisabled(id, state) {
+	var img = document.getElementById(id);
+	var lnk = document.getElementById(id + "_link");
+
+	if (lnk) {
+		if (state) {
+			lnk.setAttribute("realhref", lnk.getAttribute("href"));
+			lnk.removeAttribute("href");
+			tinyMCEPopup.dom.addClass(img, 'disabled');
+		} else {
+			if (lnk.getAttribute("realhref"))
+				lnk.setAttribute("href", lnk.getAttribute("realhref"));
+
+			tinyMCEPopup.dom.removeClass(img, 'disabled');
+		}
+	}
+}
+
+function getBrowserHTML(id, target_form_element, type, prefix) {
+	var option = prefix + "_" + type + "_browser_callback", cb, html;
+
+	cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
+
+	if (!cb)
+		return "";
+
+	html = "";
+	html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';
+	html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';
+
+	return html;
+}
+
+function openBrowser(img_id, target_form_element, type, option) {
+	var img = document.getElementById(img_id);
+
+	if (img.className != "mceButtonDisabled")
+		tinyMCEPopup.openBrowser(target_form_element, type, option);
+}
+
+function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
+	if (!form_obj || !form_obj.elements[field_name])
+		return;
+
+	var sel = form_obj.elements[field_name];
+
+	var found = false;
+	for (var i=0; i<sel.options.length; i++) {
+		var option = sel.options[i];
+
+		if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
+			option.selected = true;
+			found = true;
+		} else
+			option.selected = false;
+	}
+
+	if (!found && add_custom && value != '') {
+		var option = new Option(value, value);
+		option.selected = true;
+		sel.options[sel.options.length] = option;
+		sel.selectedIndex = sel.options.length - 1;
+	}
+
+	return found;
+}
+
+function getSelectValue(form_obj, field_name) {
+	var elm = form_obj.elements[field_name];
+
+	if (elm == null || elm.options == null || elm.selectedIndex === -1)
+		return "";
+
+	return elm.options[elm.selectedIndex].value;
+}
+
+function addSelectValue(form_obj, field_name, name, value) {
+	var s = form_obj.elements[field_name];
+	var o = new Option(name, value);
+	s.options[s.options.length] = o;
+}
+
+function addClassesToList(list_id, specific_option) {
+	// Setup class droplist
+	var styleSelectElm = document.getElementById(list_id);
+	var styles = tinyMCEPopup.getParam('theme_advanced_styles', false);
+	styles = tinyMCEPopup.getParam(specific_option, styles);
+
+	if (styles) {
+		var stylesAr = styles.split(';');
+
+		for (var i=0; i<stylesAr.length; i++) {
+			if (stylesAr != "") {
+				var key, value;
+
+				key = stylesAr[i].split('=')[0];
+				value = stylesAr[i].split('=')[1];
+
+				styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
+			}
+		}
+	} else {
+		tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
+			styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
+		});
+	}
+}
+
+function isVisible(element_id) {
+	var elm = document.getElementById(element_id);
+
+	return elm && elm.style.display != "none";
+}
+
+function convertRGBToHex(col) {
+	var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
+
+	var rgb = col.replace(re, "$1,$2,$3").split(',');
+	if (rgb.length == 3) {
+		r = parseInt(rgb[0]).toString(16);
+		g = parseInt(rgb[1]).toString(16);
+		b = parseInt(rgb[2]).toString(16);
+
+		r = r.length == 1 ? '0' + r : r;
+		g = g.length == 1 ? '0' + g : g;
+		b = b.length == 1 ? '0' + b : b;
+
+		return "#" + r + g + b;
+	}
+
+	return col;
+}
+
+function convertHexToRGB(col) {
+	if (col.indexOf('#') != -1) {
+		col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
+
+		r = parseInt(col.substring(0, 2), 16);
+		g = parseInt(col.substring(2, 4), 16);
+		b = parseInt(col.substring(4, 6), 16);
+
+		return "rgb(" + r + "," + g + "," + b + ")";
+	}
+
+	return col;
+}
+
+function trimSize(size) {
+	return size.replace(/([0-9\.]+)px|(%|in|cm|mm|em|ex|pt|pc)/, '$1$2');
+}
+
+function getCSSSize(size) {
+	size = trimSize(size);
+
+	if (size == "")
+		return "";
+
+	// Add px
+	if (/^[0-9]+$/.test(size))
+		size += 'px';
+
+	return size;
+}
+
+function getStyle(elm, attrib, style) {
+	var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
+
+	if (val != '')
+		return '' + val;
+
+	if (typeof(style) == 'undefined')
+		style = attrib;
+
+	return tinyMCEPopup.dom.getStyle(elm, style);
+}
Index: /tags/3.1/wp-includes/js/tinymce/utils/mctabs.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/utils/mctabs.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/utils/mctabs.js	(revision 17487)
@@ -0,0 +1,77 @@
+/**
+ * mctabs.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+function MCTabs() {
+	this.settings = [];
+};
+
+MCTabs.prototype.init = function(settings) {
+	this.settings = settings;
+};
+
+MCTabs.prototype.getParam = function(name, default_value) {
+	var value = null;
+
+	value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
+
+	// Fix bool values
+	if (value == "true" || value == "false")
+		return (value == "true");
+
+	return value;
+};
+
+MCTabs.prototype.displayTab = function(tab_id, panel_id) {
+	var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i;
+
+	panelElm= document.getElementById(panel_id);
+	panelContainerElm = panelElm ? panelElm.parentNode : null;
+	tabElm = document.getElementById(tab_id);
+	tabContainerElm = tabElm ? tabElm.parentNode : null;
+	selectionClass = this.getParam('selection_class', 'current');
+
+	if (tabElm && tabContainerElm) {
+		nodes = tabContainerElm.childNodes;
+
+		// Hide all other tabs
+		for (i = 0; i < nodes.length; i++) {
+			if (nodes[i].nodeName == "LI")
+				nodes[i].className = '';
+		}
+
+		// Show selected tab
+		tabElm.className = 'current';
+	}
+
+	if (panelElm && panelContainerElm) {
+		nodes = panelContainerElm.childNodes;
+
+		// Hide all other panels
+		for (i = 0; i < nodes.length; i++) {
+			if (nodes[i].nodeName == "DIV")
+				nodes[i].className = 'panel';
+		}
+
+		// Show selected panel
+		panelElm.className = 'current';
+	}
+};
+
+MCTabs.prototype.getAnchor = function() {
+	var pos, url = document.location.href;
+
+	if ((pos = url.lastIndexOf('#')) != -1)
+		return url.substring(pos + 1);
+
+	return "";
+};
+
+// Global instance
+var mcTabs = new MCTabs();
Index: /tags/3.1/wp-includes/js/tinymce/utils/validate.js
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/utils/validate.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/utils/validate.js	(revision 17487)
@@ -0,0 +1,220 @@
+/**
+ * validate.js
+ *
+ * Copyright 2009, Moxiecode Systems AB
+ * Released under LGPL License.
+ *
+ * License: http://tinymce.moxiecode.com/license
+ * Contributing: http://tinymce.moxiecode.com/contributing
+ */
+
+/**
+	// String validation:
+
+	if (!Validator.isEmail('myemail'))
+		alert('Invalid email.');
+
+	// Form validation:
+
+	var f = document.forms['myform'];
+
+	if (!Validator.isEmail(f.myemail))
+		alert('Invalid email.');
+*/
+
+var Validator = {
+	isEmail : function(s) {
+		return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
+	},
+
+	isAbsUrl : function(s) {
+		return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
+	},
+
+	isSize : function(s) {
+		return this.test(s, '^[0-9]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
+	},
+
+	isId : function(s) {
+		return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
+	},
+
+	isEmpty : function(s) {
+		var nl, i;
+
+		if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
+			return true;
+
+		if (s.type == 'checkbox' && !s.checked)
+			return true;
+
+		if (s.type == 'radio') {
+			for (i=0, nl = s.form.elements; i<nl.length; i++) {
+				if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
+					return false;
+			}
+
+			return true;
+		}
+
+		return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
+	},
+
+	isNumber : function(s, d) {
+		return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
+	},
+
+	test : function(s, p) {
+		s = s.nodeType == 1 ? s.value : s;
+
+		return s == '' || new RegExp(p).test(s);
+	}
+};
+
+var AutoValidator = {
+	settings : {
+		id_cls : 'id',
+		int_cls : 'int',
+		url_cls : 'url',
+		number_cls : 'number',
+		email_cls : 'email',
+		size_cls : 'size',
+		required_cls : 'required',
+		invalid_cls : 'invalid',
+		min_cls : 'min',
+		max_cls : 'max'
+	},
+
+	init : function(s) {
+		var n;
+
+		for (n in s)
+			this.settings[n] = s[n];
+	},
+
+	validate : function(f) {
+		var i, nl, s = this.settings, c = 0;
+
+		nl = this.tags(f, 'label');
+		for (i=0; i<nl.length; i++)
+			this.removeClass(nl[i], s.invalid_cls);
+
+		c += this.validateElms(f, 'input');
+		c += this.validateElms(f, 'select');
+		c += this.validateElms(f, 'textarea');
+
+		return c == 3;
+	},
+
+	invalidate : function(n) {
+		this.mark(n.form, n);
+	},
+
+	reset : function(e) {
+		var t = ['label', 'input', 'select', 'textarea'];
+		var i, j, nl, s = this.settings;
+
+		if (e == null)
+			return;
+
+		for (i=0; i<t.length; i++) {
+			nl = this.tags(e.form ? e.form : e, t[i]);
+			for (j=0; j<nl.length; j++)
+				this.removeClass(nl[j], s.invalid_cls);
+		}
+	},
+
+	validateElms : function(f, e) {
+		var nl, i, n, s = this.settings, st = true, va = Validator, v;
+
+		nl = this.tags(f, e);
+		for (i=0; i<nl.length; i++) {
+			n = nl[i];
+
+			this.removeClass(n, s.invalid_cls);
+
+			if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
+				st = this.mark(f, n);
+
+			if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
+				st = this.mark(f, n);
+
+			if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
+				st = this.mark(f, n);
+
+			if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
+				st = this.mark(f, n);
+
+			if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
+				st = this.mark(f, n);
+
+			if (this.hasClass(n, s.size_cls) && !va.isSize(n))
+				st = this.mark(f, n);
+
+			if (this.hasClass(n, s.id_cls) && !va.isId(n))
+				st = this.mark(f, n);
+
+			if (this.hasClass(n, s.min_cls, true)) {
+				v = this.getNum(n, s.min_cls);
+
+				if (isNaN(v) || parseInt(n.value) < parseInt(v))
+					st = this.mark(f, n);
+			}
+
+			if (this.hasClass(n, s.max_cls, true)) {
+				v = this.getNum(n, s.max_cls);
+
+				if (isNaN(v) || parseInt(n.value) > parseInt(v))
+					st = this.mark(f, n);
+			}
+		}
+
+		return st;
+	},
+
+	hasClass : function(n, c, d) {
+		return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
+	},
+
+	getNum : function(n, c) {
+		c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
+		c = c.replace(/[^0-9]/g, '');
+
+		return c;
+	},
+
+	addClass : function(n, c, b) {
+		var o = this.removeClass(n, c);
+		n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
+	},
+
+	removeClass : function(n, c) {
+		c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
+		return n.className = c != ' ' ? c : '';
+	},
+
+	tags : function(f, s) {
+		return f.getElementsByTagName(s);
+	},
+
+	mark : function(f, n) {
+		var s = this.settings;
+
+		this.addClass(n, s.invalid_cls);
+		this.markLabels(f, n, s.invalid_cls);
+
+		return false;
+	},
+
+	markLabels : function(f, n, ic) {
+		var nl, i;
+
+		nl = this.tags(f, "label");
+		for (i=0; i<nl.length; i++) {
+			if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
+				this.addClass(nl[i], ic);
+		}
+
+		return null;
+	}
+};
Index: /tags/3.1/wp-includes/js/tinymce/wp-mce-help.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/wp-mce-help.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/wp-mce-help.php	(revision 17487)
@@ -0,0 +1,263 @@
+<?php
+/**
+ * @package TinyMCE
+ * @author Moxiecode
+ * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
+ */
+
+/** @ignore */
+require_once('../../../wp-load.php');
+header('Content-Type: text/html; charset=' . get_bloginfo('charset'));
+?>
+<!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 language_attributes(); ?>>
+<head>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
+<title><?php _e('Rich Editor Help') ?></title>
+<script type="text/javascript" src="tiny_mce_popup.js?ver=3223"></script>
+<?php
+wp_admin_css( 'global', true );
+wp_admin_css( 'wp-admin', true );
+?>
+<style type="text/css">
+	#wphead {
+		font-size: 80%;
+		border-top: 0;
+		color: #555;
+		background-color: #f1f1f1;
+	}
+	#wphead h1 {
+		font-size: 24px;
+		color: #555;
+		margin: 0;
+		padding: 10px;
+	}
+	#tabs {
+		padding: 15px 15px 3px;
+		background-color: #f1f1f1;
+		border-bottom: 1px solid #dfdfdf;
+	}
+	#tabs li {
+		display: inline;
+	}
+	#tabs a.current {
+		background-color: #fff;
+		border-color: #dfdfdf;
+		border-bottom-color: #fff;
+		color: #d54e21;
+	}
+	#tabs a {
+		color: #2583AD;
+		padding: 6px;
+		border-width: 1px 1px 0;
+		border-style: solid solid none;
+		border-color: #f1f1f1;
+		text-decoration: none;
+	}
+	#tabs a:hover {
+		color: #d54e21;
+	}
+	.wrap h2 {
+		border-bottom-color: #dfdfdf;
+		color: #555;
+		margin: 5px 0;
+		padding: 0;
+		font-size: 18px;
+	}
+	#user_info {
+		right: 5%;
+		top: 5px;
+	}
+	h3 {
+		font-size: 1.1em;
+		margin-top: 10px;
+		margin-bottom: 0px;
+	}
+	#flipper {
+		margin: 0;
+		padding: 5px 20px 10px;
+		background-color: #fff;
+		border-left: 1px solid #dfdfdf;
+		border-bottom: 1px solid #dfdfdf;
+	}
+	* html {
+        overflow-x: hidden;
+        overflow-y: scroll;
+    }
+	#flipper div p {
+		margin-top: 0.4em;
+		margin-bottom: 0.8em;
+		text-align: justify;
+	}
+	th {
+		text-align: center;
+	}
+	.top th {
+		text-decoration: underline;
+	}
+	.top .key {
+		text-align: center;
+		width: 5em;
+	}
+	.top .action {
+		text-align: left;
+	}
+	.align {
+		border-left: 3px double #333;
+		border-right: 3px double #333;
+	}
+	.keys {
+		margin-bottom: 15px;
+	}
+	.keys p {
+		display: inline-block;
+		margin: 0px;
+		padding: 0px;
+	}
+	.keys .left { text-align: left; }
+	.keys .center { text-align: center; }
+	.keys .right { text-align: right; }
+	td b {
+		font-family: "Times New Roman" Times serif;
+	}
+	#buttoncontainer {
+		text-align: center;
+		margin-bottom: 20px;
+	}
+	#buttoncontainer a, #buttoncontainer a:hover {
+		border-bottom: 0px;
+	}
+</style>
+<?php if ( is_rtl() ) : ?>
+<style type="text/css">
+	#wphead, #tabs {
+		padding-left: auto;
+		padding-right: 15px;
+	}
+	#flipper {
+		margin: 5px 0 3px 10px;
+	}
+	.keys .left, .top, .action { text-align: right; }
+	.keys .right { text-align: left; }
+	td b { font-family: Tahoma, "Times New Roman", Times, serif }
+</style>
+<?php endif; ?>
+<script type="text/javascript">
+	function d(id) { return document.getElementById(id); }
+
+	function flipTab(n) {
+		for (i=1;i<=4;i++) {
+			c = d('content'+i.toString());
+			t = d('tab'+i.toString());
+			if ( n == i ) {
+				c.className = '';
+				t.className = 'current';
+			} else {
+				c.className = 'hidden';
+				t.className = '';
+			}
+		}
+	}
+
+    function init() {
+        document.getElementById('version').innerHTML = tinymce.majorVersion + "." + tinymce.minorVersion;
+        document.getElementById('date').innerHTML = tinymce.releaseDate;
+    }
+    tinyMCEPopup.onInit.add(init);
+</script>
+</head>
+<body>
+
+<div id="wphead"><h1><?php echo get_bloginfo('blogtitle'); ?></h1></div>
+
+<ul id="tabs">
+	<li><a id="tab1" href="javascript:flipTab(1)" title="<?php _e('Basics of Rich Editing') ?>" accesskey="1" tabindex="1" class="current"><?php _e('Basics') ?></a></li>
+	<li><a id="tab2" href="javascript:flipTab(2)" title="<?php _e('Advanced use of the Rich Editor') ?>" accesskey="2" tabindex="2"><?php _e('Advanced') ?></a></li>
+	<li><a id="tab3" href="javascript:flipTab(3)" title="<?php _e('Hotkeys') ?>" accesskey="3" tabindex="3"><?php _e('Hotkeys') ?></a></li>
+	<li><a id="tab4" href="javascript:flipTab(4)" title="<?php _e('About the software') ?>" accesskey="4" tabindex="4"><?php _e('About') ?></a></li>
+</ul>
+
+<div id="flipper" class="wrap">
+
+<div id="content1">
+	<h2><?php _e('Rich Editing Basics') ?></h2>
+	<p><?php _e('<em>Rich editing</em>, also called WYSIWYG for What You See Is What You Get, means your text is formatted as you type. The rich editor creates HTML code behind the scenes while you concentrate on writing. Font styles, links and images all appear approximately as they will on the internet.') ?></p>
+	<p><?php _e('WordPress includes a rich HTML editor that works well in all major web browsers used today. However editing HTML is not the same as typing text. Each web page has two major components: the structure, which is the actual HTML code and is produced by the editor as you type, and the display, that is applied to it by the currently selected WordPress theme and is defined in style.css. WordPress is producing valid XHTML 1.0 which means that inserting multiple line breaks (BR tags) after a paragraph would not produce white space on the web page. The BR tags will be removed as invalid by the internal HTML correcting functions.') ?></p>
+	<p><?php _e('While using the editor, most basic keyboard shortcuts work like in any other text editor. For example: Shift+Enter inserts line break, Ctrl+C = copy, Ctrl+X = cut, Ctrl+Z = undo, Ctrl+Y = redo, Ctrl+A = select all, etc. (on Mac use the Command key instead of Ctrl). See the Hotkeys tab for all available keyboard shortcuts.') ?></p>
+    <p><?php _e('If you do not like the way the rich editor works, you may turn it off from Your Profile submenu, under Users in the admin menu.') ?></p>
+</div>
+
+<div id="content2" class="hidden">
+	<h2><?php _e('Advanced Rich Editing') ?></h2>
+	<h3><?php _e('Images and Attachments') ?></h3>
+	<p><?php _e('There is a button in the editor toolbar for inserting images that are already hosted somewhere on the internet. If you have a URL for an image, click this button and enter the URL in the box which appears.') ?></p>
+	<p><?php _e('If you need to upload an image or another media file from your computer, you can use the Media Library buttons above the editor. The media library will attempt to create a thumbnail-sized copy from each uploaded image. To insert your image into the post, first click on the thumbnail to reveal a menu of options. When you have selected the options you like, click "Send to Editor" and your image or file will appear in the post you are editing. If you are inserting a movie, there are additional options in the "Media" dialog that can be opened from the second toolbar row.') ?></p>
+	<h3><?php _e('HTML in the Rich Editor') ?></h3>
+	<p><?php _e('Any HTML entered directly into the rich editor will show up as text when the post is viewed. What you see is what you get. When you want to include HTML elements that cannot be generated with the toolbar buttons, you must enter it by hand in the HTML editor. Examples are tables and &lt;code&gt;. To do this, click the HTML tab and edit the code, then switch back to Visual mode. If the code is valid and understood by the editor, you should see it rendered immediately.') ?></p>
+	<h3><?php _e('Pasting in the Rich Editor') ?></h3>
+	<p><?php _e('When pasting content from another web page the results can be inconsistent and depend on your browser and on the web page you are pasting from. The editor tries to correct any invalid HTML code that was pasted, but for best results try using the HTML tab or one of the paste buttons that are on the second row. Alternatively try pasting paragraph by paragraph. In most browsers to select one paragraph at a time, triple-click on it.') ?></p>
+	<p><?php _e('Pasting content from another application, like Word or Excel, is best done with the Paste from Word button on the second row, or in HTML mode.') ?></p>
+</div>
+
+<div id="content3" class="hidden">
+	<h2><?php _e('Writing at Full Speed') ?></h2>
+    <p><?php _e('Rather than reaching for your mouse to click on the toolbar, use these access keys. Windows and Linux use Ctrl + letter. Macintosh uses Command + letter.') ?></p>
+	<table class="keys" width="100%" style="border: 0 none;">
+		<tr class="top"><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th></tr>
+		<tr><th>c</th><td><?php _e('Copy') ?></td><th>v</th><td><?php _e('Paste') ?></td></tr>
+		<tr><th>a</th><td><?php _e('Select all') ?></td><th>x</th><td><?php _e('Cut') ?></td></tr>
+		<tr><th>z</th><td><?php _e('Undo') ?></td><th>y</th><td><?php _e('Redo') ?></td></tr>
+		<script type="text/javascript">
+		if ( ! tinymce.isWebKit )
+			document.write("<tr><th>b</th><td><?php _e('Bold') ?></td><th>i</th><td><?php _e('Italic') ?></td></tr>"+
+			"<tr><th>u</th><td><?php _e('Underline') ?></td><th>1</th><td><?php _e('Heading 1') ?></td></tr>"+
+			"<tr><th>2</th><td><?php _e('Heading 2') ?></td><th>3</th><td><?php _e('Heading 3') ?></td></tr>"+
+			"<tr><th>4</th><td><?php _e('Heading 4') ?></td><th>5</th><td><?php _e('Heading 5') ?></td></tr>"+
+			"<tr><th>6</th><td><?php _e('Heading 6') ?></td><th>9</th><td><?php _e('Address') ?></td></tr>")
+		</script>
+	</table>
+
+	<p><?php _e('The following shortcuts use different access keys: Alt + Shift + letter.') ?></p>
+	<table class="keys" width="100%" style="border: 0 none;">
+		<tr class="top"><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th></tr>
+		<script type="text/javascript">
+		if ( tinymce.isWebKit )
+			document.write("<tr><th>b</th><td><?php _e('Bold') ?></td><th>i</th><td><?php _e('Italic') ?></td></tr>")
+		</script>
+		<tr><th>n</th><td><?php _e('Check Spelling') ?></td><th>l</th><td><?php _e('Align Left') ?></td></tr>
+		<tr><th>j</th><td><?php _e('Justify Text') ?></td><th>c</th><td><?php _e('Align Center') ?></td></tr>
+		<tr><th>d</th><td><span style="text-decoration: line-through;"><?php _e('Strikethrough') ?></span></td><th>r</th><td><?php _e('Align Right') ?></td></tr>
+		<tr><th>u</th><td><strong>&bull;</strong> <?php _e('List') ?></td><th>a</th><td><?php _e('Insert link') ?></td></tr>
+		<tr><th>o</th><td>1. <?php _e('List') ?></td><th>s</th><td><?php _e('Remove link') ?></td></tr>
+		<tr><th>q</th><td><?php _e('Quote') ?></td><th>m</th><td><?php _e('Insert Image') ?></td></tr>
+		<tr><th>g</th><td><?php _e('Full Screen') ?></td><th>t</th><td><?php _e('Insert More Tag') ?></td></tr>
+		<tr><th>p</th><td><?php _e('Insert Page Break tag') ?></td><th>h</th><td><?php _e('Help') ?></td></tr>
+		<tr><th>e</th><td colspan="3"><?php _e('Switch to HTML mode') ?></td></tr>
+	</table>
+</div>
+
+<div id="content4" class="hidden">
+	<h2><?php _e('About TinyMCE'); ?></h2>
+
+    <p><?php _e('Version:'); ?> <span id="version"></span> (<span id="date"></span>)</p>
+	<p><?php printf(__('TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under %sLGPL</a>	by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.'), '<a href="'.home_url('/wp-includes/js/tinymce/license.txt').'" target="_blank" title="'.esc_attr__('GNU Library General Public Licence').'">') ?></p>
+	<p><?php _e('Copyright &copy; 2003-2007, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.') ?></p>
+	<p><?php _e('For more information about this software visit the <a href="http://tinymce.moxiecode.com" target="_blank">TinyMCE website</a>.') ?></p>
+
+	<div id="buttoncontainer">
+		<a href="http://www.moxiecode.com" target="_blank"><img src="themes/advanced/img/gotmoxie.png" alt="<?php _e('Got Moxie?') ?>" style="border: none;" /></a>
+		<a href="http://sourceforge.net/projects/tinymce/" target="_blank"><img src="themes/advanced/img/sflogo.png" alt="<?php _e('Hosted By Sourceforge') ?>" style="border: none;" /></a>
+		<a href="http://www.freshmeat.net/projects/tinymce" target="_blank"><img src="themes/advanced/img/fm.gif" alt="<?php _e('Also on freshmeat') ?>" style="border: none;" /></a>
+	</div>
+
+</div>
+</div>
+
+<div class="mceActionPanel">
+	<div style="margin: 8px auto; text-align: center;padding-bottom: 10px;">
+		<input type="button" id="cancel" name="cancel" value="<?php _e('Close'); ?>" title="<?php _e('Close'); ?>" onclick="tinyMCEPopup.close();" />
+	</div>
+</div>
+
+</body>
+</html>
Index: /tags/3.1/wp-includes/js/tinymce/wp-tinymce.php
===================================================================
--- /tags/3.1/wp-includes/js/tinymce/wp-tinymce.php	(revision 17487)
+++ /tags/3.1/wp-includes/js/tinymce/wp-tinymce.php	(revision 17487)
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Disable error reporting
+ *
+ * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
+ */
+error_reporting(0);
+
+$basepath = dirname(__FILE__);
+
+function get_file($path) {
+
+	if ( function_exists('realpath') )
+		$path = realpath($path);
+
+	if ( ! $path || ! @is_file($path) )
+		return false;
+
+	return @file_get_contents($path);
+}
+
+$expires_offset = 31536000;
+
+header('Content-Type: application/x-javascript; charset=UTF-8');
+header('Vary: Accept-Encoding'); // Handle proxies
+header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
+header("Cache-Control: public, max-age=$expires_offset");
+
+if ( isset($_GET['c']) && 1 == $_GET['c'] && isset($_SERVER['HTTP_ACCEPT_ENCODING'])
+	&& false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && ( $file = get_file($basepath . '/wp-tinymce.js.gz') ) ) {
+
+	header('Content-Encoding: gzip');
+	echo $file;
+} else {
+	echo get_file($basepath . '/tiny_mce.js');
+}
+exit;
Index: /tags/3.1/wp-includes/js/tw-sack.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/tw-sack.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tw-sack.dev.js	(revision 17487)
@@ -0,0 +1,193 @@
+/* Simple AJAX Code-Kit (SACK) v1.6.1 */
+/* ©2005 Gregory Wild-Smith */
+/* www.twilightuniverse.com */
+/* Software licenced under a modified X11 licence,
+   see documentation or authors website for more details */
+
+function sack(file) {
+	this.xmlhttp = null;
+
+	this.resetData = function() {
+		this.method = "POST";
+  		this.queryStringSeparator = "?";
+		this.argumentSeparator = "&";
+		this.URLString = "";
+		this.encodeURIString = true;
+  		this.execute = false;
+  		this.element = null;
+		this.elementObj = null;
+		this.requestFile = file;
+		this.vars = new Object();
+		this.responseStatus = new Array(2);
+  	};
+
+	this.resetFunctions = function() {
+  		this.onLoading = function() { };
+  		this.onLoaded = function() { };
+  		this.onInteractive = function() { };
+  		this.onCompletion = function() { };
+  		this.onError = function() { };
+		this.onFail = function() { };
+	};
+
+	this.reset = function() {
+		this.resetFunctions();
+		this.resetData();
+	};
+
+	this.createAJAX = function() {
+		try {
+			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+		} catch (e1) {
+			try {
+				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+			} catch (e2) {
+				this.xmlhttp = null;
+			}
+		}
+
+		if (! this.xmlhttp) {
+			if (typeof XMLHttpRequest != "undefined") {
+				this.xmlhttp = new XMLHttpRequest();
+			} else {
+				this.failed = true;
+			}
+		}
+	};
+
+	this.setVar = function(name, value){
+		this.vars[name] = Array(value, false);
+	};
+
+	this.encVar = function(name, value, returnvars) {
+		if (true == returnvars) {
+			return Array(encodeURIComponent(name), encodeURIComponent(value));
+		} else {
+			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
+		}
+	}
+
+	this.processURLString = function(string, encode) {
+		encoded = encodeURIComponent(this.argumentSeparator);
+		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
+		varArray = string.split(regexp);
+		for (i = 0; i < varArray.length; i++){
+			urlVars = varArray[i].split("=");
+			if (true == encode){
+				this.encVar(urlVars[0], urlVars[1]);
+			} else {
+				this.setVar(urlVars[0], urlVars[1]);
+			}
+		}
+	}
+
+	this.createURLString = function(urlstring) {
+		if (this.encodeURIString && this.URLString.length) {
+			this.processURLString(this.URLString, true);
+		}
+
+		if (urlstring) {
+			if (this.URLString.length) {
+				this.URLString += this.argumentSeparator + urlstring;
+			} else {
+				this.URLString = urlstring;
+			}
+		}
+
+		// prevents caching of URLString
+		this.setVar("rndval", new Date().getTime());
+
+		urlstringtemp = new Array();
+		for (key in this.vars) {
+			if (false == this.vars[key][1] && true == this.encodeURIString) {
+				encoded = this.encVar(key, this.vars[key][0], true);
+				delete this.vars[key];
+				this.vars[encoded[0]] = Array(encoded[1], true);
+				key = encoded[0];
+			}
+
+			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
+		}
+		if (urlstring){
+			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
+		} else {
+			this.URLString += urlstringtemp.join(this.argumentSeparator);
+		}
+	}
+
+	this.runResponse = function() {
+		eval(this.response);
+	}
+
+	this.runAJAX = function(urlstring) {
+		if (this.failed) {
+			this.onFail();
+		} else {
+			this.createURLString(urlstring);
+			if (this.element) {
+				this.elementObj = document.getElementById(this.element);
+			}
+			if (this.xmlhttp) {
+				var self = this;
+				if (this.method == "GET") {
+					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
+					this.xmlhttp.open(this.method, totalurlstring, true);
+				} else {
+					this.xmlhttp.open(this.method, this.requestFile, true);
+					try {
+						this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+					} catch (e) { }
+				}
+
+				this.xmlhttp.onreadystatechange = function() {
+					switch (self.xmlhttp.readyState) {
+						case 1:
+							self.onLoading();
+							break;
+						case 2:
+							self.onLoaded();
+							break;
+						case 3:
+							self.onInteractive();
+							break;
+						case 4:
+							self.response = self.xmlhttp.responseText;
+							self.responseXML = self.xmlhttp.responseXML;
+							self.responseStatus[0] = self.xmlhttp.status;
+							self.responseStatus[1] = self.xmlhttp.statusText;
+
+							if (self.execute) {
+								self.runResponse();
+							}
+
+							if (self.elementObj) {
+								elemNodeName = self.elementObj.nodeName;
+								elemNodeName.toLowerCase();
+								if (elemNodeName == "input"
+								|| elemNodeName == "select"
+								|| elemNodeName == "option"
+								|| elemNodeName == "textarea") {
+									self.elementObj.value = self.response;
+								} else {
+									self.elementObj.innerHTML = self.response;
+								}
+							}
+							if (self.responseStatus[0] == "200") {
+								self.onCompletion();
+							} else {
+								self.onError();
+							}
+
+							self.URLString = "";
+							break;
+					}
+				};
+
+				this.xmlhttp.send(this.URLString);
+			}
+		}
+	};
+
+	this.reset();
+	this.createAJAX();
+}
Index: /tags/3.1/wp-includes/js/tw-sack.js
===================================================================
--- /tags/3.1/wp-includes/js/tw-sack.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/tw-sack.js	(revision 17487)
@@ -0,0 +1,1 @@
+function sack(file){this.xmlhttp=null;this.resetData=function(){this.method="POST";this.queryStringSeparator="?";this.argumentSeparator="&";this.URLString="";this.encodeURIString=true;this.execute=false;this.element=null;this.elementObj=null;this.requestFile=file;this.vars=new Object();this.responseStatus=new Array(2)};this.resetFunctions=function(){this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onError=function(){};this.onFail=function(){}};this.reset=function(){this.resetFunctions();this.resetData()};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e1){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e2){this.xmlhttp=null}}if(!this.xmlhttp){if(typeof XMLHttpRequest!="undefined"){this.xmlhttp=new XMLHttpRequest()}else{this.failed=true}}};this.setVar=function(name,value){this.vars[name]=Array(value,false)};this.encVar=function(name,value,returnvars){if(true==returnvars){return Array(encodeURIComponent(name),encodeURIComponent(value))}else{this.vars[encodeURIComponent(name)]=Array(encodeURIComponent(value),true)}};this.processURLString=function(string,encode){encoded=encodeURIComponent(this.argumentSeparator);regexp=new RegExp(this.argumentSeparator+"|"+encoded);varArray=string.split(regexp);for(i=0;i<varArray.length;i++){urlVars=varArray[i].split("=");if(true==encode){this.encVar(urlVars[0],urlVars[1])}else{this.setVar(urlVars[0],urlVars[1])}}};this.createURLString=function(urlstring){if(this.encodeURIString&&this.URLString.length){this.processURLString(this.URLString,true)}if(urlstring){if(this.URLString.length){this.URLString+=this.argumentSeparator+urlstring}else{this.URLString=urlstring}}this.setVar("rndval",new Date().getTime());urlstringtemp=new Array();for(key in this.vars){if(false==this.vars[key][1]&&true==this.encodeURIString){encoded=this.encVar(key,this.vars[key][0],true);delete this.vars[key];this.vars[encoded[0]]=Array(encoded[1],true);key=encoded[0]}urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0]}if(urlstring){this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator)}else{this.URLString+=urlstringtemp.join(this.argumentSeparator)}};this.runResponse=function(){eval(this.response)};this.runAJAX=function(urlstring){if(this.failed){this.onFail()}else{this.createURLString(urlstring);if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var self=this;if(this.method=="GET"){totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;this.xmlhttp.open(this.method,totalurlstring,true)}else{this.xmlhttp.open(this.method,this.requestFile,true);try{this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(e){}}this.xmlhttp.onreadystatechange=function(){switch(self.xmlhttp.readyState){case 1:self.onLoading();break;case 2:self.onLoaded();break;case 3:self.onInteractive();break;case 4:self.response=self.xmlhttp.responseText;self.responseXML=self.xmlhttp.responseXML;self.responseStatus[0]=self.xmlhttp.status;self.responseStatus[1]=self.xmlhttp.statusText;if(self.execute){self.runResponse()}if(self.elementObj){elemNodeName=self.elementObj.nodeName;elemNodeName.toLowerCase();if(elemNodeName=="input"||elemNodeName=="select"||elemNodeName=="option"||elemNodeName=="textarea"){self.elementObj.value=self.response}else{self.elementObj.innerHTML=self.response}}if(self.responseStatus[0]=="200"){self.onCompletion()}else{self.onError()}self.URLString="";break}};this.xmlhttp.send(this.URLString)}}};this.reset();this.createAJAX()};
Index: /tags/3.1/wp-includes/js/wp-ajax-response.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/wp-ajax-response.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/wp-ajax-response.dev.js	(revision 17487)
@@ -0,0 +1,64 @@
+var wpAjax = jQuery.extend( {
+	unserialize: function( s ) {
+		var r = {}, q, pp, i, p;
+		if ( !s ) { return r; }
+		q = s.split('?'); if ( q[1] ) { s = q[1]; }
+		pp = s.split('&');
+		for ( i in pp ) {
+			if ( jQuery.isFunction(pp.hasOwnProperty) && !pp.hasOwnProperty(i) ) { continue; }
+			p = pp[i].split('=');
+			r[p[0]] = p[1];
+		}
+		return r;
+	},
+	parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission
+		var parsed = {}, re = jQuery('#' + r).html(''), err = '';
+
+		if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) {
+			parsed.responses = [];
+			parsed.errors = false;
+			jQuery('response', x).each( function() {
+				var th = jQuery(this), child = jQuery(this.firstChild), response;
+				response = { action: th.attr('action'), what: child.get(0).nodeName, id: child.attr('id'), oldId: child.attr('old_id'), position: child.attr('position') };
+				response.data = jQuery( 'response_data', child ).text();
+				response.supplemental = {};
+				if ( !jQuery( 'supplemental', child ).children().each( function() {
+					response.supplemental[this.nodeName] = jQuery(this).text();
+				} ).size() ) { response.supplemental = false }
+				response.errors = [];
+				if ( !jQuery('wp_error', child).each( function() {
+					var code = jQuery(this).attr('code'), anError, errorData, formField;
+					anError = { code: code, message: this.firstChild.nodeValue, data: false };
+					errorData = jQuery('wp_error_data[code="' + code + '"]', x);
+					if ( errorData ) { anError.data = errorData.get(); }
+					formField = jQuery( 'form-field', errorData ).text();
+					if ( formField ) { code = formField; }
+					if ( e ) { wpAjax.invalidateForm( jQuery('#' + e + ' :input[name="' + code + '"]' ).parents('.form-field:first') ); }
+					err += '<p>' + anError.message + '</p>';
+					response.errors.push( anError );
+					parsed.errors = true;
+				} ).size() ) { response.errors = false; }
+				parsed.responses.push( response );
+			} );
+			if ( err.length ) { re.html( '<div class="error">' + err + '</div>' ); }
+			return parsed;
+		}
+		if ( isNaN(x) ) { return !re.html('<div class="error"><p>' + x + '</p></div>'); }
+		x = parseInt(x,10);
+		if ( -1 == x ) { return !re.html('<div class="error"><p>' + wpAjax.noPerm + '</p></div>'); }
+		else if ( 0 === x ) { return !re.html('<div class="error"><p>' + wpAjax.broken  + '</p></div>'); }
+		return true;
+	},
+	invalidateForm: function ( selector ) {
+		return jQuery( selector ).addClass( 'form-invalid' ).find('input:visible').change( function() { jQuery(this).closest('.form-invalid').removeClass( 'form-invalid' ); } );
+	},
+	validateForm: function( selector ) {
+		selector = jQuery( selector );
+		return !wpAjax.invalidateForm( selector.find('.form-required').filter( function() { return jQuery('input:visible', this).val() == ''; } ) ).size();
+	}
+}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } );
+
+// Basic form validation
+jQuery(document).ready( function($){
+	$('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
+});
Index: /tags/3.1/wp-includes/js/wp-ajax-response.js
===================================================================
--- /tags/3.1/wp-includes/js/wp-ajax-response.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/wp-ajax-response.js	(revision 17487)
@@ -0,0 +1,1 @@
+var wpAjax=jQuery.extend({unserialize:function(c){var d={},e,a,b,f;if(!c){return d}e=c.split("?");if(e[1]){c=e[1]}a=c.split("&");for(b in a){if(jQuery.isFunction(a.hasOwnProperty)&&!a.hasOwnProperty(b)){continue}f=a[b].split("=");d[f[0]]=f[1]}return d},parseAjaxResponse:function(a,f,g){var b={},c=jQuery("#"+f).html(""),d="";if(a&&typeof a=="object"&&a.getElementsByTagName("wp_ajax")){b.responses=[];b.errors=false;jQuery("response",a).each(function(){var h=jQuery(this),i=jQuery(this.firstChild),e;e={action:h.attr("action"),what:i.get(0).nodeName,id:i.attr("id"),oldId:i.attr("old_id"),position:i.attr("position")};e.data=jQuery("response_data",i).text();e.supplemental={};if(!jQuery("supplemental",i).children().each(function(){e.supplemental[this.nodeName]=jQuery(this).text()}).size()){e.supplemental=false}e.errors=[];if(!jQuery("wp_error",i).each(function(){var j=jQuery(this).attr("code"),m,l,k;m={code:j,message:this.firstChild.nodeValue,data:false};l=jQuery('wp_error_data[code="'+j+'"]',a);if(l){m.data=l.get()}k=jQuery("form-field",l).text();if(k){j=k}if(g){wpAjax.invalidateForm(jQuery("#"+g+' :input[name="'+j+'"]').parents(".form-field:first"))}d+="<p>"+m.message+"</p>";e.errors.push(m);b.errors=true}).size()){e.errors=false}b.responses.push(e)});if(d.length){c.html('<div class="error">'+d+"</div>")}return b}if(isNaN(a)){return !c.html('<div class="error"><p>'+a+"</p></div>")}a=parseInt(a,10);if(-1==a){return !c.html('<div class="error"><p>'+wpAjax.noPerm+"</p></div>")}else{if(0===a){return !c.html('<div class="error"><p>'+wpAjax.broken+"</p></div>")}}return true},invalidateForm:function(a){return jQuery(a).addClass("form-invalid").find("input:visible").change(function(){jQuery(this).closest(".form-invalid").removeClass("form-invalid")})},validateForm:function(a){a=jQuery(a);return !wpAjax.invalidateForm(a.find(".form-required").filter(function(){return jQuery("input:visible",this).val()==""})).size()}},wpAjax||{noPerm:"You do not have permission to do that.",broken:"An unidentified error has occurred."});jQuery(document).ready(function(a){a("form.validate").submit(function(){return wpAjax.validateForm(a(this))})});
Index: /tags/3.1/wp-includes/js/wp-list-revisions.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/wp-list-revisions.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/wp-list-revisions.dev.js	(revision 17487)
@@ -0,0 +1,24 @@
+(function(w) {
+	var init = function() {
+		var pr = document.getElementById('post-revisions'),
+		inputs = pr ? pr.getElementsByTagName('input') : [];
+		pr.onclick = function() {
+			var i, checkCount = 0, side;
+			for ( i = 0; i < inputs.length; i++ ) {
+				checkCount += inputs[i].checked ? 1 : 0;
+				side = inputs[i].getAttribute('name');
+				if ( ! inputs[i].checked &&
+				( 'left' == side && 1 > checkCount || 'right' == side && 1 < checkCount && ( ! inputs[i-1] || ! inputs[i-1].checked ) ) &&
+				! ( inputs[i+1] && inputs[i+1].checked && 'right' == inputs[i+1].getAttribute('name') ) )
+					inputs[i].style.visibility = 'hidden';
+				else if ( 'left' == side || 'right' == side )
+					inputs[i].style.visibility = 'visible';
+			}
+		}
+		pr.onclick();
+	}
+	if ( w && w.addEventListener )
+		w.addEventListener('load', init, false);
+	else if ( w && w.attachEvent )
+		w.attachEvent('onload', init);
+})(window);
Index: /tags/3.1/wp-includes/js/wp-list-revisions.js
===================================================================
--- /tags/3.1/wp-includes/js/wp-list-revisions.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/wp-list-revisions.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(a){var b=function(){var d=document.getElementById("post-revisions"),c=d?d.getElementsByTagName("input"):[];d.onclick=function(){var g,f=0,e;for(g=0;g<c.length;g++){f+=c[g].checked?1:0;e=c[g].getAttribute("name");if(!c[g].checked&&("left"==e&&1>f||"right"==e&&1<f&&(!c[g-1]||!c[g-1].checked))&&!(c[g+1]&&c[g+1].checked&&"right"==c[g+1].getAttribute("name"))){c[g].style.visibility="hidden"}else{if("left"==e||"right"==e){c[g].style.visibility="visible"}}}};d.onclick()};if(a&&a.addEventListener){a.addEventListener("load",b,false)}else{if(a&&a.attachEvent){a.attachEvent("onload",b)}}})(window);
Index: /tags/3.1/wp-includes/js/wp-lists.dev.js
===================================================================
--- /tags/3.1/wp-includes/js/wp-lists.dev.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/wp-lists.dev.js	(revision 17487)
@@ -0,0 +1,380 @@
+(function($) {
+var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, wpList;
+
+wpList = {
+	settings: {
+		url: ajaxurl, type: 'POST',
+		response: 'ajax-response',
+
+		what: '',
+		alt: 'alternate', altOffset: 0,
+		addColor: null, delColor: null, dimAddColor: null, dimDelColor: null,
+
+		confirm: null,
+		addBefore: null, addAfter: null,
+		delBefore: null, delAfter: null,
+		dimBefore: null, dimAfter: null
+	},
+
+	nonce: function(e,s) {
+		var url = wpAjax.unserialize(e.attr('href'));
+		return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0;
+	},
+
+	parseClass: function(e,t) {
+		var c = [], cl;
+		try {
+			cl = $(e).attr('class') || '';
+			cl = cl.match(new RegExp(t+':[\\S]+'));
+			if ( cl ) { c = cl[0].split(':'); }
+		} catch(r) {}
+		return c;
+	},
+
+	pre: function(e,s,a) {
+		var bg, r;
+		s = $.extend( {}, this.wpList.settings, {
+			element: null,
+			nonce: 0,
+			target: e.get(0)
+		}, s || {} );
+		if ( $.isFunction( s.confirm ) ) {
+			if ( 'add' != a ) {
+				bg = $('#' + s.element).css('backgroundColor');
+				$('#' + s.element).css('backgroundColor', '#FF9966');
+			}
+			r = s.confirm.call(this,e,s,a,bg);
+			if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); }
+			if ( !r ) { return false; }
+		}
+		return s;
+	},
+
+	ajaxAdd: function( e, s ) {
+		e = $(e);
+		s = s || {};
+		var list = this, cls = wpList.parseClass(e,'add'), es, valid, formData;
+		s = wpList.pre.call( list, e, s, 'add' );
+
+		s.element = cls[2] || e.attr( 'id' ) || s.element || null;
+		if ( cls[3] ) { s.addColor = '#' + cls[3]; }
+		else { s.addColor = s.addColor || '#FFFF33'; }
+
+		if ( !s ) { return false; }
+
+		if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); }
+
+		if ( !s.element ) { return true; }
+
+		s.action = 'add-' + s.what;
+
+		s.nonce = wpList.nonce(e,s);
+
+		es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]');
+		valid = wpAjax.validateForm( '#' + s.element );
+		if ( !valid ) { return false; }
+
+		s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) );
+		formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize();
+		if ( formData ) { s.data += '&' + formData; }
+
+		if ( $.isFunction(s.addBefore) ) {
+			s = s.addBefore( s );
+			if ( !s ) { return true; }
+		}
+		if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) ) { return true; }
+
+		s.success = function(r) {
+			var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
+			if ( !res || res.errors ) { return false; }
+
+			if ( true === res ) { return true; }
+
+			jQuery.each( res.responses, function() {
+				wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue
+					pos: this.position || 0,
+					id: this.id || 0,
+					oldId: this.oldId || null
+				} ) );
+			} );
+
+			if ( $.isFunction(s.addAfter) ) {
+				o = this.complete;
+				this.complete = function(x,st) {
+					var _s = $.extend( { xml: x, status: st, parsed: res }, s );
+					s.addAfter( r, _s );
+					if ( $.isFunction(o) ) { o(x,st); }
+				};
+			}
+			list.wpList.recolor();
+			$(list).trigger( 'wpListAddEnd', [ s, list.wpList ] );
+			wpList.clear.call(list,'#' + s.element);
+		};
+
+		$.ajax( s );
+		return false;
+	},
+
+	ajaxDel: function( e, s ) {
+		e = $(e); s = s || {};
+		var list = this, cls = wpList.parseClass(e,'delete'), element;
+		s = wpList.pre.call( list, e, s, 'delete' );
+
+		s.element = cls[2] || s.element || null;
+		if ( cls[3] ) { s.delColor = '#' + cls[3]; }
+		else { s.delColor = s.delColor || '#faa'; }
+
+		if ( !s || !s.element ) { return false; }
+
+		s.action = 'delete-' + s.what;
+
+		s.nonce = wpList.nonce(e,s);
+
+		s.data = $.extend(
+			{ action: s.action, id: s.element.split('-').pop(), _ajax_nonce: s.nonce },
+			wpAjax.unserialize( cls[4] || '' )
+		);
+
+		if ( $.isFunction(s.delBefore) ) {
+			s = s.delBefore( s, list );
+			if ( !s ) { return true; }
+		}
+		if ( !s.data._ajax_nonce ) { return true; }
+
+		element = $('#' + s.element);
+
+		if ( 'none' != s.delColor ) {
+			element.css( 'backgroundColor', s.delColor ).fadeOut( 350, function(){
+				list.wpList.recolor();
+				$(list).trigger( 'wpListDelEnd', [ s, list.wpList ] );
+			});
+		} else {
+			list.wpList.recolor();
+			$(list).trigger( 'wpListDelEnd', [ s, list.wpList ] );
+		}
+
+		s.success = function(r) {
+			var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
+			if ( !res || res.errors ) {
+				element.stop().stop().css( 'backgroundColor', '#faa' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
+				return false;
+			}
+			if ( $.isFunction(s.delAfter) ) {
+				o = this.complete;
+				this.complete = function(x,st) {
+					element.queue( function() {
+						var _s = $.extend( { xml: x, status: st, parsed: res }, s );
+						s.delAfter( r, _s );
+						if ( $.isFunction(o) ) { o(x,st); }
+					} ).dequeue();
+				};
+			}
+		};
+		$.ajax( s );
+		return false;
+	},
+
+	ajaxDim: function( e, s ) {
+		if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys
+			return false;
+		e = $(e); s = s || {};
+		var list = this, cls = wpList.parseClass(e,'dim'), element, isClass, color, dimColor;
+		s = wpList.pre.call( list, e, s, 'dim' );
+
+		s.element = cls[2] || s.element || null;
+		s.dimClass =  cls[3] || s.dimClass || null;
+		if ( cls[4] ) { s.dimAddColor = '#' + cls[4]; }
+		else { s.dimAddColor = s.dimAddColor || '#FFFF33'; }
+		if ( cls[5] ) { s.dimDelColor = '#' + cls[5]; }
+		else { s.dimDelColor = s.dimDelColor || '#FF3333'; }
+
+		if ( !s || !s.element || !s.dimClass ) { return true; }
+
+		s.action = 'dim-' + s.what;
+
+		s.nonce = wpList.nonce(e,s);
+
+		s.data = $.extend(
+			{ action: s.action, id: s.element.split('-').pop(), dimClass: s.dimClass, _ajax_nonce : s.nonce },
+			wpAjax.unserialize( cls[6] || '' )
+		);
+
+		if ( $.isFunction(s.dimBefore) ) {
+			s = s.dimBefore( s );
+			if ( !s ) { return true; }
+		}
+
+		element = $('#' + s.element);
+		isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass);
+		color = wpList.getColor( element );
+		element.toggleClass( s.dimClass );
+		dimColor = isClass ? s.dimAddColor : s.dimDelColor;
+		if ( 'none' != dimColor ) {
+			element
+				.animate( { backgroundColor: dimColor }, 'fast' )
+				.queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } )
+				.animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); $(list).trigger( 'wpListDimEnd', [ s, list.wpList ] ); } } );
+		} else {
+			$(list).trigger( 'wpListDimEnd', [ s, list.wpList ] );
+		}
+
+		if ( !s.data._ajax_nonce ) { return true; }
+
+		s.success = function(r) {
+			var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
+			if ( !res || res.errors ) {
+				element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
+				return false;
+			}
+			if ( $.isFunction(s.dimAfter) ) {
+				o = this.complete;
+				this.complete = function(x,st) {
+					element.queue( function() {
+						var _s = $.extend( { xml: x, status: st, parsed: res }, s );
+						s.dimAfter( r, _s );
+						if ( $.isFunction(o) ) { o(x,st); }
+					} ).dequeue();
+				};
+			}
+		};
+
+		$.ajax( s );
+		return false;
+	},
+
+	// From jquery.color.js: jQuery Color Animation by John Resig
+	getColor: function( el ) {
+		if ( el.constructor == Object )
+			el = el.get(0);
+		var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" );
+		do {
+			color = jQuery.curCSS(elem, 'backgroundColor');
+			if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") )
+				break;
+		} while ( elem = elem.parentNode );
+		return color || '#ffffff';
+	},
+
+	add: function( e, s ) {
+		e = $(e);
+
+		var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color;
+
+		if ( 'string' == typeof s )
+			s = { what: s };
+
+		s = $.extend(_s, this.wpList.settings, s);
+
+		if ( !e.size() || !s.what )
+			return false;
+
+		if ( s.oldId )
+			old = $('#' + s.what + '-' + s.oldId);
+
+		if ( s.id && ( s.id != s.oldId || !old || !old.size() ) )
+			$('#' + s.what + '-' + s.id).remove();
+
+		if ( old && old.size() ) {
+			old.before(e);
+			old.remove();
+		} else if ( isNaN(s.pos) ) {
+			ba = 'after';
+			if ( '-' == s.pos.substr(0,1) ) {
+				s.pos = s.pos.substr(1);
+				ba = 'before';
+			}
+			ref = list.find( '#' + s.pos );
+			if ( 1 === ref.size() ) { ref[ba](e); }
+			else { list.append(e); }
+		} else if ( s.pos < 0 ) {
+			list.prepend(e);
+		} else {
+			list.append(e);
+		}
+
+		if ( s.alt ) {
+			if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); }
+			else { e.addClass( s.alt ); }
+		}
+
+		if ( 'none' != s.addColor ) {
+			color = wpList.getColor( e );
+			e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } );
+		}
+		list.each( function() { this.wpList.process( e ); } );
+		return e;
+	},
+
+	clear: function(e) {
+		var list = this, t, tag;
+		e = $(e);
+		if ( list.wpList && e.parents( '#' + list.id ).size() ) { return; }
+		e.find(':input').each( function() {
+			if ( $(this).parents('.form-no-clear').size() )
+				return;
+			t = this.type.toLowerCase();
+			tag = this.tagName.toLowerCase();
+			if ( 'text' == t || 'password' == t || 'textarea' == tag ) { this.value = ''; }
+			else if ( 'checkbox' == t || 'radio' == t ) { this.checked = false; }
+			else if ( 'select' == tag ) { this.selectedIndex = null; }
+		});
+	},
+
+	process: function(el) {
+		var list = this,
+			$el = $(el || document);
+
+		$el.delegate( "form[class^=add:" + list.id + ":]", 'submit', function(){
+			return list.wpList.add(this);
+		});
+
+		$el.delegate( "[class^=add:" + list.id + ":]:not(form)", 'click', function(){
+			return list.wpList.add(this);
+		});
+
+		$el.delegate( "[class^=delete:" + list.id + ":]", 'click', function(){
+			return list.wpList.del(this);
+		});
+
+		$el.delegate( "[class^=dim:" + list.id + ":]", 'click', function(){
+			return list.wpList.dim(this);
+		});
+	},
+
+	recolor: function() {
+		var list = this, items, eo;
+		if ( !list.wpList.settings.alt ) { return; }
+		items = $('.list-item:visible', list);
+		if ( !items.size() ) { items = $(list).children(':visible'); }
+		eo = [':even',':odd'];
+		if ( list.wpList.settings.altOffset % 2 ) { eo.reverse(); }
+		items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt);
+	},
+
+	init: function() {
+		var lists = this;
+		lists.wpList.process = function(a) {
+			lists.each( function() {
+				this.wpList.process(a);
+			} );
+		};
+		lists.wpList.recolor = function() {
+			lists.each( function() {
+				this.wpList.recolor();
+			} );
+		};
+	}
+};
+
+$.fn.wpList = function( settings ) {
+	this.each( function() {
+		var _this = this;
+		this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseClass(this,'list')[1] || '' }, settings ) };
+		$.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } );
+	} );
+	wpList.init.call(this);
+	this.wpList.process();
+	return this;
+};
+
+})(jQuery);
Index: /tags/3.1/wp-includes/js/wp-lists.js
===================================================================
--- /tags/3.1/wp-includes/js/wp-lists.js	(revision 17487)
+++ /tags/3.1/wp-includes/js/wp-lists.js	(revision 17487)
@@ -0,0 +1,1 @@
+(function(b){var a={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"},c;c={settings:{url:ajaxurl,type:"POST",response:"ajax-response",what:"",alt:"alternate",altOffset:0,addColor:null,delColor:null,dimAddColor:null,dimDelColor:null,confirm:null,addBefore:null,addAfter:null,delBefore:null,delAfter:null,dimBefore:null,dimAfter:null},nonce:function(g,f){var d=wpAjax.unserialize(g.attr("href"));return f.nonce||d._ajax_nonce||b("#"+f.element+" input[name=_ajax_nonce]").val()||d._wpnonce||b("#"+f.element+" input[name=_wpnonce]").val()||0},parseClass:function(h,f){var i=[],d;try{d=b(h).attr("class")||"";d=d.match(new RegExp(f+":[\\S]+"));if(d){i=d[0].split(":")}}catch(g){}return i},pre:function(i,g,d){var f,h;g=b.extend({},this.wpList.settings,{element:null,nonce:0,target:i.get(0)},g||{});if(b.isFunction(g.confirm)){if("add"!=d){f=b("#"+g.element).css("backgroundColor");b("#"+g.element).css("backgroundColor","#FF9966")}h=g.confirm.call(this,i,g,d,f);if("add"!=d){b("#"+g.element).css("backgroundColor",f)}if(!h){return false}}return g},ajaxAdd:function(j,f){j=b(j);f=f||{};var h=this,d=c.parseClass(j,"add"),k,g,i;f=c.pre.call(h,j,f,"add");f.element=d[2]||j.attr("id")||f.element||null;if(d[3]){f.addColor="#"+d[3]}else{f.addColor=f.addColor||"#FFFF33"}if(!f){return false}if(!j.is("[class^=add:"+h.id+":]")){return !c.add.call(h,j,f)}if(!f.element){return true}f.action="add-"+f.what;f.nonce=c.nonce(j,f);k=b("#"+f.element+" :input").not("[name=_ajax_nonce], [name=_wpnonce], [name=action]");g=wpAjax.validateForm("#"+f.element);if(!g){return false}f.data=b.param(b.extend({_ajax_nonce:f.nonce,action:f.action},wpAjax.unserialize(d[4]||"")));i=b.isFunction(k.fieldSerialize)?k.fieldSerialize():k.serialize();if(i){f.data+="&"+i}if(b.isFunction(f.addBefore)){f=f.addBefore(f);if(!f){return true}}if(!f.data.match(/_ajax_nonce=[a-f0-9]+/)){return true}f.success=function(l){var e=wpAjax.parseAjaxResponse(l,f.response,f.element),m;if(!e||e.errors){return false}if(true===e){return true}jQuery.each(e.responses,function(){c.add.call(h,this.data,b.extend({},f,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))});if(b.isFunction(f.addAfter)){m=this.complete;this.complete=function(n,o){var p=b.extend({xml:n,status:o,parsed:e},f);f.addAfter(l,p);if(b.isFunction(m)){m(n,o)}}}h.wpList.recolor();b(h).trigger("wpListAddEnd",[f,h.wpList]);c.clear.call(h,"#"+f.element)};b.ajax(f);return false},ajaxDel:function(i,g){i=b(i);g=g||{};var h=this,d=c.parseClass(i,"delete"),f;g=c.pre.call(h,i,g,"delete");g.element=d[2]||g.element||null;if(d[3]){g.delColor="#"+d[3]}else{g.delColor=g.delColor||"#faa"}if(!g||!g.element){return false}g.action="delete-"+g.what;g.nonce=c.nonce(i,g);g.data=b.extend({action:g.action,id:g.element.split("-").pop(),_ajax_nonce:g.nonce},wpAjax.unserialize(d[4]||""));if(b.isFunction(g.delBefore)){g=g.delBefore(g,h);if(!g){return true}}if(!g.data._ajax_nonce){return true}f=b("#"+g.element);if("none"!=g.delColor){f.css("backgroundColor",g.delColor).fadeOut(350,function(){h.wpList.recolor();b(h).trigger("wpListDelEnd",[g,h.wpList])})}else{h.wpList.recolor();b(h).trigger("wpListDelEnd",[g,h.wpList])}g.success=function(j){var e=wpAjax.parseAjaxResponse(j,g.response,g.element),k;if(!e||e.errors){f.stop().stop().css("backgroundColor","#faa").show().queue(function(){h.wpList.recolor();b(this).dequeue()});return false}if(b.isFunction(g.delAfter)){k=this.complete;this.complete=function(l,m){f.queue(function(){var n=b.extend({xml:l,status:m,parsed:e},g);g.delAfter(j,n);if(b.isFunction(k)){k(l,m)}}).dequeue()}}};b.ajax(g);return false},ajaxDim:function(k,h){if(b(k).parent().css("display")=="none"){return false}k=b(k);h=h||{};var j=this,d=c.parseClass(k,"dim"),g,l,f,i;h=c.pre.call(j,k,h,"dim");h.element=d[2]||h.element||null;h.dimClass=d[3]||h.dimClass||null;if(d[4]){h.dimAddColor="#"+d[4]}else{h.dimAddColor=h.dimAddColor||"#FFFF33"}if(d[5]){h.dimDelColor="#"+d[5]}else{h.dimDelColor=h.dimDelColor||"#FF3333"}if(!h||!h.element||!h.dimClass){return true}h.action="dim-"+h.what;h.nonce=c.nonce(k,h);h.data=b.extend({action:h.action,id:h.element.split("-").pop(),dimClass:h.dimClass,_ajax_nonce:h.nonce},wpAjax.unserialize(d[6]||""));if(b.isFunction(h.dimBefore)){h=h.dimBefore(h);if(!h){return true}}g=b("#"+h.element);l=g.toggleClass(h.dimClass).is("."+h.dimClass);f=c.getColor(g);g.toggleClass(h.dimClass);i=l?h.dimAddColor:h.dimDelColor;if("none"!=i){g.animate({backgroundColor:i},"fast").queue(function(){g.toggleClass(h.dimClass);b(this).dequeue()}).animate({backgroundColor:f},{complete:function(){b(this).css("backgroundColor","");b(j).trigger("wpListDimEnd",[h,j.wpList])}})}else{b(j).trigger("wpListDimEnd",[h,j.wpList])}if(!h.data._ajax_nonce){return true}h.success=function(m){var e=wpAjax.parseAjaxResponse(m,h.response,h.element),n;if(!e||e.errors){g.stop().stop().css("backgroundColor","#FF3333")[l?"removeClass":"addClass"](h.dimClass).show().queue(function(){j.wpList.recolor();b(this).dequeue()});return false}if(b.isFunction(h.dimAfter)){n=this.complete;this.complete=function(o,p){g.queue(function(){var q=b.extend({xml:o,status:p,parsed:e},h);h.dimAfter(m,q);if(b.isFunction(n)){n(o,p)}}).dequeue()}}};b.ajax(h);return false},getColor:function(e){if(e.constructor==Object){e=e.get(0)}var f=e,d,g=new RegExp("rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)","i");do{d=jQuery.curCSS(f,"backgroundColor");if(d!=""&&d!="transparent"&&!d.match(g)||jQuery.nodeName(f,"body")){break}}while(f=f.parentNode);return d||"#ffffff"},add:function(k,g){k=b(k);var i=b(this),d=false,j={pos:0,id:0,oldId:null},l,h,f;if("string"==typeof g){g={what:g}}g=b.extend(j,this.wpList.settings,g);if(!k.size()||!g.what){return false}if(g.oldId){d=b("#"+g.what+"-"+g.oldId)}if(g.id&&(g.id!=g.oldId||!d||!d.size())){b("#"+g.what+"-"+g.id).remove()}if(d&&d.size()){d.before(k);d.remove()}else{if(isNaN(g.pos)){l="after";if("-"==g.pos.substr(0,1)){g.pos=g.pos.substr(1);l="before"}h=i.find("#"+g.pos);if(1===h.size()){h[l](k)}else{i.append(k)}}else{if(g.pos<0){i.prepend(k)}else{i.append(k)}}}if(g.alt){if((i.children(":visible").index(k[0])+g.altOffset)%2){k.removeClass(g.alt)}else{k.addClass(g.alt)}}if("none"!=g.addColor){f=c.getColor(k);k.css("backgroundColor",g.addColor).animate({backgroundColor:f},{complete:function(){b(this).css("backgroundColor","")}})}i.each(function(){this.wpList.process(k)});return k},clear:function(h){var g=this,f,d;h=b(h);if(g.wpList&&h.parents("#"+g.id).size()){return}h.find(":input").each(function(){if(b(this).parents(".form-no-clear").size()){return}f=this.type.toLowerCase();d=this.tagName.toLowerCase();if("text"==f||"password"==f||"textarea"==d){this.value=""}else{if("checkbox"==f||"radio"==f){this.checked=false}else{if("select"==d){this.selectedIndex=null}}}})},process:function(e){var f=this,d=b(e||document);d.delegate("form[class^=add:"+f.id+":]","submit",function(){return f.wpList.add(this)});d.delegate("[class^=add:"+f.id+":]:not(form)","click",function(){return f.wpList.add(this)});d.delegate("[class^=delete:"+f.id+":]","click",function(){return f.wpList.del(this)});d.delegate("[class^=dim:"+f.id+":]","click",function(){return f.wpList.dim(this)})},recolor:function(){var f=this,e,d;if(!f.wpList.settings.alt){return}e=b(".list-item:visible",f);if(!e.size()){e=b(f).children(":visible")}d=[":even",":odd"];if(f.wpList.settings.altOffset%2){d.reverse()}e.filter(d[0]).addClass(f.wpList.settings.alt).end().filter(d[1]).removeClass(f.wpList.settings.alt)},init:function(){var d=this;d.wpList.process=function(e){d.each(function(){this.wpList.process(e)})};d.wpList.recolor=function(){d.each(function(){this.wpList.recolor()})}}};b.fn.wpList=function(d){this.each(function(){var e=this;this.wpList={settings:b.extend({},c.settings,{what:c.parseClass(this,"list")[1]||""},d)};b.each(a,function(g,h){e.wpList[g]=function(i,f){return c[h].call(e,i,f)}})});c.init.call(this);this.wpList.process();return this}})(jQuery);
Index: /tags/3.1/wp-includes/kses.php
===================================================================
--- /tags/3.1/wp-includes/kses.php	(revision 17487)
+++ /tags/3.1/wp-includes/kses.php	(revision 17487)
@@ -0,0 +1,1419 @@
+<?php
+/**
+ * kses 0.2.2 - HTML/XHTML filter that only allows some elements and attributes
+ * Copyright (C) 2002, 2003, 2005  Ulf Harnhammar
+ *
+ * This program is free software and open source software; you can redistribute
+ * it and/or modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  or visit
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * [kses strips evil scripts!]
+ *
+ * Added wp_ prefix to avoid conflicts with existing kses users
+ *
+ * @version 0.2.2
+ * @copyright (C) 2002, 2003, 2005
+ * @author Ulf Harnhammar <http://advogato.org/person/metaur/>
+ *
+ * @package External
+ * @subpackage KSES
+ *
+ */
+
+/**
+ * You can override this in a plugin.
+ *
+ * @since 1.2.0
+ */
+if ( ! defined( 'CUSTOM_TAGS' ) )
+	define( 'CUSTOM_TAGS', false );
+
+if ( ! CUSTOM_TAGS ) {
+	/**
+	 * Kses global for default allowable HTML tags.
+	 *
+	 * Can be override by using CUSTOM_TAGS constant.
+	 *
+	 * @global array $allowedposttags
+	 * @since 2.0.0
+	 */
+	$allowedposttags = array(
+		'address' => array(),
+		'a' => array(
+			'class' => array (),
+			'href' => array (),
+			'id' => array (),
+			'title' => array (),
+			'rel' => array (),
+			'rev' => array (),
+			'name' => array (),
+			'target' => array()),
+		'abbr' => array(
+			'class' => array (),
+			'title' => array ()),
+		'acronym' => array(
+			'title' => array ()),
+		'article' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'aside' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'b' => array(),
+		'big' => array(),
+		'blockquote' => array(
+			'id' => array (),
+			'cite' => array (),
+			'class' => array(),
+			'lang' => array(),
+			'xml:lang' => array()),
+		'br' => array (
+			'class' => array ()),
+		'button' => array(
+			'disabled' => array (),
+			'name' => array (),
+			'type' => array (),
+			'value' => array ()),
+		'caption' => array(
+			'align' => array (),
+			'class' => array ()),
+		'cite' => array (
+			'class' => array(),
+			'dir' => array(),
+			'lang' => array(),
+			'title' => array ()),
+		'code' => array (
+			'style' => array()),
+		'col' => array(
+			'align' => array (),
+			'char' => array (),
+			'charoff' => array (),
+			'span' => array (),
+			'dir' => array(),
+			'style' => array (),
+			'valign' => array (),
+			'width' => array ()),
+		'del' => array(
+			'datetime' => array ()),
+		'dd' => array(),
+		'details' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'open' => array (),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'div' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array()),
+		'dl' => array(),
+		'dt' => array(),
+		'em' => array(),
+		'fieldset' => array(),
+		'figure' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'figcaption' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'font' => array(
+			'color' => array (),
+			'face' => array (),
+			'size' => array ()),
+		'footer' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'form' => array(
+			'action' => array (),
+			'accept' => array (),
+			'accept-charset' => array (),
+			'enctype' => array (),
+			'method' => array (),
+			'name' => array (),
+			'target' => array ()),
+		'h1' => array(
+			'align' => array (),
+			'class' => array (),
+			'id'    => array (),
+			'style' => array ()),
+		'h2' => array (
+			'align' => array (),
+			'class' => array (),
+			'id'    => array (),
+			'style' => array ()),
+		'h3' => array (
+			'align' => array (),
+			'class' => array (),
+			'id'    => array (),
+			'style' => array ()),
+		'h4' => array (
+			'align' => array (),
+			'class' => array (),
+			'id'    => array (),
+			'style' => array ()),
+		'h5' => array (
+			'align' => array (),
+			'class' => array (),
+			'id'    => array (),
+			'style' => array ()),
+		'h6' => array (
+			'align' => array (),
+			'class' => array (),
+			'id'    => array (),
+			'style' => array ()),
+		'header' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'hgroup' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'hr' => array (
+			'align' => array (),
+			'class' => array (),
+			'noshade' => array (),
+			'size' => array (),
+			'width' => array ()),
+		'i' => array(),
+		'img' => array(
+			'alt' => array (),
+			'align' => array (),
+			'border' => array (),
+			'class' => array (),
+			'height' => array (),
+			'hspace' => array (),
+			'longdesc' => array (),
+			'vspace' => array (),
+			'src' => array (),
+			'style' => array (),
+			'width' => array ()),
+		'ins' => array(
+			'datetime' => array (),
+			'cite' => array ()),
+		'kbd' => array(),
+		'label' => array(
+			'for' => array ()),
+		'legend' => array(
+			'align' => array ()),
+		'li' => array (
+			'align' => array (),
+			'class' => array ()),
+		'menu' => array (
+			'class' => array (),
+			'style' => array (),
+			'type' => array ()),
+		'nav' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'p' => array(
+			'class' => array (),
+			'align' => array (),
+			'dir' => array(),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array()),
+		'pre' => array(
+			'style' => array(),
+			'width' => array ()),
+		'q' => array(
+			'cite' => array ()),
+		's' => array(),
+		'span' => array (
+			'class' => array (),
+			'dir' => array (),
+			'align' => array (),
+			'lang' => array (),
+			'style' => array (),
+			'title' => array (),
+			'xml:lang' => array()),
+		'section' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'strike' => array(),
+		'strong' => array(),
+		'sub' => array(),
+		'summary' => array(
+			'align' => array (),
+			'class' => array (),
+			'dir' => array (),
+			'lang' => array(),
+			'style' => array (),
+			'xml:lang' => array(),
+		),
+		'sup' => array(),
+		'table' => array(
+			'align' => array (),
+			'bgcolor' => array (),
+			'border' => array (),
+			'cellpadding' => array (),
+			'cellspacing' => array (),
+			'class' => array (),
+			'dir' => array(),
+			'id' => array(),
+			'rules' => array (),
+			'style' => array (),
+			'summary' => array (),
+			'width' => array ()),
+		'tbody' => array(
+			'align' => array (),
+			'char' => array (),
+			'charoff' => array (),
+			'valign' => array ()),
+		'td' => array(
+			'abbr' => array (),
+			'align' => array (),
+			'axis' => array (),
+			'bgcolor' => array (),
+			'char' => array (),
+			'charoff' => array (),
+			'class' => array (),
+			'colspan' => array (),
+			'dir' => array(),
+			'headers' => array (),
+			'height' => array (),
+			'nowrap' => array (),
+			'rowspan' => array (),
+			'scope' => array (),
+			'style' => array (),
+			'valign' => array (),
+			'width' => array ()),
+		'textarea' => array(
+			'cols' => array (),
+			'rows' => array (),
+			'disabled' => array (),
+			'name' => array (),
+			'readonly' => array ()),
+		'tfoot' => array(
+			'align' => array (),
+			'char' => array (),
+			'class' => array (),
+			'charoff' => array (),
+			'valign' => array ()),
+		'th' => array(
+			'abbr' => array (),
+			'align' => array (),
+			'axis' => array (),
+			'bgcolor' => array (),
+			'char' => array (),
+			'charoff' => array (),
+			'class' => array (),
+			'colspan' => array (),
+			'headers' => array (),
+			'height' => array (),
+			'nowrap' => array (),
+			'rowspan' => array (),
+			'scope' => array (),
+			'valign' => array (),
+			'width' => array ()),
+		'thead' => array(
+			'align' => array (),
+			'char' => array (),
+			'charoff' => array (),
+			'class' => array (),
+			'valign' => array ()),
+		'title' => array(),
+		'tr' => array(
+			'align' => array (),
+			'bgcolor' => array (),
+			'char' => array (),
+			'charoff' => array (),
+			'class' => array (),
+			'style' => array (),
+			'valign' => array ()),
+		'tt' => array(),
+		'u' => array(),
+		'ul' => array (
+			'class' => array (),
+			'style' => array (),
+			'type' => array ()),
+		'ol' => array (
+			'class' => array (),
+			'start' => array (),
+			'style' => array (),
+			'type' => array ()),
+		'var' => array ());
+
+	/**
+	 * Kses allowed HTML elements.
+	 *
+	 * @global array $allowedtags
+	 * @since 1.0.0
+	 */
+	$allowedtags = array(
+		'a' => array(
+			'href' => array (),
+			'title' => array ()),
+		'abbr' => array(
+			'title' => array ()),
+		'acronym' => array(
+			'title' => array ()),
+		'b' => array(),
+		'blockquote' => array(
+			'cite' => array ()),
+		//	'br' => array(),
+		'cite' => array (),
+		'code' => array(),
+		'del' => array(
+			'datetime' => array ()),
+		//	'dd' => array(),
+		//	'dl' => array(),
+		//	'dt' => array(),
+		'em' => array (), 'i' => array (),
+		//	'ins' => array('datetime' => array(), 'cite' => array()),
+		//	'li' => array(),
+		//	'ol' => array(),
+		//	'p' => array(),
+		'q' => array(
+			'cite' => array ()),
+		'strike' => array(),
+		'strong' => array(),
+		//	'sub' => array(),
+		//	'sup' => array(),
+		//	'u' => array(),
+		//	'ul' => array(),
+	);
+
+	$allowedentitynames = array(
+		'nbsp',    'iexcl',  'cent',    'pound',  'curren', 'yen',
+		'brvbar',  'sect',   'uml',     'copy',   'ordf',   'laquo',
+		'not',     'shy',    'reg',     'macr',   'deg',    'plusmn',
+		'acute',   'micro',  'para',    'middot', 'cedil',  'ordm',
+		'raquo',   'iquest', 'Agrave',  'Aacute', 'Acirc',  'Atilde',
+		'Auml',    'Aring',  'AElig',   'Ccedil', 'Egrave', 'Eacute',
+		'Ecirc',   'Euml',   'Igrave',  'Iacute', 'Icirc',  'Iuml',
+		'ETH',     'Ntilde', 'Ograve',  'Oacute', 'Ocirc',  'Otilde',
+		'Ouml',    'times',  'Oslash',  'Ugrave', 'Uacute', 'Ucirc',
+		'Uuml',    'Yacute', 'THORN',   'szlig',  'agrave', 'aacute',
+		'acirc',   'atilde', 'auml',    'aring',  'aelig',  'ccedil',
+		'egrave',  'eacute', 'ecirc',   'euml',   'igrave', 'iacute',
+		'icirc',   'iuml',   'eth',     'ntilde', 'ograve', 'oacute',
+		'ocirc',   'otilde', 'ouml',    'divide', 'oslash', 'ugrave',
+		'uacute',  'ucirc',  'uuml',    'yacute', 'thorn',  'yuml',
+		'quot',    'amp',    'lt',      'gt',     'apos',   'OElig',
+		'oelig',   'Scaron', 'scaron',  'Yuml',   'circ',   'tilde',
+		'ensp',    'emsp',   'thinsp',  'zwnj',   'zwj',    'lrm',
+		'rlm',     'ndash',  'mdash',   'lsquo',  'rsquo',  'sbquo',
+		'ldquo',   'rdquo',  'bdquo',   'dagger', 'Dagger', 'permil',
+		'lsaquo',  'rsaquo', 'euro',    'fnof',   'Alpha',  'Beta',
+		'Gamma',   'Delta',  'Epsilon', 'Zeta',   'Eta',    'Theta',
+		'Iota',    'Kappa',  'Lambda',  'Mu',     'Nu',     'Xi',
+		'Omicron', 'Pi',     'Rho',     'Sigma',  'Tau',    'Upsilon',
+		'Phi',     'Chi',    'Psi',     'Omega',  'alpha',  'beta',
+		'gamma',   'delta',  'epsilon', 'zeta',   'eta',    'theta',
+		'iota',    'kappa',  'lambda',  'mu',     'nu',     'xi',
+		'omicron', 'pi',     'rho',     'sigmaf', 'sigma',  'tau',
+		'upsilon', 'phi',    'chi',     'psi',    'omega',  'thetasym',
+		'upsih',   'piv',    'bull',    'hellip', 'prime',  'Prime',
+		'oline',   'frasl',  'weierp',  'image',  'real',   'trade',
+		'alefsym', 'larr',   'uarr',    'rarr',   'darr',   'harr',
+		'crarr',   'lArr',   'uArr',    'rArr',   'dArr',   'hArr',
+		'forall',  'part',   'exist',   'empty',  'nabla',  'isin',
+		'notin',   'ni',     'prod',    'sum',    'minus',  'lowast',
+		'radic',   'prop',   'infin',   'ang',    'and',    'or',
+		'cap',     'cup',    'int',     'sim',    'cong',   'asymp',
+		'ne',      'equiv',  'le',      'ge',     'sub',    'sup',
+		'nsub',    'sube',   'supe',    'oplus',  'otimes', 'perp',
+		'sdot',    'lceil',  'rceil',   'lfloor', 'rfloor', 'lang',
+		'rang',    'loz',    'spades',  'clubs',  'hearts', 'diams',
+	);
+}
+
+/**
+ * Filters content and keeps only allowable HTML elements.
+ *
+ * This function makes sure that only the allowed HTML element names, attribute
+ * names and attribute values plus only sane HTML entities will occur in
+ * $string. You have to remove any slashes from PHP's magic quotes before you
+ * call this function.
+ *
+ * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
+ * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
+ * covers all common link protocols, except for 'javascript' which should not
+ * be allowed for untrusted users.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string Content to filter through kses
+ * @param array $allowed_html List of allowed HTML elements
+ * @param array $allowed_protocols Optional. Allowed protocol in links.
+ * @return string Filtered content with only allowed HTML elements
+ */
+function wp_kses($string, $allowed_html, $allowed_protocols = array ()) {
+	$allowed_protocols = wp_parse_args( $allowed_protocols, apply_filters('kses_allowed_protocols', array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn') ));
+	$string = wp_kses_no_null($string);
+	$string = wp_kses_js_entities($string);
+	$string = wp_kses_normalize_entities($string);
+	$allowed_html_fixed = wp_kses_array_lc($allowed_html);
+	$string = wp_kses_hook($string, $allowed_html_fixed, $allowed_protocols); // WP changed the order of these funcs and added args to wp_kses_hook
+	return wp_kses_split($string, $allowed_html_fixed, $allowed_protocols);
+}
+
+/**
+ * You add any kses hooks here.
+ *
+ * There is currently only one kses WordPress hook and it is called here. All
+ * parameters are passed to the hooks and expected to recieve a string.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string Content to filter through kses
+ * @param array $allowed_html List of allowed HTML elements
+ * @param array $allowed_protocols Allowed protocol in links
+ * @return string Filtered content through 'pre_kses' hook
+ */
+function wp_kses_hook($string, $allowed_html, $allowed_protocols) {
+	$string = apply_filters('pre_kses', $string, $allowed_html, $allowed_protocols);
+	return $string;
+}
+
+/**
+ * This function returns kses' version number.
+ *
+ * @since 1.0.0
+ *
+ * @return string KSES Version Number
+ */
+function wp_kses_version() {
+	return '0.2.2';
+}
+
+/**
+ * Searches for HTML tags, no matter how malformed.
+ *
+ * It also matches stray ">" characters.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string Content to filter
+ * @param array $allowed_html Allowed HTML elements
+ * @param array $allowed_protocols Allowed protocols to keep
+ * @return string Content with fixed HTML tags
+ */
+function wp_kses_split($string, $allowed_html, $allowed_protocols) {
+	global $pass_allowed_html, $pass_allowed_protocols;
+	$pass_allowed_html = $allowed_html;
+	$pass_allowed_protocols = $allowed_protocols;
+	return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_wp_kses_split_callback', $string );
+}
+
+/**
+ * Callback for wp_kses_split.
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _wp_kses_split_callback( $match ) {
+	global $pass_allowed_html, $pass_allowed_protocols;
+	return wp_kses_split2( $match[1], $pass_allowed_html, $pass_allowed_protocols );
+}
+
+/**
+ * Callback for wp_kses_split for fixing malformed HTML tags.
+ *
+ * This function does a lot of work. It rejects some very malformed things like
+ * <:::>. It returns an empty string, if the element isn't allowed (look ma, no
+ * strip_tags()!). Otherwise it splits the tag into an element and an attribute
+ * list.
+ *
+ * After the tag is split into an element and an attribute list, it is run
+ * through another filter which will remove illegal attributes and once that is
+ * completed, will be returned.
+ *
+ * @access private
+ * @since 1.0.0
+ * @uses wp_kses_attr()
+ *
+ * @param string $string Content to filter
+ * @param array $allowed_html Allowed HTML elements
+ * @param array $allowed_protocols Allowed protocols to keep
+ * @return string Fixed HTML element
+ */
+function wp_kses_split2($string, $allowed_html, $allowed_protocols) {
+	$string = wp_kses_stripslashes($string);
+
+	if (substr($string, 0, 1) != '<')
+		return '&gt;';
+	# It matched a ">" character
+
+	if (preg_match('%^<!--(.*?)(-->)?$%', $string, $matches)) {
+		$string = str_replace(array('<!--', '-->'), '', $matches[1]);
+		while ( $string != $newstring = wp_kses($string, $allowed_html, $allowed_protocols) )
+			$string = $newstring;
+		if ( $string == '' )
+			return '';
+		// prevent multiple dashes in comments
+		$string = preg_replace('/--+/', '-', $string);
+		// prevent three dashes closing a comment
+		$string = preg_replace('/-$/', '', $string);
+		return "<!--{$string}-->";
+	}
+	# Allow HTML comments
+
+	if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches))
+		return '';
+	# It's seriously malformed
+
+	$slash = trim($matches[1]);
+	$elem = $matches[2];
+	$attrlist = $matches[3];
+
+	if (!@isset($allowed_html[strtolower($elem)]))
+		return '';
+	# They are using a not allowed HTML element
+
+	if ($slash != '')
+		return "<$slash$elem>";
+	# No attributes are allowed for closing elements
+
+	return wp_kses_attr("$slash$elem", $attrlist, $allowed_html, $allowed_protocols);
+}
+
+/**
+ * Removes all attributes, if none are allowed for this element.
+ *
+ * If some are allowed it calls wp_kses_hair() to split them further, and then
+ * it builds up new HTML code from the data that kses_hair() returns. It also
+ * removes "<" and ">" characters, if there are any left. One more thing it does
+ * is to check if the tag has a closing XHTML slash, and if it does, it puts one
+ * in the returned code as well.
+ *
+ * @since 1.0.0
+ *
+ * @param string $element HTML element/tag
+ * @param string $attr HTML attributes from HTML element to closing HTML element tag
+ * @param array $allowed_html Allowed HTML elements
+ * @param array $allowed_protocols Allowed protocols to keep
+ * @return string Sanitized HTML element
+ */
+function wp_kses_attr($element, $attr, $allowed_html, $allowed_protocols) {
+	# Is there a closing XHTML slash at the end of the attributes?
+
+	$xhtml_slash = '';
+	if (preg_match('%\s*/\s*$%', $attr))
+		$xhtml_slash = ' /';
+
+	# Are any attributes allowed at all for this element?
+
+	if (@ count($allowed_html[strtolower($element)]) == 0)
+		return "<$element$xhtml_slash>";
+
+	# Split it
+
+	$attrarr = wp_kses_hair($attr, $allowed_protocols);
+
+	# Go through $attrarr, and save the allowed attributes for this element
+	# in $attr2
+
+	$attr2 = '';
+
+	foreach ($attrarr as $arreach) {
+		if (!@ isset ($allowed_html[strtolower($element)][strtolower($arreach['name'])]))
+			continue; # the attribute is not allowed
+
+		$current = $allowed_html[strtolower($element)][strtolower($arreach['name'])];
+		if ($current == '')
+			continue; # the attribute is not allowed
+
+		if (!is_array($current))
+			$attr2 .= ' '.$arreach['whole'];
+		# there are no checks
+
+		else {
+			# there are some checks
+			$ok = true;
+			foreach ($current as $currkey => $currval)
+				if (!wp_kses_check_attr_val($arreach['value'], $arreach['vless'], $currkey, $currval)) {
+					$ok = false;
+					break;
+				}
+
+			if ( strtolower($arreach['name']) == 'style' ) {
+				$orig_value = $arreach['value'];
+
+				$value = safecss_filter_attr($orig_value);
+
+				if ( empty($value) )
+					continue;
+
+				$arreach['value'] = $value;
+
+				$arreach['whole'] = str_replace($orig_value, $value, $arreach['whole']);
+			}
+
+			if ($ok)
+				$attr2 .= ' '.$arreach['whole']; # it passed them
+		} # if !is_array($current)
+	} # foreach
+
+	# Remove any "<" or ">" characters
+
+	$attr2 = preg_replace('/[<>]/', '', $attr2);
+
+	return "<$element$attr2$xhtml_slash>";
+}
+
+/**
+ * Builds an attribute list from string containing attributes.
+ *
+ * This function does a lot of work. It parses an attribute list into an array
+ * with attribute data, and tries to do the right thing even if it gets weird
+ * input. It will add quotes around attribute values that don't have any quotes
+ * or apostrophes around them, to make it easier to produce HTML code that will
+ * conform to W3C's HTML specification. It will also remove bad URL protocols
+ * from attribute values.  It also reduces duplicate attributes by using the
+ * attribute defined first (foo='bar' foo='baz' will result in foo='bar').
+ *
+ * @since 1.0.0
+ *
+ * @param string $attr Attribute list from HTML element to closing HTML element tag
+ * @param array $allowed_protocols Allowed protocols to keep
+ * @return array List of attributes after parsing
+ */
+function wp_kses_hair($attr, $allowed_protocols) {
+	$attrarr = array ();
+	$mode = 0;
+	$attrname = '';
+	$uris = array('xmlns', 'profile', 'href', 'src', 'cite', 'classid', 'codebase', 'data', 'usemap', 'longdesc', 'action');
+
+	# Loop through the whole attribute list
+
+	while (strlen($attr) != 0) {
+		$working = 0; # Was the last operation successful?
+
+		switch ($mode) {
+			case 0 : # attribute name, href for instance
+
+				if (preg_match('/^([-a-zA-Z]+)/', $attr, $match)) {
+					$attrname = $match[1];
+					$working = $mode = 1;
+					$attr = preg_replace('/^[-a-zA-Z]+/', '', $attr);
+				}
+
+				break;
+
+			case 1 : # equals sign or valueless ("selected")
+
+				if (preg_match('/^\s*=\s*/', $attr)) # equals sign
+					{
+					$working = 1;
+					$mode = 2;
+					$attr = preg_replace('/^\s*=\s*/', '', $attr);
+					break;
+				}
+
+				if (preg_match('/^\s+/', $attr)) # valueless
+					{
+					$working = 1;
+					$mode = 0;
+					if(FALSE === array_key_exists($attrname, $attrarr)) {
+						$attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
+					}
+					$attr = preg_replace('/^\s+/', '', $attr);
+				}
+
+				break;
+
+			case 2 : # attribute value, a URL after href= for instance
+
+				if (preg_match('%^"([^"]*)"(\s+|/?$)%', $attr, $match))
+					# "value"
+					{
+					$thisval = $match[1];
+					if ( in_array(strtolower($attrname), $uris) )
+						$thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
+
+					if(FALSE === array_key_exists($attrname, $attrarr)) {
+						$attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
+					}
+					$working = 1;
+					$mode = 0;
+					$attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
+					break;
+				}
+
+				if (preg_match("%^'([^']*)'(\s+|/?$)%", $attr, $match))
+					# 'value'
+					{
+					$thisval = $match[1];
+					if ( in_array(strtolower($attrname), $uris) )
+						$thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
+
+					if(FALSE === array_key_exists($attrname, $attrarr)) {
+						$attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname='$thisval'", 'vless' => 'n');
+					}
+					$working = 1;
+					$mode = 0;
+					$attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
+					break;
+				}
+
+				if (preg_match("%^([^\s\"']+)(\s+|/?$)%", $attr, $match))
+					# value
+					{
+					$thisval = $match[1];
+					if ( in_array(strtolower($attrname), $uris) )
+						$thisval = wp_kses_bad_protocol($thisval, $allowed_protocols);
+
+					if(FALSE === array_key_exists($attrname, $attrarr)) {
+						$attrarr[$attrname] = array ('name' => $attrname, 'value' => $thisval, 'whole' => "$attrname=\"$thisval\"", 'vless' => 'n');
+					}
+					# We add quotes to conform to W3C's HTML spec.
+					$working = 1;
+					$mode = 0;
+					$attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr);
+				}
+
+				break;
+		} # switch
+
+		if ($working == 0) # not well formed, remove and try again
+		{
+			$attr = wp_kses_html_error($attr);
+			$mode = 0;
+		}
+	} # while
+
+	if ($mode == 1 && FALSE === array_key_exists($attrname, $attrarr))
+		# special case, for when the attribute list ends with a valueless
+		# attribute like "selected"
+		$attrarr[$attrname] = array ('name' => $attrname, 'value' => '', 'whole' => $attrname, 'vless' => 'y');
+
+	return $attrarr;
+}
+
+/**
+ * Performs different checks for attribute values.
+ *
+ * The currently implemented checks are "maxlen", "minlen", "maxval", "minval"
+ * and "valueless" with even more checks to come soon.
+ *
+ * @since 1.0.0
+ *
+ * @param string $value Attribute value
+ * @param string $vless Whether the value is valueless. Use 'y' or 'n'
+ * @param string $checkname What $checkvalue is checking for.
+ * @param mixed $checkvalue What constraint the value should pass
+ * @return bool Whether check passes
+ */
+function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) {
+	$ok = true;
+
+	switch (strtolower($checkname)) {
+		case 'maxlen' :
+			# The maxlen check makes sure that the attribute value has a length not
+			# greater than the given value. This can be used to avoid Buffer Overflows
+			# in WWW clients and various Internet servers.
+
+			if (strlen($value) > $checkvalue)
+				$ok = false;
+			break;
+
+		case 'minlen' :
+			# The minlen check makes sure that the attribute value has a length not
+			# smaller than the given value.
+
+			if (strlen($value) < $checkvalue)
+				$ok = false;
+			break;
+
+		case 'maxval' :
+			# The maxval check does two things: it checks that the attribute value is
+			# an integer from 0 and up, without an excessive amount of zeroes or
+			# whitespace (to avoid Buffer Overflows). It also checks that the attribute
+			# value is not greater than the given value.
+			# This check can be used to avoid Denial of Service attacks.
+
+			if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
+				$ok = false;
+			if ($value > $checkvalue)
+				$ok = false;
+			break;
+
+		case 'minval' :
+			# The minval check checks that the attribute value is a positive integer,
+			# and that it is not smaller than the given value.
+
+			if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value))
+				$ok = false;
+			if ($value < $checkvalue)
+				$ok = false;
+			break;
+
+		case 'valueless' :
+			# The valueless check checks if the attribute has a value
+			# (like <a href="blah">) or not (<option selected>). If the given value
+			# is a "y" or a "Y", the attribute must not have a value.
+			# If the given value is an "n" or an "N", the attribute must have one.
+
+			if (strtolower($checkvalue) != $vless)
+				$ok = false;
+			break;
+	} # switch
+
+	return $ok;
+}
+
+/**
+ * Sanitize string from bad protocols.
+ *
+ * This function removes all non-allowed protocols from the beginning of
+ * $string. It ignores whitespace and the case of the letters, and it does
+ * understand HTML entities. It does its work in a while loop, so it won't be
+ * fooled by a string like "javascript:javascript:alert(57)".
+ *
+ * @since 1.0.0
+ *
+ * @param string $string Content to filter bad protocols from
+ * @param array $allowed_protocols Allowed protocols to keep
+ * @return string Filtered content
+ */
+function wp_kses_bad_protocol($string, $allowed_protocols) {
+	$string = wp_kses_no_null($string);
+	$string2 = $string.'a';
+
+	while ($string != $string2) {
+		$string2 = $string;
+		$string = wp_kses_bad_protocol_once($string, $allowed_protocols);
+	} # while
+
+	return $string;
+}
+
+/**
+ * Removes any NULL characters in $string.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string
+ * @return string
+ */
+function wp_kses_no_null($string) {
+	$string = preg_replace('/\0+/', '', $string);
+	$string = preg_replace('/(\\\\0)+/', '', $string);
+
+	return $string;
+}
+
+/**
+ * Strips slashes from in front of quotes.
+ *
+ * This function changes the character sequence  \"  to just  ". It leaves all
+ * other slashes alone. It's really weird, but the quoting from
+ * preg_replace(//e) seems to require this.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string String to strip slashes
+ * @return string Fixed strings with quoted slashes
+ */
+function wp_kses_stripslashes($string) {
+	return preg_replace('%\\\\"%', '"', $string);
+}
+
+/**
+ * Goes through an array and changes the keys to all lower case.
+ *
+ * @since 1.0.0
+ *
+ * @param array $inarray Unfiltered array
+ * @return array Fixed array with all lowercase keys
+ */
+function wp_kses_array_lc($inarray) {
+	$outarray = array ();
+
+	foreach ( (array) $inarray as $inkey => $inval) {
+		$outkey = strtolower($inkey);
+		$outarray[$outkey] = array ();
+
+		foreach ( (array) $inval as $inkey2 => $inval2) {
+			$outkey2 = strtolower($inkey2);
+			$outarray[$outkey][$outkey2] = $inval2;
+		} # foreach $inval
+	} # foreach $inarray
+
+	return $outarray;
+}
+
+/**
+ * Removes the HTML JavaScript entities found in early versions of Netscape 4.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string
+ * @return string
+ */
+function wp_kses_js_entities($string) {
+	return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);
+}
+
+/**
+ * Handles parsing errors in wp_kses_hair().
+ *
+ * The general plan is to remove everything to and including some whitespace,
+ * but it deals with quotes and apostrophes as well.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string
+ * @return string
+ */
+function wp_kses_html_error($string) {
+	return preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string);
+}
+
+/**
+ * Sanitizes content from bad protocols and other characters.
+ *
+ * This function searches for URL protocols at the beginning of $string, while
+ * handling whitespace and HTML entities.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string Content to check for bad protocols
+ * @param string $allowed_protocols Allowed protocols
+ * @return string Sanitized content
+ */
+function wp_kses_bad_protocol_once($string, $allowed_protocols) {
+	$string2 = preg_split( '/:|&#0*58;|&#x0*3a;/i', $string, 2 );
+	if ( isset($string2[1]) && ! preg_match('%/\?%', $string2[0]) )
+		$string = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ) . trim( $string2[1] );
+
+	return $string;
+}
+
+/**
+ * Callback for wp_kses_bad_protocol_once() regular expression.
+ *
+ * This function processes URL protocols, checks to see if they're in the
+ * white-list or not, and returns different data depending on the answer.
+ *
+ * @access private
+ * @since 1.0.0
+ *
+ * @param string $string URI scheme to check against the whitelist
+ * @param string $allowed_protocols Allowed protocols
+ * @return string Sanitized content
+ */
+function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) {
+	$string2 = wp_kses_decode_entities($string);
+	$string2 = preg_replace('/\s/', '', $string2);
+	$string2 = wp_kses_no_null($string2);
+	$string2 = strtolower($string2);
+
+	$allowed = false;
+	foreach ( (array) $allowed_protocols as $one_protocol )
+		if ( strtolower($one_protocol) == $string2 ) {
+			$allowed = true;
+			break;
+		}
+
+	if ($allowed)
+		return "$string2:";
+	else
+		return '';
+}
+
+/**
+ * Converts and fixes HTML entities.
+ *
+ * This function normalizes HTML entities. It will convert "AT&T" to the correct
+ * "AT&amp;T", "&#00058;" to "&#58;", "&#XYZZY;" to "&amp;#XYZZY;" and so on.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string Content to normalize entities
+ * @return string Content with normalized entities
+ */
+function wp_kses_normalize_entities($string) {
+	# Disarm all entities by converting & to &amp;
+
+	$string = str_replace('&', '&amp;', $string);
+
+	# Change back the allowed entities in our entity whitelist
+
+	$string = preg_replace_callback('/&amp;([A-Za-z]{2,8});/', 'wp_kses_named_entities', $string);
+	$string = preg_replace_callback('/&amp;#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $string);
+	$string = preg_replace_callback('/&amp;#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $string);
+
+	return $string;
+}
+
+/**
+ * Callback for wp_kses_normalize_entities() regular expression.
+ *
+ * This function only accepts valid named entity references, which are finite,
+ * case-sensitive, and highly scrutinized by HTML and XML validators.
+ *
+ * @since 3.0.0
+ *
+ * @param array $matches preg_replace_callback() matches array
+ * @return string Correctly encoded entity
+ */
+function wp_kses_named_entities($matches) {
+	global $allowedentitynames;
+
+	if ( empty($matches[1]) )
+		return '';
+
+	$i = $matches[1];
+	return ( ( ! in_array($i, $allowedentitynames) ) ? "&amp;$i;" : "&$i;" );
+}
+
+/**
+ * Callback for wp_kses_normalize_entities() regular expression.
+ *
+ * This function helps wp_kses_normalize_entities() to only accept 16 bit values
+ * and nothing more for &#number; entities.
+ *
+ * @access private
+ * @since 1.0.0
+ *
+ * @param array $matches preg_replace_callback() matches array
+ * @return string Correctly encoded entity
+ */
+function wp_kses_normalize_entities2($matches) {
+	if ( empty($matches[1]) )
+		return '';
+
+	$i = $matches[1];
+	if (valid_unicode($i)) {
+		$i = str_pad(ltrim($i,'0'), 3, '0', STR_PAD_LEFT);
+		$i = "&#$i;";
+	} else {
+		$i = "&amp;#$i;";
+	}
+
+	return $i;
+}
+
+/**
+ * Callback for wp_kses_normalize_entities() for regular expression.
+ *
+ * This function helps wp_kses_normalize_entities() to only accept valid Unicode
+ * numeric entities in hex form.
+ *
+ * @access private
+ *
+ * @param array $matches preg_replace_callback() matches array
+ * @return string Correctly encoded entity
+ */
+function wp_kses_normalize_entities3($matches) {
+	if ( empty($matches[1]) )
+		return '';
+
+	$hexchars = $matches[1];
+	return ( ( ! valid_unicode(hexdec($hexchars)) ) ? "&amp;#x$hexchars;" : '&#x'.ltrim($hexchars,'0').';' );
+}
+
+/**
+ * Helper function to determine if a Unicode value is valid.
+ *
+ * @param int $i Unicode value
+ * @return bool true if the value was a valid Unicode number
+ */
+function valid_unicode($i) {
+	return ( $i == 0x9 || $i == 0xa || $i == 0xd ||
+			($i >= 0x20 && $i <= 0xd7ff) ||
+			($i >= 0xe000 && $i <= 0xfffd) ||
+			($i >= 0x10000 && $i <= 0x10ffff) );
+}
+
+/**
+ * Convert all entities to their character counterparts.
+ *
+ * This function decodes numeric HTML entities (&#65; and &#x41;). It doesn't do
+ * anything with other entities like &auml;, but we don't need them in the URL
+ * protocol whitelisting system anyway.
+ *
+ * @since 1.0.0
+ *
+ * @param string $string Content to change entities
+ * @return string Content after decoded entities
+ */
+function wp_kses_decode_entities($string) {
+	$string = preg_replace_callback('/&#([0-9]+);/', '_wp_kses_decode_entities_chr', $string);
+	$string = preg_replace_callback('/&#[Xx]([0-9A-Fa-f]+);/', '_wp_kses_decode_entities_chr_hexdec', $string);
+
+	return $string;
+}
+
+/**
+ * Regex callback for wp_kses_decode_entities()
+ *
+ * @param array $match preg match
+ * @return string
+ */
+function _wp_kses_decode_entities_chr( $match ) {
+	return chr( $match[1] );
+}
+
+/**
+ * Regex callback for wp_kses_decode_entities()
+ *
+ * @param array $match preg match
+ * @return string
+ */
+function _wp_kses_decode_entities_chr_hexdec( $match ) {
+	return chr( hexdec( $match[1] ) );
+}
+
+/**
+ * Sanitize content with allowed HTML Kses rules.
+ *
+ * @since 1.0.0
+ * @uses $allowedtags
+ *
+ * @param string $data Content to filter, expected to be escaped with slashes
+ * @return string Filtered content
+ */
+function wp_filter_kses($data) {
+	global $allowedtags;
+	return addslashes( wp_kses(stripslashes( $data ), $allowedtags) );
+}
+
+/**
+ * Sanitize content with allowed HTML Kses rules.
+ *
+ * @since 2.9.0
+ * @uses $allowedtags
+ *
+ * @param string $data Content to filter, expected to not be escaped
+ * @return string Filtered content
+ */
+function wp_kses_data($data) {
+	global $allowedtags;
+	return wp_kses( $data , $allowedtags );
+}
+
+/**
+ * Sanitize content for allowed HTML tags for post content.
+ *
+ * Post content refers to the page contents of the 'post' type and not $_POST
+ * data from forms.
+ *
+ * @since 2.0.0
+ * @uses $allowedposttags
+ *
+ * @param string $data Post content to filter, expected to be escaped with slashes
+ * @return string Filtered post content with allowed HTML tags and attributes intact.
+ */
+function wp_filter_post_kses($data) {
+	global $allowedposttags;
+	return addslashes ( wp_kses(stripslashes( $data ), $allowedposttags) );
+}
+
+/**
+ * Sanitize content for allowed HTML tags for post content.
+ *
+ * Post content refers to the page contents of the 'post' type and not $_POST
+ * data from forms.
+ *
+ * @since 2.9.0
+ * @uses $allowedposttags
+ *
+ * @param string $data Post content to filter
+ * @return string Filtered post content with allowed HTML tags and attributes intact.
+ */
+function wp_kses_post($data) {
+	global $allowedposttags;
+	return wp_kses( $data , $allowedposttags );
+}
+
+/**
+ * Strips all of the HTML in the content.
+ *
+ * @since 2.1.0
+ *
+ * @param string $data Content to strip all HTML from
+ * @return string Filtered content without any HTML
+ */
+function wp_filter_nohtml_kses($data) {
+	return addslashes ( wp_kses(stripslashes( $data ), array()) );
+}
+
+/**
+ * Adds all Kses input form content filters.
+ *
+ * All hooks have default priority. The wp_filter_kses() function is added to
+ * the 'pre_comment_content' and 'title_save_pre' hooks.
+ *
+ * The wp_filter_post_kses() function is added to the 'content_save_pre',
+ * 'excerpt_save_pre', and 'content_filtered_save_pre' hooks.
+ *
+ * @since 2.0.0
+ * @uses add_filter() See description for what functions are added to what hooks.
+ */
+function kses_init_filters() {
+	// Normal filtering.
+	add_filter('pre_comment_content', 'wp_filter_kses');
+	add_filter('title_save_pre', 'wp_filter_kses');
+
+	// Post filtering
+	add_filter('content_save_pre', 'wp_filter_post_kses');
+	add_filter('excerpt_save_pre', 'wp_filter_post_kses');
+	add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
+}
+
+/**
+ * Removes all Kses input form content filters.
+ *
+ * A quick procedural method to removing all of the filters that kses uses for
+ * content in WordPress Loop.
+ *
+ * Does not remove the kses_init() function from 'init' hook (priority is
+ * default). Also does not remove kses_init() function from 'set_current_user'
+ * hook (priority is also default).
+ *
+ * @since 2.0.6
+ */
+function kses_remove_filters() {
+	// Normal filtering.
+	remove_filter('pre_comment_content', 'wp_filter_kses');
+	remove_filter('title_save_pre', 'wp_filter_kses');
+
+	// Post filtering
+	remove_filter('content_save_pre', 'wp_filter_post_kses');
+	remove_filter('excerpt_save_pre', 'wp_filter_post_kses');
+	remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
+}
+
+/**
+ * Sets up most of the Kses filters for input form content.
+ *
+ * If you remove the kses_init() function from 'init' hook and
+ * 'set_current_user' (priority is default), then none of the Kses filter hooks
+ * will be added.
+ *
+ * First removes all of the Kses filters in case the current user does not need
+ * to have Kses filter the content. If the user does not have unfiltered html
+ * capability, then Kses filters are added.
+ *
+ * @uses kses_remove_filters() Removes the Kses filters
+ * @uses kses_init_filters() Adds the Kses filters back if the user
+ *		does not have unfiltered HTML capability.
+ * @since 2.0.0
+ */
+function kses_init() {
+	kses_remove_filters();
+
+	if (current_user_can('unfiltered_html') == false)
+		kses_init_filters();
+}
+
+add_action('init', 'kses_init');
+add_action('set_current_user', 'kses_init');
+
+/**
+ * Inline CSS filter
+ *
+ * @since 2.8.1
+ */
+function safecss_filter_attr( $css, $deprecated = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.8.1' ); // Never implemented
+
+	$css = wp_kses_no_null($css);
+	$css = str_replace(array("\n","\r","\t"), '', $css);
+
+	if ( preg_match( '%[\\(&=}]|/\*%', $css ) ) // remove any inline css containing \ ( & } = or comments
+		return '';
+
+	$css_array = explode( ';', trim( $css ) );
+	$allowed_attr = apply_filters( 'safe_style_css', array( 'text-align', 'margin', 'color', 'float',
+	'border', 'background', 'background-color', 'border-bottom', 'border-bottom-color',
+	'border-bottom-style', 'border-bottom-width', 'border-collapse', 'border-color', 'border-left',
+	'border-left-color', 'border-left-style', 'border-left-width', 'border-right', 'border-right-color',
+	'border-right-style', 'border-right-width', 'border-spacing', 'border-style', 'border-top',
+	'border-top-color', 'border-top-style', 'border-top-width', 'border-width', 'caption-side',
+	'clear', 'cursor', 'direction', 'font', 'font-family', 'font-size', 'font-style',
+	'font-variant', 'font-weight', 'height', 'letter-spacing', 'line-height', 'margin-bottom',
+	'margin-left', 'margin-right', 'margin-top', 'overflow', 'padding', 'padding-bottom',
+	'padding-left', 'padding-right', 'padding-top', 'text-decoration', 'text-indent', 'vertical-align',
+	'width' ) );
+
+	if ( empty($allowed_attr) )
+		return $css;
+
+	$css = '';
+	foreach ( $css_array as $css_item ) {
+		if ( $css_item == '' )
+			continue;
+		$css_item = trim( $css_item );
+		$found = false;
+		if ( strpos( $css_item, ':' ) === false ) {
+			$found = true;
+		} else {
+			$parts = split( ':', $css_item );
+			if ( in_array( trim( $parts[0] ), $allowed_attr ) )
+				$found = true;
+		}
+		if ( $found ) {
+			if( $css != '' )
+				$css .= ';';
+			$css .= $css_item;
+		}
+	}
+
+	return $css;
+}
Index: /tags/3.1/wp-includes/l10n.php
===================================================================
--- /tags/3.1/wp-includes/l10n.php	(revision 17487)
+++ /tags/3.1/wp-includes/l10n.php	(revision 17487)
@@ -0,0 +1,535 @@
+<?php
+/**
+ * WordPress Translation API
+ *
+ * @package WordPress
+ * @subpackage i18n
+ */
+
+/**
+ * Gets the current locale.
+ *
+ * If the locale is set, then it will filter the locale in the 'locale' filter
+ * hook and return the value.
+ *
+ * If the locale is not set already, then the WPLANG constant is used if it is
+ * defined. Then it is filtered through the 'locale' filter hook and the value
+ * for the locale global set and the locale is returned.
+ *
+ * The process to get the locale should only be done once but the locale will
+ * always be filtered using the 'locale' hook.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'locale' hook on locale value.
+ * @uses $locale Gets the locale stored in the global.
+ *
+ * @return string The locale of the blog or from the 'locale' hook.
+ */
+function get_locale() {
+	global $locale;
+
+	if ( isset( $locale ) )
+		return apply_filters( 'locale', $locale );
+
+	// WPLANG is defined in wp-config.
+	if ( defined( 'WPLANG' ) )
+		$locale = WPLANG;
+
+	// If multisite, check options.
+	if ( is_multisite() && !defined('WP_INSTALLING') ) {
+		$ms_locale = get_option('WPLANG');
+		if ( $ms_locale === false )
+			$ms_locale = get_site_option('WPLANG');
+
+		if ( $ms_locale !== false )
+			$locale = $ms_locale;
+	}
+
+	if ( empty( $locale ) )
+		$locale = 'en_US';
+
+	return apply_filters( 'locale', $locale );
+}
+
+/**
+ * Retrieves the translation of $text. If there is no translation, or
+ * the domain isn't loaded the original text is returned.
+ *
+ * @see __() Don't use translate() directly, use __()
+ * @since 2.2.0
+ * @uses apply_filters() Calls 'gettext' on domain translated text
+ *		with the untranslated text as second parameter.
+ *
+ * @param string $text Text to translate.
+ * @param string $domain Domain to retrieve the translated text.
+ * @return string Translated text
+ */
+function translate( $text, $domain = 'default' ) {
+	$translations = &get_translations_for_domain( $domain );
+	return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain );
+}
+
+function before_last_bar( $string ) {
+	$last_bar = strrpos( $string, '|' );
+	if ( false == $last_bar )
+		return $string;
+	else
+		return substr( $string, 0, $last_bar );
+}
+
+function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
+	$translations = &get_translations_for_domain( $domain );
+	return apply_filters( 'gettext_with_context', $translations->translate( $text, $context ), $text, $context, $domain );
+}
+
+/**
+ * Retrieves the translation of $text. If there is no translation, or
+ * the domain isn't loaded the original text is returned.
+ *
+ * @see translate() An alias of translate()
+ * @since 2.1.0
+ *
+ * @param string $text Text to translate
+ * @param string $domain Optional. Domain to retrieve the translated text
+ * @return string Translated text
+ */
+function __( $text, $domain = 'default' ) {
+	return translate( $text, $domain );
+}
+
+/**
+ * Retrieves the translation of $text and escapes it for safe use in an attribute.
+ * If there is no translation, or the domain isn't loaded the original text is returned.
+ *
+ * @see translate() An alias of translate()
+ * @see esc_attr()
+ * @since 2.8.0
+ *
+ * @param string $text Text to translate
+ * @param string $domain Optional. Domain to retrieve the translated text
+ * @return string Translated text
+ */
+function esc_attr__( $text, $domain = 'default' ) {
+	return esc_attr( translate( $text, $domain ) );
+}
+
+/**
+ * Retrieves the translation of $text and escapes it for safe use in HTML output.
+ * If there is no translation, or the domain isn't loaded the original text is returned.
+ *
+ * @see translate() An alias of translate()
+ * @see esc_html()
+ * @since 2.8.0
+ *
+ * @param string $text Text to translate
+ * @param string $domain Optional. Domain to retrieve the translated text
+ * @return string Translated text
+ */
+function esc_html__( $text, $domain = 'default' ) {
+	return esc_html( translate( $text, $domain ) );
+}
+
+/**
+ * Displays the returned translated text from translate().
+ *
+ * @see translate() Echoes returned translate() string
+ * @since 1.2.0
+ *
+ * @param string $text Text to translate
+ * @param string $domain Optional. Domain to retrieve the translated text
+ */
+function _e( $text, $domain = 'default' ) {
+	echo translate( $text, $domain );
+}
+
+/**
+ * Displays translated text that has been escaped for safe use in an attribute.
+ *
+ * @see translate() Echoes returned translate() string
+ * @see esc_attr()
+ * @since 2.8.0
+ *
+ * @param string $text Text to translate
+ * @param string $domain Optional. Domain to retrieve the translated text
+ */
+function esc_attr_e( $text, $domain = 'default' ) {
+	echo esc_attr( translate( $text, $domain ) );
+}
+
+/**
+ * Displays translated text that has been escaped for safe use in HTML output.
+ *
+ * @see translate() Echoes returned translate() string
+ * @see esc_html()
+ * @since 2.8.0
+ *
+ * @param string $text Text to translate
+ * @param string $domain Optional. Domain to retrieve the translated text
+ */
+function esc_html_e( $text, $domain = 'default' ) {
+	echo esc_html( translate( $text, $domain ) );
+}
+
+/**
+ * Retrieve translated string with gettext context
+ *
+ * Quite a few times, there will be collisions with similar translatable text
+ * found in more than two places but with different translated context.
+ *
+ * By including the context in the pot file translators can translate the two
+ * string differently.
+ *
+ * @since 2.8.0
+ *
+ * @param string $text Text to translate
+ * @param string $context Context information for the translators
+ * @param string $domain Optional. Domain to retrieve the translated text
+ * @return string Translated context string without pipe
+ */
+function _x( $single, $context, $domain = 'default' ) {
+	return translate_with_gettext_context( $single, $context, $domain );
+}
+
+/**
+ * Displays translated string with gettext context
+ *
+ * @see _x
+ * @since 3.0.0
+ *
+ * @param string $text Text to translate
+ * @param string $context Context information for the translators
+ * @param string $domain Optional. Domain to retrieve the translated text
+ * @return string Translated context string without pipe
+ */
+function _ex( $single, $context, $domain = 'default' ) {
+	echo _x( $single, $context, $domain );
+}
+
+function esc_attr_x( $single, $context, $domain = 'default' ) {
+	return esc_attr( translate_with_gettext_context( $single, $context, $domain ) );
+}
+
+function esc_html_x( $single, $context, $domain = 'default' ) {
+	return esc_html( translate_with_gettext_context( $single, $context, $domain ) );
+}
+
+/**
+ * Retrieve the plural or single form based on the amount.
+ *
+ * If the domain is not set in the $l10n list, then a comparison will be made
+ * and either $plural or $single parameters returned.
+ *
+ * If the domain does exist, then the parameters $single, $plural, and $number
+ * will first be passed to the domain's ngettext method. Then it will be passed
+ * to the 'ngettext' filter hook along with the same parameters. The expected
+ * type will be a string.
+ *
+ * @since 2.8.0
+ * @uses $l10n Gets list of domain translated string (gettext_reader) objects
+ * @uses apply_filters() Calls 'ngettext' hook on domains text returned,
+ *		along with $single, $plural, and $number parameters. Expected to return string.
+ *
+ * @param string $single The text that will be used if $number is 1
+ * @param string $plural The text that will be used if $number is not 1
+ * @param int $number The number to compare against to use either $single or $plural
+ * @param string $domain Optional. The domain identifier the text should be retrieved in
+ * @return string Either $single or $plural translated text
+ */
+function _n( $single, $plural, $number, $domain = 'default' ) {
+	$translations = &get_translations_for_domain( $domain );
+	$translation = $translations->translate_plural( $single, $plural, $number );
+	return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
+}
+
+/**
+ * A hybrid of _n() and _x(). It supports contexts and plurals.
+ *
+ * @see _n()
+ * @see _x()
+ *
+ */
+function _nx($single, $plural, $number, $context, $domain = 'default') {
+	$translations = &get_translations_for_domain( $domain );
+	$translation = $translations->translate_plural( $single, $plural, $number, $context );
+	return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
+}
+
+/**
+ * Register plural strings in POT file, but don't translate them.
+ *
+ * Used when you want do keep structures with translatable plural strings and
+ * use them later.
+ *
+ * Example:
+ *  $messages = array(
+ *  	'post' => _n_noop('%s post', '%s posts'),
+ *  	'page' => _n_noop('%s pages', '%s pages')
+ *  );
+ *  ...
+ *  $message = $messages[$type];
+ *  $usable_text = sprintf( translate_nooped_plural( $message, $count ), $count );
+ *
+ * @since 2.5
+ * @param string $single Single form to be i18ned
+ * @param string $plural Plural form to be i18ned
+ * @return array array($single, $plural)
+ */
+function _n_noop( $singular, $plural ) {
+	return array( 0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null );
+}
+
+/**
+ * Register plural strings with context in POT file, but don't translate them.
+ *
+ * @see _n_noop()
+ */
+function _nx_noop( $singular, $plural, $context ) {
+	return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context );
+}
+
+/**
+ * Translate the result of _n_noop() or _nx_noop()
+ *
+ * @since 3.1
+ * @param array $nooped_plural array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop()
+ * @param int $count number of objects
+ * @param string $domain Optional. The domain identifier the text should be retrieved in
+ */
+function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
+	if ( $nooped_plural['context'] )
+		return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
+	else
+		return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
+}
+
+/**
+ * Loads a MO file into the domain $domain.
+ *
+ * If the domain already exists, the translations will be merged. If both
+ * sets have the same string, the translation from the original value will be taken.
+ *
+ * On success, the .mo file will be placed in the $l10n global by $domain
+ * and will be a MO object.
+ *
+ * @since 1.5.0
+ * @uses $l10n Gets list of domain translated string objects
+ *
+ * @param string $domain Unique identifier for retrieving translated strings
+ * @param string $mofile Path to the .mo file
+ * @return bool true on success, false on failure
+ */
+function load_textdomain( $domain, $mofile ) {
+	global $l10n;
+
+	$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
+
+	if ( true == $plugin_override ) {
+		return true;
+	}
+
+	do_action( 'load_textdomain', $domain, $mofile );
+
+	$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
+
+	if ( !is_readable( $mofile ) ) return false;
+
+	$mo = new MO();
+	if ( !$mo->import_from_file( $mofile ) ) return false;
+
+	if ( isset( $l10n[$domain] ) )
+		$mo->merge_with( $l10n[$domain] );
+
+	$l10n[$domain] = &$mo;
+
+	return true;
+}
+
+/**
+ * Unloads translations for a domain
+ *
+ * @since 3.0.0
+ * @param string $domain Textdomain to be unloaded
+ * @return bool Whether textdomain was unloaded
+ */
+function unload_textdomain( $domain ) {
+	global $l10n;
+
+	$plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
+
+	if ( $plugin_override )
+		return true;
+
+	do_action( 'unload_textdomain', $domain );
+
+	if ( isset( $l10n[$domain] ) ) {
+		unset( $l10n[$domain] );
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * Loads default translated strings based on locale.
+ *
+ * Loads the .mo file in WP_LANG_DIR constant path from WordPress root. The
+ * translated (.mo) file is named based off of the locale.
+ *
+ * @since 1.5.0
+ */
+function load_default_textdomain() {
+	$locale = get_locale();
+
+	load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );
+
+	if ( is_multisite() || ( defined( 'WP_NETWORK_ADMIN_PAGE' ) && WP_NETWORK_ADMIN_PAGE ) ) {
+		load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" );
+	}
+}
+
+/**
+ * Loads the plugin's translated strings.
+ *
+ * If the path is not given then it will be the root of the plugin directory.
+ * The .mo file should be named based on the domain with a dash, and then the locale exactly.
+ *
+ * @since 1.5.0
+ *
+ * @param string $domain Unique identifier for retrieving translated strings
+ * @param string $abs_rel_path Optional. Relative path to ABSPATH of a folder,
+ * 	where the .mo file resides. Deprecated, but still functional until 2.7
+ * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precendence over $abs_rel_path
+ */
+function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) {
+	$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
+
+	if ( false !== $plugin_rel_path	) {
+		$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
+	} else if ( false !== $abs_rel_path ) {
+		_deprecated_argument( __FUNCTION__, '2.7' );
+		$path = ABSPATH . trim( $abs_rel_path, '/' );
+	} else {
+		$path = WP_PLUGIN_DIR;
+	}
+
+	$mofile = $path . '/'. $domain . '-' . $locale . '.mo';
+	return load_textdomain( $domain, $mofile );
+}
+
+/**
+ * Load the translated strings for a plugin residing in the mu-plugins dir.
+ *
+ * @since 3.0.0
+ *
+ * @param string $domain Unique identifier for retrieving translated strings
+ * @param strings $mu_plugin_rel_path Relative to WPMU_PLUGIN_DIR directory in which
+ * the MO file resides. Defaults is empty string.
+ */
+function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
+	$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
+	$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
+	load_textdomain( $domain, trailingslashit( $path ) . "$domain-$locale.mo" );
+}
+
+/**
+ * Loads the theme's translated strings.
+ *
+ * If the current locale exists as a .mo file in the theme's root directory, it
+ * will be included in the translated strings by the $domain.
+ *
+ * The .mo files must be named based on the locale exactly.
+ *
+ * @since 1.5.0
+ *
+ * @param string $domain Unique identifier for retrieving translated strings
+ */
+function load_theme_textdomain( $domain, $path = false ) {
+	$locale = apply_filters( 'theme_locale', get_locale(), $domain );
+
+	$path = ( empty( $path ) ) ? get_template_directory() : $path;
+
+	$mofile = "$path/$locale.mo";
+	return load_textdomain($domain, $mofile);
+}
+
+/**
+ * Loads the child themes translated strings.
+ *
+ * If the current locale exists as a .mo file in the child themes root directory, it
+ * will be included in the translated strings by the $domain.
+ *
+ * The .mo files must be named based on the locale exactly.
+ *
+ * @since 2.9.0
+ *
+ * @param string $domain Unique identifier for retrieving translated strings
+ */
+function load_child_theme_textdomain( $domain, $path = false ) {
+	$locale = apply_filters( 'theme_locale', get_locale(), $domain );
+
+	$path = ( empty( $path ) ) ? get_stylesheet_directory() : $path;
+
+	$mofile = "$path/$locale.mo";
+	return load_textdomain($domain, $mofile);
+}
+
+/**
+ * Returns the Translations instance for a domain. If there isn't one,
+ * returns empty Translations instance.
+ *
+ * @param string $domain
+ * @return object A Translation instance
+ */
+function &get_translations_for_domain( $domain ) {
+	global $l10n;
+	if ( !isset( $l10n[$domain] ) ) {
+		$l10n[$domain] = &new NOOP_Translations;
+	}
+	return $l10n[$domain];
+}
+
+/**
+ * Whether there are translations for the domain
+ *
+ * @since 3.0.0
+ * @param string $domain
+ * @return bool Whether there are translations
+ */
+function is_textdomain_loaded( $domain ) {
+	global $l10n;
+	return isset( $l10n[$domain] );
+}
+
+/**
+ * Translates role name. Since the role names are in the database and
+ * not in the source there are dummy gettext calls to get them into the POT
+ * file and this function properly translates them back.
+ *
+ * The before_last_bar() call is needed, because older installs keep the roles
+ * using the old context format: 'Role name|User role' and just skipping the
+ * content after the last bar is easier than fixing them in the DB. New installs
+ * won't suffer from that problem.
+ */
+function translate_user_role( $name ) {
+	return translate_with_gettext_context( before_last_bar($name), 'User role' );
+}
+
+/**
+ * Get all available languages based on the presence of *.mo files in a given directory. The default directory is WP_LANG_DIR.
+ *
+ * @since 3.0.0
+ *
+ * @param string $dir A directory in which to search for language files. The default directory is WP_LANG_DIR.
+ * @return array Array of language codes or an empty array if no languages are present.  Language codes are formed by stripping the .mo extension from the language file names.
+ */
+function get_available_languages( $dir = null ) {
+	$languages = array();
+
+	foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) {
+		$lang_file = basename($lang_file, '.mo');
+		if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) )
+			$languages[] = $lang_file;
+	}
+
+	return $languages;
+}
Index: /tags/3.1/wp-includes/link-template.php
===================================================================
--- /tags/3.1/wp-includes/link-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/link-template.php	(revision 17487)
@@ -0,0 +1,2470 @@
+<?php
+/**
+ * WordPress Link Template Functions
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Display the permalink for the current post.
+ *
+ * @since 1.2.0
+ * @uses apply_filters() Calls 'the_permalink' filter on the permalink string.
+ */
+function the_permalink() {
+	echo apply_filters('the_permalink', get_permalink());
+}
+
+/**
+ * Retrieve trailing slash string, if blog set for adding trailing slashes.
+ *
+ * Conditionally adds a trailing slash if the permalink structure has a trailing
+ * slash, strips the trailing slash if not. The string is passed through the
+ * 'user_trailingslashit' filter. Will remove trailing slash from string, if
+ * blog is not set to have them.
+ *
+ * @since 2.2.0
+ * @uses $wp_rewrite
+ *
+ * @param string $string URL with or without a trailing slash.
+ * @param string $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
+ * @return string
+ */
+function user_trailingslashit($string, $type_of_url = '') {
+	global $wp_rewrite;
+	if ( $wp_rewrite->use_trailing_slashes )
+		$string = trailingslashit($string);
+	else
+		$string = untrailingslashit($string);
+
+	// Note that $type_of_url can be one of following:
+	// single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged, post_type_archive
+	$string = apply_filters('user_trailingslashit', $string, $type_of_url);
+	return $string;
+}
+
+/**
+ * Display permalink anchor for current post.
+ *
+ * The permalink mode title will use the post title for the 'a' element 'id'
+ * attribute. The id mode uses 'post-' with the post ID for the 'id' attribute.
+ *
+ * @since 0.71
+ *
+ * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
+ */
+function permalink_anchor($mode = 'id') {
+	global $post;
+	switch ( strtolower($mode) ) {
+		case 'title':
+			$title = sanitize_title($post->post_title) . '-' . $post->ID;
+			echo '<a id="'.$title.'"></a>';
+			break;
+		case 'id':
+		default:
+			echo '<a id="post-' . $post->ID . '"></a>';
+			break;
+	}
+}
+
+/**
+ * Retrieve full permalink for current post or post ID.
+ *
+ * @since 1.0.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
+ * @return string
+ */
+function get_permalink($id = 0, $leavename = false) {
+	$rewritecode = array(
+		'%year%',
+		'%monthnum%',
+		'%day%',
+		'%hour%',
+		'%minute%',
+		'%second%',
+		$leavename? '' : '%postname%',
+		'%post_id%',
+		'%category%',
+		'%author%',
+		$leavename? '' : '%pagename%',
+	);
+
+	if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) {
+		$post = $id;
+		$sample = true;
+	} else {
+		$post = &get_post($id);
+		$sample = false;
+	}
+
+	if ( empty($post->ID) )
+		return false;
+
+	if ( $post->post_type == 'page' )
+		return get_page_link($post->ID, $leavename, $sample);
+	elseif ( $post->post_type == 'attachment' )
+		return get_attachment_link($post->ID);
+	elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) )
+		return get_post_permalink($post->ID, $leavename, $sample);
+
+	$permalink = get_option('permalink_structure');
+
+	$permalink = apply_filters('pre_post_link', $permalink, $post, $leavename);
+
+	if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {
+		$unixtime = strtotime($post->post_date);
+
+		$category = '';
+		if ( strpos($permalink, '%category%') !== false ) {
+			$cats = get_the_category($post->ID);
+			if ( $cats ) {
+				usort($cats, '_usort_terms_by_ID'); // order by ID
+				$category = $cats[0]->slug;
+				if ( $parent = $cats[0]->parent )
+					$category = get_category_parents($parent, false, '/', true) . $category;
+			}
+			// show default category in permalinks, without
+			// having to assign it explicitly
+			if ( empty($category) ) {
+				$default_category = get_category( get_option( 'default_category' ) );
+				$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
+			}
+		}
+
+		$author = '';
+		if ( strpos($permalink, '%author%') !== false ) {
+			$authordata = get_userdata($post->post_author);
+			$author = $authordata->user_nicename;
+		}
+
+		$date = explode(" ",date('Y m d H i s', $unixtime));
+		$rewritereplace =
+		array(
+			$date[0],
+			$date[1],
+			$date[2],
+			$date[3],
+			$date[4],
+			$date[5],
+			$post->post_name,
+			$post->ID,
+			$category,
+			$author,
+			$post->post_name,
+		);
+		$permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
+		$permalink = user_trailingslashit($permalink, 'single');
+	} else { // if they're not using the fancy permalink option
+		$permalink = home_url('?p=' . $post->ID);
+	}
+	return apply_filters('post_link', $permalink, $post, $leavename);
+}
+
+/**
+ * Retrieve the permalink for a post with a custom post type.
+ *
+ * @since 3.0.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $leavename Optional, defaults to false. Whether to keep post name.
+ * @param bool $sample Optional, defaults to false. Is it a sample permalink.
+ * @return string
+ */
+function get_post_permalink( $id = 0, $leavename = false, $sample = false ) {
+	global $wp_rewrite;
+
+	$post = &get_post($id);
+
+	if ( is_wp_error( $post ) )
+		return $post;
+
+	$post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
+
+	$slug = $post->post_name;
+
+	$draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
+
+	$post_type = get_post_type_object($post->post_type);
+
+	if ( !empty($post_link) && ( !$draft_or_pending || $sample ) ) {
+		if ( ! $leavename ) {
+			if ( $post_type->hierarchical )
+				$slug = get_page_uri($id);
+			$post_link = str_replace("%$post->post_type%", $slug, $post_link);
+		}
+		$post_link = home_url( user_trailingslashit($post_link) );
+	} else {
+		if ( $post_type->query_var && ( isset($post->post_status) && !$draft_or_pending ) )
+			$post_link = add_query_arg($post_type->query_var, $slug, '');
+		else
+			$post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
+		$post_link = home_url($post_link);
+	}
+
+	return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
+}
+
+/**
+ * Retrieve permalink from post ID.
+ *
+ * @since 1.0.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param mixed $deprecated Not used.
+ * @return string
+ */
+function post_permalink( $post_id = 0, $deprecated = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '1.3' );
+
+	return get_permalink($post_id);
+}
+
+/**
+ * Retrieve the permalink for current page or page ID.
+ *
+ * Respects page_on_front. Use this one.
+ *
+ * @since 1.5.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $leavename Optional, defaults to false. Whether to keep page name.
+ * @param bool $sample Optional, defaults to false. Is it a sample permalink.
+ * @return string
+ */
+function get_page_link( $id = false, $leavename = false, $sample = false ) {
+	global $post;
+
+	$id = (int) $id;
+	if ( !$id )
+		$id = (int) $post->ID;
+
+	if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
+		$link = home_url('/');
+	else
+		$link = _get_page_link( $id , $leavename, $sample );
+
+	return apply_filters('page_link', $link, $id, $sample);
+}
+
+/**
+ * Retrieve the page permalink.
+ *
+ * Ignores page_on_front. Internal use only.
+ *
+ * @since 2.1.0
+ * @access private
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $leavename Optional. Leave name.
+ * @param bool $sample Optional. Sample permalink.
+ * @return string
+ */
+function _get_page_link( $id = false, $leavename = false, $sample = false ) {
+	global $post, $wp_rewrite;
+
+	if ( !$id )
+		$id = (int) $post->ID;
+	else
+		$post = &get_post($id);
+
+	$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
+
+	$link = $wp_rewrite->get_page_permastruct();
+
+	if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) {
+		if ( ! $leavename ) {
+			$link = str_replace('%pagename%', get_page_uri($id), $link);
+		}
+
+		$link = home_url($link);
+		$link = user_trailingslashit($link, 'page');
+	} else {
+		$link = home_url("?page_id=$id");
+	}
+
+	return apply_filters( '_get_page_link', $link, $id );
+}
+
+/**
+ * Retrieve permalink for attachment.
+ *
+ * This can be used in the WordPress Loop or outside of it.
+ *
+ * @since 2.0.0
+ *
+ * @param int $id Optional. Post ID.
+ * @return string
+ */
+function get_attachment_link($id = false) {
+	global $post, $wp_rewrite;
+
+	$link = false;
+
+	if ( ! $id)
+		$id = (int) $post->ID;
+
+	$object = get_post($id);
+	if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) && ($object->post_parent != $id) ) {
+		$parent = get_post($object->post_parent);
+		if ( 'page' == $parent->post_type )
+			$parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front
+		else
+			$parentlink = get_permalink( $object->post_parent );
+
+		if ( is_numeric($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
+			$name = 'attachment/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
+		else
+			$name = $object->post_name;
+
+		if ( strpos($parentlink, '?') === false )
+			$link = user_trailingslashit( trailingslashit($parentlink) . $name );
+	}
+
+	if ( ! $link )
+		$link = home_url( "/?attachment_id=$id" );
+
+	return apply_filters('attachment_link', $link, $id);
+}
+
+/**
+ * Retrieve the permalink for the year archives.
+ *
+ * @since 1.5.0
+ *
+ * @param int|bool $year False for current year or year for permalink.
+ * @return string
+ */
+function get_year_link($year) {
+	global $wp_rewrite;
+	if ( !$year )
+		$year = gmdate('Y', current_time('timestamp'));
+	$yearlink = $wp_rewrite->get_year_permastruct();
+	if ( !empty($yearlink) ) {
+		$yearlink = str_replace('%year%', $year, $yearlink);
+		return apply_filters('year_link', home_url( user_trailingslashit($yearlink, 'year') ), $year);
+	} else {
+		return apply_filters('year_link', home_url('?m=' . $year), $year);
+	}
+}
+
+/**
+ * Retrieve the permalink for the month archives with year.
+ *
+ * @since 1.0.0
+ *
+ * @param bool|int $year False for current year. Integer of year.
+ * @param bool|int $month False for current month. Integer of month.
+ * @return string
+ */
+function get_month_link($year, $month) {
+	global $wp_rewrite;
+	if ( !$year )
+		$year = gmdate('Y', current_time('timestamp'));
+	if ( !$month )
+		$month = gmdate('m', current_time('timestamp'));
+	$monthlink = $wp_rewrite->get_month_permastruct();
+	if ( !empty($monthlink) ) {
+		$monthlink = str_replace('%year%', $year, $monthlink);
+		$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
+		return apply_filters('month_link', home_url( user_trailingslashit($monthlink, 'month') ), $year, $month);
+	} else {
+		return apply_filters('month_link', home_url( '?m=' . $year . zeroise($month, 2) ), $year, $month);
+	}
+}
+
+/**
+ * Retrieve the permalink for the day archives with year and month.
+ *
+ * @since 1.0.0
+ *
+ * @param bool|int $year False for current year. Integer of year.
+ * @param bool|int $month False for current month. Integer of month.
+ * @param bool|int $day False for current day. Integer of day.
+ * @return string
+ */
+function get_day_link($year, $month, $day) {
+	global $wp_rewrite;
+	if ( !$year )
+		$year = gmdate('Y', current_time('timestamp'));
+	if ( !$month )
+		$month = gmdate('m', current_time('timestamp'));
+	if ( !$day )
+		$day = gmdate('j', current_time('timestamp'));
+
+	$daylink = $wp_rewrite->get_day_permastruct();
+	if ( !empty($daylink) ) {
+		$daylink = str_replace('%year%', $year, $daylink);
+		$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
+		$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
+		return apply_filters('day_link', home_url( user_trailingslashit($daylink, 'day') ), $year, $month, $day);
+	} else {
+		return apply_filters('day_link', home_url( '?m=' . $year . zeroise($month, 2) . zeroise($day, 2) ), $year, $month, $day);
+	}
+}
+
+/**
+ * Display the permalink for the feed type.
+ *
+ * @since 3.0.0
+ *
+ * @param string $anchor The link's anchor text.
+ * @param string $feed Optional, defaults to default feed. Feed type.
+ */
+function the_feed_link( $anchor, $feed = '' ) {
+	$link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>';
+	echo apply_filters( 'the_feed_link', $link, $feed );
+}
+
+/**
+ * Retrieve the permalink for the feed type.
+ *
+ * @since 1.5.0
+ *
+ * @param string $feed Optional, defaults to default feed. Feed type.
+ * @return string
+ */
+function get_feed_link($feed = '') {
+	global $wp_rewrite;
+
+	$permalink = $wp_rewrite->get_feed_permastruct();
+	if ( '' != $permalink ) {
+		if ( false !== strpos($feed, 'comments_') ) {
+			$feed = str_replace('comments_', '', $feed);
+			$permalink = $wp_rewrite->get_comment_feed_permastruct();
+		}
+
+		if ( get_default_feed() == $feed )
+			$feed = '';
+
+		$permalink = str_replace('%feed%', $feed, $permalink);
+		$permalink = preg_replace('#/+#', '/', "/$permalink");
+		$output =  home_url( user_trailingslashit($permalink, 'feed') );
+	} else {
+		if ( empty($feed) )
+			$feed = get_default_feed();
+
+		if ( false !== strpos($feed, 'comments_') )
+			$feed = str_replace('comments_', 'comments-', $feed);
+
+		$output = home_url("?feed={$feed}");
+	}
+
+	return apply_filters('feed_link', $output, $feed);
+}
+
+/**
+ * Retrieve the permalink for the post comments feed.
+ *
+ * @since 2.2.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
+function get_post_comments_feed_link($post_id = 0, $feed = '') {
+	$post_id = absint( $post_id );
+
+	if ( ! $post_id )
+		$post_id = get_the_ID();
+
+	if ( empty( $feed ) )
+		$feed = get_default_feed();
+
+	if ( '' != get_option('permalink_structure') ) {
+		if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') )
+			$url = _get_page_link( $post_id );
+		else
+			$url = get_permalink($post_id);
+
+		$url = trailingslashit($url) . 'feed';
+		if ( $feed != get_default_feed() )
+			$url .= "/$feed";
+		$url = user_trailingslashit($url, 'single_feed');
+	} else {
+		$type = get_post_field('post_type', $post_id);
+		if ( 'page' == $type )
+			$url = home_url("?feed=$feed&amp;page_id=$post_id");
+		else
+			$url = home_url("?feed=$feed&amp;p=$post_id");
+	}
+
+	return apply_filters('post_comments_feed_link', $url);
+}
+
+/**
+ * Display the comment feed link for a post.
+ *
+ * Prints out the comment feed link for a post. Link text is placed in the
+ * anchor. If no link text is specified, default text is used. If no post ID is
+ * specified, the current post is used.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5.0
+ *
+ * @param string $link_text Descriptive text.
+ * @param int $post_id Optional post ID.  Default to current post.
+ * @param string $feed Optional. Feed format.
+ * @return string Link to the comment feed for the current post.
+*/
+function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
+	$url = get_post_comments_feed_link($post_id, $feed);
+	if ( empty($link_text) )
+		$link_text = __('Comments Feed');
+
+	echo apply_filters( 'post_comments_feed_link_html', "<a href='$url'>$link_text</a>", $post_id, $feed );
+}
+
+/**
+ * Retrieve the feed link for a given author.
+ *
+ * Returns a link to the feed for all posts by a given author. A specific feed
+ * can be requested or left blank to get the default feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5.0
+ *
+ * @param int $author_id ID of an author.
+ * @param string $feed Optional. Feed type.
+ * @return string Link to the feed for the author specified by $author_id.
+*/
+function get_author_feed_link( $author_id, $feed = '' ) {
+	$author_id = (int) $author_id;
+	$permalink_structure = get_option('permalink_structure');
+
+	if ( empty($feed) )
+		$feed = get_default_feed();
+
+	if ( '' == $permalink_structure ) {
+		$link = home_url("?feed=$feed&amp;author=" . $author_id);
+	} else {
+		$link = get_author_posts_url($author_id);
+		if ( $feed == get_default_feed() )
+			$feed_link = 'feed';
+		else
+			$feed_link = "feed/$feed";
+
+		$link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
+	}
+
+	$link = apply_filters('author_feed_link', $link, $feed);
+
+	return $link;
+}
+
+/**
+ * Retrieve the feed link for a category.
+ *
+ * Returns a link to the feed for all post in a given category. A specific feed
+ * can be requested or left blank to get the default feed.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5.0
+ *
+ * @param int $cat_id ID of a category.
+ * @param string $feed Optional. Feed type.
+ * @return string Link to the feed for the category specified by $cat_id.
+*/
+function get_category_feed_link($cat_id, $feed = '') {
+	return get_term_feed_link($cat_id, 'category', $feed);
+}
+
+/**
+ * Retrieve the feed link for a taxonomy.
+ *
+ * Returns a link to the feed for all post in a given term. A specific feed
+ * can be requested or left blank to get the default feed.
+ *
+ * @since 3.0
+ *
+ * @param int $term_id ID of a category.
+ * @param string $taxonomy Optional. Taxonomy of $term_id
+ * @param string $feed Optional. Feed type.
+ * @return string Link to the feed for the taxonomy specified by $term_id and $taxonomy.
+*/
+function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {
+	global $wp_rewrite;
+
+	$term_id = ( int ) $term_id;
+
+	$term = get_term( $term_id, $taxonomy  );
+
+	if ( empty( $term ) || is_wp_error( $term ) )
+		return false;
+
+	if ( empty( $feed ) )
+		$feed = get_default_feed();
+
+	$permalink_structure = get_option( 'permalink_structure' );
+
+	if ( '' == $permalink_structure ) {
+		if ( 'category' == $taxonomy ) {
+			$link = home_url("?feed=$feed&amp;cat=$term_id");
+		}
+		elseif ( 'post_tag' == $taxonomy ) {
+			$link = home_url("?feed=$feed&amp;tag=$term->slug");
+		} else {
+			$t = get_taxonomy( $taxonomy );
+			$link = home_url("?feed=$feed&amp;$t->query_var=$term->slug");
+		}
+	} else {
+		$link = get_term_link( $term_id, $term->taxonomy );
+		if ( $feed == get_default_feed() )
+			$feed_link = 'feed';
+		else
+			$feed_link = "feed/$feed";
+
+		$link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );
+	}
+
+	if ( 'category' == $taxonomy )
+		$link = apply_filters( 'category_feed_link', $link, $feed );
+	elseif ( 'post_tag' == $taxonomy )
+		$link = apply_filters( 'category_feed_link', $link, $feed );
+	else
+		$link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy );
+
+
+	return $link;
+}
+
+/**
+ * Retrieve permalink for feed of tag.
+ *
+ * @since 2.3.0
+ *
+ * @param int $tag_id Tag ID.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
+function get_tag_feed_link($tag_id, $feed = '') {
+	return get_term_feed_link($tag_id, 'post_tag', $feed);
+}
+
+/**
+ * Retrieve edit tag link.
+ *
+ * @since 2.7.0
+ *
+ * @param int $tag_id Tag ID
+ * @param string $taxonomy Taxonomy
+ * @return string
+ */
+function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) {
+	return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) );
+}
+
+/**
+ * Display or retrieve edit tag link with formatting.
+ *
+ * @since 2.7.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @param int|object $tag Tag object or ID
+ * @return string HTML content.
+ */
+function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
+	$link = edit_term_link( $link, '', '', false, $tag );
+	echo $before . apply_filters( 'edit_tag_link', $link ) . $after;
+}
+
+/**
+ * Retrieve edit term url.
+ *
+ * @since 3.1.0
+ *
+ * @param int $term_id Term ID
+ * @param string $taxonomy Taxonomy
+ * @param string $object_type The object type
+ * @return string
+ */
+function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) {
+	$tax = get_taxonomy( $taxonomy );
+	if ( !current_user_can( $tax->cap->edit_terms ) )
+		return;
+
+	$term = get_term( $term_id, $taxonomy );
+
+	$args = array(
+		'action' => 'edit',
+		'taxonomy' => $taxonomy,
+		'tag_ID' => $term->term_id,
+	);
+
+	if ( $object_type )
+		$args['post_type'] = $object_type;
+
+	$location = add_query_arg( $args, admin_url( 'edit-tags.php' ) );
+
+	return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type );
+}
+
+/**
+ * Display or retrieve edit term link with formatting.
+ *
+ * @since 3.1.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @param object $term Term object
+ * @return string HTML content.
+ */
+function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) {
+	if ( is_null( $term ) ) {
+		$term = get_queried_object();
+	}
+
+	$tax = get_taxonomy( $term->taxonomy );
+	if ( !current_user_can($tax->cap->edit_terms) )
+		return;
+
+	if ( empty( $link ) )
+		$link = __('Edit This');
+
+	$link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '" title="' . $link . '">' . $link . '</a>';
+	$link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
+
+	if ( $echo )
+		echo $link;
+	else
+		return $link;
+}
+
+/**
+* Retrieve permalink for search.
+*
+* @since  3.0.0
+* @param string $query Optional. The query string to use. If empty the current query is used.
+* @return string
+*/
+function get_search_link( $query = '' ) {
+	global $wp_rewrite;
+
+	if ( empty($query) )
+		$search = get_search_query( false );
+	else
+		$search = stripslashes($query);
+
+	$permastruct = $wp_rewrite->get_search_permastruct();
+
+	if ( empty( $permastruct ) ) {
+		$link = home_url('?s=' . urlencode($search) );
+	} else {
+		$search = urlencode($search);
+		$search = str_replace('%2F', '/', $search); // %2F(/) is not valid within a URL, send it unencoded.
+		$link = str_replace( '%search%', $search, $permastruct );
+		$link = home_url( user_trailingslashit( $link, 'search' ) );
+	}
+
+	return apply_filters( 'search_link', $link, $search );
+}
+
+/**
+ * Retrieve the permalink for the feed of the search results.
+ *
+ * @since 2.5.0
+ *
+ * @param string $search_query Optional. Search query.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
+function get_search_feed_link($search_query = '', $feed = '') {
+	global $wp_rewrite;
+	$link = get_search_link($search_query);
+
+	if ( empty($feed) )
+		$feed = get_default_feed();
+
+	$permastruct = $wp_rewrite->get_search_permastruct();
+
+	if ( empty($permastruct) ) {
+		$link = add_query_arg('feed', $feed, $link);
+	} else {
+		$link = trailingslashit($link);
+		$link .= "feed/$feed/";
+	}
+
+	$link = apply_filters('search_feed_link', $link, $feed, 'posts');
+
+	return $link;
+}
+
+/**
+ * Retrieve the permalink for the comments feed of the search results.
+ *
+ * @since 2.5.0
+ *
+ * @param string $search_query Optional. Search query.
+ * @param string $feed Optional. Feed type.
+ * @return string
+ */
+function get_search_comments_feed_link($search_query = '', $feed = '') {
+	global $wp_rewrite;
+
+	if ( empty($feed) )
+		$feed = get_default_feed();
+
+	$link = get_search_feed_link($search_query, $feed);
+
+	$permastruct = $wp_rewrite->get_search_permastruct();
+
+	if ( empty($permastruct) )
+		$link = add_query_arg('feed', 'comments-' . $feed, $link);
+	else
+		$link = add_query_arg('withcomments', 1, $link);
+
+	$link = apply_filters('search_feed_link', $link, $feed, 'comments');
+
+	return $link;
+}
+
+/**
+ * Retrieve the permalink for a post type archive.
+ *
+ * @since 3.1.0
+ *
+ * @param string $post_type Post type
+ * @return string
+ */
+function get_post_type_archive_link( $post_type ) {
+	global $wp_rewrite;
+	if ( ! $post_type_obj = get_post_type_object( $post_type ) )
+		return false;
+
+	if ( ! $post_type_obj->has_archive )
+		return false;
+
+	if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) {
+		$struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
+		if ( $post_type_obj->rewrite['with_front'] )
+			$struct = $wp_rewrite->front . $struct;
+		$link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) );
+	} else {
+		$link = home_url( '?post_type=' . $post_type );
+	}
+
+	return apply_filters( 'post_type_archive_link', $link, $post_type );
+}
+
+/**
+ * Retrieve the permalink for a post type archive feed.
+ *
+ * @since 3.1.0
+ *
+ * @param string $post_type Post type
+ * @param string $feed Optional. Feed type
+ * @return string
+ */
+function get_post_type_archive_feed_link( $post_type, $feed = '' ) {
+	$default_feed = get_default_feed();
+	if ( empty( $feed ) )
+		$feed = $default_feed;
+
+	if ( ! $link = get_post_type_archive_link( $post_type ) )
+		return false;
+	$post_type_obj = get_post_type_object( $post_type );
+	if ( $post_type_obj->rewrite['feeds'] && get_option( 'permalink_structure' ) ) {
+		$link = trailingslashit($link);
+		$link .= 'feed/';
+		if ( $feed != $default_feed )
+			$link .= "$feed/";
+	} else {
+		$link = add_query_arg( 'feed', $feed, $link );
+	}
+
+	return apply_filters( 'post_type_archive_feed_link', $link, $feed );
+}
+
+/**
+ * Retrieve edit posts link for post.
+ *
+ * Can be used within the WordPress loop or outside of it. Can be used with
+ * pages, posts, attachments, and revisions.
+ *
+ * @since 2.3.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param string $context Optional, default to display. How to write the '&', defaults to '&amp;'.
+ * @return string
+ */
+function get_edit_post_link( $id = 0, $context = 'display' ) {
+	if ( !$post = &get_post( $id ) )
+		return;
+
+	if ( 'display' == $context )
+		$action = '&amp;action=edit';
+	else
+		$action = '&action=edit';
+
+	$post_type_object = get_post_type_object( $post->post_type );
+	if ( !$post_type_object )
+		return;
+
+	if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) )
+		return;
+
+	return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context );
+}
+
+/**
+ * Display edit post link for post.
+ *
+ * @since 1.0.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @param int $id Optional. Post ID.
+ */
+function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
+	if ( !$post = &get_post( $id ) )
+		return;
+
+	if ( !$url = get_edit_post_link( $post->ID ) )
+		return;
+
+	if ( null === $link )
+		$link = __('Edit This');
+
+	$post_type_obj = get_post_type_object( $post->post_type );
+	$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
+	echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
+}
+
+/**
+ * Retrieve delete posts link for post.
+ *
+ * Can be used within the WordPress loop or outside of it, with any post type.
+ *
+ * @since 2.9.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param string $deprecated Not used.
+ * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.
+ * @return string
+ */
+function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false ) {
+	if ( ! empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '3.0' );
+
+	if ( !$post = &get_post( $id ) )
+		return;
+
+	$post_type_object = get_post_type_object( $post->post_type );
+	if ( !$post_type_object )
+		return;
+
+	if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) )
+		return;
+
+	$action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
+
+	$delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
+
+	return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-{$post->post_type}_{$post->ID}" ), $post->ID, $force_delete );
+}
+
+/**
+ * Retrieve edit comment link.
+ *
+ * @since 2.3.0
+ *
+ * @param int $comment_id Optional. Comment ID.
+ * @return string
+ */
+function get_edit_comment_link( $comment_id = 0 ) {
+	$comment = &get_comment( $comment_id );
+
+	if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
+		return;
+
+	$location = admin_url('comment.php?action=editcomment&amp;c=') . $comment->comment_ID;
+	return apply_filters( 'get_edit_comment_link', $location );
+}
+
+/**
+ * Display or retrieve edit comment link with formatting.
+ *
+ * @since 1.0.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @return string|null HTML content, if $echo is set to false.
+ */
+function edit_comment_link( $link = null, $before = '', $after = '' ) {
+	global $comment;
+
+	if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
+		return;
+
+	if ( null === $link )
+		$link = __('Edit This');
+
+	$link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . esc_attr__( 'Edit comment' ) . '">' . $link . '</a>';
+	echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
+}
+
+/**
+ * Display edit bookmark (literally a URL external to blog) link.
+ *
+ * @since 2.7.0
+ *
+ * @param int $link Optional. Bookmark ID.
+ * @return string
+ */
+function get_edit_bookmark_link( $link = 0 ) {
+	$link = get_bookmark( $link );
+
+	if ( !current_user_can('manage_links') )
+		return;
+
+	$location = admin_url('link.php?action=edit&amp;link_id=') . $link->link_id;
+	return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id );
+}
+
+/**
+ * Display edit bookmark (literally a URL external to blog) link anchor content.
+ *
+ * @since 2.7.0
+ *
+ * @param string $link Optional. Anchor text.
+ * @param string $before Optional. Display before edit link.
+ * @param string $after Optional. Display after edit link.
+ * @param int $bookmark Optional. Bookmark ID.
+ */
+function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) {
+	$bookmark = get_bookmark($bookmark);
+
+	if ( !current_user_can('manage_links') )
+		return;
+
+	if ( empty($link) )
+		$link = __('Edit This');
+
+	$link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '" title="' . esc_attr__( 'Edit Link' ) . '">' . $link . '</a>';
+	echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after;
+}
+
+// Navigation links
+
+/**
+ * Retrieve previous post that is adjacent to current post.
+ *
+ * @since 1.5.0
+ *
+ * @param bool $in_same_cat Optional. Whether post should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
+ */
+function get_previous_post($in_same_cat = false, $excluded_categories = '') {
+	return get_adjacent_post($in_same_cat, $excluded_categories);
+}
+
+/**
+ * Retrieve next post that is adjacent to current post.
+ *
+ * @since 1.5.0
+ *
+ * @param bool $in_same_cat Optional. Whether post should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
+ */
+function get_next_post($in_same_cat = false, $excluded_categories = '') {
+	return get_adjacent_post($in_same_cat, $excluded_categories, false);
+}
+
+/**
+ * Retrieve adjacent post.
+ *
+ * Can either be next or previous post.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $in_same_cat Optional. Whether post should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $previous Optional. Whether to retrieve previous post.
+ * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
+ */
+function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) {
+	global $post, $wpdb;
+
+	if ( empty( $post ) )
+		return null;
+
+	$current_post_date = $post->post_date;
+
+	$join = '';
+	$posts_in_ex_cats_sql = '';
+	if ( $in_same_cat || !empty($excluded_categories) ) {
+		$join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
+
+		if ( $in_same_cat ) {
+			$cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
+			$join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
+		}
+
+		$posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
+		if ( !empty($excluded_categories) ) {
+			$excluded_categories = array_map('intval', explode(' and ', $excluded_categories));
+			if ( !empty($cat_array) ) {
+				$excluded_categories = array_diff($excluded_categories, $cat_array);
+				$posts_in_ex_cats_sql = '';
+			}
+
+			if ( !empty($excluded_categories) ) {
+				$posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';
+			}
+		}
+	}
+
+	$adjacent = $previous ? 'previous' : 'next';
+	$op = $previous ? '<' : '>';
+	$order = $previous ? 'DESC' : 'ASC';
+
+	$join  = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories );
+	$where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories );
+	$sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );
+
+	$query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort";
+	$query_key = 'adjacent_post_' . md5($query);
+	$result = wp_cache_get($query_key, 'counts');
+	if ( false !== $result )
+		return $result;
+
+	$result = $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort");
+	if ( null === $result )
+		$result = '';
+
+	wp_cache_set($query_key, $result, 'counts');
+	return $result;
+}
+
+/**
+ * Get adjacent post relational link.
+ *
+ * Can either be next or previous post relational link.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Optional. Link title format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $previous Optional, default is true. Whether display link to previous post.
+ * @return string
+ */
+function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) {
+	if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) )
+		$post = & get_post($GLOBALS['post']->post_parent);
+	else
+		$post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);
+
+	if ( empty($post) )
+		return;
+
+	if ( empty($post->post_title) )
+		$post->post_title = $previous ? __('Previous Post') : __('Next Post');
+
+	$date = mysql2date(get_option('date_format'), $post->post_date);
+
+	$title = str_replace('%title', $post->post_title, $title);
+	$title = str_replace('%date', $date, $title);
+	$title = apply_filters('the_title', $title, $post->ID);
+
+	$link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
+	$link .= esc_attr( $title );
+	$link .= "' href='" . get_permalink($post) . "' />\n";
+
+	$adjacent = $previous ? 'previous' : 'next';
+	return apply_filters( "{$adjacent}_post_rel_link", $link );
+}
+
+/**
+ * Display relational links for the posts adjacent to the current post.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Optional. Link title format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
+function adjacent_posts_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
+	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true);
+	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false);
+}
+
+/**
+ * Display relational links for the posts adjacent to the current post for single post pages.
+ *
+ * This is meant to be attached to actions like 'wp_head'.  Do not call this directly in plugins or theme templates.
+ * @since 3.0.0
+ *
+ */
+function adjacent_posts_rel_link_wp_head() {
+	if ( !is_singular() || is_attachment() )
+		return;
+	adjacent_posts_rel_link();
+}
+
+/**
+ * Display relational link for the next post adjacent to the current post.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Optional. Link title format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
+function next_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
+	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false);
+}
+
+/**
+ * Display relational link for the previous post adjacent to the current post.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Optional. Link title format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
+function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
+	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true);
+}
+
+/**
+ * Retrieve boundary post.
+ *
+ * Boundary being either the first or last post by publish date within the constraints specified
+ * by in same category or excluded categories.
+ *
+ * @since 2.8.0
+ *
+ * @param bool $in_same_cat Optional. Whether returned post should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $start Optional. Whether to retrieve first or last post.
+ * @return object
+ */
+function get_boundary_post($in_same_cat = false, $excluded_categories = '', $start = true) {
+	global $post;
+
+	if ( empty($post) || !is_single() || is_attachment() )
+		return null;
+
+	$cat_array = array();
+	$excluded_categories = array();
+	if ( !empty($in_same_cat) || !empty($excluded_categories) ) {
+		if ( !empty($in_same_cat) ) {
+			$cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
+		}
+
+		if ( !empty($excluded_categories) ) {
+			$excluded_categories = array_map('intval', explode(',', $excluded_categories));
+
+			if ( !empty($cat_array) )
+				$excluded_categories = array_diff($excluded_categories, $cat_array);
+
+			$inverse_cats = array();
+			foreach ( $excluded_categories as $excluded_category)
+				$inverse_cats[] = $excluded_category * -1;
+			$excluded_categories = $inverse_cats;
+		}
+	}
+
+	$categories = implode(',', array_merge($cat_array, $excluded_categories) );
+
+	$order = $start ? 'ASC' : 'DESC';
+
+	return get_posts( array('numberposts' => 1, 'category' => $categories, 'order' => $order, 'update_post_term_cache' => false, 'update_post_meta_cache' => false) );
+}
+
+/**
+ * Get boundary post relational link.
+ *
+ * Can either be start or end post relational link.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Optional. Link title format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $start Optional, default is true. Whether display link to first or last post.
+ * @return string
+ */
+function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
+	$posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
+	// If there is no post stop.
+	if ( empty($posts) )
+		return;
+
+	// Even though we limited get_posts to return only 1 item it still returns an array of objects.
+	$post = $posts[0];
+
+	if ( empty($post->post_title) )
+		$post->post_title = $start ? __('First Post') : __('Last Post');
+
+	$date = mysql2date(get_option('date_format'), $post->post_date);
+
+	$title = str_replace('%title', $post->post_title, $title);
+	$title = str_replace('%date', $date, $title);
+	$title = apply_filters('the_title', $title, $post->ID);
+
+	$link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
+	$link .= esc_attr($title);
+	$link .= "' href='" . get_permalink($post) . "' />\n";
+
+	$boundary = $start ? 'start' : 'end';
+	return apply_filters( "{$boundary}_post_rel_link", $link );
+}
+
+/**
+ * Display relational link for the first post.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Optional. Link title format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
+function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
+	echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);
+}
+
+/**
+ * Get site index relational link.
+ *
+ * @since 2.8.0
+ *
+ * @return string
+ */
+function get_index_rel_link() {
+	$link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n";
+	return apply_filters( "index_rel_link", $link );
+}
+
+/**
+ * Display relational link for the site index.
+ *
+ * @since 2.8.0
+ */
+function index_rel_link() {
+	echo get_index_rel_link();
+}
+
+/**
+ * Get parent post relational link.
+ *
+ * @since 2.8.0
+ *
+ * @param string $title Optional. Link title format.
+ * @return string
+ */
+function get_parent_post_rel_link($title = '%title') {
+	if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
+		$post = & get_post($GLOBALS['post']->post_parent);
+
+	if ( empty($post) )
+		return;
+
+	$date = mysql2date(get_option('date_format'), $post->post_date);
+
+	$title = str_replace('%title', $post->post_title, $title);
+	$title = str_replace('%date', $date, $title);
+	$title = apply_filters('the_title', $title, $post->ID);
+
+	$link = "<link rel='up' title='";
+	$link .= esc_attr( $title );
+	$link .= "' href='" . get_permalink($post) . "' />\n";
+
+	return apply_filters( "parent_post_rel_link", $link );
+}
+
+/**
+ * Display relational link for parent item
+ *
+ * @since 2.8.0
+ */
+function parent_post_rel_link($title = '%title') {
+	echo get_parent_post_rel_link($title);
+}
+
+/**
+ * Display previous post link that is adjacent to the current post.
+ *
+ * @since 1.5.0
+ *
+ * @param string $format Optional. Link anchor format.
+ * @param string $link Optional. Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
+function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+	adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
+}
+
+/**
+ * Display next post link that is adjacent to the current post.
+ *
+ * @since 1.5.0
+ *
+ * @param string $format Optional. Link anchor format.
+ * @param string $link Optional. Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ */
+function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+	adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
+}
+
+/**
+ * Display adjacent post link.
+ *
+ * Can be either next post link or previous.
+ *
+ * @since 2.5.0
+ *
+ * @param string $format Link anchor format.
+ * @param string $link Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $previous Optional, default is true. Whether display link to previous post.
+ */
+function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
+	if ( $previous && is_attachment() )
+		$post = & get_post($GLOBALS['post']->post_parent);
+	else
+		$post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);
+
+	if ( !$post )
+		return;
+
+	$title = $post->post_title;
+
+	if ( empty($post->post_title) )
+		$title = $previous ? __('Previous Post') : __('Next Post');
+
+	$title = apply_filters('the_title', $title, $post->ID);
+	$date = mysql2date(get_option('date_format'), $post->post_date);
+	$rel = $previous ? 'prev' : 'next';
+
+	$string = '<a href="'.get_permalink($post).'" rel="'.$rel.'">';
+	$link = str_replace('%title', $title, $link);
+	$link = str_replace('%date', $date, $link);
+	$link = $string . $link . '</a>';
+
+	$format = str_replace('%link', $link, $format);
+
+	$adjacent = $previous ? 'previous' : 'next';
+	echo apply_filters( "{$adjacent}_post_link", $format, $link );
+}
+
+/**
+ * Retrieve get links for page numbers.
+ *
+ * @since 1.5.0
+ *
+ * @param int $pagenum Optional. Page ID.
+ * @return string
+ */
+function get_pagenum_link($pagenum = 1) {
+	global $wp_rewrite;
+
+	$pagenum = (int) $pagenum;
+
+	$request = remove_query_arg( 'paged' );
+
+	$home_root = parse_url(home_url());
+	$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
+	$home_root = preg_quote( trailingslashit( $home_root ), '|' );
+
+	$request = preg_replace('|^'. $home_root . '|', '', $request);
+	$request = preg_replace('|^/+|', '', $request);
+
+	if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
+		$base = trailingslashit( get_bloginfo( 'url' ) );
+
+		if ( $pagenum > 1 ) {
+			$result = add_query_arg( 'paged', $pagenum, $base . $request );
+		} else {
+			$result = $base . $request;
+		}
+	} else {
+		$qs_regex = '|\?.*?$|';
+		preg_match( $qs_regex, $request, $qs_match );
+
+		if ( !empty( $qs_match[0] ) ) {
+			$query_string = $qs_match[0];
+			$request = preg_replace( $qs_regex, '', $request );
+		} else {
+			$query_string = '';
+		}
+
+		$request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
+		$request = preg_replace( '|^index\.php|', '', $request);
+		$request = ltrim($request, '/');
+
+		$base = trailingslashit( get_bloginfo( 'url' ) );
+
+		if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
+			$base .= 'index.php/';
+
+		if ( $pagenum > 1 ) {
+			$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
+		}
+
+		$result = $base . $request . $query_string;
+	}
+
+	$result = apply_filters('get_pagenum_link', $result);
+
+	return $result;
+}
+
+/**
+ * Retrieve next posts pages link.
+ *
+ * Backported from 2.1.3 to 2.0.10.
+ *
+ * @since 2.0.10
+ *
+ * @param int $max_page Optional. Max pages.
+ * @return string
+ */
+function get_next_posts_page_link($max_page = 0) {
+	global $paged;
+
+	if ( !is_single() ) {
+		if ( !$paged )
+			$paged = 1;
+		$nextpage = intval($paged) + 1;
+		if ( !$max_page || $max_page >= $nextpage )
+			return get_pagenum_link($nextpage);
+	}
+}
+
+/**
+ * Display or return the next posts pages link.
+ *
+ * @since 0.71
+ *
+ * @param int $max_page Optional. Max pages.
+ * @param boolean $echo Optional. Echo or return;
+ */
+function next_posts( $max_page = 0, $echo = true ) {
+	$output = esc_url( get_next_posts_page_link( $max_page ) );
+
+	if ( $echo )
+		echo $output;
+	else
+		return $output;
+}
+
+/**
+ * Return the next posts pages link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Content for link text.
+ * @param int $max_page Optional. Max pages.
+ * @return string|null
+ */
+function get_next_posts_link( $label = 'Next Page &raquo;', $max_page = 0 ) {
+	global $paged, $wp_query;
+
+	if ( !$max_page )
+		$max_page = $wp_query->max_num_pages;
+
+	if ( !$paged )
+		$paged = 1;
+
+	$nextpage = intval($paged) + 1;
+
+	if ( !is_single() && ( $nextpage <= $max_page ) ) {
+		$attr = apply_filters( 'next_posts_link_attributes', '' );
+		return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) . '</a>';
+	}
+}
+
+/**
+ * Display the next posts pages link.
+ *
+ * @since 0.71
+ * @uses get_next_posts_link()
+ *
+ * @param string $label Content for link text.
+ * @param int $max_page Optional. Max pages.
+ */
+function next_posts_link( $label = 'Next Page &raquo;', $max_page = 0 ) {
+	echo get_next_posts_link( $label, $max_page );
+}
+
+/**
+ * Retrieve previous post pages link.
+ *
+ * Will only return string, if not on a single page or post.
+ *
+ * Backported to 2.0.10 from 2.1.3.
+ *
+ * @since 2.0.10
+ *
+ * @return string|null
+ */
+function get_previous_posts_page_link() {
+	global $paged;
+
+	if ( !is_single() ) {
+		$nextpage = intval($paged) - 1;
+		if ( $nextpage < 1 )
+			$nextpage = 1;
+		return get_pagenum_link($nextpage);
+	}
+}
+
+/**
+ * Display or return the previous posts pages link.
+ *
+ * @since 0.71
+ *
+ * @param boolean $echo Optional. Echo or return;
+ */
+function previous_posts( $echo = true ) {
+	$output = esc_url( get_previous_posts_page_link() );
+
+	if ( $echo )
+		echo $output;
+	else
+		return $output;
+}
+
+/**
+ * Return the previous posts pages link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Optional. Previous page link text.
+ * @return string|null
+ */
+function get_previous_posts_link( $label = '&laquo; Previous Page' ) {
+	global $paged;
+
+	if ( !is_single() && $paged > 1 ) {
+		$attr = apply_filters( 'previous_posts_link_attributes', '' );
+		return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label ) .'</a>';
+	}
+}
+
+/**
+ * Display the previous posts page link.
+ *
+ * @since 0.71
+ * @uses get_previous_posts_link()
+ *
+ * @param string $label Optional. Previous page link text.
+ */
+function previous_posts_link( $label = '&laquo; Previous Page' ) {
+	echo get_previous_posts_link( $label );
+}
+
+/**
+ * Return post pages link navigation for previous and next pages.
+ *
+ * @since 2.8
+ *
+ * @param string|array $args Optional args.
+ * @return string The posts link navigation.
+ */
+function get_posts_nav_link( $args = array() ) {
+	global $wp_query;
+
+	$return = '';
+
+	if ( !is_singular() ) {
+		$defaults = array(
+			'sep' => ' &#8212; ',
+			'prelabel' => __('&laquo; Previous Page'),
+			'nxtlabel' => __('Next Page &raquo;'),
+		);
+		$args = wp_parse_args( $args, $defaults );
+
+		$max_num_pages = $wp_query->max_num_pages;
+		$paged = get_query_var('paged');
+
+		//only have sep if there's both prev and next results
+		if ($paged < 2 || $paged >= $max_num_pages) {
+			$args['sep'] = '';
+		}
+
+		if ( $max_num_pages > 1 ) {
+			$return = get_previous_posts_link($args['prelabel']);
+			$return .= preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $args['sep']);
+			$return .= get_next_posts_link($args['nxtlabel']);
+		}
+	}
+	return $return;
+
+}
+
+/**
+ * Display post pages link navigation for previous and next pages.
+ *
+ * @since 0.71
+ *
+ * @param string $sep Optional. Separator for posts navigation links.
+ * @param string $prelabel Optional. Label for previous pages.
+ * @param string $nxtlabel Optional Label for next pages.
+ */
+function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) {
+	$args = array_filter( compact('sep', 'prelabel', 'nxtlabel') );
+	echo get_posts_nav_link($args);
+}
+
+/**
+ * Retrieve page numbers links.
+ *
+ * @since 2.7.0
+ *
+ * @param int $pagenum Optional. Page number.
+ * @return string
+ */
+function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
+	global $post, $wp_rewrite;
+
+	$pagenum = (int) $pagenum;
+
+	$result = get_permalink( $post->ID );
+
+	if ( 'newest' == get_option('default_comments_page') ) {
+		if ( $pagenum != $max_page ) {
+			if ( $wp_rewrite->using_permalinks() )
+				$result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
+			else
+				$result = add_query_arg( 'cpage', $pagenum, $result );
+		}
+	} elseif ( $pagenum > 1 ) {
+		if ( $wp_rewrite->using_permalinks() )
+			$result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
+		else
+			$result = add_query_arg( 'cpage', $pagenum, $result );
+	}
+
+	$result .= '#comments';
+
+	$result = apply_filters('get_comments_pagenum_link', $result);
+
+	return $result;
+}
+
+/**
+ * Return the link to next comments pages.
+ *
+ * @since 2.7.1
+ *
+ * @param string $label Optional. Label for link text.
+ * @param int $max_page Optional. Max page.
+ * @return string|null
+ */
+function get_next_comments_link( $label = '', $max_page = 0 ) {
+	global $wp_query;
+
+	if ( !is_singular() || !get_option('page_comments') )
+		return;
+
+	$page = get_query_var('cpage');
+
+	$nextpage = intval($page) + 1;
+
+	if ( empty($max_page) )
+		$max_page = $wp_query->max_num_comment_pages;
+
+	if ( empty($max_page) )
+		$max_page = get_comment_pages_count();
+
+	if ( $nextpage > $max_page )
+		return;
+
+	if ( empty($label) )
+		$label = __('Newer Comments &raquo;');
+
+	return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) .'</a>';
+}
+
+/**
+ * Display the link to next comments pages.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Optional. Label for link text.
+ * @param int $max_page Optional. Max page.
+ */
+function next_comments_link( $label = '', $max_page = 0 ) {
+	echo get_next_comments_link( $label, $max_page );
+}
+
+/**
+ * Return the previous comments page link.
+ *
+ * @since 2.7.1
+ *
+ * @param string $label Optional. Label for comments link text.
+ * @return string|null
+ */
+function get_previous_comments_link( $label = '' ) {
+	if ( !is_singular() || !get_option('page_comments') )
+		return;
+
+	$page = get_query_var('cpage');
+
+	if ( intval($page) <= 1 )
+		return;
+
+	$prevpage = intval($page) - 1;
+
+	if ( empty($label) )
+		$label = __('&laquo; Older Comments');
+
+	return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label) .'</a>';
+}
+
+/**
+ * Display the previous comments page link.
+ *
+ * @since 2.7.0
+ *
+ * @param string $label Optional. Label for comments link text.
+ */
+function previous_comments_link( $label = '' ) {
+	echo get_previous_comments_link( $label );
+}
+
+/**
+ * Create pagination links for the comments on the current post.
+ *
+ * @see paginate_links()
+ * @since 2.7.0
+ *
+ * @param string|array $args Optional args. See paginate_links.
+ * @return string Markup for pagination links.
+*/
+function paginate_comments_links($args = array()) {
+	global $wp_rewrite;
+
+	if ( !is_singular() || !get_option('page_comments') )
+		return;
+
+	$page = get_query_var('cpage');
+	if ( !$page )
+		$page = 1;
+	$max_page = get_comment_pages_count();
+	$defaults = array(
+		'base' => add_query_arg( 'cpage', '%#%' ),
+		'format' => '',
+		'total' => $max_page,
+		'current' => $page,
+		'echo' => true,
+		'add_fragment' => '#comments'
+	);
+	if ( $wp_rewrite->using_permalinks() )
+		$defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . 'comment-page-%#%', 'commentpaged');
+
+	$args = wp_parse_args( $args, $defaults );
+	$page_links = paginate_links( $args );
+
+	if ( $args['echo'] )
+		echo $page_links;
+	else
+		return $page_links;
+}
+
+/**
+ * Retrieve shortcut link.
+ *
+ * Use this in 'a' element 'href' attribute.
+ *
+ * @since 2.6.0
+ *
+ * @return string
+ */
+function get_shortcut_link() {
+	$link = "javascript:
+			var d=document,
+			w=window,
+			e=w.getSelection,
+			k=d.getSelection,
+			x=d.selection,
+			s=(e?e():(k)?k():(x?x.createRange().text:0)),
+			f='" . admin_url('press-this.php') . "',
+			l=d.location,
+			e=encodeURIComponent,
+			u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';
+			a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};
+			if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();
+			void(0)";
+
+	$link = str_replace(array("\r", "\n", "\t"),  '', $link);
+
+	return apply_filters('shortcut_link', $link);
+}
+
+/**
+ * Retrieve the home url for the current site.
+ *
+ * Returns the 'home' option with the appropriate protocol,  'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @uses get_home_url()
+ *
+ * @param  string $path   (optional) Path relative to the home url.
+ * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
+ * @return string Home url link with optional path appended.
+*/
+function home_url( $path = '', $scheme = null ) {
+	return get_home_url(null, $path, $scheme);
+}
+
+/**
+ * Retrieve the home url for a given site.
+ *
+ * Returns the 'home' option with the appropriate protocol,  'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @param  int $blog_id   (optional) Blog ID. Defaults to current blog.
+ * @param  string $path   (optional) Path relative to the home url.
+ * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
+ * @return string Home url link with optional path appended.
+*/
+function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
+	$orig_scheme = $scheme;
+
+	if ( !in_array( $scheme, array( 'http', 'https' ) ) )
+		$scheme = is_ssl() && !is_admin() ? 'https' : 'http';
+
+	if ( empty( $blog_id ) || !is_multisite() )
+		$url = get_option( 'home' );
+	else
+		$url = get_blog_option( $blog_id, 'home' );
+
+	if ( 'http' != $scheme )
+		$url = str_replace( 'http://', "$scheme://", $url );
+
+	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+		$url .= '/' . ltrim( $path, '/' );
+
+	return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
+}
+
+/**
+ * Retrieve the site url for the current site.
+ *
+ * Returns the 'site_url' option with the appropriate protocol,  'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
+ *
+ * @package WordPress
+ * @since 2.6.0
+ *
+ * @uses get_site_url()
+ *
+ * @param string $path Optional. Path relative to the site url.
+ * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'.
+ * @return string Site url link with optional path appended.
+*/
+function site_url( $path = '', $scheme = null ) {
+	return get_site_url(null, $path, $scheme);
+}
+
+/**
+ * Retrieve the site url for a given site.
+ *
+ * Returns the 'site_url' option with the appropriate protocol,  'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @param int $blog_id (optional) Blog ID. Defaults to current blog.
+ * @param string $path Optional. Path relative to the site url.
+ * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'.
+ * @return string Site url link with optional path appended.
+*/
+function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
+	// should the list of allowed schemes be maintained elsewhere?
+	$orig_scheme = $scheme;
+	if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
+		if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
+			$scheme = 'https';
+		elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
+			$scheme = 'https';
+		elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )
+			$scheme = 'https';
+		else
+			$scheme = ( is_ssl() ? 'https' : 'http' );
+	}
+
+	if ( empty( $blog_id ) || !is_multisite() )
+		$url = get_option( 'siteurl' );
+	else
+		$url = get_blog_option( $blog_id, 'siteurl' );
+
+	if ( 'http' != $scheme )
+		$url = str_replace( 'http://', "{$scheme}://", $url );
+
+	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+		$url .= '/' . ltrim( $path, '/' );
+
+	return apply_filters( 'site_url', $url, $path, $orig_scheme, $blog_id );
+}
+
+/**
+ * Retrieve the url to the admin area for the current site.
+ *
+ * @package WordPress
+ * @since 2.6.0
+ *
+ * @param string $path Optional path relative to the admin url
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Admin url link with optional path appended
+*/
+function admin_url( $path = '', $scheme = 'admin' ) {
+	return get_admin_url(null, $path, $scheme);
+}
+
+/**
+ * Retrieve the url to the admin area for a given site.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @param int $blog_id (optional) Blog ID. Defaults to current blog.
+ * @param string $path Optional path relative to the admin url
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Admin url link with optional path appended
+*/
+function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {
+	$url = get_site_url($blog_id, 'wp-admin/', $scheme);
+
+	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+		$url .= ltrim($path, '/');
+
+	return apply_filters('admin_url', $url, $path, $blog_id);
+}
+
+/**
+ * Retrieve the url to the includes directory.
+ *
+ * @package WordPress
+ * @since 2.6.0
+ *
+ * @param string $path Optional. Path relative to the includes url.
+ * @return string Includes url link with optional path appended.
+*/
+function includes_url($path = '') {
+	$url = site_url() . '/' . WPINC . '/';
+
+	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+		$url .= ltrim($path, '/');
+
+	return apply_filters('includes_url', $url, $path);
+}
+
+/**
+ * Retrieve the url to the content directory.
+ *
+ * @package WordPress
+ * @since 2.6.0
+ *
+ * @param string $path Optional. Path relative to the content url.
+ * @return string Content url link with optional path appended.
+*/
+function content_url($path = '') {
+	$url = WP_CONTENT_URL;
+	if ( 0 === strpos($url, 'http') && is_ssl() )
+		$url = str_replace( 'http://', 'https://', $url );
+
+	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+		$url .= '/' . ltrim($path, '/');
+
+	return apply_filters('content_url', $url, $path);
+}
+
+/**
+ * Retrieve the url to the plugins directory or to a specific file within that directory.
+ * You can hardcode the plugin slug in $path or pass __FILE__ as a second argument to get the correct folder name.
+ *
+ * @package WordPress
+ * @since 2.6.0
+ *
+ * @param string $path Optional. Path relative to the plugins url.
+ * @param string $plugin Optional. The plugin file that you want to be relative to - i.e. pass in __FILE__
+ * @return string Plugins url link with optional path appended.
+*/
+function plugins_url($path = '', $plugin = '') {
+
+	$mu_plugin_dir = WPMU_PLUGIN_DIR;
+	foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) {
+		$$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs
+		$$var = preg_replace('|/+|', '/', $$var);
+	}
+
+	if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) )
+		$url = WPMU_PLUGIN_URL;
+	else
+		$url = WP_PLUGIN_URL;
+
+	if ( 0 === strpos($url, 'http') && is_ssl() )
+		$url = str_replace( 'http://', 'https://', $url );
+
+	if ( !empty($plugin) && is_string($plugin) ) {
+		$folder = dirname(plugin_basename($plugin));
+		if ( '.' != $folder )
+			$url .= '/' . ltrim($folder, '/');
+	}
+
+	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+		$url .= '/' . ltrim($path, '/');
+
+	return apply_filters('plugins_url', $url, $path, $plugin);
+}
+
+/**
+ * Retrieve the site url for the current network.
+ *
+ * Returns the site url with the appropriate protocol,  'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @param string $path Optional. Path relative to the site url.
+ * @param string $scheme Optional. Scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'.
+ * @return string Site url link with optional path appended.
+*/
+function network_site_url( $path = '', $scheme = null ) {
+	global $current_site;
+
+	if ( !is_multisite() )
+		return site_url($path, $scheme);
+
+	$orig_scheme = $scheme;
+	if ( !in_array($scheme, array('http', 'https')) ) {
+		if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
+			$scheme = 'https';
+		elseif ( ('login' == $scheme) && ( force_ssl_admin() ) )
+			$scheme = 'https';
+		elseif ( ('admin' == $scheme) && force_ssl_admin() )
+			$scheme = 'https';
+		else
+			$scheme = ( is_ssl() ? 'https' : 'http' );
+	}
+
+	$url = $scheme . '://' . $current_site->domain . $current_site->path;
+
+	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+		$url .= ltrim($path, '/');
+
+	return apply_filters('network_site_url', $url, $path, $orig_scheme);
+}
+
+/**
+ * Retrieve the home url for the current network.
+ *
+ * Returns the home url with the appropriate protocol,  'https' if
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
+ * overridden.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @param  string $path   (optional) Path relative to the home url.
+ * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
+ * @return string Home url link with optional path appended.
+*/
+function network_home_url( $path = '', $scheme = null ) {
+	global $current_site;
+
+	if ( !is_multisite() )
+		return home_url($path, $scheme);
+
+	$orig_scheme = $scheme;
+
+	if ( !in_array($scheme, array('http', 'https')) )
+		$scheme = is_ssl() && !is_admin() ? 'https' : 'http';
+
+	$url = $scheme . '://' . $current_site->domain . $current_site->path;
+
+	if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+		$url .= ltrim( $path, '/' );
+
+	return apply_filters( 'network_home_url', $url, $path, $orig_scheme);
+}
+
+/**
+ * Retrieve the url to the admin area for the network.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @param string $path Optional path relative to the admin url
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Admin url link with optional path appended
+*/
+function network_admin_url( $path = '', $scheme = 'admin' ) {
+	if ( ! is_multisite() )
+		return admin_url( $path, $scheme );
+
+	$url = network_site_url('wp-admin/network/', $scheme);
+
+	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+		$url .= ltrim($path, '/');
+
+	return apply_filters('network_admin_url', $url, $path);
+}
+
+/**
+ * Retrieve the url to the admin area for the current user.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ *
+ * @param string $path Optional path relative to the admin url
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Admin url link with optional path appended
+*/
+function user_admin_url( $path = '', $scheme = 'admin' ) {
+	$url = network_site_url('wp-admin/user/', $scheme);
+
+	if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+		$url .= ltrim($path, '/');
+
+	return apply_filters('user_admin_url', $url, $path);
+}
+
+/**
+ * Retrieve the url to the admin area for either the current blog or the network depending on context.
+ *
+ * @package WordPress
+ * @since 3.1.0
+ *
+ * @param string $path Optional path relative to the admin url
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Admin url link with optional path appended
+*/
+function self_admin_url($path = '', $scheme = 'admin') {
+	if ( is_network_admin() )
+		return network_admin_url($path, $scheme);
+	elseif ( is_user_admin() )
+		return user_admin_url($path, $scheme);
+	else
+		return admin_url($path, $scheme);
+}
+
+/**
+ * Get the URL to the user's dashboard.
+ *
+ * If a user does not belong to any sites, the global user dashboard is used.  If the user belongs to the current site,
+ * the dashboard for the current site is returned.  If the user cannot edit the current site, the dashboard to the user's
+ * primary blog is returned.
+ *
+ * @since 3.1.0
+ *
+ * @param int $user_id User ID
+ * @param string $path Optional path relative to the dashboard.  Use only paths known to both blog and user admins.
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Dashboard url link with optional path appended
+ */
+function get_dashboard_url( $user_id, $path = '', $scheme = 'admin' ) {
+	$user_id = (int) $user_id;
+
+	$blogs = get_blogs_of_user( $user_id );
+	if ( empty($blogs) ) {
+		$url = user_admin_url( $path, $scheme );
+	} elseif ( ! is_multisite() ) {
+		$url = admin_url( $path, $scheme );
+	} else {
+		$current_blog = get_current_blog_id();
+		if ( $current_blog  && in_array($current_blog, array_keys($blogs)) ) {
+			$url = admin_url( $path, $scheme );
+		} else {
+			$active = get_active_blog_for_user( $user_id );
+			if ( $active )
+				$url = get_admin_url( $active->blog_id, $path, $scheme );
+			else
+				$url = user_admin_url( $path, $scheme );
+		}
+	}
+
+	return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme);
+}
+
+/**
+ * Get the URL to the user's profile editor.
+ *
+ * @since 3.1.0
+ *
+ * @param int $user User ID
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Dashboard url link with optional path appended
+ */
+function get_edit_profile_url( $user, $scheme = 'admin' ) {
+	$user = (int) $user;
+
+	if ( is_user_admin() )
+		$url = user_admin_url( 'profile.php', $scheme );
+	elseif ( is_network_admin() )
+		$url = network_admin_url( 'profile.php', $scheme );
+	else
+		$url = get_dashboard_url( $user, 'profile.php', $scheme );
+
+	return apply_filters( 'edit_profile_url', $url, $user, $scheme);
+}
+
+/**
+ * Output rel=canonical for singular queries
+ *
+ * @package WordPress
+ * @since 2.9.0
+*/
+function rel_canonical() {
+	if ( !is_singular() )
+		return;
+
+	global $wp_the_query;
+	if ( !$id = $wp_the_query->get_queried_object_id() )
+		return;
+
+	$link = get_permalink( $id );
+	echo "<link rel='canonical' href='$link' />\n";
+}
+
+/**
+ * Return a shortlink for a post, page, attachment, or blog.
+ *
+ * This function exists to provide a shortlink tag that all themes and plugins can target.  A plugin must hook in to
+ * provide the actual shortlinks.  Default shortlink support is limited to providing ?p= style links for posts.
+ * Plugins can short circuit this function via the pre_get_shortlink filter or filter the output
+ * via the get_shortlink filter.
+ *
+ * @since 3.0.0.
+ *
+ * @param int $id A post or blog id.  Default is 0, which means the current post or blog.
+ * @param string $context Whether the id is a 'blog' id, 'post' id, or 'media' id. If 'post', the post_type of the post is consulted. If 'query', the current query is consulted to determine the id and context. Default is 'post'.
+ * @param bool $allow_slugs Whether to allow post slugs in the shortlink. It is up to the plugin how and whether to honor this.
+ * @return string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks are not enabled.
+ */
+function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) {
+	// Allow plugins to short-circuit this function.
+	$shortlink = apply_filters('pre_get_shortlink', false, $id, $context, $allow_slugs);
+	if ( false !== $shortlink )
+		return $shortlink;
+
+	global $wp_query;
+	$post_id = 0;
+	if ( 'query' == $context && is_single() ) {
+		$post_id = $wp_query->get_queried_object_id();
+	} elseif ( 'post' == $context ) {
+		$post = get_post($id);
+		$post_id = $post->ID;
+	}
+
+	$shortlink = '';
+
+	// Return p= link for posts.
+	if ( !empty($post_id) && '' != get_option('permalink_structure') ) {
+		$post = get_post($post_id);
+		if ( isset($post->post_type) && 'post' == $post->post_type )
+			$shortlink = home_url('?p=' . $post->ID);
+	}
+
+	return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs);
+}
+
+/**
+ *  Inject rel=sortlink into head if a shortlink is defined for the current page.
+ *
+ *  Attached to the wp_head action.
+ *
+ * @since 3.0.0
+ *
+ * @uses wp_get_shortlink()
+ */
+function wp_shortlink_wp_head() {
+	$shortlink = wp_get_shortlink( 0, 'query' );
+
+	if ( empty( $shortlink ) )
+		return;
+
+	echo "<link rel='shortlink' href='" . esc_url_raw( $shortlink ) . "' />\n";
+}
+
+/**
+ * Send a Link: rel=shortlink header if a shortlink is defined for the current page.
+ *
+ * Attached to the wp action.
+ *
+ * @since 3.0.0
+ *
+ * @uses wp_get_shortlink()
+ */
+function wp_shortlink_header() {
+	if ( headers_sent() )
+		return;
+
+	$shortlink = wp_get_shortlink(0, 'query');
+
+	if ( empty($shortlink) )
+		return;
+
+	header('Link: <' . $shortlink . '>; rel=shortlink', false);
+}
+
+/**
+ * Display the Short Link for a Post
+ *
+ * Must be called from inside "The Loop"
+ *
+ * Call like the_shortlink(__('Shortlinkage FTW'))
+ *
+ * @since 3.0.0
+ *
+ * @param string $text Optional The link text or HTML to be displayed.  Defaults to 'This is the short link.'
+ * @param string $title Optional The tooltip for the link.  Must be sanitized.  Defaults to the sanitized post title.
+ * @param string $before Optional HTML to display before the link.
+ * @param string $before Optional HTML to display after the link.
+ */
+function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
+	global $post;
+
+	if ( empty( $text ) )
+		$text = __('This is the short link.');
+
+	if ( empty( $title ) )
+		$title = the_title_attribute( array( 'echo' => FALSE ) );
+
+	$shortlink = wp_get_shortlink( $post->ID );
+
+	if ( !empty( $shortlink ) ) {
+		$link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>';
+		$link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title );
+		echo $before, $link, $after;
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/load.php
===================================================================
--- /tags/3.1/wp-includes/load.php	(revision 17487)
+++ /tags/3.1/wp-includes/load.php	(revision 17487)
@@ -0,0 +1,653 @@
+<?php
+/**
+ * These functions are needed to load WordPress.
+ *
+ * @package WordPress
+ */
+
+/**
+ * Turn register globals off.
+ *
+ * @access private
+ * @since 2.1.0
+ * @return null Will return null if register_globals PHP directive was disabled
+ */
+function wp_unregister_GLOBALS() {
+	if ( !ini_get( 'register_globals' ) )
+		return;
+
+	if ( isset( $_REQUEST['GLOBALS'] ) )
+		die( /*WP_I18N_GLOBALS_OVERWRITE*/'GLOBALS overwrite attempt detected'/*/WP_I18N_GLOBALS_OVERWRITE*/ );
+
+	// Variables that shouldn't be unset
+	$no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
+
+	$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
+	foreach ( $input as $k => $v )
+		if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) {
+			$GLOBALS[$k] = null;
+			unset( $GLOBALS[$k] );
+		}
+}
+
+/**
+ * Fix $_SERVER variables for various setups.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_fix_server_vars() {
+	global $PHP_SELF;
+
+	$default_server_values = array(
+		'SERVER_SOFTWARE' => '',
+		'REQUEST_URI' => '',
+	);
+
+	$_SERVER = array_merge( $default_server_values, $_SERVER );
+
+	// Fix for IIS when running with PHP ISAPI
+	if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
+
+		// IIS Mod-Rewrite
+		if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
+			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
+		}
+		// IIS Isapi_Rewrite
+		else if ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
+			$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
+		} else {
+			// Use ORIG_PATH_INFO if there is no PATH_INFO
+			if ( !isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )
+				$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
+
+			// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
+			if ( isset( $_SERVER['PATH_INFO'] ) ) {
+				if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
+					$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
+				else
+					$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
+			}
+
+			// Append the query string if it exists and isn't null
+			if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
+				$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
+			}
+		}
+	}
+
+	// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
+	if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) )
+		$_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
+
+	// Fix for Dreamhost and other PHP as CGI hosts
+	if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false )
+		unset( $_SERVER['PATH_INFO'] );
+
+	// Fix empty PHP_SELF
+	$PHP_SELF = $_SERVER['PHP_SELF'];
+	if ( empty( $PHP_SELF ) )
+		$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] );
+}
+
+/**
+ * Check for the required PHP version, and the MySQL extension or a database drop-in.
+ *
+ * Dies if requirements are not met.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_check_php_mysql_versions() {
+	// we can probably extend this function to check if wp_die() exists then use translated strings, and then use it in install.php etc.
+
+	global $required_php_version, $wp_version;
+	$php_version = phpversion();
+	if ( version_compare( $required_php_version, $php_version, '>' ) )
+		die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.'/*/WP_I18N_OLD_PHP*/, $php_version, $wp_version, $required_php_version ) );
+
+	if ( !extension_loaded( 'mysql' ) && !file_exists( WP_CONTENT_DIR . '/db.php' ) )
+		die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ );
+}
+
+/**
+ * Don't load all of WordPress when handling a favicon.ico request.
+ * Instead, send the headers for a zero-length favicon and bail.
+ *
+ * @since 3.0.0
+ */
+function wp_favicon_request() {
+	if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
+		header('Content-Type: image/vnd.microsoft.icon');
+		header('Content-Length: 0');
+		exit;
+	}
+}
+
+/**
+ * Dies with a maintenance message when conditions are met.
+ *
+ * Checks for a file in the WordPress root directory named ".maintenance".
+ * This file will contain the variable $upgrading, set to the time the file
+ * was created. If the file was created less than 10 minutes ago, WordPress
+ * enters maintenance mode and displays a message.
+ *
+ * The default message can be replaced by using a drop-in (maintenance.php in
+ * the wp-content directory).
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_maintenance() {
+	if ( !file_exists( ABSPATH . '.maintenance' ) || defined( 'WP_INSTALLING' ) )
+		return;
+
+	global $upgrading;
+
+	include( ABSPATH . '.maintenance' );
+	// If the $upgrading timestamp is older than 10 minutes, don't die.
+	if ( ( time() - $upgrading ) >= 600 )
+		return;
+
+	if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
+		require_once( WP_CONTENT_DIR . '/maintenance.php' );
+		die();
+	}
+
+	$protocol = $_SERVER["SERVER_PROTOCOL"];
+	if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
+		$protocol = 'HTTP/1.0';
+	header( "$protocol 503 Service Unavailable", true, 503 );
+	header( 'Content-Type: text/html; charset=utf-8' );
+	header( 'Retry-After: 600' );
+?>
+	<!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>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+		<title><?php echo /*WP_I18N_MAINTENANCE*/'Maintenance'/*/WP_I18N_MAINTENANCE*/; ?></title>
+
+	</head>
+	<body>
+		<h1><?php echo /*WP_I18N_MAINT_MSG*/'Briefly unavailable for scheduled maintenance. Check back in a minute.'/*/WP_I18N_MAINT_MSG*/; ?></h1>
+	</body>
+	</html>
+<?php
+	die();
+}
+
+/**
+ * PHP 4 standard microtime start capture.
+ *
+ * @access private
+ * @since 0.71
+ * @global int $timestart Seconds and Microseconds added together from when function is called.
+ * @return bool Always returns true.
+ */
+function timer_start() {
+	global $timestart;
+	$mtime = explode( ' ', microtime() );
+	$timestart = $mtime[1] + $mtime[0];
+	return true;
+}
+
+/**
+ * Return and/or display the time from the page start to when function is called.
+ *
+ * You can get the results and print them by doing:
+ * <code>
+ * $nTimePageTookToExecute = timer_stop();
+ * echo $nTimePageTookToExecute;
+ * </code>
+ *
+ * Or instead, you can do:
+ * <code>
+ * timer_stop(1);
+ * </code>
+ * which will do what the above does. If you need the result, you can assign it to a variable, but
+ * most cases, you only need to echo it.
+ *
+ * @since 0.71
+ * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
+ * @global int $timeend  Seconds and Microseconds added together from when function is called
+ *
+ * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
+ * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
+ * @return float The "second.microsecond" finished time calculation
+ */
+function timer_stop( $display = 0, $precision = 3 ) { // if called like timer_stop(1), will echo $timetotal
+	global $timestart, $timeend;
+	$mtime = microtime();
+	$mtime = explode( ' ', $mtime );
+	$timeend = $mtime[1] + $mtime[0];
+	$timetotal = $timeend - $timestart;
+	$r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
+	if ( $display )
+		echo $r;
+	return $r;
+}
+
+/**
+ * Sets PHP error handling and handles WordPress debug mode.
+ *
+ * Uses three constants: WP_DEBUG, WP_DEBUG_DISPLAY, and WP_DEBUG_LOG. All three can be
+ * defined in wp-config.php. Example: <code> define( 'WP_DEBUG', true ); </code>
+ *
+ * WP_DEBUG_DISPLAY and WP_DEBUG_LOG perform no function unless WP_DEBUG is true.
+ * WP_DEBUG defaults to false.
+ *
+ * When WP_DEBUG is true, all PHP notices are reported. WordPress will also display
+ * notices, including one when a deprecated WordPress function, function argument,
+ * or file is used. Deprecated code may be removed from a later version.
+ *
+ * It is strongly recommended that plugin and theme developers use WP_DEBUG in their
+ * development environments.
+ *
+ * When WP_DEBUG_DISPLAY is true, WordPress will force errors to be displayed.
+ * WP_DEBUG_DISPLAY defaults to true. Defining it as false prevents WordPress from
+ * changing the global configuration setting. (Defining WP_DEBUG_DISPLAY as false
+ * will never force errors to be hidden.)
+ *
+ * When WP_DEBUG_LOG is true, errors will be logged to wp-content/debug.log.
+ * WP_DEBUG_LOG defaults to false.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_debug_mode() {
+	if ( WP_DEBUG ) {
+		// E_DEPRECATED is a core PHP constant in PHP 5.3. Don't define this yourself.
+		// The two statements are equivalent, just one is for 5.3+ and for less than 5.3.
+		if ( defined( 'E_DEPRECATED' ) )
+			error_reporting( E_ALL & ~E_DEPRECATED & ~E_STRICT );
+		else
+			error_reporting( E_ALL );
+
+		if ( WP_DEBUG_DISPLAY )
+			ini_set( 'display_errors', 1 );
+
+		if ( WP_DEBUG_LOG ) {
+			ini_set( 'log_errors', 1 );
+			ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
+		}
+	} else {
+		if ( defined( 'E_RECOVERABLE_ERROR' ) )
+			error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
+		else
+			error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING );
+	}
+}
+
+/**
+ * Sets the location of the language directory.
+ *
+ * To set directory manually, define <code>WP_LANG_DIR</code> in wp-config.php.
+ *
+ * First looks for language folder in WP_CONTENT_DIR and uses that folder if it
+ * exists. Or it uses the "languages" folder in WPINC.
+ *
+ * The WP_LANG_DIR constant was introduced in 2.1.0.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_set_lang_dir() {
+	if ( !defined( 'WP_LANG_DIR' ) ) {
+		if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) {
+			define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
+			if ( !defined( 'LANGDIR' ) ) {
+				// Old static relative path maintained for limited backwards compatibility - won't work in some cases
+				define( 'LANGDIR', 'wp-content/languages' );
+			}
+		} else {
+			define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
+			if ( !defined( 'LANGDIR' ) ) {
+				// Old relative path maintained for backwards compatibility
+				define( 'LANGDIR', WPINC . '/languages' );
+			}
+		}
+	}
+}
+
+/**
+ * Load the correct database class file.
+ *
+ * This function is used to load the database class file either at runtime or by
+ * wp-admin/setup-config.php. We must globalize $wpdb to ensure that it is
+ * defined globally by the inline code in wp-db.php.
+ *
+ * @since 2.5.0
+ * @global $wpdb WordPress Database Object
+ */
+function require_wp_db() {
+	global $wpdb;
+
+	require_once( ABSPATH . WPINC . '/wp-db.php' );
+	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
+		require_once( WP_CONTENT_DIR . '/db.php' );
+
+	if ( isset( $wpdb ) )
+		return;
+
+	$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
+}
+
+/**
+ * Sets the database table prefix and the format specifiers for database table columns.
+ *
+ * Columns not listed here default to %s.
+ *
+ * @see wpdb::$field_types Since 2.8.0
+ * @see wpdb::prepare()
+ * @see wpdb::insert()
+ * @see wpdb::update()
+ * @see wpdb::set_prefix()
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_set_wpdb_vars() {
+	global $wpdb, $table_prefix;
+	if ( !empty( $wpdb->error ) )
+		dead_db();
+
+	$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
+		'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
+		'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
+		'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
+		// multisite:
+		'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
+	);
+
+	$prefix = $wpdb->set_prefix( $table_prefix );
+
+	if ( is_wp_error( $prefix ) )
+		wp_die( /*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ );
+}
+
+/**
+ * Starts the WordPress object cache.
+ *
+ * If an object-cache.php file exists in the wp-content directory,
+ * it uses that drop-in as an external object cache.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_start_object_cache() {
+	global $_wp_using_ext_object_cache;
+
+	$first_init = false;
+ 	if ( ! function_exists( 'wp_cache_init' ) ) {
+		if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
+			require_once ( WP_CONTENT_DIR . '/object-cache.php' );
+			$_wp_using_ext_object_cache = true;
+		} else {
+			require_once ( ABSPATH . WPINC . '/cache.php' );
+			$_wp_using_ext_object_cache = false;
+		}
+		$first_init = true;
+	} else if ( !$_wp_using_ext_object_cache && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
+		// Sometimes advanced-cache.php can load object-cache.php before it is loaded here.
+		// This breaks the function_exists check above and can result in $_wp_using_ext_object_cache
+		// being set incorrectly.  Double check if an external cache exists.
+		$_wp_using_ext_object_cache = true;
+	}
+
+	// If cache supports reset, reset instead of init if already initialized.
+	// Reset signals to the cache that global IDs have changed and it may need to update keys
+	// and cleanup caches.
+	if ( !$first_init && function_exists('wp_cache_reset') )
+		wp_cache_reset();
+	else
+		wp_cache_init();
+
+	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
+		wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );
+		wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
+	}
+}
+
+/**
+ * Redirects to the installer if WordPress is not installed.
+ *
+ * Dies with an error message when multisite is enabled.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_not_installed() {
+	if ( is_multisite() ) {
+		if ( ! is_blog_installed() && ! defined( 'WP_INSTALLING' ) )
+			wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
+	} elseif ( ! is_blog_installed() && false === strpos( $_SERVER['PHP_SELF'], 'install.php' ) && !defined( 'WP_INSTALLING' ) ) {
+
+		$link = wp_guess_url() . '/wp-admin/install.php';
+
+		require( ABSPATH . WPINC . '/kses.php' );
+		require( ABSPATH . WPINC . '/pluggable.php' );
+		require( ABSPATH . WPINC . '/formatting.php' );
+		wp_redirect( $link );
+		die();
+	}
+}
+
+/**
+ * Returns array of must-use plugin files to be included in global scope.
+ *
+ * The default directory is wp-content/mu-plugins. To change the default directory
+ * manually, define <code>WPMU_PLUGIN_DIR</code> and <code>WPMU_PLUGIN_URL</code>
+ * in wp-config.php.
+ *
+ * @access private
+ * @since 3.0.0
+ * @return array Files to include
+ */
+function wp_get_mu_plugins() {
+	$mu_plugins = array();
+	if ( !is_dir( WPMU_PLUGIN_DIR ) )
+		return $mu_plugins;
+	if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) )
+		return $mu_plugins;
+	while ( ( $plugin = readdir( $dh ) ) !== false ) {
+		if ( substr( $plugin, -4 ) == '.php' )
+			$mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin;
+	}
+	closedir( $dh );
+	sort( $mu_plugins );
+
+	return $mu_plugins;
+}
+
+/**
+ * Returns array of plugin files to be included in global scope.
+ *
+ * The default directory is wp-content/plugins. To change the default directory
+ * manually, define <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
+ * in wp-config.php.
+ *
+ * @access private
+ * @since 3.0.0
+ * @return array Files to include
+ */
+function wp_get_active_and_valid_plugins() {
+	$plugins = array();
+	$active_plugins = (array) get_option( 'active_plugins', array() );
+
+	// Check for hacks file if the option is enabled
+	if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) {
+		_deprecated_file( 'my-hacks.php', '1.5' );
+		array_unshift( $plugins, ABSPATH . 'my-hacks.php' );
+	}
+
+	if ( empty( $active_plugins ) || defined( 'WP_INSTALLING' ) )
+		return $plugins;
+
+	$network_plugins = is_multisite() ? wp_get_active_network_plugins() : false;
+
+	foreach ( $active_plugins as $plugin ) {
+		if ( ! validate_file( $plugin ) // $plugin must validate as file
+			&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
+			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
+			// not already included as a network plugin
+			&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
+			)
+		$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
+	}
+	return $plugins;
+}
+
+/**
+ * Sets internal encoding using mb_internal_encoding().
+ *
+ * In most cases the default internal encoding is latin1, which is of no use,
+ * since we want to use the mb_ functions for utf-8 strings.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_set_internal_encoding() {
+	if ( function_exists( 'mb_internal_encoding' ) ) {
+		if ( !@mb_internal_encoding( get_option( 'blog_charset' ) ) )
+			mb_internal_encoding( 'UTF-8' );
+	}
+}
+
+/**
+ * Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
+ *
+ * Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
+ * or $_ENV are needed, use those superglobals directly.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function wp_magic_quotes() {
+	// If already slashed, strip.
+	if ( get_magic_quotes_gpc() ) {
+		$_GET    = stripslashes_deep( $_GET    );
+		$_POST   = stripslashes_deep( $_POST   );
+		$_COOKIE = stripslashes_deep( $_COOKIE );
+	}
+
+	// Escape with wpdb.
+	$_GET    = add_magic_quotes( $_GET    );
+	$_POST   = add_magic_quotes( $_POST   );
+	$_COOKIE = add_magic_quotes( $_COOKIE );
+	$_SERVER = add_magic_quotes( $_SERVER );
+
+	// Force REQUEST to be GET + POST.
+	$_REQUEST = array_merge( $_GET, $_POST );
+}
+
+/**
+ * Runs just before PHP shuts down execution.
+ *
+ * @access private
+ * @since 1.2.0
+ */
+function shutdown_action_hook() {
+	do_action( 'shutdown' );
+	wp_cache_close();
+}
+
+/**
+ * Copy an object.
+ *
+ * Returns a cloned copy of an object.
+ *
+ * @since 2.7.0
+ *
+ * @param object $object The object to clone
+ * @return object The cloned object
+ */
+function wp_clone( $object ) {
+	static $can_clone;
+	if ( !isset( $can_clone ) )
+		$can_clone = version_compare( phpversion(), '5.0', '>=' );
+
+	return $can_clone ? clone( $object ) : $object;
+}
+
+/**
+ * Whether the current request is for a network or blog admin page
+ *
+ * Does not inform on whether the user is an admin! Use capability checks to
+ * tell if the user should be accessing a section or not.
+ *
+ * @since 1.5.1
+ *
+ * @return bool True if inside WordPress administration pages.
+ */
+function is_admin() {
+	if ( defined( 'WP_ADMIN' ) )
+		return WP_ADMIN;
+	return false;
+}
+
+/**
+ * Whether the current request is for a blog admin screen /wp-admin/
+ *
+ * Does not inform on whether the user is a blog admin! Use capability checks to
+ * tell if the user should be accessing a section or not.
+ *
+ * @since 3.1.0
+ *
+ * @return bool True if inside WordPress network administration pages.
+ */
+function is_blog_admin() {
+	if ( defined( 'WP_BLOG_ADMIN' ) )
+		return WP_BLOG_ADMIN;
+	return false;
+}
+
+/**
+ * Whether the current request is for a network admin screen /wp-admin/network/
+ *
+ * Does not inform on whether the user is a network admin! Use capability checks to
+ * tell if the user should be accessing a section or not.
+ *
+ * @since 3.1.0
+ *
+ * @return bool True if inside WordPress network administration pages.
+ */
+function is_network_admin() {
+	if ( defined( 'WP_NETWORK_ADMIN' ) )
+		return WP_NETWORK_ADMIN;
+	return false;
+}
+
+/**
+ * Whether the current request is for a user admin screen /wp-admin/user/
+ *
+ * Does not inform on whether the user is an admin! Use capability checks to
+ * tell if the user should be accessing a section or not.
+ *
+ * @since 3.1.0
+ *
+ * @return bool True if inside WordPress user administration pages.
+ */
+function is_user_admin() {
+	if ( defined( 'WP_USER_ADMIN' ) )
+		return WP_USER_ADMIN;
+	return false;
+}
+
+/**
+ * Whether Multisite support is enabled
+ *
+ * @since 3.0.0
+ *
+ * @return bool True if multisite is enabled, false otherwise.
+ */
+function is_multisite() {
+	if ( defined( 'MULTISITE' ) )
+		return MULTISITE;
+
+	if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
+		return true;
+
+	return false;
+}
+
+?>
Index: /tags/3.1/wp-includes/locale.php
===================================================================
--- /tags/3.1/wp-includes/locale.php	(revision 17487)
+++ /tags/3.1/wp-includes/locale.php	(revision 17487)
@@ -0,0 +1,351 @@
+<?php
+/**
+ * Date and Time Locale object
+ *
+ * @package WordPress
+ * @subpackage i18n
+ */
+
+/**
+ * Class that loads the calendar locale.
+ *
+ * @since 2.1.0
+ */
+class WP_Locale {
+	/**
+	 * Stores the translated strings for the full weekday names.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $weekday;
+
+	/**
+	 * Stores the translated strings for the one character weekday names.
+	 *
+	 * There is a hack to make sure that Tuesday and Thursday, as well
+	 * as Sunday and Saturday don't conflict. See init() method for more.
+	 *
+	 * @see WP_Locale::init() for how to handle the hack.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $weekday_initial;
+
+	/**
+	 * Stores the translated strings for the abbreviated weekday names.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $weekday_abbrev;
+
+	/**
+	 * Stores the translated strings for the full month names.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $month;
+
+	/**
+	 * Stores the translated strings for the abbreviated month names.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $month_abbrev;
+
+	/**
+	 * Stores the translated strings for 'am' and 'pm'.
+	 *
+	 * Also the capalized versions.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $meridiem;
+
+	/**
+	 * The text direction of the locale language.
+	 *
+	 * Default is left to right 'ltr'.
+	 *
+	 * @since 2.1.0
+	 * @var string
+	 * @access private
+	 */
+	var $text_direction = 'ltr';
+
+	/**
+	 * Imports the global version to the class property.
+	 *
+	 * @since 2.1.0
+	 * @var array
+	 * @access private
+	 */
+	var $locale_vars = array('text_direction');
+
+	/**
+	 * Sets up the translated strings and object properties.
+	 *
+	 * The method creates the translatable strings for various
+	 * calendar elements. Which allows for specifying locale
+	 * specific calendar names and text direction.
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 */
+	function init() {
+		// The Weekdays
+		$this->weekday[0] = /* translators: weekday */ __('Sunday');
+		$this->weekday[1] = /* translators: weekday */ __('Monday');
+		$this->weekday[2] = /* translators: weekday */ __('Tuesday');
+		$this->weekday[3] = /* translators: weekday */ __('Wednesday');
+		$this->weekday[4] = /* translators: weekday */ __('Thursday');
+		$this->weekday[5] = /* translators: weekday */ __('Friday');
+		$this->weekday[6] = /* translators: weekday */ __('Saturday');
+
+		// The first letter of each day.  The _%day%_initial suffix is a hack to make
+		// sure the day initials are unique.
+		$this->weekday_initial[__('Sunday')]    = /* translators: one-letter abbreviation of the weekday */ __('S_Sunday_initial');
+		$this->weekday_initial[__('Monday')]    = /* translators: one-letter abbreviation of the weekday */ __('M_Monday_initial');
+		$this->weekday_initial[__('Tuesday')]   = /* translators: one-letter abbreviation of the weekday */ __('T_Tuesday_initial');
+		$this->weekday_initial[__('Wednesday')] = /* translators: one-letter abbreviation of the weekday */ __('W_Wednesday_initial');
+		$this->weekday_initial[__('Thursday')]  = /* translators: one-letter abbreviation of the weekday */ __('T_Thursday_initial');
+		$this->weekday_initial[__('Friday')]    = /* translators: one-letter abbreviation of the weekday */ __('F_Friday_initial');
+		$this->weekday_initial[__('Saturday')]  = /* translators: one-letter abbreviation of the weekday */ __('S_Saturday_initial');
+
+		foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
+			$this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
+		}
+
+		// Abbreviations for each day.
+		$this->weekday_abbrev[__('Sunday')]    = /* translators: three-letter abbreviation of the weekday */ __('Sun');
+		$this->weekday_abbrev[__('Monday')]    = /* translators: three-letter abbreviation of the weekday */ __('Mon');
+		$this->weekday_abbrev[__('Tuesday')]   = /* translators: three-letter abbreviation of the weekday */ __('Tue');
+		$this->weekday_abbrev[__('Wednesday')] = /* translators: three-letter abbreviation of the weekday */ __('Wed');
+		$this->weekday_abbrev[__('Thursday')]  = /* translators: three-letter abbreviation of the weekday */ __('Thu');
+		$this->weekday_abbrev[__('Friday')]    = /* translators: three-letter abbreviation of the weekday */ __('Fri');
+		$this->weekday_abbrev[__('Saturday')]  = /* translators: three-letter abbreviation of the weekday */ __('Sat');
+
+		// The Months
+		$this->month['01'] = /* translators: month name */ __('January');
+		$this->month['02'] = /* translators: month name */ __('February');
+		$this->month['03'] = /* translators: month name */ __('March');
+		$this->month['04'] = /* translators: month name */ __('April');
+		$this->month['05'] = /* translators: month name */ __('May');
+		$this->month['06'] = /* translators: month name */ __('June');
+		$this->month['07'] = /* translators: month name */ __('July');
+		$this->month['08'] = /* translators: month name */ __('August');
+		$this->month['09'] = /* translators: month name */ __('September');
+		$this->month['10'] = /* translators: month name */ __('October');
+		$this->month['11'] = /* translators: month name */ __('November');
+		$this->month['12'] = /* translators: month name */ __('December');
+
+		// Abbreviations for each month. Uses the same hack as above to get around the
+		// 'May' duplication.
+		$this->month_abbrev[__('January')] = /* translators: three-letter abbreviation of the month */ __('Jan_January_abbreviation');
+		$this->month_abbrev[__('February')] = /* translators: three-letter abbreviation of the month */ __('Feb_February_abbreviation');
+		$this->month_abbrev[__('March')] = /* translators: three-letter abbreviation of the month */ __('Mar_March_abbreviation');
+		$this->month_abbrev[__('April')] = /* translators: three-letter abbreviation of the month */ __('Apr_April_abbreviation');
+		$this->month_abbrev[__('May')] = /* translators: three-letter abbreviation of the month */ __('May_May_abbreviation');
+		$this->month_abbrev[__('June')] = /* translators: three-letter abbreviation of the month */ __('Jun_June_abbreviation');
+		$this->month_abbrev[__('July')] = /* translators: three-letter abbreviation of the month */ __('Jul_July_abbreviation');
+		$this->month_abbrev[__('August')] = /* translators: three-letter abbreviation of the month */ __('Aug_August_abbreviation');
+		$this->month_abbrev[__('September')] = /* translators: three-letter abbreviation of the month */ __('Sep_September_abbreviation');
+		$this->month_abbrev[__('October')] = /* translators: three-letter abbreviation of the month */ __('Oct_October_abbreviation');
+		$this->month_abbrev[__('November')] = /* translators: three-letter abbreviation of the month */ __('Nov_November_abbreviation');
+		$this->month_abbrev[__('December')] = /* translators: three-letter abbreviation of the month */ __('Dec_December_abbreviation');
+
+		foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
+			$this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
+		}
+
+		// The Meridiems
+		$this->meridiem['am'] = __('am');
+		$this->meridiem['pm'] = __('pm');
+		$this->meridiem['AM'] = __('AM');
+		$this->meridiem['PM'] = __('PM');
+
+		// Numbers formatting
+		// See http://php.net/number_format
+
+		/* translators: $thousands_sep argument for http://php.net/number_format, default is , */
+		$trans = __('number_format_thousands_sep');
+		$this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
+
+		/* translators: $dec_point argument for http://php.net/number_format, default is . */
+		$trans = __('number_format_decimal_point');
+		$this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
+
+		// Import global locale vars set during inclusion of $locale.php.
+		foreach ( (array) $this->locale_vars as $var ) {
+			if ( isset($GLOBALS[$var]) )
+				$this->$var = $GLOBALS[$var];
+		}
+
+	}
+
+	/**
+	 * Retrieve the full translated weekday word.
+	 *
+	 * Week starts on translated Sunday and can be fetched
+	 * by using 0 (zero). So the week starts with 0 (zero)
+	 * and ends on Saturday with is fetched by using 6 (six).
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param int $weekday_number 0 for Sunday through 6 Saturday
+	 * @return string Full translated weekday
+	 */
+	function get_weekday($weekday_number) {
+		return $this->weekday[$weekday_number];
+	}
+
+	/**
+	 * Retrieve the translated weekday initial.
+	 *
+	 * The weekday initial is retrieved by the translated
+	 * full weekday word. When translating the weekday initial
+	 * pay attention to make sure that the starting letter does
+	 * not conflict.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string $weekday_name
+	 * @return string
+	 */
+	function get_weekday_initial($weekday_name) {
+		return $this->weekday_initial[$weekday_name];
+	}
+
+	/**
+	 * Retrieve the translated weekday abbreviation.
+	 *
+	 * The weekday abbreviation is retrieved by the translated
+	 * full weekday word.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string $weekday_name Full translated weekday word
+	 * @return string Translated weekday abbreviation
+	 */
+	function get_weekday_abbrev($weekday_name) {
+		return $this->weekday_abbrev[$weekday_name];
+	}
+
+	/**
+	 * Retrieve the full translated month by month number.
+	 *
+	 * The $month_number parameter has to be a string
+	 * because it must have the '0' in front of any number
+	 * that is less than 10. Starts from '01' and ends at
+	 * '12'.
+	 *
+	 * You can use an integer instead and it will add the
+	 * '0' before the numbers less than 10 for you.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string|int $month_number '01' through '12'
+	 * @return string Translated full month name
+	 */
+	function get_month($month_number) {
+		return $this->month[zeroise($month_number, 2)];
+	}
+
+	/**
+	 * Retrieve translated version of month abbreviation string.
+	 *
+	 * The $month_name parameter is expected to be the translated or
+	 * translatable version of the month.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string $month_name Translated month to get abbreviated version
+	 * @return string Translated abbreviated month
+	 */
+	function get_month_abbrev($month_name) {
+		return $this->month_abbrev[$month_name];
+	}
+
+	/**
+	 * Retrieve translated version of meridiem string.
+	 *
+	 * The $meridiem parameter is expected to not be translated.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version.
+	 * @return string Translated version
+	 */
+	function get_meridiem($meridiem) {
+		return $this->meridiem[$meridiem];
+	}
+
+	/**
+	 * Global variables are deprecated. For backwards compatibility only.
+	 *
+	 * @deprecated For backwards compatibility only.
+	 * @access private
+	 *
+	 * @since 2.1.0
+	 */
+	function register_globals() {
+		$GLOBALS['weekday']         = $this->weekday;
+		$GLOBALS['weekday_initial'] = $this->weekday_initial;
+		$GLOBALS['weekday_abbrev']  = $this->weekday_abbrev;
+		$GLOBALS['month']           = $this->month;
+		$GLOBALS['month_abbrev']    = $this->month_abbrev;
+	}
+
+	/**
+	 * PHP4 style constructor which calls helper methods to set up object variables
+	 *
+	 * @uses WP_Locale::init()
+	 * @uses WP_Locale::register_globals()
+	 * @since 2.1.0
+	 *
+	 * @return WP_Locale
+	 */
+	function WP_Locale() {
+		$this->init();
+		$this->register_globals();
+	}
+	/**
+	 * Checks if current locale is RTL.
+	 *
+	 * @since 3.0.0
+	 * @return bool Whether locale is RTL.
+	 */
+	 function is_rtl() {
+	 	return 'rtl' == $this->text_direction;
+	 }
+}
+
+/**
+ * Checks if current locale is RTL.
+ *
+ * @since 3.0.0
+ * @return bool Whether locale is RTL.
+ */
+function is_rtl() {
+	global $wp_locale;
+	return $wp_locale->is_rtl();
+}
+
+?>
Index: /tags/3.1/wp-includes/media.php
===================================================================
--- /tags/3.1/wp-includes/media.php	(revision 17487)
+++ /tags/3.1/wp-includes/media.php	(revision 17487)
@@ -0,0 +1,1408 @@
+<?php
+/**
+ * WordPress API for media display.
+ *
+ * @package WordPress
+ */
+
+/**
+ * Scale down the default size of an image.
+ *
+ * This is so that the image is a better fit for the editor and theme.
+ *
+ * The $size parameter accepts either an array or a string. The supported string
+ * values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
+ * 128 width and 96 height in pixels. Also supported for the string value is
+ * 'medium' and 'full'. The 'full' isn't actually supported, but any value other
+ * than the supported will result in the content_width size or 500 if that is
+ * not set.
+ *
+ * Finally, there is a filter named, 'editor_max_image_size' that will be called
+ * on the calculated array for width and height, respectively. The second
+ * parameter will be the value that was in the $size parameter. The returned
+ * type for the hook is an array with the width as the first element and the
+ * height as the second element.
+ *
+ * @since 2.5.0
+ * @uses wp_constrain_dimensions() This function passes the widths and the heights.
+ *
+ * @param int $width Width of the image
+ * @param int $height Height of the image
+ * @param string|array $size Size of what the result image should be.
+ * @return array Width and height of what the result image should resize to.
+ */
+function image_constrain_size_for_editor($width, $height, $size = 'medium') {
+	global $content_width, $_wp_additional_image_sizes;
+
+	if ( is_array($size) ) {
+		$max_width = $size[0];
+		$max_height = $size[1];
+	}
+	elseif ( $size == 'thumb' || $size == 'thumbnail' ) {
+		$max_width = intval(get_option('thumbnail_size_w'));
+		$max_height = intval(get_option('thumbnail_size_h'));
+		// last chance thumbnail size defaults
+		if ( !$max_width && !$max_height ) {
+			$max_width = 128;
+			$max_height = 96;
+		}
+	}
+	elseif ( $size == 'medium' ) {
+		$max_width = intval(get_option('medium_size_w'));
+		$max_height = intval(get_option('medium_size_h'));
+		// if no width is set, default to the theme content width if available
+	}
+	elseif ( $size == 'large' ) {
+		// we're inserting a large size image into the editor.  if it's a really
+		// big image we'll scale it down to fit reasonably within the editor
+		// itself, and within the theme's content width if it's known.  the user
+		// can resize it in the editor if they wish.
+		$max_width = intval(get_option('large_size_w'));
+		$max_height = intval(get_option('large_size_h'));
+		if ( intval($content_width) > 0 )
+			$max_width = min( intval($content_width), $max_width );
+	} elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {
+		$max_width = intval( $_wp_additional_image_sizes[$size]['width'] );
+		$max_height = intval( $_wp_additional_image_sizes[$size]['height'] );
+		if ( intval($content_width) > 0 && is_admin() ) // Only in admin. Assume that theme authors know what they're doing.
+			$max_width = min( intval($content_width), $max_width );
+	}
+	// $size == 'full' has no constraint
+	else {
+		$max_width = $width;
+		$max_height = $height;
+	}
+
+	list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size );
+
+	return wp_constrain_dimensions( $width, $height, $max_width, $max_height );
+}
+
+/**
+ * Retrieve width and height attributes using given width and height values.
+ *
+ * Both attributes are required in the sense that both parameters must have a
+ * value, but are optional in that if you set them to false or null, then they
+ * will not be added to the returned string.
+ *
+ * You can set the value using a string, but it will only take numeric values.
+ * If you wish to put 'px' after the numbers, then it will be stripped out of
+ * the return.
+ *
+ * @since 2.5.0
+ *
+ * @param int|string $width Optional. Width attribute value.
+ * @param int|string $height Optional. Height attribute value.
+ * @return string HTML attributes for width and, or height.
+ */
+function image_hwstring($width, $height) {
+	$out = '';
+	if ($width)
+		$out .= 'width="'.intval($width).'" ';
+	if ($height)
+		$out .= 'height="'.intval($height).'" ';
+	return $out;
+}
+
+/**
+ * Scale an image to fit a particular size (such as 'thumb' or 'medium').
+ *
+ * Array with image url, width, height, and whether is intermediate size, in
+ * that order is returned on success is returned. $is_intermediate is true if
+ * $url is a resized image, false if it is the original.
+ *
+ * The URL might be the original image, or it might be a resized version. This
+ * function won't create a new resized copy, it will just return an already
+ * resized one if it exists.
+ *
+ * A plugin may use the 'image_downsize' filter to hook into and offer image
+ * resizing services for images. The hook must return an array with the same
+ * elements that are returned in the function. The first element being the URL
+ * to the new image that was resized.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'image_downsize' on $id and $size to provide
+ *		resize services.
+ *
+ * @param int $id Attachment ID for image.
+ * @param string $size Optional, default is 'medium'. Size of image, can be 'thumbnail'.
+ * @return bool|array False on failure, array on success.
+ */
+function image_downsize($id, $size = 'medium') {
+
+	if ( !wp_attachment_is_image($id) )
+		return false;
+
+	$img_url = wp_get_attachment_url($id);
+	$meta = wp_get_attachment_metadata($id);
+	$width = $height = 0;
+	$is_intermediate = false;
+	$img_url_basename = wp_basename($img_url);
+
+	// plugins can use this to provide resize services
+	if ( $out = apply_filters('image_downsize', false, $id, $size) )
+		return $out;
+
+	// try for a new style intermediate size
+	if ( $intermediate = image_get_intermediate_size($id, $size) ) {
+		$img_url = str_replace($img_url_basename, $intermediate['file'], $img_url);
+		$width = $intermediate['width'];
+		$height = $intermediate['height'];
+		$is_intermediate = true;
+	}
+	elseif ( $size == 'thumbnail' ) {
+		// fall back to the old thumbnail
+		if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) {
+			$img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url);
+			$width = $info[0];
+			$height = $info[1];
+			$is_intermediate = true;
+		}
+	}
+	if ( !$width && !$height && isset($meta['width'], $meta['height']) ) {
+		// any other type: use the real image
+		$width = $meta['width'];
+		$height = $meta['height'];
+	}
+
+	if ( $img_url) {
+		// we have the actual image size, but might need to further constrain it if content_width is narrower
+		list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
+
+		return array( $img_url, $width, $height, $is_intermediate );
+	}
+	return false;
+
+}
+
+/**
+ * Registers a new image size
+ */
+function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {
+	global $_wp_additional_image_sizes;
+	$_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => (bool) $crop );
+}
+
+/**
+ * Registers an image size for the post thumbnail
+ */
+function set_post_thumbnail_size( $width = 0, $height = 0, $crop = false ) {
+	add_image_size( 'post-thumbnail', $width, $height, $crop );
+}
+
+/**
+ * An <img src /> tag for an image attachment, scaling it down if requested.
+ *
+ * The filter 'get_image_tag_class' allows for changing the class name for the
+ * image without having to use regular expressions on the HTML content. The
+ * parameters are: what WordPress will use for the class, the Attachment ID,
+ * image align value, and the size the image should be.
+ *
+ * The second filter 'get_image_tag' has the HTML content, which can then be
+ * further manipulated by a plugin to change all attribute values and even HTML
+ * content.
+ *
+ * @since 2.5.0
+ *
+ * @uses apply_filters() The 'get_image_tag_class' filter is the IMG element
+ *		class attribute.
+ * @uses apply_filters() The 'get_image_tag' filter is the full IMG element with
+ *		all attributes.
+ *
+ * @param int $id Attachment ID.
+ * @param string $alt Image Description for the alt attribute.
+ * @param string $title Image Description for the title attribute.
+ * @param string $align Part of the class name for aligning the image.
+ * @param string $size Optional. Default is 'medium'.
+ * @return string HTML IMG element for given image attachment
+ */
+function get_image_tag($id, $alt, $title, $align, $size='medium') {
+
+	list( $img_src, $width, $height ) = image_downsize($id, $size);
+	$hwstring = image_hwstring($width, $height);
+
+	$class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id;
+	$class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
+
+	$html = '<img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title).'" '.$hwstring.'class="'.$class.'" />';
+
+	$html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size );
+
+	return $html;
+}
+
+/**
+ * Load an image from a string, if PHP supports it.
+ *
+ * @since 2.1.0
+ *
+ * @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 ( is_numeric( $file ) )
+		$file = get_attached_file( $file );
+
+	if ( ! file_exists( $file ) )
+		return sprintf(__('File &#8220;%s&#8221; doesn&#8217;t exist?'), $file);
+
+	if ( ! function_exists('imagecreatefromstring') )
+		return __('The GD image library is not installed.');
+
+	// 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 &#8220;%s&#8221; is not an image.'), $file);
+
+	return $image;
+}
+
+/**
+ * Calculates the new dimentions for a downsampled image.
+ *
+ * If either width or height are empty, no constraint is applied on
+ * that dimension.
+ *
+ * @since 2.5.0
+ *
+ * @param int $current_width Current width of the image.
+ * @param int $current_height Current height of the image.
+ * @param int $max_width Optional. Maximum wanted width.
+ * @param int $max_height Optional. Maximum wanted height.
+ * @return array First item is the width, the second item is the height.
+ */
+function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) {
+	if ( !$max_width and !$max_height )
+		return array( $current_width, $current_height );
+
+	$width_ratio = $height_ratio = 1.0;
+	$did_width = $did_height = false;
+
+	if ( $max_width > 0 && $current_width > 0 && $current_width > $max_width ) {
+		$width_ratio = $max_width / $current_width;
+		$did_width = true;
+	}
+
+	if ( $max_height > 0 && $current_height > 0 && $current_height > $max_height ) {
+		$height_ratio = $max_height / $current_height;
+		$did_height = true;
+	}
+
+	// Calculate the larger/smaller ratios
+	$smaller_ratio = min( $width_ratio, $height_ratio );
+	$larger_ratio  = max( $width_ratio, $height_ratio );
+
+	if ( intval( $current_width * $larger_ratio ) > $max_width || intval( $current_height * $larger_ratio ) > $max_height )
+ 		// The larger ratio is too big. It would result in an overflow.
+		$ratio = $smaller_ratio;
+	else
+		// The larger ratio fits, and is likely to be a more "snug" fit.
+		$ratio = $larger_ratio;
+
+	$w = intval( $current_width  * $ratio );
+	$h = intval( $current_height * $ratio );
+
+	// Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short
+	// We also have issues with recursive calls resulting in an ever-changing result. Contraining to the result of a constraint should yield the original result.
+	// Thus we look for dimensions that are one pixel shy of the max value and bump them up
+	if ( $did_width && $w == $max_width - 1 )
+		$w = $max_width; // Round it up
+	if ( $did_height && $h == $max_height - 1 )
+		$h = $max_height; // Round it up
+
+	return array( $w, $h );
+}
+
+/**
+ * Retrieve calculated resized dimensions for use in imagecopyresampled().
+ *
+ * Calculate dimensions and coordinates for a resized image that fits within a
+ * specified width and height. If $crop is true, the largest matching central
+ * portion of the image will be cropped out and resized to the required size.
+ *
+ * @since 2.5.0
+ *
+ * @param int $orig_w Original width.
+ * @param int $orig_h Original height.
+ * @param int $dest_w New width.
+ * @param int $dest_h New height.
+ * @param bool $crop Optional, default is false. Whether to crop image or resize.
+ * @return bool|array False, on failure. Returned array matches parameters for imagecopyresampled() PHP function.
+ */
+function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false) {
+
+	if ($orig_w <= 0 || $orig_h <= 0)
+		return false;
+	// at least one of dest_w or dest_h must be specific
+	if ($dest_w <= 0 && $dest_h <= 0)
+		return false;
+
+	if ( $crop ) {
+		// crop the largest possible portion of the original image that we can size to $dest_w x $dest_h
+		$aspect_ratio = $orig_w / $orig_h;
+		$new_w = min($dest_w, $orig_w);
+		$new_h = min($dest_h, $orig_h);
+
+		if ( !$new_w ) {
+			$new_w = intval($new_h * $aspect_ratio);
+		}
+
+		if ( !$new_h ) {
+			$new_h = intval($new_w / $aspect_ratio);
+		}
+
+		$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
+
+		$crop_w = round($new_w / $size_ratio);
+		$crop_h = round($new_h / $size_ratio);
+
+		$s_x = floor( ($orig_w - $crop_w) / 2 );
+		$s_y = floor( ($orig_h - $crop_h) / 2 );
+	} else {
+		// don't crop, just resize using $dest_w x $dest_h as a maximum bounding box
+		$crop_w = $orig_w;
+		$crop_h = $orig_h;
+
+		$s_x = 0;
+		$s_y = 0;
+
+		list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h );
+	}
+
+	// if the resulting image would be the same size or larger we don't want to resize it
+	if ( $new_w >= $orig_w && $new_h >= $orig_h )
+		return false;
+
+	// the return array matches the parameters to imagecopyresampled()
+	// int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h
+	return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
+
+}
+
+/**
+ * Scale down an image to fit a particular size and save a new copy of the image.
+ *
+ * The PNG transparency will be preserved using the function, as well as the
+ * image type. If the file going in is PNG, then the resized image is going to
+ * be PNG. The only supported image types are PNG, GIF, and JPEG.
+ *
+ * Some functionality requires API to exist, so some PHP version may lose out
+ * support. This is not the fault of WordPress (where functionality is
+ * downgraded, not actual defects), but of your PHP version.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Image file path.
+ * @param int $max_w Maximum width to resize to.
+ * @param int $max_h Maximum height to resize to.
+ * @param bool $crop Optional. Whether to crop image or resize.
+ * @param string $suffix Optional. File Suffix.
+ * @param string $dest_path Optional. New image file path.
+ * @param int $jpeg_quality Optional, default is 90. Image quality percentage.
+ * @return mixed WP_Error on failure. String with new destination path.
+ */
+function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
+
+	$image = wp_load_image( $file );
+	if ( !is_resource( $image ) )
+		return new WP_Error( 'error_loading_image', $image, $file );
+
+	$size = @getimagesize( $file );
+	if ( !$size )
+		return new WP_Error('invalid_image', __('Could not read image size'), $file);
+	list($orig_w, $orig_h, $orig_type) = $size;
+
+	$dims = image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop);
+	if ( !$dims )
+		return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
+	list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
+
+	$newimage = wp_imagecreatetruecolor( $dst_w, $dst_h );
+
+	imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
+
+	// convert from full colors to index colors, like original PNG.
+	if ( IMAGETYPE_PNG == $orig_type && function_exists('imageistruecolor') && !imageistruecolor( $image ) )
+		imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) );
+
+	// we don't need the original in memory anymore
+	imagedestroy( $image );
+
+	// $suffix will be appended to the destination filename, just before the extension
+	if ( !$suffix )
+		$suffix = "{$dst_w}x{$dst_h}";
+
+	$info = pathinfo($file);
+	$dir = $info['dirname'];
+	$ext = $info['extension'];
+	$name = wp_basename($file, ".$ext");
+
+	if ( !is_null($dest_path) and $_dest_path = realpath($dest_path) )
+		$dir = $_dest_path;
+	$destfilename = "{$dir}/{$name}-{$suffix}.{$ext}";
+
+	if ( IMAGETYPE_GIF == $orig_type ) {
+		if ( !imagegif( $newimage, $destfilename ) )
+			return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
+	} elseif ( IMAGETYPE_PNG == $orig_type ) {
+		if ( !imagepng( $newimage, $destfilename ) )
+			return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
+	} else {
+		// all other formats are converted to jpg
+		$destfilename = "{$dir}/{$name}-{$suffix}.jpg";
+		if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) )
+			return new WP_Error('resize_path_invalid', __( 'Resize path invalid' ));
+	}
+
+	imagedestroy( $newimage );
+
+	// Set correct file permissions
+	$stat = stat( dirname( $destfilename ));
+	$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
+	@ chmod( $destfilename, $perms );
+
+	return $destfilename;
+}
+
+/**
+ * Resize an image to make a thumbnail or intermediate size.
+ *
+ * The returned array has the file size, the image width, and image height. The
+ * filter 'image_make_intermediate_size' can be used to hook in and change the
+ * values of the returned array. The only parameter is the resized file path.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file File path.
+ * @param int $width Image width.
+ * @param int $height Image height.
+ * @param bool $crop Optional, default is false. Whether to crop image to specified height and width or resize.
+ * @return bool|array False, if no image was created. Metadata array on success.
+ */
+function image_make_intermediate_size($file, $width, $height, $crop=false) {
+	if ( $width || $height ) {
+		$resized_file = image_resize($file, $width, $height, $crop);
+		if ( !is_wp_error($resized_file) && $resized_file && $info = getimagesize($resized_file) ) {
+			$resized_file = apply_filters('image_make_intermediate_size', $resized_file);
+			return array(
+				'file' => wp_basename( $resized_file ),
+				'width' => $info[0],
+				'height' => $info[1],
+			);
+		}
+	}
+	return false;
+}
+
+/**
+ * Retrieve the image's intermediate size (resized) path, width, and height.
+ *
+ * The $size parameter can be an array with the width and height respectively.
+ * If the size matches the 'sizes' metadata array for width and height, then it
+ * will be used. If there is no direct match, then the nearest image size larger
+ * than the specified size will be used. If nothing is found, then the function
+ * will break out and return false.
+ *
+ * The metadata 'sizes' is used for compatible sizes that can be used for the
+ * parameter $size value.
+ *
+ * The url path will be given, when the $size parameter is a string.
+ *
+ * If you are passing an array for the $size, you should consider using
+ * add_image_size() so that a cropped version is generated. It's much more
+ * efficient than having to find the closest-sized image and then having the
+ * browser scale down the image.
+ *
+ * @since 2.5.0
+ * @see add_image_size()
+ *
+ * @param int $post_id Attachment ID for image.
+ * @param array|string $size Optional, default is 'thumbnail'. Size of image, either array or string.
+ * @return bool|array False on failure or array of file path, width, and height on success.
+ */
+function image_get_intermediate_size($post_id, $size='thumbnail') {
+	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) )
+		return false;
+
+	// get the best one for a specified set of dimensions
+	if ( is_array($size) && !empty($imagedata['sizes']) ) {
+		foreach ( $imagedata['sizes'] as $_size => $data ) {
+			// already cropped to width or height; so use this size
+			if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
+				$file = $data['file'];
+				list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
+				return compact( 'file', 'width', 'height' );
+			}
+			// add to lookup table: area => size
+			$areas[$data['width'] * $data['height']] = $_size;
+		}
+		if ( !$size || !empty($areas) ) {
+			// find for the smallest image not smaller than the desired size
+			ksort($areas);
+			foreach ( $areas as $_size ) {
+				$data = $imagedata['sizes'][$_size];
+				if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) {
+					// Skip images with unexpectedly divergent aspect ratios (crops)
+					// First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop
+					$maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false );
+					// If the size doesn't match within one pixel, then it is of a different aspect ratio, so we skip it, unless it's the thumbnail size
+					if ( 'thumbnail' != $_size && ( !$maybe_cropped || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) ) )
+						continue;
+					// If we're still here, then we're going to use this size
+					$file = $data['file'];
+					list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
+					return compact( 'file', 'width', 'height' );
+				}
+			}
+		}
+	}
+
+	if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) )
+		return false;
+
+	$data = $imagedata['sizes'][$size];
+	// include the full filesystem path of the intermediate file
+	if ( empty($data['path']) && !empty($data['file']) ) {
+		$file_url = wp_get_attachment_url($post_id);
+		$data['path'] = path_join( dirname($imagedata['file']), $data['file'] );
+		$data['url'] = path_join( dirname($file_url), $data['file'] );
+	}
+	return $data;
+}
+
+/**
+ * Get the available image sizes
+ * @since 3.0.0
+ * @return array Returns a filtered array of image size strings
+ */
+function get_intermediate_image_sizes() {
+	global $_wp_additional_image_sizes;
+	$image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
+	if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
+		$image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
+
+	return apply_filters( 'intermediate_image_sizes', $image_sizes );
+}
+
+/**
+ * Retrieve an image to represent an attachment.
+ *
+ * A mime icon for files, thumbnail or intermediate size for images.
+ *
+ * @since 2.5.0
+ *
+ * @param int $attachment_id Image attachment ID.
+ * @param string $size Optional, default is 'thumbnail'.
+ * @param bool $icon Optional, default is false. Whether it is an icon.
+ * @return bool|array Returns an array (url, width, height), or false, if no image is available.
+ */
+function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) {
+
+	// get a thumbnail or intermediate image if there is one
+	if ( $image = image_downsize($attachment_id, $size) )
+		return $image;
+
+	$src = false;
+
+	if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
+		$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
+		$src_file = $icon_dir . '/' . wp_basename($src);
+		@list($width, $height) = getimagesize($src_file);
+	}
+	if ( $src && $width && $height )
+		return array( $src, $width, $height );
+	return false;
+}
+
+/**
+ * Get an HTML img element representing an image attachment
+ *
+ * While $size will accept an array, it is better to register a size with
+ * add_image_size() so that a cropped version is generated. It's much more
+ * efficient than having to find the closest-sized image and then having the
+ * browser scale down the image.
+ *
+ * @see add_image_size()
+ * @uses apply_filters() Calls 'wp_get_attachment_image_attributes' hook on attributes array
+ * @uses wp_get_attachment_image_src() Gets attachment file URL and dimensions
+ * @since 2.5.0
+ *
+ * @param int $attachment_id Image attachment ID.
+ * @param string $size Optional, default is 'thumbnail'.
+ * @param bool $icon Optional, default is false. Whether it is an icon.
+ * @return string HTML img element or empty string on failure.
+ */
+function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') {
+
+	$html = '';
+	$image = wp_get_attachment_image_src($attachment_id, $size, $icon);
+	if ( $image ) {
+		list($src, $width, $height) = $image;
+		$hwstring = image_hwstring($width, $height);
+		if ( is_array($size) )
+			$size = join('x', $size);
+		$attachment =& get_post($attachment_id);
+		$default_attr = array(
+			'src'	=> $src,
+			'class'	=> "attachment-$size",
+			'alt'	=> trim(strip_tags( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) )), // Use Alt field first
+			'title'	=> trim(strip_tags( $attachment->post_title )),
+		);
+		if ( empty($default_attr['alt']) )
+			$default_attr['alt'] = trim(strip_tags( $attachment->post_excerpt )); // If not, Use the Caption
+		if ( empty($default_attr['alt']) )
+			$default_attr['alt'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title
+
+		$attr = wp_parse_args($attr, $default_attr);
+		$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment );
+		$attr = array_map( 'esc_attr', $attr );
+		$html = rtrim("<img $hwstring");
+		foreach ( $attr as $name => $value ) {
+			$html .= " $name=" . '"' . $value . '"';
+		}
+		$html .= ' />';
+	}
+
+	return $html;
+}
+
+/**
+ * Adds a 'wp-post-image' class to post thumbnail thumbnails
+ * Uses the begin_fetch_post_thumbnail_html and end_fetch_post_thumbnail_html action hooks to
+ * dynamically add/remove itself so as to only filter post thumbnail thumbnails
+ *
+ * @since 2.9.0
+ * @param array $attr Attributes including src, class, alt, title
+ * @return array
+ */
+function _wp_post_thumbnail_class_filter( $attr ) {
+	$attr['class'] .= ' wp-post-image';
+	return $attr;
+}
+
+/**
+ * Adds _wp_post_thumbnail_class_filter to the wp_get_attachment_image_attributes filter
+ *
+ * @since 2.9.0
+ */
+function _wp_post_thumbnail_class_filter_add( $attr ) {
+	add_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );
+}
+
+/**
+ * Removes _wp_post_thumbnail_class_filter from the wp_get_attachment_image_attributes filter
+ *
+ * @since 2.9.0
+ */
+function _wp_post_thumbnail_class_filter_remove( $attr ) {
+	remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );
+}
+
+add_shortcode('wp_caption', 'img_caption_shortcode');
+add_shortcode('caption', 'img_caption_shortcode');
+
+/**
+ * The Caption shortcode.
+ *
+ * Allows a plugin to replace the content that would otherwise be returned. The
+ * filter is 'img_caption_shortcode' and passes an empty string, the attr
+ * parameter and the content parameter values.
+ *
+ * The supported attributes for the shortcode are 'id', 'align', 'width', and
+ * 'caption'.
+ *
+ * @since 2.6.0
+ *
+ * @param array $attr Attributes attributed to the shortcode.
+ * @param string $content Optional. Shortcode content.
+ * @return string
+ */
+function img_caption_shortcode($attr, $content = null) {
+
+	// Allow plugins/themes to override the default caption template.
+	$output = apply_filters('img_caption_shortcode', '', $attr, $content);
+	if ( $output != '' )
+		return $output;
+
+	extract(shortcode_atts(array(
+		'id'	=> '',
+		'align'	=> 'alignnone',
+		'width'	=> '',
+		'caption' => ''
+	), $attr));
+
+	if ( 1 > (int) $width || empty($caption) )
+		return $content;
+
+	if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
+
+	return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . (10 + (int) $width) . 'px">'
+	. do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
+}
+
+add_shortcode('gallery', 'gallery_shortcode');
+
+/**
+ * The Gallery shortcode.
+ *
+ * This implements the functionality of the Gallery Shortcode for displaying
+ * WordPress images on a post.
+ *
+ * @since 2.5.0
+ *
+ * @param array $attr Attributes attributed to the shortcode.
+ * @return string HTML content to display gallery.
+ */
+function gallery_shortcode($attr) {
+	global $post, $wp_locale;
+
+	static $instance = 0;
+	$instance++;
+
+	// Allow plugins/themes to override the default gallery template.
+	$output = apply_filters('post_gallery', '', $attr);
+	if ( $output != '' )
+		return $output;
+
+	// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
+	if ( isset( $attr['orderby'] ) ) {
+		$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
+		if ( !$attr['orderby'] )
+			unset( $attr['orderby'] );
+	}
+
+	extract(shortcode_atts(array(
+		'order'      => 'ASC',
+		'orderby'    => 'menu_order ID',
+		'id'         => $post->ID,
+		'itemtag'    => 'dl',
+		'icontag'    => 'dt',
+		'captiontag' => 'dd',
+		'columns'    => 3,
+		'size'       => 'thumbnail',
+		'include'    => '',
+		'exclude'    => ''
+	), $attr));
+
+	$id = intval($id);
+	if ( 'RAND' == $order )
+		$orderby = 'none';
+
+	if ( !empty($include) ) {
+		$include = preg_replace( '/[^0-9,]+/', '', $include );
+		$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
+
+		$attachments = array();
+		foreach ( $_attachments as $key => $val ) {
+			$attachments[$val->ID] = $_attachments[$key];
+		}
+	} elseif ( !empty($exclude) ) {
+		$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
+		$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
+	} else {
+		$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
+	}
+
+	if ( empty($attachments) )
+		return '';
+
+	if ( is_feed() ) {
+		$output = "\n";
+		foreach ( $attachments as $att_id => $attachment )
+			$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
+		return $output;
+	}
+
+	$itemtag = tag_escape($itemtag);
+	$captiontag = tag_escape($captiontag);
+	$columns = intval($columns);
+	$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
+	$float = is_rtl() ? 'right' : 'left';
+
+	$selector = "gallery-{$instance}";
+
+	$gallery_style = $gallery_div = '';
+	if ( apply_filters( 'use_default_gallery_style', true ) )
+		$gallery_style = "
+		<style type='text/css'>
+			#{$selector} {
+				margin: auto;
+			}
+			#{$selector} .gallery-item {
+				float: {$float};
+				margin-top: 10px;
+				text-align: center;
+				width: {$itemwidth}%;
+			}
+			#{$selector} img {
+				border: 2px solid #cfcfcf;
+			}
+			#{$selector} .gallery-caption {
+				margin-left: 0;
+			}
+		</style>
+		<!-- see gallery_shortcode() in wp-includes/media.php -->";
+	$size_class = sanitize_html_class( $size );
+	$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
+	$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
+
+	$i = 0;
+	foreach ( $attachments as $id => $attachment ) {
+		$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
+
+		$output .= "<{$itemtag} class='gallery-item'>";
+		$output .= "
+			<{$icontag} class='gallery-icon'>
+				$link
+			</{$icontag}>";
+		if ( $captiontag && trim($attachment->post_excerpt) ) {
+			$output .= "
+				<{$captiontag} class='wp-caption-text gallery-caption'>
+				" . wptexturize($attachment->post_excerpt) . "
+				</{$captiontag}>";
+		}
+		$output .= "</{$itemtag}>";
+		if ( $columns > 0 && ++$i % $columns == 0 )
+			$output .= '<br style="clear: both" />';
+	}
+
+	$output .= "
+			<br style='clear: both;' />
+		</div>\n";
+
+	return $output;
+}
+
+/**
+ * Display previous image link that has the same post parent.
+ *
+ * @since 2.5.0
+ * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
+ * @param string $text Optional, default is false. If included, link will reflect $text variable.
+ * @return string HTML content.
+ */
+function previous_image_link($size = 'thumbnail', $text = false) {
+	adjacent_image_link(true, $size, $text);
+}
+
+/**
+ * Display next image link that has the same post parent.
+ *
+ * @since 2.5.0
+ * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
+ * @param string $text Optional, default is false. If included, link will reflect $text variable.
+ * @return string HTML content.
+ */
+function next_image_link($size = 'thumbnail', $text = false) {
+	adjacent_image_link(false, $size, $text);
+}
+
+/**
+ * Display next or previous image link that has the same post parent.
+ *
+ * Retrieves the current attachment object from the $post global.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $prev Optional. Default is true to display previous link, true for next.
+ */
+function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) {
+	global $post;
+	$post = get_post($post);
+	$attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));
+
+	foreach ( $attachments as $k => $attachment )
+		if ( $attachment->ID == $post->ID )
+			break;
+
+	$k = $prev ? $k - 1 : $k + 1;
+
+	if ( isset($attachments[$k]) )
+		echo wp_get_attachment_link($attachments[$k]->ID, $size, true, false, $text);
+}
+
+/**
+ * Retrieve taxonomies attached to the attachment.
+ *
+ * @since 2.5.0
+ *
+ * @param int|array|object $attachment Attachment ID, Attachment data array, or Attachment data object.
+ * @return array Empty array on failure. List of taxonomies on success.
+ */
+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);
+}
+
+/**
+ * Check if the installed version of GD supports particular image type
+ *
+ * @since 2.9.0
+ *
+ * @param string $mime_type
+ * @return bool
+ */
+function gd_edit_image_support($mime_type) {
+	if ( function_exists('imagetypes') ) {
+		switch( $mime_type ) {
+			case 'image/jpeg':
+				return (imagetypes() & IMG_JPG) != 0;
+			case 'image/png':
+				return (imagetypes() & IMG_PNG) != 0;
+			case 'image/gif':
+				return (imagetypes() & IMG_GIF) != 0;
+		}
+	} else {
+		switch( $mime_type ) {
+			case 'image/jpeg':
+				return function_exists('imagecreatefromjpeg');
+			case 'image/png':
+				return function_exists('imagecreatefrompng');
+			case 'image/gif':
+				return function_exists('imagecreatefromgif');
+		}
+	}
+	return false;
+}
+
+/**
+ * Create new GD image resource with transparency support
+ *
+ * @since 2.9.0
+ *
+ * @param int $width Image width
+ * @param int $height Image height
+ * @return image resource
+ */
+function wp_imagecreatetruecolor($width, $height) {
+	$img = imagecreatetruecolor($width, $height);
+	if ( is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
+		imagealphablending($img, false);
+		imagesavealpha($img, true);
+	}
+	return $img;
+}
+
+/**
+ * API for easily embedding rich media such as videos and images into content.
+ *
+ * @package WordPress
+ * @subpackage Embed
+ * @since 2.9.0
+ */
+class WP_Embed {
+	var $handlers = array();
+	var $post_ID;
+	var $usecache = true;
+	var $linkifunknown = true;
+
+	/**
+	 * PHP4 constructor
+	 */
+	function WP_Embed() {
+		return $this->__construct();
+	}
+
+	/**
+	 * PHP5 constructor
+	 */
+	function __construct() {
+		// Hack to get the [embed] shortcode to run before wpautop()
+		add_filter( 'the_content', array(&$this, 'run_shortcode'), 8 );
+
+		// Shortcode placeholder for strip_shortcodes()
+		add_shortcode( 'embed', '__return_false' );
+
+		// Attempts to embed all URLs in a post
+		if ( get_option('embed_autourls') )
+			add_filter( 'the_content', array(&$this, 'autoembed'), 8 );
+
+		// After a post is saved, invalidate the oEmbed cache
+		add_action( 'save_post', array(&$this, 'delete_oembed_caches') );
+
+		// After a post is saved, cache oEmbed items via AJAX
+		add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') );
+	}
+
+	/**
+	 * Process the [embed] shortcode.
+	 *
+	 * Since the [embed] shortcode needs to be run earlier than other shortcodes,
+	 * this function removes all existing shortcodes, registers the [embed] shortcode,
+	 * calls {@link do_shortcode()}, and then re-registers the old shortcodes.
+	 *
+	 * @uses $shortcode_tags
+	 * @uses remove_all_shortcodes()
+	 * @uses add_shortcode()
+	 * @uses do_shortcode()
+	 *
+	 * @param string $content Content to parse
+	 * @return string Content with shortcode parsed
+	 */
+	function run_shortcode( $content ) {
+		global $shortcode_tags;
+
+		// Back up current registered shortcodes and clear them all out
+		$orig_shortcode_tags = $shortcode_tags;
+		remove_all_shortcodes();
+
+		add_shortcode( 'embed', array(&$this, 'shortcode') );
+
+		// Do the shortcode (only the [embed] one is registered)
+		$content = do_shortcode( $content );
+
+		// Put the original shortcodes back
+		$shortcode_tags = $orig_shortcode_tags;
+
+		return $content;
+	}
+
+	/**
+	 * If a post/page was saved, then output Javascript to make
+	 * an AJAX request that will call WP_Embed::cache_oembed().
+	 */
+	function maybe_run_ajax_cache() {
+		global $post_ID;
+
+		if ( empty($post_ID) || empty($_GET['message']) || 1 != $_GET['message'] )
+			return;
+
+?>
+<script type="text/javascript">
+/* <![CDATA[ */
+	jQuery(document).ready(function($){
+		$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID ); ?>");
+	});
+/* ]]> */
+</script>
+<?php
+	}
+
+	/**
+	 * Register an embed handler. Do not use this function directly, use {@link wp_embed_register_handler()} instead.
+	 * This function should probably also only be used for sites that do not support oEmbed.
+	 *
+	 * @param string $id An internal ID/name for the handler. Needs to be unique.
+	 * @param string $regex The regex that will be used to see if this handler should be used for a URL.
+	 * @param callback $callback The callback function that will be called if the regex is matched.
+	 * @param int $priority Optional. Used to specify the order in which the registered handlers will be tested (default: 10). Lower numbers correspond with earlier testing, and handlers with the same priority are tested in the order in which they were added to the action.
+	 */
+	function register_handler( $id, $regex, $callback, $priority = 10 ) {
+		$this->handlers[$priority][$id] = array(
+			'regex'    => $regex,
+			'callback' => $callback,
+		);
+	}
+
+	/**
+	 * Unregister a previously registered embed handler. Do not use this function directly, use {@link wp_embed_unregister_handler()} instead.
+	 *
+	 * @param string $id The handler ID that should be removed.
+	 * @param int $priority Optional. The priority of the handler to be removed (default: 10).
+	 */
+	function unregister_handler( $id, $priority = 10 ) {
+		if ( isset($this->handlers[$priority][$id]) )
+			unset($this->handlers[$priority][$id]);
+	}
+
+	/**
+	 * The {@link do_shortcode()} callback function.
+	 *
+	 * Attempts to convert a URL into embed HTML. Starts by checking the URL against the regex of the registered embed handlers.
+	 * If none of the regex matches and it's enabled, then the URL will be given to the {@link WP_oEmbed} class.
+	 *
+	 * @uses wp_oembed_get()
+	 * @uses wp_parse_args()
+	 * @uses wp_embed_defaults()
+	 * @uses WP_Embed::maybe_make_link()
+	 * @uses get_option()
+	 * @uses current_user_can()
+	 * @uses wp_cache_get()
+	 * @uses wp_cache_set()
+	 * @uses get_post_meta()
+	 * @uses update_post_meta()
+	 *
+	 * @param array $attr Shortcode attributes.
+	 * @param string $url The URL attempting to be embeded.
+	 * @return string The embed HTML on success, otherwise the original URL.
+	 */
+	function shortcode( $attr, $url = '' ) {
+		global $post;
+
+		if ( empty($url) )
+			return '';
+
+		$rawattr = $attr;
+		$attr = wp_parse_args( $attr, wp_embed_defaults() );
+
+		// kses converts & into &amp; and we need to undo this
+		// See http://core.trac.wordpress.org/ticket/11311
+		$url = str_replace( '&amp;', '&', $url );
+
+		// Look for known internal handlers
+		ksort( $this->handlers );
+		foreach ( $this->handlers as $priority => $handlers ) {
+			foreach ( $handlers as $id => $handler ) {
+				if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
+					if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) )
+						return apply_filters( 'embed_handler_html', $return, $url, $attr );
+				}
+			}
+		}
+
+		$post_ID = ( !empty($post->ID) ) ? $post->ID : null;
+		if ( !empty($this->post_ID) ) // Potentially set by WP_Embed::cache_oembed()
+			$post_ID = $this->post_ID;
+
+		// Unknown URL format. Let oEmbed have a go.
+		if ( $post_ID ) {
+
+			// Check for a cached result (stored in the post meta)
+			$cachekey = '_oembed_' . md5( $url . serialize( $attr ) );
+			if ( $this->usecache ) {
+				$cache = get_post_meta( $post_ID, $cachekey, true );
+
+				// Failures are cached
+				if ( '{{unknown}}' === $cache )
+					return $this->maybe_make_link( $url );
+
+				if ( !empty($cache) )
+					return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID );
+			}
+
+			// Use oEmbed to get the HTML
+			$attr['discover'] = ( apply_filters('embed_oembed_discover', false) && author_can( $post_ID, 'unfiltered_html' ) );
+			$html = wp_oembed_get( $url, $attr );
+
+			// Cache the result
+			$cache = ( $html ) ? $html : '{{unknown}}';
+			update_post_meta( $post_ID, $cachekey, $cache );
+
+			// If there was a result, return it
+			if ( $html )
+				return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID );
+		}
+
+		// Still unknown
+		return $this->maybe_make_link( $url );
+	}
+
+	/**
+	 * Delete all oEmbed caches.
+	 *
+	 * @param int $post_ID Post ID to delete the caches for.
+	 */
+	function delete_oembed_caches( $post_ID ) {
+		$post_metas = get_post_custom_keys( $post_ID );
+		if ( empty($post_metas) )
+			return;
+
+		foreach( $post_metas as $post_meta_key ) {
+			if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) )
+				delete_post_meta( $post_ID, $post_meta_key );
+		}
+	}
+
+	/**
+	 * Triggers a caching of all oEmbed results.
+	 *
+	 * @param int $post_ID Post ID to do the caching for.
+	 */
+	function cache_oembed( $post_ID ) {
+		$post = get_post( $post_ID );
+
+		if ( empty($post->ID) || !in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', array( 'post', 'page' ) ) ) )
+			return;
+
+		// Trigger a caching
+		if ( !empty($post->post_content) ) {
+			$this->post_ID = $post->ID;
+			$this->usecache = false;
+
+			$content = $this->run_shortcode( $post->post_content );
+			if ( get_option('embed_autourls') )
+				$this->autoembed( $content );
+
+			$this->usecache = true;
+		}
+	}
+
+	/**
+	 * Passes any unlinked URLs that are on their own line to {@link WP_Embed::shortcode()} for potential embedding.
+	 *
+	 * @uses WP_Embed::autoembed_callback()
+	 *
+	 * @param string $content The content to be searched.
+	 * @return string Potentially modified $content.
+	 */
+	function autoembed( $content ) {
+		return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array(&$this, 'autoembed_callback'), $content );
+	}
+
+	/**
+	 * Callback function for {@link WP_Embed::autoembed()}.
+	 *
+	 * @uses WP_Embed::shortcode()
+	 *
+	 * @param array $match A regex match array.
+	 * @return string The embed HTML on success, otherwise the original URL.
+	 */
+	function autoembed_callback( $match ) {
+		$oldval = $this->linkifunknown;
+		$this->linkifunknown = false;
+		$return = $this->shortcode( array(), $match[1] );
+		$this->linkifunknown = $oldval;
+
+		return "\n$return\n";
+	}
+
+	/**
+	 * Conditionally makes a hyperlink based on an internal class variable.
+	 *
+	 * @param string $url URL to potentially be linked.
+	 * @return string Linked URL or the original URL.
+	 */
+	function maybe_make_link( $url ) {
+		$output = ( $this->linkifunknown ) ? '<a href="' . esc_attr($url) . '">' . esc_html($url) . '</a>' : $url;
+		return apply_filters( 'embed_maybe_make_link', $output, $url );
+	}
+}
+$wp_embed = new WP_Embed();
+
+/**
+ * Register an embed handler. This function should probably only be used for sites that do not support oEmbed.
+ *
+ * @since 2.9.0
+ * @see WP_Embed::register_handler()
+ */
+function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) {
+	global $wp_embed;
+	$wp_embed->register_handler( $id, $regex, $callback, $priority );
+}
+
+/**
+ * Unregister a previously registered embed handler.
+ *
+ * @since 2.9.0
+ * @see WP_Embed::unregister_handler()
+ */
+function wp_embed_unregister_handler( $id, $priority = 10 ) {
+	global $wp_embed;
+	$wp_embed->unregister_handler( $id, $priority );
+}
+
+/**
+ * Create default array of embed parameters.
+ *
+ * @since 2.9.0
+ *
+ * @return array Default embed parameters.
+ */
+function wp_embed_defaults() {
+	if ( !empty($GLOBALS['content_width']) )
+		$theme_width = (int) $GLOBALS['content_width'];
+
+	$width = get_option('embed_size_w');
+
+	if ( empty($width) && !empty($theme_width) )
+		$width = $theme_width;
+
+	if ( empty($width) )
+		$width = 500;
+
+	$height = get_option('embed_size_h');
+
+	if ( empty($height) )
+		$height = 700;
+
+	return apply_filters( 'embed_defaults', array(
+		'width'  => $width,
+		'height' => $height,
+	) );
+}
+
+/**
+ * Based on a supplied width/height example, return the biggest possible dimensions based on the max width/height.
+ *
+ * @since 2.9.0
+ * @uses wp_constrain_dimensions() This function passes the widths and the heights.
+ *
+ * @param int $example_width The width of an example embed.
+ * @param int $example_height The height of an example embed.
+ * @param int $max_width The maximum allowed width.
+ * @param int $max_height The maximum allowed height.
+ * @return array The maximum possible width and height based on the example ratio.
+ */
+function wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height ) {
+	$example_width  = (int) $example_width;
+	$example_height = (int) $example_height;
+	$max_width      = (int) $max_width;
+	$max_height     = (int) $max_height;
+
+	return wp_constrain_dimensions( $example_width * 1000000, $example_height * 1000000, $max_width, $max_height );
+}
+
+/**
+ * Attempts to fetch the embed HTML for a provided URL using oEmbed.
+ *
+ * @since 2.9.0
+ * @see WP_oEmbed
+ *
+ * @uses _wp_oembed_get_object()
+ * @uses WP_oEmbed::get_html()
+ *
+ * @param string $url The URL that should be embeded.
+ * @param array $args Addtional arguments and parameters.
+ * @return string The original URL on failure or the embed HTML on success.
+ */
+function wp_oembed_get( $url, $args = '' ) {
+	require_once( ABSPATH . WPINC . '/class-oembed.php' );
+	$oembed = _wp_oembed_get_object();
+	return $oembed->get_html( $url, $args );
+}
+
+/**
+ * Adds a URL format and oEmbed provider URL pair.
+ *
+ * @since 2.9.0
+ * @see WP_oEmbed
+ *
+ * @uses _wp_oembed_get_object()
+ *
+ * @param string $format The format of URL that this provider can handle. You can use asterisks as wildcards.
+ * @param string $provider The URL to the oEmbed provider.
+ * @param boolean $regex Whether the $format parameter is in a regex format.
+ */
+function wp_oembed_add_provider( $format, $provider, $regex = false ) {
+	require_once( ABSPATH . WPINC . '/class-oembed.php' );
+	$oembed = _wp_oembed_get_object();
+	$oembed->providers[$format] = array( $provider, $regex );
+}
Index: /tags/3.1/wp-includes/meta.php
===================================================================
--- /tags/3.1/wp-includes/meta.php	(revision 17487)
+++ /tags/3.1/wp-includes/meta.php	(revision 17487)
@@ -0,0 +1,491 @@
+<?php
+/**
+ * Metadata API
+ *
+ * Functions for retrieving and manipulating metadata of various WordPress object types.  Metadata
+ * for an object is a represented by a simple key-value pair.  Objects may contain multiple
+ * metadata entries that share the same key and differ only in their value.
+ *
+ * @package WordPress
+ * @subpackage Meta
+ * @since 2.9.0
+ */
+
+/**
+ * Add metadata for the specified object.
+ *
+ * @since 2.9.0
+ * @uses $wpdb WordPress database object for queries.
+ * @uses do_action() Calls 'added_{$meta_type}_meta' with meta_id of added metadata entry,
+ * 		object ID, meta key, and meta value
+ *
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
+ * @param int $object_id ID of the object metadata is for
+ * @param string $meta_key Metadata key
+ * @param string $meta_value Metadata value
+ * @param bool $unique Optional, default is false.  Whether the specified metadata key should be
+ * 		unique for the object.  If true, and the object already has a value for the specified
+ * 		metadata key, no change will be made
+ * @return bool True on successful update, false on failure.
+ */
+function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique = false) {
+	if ( !$meta_type || !$meta_key )
+		return false;
+
+	if ( !$object_id = absint($object_id) )
+		return false;
+
+	if ( ! $table = _get_meta_table($meta_type) )
+		return false;
+
+	global $wpdb;
+
+	$column = esc_sql($meta_type . '_id');
+
+	// expected_slashed ($meta_key)
+	$meta_key = stripslashes($meta_key);
+	$meta_value = stripslashes_deep($meta_value);
+
+	$check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
+	if ( null !== $check )
+		return (bool) $check;
+
+	if ( $unique && $wpdb->get_var( $wpdb->prepare(
+		"SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d",
+		$meta_key, $object_id ) ) )
+		return false;
+
+	$_meta_value = $meta_value;
+	$meta_value = maybe_serialize( $meta_value );
+
+	do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value );
+
+	$wpdb->insert( $table, array(
+		$column => $object_id,
+		'meta_key' => $meta_key,
+		'meta_value' => $meta_value
+	) );
+
+	wp_cache_delete($object_id, $meta_type . '_meta');
+	// users cache stores usermeta that must be cleared.
+	if ( 'user' == $meta_type )
+		clean_user_cache($object_id);
+
+	do_action( "added_{$meta_type}_meta", $wpdb->insert_id, $object_id, $meta_key, $_meta_value );
+
+	return true;
+}
+
+/**
+ * Update metadata for the specified object.  If no value already exists for the specified object
+ * ID and metadata key, the metadata will be added.
+ *
+ * @since 2.9.0
+ * @uses $wpdb WordPress database object for queries.
+ * @uses do_action() Calls 'update_{$meta_type}_meta' before updating metadata with meta_id of
+ * 		metadata entry to update, object ID, meta key, and meta value
+ * @uses do_action() Calls 'updated_{$meta_type}_meta' after updating metadata with meta_id of
+ * 		updated metadata entry, object ID, meta key, and meta value
+ *
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
+ * @param int $object_id ID of the object metadata is for
+ * @param string $meta_key Metadata key
+ * @param string $meta_value Metadata value
+ * @param string $prev_value Optional.  If specified, only update existing metadata entries with
+ * 		the specified value.  Otherwise, update all entries.
+ * @return bool True on successful update, false on failure.
+ */
+function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value = '') {
+	if ( !$meta_type || !$meta_key )
+		return false;
+
+	if ( !$object_id = absint($object_id) )
+		return false;
+
+	if ( ! $table = _get_meta_table($meta_type) )
+		return false;
+
+	global $wpdb;
+
+	$column = esc_sql($meta_type . '_id');
+	$id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
+
+	// expected_slashed ($meta_key)
+	$meta_key = stripslashes($meta_key);
+	$meta_value = stripslashes_deep($meta_value);
+
+	$check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
+	if ( null !== $check )
+		return (bool) $check;
+
+	if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )
+		return add_metadata($meta_type, $object_id, $meta_key, $meta_value);
+
+	// Compare existing value to new value if no prev value given and the key exists only once.
+	if ( empty($prev_value) ) {
+		$old_value = get_metadata($meta_type, $object_id, $meta_key);
+		if ( count($old_value) == 1 ) {
+			if ( $old_value[0] === $meta_value )
+				return false;
+		}
+	}
+
+	$_meta_value = $meta_value;
+	$meta_value = maybe_serialize( $meta_value );
+
+	$data  = compact( 'meta_value' );
+	$where = array( $column => $object_id, 'meta_key' => $meta_key );
+
+	if ( !empty( $prev_value ) ) {
+		$prev_value = maybe_serialize($prev_value);
+		$where['meta_value'] = $prev_value;
+	}
+
+	do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
+
+	$wpdb->update( $table, $data, $where );
+	wp_cache_delete($object_id, $meta_type . '_meta');
+	// users cache stores usermeta that must be cleared.
+	if ( 'user' == $meta_type )
+		clean_user_cache($object_id);
+
+	do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
+
+	return true;
+}
+
+/**
+ * Delete metadata for the specified object.
+ *
+ * @since 2.9.0
+ * @uses $wpdb WordPress database object for queries.
+ * @uses do_action() Calls 'deleted_{$meta_type}_meta' after deleting with meta_id of
+ * 		deleted metadata entries, object ID, meta key, and meta value
+ *
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
+ * @param int $object_id ID of the object metadata is for
+ * @param string $meta_key Metadata key
+ * @param string $meta_value Optional. Metadata value.  If specified, only delete metadata entries
+ * 		with this value.  Otherwise, delete all entries with the specified meta_key.
+ * @param bool $delete_all Optional, default is false.  If true, delete matching metadata entries
+ * 		for all objects, ignoring the specified object_id.  Otherwise, only delete matching
+ * 		metadata entries for the specified object_id.
+ * @return bool True on successful delete, false on failure.
+ */
+function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $delete_all = false) {
+	if ( !$meta_type || !$meta_key )
+		return false;
+
+	if ( (!$object_id = absint($object_id)) && !$delete_all )
+		return false;
+
+	if ( ! $table = _get_meta_table($meta_type) )
+		return false;
+
+	global $wpdb;
+
+	$type_column = esc_sql($meta_type . '_id');
+	$id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
+	// expected_slashed ($meta_key)
+	$meta_key = stripslashes($meta_key);
+	$meta_value = stripslashes_deep($meta_value);
+
+	$check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );
+	if ( null !== $check )
+		return (bool) $check;
+
+	$_meta_value = $meta_value;
+	$meta_value = maybe_serialize( $meta_value );
+
+	$query = $wpdb->prepare( "SELECT $id_column FROM $table WHERE meta_key = %s", $meta_key );
+
+	if ( !$delete_all )
+		$query .= $wpdb->prepare(" AND $type_column = %d", $object_id );
+
+	if ( $meta_value )
+		$query .= $wpdb->prepare(" AND meta_value = %s", $meta_value );
+
+	$meta_ids = $wpdb->get_col( $query );
+	if ( !count( $meta_ids ) )
+		return false;
+
+	do_action( "delete_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
+
+	$query = "DELETE FROM $table WHERE $id_column IN( " . implode( ',', $meta_ids ) . " )";
+
+	$count = $wpdb->query($query);
+
+	if ( !$count )
+		return false;
+
+	wp_cache_delete($object_id, $meta_type . '_meta');
+	// users cache stores usermeta that must be cleared.
+	if ( 'user' == $meta_type )
+		clean_user_cache($object_id);
+
+	do_action( "deleted_{$meta_type}_meta", $meta_ids, $object_id, $meta_key, $_meta_value );
+
+	return true;
+}
+
+/**
+ * Retrieve metadata for the specified object.
+ *
+ * @since 2.9.0
+ *
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
+ * @param int $object_id ID of the object metadata is for
+ * @param string $meta_key Optional.  Metadata key.  If not specified, retrieve all metadata for
+ * 		the specified object.
+ * @param bool $single Optional, default is false.  If true, return only the first value of the
+ * 		specified meta_key.  This parameter has no effect if meta_key is not specified.
+ * @return string|array Single metadata value, or array of values
+ */
+function get_metadata($meta_type, $object_id, $meta_key = '', $single = false) {
+	if ( !$meta_type )
+		return false;
+
+	if ( !$object_id = absint($object_id) )
+		return false;
+
+	$check = apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );
+	if ( null !== $check ) {
+		if ( $single && is_array( $check ) )
+			return $check[0];
+		else
+			return $check;
+	}
+
+	$meta_cache = wp_cache_get($object_id, $meta_type . '_meta');
+
+	if ( !$meta_cache ) {
+		$meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
+		$meta_cache = $meta_cache[$object_id];
+	}
+
+	if ( !$meta_key )
+		return $meta_cache;
+
+	if ( isset($meta_cache[$meta_key]) ) {
+		if ( $single )
+			return maybe_unserialize( $meta_cache[$meta_key][0] );
+		else
+			return array_map('maybe_unserialize', $meta_cache[$meta_key]);
+	}
+
+	if ($single)
+		return '';
+	else
+		return array();
+}
+
+/**
+ * Update the metadata cache for the specified objects.
+ *
+ * @since 2.9.0
+ * @uses $wpdb WordPress database object for queries.
+ *
+ * @param string $meta_type Type of object metadata is for (e.g., comment, post, or user)
+ * @param int|array $object_ids array or comma delimited list of object IDs to update cache for
+ * @return mixed Metadata cache for the specified objects, or false on failure.
+ */
+function update_meta_cache($meta_type, $object_ids) {
+	if ( empty( $meta_type ) || empty( $object_ids ) )
+		return false;
+
+	if ( ! $table = _get_meta_table($meta_type) )
+		return false;
+
+	$column = esc_sql($meta_type . '_id');
+
+	global $wpdb;
+
+	if ( !is_array($object_ids) ) {
+		$object_ids = preg_replace('|[^0-9,]|', '', $object_ids);
+		$object_ids = explode(',', $object_ids);
+	}
+
+	$object_ids = array_map('intval', $object_ids);
+
+	$cache_key = $meta_type . '_meta';
+	$ids = array();
+	$cache = array();
+	foreach ( $object_ids as $id ) {
+		$cached_object = wp_cache_get( $id, $cache_key );
+		if ( false === $cached_object )
+			$ids[] = $id;
+		else
+			$cache[$id] = $cached_object;
+	}
+
+	if ( empty( $ids ) )
+		return $cache;
+
+	// Get meta info
+	$id_list = join(',', $ids);
+	$meta_list = $wpdb->get_results( $wpdb->prepare("SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list)",
+		$meta_type), ARRAY_A );
+
+	if ( !empty($meta_list) ) {
+		foreach ( $meta_list as $metarow) {
+			$mpid = intval($metarow[$column]);
+			$mkey = $metarow['meta_key'];
+			$mval = $metarow['meta_value'];
+
+			// Force subkeys to be array type:
+			if ( !isset($cache[$mpid]) || !is_array($cache[$mpid]) )
+				$cache[$mpid] = array();
+			if ( !isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey]) )
+				$cache[$mpid][$mkey] = array();
+
+			// Add a value to the current pid/key:
+			$cache[$mpid][$mkey][] = $mval;
+		}
+	}
+
+	foreach ( $ids as $id ) {
+		if ( ! isset($cache[$id]) )
+			$cache[$id] = array();
+		wp_cache_add( $id, $cache[$id], $cache_key );
+	}
+
+	return $cache;
+}
+
+/**
+ * Given a meta query, generates SQL clauses to be appended to a main query
+ *
+ * @since 3.1.0
+ * @access private
+ *
+ * @param array $meta_query List of metadata queries. A single query is an associative array:
+ * - 'key' string The meta key
+ * - 'value' string|array The meta value
+ * - 'compare' (optional) string How to compare the key to the value.
+ *		Possible values: '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'.
+ *		Default: '='
+ * - 'type' string (optional) The type of the value.
+ *		Possible values: 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'.
+ *		Default: 'CHAR'
+ *
+ * @param string $meta_type
+ * @param string $primary_table
+ * @param string $primary_id_column
+ * @param object $context (optional) The main query object
+ * @return array( 'join' => $join_sql, 'where' => $where_sql )
+ */
+function _get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_column, $context = null ) {
+	global $wpdb;
+
+	if ( ! $meta_table = _get_meta_table( $meta_type ) )
+		return false;
+
+	$meta_id_column = esc_sql( $meta_type . '_id' );
+
+	$join = '';
+	$where = '';
+	$i = 0;
+	foreach ( $meta_query as $q ) {
+		$meta_key = isset( $q['key'] ) ? trim( $q['key'] ) : '';
+		$meta_value = isset( $q['value'] ) ? $q['value'] : '';
+		$meta_compare = isset( $q['compare'] ) ? strtoupper( $q['compare'] ) : '=';
+		$meta_type = isset( $q['type'] ) ? strtoupper( $q['type'] ) : 'CHAR';
+
+		if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) )
+			$meta_compare = '=';
+
+		if ( 'NUMERIC' == $meta_type )
+			$meta_type = 'SIGNED';
+		elseif ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED' ) ) )
+			$meta_type = 'CHAR';
+
+		if ( empty( $meta_key ) && empty( $meta_value ) )
+			continue;
+
+		$alias = $i ? 'mt' . $i : $meta_table;
+
+		$join .= "\nINNER JOIN $meta_table";
+		$join .= $i ? " AS $alias" : '';
+		$join .= " ON ($primary_table.$primary_id_column = $alias.$meta_id_column)";
+
+		$i++;
+
+		if ( !empty( $meta_key ) )
+			$where .= $wpdb->prepare( " AND $alias.meta_key = %s", $meta_key );
+
+		if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
+			if ( ! is_array( $meta_value ) )
+				$meta_value = preg_split( '/[,\s]+/', $meta_value );
+		} else {
+			$meta_value = trim( $meta_value );
+		}
+
+		if ( empty( $meta_value ) )
+			continue;
+
+		if ( 'IN' == substr( $meta_compare, -2) ) {
+			$meta_compare_string = '(' . substr( str_repeat( ',%s', count( $meta_value ) ), 1 ) . ')';
+		} elseif ( 'BETWEEN' == substr( $meta_compare, -7) ) {
+			$meta_value = array_slice( $meta_value, 0, 2 );
+			$meta_compare_string = '%s AND %s';
+		} elseif ( 'LIKE' == substr( $meta_compare, -4 ) ) {
+			$meta_value = '%' . like_escape( $meta_value ) . '%';
+			$meta_compare_string = '%s';
+		} else {
+			$meta_compare_string = '%s';
+		}
+
+		// @todo Temporary hack to support empty values. Do not use outside of core.
+		if ( '_wp_zero_value' == $meta_value )
+			$meta_value = 0;
+
+		$where .= $wpdb->prepare( " AND CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$meta_compare_string}", $meta_value );
+	}
+
+	return apply_filters_ref_array( 'get_meta_sql', array( compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column, &$context ) );
+}
+
+/**
+ * Populates the $meta_query property
+ *
+ * @access private
+ * @since 3.1.0
+ *
+ * @param array $qv The query variables
+ */
+function _parse_meta_query( &$qv ) {
+	$meta_query = array();
+
+	// Simple query needs to be first for orderby=meta_value to work correctly
+	foreach ( array( 'key', 'value', 'compare', 'type' ) as $key ) {
+		if ( !empty( $qv[ "meta_$key" ] ) )
+			$meta_query[0][ $key ] = $qv[ "meta_$key" ];
+	}
+
+	if ( !empty( $qv['meta_query'] ) && is_array( $qv['meta_query'] ) ) {
+		$meta_query = array_merge( $meta_query, $qv['meta_query'] );
+	}
+
+	$qv['meta_query'] = $meta_query;
+}
+
+/**
+ * Retrieve the name of the metadata table for the specified object type.
+ *
+ * @since 2.9.0
+ * @uses $wpdb WordPress database object for queries.
+ *
+ * @param string $type Type of object to get metadata table for (e.g., comment, post, or user)
+ * @return mixed Metadata table name, or false if no metadata table exists
+ */
+function _get_meta_table($type) {
+	global $wpdb;
+
+	$table_name = $type . 'meta';
+
+	if ( empty($wpdb->$table_name) )
+		return false;
+
+	return $wpdb->$table_name;
+}
+?>
Index: /tags/3.1/wp-includes/ms-blogs.php
===================================================================
--- /tags/3.1/wp-includes/ms-blogs.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-blogs.php	(revision 17487)
@@ -0,0 +1,681 @@
+<?php
+
+/**
+ * Site/blog functions that work with the blogs table and related data.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since MU
+ */
+
+/**
+ * Update the last_updated field for the current blog.
+ *
+ * @since MU
+ */
+function wpmu_update_blogs_date() {
+	global $wpdb;
+
+	// TODO: use update_blog_details
+
+	$wpdb->update( $wpdb->blogs, array('last_updated' => current_time('mysql', true)), array('blog_id' => $wpdb->blogid) );
+	refresh_blog_details( $wpdb->blogid );
+
+	do_action( 'wpmu_blog_updated', $wpdb->blogid );
+}
+
+/**
+ * Get a full blog URL, given a blog id.
+ *
+ * @since MU
+ *
+ * @param int $blog_id Blog ID
+ * @return string
+ */
+function get_blogaddress_by_id( $blog_id ) {
+	$bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
+	return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path );
+}
+
+/**
+ * Get a full blog URL, given a blog name.
+ *
+ * @since MU
+ *
+ * @param string $blogname The (subdomain or directory) name
+ * @return string
+ */
+function get_blogaddress_by_name( $blogname ) {
+	global $current_site;
+
+	if ( is_subdomain_install() ) {
+		if ( $blogname == 'main' )
+			$blogname = 'www';
+		$url = rtrim( network_home_url(), '/' );
+		if ( !empty( $blogname ) )
+			$url = preg_replace( '|^([^\.]+://)|', '$1' . $blogname . '.', $url );
+	} else {
+		$url = network_home_url( $blogname );
+	}
+	return esc_url( $url . '/' );
+}
+
+/**
+ * Get a full blog URL, given a domain and a path.
+ *
+ * @since MU
+ *
+ * @param string $domain
+ * @param string $path
+ * @return string
+ */
+function get_blogaddress_by_domain( $domain, $path ) {
+	if ( is_subdomain_install() ) {
+		$url = "http://".$domain.$path;
+	} else {
+		if ( $domain != $_SERVER['HTTP_HOST'] ) {
+			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
+			$url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path;
+			// we're not installing the main blog
+			if ( $blogname != 'www.' )
+				$url .= $blogname . '/';
+		} else { // main blog
+			$url = 'http://' . $domain . $path;
+		}
+	}
+	return esc_url( $url );
+}
+
+/**
+ * Given a blog's (subdomain or directory) name, retrieve it's id.
+ *
+ * @since MU
+ *
+ * @param string $name
+ * @return int A blog id
+ */
+function get_id_from_blogname( $name ) {
+	global $wpdb, $current_site;
+	$blog_id = wp_cache_get( "get_id_from_blogname_" . $name, 'blog-details' );
+	if ( $blog_id )
+		return $blog_id;
+
+	if ( is_subdomain_install() ) {
+		$domain = $name . '.' . $current_site->domain;
+		$path = $current_site->path;
+	} else {
+		$domain = $current_site->domain;
+		$path = $current_site->path . $name . '/';
+	}
+	$blog_id = $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $domain, $path) );
+	wp_cache_set( 'get_id_from_blogname_' . $name, $blog_id, 'blog-details' );
+	return $blog_id;
+}
+
+/**
+ * Retrieve the details for a blog from the blogs table and blog options.
+ *
+ * @since MU
+ *
+ * @param int|string|array $fields A blog ID, a blog name, or an array of fields to query against.
+ * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
+ * @return object Blog details.
+ */
+function get_blog_details( $fields, $get_all = true ) {
+	global $wpdb;
+
+	if ( is_array($fields ) ) {
+		if ( isset($fields['blog_id']) ) {
+			$blog_id = $fields['blog_id'];
+		} elseif ( isset($fields['domain']) && isset($fields['path']) ) {
+			$key = md5( $fields['domain'] . $fields['path'] );
+			$blog = wp_cache_get($key, 'blog-lookup');
+			if ( false !== $blog )
+				return $blog;
+			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
+				$nowww = substr( $fields['domain'], 4 );
+				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path'] ) );
+			} else {
+				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s AND path = %s", $fields['domain'], $fields['path'] ) );
+			}
+			if ( $blog ) {
+				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
+				$blog_id = $blog->blog_id;
+			} else {
+				return false;
+			}
+		} elseif ( isset($fields['domain']) && is_subdomain_install() ) {
+			$key = md5( $fields['domain'] );
+			$blog = wp_cache_get($key, 'blog-lookup');
+			if ( false !== $blog )
+				return $blog;
+			if ( substr( $fields['domain'], 0, 4 ) == 'www.' ) {
+				$nowww = substr( $fields['domain'], 4 );
+				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'] ) );
+			} else {
+				$blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE domain = %s", $fields['domain'] ) );
+			}
+			if ( $blog ) {
+				wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
+				$blog_id = $blog->blog_id;
+			} else {
+				return false;
+			}
+		} else {
+			return false;
+		}
+	} else {
+		if ( !is_numeric( $fields ) )
+			$blog_id = get_id_from_blogname( $fields );
+		else
+			$blog_id = $fields;
+	}
+
+	$blog_id = (int) $blog_id;
+
+	$all = $get_all == true ? '' : 'short';
+	$details = wp_cache_get( $blog_id . $all, 'blog-details' );
+
+	if ( $details ) {
+		if ( ! is_object( $details ) ) {
+			if ( $details == -1 ) {
+				return false;
+			} else {
+				// Clear old pre-serialized objects. Cache clients do better with that.
+				wp_cache_delete( $blog_id . $all, 'blog-details' );
+				unset($details);
+			}
+		} else {
+			return $details;
+		}
+	}
+
+	// Try the other cache.
+	if ( $get_all ) {
+		$details = wp_cache_get( $blog_id . 'short', 'blog-details' );
+	} else {
+		$details = wp_cache_get( $blog_id, 'blog-details' );
+		// If short was requested and full cache is set, we can return.
+		if ( $details ) {
+			if ( ! is_object( $details ) ) {
+				if ( $details == -1 ) {
+					return false;
+				} else {
+					// Clear old pre-serialized objects. Cache clients do better with that.
+					wp_cache_delete( $blog_id, 'blog-details' );
+					unset($details);
+				}
+			} else {
+				return $details;
+			}
+		}
+	}
+
+	if ( empty($details) ) {
+		$details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id ) );
+		if ( ! $details ) {
+			// Set the full cache.
+			wp_cache_set( $blog_id, -1, 'blog-details' );
+			return false;
+		}
+	}
+
+	if ( ! $get_all ) {
+		wp_cache_set( $blog_id . $all, $details, 'blog-details' );
+		return $details;
+	}
+
+	$details->blogname		= get_blog_option( $blog_id, 'blogname' );
+	$details->siteurl		= get_blog_option( $blog_id, 'siteurl' );
+	$details->post_count	= get_blog_option( $blog_id, 'post_count' );
+
+	$details = apply_filters( 'blog_details', $details );
+
+	wp_cache_set( $blog_id . $all, $details, 'blog-details' );
+
+	$key = md5( $details->domain . $details->path );
+	wp_cache_set( $key, $details, 'blog-lookup' );
+
+	return $details;
+}
+
+/**
+ * Clear the blog details cache.
+ *
+ * @since MU
+ *
+ * @param int $blog_id Blog ID
+ */
+function refresh_blog_details( $blog_id ) {
+	$blog_id = (int) $blog_id;
+	$details = get_blog_details( $blog_id, false );
+
+	wp_cache_delete( $blog_id , 'blog-details' );
+	wp_cache_delete( $blog_id . 'short' , 'blog-details' );
+	wp_cache_delete( md5( $details->domain . $details->path )  , 'blog-lookup' );
+	wp_cache_delete( 'current_blog_' . $details->domain, 'site-options' );
+	wp_cache_delete( 'current_blog_' . $details->domain . $details->path, 'site-options' );
+}
+
+/**
+ * Update the details for a blog. Updates the blogs table for a given blog id.
+ *
+ * @since MU
+ *
+ * @param int $blog_id Blog ID
+ * @param array $details Array of details keyed by blogs table field names.
+ * @return bool True if update succeeds, false otherwise.
+ */
+function update_blog_details( $blog_id, $details = array() ) {
+	global $wpdb;
+
+	if ( empty($details) )
+		return false;
+
+	if ( is_object($details) )
+		$details = get_object_vars($details);
+
+	$current_details = get_blog_details($blog_id, false);
+	if ( empty($current_details) )
+		return false;
+
+	$current_details = get_object_vars($current_details);
+
+	$details = array_merge($current_details, $details);
+	$details['last_updated'] = current_time('mysql', true);
+
+	$update_details = array();
+	$fields = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id');
+	foreach ( array_intersect( array_keys( $details ), $fields ) as $field )
+		$update_details[$field] = $details[$field];
+
+	$wpdb->update( $wpdb->blogs, $update_details, array('blog_id' => $blog_id) );
+
+	// If spam status changed, issue actions.
+	if ( $details[ 'spam' ] != $current_details[ 'spam' ] ) {
+		if ( $details[ 'spam' ] == 1 )
+			do_action( "make_spam_blog", $blog_id );
+		else
+			do_action( "make_ham_blog", $blog_id );
+	}
+
+	if ( isset($details[ 'public' ]) )
+		update_blog_option( $blog_id, 'blog_public', $details[ 'public' ] );
+
+	refresh_blog_details($blog_id);
+
+	return true;
+}
+
+/**
+ * Retrieve option value based on setting name and blog_id.
+ *
+ * If the option does not exist or does not have a value, then the return value
+ * will be false. This is useful to check whether you need to install an option
+ * and is commonly used during installation of plugin options and to test
+ * whether upgrading is required.
+ *
+ * There is a filter called 'blog_option_$option' with the $option being
+ * replaced with the option name. The filter takes two parameters. $value and
+ * $blog_id. It returns $value.
+ * The 'option_$option' filter in get_option() is not called.
+ *
+ * @since MU
+ * @uses apply_filters() Calls 'blog_option_$optionname' with the option name value.
+ *
+ * @param int $blog_id is the id of the blog.
+ * @param string $setting Name of option to retrieve. Should already be SQL-escaped.
+ * @param string $default (optional) Default value returned if option not found.
+ * @return mixed Value set for the option.
+ */
+function get_blog_option( $blog_id, $setting, $default = false ) {
+	global $wpdb;
+
+	$key = $blog_id."-".$setting."-blog_option";
+	$value = wp_cache_get( $key, "site-options" );
+	if ( $value == null ) {
+		if ( $blog_id == $wpdb->blogid ) {
+			$value = get_option( $setting, $default );
+			$notoptions = wp_cache_get( 'notoptions', 'options' );
+			if ( isset( $notoptions[$setting] ) ) {
+				wp_cache_set( $key, 'noop', 'site-options' );
+				$value = $default;
+			} elseif ( $value == false ) {
+				wp_cache_set( $key, 'falsevalue', 'site-options' );
+			} else {
+				wp_cache_set( $key, $value, 'site-options' );
+			}
+			return apply_filters( 'blog_option_' . $setting, $value, $blog_id );
+		} else {
+			$blog_prefix = $wpdb->get_blog_prefix( $blog_id );
+			$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$blog_prefix}options WHERE option_name = %s", $setting ) );
+			if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
+				$value = $row->option_value;
+				if ( $value == false )
+					wp_cache_set( $key, 'falsevalue', 'site-options' );
+				else
+					wp_cache_set( $key, $value, 'site-options' );
+			} else { // option does not exist, so we must cache its non-existence
+				wp_cache_set( $key, 'noop', 'site-options' );
+				$value = $default;
+			}
+		}
+	} elseif ( $value == 'noop' ) {
+		$value = $default;
+	} elseif ( $value == 'falsevalue' ) {
+		$value = false;
+	}
+	// If home is not set use siteurl.
+	if ( 'home' == $setting && '' == $value )
+		return get_blog_option( $blog_id, 'siteurl' );
+
+	if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
+		$value = untrailingslashit( $value );
+
+	return apply_filters( 'blog_option_' . $setting, maybe_unserialize( $value ), $blog_id );
+}
+
+/**
+ * Add an option for a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $key The option key
+ * @param mixed $value The option value
+ */
+function add_blog_option( $id, $key, $value ) {
+	$id = (int) $id;
+
+	switch_to_blog($id);
+	add_option( $key, $value );
+	restore_current_blog();
+	wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options' );
+}
+
+/**
+ * Delete an option for a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $key The option key
+ */
+function delete_blog_option( $id, $key ) {
+	$id = (int) $id;
+
+	switch_to_blog($id);
+	delete_option( $key );
+	restore_current_blog();
+	wp_cache_set( $id."-".$key."-blog_option", '', 'site-options' );
+}
+
+/**
+ * Update an option for a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $key The option key
+ * @param mixed $value The option value
+ */
+function update_blog_option( $id, $key, $value, $deprecated = null ) {
+	$id = (int) $id;
+
+	if ( null !== $deprecated  )
+		_deprecated_argument( __FUNCTION__, '3.1' );
+
+	switch_to_blog($id);
+	update_option( $key, $value );
+	restore_current_blog();
+
+	refresh_blog_details( $id );
+
+	wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options');
+}
+
+/**
+ * Switch the current blog.
+ *
+ * This function is useful if you need to pull posts, or other information,
+ * from other blogs. You can switch back afterwards using restore_current_blog().
+ *
+ * Things that aren't switched:
+ *  - autoloaded options. See #14992
+ *  - plugins. See #14941
+ *
+ * @see restore_current_blog()
+ * @since MU
+ *
+ * @param int $new_blog The id of the blog you want to switch to. Default: current blog
+ * @param bool $validate Whether to check if $new_blog exists before proceeding
+ * @return bool	True on success, False if the validation failed
+ */
+function switch_to_blog( $new_blog, $validate = false ) {
+	global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
+
+	if ( empty($new_blog) )
+		$new_blog = $blog_id;
+
+	if ( $validate && ! get_blog_details( $new_blog ) )
+		return false;
+
+	if ( empty($switched_stack) )
+		$switched_stack = array();
+
+	$switched_stack[] = $blog_id;
+
+	/* If we're switching to the same blog id that we're on,
+	* set the right vars, do the associated actions, but skip
+	* the extra unnecessary work */
+	if ( $blog_id == $new_blog ) {
+		do_action( 'switch_blog', $blog_id, $blog_id );
+		$switched = true;
+		return true;
+	}
+
+	$wpdb->set_blog_id($new_blog);
+	$table_prefix = $wpdb->prefix;
+	$prev_blog_id = $blog_id;
+	$blog_id = $new_blog;
+
+	if ( is_object( $wp_roles ) ) {
+		$wpdb->suppress_errors();
+		if ( method_exists( $wp_roles ,'_init' ) )
+			$wp_roles->_init();
+		elseif ( method_exists( $wp_roles, '__construct' ) )
+			$wp_roles->__construct();
+		$wpdb->suppress_errors( false );
+	}
+
+	if ( did_action('init') ) {
+		$current_user = wp_get_current_user();
+		if ( is_object( $current_user ) )
+			$current_user->for_blog( $blog_id );
+	}
+
+	if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
+		$global_groups = $wp_object_cache->global_groups;
+	else
+		$global_groups = false;
+
+	wp_cache_init();
+	if ( function_exists('wp_cache_add_global_groups') ) {
+		if ( is_array( $global_groups ) )
+			wp_cache_add_global_groups( $global_groups );
+		else
+			wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );
+		wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
+	}
+
+	do_action('switch_blog', $blog_id, $prev_blog_id);
+	$switched = true;
+	return true;
+}
+
+/**
+ * Restore the current blog, after calling switch_to_blog()
+ *
+ * @see switch_to_blog()
+ * @since MU
+ *
+ * @return bool True on success, False if we're already on the current blog
+ */
+function restore_current_blog() {
+	global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
+
+	if ( !$switched )
+		return false;
+
+	if ( !is_array( $switched_stack ) )
+		return false;
+
+	$blog = array_pop( $switched_stack );
+	if ( $blog_id == $blog ) {
+		do_action( 'switch_blog', $blog, $blog );
+		/* If we still have items in the switched stack, consider ourselves still 'switched' */
+		$switched = ( is_array( $switched_stack ) && count( $switched_stack ) > 0 );
+		return true;
+	}
+
+	$wpdb->set_blog_id($blog);
+	$prev_blog_id = $blog_id;
+	$blog_id = $blog;
+	$table_prefix = $wpdb->prefix;
+
+	if ( is_object( $wp_roles ) ) {
+		$wpdb->suppress_errors();
+		if ( method_exists( $wp_roles ,'_init' ) )
+			$wp_roles->_init();
+		elseif ( method_exists( $wp_roles, '__construct' ) )
+			$wp_roles->__construct();
+		$wpdb->suppress_errors( false );
+	}
+
+	if ( did_action('init') ) {
+		$current_user = wp_get_current_user();
+		if ( is_object( $current_user ) )
+			$current_user->for_blog( $blog_id );
+	}
+
+	if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
+		$global_groups = $wp_object_cache->global_groups;
+	else
+		$global_groups = false;
+
+	wp_cache_init();
+	if ( function_exists('wp_cache_add_global_groups') ) {
+		if ( is_array( $global_groups ) )
+			wp_cache_add_global_groups( $global_groups );
+		else
+			wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts' ) );
+		wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
+	}
+
+	do_action('switch_blog', $blog_id, $prev_blog_id);
+
+	/* If we still have items in the switched stack, consider ourselves still 'switched' */
+	$switched = ( is_array( $switched_stack ) && count( $switched_stack ) > 0 );
+	return true;
+}
+
+/**
+ * Check if a particular blog is archived.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @return string Whether the blog is archived or not
+ */
+function is_archived( $id ) {
+	return get_blog_status($id, 'archived');
+}
+
+/**
+ * Update the 'archived' status of a particular blog.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $archived The new status
+ * @return string $archived
+ */
+function update_archived( $id, $archived ) {
+	update_blog_status($id, 'archived', $archived);
+	return $archived;
+}
+
+/**
+ * Update a blog details field.
+ *
+ * @since MU
+ *
+ * @param int $blog_id BLog ID
+ * @param string $pref A field name
+ * @param string $value Value for $pref
+ * @return string $value
+ */
+function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
+	global $wpdb;
+
+	if ( null !== $deprecated  )
+		_deprecated_argument( __FUNCTION__, '3.1' );
+
+	if ( !in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id') ) )
+		return $value;
+
+	$wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $blog_id) );
+
+	refresh_blog_details($blog_id);
+
+	if ( 'spam' == $pref )
+		( $value == 1 ) ? do_action( 'make_spam_blog', $blog_id ) :	do_action( 'make_ham_blog', $blog_id );
+	elseif ( 'mature' == $pref )
+		( $value == 1 ) ? do_action( 'mature_blog', $blog_id ) : do_action( 'unmature_blog', $blog_id );
+	elseif ( 'archived' == $pref )
+		( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
+	elseif ( 'archived' == $pref )
+		( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id );
+
+	return $value;
+}
+
+/**
+ * Get a blog details field.
+ *
+ * @since MU
+ *
+ * @param int $id The blog id
+ * @param string $pref A field name
+ * @return bool $value
+ */
+function get_blog_status( $id, $pref ) {
+	global $wpdb;
+
+	$details = get_blog_details( $id, false );
+	if ( $details )
+		return $details->$pref;
+
+	return $wpdb->get_var( $wpdb->prepare("SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref, $id) );
+}
+
+/**
+ * Get a list of most recently updated blogs.
+ *
+ * @since MU
+ *
+ * @param mixed $deprecated Not used
+ * @param int $start The offset
+ * @param int $quantity The maximum number of blogs to retrieve. Default is 40.
+ * @return array The list of blogs
+ */
+function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
+	global $wpdb;
+
+	if ( ! empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, 'MU' ); // never used
+
+	return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
+}
+
+?>
Index: /tags/3.1/wp-includes/ms-default-constants.php
===================================================================
--- /tags/3.1/wp-includes/ms-default-constants.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-default-constants.php	(revision 17487)
@@ -0,0 +1,140 @@
+<?php
+/**
+ * Defines constants and global variables that can be overridden, generally in wp-config.php.
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/**
+ * Defines Multisite upload constants.
+ *
+ * @since 3.0.0
+ */
+function ms_upload_constants(  ) {
+	global $wpdb;
+
+	/** @since 3.0.0 */
+	// Base uploads dir relative to ABSPATH
+	if ( !defined( 'UPLOADBLOGSDIR' ) )
+		define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
+
+	/** @since 3.0.0 */
+	if ( !defined( 'UPLOADS' ) ) {
+		// Uploads dir relative to ABSPATH
+		define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
+		if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR )
+			define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
+	}
+}
+
+/**
+ * Defines Multisite cookie constants.
+ *
+ * @since 3.0.0
+ */
+function ms_cookie_constants(  ) {
+	global $current_site;
+
+	/**
+	 * @since 1.2.0
+	 */
+	if ( !defined( 'COOKIEPATH' ) )
+		define( 'COOKIEPATH', $current_site->path );
+
+	/**
+	 * @since 1.5.0
+	 */
+	if ( !defined( 'SITECOOKIEPATH' ) )
+		define( 'SITECOOKIEPATH', $current_site->path );
+
+	/**
+	 * @since 2.6.0
+	 */
+	if ( !defined( 'ADMIN_COOKIE_PATH' ) ) {
+		if( !is_subdomain_install() ) {
+			define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
+		} else {
+			define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
+		}
+	}
+
+	/**
+	 * @since 2.0.0
+	 */
+	if ( !defined('COOKIE_DOMAIN') && is_subdomain_install() ) {
+		if ( !empty( $current_site->cookie_domain ) )
+			define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
+		else
+			define('COOKIE_DOMAIN', '.' . $current_site->domain);
+	}
+}
+
+/**
+ * Defines Multisite file constants.
+ *
+ * @since 3.0.0
+ */
+function ms_file_constants(  ) {
+	/**
+	 * Optional support for X-Sendfile header
+	 * @since 3.0.0
+	 */
+	if ( !defined( 'WPMU_SENDFILE' ) )
+		define( 'WPMU_SENDFILE', false );
+
+	/**
+	 * Optional support for X-Accel-Redirect header
+	 * @since 3.0.0
+	 */
+	if ( !defined( 'WPMU_ACCEL_REDIRECT' ) )
+		define( 'WPMU_ACCEL_REDIRECT', false );
+}
+
+/**
+ * Defines Multisite subdomain constants and handles warnings and notices.
+ *
+ * VHOST is deprecated in favor of SUBDOMAIN_INSTALL, which is a bool.
+ *
+ * On first call, the constants are checked and defined. On second call,
+ * we will have translations loaded and can trigger warnings easily.
+ *
+ * @since 3.0.0
+ */
+function ms_subdomain_constants() {
+	static $error = null;
+	static $error_warn = false;
+
+	if ( false === $error )
+		return;
+
+	if ( $error ) {
+		$vhost_deprecated = __( 'The constant <code>VHOST</code> <strong>is deprecated</strong>. Use the boolean constant <code>SUBDOMAIN_INSTALL</code> in wp-config.php to enable a subdomain configuration. Use is_subdomain_install() to check whether a subdomain configuration is enabled.' );
+		if ( $error_warn ) {
+			trigger_error( __( '<strong>Conflicting values for the constants VHOST and SUBDOMAIN_INSTALL.</strong> The value of SUBDOMAIN_INSTALL will be assumed to be your subdomain configuration setting.' ) . ' ' . $vhost_deprecated, E_USER_WARNING );
+		} else {
+	 		_deprecated_argument( 'define()', '3.0', $vhost_deprecated );
+		}
+		return;
+	}
+
+	if ( defined( 'SUBDOMAIN_INSTALL' ) && defined( 'VHOST' ) ) {
+		if ( SUBDOMAIN_INSTALL == ( 'yes' == VHOST ) ) {
+			$error = true;
+		} else {
+			$error = $error_warn = true;
+		}
+	} elseif ( defined( 'SUBDOMAIN_INSTALL' ) ) {
+		define( 'VHOST', SUBDOMAIN_INSTALL ? 'yes' : 'no' );
+	} elseif ( defined( 'VHOST' ) ) {
+		$error = true;
+		define( 'SUBDOMAIN_INSTALL', 'yes' == VHOST );
+	} else {
+		define( 'SUBDOMAIN_INSTALL', false );
+		define( 'VHOST', 'no' );
+	}
+}
+add_action( 'init', 'ms_subdomain_constants' );
+
+?>
Index: /tags/3.1/wp-includes/ms-default-filters.php
===================================================================
--- /tags/3.1/wp-includes/ms-default-filters.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-default-filters.php	(revision 17487)
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Sets up the default filters and actions for Multisite.
+ *
+ * If you need to remove a default hook, this file will give you the priority
+ * for which to use to remove the hook.
+ *
+ * Not all of the Multisite default hooks are found in ms-default-filters.php
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @see default-filters.php
+ * @since 3.0.0
+ */
+
+// Users
+add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' );
+add_action( 'init', 'maybe_add_existing_user_to_blog' );
+add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' );
+add_action( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
+add_action( 'sanitize_user', 'strtolower' );
+
+// Blogs
+add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' );
+add_action( 'wpmu_new_blog', 'wpmu_log_new_registrations', 10, 2 );
+add_action( 'wpmu_new_blog', 'newblog_notify_siteadmin', 10, 2 );
+
+// Register Nonce
+add_action( 'signup_hidden_fields', 'signup_nonce_fields' );
+
+// Template
+add_action( 'template_redirect', 'maybe_redirect_404' );
+add_filter( 'allowed_redirect_hosts', 'redirect_this_site' );
+
+// Administration
+add_filter( 'term_id_filter', 'global_terms', 10, 2 );
+add_action( 'publish_post', 'update_posts_count' );
+add_action( 'delete_post', 'wpmu_update_blogs_date' );
+add_action( 'private_to_published', 'wpmu_update_blogs_date' );
+add_action( 'publish_phone', 'wpmu_update_blogs_date' );
+add_action( 'publish_post', 'wpmu_update_blogs_date' );
+add_action( 'admin_init', 'wp_schedule_update_network_counts');
+add_action( 'update_network_counts', 'wp_update_network_counts');
+
+// Files
+add_filter( 'wp_upload_bits', 'upload_is_file_too_big' );
+add_filter( 'import_upload_size_limit', 'fix_import_form_size' );
+add_filter( 'upload_mimes', 'check_upload_mimes' );
+add_filter( 'upload_size_limit', 'upload_size_limit_filter' );
+
+// Mail
+add_action( 'phpmailer_init', 'fix_phpmailer_messageid' );
+
+// Disable somethings by default for multisite
+add_filter( 'enable_update_services_configuration', '__return_false' );
+if ( ! defined('POST_BY_EMAIL') || ! POST_BY_EMAIL ) // back compat constant.
+	add_filter( 'enable_post_by_email_configuration', '__return_false' );
+if ( ! defined('EDIT_ANY_USER') || ! EDIT_ANY_USER ) // back compat constant.
+	add_filter( 'enable_edit_any_user_configuration', '__return_false' );
+add_filter( 'force_filtered_html_on_import', '__return_true' );
+
+// WP_HOME and WP_SITEURL should not have any effect in MS
+remove_filter( 'option_siteurl', '_config_wp_siteurl' );
+remove_filter( 'option_home',    '_config_wp_home'    );
+
+?>
Index: /tags/3.1/wp-includes/ms-deprecated.php
===================================================================
--- /tags/3.1/wp-includes/ms-deprecated.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-deprecated.php	(revision 17487)
@@ -0,0 +1,203 @@
+<?php
+/**
+ * Deprecated functions from WordPress MU and the multisite feature. You shouldn't
+ * use these functions and look for the alternatives instead. The functions will be
+ * removed in a later version.
+ *
+ * @package WordPress
+ * @subpackage Deprecated
+ * @since 3.0.0
+ */
+
+/*
+ * Deprecated functions come here to die.
+ */
+
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use wp_generate_password()
+ * @see wp_generate_password()
+ */
+function generate_random_password( $len = 8 ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'wp_generate_password()' );
+	return wp_generate_password( $len );
+}
+
+/**
+ * Determine if user is a site admin.
+ *
+ * Plugins should use is_multisite() instead of checking if this function exists
+ * to determine if multisite is enabled.
+ *
+ * This function must reside in a file included only if is_multisite() due to
+ * legacy function_exists() checks to determine if multisite is enabled.
+ *
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use is_super_admin()
+ * @see is_super_admin()
+ * @see is_multisite()
+ *
+ */
+function is_site_admin( $user_login = '' ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'is_super_admin()' );
+
+	if ( empty( $user_login ) ) {
+		$user_id = get_current_user_id();
+		if ( !$user_id )
+			return false;
+	} else {
+		$user = get_user_by( 'login', $user_login );
+		if ( empty( $user->ID ) )
+			return false;
+		$user_id = $user->ID;
+	}
+
+	return is_super_admin( $user_id );
+}
+
+if ( !function_exists( 'graceful_fail' ) ) :
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use wp_die()
+ * @see wp_die()
+ */
+function graceful_fail( $message ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'wp_die()' );
+	$message = apply_filters( 'graceful_fail', $message );
+	$message_template = apply_filters( 'graceful_fail_template',
+'<!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 profile="http://gmpg.org/xfn/11">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>Error!</title>
+<style type="text/css">
+img {
+	border: 0;
+}
+body {
+line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto;
+text-align: center;
+}
+.message {
+	font-size: 22px;
+	width: 350px;
+	margin: auto;
+}
+</style>
+</head>
+<body>
+<p class="message">%s</p>
+</body>
+</html>' );
+	die( sprintf( $message_template, $message ) );
+}
+endif;
+
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use get_user_by()
+ * @see get_user_by()
+ */
+function get_user_details( $username ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'get_user_by()' );
+	return get_user_by('login', $username);
+}
+
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use clean_post_cache()
+ * @see clean_post_cache()
+ */
+function clear_global_post_cache( $post_id ) {
+	_deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache()' );
+}
+
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use is_main_site()
+ * @see is_main_site()
+ */
+function is_main_blog() {
+	_deprecated_function( __FUNCTION__, '3.0', 'is_main_site()' );
+	return is_main_site();
+}
+
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use is_email()
+ * @see is_email()
+ */
+function validate_email( $email, $check_domain = true) {
+	_deprecated_function( __FUNCTION__, '3.0', 'is_email()' );
+	return is_email( $email, $check_domain );
+}
+
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated No alternative available. For performance reasons this function is not recommended.
+ */
+function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
+	_deprecated_function( __FUNCTION__, '3.0' );
+
+	global $wpdb;
+	$blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
+
+	foreach ( (array) $blogs as $details ) {
+		$blog_list[ $details['blog_id'] ] = $details;
+		$blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
+	}
+	unset( $blogs );
+	$blogs = $blog_list;
+
+	if ( false == is_array( $blogs ) )
+		return array();
+
+	if ( $num == 'all' )
+		return array_slice( $blogs, $start, count( $blogs ) );
+	else
+		return array_slice( $blogs, $start, $num );
+}
+
+/**
+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated No alternative available. For performance reasons this function is not recommended.
+ */
+function get_most_active_blogs( $num = 10, $display = true ) {
+	_deprecated_function( __FUNCTION__, '3.0' );
+
+	$blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
+	if ( is_array( $blogs ) ) {
+		reset( $blogs );
+		foreach ( (array) $blogs as $key => $details ) {
+			$most_active[ $details['blog_id'] ] = $details['postcount'];
+			$blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
+		}
+		arsort( $most_active );
+		reset( $most_active );
+		foreach ( (array) $most_active as $key => $details )
+			$t[ $key ] = $blog_list[ $key ];
+
+		unset( $most_active );
+		$most_active = $t;
+	}
+
+	if ( $display == true ) {
+		if ( is_array( $most_active ) ) {
+			reset( $most_active );
+			foreach ( (array) $most_active as $key => $details ) {
+				$url = esc_url('http://' . $details['domain'] . $details['path']);
+				echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
+			}
+		}
+	}
+	return array_slice( $most_active, 0, $num );
+}
+?>
Index: /tags/3.1/wp-includes/ms-files.php
===================================================================
--- /tags/3.1/wp-includes/ms-files.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-files.php	(revision 17487)
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Multisite upload handler.
+ *
+ * @since 3.0.0
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ */
+
+define( 'SHORTINIT', true );
+require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
+
+if( !is_multisite() )
+	die( 'Multisite support not enabled' );
+
+ms_file_constants();
+
+error_reporting( 0 );
+
+if ( $current_blog->archived == '1' || $current_blog->spam == '1' || $current_blog->deleted == '1' ) {
+	status_header( 404 );
+	die( '404 &#8212; File not found.' );
+}
+
+$file = BLOGUPLOADDIR . str_replace( '..', '', $_GET[ 'file' ] );
+if ( !is_file( $file ) ) {
+	status_header( 404 );
+	die( '404 &#8212; File not found.' );
+}
+
+$mime = wp_check_filetype( $file );
+if( false === $mime[ 'type' ] && function_exists( 'mime_content_type' ) )
+	$mime[ 'type' ] = mime_content_type( $file );
+
+if( $mime[ 'type' ] )
+	$mimetype = $mime[ 'type' ];
+else
+	$mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 );
+
+header( 'Content-type: ' . $mimetype ); // always send this
+if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) )
+	header( 'Content-Length: ' . filesize( $file ) );
+
+// Optional support for X-Sendfile and X-Accel-Redirect
+if ( WPMU_ACCEL_REDIRECT ) {
+	header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) );
+	exit;
+} elseif ( WPMU_SENDFILE ) {
+	header( 'X-Sendfile: ' . $file );
+	exit;
+}
+
+$last_modified = gmdate( 'D, d M Y H:i:s', filemtime( $file ) );
+$etag = '"' . md5( $last_modified ) . '"';
+header( "Last-Modified: $last_modified GMT" );
+header( 'ETag: ' . $etag );
+header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
+
+// Support for Conditional GET
+$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
+
+if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
+	$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
+
+$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
+// If string is empty, return 0. If not, attempt to parse into a timestamp
+$client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0;
+
+// Make a timestamp for our most recent modification...
+$modified_timestamp = strtotime($last_modified);
+
+if ( ( $client_last_modified && $client_etag )
+	? ( ( $client_modified_timestamp >= $modified_timestamp) && ( $client_etag == $etag ) )
+	: ( ( $client_modified_timestamp >= $modified_timestamp) || ( $client_etag == $etag ) )
+	) {
+	status_header( 304 );
+	exit;
+}
+
+// If we made it this far, just serve the file
+readfile( $file );
+?>
Index: /tags/3.1/wp-includes/ms-functions.php
===================================================================
--- /tags/3.1/wp-includes/ms-functions.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-functions.php	(revision 17487)
@@ -0,0 +1,2076 @@
+<?php
+/**
+ * Multi-site WordPress API
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+/**
+ * Gets the network's site and user counts.
+ *
+ * @since MU 1.0
+ * @uses get_blog_count()
+ * @uses get_user_count()
+ *
+ * @return array Site and user count for the network.
+ */
+function get_sitestats() {
+	global $wpdb;
+
+	$stats['blogs'] = get_blog_count();
+	$stats['users'] = get_user_count();
+
+	return $stats;
+}
+
+/**
+ * Get the admin for a domain/path combination.
+ *
+ * @since MU 1.0
+ *
+ * @param string $sitedomain Optional. Site domain.
+ * @param string $path Optional. Site path.
+ * @return array The network admins
+ */
+function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
+	global $wpdb;
+
+	if ( ! $sitedomain )
+		$site_id = $wpdb->siteid;
+	else
+		$site_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path ) );
+
+	if ( $site_id )
+		return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $site_id ), ARRAY_A );
+
+	return false;
+}
+
+/**
+ * Get one of a user's active blogs
+ *
+ * Returns the user's primary blog, if she has one and
+ * it is active. If it's inactive, function returns another
+ * active blog of the user. If none are found, the user
+ * is added as a Subscriber to the Dashboard Blog and that blog
+ * is returned.
+ *
+ * @since MU 1.0
+ * @uses get_blogs_of_user()
+ * @uses add_user_to_blog()
+ * @uses get_blog_details()
+ *
+ * @param int $user_id The unique ID of the user
+ * @return object The blog object
+ */
+function get_active_blog_for_user( $user_id ) {
+	global $wpdb;
+	$blogs = get_blogs_of_user( $user_id );
+	if ( empty( $blogs ) )
+		return null;
+
+	if ( !is_multisite() )
+		return $blogs[$wpdb->blogid];
+
+	$primary_blog = get_user_meta( $user_id, 'primary_blog', true );
+	$first_blog = current($blogs);
+	if ( false !== $primary_blog ) {
+		if ( ! isset( $blogs[ $primary_blog ] ) ) {
+			update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
+			$primary = $first_blog;
+		} else {
+			$primary = get_blog_details( $primary_blog );
+		}
+	} else {
+		//TODO Review this call to add_user_to_blog too - to get here the user must have a role on this blog?
+		add_user_to_blog( $first_blog->userblog_id, $user_id, 'subscriber' );
+		update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
+		$primary = $first_blog;
+	}
+
+	if ( ( ! is_object( $primary ) ) || ( is_object( $primary ) && $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) {
+		$blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs.
+		$ret = false;
+		if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
+			foreach ( (array) $blogs as $blog_id => $blog ) {
+				if ( $blog->site_id != $wpdb->siteid )
+					continue;
+				$details = get_blog_details( $blog_id );
+				if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
+					$ret = $blog;
+					if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id )
+						update_user_meta( $user_id, 'primary_blog', $blog_id );
+					if ( !get_user_meta($user_id , 'source_domain', true) )
+						update_user_meta( $user_id, 'source_domain', $blog->domain );
+					break;
+				}
+			}
+		} else {
+			return null;
+		}
+		return $ret;
+	} else {
+		return $primary;
+	}
+}
+
+/**
+ * Find out whether a user is a member of a given blog.
+ *
+ * @since MU 1.1
+ * @uses get_blogs_of_user()
+ *
+ * @param int $user_id The unique ID of the user
+ * @param int $blog Optional. If no blog_id is provided, current site is used
+ * @return bool
+ */
+function is_user_member_of_blog( $user_id, $blog_id = 0 ) {
+	$user_id = (int) $user_id;
+	$blog_id = (int) $blog_id;
+
+	if ( $blog_id == 0 ) {
+		global $wpdb;
+		$blog_id = $wpdb->blogid;
+	}
+
+	$blogs = get_blogs_of_user( $user_id );
+	if ( is_array( $blogs ) )
+		return array_key_exists( $blog_id, $blogs );
+	else
+		return false;
+}
+
+/**
+ * The number of active users in your installation.
+ *
+ * The count is cached and updated twice daily. This is not a live count.
+ *
+ * @since MU 2.7
+ *
+ * @return int
+ */
+function get_user_count() {
+	return get_site_option( 'user_count' );
+}
+
+/**
+ * The number of active sites on your installation.
+ *
+ * The count is cached and updated twice daily. This is not a live count.
+ *
+ * @since MU 1.0
+ *
+ * @param int $id Optional. A site_id.
+ * @return int
+ */
+function get_blog_count( $id = 0 ) {
+	return get_site_option( 'blog_count' );
+}
+
+/**
+ * Get a blog post from any site on the network.
+ *
+ * @since MU 1.0
+ *
+ * @param int $blog_id ID of the blog.
+ * @param int $post_id ID of the post you're looking for.
+ * @return object The post.
+ */
+function get_blog_post( $blog_id, $post_id ) {
+	global $wpdb;
+
+	$key = $blog_id . '-' . $post_id;
+	$post = wp_cache_get( $key, 'global-posts' );
+	if ( $post == false ) {
+		$post = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->get_blog_prefix( $blog_id ) . 'posts WHERE ID = %d', $post_id ) );
+		wp_cache_add( $key, $post, 'global-posts' );
+	}
+
+	return $post;
+}
+
+/**
+ * Add a user to a blog.
+ *
+ * Use the 'add_user_to_blog' action to fire an event when
+ * users are added to a blog.
+ *
+ * @since MU 1.0
+ *
+ * @param int $blog_id ID of the blog you're adding the user to.
+ * @param int $user_id ID of the user you're adding.
+ * @param string $role The role you want the user to have
+ * @return bool
+ */
+function add_user_to_blog( $blog_id, $user_id, $role ) {
+	switch_to_blog($blog_id);
+
+	$user = new WP_User($user_id);
+
+	if ( empty( $user->ID ) ) {
+		restore_current_blog();
+		return new WP_Error('user_does_not_exist', __('That user does not exist.'));
+	}
+
+	if ( !get_user_meta($user_id, 'primary_blog', true) ) {
+		update_user_meta($user_id, 'primary_blog', $blog_id);
+		$details = get_blog_details($blog_id);
+		update_user_meta($user_id, 'source_domain', $details->domain);
+	}
+
+	$user->set_role($role);
+
+	do_action('add_user_to_blog', $user_id, $role, $blog_id);
+	wp_cache_delete( $user_id, 'users' );
+	restore_current_blog();
+	return true;
+}
+
+/**
+ * Remove a user from a blog.
+ *
+ * Use the 'remove_user_from_blog' action to fire an event when
+ * users are removed from a blog.
+ *
+ * Accepts an optional $reassign parameter, if you want to
+ * reassign the user's blog posts to another user upon removal.
+ *
+ * @since MU 1.0
+ *
+ * @param int $user_id ID of the user you're removing.
+ * @param int $blog_id ID of the blog you're removing the user from.
+ * @param string $reassign Optional. A user to whom to reassign posts.
+ * @return bool
+ */
+function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
+	global $wpdb;
+	switch_to_blog($blog_id);
+	$user_id = (int) $user_id;
+	do_action('remove_user_from_blog', $user_id, $blog_id);
+
+	// If being removed from the primary blog, set a new primary if the user is assigned
+	// to multiple blogs.
+	$primary_blog = get_user_meta($user_id, 'primary_blog', true);
+	if ( $primary_blog == $blog_id ) {
+		$new_id = '';
+		$new_domain = '';
+		$blogs = get_blogs_of_user($user_id);
+		foreach ( (array) $blogs as $blog ) {
+			if ( $blog->userblog_id == $blog_id )
+				continue;
+			$new_id = $blog->userblog_id;
+			$new_domain = $blog->domain;
+			break;
+		}
+
+		update_user_meta($user_id, 'primary_blog', $new_id);
+		update_user_meta($user_id, 'source_domain', $new_domain);
+	}
+
+	// wp_revoke_user($user_id);
+	$user = new WP_User($user_id);
+	if ( empty( $user->ID ) ) {
+		restore_current_blog();
+		return new WP_Error('user_does_not_exist', __('That user does not exist.'));
+	}
+
+	$user->remove_all_caps();
+
+	$blogs = get_blogs_of_user($user_id);
+	if ( count($blogs) == 0 ) {
+		update_user_meta($user_id, 'primary_blog', '');
+		update_user_meta($user_id, 'source_domain', '');
+	}
+
+	if ( $reassign != '' ) {
+		$reassign = (int) $reassign;
+		$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) );
+		$wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id) );
+	}
+
+	restore_current_blog();
+}
+
+/**
+ * Create an empty blog.
+ *
+ * @since MU 1.0
+ * @uses install_blog()
+ *
+ * @param string $domain The new blog's domain.
+ * @param string $path The new blog's path.
+ * @param string $string The new blog's title.
+ * @param int $site Optional. Defaults to 1.
+ * @return int The ID of the newly created blog
+ */
+function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
+	$domain			= addslashes( $domain );
+	$weblog_title	= addslashes( $weblog_title );
+
+	if ( empty($path) )
+		$path = '/';
+
+	// Check if the domain has been used already. We should return an error message.
+	if ( domain_exists($domain, $path, $site_id) )
+		return __( 'Error: Site URL already taken.' );
+
+	// Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
+	// Need to get blog_id from wp_blogs, and create new table names.
+	// Must restore table names at the end of function.
+
+	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
+		return __( 'Error: problem creating site entry.' );
+
+	switch_to_blog($blog_id);
+	install_blog($blog_id);
+	restore_current_blog();
+
+	return $blog_id;
+}
+
+/**
+ * Get the permalink for a post on another blog.
+ *
+ * @since MU 1.0
+ *
+ * @param int $_blog_id ID of the source blog.
+ * @param int $post_id ID of the desired post.
+ * @return string The post's permalink
+ */
+function get_blog_permalink( $_blog_id, $post_id ) {
+	$key = "{$_blog_id}-{$post_id}-blog_permalink";
+	$link = wp_cache_get( $key, 'site-options' );
+	if ( $link == false ) {
+		switch_to_blog( $_blog_id );
+		$link = get_permalink( $post_id );
+		restore_current_blog();
+		wp_cache_add( $key, $link, 'site-options', 360 );
+	}
+	return $link;
+}
+
+/**
+ * Get a blog's numeric ID from its URL.
+ *
+ * On a subdirectory installation like example.com/blog1/,
+ * $domain will be the root 'example.com' and $path the
+ * subdirectory '/blog1/'. With subdomains like blog1.example.com,
+ * $domain is 'blog1.example.com' and $path is '/'.
+ *
+ * @since MU 2.6.5
+ *
+ * @param string $domain
+ * @param string $path Optional. Not required for subdomain installations.
+ * @return int
+ */
+function get_blog_id_from_url( $domain, $path = '/' ) {
+	global $wpdb;
+
+	$domain = strtolower( $wpdb->escape( $domain ) );
+	$path = strtolower( $wpdb->escape( $path ) );
+	$id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
+
+	if ( $id == -1 ) { // blog does not exist
+		return 0;
+	} elseif ( $id ) {
+		return (int)$id;
+	}
+
+	$id = $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs WHERE domain = '$domain' and path = '$path' /* get_blog_id_from_url */" );
+
+	if ( !$id ) {
+		wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );
+		return false;
+	}
+	wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );
+
+	return $id;
+}
+
+// Admin functions
+
+/**
+ * Redirect a user based on $_GET or $_POST arguments.
+ *
+ * The function looks for redirect arguments in the following order:
+ * 1) $_GET['ref']
+ * 2) $_POST['ref']
+ * 3) $_SERVER['HTTP_REFERER']
+ * 4) $_GET['redirect']
+ * 5) $_POST['redirect']
+ * 6) $url
+ *
+ * @since MU
+ * @uses wpmu_admin_redirect_add_updated_param()
+ *
+ * @param string $url
+ */
+function wpmu_admin_do_redirect( $url = '' ) {
+	$ref = '';
+	if ( isset( $_GET['ref'] ) )
+		$ref = $_GET['ref'];
+	if ( isset( $_POST['ref'] ) )
+		$ref = $_POST['ref'];
+
+	if ( $ref ) {
+		$ref = wpmu_admin_redirect_add_updated_param( $ref );
+		wp_redirect( $ref );
+		exit();
+	}
+	if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
+		wp_redirect( $_SERVER['HTTP_REFERER'] );
+		exit();
+	}
+
+	$url = wpmu_admin_redirect_add_updated_param( $url );
+	if ( isset( $_GET['redirect'] ) ) {
+		if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
+			$url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
+	} elseif ( isset( $_POST['redirect'] ) ) {
+		$url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
+	}
+	wp_redirect( $url );
+	exit();
+}
+
+/**
+ * Adds an 'updated=true' argument to a URL.
+ *
+ * @since MU
+ *
+ * @param string $url
+ * @return string
+ */
+function wpmu_admin_redirect_add_updated_param( $url = '' ) {
+	if ( strpos( $url, 'updated=true' ) === false ) {
+		if ( strpos( $url, '?' ) === false )
+			return $url . '?updated=true';
+		else
+			return $url . '&updated=true';
+	}
+	return $url;
+}
+
+/**
+ * Checks an email address against a list of banned domains.
+ *
+ * This function checks against the Banned Email Domains list
+ * at wp-admin/network/settings.php. The check is only run on
+ * self-registrations; user creation at wp-admin/network/users.php
+ * bypasses this check.
+ *
+ * @since MU
+ *
+ * @param string $user_email The email provided by the user at registration.
+ * @return bool Returns true when the email address is banned.
+ */
+function is_email_address_unsafe( $user_email ) {
+	$banned_names = get_site_option( 'banned_email_domains' );
+	if ($banned_names && !is_array( $banned_names ))
+		$banned_names = explode( "\n", $banned_names);
+
+	if ( is_array( $banned_names ) && empty( $banned_names ) == false ) {
+		$email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
+		foreach ( (array) $banned_names as $banned_domain ) {
+			if ( $banned_domain == '' )
+				continue;
+			if (
+				strstr( $email_domain, $banned_domain ) ||
+				(
+					strstr( $banned_domain, '/' ) &&
+					preg_match( $banned_domain, $email_domain )
+				)
+			)
+			return true;
+		}
+	}
+	return false;
+}
+
+/**
+ * Processes new user registrations.
+ *
+ * Checks the data provided by the user during signup. Verifies
+ * the validity and uniqueness of user names and user email addresses,
+ * and checks email addresses against admin-provided domain
+ * whitelists and blacklists.
+ *
+ * The hook 'wpmu_validate_user_signup' provides an easy way
+ * to modify the signup process. The value $result, which is passed
+ * to the hook, contains both the user-provided info and the error
+ * messages created by the function. 'wpmu_validate_user_signup' allows
+ * you to process the data in any way you'd like, and unset the
+ * relevant errors if necessary.
+ *
+ * @since MU
+ * @uses is_email_address_unsafe()
+ * @uses username_exists()
+ * @uses email_exists()
+ *
+ * @param string $user_name The login name provided by the user.
+ * @param string $user_email The email provided by the user.
+ * @return array Contains username, email, and error messages.
+ */
+function wpmu_validate_user_signup($user_name, $user_email) {
+	global $wpdb;
+
+	$errors = new WP_Error();
+
+	$orig_username = $user_name;
+	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
+	$maybe = array();
+	preg_match( '/[a-z0-9]+/', $user_name, $maybe );
+
+	if ( $user_name != $orig_username || $user_name != $maybe[0] ) {
+		$errors->add( 'user_name', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) );
+		$user_name = $orig_username;
+	}
+
+	$user_email = sanitize_email( $user_email );
+
+	if ( empty( $user_name ) )
+	   	$errors->add('user_name', __('Please enter a username'));
+
+	$illegal_names = get_site_option( 'illegal_names' );
+	if ( is_array( $illegal_names ) == false ) {
+		$illegal_names = array(  'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
+		add_site_option( 'illegal_names', $illegal_names );
+	}
+	if ( in_array( $user_name, $illegal_names ) == true )
+		$errors->add('user_name',  __('That username is not allowed'));
+
+	if ( is_email_address_unsafe( $user_email ) )
+		$errors->add('user_email',  __('You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider.'));
+
+	if ( strlen( $user_name ) < 4 )
+		$errors->add('user_name',  __('Username must be at least 4 characters'));
+
+	if ( strpos( ' ' . $user_name, '_' ) != false )
+		$errors->add( 'user_name', __( 'Sorry, usernames may not contain the character &#8220;_&#8221;!' ) );
+
+	// all numeric?
+	$match = array();
+	preg_match( '/[0-9]*/', $user_name, $match );
+	if ( $match[0] == $user_name )
+		$errors->add('user_name', __('Sorry, usernames must have letters too!'));
+
+	if ( !is_email( $user_email ) )
+		$errors->add('user_email', __('Please enter a correct email address'));
+
+	$limited_email_domains = get_site_option( 'limited_email_domains' );
+	if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
+		$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
+		if ( in_array( $emaildomain, $limited_email_domains ) == false )
+			$errors->add('user_email', __('Sorry, that email address is not allowed!'));
+	}
+
+	// Check if the username has been used already.
+	if ( username_exists($user_name) )
+		$errors->add('user_name', __('Sorry, that username already exists!'));
+
+	// Check if the email address has been used already.
+	if ( email_exists($user_email) )
+		$errors->add('user_email', __('Sorry, that email address is already used!'));
+
+	// Has someone already signed up for this username?
+	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) );
+	if ( $signup != null ) {
+		$registered_at =  mysql2date('U', $signup->registered);
+		$now = current_time( 'timestamp', true );
+		$diff = $now - $registered_at;
+		// If registered more than two days ago, cancel registration and let this signup go through.
+		if ( $diff > 172800 )
+			$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_login = %s", $user_name) );
+		else
+			$errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
+
+		if ( $signup->active == 0 && $signup->user_email == $user_email )
+			$errors->add('user_email_used', __('username and email used'));
+	}
+
+	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) );
+	if ( $signup != null ) {
+		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
+		// If registered more than two days ago, cancel registration and let this signup go through.
+		if ( $diff > 172800 )
+			$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_email = %s", $user_email) );
+		else
+			$errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
+	}
+
+	$result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors);
+
+	return apply_filters('wpmu_validate_user_signup', $result);
+}
+
+/**
+ * Processes new site registrations.
+ *
+ * Checks the data provided by the user during blog signup. Verifies
+ * the validity and uniqueness of blog paths and domains.
+ *
+ * This function prevents the current user from registering a new site
+ * with a blogname equivalent to another user's login name. Passing the
+ * $user parameter to the function, where $user is the other user, is
+ * effectively an override of this limitation.
+ *
+ * Filter 'wpmu_validate_blog_signup' if you want to modify
+ * the way that WordPress validates new site signups.
+ *
+ * @since MU
+ * @uses domain_exists()
+ * @uses username_exists()
+ *
+ * @param string $blogname The blog name provided by the user. Must be unique.
+ * @param string $blog_title The blog title provided by the user.
+ * @return array Contains the new site data and error messages.
+ */
+function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
+	global $wpdb, $domain, $base, $current_site;
+
+	$blog_title = strip_tags( $blog_title );
+	$blog_title = substr( $blog_title, 0, 50 );
+
+	$errors = new WP_Error();
+	$illegal_names = get_site_option( 'illegal_names' );
+	if ( $illegal_names == false ) {
+		$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
+		add_site_option( 'illegal_names', $illegal_names );
+	}
+
+	// On sub dir installs, Some names are so illegal, only a filter can spring them from jail
+	if (! is_subdomain_install() )
+		$illegal_names = array_merge($illegal_names, apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ) );
+
+
+	if ( empty( $blogname ) )
+		$errors->add('blogname', __('Please enter a site name'));
+
+	$maybe = array();
+	preg_match( '/[a-z0-9]+/', $blogname, $maybe );
+	if ( $blogname != $maybe[0] )
+		$errors->add('blogname', __('Only lowercase letters and numbers allowed'));
+
+	if ( in_array( $blogname, $illegal_names ) == true )
+		$errors->add('blogname',  __('That name is not allowed'));
+
+	if ( strlen( $blogname ) < 4 && !is_super_admin() )
+		$errors->add('blogname',  __('Site name must be at least 4 characters'));
+
+	if ( strpos( ' ' . $blogname, '_' ) != false )
+		$errors->add( 'blogname', __( 'Sorry, site names may not contain the character &#8220;_&#8221;!' ) );
+
+	// do not allow users to create a blog that conflicts with a page on the main blog.
+	if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
+		$errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
+
+	// all numeric?
+	$match = array();
+	preg_match( '/[0-9]*/', $blogname, $match );
+	if ( $match[0] == $blogname )
+		$errors->add('blogname', __('Sorry, site names must have letters too!'));
+
+	$blogname = apply_filters( 'newblogname', $blogname );
+
+	$blog_title = stripslashes(  $blog_title );
+
+	if ( empty( $blog_title ) )
+		$errors->add('blog_title', __('Please enter a site title'));
+
+	// Check if the domain/path has been used already.
+	if ( is_subdomain_install() ) {
+		$mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
+		$path = $base;
+	} else {
+		$mydomain = "$domain";
+		$path = $base.$blogname.'/';
+	}
+	if ( domain_exists($mydomain, $path) )
+		$errors->add('blogname', __('Sorry, that site already exists!'));
+
+	if ( username_exists( $blogname ) ) {
+		if ( is_object( $user ) == false || ( is_object($user) && ( $user->user_login != $blogname ) ) )
+			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
+	}
+
+	// Has someone already signed up for this domain?
+	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) ); // TODO: Check email too?
+	if ( ! empty($signup) ) {
+		$diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
+		// If registered more than two days ago, cancel registration and let this signup go through.
+		if ( $diff > 172800 )
+			$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) );
+		else
+			$errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
+	}
+
+	$result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors);
+	return apply_filters('wpmu_validate_blog_signup', $result);
+}
+
+/**
+ * Record site signup information for future activation.
+ *
+ * @since MU
+ * @uses wpmu_signup_blog_notification()
+ *
+ * @param string $domain The requested domain.
+ * @param string $path The requested path.
+ * @param string $title The requested site title.
+ * @param string $user The user's requested login name.
+ * @param string $user_email The user's email address.
+ * @param array $meta By default, contains the requested privacy setting and lang_id.
+ */
+function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = '') {
+	global $wpdb;
+
+	$key = substr( md5( time() . rand() . $domain ), 0, 16 );
+	$meta = serialize($meta);
+	$domain = $wpdb->escape($domain);
+	$path = $wpdb->escape($path);
+	$title = $wpdb->escape($title);
+
+	$wpdb->insert( $wpdb->signups, array(
+		'domain' => $domain,
+		'path' => $path,
+		'title' => $title,
+		'user_login' => $user,
+		'user_email' => $user_email,
+		'registered' => current_time('mysql', true),
+		'activation_key' => $key,
+		'meta' => $meta
+	) );
+
+	wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta);
+}
+
+/**
+ * Record user signup information for future activation.
+ *
+ * This function is used when user registration is open but
+ * new site registration is not.
+ *
+ * @since MU
+ * @uses wpmu_signup_user_notification()
+ *
+ * @param string $user The user's requested login name.
+ * @param string $user_email The user's email address.
+ * @param array $meta By default, this is an empty array.
+ */
+function wpmu_signup_user($user, $user_email, $meta = '') {
+	global $wpdb;
+
+	// Format data
+	$user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );
+	$user_email = sanitize_email( $user_email );
+	$key = substr( md5( time() . rand() . $user_email ), 0, 16 );
+	$meta = serialize($meta);
+
+	$wpdb->insert( $wpdb->signups, array(
+		'domain' => '',
+		'path' => '',
+		'title' => '',
+		'user_login' => $user,
+		'user_email' => $user_email,
+		'registered' => current_time('mysql', true),
+		'activation_key' => $key,
+		'meta' => $meta
+	) );
+
+	wpmu_signup_user_notification($user, $user_email, $key, $meta);
+}
+
+/**
+ * Notify user of signup success.
+ *
+ * This is the notification function used when site registration
+ * is enabled.
+ *
+ * Filter 'wpmu_signup_blog_notification' to bypass this function or
+ * replace it with your own notification behavior.
+ *
+ * Filter 'wpmu_signup_blog_notification_email' and
+ * 'wpmu_signup_blog_notification_email' to change the content
+ * and subject line of the email sent to newly registered users.
+ *
+ * @since MU
+ *
+ * @param string $domain The new blog domain.
+ * @param string $path The new blog path.
+ * @param string $title The site title.
+ * @param string $user The user's login name.
+ * @param string $user_email The user's email address.
+ * @param array $meta By default, contains the requested privacy setting and lang_id.
+ * @param string $key The activation key created in wpmu_signup_blog()
+ * @return bool
+ */
+function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta = '') {
+	global $current_site;
+
+	if ( !apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta) )
+		return false;
+
+	// Send email with activation link.
+	if ( !is_subdomain_install() || $current_site->id != 1 )
+		$activate_url = network_site_url("wp-activate.php?key=$key");
+	else
+		$activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
+
+	$activate_url = esc_url($activate_url);
+	$admin_email = get_site_option( 'admin_email' );
+	if ( $admin_email == '' )
+		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
+	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
+	$message = sprintf(
+		apply_filters( 'wpmu_signup_blog_notification_email',
+			__( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ),
+			$domain, $path, $title, $user, $user_email, $key, $meta
+		),
+		$activate_url,
+		esc_url( "http://{$domain}{$path}" ),
+		$key
+	);
+	// TODO: Don't hard code activation link.
+	$subject = sprintf(
+		apply_filters( 'wpmu_signup_blog_notification_subject',
+			__( '[%1$s] Activate %2$s' ),
+			$domain, $path, $title, $user, $user_email, $key, $meta
+		),
+		$from_name,
+		esc_url( 'http://' . $domain . $path )
+	);
+	wp_mail($user_email, $subject, $message, $message_headers);
+	return true;
+}
+
+/**
+ * Notify user of signup success.
+ *
+ * This is the notification function used when no new site has
+ * been requested.
+ *
+ * Filter 'wpmu_signup_user_notification' to bypass this function or
+ * replace it with your own notification behavior.
+ *
+ * Filter 'wpmu_signup_user_notification_email' and
+ * 'wpmu_signup_user_notification_subject' to change the content
+ * and subject line of the email sent to newly registered users.
+ *
+ * @since MU
+ *
+ * @param string $user The user's login name.
+ * @param string $user_email The user's email address.
+ * @param array $meta By default, an empty array.
+ * @param string $key The activation key created in wpmu_signup_user()
+ * @return bool
+ */
+function wpmu_signup_user_notification($user, $user_email, $key, $meta = '') {
+	if ( !apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta) )
+		return false;
+
+	// Send email with activation link.
+	$admin_email = get_site_option( 'admin_email' );
+	if ( $admin_email == '' )
+		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
+	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
+	$message = sprintf(
+		apply_filters( 'wpmu_signup_user_notification_email',
+			__( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\n" ),
+			$user, $user_email, $key, $meta
+		),
+		site_url( "wp-activate.php?key=$key" ),
+		$key
+	);
+	// TODO: Don't hard code activation link.
+	$subject = sprintf(
+		apply_filters( 'wpmu_signup_user_notification_subject',
+			__( '[%1$s] Activate %2$s' ),
+			$user, $user_email, $key, $meta
+		),
+		$from_name,
+		$user
+	);
+	wp_mail($user_email, $subject, $message, $message_headers);
+	return true;
+}
+
+/**
+ * Activate a signup.
+ *
+ * Hook to 'wpmu_activate_user' or 'wpmu_activate_blog' for events
+ * that should happen only when users or sites are self-created (since
+ * those actions are not called when users and sites are created
+ * by a Super Admin).
+ *
+ * @since MU
+ * @uses wp_generate_password()
+ * @uses wpmu_welcome_user_notification()
+ * @uses add_user_to_blog()
+ * @uses add_new_user_to_blog()
+ * @uses wpmu_create_user()
+ * @uses wpmu_create_blog()
+ * @uses wpmu_welcome_notification()
+ *
+ * @param string $key The activation key provided to the user.
+ * @return array An array containing information about the activated user and/or blog
+ */
+function wpmu_activate_signup($key) {
+	global $wpdb, $current_site;
+
+	$signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
+
+	if ( empty( $signup ) )
+		return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
+
+	if ( $signup->active ) {
+		if ( empty( $signup->domain ) )
+			return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
+		else
+			return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
+	}
+
+	$meta = unserialize($signup->meta);
+	$user_login = $wpdb->escape($signup->user_login);
+	$user_email = $wpdb->escape($signup->user_email);
+	$password = wp_generate_password( 12, false );
+
+	$user_id = username_exists($user_login);
+
+	if ( ! $user_id )
+		$user_id = wpmu_create_user($user_login, $password, $user_email);
+	else
+		$user_already_exists = true;
+
+	if ( ! $user_id )
+		return new WP_Error('create_user', __('Could not create user'), $signup);
+
+	$now = current_time('mysql', true);
+
+	if ( empty($signup->domain) ) {
+		$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
+
+		if ( isset( $user_already_exists ) )
+			return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
+
+		wpmu_welcome_user_notification($user_id, $password, $meta);
+
+		add_new_user_to_blog( $user_id, $user_email, $meta );
+		do_action('wpmu_activate_user', $user_id, $password, $meta);
+		return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta);
+	}
+
+	$blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id, $meta, $wpdb->siteid );
+
+	// TODO: What to do if we create a user but cannot create a blog?
+	if ( is_wp_error($blog_id) ) {
+		// If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and
+		// setting the activation flag.  Let's just set the active flag and instruct the user to reset their password.
+		if ( 'blog_taken' == $blog_id->get_error_code() ) {
+			$blog_id->add_data( $signup );
+			$wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) );
+		}
+		return $blog_id;
+	}
+
+	$wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
+	wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta);
+	do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);
+
+	return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
+}
+
+/**
+ * Create a user.
+ *
+ * This function runs when a user self-registers as well as when
+ * a Super Admin creates a new user. Hook to 'wpmu_new_user' for events
+ * that should affect all new users, but only on Multisite (otherwise
+ * use 'user_register').
+ *
+ * @since MU
+ * @uses wp_create_user()
+ *
+ * @param string $user_name The new user's login name.
+ * @param string $password The new user's password.
+ * @param string $email The new user's email address.
+ * @return mixed Returns false on failure, or int $user_id on success
+ */
+function wpmu_create_user( $user_name, $password, $email) {
+	$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
+
+	$user_id = wp_create_user( $user_name, $password, $email );
+	if ( is_wp_error($user_id) )
+		return false;
+
+	// Newly created users have no roles or caps until they are added to a blog.
+	delete_user_option( $user_id, 'capabilities' );
+	delete_user_option( $user_id, 'user_level' );
+
+	do_action( 'wpmu_new_user', $user_id );
+
+	return $user_id;
+}
+
+/**
+ * Create a site.
+ *
+ * This function runs when a user self-registers a new site as well
+ * as when a Super Admin creates a new site. Hook to 'wpmu_new_blog'
+ * for events that should affect all new sites.
+ *
+ * On subdirectory installs, $domain is the same as the main site's
+ * domain, and the path is the subdirectory name (eg 'example.com'
+ * and '/blog1/'). On subdomain installs, $domain is the new subdomain +
+ * root domain (eg 'blog1.example.com'), and $path is '/'.
+ *
+ * @since MU
+ * @uses domain_exists()
+ * @uses insert_blog()
+ * @uses wp_install_defaults()
+ * @uses add_user_to_blog()
+ *
+ * @param string $domain The new site's domain.
+ * @param string $path The new site's path.
+ * @param string $title The new site's title.
+ * @param int $user_id The user ID of the new site's admin.
+ * @param array $meta Optional. Used to set initial site options.
+ * @param int $site_id Optional. Only relevant on multi-network installs.
+ * @return mixed Returns WP_Error object on failure, int $blog_id on success
+ */
+function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
+	$domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
+
+	if ( is_subdomain_install() )
+		$domain = str_replace( '@', '', $domain );
+
+	$title = strip_tags( $title );
+	$user_id = (int) $user_id;
+
+	if ( empty($path) )
+		$path = '/';
+
+	// Check if the domain has been used already. We should return an error message.
+	if ( domain_exists($domain, $path, $site_id) )
+		return new WP_Error('blog_taken', __('Site already exists.'));
+
+	if ( !defined('WP_INSTALLING') )
+		define( 'WP_INSTALLING', true );
+
+	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
+		return new WP_Error('insert_blog', __('Could not create site.'));
+
+	switch_to_blog($blog_id);
+	install_blog($blog_id, $title);
+	wp_install_defaults($user_id);
+
+	add_user_to_blog($blog_id, $user_id, 'administrator');
+
+	if ( is_array($meta) ) foreach ($meta as $key => $value) {
+		if ( $key == 'public' || $key == 'archived' || $key == 'mature' || $key == 'spam' || $key == 'deleted' || $key == 'lang_id' )
+			update_blog_status( $blog_id, $key, $value );
+		else
+			update_option( $key, $value );
+	}
+
+	add_option( 'WPLANG', get_site_option( 'WPLANG' ) );
+	update_option( 'blog_public', (int)$meta['public'] );
+
+	if ( !is_super_admin() && ! get_user_meta( $user_id, 'primary_blog', true ) )
+		update_user_meta( $user_id, 'primary_blog', $blog_id );
+
+	restore_current_blog();
+	do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
+
+	return $blog_id;
+}
+
+/**
+ * Notifies the network admin that a new site has been activated.
+ *
+ * Filter 'newblog_notify_siteadmin' to change the content of
+ * the notification email.
+ *
+ * @since MU
+ *
+ * @param int $blog_id The new site's ID.
+ * @return bool
+ */
+function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
+	if ( get_site_option( 'registrationnotification' ) != 'yes' )
+		return false;
+
+	$email = get_site_option( 'admin_email' );
+	if ( is_email($email) == false )
+		return false;
+
+	$options_site_url = esc_url(network_admin_url('settings.php'));
+
+	switch_to_blog( $blog_id );
+	$blogname = get_option( 'blogname' );
+	$siteurl = site_url();
+	restore_current_blog();
+
+	$msg = sprintf( __( 'New Site: %1s
+URL: %2s
+Remote IP: %3s
+
+Disable these notifications: %4s' ), $blogname, $siteurl, $_SERVER['REMOTE_ADDR'], $options_site_url);
+	$msg = apply_filters( 'newblog_notify_siteadmin', $msg );
+
+	wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg );
+	return true;
+}
+
+/**
+ * Notifies the network admin that a new user has been activated.
+ *
+ * Filter 'newuser_notify_siteadmin' to change the content of
+ * the notification email.
+ *
+ * @since MU
+ *
+ * @param int $user_id The new user's ID.
+ * @return bool
+ */
+function newuser_notify_siteadmin( $user_id ) {
+	if ( get_site_option( 'registrationnotification' ) != 'yes' )
+		return false;
+
+	$email = get_site_option( 'admin_email' );
+
+	if ( is_email($email) == false )
+		return false;
+
+	$user = new WP_User($user_id);
+
+	$options_site_url = esc_url(network_admin_url('settings.php'));
+	$msg = sprintf(__('New User: %1s
+Remote IP: %2s
+
+Disable these notifications: %3s'), $user->user_login, $_SERVER['REMOTE_ADDR'], $options_site_url);
+
+	$msg = apply_filters( 'newuser_notify_siteadmin', $msg );
+	wp_mail( $email, sprintf(__('New User Registration: %s'), $user->user_login), $msg );
+	return true;
+}
+
+/**
+ * Check whether a blogname is already taken.
+ *
+ * Used during the new site registration process to ensure
+ * that each blogname is unique.
+ *
+ * @since MU
+ *
+ * @param string $domain The domain to be checked.
+ * @param string $path The path to be checked.
+ * @param int $site_id Optional. Relevant only on multi-network installs.
+ * @return int
+ */
+function domain_exists($domain, $path, $site_id = 1) {
+	global $wpdb;
+	return $wpdb->get_var( $wpdb->prepare("SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s AND site_id = %d", $domain, $path, $site_id) );
+}
+
+/**
+ * Store basic site info in the blogs table.
+ *
+ * This function creates a row in the wp_blogs table and returns
+ * the new blog's ID. It is the first step in creating a new blog.
+ *
+ * @since MU
+ *
+ * @param string $domain The domain of the new site.
+ * @param string $path The path of the new site.
+ * @param int $site_id Unless you're running a multi-network install, be sure to set this value to 1.
+ * @return int The ID of the new row
+ */
+function insert_blog($domain, $path, $site_id) {
+	global $wpdb;
+
+	$path = trailingslashit($path);
+	$site_id = (int) $site_id;
+
+	$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
+	if ( ! $result )
+		return false;
+
+	refresh_blog_details($wpdb->insert_id);
+	return $wpdb->insert_id;
+}
+
+/**
+ * Install an empty blog.
+ *
+ * Creates the new blog tables and options. If calling this function
+ * directly, be sure to use switch_to_blog() first, so that $wpdb
+ * points to the new blog.
+ *
+ * @since MU
+ * @uses make_db_current_silent()
+ * @uses populate_roles()
+ *
+ * @param int $blog_id The value returned by insert_blog().
+ * @param string $blog_title The title of the new site.
+ */
+function install_blog($blog_id, $blog_title = '') {
+	global $wpdb, $table_prefix, $wp_roles;
+	$wpdb->suppress_errors();
+
+	// Cast for security
+	$blog_id = (int) $blog_id;
+
+	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+
+	if ( $wpdb->get_results("SELECT ID FROM $wpdb->posts") )
+		die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
+
+	$wpdb->suppress_errors(false);
+
+	$url = get_blogaddress_by_id($blog_id);
+
+	// Set everything up
+	make_db_current_silent();
+	populate_options();
+	populate_roles();
+	$wp_roles->_init();
+
+	// fix url.
+	update_option('siteurl', $url);
+	update_option('home', $url);
+	update_option('fileupload_url', $url . "files" );
+	update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files");
+	update_option('blogname', stripslashes( $blog_title ) );
+	update_option('admin_email', '');
+	$wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
+
+	// remove all perms
+	$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'user_level') );
+	$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'capabilities') );
+
+	$wpdb->suppress_errors( false );
+}
+
+/**
+ * Set blog defaults.
+ *
+ * This function creates a row in the wp_blogs table.
+ *
+ * @since MU
+ * @deprecated MU
+ * @deprecated Use wp_install_defaults()
+ * @uses wp_install_defaults()
+ *
+ * @param int $blog_id Ignored in this function.
+ * @param int $user_id
+ */
+function install_blog_defaults($blog_id, $user_id) {
+	global $wpdb;
+
+	require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+
+	$wpdb->suppress_errors();
+
+	wp_install_defaults($user_id);
+
+	$wpdb->suppress_errors( false );
+}
+
+/**
+ * Notify a user that her blog activation has been successful.
+ *
+ * Filter 'wpmu_welcome_notification' to disable or bypass.
+ *
+ * Filter 'update_welcome_email' and 'update_welcome_subject' to
+ * modify the content and subject line of the notification email.
+ *
+ * @since MU
+ *
+ * @param int $blog_id
+ * @param int $user_id
+ * @param string $password
+ * @param string $title The new blog's title
+ * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization.
+ * @return bool
+ */
+function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = '') {
+	global $current_site;
+
+	if ( !apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta) )
+		return false;
+
+	$welcome_email = stripslashes( get_site_option( 'welcome_email' ) );
+	if ( $welcome_email == false )
+		$welcome_email = stripslashes( __( 'Dear User,
+
+Your new SITE_NAME site has been successfully set up at:
+BLOG_URL
+
+You can log in to the administrator account with the following information:
+Username: USERNAME
+Password: PASSWORD
+Login Here: BLOG_URLwp-login.php
+
+We hope you enjoy your new site.
+Thanks!
+
+--The Team @ SITE_NAME' ) );
+
+	$url = get_blogaddress_by_id($blog_id);
+	$user = new WP_User($user_id);
+
+	$welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email );
+	$welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
+	$welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
+	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
+	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
+
+	$welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta);
+	$admin_email = get_site_option( 'admin_email' );
+
+	if ( $admin_email == '' )
+		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
+
+	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
+	$message = $welcome_email;
+
+	if ( empty( $current_site->site_name ) )
+		$current_site->site_name = 'WordPress MU';
+
+	$subject = apply_filters( 'update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, stripslashes( $title ) ) );
+	wp_mail($user->user_email, $subject, $message, $message_headers);
+	return true;
+}
+
+/**
+ * Notify a user that her account activation has been successful.
+ *
+ * Filter 'wpmu_welcome_user_notification' to disable or bypass.
+ *
+ * Filter 'update_welcome_user_email' and 'update_welcome_user_subject' to
+ * modify the content and subject line of the notification email.
+ *
+ * @since MU
+ *
+ * @param int $user_id
+ * @param string $password
+ * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization.
+ * @return bool
+ */
+function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
+	global $current_site;
+
+	if ( !apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta) )
+		return false;
+
+	$welcome_email = get_site_option( 'welcome_user_email' );
+
+	$user = new WP_User($user_id);
+
+	$welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta);
+	$welcome_email = str_replace( 'SITE_NAME', $current_site->site_name, $welcome_email );
+	$welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
+	$welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
+	$welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
+
+	$admin_email = get_site_option( 'admin_email' );
+
+	if ( $admin_email == '' )
+		$admin_email = 'support@' . $_SERVER['SERVER_NAME'];
+
+	$from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
+	$message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
+	$message = $welcome_email;
+
+	if ( empty( $current_site->site_name ) )
+		$current_site->site_name = 'WordPress MU';
+
+	$subject = apply_filters( 'update_welcome_user_subject', sprintf(__('New %1$s User: %2$s'), $current_site->site_name, $user->user_login) );
+	wp_mail($user->user_email, $subject, $message, $message_headers);
+	return true;
+}
+
+/**
+ * Get the current site info.
+ *
+ * Returns an object containing the ID, domain, path, and site_name
+ * of the site being viewed.
+ *
+ * @since MU
+ *
+ * @return object
+ */
+function get_current_site() {
+	global $current_site;
+	return $current_site;
+}
+
+/**
+ * Get a numeric user ID from either an email address or a login.
+ *
+ * @since MU
+ * @uses is_email()
+ *
+ * @param string $string
+ * @return int
+ */
+function get_user_id_from_string( $string ) {
+	$user_id = 0;
+	if ( is_email( $string ) ) {
+		$user = get_user_by('email', $string);
+		if ( $user )
+			$user_id = $user->ID;
+	} elseif ( is_numeric( $string ) ) {
+		$user_id = $string;
+	} else {
+		$user = get_user_by('login', $string);
+		if ( $user )
+			$user_id = $user->ID;
+	}
+
+	return $user_id;
+}
+
+/**
+ * Get a user's most recent post.
+ *
+ * Walks through each of a user's blogs to find the post with
+ * the most recent post_date_gmt.
+ *
+ * @since MU
+ * @uses get_blogs_of_user()
+ *
+ * @param int $user_id
+ * @return array Contains the blog_id, post_id, post_date_gmt, and post_gmt_ts
+ */
+function get_most_recent_post_of_user( $user_id ) {
+	global $wpdb;
+
+	$user_blogs = get_blogs_of_user( (int) $user_id );
+	$most_recent_post = array();
+
+	// Walk through each blog and get the most recent post
+	// published by $user_id
+	foreach ( (array) $user_blogs as $blog ) {
+		$recent_post = $wpdb->get_row( $wpdb->prepare("SELECT ID, post_date_gmt FROM {$wpdb->base_prefix}{$blog->userblog_id}_posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A);
+
+		// Make sure we found a post
+		if ( isset($recent_post['ID']) ) {
+			$post_gmt_ts = strtotime($recent_post['post_date_gmt']);
+
+			// If this is the first post checked or if this post is
+			// newer than the current recent post, make it the new
+			// most recent post.
+			if ( !isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
+				$most_recent_post = array(
+					'blog_id'		=> $blog->userblog_id,
+					'post_id'		=> $recent_post['ID'],
+					'post_date_gmt'	=> $recent_post['post_date_gmt'],
+					'post_gmt_ts'	=> $post_gmt_ts
+				);
+			}
+		}
+	}
+
+	return $most_recent_post;
+}
+
+// Misc functions
+
+/**
+ * Get the size of a directory.
+ *
+ * A helper function that is used primarily to check whether
+ * a blog has exceeded its allowed upload space.
+ *
+ * @since MU
+ * @uses recurse_dirsize()
+ *
+ * @param string $directory
+ * @return int
+ */
+function get_dirsize( $directory ) {
+	$dirsize = get_transient( 'dirsize_cache' );
+	if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
+		return $dirsize[ $directory ][ 'size' ];
+
+	if ( false == is_array( $dirsize ) )
+		$dirsize = array();
+
+	$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
+
+	set_transient( 'dirsize_cache', $dirsize, 3600 );
+	return $dirsize[ $directory ][ 'size' ];
+}
+
+/**
+ * Get the size of a directory recursively.
+ *
+ * Used by get_dirsize() to get a directory's size when it contains
+ * other directories.
+ *
+ * @since MU
+ *
+ * @param string $directory
+ * @return int
+ */
+function recurse_dirsize( $directory ) {
+	$size = 0;
+
+	if ( substr( $directory, -1 ) == '/' )
+		$directory = substr($directory,0,-1);
+
+	if ( !file_exists($directory) || !is_dir( $directory ) || !is_readable( $directory ) )
+		return false;
+
+	if ($handle = opendir($directory)) {
+		while(($file = readdir($handle)) !== false) {
+			$path = $directory.'/'.$file;
+			if ($file != '.' && $file != '..') {
+				if (is_file($path)) {
+					$size += filesize($path);
+				} elseif (is_dir($path)) {
+					$handlesize = recurse_dirsize($path);
+					if ($handlesize > 0)
+						$size += $handlesize;
+				}
+			}
+		}
+		closedir($handle);
+	}
+	return $size;
+}
+
+/**
+ * Check whether a blog has used its allotted upload space.
+ *
+ * Used by get_dirsize() to get a directory's size when it contains
+ * other directories.
+ *
+ * @since MU
+ * @uses get_dirsize()
+ *
+ * @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
+ * @return int
+ */
+function upload_is_user_over_quota( $echo = true ) {
+	if ( get_site_option( 'upload_space_check_disabled' ) )
+		return false;
+
+	$spaceAllowed = get_space_allowed();
+	if ( empty( $spaceAllowed ) || !is_numeric( $spaceAllowed ) )
+		$spaceAllowed = 10;	// Default space allowed is 10 MB
+
+	$dirName = BLOGUPLOADDIR;
+	$size = get_dirsize($dirName) / 1024 / 1024;
+
+	if ( ($spaceAllowed-$size) < 0 ) {
+		if ( $echo )
+			_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' ); // No space left
+		return true;
+	} else {
+		return false;
+	}
+}
+
+/**
+ * Check an array of MIME types against a whitelist.
+ *
+ * WordPress ships with a set of allowed upload filetypes,
+ * which is defined in wp-includes/functions.php in
+ * get_allowed_mime_types(). This function is used to filter
+ * that list against the filetype whitelist provided by Multisite
+ * Super Admins at wp-admin/network/settings.php.
+ *
+ * @since MU
+ *
+ * @param array $mimes
+ * @return array
+ */
+function check_upload_mimes( $mimes ) {
+	$site_exts = explode( ' ', get_site_option( 'upload_filetypes' ) );
+	foreach ( $site_exts as $ext ) {
+		foreach ( $mimes as $ext_pattern => $mime ) {
+			if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
+				$site_mimes[$ext_pattern] = $mime;
+		}
+	}
+	return $site_mimes;
+}
+
+/**
+ * Update a blog's post count.
+ *
+ * WordPress MS stores a blog's post count as an option so as
+ * to avoid extraneous COUNTs when a blog's details are fetched
+ * with get_blog_details(). This function is called when posts
+ * are published to make sure the count stays current.
+ *
+ * @since MU
+ */
+function update_posts_count( $deprecated = '' ) {
+	global $wpdb;
+	update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
+}
+
+/**
+ * Logs user registrations.
+ *
+ * @since MU
+ *
+ * @param int $blog_id
+ * @param int $user_id
+ */
+function wpmu_log_new_registrations( $blog_id, $user_id ) {
+	global $wpdb;
+	$user = new WP_User( (int) $user_id );
+	$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
+}
+
+/**
+ * Get the remaining upload space for this blog.
+ *
+ * @since MU
+ * @uses upload_is_user_over_quota()
+ * @uses get_space_allowed()
+ * @uses get_dirsize()
+ *
+ * @param int $size
+ * @return int
+ */
+function fix_import_form_size( $size ) {
+	if ( upload_is_user_over_quota( false ) == true )
+		return 0;
+
+	$spaceAllowed = 1024 * 1024 * get_space_allowed();
+	$dirName = BLOGUPLOADDIR;
+	$dirsize = get_dirsize($dirName) ;
+	if ( $size > $spaceAllowed - $dirsize )
+		return $spaceAllowed - $dirsize; // remaining space
+	else
+		return $size; // default
+}
+
+/**
+ * Maintains a canonical list of terms by syncing terms created for each blog with the global terms table.
+ *
+ * @since 3.0.0
+ *
+ * @see term_id_filter
+ *
+ * @param int $term_id An ID for a term on the current blog.
+ * @return int An ID from the global terms table mapped from $term_id.
+ */
+function global_terms( $term_id, $deprecated = '' ) {
+	global $wpdb;
+	static $global_terms_recurse = null;
+
+	if ( !global_terms_enabled() )
+		return $term_id;
+
+	// prevent a race condition
+	$recurse_start = false;
+	if ( $global_terms_recurse === null ) {
+		$recurse_start = true;
+		$global_terms_recurse = 1;
+	} elseif ( 10 < $global_terms_recurse++ ) {
+		return $term_id;
+	}
+
+	$term_id = intval( $term_id );
+	$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
+
+	$global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) );
+	if ( $global_id == null ) {
+		$used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) );
+		if ( null == $used_global_id ) {
+			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
+			$global_id = $wpdb->insert_id;
+			if ( empty( $global_id ) )
+				return $term_id;
+		} else {
+			$max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );
+			$max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
+			$new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 );
+			$wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
+			$global_id = $wpdb->insert_id;
+		}
+	} elseif ( $global_id != $term_id ) {
+		$local_id = $wpdb->get_row( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) );
+		if ( null != $local_id )
+			$local_id = global_terms( $local_id );
+			if ( 10 < $global_terms_recurse )
+				$global_id = $term_id;
+	}
+
+	if ( $global_id != $term_id ) {
+		if ( get_option( 'default_category' ) == $term_id )
+			update_option( 'default_category', $global_id );
+
+		$wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) );
+		$wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) );
+		$wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) );
+
+		clean_term_cache($term_id);
+	}
+	if( $recurse_start )
+		$global_terms_recurse = null;
+
+	return $global_id;
+}
+
+/**
+ * Ensure that the current site's domain is listed in the allowed redirect host list.
+ *
+ * @see wp_validate_redirect()
+ * @since MU
+ *
+ * @return array The current site's domain
+ */
+function redirect_this_site( $deprecated = '' ) {
+	global $current_site;
+	return array( $current_site->domain );
+}
+
+/**
+ * Check whether an upload is too big.
+ *
+ * @since MU
+ *
+ * @param array $upload
+ * @return mixed If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
+ */
+function upload_is_file_too_big( $upload ) {
+	if ( is_array( $upload ) == false || defined( 'WP_IMPORTING' ) )
+		return $upload;
+
+	if ( strlen( $upload['bits'] )  > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
+		return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ));
+
+	return $upload;
+}
+
+/**
+ * Add a nonce field to the signup page.
+ *
+ * @since MU
+ * @uses wp_nonce_field()
+ */
+function signup_nonce_fields() {
+	$id = mt_rand();
+	echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
+	wp_nonce_field('signup_form_' . $id, '_signup_form', false);
+}
+
+/**
+ * Process the signup nonce created in signup_nonce_fields().
+ *
+ * @since MU
+ * @uses wp_create_nonce()
+ *
+ * @param array $result
+ * @return array
+ */
+function signup_nonce_check( $result ) {
+	if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
+		return $result;
+
+	if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] )
+		wp_die( __('Please try again!') );
+
+	return $result;
+}
+
+/**
+ * Correct 404 redirects when NOBLOGREDIRECT is defined.
+ *
+ * @since MU
+ */
+function maybe_redirect_404() {
+	global $current_site;
+	if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
+		if ( $destination == '%siteurl%' )
+			$destination = network_home_url();
+		wp_redirect( $destination );
+		exit();
+	}
+}
+
+/**
+ * Add a new user to a blog by visiting /newbloguser/username/.
+ *
+ * This will only work when the user's details are saved as an option
+ * keyed as 'new_user_x', where 'x' is the username of the user to be
+ * added, as when a user is invited through the regular WP Add User interface.
+ *
+ * @since MU
+ * @uses add_existing_user_to_blog()
+ */
+function maybe_add_existing_user_to_blog() {
+	if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
+		return false;
+
+	$parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
+	$key = array_pop( $parts );
+
+	if ( $key == '' )
+		$key = array_pop( $parts );
+
+	$details = get_option( 'new_user_' . $key );
+	if ( !empty( $details ) )
+		delete_option( 'new_user_' . $key );
+
+	if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
+		wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), site_url() ) );
+
+	wp_die( sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">login</a> using your username and password.'), site_url(), admin_url() ), __('Success') );
+}
+
+/**
+ * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
+ *
+ * @since MU
+ * @uses add_user_to_blog()
+ *
+ * @param array $details
+ */
+function add_existing_user_to_blog( $details = false ) {
+	global $blog_id;
+
+	if ( is_array( $details ) ) {
+		$result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] );
+		do_action( 'added_existing_user', $details[ 'user_id' ], $result );
+	}
+	return $result;
+}
+
+/**
+ * Add a newly created user to the appropriate blog
+ *
+ * @since MU
+ *
+ * @param int $user_id
+ * @param string $email
+ * @param array $meta
+ */
+function add_new_user_to_blog( $user_id, $email, $meta ) {
+	global $current_site;
+	if ( $meta[ 'add_to_blog' ] ) {
+		$blog_id = $meta[ 'add_to_blog' ];
+		$role = $meta[ 'new_role' ];
+		remove_user_from_blog($user_id, $current_site->blog_id); // remove user from main blog.
+		add_user_to_blog( $blog_id, $user_id, $role );
+		update_user_meta( $user_id, 'primary_blog', $blog_id );
+	}
+}
+
+/**
+ * Correct From host on outgoing mail to match the site domain
+ *
+ * @since MU
+ */
+function fix_phpmailer_messageid( $phpmailer ) {
+	global $current_site;
+	$phpmailer->Hostname = $current_site->domain;
+}
+
+/**
+ * Check to see whether a user is marked as a spammer, based on username
+ *
+ * @since MU
+ * @uses get_current_user_id()
+ * @uses get_user_id_from_string()
+ *
+ * @param string $username
+ * @return bool
+ */
+function is_user_spammy( $username = 0 ) {
+	if ( $username == 0 ) {
+		$user_id = get_current_user_id();
+	} else {
+		$user_id = get_user_id_from_string( $username );
+	}
+	$u = new WP_User( $user_id );
+
+	return ( isset( $u->spam ) && $u->spam == 1 );
+}
+
+/**
+ * Update this blog's 'public' setting in the global blogs table.
+ *
+ * Public blogs have a setting of 1, private blogs are 0.
+ *
+ * @since MU
+ * @uses update_blog_status()
+ *
+ * @param int $old_value
+ * @param int $value The new public value
+ * @return bool
+ */
+function update_blog_public( $old_value, $value ) {
+	global $wpdb;
+	do_action('update_blog_public');
+	update_blog_status( $wpdb->blogid, 'public', (int) $value );
+}
+add_action('update_option_blog_public', 'update_blog_public', 10, 2);
+
+/**
+ * Get the "dashboard blog", the blog where users without a blog edit their profile data.
+ *
+ * @since MU
+ * @uses get_blog_details()
+ *
+ * @return int
+ */
+function get_dashboard_blog() {
+	if ( $blog = get_site_option( 'dashboard_blog' ) )
+		return get_blog_details( $blog );
+
+	return get_blog_details( $GLOBALS['current_site']->blog_id );
+}
+
+/**
+ * Check whether a usermeta key has to do with the current blog.
+ *
+ * @since MU
+ * @uses wp_get_current_user()
+ *
+ * @param string $key
+ * @param int $user_id Optional. Defaults to current user.
+ * @param int $blog_id Optional. Defaults to current blog.
+ * @return bool
+ */
+function is_user_option_local( $key, $user_id = 0, $blog_id = 0 ) {
+	global $wpdb;
+
+	$current_user = wp_get_current_user();
+	if ( $user_id == 0 )
+		$user_id = $current_user->ID;
+	if ( $blog_id == 0 )
+		$blog_id = $wpdb->blogid;
+
+	$local_key = $wpdb->base_prefix . $blog_id . '_' . $key;
+
+	if ( isset( $current_user->$local_key ) )
+		return true;
+
+	return false;
+}
+
+/**
+ * Check whether users can self-register, based on Network settings.
+ *
+ * @since MU
+ *
+ * @return bool
+ */
+function users_can_register_signup_filter() {
+	$registration = get_site_option('registration');
+	if ( $registration == 'all' || $registration == 'user' )
+		return true;
+
+	return false;
+}
+add_filter('option_users_can_register', 'users_can_register_signup_filter');
+
+/**
+ * Ensure that the welcome message is not empty. Currently unused.
+ *
+ * @since MU
+ *
+ * @param string $text
+ * @return string
+ */
+function welcome_user_msg_filter( $text ) {
+	if ( !$text ) {
+		return __( 'Dear User,
+
+Your new account is set up.
+
+You can log in with the following information:
+Username: USERNAME
+Password: PASSWORD
+LOGINLINK
+
+Thanks!
+
+--The Team @ SITE_NAME' );
+	}
+	return $text;
+}
+add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
+
+/**
+ * Whether to force SSL on content.
+ *
+ * @since 2.8.5
+ *
+ * @param string|bool $force
+ * @return bool True if forced, false if not forced.
+ */
+function force_ssl_content( $force = '' ) {
+	static $forced_content;
+
+	if ( '' != $force ) {
+		$old_forced = $forced_content;
+		$forced_content = $force;
+		return $old_forced;
+	}
+
+	return $forced_content;
+}
+
+/**
+ * Formats an String URL to use HTTPS if HTTP is found.
+ * Useful as a filter.
+ *
+ * @since 2.8.5
+ **/
+function filter_SSL( $url ) {
+	if ( !is_string( $url ) )
+		return get_bloginfo( 'url' ); //return home blog url with proper scheme
+
+	$arrURL = parse_url( $url );
+
+	if ( force_ssl_content() && is_ssl() ) {
+		if ( 'http' === $arrURL['scheme'] && 'https' !== $arrURL['scheme'] )
+			$url = str_replace( $arrURL['scheme'], 'https', $url );
+	}
+
+	return $url;
+}
+
+/**
+ * Schedule update of the network-wide counts for the current network.
+ *
+ * @since 3.1.0
+ */
+function wp_schedule_update_network_counts() {
+	if ( !is_main_site() )
+		return;
+
+	if ( !wp_next_scheduled('update_network_counts') && !defined('WP_INSTALLING') )
+		wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
+}
+
+/**
+ *  Update the network-wide counts for the current network.
+ *
+ *  @since 3.1.0
+ */
+function wp_update_network_counts() {
+	global $wpdb;
+
+	$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $wpdb->siteid) );
+	update_site_option( 'blog_count', $count );
+
+	$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") );
+	update_site_option( 'user_count', $count );
+}
+
+?>
Index: /tags/3.1/wp-includes/ms-load.php
===================================================================
--- /tags/3.1/wp-includes/ms-load.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-load.php	(revision 17487)
@@ -0,0 +1,250 @@
+<?php
+/**
+ * These functions are needed to load Multisite.
+ *
+ * @since 3.0.0
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ */
+
+/**
+ * Whether a subdomain configuration is enabled.
+ *
+ * @since 3.0.0
+ *
+ * @return bool True if subdomain configuration is enabled, false otherwise.
+ */
+function is_subdomain_install() {
+	if ( defined('SUBDOMAIN_INSTALL') )
+		return SUBDOMAIN_INSTALL;
+
+	if ( defined('VHOST') && VHOST == 'yes' )
+		return true;
+
+	return false;
+}
+
+/**
+ * Returns array of network plugin files to be included in global scope.
+ *
+ * The default directory is wp-content/plugins. To change the default directory
+ * manually, define <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
+ * in wp-config.php.
+ *
+ * @access private
+ * @since 3.1.0
+ * @return array Files to include
+ */
+function wp_get_active_network_plugins() {
+	$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
+	if ( empty( $active_plugins ) )
+		return array();
+
+	$plugins = array();
+	$active_plugins = array_keys( $active_plugins );
+	sort( $active_plugins );
+
+	foreach ( $active_plugins as $plugin ) {
+		if ( ! validate_file( $plugin ) // $plugin must validate as file
+			&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
+			&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
+			)
+		$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
+	}
+	return $plugins;
+}
+
+/**
+ * Checks status of current blog.
+ *
+ * Checks if the blog is deleted, inactive, archived, or spammed.
+ *
+ * Dies with a default message if the blog does not pass the check.
+ *
+ * To change the default message when a blog does not pass the check,
+ * use the wp-content/blog-deleted.php, blog-inactive.php and
+ * blog-suspended.php drop-ins.
+ *
+ * @return bool|string Returns true on success, or drop-in file to include.
+ */
+function ms_site_check() {
+	global $wpdb, $current_blog;
+
+	// Allow short-circuiting
+	$check = apply_filters('ms_site_check', null);
+	if ( null !== $check )
+		return true;
+
+	// Allow super admins to see blocked sites
+	if ( is_super_admin() )
+		return true;
+
+	if ( '1' == $current_blog->deleted ) {
+		if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
+			return WP_CONTENT_DIR . '/blog-deleted.php';
+		else
+			wp_die( __( 'This user has elected to delete their account and the content is no longer available.' ), '', array( 'response' => 410 ) );
+	}
+
+	if ( '2' == $current_blog->deleted ) {
+		if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) )
+			return WP_CONTENT_DIR . '/blog-inactive.php';
+		else
+			wp_die( sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) );
+	}
+
+	if ( $current_blog->archived == '1' || $current_blog->spam == '1' ) {
+		if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) )
+			return WP_CONTENT_DIR . '/blog-suspended.php';
+		else
+			wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) );
+	}
+
+	return true;
+}
+
+/**
+ * Sets current site name.
+ *
+ * @access private
+ * @since 3.0.0
+ * @return object $current_site object with site_name
+ */
+function get_current_site_name( $current_site ) {
+	global $wpdb;
+
+	$current_site->site_name = wp_cache_get( $current_site->id . ':site_name', 'site-options' );
+	if ( ! $current_site->site_name ) {
+		$current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) );
+		if ( ! $current_site->site_name )
+			$current_site->site_name = ucfirst( $current_site->domain );
+	}
+	wp_cache_set( $current_site->id . ':site_name', $current_site->site_name, 'site-options' );
+
+	return $current_site;
+}
+
+/**
+ * Sets current_site object.
+ *
+ * @access private
+ * @since 3.0.0
+ * @return object $current_site object
+ */
+function wpmu_current_site() {
+	global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
+	if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
+		$current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
+		$current_site->domain = DOMAIN_CURRENT_SITE;
+		$current_site->path   = $path = PATH_CURRENT_SITE;
+		if ( defined( 'BLOG_ID_CURRENT_SITE' ) )
+			$current_site->blog_id = BLOG_ID_CURRENT_SITE;
+		elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated.
+			$current_site->blog_id = BLOGID_CURRENT_SITE;
+		if ( DOMAIN_CURRENT_SITE == $domain )
+			$current_site->cookie_domain = $cookie_domain;
+		elseif ( substr( $current_site->domain, 0, 4 ) == 'www.' )
+			$current_site->cookie_domain = substr( $current_site->domain, 4 );
+		else
+			$current_site->cookie_domain = $current_site->domain;
+
+		wp_load_core_site_options( $current_site->id );
+
+		return $current_site;
+	}
+
+	$current_site = wp_cache_get( 'current_site', 'site-options' );
+	if ( $current_site )
+		return $current_site;
+
+	$sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site
+	if ( 1 == count( $sites ) ) {
+		$current_site = $sites[0];
+		wp_load_core_site_options( $current_site->id );
+		$path = $current_site->path;
+		$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
+		$current_site = get_current_site_name( $current_site );
+		if ( substr( $current_site->domain, 0, 4 ) == 'www.' )
+			$current_site->cookie_domain = substr( $current_site->domain, 4 );
+		wp_cache_set( 'current_site', $current_site, 'site-options' );
+		return $current_site;
+	}
+	$path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) );
+
+	if ( $domain == $cookie_domain )
+		$current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) );
+	else
+		$current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE domain IN ( %s, %s ) AND path = %s ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1", $domain, $cookie_domain, $path ) );
+
+	if ( ! $current_site ) {
+		if ( $domain == $cookie_domain )
+			$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain ) );
+		else
+			$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain IN ( %s, %s ) AND path = '/' ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1", $domain, $cookie_domain, $path ) );
+	}
+
+	if ( $current_site ) {
+		$path = $current_site->path;
+		$current_site->cookie_domain = $cookie_domain;
+		return $current_site;
+	}
+
+	if ( is_subdomain_install() ) {
+		$sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
+		$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) );
+		if ( $current_site ) {
+			$current_site->cookie_domain = $current_site->domain;
+			return $current_site;
+		}
+
+		$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $sitedomain) );
+	}
+
+	if ( $current_site || defined( 'WP_INSTALLING' ) ) {
+		$path = '/';
+		return $current_site;
+	}
+
+	// Still no dice.
+	if ( 1 == count( $sites ) )
+		wp_die( sprintf( /*WP_I18N_BLOG_DOESNT_EXIST*/'That site does not exist. Please try <a href="%s">%s</a>.'/*/WP_I18N_BLOG_DOESNT_EXIST*/, $sites[0]->domain . $sites[0]->path ) );
+	else
+		wp_die( /*WP_I18N_NO_SITE_DEFINED*/'No site defined on this host. If you are the owner of this site, please check <a href="http://codex.wordpress.org/Debugging_a_WordPress_Network">Debugging a WordPress Network</a> for help.'/*/WP_I18N_NO_SITE_DEFINED*/ );
+}
+
+/**
+ * Displays a failure message.
+ *
+ * Used when a blog's tables do not exist. Checks for a missing $wpdb->site table as well.
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function ms_not_installed() {
+	global $wpdb, $domain, $path;
+
+	$title = /*WP_I18N_FATAL_ERROR*/'Error establishing database connection'/*/WP_I18N_FATAL_ERROR*/;
+	$msg  = '<h1>' . $title . '</h1>';
+	if ( ! is_admin() )
+		die( $msg );
+	$msg .= '<p>' . /*WP_I18N_CONTACT_OWNER*/'If your site does not display, please contact the owner of this network.'/*/WP_I18N_CONTACT_OWNER*/ . '';
+	$msg .= ' ' . /*WP_I18N_CHECK_MYSQL*/'If you are the owner of this network please check that MySQL is running properly and all tables are error free.'/*/WP_I18N_CHECK_MYSQL*/ . '</p>';
+	if ( false && !$wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
+		$msg .= '<p>' . sprintf( /*WP_I18N_TABLES_MISSING_LONG*/'<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted <code>%s</code>. You really should look at your database now.'/*/WP_I18N_TABLES_MISSING_LONG*/, $wpdb->site ) . '</p>';
+	else
+		$msg .= '<p>' . sprintf( /*WP_I18N_NO_SITE_FOUND*/'<strong>Could not find site <code>%1$s</code>.</strong> Searched for table <code>%2$s</code> in database <code>%3$s</code>. Is that right?'/*/WP_I18N_NO_SITE_FOUND*/, rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '</p>';
+	$msg .= '<p><strong>' . /*WP_I18N_WHAT_DO_I_DO*/'What do I do now?'/*WP_I18N_WHAT_DO_I_DO*/ . '</strong> ';
+	$msg .= /*WP_I18N_RTFM*/'Read the <a target="_blank" href="http://codex.wordpress.org/Debugging_a_WordPress_Network">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.'/*/WP_I18N_RTFM*/;
+	$msg .= ' ' . /*WP_I18N_STUCK*/'If you&#8217;re still stuck with this message, then check that your database contains the following tables:'/*/WP_I18N_STUCK*/ . '</p><ul>';
+	foreach ( $wpdb->tables('global') as $t => $table ) {
+		if ( 'sitecategories' == $t )
+			continue;
+		$msg .= '<li>' . $table . '</li>';
+	}
+	$msg .= '</ul>';
+
+	wp_die( $msg, $title );
+}
+
+?>
Index: /tags/3.1/wp-includes/ms-settings.php
===================================================================
--- /tags/3.1/wp-includes/ms-settings.php	(revision 17487)
+++ /tags/3.1/wp-includes/ms-settings.php	(revision 17487)
@@ -0,0 +1,136 @@
+<?php
+/**
+ * Used to set up and fix common variables and include
+ * the Multisite procedural and class library.
+ *
+ * Allows for some configuration in wp-config.php (see ms-default-constants.php)
+ *
+ * @package WordPress
+ * @subpackage Multisite
+ * @since 3.0.0
+ */
+
+// $base sanity check.
+if ( 'BASE' == $base )
+	die( /*WP_I18N_BASE_ERROR*/'Configuration error in <code>wp-config.php</code>. <code>$base</code> is set to <code>BASE</code> when it should be like <code>/</code> or <code>/blogs/</code>.'/*/WP_I18N_BASE_ERROR*/ );
+
+/** Include Multisite initialization functions */
+require( ABSPATH . WPINC . '/ms-load.php' );
+require( ABSPATH . WPINC . '/ms-default-constants.php' );
+
+if ( defined( 'SUNRISE' ) )
+	include_once( WP_CONTENT_DIR . '/sunrise.php' );
+
+/** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */
+ms_subdomain_constants();
+
+if ( !isset( $current_site ) || !isset( $current_blog ) ) {
+
+	$domain = addslashes( $_SERVER['HTTP_HOST'] );
+	if ( false !== strpos( $domain, ':' ) ) {
+		if ( substr( $domain, -3 ) == ':80' ) {
+			$domain = substr( $domain, 0, -3 );
+			$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
+		} elseif ( substr( $domain, -4 ) == ':443' ) {
+			$domain = substr( $domain, 0, -4 );
+			$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
+		} else {
+			wp_die( /*WP_I18N_NO_PORT_NUMBER*/'Multisite only works without the port number in the URL.'/*/WP_I18N_NO_PORT_NUMBER*/ );
+		}
+	}
+
+	$domain = rtrim( $domain, '.' );
+	$cookie_domain = $domain;
+	if ( substr( $cookie_domain, 0, 4 ) == 'www.' )
+		$cookie_domain = substr( $cookie_domain, 4 );
+
+	$path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] );
+	$path = str_replace ( '/wp-admin/', '/', $path );
+	$path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path );
+
+	$current_site = wpmu_current_site();
+	if ( ! isset( $current_site->blog_id ) )
+		$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
+
+	if ( is_subdomain_install() ) {
+		$current_blog = wp_cache_get( 'current_blog_' . $domain, 'site-options' );
+		if ( !$current_blog ) {
+			$current_blog = get_blog_details( array( 'domain' => $domain ), false );
+			if ( $current_blog )
+				wp_cache_set( 'current_blog_' . $domain, $current_blog, 'site-options' );
+		}
+		if ( $current_blog && $current_blog->site_id != $current_site->id ) {
+			$current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d", $current_blog->site_id ) );
+			if ( ! isset( $current_site->blog_id ) )
+				$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
+		} else
+			$blogname = substr( $domain, 0, strpos( $domain, '.' ) );
+	} else {
+		$blogname = htmlspecialchars( substr( $_SERVER[ 'REQUEST_URI' ], strlen( $path ) ) );
+		if ( false !== strpos( $blogname, '/' ) )
+			$blogname = substr( $blogname, 0, strpos( $blogname, '/' ) );
+		if ( false !== strpos( $blogname, '?' ) )
+			$blogname = substr( $blogname, 0, strpos( $blogname, '?' ) );
+		$reserved_blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed' );
+		if ( $blogname != '' && ! in_array( $blogname, $reserved_blognames ) && ! is_file( $blogname ) )
+			$path .= $blogname . '/';
+		$current_blog = wp_cache_get( 'current_blog_' . $domain . $path, 'site-options' );
+		if ( ! $current_blog ) {
+			$current_blog = get_blog_details( array( 'domain' => $domain, 'path' => $path ), false );
+			if ( $current_blog )
+				wp_cache_set( 'current_blog_' . $domain . $path, $current_blog, 'site-options' );
+		}
+		unset($reserved_blognames);
+	}
+
+	if ( ! defined( 'WP_INSTALLING' ) && is_subdomain_install() && ! is_object( $current_blog ) ) {
+		if ( defined( 'NOBLOGREDIRECT' ) ) {
+			$destination = NOBLOGREDIRECT;
+			if ( '%siteurl%' == $destination )
+				$destination = "http://" . $current_site->domain . $current_site->path;
+		} else {
+			$destination = 'http://' . $current_site->domain . $current_site->path . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );
+		}
+		header( 'Location: ' . $destination );
+		die();
+	}
+
+	if ( ! defined( 'WP_INSTALLING' ) ) {
+		if ( $current_site && ! $current_blog ) {
+			if ( $current_site->domain != $_SERVER[ 'HTTP_HOST' ] ) {
+				header( 'Location: http://' . $current_site->domain . $current_site->path );
+				exit;
+			}
+			$current_blog = get_blog_details( array( 'domain' => $current_site->domain, 'path' => $current_site->path ), false );
+		}
+		if ( ! $current_blog || ! $current_site )
+			ms_not_installed();
+	}
+
+	$blog_id = $current_blog->blog_id;
+	$public  = $current_blog->public;
+
+	if ( empty( $current_blog->site_id ) )
+		$current_blog->site_id = 1;
+	$site_id = $current_blog->site_id;
+
+	$current_site = get_current_site_name( $current_site );
+
+	if ( ! $blog_id ) {
+		if ( defined( 'WP_INSTALLING' ) ) {
+			$current_blog->blog_id = $blog_id = 1;
+		} else {
+			$msg = ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ? ' ' . /*WP_I18N_TABLES_MISSING*/'Database tables are missing.'/*/WP_I18N_TABLES_MISSING*/ : '';
+			wp_die( /*WP_I18N_NO_BLOG*/'No site by that name on this system.'/*/WP_I18N_NO_BLOG*/ . $msg );
+		}
+	}
+}
+$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php
+$wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id );
+$table_prefix = $wpdb->get_blog_prefix();
+
+// need to init cache again after blog_id is set
+wp_start_object_cache();
+
+// Define upload directory constants
+ms_upload_constants();
Index: /tags/3.1/wp-includes/nav-menu-template.php
===================================================================
--- /tags/3.1/wp-includes/nav-menu-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/nav-menu-template.php	(revision 17487)
@@ -0,0 +1,489 @@
+<?php
+/**
+ * Navigation Menu template functions
+ *
+ * @package WordPress
+ * @subpackage Nav_Menus
+ * @since 3.0.0
+ */
+
+/**
+ * Create HTML list of nav menu items.
+ *
+ * @package WordPress
+ * @since 3.0.0
+ * @uses Walker
+ */
+class Walker_Nav_Menu extends Walker {
+	/**
+	 * @see Walker::$tree_type
+	 * @since 3.0.0
+	 * @var string
+	 */
+	var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
+
+	/**
+	 * @see Walker::$db_fields
+	 * @since 3.0.0
+	 * @todo Decouple this.
+	 * @var array
+	 */
+	var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
+
+	/**
+	 * @see Walker::start_lvl()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of page. Used for padding.
+	 */
+	function start_lvl(&$output, $depth) {
+		$indent = str_repeat("\t", $depth);
+		$output .= "\n$indent<ul class=\"sub-menu\">\n";
+	}
+
+	/**
+	 * @see Walker::end_lvl()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of page. Used for padding.
+	 */
+	function end_lvl(&$output, $depth) {
+		$indent = str_repeat("\t", $depth);
+		$output .= "$indent</ul>\n";
+	}
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $item Menu item data object.
+	 * @param int $depth Depth of menu item. Used for padding.
+	 * @param int $current_page Menu item ID.
+	 * @param object $args
+	 */
+	function start_el(&$output, $item, $depth, $args) {
+		global $wp_query;
+		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
+
+		$class_names = $value = '';
+
+		$classes = empty( $item->classes ) ? array() : (array) $item->classes;
+		$classes[] = 'menu-item-' . $item->ID;
+
+		$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
+		$class_names = ' class="' . esc_attr( $class_names ) . '"';
+
+		$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
+		$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
+
+		$output .= $indent . '<li' . $id . $value . $class_names .'>';
+
+		$attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
+		$attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
+		$attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
+		$attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
+
+		$item_output = $args->before;
+		$item_output .= '<a'. $attributes .'>';
+		$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
+		$item_output .= '</a>';
+		$item_output .= $args->after;
+
+		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
+	}
+
+	/**
+	 * @see Walker::end_el()
+	 * @since 3.0.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $item Page data object. Not used.
+	 * @param int $depth Depth of page. Not Used.
+	 */
+	function end_el(&$output, $item, $depth) {
+		$output .= "</li>\n";
+	}
+}
+
+/**
+ * Displays a navigation menu.
+ *
+ * Optional $args contents:
+ *
+ * menu - The menu that is desired.  Accepts (matching in order) id, slug, name. Defaults to blank.
+ * menu_class - CSS class to use for the ul element which forms the menu. Defaults to 'menu'.
+ * menu_id - The ID that is applied to the ul element which forms the menu. Defaults to the menu slug, incremented.
+ * container - Whether to wrap the ul, and what to wrap it with. Defaults to 'div'.
+ * container_class - the class that is applied to the container. Defaults to 'menu-{menu slug}-container'.
+ * container_id - The ID that is applied to the container. Defaults to blank.
+ * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'. Set to false for no fallback.
+ * before - Text before the link text.
+ * after - Text after the link text.
+ * link_before - Text before the link.
+ * link_after - Text after the link.
+ * echo - Whether to echo the menu or return it. Defaults to echo.
+ * depth - how many levels of the hierarchy are to be included.  0 means all.  Defaults to 0.
+ * walker - allows a custom walker to be specified.
+ * theme_location - the location in the theme to be used.  Must be registered with register_nav_menu() in order to be selectable by the user.
+ * items_wrap - How the list items should be wrapped. Defaults to a ul with an id and class. Uses printf() format with numbered placeholders.
+ *
+ * @since 3.0.0
+ *
+ * @param array $args Arguments
+ */
+function wp_nav_menu( $args = array() ) {
+	static $menu_id_slugs = array();
+
+	$defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
+	'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
+	'depth' => 0, 'walker' => '', 'theme_location' => '' );
+
+	$args = wp_parse_args( $args, $defaults );
+	$args = apply_filters( 'wp_nav_menu_args', $args );
+	$args = (object) $args;
+
+	// Get the nav menu based on the requested menu
+	$menu = wp_get_nav_menu_object( $args->menu );
+
+	// Get the nav menu based on the theme_location
+	if ( ! $menu && $args->theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) )
+		$menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] );
+
+	// get the first menu that has items if we still can't find a menu
+	if ( ! $menu && !$args->theme_location ) {
+		$menus = wp_get_nav_menus();
+		foreach ( $menus as $menu_maybe ) {
+			if ( $menu_items = wp_get_nav_menu_items($menu_maybe->term_id) ) {
+				$menu = $menu_maybe;
+				break;
+			}
+		}
+	}
+
+	// If the menu exists, get its items.
+	if ( $menu && ! is_wp_error($menu) && !isset($menu_items) )
+		$menu_items = wp_get_nav_menu_items( $menu->term_id );
+
+	// If no menu was found or if the menu has no items and no location was requested, call the fallback_cb if it exists
+	if ( ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) && !$args->theme_location ) )
+		&& $args->fallback_cb && is_callable( $args->fallback_cb ) )
+			return call_user_func( $args->fallback_cb, (array) $args );
+
+	// If no fallback function was specified and the menu doesn't exists, bail.
+	if ( !$menu || is_wp_error($menu) )
+		return false;
+
+	$nav_menu = $items = '';
+
+	$show_container = false;
+	if ( $args->container ) {
+		$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
+		if ( in_array( $args->container, $allowed_tags ) ) {
+			$show_container = true;
+			$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-'. $menu->slug .'-container"';
+			$id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : '';
+			$nav_menu .= '<'. $args->container . $id . $class . '>';
+		}
+	}
+
+	// Set up the $menu_item variables
+	_wp_menu_item_classes_by_context( $menu_items );
+
+	$sorted_menu_items = array();
+	foreach ( (array) $menu_items as $key => $menu_item )
+		$sorted_menu_items[$menu_item->menu_order] = $menu_item;
+
+	unset($menu_items);
+
+	$sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
+
+	$items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
+	unset($sorted_menu_items);
+
+	// Attributes
+	if ( ! empty( $args->menu_id ) ) {
+		$wrap_id = $args->menu_id;
+	} else {
+		$wrap_id = 'menu-' . $menu->slug;
+		while ( in_array( $wrap_id, $menu_id_slugs ) ) {
+			if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) )
+				$wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id );
+			else
+				$wrap_id = $wrap_id . '-1';
+		}
+	}
+	$menu_id_slugs[] = $wrap_id;
+
+	$wrap_class = $args->menu_class ? $args->menu_class : '';
+
+	// Allow plugins to hook into the menu to add their own <li>'s
+	$items = apply_filters( 'wp_nav_menu_items', $items, $args );
+	$items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
+
+	$nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items );
+	unset( $items );
+
+	if ( $show_container )
+		$nav_menu .= '</' . $args->container . '>';
+
+	$nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
+
+	if ( $args->echo )
+		echo $nav_menu;
+	else
+		return $nav_menu;
+}
+
+/**
+ * Add the class property classes for the current context, if applicable.
+ *
+ * @access private
+ * @since 3.0
+ *
+ * @param array $menu_items The current menu item objects to which to add the class property information.
+ */
+function _wp_menu_item_classes_by_context( &$menu_items ) {
+	global $wp_query;
+
+	$queried_object = $wp_query->get_queried_object();
+	$queried_object_id = (int) $wp_query->queried_object_id;
+
+	$active_object = '';
+	$active_ancestor_item_ids = array();
+	$active_parent_item_ids = array();
+	$active_parent_object_ids = array();
+	$possible_taxonomy_ancestors = array();
+	$possible_object_parents = array();
+	$home_page_id = (int) get_option( 'page_for_posts' );
+
+	if ( $wp_query->is_singular && ! empty( $queried_object->post_type ) && ! is_post_type_hierarchical( $queried_object->post_type ) ) {
+		foreach ( (array) get_object_taxonomies( $queried_object->post_type ) as $taxonomy ) {
+			if ( is_taxonomy_hierarchical( $taxonomy ) ) {
+				$term_hierarchy = _get_term_hierarchy( $taxonomy );
+				$terms = wp_get_object_terms( $queried_object_id, $taxonomy, array( 'fields' => 'ids' ) );
+				if ( is_array( $terms ) ) {
+					$possible_object_parents = array_merge( $possible_object_parents, $terms );
+					$term_to_ancestor = array();
+					foreach ( (array) $term_hierarchy as $anc => $descs ) {
+						foreach ( (array) $descs as $desc )
+							$term_to_ancestor[ $desc ] = $anc;
+					}
+
+					foreach ( $terms as $desc ) {
+						do {
+							$possible_taxonomy_ancestors[ $taxonomy ][] = $desc;
+							if ( isset( $term_to_ancestor[ $desc ] ) ) {
+								$_desc = $term_to_ancestor[ $desc ];
+								unset( $term_to_ancestor[ $desc ] );
+								$desc = $_desc;
+							} else {
+								$desc = 0;
+							}
+						} while ( ! empty( $desc ) );
+					}
+				}
+			}
+		}
+	} elseif ( ! empty( $queried_object->post_type ) && is_post_type_hierarchical( $queried_object->post_type ) ) {
+		_get_post_ancestors( $queried_object );
+	} elseif ( ! empty( $queried_object->taxonomy ) && is_taxonomy_hierarchical( $queried_object->taxonomy ) ) {
+		$term_hierarchy = _get_term_hierarchy( $queried_object->taxonomy );
+		$term_to_ancestor = array();
+		foreach ( (array) $term_hierarchy as $anc => $descs ) {
+			foreach ( (array) $descs as $desc )
+				$term_to_ancestor[ $desc ] = $anc;
+		}
+		$desc = $queried_object->term_id;
+		do {
+			$possible_taxonomy_ancestors[ $queried_object->taxonomy ][] = $desc;
+			if ( isset( $term_to_ancestor[ $desc ] ) ) {
+				$_desc = $term_to_ancestor[ $desc ];
+				unset( $term_to_ancestor[ $desc ] );
+				$desc = $_desc;
+			} else {
+				$desc = 0;
+			}
+		} while ( ! empty( $desc ) );
+	}
+
+	$possible_object_parents = array_filter( $possible_object_parents );
+
+	$front_page_url = home_url();
+
+	foreach ( (array) $menu_items as $key => $menu_item ) {
+
+		$menu_items[$key]->current = false;
+
+		$classes = (array) $menu_item->classes;
+		$classes[] = 'menu-item';
+		$classes[] = 'menu-item-type-' . $menu_item->type;
+		$classes[] = 'menu-item-object-' . $menu_item->object;
+
+		// if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object
+		if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) {
+			$active_parent_object_ids[] = (int) $menu_item->object_id;
+			$active_parent_item_ids[] = (int) $menu_item->db_id;
+			$active_object = $queried_object->post_type;
+
+		// if the menu item corresponds to the currently-queried post or taxonomy object
+		} elseif (
+			$menu_item->object_id == $queried_object_id &&
+			(
+				( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
+				( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
+				( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) )
+			)
+		) {
+			$classes[] = 'current-menu-item';
+			$menu_items[$key]->current = true;
+			$_anc_id = (int) $menu_item->db_id;
+
+			while(
+				( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
+				! in_array( $_anc_id, $active_ancestor_item_ids )
+			) {
+				$active_ancestor_item_ids[] = $_anc_id;
+			}
+
+			if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) {
+				// Back compat classes for pages to match wp_page_menu()
+				$classes[] = 'page_item';
+				$classes[] = 'page-item-' . $menu_item->object_id;
+				$classes[] = 'current_page_item';
+			}
+			$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
+			$active_parent_object_ids[] = (int) $menu_item->post_parent;
+			$active_object = $menu_item->object;
+
+		// if the menu item corresponds to the currently-requested URL
+		} elseif ( 'custom' == $menu_item->object ) {
+			$current_url = untrailingslashit( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
+			$item_url = untrailingslashit( strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url );
+			$_indexless_current = untrailingslashit( preg_replace( '/index.php$/', '', $current_url ) );
+
+			if ( in_array( $item_url, array( $current_url, $_indexless_current ) ) ) {
+				$classes[] = 'current-menu-item';
+				$menu_items[$key]->current = true;
+				$_anc_id = (int) $menu_item->db_id;
+
+				while(
+					( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
+					! in_array( $_anc_id, $active_ancestor_item_ids )
+				) {
+					$active_ancestor_item_ids[] = $_anc_id;
+				}
+
+				if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) {
+					// Back compat for home link to match wp_page_menu()
+					$classes[] = 'current_page_item';
+				}
+				$active_parent_item_ids[] = (int) $menu_item->menu_item_parent;
+				$active_parent_object_ids[] = (int) $menu_item->post_parent;
+				$active_object = $menu_item->object;
+
+			// give front page item current-menu-item class when extra query arguments involved
+			} elseif ( $item_url == $front_page_url && is_front_page() ) {
+				$classes[] = 'current-menu-item';
+			}
+
+			if ( untrailingslashit($item_url) == home_url() )
+				$classes[] = 'menu-item-home';
+		}
+
+		// back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query
+		if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id )
+			$classes[] = 'current_page_parent';
+
+		$menu_items[$key]->classes = array_unique( $classes );
+	}
+	$active_ancestor_item_ids = array_filter( array_unique( $active_ancestor_item_ids ) );
+	$active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) );
+	$active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) );
+
+	// set parent's class
+	foreach ( (array) $menu_items as $key => $parent_item ) {
+		$classes = (array) $parent_item->classes;
+		$menu_items[$key]->current_item_ancestor = false;
+		$menu_items[$key]->current_item_parent = false;
+
+		if (
+			isset( $parent_item->type ) &&
+			(
+				// ancestral post object
+				(
+					'post_type' == $parent_item->type &&
+					! empty( $queried_object->post_type ) &&
+					is_post_type_hierarchical( $queried_object->post_type ) &&
+					in_array( $parent_item->object_id, $queried_object->ancestors ) &&
+					$parent_item->object != $queried_object->ID
+				) ||
+
+				// ancestral term
+				(
+					'taxonomy' == $parent_item->type &&
+					isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
+					in_array( $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
+					(
+						! isset( $queried_object->term_id ) ||
+						$parent_item->object_id != $queried_object->term_id
+					)
+				)
+			)
+		) {
+			$classes[] = empty( $queried_object->taxonomy ) ? 'current-' . $queried_object->post_type . '-ancestor' : 'current-' . $queried_object->taxonomy . '-ancestor';
+		}
+
+		if ( in_array(  intval( $parent_item->db_id ), $active_ancestor_item_ids ) ) {
+			$classes[] = 'current-menu-ancestor';
+			$menu_items[$key]->current_item_ancestor = true;
+		}
+		if ( in_array( $parent_item->db_id, $active_parent_item_ids ) ) {
+			$classes[] = 'current-menu-parent';
+			$menu_items[$key]->current_item_parent = true;
+		}
+		if ( in_array( $parent_item->object_id, $active_parent_object_ids ) )
+			$classes[] = 'current-' . $active_object . '-parent';
+
+		if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) {
+			// Back compat classes for pages to match wp_page_menu()
+			if ( in_array('current-menu-parent', $classes) )
+				$classes[] = 'current_page_parent';
+			if ( in_array('current-menu-ancestor', $classes) )
+				$classes[] = 'current_page_ancestor';
+		}
+
+		$menu_items[$key]->classes = array_unique( $classes );
+	}
+}
+
+/**
+ * Retrieve the HTML list content for nav menu items.
+ *
+ * @uses Walker_Nav_Menu to create HTML list content.
+ * @since 3.0.0
+ * @see Walker::walk() for parameters and return description.
+ */
+function walk_nav_menu_tree( $items, $depth, $r ) {
+	$walker = ( empty($r->walker) ) ? new Walker_Nav_Menu : $r->walker;
+	$args = array( $items, $depth, $r );
+
+	return call_user_func_array( array(&$walker, 'walk'), $args );
+}
+
+/**
+ * Prevents a menu item ID from being used more than once.
+ *
+ * @since 3.0.1
+ * @access private
+ */
+function _nav_menu_item_id_use_once( $id, $item ) {
+	static $_used_ids = array();
+	if ( in_array( $item->ID, $_used_ids ) )
+		return '';
+	$_used_ids[] = $item->ID;
+	return $id;
+}
+add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
Index: /tags/3.1/wp-includes/nav-menu.php
===================================================================
--- /tags/3.1/wp-includes/nav-menu.php	(revision 17487)
+++ /tags/3.1/wp-includes/nav-menu.php	(revision 17487)
@@ -0,0 +1,751 @@
+<?php
+/**
+ * Navigation Menu functions
+ *
+ * @package WordPress
+ * @subpackage Nav_Menus
+ * @since 3.0.0
+ */
+
+/**
+ * Returns a navigation menu object.
+ *
+ * @since 3.0.0
+ *
+ * @uses get_term
+ * @uses get_term_by
+ *
+ * @param string $menu Menu id, slug or name
+ * @return mixed false if $menu param isn't supplied or term does not exist, menu object if successful.
+ */
+function wp_get_nav_menu_object( $menu ) {
+	if ( ! $menu )
+		return false;
+
+	$menu_obj = get_term( $menu, 'nav_menu' );
+
+	if ( ! $menu_obj )
+		$menu_obj = get_term_by( 'slug', $menu, 'nav_menu' );
+
+	if ( ! $menu_obj )
+		$menu_obj = get_term_by( 'name', $menu, 'nav_menu' );
+
+	if ( ! $menu_obj )
+		$menu_obj = false;
+
+	return $menu_obj;
+}
+
+/**
+ * Check if the given ID is a navigation menu.
+ *
+ * Returns true if it is; false otherwise.
+ *
+ * @since 3.0.0
+ *
+ * @param int|string $menu The menu to check (id, slug, or name)
+ * @return bool Whether the menu exists.
+ */
+function is_nav_menu( $menu ) {
+	if ( ! $menu )
+		return false;
+
+	$menu_obj = wp_get_nav_menu_object( $menu );
+
+	if (
+		$menu_obj &&
+		! is_wp_error( $menu_obj ) &&
+		! empty( $menu_obj->taxonomy ) &&
+		'nav_menu' == $menu_obj->taxonomy
+	)
+		return true;
+
+	return false;
+}
+
+/**
+ * Register navigation menus for a theme.
+ *
+ * @since 3.0.0
+ *
+ * @param array $locations Associative array of menu location identifiers (like a slug) and descriptive text.
+ */
+function register_nav_menus( $locations = array() ) {
+	global $_wp_registered_nav_menus;
+
+	add_theme_support( 'menus' );
+
+	$_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus, $locations );
+}
+
+/**
+ * Unregisters a navigation menu for a theme.
+ *
+ * @param array $location the menu location identifier
+ *
+ * @return bool True on success, false on failure.
+ */
+function unregister_nav_menu( $location ) {
+	global $_wp_registered_nav_menus;
+
+	if ( is_array( $_wp_registered_nav_menus ) && isset( $_wp_registered_nav_menus[$location] ) ) {
+		unset( $_wp_registered_nav_menus[$location] );
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Register a navigation menu for a theme.
+ *
+ * @since 3.0.0
+ *
+ * @param string $location Menu location identifier, like a slug.
+ * @param string $description Menu location descriptive text.
+ */
+function register_nav_menu( $location, $description ) {
+	register_nav_menus( array( $location => $description ) );
+}
+/**
+ * Returns an array of all registered navigation menus in a theme
+ *
+ * @since 3.0.0
+ * @return array
+ */
+function get_registered_nav_menus() {
+	global $_wp_registered_nav_menus;
+	if ( isset( $_wp_registered_nav_menus ) )
+		return $_wp_registered_nav_menus;
+	return array();
+}
+
+/**
+ * Returns an array with the registered navigation menu locations and the menu assigned to it
+ *
+ * @since 3.0.0
+ * @return array
+ */
+
+function get_nav_menu_locations() {
+	return get_theme_mod( 'nav_menu_locations' );
+}
+
+/**
+ * Whether a registered nav menu location has a menu assigned to it.
+ *
+ * @since 3.0.0
+ * @param string $location Menu location identifier.
+ * @return bool Whether location has a menu.
+ */
+function has_nav_menu( $location ) {
+	$locations = get_nav_menu_locations();
+	return ( ! empty( $locations[ $location ] ) );
+}
+
+/**
+ * Determine whether the given ID is a nav menu item.
+ *
+ * @since 3.0.0
+ *
+ * @param int $menu_item_id The ID of the potential nav menu item.
+ * @return bool Whether the given ID is that of a nav menu item.
+ */
+function is_nav_menu_item( $menu_item_id = 0 ) {
+	return ( ! is_wp_error( $menu_item_id ) && ( 'nav_menu_item' == get_post_type( $menu_item_id ) ) );
+}
+
+/**
+ * Create a Navigation Menu.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu_name Menu Name
+ * @return mixed Menu object on success|WP_Error on failure
+ */
+function wp_create_nav_menu( $menu_name ) {
+	return wp_update_nav_menu_object( 0, array( 'menu-name' => $menu_name ) );
+}
+
+/**
+ * Delete a Navigation Menu.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu name|id|slug
+ * @return mixed Menu object on success|WP_Error on failure
+ */
+function wp_delete_nav_menu( $menu ) {
+	$menu = wp_get_nav_menu_object( $menu );
+	if ( ! $menu )
+		return false;
+
+	$menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' );
+	if ( ! empty( $menu_objects ) ) {
+		foreach ( $menu_objects as $item ) {
+			wp_delete_post( $item );
+		}
+	}
+
+	$result = wp_delete_term( $menu->term_id, 'nav_menu' );
+
+	if ( $result && !is_wp_error($result) )
+		do_action( 'wp_delete_nav_menu', $menu->term_id );
+
+	return $result;
+}
+
+/**
+ * Save the properties of a menu or create a new menu with those properties.
+ *
+ * @since 3.0.0
+ *
+ * @param int $menu_id The ID of the menu or "0" to create a new menu.
+ * @param array $menu_data The array of menu data.
+ * @return int|error object The menu's ID or WP_Error object.
+ */
+function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) {
+	$menu_id = (int) $menu_id;
+
+	$_menu = wp_get_nav_menu_object( $menu_id );
+
+	$args = array(
+		'description' => ( isset( $menu_data['description'] ) ? $menu_data['description']  : '' ),
+		'name'        => ( isset( $menu_data['menu-name']   ) ? $menu_data['menu-name']    : '' ),
+		'parent'      => ( isset( $menu_data['parent']      ) ? (int) $menu_data['parent'] : 0  ),
+		'slug'        => null,
+	);
+
+	// double-check that we're not going to have one menu take the name of another
+	$_possible_existing = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' );
+	if (
+		$_possible_existing &&
+		! is_wp_error( $_possible_existing ) &&
+		isset( $_possible_existing->term_id ) &&
+		$_possible_existing->term_id != $menu_id
+	)
+		return new WP_Error( 'menu_exists', sprintf( __('The menu name <strong>%s</strong> conflicts with another menu name. Please try another.'), esc_html( $menu_data['menu-name'] ) ) );
+
+	// menu doesn't already exist, so create a new menu
+	if ( ! $_menu || is_wp_error( $_menu ) ) {
+		$menu_exists = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' );
+
+		if ( $menu_exists )
+			return new WP_Error( 'menu_exists', sprintf( __('The menu name <strong>%s</strong> conflicts with another menu name. Please try another.'), esc_html( $menu_data['menu-name'] ) ) );
+
+		$_menu = wp_insert_term( $menu_data['menu-name'], 'nav_menu', $args );
+
+		if ( is_wp_error( $_menu ) )
+			return $_menu;
+
+		do_action( 'wp_create_nav_menu', $_menu['term_id'], $menu_data );
+
+		return (int) $_menu['term_id'];
+	}
+
+	if ( ! $_menu || ! isset( $_menu->term_id ) )
+		return 0;
+
+	$menu_id = (int) $_menu->term_id;
+
+	$update_response = wp_update_term( $menu_id, 'nav_menu', $args );
+
+	if ( is_wp_error( $update_response ) )
+		return $update_response;
+
+	do_action( 'wp_update_nav_menu', $menu_id, $menu_data );
+	return $menu_id;
+}
+
+/**
+ * Save the properties of a menu item or create a new one.
+ *
+ * @since 3.0.0
+ *
+ * @param int $menu_id The ID of the menu. Required. If "0", makes the menu item a draft orphan.
+ * @param int $menu_item_db_id The ID of the menu item. If "0", creates a new menu item.
+ * @param array $menu_item_data The menu item's data.
+ * @return int The menu item's database ID or WP_Error object on failure.
+ */
+function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item_data = array() ) {
+	$menu_id = (int) $menu_id;
+	$menu_item_db_id = (int) $menu_item_db_id;
+
+	// make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects
+	if ( ! empty( $menu_item_db_id ) && ! is_nav_menu_item( $menu_item_db_id ) )
+		return new WP_Error('update_nav_menu_item_failed', __('The given object ID is not that of a menu item.'));
+
+	$menu = wp_get_nav_menu_object( $menu_id );
+
+	if ( ( ! $menu && 0 !== $menu_id ) || is_wp_error( $menu ) )
+		return $menu;
+
+	$menu_items = 0 == $menu_id ? array() : (array) wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) );
+
+	$count = count( $menu_items );
+
+	$defaults = array(
+		'menu-item-db-id' => $menu_item_db_id,
+		'menu-item-object-id' => 0,
+		'menu-item-object' => '',
+		'menu-item-parent-id' => 0,
+		'menu-item-position' => 0,
+		'menu-item-type' => 'custom',
+		'menu-item-title' => '',
+		'menu-item-url' => '',
+		'menu-item-description' => '',
+		'menu-item-attr-title' => '',
+		'menu-item-target' => '',
+		'menu-item-classes' => '',
+		'menu-item-xfn' => '',
+		'menu-item-status' => '',
+	);
+
+	$args = wp_parse_args( $menu_item_data, $defaults );
+
+	if ( 0 == $menu_id ) {
+		$args['menu-item-position'] = 1;
+	} elseif ( 0 == (int) $args['menu-item-position'] ) {
+		$last_item = array_pop( $menu_items );
+		$args['menu-item-position'] = ( $last_item && isset( $last_item->menu_order ) ) ? 1 + $last_item->menu_order : $count;
+	}
+
+	$original_parent = 0 < $menu_item_db_id ? get_post_field( 'post_parent', $menu_item_db_id ) : 0;
+
+	if ( 'custom' != $args['menu-item-type'] ) {
+		/* if non-custom menu item, then:
+			* use original object's URL
+			* blank default title to sync with original object's
+		*/
+
+		$args['menu-item-url'] = '';
+
+		$original_title = '';
+		if ( 'taxonomy' == $args['menu-item-type'] ) {
+			$original_parent = get_term_field( 'parent', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
+			$original_title = get_term_field( 'name', $args['menu-item-object-id'], $args['menu-item-object'], 'raw' );
+		} elseif ( 'post_type' == $args['menu-item-type'] ) {
+
+			$original_object = get_post( $args['menu-item-object-id'] );
+			$original_parent = (int) $original_object->post_parent;
+			$original_title = $original_object->post_title;
+		}
+
+		if ( empty( $args['menu-item-title'] ) || $args['menu-item-title'] == $original_title ) {
+			$args['menu-item-title'] = '';
+
+			// hack to get wp to create a post object when too many properties are empty
+			if ( empty( $args['menu-item-description'] ) )
+				$args['menu-item-description'] = ' ';
+		}
+	}
+
+	// Populate the menu item object
+	$post = array(
+		'menu_order' => $args['menu-item-position'],
+		'ping_status' => 0,
+		'post_content' => $args['menu-item-description'],
+		'post_excerpt' => $args['menu-item-attr-title'],
+		'post_parent' => $original_parent,
+		'post_title' => $args['menu-item-title'],
+		'post_type' => 'nav_menu_item',
+	);
+
+	if ( 0 != $menu_id )
+		$post['tax_input'] = array( 'nav_menu' => array( intval( $menu->term_id ) ) );
+
+	// New menu item. Default is draft status
+	if ( 0 == $menu_item_db_id ) {
+		$post['ID'] = 0;
+		$post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft';
+		$menu_item_db_id = wp_insert_post( $post );
+
+	// Update existing menu item. Default is publish status
+	} else {
+		$post['ID'] = $menu_item_db_id;
+		$post['post_status'] = 'draft' == $args['menu-item-status'] ? 'draft' : 'publish';
+		wp_update_post( $post );
+	}
+
+	if ( 'custom' == $args['menu-item-type'] ) {
+		$args['menu-item-object-id'] = $menu_item_db_id;
+		$args['menu-item-object'] = 'custom';
+	}
+
+	if ( ! $menu_item_db_id || is_wp_error( $menu_item_db_id ) )
+		return $menu_item_db_id;
+
+	$menu_item_db_id = (int) $menu_item_db_id;
+
+	update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']) );
+	update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', (int) $args['menu-item-parent-id'] );
+	update_post_meta( $menu_item_db_id, '_menu_item_object_id', (int) $args['menu-item-object-id'] );
+	update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
+	update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']) );
+
+	$args['menu-item-classes'] = array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-classes'] ) );
+	$args['menu-item-xfn'] = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-xfn'] ) ) );
+	update_post_meta( $menu_item_db_id, '_menu_item_classes', $args['menu-item-classes'] );
+	update_post_meta( $menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn'] );
+	update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url']) );
+
+	if ( 0 == $menu_id )
+		update_post_meta( $menu_item_db_id, '_menu_item_orphaned', time() );
+	else
+		delete_post_meta( $menu_item_db_id, '_menu_item_orphaned' );
+
+	do_action('wp_update_nav_menu_item', $menu_id, $menu_item_db_id, $args );
+
+	return $menu_item_db_id;
+}
+
+/**
+ * Returns all navigation menu objects.
+ *
+ * @since 3.0.0
+ *
+ * @param array $args Array of arguments passed on to get_terms().
+ * @return array menu objects
+ */
+function wp_get_nav_menus( $args = array() ) {
+	$defaults = array( 'hide_empty' => false, 'orderby' => 'none' );
+	$args = wp_parse_args( $args, $defaults );
+	return apply_filters( 'wp_get_nav_menus', get_terms( 'nav_menu',  $args), $args );
+}
+
+/**
+ * Sort menu items by the desired key.
+ *
+ * @since 3.0.0
+ * @access private
+ *
+ * @param object $a The first object to compare
+ * @param object $b The second object to compare
+ * @return int -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.
+ */
+function _sort_nav_menu_items( $a, $b ) {
+	global $_menu_item_sort_prop;
+
+	if ( empty( $_menu_item_sort_prop ) )
+		return 0;
+
+	if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) )
+		return 0;
+
+	$_a = (int) $a->$_menu_item_sort_prop;
+	$_b = (int) $b->$_menu_item_sort_prop;
+
+	if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop )
+		return 0;
+	elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop )
+		return $_a < $_b ? -1 : 1;
+	else
+		return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
+}
+
+/**
+ * Returns all menu items of a navigation menu.
+ *
+ * @since 3.0.0
+ *
+ * @param string $menu menu name, id, or slug
+ * @param string $args
+ * @return mixed $items array of menu items, else false.
+ */
+function wp_get_nav_menu_items( $menu, $args = array() ) {
+	global $_wp_using_ext_object_cache;
+
+	$menu = wp_get_nav_menu_object( $menu );
+
+	if ( ! $menu )
+		return false;
+
+	static $fetched = array();
+
+	$items = get_objects_in_term( $menu->term_id, 'nav_menu' );
+
+	if ( empty( $items ) )
+		return $items;
+
+	$defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item',
+		'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true,
+		'update_post_term_cache' => false );
+	$args = wp_parse_args( $args, $defaults );
+	if ( count( $items ) > 1 )
+		$args['include'] = implode( ',', $items );
+	else
+		$args['include'] = $items[0];
+
+	$items = get_posts( $args );
+
+	if ( is_wp_error( $items ) || ! is_array( $items ) )
+		return false;
+
+	// Get all posts and terms at once to prime the caches
+	if ( empty( $fetched[$menu->term_id] ) || $_wp_using_ext_object_cache ) {
+		$fetched[$menu->term_id] = true;
+		$posts = array();
+		$terms = array();
+		foreach ( $items as $item ) {
+			$object_id = get_post_meta( $item->ID, '_menu_item_object_id', true );
+			$object    = get_post_meta( $item->ID, '_menu_item_object',    true );
+			$type      = get_post_meta( $item->ID, '_menu_item_type',      true );
+
+			if ( 'post_type' == $type )
+				$posts[$object][] = $object_id;
+			elseif ( 'taxonomy' == $type)
+				$terms[$object][] = $object_id;
+		}
+
+		if ( ! empty( $posts ) ) {
+			foreach ( array_keys($posts) as $post_type ) {
+				get_posts( array('post__in' => $posts[$post_type], 'post_type' => $post_type, 'nopaging' => true, 'update_post_term_cache' => false) );
+			}
+		}
+		unset($posts);
+
+		if ( ! empty( $terms ) ) {
+			foreach ( array_keys($terms) as $taxonomy ) {
+				get_terms($taxonomy, array('include' => $terms[$taxonomy]) );
+			}
+		}
+		unset($terms);
+	}
+
+	$items = array_map( 'wp_setup_nav_menu_item', $items );
+
+	if ( ARRAY_A == $args['output'] ) {
+		$GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
+		usort($items, '_sort_nav_menu_items');
+		$i = 1;
+		foreach( $items as $k => $item ) {
+			$items[$k]->$args['output_key'] = $i++;
+		}
+	}
+
+	return apply_filters( 'wp_get_nav_menu_items',  $items, $menu, $args );
+}
+
+/**
+ * Decorates a menu item object with the shared navigation menu item properties.
+ *
+ * Properties:
+ * - db_id: 		The DB ID of this item as a nav_menu_item object, if it exists (0 if it doesn't exist).
+ * - object_id:		The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
+ * - type:		The family of objects originally represented, such as "post_type" or "taxonomy."
+ * - object:		The type of object originally represented, such as "category," "post", or "attachment."
+ * - type_label:	The singular label used to describe this type of menu item.
+ * - post_parent:	The DB ID of the original object's parent object, if any (0 otherwise).
+ * - menu_item_parent: 	The DB ID of the nav_menu_item that is this item's menu parent, if any.  0 otherwise.
+ * - url:		The URL to which this menu item points.
+ * - title:		The title of this menu item.
+ * - target: 		The target attribute of the link element for this menu item.
+ * - attr_title:	The title attribute of the link element for this menu item.
+ * - classes:		The array of class attribute values for the link element of this menu item.
+ * - xfn:		The XFN relationship expressed in the link of this menu item.
+ * - description:	The description of this menu item.
+ *
+ * @since 3.0.0
+ *
+ * @param object $menu_item The menu item to modify.
+ * @return object $menu_item The menu item with standard menu item properties.
+ */
+function wp_setup_nav_menu_item( $menu_item ) {
+	if ( isset( $menu_item->post_type ) ) {
+		if ( 'nav_menu_item' == $menu_item->post_type ) {
+			$menu_item->db_id = (int) $menu_item->ID;
+			$menu_item->menu_item_parent = empty( $menu_item->menu_item_parent ) ? get_post_meta( $menu_item->ID, '_menu_item_menu_item_parent', true ) : $menu_item->menu_item_parent;
+			$menu_item->object_id = empty( $menu_item->object_id ) ? get_post_meta( $menu_item->ID, '_menu_item_object_id', true ) : $menu_item->object_id;
+			$menu_item->object = empty( $menu_item->object ) ? get_post_meta( $menu_item->ID, '_menu_item_object', true ) : $menu_item->object;
+			$menu_item->type = empty( $menu_item->type ) ? get_post_meta( $menu_item->ID, '_menu_item_type', true ) : $menu_item->type;
+
+			if ( 'post_type' == $menu_item->type ) {
+				$object = get_post_type_object( $menu_item->object );
+				$menu_item->type_label = $object->labels->singular_name;
+				$menu_item->url = get_permalink( $menu_item->object_id );
+
+				$original_object = get_post( $menu_item->object_id );
+				$original_title = $original_object->post_title;
+				$menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
+
+			} elseif ( 'taxonomy' == $menu_item->type ) {
+				$object = get_taxonomy( $menu_item->object );
+				$menu_item->type_label = $object->labels->singular_name;
+				$term_url = get_term_link( (int) $menu_item->object_id, $menu_item->object );
+				$menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';
+
+				$original_title = get_term_field( 'name', $menu_item->object_id, $menu_item->object, 'raw' );
+				$menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
+
+			} else {
+				$menu_item->type_label = __('Custom');
+				$menu_item->title = $menu_item->post_title;
+				$menu_item->url = empty( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url;
+			}
+
+			$menu_item->target = empty( $menu_item->target ) ? get_post_meta( $menu_item->ID, '_menu_item_target', true ) : $menu_item->target;
+
+			$menu_item->attr_title = empty( $menu_item->attr_title ) ? apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt ) : $menu_item->attr_title;
+			$menu_item->description = empty( $menu_item->description ) ? apply_filters( 'nav_menu_description', $menu_item->post_content ) : $menu_item->description;
+
+			$menu_item->classes = empty( $menu_item->classes ) ? (array) get_post_meta( $menu_item->ID, '_menu_item_classes', true ) : $menu_item->classes;
+			$menu_item->xfn = empty( $menu_item->xfn ) ? get_post_meta( $menu_item->ID, '_menu_item_xfn', true ) : $menu_item->xfn;
+		} else {
+			$menu_item->db_id = 0;
+			$menu_item->menu_item_parent = 0;
+			$menu_item->object_id = (int) $menu_item->ID;
+			$menu_item->type = 'post_type';
+
+			$object = get_post_type_object( $menu_item->post_type );
+			$menu_item->object = $object->name;
+			$menu_item->type_label = $object->labels->singular_name;
+
+			$menu_item->title = $menu_item->post_title;
+			$menu_item->url = get_permalink( $menu_item->ID );
+			$menu_item->target = '';
+
+			$menu_item->attr_title = apply_filters( 'nav_menu_attr_title', $menu_item->post_excerpt );
+			$menu_item->description = apply_filters( 'nav_menu_description', $menu_item->post_content );
+			$menu_item->classes = array();
+			$menu_item->xfn = '';
+		}
+	} elseif ( isset( $menu_item->taxonomy ) ) {
+		$menu_item->ID = $menu_item->term_id;
+		$menu_item->db_id = 0;
+		$menu_item->menu_item_parent = 0;
+		$menu_item->object_id = (int) $menu_item->term_id;
+		$menu_item->post_parent = (int) $menu_item->parent;
+		$menu_item->type = 'taxonomy';
+
+		$object = get_taxonomy( $menu_item->taxonomy );
+		$menu_item->object = $object->name;
+		$menu_item->type_label = $object->labels->singular_name;
+
+		$menu_item->title = $menu_item->name;
+		$menu_item->url = get_term_link( $menu_item, $menu_item->taxonomy );
+		$menu_item->target = '';
+		$menu_item->attr_title = '';
+		$menu_item->description = get_term_field( 'description', $menu_item->term_id, $menu_item->taxonomy );
+		$menu_item->classes = array();
+		$menu_item->xfn = '';
+
+	}
+
+	return apply_filters( 'wp_setup_nav_menu_item', $menu_item );
+}
+
+/**
+ * Get the menu items associated with a particular object.
+ *
+ * @since 3.0.0
+ *
+ * @param int $object_id The ID of the original object.
+ * @param string $object_type The type of object, such as "taxonomy" or "post_type."
+ * @return array The array of menu item IDs; empty array if none;
+ */
+function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type' ) {
+	$object_id = (int) $object_id;
+	$menu_item_ids = array();
+
+	$query = new WP_Query;
+	$menu_items = $query->query(
+		array(
+			'meta_key' => '_menu_item_object_id',
+			'meta_value' => $object_id,
+			'post_status' => 'any',
+			'post_type' => 'nav_menu_item',
+			'posts_per_page' => -1,
+		)
+	);
+	foreach( (array) $menu_items as $menu_item ) {
+		if ( isset( $menu_item->ID ) && is_nav_menu_item( $menu_item->ID ) ) {
+			if ( get_post_meta( $menu_item->ID, '_menu_item_type', true ) != $object_type )
+				continue;
+
+			$menu_item_ids[] = (int) $menu_item->ID;
+		}
+	}
+
+	return array_unique( $menu_item_ids );
+}
+
+/**
+ * Callback for handling a menu item when its original object is deleted.
+ *
+ * @since 3.0.0
+ * @access private
+ *
+ * @param int $object_id The ID of the original object being trashed.
+ *
+ */
+function _wp_delete_post_menu_item( $object_id = 0 ) {
+	$object_id = (int) $object_id;
+
+	$menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'post_type' );
+
+	foreach( (array) $menu_item_ids as $menu_item_id ) {
+		wp_delete_post( $menu_item_id, true );
+	}
+}
+
+/**
+ * Callback for handling a menu item when its original object is deleted.
+ *
+ * @since 3.0.0
+ * @access private
+ *
+ * @param int $object_id The ID of the original object being trashed.
+ *
+ */
+function _wp_delete_tax_menu_item( $object_id = 0 ) {
+	$object_id = (int) $object_id;
+
+	$menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy' );
+
+	foreach( (array) $menu_item_ids as $menu_item_id ) {
+		wp_delete_post( $menu_item_id, true );
+	}
+}
+
+/**
+ * Automatically add newly published page objects to menus with that as an option.
+ *
+ * @since 3.0.0
+ * @access private
+ *
+ * @param string $new_status The new status of the post object.
+ * @param string $old_status The old status of the post object.
+ * @param object $post The post object being transitioned from one status to another.
+ * @return void
+ */
+function _wp_auto_add_pages_to_menu( $new_status, $old_status, $post ) {
+	if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type )
+		return;
+	if ( ! empty( $post->post_parent ) )
+		return;
+	$auto_add = get_option( 'nav_menu_options' );
+	if ( empty( $auto_add ) || ! is_array( $auto_add ) || ! isset( $auto_add['auto_add'] ) )
+		return;
+	$auto_add = $auto_add['auto_add'];
+	if ( empty( $auto_add ) || ! is_array( $auto_add ) )
+		return;
+
+	$args = array(
+		'menu-item-object-id' => $post->ID,
+		'menu-item-object' => $post->post_type,
+		'menu-item-type' => 'post_type',
+		'menu-item-status' => 'publish',
+	);
+
+	foreach ( $auto_add as $menu_id ) {
+		$items = wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) );
+		if ( ! is_array( $items ) )
+			continue;
+		foreach ( $items as $item ) {
+			if ( $post->ID == $item->object_id )
+				continue 2;
+		}
+		wp_update_nav_menu_item( $menu_id, 0, $args );
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/pluggable-deprecated.php
===================================================================
--- /tags/3.1/wp-includes/pluggable-deprecated.php	(revision 17487)
+++ /tags/3.1/wp-includes/pluggable-deprecated.php	(revision 17487)
@@ -0,0 +1,136 @@
+<?php
+/**
+ * Deprecated pluggable functions from past WordPress versions. You shouldn't use these
+ * functions and look for the alternatives instead. The functions will be removed in a
+ * later version.
+ *
+ * Deprecated warnings are also thrown if one of these functions is being defined by a plugin.
+ *
+ * @package WordPress
+ * @subpackage Deprecated
+ * @see pluggable.php
+ */
+
+/*
+ * Deprecated functions come here to die.
+ */
+
+if ( !function_exists('set_current_user') ) :
+/**
+ * Changes the current user by ID or name.
+ *
+ * Set $id to null and specify a name if you do not know a user's ID.
+ *
+ * @since 2.0.1
+ * @see wp_set_current_user() An alias of wp_set_current_user()
+ * @deprecated 3.0.0
+ * @deprecated Use wp_set_current_user()
+ *
+ * @param int|null $id User ID.
+ * @param string $name Optional. The user's username
+ * @return object returns wp_set_current_user()
+ */
+function set_current_user($id, $name = '') {
+	_deprecated_function( __FUNCTION__, '3.0', 'wp_set_current_user()' );
+	return wp_set_current_user($id, $name);
+}
+endif;
+
+if ( !function_exists('wp_setcookie') ) :
+/**
+ * Sets a cookie for a user who just logged in. This function is deprecated.
+ *
+ * @since 1.5
+ * @deprecated 2.5
+ * @deprecated Use wp_set_auth_cookie()
+ * @see wp_set_auth_cookie()
+ *
+ * @param string $username The user's username
+ * @param string $password Optional. The user's password
+ * @param bool $already_md5 Optional. Whether the password has already been through MD5
+ * @param string $home Optional. Will be used instead of COOKIEPATH if set
+ * @param string $siteurl Optional. Will be used instead of SITECOOKIEPATH if set
+ * @param bool $remember Optional. Remember that the user is logged in
+ */
+function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
+	_deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
+	$user = get_userdatabylogin($username);
+	wp_set_auth_cookie($user->ID, $remember);
+}
+else :
+	_deprecated_function( 'wp_setcookie', '2.5', 'wp_set_auth_cookie()' );
+endif;
+
+if ( !function_exists('wp_clearcookie') ) :
+/**
+ * Clears the authentication cookie, logging the user out. This function is deprecated.
+ *
+ * @since 1.5
+ * @deprecated 2.5
+ * @deprecated Use wp_clear_auth_cookie()
+ * @see wp_clear_auth_cookie()
+ */
+function wp_clearcookie() {
+	_deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' );
+	wp_clear_auth_cookie();
+}
+else :
+	_deprecated_function( 'wp_clearcookie', '2.5', 'wp_clear_auth_cookie()' );
+endif;
+
+if ( !function_exists('wp_get_cookie_login') ):
+/**
+ * Gets the user cookie login. This function is deprecated.
+ *
+ * This function is deprecated and should no longer be extended as it won't be
+ * used anywhere in WordPress. Also, plugins shouldn't use it either.
+ *
+ * @since 2.0.3
+ * @deprecated 2.5
+ * @deprecated No alternative
+ *
+ * @return bool Always returns false
+ */
+function wp_get_cookie_login() {
+	_deprecated_function( __FUNCTION__, '2.5' );
+	return false;
+}
+else :
+	_deprecated_function( 'wp_get_cookie_login', '2.5' );
+endif;
+
+if ( !function_exists('wp_login') ) :
+/**
+ * Checks a users login information and logs them in if it checks out. This function is deprecated.
+ *
+ * Use the global $error to get the reason why the login failed. If the username
+ * is blank, no error will be set, so assume blank username on that case.
+ *
+ * Plugins extending this function should also provide the global $error and set
+ * what the error is, so that those checking the global for why there was a
+ * failure can utilize it later.
+ *
+ * @since 1.2.2
+ * @deprecated Use wp_signon()
+ * @global string $error Error when false is returned
+ *
+ * @param string $username User's username
+ * @param string $password User's password
+ * @param bool $deprecated Not used
+ * @return bool False on login failure, true on successful check
+ */
+function wp_login($username, $password, $deprecated = '') {
+	_deprecated_function( __FUNCTION__, '2.5', 'wp_signon()' );
+	global $error;
+
+	$user = wp_authenticate($username, $password);
+
+	if ( ! is_wp_error($user) )
+		return true;
+
+	$error = $user->get_error_message();
+	return false;
+}
+else :
+	_deprecated_function( 'wp_login', '2.5', 'wp_signon()' );
+endif;
Index: /tags/3.1/wp-includes/pluggable.php
===================================================================
--- /tags/3.1/wp-includes/pluggable.php	(revision 17487)
+++ /tags/3.1/wp-includes/pluggable.php	(revision 17487)
@@ -0,0 +1,1774 @@
+<?php
+/**
+ * These functions can be replaced via plugins. If plugins do not redefine these
+ * functions, then these will be used instead.
+ *
+ * @package WordPress
+ */
+
+if ( !function_exists('wp_set_current_user') ) :
+/**
+ * Changes the current user by ID or name.
+ *
+ * Set $id to null and specify a name if you do not know a user's ID.
+ *
+ * Some WordPress functionality is based on the current user and not based on
+ * the signed in user. Therefore, it opens the ability to edit and perform
+ * actions on users who aren't signed in.
+ *
+ * @since 2.0.3
+ * @global object $current_user The current user object which holds the user data.
+ * @uses do_action() Calls 'set_current_user' hook after setting the current user.
+ *
+ * @param int $id User ID
+ * @param string $name User's username
+ * @return WP_User Current user User object
+ */
+function wp_set_current_user($id, $name = '') {
+	global $current_user;
+
+	if ( isset($current_user) && ($id == $current_user->ID) )
+		return $current_user;
+
+	$current_user = new WP_User($id, $name);
+
+	setup_userdata($current_user->ID);
+
+	do_action('set_current_user');
+
+	return $current_user;
+}
+endif;
+
+if ( !function_exists('wp_get_current_user') ) :
+/**
+ * Retrieve the current user object.
+ *
+ * @since 2.0.3
+ *
+ * @return WP_User Current user WP_User object
+ */
+function wp_get_current_user() {
+	global $current_user;
+
+	get_currentuserinfo();
+
+	return $current_user;
+}
+endif;
+
+if ( !function_exists('get_currentuserinfo') ) :
+/**
+ * Populate global variables with information about the currently logged in user.
+ *
+ * Will set the current user, if the current user is not set. The current user
+ * will be set to the logged in person. If no user is logged in, then it will
+ * set the current user to 0, which is invalid and won't have any permissions.
+ *
+ * @since 0.71
+ * @uses $current_user Checks if the current user is set
+ * @uses wp_validate_auth_cookie() Retrieves current logged in user.
+ *
+ * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set
+ */
+function get_currentuserinfo() {
+	global $current_user;
+
+	if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
+		return false;
+
+	if ( ! empty($current_user) )
+		return;
+
+	if ( ! $user = wp_validate_auth_cookie() ) {
+		 if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
+		 	wp_set_current_user(0);
+		 	return false;
+		 }
+	}
+
+	wp_set_current_user($user);
+}
+endif;
+
+if ( !function_exists('get_userdata') ) :
+/**
+ * Retrieve user info by user ID.
+ *
+ * @since 0.71
+ *
+ * @param int $user_id User ID
+ * @return bool|object False on failure, User DB row object
+ */
+function get_userdata( $user_id ) {
+	global $wpdb;
+
+	if ( ! is_numeric( $user_id ) )
+		return false;
+
+	$user_id = absint( $user_id );
+	if ( ! $user_id )
+		return false;
+
+	$user = wp_cache_get( $user_id, 'users' );
+
+	if ( $user )
+		return $user;
+
+	if ( ! $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d LIMIT 1", $user_id ) ) )
+		return false;
+
+	_fill_user( $user );
+
+	return $user;
+}
+endif;
+
+if ( !function_exists('cache_users') ) :
+/**
+ * Retrieve info for user lists to prevent multiple queries by get_userdata()
+ *
+ * @since 3.0.0
+ *
+ * @param array $users User ID numbers list
+ */
+function cache_users( $users ) {
+	global $wpdb;
+
+	$clean = array();
+	foreach($users as $id) {
+		$id = (int) $id;
+		if (wp_cache_get($id, 'users')) {
+			// seems to be cached already
+		} else {
+			$clean[] = $id;
+		}
+	}
+
+	if ( 0 == count($clean) )
+		return;
+
+	$list = implode(',', $clean);
+
+	$results = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID IN ($list)");
+
+	_fill_many_users($results);
+}
+endif;
+
+if ( !function_exists('get_user_by') ) :
+/**
+ * Retrieve user info by a given field
+ *
+ * @since 2.8.0
+ *
+ * @param string $field The field to retrieve the user with.  id | slug | email | login
+ * @param int|string $value A value for $field.  A user ID, slug, email address, or login name.
+ * @return bool|object False on failure, User DB row object
+ */
+function get_user_by($field, $value) {
+	global $wpdb;
+
+	switch ($field) {
+		case 'id':
+			return get_userdata($value);
+			break;
+		case 'slug':
+			$user_id = wp_cache_get($value, 'userslugs');
+			$field = 'user_nicename';
+			break;
+		case 'email':
+			$user_id = wp_cache_get($value, 'useremail');
+			$field = 'user_email';
+			break;
+		case 'login':
+			$value = sanitize_user( $value );
+			$user_id = wp_cache_get($value, 'userlogins');
+			$field = 'user_login';
+			break;
+		default:
+			return false;
+	}
+
+	 if ( false !== $user_id )
+		return get_userdata($user_id);
+
+	if ( !$user = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->users WHERE $field = %s", $value) ) )
+		return false;
+
+	_fill_user($user);
+
+	return $user;
+}
+endif;
+
+if ( !function_exists('get_userdatabylogin') ) :
+/**
+ * Retrieve user info by login name.
+ *
+ * @since 0.71
+ *
+ * @param string $user_login User's username
+ * @return bool|object False on failure, User DB row object
+ */
+function get_userdatabylogin($user_login) {
+	return get_user_by('login', $user_login);
+}
+endif;
+
+if ( !function_exists('get_user_by_email') ) :
+/**
+ * Retrieve user info by email.
+ *
+ * @since 2.5
+ *
+ * @param string $email User's email address
+ * @return bool|object False on failure, User DB row object
+ */
+function get_user_by_email($email) {
+	return get_user_by('email', $email);
+}
+endif;
+
+if ( !function_exists( 'wp_mail' ) ) :
+/**
+ * Send mail, similar to PHP's mail
+ *
+ * A true return value does not automatically mean that the user received the
+ * email successfully. It just only means that the method used was able to
+ * process the request without any errors.
+ *
+ * Using the two 'wp_mail_from' and 'wp_mail_from_name' hooks allow from
+ * creating a from address like 'Name <email@address.com>' when both are set. If
+ * just 'wp_mail_from' is set, then just the email address will be used with no
+ * name.
+ *
+ * The default content type is 'text/plain' which does not allow using HTML.
+ * However, you can set the content type of the email by using the
+ * 'wp_mail_content_type' filter.
+ *
+ * The default charset is based on the charset used on the blog. The charset can
+ * be set using the 'wp_mail_charset' filter.
+ *
+ * @since 1.2.1
+ * @uses apply_filters() Calls 'wp_mail' hook on an array of all of the parameters.
+ * @uses apply_filters() Calls 'wp_mail_from' hook to get the from email address.
+ * @uses apply_filters() Calls 'wp_mail_from_name' hook to get the from address name.
+ * @uses apply_filters() Calls 'wp_mail_content_type' hook to get the email content type.
+ * @uses apply_filters() Calls 'wp_mail_charset' hook to get the email charset
+ * @uses do_action_ref_array() Calls 'phpmailer_init' hook on the reference to
+ *		phpmailer object.
+ * @uses PHPMailer
+ * @
+ *
+ * @param string|array $to Array or comma-separated list of email addresses to send message.
+ * @param string $subject Email subject
+ * @param string $message Message contents
+ * @param string|array $headers Optional. Additional headers.
+ * @param string|array $attachments Optional. Files to attach.
+ * @return bool Whether the email contents were sent successfully.
+ */
+function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
+	// Compact the input, apply the filters, and extract them back out
+	extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
+
+	if ( !is_array($attachments) )
+		$attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
+
+	global $phpmailer;
+
+	// (Re)create it, if it's gone missing
+	if ( !is_object( $phpmailer ) || !is_a( $phpmailer, 'PHPMailer' ) ) {
+		require_once ABSPATH . WPINC . '/class-phpmailer.php';
+		require_once ABSPATH . WPINC . '/class-smtp.php';
+		$phpmailer = new PHPMailer();
+	}
+
+	// Headers
+	if ( empty( $headers ) ) {
+		$headers = array();
+	} else {
+		if ( !is_array( $headers ) ) {
+			// Explode the headers out, so this function can take both
+			// string headers and an array of headers.
+			$tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
+		} else {
+			$tempheaders = $headers;
+		}
+		$headers = array();
+
+		// If it's actually got contents
+		if ( !empty( $tempheaders ) ) {
+			// Iterate through the raw headers
+			foreach ( (array) $tempheaders as $header ) {
+				if ( strpos($header, ':') === false ) {
+					if ( false !== stripos( $header, 'boundary=' ) ) {
+						$parts = preg_split('/boundary=/i', trim( $header ) );
+						$boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
+					}
+					continue;
+				}
+				// Explode them out
+				list( $name, $content ) = explode( ':', trim( $header ), 2 );
+
+				// Cleanup crew
+				$name    = trim( $name    );
+				$content = trim( $content );
+
+				switch ( strtolower( $name ) ) {
+					// Mainly for legacy -- process a From: header if it's there
+					case 'from':
+						if ( strpos($content, '<' ) !== false ) {
+							// So... making my life hard again?
+							$from_name = substr( $content, 0, strpos( $content, '<' ) - 1 );
+							$from_name = str_replace( '"', '', $from_name );
+							$from_name = trim( $from_name );
+
+							$from_email = substr( $content, strpos( $content, '<' ) + 1 );
+							$from_email = str_replace( '>', '', $from_email );
+							$from_email = trim( $from_email );
+						} else {
+							$from_email = trim( $content );
+						}
+						break;
+					case 'content-type':
+						if ( strpos( $content, ';' ) !== false ) {
+							list( $type, $charset ) = explode( ';', $content );
+							$content_type = trim( $type );
+							if ( false !== stripos( $charset, 'charset=' ) ) {
+								$charset = trim( str_replace( array( 'charset=', '"' ), '', $charset ) );
+							} elseif ( false !== stripos( $charset, 'boundary=' ) ) {
+								$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset ) );
+								$charset = '';
+							}
+						} else {
+							$content_type = trim( $content );
+						}
+						break;
+					case 'cc':
+						$cc = array_merge( (array) $cc, explode( ',', $content ) );
+						break;
+					case 'bcc':
+						$bcc = array_merge( (array) $bcc, explode( ',', $content ) );
+						break;
+					default:
+						// Add it to our grand headers array
+						$headers[trim( $name )] = trim( $content );
+						break;
+				}
+			}
+		}
+	}
+
+	// Empty out the values that may be set
+	$phpmailer->ClearAddresses();
+	$phpmailer->ClearAllRecipients();
+	$phpmailer->ClearAttachments();
+	$phpmailer->ClearBCCs();
+	$phpmailer->ClearCCs();
+	$phpmailer->ClearCustomHeaders();
+	$phpmailer->ClearReplyTos();
+
+	// From email and name
+	// If we don't have a name from the input headers
+	if ( !isset( $from_name ) )
+		$from_name = 'WordPress';
+
+	/* If we don't have an email from the input headers default to wordpress@$sitename
+	 * Some hosts will block outgoing mail from this address if it doesn't exist but
+	 * there's no easy alternative. Defaulting to admin_email might appear to be another
+	 * option but some hosts may refuse to relay mail from an unknown domain. See
+	 * http://trac.wordpress.org/ticket/5007.
+	 */
+
+	if ( !isset( $from_email ) ) {
+		// Get the site domain and get rid of www.
+		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
+		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
+			$sitename = substr( $sitename, 4 );
+		}
+
+		$from_email = 'wordpress@' . $sitename;
+	}
+
+	// Plugin authors can override the potentially troublesome default
+	$phpmailer->From     = apply_filters( 'wp_mail_from'     , $from_email );
+	$phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name  );
+
+	// Set destination addresses
+	if ( !is_array( $to ) )
+		$to = explode( ',', $to );
+
+	foreach ( (array) $to as $recipient ) {
+		$phpmailer->AddAddress( trim( $recipient ) );
+	}
+
+	// Set mail's subject and body
+	$phpmailer->Subject = $subject;
+	$phpmailer->Body    = $message;
+
+	// Add any CC and BCC recipients
+	if ( !empty( $cc ) ) {
+		foreach ( (array) $cc as $recipient ) {
+			$phpmailer->AddCc( trim($recipient) );
+		}
+	}
+
+	if ( !empty( $bcc ) ) {
+		foreach ( (array) $bcc as $recipient) {
+			$phpmailer->AddBcc( trim($recipient) );
+		}
+	}
+
+	// Set to use PHP's mail()
+	$phpmailer->IsMail();
+
+	// Set Content-Type and charset
+	// If we don't have a content-type from the input headers
+	if ( !isset( $content_type ) )
+		$content_type = 'text/plain';
+
+	$content_type = apply_filters( 'wp_mail_content_type', $content_type );
+
+	$phpmailer->ContentType = $content_type;
+
+	// Set whether it's plaintext, depending on $content_type
+	if ( 'text/html' == $content_type )
+		$phpmailer->IsHTML( true );
+
+	// If we don't have a charset from the input headers
+	if ( !isset( $charset ) )
+		$charset = get_bloginfo( 'charset' );
+
+	// Set the content-type and charset
+	$phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
+
+	// Set custom headers
+	if ( !empty( $headers ) ) {
+		foreach( (array) $headers as $name => $content ) {
+			$phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
+		}
+
+		if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
+			$phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
+	}
+
+	if ( !empty( $attachments ) ) {
+		foreach ( $attachments as $attachment ) {
+			$phpmailer->AddAttachment($attachment);
+		}
+	}
+
+	do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
+
+	// Send!
+	$result = @$phpmailer->Send();
+
+	return $result;
+}
+endif;
+
+if ( !function_exists('wp_authenticate') ) :
+/**
+ * Checks a user's login information and logs them in if it checks out.
+ *
+ * @since 2.5.0
+ *
+ * @param string $username User's username
+ * @param string $password User's password
+ * @return WP_Error|WP_User WP_User object if login successful, otherwise WP_Error object.
+ */
+function wp_authenticate($username, $password) {
+	$username = sanitize_user($username);
+	$password = trim($password);
+
+	$user = apply_filters('authenticate', null, $username, $password);
+
+	if ( $user == null ) {
+		// TODO what should the error message be? (Or would these even happen?)
+		// Only needed if all authentication handlers fail to return anything.
+		$user = new WP_Error('authentication_failed', __('<strong>ERROR</strong>: Invalid username or incorrect password.'));
+	}
+
+	$ignore_codes = array('empty_username', 'empty_password');
+
+	if (is_wp_error($user) && !in_array($user->get_error_code(), $ignore_codes) ) {
+		do_action('wp_login_failed', $username);
+	}
+
+	return $user;
+}
+endif;
+
+if ( !function_exists('wp_logout') ) :
+/**
+ * Log the current user out.
+ *
+ * @since 2.5.0
+ */
+function wp_logout() {
+	wp_clear_auth_cookie();
+	do_action('wp_logout');
+}
+endif;
+
+if ( !function_exists('wp_validate_auth_cookie') ) :
+/**
+ * Validates authentication cookie.
+ *
+ * The checks include making sure that the authentication cookie is set and
+ * pulling in the contents (if $cookie is not used).
+ *
+ * Makes sure the cookie is not expired. Verifies the hash in cookie is what is
+ * should be and compares the two.
+ *
+ * @since 2.5
+ *
+ * @param string $cookie Optional. If used, will validate contents instead of cookie's
+ * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
+ * @return bool|int False if invalid cookie, User ID if valid.
+ */
+function wp_validate_auth_cookie($cookie = '', $scheme = '') {
+	if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) {
+		do_action('auth_cookie_malformed', $cookie, $scheme);
+		return false;
+	}
+
+	extract($cookie_elements, EXTR_OVERWRITE);
+
+	$expired = $expiration;
+
+	// Allow a grace period for POST and AJAX requests
+	if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] )
+		$expired += 3600;
+
+	// Quick check to see if an honest cookie has expired
+	if ( $expired < time() ) {
+		do_action('auth_cookie_expired', $cookie_elements);
+		return false;
+	}
+
+	$user = get_userdatabylogin($username);
+	if ( ! $user ) {
+		do_action('auth_cookie_bad_username', $cookie_elements);
+		return false;
+	}
+
+	$pass_frag = substr($user->user_pass, 8, 4);
+
+	$key = wp_hash($username . $pass_frag . '|' . $expiration, $scheme);
+	$hash = hash_hmac('md5', $username . '|' . $expiration, $key);
+
+	if ( $hmac != $hash ) {
+		do_action('auth_cookie_bad_hash', $cookie_elements);
+		return false;
+	}
+
+	if ( $expiration < time() ) // AJAX/POST grace period set above
+		$GLOBALS['login_grace_period'] = 1;
+
+	do_action('auth_cookie_valid', $cookie_elements, $user);
+
+	return $user->ID;
+}
+endif;
+
+if ( !function_exists('wp_generate_auth_cookie') ) :
+/**
+ * Generate authentication cookie contents.
+ *
+ * @since 2.5
+ * @uses apply_filters() Calls 'auth_cookie' hook on $cookie contents, User ID
+ *		and expiration of cookie.
+ *
+ * @param int $user_id User ID
+ * @param int $expiration Cookie expiration in seconds
+ * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
+ * @return string Authentication cookie contents
+ */
+function wp_generate_auth_cookie($user_id, $expiration, $scheme = 'auth') {
+	$user = get_userdata($user_id);
+
+	$pass_frag = substr($user->user_pass, 8, 4);
+
+	$key = wp_hash($user->user_login . $pass_frag . '|' . $expiration, $scheme);
+	$hash = hash_hmac('md5', $user->user_login . '|' . $expiration, $key);
+
+	$cookie = $user->user_login . '|' . $expiration . '|' . $hash;
+
+	return apply_filters('auth_cookie', $cookie, $user_id, $expiration, $scheme);
+}
+endif;
+
+if ( !function_exists('wp_parse_auth_cookie') ) :
+/**
+ * Parse a cookie into its components
+ *
+ * @since 2.7
+ *
+ * @param string $cookie
+ * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
+ * @return array Authentication cookie components
+ */
+function wp_parse_auth_cookie($cookie = '', $scheme = '') {
+	if ( empty($cookie) ) {
+		switch ($scheme){
+			case 'auth':
+				$cookie_name = AUTH_COOKIE;
+				break;
+			case 'secure_auth':
+				$cookie_name = SECURE_AUTH_COOKIE;
+				break;
+			case "logged_in":
+				$cookie_name = LOGGED_IN_COOKIE;
+				break;
+			default:
+				if ( is_ssl() ) {
+					$cookie_name = SECURE_AUTH_COOKIE;
+					$scheme = 'secure_auth';
+				} else {
+					$cookie_name = AUTH_COOKIE;
+					$scheme = 'auth';
+				}
+	    }
+
+		if ( empty($_COOKIE[$cookie_name]) )
+			return false;
+		$cookie = $_COOKIE[$cookie_name];
+	}
+
+	$cookie_elements = explode('|', $cookie);
+	if ( count($cookie_elements) != 3 )
+		return false;
+
+	list($username, $expiration, $hmac) = $cookie_elements;
+
+	return compact('username', 'expiration', 'hmac', 'scheme');
+}
+endif;
+
+if ( !function_exists('wp_set_auth_cookie') ) :
+/**
+ * Sets the authentication cookies based User ID.
+ *
+ * The $remember parameter increases the time that the cookie will be kept. The
+ * default the cookie is kept without remembering is two days. When $remember is
+ * set, the cookies will be kept for 14 days or two weeks.
+ *
+ * @since 2.5
+ *
+ * @param int $user_id User ID
+ * @param bool $remember Whether to remember the user
+ */
+function wp_set_auth_cookie($user_id, $remember = false, $secure = '') {
+	if ( $remember ) {
+		$expiration = $expire = time() + apply_filters('auth_cookie_expiration', 1209600, $user_id, $remember);
+	} else {
+		$expiration = time() + apply_filters('auth_cookie_expiration', 172800, $user_id, $remember);
+		$expire = 0;
+	}
+
+	if ( '' === $secure )
+		$secure = is_ssl();
+
+	$secure = apply_filters('secure_auth_cookie', $secure, $user_id);
+	$secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure);
+
+	if ( $secure ) {
+		$auth_cookie_name = SECURE_AUTH_COOKIE;
+		$scheme = 'secure_auth';
+	} else {
+		$auth_cookie_name = AUTH_COOKIE;
+		$scheme = 'auth';
+	}
+
+	$auth_cookie = wp_generate_auth_cookie($user_id, $expiration, $scheme);
+	$logged_in_cookie = wp_generate_auth_cookie($user_id, $expiration, 'logged_in');
+
+	do_action('set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme);
+	do_action('set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in');
+
+	// Set httponly if the php version is >= 5.2.0
+	if ( version_compare(phpversion(), '5.2.0', 'ge') ) {
+		setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
+		setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
+		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
+		if ( COOKIEPATH != SITECOOKIEPATH )
+			setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
+	} else {
+		$cookie_domain = COOKIE_DOMAIN;
+		if ( !empty($cookie_domain) )
+			$cookie_domain .= '; HttpOnly';
+		setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, $cookie_domain, $secure);
+		setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, $cookie_domain, $secure);
+		setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, $cookie_domain, $secure_logged_in_cookie);
+		if ( COOKIEPATH != SITECOOKIEPATH )
+			setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, $cookie_domain, $secure_logged_in_cookie);
+	}
+}
+endif;
+
+if ( !function_exists('wp_clear_auth_cookie') ) :
+/**
+ * Removes all of the cookies associated with authentication.
+ *
+ * @since 2.5
+ */
+function wp_clear_auth_cookie() {
+	do_action('clear_auth_cookie');
+
+	setcookie(AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
+	setcookie(AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
+	setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
+	setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
+
+	// Old cookies
+	setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
+	setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
+	setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
+
+	// Even older cookies
+	setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
+	setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
+	setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
+	setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
+}
+endif;
+
+if ( !function_exists('is_user_logged_in') ) :
+/**
+ * Checks if the current visitor is a logged in user.
+ *
+ * @since 2.0.0
+ *
+ * @return bool True if user is logged in, false if not logged in.
+ */
+function is_user_logged_in() {
+	$user = wp_get_current_user();
+
+	if ( $user->id == 0 )
+		return false;
+
+	return true;
+}
+endif;
+
+if ( !function_exists('auth_redirect') ) :
+/**
+ * Checks if a user is logged in, if not it redirects them to the login page.
+ *
+ * @since 1.5
+ */
+function auth_redirect() {
+	// Checks if a user is logged in, if not redirects them to the login page
+
+	$secure = ( is_ssl() || force_ssl_admin() );
+
+	$secure = apply_filters('secure_auth_redirect', $secure);
+
+	// If https is required and request is http, redirect
+	if ( $secure && !is_ssl() && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
+		if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
+			wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
+			exit();
+		} else {
+			wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+			exit();
+		}
+	}
+
+	if ( is_user_admin() )
+		$scheme = 'logged_in';
+	else
+		$scheme = apply_filters( 'auth_redirect_scheme', '' );
+
+	if ( $user_id = wp_validate_auth_cookie( '',  $scheme) ) {
+		do_action('auth_redirect', $user_id);
+
+		// If the user wants ssl but the session is not ssl, redirect.
+		if ( !$secure && get_user_option('use_ssl', $user_id) && false !== strpos($_SERVER['REQUEST_URI'], 'wp-admin') ) {
+			if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
+				wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
+				exit();
+			} else {
+				wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+				exit();
+			}
+		}
+
+		return;  // The cookie is good so we're done
+	}
+
+	// The cookie is no good so force login
+	nocache_headers();
+
+	if ( is_ssl() )
+		$proto = 'https://';
+	else
+		$proto = 'http://';
+
+	$redirect = ( strpos($_SERVER['REQUEST_URI'], '/options.php') && wp_get_referer() ) ? wp_get_referer() : $proto . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+
+	$login_url = wp_login_url($redirect, true);
+
+	wp_redirect($login_url);
+	exit();
+}
+endif;
+
+if ( !function_exists('check_admin_referer') ) :
+/**
+ * Makes sure that a user was referred from another admin page.
+ *
+ * To avoid security exploits.
+ *
+ * @since 1.2.0
+ * @uses do_action() Calls 'check_admin_referer' on $action.
+ *
+ * @param string $action Action nonce
+ * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
+ */
+function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
+	$adminurl = strtolower(admin_url());
+	$referer = strtolower(wp_get_referer());
+	$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
+	if ( !$result && !(-1 == $action && strpos($referer, $adminurl) === 0) ) {
+		wp_nonce_ays($action);
+		die();
+	}
+	do_action('check_admin_referer', $action, $result);
+	return $result;
+}endif;
+
+if ( !function_exists('check_ajax_referer') ) :
+/**
+ * Verifies the AJAX request to prevent processing requests external of the blog.
+ *
+ * @since 2.0.3
+ *
+ * @param string $action Action nonce
+ * @param string $query_arg where to look for nonce in $_REQUEST (since 2.5)
+ */
+function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) {
+	if ( $query_arg )
+		$nonce = $_REQUEST[$query_arg];
+	else
+		$nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce'];
+
+	$result = wp_verify_nonce( $nonce, $action );
+
+	if ( $die && false == $result )
+		die('-1');
+
+	do_action('check_ajax_referer', $action, $result);
+
+	return $result;
+}
+endif;
+
+if ( !function_exists('wp_redirect') ) :
+/**
+ * Redirects to another page.
+ *
+ * @since 1.5.1
+ * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
+ *
+ * @param string $location The path to redirect to
+ * @param int $status Status code to use
+ * @return bool False if $location is not set
+ */
+function wp_redirect($location, $status = 302) {
+	global $is_IIS;
+
+	$location = apply_filters('wp_redirect', $location, $status);
+	$status = apply_filters('wp_redirect_status', $status, $location);
+
+	if ( !$location ) // allows the wp_redirect filter to cancel a redirect
+		return false;
+
+	$location = wp_sanitize_redirect($location);
+
+	if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
+		status_header($status); // This causes problems on IIS and some FastCGI setups
+
+	header("Location: $location", true, $status);
+}
+endif;
+
+if ( !function_exists('wp_sanitize_redirect') ) :
+/**
+ * Sanitizes a URL for use in a redirect.
+ *
+ * @since 2.3
+ *
+ * @return string redirect-sanitized URL
+ **/
+function wp_sanitize_redirect($location) {
+	$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location);
+	$location = wp_kses_no_null($location);
+
+	// remove %0d and %0a from location
+	$strip = array('%0d', '%0a', '%0D', '%0A');
+	$location = _deep_replace($strip, $location);
+	return $location;
+}
+endif;
+
+if ( !function_exists('wp_safe_redirect') ) :
+/**
+ * Performs a safe (local) redirect, using wp_redirect().
+ *
+ * Checks whether the $location is using an allowed host, if it has an absolute
+ * path. A plugin can therefore set or remove allowed host(s) to or from the
+ * list.
+ *
+ * If the host is not allowed, then the redirect is to wp-admin on the siteurl
+ * instead. This prevents malicious redirects which redirect to another host,
+ * but only used in a few places.
+ *
+ * @since 2.3
+ * @uses wp_validate_redirect() To validate the redirect is to an allowed host.
+ *
+ * @return void Does not return anything
+ **/
+function wp_safe_redirect($location, $status = 302) {
+
+	// Need to look at the URL the way it will end up in wp_redirect()
+	$location = wp_sanitize_redirect($location);
+
+	$location = wp_validate_redirect($location, admin_url());
+
+	wp_redirect($location, $status);
+}
+endif;
+
+if ( !function_exists('wp_validate_redirect') ) :
+/**
+ * Validates a URL for use in a redirect.
+ *
+ * Checks whether the $location is using an allowed host, if it has an absolute
+ * path. A plugin can therefore set or remove allowed host(s) to or from the
+ * list.
+ *
+ * If the host is not allowed, then the redirect is to $default supplied
+ *
+ * @since 2.8.1
+ * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing
+ *		WordPress host string and $location host string.
+ *
+ * @param string $location The redirect to validate
+ * @param string $default The value to return is $location is not allowed
+ * @return string redirect-sanitized URL
+ **/
+function wp_validate_redirect($location, $default = '') {
+	// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
+	if ( substr($location, 0, 2) == '//' )
+		$location = 'http:' . $location;
+
+	// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
+	$test = ( $cut = strpos($location, '?') ) ? substr( $location, 0, $cut ) : $location;
+
+	$lp  = parse_url($test);
+
+	// Give up if malformed URL
+	if ( false === $lp )
+		return $default;
+
+	// Allow only http and https schemes. No data:, etc.
+	if ( isset($lp['scheme']) && !('http' == $lp['scheme'] || 'https' == $lp['scheme']) )
+		return $default;
+
+	// Reject if scheme is set but host is not. This catches urls like https:host.com for which parse_url does not set the host field.
+	if ( isset($lp['scheme'])  && !isset($lp['host']) )
+		return $default;
+
+	$wpp = parse_url(home_url());
+
+	$allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');
+
+	if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) )
+		$location = $default;
+
+	return $location;
+}
+endif;
+
+if ( ! function_exists('wp_notify_postauthor') ) :
+/**
+ * Notify an author of a comment/trackback/pingback to one of their posts.
+ *
+ * @since 1.0.0
+ *
+ * @param int $comment_id Comment ID
+ * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
+ * @return bool False if user email does not exist. True on completion.
+ */
+function wp_notify_postauthor( $comment_id, $comment_type = '' ) {
+	$comment = get_comment( $comment_id );
+	$post    = get_post( $comment->comment_post_ID );
+	$author  = get_userdata( $post->post_author );
+
+	// The comment was left by the author
+	if ( $comment->user_id == $post->post_author )
+		return false;
+
+	// The author moderated a comment on his own post
+	if ( $post->post_author == get_current_user_id() )
+		return false;
+
+	// If there's no email to send the comment to
+	if ( '' == $author->user_email )
+		return false;
+
+	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
+
+	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
+	// we want to reverse this for the plain text arena of emails.
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
+
+	if ( empty( $comment_type ) ) $comment_type = 'comment';
+
+	if ('comment' == $comment_type) {
+		$notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
+		/* translators: 1: comment author, 2: author IP, 3: author domain */
+		$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+		$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
+		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
+		$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
+		$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+		$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
+		/* translators: 1: blog name, 2: post title */
+		$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
+	} elseif ('trackback' == $comment_type) {
+		$notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
+		/* translators: 1: website name, 2: author IP, 3: author domain */
+		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
+		$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+		$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
+		/* translators: 1: blog name, 2: post title */
+		$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
+	} elseif ('pingback' == $comment_type) {
+		$notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
+		/* translators: 1: comment author, 2: author IP, 3: author domain */
+		$notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+		$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
+		$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
+		$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
+		/* translators: 1: blog name, 2: post title */
+		$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
+	}
+	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
+	$notify_message .= sprintf( __('Permalink: %s'), get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id ) . "\r\n";
+	if ( EMPTY_TRASH_DAYS )
+		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
+	else
+		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
+	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
+
+	$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
+
+	if ( '' == $comment->comment_author ) {
+		$from = "From: \"$blogname\" <$wp_email>";
+		if ( '' != $comment->comment_author_email )
+			$reply_to = "Reply-To: $comment->comment_author_email";
+	} else {
+		$from = "From: \"$comment->comment_author\" <$wp_email>";
+		if ( '' != $comment->comment_author_email )
+			$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
+	}
+
+	$message_headers = "$from\n"
+		. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
+
+	if ( isset($reply_to) )
+		$message_headers .= $reply_to . "\n";
+
+	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
+	$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
+	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
+
+	@wp_mail( $author->user_email, $subject, $notify_message, $message_headers );
+
+	return true;
+}
+endif;
+
+if ( !function_exists('wp_notify_moderator') ) :
+/**
+ * Notifies the moderator of the blog about a new comment that is awaiting approval.
+ *
+ * @since 1.0
+ * @uses $wpdb
+ *
+ * @param int $comment_id Comment ID
+ * @return bool Always returns true
+ */
+function wp_notify_moderator($comment_id) {
+	global $wpdb;
+
+	if ( 0 == get_option( 'moderation_notify' ) )
+		return true;
+
+	$comment = get_comment($comment_id);
+	$post = get_post($comment->comment_post_ID);
+	$user = get_userdata( $post->post_author );
+	// Send to the administation and to the post author if the author can modify the comment.
+	$email_to = array( get_option('admin_email') );
+	if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )
+		$email_to[] = $user->user_email;
+
+	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
+	$comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
+
+	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
+	// we want to reverse this for the plain text arena of emails.
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
+
+	switch ($comment->comment_type)
+	{
+		case 'trackback':
+			$notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
+			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
+			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
+			$notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+			break;
+		case 'pingback':
+			$notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
+			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
+			$notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
+			$notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+			break;
+		default: //Comments
+			$notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
+			$notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
+			$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
+			$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
+			$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
+			$notify_message .= sprintf( __('Whois  : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n";
+			$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
+			break;
+	}
+
+	$notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
+	if ( EMPTY_TRASH_DAYS )
+		$notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
+	else
+		$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
+	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
+
+	$notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
+ 		'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
+	$notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n";
+
+	$subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title );
+	$message_headers = '';
+
+	$notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
+	$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
+	$message_headers = apply_filters('comment_moderation_headers', $message_headers);
+
+	foreach ( $email_to as $email )
+		@wp_mail($email, $subject, $notify_message, $message_headers);
+
+	return true;
+}
+endif;
+
+if ( !function_exists('wp_password_change_notification') ) :
+/**
+ * Notify the blog admin of a user changing password, normally via email.
+ *
+ * @since 2.7
+ *
+ * @param object $user User Object
+ */
+function wp_password_change_notification(&$user) {
+	// send a copy of password change notification to the admin
+	// but check to see if it's the admin whose password we're changing, and skip this
+	if ( $user->user_email != get_option('admin_email') ) {
+		$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
+		// The blogname option is escaped with esc_html on the way into the database in sanitize_option
+		// we want to reverse this for the plain text arena of emails.
+		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
+		wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
+	}
+}
+endif;
+
+if ( !function_exists('wp_new_user_notification') ) :
+/**
+ * Notify the blog admin of a new user, normally via email.
+ *
+ * @since 2.0
+ *
+ * @param int $user_id User ID
+ * @param string $plaintext_pass Optional. The user's plaintext password
+ */
+function wp_new_user_notification($user_id, $plaintext_pass = '') {
+	$user = new WP_User($user_id);
+
+	$user_login = stripslashes($user->user_login);
+	$user_email = stripslashes($user->user_email);
+
+	// The blogname option is escaped with esc_html on the way into the database in sanitize_option
+	// we want to reverse this for the plain text arena of emails.
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
+
+	$message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
+	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
+	$message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
+
+	@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
+
+	if ( empty($plaintext_pass) )
+		return;
+
+	$message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
+	$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
+	$message .= wp_login_url() . "\r\n";
+
+	wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
+
+}
+endif;
+
+if ( !function_exists('wp_nonce_tick') ) :
+/**
+ * Get the time-dependent variable for nonce creation.
+ *
+ * A nonce has a lifespan of two ticks. Nonces in their second tick may be
+ * updated, e.g. by autosave.
+ *
+ * @since 2.5
+ *
+ * @return int
+ */
+function wp_nonce_tick() {
+	$nonce_life = apply_filters('nonce_life', 86400);
+
+	return ceil(time() / ( $nonce_life / 2 ));
+}
+endif;
+
+if ( !function_exists('wp_verify_nonce') ) :
+/**
+ * Verify that correct nonce was used with time limit.
+ *
+ * The user is given an amount of time to use the token, so therefore, since the
+ * UID and $action remain the same, the independent variable is the time.
+ *
+ * @since 2.0.3
+ *
+ * @param string $nonce Nonce that was used in the form to verify
+ * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
+ * @return bool Whether the nonce check passed or failed.
+ */
+function wp_verify_nonce($nonce, $action = -1) {
+	$user = wp_get_current_user();
+	$uid = (int) $user->id;
+
+	$i = wp_nonce_tick();
+
+	// Nonce generated 0-12 hours ago
+	if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )
+		return 1;
+	// Nonce generated 12-24 hours ago
+	if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) == $nonce )
+		return 2;
+	// Invalid nonce
+	return false;
+}
+endif;
+
+if ( !function_exists('wp_create_nonce') ) :
+/**
+ * Creates a random, one time use token.
+ *
+ * @since 2.0.3
+ *
+ * @param string|int $action Scalar value to add context to the nonce.
+ * @return string The one use form token
+ */
+function wp_create_nonce($action = -1) {
+	$user = wp_get_current_user();
+	$uid = (int) $user->id;
+
+	$i = wp_nonce_tick();
+
+	return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
+}
+endif;
+
+if ( !function_exists('wp_salt') ) :
+/**
+ * Get salt to add to hashes to help prevent attacks.
+ *
+ * The secret key is located in two places: the database in case the secret key
+ * isn't defined in the second place, which is in the wp-config.php file. If you
+ * are going to set the secret key, then you must do so in the wp-config.php
+ * file.
+ *
+ * The secret key in the database is randomly generated and will be appended to
+ * the secret key that is in wp-config.php file in some instances. It is
+ * important to have the secret key defined or changed in wp-config.php.
+ *
+ * If you have installed WordPress 2.5 or later, then you will have the
+ * SECRET_KEY defined in the wp-config.php already. You will want to change the
+ * value in it because hackers will know what it is. If you have upgraded to
+ * WordPress 2.5 or later version from a version before WordPress 2.5, then you
+ * should add the constant to your wp-config.php file.
+ *
+ * Below is an example of how the SECRET_KEY constant is defined with a value.
+ * You must not copy the below example and paste into your wp-config.php. If you
+ * need an example, then you can have a
+ * {@link https://api.wordpress.org/secret-key/1.1/ secret key created} for you.
+ *
+ * <code>
+ * define('SECRET_KEY', 'mAry1HadA15|\/|b17w55w1t3asSn09w');
+ * </code>
+ *
+ * Salting passwords helps against tools which has stored hashed values of
+ * common dictionary strings. The added values makes it harder to crack if given
+ * salt string is not weak.
+ *
+ * @since 2.5
+ * @link https://api.wordpress.org/secret-key/1.1/ Create a Secret Key for wp-config.php
+ *
+ * @param string $scheme Authentication scheme
+ * @return string Salt value
+ */
+function wp_salt($scheme = 'auth') {
+	global $wp_default_secret_key;
+	$secret_key = '';
+	if ( defined('SECRET_KEY') && ('' != SECRET_KEY) && ( $wp_default_secret_key != SECRET_KEY) )
+		$secret_key = SECRET_KEY;
+
+	if ( 'auth' == $scheme ) {
+		if ( defined('AUTH_KEY') && ('' != AUTH_KEY) && ( $wp_default_secret_key != AUTH_KEY) )
+			$secret_key = AUTH_KEY;
+
+		if ( defined('AUTH_SALT') && ('' != AUTH_SALT) && ( $wp_default_secret_key != AUTH_SALT) ) {
+			$salt = AUTH_SALT;
+		} elseif ( defined('SECRET_SALT') && ('' != SECRET_SALT) && ( $wp_default_secret_key != SECRET_SALT) ) {
+			$salt = SECRET_SALT;
+		} else {
+			$salt = get_site_option('auth_salt');
+			if ( empty($salt) ) {
+				$salt = wp_generate_password( 64, true, true );
+				update_site_option('auth_salt', $salt);
+			}
+		}
+	} elseif ( 'secure_auth' == $scheme ) {
+		if ( defined('SECURE_AUTH_KEY') && ('' != SECURE_AUTH_KEY) && ( $wp_default_secret_key != SECURE_AUTH_KEY) )
+			$secret_key = SECURE_AUTH_KEY;
+
+		if ( defined('SECURE_AUTH_SALT') && ('' != SECURE_AUTH_SALT) && ( $wp_default_secret_key != SECURE_AUTH_SALT) ) {
+			$salt = SECURE_AUTH_SALT;
+		} else {
+			$salt = get_site_option('secure_auth_salt');
+			if ( empty($salt) ) {
+				$salt = wp_generate_password( 64, true, true );
+				update_site_option('secure_auth_salt', $salt);
+			}
+		}
+	} elseif ( 'logged_in' == $scheme ) {
+		if ( defined('LOGGED_IN_KEY') && ('' != LOGGED_IN_KEY) && ( $wp_default_secret_key != LOGGED_IN_KEY) )
+			$secret_key = LOGGED_IN_KEY;
+
+		if ( defined('LOGGED_IN_SALT') && ('' != LOGGED_IN_SALT) && ( $wp_default_secret_key != LOGGED_IN_SALT) ) {
+			$salt = LOGGED_IN_SALT;
+		} else {
+			$salt = get_site_option('logged_in_salt');
+			if ( empty($salt) ) {
+				$salt = wp_generate_password( 64, true, true );
+				update_site_option('logged_in_salt', $salt);
+			}
+		}
+	} elseif ( 'nonce' == $scheme ) {
+		if ( defined('NONCE_KEY') && ('' != NONCE_KEY) && ( $wp_default_secret_key != NONCE_KEY) )
+			$secret_key = NONCE_KEY;
+
+		if ( defined('NONCE_SALT') && ('' != NONCE_SALT) && ( $wp_default_secret_key != NONCE_SALT) ) {
+			$salt = NONCE_SALT;
+		} else {
+			$salt = get_site_option('nonce_salt');
+			if ( empty($salt) ) {
+				$salt = wp_generate_password( 64, true, true );
+				update_site_option('nonce_salt', $salt);
+			}
+		}
+	} else {
+		// ensure each auth scheme has its own unique salt
+		$salt = hash_hmac('md5', $scheme, $secret_key);
+	}
+
+	return apply_filters('salt', $secret_key . $salt, $scheme);
+}
+endif;
+
+if ( !function_exists('wp_hash') ) :
+/**
+ * Get hash of given string.
+ *
+ * @since 2.0.3
+ * @uses wp_salt() Get WordPress salt
+ *
+ * @param string $data Plain text to hash
+ * @return string Hash of $data
+ */
+function wp_hash($data, $scheme = 'auth') {
+	$salt = wp_salt($scheme);
+
+	return hash_hmac('md5', $data, $salt);
+}
+endif;
+
+if ( !function_exists('wp_hash_password') ) :
+/**
+ * Create a hash (encrypt) of a plain text password.
+ *
+ * For integration with other applications, this function can be overwritten to
+ * instead use the other package password checking algorithm.
+ *
+ * @since 2.5
+ * @global object $wp_hasher PHPass object
+ * @uses PasswordHash::HashPassword
+ *
+ * @param string $password Plain text user password to hash
+ * @return string The hash string of the password
+ */
+function wp_hash_password($password) {
+	global $wp_hasher;
+
+	if ( empty($wp_hasher) ) {
+		require_once( ABSPATH . 'wp-includes/class-phpass.php');
+		// By default, use the portable hash from phpass
+		$wp_hasher = new PasswordHash(8, TRUE);
+	}
+
+	return $wp_hasher->HashPassword($password);
+}
+endif;
+
+if ( !function_exists('wp_check_password') ) :
+/**
+ * Checks the plaintext password against the encrypted Password.
+ *
+ * Maintains compatibility between old version and the new cookie authentication
+ * protocol using PHPass library. The $hash parameter is the encrypted password
+ * and the function compares the plain text password when encypted similarly
+ * against the already encrypted password to see if they match.
+ *
+ * For integration with other applications, this function can be overwritten to
+ * instead use the other package password checking algorithm.
+ *
+ * @since 2.5
+ * @global object $wp_hasher PHPass object used for checking the password
+ *	against the $hash + $password
+ * @uses PasswordHash::CheckPassword
+ *
+ * @param string $password Plaintext user's password
+ * @param string $hash Hash of the user's password to check against.
+ * @return bool False, if the $password does not match the hashed password
+ */
+function wp_check_password($password, $hash, $user_id = '') {
+	global $wp_hasher;
+
+	// If the hash is still md5...
+	if ( strlen($hash) <= 32 ) {
+		$check = ( $hash == md5($password) );
+		if ( $check && $user_id ) {
+			// Rehash using new hash.
+			wp_set_password($password, $user_id);
+			$hash = wp_hash_password($password);
+		}
+
+		return apply_filters('check_password', $check, $password, $hash, $user_id);
+	}
+
+	// If the stored hash is longer than an MD5, presume the
+	// new style phpass portable hash.
+	if ( empty($wp_hasher) ) {
+		require_once( ABSPATH . 'wp-includes/class-phpass.php');
+		// By default, use the portable hash from phpass
+		$wp_hasher = new PasswordHash(8, TRUE);
+	}
+
+	$check = $wp_hasher->CheckPassword($password, $hash);
+
+	return apply_filters('check_password', $check, $password, $hash, $user_id);
+}
+endif;
+
+if ( !function_exists('wp_generate_password') ) :
+/**
+ * Generates a random password drawn from the defined set of characters.
+ *
+ * @since 2.5
+ *
+ * @param int $length The length of password to generate
+ * @param bool $special_chars Whether to include standard special characters. Default true.
+ * @param bool $extra_special_chars Whether to include other special characters. Used when
+ *   generating secret keys and salts. Default false.
+ * @return string The random password
+ **/
+function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
+	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+	if ( $special_chars )
+		$chars .= '!@#$%^&*()';
+	if ( $extra_special_chars )
+		$chars .= '-_ []{}<>~`+=,.;:/?|';
+
+	$password = '';
+	for ( $i = 0; $i < $length; $i++ ) {
+		$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
+	}
+
+	// random_password filter was previously in random_password function which was deprecated
+	return apply_filters('random_password', $password);
+}
+endif;
+
+if ( !function_exists('wp_rand') ) :
+ /**
+ * Generates a random number
+ *
+ * @since 2.6.2
+ *
+ * @param int $min Lower limit for the generated number (optional, default is 0)
+ * @param int $max Upper limit for the generated number (optional, default is 4294967295)
+ * @return int A random number between min and max
+ */
+function wp_rand( $min = 0, $max = 0 ) {
+	global $rnd_value;
+
+	// Reset $rnd_value after 14 uses
+	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
+	if ( strlen($rnd_value) < 8 ) {
+		if ( defined( 'WP_SETUP_CONFIG' ) )
+			static $seed = '';
+		else
+			$seed = get_transient('random_seed');
+		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
+		$rnd_value .= sha1($rnd_value);
+		$rnd_value .= sha1($rnd_value . $seed);
+		$seed = md5($seed . $rnd_value);
+		if ( ! defined( 'WP_SETUP_CONFIG' ) )
+			set_transient('random_seed', $seed);
+	}
+
+	// Take the first 8 digits for our value
+	$value = substr($rnd_value, 0, 8);
+
+	// Strip the first eight, leaving the remainder for the next call to wp_rand().
+	$rnd_value = substr($rnd_value, 8);
+
+	$value = abs(hexdec($value));
+
+	// Reduce the value to be within the min - max range
+	// 4294967295 = 0xffffffff = max random number
+	if ( $max != 0 )
+		$value = $min + (($max - $min + 1) * ($value / (4294967295 + 1)));
+
+	return abs(intval($value));
+}
+endif;
+
+if ( !function_exists('wp_set_password') ) :
+/**
+ * Updates the user's password with a new encrypted one.
+ *
+ * For integration with other applications, this function can be overwritten to
+ * instead use the other package password checking algorithm.
+ *
+ * @since 2.5
+ * @uses $wpdb WordPress database object for queries
+ * @uses wp_hash_password() Used to encrypt the user's password before passing to the database
+ *
+ * @param string $password The plaintext new user password
+ * @param int $user_id User ID
+ */
+function wp_set_password( $password, $user_id ) {
+	global $wpdb;
+
+	$hash = wp_hash_password($password);
+	$wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) );
+
+	wp_cache_delete($user_id, 'users');
+}
+endif;
+
+if ( !function_exists( 'get_avatar' ) ) :
+/**
+ * Retrieve the avatar for a user who provided a user ID or email address.
+ *
+ * @since 2.5
+ * @param int|string|object $id_or_email A user ID,  email address, or comment object
+ * @param int $size Size of the avatar image
+ * @param string $default URL to a default image to use if no avatar is available
+ * @param string $alt Alternate text to use in image tag. Defaults to blank
+ * @return string <img> tag for the user's avatar
+*/
+function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
+	if ( ! get_option('show_avatars') )
+		return false;
+
+	if ( false === $alt)
+		$safe_alt = '';
+	else
+		$safe_alt = esc_attr( $alt );
+
+	if ( !is_numeric($size) )
+		$size = '96';
+
+	$email = '';
+	if ( is_numeric($id_or_email) ) {
+		$id = (int) $id_or_email;
+		$user = get_userdata($id);
+		if ( $user )
+			$email = $user->user_email;
+	} elseif ( is_object($id_or_email) ) {
+		// No avatar for pingbacks or trackbacks
+		$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
+		if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) )
+			return false;
+
+		if ( !empty($id_or_email->user_id) ) {
+			$id = (int) $id_or_email->user_id;
+			$user = get_userdata($id);
+			if ( $user)
+				$email = $user->user_email;
+		} elseif ( !empty($id_or_email->comment_author_email) ) {
+			$email = $id_or_email->comment_author_email;
+		}
+	} else {
+		$email = $id_or_email;
+	}
+
+	if ( empty($default) ) {
+		$avatar_default = get_option('avatar_default');
+		if ( empty($avatar_default) )
+			$default = 'mystery';
+		else
+			$default = $avatar_default;
+	}
+
+	if ( !empty($email) )
+		$email_hash = md5( strtolower( $email ) );
+
+	if ( is_ssl() ) {
+		$host = 'https://secure.gravatar.com';
+	} else {
+		if ( !empty($email) )
+			$host = sprintf( "http://%d.gravatar.com", ( hexdec( $email_hash[0] ) % 2 ) );
+		else
+			$host = 'http://0.gravatar.com';
+	}
+
+	if ( 'mystery' == $default )
+		$default = "$host/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}"; // ad516503a11cd5ca435acc9bb6523536 == md5('unknown@gravatar.com')
+	elseif ( 'blank' == $default )
+		$default = includes_url('images/blank.gif');
+	elseif ( !empty($email) && 'gravatar_default' == $default )
+		$default = '';
+	elseif ( 'gravatar_default' == $default )
+		$default = "$host/avatar/s={$size}";
+	elseif ( empty($email) )
+		$default = "$host/avatar/?d=$default&amp;s={$size}";
+	elseif ( strpos($default, 'http://') === 0 )
+		$default = add_query_arg( 's', $size, $default );
+
+	if ( !empty($email) ) {
+		$out = "$host/avatar/";
+		$out .= $email_hash;
+		$out .= '?s='.$size;
+		$out .= '&amp;d=' . urlencode( $default );
+
+		$rating = get_option('avatar_rating');
+		if ( !empty( $rating ) )
+			$out .= "&amp;r={$rating}";
+
+		$avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
+	} else {
+		$avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
+	}
+
+	return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
+}
+endif;
+
+if ( !function_exists( 'wp_text_diff' ) ) :
+/**
+ * Displays a human readable HTML representation of the difference between two strings.
+ *
+ * The Diff is available for getting the changes between versions. The output is
+ * HTML, so the primary use is for displaying the changes. If the two strings
+ * are equivalent, then an empty string will be returned.
+ *
+ * The arguments supported and can be changed are listed below.
+ *
+ * 'title' : Default is an empty string. Titles the diff in a manner compatible
+ *		with the output.
+ * 'title_left' : Default is an empty string. Change the HTML to the left of the
+ *		title.
+ * 'title_right' : Default is an empty string. Change the HTML to the right of
+ *		the title.
+ *
+ * @since 2.6
+ * @see wp_parse_args() Used to change defaults to user defined settings.
+ * @uses Text_Diff
+ * @uses WP_Text_Diff_Renderer_Table
+ *
+ * @param string $left_string "old" (left) version of string
+ * @param string $right_string "new" (right) version of string
+ * @param string|array $args Optional. Change 'title', 'title_left', and 'title_right' defaults.
+ * @return string Empty string if strings are equivalent or HTML with differences.
+ */
+function wp_text_diff( $left_string, $right_string, $args = null ) {
+	$defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
+	$args = wp_parse_args( $args, $defaults );
+
+	if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
+		require( ABSPATH . WPINC . '/wp-diff.php' );
+
+	$left_string  = normalize_whitespace($left_string);
+	$right_string = normalize_whitespace($right_string);
+
+	$left_lines  = split("\n", $left_string);
+	$right_lines = split("\n", $right_string);
+
+	$text_diff = new Text_Diff($left_lines, $right_lines);
+	$renderer  = new WP_Text_Diff_Renderer_Table();
+	$diff = $renderer->render($text_diff);
+
+	if ( !$diff )
+		return '';
+
+	$r  = "<table class='diff'>\n";
+	$r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
+
+	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
+		$r .= "<thead>";
+	if ( $args['title'] )
+		$r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n";
+	if ( $args['title_left'] || $args['title_right'] ) {
+		$r .= "<tr class='diff-sub-title'>\n";
+		$r .= "\t<td></td><th>$args[title_left]</th>\n";
+		$r .= "\t<td></td><th>$args[title_right]</th>\n";
+		$r .= "</tr>\n";
+	}
+	if ( $args['title'] || $args['title_left'] || $args['title_right'] )
+		$r .= "</thead>\n";
+
+	$r .= "<tbody>\n$diff\n</tbody>\n";
+	$r .= "</table>";
+
+	return $r;
+}
+endif;
Index: /tags/3.1/wp-includes/plugin.php
===================================================================
--- /tags/3.1/wp-includes/plugin.php	(revision 17487)
+++ /tags/3.1/wp-includes/plugin.php	(revision 17487)
@@ -0,0 +1,775 @@
+<?php
+/**
+ * The plugin API is located in this file, which allows for creating actions
+ * and filters and hooking functions, and methods. The functions or methods will
+ * then be run when the action or filter is called.
+ *
+ * The API callback examples reference functions, but can be methods of classes.
+ * To hook methods, you'll need to pass an array one of two ways.
+ *
+ * Any of the syntaxes explained in the PHP documentation for the
+ * {@link http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'}
+ * type are valid.
+ *
+ * Also see the {@link http://codex.wordpress.org/Plugin_API Plugin API} for
+ * more information and examples on how to use a lot of these functions.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 1.5
+ */
+
+/**
+ * Hooks a function or method to a specific filter action.
+ *
+ * Filters are the hooks that WordPress launches to modify text of various types
+ * before adding it to the database or sending it to the browser screen. Plugins
+ * can specify that one or more of its PHP functions is executed to
+ * modify specific types of text at these times, using the Filter API.
+ *
+ * To use the API, the following code should be used to bind a callback to the
+ * filter.
+ *
+ * <code>
+ * function example_hook($example) { echo $example; }
+ * add_filter('example_filter', 'example_hook');
+ * </code>
+ *
+ * In WordPress 1.5.1+, hooked functions can take extra arguments that are set
+ * when the matching do_action() or apply_filters() call is run. The
+ * $accepted_args allow for calling functions only when the number of args
+ * match. Hooked functions can take extra arguments that are set when the
+ * matching do_action() or apply_filters() call is run. For example, the action
+ * comment_id_not_found will pass any functions that hook onto it the ID of the
+ * requested comment.
+ *
+ * <strong>Note:</strong> the function will return true no matter if the
+ * function was hooked fails or not. There are no checks for whether the
+ * function exists beforehand and no checks to whether the <tt>$function_to_add
+ * is even a string. It is up to you to take care and this is done for
+ * optimization purposes, so everything is as quick as possible.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 0.71
+ * @global array $wp_filter Stores all of the filters added in the form of
+ *	wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)']']
+ * @global array $merged_filters Tracks the tags that need to be merged for later. If the hook is added, it doesn't need to run through that process.
+ *
+ * @param string $tag The name of the filter to hook the $function_to_add to.
+ * @param callback $function_to_add The name of the function to be called when the filter is applied.
+ * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
+ * @param int $accepted_args optional. The number of arguments the function accept (default 1).
+ * @return boolean true
+ */
+function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
+	global $wp_filter, $merged_filters;
+
+	$idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
+	$wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
+	unset( $merged_filters[ $tag ] );
+	return true;
+}
+
+/**
+ * Check if any filter has been registered for a hook.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.5
+ * @global array $wp_filter Stores all of the filters
+ *
+ * @param string $tag The name of the filter hook.
+ * @param callback $function_to_check optional.  If specified, return the priority of that function on this hook or false if not attached.
+ * @return int|boolean Optionally returns the priority on that hook for the specified function.
+ */
+function has_filter($tag, $function_to_check = false) {
+	global $wp_filter;
+
+	$has = !empty($wp_filter[$tag]);
+	if ( false === $function_to_check || false == $has )
+		return $has;
+
+	if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) )
+		return false;
+
+	foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) {
+		if ( isset($wp_filter[$tag][$priority][$idx]) )
+			return $priority;
+	}
+
+	return false;
+}
+
+/**
+ * Call the functions added to a filter hook.
+ *
+ * The callback functions attached to filter hook $tag are invoked by calling
+ * this function. This function can be used to create a new filter hook by
+ * simply calling this function with the name of the new hook specified using
+ * the $tag parameter.
+ *
+ * The function allows for additional arguments to be added and passed to hooks.
+ * <code>
+ * function example_hook($string, $arg1, $arg2)
+ * {
+ *		//Do stuff
+ *		return $string;
+ * }
+ * $value = apply_filters('example_filter', 'filter me', 'arg1', 'arg2');
+ * </code>
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 0.71
+ * @global array $wp_filter Stores all of the filters
+ * @global array $merged_filters Merges the filter hooks using this function.
+ * @global array $wp_current_filter stores the list of current filters with the current one last
+ *
+ * @param string $tag The name of the filter hook.
+ * @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on.
+ * @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>.
+ * @return mixed The filtered value after all hooked functions are applied to it.
+ */
+function apply_filters($tag, $value) {
+	global $wp_filter, $merged_filters, $wp_current_filter;
+
+	$args = array();
+	$wp_current_filter[] = $tag;
+
+	// Do 'all' actions first
+	if ( isset($wp_filter['all']) ) {
+		$args = func_get_args();
+		_wp_call_all_hook($args);
+	}
+
+	if ( !isset($wp_filter[$tag]) ) {
+		array_pop($wp_current_filter);
+		return $value;
+	}
+
+	// Sort
+	if ( !isset( $merged_filters[ $tag ] ) ) {
+		ksort($wp_filter[$tag]);
+		$merged_filters[ $tag ] = true;
+	}
+
+	reset( $wp_filter[ $tag ] );
+
+	if ( empty($args) )
+		$args = func_get_args();
+
+	do {
+		foreach( (array) current($wp_filter[$tag]) as $the_ )
+			if ( !is_null($the_['function']) ){
+				$args[1] = $value;
+				$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
+			}
+
+	} while ( next($wp_filter[$tag]) !== false );
+
+	array_pop( $wp_current_filter );
+
+	return $value;
+}
+
+/**
+ * Execute functions hooked on a specific filter hook, specifying arguments in an array.
+ *
+ * @see apply_filters() This function is identical, but the arguments passed to the
+ * functions hooked to <tt>$tag</tt> are supplied using an array.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 3.0.0
+ * @global array $wp_filter Stores all of the filters
+ * @global array $merged_filters Merges the filter hooks using this function.
+ * @global array $wp_current_filter stores the list of current filters with the current one last
+ *
+ * @param string $tag The name of the filter hook.
+ * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
+ * @return mixed The filtered value after all hooked functions are applied to it.
+ */
+function apply_filters_ref_array($tag, $args) {
+	global $wp_filter, $merged_filters, $wp_current_filter;
+
+	$wp_current_filter[] = $tag;
+
+	// Do 'all' actions first
+	if ( isset($wp_filter['all']) ) {
+		$all_args = func_get_args();
+		_wp_call_all_hook($all_args);
+	}
+
+	if ( !isset($wp_filter[$tag]) ) {
+		array_pop($wp_current_filter);
+		return $args[0];
+	}
+
+	// Sort
+	if ( !isset( $merged_filters[ $tag ] ) ) {
+		ksort($wp_filter[$tag]);
+		$merged_filters[ $tag ] = true;
+	}
+
+	reset( $wp_filter[ $tag ] );
+
+	do {
+		foreach( (array) current($wp_filter[$tag]) as $the_ )
+			if ( !is_null($the_['function']) )
+				$args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
+
+	} while ( next($wp_filter[$tag]) !== false );
+
+	array_pop( $wp_current_filter );
+
+	return $args[0];
+}
+
+/**
+ * Removes a function from a specified filter hook.
+ *
+ * This function removes a function attached to a specified filter hook. This
+ * method can be used to remove default functions attached to a specific filter
+ * hook and possibly replace them with a substitute.
+ *
+ * To remove a hook, the $function_to_remove and $priority arguments must match
+ * when the hook was added. This goes for both filters and actions. No warning
+ * will be given on removal failure.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 1.2
+ *
+ * @param string $tag The filter hook to which the function to be removed is hooked.
+ * @param callback $function_to_remove The name of the function which should be removed.
+ * @param int $priority optional. The priority of the function (default: 10).
+ * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
+ * @return boolean Whether the function existed before it was removed.
+ */
+function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+	$function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority);
+
+	$r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
+
+	if ( true === $r) {
+		unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
+		if ( empty($GLOBALS['wp_filter'][$tag][$priority]) )
+			unset($GLOBALS['wp_filter'][$tag][$priority]);
+		unset($GLOBALS['merged_filters'][$tag]);
+	}
+
+	return $r;
+}
+
+/**
+ * Remove all of the hooks from a filter.
+ *
+ * @since 2.7
+ *
+ * @param string $tag The filter to remove hooks from.
+ * @param int $priority The priority number to remove.
+ * @return bool True when finished.
+ */
+function remove_all_filters($tag, $priority = false) {
+	global $wp_filter, $merged_filters;
+
+	if( isset($wp_filter[$tag]) ) {
+		if( false !== $priority && isset($wp_filter[$tag][$priority]) )
+			unset($wp_filter[$tag][$priority]);
+		else
+			unset($wp_filter[$tag]);
+	}
+
+	if( isset($merged_filters[$tag]) )
+		unset($merged_filters[$tag]);
+
+	return true;
+}
+
+/**
+ * Retrieve the name of the current filter or action.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.5
+ *
+ * @return string Hook name of the current filter or action.
+ */
+function current_filter() {
+	global $wp_current_filter;
+	return end( $wp_current_filter );
+}
+
+
+/**
+ * Hooks a function on to a specific action.
+ *
+ * Actions are the hooks that the WordPress core launches at specific points
+ * during execution, or when specific events occur. Plugins can specify that
+ * one or more of its PHP functions are executed at these points, using the
+ * Action API.
+ *
+ * @uses add_filter() Adds an action. Parameter list and functionality are the same.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 1.2
+ *
+ * @param string $tag The name of the action to which the $function_to_add is hooked.
+ * @param callback $function_to_add The name of the function you wish to be called.
+ * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
+ * @param int $accepted_args optional. The number of arguments the function accept (default 1).
+ */
+function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
+	return add_filter($tag, $function_to_add, $priority, $accepted_args);
+}
+
+
+/**
+ * Execute functions hooked on a specific action hook.
+ *
+ * This function invokes all functions attached to action hook $tag. It is
+ * possible to create new action hooks by simply calling this function,
+ * specifying the name of the new hook using the <tt>$tag</tt> parameter.
+ *
+ * You can pass extra arguments to the hooks, much like you can with
+ * apply_filters().
+ *
+ * @see apply_filters() This function works similar with the exception that
+ * nothing is returned and only the functions or methods are called.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 1.2
+ * @global array $wp_filter Stores all of the filters
+ * @global array $wp_actions Increments the amount of times action was triggered.
+ *
+ * @param string $tag The name of the action to be executed.
+ * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
+ * @return null Will return null if $tag does not exist in $wp_filter array
+ */
+function do_action($tag, $arg = '') {
+	global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
+
+	if ( ! isset($wp_actions) )
+		$wp_actions = array();
+
+	if ( ! isset($wp_actions[$tag]) )
+		$wp_actions[$tag] = 1;
+	else
+		++$wp_actions[$tag];
+
+	$wp_current_filter[] = $tag;
+
+	// Do 'all' actions first
+	if ( isset($wp_filter['all']) ) {
+		$all_args = func_get_args();
+		_wp_call_all_hook($all_args);
+	}
+
+	if ( !isset($wp_filter[$tag]) ) {
+		array_pop($wp_current_filter);
+		return;
+	}
+
+	$args = array();
+	if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
+		$args[] =& $arg[0];
+	else
+		$args[] = $arg;
+	for ( $a = 2; $a < func_num_args(); $a++ )
+		$args[] = func_get_arg($a);
+
+	// Sort
+	if ( !isset( $merged_filters[ $tag ] ) ) {
+		ksort($wp_filter[$tag]);
+		$merged_filters[ $tag ] = true;
+	}
+
+	reset( $wp_filter[ $tag ] );
+
+	do {
+		foreach ( (array) current($wp_filter[$tag]) as $the_ )
+			if ( !is_null($the_['function']) )
+				call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
+
+	} while ( next($wp_filter[$tag]) !== false );
+
+	array_pop($wp_current_filter);
+}
+
+/**
+ * Retrieve the number times an action is fired.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.1
+ * @global array $wp_actions Increments the amount of times action was triggered.
+ *
+ * @param string $tag The name of the action hook.
+ * @return int The number of times action hook <tt>$tag</tt> is fired
+ */
+function did_action($tag) {
+	global $wp_actions;
+
+	if ( ! isset( $wp_actions ) || ! isset( $wp_actions[$tag] ) )
+		return 0;
+
+	return $wp_actions[$tag];
+}
+
+/**
+ * Execute functions hooked on a specific action hook, specifying arguments in an array.
+ *
+ * @see do_action() This function is identical, but the arguments passed to the
+ * functions hooked to <tt>$tag</tt> are supplied using an array.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.1
+ * @global array $wp_filter Stores all of the filters
+ * @global array $wp_actions Increments the amount of times action was triggered.
+ *
+ * @param string $tag The name of the action to be executed.
+ * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
+ * @return null Will return null if $tag does not exist in $wp_filter array
+ */
+function do_action_ref_array($tag, $args) {
+	global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
+
+	if ( ! isset($wp_actions) )
+		$wp_actions = array();
+
+	if ( ! isset($wp_actions[$tag]) )
+		$wp_actions[$tag] = 1;
+	else
+		++$wp_actions[$tag];
+
+	$wp_current_filter[] = $tag;
+
+	// Do 'all' actions first
+	if ( isset($wp_filter['all']) ) {
+		$all_args = func_get_args();
+		_wp_call_all_hook($all_args);
+	}
+
+	if ( !isset($wp_filter[$tag]) ) {
+		array_pop($wp_current_filter);
+		return;
+	}
+
+	// Sort
+	if ( !isset( $merged_filters[ $tag ] ) ) {
+		ksort($wp_filter[$tag]);
+		$merged_filters[ $tag ] = true;
+	}
+
+	reset( $wp_filter[ $tag ] );
+
+	do {
+		foreach( (array) current($wp_filter[$tag]) as $the_ )
+			if ( !is_null($the_['function']) )
+				call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
+
+	} while ( next($wp_filter[$tag]) !== false );
+
+	array_pop($wp_current_filter);
+}
+
+/**
+ * Check if any action has been registered for a hook.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.5
+ * @see has_filter() has_action() is an alias of has_filter().
+ *
+ * @param string $tag The name of the action hook.
+ * @param callback $function_to_check optional.  If specified, return the priority of that function on this hook or false if not attached.
+ * @return int|boolean Optionally returns the priority on that hook for the specified function.
+ */
+function has_action($tag, $function_to_check = false) {
+	return has_filter($tag, $function_to_check);
+}
+
+/**
+ * Removes a function from a specified action hook.
+ *
+ * This function removes a function attached to a specified action hook. This
+ * method can be used to remove default functions attached to a specific filter
+ * hook and possibly replace them with a substitute.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 1.2
+ *
+ * @param string $tag The action hook to which the function to be removed is hooked.
+ * @param callback $function_to_remove The name of the function which should be removed.
+ * @param int $priority optional The priority of the function (default: 10).
+ * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
+ * @return boolean Whether the function is removed.
+ */
+function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
+	return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
+}
+
+/**
+ * Remove all of the hooks from an action.
+ *
+ * @since 2.7
+ *
+ * @param string $tag The action to remove hooks from.
+ * @param int $priority The priority number to remove them from.
+ * @return bool True when finished.
+ */
+function remove_all_actions($tag, $priority = false) {
+	return remove_all_filters($tag, $priority);
+}
+
+//
+// Functions for handling plugins.
+//
+
+/**
+ * Gets the basename of a plugin.
+ *
+ * This method extracts the name of a plugin from its filename.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 1.5
+ *
+ * @access private
+ *
+ * @param string $file The filename of plugin.
+ * @return string The name of a plugin.
+ * @uses WP_PLUGIN_DIR
+ */
+function plugin_basename($file) {
+	$file = str_replace('\\','/',$file); // sanitize for Win32 installs
+	$file = preg_replace('|/+|','/', $file); // remove any duplicate slash
+	$plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
+	$plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
+	$mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
+	$mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
+	$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
+	$file = trim($file, '/');
+	return $file;
+}
+
+/**
+ * Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.8
+ *
+ * @param string $file The filename of the plugin (__FILE__)
+ * @return string the filesystem path of the directory that contains the plugin
+ */
+function plugin_dir_path( $file ) {
+	return trailingslashit( dirname( $file ) );
+}
+
+/**
+ * Gets the URL directory path (with trailing slash) for the plugin __FILE__ passed in
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.8
+ *
+ * @param string $file The filename of the plugin (__FILE__)
+ * @return string the URL path of the directory that contains the plugin
+ */
+function plugin_dir_url( $file ) {
+	return trailingslashit( plugins_url( '', $file ) );
+}
+
+/**
+ * Set the activation hook for a plugin.
+ *
+ * When a plugin is activated, the action 'activate_PLUGINNAME' hook is
+ * activated. In the name of this hook, PLUGINNAME is replaced with the name of
+ * the plugin, including the optional subdirectory. For example, when the plugin
+ * is located in wp-content/plugin/sampleplugin/sample.php, then the name of
+ * this hook will become 'activate_sampleplugin/sample.php'. When the plugin
+ * consists of only one file and is (as by default) located at
+ * wp-content/plugin/sample.php the name of this hook will be
+ * 'activate_sample.php'.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.0
+ *
+ * @param string $file The filename of the plugin including the path.
+ * @param callback $function the function hooked to the 'activate_PLUGIN' action.
+ */
+function register_activation_hook($file, $function) {
+	$file = plugin_basename($file);
+	add_action('activate_' . $file, $function);
+}
+
+/**
+ * Set the deactivation hook for a plugin.
+ *
+ * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is
+ * deactivated. In the name of this hook, PLUGINNAME is replaced with the name
+ * of the plugin, including the optional subdirectory. For example, when the
+ * plugin is located in wp-content/plugin/sampleplugin/sample.php, then
+ * the name of this hook will become 'activate_sampleplugin/sample.php'.
+ *
+ * When the plugin consists of only one file and is (as by default) located at
+ * wp-content/plugin/sample.php the name of this hook will be
+ * 'activate_sample.php'.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.0
+ *
+ * @param string $file The filename of the plugin including the path.
+ * @param callback $function the function hooked to the 'activate_PLUGIN' action.
+ */
+function register_deactivation_hook($file, $function) {
+	$file = plugin_basename($file);
+	add_action('deactivate_' . $file, $function);
+}
+
+/**
+ * Set the uninstallation hook for a plugin.
+ *
+ * Registers the uninstall hook that will be called when the user clicks on the
+ * uninstall link that calls for the plugin to uninstall itself. The link won't
+ * be active unless the plugin hooks into the action.
+ *
+ * The plugin should not run arbitrary code outside of functions, when
+ * registering the uninstall hook. In order to run using the hook, the plugin
+ * will have to be included, which means that any code laying outside of a
+ * function will be run during the uninstall process. The plugin should not
+ * hinder the uninstall process.
+ *
+ * If the plugin can not be written without running code within the plugin, then
+ * the plugin should create a file named 'uninstall.php' in the base plugin
+ * folder. This file will be called, if it exists, during the uninstall process
+ * bypassing the uninstall hook. The plugin, when using the 'uninstall.php'
+ * should always check for the 'WP_UNINSTALL_PLUGIN' constant, before
+ * executing.
+ *
+ * @since 2.7
+ *
+ * @param string $file
+ * @param callback $callback The callback to run when the hook is called. Must be a static method or function.
+ */
+function register_uninstall_hook( $file, $callback ) {
+	if ( is_array( $callback ) && is_object( $callback[0] ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Only a static class method or function can be used in an uninstall hook.' ), '3.1' );
+		return;
+	}
+
+	// The option should not be autoloaded, because it is not needed in most
+	// cases. Emphasis should be put on using the 'uninstall.php' way of
+	// uninstalling the plugin.
+	$uninstallable_plugins = (array) get_option('uninstall_plugins');
+	$uninstallable_plugins[plugin_basename($file)] = $callback;
+	update_option('uninstall_plugins', $uninstallable_plugins);
+}
+
+/**
+ * Calls the 'all' hook, which will process the functions hooked into it.
+ *
+ * The 'all' hook passes all of the arguments or parameters that were used for
+ * the hook, which this function was called for.
+ *
+ * This function is used internally for apply_filters(), do_action(), and
+ * do_action_ref_array() and is not meant to be used from outside those
+ * functions. This function does not check for the existence of the all hook, so
+ * it will fail unless the all hook exists prior to this function call.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @since 2.5
+ * @access private
+ *
+ * @uses $wp_filter Used to process all of the functions in the 'all' hook
+ *
+ * @param array $args The collected parameters from the hook that was called.
+ * @param string $hook Optional. The hook name that was used to call the 'all' hook.
+ */
+function _wp_call_all_hook($args) {
+	global $wp_filter;
+
+	reset( $wp_filter['all'] );
+	do {
+		foreach( (array) current($wp_filter['all']) as $the_ )
+			if ( !is_null($the_['function']) )
+				call_user_func_array($the_['function'], $args);
+
+	} while ( next($wp_filter['all']) !== false );
+}
+
+/**
+ * Build Unique ID for storage and retrieval.
+ *
+ * The old way to serialize the callback caused issues and this function is the
+ * solution. It works by checking for objects and creating an a new property in
+ * the class to keep track of the object and new objects of the same class that
+ * need to be added.
+ *
+ * It also allows for the removal of actions and filters for objects after they
+ * change class properties. It is possible to include the property $wp_filter_id
+ * in your class and set it to "null" or a number to bypass the workaround.
+ * However this will prevent you from adding new classes and any new classes
+ * will overwrite the previous hook by the same class.
+ *
+ * Functions and static method callbacks are just returned as strings and
+ * shouldn't have any speed penalty.
+ *
+ * @package WordPress
+ * @subpackage Plugin
+ * @access private
+ * @since 2.2.3
+ * @link http://trac.wordpress.org/ticket/3875
+ *
+ * @global array $wp_filter Storage for all of the filters and actions
+ * @param string $tag Used in counting how many hooks were applied
+ * @param callback $function Used for creating unique id
+ * @param int|bool $priority Used in counting how many hooks were applied.  If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise.
+ * @return string|bool Unique ID for usage as array key or false if $priority === false and $function is an object reference, and it does not already have a uniqe id.
+ */
+function _wp_filter_build_unique_id($tag, $function, $priority) {
+	global $wp_filter;
+	static $filter_id_count = 0;
+
+	if ( is_string($function) )
+		return $function;
+
+	if ( is_object($function) ) {
+		// Closures are currently implemented as objects
+		$function = array( $function, '' );
+	} else {
+		$function = (array) $function;
+	}
+
+	if (is_object($function[0]) ) {
+		// Object Class Calling
+		if ( function_exists('spl_object_hash') ) {
+			return spl_object_hash($function[0]) . $function[1];
+		} else {
+			$obj_idx = get_class($function[0]).$function[1];
+			if ( !isset($function[0]->wp_filter_id) ) {
+				if ( false === $priority )
+					return false;
+				$obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : $filter_id_count;
+				$function[0]->wp_filter_id = $filter_id_count;
+				++$filter_id_count;
+			} else {
+				$obj_idx .= $function[0]->wp_filter_id;
+			}
+
+			return $obj_idx;
+		}
+	} else if ( is_string($function[0]) ) {
+		// Static Calling
+		return $function[0].$function[1];
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/pomo/entry.php
===================================================================
--- /tags/3.1/wp-includes/pomo/entry.php	(revision 17487)
+++ /tags/3.1/wp-includes/pomo/entry.php	(revision 17487)
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Contains Translation_Entry class
+ *
+ * @version $Id: entry.php 406 2010-02-07 11:10:24Z nbachiyski $
+ * @package pomo
+ * @subpackage entry
+ */
+
+if ( !class_exists( 'Translation_Entry' ) ):
+/**
+ * Translation_Entry class encapsulates a translatable string
+ */
+class Translation_Entry {
+
+	/**
+	 * Whether the entry contains a string and its plural form, default is false
+	 *
+	 * @var boolean
+	 */
+	var $is_plural = false;
+
+	var $context = null;
+	var $singular = null;
+	var $plural = null;
+	var $translations = array();
+	var $translator_comments = '';
+	var $extracted_comments = '';
+	var $references = array();
+	var $flags = array();
+
+	/**
+	 * @param array $args associative array, support following keys:
+	 * 	- singular (string) -- the string to translate, if omitted and empty entry will be created
+	 * 	- plural (string) -- the plural form of the string, setting this will set {@link $is_plural} to true
+	 * 	- translations (array) -- translations of the string and possibly -- its plural forms
+	 * 	- context (string) -- a string differentiating two equal strings used in different contexts
+	 * 	- translator_comments (string) -- comments left by translators
+	 * 	- extracted_comments (string) -- comments left by developers
+	 * 	- references (array) -- places in the code this strings is used, in relative_to_root_path/file.php:linenum form
+	 * 	- flags (array) -- flags like php-format
+	 */
+	function Translation_Entry($args=array()) {
+		// if no singular -- empty object
+		if (!isset($args['singular'])) {
+			return;
+		}
+		// get member variable values from args hash
+		foreach ($args as $varname => $value) {
+			$this->$varname = $value;
+		}
+		if (isset($args['plural'])) $this->is_plural = true;
+		if (!is_array($this->translations)) $this->translations = array();
+		if (!is_array($this->references)) $this->references = array();
+		if (!is_array($this->flags)) $this->flags = array();
+	}
+
+	/**
+	 * Generates a unique key for this entry
+	 *
+	 * @return string|bool the key or false if the entry is empty
+	 */
+	function key() {
+		if (is_null($this->singular)) return false;
+		// prepend context and EOT, like in MO files
+		return is_null($this->context)? $this->singular : $this->context.chr(4).$this->singular;
+	}
+}
+endif;
Index: /tags/3.1/wp-includes/pomo/mo.php
===================================================================
--- /tags/3.1/wp-includes/pomo/mo.php	(revision 17487)
+++ /tags/3.1/wp-includes/pomo/mo.php	(revision 17487)
@@ -0,0 +1,231 @@
+<?php
+/**
+ * Class for working with MO files
+ *
+ * @version $Id: mo.php 406 2010-02-07 11:10:24Z nbachiyski $
+ * @package pomo
+ * @subpackage mo
+ */
+
+require_once dirname(__FILE__) . '/translations.php';
+require_once dirname(__FILE__) . '/streams.php';
+
+if ( !class_exists( 'MO' ) ):
+class MO extends Gettext_Translations {
+
+	var $_nplurals = 2;
+
+	/**
+	 * Fills up with the entries from MO file $filename
+	 *
+	 * @param string $filename MO file to load
+	 */
+	function import_from_file($filename) {
+		$reader = new POMO_FileReader($filename);
+		if (!$reader->is_resource())
+			return false;
+		return $this->import_from_reader($reader);
+	}
+
+	function export_to_file($filename) {
+		$fh = fopen($filename, 'wb');
+		if ( !$fh ) return false;
+		$entries = array_filter($this->entries, create_function('$e', 'return !empty($e->translations);'));
+		ksort($entries);
+		$magic = 0x950412de;
+		$revision = 0;
+		$total = count($entries) + 1; // all the headers are one entry
+		$originals_lenghts_addr = 28;
+		$translations_lenghts_addr = $originals_lenghts_addr + 8 * $total;
+		$size_of_hash = 0;
+		$hash_addr = $translations_lenghts_addr + 8 * $total;
+		$current_addr = $hash_addr;
+		fwrite($fh, pack('V*', $magic, $revision, $total, $originals_lenghts_addr,
+			$translations_lenghts_addr, $size_of_hash, $hash_addr));
+		fseek($fh, $originals_lenghts_addr);
+
+		// headers' msgid is an empty string
+		fwrite($fh, pack('VV', 0, $current_addr));
+		$current_addr++;
+		$originals_table = chr(0);
+
+		foreach($entries as $entry) {
+			$originals_table .= $this->export_original($entry) . chr(0);
+			$length = strlen($this->export_original($entry));
+			fwrite($fh, pack('VV', $length, $current_addr));
+			$current_addr += $length + 1; // account for the NULL byte after
+		}
+
+		$exported_headers = $this->export_headers();
+		fwrite($fh, pack('VV', strlen($exported_headers), $current_addr));
+		$current_addr += strlen($exported_headers) + 1;
+		$translations_table = $exported_headers . chr(0);
+
+		foreach($entries as $entry) {
+			$translations_table .= $this->export_translations($entry) . chr(0);
+			$length = strlen($this->export_translations($entry));
+			fwrite($fh, pack('VV', $length, $current_addr));
+			$current_addr += $length + 1;
+		}
+
+		fwrite($fh, $originals_table);
+		fwrite($fh, $translations_table);
+		fclose($fh);
+	}
+
+	function export_original($entry) {
+		//TODO: warnings for control characters
+		$exported = $entry->singular;
+		if ($entry->is_plural) $exported .= chr(0).$entry->plural;
+		if (!is_null($entry->context)) $exported = $entry->context . chr(4) . $exported;
+		return $exported;
+	}
+
+	function export_translations($entry) {
+		//TODO: warnings for control characters
+		return implode(chr(0), $entry->translations);
+	}
+
+	function export_headers() {
+		$exported = '';
+		foreach($this->headers as $header => $value) {
+			$exported.= "$header: $value\n";
+		}
+		return $exported;
+	}
+
+	function get_byteorder($magic) {
+		// The magic is 0x950412de
+
+		// bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
+		$magic_little = (int) - 1794895138;
+		$magic_little_64 = (int) 2500072158;
+		// 0xde120495
+		$magic_big = ((int) - 569244523) & 0xFFFFFFFF;
+		if ($magic_little == $magic || $magic_little_64 == $magic) {
+			return 'little';
+		} else if ($magic_big == $magic) {
+			return 'big';
+		} else {
+			return false;
+		}
+	}
+
+	function import_from_reader($reader) {
+		$endian_string = MO::get_byteorder($reader->readint32());
+		if (false === $endian_string) {
+			return false;
+		}
+		$reader->setEndian($endian_string);
+
+		$endian = ('big' == $endian_string)? 'N' : 'V';
+
+		$header = $reader->read(24);
+		if ($reader->strlen($header) != 24)
+			return false;
+
+		// parse header
+		$header = unpack("{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header);
+		if (!is_array($header))
+			return false;
+
+		extract( $header );
+
+		// support revision 0 of MO format specs, only
+		if ($revision != 0)
+			return false;
+
+		// seek to data blocks
+		$reader->seekto($originals_lenghts_addr);
+
+		// read originals' indices
+		$originals_lengths_length = $translations_lenghts_addr - $originals_lenghts_addr;
+		if ( $originals_lengths_length != $total * 8 )
+			return false;
+
+		$originals = $reader->read($originals_lengths_length);
+		if ( $reader->strlen( $originals ) != $originals_lengths_length )
+			return false;
+
+		// read translations' indices
+		$translations_lenghts_length = $hash_addr - $translations_lenghts_addr;
+		if ( $translations_lenghts_length != $total * 8 )
+			return false;
+
+		$translations = $reader->read($translations_lenghts_length);
+		if ( $reader->strlen( $translations ) != $translations_lenghts_length )
+			return false;
+
+		// transform raw data into set of indices
+		$originals    = $reader->str_split( $originals, 8 );
+		$translations = $reader->str_split( $translations, 8 );
+
+		// skip hash table
+		$strings_addr = $hash_addr + $hash_length * 4;
+
+		$reader->seekto($strings_addr);
+
+		$strings = $reader->read_all();
+		$reader->close();
+
+		for ( $i = 0; $i < $total; $i++ ) {
+			$o = unpack( "{$endian}length/{$endian}pos", $originals[$i] );
+			$t = unpack( "{$endian}length/{$endian}pos", $translations[$i] );
+			if ( !$o || !$t ) return false;
+
+			// adjust offset due to reading strings to separate space before
+			$o['pos'] -= $strings_addr;
+			$t['pos'] -= $strings_addr;
+
+			$original    = $reader->substr( $strings, $o['pos'], $o['length'] );
+			$translation = $reader->substr( $strings, $t['pos'], $t['length'] );
+
+			if ('' === $original) {
+				$this->set_headers($this->make_headers($translation));
+			} else {
+				$entry = &$this->make_entry($original, $translation);
+				$this->entries[$entry->key()] = &$entry;
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Build a Translation_Entry from original string and translation strings,
+	 * found in a MO file
+	 *
+	 * @static
+	 * @param string $original original string to translate from MO file. Might contain
+	 * 	0x04 as context separator or 0x00 as singular/plural separator
+	 * @param string $translation translation string from MO file. Might contain
+	 * 	0x00 as a plural translations separator
+	 */
+	function &make_entry($original, $translation) {
+		$entry = new Translation_Entry();
+		// look for context
+		$parts = explode(chr(4), $original);
+		if (isset($parts[1])) {
+			$original = $parts[1];
+			$entry->context = $parts[0];
+		}
+		// look for plural original
+		$parts = explode(chr(0), $original);
+		$entry->singular = $parts[0];
+		if (isset($parts[1])) {
+			$entry->is_plural = true;
+			$entry->plural = $parts[1];
+		}
+		// plural translations are also separated by \0
+		$entry->translations = explode(chr(0), $translation);
+		return $entry;
+	}
+
+	function select_plural_form($count) {
+		return $this->gettext_select_plural_form($count);
+	}
+
+	function get_plural_forms_count() {
+		return $this->_nplurals;
+	}
+}
+endif;
Index: /tags/3.1/wp-includes/pomo/po.php
===================================================================
--- /tags/3.1/wp-includes/pomo/po.php	(revision 17487)
+++ /tags/3.1/wp-includes/pomo/po.php	(revision 17487)
@@ -0,0 +1,363 @@
+<?php
+/**
+ * Class for working with PO files
+ *
+ * @version $Id: po.php 406 2010-02-07 11:10:24Z nbachiyski $
+ * @package pomo
+ * @subpackage po
+ */
+
+require_once dirname(__FILE__) . '/translations.php';
+
+define('PO_MAX_LINE_LEN', 79);
+
+ini_set('auto_detect_line_endings', 1);
+
+/**
+ * Routines for working with PO files
+ */
+if ( !class_exists( 'PO' ) ):
+class PO extends Gettext_Translations {
+
+
+	/**
+	 * Exports headers to a PO entry
+	 *
+	 * @return string msgid/msgstr PO entry for this PO file headers, doesn't contain newline at the end
+	 */
+	function export_headers() {
+		$header_string = '';
+		foreach($this->headers as $header => $value) {
+			$header_string.= "$header: $value\n";
+		}
+		$poified = PO::poify($header_string);
+		return rtrim("msgid \"\"\nmsgstr $poified");
+	}
+
+	/**
+	 * Exports all entries to PO format
+	 *
+	 * @return string sequence of mgsgid/msgstr PO strings, doesn't containt newline at the end
+	 */
+	function export_entries() {
+		//TODO sorting
+		return implode("\n\n", array_map(array('PO', 'export_entry'), $this->entries));
+	}
+
+	/**
+	 * Exports the whole PO file as a string
+	 *
+	 * @param bool $include_headers whether to include the headers in the export
+	 * @return string ready for inclusion in PO file string for headers and all the enrtries
+	 */
+	function export($include_headers = true) {
+		$res = '';
+		if ($include_headers) {
+			$res .= $this->export_headers();
+			$res .= "\n\n";
+		}
+		$res .= $this->export_entries();
+		return $res;
+	}
+
+	/**
+	 * Same as {@link export}, but writes the result to a file
+	 *
+	 * @param string $filename where to write the PO string
+	 * @param bool $include_headers whether to include tje headers in the export
+	 * @return bool true on success, false on error
+	 */
+	function export_to_file($filename, $include_headers = true) {
+		$fh = fopen($filename, 'w');
+		if (false === $fh) return false;
+		$export = $this->export($include_headers);
+		$res = fwrite($fh, $export);
+		if (false === $res) return false;
+		return fclose($fh);
+	}
+
+	/**
+	 * Formats a string in PO-style
+	 *
+	 * @static
+	 * @param string $string the string to format
+	 * @return string the poified string
+	 */
+	function poify($string) {
+		$quote = '"';
+		$slash = '\\';
+		$newline = "\n";
+
+		$replaces = array(
+			"$slash" 	=> "$slash$slash",
+			"$quote"	=> "$slash$quote",
+			"\t" 		=> '\t',
+		);
+
+		$string = str_replace(array_keys($replaces), array_values($replaces), $string);
+
+		$po = $quote.implode("${slash}n$quote$newline$quote", explode($newline, $string)).$quote;
+		// add empty string on first line for readbility
+		if (false !== strpos($string, $newline) &&
+				(substr_count($string, $newline) > 1 || !($newline === substr($string, -strlen($newline))))) {
+			$po = "$quote$quote$newline$po";
+		}
+		// remove empty strings
+		$po = str_replace("$newline$quote$quote", '', $po);
+		return $po;
+	}
+
+	/**
+	 * Gives back the original string from a PO-formatted string
+	 *
+	 * @static
+	 * @param string $string PO-formatted string
+	 * @return string enascaped string
+	 */
+	function unpoify($string) {
+		$escapes = array('t' => "\t", 'n' => "\n", '\\' => '\\');
+		$lines = array_map('trim', explode("\n", $string));
+		$lines = array_map(array('PO', 'trim_quotes'), $lines);
+		$unpoified = '';
+		$previous_is_backslash = false;
+		foreach($lines as $line) {
+			preg_match_all('/./u', $line, $chars);
+			$chars = $chars[0];
+			foreach($chars as $char) {
+				if (!$previous_is_backslash) {
+					if ('\\' == $char)
+						$previous_is_backslash = true;
+					else
+						$unpoified .= $char;
+				} else {
+					$previous_is_backslash = false;
+					$unpoified .= isset($escapes[$char])? $escapes[$char] : $char;
+				}
+			}
+		}
+		return $unpoified;
+	}
+
+	/**
+	 * Inserts $with in the beginning of every new line of $string and
+	 * returns the modified string
+	 *
+	 * @static
+	 * @param string $string prepend lines in this string
+	 * @param string $with prepend lines with this string
+	 */
+	function prepend_each_line($string, $with) {
+		$php_with = var_export($with, true);
+		$lines = explode("\n", $string);
+		// do not prepend the string on the last empty line, artefact by explode
+		if ("\n" == substr($string, -1)) unset($lines[count($lines) - 1]);
+		$res = implode("\n", array_map(create_function('$x', "return $php_with.\$x;"), $lines));
+		// give back the empty line, we ignored above
+		if ("\n" == substr($string, -1)) $res .= "\n";
+		return $res;
+	}
+
+	/**
+	 * Prepare a text as a comment -- wraps the lines and prepends #
+	 * and a special character to each line
+	 *
+	 * @access private
+	 * @param string $text the comment text
+	 * @param string $char character to denote a special PO comment,
+	 * 	like :, default is a space
+	 */
+	function comment_block($text, $char=' ') {
+		$text = wordwrap($text, PO_MAX_LINE_LEN - 3);
+		return PO::prepend_each_line($text, "#$char ");
+	}
+
+	/**
+	 * Builds a string from the entry for inclusion in PO file
+	 *
+	 * @static
+	 * @param object &$entry the entry to convert to po string
+	 * @return string|bool PO-style formatted string for the entry or
+	 * 	false if the entry is empty
+	 */
+	function export_entry(&$entry) {
+		if (is_null($entry->singular)) return false;
+		$po = array();
+		if (!empty($entry->translator_comments)) $po[] = PO::comment_block($entry->translator_comments);
+		if (!empty($entry->extracted_comments)) $po[] = PO::comment_block($entry->extracted_comments, '.');
+		if (!empty($entry->references)) $po[] = PO::comment_block(implode(' ', $entry->references), ':');
+		if (!empty($entry->flags)) $po[] = PO::comment_block(implode(", ", $entry->flags), ',');
+		if (!is_null($entry->context)) $po[] = 'msgctxt '.PO::poify($entry->context);
+		$po[] = 'msgid '.PO::poify($entry->singular);
+		if (!$entry->is_plural) {
+			$translation = empty($entry->translations)? '' : $entry->translations[0];
+			$po[] = 'msgstr '.PO::poify($translation);
+		} else {
+			$po[] = 'msgid_plural '.PO::poify($entry->plural);
+			$translations = empty($entry->translations)? array('', '') : $entry->translations;
+			foreach($translations as $i => $translation) {
+				$po[] = "msgstr[$i] ".PO::poify($translation);
+			}
+		}
+		return implode("\n", $po);
+	}
+
+	function import_from_file($filename) {
+		$f = fopen($filename, 'r');
+		if (!$f) return false;
+		$lineno = 0;
+		while (true) {
+			$res = $this->read_entry($f, $lineno);
+			if (!$res) break;
+			if ($res['entry']->singular == '') {
+				$this->set_headers($this->make_headers($res['entry']->translations[0]));
+			} else {
+				$this->add_entry($res['entry']);
+			}
+		}
+		PO::read_line($f, 'clear');
+		return $res !== false;
+	}
+
+	function read_entry($f, $lineno = 0) {
+		$entry = new Translation_Entry();
+		// where were we in the last step
+		// can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural
+		$context = '';
+		$msgstr_index = 0;
+		$is_final = create_function('$context', 'return $context == "msgstr" || $context == "msgstr_plural";');
+		while (true) {
+			$lineno++;
+			$line = PO::read_line($f);
+			if (!$line)  {
+				if (feof($f)) {
+					if ($is_final($context))
+						break;
+					elseif (!$context) // we haven't read a line and eof came
+						return null;
+					else
+						return false;
+				} else {
+					return false;
+				}
+			}
+			if ($line == "\n") continue;
+			$line = trim($line);
+			if (preg_match('/^#/', $line, $m)) {
+				// the comment is the start of a new entry
+				if ($is_final($context)) {
+					PO::read_line($f, 'put-back');
+					$lineno--;
+					break;
+				}
+				// comments have to be at the beginning
+				if ($context && $context != 'comment') {
+					return false;
+				}
+				// add comment
+				$this->add_comment_to_entry($entry, $line);
+			} elseif (preg_match('/^msgctxt\s+(".*")/', $line, $m)) {
+				if ($is_final($context)) {
+					PO::read_line($f, 'put-back');
+					$lineno--;
+					break;
+				}
+				if ($context && $context != 'comment') {
+					return false;
+				}
+				$context = 'msgctxt';
+				$entry->context .= PO::unpoify($m[1]);
+			} elseif (preg_match('/^msgid\s+(".*")/', $line, $m)) {
+				if ($is_final($context)) {
+					PO::read_line($f, 'put-back');
+					$lineno--;
+					break;
+				}
+				if ($context && $context != 'msgctxt' && $context != 'comment') {
+					return false;
+				}
+				$context = 'msgid';
+				$entry->singular .= PO::unpoify($m[1]);
+			} elseif (preg_match('/^msgid_plural\s+(".*")/', $line, $m)) {
+				if ($context != 'msgid') {
+					return false;
+				}
+				$context = 'msgid_plural';
+				$entry->is_plural = true;
+				$entry->plural .= PO::unpoify($m[1]);
+			} elseif (preg_match('/^msgstr\s+(".*")/', $line, $m)) {
+				if ($context != 'msgid') {
+					return false;
+				}
+				$context = 'msgstr';
+				$entry->translations = array(PO::unpoify($m[1]));
+			} elseif (preg_match('/^msgstr\[(\d+)\]\s+(".*")/', $line, $m)) {
+				if ($context != 'msgid_plural' && $context != 'msgstr_plural') {
+					return false;
+				}
+				$context = 'msgstr_plural';
+				$msgstr_index = $m[1];
+				$entry->translations[$m[1]] = PO::unpoify($m[2]);
+			} elseif (preg_match('/^".*"$/', $line)) {
+				$unpoified = PO::unpoify($line);
+				switch ($context) {
+					case 'msgid':
+						$entry->singular .= $unpoified; break;
+					case 'msgctxt':
+						$entry->context .= $unpoified; break;
+					case 'msgid_plural':
+						$entry->plural .= $unpoified; break;
+					case 'msgstr':
+						$entry->translations[0] .= $unpoified; break;
+					case 'msgstr_plural':
+						$entry->translations[$msgstr_index] .= $unpoified; break;
+					default:
+						return false;
+				}
+			} else {
+				return false;
+			}
+		}
+		if (array() == array_filter($entry->translations, create_function('$t', 'return $t || "0" === $t;'))) {
+			$entry->translations = array();
+		}
+		return array('entry' => $entry, 'lineno' => $lineno);
+	}
+
+	function read_line($f, $action = 'read') {
+		static $last_line = '';
+		static $use_last_line = false;
+		if ('clear' == $action) {
+			$last_line = '';
+			return true;
+		}
+		if ('put-back' == $action) {
+			$use_last_line = true;
+			return true;
+		}
+		$line = $use_last_line? $last_line : fgets($f);
+		$last_line = $line;
+		$use_last_line = false;
+		return $line;
+	}
+
+	function add_comment_to_entry(&$entry, $po_comment_line) {
+		$first_two = substr($po_comment_line, 0, 2);
+		$comment = trim(substr($po_comment_line, 2));
+		if ('#:' == $first_two) {
+			$entry->references = array_merge($entry->references, preg_split('/\s+/', $comment));
+		} elseif ('#.' == $first_two) {
+			$entry->extracted_comments = trim($entry->extracted_comments . "\n" . $comment);
+		} elseif ('#,' == $first_two) {
+			$entry->flags = array_merge($entry->flags, preg_split('/,\s*/', $comment));
+		} else {
+			$entry->translator_comments = trim($entry->translator_comments . "\n" . $comment);
+		}
+	}
+
+	function trim_quotes($s) {
+		if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
+		if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1);
+		return $s;
+	}
+}
+endif;
Index: /tags/3.1/wp-includes/pomo/streams.php
===================================================================
--- /tags/3.1/wp-includes/pomo/streams.php	(revision 17487)
+++ /tags/3.1/wp-includes/pomo/streams.php	(revision 17487)
@@ -0,0 +1,209 @@
+<?php
+/**
+ * Classes, which help reading streams of data from files.
+ * Based on the classes from Danilo Segan <danilo@kvota.net>
+ *
+ * @version $Id: streams.php 406 2010-02-07 11:10:24Z nbachiyski $
+ * @package pomo
+ * @subpackage streams
+ */
+
+if ( !class_exists( 'POMO_Reader' ) ):
+class POMO_Reader {
+
+	var $endian = 'little';
+	var $_post = '';
+
+	function POMO_Reader() {
+		$this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr');
+		$this->_pos = 0;
+	}
+
+	/**
+	 * Sets the endianness of the file.
+	 *
+	 * @param string $endian 'big' or 'little'
+	 */
+	function setEndian($endian) {
+		$this->endian = $endian;
+	}
+
+	/**
+	 * Reads a 32bit Integer from the Stream
+	 *
+	 * @return mixed The integer, corresponding to the next 32 bits from
+	 * 	the stream of false if there are not enough bytes or on error
+	 */
+	function readint32() {
+		$bytes = $this->read(4);
+		if (4 != $this->strlen($bytes))
+			return false;
+		$endian_letter = ('big' == $this->endian)? 'N' : 'V';
+		$int = unpack($endian_letter, $bytes);
+		return array_shift($int);
+	}
+
+	/**
+	 * Reads an array of 32-bit Integers from the Stream
+	 *
+	 * @param integer count How many elements should be read
+	 * @return mixed Array of integers or false if there isn't
+	 * 	enough data or on error
+	 */
+	function readint32array($count) {
+		$bytes = $this->read(4 * $count);
+		if (4*$count != $this->strlen($bytes))
+			return false;
+		$endian_letter = ('big' == $this->endian)? 'N' : 'V';
+		return unpack($endian_letter.$count, $bytes);
+	}
+
+
+	function substr($string, $start, $length) {
+		if ($this->is_overloaded) {
+			return mb_substr($string, $start, $length, 'ascii');
+		} else {
+			return substr($string, $start, $length);
+		}
+	}
+
+	function strlen($string) {
+		if ($this->is_overloaded) {
+			return mb_strlen($string, 'ascii');
+		} else {
+			return strlen($string);
+		}
+	}
+
+	function str_split($string, $chunk_size) {
+		if (!function_exists('str_split')) {
+			$length = $this->strlen($string);
+			$out = array();
+			for ($i = 0; $i < $length; $i += $chunk_size)
+				$out[] = $this->substr($string, $i, $chunk_size);
+			return $out;
+		} else {
+			return str_split( $string, $chunk_size );
+		}
+	}
+
+
+	function pos() {
+		return $this->_pos;
+	}
+
+	function is_resource() {
+		return true;
+	}
+
+	function close() {
+		return true;
+	}
+}
+endif;
+
+if ( !class_exists( 'POMO_FileReader' ) ):
+class POMO_FileReader extends POMO_Reader {
+	function POMO_FileReader($filename) {
+		parent::POMO_Reader();
+		$this->_f = fopen($filename, 'r');
+	}
+
+	function read($bytes) {
+		return fread($this->_f, $bytes);
+	}
+
+	function seekto($pos) {
+		if ( -1 == fseek($this->_f, $pos, SEEK_SET)) {
+			return false;
+		}
+		$this->_pos = $pos;
+		return true;
+	}
+
+	function is_resource() {
+		return is_resource($this->_f);
+	}
+
+	function feof() {
+		return feof($this->_f);
+	}
+
+	function close() {
+		return fclose($this->_f);
+	}
+
+	function read_all() {
+		$all = '';
+		while ( !$this->feof() )
+			$all .= $this->read(4096);
+		return $all;
+	}
+}
+endif;
+
+if ( !class_exists( 'POMO_StringReader' ) ):
+/**
+ * Provides file-like methods for manipulating a string instead
+ * of a physical file.
+ */
+class POMO_StringReader extends POMO_Reader {
+
+	var $_str = '';
+
+	function POMO_StringReader($str = '') {
+		parent::POMO_Reader();
+		$this->_str = $str;
+		$this->_pos = 0;
+	}
+
+
+	function read($bytes) {
+		$data = $this->substr($this->_str, $this->_pos, $bytes);
+		$this->_pos += $bytes;
+		if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);
+		return $data;
+	}
+
+	function seekto($pos) {
+		$this->_pos = $pos;
+		if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);
+		return $this->_pos;
+	}
+
+	function length() {
+		return $this->strlen($this->_str);
+	}
+
+	function read_all() {
+		return $this->substr($this->_str, $this->_pos, $this->strlen($this->_str));
+	}
+
+}
+endif;
+
+if ( !class_exists( 'POMO_CachedFileReader' ) ):
+/**
+ * Reads the contents of the file in the beginning.
+ */
+class POMO_CachedFileReader extends POMO_StringReader {
+	function POMO_CachedFileReader($filename) {
+		parent::POMO_StringReader();
+		$this->_str = file_get_contents($filename);
+		if (false === $this->_str)
+			return false;
+		$this->_pos = 0;
+	}
+}
+endif;
+
+if ( !class_exists( 'POMO_CachedIntFileReader' ) ):
+/**
+ * Reads the contents of the file in the beginning.
+ */
+class POMO_CachedIntFileReader extends POMO_CachedFileReader {
+	function POMO_CachedIntFileReader($filename) {
+		parent::POMO_CachedFileReader($filename);
+	}
+}
+endif;
Index: /tags/3.1/wp-includes/pomo/translations.php
===================================================================
--- /tags/3.1/wp-includes/pomo/translations.php	(revision 17487)
+++ /tags/3.1/wp-includes/pomo/translations.php	(revision 17487)
@@ -0,0 +1,253 @@
+<?php
+/**
+ * Class for a set of entries for translation and their associated headers
+ *
+ * @version $Id: translations.php 406 2010-02-07 11:10:24Z nbachiyski $
+ * @package pomo
+ * @subpackage translations
+ */
+
+require_once dirname(__FILE__) . '/entry.php';
+
+if ( !class_exists( 'Translations' ) ):
+class Translations {
+	var $entries = array();
+	var $headers = array();
+
+	/**
+	 * Add entry to the PO structure
+	 *
+	 * @param object &$entry
+	 * @return bool true on success, false if the entry doesn't have a key
+	 */
+	function add_entry($entry) {
+		if (is_array($entry)) {
+			$entry = new Translation_Entry($entry);
+		}
+		$key = $entry->key();
+		if (false === $key) return false;
+		$this->entries[$key] = &$entry;
+		return true;
+	}
+
+	/**
+	 * Sets $header PO header to $value
+	 *
+	 * If the header already exists, it will be overwritten
+	 *
+	 * TODO: this should be out of this class, it is gettext specific
+	 *
+	 * @param string $header header name, without trailing :
+	 * @param string $value header value, without trailing \n
+	 */
+	function set_header($header, $value) {
+		$this->headers[$header] = $value;
+	}
+
+	function set_headers(&$headers) {
+		foreach($headers as $header => $value) {
+			$this->set_header($header, $value);
+		}
+	}
+
+	function get_header($header) {
+		return isset($this->headers[$header])? $this->headers[$header] : false;
+	}
+
+	function translate_entry(&$entry) {
+		$key = $entry->key();
+		return isset($this->entries[$key])? $this->entries[$key] : false;
+	}
+
+	function translate($singular, $context=null) {
+		$entry = new Translation_Entry(array('singular' => $singular, 'context' => $context));
+		$translated = $this->translate_entry($entry);
+		return ($translated && !empty($translated->translations))? $translated->translations[0] : $singular;
+	}
+
+	/**
+	 * Given the number of items, returns the 0-based index of the plural form to use
+	 *
+	 * Here, in the base Translations class, the commong logic for English is implmented:
+	 * 	0 if there is one element, 1 otherwise
+	 *
+	 * This function should be overrided by the sub-classes. For example MO/PO can derive the logic
+	 * from their headers.
+	 *
+	 * @param integer $count number of items
+	 */
+	function select_plural_form($count) {
+		return 1 == $count? 0 : 1;
+	}
+
+	function get_plural_forms_count() {
+		return 2;
+	}
+
+	function translate_plural($singular, $plural, $count, $context = null) {
+		$entry = new Translation_Entry(array('singular' => $singular, 'plural' => $plural, 'context' => $context));
+		$translated = $this->translate_entry($entry);
+		$index = $this->select_plural_form($count);
+		$total_plural_forms = $this->get_plural_forms_count();
+		if ($translated && 0 <= $index && $index < $total_plural_forms &&
+				is_array($translated->translations) &&
+				isset($translated->translations[$index]))
+			return $translated->translations[$index];
+		else
+			return 1 == $count? $singular : $plural;
+	}
+
+	/**
+	 * Merge $other in the current object.
+	 *
+	 * @param Object &$other Another Translation object, whose translations will be merged in this one
+	 * @return void
+	 **/
+	function merge_with(&$other) {
+		foreach( $other->entries as $entry ) {
+			$this->entries[$entry->key()] = $entry;
+		}
+	}
+}
+
+class Gettext_Translations extends Translations {
+	/**
+	 * The gettext implmentation of select_plural_form.
+	 *
+	 * It lives in this class, because there are more than one descendand, which will use it and
+	 * they can't share it effectively.
+	 *
+	 */
+	function gettext_select_plural_form($count) {
+		if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) {
+			list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
+			$this->_nplurals = $nplurals;
+			$this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
+		}
+		return call_user_func($this->_gettext_select_plural_form, $count);
+	}
+
+	function nplurals_and_expression_from_header($header) {
+		if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
+			$nplurals = (int)$matches[1];
+			$expression = trim($this->parenthesize_plural_exression($matches[2]));
+			return array($nplurals, $expression);
+		} else {
+			return array(2, 'n != 1');
+		}
+	}
+
+	/**
+	 * Makes a function, which will return the right translation index, according to the
+	 * plural forms header
+	 */
+	function make_plural_form_function($nplurals, $expression) {
+		$expression = str_replace('n', '$n', $expression);
+		$func_body = "
+			\$index = (int)($expression);
+			return (\$index < $nplurals)? \$index : $nplurals - 1;";
+		return create_function('$n', $func_body);
+	}
+
+	/**
+	 * Adds parantheses to the inner parts of ternary operators in
+	 * plural expressions, because PHP evaluates ternary oerators from left to right
+	 *
+	 * @param string $expression the expression without parentheses
+	 * @return string the expression with parentheses added
+	 */
+	function parenthesize_plural_exression($expression) {
+		$expression .= ';';
+		$res = '';
+		$depth = 0;
+		for ($i = 0; $i < strlen($expression); ++$i) {
+			$char = $expression[$i];
+			switch ($char) {
+				case '?':
+					$res .= ' ? (';
+					$depth++;
+					break;
+				case ':':
+					$res .= ') : (';
+					break;
+				case ';':
+					$res .= str_repeat(')', $depth) . ';';
+					$depth= 0;
+					break;
+				default:
+					$res .= $char;
+			}
+		}
+		return rtrim($res, ';');
+	}
+
+	function make_headers($translation) {
+		$headers = array();
+		// sometimes \ns are used instead of real new lines
+		$translation = str_replace('\n', "\n", $translation);
+		$lines = explode("\n", $translation);
+		foreach($lines as $line) {
+			$parts = explode(':', $line, 2);
+			if (!isset($parts[1])) continue;
+			$headers[trim($parts[0])] = trim($parts[1]);
+		}
+		return $headers;
+	}
+
+	function set_header($header, $value) {
+		parent::set_header($header, $value);
+		if ('Plural-Forms' == $header) {
+			list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
+			$this->_nplurals = $nplurals;
+			$this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
+		}
+	}
+}
+endif;
+
+if ( !class_exists( 'NOOP_Translations' ) ):
+/**
+ * Provides the same interface as Translations, but doesn't do anything
+ */
+class NOOP_Translations {
+	var $entries = array();
+	var $headers = array();
+
+	function add_entry($entry) {
+		return true;
+	}
+
+	function set_header($header, $value) {
+	}
+
+	function set_headers(&$headers) {
+	}
+
+	function get_header($header) {
+		return false;
+	}
+
+	function translate_entry(&$entry) {
+		return false;
+	}
+
+	function translate($singular, $context=null) {
+		return $singular;
+	}
+
+	function select_plural_form($count) {
+		return 1 == $count? 0 : 1;
+	}
+
+	function get_plural_forms_count() {
+		return 2;
+	}
+
+	function translate_plural($singular, $plural, $count, $context = null) {
+			return 1 == $count? $singular : $plural;
+	}
+
+	function merge_with(&$other) {
+	}
+}
+endif;
Index: /tags/3.1/wp-includes/post-template.php
===================================================================
--- /tags/3.1/wp-includes/post-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/post-template.php	(revision 17487)
@@ -0,0 +1,1436 @@
+<?php
+/**
+ * WordPress Post Template Functions.
+ *
+ * Gets content for the current post in the loop.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Display the ID of the current item in the WordPress Loop.
+ *
+ * @since 0.71
+ */
+function the_ID() {
+	echo get_the_ID();
+}
+
+/**
+ * Retrieve the ID of the current item in the WordPress Loop.
+ *
+ * @since 2.1.0
+ * @uses $post
+ *
+ * @return int
+ */
+function get_the_ID() {
+	global $post;
+	return $post->ID;
+}
+
+/**
+ * Display or retrieve the current post title with optional content.
+ *
+ * @since 0.71
+ *
+ * @param string $before Optional. Content to prepend to the title.
+ * @param string $after Optional. Content to append to the title.
+ * @param bool $echo Optional, default to true.Whether to display or return.
+ * @return null|string Null on no title. String if $echo parameter is false.
+ */
+function the_title($before = '', $after = '', $echo = true) {
+	$title = get_the_title();
+
+	if ( strlen($title) == 0 )
+		return;
+
+	$title = $before . $title . $after;
+
+	if ( $echo )
+		echo $title;
+	else
+		return $title;
+}
+
+/**
+ * Sanitize the current title when retrieving or displaying.
+ *
+ * Works like {@link the_title()}, except the parameters can be in a string or
+ * an array. See the function for what can be override in the $args parameter.
+ *
+ * The title before it is displayed will have the tags stripped and {@link
+ * esc_attr()} before it is passed to the user or displayed. The default
+ * as with {@link the_title()}, is to display the title.
+ *
+ * @since 2.3.0
+ *
+ * @param string|array $args Optional. Override the defaults.
+ * @return string|null Null on failure or display. String when echo is false.
+ */
+function the_title_attribute( $args = '' ) {
+	$title = get_the_title();
+
+	if ( strlen($title) == 0 )
+		return;
+
+	$defaults = array('before' => '', 'after' =>  '', 'echo' => true);
+	$r = wp_parse_args($args, $defaults);
+	extract( $r, EXTR_SKIP );
+
+
+	$title = $before . $title . $after;
+	$title = esc_attr(strip_tags($title));
+
+	if ( $echo )
+		echo $title;
+	else
+		return $title;
+}
+
+/**
+ * Retrieve post title.
+ *
+ * If the post is protected and the visitor is not an admin, then "Protected"
+ * will be displayed before the post title. If the post is private, then
+ * "Private" will be located before the post title.
+ *
+ * @since 0.71
+ *
+ * @param int $id Optional. Post ID.
+ * @return string
+ */
+function get_the_title( $id = 0 ) {
+	$post = &get_post($id);
+
+	$title = isset($post->post_title) ? $post->post_title : '';
+	$id = isset($post->ID) ? $post->ID : (int) $id;
+
+	if ( !is_admin() ) {
+		if ( !empty($post->post_password) ) {
+			$protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
+			$title = sprintf($protected_title_format, $title);
+		} else if ( isset($post->post_status) && 'private' == $post->post_status ) {
+			$private_title_format = apply_filters('private_title_format', __('Private: %s'));
+			$title = sprintf($private_title_format, $title);
+		}
+	}
+	return apply_filters( 'the_title', $title, $id );
+}
+
+/**
+ * Display the Post Global Unique Identifier (guid).
+ *
+ * The guid will appear to be a link, but should not be used as an link to the
+ * post. The reason you should not use it as a link, is because of moving the
+ * blog across domains.
+ *
+ * Url is escaped to make it xml safe
+ *
+ * @since 1.5.0
+ *
+ * @param int $id Optional. Post ID.
+ */
+function the_guid( $id = 0 ) {
+	echo esc_url( get_the_guid( $id ) );
+}
+
+/**
+ * Retrieve the Post Global Unique Identifier (guid).
+ *
+ * The guid will appear to be a link, but should not be used as an link to the
+ * post. The reason you should not use it as a link, is because of moving the
+ * blog across domains.
+ *
+ * @since 1.5.0
+ *
+ * @param int $id Optional. Post ID.
+ * @return string
+ */
+function get_the_guid( $id = 0 ) {
+	$post = &get_post($id);
+
+	return apply_filters('get_the_guid', $post->guid);
+}
+
+/**
+ * Display the post content.
+ *
+ * @since 0.71
+ *
+ * @param string $more_link_text Optional. Content for when there is more text.
+ * @param string $stripteaser Optional. Teaser content before the more text.
+ */
+function the_content($more_link_text = null, $stripteaser = 0) {
+	$content = get_the_content($more_link_text, $stripteaser);
+	$content = apply_filters('the_content', $content);
+	$content = str_replace(']]>', ']]&gt;', $content);
+	echo $content;
+}
+
+/**
+ * Retrieve the post content.
+ *
+ * @since 0.71
+ *
+ * @param string $more_link_text Optional. Content for when there is more text.
+ * @param string $stripteaser Optional. Teaser content before the more text.
+ * @return string
+ */
+function get_the_content($more_link_text = null, $stripteaser = 0) {
+	global $post, $more, $page, $pages, $multipage, $preview;
+
+	if ( null === $more_link_text )
+		$more_link_text = __( '(more...)' );
+
+	$output = '';
+	$hasTeaser = false;
+
+	// If post password required and it doesn't match the cookie.
+	if ( post_password_required($post) ) {
+		$output = get_the_password_form();
+		return $output;
+	}
+
+	if ( $page > count($pages) ) // if the requested page doesn't exist
+		$page = count($pages); // give them the highest numbered page that DOES exist
+
+	$content = $pages[$page-1];
+	if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {
+		$content = explode($matches[0], $content, 2);
+		if ( !empty($matches[1]) && !empty($more_link_text) )
+			$more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));
+
+		$hasTeaser = true;
+	} else {
+		$content = array($content);
+	}
+	if ( (false !== strpos($post->post_content, '<!--noteaser-->') && ((!$multipage) || ($page==1))) )
+		$stripteaser = 1;
+	$teaser = $content[0];
+	if ( ($more) && ($stripteaser) && ($hasTeaser) )
+		$teaser = '';
+	$output .= $teaser;
+	if ( count($content) > 1 ) {
+		if ( $more ) {
+			$output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
+		} else {
+			if ( ! empty($more_link_text) )
+				$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
+			$output = force_balance_tags($output);
+		}
+
+	}
+	if ( $preview ) // preview fix for javascript bug with foreign languages
+		$output =	preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output);
+
+	return $output;
+}
+
+/**
+ * Preview fix for javascript bug with foreign languages
+ *
+ * @since 3.1.0
+ * @access private
+ * @param array $match Match array from preg_replace_callback
+ * @returns string
+ */
+function _convert_urlencoded_to_entities( $match ) {
+	return '&#' . base_convert( $match[1], 16, 10 ) . ';';
+}
+
+/**
+ * Display the post excerpt.
+ *
+ * @since 0.71
+ * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt.
+ */
+function the_excerpt() {
+	echo apply_filters('the_excerpt', get_the_excerpt());
+}
+
+/**
+ * Retrieve the post excerpt.
+ *
+ * @since 0.71
+ *
+ * @param mixed $deprecated Not used.
+ * @return string
+ */
+function get_the_excerpt( $deprecated = '' ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.3' );
+
+	global $post;
+	$output = $post->post_excerpt;
+	if ( post_password_required($post) ) {
+		$output = __('There is no excerpt because this is a protected post.');
+		return $output;
+	}
+
+	return apply_filters('get_the_excerpt', $output);
+}
+
+/**
+ * Whether post has excerpt.
+ *
+ * @since 2.3.0
+ *
+ * @param int $id Optional. Post ID.
+ * @return bool
+ */
+function has_excerpt( $id = 0 ) {
+	$post = &get_post( $id );
+	return ( !empty( $post->post_excerpt ) );
+}
+
+/**
+ * Display the classes for the post div.
+ *
+ * @since 2.7.0
+ *
+ * @param string|array $class One or more classes to add to the class list.
+ * @param int $post_id An optional post ID.
+ */
+function post_class( $class = '', $post_id = null ) {
+	// Separates classes with a single space, collates classes for post DIV
+	echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
+}
+
+/**
+ * Retrieve the classes for the post div as an array.
+ *
+ * The class names are add are many. If the post is a sticky, then the 'sticky'
+ * class name. The class 'hentry' is always added to each post. For each
+ * category, the class will be added with 'category-' with category slug is
+ * added. The tags are the same way as the categories with 'tag-' before the tag
+ * slug. All classes are passed through the filter, 'post_class' with the list
+ * of classes, followed by $class parameter value, with the post ID as the last
+ * parameter.
+ *
+ * @since 2.7.0
+ *
+ * @param string|array $class One or more classes to add to the class list.
+ * @param int $post_id An optional post ID.
+ * @return array Array of classes.
+ */
+function get_post_class( $class = '', $post_id = null ) {
+	$post = get_post($post_id);
+
+	$classes = array();
+
+	if ( empty($post) )
+		return $classes;
+
+	$classes[] = 'post-' . $post->ID;
+	$classes[] = $post->post_type;
+	$classes[] = 'type-' . $post->post_type;
+	$classes[] = 'status-' . $post->post_status;
+
+	// Post Format
+	$post_format = get_post_format( $post->ID );
+
+	if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
+		if ( $post_format && !is_wp_error($post_format) )
+			$classes[] = 'format-' . sanitize_html_class( $post_format );
+		else
+			$classes[] = 'format-standard';
+	}
+
+	// post requires password
+	if ( post_password_required($post->ID) )
+		$classes[] = 'post-password-required';
+
+	// sticky for Sticky Posts
+	if ( is_sticky($post->ID) && is_home() && !is_paged() )
+		$classes[] = 'sticky';
+
+	// hentry for hAtom compliance
+	$classes[] = 'hentry';
+
+	// Categories
+	if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) {
+		foreach ( (array) get_the_category($post->ID) as $cat ) {
+			if ( empty($cat->slug ) )
+				continue;
+			$classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->term_id);
+		}
+	}
+
+	// Tags
+	if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) {
+		foreach ( (array) get_the_tags($post->ID) as $tag ) {
+			if ( empty($tag->slug ) )
+				continue;
+			$classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id);
+		}
+	}
+
+	if ( !empty($class) ) {
+		if ( !is_array( $class ) )
+			$class = preg_split('#\s+#', $class);
+		$classes = array_merge($classes, $class);
+	}
+
+	$classes = array_map('esc_attr', $classes);
+
+	return apply_filters('post_class', $classes, $class, $post->ID);
+}
+
+/**
+ * Display the classes for the body element.
+ *
+ * @since 2.8.0
+ *
+ * @param string|array $class One or more classes to add to the class list.
+ */
+function body_class( $class = '' ) {
+	// Separates classes with a single space, collates classes for body element
+	echo 'class="' . join( ' ', get_body_class( $class ) ) . '"';
+}
+
+/**
+ * Retrieve the classes for the body element as an array.
+ *
+ * @since 2.8.0
+ *
+ * @param string|array $class One or more classes to add to the class list.
+ * @return array Array of classes.
+ */
+function get_body_class( $class = '' ) {
+	global $wp_query, $wpdb;
+
+	$classes = array();
+
+	if ( is_rtl() )
+		$classes[] = 'rtl';
+
+	if ( is_front_page() )
+		$classes[] = 'home';
+	if ( is_home() )
+		$classes[] = 'blog';
+	if ( is_archive() )
+		$classes[] = 'archive';
+	if ( is_date() )
+		$classes[] = 'date';
+	if ( is_search() )
+		$classes[] = 'search';
+	if ( is_paged() )
+		$classes[] = 'paged';
+	if ( is_attachment() )
+		$classes[] = 'attachment';
+	if ( is_404() )
+		$classes[] = 'error404';
+
+	if ( is_single() ) {
+		$post_id = $wp_query->get_queried_object_id();
+		$post = $wp_query->get_queried_object();
+
+		$classes[] = 'single';
+		$classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id);
+		$classes[] = 'postid-' . $post_id;
+
+		// Post Format
+		$post_format = get_post_format( $post->ID );
+
+		if ( $post_format && !is_wp_error($post_format) )
+			$classes[] = 'single-format-' . sanitize_html_class( $post_format );
+		else
+			$classes[] = 'single-format-standard';
+
+		if ( is_attachment() ) {
+			$mime_type = get_post_mime_type($post_id);
+			$mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
+			$classes[] = 'attachmentid-' . $post_id;
+			$classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
+		}
+	} elseif ( is_archive() ) {
+		if ( is_post_type_archive() ) {
+			$classes[] = 'post-type-archive';
+			$classes[] = 'post-type-archive-' . sanitize_html_class( get_query_var( 'post_type' ) );
+		} else if ( is_author() ) {
+			$author = $wp_query->get_queried_object();
+			$classes[] = 'author';
+			$classes[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID );
+			$classes[] = 'author-' . $author->ID;
+		} elseif ( is_category() ) {
+			$cat = $wp_query->get_queried_object();
+			$classes[] = 'category';
+			$classes[] = 'category-' . sanitize_html_class( $cat->slug, $cat->term_id );
+			$classes[] = 'category-' . $cat->term_id;
+		} elseif ( is_tag() ) {
+			$tags = $wp_query->get_queried_object();
+			$classes[] = 'tag';
+			$classes[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id );
+			$classes[] = 'tag-' . $tags->term_id;
+		} elseif ( is_tax() ) {
+			$term = $wp_query->get_queried_object();
+			$classes[] = 'tax-' . sanitize_html_class( $term->taxonomy );
+			$classes[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id );
+			$classes[] = 'term-' . $term->term_id;
+		}
+	} elseif ( is_page() ) {
+		$classes[] = 'page';
+
+		$page_id = $wp_query->get_queried_object_id();
+
+		$post = get_page($page_id);
+
+		$classes[] = 'page-id-' . $page_id;
+
+		if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status = 'publish' LIMIT 1", $page_id) ) )
+			$classes[] = 'page-parent';
+
+		if ( $post->post_parent ) {
+			$classes[] = 'page-child';
+			$classes[] = 'parent-pageid-' . $post->post_parent;
+		}
+		if ( is_page_template() ) {
+			$classes[] = 'page-template';
+			$classes[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $page_id, '_wp_page_template', true ) ), '' );
+		}
+	} elseif ( is_search() ) {
+		if ( !empty( $wp_query->posts ) )
+			$classes[] = 'search-results';
+		else
+			$classes[] = 'search-no-results';
+	}
+
+	if ( is_user_logged_in() )
+		$classes[] = 'logged-in';
+
+	if ( is_admin_bar_showing() )
+		$classes[] = 'admin-bar';
+
+	$page = $wp_query->get( 'page' );
+
+	if ( !$page || $page < 2)
+		$page = $wp_query->get( 'paged' );
+
+	if ( $page && $page > 1 ) {
+		$classes[] = 'paged-' . $page;
+
+		if ( is_single() )
+			$classes[] = 'single-paged-' . $page;
+		elseif ( is_page() )
+			$classes[] = 'page-paged-' . $page;
+		elseif ( is_category() )
+			$classes[] = 'category-paged-' . $page;
+		elseif ( is_tag() )
+			$classes[] = 'tag-paged-' . $page;
+		elseif ( is_date() )
+			$classes[] = 'date-paged-' . $page;
+		elseif ( is_author() )
+			$classes[] = 'author-paged-' . $page;
+		elseif ( is_search() )
+			$classes[] = 'search-paged-' . $page;
+		elseif ( is_post_type_archive() )
+			$classes[] = 'post-type-paged-' . $page;
+	}
+
+	if ( !empty( $class ) ) {
+		if ( !is_array( $class ) )
+			$class = preg_split( '#\s+#', $class );
+		$classes = array_merge( $classes, $class );
+	}
+
+	$classes = array_map( 'esc_attr', $classes );
+
+	return apply_filters( 'body_class', $classes, $class );
+}
+
+/**
+ * Whether post requires password and correct password has been provided.
+ *
+ * @since 2.7.0
+ *
+ * @param int|object $post An optional post.  Global $post used if not provided.
+ * @return bool false if a password is not required or the correct password cookie is present, true otherwise.
+ */
+function post_password_required( $post = null ) {
+	$post = get_post($post);
+
+	if ( empty($post->post_password) )
+		return false;
+
+	if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) )
+		return true;
+
+	if ( $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password )
+		return true;
+
+	return false;
+}
+
+/**
+ * Display "sticky" CSS class, if a post is sticky.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id An optional post ID.
+ */
+function sticky_class( $post_id = null ) {
+	if ( !is_sticky($post_id) )
+		return;
+
+	echo " sticky";
+}
+
+/**
+ * Page Template Functions for usage in Themes
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * The formatted output of a list of pages.
+ *
+ * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
+ * Quicktag one or more times). This tag must be within The Loop.
+ *
+ * The defaults for overwriting are:
+ * 'next_or_number' - Default is 'number' (string). Indicates whether page
+ *      numbers should be used. Valid values are number and next.
+ * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
+ *      of the bookmark.
+ * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
+ *      previous page, if available.
+ * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
+ *      the parameter string will be replaced with the page number, so Page %
+ *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
+ * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
+ *      each bookmarks.
+ * 'after' - Default is '</p>' (string). The html or text to append to each
+ *      bookmarks.
+ * 'link_before' - Default is '' (string). The html or text to prepend to each
+ *      Pages link inside the <a> tag. Also prepended to the current item, which
+ *      is not linked.
+ * 'link_after' - Default is '' (string). The html or text to append to each
+ *      Pages link inside the <a> tag. Also appended to the current item, which
+ *      is not linked.
+ *
+ * @since 1.2.0
+ * @access private
+ *
+ * @param string|array $args Optional. Overwrite the defaults.
+ * @return string Formatted output in HTML.
+ */
+function wp_link_pages($args = '') {
+	$defaults = array(
+		'before' => '<p>' . __('Pages:'), 'after' => '</p>',
+		'link_before' => '', 'link_after' => '',
+		'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
+		'previouspagelink' => __('Previous page'), 'pagelink' => '%',
+		'echo' => 1
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	$r = apply_filters( 'wp_link_pages_args', $r );
+	extract( $r, EXTR_SKIP );
+
+	global $page, $numpages, $multipage, $more, $pagenow;
+
+	$output = '';
+	if ( $multipage ) {
+		if ( 'number' == $next_or_number ) {
+			$output .= $before;
+			for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {
+				$j = str_replace('%',$i,$pagelink);
+				$output .= ' ';
+				if ( ($i != $page) || ((!$more) && ($page==1)) ) {
+					$output .= _wp_link_page($i);
+				}
+				$output .= $link_before . $j . $link_after;
+				if ( ($i != $page) || ((!$more) && ($page==1)) )
+					$output .= '</a>';
+			}
+			$output .= $after;
+		} else {
+			if ( $more ) {
+				$output .= $before;
+				$i = $page - 1;
+				if ( $i && $more ) {
+					$output .= _wp_link_page($i);
+					$output .= $link_before. $previouspagelink . $link_after . '</a>';
+				}
+				$i = $page + 1;
+				if ( $i <= $numpages && $more ) {
+					$output .= _wp_link_page($i);
+					$output .= $link_before. $nextpagelink . $link_after . '</a>';
+				}
+				$output .= $after;
+			}
+		}
+	}
+
+	if ( $echo )
+		echo $output;
+
+	return $output;
+}
+
+/**
+ * Helper function for wp_link_pages().
+ *
+ * @since 3.1.0
+ * @access private
+ *
+ * @param int $i Page number.
+ * @return string Link.
+ */
+function _wp_link_page( $i ) {
+	global $post, $wp_rewrite;
+
+	if ( 1 == $i ) {
+		$url = get_permalink();
+	} else {
+		if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
+			$url = add_query_arg( 'page', $i, get_permalink() );
+		elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
+			$url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
+		else
+			$url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
+	}
+
+	return '<a href="' . esc_url( $url ) . '">';
+}
+
+//
+// Post-meta: Custom per-post fields.
+//
+
+/**
+ * Retrieve post custom meta data field.
+ *
+ * @since 1.5.0
+ *
+ * @param string $key Meta data key name.
+ * @return bool|string|array Array of values or single value, if only one element exists. False will be returned if key does not exist.
+ */
+function post_custom( $key = '' ) {
+	$custom = get_post_custom();
+
+	if ( !isset( $custom[$key] ) )
+		return false;
+	elseif ( 1 == count($custom[$key]) )
+		return $custom[$key][0];
+	else
+		return $custom[$key];
+}
+
+/**
+ * Display list of post custom fields.
+ *
+ * @internal This will probably change at some point...
+ * @since 1.2.0
+ * @uses apply_filters() Calls 'the_meta_key' on list item HTML content, with key and value as separate parameters.
+ */
+function the_meta() {
+	if ( $keys = get_post_custom_keys() ) {
+		echo "<ul class='post-meta'>\n";
+		foreach ( (array) $keys as $key ) {
+			$keyt = trim($key);
+			if ( '_' == $keyt[0] )
+				continue;
+			$values = array_map('trim', get_post_custom_values($key));
+			$value = implode($values,', ');
+			echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value);
+		}
+		echo "</ul>\n";
+	}
+}
+
+//
+// Pages
+//
+
+/**
+ * Retrieve or display list of pages as a dropdown (select list).
+ *
+ * @since 2.1.0
+ *
+ * @param array|string $args Optional. Override default arguments.
+ * @return string HTML content, if not displaying.
+ */
+function wp_dropdown_pages($args = '') {
+	$defaults = array(
+		'depth' => 0, 'child_of' => 0,
+		'selected' => 0, 'echo' => 1,
+		'name' => 'page_id', 'id' => '',
+		'show_option_none' => '', 'show_option_no_change' => '',
+		'option_none_value' => ''
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	$pages = get_pages($r);
+	$output = '';
+	$name = esc_attr($name);
+	// Back-compat with old system where both id and name were based on $name argument
+	if ( empty($id) )
+		$id = $name;
+
+	if ( ! empty($pages) ) {
+		$output = "<select name=\"$name\" id=\"$id\">\n";
+		if ( $show_option_no_change )
+			$output .= "\t<option value=\"-1\">$show_option_no_change</option>";
+		if ( $show_option_none )
+			$output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">$show_option_none</option>\n";
+		$output .= walk_page_dropdown_tree($pages, $depth, $r);
+		$output .= "</select>\n";
+	}
+
+	$output = apply_filters('wp_dropdown_pages', $output);
+
+	if ( $echo )
+		echo $output;
+
+	return $output;
+}
+
+/**
+ * Retrieve or display list of pages in list (li) format.
+ *
+ * @since 1.5.0
+ *
+ * @param array|string $args Optional. Override default arguments.
+ * @return string HTML content, if not displaying.
+ */
+function wp_list_pages($args = '') {
+	$defaults = array(
+		'depth' => 0, 'show_date' => '',
+		'date_format' => get_option('date_format'),
+		'child_of' => 0, 'exclude' => '',
+		'title_li' => __('Pages'), 'echo' => 1,
+		'authors' => '', 'sort_column' => 'menu_order, post_title',
+		'link_before' => '', 'link_after' => '', 'walker' => '',
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	$output = '';
+	$current_page = 0;
+
+	// sanitize, mostly to keep spaces out
+	$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
+
+	// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
+	$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
+	$r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );
+
+	// Query pages.
+	$r['hierarchical'] = 0;
+	$pages = get_pages($r);
+
+	if ( !empty($pages) ) {
+		if ( $r['title_li'] )
+			$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
+
+		global $wp_query;
+		if ( is_page() || is_attachment() || $wp_query->is_posts_page )
+			$current_page = $wp_query->get_queried_object_id();
+		$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
+
+		if ( $r['title_li'] )
+			$output .= '</ul></li>';
+	}
+
+	$output = apply_filters('wp_list_pages', $output, $r);
+
+	if ( $r['echo'] )
+		echo $output;
+	else
+		return $output;
+}
+
+/**
+ * Display or retrieve list of pages with optional home link.
+ *
+ * The arguments are listed below and part of the arguments are for {@link
+ * wp_list_pages()} function. Check that function for more info on those
+ * arguments.
+ *
+ * <ul>
+ * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults
+ * to page title. Use column for posts table.</li>
+ * <li><strong>menu_class</strong> - Class to use for the div ID which contains
+ * the page list. Defaults to 'menu'.</li>
+ * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to
+ * echo.</li>
+ * <li><strong>link_before</strong> - Text before show_home argument text.</li>
+ * <li><strong>link_after</strong> - Text after show_home argument text.</li>
+ * <li><strong>show_home</strong> - If you set this argument, then it will
+ * display the link to the home page. The show_home argument really just needs
+ * to be set to the value of the text of the link.</li>
+ * </ul>
+ *
+ * @since 2.7.0
+ *
+ * @param array|string $args
+ */
+function wp_page_menu( $args = array() ) {
+	$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
+	$args = wp_parse_args( $args, $defaults );
+	$args = apply_filters( 'wp_page_menu_args', $args );
+
+	$menu = '';
+
+	$list_args = $args;
+
+	// Show Home in the menu
+	if ( ! empty($args['show_home']) ) {
+		if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
+			$text = __('Home');
+		else
+			$text = $args['show_home'];
+		$class = '';
+		if ( is_front_page() && !is_paged() )
+			$class = 'class="current_page_item"';
+		$menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
+		// If the front page is a page, add it to the exclude list
+		if (get_option('show_on_front') == 'page') {
+			if ( !empty( $list_args['exclude'] ) ) {
+				$list_args['exclude'] .= ',';
+			} else {
+				$list_args['exclude'] = '';
+			}
+			$list_args['exclude'] .= get_option('page_on_front');
+		}
+	}
+
+	$list_args['echo'] = false;
+	$list_args['title_li'] = '';
+	$menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
+
+	if ( $menu )
+		$menu = '<ul>' . $menu . '</ul>';
+
+	$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
+	$menu = apply_filters( 'wp_page_menu', $menu, $args );
+	if ( $args['echo'] )
+		echo $menu;
+	else
+		return $menu;
+}
+
+//
+// Page helpers
+//
+
+/**
+ * Retrieve HTML list content for page list.
+ *
+ * @uses Walker_Page to create HTML list content.
+ * @since 2.1.0
+ * @see Walker_Page::walk() for parameters and return description.
+ */
+function walk_page_tree($pages, $depth, $current_page, $r) {
+	if ( empty($r['walker']) )
+		$walker = new Walker_Page;
+	else
+		$walker = $r['walker'];
+
+	$args = array($pages, $depth, $r, $current_page);
+	return call_user_func_array(array(&$walker, 'walk'), $args);
+}
+
+/**
+ * Retrieve HTML dropdown (select) content for page list.
+ *
+ * @uses Walker_PageDropdown to create HTML dropdown content.
+ * @since 2.1.0
+ * @see Walker_PageDropdown::walk() for parameters and return description.
+ */
+function walk_page_dropdown_tree() {
+	$args = func_get_args();
+	if ( empty($args[2]['walker']) ) // the user's options are the third parameter
+		$walker = new Walker_PageDropdown;
+	else
+		$walker = $args[2]['walker'];
+
+	return call_user_func_array(array(&$walker, 'walk'), $args);
+}
+
+/**
+ * Create HTML list of pages.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
+class Walker_Page extends Walker {
+	/**
+	 * @see Walker::$tree_type
+	 * @since 2.1.0
+	 * @var string
+	 */
+	var $tree_type = 'page';
+
+	/**
+	 * @see Walker::$db_fields
+	 * @since 2.1.0
+	 * @todo Decouple this.
+	 * @var array
+	 */
+	var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
+
+	/**
+	 * @see Walker::start_lvl()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of page. Used for padding.
+	 */
+	function start_lvl(&$output, $depth) {
+		$indent = str_repeat("\t", $depth);
+		$output .= "\n$indent<ul class='children'>\n";
+	}
+
+	/**
+	 * @see Walker::end_lvl()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param int $depth Depth of page. Used for padding.
+	 */
+	function end_lvl(&$output, $depth) {
+		$indent = str_repeat("\t", $depth);
+		$output .= "$indent</ul>\n";
+	}
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $page Page data object.
+	 * @param int $depth Depth of page. Used for padding.
+	 * @param int $current_page Page ID.
+	 * @param array $args
+	 */
+	function start_el(&$output, $page, $depth, $args, $current_page) {
+		if ( $depth )
+			$indent = str_repeat("\t", $depth);
+		else
+			$indent = '';
+
+		extract($args, EXTR_SKIP);
+		$css_class = array('page_item', 'page-item-'.$page->ID);
+		if ( !empty($current_page) ) {
+			$_current_page = get_page( $current_page );
+			_get_post_ancestors($_current_page);
+			if ( isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors) )
+				$css_class[] = 'current_page_ancestor';
+			if ( $page->ID == $current_page )
+				$css_class[] = 'current_page_item';
+			elseif ( $_current_page && $page->ID == $_current_page->post_parent )
+				$css_class[] = 'current_page_parent';
+		} elseif ( $page->ID == get_option('page_for_posts') ) {
+			$css_class[] = 'current_page_parent';
+		}
+
+		$css_class = implode(' ', apply_filters('page_css_class', $css_class, $page));
+
+		$output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '" title="' . esc_attr( wp_strip_all_tags( apply_filters( 'the_title', $page->post_title, $page->ID ) ) ) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>';
+
+		if ( !empty($show_date) ) {
+			if ( 'modified' == $show_date )
+				$time = $page->post_modified;
+			else
+				$time = $page->post_date;
+
+			$output .= " " . mysql2date($date_format, $time);
+		}
+	}
+
+	/**
+	 * @see Walker::end_el()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $page Page data object. Not used.
+	 * @param int $depth Depth of page. Not Used.
+	 */
+	function end_el(&$output, $page, $depth) {
+		$output .= "</li>\n";
+	}
+
+}
+
+/**
+ * Create HTML dropdown list of pages.
+ *
+ * @package WordPress
+ * @since 2.1.0
+ * @uses Walker
+ */
+class Walker_PageDropdown extends Walker {
+	/**
+	 * @see Walker::$tree_type
+	 * @since 2.1.0
+	 * @var string
+	 */
+	var $tree_type = 'page';
+
+	/**
+	 * @see Walker::$db_fields
+	 * @since 2.1.0
+	 * @todo Decouple this
+	 * @var array
+	 */
+	var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
+
+	/**
+	 * @see Walker::start_el()
+	 * @since 2.1.0
+	 *
+	 * @param string $output Passed by reference. Used to append additional content.
+	 * @param object $page Page data object.
+	 * @param int $depth Depth of page in reference to parent pages. Used for padding.
+	 * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
+	 */
+	function start_el(&$output, $page, $depth, $args) {
+		$pad = str_repeat('&nbsp;', $depth * 3);
+
+		$output .= "\t<option class=\"level-$depth\" value=\"$page->ID\"";
+		if ( $page->ID == $args['selected'] )
+			$output .= ' selected="selected"';
+		$output .= '>';
+		$title = esc_html($page->post_title);
+		$title = apply_filters( 'list_pages', $page->post_title );
+		$output .= "$pad$title";
+		$output .= "</option>\n";
+	}
+}
+
+//
+// Attachments
+//
+
+/**
+ * Display an attachment page link using an image or icon.
+ *
+ * @since 2.0.0
+ *
+ * @param int $id Optional. Post ID.
+ * @param bool $fullsize Optional, default is false. Whether to use full size.
+ * @param bool $deprecated Deprecated. Not used.
+ * @param bool $permalink Optional, default is false. Whether to include permalink.
+ */
+function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '2.5' );
+
+	if ( $fullsize )
+		echo wp_get_attachment_link($id, 'full', $permalink);
+	else
+		echo wp_get_attachment_link($id, 'thumbnail', $permalink);
+}
+
+/**
+ * Retrieve an attachment page link using an image or icon, if possible.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
+ *
+ * @param int $id Optional. Post ID.
+ * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
+ * @param bool $permalink Optional, default is false. Whether to add permalink to image.
+ * @param bool $icon Optional, default is false. Whether to include icon.
+ * @param string $text Optional, default is false. If string, then will be link text.
+ * @return string HTML content.
+ */
+function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false) {
+	$id = intval($id);
+	$_post = & get_post( $id );
+
+	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
+		return __('Missing Attachment');
+
+	if ( $permalink )
+		$url = get_attachment_link($_post->ID);
+
+	$post_title = esc_attr($_post->post_title);
+
+	if ( $text ) {
+		$link_text = esc_attr($text);
+	} elseif ( ( is_int($size) && $size != 0 ) or ( is_string($size) && $size != 'none' ) or $size != false ) {
+		$link_text = wp_get_attachment_image($id, $size, $icon);
+	} else {
+		$link_text = '';
+	}
+
+	if( trim($link_text) == '' )
+		$link_text = $_post->post_title;
+
+	return apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon, $text );
+}
+
+/**
+ * Wrap attachment in <<p>> element before content.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'prepend_attachment' hook on HTML content.
+ *
+ * @param string $content
+ * @return string
+ */
+function prepend_attachment($content) {
+	global $post;
+
+	if ( empty($post->post_type) || $post->post_type != 'attachment' )
+		return $content;
+
+	$p = '<p class="attachment">';
+	// show the medium sized image representation of the attachment if available, and link to the raw file
+	$p .= wp_get_attachment_link(0, 'medium', false);
+	$p .= '</p>';
+	$p = apply_filters('prepend_attachment', $p);
+
+	return "$p\n$content";
+}
+
+//
+// Misc
+//
+
+/**
+ * Retrieve protected post password form content.
+ *
+ * @since 1.0.0
+ * @uses apply_filters() Calls 'the_password_form' filter on output.
+ *
+ * @return string HTML content for password form for password protected post.
+ */
+function get_the_password_form() {
+	global $post;
+	$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
+	$output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
+	<p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
+	<p><label for="' . $label . '">' . __("Password:") . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__("Submit") . '" /></p>
+	</form>
+	';
+	return apply_filters('the_password_form', $output);
+}
+
+/**
+ * Whether currently in a page template.
+ *
+ * This template tag allows you to determine if you are in a page template.
+ * You can optionally provide a template name and then the check will be
+ * specific to that template.
+ *
+ * @since 2.5.0
+ * @uses $wp_query
+ *
+ * @param string $template The specific template name if specific matching is required.
+ * @return bool False on failure, true if success.
+ */
+function is_page_template($template = '') {
+	if (!is_page()) {
+		return false;
+	}
+
+	global $wp_query;
+
+	$page = $wp_query->get_queried_object();
+	$custom_fields = get_post_custom_values('_wp_page_template',$page->ID);
+	$page_template = $custom_fields[0];
+
+	// We have no argument passed so just see if a page_template has been specified
+	if ( empty( $template ) ) {
+		if (!empty( $page_template ) ) {
+			return true;
+		}
+	} elseif ( $template == $page_template) {
+		return true;
+	}
+
+	return false;
+}
+
+/**
+ * Retrieve formatted date timestamp of a revision (linked to that revisions's page).
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses date_i18n()
+ *
+ * @param int|object $revision Revision ID or revision object.
+ * @param bool $link Optional, default is true. Link to revisions's page?
+ * @return string i18n formatted datetimestamp or localized 'Current Revision'.
+ */
+function wp_post_revision_title( $revision, $link = true ) {
+	if ( !$revision = get_post( $revision ) )
+		return $revision;
+
+	if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
+		return false;
+
+	/* translators: revision date format, see http://php.net/date */
+	$datef = _x( 'j F, Y @ G:i', 'revision date format');
+	/* translators: 1: date */
+	$autosavef = __( '%1$s [Autosave]' );
+	/* translators: 1: date */
+	$currentf  = __( '%1$s [Current Revision]' );
+
+	$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
+	if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
+		$date = "<a href='$link'>$date</a>";
+
+	if ( !wp_is_post_revision( $revision ) )
+		$date = sprintf( $currentf, $date );
+	elseif ( wp_is_post_autosave( $revision ) )
+		$date = sprintf( $autosavef, $date );
+
+	return $date;
+}
+
+/**
+ * Display list of a post's revisions.
+ *
+ * Can output either a UL with edit links or a TABLE with diff interface, and
+ * restore action links.
+ *
+ * Second argument controls parameters:
+ *   (bool)   parent : include the parent (the "Current Revision") in the list.
+ *   (string) format : 'list' or 'form-table'.  'list' outputs UL, 'form-table'
+ *                     outputs TABLE with UI.
+ *   (int)    right  : what revision is currently being viewed - used in
+ *                     form-table format.
+ *   (int)    left   : what revision is currently being diffed against right -
+ *                     used in form-table format.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses wp_get_post_revisions()
+ * @uses wp_post_revision_title()
+ * @uses get_edit_post_link()
+ * @uses get_the_author_meta()
+ *
+ * @todo split into two functions (list, form-table) ?
+ *
+ * @param int|object $post_id Post ID or post object.
+ * @param string|array $args See description {@link wp_parse_args()}.
+ * @return null
+ */
+function wp_list_post_revisions( $post_id = 0, $args = null ) {
+	if ( !$post = get_post( $post_id ) )
+		return;
+
+	$defaults = array( 'parent' => false, 'right' => false, 'left' => false, 'format' => 'list', 'type' => 'all' );
+	extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
+
+	switch ( $type ) {
+		case 'autosave' :
+			if ( !$autosave = wp_get_post_autosave( $post->ID ) )
+				return;
+			$revisions = array( $autosave );
+			break;
+		case 'revision' : // just revisions - remove autosave later
+		case 'all' :
+		default :
+			if ( !$revisions = wp_get_post_revisions( $post->ID ) )
+				return;
+			break;
+	}
+
+	/* translators: post revision: 1: when, 2: author name */
+	$titlef = _x( '%1$s by %2$s', 'post revision' );
+
+	if ( $parent )
+		array_unshift( $revisions, $post );
+
+	$rows = '';
+	$class = false;
+	$can_edit_post = current_user_can( 'edit_post', $post->ID );
+	foreach ( $revisions as $revision ) {
+		if ( !current_user_can( 'read_post', $revision->ID ) )
+			continue;
+		if ( 'revision' === $type && wp_is_post_autosave( $revision ) )
+			continue;
+
+		$date = wp_post_revision_title( $revision );
+		$name = get_the_author_meta( 'display_name', $revision->post_author );
+
+		if ( 'form-table' == $format ) {
+			if ( $left )
+				$left_checked = $left == $revision->ID ? ' checked="checked"' : '';
+			else
+				$left_checked = $right_checked ? ' checked="checked"' : ''; // [sic] (the next one)
+			$right_checked = $right == $revision->ID ? ' checked="checked"' : '';
+
+			$class = $class ? '' : " class='alternate'";
+
+			if ( $post->ID != $revision->ID && $can_edit_post )
+				$actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'action' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>';
+			else
+				$actions = '';
+
+			$rows .= "<tr$class>\n";
+			$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /></th>\n";
+			$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n";
+			$rows .= "\t<td>$date</td>\n";
+			$rows .= "\t<td>$name</td>\n";
+			$rows .= "\t<td class='action-links'>$actions</td>\n";
+			$rows .= "</tr>\n";
+		} else {
+			$title = sprintf( $titlef, $date, $name );
+			$rows .= "\t<li>$title</li>\n";
+		}
+	}
+
+	if ( 'form-table' == $format ) : ?>
+
+<form action="revision.php" method="get">
+
+<div class="tablenav">
+	<div class="alignleft">
+		<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Compare Revisions' ); ?>" />
+		<input type="hidden" name="action" value="diff" />
+		<input type="hidden" name="post_type" value="<?php echo esc_attr($post->post_type); ?>" />
+	</div>
+</div>
+
+<br class="clear" />
+
+<table class="widefat post-revisions" cellspacing="0" id="post-revisions">
+	<col />
+	<col />
+	<col style="width: 33%" />
+	<col style="width: 33%" />
+	<col style="width: 33%" />
+<thead>
+<tr>
+	<th scope="col"><?php /* translators: column name in revisons */ _ex( 'Old', 'revisions column name' ); ?></th>
+	<th scope="col"><?php /* translators: column name in revisons */ _ex( 'New', 'revisions column name' ); ?></th>
+	<th scope="col"><?php /* translators: column name in revisons */ _ex( 'Date Created', 'revisions column name' ); ?></th>
+	<th scope="col"><?php _e( 'Author' ); ?></th>
+	<th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th>
+</tr>
+</thead>
+<tbody>
+
+<?php echo $rows; ?>
+
+</tbody>
+</table>
+
+</form>
+
+<?php
+	else :
+		echo "<ul class='post-revisions'>\n";
+		echo $rows;
+		echo "</ul>";
+	endif;
+
+}
Index: /tags/3.1/wp-includes/post-thumbnail-template.php
===================================================================
--- /tags/3.1/wp-includes/post-thumbnail-template.php	(revision 17487)
+++ /tags/3.1/wp-includes/post-thumbnail-template.php	(revision 17487)
@@ -0,0 +1,73 @@
+<?php
+/**
+ * WordPress Post Thumbnail Template Functions.
+ *
+ * Support for post thumbnails
+ * Themes function.php must call add_theme_support( 'post-thumbnails' ) to use these.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Check if post has an image attached.
+ *
+ * @since 2.9.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return bool Whether post has an image attached.
+ */
+function has_post_thumbnail( $post_id = null ) {
+	$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
+	return (bool) get_post_thumbnail_id( $post_id );
+}
+
+/**
+ * Retrieve Post Thumbnail ID.
+ *
+ * @since 2.9.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return int
+ */
+function get_post_thumbnail_id( $post_id = null ) {
+	$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
+	return get_post_meta( $post_id, '_thumbnail_id', true );
+}
+
+/**
+ * Display Post Thumbnail.
+ *
+ * @since 2.9.0
+ *
+ * @param int $size Optional. Image size.  Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );.
+ * @param string|array $attr Optional. Query string or array of attributes.
+ */
+function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) {
+	echo get_the_post_thumbnail( null, $size, $attr );
+}
+
+/**
+ * Retrieve Post Thumbnail.
+ *
+ * @since 2.9.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param string $size Optional. Image size.  Defaults to 'thumbnail'.
+ * @param string|array $attr Optional. Query string or array of attributes.
+ */
+function get_the_post_thumbnail( $post_id = null, $size = 'post-thumbnail', $attr = '' ) {
+	$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
+	$post_thumbnail_id = get_post_thumbnail_id( $post_id );
+	$size = apply_filters( 'post_thumbnail_size', $size );
+	if ( $post_thumbnail_id ) {
+		do_action( 'begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
+		$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
+		do_action( 'end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size );
+	} else {
+		$html = '';
+	}
+	return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
+}
+
+?>
Index: /tags/3.1/wp-includes/post.php
===================================================================
--- /tags/3.1/wp-includes/post.php	(revision 17487)
+++ /tags/3.1/wp-includes/post.php	(revision 17487)
@@ -0,0 +1,5239 @@
+<?php
+/**
+ * Post functions and post utility function.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 1.5.0
+ */
+
+//
+// Post Type Registration
+//
+
+/**
+ * Creates the initial post types when 'init' action is fired.
+ *
+ * @since 2.9.0
+ */
+function create_initial_post_types() {
+	register_post_type( 'post', array(
+		'public'  => true,
+		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
+		'_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
+		'capability_type' => 'post',
+		'map_meta_cap' => true,
+		'hierarchical' => false,
+		'rewrite' => false,
+		'query_var' => false,
+		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
+	) );
+
+	register_post_type( 'page', array(
+		'public' => true,
+		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
+		'_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
+		'capability_type' => 'page',
+		'map_meta_cap' => true,
+		'hierarchical' => true,
+		'rewrite' => false,
+		'query_var' => false,
+		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
+	) );
+
+	register_post_type( 'attachment', array(
+		'labels' => array(
+			'name' => __( 'Media' ),
+		),
+		'public' => true,
+		'show_ui' => false,
+		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
+		'_edit_link' => 'media.php?attachment_id=%d', /* internal use only. don't use this when registering your own post type. */
+		'capability_type' => 'post',
+		'map_meta_cap' => true,
+		'hierarchical' => false,
+		'rewrite' => false,
+		'query_var' => false,
+		'show_in_nav_menus' => false,
+	) );
+
+	register_post_type( 'revision', array(
+		'labels' => array(
+			'name' => __( 'Revisions' ),
+			'singular_name' => __( 'Revision' ),
+		),
+		'public' => false,
+		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
+		'_edit_link' => 'revision.php?revision=%d', /* internal use only. don't use this when registering your own post type. */
+		'capability_type' => 'post',
+		'map_meta_cap' => true,
+		'hierarchical' => false,
+		'rewrite' => false,
+		'query_var' => false,
+		'can_export' => false,
+	) );
+
+	register_post_type( 'nav_menu_item', array(
+		'labels' => array(
+			'name' => __( 'Navigation Menu Items' ),
+			'singular_name' => __( 'Navigation Menu Item' ),
+		),
+		'public' => false,
+		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
+		'hierarchical' => false,
+		'rewrite' => false,
+		'query_var' => false,
+	) );
+
+	register_post_status( 'publish', array(
+		'label'       => _x( 'Published', 'post' ),
+		'public'      => true,
+		'_builtin'    => true, /* internal use only. */
+		'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),
+	) );
+
+	register_post_status( 'future', array(
+		'label'       => _x( 'Scheduled', 'post' ),
+		'protected'   => true,
+		'_builtin'    => true, /* internal use only. */
+		'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),
+	) );
+
+	register_post_status( 'draft', array(
+		'label'       => _x( 'Draft', 'post' ),
+		'protected'   => true,
+		'_builtin'    => true, /* internal use only. */
+		'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),
+	) );
+
+	register_post_status( 'pending', array(
+		'label'       => _x( 'Pending', 'post' ),
+		'protected'   => true,
+		'_builtin'    => true, /* internal use only. */
+		'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),
+	) );
+
+	register_post_status( 'private', array(
+		'label'       => _x( 'Private', 'post' ),
+		'private'     => true,
+		'_builtin'    => true, /* internal use only. */
+		'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),
+	) );
+
+	register_post_status( 'trash', array(
+		'label'       => _x( 'Trash', 'post' ),
+		'internal'    => true,
+		'_builtin'    => true, /* internal use only. */
+		'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),
+		'show_in_admin_status_list' => true,
+	) );
+
+	register_post_status( 'auto-draft', array(
+		'label'    => 'auto-draft',
+		'internal' => true,
+		'_builtin' => true, /* internal use only. */
+	) );
+
+	register_post_status( 'inherit', array(
+		'label'    => 'inherit',
+		'internal' => true,
+		'_builtin' => true, /* internal use only. */
+		'exclude_from_search' => false,
+	) );
+}
+add_action( 'init', 'create_initial_post_types', 0 ); // highest priority
+
+/**
+ * Retrieve attached file path based on attachment ID.
+ *
+ * You can optionally send it through the 'get_attached_file' filter, but by
+ * default it will just return the file path unfiltered.
+ *
+ * The function works by getting the single post meta name, named
+ * '_wp_attached_file' and returning it. This is a convenience function to
+ * prevent looking up the meta name and provide a mechanism for sending the
+ * attached filename through a filter.
+ *
+ * @since 2.0.0
+ * @uses apply_filters() Calls 'get_attached_file' on file path and attachment ID.
+ *
+ * @param int $attachment_id Attachment ID.
+ * @param bool $unfiltered Whether to apply filters.
+ * @return string The file path to the attached file.
+ */
+function get_attached_file( $attachment_id, $unfiltered = false ) {
+	$file = get_post_meta( $attachment_id, '_wp_attached_file', true );
+	// If the file is relative, prepend upload dir
+	if ( 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) )
+		$file = $uploads['basedir'] . "/$file";
+	if ( $unfiltered )
+		return $file;
+	return apply_filters( 'get_attached_file', $file, $attachment_id );
+}
+
+/**
+ * Update attachment file path based on attachment ID.
+ *
+ * Used to update the file path of the attachment, which uses post meta name
+ * '_wp_attached_file' to store the path of the attachment.
+ *
+ * @since 2.1.0
+ * @uses apply_filters() Calls 'update_attached_file' on file path and attachment ID.
+ *
+ * @param int $attachment_id Attachment ID
+ * @param string $file File path for the attachment
+ * @return bool False on failure, true on success.
+ */
+function update_attached_file( $attachment_id, $file ) {
+	if ( !get_post( $attachment_id ) )
+		return false;
+
+	$file = apply_filters( 'update_attached_file', $file, $attachment_id );
+	$file = _wp_relative_upload_path($file);
+
+	return update_post_meta( $attachment_id, '_wp_attached_file', $file );
+}
+
+/**
+ * Return relative path to an uploaded file.
+ *
+ * The path is relative to the current upload dir.
+ *
+ * @since 2.9.0
+ * @uses apply_filters() Calls '_wp_relative_upload_path' on file path.
+ *
+ * @param string $path Full path to the file
+ * @return string relative path on success, unchanged path on failure.
+ */
+function _wp_relative_upload_path( $path ) {
+	$new_path = $path;
+
+	if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) {
+		if ( 0 === strpos($new_path, $uploads['basedir']) ) {
+				$new_path = str_replace($uploads['basedir'], '', $new_path);
+				$new_path = ltrim($new_path, '/');
+		}
+	}
+
+	return apply_filters( '_wp_relative_upload_path', $new_path, $path );
+}
+
+/**
+ * Retrieve all children of the post parent ID.
+ *
+ * Normally, without any enhancements, the children would apply to pages. In the
+ * context of the inner workings of WordPress, pages, posts, and attachments
+ * share the same table, so therefore the functionality could apply to any one
+ * of them. It is then noted that while this function does not work on posts, it
+ * does not mean that it won't work on posts. It is recommended that you know
+ * what context you wish to retrieve the children of.
+ *
+ * Attachments may also be made the child of a post, so if that is an accurate
+ * statement (which needs to be verified), it would then be possible to get
+ * all of the attachments for a post. Attachments have since changed since
+ * version 2.5, so this is most likely unaccurate, but serves generally as an
+ * example of what is possible.
+ *
+ * The arguments listed as defaults are for this function and also of the
+ * {@link get_posts()} function. The arguments are combined with the
+ * get_children defaults and are then passed to the {@link get_posts()}
+ * function, which accepts additional arguments. You can replace the defaults in
+ * this function, listed below and the additional arguments listed in the
+ * {@link get_posts()} function.
+ *
+ * The 'post_parent' is the most important argument and important attention
+ * needs to be paid to the $args parameter. If you pass either an object or an
+ * integer (number), then just the 'post_parent' is grabbed and everything else
+ * is lost. If you don't specify any arguments, then it is assumed that you are
+ * in The Loop and the post parent will be grabbed for from the current post.
+ *
+ * The 'post_parent' argument is the ID to get the children. The 'numberposts'
+ * is the amount of posts to retrieve that has a default of '-1', which is
+ * used to get all of the posts. Giving a number higher than 0 will only
+ * retrieve that amount of posts.
+ *
+ * The 'post_type' and 'post_status' arguments can be used to choose what
+ * criteria of posts to retrieve. The 'post_type' can be anything, but WordPress
+ * post types are 'post', 'pages', and 'attachments'. The 'post_status'
+ * argument will accept any post status within the write administration panels.
+ *
+ * @see get_posts() Has additional arguments that can be replaced.
+ * @internal Claims made in the long description might be inaccurate.
+ *
+ * @since 2.0.0
+ *
+ * @param mixed $args Optional. User defined arguments for replacing the defaults.
+ * @param string $output Optional. Constant for return type, either OBJECT (default), ARRAY_A, ARRAY_N.
+ * @return array|bool False on failure and the type will be determined by $output parameter.
+ */
+function get_children($args = '', $output = OBJECT) {
+	$kids = array();
+	if ( empty( $args ) ) {
+		if ( isset( $GLOBALS['post'] ) ) {
+			$args = array('post_parent' => (int) $GLOBALS['post']->post_parent );
+		} else {
+			return $kids;
+		}
+	} elseif ( is_object( $args ) ) {
+		$args = array('post_parent' => (int) $args->post_parent );
+	} elseif ( is_numeric( $args ) ) {
+		$args = array('post_parent' => (int) $args);
+	}
+
+	$defaults = array(
+		'numberposts' => -1, 'post_type' => 'any',
+		'post_status' => 'any', 'post_parent' => 0,
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+
+	$children = get_posts( $r );
+
+	if ( !$children )
+		return $kids;
+
+	update_post_cache($children);
+
+	foreach ( $children as $key => $child )
+		$kids[$child->ID] = $children[$key];
+
+	if ( $output == OBJECT ) {
+		return $kids;
+	} elseif ( $output == ARRAY_A ) {
+		foreach ( (array) $kids as $kid )
+			$weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
+		return $weeuns;
+	} elseif ( $output == ARRAY_N ) {
+		foreach ( (array) $kids as $kid )
+			$babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
+		return $babes;
+	} else {
+		return $kids;
+	}
+}
+
+/**
+ * Get extended entry info (<!--more-->).
+ *
+ * There should not be any space after the second dash and before the word
+ * 'more'. There can be text or space(s) after the word 'more', but won't be
+ * referenced.
+ *
+ * The returned array has 'main' and 'extended' keys. Main has the text before
+ * the <code><!--more--></code>. The 'extended' key has the content after the
+ * <code><!--more--></code> comment.
+ *
+ * @since 1.0.0
+ *
+ * @param string $post Post content.
+ * @return array Post before ('main') and after ('extended').
+ */
+function get_extended($post) {
+	//Match the new style more links
+	if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) {
+		list($main, $extended) = explode($matches[0], $post, 2);
+	} else {
+		$main = $post;
+		$extended = '';
+	}
+
+	// Strip leading and trailing whitespace
+	$main = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $main);
+	$extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended);
+
+	return array('main' => $main, 'extended' => $extended);
+}
+
+/**
+ * Retrieves post data given a post ID or post object.
+ *
+ * See {@link sanitize_post()} for optional $filter values. Also, the parameter
+ * $post, must be given as a variable, since it is passed by reference.
+ *
+ * @since 1.5.1
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/get_post
+ *
+ * @param int|object $post Post ID or post object.
+ * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N.
+ * @param string $filter Optional, default is raw.
+ * @return mixed Post data
+ */
+function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
+	global $wpdb;
+	$null = null;
+
+	if ( empty($post) ) {
+		if ( isset($GLOBALS['post']) )
+			$_post = & $GLOBALS['post'];
+		else
+			return $null;
+	} elseif ( is_object($post) && empty($post->filter) ) {
+		_get_post_ancestors($post);
+		$_post = sanitize_post($post, 'raw');
+		wp_cache_add($post->ID, $_post, 'posts');
+	} else {
+		if ( is_object($post) )
+			$post_id = $post->ID;
+		else
+			$post_id = $post;
+
+		$post_id = (int) $post_id;
+		if ( ! $_post = wp_cache_get($post_id, 'posts') ) {
+			$_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id));
+			if ( ! $_post )
+				return $null;
+			_get_post_ancestors($_post);
+			$_post = sanitize_post($_post, 'raw');
+			wp_cache_add($_post->ID, $_post, 'posts');
+		}
+	}
+
+	if ($filter != 'raw')
+		$_post = sanitize_post($_post, $filter);
+
+	if ( $output == OBJECT ) {
+		return $_post;
+	} elseif ( $output == ARRAY_A ) {
+		$__post = get_object_vars($_post);
+		return $__post;
+	} elseif ( $output == ARRAY_N ) {
+		$__post = array_values(get_object_vars($_post));
+		return $__post;
+	} else {
+		return $_post;
+	}
+}
+
+/**
+ * Retrieve ancestors of a post.
+ *
+ * @since 2.5.0
+ *
+ * @param int|object $post Post ID or post object
+ * @return array Ancestor IDs or empty array if none are found.
+ */
+function get_post_ancestors($post) {
+	$post = get_post($post);
+
+	if ( !empty($post->ancestors) )
+		return $post->ancestors;
+
+	return array();
+}
+
+/**
+ * Retrieve data from a post field based on Post ID.
+ *
+ * Examples of the post field will be, 'post_type', 'post_status', 'content',
+ * etc and based off of the post object property or key names.
+ *
+ * The context values are based off of the taxonomy filter functions and
+ * supported values are found within those functions.
+ *
+ * @since 2.3.0
+ * @uses sanitize_post_field() See for possible $context values.
+ *
+ * @param string $field Post field name
+ * @param id $post Post ID
+ * @param string $context Optional. How to filter the field. Default is display.
+ * @return WP_Error|string Value in post field or WP_Error on failure
+ */
+function get_post_field( $field, $post, $context = 'display' ) {
+	$post = (int) $post;
+	$post = get_post( $post );
+
+	if ( is_wp_error($post) )
+		return $post;
+
+	if ( !is_object($post) )
+		return '';
+
+	if ( !isset($post->$field) )
+		return '';
+
+	return sanitize_post_field($field, $post->$field, $post->ID, $context);
+}
+
+/**
+ * Retrieve the mime type of an attachment based on the ID.
+ *
+ * This function can be used with any post type, but it makes more sense with
+ * attachments.
+ *
+ * @since 2.0.0
+ *
+ * @param int $ID Optional. Post ID.
+ * @return bool|string False on failure or returns the mime type
+ */
+function get_post_mime_type($ID = '') {
+	$post = & get_post($ID);
+
+	if ( is_object($post) )
+		return $post->post_mime_type;
+
+	return false;
+}
+
+/**
+ * Retrieve the format slug for a post
+ *
+ * @since 3.1.0
+ *
+ * @param int|object $post A post
+ *
+ * @return mixed The format if successful. False if no format is set.  WP_Error if errors.
+ */
+function get_post_format( $post = null ) {
+	$post = get_post($post);
+
+	if ( ! post_type_supports( $post->post_type, 'post-formats' ) )
+		return false;
+
+	$_format = get_the_terms( $post->ID, 'post_format' );
+
+	if ( empty( $_format ) )
+		return false;
+
+	$format = array_shift( $_format );
+
+	return ( str_replace('post-format-', '', $format->slug ) );
+}
+
+/**
+ * Check if a post has a particular format
+ *
+ * @since 3.1.0
+ * @uses has_term()
+ *
+ * @param string $format The format to check for
+ * @param object|id $post The post to check. If not supplied, defaults to the current post if used in the loop.
+ * @return bool True if the post has the format, false otherwise.
+ */
+function has_post_format( $format, $post = null ) {
+	return has_term('post-format-' . sanitize_key($format), 'post_format', $post);
+}
+
+/**
+ * Assign a format to a post
+ *
+ * @since 3.1.0
+ *
+ * @param int|object $post The post for which to assign a format
+ * @param string $format  A format to assign.  Use an empty string or array to remove all formats from the post.
+ * @return mixed WP_Error on error. Array of affected term IDs on success.
+ */
+function set_post_format( $post, $format ) {
+	$post = get_post($post);
+
+	if ( empty($post) )
+		return new WP_Error('invalid_post', __('Invalid post'));
+
+	if ( !empty($format) ) {
+		$format = sanitize_key($format);
+		if ( 'standard' == $format || !in_array( $format, array_keys( get_post_format_slugs() ) ) )
+			$format = '';
+		else
+			$format = 'post-format-' . $format;
+	}
+
+	return wp_set_post_terms($post->ID, $format, 'post_format');
+}
+
+/**
+ * Retrieve the post status based on the Post ID.
+ *
+ * If the post ID is of an attachment, then the parent post status will be given
+ * instead.
+ *
+ * @since 2.0.0
+ *
+ * @param int $ID Post ID
+ * @return string|bool Post status or false on failure.
+ */
+function get_post_status($ID = '') {
+	$post = get_post($ID);
+
+	if ( !is_object($post) )
+		return false;
+
+	// Unattached attachments are assumed to be published.
+	if ( ('attachment' == $post->post_type) && ('inherit' == $post->post_status) && ( 0 == $post->post_parent) )
+		return 'publish';
+
+	if ( ('attachment' == $post->post_type) && $post->post_parent && ($post->ID != $post->post_parent) )
+		return get_post_status($post->post_parent);
+
+	return $post->post_status;
+}
+
+/**
+ * Retrieve all of the WordPress supported post statuses.
+ *
+ * Posts have a limited set of valid status values, this provides the
+ * post_status values and descriptions.
+ *
+ * @since 2.5.0
+ *
+ * @return array List of post statuses.
+ */
+function get_post_statuses( ) {
+	$status = array(
+		'draft'			=> __('Draft'),
+		'pending'		=> __('Pending Review'),
+		'private'		=> __('Private'),
+		'publish'		=> __('Published')
+	);
+
+	return $status;
+}
+
+/**
+ * Retrieve all of the WordPress support page statuses.
+ *
+ * Pages have a limited set of valid status values, this provides the
+ * post_status values and descriptions.
+ *
+ * @since 2.5.0
+ *
+ * @return array List of page statuses.
+ */
+function get_page_statuses( ) {
+	$status = array(
+		'draft'			=> __('Draft'),
+		'private'		=> __('Private'),
+		'publish'		=> __('Published')
+	);
+
+	return $status;
+}
+
+/**
+ * Register a post type. Do not use before init.
+ *
+ * A simple function for creating or modifying a post status based on the
+ * parameters given. The function will accept an array (second optional
+ * parameter), along with a string for the post status name.
+ *
+ *
+ * Optional $args contents:
+ *
+ * label - A descriptive name for the post status marked for translation. Defaults to $post_status.
+ * public - Whether posts of this status should be shown in the front end of the site. Defaults to true.
+ * exclude_from_search - Whether to exclude posts with this post status from search results. Defaults to true.
+ * show_in_admin_all_list - Whether to include posts in the edit listing for their post type
+ * show_in_admin_status_list - Show in the list of statuses with post counts at the top of the edit
+ *                             listings, e.g. All (12) | Published (9) | My Custom Status (2) ...
+ *
+ * Arguments prefixed with an _underscore shouldn't be used by plugins and themes.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 3.0.0
+ * @uses $wp_post_statuses Inserts new post status object into the list
+ *
+ * @param string $post_status Name of the post status.
+ * @param array|string $args See above description.
+ */
+function register_post_status($post_status, $args = array()) {
+	global $wp_post_statuses;
+
+	if (!is_array($wp_post_statuses))
+		$wp_post_statuses = array();
+
+	// Args prefixed with an underscore are reserved for internal use.
+	$defaults = array('label' => false, 'label_count' => false, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => null, 'internal' => null, 'protected' => null, 'private' => null, 'show_in_admin_all' => null, 'publicly_queryable' => null, 'show_in_admin_status_list' => null, 'show_in_admin_all_list' => null, 'single_view_cap' => null);
+	$args = wp_parse_args($args, $defaults);
+	$args = (object) $args;
+
+	$post_status = sanitize_key($post_status);
+	$args->name = $post_status;
+
+	if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private )
+		$args->internal = true;
+
+	if ( null === $args->public  )
+		$args->public = false;
+
+	if ( null === $args->private  )
+		$args->private = false;
+
+	if ( null === $args->protected  )
+		$args->protected = false;
+
+	if ( null === $args->internal  )
+		$args->internal = false;
+
+	if ( null === $args->publicly_queryable )
+		$args->publicly_queryable = $args->public;
+
+	if ( null === $args->exclude_from_search )
+		$args->exclude_from_search = $args->internal;
+
+	if ( null === $args->show_in_admin_all_list )
+		$args->show_in_admin_all_list = !$args->internal;
+
+	if ( null === $args->show_in_admin_status_list )
+			$args->show_in_admin_status_list = !$args->internal;
+
+	if ( null === $args->single_view_cap )
+		$args->single_view_cap = $args->public ? '' : 'edit';
+
+	if ( false === $args->label )
+		$args->label = $post_status;
+
+	if ( false === $args->label_count )
+		$args->label_count = array( $args->label, $args->label );
+
+	$wp_post_statuses[$post_status] = $args;
+
+	return $args;
+}
+
+/**
+ * Retrieve a post status object by name
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 3.0.0
+ * @uses $wp_post_statuses
+ * @see register_post_status
+ * @see get_post_statuses
+ *
+ * @param string $post_status The name of a registered post status
+ * @return object A post status object
+ */
+function get_post_status_object( $post_status ) {
+	global $wp_post_statuses;
+
+	if ( empty($wp_post_statuses[$post_status]) )
+		return null;
+
+	return $wp_post_statuses[$post_status];
+}
+
+/**
+ * Get a list of all registered post status objects.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 3.0.0
+ * @uses $wp_post_statuses
+ * @see register_post_status
+ * @see get_post_status_object
+ *
+ * @param array|string $args An array of key => value arguments to match against the post status objects.
+ * @param string $output The type of output to return, either post status 'names' or 'objects'. 'names' is the default.
+ * @param string $operator The logical operation to perform. 'or' means only one element
+ *  from the array needs to match; 'and' means all elements must match. The default is 'and'.
+ * @return array A list of post type names or objects
+ */
+function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) {
+	global $wp_post_statuses;
+
+	$field = ('names' == $output) ? 'name' : false;
+
+	return wp_filter_object_list($wp_post_statuses, $args, $operator, $field);
+}
+
+/**
+ * Whether the post type is hierarchical.
+ *
+ * A false return value might also mean that the post type does not exist.
+ *
+ * @since 3.0.0
+ * @see get_post_type_object
+ *
+ * @param string $post_type Post type name
+ * @return bool Whether post type is hierarchical.
+ */
+function is_post_type_hierarchical( $post_type ) {
+	if ( ! post_type_exists( $post_type ) )
+		return false;
+
+	$post_type = get_post_type_object( $post_type );
+	return $post_type->hierarchical;
+}
+
+/**
+ * Checks if a post type is registered.
+ *
+ * @since 3.0.0
+ * @uses get_post_type_object()
+ *
+ * @param string $post_type Post type name
+ * @return bool Whether post type is registered.
+ */
+function post_type_exists( $post_type ) {
+	return (bool) get_post_type_object( $post_type );
+}
+
+/**
+ * Retrieve the post type of the current post or of a given post.
+ *
+ * @since 2.1.0
+ *
+ * @uses $post The Loop current post global
+ *
+ * @param mixed $the_post Optional. Post object or post ID.
+ * @return bool|string post type or false on failure.
+ */
+function get_post_type( $the_post = false ) {
+	global $post;
+
+	if ( false === $the_post )
+		$the_post = $post;
+	elseif ( is_numeric($the_post) )
+		$the_post = get_post($the_post);
+
+	if ( is_object($the_post) )
+		return $the_post->post_type;
+
+	return false;
+}
+
+/**
+ * Retrieve a post type object by name
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 3.0.0
+ * @uses $wp_post_types
+ * @see register_post_type
+ * @see get_post_types
+ *
+ * @param string $post_type The name of a registered post type
+ * @return object A post type object
+ */
+function get_post_type_object( $post_type ) {
+	global $wp_post_types;
+
+	if ( empty($wp_post_types[$post_type]) )
+		return null;
+
+	return $wp_post_types[$post_type];
+}
+
+/**
+ * Get a list of all registered post type objects.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 2.9.0
+ * @uses $wp_post_types
+ * @see register_post_type
+ *
+ * @param array|string $args An array of key => value arguments to match against the post type objects.
+ * @param string $output The type of output to return, either post type 'names' or 'objects'. 'names' is the default.
+ * @param string $operator The logical operation to perform. 'or' means only one element
+ *  from the array needs to match; 'and' means all elements must match. The default is 'and'.
+ * @return array A list of post type names or objects
+ */
+function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) {
+	global $wp_post_types;
+
+	$field = ('names' == $output) ? 'name' : false;
+
+	return wp_filter_object_list($wp_post_types, $args, $operator, $field);
+}
+
+/**
+ * Register a post type. Do not use before init.
+ *
+ * A function for creating or modifying a post type based on the
+ * parameters given. The function will accept an array (second optional
+ * parameter), along with a string for the post type name.
+ *
+ * Optional $args contents:
+ *
+ * - label - Name of the post type shown in the menu. Usually plural. If not set, labels['name'] will be used.
+ * - description - A short descriptive summary of what the post type is. Defaults to blank.
+ * - public - Whether posts of this type should be shown in the admin UI. Defaults to false.
+ * - exclude_from_search - Whether to exclude posts with this post type from search results.
+ *     Defaults to true if the type is not public, false if the type is public.
+ * - publicly_queryable - Whether post_type queries can be performed from the front page.
+ *     Defaults to whatever public is set as.
+ * - show_ui - Whether to generate a default UI for managing this post type. Defaults to true
+ *     if the type is public, false if the type is not public.
+ * - show_in_menu - Where to show the post type in the admin menu. True for a top level menu,
+ *     false for no menu, or can be a top level page like 'tools.php' or 'edit.php?post_type=page'.
+ *     show_ui must be true.
+ * - menu_position - The position in the menu order the post type should appear. Defaults to the bottom.
+ * - menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon.
+ * - capability_type - The string to use to build the read, edit, and delete capabilities. Defaults to 'post'.
+ *   May be passed as an array to allow for alternative plurals when using this argument as a base to construct the
+ *   capabilities, e.g. array('story', 'stories').
+ * - capabilities - Array of capabilities for this post type. By default the capability_type is used
+ *      as a base to construct capabilities. You can see accepted values in {@link get_post_type_capabilities()}.
+ * - map_meta_cap - Whether to use the internal default meta capability handling. Defaults to false.
+ * - hierarchical - Whether the post type is hierarchical. Defaults to false.
+ * - supports - An alias for calling add_post_type_support() directly. See {@link add_post_type_support()}
+ *     for documentation. Defaults to none.
+ * - register_meta_box_cb - Provide a callback function that will be called when setting up the
+ *     meta boxes for the edit form.  Do remove_meta_box() and add_meta_box() calls in the callback.
+ * - taxonomies - An array of taxonomy identifiers that will be registered for the post type.
+ *     Default is no taxonomies. Taxonomies can be registered later with register_taxonomy() or
+ *     register_taxonomy_for_object_type().
+ * - labels - An array of labels for this post type. By default post labels are used for non-hierarchical
+ *     types and page labels for hierarchical ones. You can see accepted values in {@link get_post_type_labels()}.
+ * - permalink_epmask - The default rewrite endpoint bitmasks.
+ * - has_archive - True to enable post type archives. Will generate the proper rewrite rules if rewrite is enabled.
+ * - rewrite - false to prevent rewrite. Defaults to true. Use array('slug'=>$slug) to customize permastruct;
+ *     default will use $post_type as slug. Other options include 'with_front', 'feeds', and 'pages'.
+ * - query_var - false to prevent queries, or string to value of the query var to use for this post type
+ * - can_export - true allows this post type to be exported.
+ * - show_in_nav_menus - true makes this post type available for selection in navigation menus.
+ * - _builtin - true if this post type is a native or "built-in" post_type. THIS IS FOR INTERNAL USE ONLY!
+ * - _edit_link - URL segement to use for edit link of this post type. THIS IS FOR INTERNAL USE ONLY!
+ *
+ * @since 2.9.0
+ * @uses $wp_post_types Inserts new post type object into the list
+ *
+ * @param string $post_type Name of the post type.
+ * @param array|string $args See above description.
+ * @return object|WP_Error the registered post type object, or an error object
+ */
+function register_post_type($post_type, $args = array()) {
+	global $wp_post_types, $wp_rewrite, $wp;
+
+	if ( !is_array($wp_post_types) )
+		$wp_post_types = array();
+
+	// Args prefixed with an underscore are reserved for internal use.
+	$defaults = array(
+		'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null,
+		'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => null,
+		'_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false,
+		'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true,
+		'supports' => array(), 'register_meta_box_cb' => null,
+		'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null,
+		'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 'show_in_nav_menus' => null, 'show_in_menu' => null,
+	);
+	$args = wp_parse_args($args, $defaults);
+	$args = (object) $args;
+
+	$post_type = sanitize_key($post_type);
+	$args->name = $post_type;
+
+	if ( strlen( $post_type ) > 20 )
+			return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) );
+
+	// If not set, default to the setting for public.
+	if ( null === $args->publicly_queryable )
+		$args->publicly_queryable = $args->public;
+
+	// If not set, default to the setting for public.
+	if ( null === $args->show_ui )
+		$args->show_ui = $args->public;
+
+	// If not set, default to the setting for show_ui.
+	if ( null === $args->show_in_menu || ! $args->show_ui )
+		$args->show_in_menu = $args->show_ui;
+
+	// Whether to show this type in nav-menus.php.  Defaults to the setting for public.
+	if ( null === $args->show_in_nav_menus )
+		$args->show_in_nav_menus = $args->public;
+
+	// If not set, default to true if not public, false if public.
+	if ( null === $args->exclude_from_search )
+		$args->exclude_from_search = !$args->public;
+
+	// Back compat with quirky handling in version 3.0. #14122
+	if ( empty( $args->capabilities ) && null === $args->map_meta_cap && in_array( $args->capability_type, array( 'post', 'page' ) ) )
+		$args->map_meta_cap = true;
+
+	if ( null === $args->map_meta_cap )
+		$args->map_meta_cap = false;
+
+	$args->cap = get_post_type_capabilities( $args );
+	unset($args->capabilities);
+
+	if ( is_array( $args->capability_type ) )
+		$args->capability_type = $args->capability_type[0];
+
+	if ( ! empty($args->supports) ) {
+		add_post_type_support($post_type, $args->supports);
+		unset($args->supports);
+	} else {
+		// Add default features
+		add_post_type_support($post_type, array('title', 'editor'));
+	}
+
+	if ( false !== $args->query_var && !empty($wp) ) {
+		if ( true === $args->query_var )
+			$args->query_var = $post_type;
+		$args->query_var = sanitize_title_with_dashes($args->query_var);
+		$wp->add_query_var($args->query_var);
+	}
+
+	if ( false !== $args->rewrite && '' != get_option('permalink_structure') ) {
+		if ( ! is_array( $args->rewrite ) )
+			$args->rewrite = array();
+		if ( empty( $args->rewrite['slug'] ) )
+			$args->rewrite['slug'] = $post_type;
+		if ( ! isset( $args->rewrite['with_front'] ) )
+			$args->rewrite['with_front'] = true;
+		if ( ! isset( $args->rewrite['pages'] ) )
+			$args->rewrite['pages'] = true;
+		if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )
+			$args->rewrite['feeds'] = (bool) $args->has_archive;
+
+		if ( $args->hierarchical )
+			$wp_rewrite->add_rewrite_tag("%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
+		else
+			$wp_rewrite->add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
+
+		if ( $args->has_archive ) {
+			$archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
+			$wp_rewrite->add_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );
+			if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
+				$feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
+				$wp_rewrite->add_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
+				$wp_rewrite->add_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
+			}
+			if ( $args->rewrite['pages'] )
+				$wp_rewrite->add_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
+		}
+
+		$wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask);
+	}
+
+	if ( $args->register_meta_box_cb )
+		add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
+
+	$args->labels = get_post_type_labels( $args );
+	$args->label = $args->labels->name;
+
+	$wp_post_types[$post_type] = $args;
+
+	add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 );
+
+	foreach ( $args->taxonomies as $taxonomy ) {
+		register_taxonomy_for_object_type( $taxonomy, $post_type );
+	}
+
+	return $args;
+}
+
+/**
+ * Builds an object with all post type capabilities out of a post type object
+ *
+ * Post type capabilities use the 'capability_type' argument as a base, if the
+ * capability is not set in the 'capabilities' argument array or if the
+ * 'capabilities' argument is not supplied.
+ *
+ * The capability_type argument can optionally be registered as an array, with
+ * the first value being singular and the second plural, e.g. array('story, 'stories')
+ * Otherwise, an 's' will be added to the value for the plural form. After
+ * registration, capability_type will always be a string of the singular value.
+ *
+ * By default, seven keys are accepted as part of the capabilities array:
+ *
+ * - edit_post, read_post, and delete_post are meta capabilities, which are then
+ *   generally mapped to corresponding primitive capabilities depending on the
+ *   context, which would be the post being edited/read/deleted and the user or
+ *   role being checked. Thus these capabilities would generally not be granted
+ *   directly to users or roles.
+ *
+ * - edit_posts - Controls whether objects of this post type can be edited.
+ * - edit_others_posts - Controls whether objects of this type owned by other users
+ *   can be edited. If the post type does not support an author, then this will
+ *   behave like edit_posts.
+ * - publish_posts - Controls publishing objects of this post type.
+ * - read_private_posts - Controls whether private objects can be read.
+
+ * These four primitive capabilities are checked in core in various locations.
+ * There are also seven other primitive capabilities which are not referenced
+ * directly in core, except in map_meta_cap(), which takes the three aforementioned
+ * meta capabilities and translates them into one or more primitive capabilities
+ * that must then be checked against the user or role, depending on the context.
+ *
+ * - read - Controls whether objects of this post type can be read.
+ * - delete_posts - Controls whether objects of this post type can be deleted.
+ * - delete_private_posts - Controls whether private objects can be deleted.
+ * - delete_published_posts - Controls whether published objects can be deleted.
+ * - delete_others_posts - Controls whether objects owned by other users can be
+ *   can be deleted. If the post type does not support an author, then this will
+ *   behave like delete_posts.
+ * - edit_private_posts - Controls whether private objects can be edited.
+ * - edit_published_posts - Controls whether published objects can be deleted.
+ *
+ * These additional capabilities are only used in map_meta_cap(). Thus, they are
+ * only assigned by default if the post type is registered with the 'map_meta_cap'
+ * argument set to true (default is false).
+ *
+ * @see map_meta_cap()
+ * @since 3.0.0
+ *
+ * @param object $args Post type registration arguments
+ * @return object object with all the capabilities as member variables
+ */
+function get_post_type_capabilities( $args ) {
+	if ( ! is_array( $args->capability_type ) )
+		$args->capability_type = array( $args->capability_type, $args->capability_type . 's' );
+
+	// Singular base for meta capabilities, plural base for primitive capabilities.
+	list( $singular_base, $plural_base ) = $args->capability_type;
+
+	$default_capabilities = array(
+		// Meta capabilities
+		'edit_post'          => 'edit_'         . $singular_base,
+		'read_post'          => 'read_'         . $singular_base,
+		'delete_post'        => 'delete_'       . $singular_base,
+		// Primitive capabilities used outside of map_meta_cap():
+		'edit_posts'         => 'edit_'         . $plural_base,
+		'edit_others_posts'  => 'edit_others_'  . $plural_base,
+		'publish_posts'      => 'publish_'      . $plural_base,
+		'read_private_posts' => 'read_private_' . $plural_base,
+	);
+
+	// Primitive capabilities used within map_meta_cap():
+	if ( $args->map_meta_cap ) {
+		$default_capabilities_for_mapping = array(
+			'read'                   => 'read',
+			'delete_posts'           => 'delete_'           . $plural_base,
+			'delete_private_posts'   => 'delete_private_'   . $plural_base,
+			'delete_published_posts' => 'delete_published_' . $plural_base,
+			'delete_others_posts'    => 'delete_others_'    . $plural_base,
+			'edit_private_posts'     => 'edit_private_'     . $plural_base,
+			'edit_published_posts'   => 'edit_published_'   . $plural_base,
+		);
+		$default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
+	}
+
+	$capabilities = array_merge( $default_capabilities, $args->capabilities );
+
+	// Remember meta capabilities for future reference.
+	if ( $args->map_meta_cap )
+		_post_type_meta_capabilities( $capabilities );
+
+	return (object) $capabilities;
+}
+
+/**
+ * Stores or returns a list of post type meta caps for map_meta_cap().
+ *
+ * @since 3.1.0
+ * @access private
+ */
+function _post_type_meta_capabilities( $capabilities = null ) {
+	static $meta_caps = array();
+	if ( null === $capabilities )
+		return $meta_caps;
+	foreach ( $capabilities as $core => $custom ) {
+		if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) )
+			$meta_caps[ $custom ] = $core;
+	}
+}
+
+/**
+ * Builds an object with all post type labels out of a post type object
+ *
+ * Accepted keys of the label array in the post type object:
+ * - name - general name for the post type, usually plural. The same and overriden by $post_type_object->label. Default is Posts/Pages
+ * - singular_name - name for one object of this post type. Default is Post/Page
+ * - add_new - Default is Add New for both hierarchical and non-hierarchical types. When internationalizing this string, please use a {@link http://codex.wordpress.org/I18n_for_WordPress_Developers#Disambiguation_by_context gettext context} matching your post type. Example: <code>_x('Add New', 'product');</code>
+ * - add_new_item - Default is Add New Post/Add New Page
+ * - edit_item - Default is Edit Post/Edit Page
+ * - new_item - Default is New Post/New Page
+ * - view_item - Default is View Post/View Page
+ * - search_items - Default is Search Posts/Search Pages
+ * - not_found - Default is No posts found/No pages found
+ * - not_found_in_trash - Default is No posts found in Trash/No pages found in Trash
+ * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page:
+ *
+ * Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages).
+ *
+ * @since 3.0.0
+ * @param object $post_type_object
+ * @return object object with all the labels as member variables
+ */
+function get_post_type_labels( $post_type_object ) {
+	$nohier_vs_hier_defaults = array(
+		'name' => array( _x('Posts', 'post type general name'), _x('Pages', 'post type general name') ),
+		'singular_name' => array( _x('Post', 'post type singular name'), _x('Page', 'post type singular name') ),
+		'add_new' => array( _x('Add New', 'post'), _x('Add New', 'page') ),
+		'add_new_item' => array( __('Add New Post'), __('Add New Page') ),
+		'edit_item' => array( __('Edit Post'), __('Edit Page') ),
+		'new_item' => array( __('New Post'), __('New Page') ),
+		'view_item' => array( __('View Post'), __('View Page') ),
+		'search_items' => array( __('Search Posts'), __('Search Pages') ),
+		'not_found' => array( __('No posts found.'), __('No pages found.') ),
+		'not_found_in_trash' => array( __('No posts found in Trash.'), __('No pages found in Trash.') ),
+		'parent_item_colon' => array( null, __('Parent Page:') ),
+	);
+	$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
+	return _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
+}
+
+/**
+ * Builds an object with custom-something object (post type, taxonomy) labels out of a custom-something object
+ *
+ * @access private
+ * @since 3.0.0
+ */
+function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
+
+	if ( isset( $object->label ) && empty( $object->labels['name'] ) )
+		$object->labels['name'] = $object->label;
+
+	if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) )
+		$object->labels['singular_name'] = $object->labels['name'];
+
+	if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) )
+		$object->labels['menu_name'] = $object->labels['name'];
+
+	foreach ( $nohier_vs_hier_defaults as $key => $value )
+			$defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
+
+	$labels = array_merge( $defaults, $object->labels );
+	return (object)$labels;
+}
+
+/**
+ * Adds submenus for post types.
+ *
+ * @access private
+ * @since 3.1.0
+ */
+function _add_post_type_submenus() {
+	foreach ( get_post_types( array( 'show_ui' => true ) ) as $ptype ) {
+		$ptype_obj = get_post_type_object( $ptype );
+		// Submenus only.
+		if ( ! $ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true )
+			continue;
+		add_submenu_page( $ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->menu_name, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype" );
+	}
+}
+add_action( 'admin_menu', '_add_post_type_submenus' );
+
+/**
+ * Register support of certain features for a post type.
+ *
+ * All features are directly associated with a functional area of the edit screen, such as the
+ * editor or a meta box: 'title', 'editor', 'comments', 'revisions', 'trackbacks', 'author',
+ * 'excerpt', 'page-attributes', 'thumbnail', and 'custom-fields'.
+ *
+ * Additionally, the 'revisions' feature dictates whether the post type will store revisions,
+ * and the 'comments' feature dicates whether the comments count will show on the edit screen.
+ *
+ * @since 3.0.0
+ * @param string $post_type The post type for which to add the feature
+ * @param string|array $feature the feature being added, can be an array of feature strings or a single string
+ */
+function add_post_type_support( $post_type, $feature ) {
+	global $_wp_post_type_features;
+
+	$features = (array) $feature;
+	foreach ($features as $feature) {
+		if ( func_num_args() == 2 )
+			$_wp_post_type_features[$post_type][$feature] = true;
+		else
+			$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );
+	}
+}
+
+/**
+ * Remove support for a feature from a post type.
+ *
+ * @since 3.0.0
+ * @param string $post_type The post type for which to remove the feature
+ * @param string $feature The feature being removed
+ */
+function remove_post_type_support( $post_type, $feature ) {
+	global $_wp_post_type_features;
+
+	if ( !isset($_wp_post_type_features[$post_type]) )
+		return;
+
+	if ( isset($_wp_post_type_features[$post_type][$feature]) )
+		unset($_wp_post_type_features[$post_type][$feature]);
+}
+
+/**
+ * Checks a post type's support for a given feature
+ *
+ * @since 3.0.0
+ * @param string $post_type The post type being checked
+ * @param string $feature the feature being checked
+ * @return boolean
+ */
+
+function post_type_supports( $post_type, $feature ) {
+	global $_wp_post_type_features;
+
+	if ( !isset( $_wp_post_type_features[$post_type][$feature] ) )
+		return false;
+
+	// If no args passed then no extra checks need be performed
+	if ( func_num_args() <= 2 )
+		return true;
+
+	// @todo Allow pluggable arg checking
+	//$args = array_slice( func_get_args(), 2 );
+
+	return true;
+}
+
+/**
+ * Updates the post type for the post ID.
+ *
+ * The page or post cache will be cleaned for the post ID.
+ *
+ * @since 2.5.0
+ *
+ * @uses $wpdb
+ *
+ * @param int $post_id Post ID to change post type. Not actually optional.
+ * @param string $post_type Optional, default is post. Supported values are 'post' or 'page' to
+ *  name a few.
+ * @return int Amount of rows changed. Should be 1 for success and 0 for failure.
+ */
+function set_post_type( $post_id = 0, $post_type = 'post' ) {
+	global $wpdb;
+
+	$post_type = sanitize_post_field('post_type', $post_type, $post_id, 'db');
+	$return = $wpdb->update($wpdb->posts, array('post_type' => $post_type), array('ID' => $post_id) );
+
+	if ( 'page' == $post_type )
+		clean_page_cache($post_id);
+	else
+		clean_post_cache($post_id);
+
+	return $return;
+}
+
+/**
+ * Retrieve list of latest posts or posts matching criteria.
+ *
+ * The defaults are as follows:
+ *     'numberposts' - Default is 5. Total number of posts to retrieve.
+ *     'offset' - Default is 0. See {@link WP_Query::query()} for more.
+ *     'category' - What category to pull the posts from.
+ *     'orderby' - Default is 'post_date'. How to order the posts.
+ *     'order' - Default is 'DESC'. The order to retrieve the posts.
+ *     'include' - See {@link WP_Query::query()} for more.
+ *     'exclude' - See {@link WP_Query::query()} for more.
+ *     'meta_key' - See {@link WP_Query::query()} for more.
+ *     'meta_value' - See {@link WP_Query::query()} for more.
+ *     'post_type' - Default is 'post'. Can be 'page', or 'attachment' to name a few.
+ *     'post_parent' - The parent of the post or post type.
+ *     'post_status' - Default is 'published'. Post status to retrieve.
+ *
+ * @since 1.2.0
+ * @uses $wpdb
+ * @uses WP_Query::query() See for more default arguments and information.
+ * @link http://codex.wordpress.org/Template_Tags/get_posts
+ *
+ * @param array $args Optional. Overrides defaults.
+ * @return array List of posts.
+ */
+function get_posts($args = null) {
+	$defaults = array(
+		'numberposts' => 5, 'offset' => 0,
+		'category' => 0, 'orderby' => 'post_date',
+		'order' => 'DESC', 'include' => array(),
+		'exclude' => array(), 'meta_key' => '',
+		'meta_value' =>'', 'post_type' => 'post',
+		'suppress_filters' => true
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	if ( empty( $r['post_status'] ) )
+		$r['post_status'] = ( 'attachment' == $r['post_type'] ) ? 'inherit' : 'publish';
+	if ( ! empty($r['numberposts']) && empty($r['posts_per_page']) )
+		$r['posts_per_page'] = $r['numberposts'];
+	if ( ! empty($r['category']) )
+		$r['cat'] = $r['category'];
+	if ( ! empty($r['include']) ) {
+		$incposts = wp_parse_id_list( $r['include'] );
+		$r['posts_per_page'] = count($incposts);  // only the number of posts included
+		$r['post__in'] = $incposts;
+	} elseif ( ! empty($r['exclude']) )
+		$r['post__not_in'] = wp_parse_id_list( $r['exclude'] );
+
+	$r['ignore_sticky_posts'] = true;
+	$r['no_found_rows'] = true;
+
+	$get_posts = new WP_Query;
+	return $get_posts->query($r);
+
+}
+
+//
+// Post meta functions
+//
+
+/**
+ * Add meta data field to a post.
+ *
+ * Post meta data is called "Custom Fields" on the Administration Panels.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/add_post_meta
+ *
+ * @param int $post_id Post ID.
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Metadata value.
+ * @param bool $unique Optional, default is false. Whether the same key should not be added.
+ * @return bool False for failure. True for success.
+ */
+function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
+	// make sure meta is added to the post, not a revision
+	if ( $the_post = wp_is_post_revision($post_id) )
+		$post_id = $the_post;
+
+	return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
+}
+
+/**
+ * Remove metadata matching criteria from a post.
+ *
+ * You can match based on the key, or key and value. Removing based on key and
+ * value, will keep from removing duplicate metadata with the same key. It also
+ * allows removing all metadata matching key, if needed.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/delete_post_meta
+ *
+ * @param int $post_id post ID
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Optional. Metadata value.
+ * @return bool False for failure. True for success.
+ */
+function delete_post_meta($post_id, $meta_key, $meta_value = '') {
+	// make sure meta is added to the post, not a revision
+	if ( $the_post = wp_is_post_revision($post_id) )
+		$post_id = $the_post;
+
+	return delete_metadata('post', $post_id, $meta_key, $meta_value);
+}
+
+/**
+ * Retrieve post meta field for a post.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/get_post_meta
+ *
+ * @param int $post_id Post ID.
+ * @param string $key The meta key to retrieve.
+ * @param bool $single Whether to return a single value.
+ * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
+ *  is true.
+ */
+function get_post_meta($post_id, $key, $single = false) {
+	return get_metadata('post', $post_id, $key, $single);
+}
+
+/**
+ * Update post meta field based on post ID.
+ *
+ * Use the $prev_value parameter to differentiate between meta fields with the
+ * same key and post ID.
+ *
+ * If the meta field for the post does not exist, it will be added.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ * @link http://codex.wordpress.org/Function_Reference/update_post_meta
+ *
+ * @param int $post_id Post ID.
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @param mixed $prev_value Optional. Previous value to check before removing.
+ * @return bool False on failure, true if success.
+ */
+function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
+	// make sure meta is added to the post, not a revision
+	if ( $the_post = wp_is_post_revision($post_id) )
+		$post_id = $the_post;
+
+	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
+}
+
+/**
+ * Delete everything from post meta matching meta key.
+ *
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param string $post_meta_key Key to search for when deleting.
+ * @return bool Whether the post meta key was deleted from the database
+ */
+function delete_post_meta_by_key($post_meta_key) {
+	if ( !$post_meta_key )
+		return false;
+
+	global $wpdb;
+	$post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
+	if ( $post_ids ) {
+		$postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key ) );
+		$in = implode( ',', array_fill(1, count($postmetaids), '%d'));
+		do_action( 'delete_postmeta', $postmetaids );
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ));
+		do_action( 'deleted_postmeta', $postmetaids );
+		foreach ( $post_ids as $post_id )
+			wp_cache_delete($post_id, 'post_meta');
+		return true;
+	}
+	return false;
+}
+
+/**
+ * Retrieve post meta fields, based on post ID.
+ *
+ * The post meta fields are retrieved from the cache, so the function is
+ * optimized to be called more than once. It also applies to the functions, that
+ * use this function.
+ *
+ * @since 1.2.0
+ * @link http://codex.wordpress.org/Function_Reference/get_post_custom
+ *
+ * @uses $id Current Loop Post ID
+ *
+ * @param int $post_id post ID
+ * @return array
+ */
+function get_post_custom( $post_id = 0 ) {
+	$post_id = absint( $post_id );
+
+	if ( ! $post_id )
+		$post_id = get_the_ID();
+
+	if ( ! wp_cache_get( $post_id, 'post_meta' ) )
+		update_postmeta_cache( $post_id );
+
+	return wp_cache_get( $post_id, 'post_meta' );
+}
+
+/**
+ * Retrieve meta field names for a post.
+ *
+ * If there are no meta fields, then nothing (null) will be returned.
+ *
+ * @since 1.2.0
+ * @link http://codex.wordpress.org/Function_Reference/get_post_custom_keys
+ *
+ * @param int $post_id post ID
+ * @return array|null Either array of the keys, or null if keys could not be retrieved.
+ */
+function get_post_custom_keys( $post_id = 0 ) {
+	$custom = get_post_custom( $post_id );
+
+	if ( !is_array($custom) )
+		return;
+
+	if ( $keys = array_keys($custom) )
+		return $keys;
+}
+
+/**
+ * Retrieve values for a custom post field.
+ *
+ * The parameters must not be considered optional. All of the post meta fields
+ * will be retrieved and only the meta field key values returned.
+ *
+ * @since 1.2.0
+ * @link http://codex.wordpress.org/Function_Reference/get_post_custom_values
+ *
+ * @param string $key Meta field key.
+ * @param int $post_id Post ID
+ * @return array Meta field values.
+ */
+function get_post_custom_values( $key = '', $post_id = 0 ) {
+	if ( !$key )
+		return null;
+
+	$custom = get_post_custom($post_id);
+
+	return isset($custom[$key]) ? $custom[$key] : null;
+}
+
+/**
+ * Check if post is sticky.
+ *
+ * Sticky posts should remain at the top of The Loop. If the post ID is not
+ * given, then The Loop ID for the current post will be used.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return bool Whether post is sticky.
+ */
+function is_sticky( $post_id = 0 ) {
+	$post_id = absint( $post_id );
+
+	if ( ! $post_id )
+		$post_id = get_the_ID();
+
+	$stickies = get_option( 'sticky_posts' );
+
+	if ( ! is_array( $stickies ) )
+		return false;
+
+	if ( in_array( $post_id, $stickies ) )
+		return true;
+
+	return false;
+}
+
+/**
+ * Sanitize every post field.
+ *
+ * If the context is 'raw', then the post object or array will get minimal santization of the int fields.
+ *
+ * @since 2.3.0
+ * @uses sanitize_post_field() Used to sanitize the fields.
+ *
+ * @param object|array $post The Post Object or Array
+ * @param string $context Optional, default is 'display'. How to sanitize post fields.
+ * @return object|array The now sanitized Post Object or Array (will be the same type as $post)
+ */
+function sanitize_post($post, $context = 'display') {
+	if ( is_object($post) ) {
+		// Check if post already filtered for this context
+		if ( isset($post->filter) && $context == $post->filter )
+			return $post;
+		if ( !isset($post->ID) )
+			$post->ID = 0;
+		foreach ( array_keys(get_object_vars($post)) as $field )
+			$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
+		$post->filter = $context;
+	} else {
+		// Check if post already filtered for this context
+		if ( isset($post['filter']) && $context == $post['filter'] )
+			return $post;
+		if ( !isset($post['ID']) )
+			$post['ID'] = 0;
+		foreach ( array_keys($post) as $field )
+			$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
+		$post['filter'] = $context;
+	}
+	return $post;
+}
+
+/**
+ * Sanitize post field based on context.
+ *
+ * Possible context values are:  'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The
+ * 'display' context is used by default. 'attribute' and 'js' contexts are treated like 'display'
+ * when calling filters.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'edit_$field' and '{$field_no_prefix}_edit_pre' passing $value and
+ *  $post_id if $context == 'edit' and field name prefix == 'post_'.
+ *
+ * @uses apply_filters() Calls 'edit_post_$field' passing $value and $post_id if $context == 'db'.
+ * @uses apply_filters() Calls 'pre_$field' passing $value if $context == 'db' and field name prefix == 'post_'.
+ * @uses apply_filters() Calls '{$field}_pre' passing $value if $context == 'db' and field name prefix != 'post_'.
+ *
+ * @uses apply_filters() Calls '$field' passing $value, $post_id and $context if $context == anything
+ *  other than 'raw', 'edit' and 'db' and field name prefix == 'post_'.
+ * @uses apply_filters() Calls 'post_$field' passing $value if $context == anything other than 'raw',
+ *  'edit' and 'db' and field name prefix != 'post_'.
+ *
+ * @param string $field The Post Object field name.
+ * @param mixed $value The Post Object value.
+ * @param int $post_id Post ID.
+ * @param string $context How to sanitize post fields. Looks for 'raw', 'edit', 'db', 'display',
+ *               'attribute' and 'js'.
+ * @return mixed Sanitized value.
+ */
+function sanitize_post_field($field, $value, $post_id, $context) {
+	$int_fields = array('ID', 'post_parent', 'menu_order');
+	if ( in_array($field, $int_fields) )
+		$value = (int) $value;
+
+	// Fields which contain arrays of ints.
+	$array_int_fields = array( 'ancestors' );
+	if ( in_array($field, $array_int_fields) ) {
+		$value = array_map( 'absint', $value);
+		return $value;
+	}
+
+	if ( 'raw' == $context )
+		return $value;
+
+	$prefixed = false;
+	if ( false !== strpos($field, 'post_') ) {
+		$prefixed = true;
+		$field_no_prefix = str_replace('post_', '', $field);
+	}
+
+	if ( 'edit' == $context ) {
+		$format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_password');
+
+		if ( $prefixed ) {
+			$value = apply_filters("edit_{$field}", $value, $post_id);
+			// Old school
+			$value = apply_filters("{$field_no_prefix}_edit_pre", $value, $post_id);
+		} else {
+			$value = apply_filters("edit_post_{$field}", $value, $post_id);
+		}
+
+		if ( in_array($field, $format_to_edit) ) {
+			if ( 'post_content' == $field )
+				$value = format_to_edit($value, user_can_richedit());
+			else
+				$value = format_to_edit($value);
+		} else {
+			$value = esc_attr($value);
+		}
+	} else if ( 'db' == $context ) {
+		if ( $prefixed ) {
+			$value = apply_filters("pre_{$field}", $value);
+			$value = apply_filters("{$field_no_prefix}_save_pre", $value);
+		} else {
+			$value = apply_filters("pre_post_{$field}", $value);
+			$value = apply_filters("{$field}_pre", $value);
+		}
+	} else {
+		// Use display filters by default.
+		if ( $prefixed )
+			$value = apply_filters($field, $value, $post_id, $context);
+		else
+			$value = apply_filters("post_{$field}", $value, $post_id, $context);
+	}
+
+	if ( 'attribute' == $context )
+		$value = esc_attr($value);
+	else if ( 'js' == $context )
+		$value = esc_js($value);
+
+	return $value;
+}
+
+/**
+ * Make a post sticky.
+ *
+ * Sticky posts should be displayed at the top of the front page.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id Post ID.
+ */
+function stick_post($post_id) {
+	$stickies = get_option('sticky_posts');
+
+	if ( !is_array($stickies) )
+		$stickies = array($post_id);
+
+	if ( ! in_array($post_id, $stickies) )
+		$stickies[] = $post_id;
+
+	update_option('sticky_posts', $stickies);
+}
+
+/**
+ * Unstick a post.
+ *
+ * Sticky posts should be displayed at the top of the front page.
+ *
+ * @since 2.7.0
+ *
+ * @param int $post_id Post ID.
+ */
+function unstick_post($post_id) {
+	$stickies = get_option('sticky_posts');
+
+	if ( !is_array($stickies) )
+		return;
+
+	if ( ! in_array($post_id, $stickies) )
+		return;
+
+	$offset = array_search($post_id, $stickies);
+	if ( false === $offset )
+		return;
+
+	array_splice($stickies, $offset, 1);
+
+	update_option('sticky_posts', $stickies);
+}
+
+/**
+ * Count number of posts of a post type and is user has permissions to view.
+ *
+ * This function provides an efficient method of finding the amount of post's
+ * type a blog has. Another method is to count the amount of items in
+ * get_posts(), but that method has a lot of overhead with doing so. Therefore,
+ * when developing for 2.5+, use this function instead.
+ *
+ * The $perm parameter checks for 'readable' value and if the user can read
+ * private posts, it will display that for the user that is signed in.
+ *
+ * @since 2.5.0
+ * @link http://codex.wordpress.org/Template_Tags/wp_count_posts
+ *
+ * @param string $type Optional. Post type to retrieve count
+ * @param string $perm Optional. 'readable' or empty.
+ * @return object Number of posts for each status
+ */
+function wp_count_posts( $type = 'post', $perm = '' ) {
+	global $wpdb;
+
+	$user = wp_get_current_user();
+
+	$cache_key = $type;
+
+	$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
+	if ( 'readable' == $perm && is_user_logged_in() ) {
+		$post_type_object = get_post_type_object($type);
+		if ( !current_user_can( $post_type_object->cap->read_private_posts ) ) {
+			$cache_key .= '_' . $perm . '_' . $user->ID;
+			$query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))";
+		}
+	}
+	$query .= ' GROUP BY post_status';
+
+	$count = wp_cache_get($cache_key, 'counts');
+	if ( false !== $count )
+		return $count;
+
+	$count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
+
+	$stats = array();
+	foreach ( get_post_stati() as $state )
+		$stats[$state] = 0;
+
+	foreach ( (array) $count as $row )
+		$stats[$row['post_status']] = $row['num_posts'];
+
+	$stats = (object) $stats;
+	wp_cache_set($cache_key, $stats, 'counts');
+
+	return $stats;
+}
+
+
+/**
+ * Count number of attachments for the mime type(s).
+ *
+ * If you set the optional mime_type parameter, then an array will still be
+ * returned, but will only have the item you are looking for. It does not give
+ * you the number of attachments that are children of a post. You can get that
+ * by counting the number of children that post has.
+ *
+ * @since 2.5.0
+ *
+ * @param string|array $mime_type Optional. Array or comma-separated list of MIME patterns.
+ * @return array Number of posts for each mime type.
+ */
+function wp_count_attachments( $mime_type = '' ) {
+	global $wpdb;
+
+	$and = wp_post_mime_type_where( $mime_type );
+	$count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A );
+
+	$stats = array( );
+	foreach( (array) $count as $row ) {
+		$stats[$row['post_mime_type']] = $row['num_posts'];
+	}
+	$stats['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and");
+
+	return (object) $stats;
+}
+
+/**
+ * Check a MIME-Type against a list.
+ *
+ * If the wildcard_mime_types parameter is a string, it must be comma separated
+ * list. If the real_mime_types is a string, it is also comma separated to
+ * create the list.
+ *
+ * @since 2.5.0
+ *
+ * @param string|array $wildcard_mime_types e.g. audio/mpeg or image (same as image/*) or
+ *  flash (same as *flash*).
+ * @param string|array $real_mime_types post_mime_type values
+ * @return array array(wildcard=>array(real types))
+ */
+function wp_match_mime_types($wildcard_mime_types, $real_mime_types) {
+	$matches = array();
+	if ( is_string($wildcard_mime_types) )
+		$wildcard_mime_types = array_map('trim', explode(',', $wildcard_mime_types));
+	if ( is_string($real_mime_types) )
+		$real_mime_types = array_map('trim', explode(',', $real_mime_types));
+	$wild = '[-._a-z0-9]*';
+	foreach ( (array) $wildcard_mime_types as $type ) {
+		$type = str_replace('*', $wild, $type);
+		$patternses[1][$type] = "^$type$";
+		if ( false === strpos($type, '/') ) {
+			$patternses[2][$type] = "^$type/";
+			$patternses[3][$type] = $type;
+		}
+	}
+	asort($patternses);
+	foreach ( $patternses as $patterns )
+		foreach ( $patterns as $type => $pattern )
+			foreach ( (array) $real_mime_types as $real )
+				if ( preg_match("#$pattern#", $real) && ( empty($matches[$type]) || false === array_search($real, $matches[$type]) ) )
+					$matches[$type][] = $real;
+	return $matches;
+}
+
+/**
+ * Convert MIME types into SQL.
+ *
+ * @since 2.5.0
+ *
+ * @param string|array $post_mime_types List of mime types or comma separated string of mime types.
+ * @param string $table_alias Optional. Specify a table alias, if needed.
+ * @return string The SQL AND clause for mime searching.
+ */
+function wp_post_mime_type_where($post_mime_types, $table_alias = '') {
+	$where = '';
+	$wildcards = array('', '%', '%/%');
+	if ( is_string($post_mime_types) )
+		$post_mime_types = array_map('trim', explode(',', $post_mime_types));
+	foreach ( (array) $post_mime_types as $mime_type ) {
+		$mime_type = preg_replace('/\s/', '', $mime_type);
+		$slashpos = strpos($mime_type, '/');
+		if ( false !== $slashpos ) {
+			$mime_group = preg_replace('/[^-*.a-zA-Z0-9]/', '', substr($mime_type, 0, $slashpos));
+			$mime_subgroup = preg_replace('/[^-*.+a-zA-Z0-9]/', '', substr($mime_type, $slashpos + 1));
+			if ( empty($mime_subgroup) )
+				$mime_subgroup = '*';
+			else
+				$mime_subgroup = str_replace('/', '', $mime_subgroup);
+			$mime_pattern = "$mime_group/$mime_subgroup";
+		} else {
+			$mime_pattern = preg_replace('/[^-*.a-zA-Z0-9]/', '', $mime_type);
+			if ( false === strpos($mime_pattern, '*') )
+				$mime_pattern .= '/*';
+		}
+
+		$mime_pattern = preg_replace('/\*+/', '%', $mime_pattern);
+
+		if ( in_array( $mime_type, $wildcards ) )
+			return '';
+
+		if ( false !== strpos($mime_pattern, '%') )
+			$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
+		else
+			$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
+	}
+	if ( !empty($wheres) )
+		$where = ' AND (' . join(' OR ', $wheres) . ') ';
+	return $where;
+}
+
+/**
+ * Trashes or deletes a post or page.
+ *
+ * When the post and page is permanently deleted, everything that is tied to it is deleted also.
+ * This includes comments, post meta fields, and terms associated with the post.
+ *
+ * The post or page is moved to trash instead of permanently deleted unless trash is
+ * disabled, item is already in the trash, or $force_delete is true.
+ *
+ * @since 1.0.0
+ * @uses do_action() on 'delete_post' before deletion unless post type is 'attachment'.
+ * @uses do_action() on 'deleted_post' after deletion unless post type is 'attachment'.
+ * @uses wp_delete_attachment() if post type is 'attachment'.
+ * @uses wp_trash_post() if item should be trashed.
+ *
+ * @param int $postid Post ID.
+ * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false.
+ * @return mixed False on failure
+ */
+function wp_delete_post( $postid = 0, $force_delete = false ) {
+	global $wpdb, $wp_rewrite;
+
+	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
+		return $post;
+
+	if ( !$force_delete && ( $post->post_type == 'post' || $post->post_type == 'page') && get_post_status( $postid ) != 'trash' && EMPTY_TRASH_DAYS )
+			return wp_trash_post($postid);
+
+	if ( $post->post_type == 'attachment' )
+		return wp_delete_attachment( $postid, $force_delete );
+
+	do_action('delete_post', $postid);
+
+	delete_post_meta($postid,'_wp_trash_meta_status');
+	delete_post_meta($postid,'_wp_trash_meta_time');
+
+	wp_delete_object_term_relationships($postid, get_object_taxonomies($post->post_type));
+
+	$parent_data = array( 'post_parent' => $post->post_parent );
+	$parent_where = array( 'post_parent' => $postid );
+
+	if ( 'page' == $post->post_type) {
+	 	// if the page is defined in option page_on_front or post_for_posts,
+		// adjust the corresponding options
+		if ( get_option('page_on_front') == $postid ) {
+			update_option('show_on_front', 'posts');
+			delete_option('page_on_front');
+		}
+		if ( get_option('page_for_posts') == $postid ) {
+			delete_option('page_for_posts');
+		}
+
+		// Point children of this page to its parent, also clean the cache of affected children
+		$children_query = $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type='page'", $postid);
+		$children = $wpdb->get_results($children_query);
+
+		$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'page' ) );
+	} else {
+		unstick_post($postid);
+	}
+
+	// Do raw query.  wp_get_post_revisions() is filtered
+	$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
+	// Use wp_delete_post (via wp_delete_post_revision) again.  Ensures any meta/misplaced data gets cleaned up.
+	foreach ( $revision_ids as $revision_id )
+		wp_delete_post_revision( $revision_id );
+
+	// Point all attachments to this post up one level
+	$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
+
+	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
+	if ( ! empty($comment_ids) ) {
+		do_action( 'delete_comment', $comment_ids );
+		foreach ( $comment_ids as $comment_id )
+			wp_delete_comment( $comment_id, true );
+		do_action( 'deleted_comment', $comment_ids );
+	}
+
+	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
+	if ( !empty($post_meta_ids) ) {
+		do_action( 'delete_postmeta', $post_meta_ids );
+		$in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'";
+		$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" );
+		do_action( 'deleted_postmeta', $post_meta_ids );
+	}
+
+	do_action( 'delete_post', $postid );
+	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
+	do_action( 'deleted_post', $postid );
+
+	if ( 'page' == $post->post_type ) {
+		clean_page_cache($postid);
+
+		foreach ( (array) $children as $child )
+			clean_page_cache($child->ID);
+
+		$wp_rewrite->flush_rules(false);
+	} else {
+		clean_post_cache($postid);
+	}
+
+	wp_clear_scheduled_hook('publish_future_post', array( $postid ) );
+
+	do_action('deleted_post', $postid);
+
+	return $post;
+}
+
+/**
+ * Moves a post or page to the Trash
+ *
+ * If trash is disabled, the post or page is permanently deleted.
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'trash_post' before trashing
+ * @uses do_action() on 'trashed_post' after trashing
+ * @uses wp_delete_post() if trash is disabled
+ *
+ * @param int $post_id Post ID.
+ * @return mixed False on failure
+ */
+function wp_trash_post($post_id = 0) {
+	if ( !EMPTY_TRASH_DAYS )
+		return wp_delete_post($post_id, true);
+
+	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
+		return $post;
+
+	if ( $post['post_status'] == 'trash' )
+		return false;
+
+	do_action('trash_post', $post_id);
+
+	add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
+	add_post_meta($post_id,'_wp_trash_meta_time', time());
+
+	$post['post_status'] = 'trash';
+	wp_insert_post($post);
+
+	wp_trash_post_comments($post_id);
+
+	do_action('trashed_post', $post_id);
+
+	return $post;
+}
+
+/**
+ * Restores a post or page from the Trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'untrash_post' before undeletion
+ * @uses do_action() on 'untrashed_post' after undeletion
+ *
+ * @param int $post_id Post ID.
+ * @return mixed False on failure
+ */
+function wp_untrash_post($post_id = 0) {
+	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )
+		return $post;
+
+	if ( $post['post_status'] != 'trash' )
+		return false;
+
+	do_action('untrash_post', $post_id);
+
+	$post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);
+
+	$post['post_status'] = $post_status;
+
+	delete_post_meta($post_id, '_wp_trash_meta_status');
+	delete_post_meta($post_id, '_wp_trash_meta_time');
+
+	wp_insert_post($post);
+
+	wp_untrash_post_comments($post_id);
+
+	do_action('untrashed_post', $post_id);
+
+	return $post;
+}
+
+/**
+ * Moves comments for a post to the trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'trash_post_comments' before trashing
+ * @uses do_action() on 'trashed_post_comments' after trashing
+ *
+ * @param int $post Post ID or object.
+ * @return mixed False on failure
+ */
+function wp_trash_post_comments($post = null) {
+	global $wpdb;
+
+	$post = get_post($post);
+	if ( empty($post) )
+		return;
+
+	$post_id = $post->ID;
+
+	do_action('trash_post_comments', $post_id);
+
+	$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) );
+	if ( empty($comments) )
+		return;
+
+	// Cache current status for each comment
+	$statuses = array();
+	foreach ( $comments as $comment )
+		$statuses[$comment->comment_ID] = $comment->comment_approved;
+	add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
+
+	// Set status for all comments to post-trashed
+	$result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id));
+
+	clean_comment_cache( array_keys($statuses) );
+
+	do_action('trashed_post_comments', $post_id, $statuses);
+
+	return $result;
+}
+
+/**
+ * Restore comments for a post from the trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'untrash_post_comments' before trashing
+ * @uses do_action() on 'untrashed_post_comments' after trashing
+ *
+ * @param int $post Post ID or object.
+ * @return mixed False on failure
+ */
+function wp_untrash_post_comments($post = null) {
+	global $wpdb;
+
+	$post = get_post($post);
+	if ( empty($post) )
+		return;
+
+	$post_id = $post->ID;
+
+	$statuses = get_post_meta($post_id, '_wp_trash_meta_comments_status', true);
+
+	if ( empty($statuses) )
+		return true;
+
+	do_action('untrash_post_comments', $post_id);
+
+	// Restore each comment to its original status
+	$group_by_status = array();
+	foreach ( $statuses as $comment_id => $comment_status )
+		$group_by_status[$comment_status][] = $comment_id;
+
+	foreach ( $group_by_status as $status => $comments ) {
+		// Sanity check. This shouldn't happen.
+		if ( 'post-trashed' == $status )
+			$status = '0';
+		$comments_in = implode( "', '", $comments );
+		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = '$status' WHERE comment_ID IN ('" . $comments_in . "')" );
+	}
+
+	clean_comment_cache( array_keys($statuses) );
+
+	delete_post_meta($post_id, '_wp_trash_meta_comments_status');
+
+	do_action('untrashed_post_comments', $post_id);
+}
+
+/**
+ * Retrieve the list of categories for a post.
+ *
+ * Compatibility layer for themes and plugins. Also an easy layer of abstraction
+ * away from the complexity of the taxonomy layer.
+ *
+ * @since 2.1.0
+ *
+ * @uses wp_get_object_terms() Retrieves the categories. Args details can be found here.
+ *
+ * @param int $post_id Optional. The Post ID.
+ * @param array $args Optional. Overwrite the defaults.
+ * @return array
+ */
+function wp_get_post_categories( $post_id = 0, $args = array() ) {
+	$post_id = (int) $post_id;
+
+	$defaults = array('fields' => 'ids');
+	$args = wp_parse_args( $args, $defaults );
+
+	$cats = wp_get_object_terms($post_id, 'category', $args);
+	return $cats;
+}
+
+/**
+ * Retrieve the tags for a post.
+ *
+ * There is only one default for this function, called 'fields' and by default
+ * is set to 'all'. There are other defaults that can be overridden in
+ * {@link wp_get_object_terms()}.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 2.3.0
+ *
+ * @uses wp_get_object_terms() Gets the tags for returning. Args can be found here
+ *
+ * @param int $post_id Optional. The Post ID
+ * @param array $args Optional. Overwrite the defaults
+ * @return array List of post tags.
+ */
+function wp_get_post_tags( $post_id = 0, $args = array() ) {
+	return wp_get_post_terms( $post_id, 'post_tag', $args);
+}
+
+/**
+ * Retrieve the terms for a post.
+ *
+ * There is only one default for this function, called 'fields' and by default
+ * is set to 'all'. There are other defaults that can be overridden in
+ * {@link wp_get_object_terms()}.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 2.8.0
+ *
+ * @uses wp_get_object_terms() Gets the tags for returning. Args can be found here
+ *
+ * @param int $post_id Optional. The Post ID
+ * @param string $taxonomy The taxonomy for which to retrieve terms. Defaults to post_tag.
+ * @param array $args Optional. Overwrite the defaults
+ * @return array List of post tags.
+ */
+function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
+	$post_id = (int) $post_id;
+
+	$defaults = array('fields' => 'all');
+	$args = wp_parse_args( $args, $defaults );
+
+	$tags = wp_get_object_terms($post_id, $taxonomy, $args);
+
+	return $tags;
+}
+
+/**
+ * Retrieve number of recent posts.
+ *
+ * @since 1.0.0
+ * @uses wp_parse_args()
+ * @uses get_posts()
+ *
+ * @param string $deprecated Deprecated.
+ * @param array $args Optional. Overrides defaults.
+ * @param string $output Optional.
+ * @return unknown.
+ */
+function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
+
+	if ( is_numeric( $args ) ) {
+		_deprecated_argument( __FUNCTION__, '3.1', __( 'Passing an integer number of posts is deprecated. Pass an array of arguments instead.' ) );
+		$args = array( 'numberposts' => absint( $args ) );
+	}
+
+	// Set default arguments
+	$defaults = array(
+		'numberposts' => 10, 'offset' => 0,
+		'category' => 0, 'orderby' => 'post_date',
+		'order' => 'DESC', 'include' => '',
+		'exclude' => '', 'meta_key' => '',
+		'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private',
+		'suppress_filters' => true
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+
+	$results = get_posts( $r );
+
+	// Backward compatibility. Prior to 3.1 expected posts to be returned in array
+	if ( ARRAY_A == $output ){
+		foreach( $results as $key => $result ) {
+			$results[$key] = get_object_vars( $result );
+		}
+		return $results ? $results : array();
+	}
+
+	return $results ? $results : false;
+
+}
+
+/**
+ * Retrieve a single post, based on post ID.
+ *
+ * Has categories in 'post_category' property or key. Has tags in 'tags_input'
+ * property or key.
+ *
+ * @since 1.0.0
+ *
+ * @param int $postid Post ID.
+ * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A.
+ * @return object|array Post object or array holding post contents and information
+ */
+function wp_get_single_post($postid = 0, $mode = OBJECT) {
+	$postid = (int) $postid;
+
+	$post = get_post($postid, $mode);
+
+	if (
+		( OBJECT == $mode && empty( $post->ID ) ) ||
+		( OBJECT != $mode && empty( $post['ID'] ) )
+	)
+		return ( OBJECT == $mode ? null : array() );
+
+	// Set categories and tags
+	if ( $mode == OBJECT ) {
+		$post->post_category = array();
+		if ( is_object_in_taxonomy($post->post_type, 'category') )
+			$post->post_category = wp_get_post_categories($postid);
+		$post->tags_input = array();
+		if ( is_object_in_taxonomy($post->post_type, 'post_tag') )
+			$post->tags_input = wp_get_post_tags($postid, array('fields' => 'names'));
+	} else {
+		$post['post_category'] = array();
+		if ( is_object_in_taxonomy($post['post_type'], 'category') )
+			$post['post_category'] = wp_get_post_categories($postid);
+		$post['tags_input'] = array();
+		if ( is_object_in_taxonomy($post['post_type'], 'post_tag') )
+			$post['tags_input'] = wp_get_post_tags($postid, array('fields' => 'names'));
+	}
+
+	return $post;
+}
+
+/**
+ * Insert a post.
+ *
+ * If the $postarr parameter has 'ID' set to a value, then post will be updated.
+ *
+ * You can set the post date manually, but setting the values for 'post_date'
+ * and 'post_date_gmt' keys. You can close the comments or open the comments by
+ * setting the value for 'comment_status' key.
+ *
+ * The defaults for the parameter $postarr are:
+ *     'post_status'   - Default is 'draft'.
+ *     'post_type'     - Default is 'post'.
+ *     'post_author'   - Default is current user ID ($user_ID). The ID of the user who added the post.
+ *     'ping_status'   - Default is the value in 'default_ping_status' option.
+ *                       Whether the attachment can accept pings.
+ *     'post_parent'   - Default is 0. Set this for the post it belongs to, if any.
+ *     'menu_order'    - Default is 0. The order it is displayed.
+ *     'to_ping'       - Whether to ping.
+ *     'pinged'        - Default is empty string.
+ *     'post_password' - Default is empty string. The password to access the attachment.
+ *     'guid'          - Global Unique ID for referencing the attachment.
+ *     'post_content_filtered' - Post content filtered.
+ *     'post_excerpt'  - Post excerpt.
+ *
+ * @since 1.0.0
+ * @uses $wpdb
+ * @uses $wp_rewrite
+ * @uses $user_ID
+ * @uses do_action() Calls 'pre_post_update' on post ID if this is an update.
+ * @uses do_action() Calls 'edit_post' action on post ID and post data if this is an update.
+ * @uses do_action() Calls 'save_post' and 'wp_insert_post' on post id and post data just before returning.
+ * @uses apply_filters() Calls 'wp_insert_post_data' passing $data, $postarr prior to database update or insert.
+ * @uses wp_transition_post_status()
+ *
+ * @param array $postarr Elements that make up post to insert.
+ * @param bool $wp_error Optional. Allow return of WP_Error on failure.
+ * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
+ */
+function wp_insert_post($postarr, $wp_error = false) {
+	global $wpdb, $wp_rewrite, $user_ID;
+
+	$defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
+		'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
+		'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
+		'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0,
+		'post_content' => '', 'post_title' => '');
+
+	$postarr = wp_parse_args($postarr, $defaults);
+	$postarr = sanitize_post($postarr, 'db');
+
+	// export array as variables
+	extract($postarr, EXTR_SKIP);
+
+	// Are we updating or creating?
+	$update = false;
+	if ( !empty($ID) ) {
+		$update = true;
+		$previous_status = get_post_field('post_status', $ID);
+	} else {
+		$previous_status = 'new';
+	}
+
+	if ( ('' == $post_content) && ('' == $post_title) && ('' == $post_excerpt) && ('attachment' != $post_type) ) {
+		if ( $wp_error )
+			return new WP_Error('empty_content', __('Content, title, and excerpt are empty.'));
+		else
+			return 0;
+	}
+
+	if ( empty($post_type) )
+		$post_type = 'post';
+
+	if ( empty($post_status) )
+		$post_status = 'draft';
+
+	if ( !empty($post_category) )
+		$post_category = array_filter($post_category); // Filter out empty terms
+
+	// Make sure we set a valid category.
+	if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
+		// 'post' requires at least one category.
+		if ( 'post' == $post_type && 'auto-draft' != $post_status )
+			$post_category = array( get_option('default_category') );
+		else
+			$post_category = array();
+	}
+
+	if ( empty($post_author) )
+		$post_author = $user_ID;
+
+	$post_ID = 0;
+
+	// Get the post ID and GUID
+	if ( $update ) {
+		$post_ID = (int) $ID;
+		$guid = get_post_field( 'guid', $post_ID );
+		$post_before = get_post($post_ID);
+	}
+
+	// Don't allow contributors to set to set the post slug for pending review posts
+	if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) )
+		$post_name = '';
+
+	// Create a valid post name.  Drafts and pending posts are allowed to have an empty
+	// post name.
+	if ( empty($post_name) ) {
+		if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
+			$post_name = sanitize_title($post_title);
+		else
+			$post_name = '';
+	} else {
+		$post_name = sanitize_title($post_name);
+	}
+
+	// If the post date is empty (due to having been new or a draft) and status is not 'draft' or 'pending', set date to now
+	if ( empty($post_date) || '0000-00-00 00:00:00' == $post_date )
+		$post_date = current_time('mysql');
+
+	if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
+		if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
+			$post_date_gmt = get_gmt_from_date($post_date);
+		else
+			$post_date_gmt = '0000-00-00 00:00:00';
+	}
+
+	if ( $update || '0000-00-00 00:00:00' == $post_date ) {
+		$post_modified     = current_time( 'mysql' );
+		$post_modified_gmt = current_time( 'mysql', 1 );
+	} else {
+		$post_modified     = $post_date;
+		$post_modified_gmt = $post_date_gmt;
+	}
+
+	if ( 'publish' == $post_status ) {
+		$now = gmdate('Y-m-d H:i:59');
+		if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) )
+			$post_status = 'future';
+	} elseif( 'future' == $post_status ) {
+		$now = gmdate('Y-m-d H:i:59');
+		if ( mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false) )
+			$post_status = 'publish';
+	}
+
+	if ( empty($comment_status) ) {
+		if ( $update )
+			$comment_status = 'closed';
+		else
+			$comment_status = get_option('default_comment_status');
+	}
+	if ( empty($ping_status) )
+		$ping_status = get_option('default_ping_status');
+
+	if ( isset($to_ping) )
+		$to_ping = preg_replace('|\s+|', "\n", $to_ping);
+	else
+		$to_ping = '';
+
+	if ( ! isset($pinged) )
+		$pinged = '';
+
+	if ( isset($post_parent) )
+		$post_parent = (int) $post_parent;
+	else
+		$post_parent = 0;
+
+	// Check the post_parent to see if it will cause a hierarchy loop
+	$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
+
+	if ( isset($menu_order) )
+		$menu_order = (int) $menu_order;
+	else
+		$menu_order = 0;
+
+	if ( !isset($post_password) || 'private' == $post_status )
+		$post_password = '';
+
+	$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
+
+	// expected_slashed (everything!)
+	$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
+	$data = apply_filters('wp_insert_post_data', $data, $postarr);
+	$data = stripslashes_deep( $data );
+	$where = array( 'ID' => $post_ID );
+
+	if ( $update ) {
+		do_action( 'pre_post_update', $post_ID );
+		if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
+			if ( $wp_error )
+				return new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
+			else
+				return 0;
+		}
+	} else {
+		if ( isset($post_mime_type) )
+			$data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update
+		// If there is a suggested ID, use it if not already present
+		if ( !empty($import_id) ) {
+			$import_id = (int) $import_id;
+			if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
+				$data['ID'] = $import_id;
+			}
+		}
+		if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
+			if ( $wp_error )
+				return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error);
+			else
+				return 0;
+		}
+		$post_ID = (int) $wpdb->insert_id;
+
+		// use the newly generated $post_ID
+		$where = array( 'ID' => $post_ID );
+	}
+
+	if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
+		$data['post_name'] = sanitize_title($data['post_title'], $post_ID);
+		$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
+	}
+
+	if ( is_object_in_taxonomy($post_type, 'category') )
+		wp_set_post_categories( $post_ID, $post_category );
+
+	if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
+		wp_set_post_tags( $post_ID, $tags_input );
+
+	// new-style support for all custom taxonomies
+	if ( !empty($tax_input) ) {
+		foreach ( $tax_input as $taxonomy => $tags ) {
+			$taxonomy_obj = get_taxonomy($taxonomy);
+			if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
+				$tags = array_filter($tags);
+			if ( current_user_can($taxonomy_obj->cap->assign_terms) )
+				wp_set_post_terms( $post_ID, $tags, $taxonomy );
+		}
+	}
+
+	$current_guid = get_post_field( 'guid', $post_ID );
+
+	if ( 'page' == $data['post_type'] )
+		clean_page_cache($post_ID);
+	else
+		clean_post_cache($post_ID);
+
+	// Set GUID
+	if ( !$update && '' == $current_guid )
+		$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
+
+	$post = get_post($post_ID);
+
+	if ( !empty($page_template) && 'page' == $data['post_type'] ) {
+		$post->page_template = $page_template;
+		$page_templates = get_page_templates();
+		if ( 'default' != $page_template && !in_array($page_template, $page_templates) ) {
+			if ( $wp_error )
+				return new WP_Error('invalid_page_template', __('The page template is invalid.'));
+			else
+				return 0;
+		}
+		update_post_meta($post_ID, '_wp_page_template',  $page_template);
+	}
+
+	wp_transition_post_status($data['post_status'], $previous_status, $post);
+
+	if ( $update ) {
+		do_action('edit_post', $post_ID, $post);
+		$post_after = get_post($post_ID);
+		do_action( 'post_updated', $post_ID, $post_after, $post_before);
+	}
+
+	do_action('save_post', $post_ID, $post);
+	do_action('wp_insert_post', $post_ID, $post);
+
+	return $post_ID;
+}
+
+/**
+ * Update a post with new post data.
+ *
+ * The date does not have to be set for drafts. You can set the date and it will
+ * not be overridden.
+ *
+ * @since 1.0.0
+ *
+ * @param array|object $postarr Post data. Arrays are expected to be escaped, objects are not.
+ * @return int 0 on failure, Post ID on success.
+ */
+function wp_update_post($postarr = array()) {
+	if ( is_object($postarr) ) {
+		// non-escaped post was passed
+		$postarr = get_object_vars($postarr);
+		$postarr = add_magic_quotes($postarr);
+	}
+
+	// First, get all of the original fields
+	$post = wp_get_single_post($postarr['ID'], ARRAY_A);
+
+	// Escape data pulled from DB.
+	$post = add_magic_quotes($post);
+
+	// Passed post category list overwrites existing category list if not empty.
+	if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
+			 && 0 != count($postarr['post_category']) )
+		$post_cats = $postarr['post_category'];
+	else
+		$post_cats = $post['post_category'];
+
+	// Drafts shouldn't be assigned a date unless explicitly done so by the user
+	if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
+			 ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
+		$clear_date = true;
+	else
+		$clear_date = false;
+
+	// Merge old and new fields with new fields overwriting old ones.
+	$postarr = array_merge($post, $postarr);
+	$postarr['post_category'] = $post_cats;
+	if ( $clear_date ) {
+		$postarr['post_date'] = current_time('mysql');
+		$postarr['post_date_gmt'] = '';
+	}
+
+	if ($postarr['post_type'] == 'attachment')
+		return wp_insert_attachment($postarr);
+
+	return wp_insert_post($postarr);
+}
+
+/**
+ * Publish a post by transitioning the post status.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ * @uses do_action() Calls 'edit_post', 'save_post', and 'wp_insert_post' on post_id and post data.
+ *
+ * @param int $post_id Post ID.
+ * @return null
+ */
+function wp_publish_post($post_id) {
+	global $wpdb;
+
+	$post = get_post($post_id);
+
+	if ( empty($post) )
+		return;
+
+	if ( 'publish' == $post->post_status )
+		return;
+
+	$wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post_id ) );
+
+	$old_status = $post->post_status;
+	$post->post_status = 'publish';
+	wp_transition_post_status('publish', $old_status, $post);
+
+	// Update counts for the post's terms.
+	foreach ( (array) get_object_taxonomies('post') as $taxonomy ) {
+		$tt_ids = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'tt_ids'));
+		wp_update_term_count($tt_ids, $taxonomy);
+	}
+
+	do_action('edit_post', $post_id, $post);
+	do_action('save_post', $post_id, $post);
+	do_action('wp_insert_post', $post_id, $post);
+}
+
+/**
+ * Publish future post and make sure post ID has future post status.
+ *
+ * Invoked by cron 'publish_future_post' event. This safeguard prevents cron
+ * from publishing drafts, etc.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post_id Post ID.
+ * @return null Nothing is returned. Which can mean that no action is required or post was published.
+ */
+function check_and_publish_future_post($post_id) {
+
+	$post = get_post($post_id);
+
+	if ( empty($post) )
+		return;
+
+	if ( 'future' != $post->post_status )
+		return;
+
+	$time = strtotime( $post->post_date_gmt . ' GMT' );
+
+	if ( $time > time() ) { // Uh oh, someone jumped the gun!
+		wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // clear anything else in the system
+		wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
+		return;
+	}
+
+	return wp_publish_post($post_id);
+}
+
+
+/**
+ * Computes a unique slug for the post, when given the desired slug and some post details.
+ *
+ * @since 2.8.0
+ *
+ * @global wpdb $wpdb
+ * @global WP_Rewrite $wp_rewrite
+ * @param string $slug the desired slug (post_name)
+ * @param integer $post_ID
+ * @param string $post_status no uniqueness checks are made if the post is still draft or pending
+ * @param string $post_type
+ * @param integer $post_parent
+ * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
+ */
+function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
+	if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
+		return $slug;
+
+	global $wpdb, $wp_rewrite;
+
+	$feeds = $wp_rewrite->feeds;
+	if ( ! is_array( $feeds ) )
+		$feeds = array();
+
+	$hierarchical_post_types = get_post_types( array('hierarchical' => true) );
+	if ( 'attachment' == $post_type ) {
+		// Attachment slugs must be unique across all types.
+		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
+		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
+
+		if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
+			$suffix = 2;
+			do {
+				$alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
+				$post_name_check = $wpdb->get_var( $wpdb->prepare($check_sql, $alt_post_name, $post_ID ) );
+				$suffix++;
+			} while ( $post_name_check );
+			$slug = $alt_post_name;
+		}
+	} elseif ( in_array( $post_type, $hierarchical_post_types ) ) {
+		// Page slugs must be unique within their own trees. Pages are in a separate
+		// namespace than posts so page slugs are allowed to overlap post slugs.
+		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
+		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
+
+		if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )  || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) {
+			$suffix = 2;
+			do {
+				$alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
+				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID, $post_parent ) );
+				$suffix++;
+			} while ( $post_name_check );
+			$slug = $alt_post_name;
+		}
+	} else {
+		// Post slugs must be unique across all posts.
+		$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
+		$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
+
+		if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
+			$suffix = 2;
+			do {
+				$alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
+				$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) );
+				$suffix++;
+			} while ( $post_name_check );
+			$slug = $alt_post_name;
+		}
+	}
+
+	return $slug;
+}
+
+/**
+ * Adds tags to a post.
+ *
+ * @uses wp_set_post_tags() Same first two parameters, but the last parameter is always set to true.
+ *
+ * @package WordPress
+ * @subpackage Post
+ * @since 2.3.0
+ *
+ * @param int $post_id Post ID
+ * @param string $tags The tags to set for the post, separated by commas.
+ * @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise
+ */
+function wp_add_post_tags($post_id = 0, $tags = '') {
+	return wp_set_post_tags($post_id, $tags, true);
+}
+
+
+/**
+ * Set the tags for a post.
+ *
+ * @since 2.3.0
+ * @uses wp_set_object_terms() Sets the tags for the post.
+ *
+ * @param int $post_id Post ID.
+ * @param string $tags The tags to set for the post, separated by commas.
+ * @param bool $append If true, don't delete existing tags, just add on. If false, replace the tags with the new tags.
+ * @return mixed Array of affected term IDs. WP_Error or false on failure.
+ */
+function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
+	return wp_set_post_terms( $post_id, $tags, 'post_tag', $append);
+}
+
+/**
+ * Set the terms for a post.
+ *
+ * @since 2.8.0
+ * @uses wp_set_object_terms() Sets the tags for the post.
+ *
+ * @param int $post_id Post ID.
+ * @param string $tags The tags to set for the post, separated by commas.
+ * @param bool $append If true, don't delete existing tags, just add on. If false, replace the tags with the new tags.
+ * @return mixed Array of affected term IDs. WP_Error or false on failure.
+ */
+function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
+	$post_id = (int) $post_id;
+
+	if ( !$post_id )
+		return false;
+
+	if ( empty($tags) )
+		$tags = array();
+
+	$tags = is_array($tags) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") );
+
+	// Hierarchical taxonomies must always pass IDs rather than names so that children with the same
+	// names but different parents aren't confused.
+	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
+		$tags = array_map( 'intval', $tags );
+		$tags = array_unique( $tags );
+	}
+
+	return wp_set_object_terms($post_id, $tags, $taxonomy, $append);
+}
+
+/**
+ * Set categories for a post.
+ *
+ * If the post categories parameter is not set, then the default category is
+ * going used.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_ID Post ID.
+ * @param array $post_categories Optional. List of categories.
+ * @return bool|mixed
+ */
+function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
+	$post_ID = (int) $post_ID;
+	$post_type = get_post_type( $post_ID );
+	$post_status = get_post_status( $post_ID );
+	// If $post_categories isn't already an array, make it one:
+	if ( !is_array($post_categories) || empty($post_categories) ) {
+		if ( 'post' == $post_type && 'auto-draft' != $post_status )
+			$post_categories = array( get_option('default_category') );
+		else
+			$post_categories = array();
+	} else if ( 1 == count($post_categories) && '' == reset($post_categories) ) {
+		return true;
+	}
+
+	if ( !empty($post_categories) ) {
+		$post_categories = array_map('intval', $post_categories);
+		$post_categories = array_unique($post_categories);
+	}
+
+	return wp_set_object_terms($post_ID, $post_categories, 'category');
+}
+
+/**
+ * Transition the post status of a post.
+ *
+ * Calls hooks to transition post status.
+ *
+ * The first is 'transition_post_status' with new status, old status, and post data.
+ *
+ * The next action called is 'OLDSTATUS_to_NEWSTATUS' the 'NEWSTATUS' is the
+ * $new_status parameter and the 'OLDSTATUS' is $old_status parameter; it has the
+ * post data.
+ *
+ * The final action is named 'NEWSTATUS_POSTTYPE', 'NEWSTATUS' is from the $new_status
+ * parameter and POSTTYPE is post_type post data.
+ *
+ * @since 2.3.0
+ * @link http://codex.wordpress.org/Post_Status_Transitions
+ *
+ * @uses do_action() Calls 'transition_post_status' on $new_status, $old_status and
+ *  $post if there is a status change.
+ * @uses do_action() Calls '{$old_status}_to_{$new_status}' on $post if there is a status change.
+ * @uses do_action() Calls '{$new_status}_{$post->post_type}' on post ID and $post.
+ *
+ * @param string $new_status Transition to this post status.
+ * @param string $old_status Previous post status.
+ * @param object $post Post data.
+ */
+function wp_transition_post_status($new_status, $old_status, $post) {
+	do_action('transition_post_status', $new_status, $old_status, $post);
+	do_action("{$old_status}_to_{$new_status}", $post);
+	do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
+}
+
+//
+// Trackback and ping functions
+//
+
+/**
+ * Add a URL to those already pung.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ *
+ * @param int $post_id Post ID.
+ * @param string $uri Ping URI.
+ * @return int How many rows were updated.
+ */
+function add_ping($post_id, $uri) {
+	global $wpdb;
+	$pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id ));
+	$pung = trim($pung);
+	$pung = preg_split('/\s/', $pung);
+	$pung[] = $uri;
+	$new = implode("\n", $pung);
+	$new = apply_filters('add_ping', $new);
+	// expected_slashed ($new)
+	$new = stripslashes($new);
+	return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post_id ) );
+}
+
+/**
+ * Retrieve enclosures already enclosed for a post.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ *
+ * @param int $post_id Post ID.
+ * @return array List of enclosures
+ */
+function get_enclosed($post_id) {
+	$custom_fields = get_post_custom( $post_id );
+	$pung = array();
+	if ( !is_array( $custom_fields ) )
+		return $pung;
+
+	foreach ( $custom_fields as $key => $val ) {
+		if ( 'enclosure' != $key || !is_array( $val ) )
+			continue;
+		foreach( $val as $enc ) {
+			$enclosure = split( "\n", $enc );
+			$pung[] = trim( $enclosure[ 0 ] );
+		}
+	}
+	$pung = apply_filters('get_enclosed', $pung, $post_id);
+	return $pung;
+}
+
+/**
+ * Retrieve URLs already pinged for a post.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ *
+ * @param int $post_id Post ID.
+ * @return array
+ */
+function get_pung($post_id) {
+	global $wpdb;
+	$pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id ));
+	$pung = trim($pung);
+	$pung = preg_split('/\s/', $pung);
+	$pung = apply_filters('get_pung', $pung);
+	return $pung;
+}
+
+/**
+ * Retrieve URLs that need to be pinged.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ *
+ * @param int $post_id Post ID
+ * @return array
+ */
+function get_to_ping($post_id) {
+	global $wpdb;
+	$to_ping = $wpdb->get_var( $wpdb->prepare( "SELECT to_ping FROM $wpdb->posts WHERE ID = %d", $post_id ));
+	$to_ping = trim($to_ping);
+	$to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
+	$to_ping = apply_filters('get_to_ping',  $to_ping);
+	return $to_ping;
+}
+
+/**
+ * Do trackbacks for a list of URLs.
+ *
+ * @since 1.0.0
+ *
+ * @param string $tb_list Comma separated list of URLs
+ * @param int $post_id Post ID
+ */
+function trackback_url_list($tb_list, $post_id) {
+	if ( ! empty( $tb_list ) ) {
+		// get post data
+		$postdata = wp_get_single_post($post_id, ARRAY_A);
+
+		// import postdata as variables
+		extract($postdata, EXTR_SKIP);
+
+		// form an excerpt
+		$excerpt = strip_tags($post_excerpt ? $post_excerpt : $post_content);
+
+		if (strlen($excerpt) > 255) {
+			$excerpt = substr($excerpt,0,252) . '...';
+		}
+
+		$trackback_urls = explode(',', $tb_list);
+		foreach( (array) $trackback_urls as $tb_url) {
+			$tb_url = trim($tb_url);
+			trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
+		}
+	}
+}
+
+//
+// Page functions
+//
+
+/**
+ * Get a list of page IDs.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ *
+ * @return array List of page IDs.
+ */
+function get_all_page_ids() {
+	global $wpdb;
+
+	if ( ! $page_ids = wp_cache_get('all_page_ids', 'posts') ) {
+		$page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'");
+		wp_cache_add('all_page_ids', $page_ids, 'posts');
+	}
+
+	return $page_ids;
+}
+
+/**
+ * Retrieves page data given a page ID or page object.
+ *
+ * @since 1.5.1
+ *
+ * @param mixed $page Page object or page ID. Passed by reference.
+ * @param string $output What to output. OBJECT, ARRAY_A, or ARRAY_N.
+ * @param string $filter How the return value should be filtered.
+ * @return mixed Page data.
+ */
+function &get_page(&$page, $output = OBJECT, $filter = 'raw') {
+	$p = get_post($page, $output, $filter);
+	return $p;
+}
+
+/**
+ * Retrieves a page given its path.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ *
+ * @param string $page_path Page path
+ * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
+ * @param string $post_type Optional. Post type. Default page.
+ * @return mixed Null when complete.
+ */
+function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
+	global $wpdb;
+	$null = null;
+	$page_path = rawurlencode(urldecode($page_path));
+	$page_path = str_replace('%2F', '/', $page_path);
+	$page_path = str_replace('%20', ' ', $page_path);
+	$page_paths = '/' . trim($page_path, '/');
+	$leaf_path  = sanitize_title(basename($page_paths));
+	$page_paths = explode('/', $page_paths);
+	$full_path = '';
+	foreach ( (array) $page_paths as $pathdir )
+		$full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
+
+	$pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = %s OR post_type = 'attachment')", $leaf_path, $post_type ));
+
+	if ( empty($pages) )
+		return $null;
+
+	foreach ( $pages as $page ) {
+		$path = '/' . $leaf_path;
+		$curpage = $page;
+		while ( $curpage->post_parent != 0 ) {
+			$post_parent = $curpage->post_parent;
+			$curpage = wp_cache_get( $post_parent, 'posts' );
+			if ( false === $curpage )
+				$curpage = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type = %s", $post_parent, $post_type ) );
+			$path = '/' . $curpage->post_name . $path;
+		}
+
+		if ( $path == $full_path )
+			return get_page($page->ID, $output, $post_type);
+	}
+
+	return $null;
+}
+
+/**
+ * Retrieve a page given its title.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ *
+ * @param string $page_title Page title
+ * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
+ * @param string $post_type Optional. Post type. Default page.
+ * @return mixed
+ */
+function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) {
+	global $wpdb;
+	$page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
+	if ( $page )
+		return get_page($page, $output);
+
+	return null;
+}
+
+/**
+ * Retrieve child pages from list of pages matching page ID.
+ *
+ * Matches against the pages parameter against the page ID. Also matches all
+ * children for the same to retrieve all children of a page. Does not make any
+ * SQL queries to get the children.
+ *
+ * @since 1.5.1
+ *
+ * @param int $page_id Page ID.
+ * @param array $pages List of pages' objects.
+ * @return array
+ */
+function &get_page_children($page_id, $pages) {
+	$page_list = array();
+	foreach ( (array) $pages as $page ) {
+		if ( $page->post_parent == $page_id ) {
+			$page_list[] = $page;
+			if ( $children = get_page_children($page->ID, $pages) )
+				$page_list = array_merge($page_list, $children);
+		}
+	}
+	return $page_list;
+}
+
+/**
+ * Order the pages with children under parents in a flat list.
+ *
+ * It uses auxiliary structure to hold parent-children relationships and
+ * runs in O(N) complexity
+ *
+ * @since 2.0.0
+ *
+ * @param array $pages Posts array.
+ * @param int $page_id Parent page ID.
+ * @return array A list arranged by hierarchy. Children immediately follow their parents.
+ */
+function &get_page_hierarchy( &$pages, $page_id = 0 ) {
+	if ( empty( $pages ) ) {
+		$result = array();
+		return $result;
+	}
+
+	$children = array();
+	foreach ( (array) $pages as $p ) {
+		$parent_id = intval( $p->post_parent );
+		$children[ $parent_id ][] = $p;
+	}
+
+	$result = array();
+	_page_traverse_name( $page_id, $children, $result );
+
+	return $result;
+}
+
+/**
+ * function to traverse and return all the nested children post names of a root page.
+ * $children contains parent-chilren relations
+ *
+ * @since 2.9.0
+ */
+function _page_traverse_name( $page_id, &$children, &$result ){
+	if ( isset( $children[ $page_id ] ) ){
+		foreach( (array)$children[ $page_id ] as $child ) {
+			$result[ $child->ID ] = $child->post_name;
+			_page_traverse_name( $child->ID, $children, $result );
+		}
+	}
+}
+
+/**
+ * Builds URI for a page.
+ *
+ * Sub pages will be in the "directory" under the parent page post name.
+ *
+ * @since 1.5.0
+ *
+ * @param mixed $page Page object or page ID.
+ * @return string Page URI.
+ */
+function get_page_uri($page) {
+	if ( ! is_object($page) )
+		$page = get_page($page);
+	$uri = $page->post_name;
+
+	// A page cannot be it's own parent.
+	if ( $page->post_parent == $page->ID )
+		return $uri;
+
+	while ($page->post_parent != 0) {
+		$page = get_page($page->post_parent);
+		$uri = $page->post_name . "/" . $uri;
+	}
+
+	return $uri;
+}
+
+/**
+ * Retrieve a list of pages.
+ *
+ * The defaults that can be overridden are the following: 'child_of',
+ * 'sort_order', 'sort_column', 'post_title', 'hierarchical', 'exclude',
+ * 'include', 'meta_key', 'meta_value','authors', 'number', and 'offset'.
+ *
+ * @since 1.5.0
+ * @uses $wpdb
+ *
+ * @param mixed $args Optional. Array or string of options that overrides defaults.
+ * @return array List of pages matching defaults or $args
+ */
+function &get_pages($args = '') {
+	global $wpdb;
+
+	$defaults = array(
+		'child_of' => 0, 'sort_order' => 'ASC',
+		'sort_column' => 'post_title', 'hierarchical' => 1,
+		'exclude' => array(), 'include' => array(),
+		'meta_key' => '', 'meta_value' => '',
+		'authors' => '', 'parent' => -1, 'exclude_tree' => '',
+		'number' => '', 'offset' => 0,
+		'post_type' => 'page', 'post_status' => 'publish',
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+	$number = (int) $number;
+	$offset = (int) $offset;
+
+	// Make sure the post type is hierarchical
+	$hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
+	if ( !in_array( $post_type, $hierarchical_post_types ) )
+		return false;
+
+	// Make sure we have a valid post status
+	if ( !in_array($post_status, get_post_stati()) )
+		return false;
+
+	$cache = array();
+	$key = md5( serialize( compact(array_keys($defaults)) ) );
+	if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) {
+		if ( is_array($cache) && isset( $cache[ $key ] ) ) {
+			$pages = apply_filters('get_pages', $cache[ $key ], $r );
+			return $pages;
+		}
+	}
+
+	if ( !is_array($cache) )
+		$cache = array();
+
+	$inclusions = '';
+	if ( !empty($include) ) {
+		$child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
+		$parent = -1;
+		$exclude = '';
+		$meta_key = '';
+		$meta_value = '';
+		$hierarchical = false;
+		$incpages = wp_parse_id_list( $include );
+		if ( ! empty( $incpages ) ) {
+			foreach ( $incpages as $incpage ) {
+				if (empty($inclusions))
+					$inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage);
+				else
+					$inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage);
+			}
+		}
+	}
+	if (!empty($inclusions))
+		$inclusions .= ')';
+
+	$exclusions = '';
+	if ( !empty($exclude) ) {
+		$expages = wp_parse_id_list( $exclude );
+		if ( ! empty( $expages ) ) {
+			foreach ( $expages as $expage ) {
+				if (empty($exclusions))
+					$exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage);
+				else
+					$exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage);
+			}
+		}
+	}
+	if (!empty($exclusions))
+		$exclusions .= ')';
+
+	$author_query = '';
+	if (!empty($authors)) {
+		$post_authors = preg_split('/[\s,]+/',$authors);
+
+		if ( ! empty( $post_authors ) ) {
+			foreach ( $post_authors as $post_author ) {
+				//Do we have an author id or an author login?
+				if ( 0 == intval($post_author) ) {
+					$post_author = get_userdatabylogin($post_author);
+					if ( empty($post_author) )
+						continue;
+					if ( empty($post_author->ID) )
+						continue;
+					$post_author = $post_author->ID;
+				}
+
+				if ( '' == $author_query )
+					$author_query = $wpdb->prepare(' post_author = %d ', $post_author);
+				else
+					$author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author);
+			}
+			if ( '' != $author_query )
+				$author_query = " AND ($author_query)";
+		}
+	}
+
+	$join = '';
+	$where = "$exclusions $inclusions ";
+	if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) {
+		$join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
+
+		// meta_key and meta_value might be slashed
+		$meta_key = stripslashes($meta_key);
+		$meta_value = stripslashes($meta_value);
+		if ( ! empty( $meta_key ) )
+			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
+		if ( ! empty( $meta_value ) )
+			$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value);
+
+	}
+
+	if ( $parent >= 0 )
+		$where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
+
+	$where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status );
+
+	$query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
+	$query .= $author_query;
+	$query .= " ORDER BY " . $sort_column . " " . $sort_order ;
+
+	if ( !empty($number) )
+		$query .= ' LIMIT ' . $offset . ',' . $number;
+
+	$pages = $wpdb->get_results($query);
+
+	if ( empty($pages) ) {
+		$pages = apply_filters('get_pages', array(), $r);
+		return $pages;
+	}
+
+	// Sanitize before caching so it'll only get done once
+	$num_pages = count($pages);
+	for ($i = 0; $i < $num_pages; $i++) {
+		$pages[$i] = sanitize_post($pages[$i], 'raw');
+	}
+
+	// Update cache.
+	update_page_cache($pages);
+
+	if ( $child_of || $hierarchical )
+		$pages = & get_page_children($child_of, $pages);
+
+	if ( !empty($exclude_tree) ) {
+		$exclude = (int) $exclude_tree;
+		$children = get_page_children($exclude, $pages);
+		$excludes = array();
+		foreach ( $children as $child )
+			$excludes[] = $child->ID;
+		$excludes[] = $exclude;
+		$num_pages = count($pages);
+		for ( $i = 0; $i < $num_pages; $i++ ) {
+			if ( in_array($pages[$i]->ID, $excludes) )
+				unset($pages[$i]);
+		}
+	}
+
+	$cache[ $key ] = $pages;
+	wp_cache_set( 'get_pages', $cache, 'posts' );
+
+	$pages = apply_filters('get_pages', $pages, $r);
+
+	return $pages;
+}
+
+//
+// Attachment functions
+//
+
+/**
+ * Check if the attachment URI is local one and is really an attachment.
+ *
+ * @since 2.0.0
+ *
+ * @param string $url URL to check
+ * @return bool True on success, false on failure.
+ */
+function is_local_attachment($url) {
+	if (strpos($url, home_url()) === false)
+		return false;
+	if (strpos($url, home_url('/?attachment_id=')) !== false)
+		return true;
+	if ( $id = url_to_postid($url) ) {
+		$post = & get_post($id);
+		if ( 'attachment' == $post->post_type )
+			return true;
+	}
+	return false;
+}
+
+/**
+ * Insert an attachment.
+ *
+ * If you set the 'ID' in the $object parameter, it will mean that you are
+ * updating and attempt to update the attachment. You can also set the
+ * attachment name or title by setting the key 'post_name' or 'post_title'.
+ *
+ * You can set the dates for the attachment manually by setting the 'post_date'
+ * and 'post_date_gmt' keys' values.
+ *
+ * By default, the comments will use the default settings for whether the
+ * comments are allowed. You can close them manually or keep them open by
+ * setting the value for the 'comment_status' key.
+ *
+ * The $object parameter can have the following:
+ *     'post_status'   - Default is 'draft'. Can not be overridden, set the same as parent post.
+ *     'post_type'     - Default is 'post', will be set to attachment. Can not override.
+ *     'post_author'   - Default is current user ID. The ID of the user, who added the attachment.
+ *     'ping_status'   - Default is the value in default ping status option. Whether the attachment
+ *                       can accept pings.
+ *     'post_parent'   - Default is 0. Can use $parent parameter or set this for the post it belongs
+ *                       to, if any.
+ *     'menu_order'    - Default is 0. The order it is displayed.
+ *     'to_ping'       - Whether to ping.
+ *     'pinged'        - Default is empty string.
+ *     'post_password' - Default is empty string. The password to access the attachment.
+ *     'guid'          - Global Unique ID for referencing the attachment.
+ *     'post_content_filtered' - Attachment post content filtered.
+ *     'post_excerpt'  - Attachment excerpt.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ * @uses $user_ID
+ * @uses do_action() Calls 'edit_attachment' on $post_ID if this is an update.
+ * @uses do_action() Calls 'add_attachment' on $post_ID if this is not an update.
+ *
+ * @param string|array $object Arguments to override defaults.
+ * @param string $file Optional filename.
+ * @param int $parent Parent post ID.
+ * @return int Attachment ID.
+ */
+function wp_insert_attachment($object, $file = false, $parent = 0) {
+	global $wpdb, $user_ID;
+
+	$defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
+		'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
+		'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
+		'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0);
+
+	$object = wp_parse_args($object, $defaults);
+	if ( !empty($parent) )
+		$object['post_parent'] = $parent;
+
+	$object = sanitize_post($object, 'db');
+
+	// export array as variables
+	extract($object, EXTR_SKIP);
+
+	if ( empty($post_author) )
+		$post_author = $user_ID;
+
+	$post_type = 'attachment';
+	$post_status = 'inherit';
+
+	// Make sure we set a valid category.
+	if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
+		// 'post' requires at least one category.
+		if ( 'post' == $post_type )
+			$post_category = array( get_option('default_category') );
+		else
+			$post_category = array();
+	}
+
+	// Are we updating or creating?
+	if ( !empty($ID) ) {
+		$update = true;
+		$post_ID = (int) $ID;
+	} else {
+		$update = false;
+		$post_ID = 0;
+	}
+
+	// Create a valid post name.
+	if ( empty($post_name) )
+		$post_name = sanitize_title($post_title);
+	else
+		$post_name = sanitize_title($post_name);
+
+	// expected_slashed ($post_name)
+	$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
+
+	if ( empty($post_date) )
+		$post_date = current_time('mysql');
+	if ( empty($post_date_gmt) )
+		$post_date_gmt = current_time('mysql', 1);
+
+	if ( empty($post_modified) )
+		$post_modified = $post_date;
+	if ( empty($post_modified_gmt) )
+		$post_modified_gmt = $post_date_gmt;
+
+	if ( empty($comment_status) ) {
+		if ( $update )
+			$comment_status = 'closed';
+		else
+			$comment_status = get_option('default_comment_status');
+	}
+	if ( empty($ping_status) )
+		$ping_status = get_option('default_ping_status');
+
+	if ( isset($to_ping) )
+		$to_ping = preg_replace('|\s+|', "\n", $to_ping);
+	else
+		$to_ping = '';
+
+	if ( isset($post_parent) )
+		$post_parent = (int) $post_parent;
+	else
+		$post_parent = 0;
+
+	if ( isset($menu_order) )
+		$menu_order = (int) $menu_order;
+	else
+		$menu_order = 0;
+
+	if ( !isset($post_password) )
+		$post_password = '';
+
+	if ( ! isset($pinged) )
+		$pinged = '';
+
+	// expected_slashed (everything!)
+	$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ) );
+	$data = stripslashes_deep( $data );
+
+	if ( $update ) {
+		$wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) );
+	} else {
+		// If there is a suggested ID, use it if not already present
+		if ( !empty($import_id) ) {
+			$import_id = (int) $import_id;
+			if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
+				$data['ID'] = $import_id;
+			}
+		}
+
+		$wpdb->insert( $wpdb->posts, $data );
+		$post_ID = (int) $wpdb->insert_id;
+	}
+
+	if ( empty($post_name) ) {
+		$post_name = sanitize_title($post_title, $post_ID);
+		$wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) );
+	}
+
+	wp_set_post_categories($post_ID, $post_category);
+
+	if ( $file )
+		update_attached_file( $post_ID, $file );
+
+	clean_post_cache($post_ID);
+
+	if ( isset($post_parent) && $post_parent < 0 )
+		add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true);
+
+	if ( $update) {
+		do_action('edit_attachment', $post_ID);
+	} else {
+		do_action('add_attachment', $post_ID);
+	}
+
+	return $post_ID;
+}
+
+/**
+ * Trashes or deletes an attachment.
+ *
+ * When an attachment is permanently deleted, the file will also be removed.
+ * Deletion removes all post meta fields, taxonomy, comments, etc. associated
+ * with the attachment (except the main post).
+ *
+ * The attachment is moved to the trash instead of permanently deleted unless trash
+ * for media is disabled, item is already in the trash, or $force_delete is true.
+ *
+ * @since 2.0.0
+ * @uses $wpdb
+ * @uses do_action() Calls 'delete_attachment' hook on Attachment ID.
+ *
+ * @param int $post_id Attachment ID.
+ * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false.
+ * @return mixed False on failure. Post data on success.
+ */
+function wp_delete_attachment( $post_id, $force_delete = false ) {
+	global $wpdb;
+
+	if ( !$post = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id) ) )
+		return $post;
+
+	if ( 'attachment' != $post->post_type )
+		return false;
+
+	if ( !$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status )
+		return wp_trash_post( $post_id );
+
+	delete_post_meta($post_id, '_wp_trash_meta_status');
+	delete_post_meta($post_id, '_wp_trash_meta_time');
+
+	$meta = wp_get_attachment_metadata( $post_id );
+	$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
+	$file = get_attached_file( $post_id );
+
+	if ( is_multisite() )
+		delete_transient( 'dirsize_cache' );
+
+	do_action('delete_attachment', $post_id);
+
+	wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
+	wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
+
+	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $post_id ));
+
+	$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
+	if ( ! empty( $comment_ids ) ) {
+		do_action( 'delete_comment', $comment_ids );
+		foreach ( $comment_ids as $comment_id )
+			wp_delete_comment( $comment_id, true );
+		do_action( 'deleted_comment', $comment_ids );
+	}
+
+	$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
+	if ( !empty($post_meta_ids) ) {
+		do_action( 'delete_postmeta', $post_meta_ids );
+		$in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'";
+		$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" );
+		do_action( 'deleted_postmeta', $post_meta_ids );
+	}
+
+	do_action( 'delete_post', $post_id );
+	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));
+	do_action( 'deleted_post', $post_id );
+
+	$uploadpath = wp_upload_dir();
+
+	if ( ! empty($meta['thumb']) ) {
+		// Don't delete the thumb if another attachment uses it
+		if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $meta['thumb'] . '%', $post_id)) ) {
+			$thumbfile = str_replace(basename($file), $meta['thumb'], $file);
+			$thumbfile = apply_filters('wp_delete_file', $thumbfile);
+			@ unlink( path_join($uploadpath['basedir'], $thumbfile) );
+		}
+	}
+
+	// remove intermediate and backup images if there are any
+	foreach ( get_intermediate_image_sizes() as $size ) {
+		if ( $intermediate = image_get_intermediate_size($post_id, $size) ) {
+			$intermediate_file = apply_filters('wp_delete_file', $intermediate['path']);
+			@ unlink( path_join($uploadpath['basedir'], $intermediate_file) );
+		}
+	}
+
+	if ( is_array($backup_sizes) ) {
+		foreach ( $backup_sizes as $size ) {
+			$del_file = path_join( dirname($meta['file']), $size['file'] );
+			$del_file = apply_filters('wp_delete_file', $del_file);
+			@ unlink( path_join($uploadpath['basedir'], $del_file) );
+		}
+	}
+
+	$file = apply_filters('wp_delete_file', $file);
+
+	if ( ! empty($file) )
+		@ unlink($file);
+
+	clean_post_cache($post_id);
+
+	return $post;
+}
+
+/**
+ * Retrieve attachment meta field for attachment ID.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_id Attachment ID
+ * @param bool $unfiltered Optional, default is false. If true, filters are not run.
+ * @return string|bool Attachment meta field. False on failure.
+ */
+function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) {
+	$post_id = (int) $post_id;
+	if ( !$post =& get_post( $post_id ) )
+		return false;
+
+	$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
+
+	if ( $unfiltered )
+		return $data;
+
+	return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
+}
+
+/**
+ * Update metadata for an attachment.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_id Attachment ID.
+ * @param array $data Attachment data.
+ * @return int
+ */
+function wp_update_attachment_metadata( $post_id, $data ) {
+	$post_id = (int) $post_id;
+	if ( !$post =& get_post( $post_id ) )
+		return false;
+
+	$data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
+
+	return update_post_meta( $post->ID, '_wp_attachment_metadata', $data);
+}
+
+/**
+ * Retrieve the URL for an attachment.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_id Attachment ID.
+ * @return string
+ */
+function wp_get_attachment_url( $post_id = 0 ) {
+	$post_id = (int) $post_id;
+	if ( !$post =& get_post( $post_id ) )
+		return false;
+
+	$url = '';
+	if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { //Get attached file
+		if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory
+			if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location
+				$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location
+			elseif ( false !== strpos($file, 'wp-content/uploads') )
+				$url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );
+			else
+				$url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.
+		}
+	}
+
+	if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recomended to rely upon this.
+		$url = get_the_guid( $post->ID );
+
+	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
+
+	if ( 'attachment' != $post->post_type || empty( $url ) )
+		return false;
+
+	return $url;
+}
+
+/**
+ * Retrieve thumbnail for an attachment.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_id Attachment ID.
+ * @return mixed False on failure. Thumbnail file path on success.
+ */
+function wp_get_attachment_thumb_file( $post_id = 0 ) {
+	$post_id = (int) $post_id;
+	if ( !$post =& get_post( $post_id ) )
+		return false;
+	if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) )
+		return false;
+
+	$file = get_attached_file( $post->ID );
+
+	if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) )
+		return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
+	return false;
+}
+
+/**
+ * Retrieve URL for an attachment thumbnail.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_id Attachment ID
+ * @return string|bool False on failure. Thumbnail URL on success.
+ */
+function wp_get_attachment_thumb_url( $post_id = 0 ) {
+	$post_id = (int) $post_id;
+	if ( !$post =& get_post( $post_id ) )
+		return false;
+	if ( !$url = wp_get_attachment_url( $post->ID ) )
+		return false;
+
+	$sized = image_downsize( $post_id, 'thumbnail' );
+	if ( $sized )
+		return $sized[0];
+
+	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
+		return false;
+
+	$url = str_replace(basename($url), basename($thumb), $url);
+
+	return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
+}
+
+/**
+ * Check if the attachment is an image.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_id Attachment ID
+ * @return bool
+ */
+function wp_attachment_is_image( $post_id = 0 ) {
+	$post_id = (int) $post_id;
+	if ( !$post =& get_post( $post_id ) )
+		return false;
+
+	if ( !$file = get_attached_file( $post->ID ) )
+		return false;
+
+	$ext = preg_match('/\.([^.]+)$/', $file, $matches) ? strtolower($matches[1]) : false;
+
+	$image_exts = array('jpg', 'jpeg', 'gif', 'png');
+
+	if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import' == $post->post_mime_type && in_array($ext, $image_exts) )
+		return true;
+	return false;
+}
+
+/**
+ * Retrieve the icon for a MIME type.
+ *
+ * @since 2.1.0
+ *
+ * @param string $mime MIME type
+ * @return string|bool
+ */
+function wp_mime_type_icon( $mime = 0 ) {
+	if ( !is_numeric($mime) )
+		$icon = wp_cache_get("mime_type_icon_$mime");
+	if ( empty($icon) ) {
+		$post_id = 0;
+		$post_mimes = array();
+		if ( is_numeric($mime) ) {
+			$mime = (int) $mime;
+			if ( $post =& get_post( $mime ) ) {
+				$post_id = (int) $post->ID;
+				$ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid);
+				if ( !empty($ext) ) {
+					$post_mimes[] = $ext;
+					if ( $ext_type = wp_ext2type( $ext ) )
+						$post_mimes[] = $ext_type;
+				}
+				$mime = $post->post_mime_type;
+			} else {
+				$mime = 0;
+			}
+		} else {
+			$post_mimes[] = $mime;
+		}
+
+		$icon_files = wp_cache_get('icon_files');
+
+		if ( !is_array($icon_files) ) {
+			$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
+			$icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url('images/crystal') );
+			$dirs = apply_filters( 'icon_dirs', array($icon_dir => $icon_dir_uri) );
+			$icon_files = array();
+			while ( $dirs ) {
+				$dir = array_shift($keys = array_keys($dirs));
+				$uri = array_shift($dirs);
+				if ( $dh = opendir($dir) ) {
+					while ( false !== $file = readdir($dh) ) {
+						$file = basename($file);
+						if ( substr($file, 0, 1) == '.' )
+							continue;
+						if ( !in_array(strtolower(substr($file, -4)), array('.png', '.gif', '.jpg') ) ) {
+							if ( is_dir("$dir/$file") )
+								$dirs["$dir/$file"] = "$uri/$file";
+							continue;
+						}
+						$icon_files["$dir/$file"] = "$uri/$file";
+					}
+					closedir($dh);
+				}
+			}
+			wp_cache_set('icon_files', $icon_files, 600);
+		}
+
+		// Icon basename - extension = MIME wildcard
+		foreach ( $icon_files as $file => $uri )
+			$types[ preg_replace('/^([^.]*).*$/', '$1', basename($file)) ] =& $icon_files[$file];
+
+		if ( ! empty($mime) ) {
+			$post_mimes[] = substr($mime, 0, strpos($mime, '/'));
+			$post_mimes[] = substr($mime, strpos($mime, '/') + 1);
+			$post_mimes[] = str_replace('/', '_', $mime);
+		}
+
+		$matches = wp_match_mime_types(array_keys($types), $post_mimes);
+		$matches['default'] = array('default');
+
+		foreach ( $matches as $match => $wilds ) {
+			if ( isset($types[$wilds[0]])) {
+				$icon = $types[$wilds[0]];
+				if ( !is_numeric($mime) )
+					wp_cache_set("mime_type_icon_$mime", $icon);
+				break;
+			}
+		}
+	}
+
+	return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); // Last arg is 0 if function pass mime type.
+}
+
+/**
+ * Checked for changed slugs for published post objects and save the old slug.
+ *
+ * The function is used when a post object of any type is updated,
+ * by comparing the current and previous post objects.
+ *
+ * If the slug was changed and not already part of the old slugs then it will be
+ * added to the post meta field ('_wp_old_slug') for storing old slugs for that
+ * post.
+ *
+ * The most logically usage of this function is redirecting changed post objects, so
+ * that those that linked to an changed post will be redirected to the new post.
+ *
+ * @since 2.1.0
+ *
+ * @param int $post_id Post ID.
+ * @param object $post The Post Object
+ * @param object $post_before The Previous Post Object
+ * @return int Same as $post_id
+ */
+function wp_check_for_changed_slugs($post_id, $post, $post_before) {
+	// dont bother if it hasnt changed
+	if ( $post->post_name == $post_before->post_name )
+		return;
+
+	// we're only concerned with published, non-hierarchical objects
+	if ( $post->post_status != 'publish' || is_post_type_hierarchical( $post->post_type ) )
+		return;
+
+	$old_slugs = (array) get_post_meta($post_id, '_wp_old_slug');
+
+	// if we haven't added this old slug before, add it now
+	if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) )
+		add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
+
+	// if the new slug was used previously, delete it from the list
+	if ( in_array($post->post_name, $old_slugs) )
+		delete_post_meta($post_id, '_wp_old_slug', $post->post_name);
+}
+
+/**
+ * Retrieve the private post SQL based on capability.
+ *
+ * This function provides a standardized way to appropriately select on the
+ * post_status of posts/pages. The function will return a piece of SQL code that
+ * can be added to a WHERE clause; this SQL is constructed to allow all
+ * published posts, and all private posts to which the user has access.
+ *
+ * It also allows plugins that define their own post type to control the cap by
+ * using the hook 'pub_priv_sql_capability'. The plugin is expected to return
+ * the capability the user must have to read the private post type.
+ *
+ * @since 2.2.0
+ *
+ * @uses $user_ID
+ * @uses apply_filters() Call 'pub_priv_sql_capability' filter for plugins with different post types.
+ *
+ * @param string $post_type currently only supports 'post' or 'page'.
+ * @return string SQL code that can be added to a where clause.
+ */
+function get_private_posts_cap_sql($post_type) {
+	return get_posts_by_author_sql($post_type, FALSE);
+}
+
+/**
+ * Retrieve the post SQL based on capability, author, and type.
+ *
+ * See above for full description.
+ *
+ * @since 3.0.0
+ * @param string $post_type currently only supports 'post' or 'page'.
+ * @param bool $full Optional.  Returns a full WHERE statement instead of just an 'andalso' term.
+ * @param int $post_author Optional.  Query posts having a single author ID.
+ * @return string SQL WHERE code that can be added to a query.
+ */
+function get_posts_by_author_sql($post_type, $full = TRUE, $post_author = NULL) {
+	global $user_ID, $wpdb;
+
+	// Private posts
+	if ($post_type == 'post') {
+		$cap = 'read_private_posts';
+	// Private pages
+	} elseif ($post_type == 'page') {
+		$cap = 'read_private_pages';
+	// Dunno what it is, maybe plugins have their own post type?
+	} else {
+		$cap = '';
+		$cap = apply_filters('pub_priv_sql_capability', $cap);
+
+		if (empty($cap)) {
+			// We don't know what it is, filters don't change anything,
+			// so set the SQL up to return nothing.
+			return ' 1 = 0 ';
+		}
+	}
+
+	if ($full) {
+		if (is_null($post_author)) {
+			$sql = $wpdb->prepare('WHERE post_type = %s AND ', $post_type);
+		} else {
+			$sql = $wpdb->prepare('WHERE post_author = %d AND post_type = %s AND ', $post_author, $post_type);
+		}
+	} else {
+		$sql = '';
+	}
+
+	$sql .= "(post_status = 'publish'";
+
+	if (current_user_can($cap)) {
+		// Does the user have the capability to view private posts? Guess so.
+		$sql .= " OR post_status = 'private'";
+	} elseif (is_user_logged_in()) {
+		// Users can view their own private posts.
+		$id = (int) $user_ID;
+		if (is_null($post_author) || !$full) {
+			$sql .= " OR post_status = 'private' AND post_author = $id";
+		} elseif ($id == (int)$post_author) {
+			$sql .= " OR post_status = 'private'";
+		} // else none
+	} // else none
+
+	$sql .= ')';
+
+	return $sql;
+}
+
+/**
+ * Retrieve the date that the last post was published.
+ *
+ * The server timezone is the default and is the difference between GMT and
+ * server time. The 'blog' value is the date when the last post was posted. The
+ * 'gmt' is when the last post was posted in GMT formatted date.
+ *
+ * @since 0.71
+ *
+ * @uses apply_filters() Calls 'get_lastpostdate' filter
+ *
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
+ * @return string The date of the last post.
+ */
+function get_lastpostdate($timezone = 'server') {
+	return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone );
+}
+
+/**
+ * Retrieve last post modified date depending on timezone.
+ *
+ * The server timezone is the default and is the difference between GMT and
+ * server time. The 'blog' value is just when the last post was modified. The
+ * 'gmt' is when the last post was modified in GMT time.
+ *
+ * @since 1.2.0
+ * @uses apply_filters() Calls 'get_lastpostmodified' filter
+ *
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
+ * @return string The date the post was last modified.
+ */
+function get_lastpostmodified($timezone = 'server') {
+	$lastpostmodified = _get_last_post_time( $timezone, 'modified' );
+
+	$lastpostdate = get_lastpostdate($timezone);
+	if ( $lastpostdate > $lastpostmodified )
+		$lastpostmodified = $lastpostdate;
+
+	return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
+}
+
+/**
+ * Retrieve latest post date data based on timezone.
+ *
+ * @access private
+ * @since 3.1.0
+ *
+ * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
+ * @param string $field Field to check. Can be 'date' or 'modified'.
+ * @return string The date.
+ */
+function _get_last_post_time( $timezone, $field ) {
+	global $wpdb;
+
+	if ( !in_array( $field, array( 'date', 'modified' ) ) )
+		return false;
+
+	$timezone = strtolower( $timezone );
+
+	$key = "lastpost{$field}:$timezone";
+
+	$date = wp_cache_get( $key, 'timeinfo' );
+
+	if ( !$date ) {
+		$add_seconds_server = date('Z');
+
+		$post_types = get_post_types( array( 'publicly_queryable' => true ) );
+		array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) );
+		$post_types = "'" . implode( "', '", $post_types ) . "'";
+
+		switch ( $timezone ) {
+			case 'gmt':
+				$date = $wpdb->get_var("SELECT post_{$field}_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
+				break;
+			case 'blog':
+				$date = $wpdb->get_var("SELECT post_{$field} FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
+				break;
+			case 'server':
+				$date = $wpdb->get_var("SELECT DATE_ADD(post_{$field}_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_{$field}_gmt DESC LIMIT 1");
+				break;
+		}
+
+		if ( $date )
+			wp_cache_set( $key, $date, 'timeinfo' );
+	}
+
+	return $date;
+}
+
+/**
+ * Updates posts in cache.
+ *
+ * @usedby update_page_cache() Aliased by this function.
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 1.5.1
+ *
+ * @param array $posts Array of post objects
+ */
+function update_post_cache(&$posts) {
+	if ( !$posts )
+		return;
+
+	foreach ( $posts as $post )
+		wp_cache_add($post->ID, $post, 'posts');
+}
+
+/**
+ * Will clean the post in the cache.
+ *
+ * Cleaning means delete from the cache of the post. Will call to clean the term
+ * object cache associated with the post ID.
+ *
+ * clean_post_cache() will call itself recursively for each child post.
+ *
+ * This function not run if $_wp_suspend_cache_invalidation is not empty. See
+ * wp_suspend_cache_invalidation().
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 2.0.0
+ *
+ * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any).
+ *
+ * @param int $id The Post ID in the cache to clean
+ */
+function clean_post_cache($id) {
+	global $_wp_suspend_cache_invalidation, $wpdb;
+
+	if ( !empty($_wp_suspend_cache_invalidation) )
+		return;
+
+	$id = (int) $id;
+
+	if ( 0 === $id )
+		return;
+
+	wp_cache_delete($id, 'posts');
+	wp_cache_delete($id, 'post_meta');
+
+	clean_object_term_cache($id, 'post');
+
+	wp_cache_delete( 'wp_get_archives', 'general' );
+
+	do_action('clean_post_cache', $id);
+
+	if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {
+		foreach ( $children as $cid ) {
+			// Loop detection
+			if ( $cid == $id )
+				continue;
+			clean_post_cache( $cid );
+		}
+	}
+
+	if ( is_multisite() )
+		wp_cache_delete( $wpdb->blogid . '-' . $id, 'global-posts' );
+}
+
+/**
+ * Alias of update_post_cache().
+ *
+ * @see update_post_cache() Posts and pages are the same, alias is intentional
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 1.5.1
+ *
+ * @param array $pages list of page objects
+ */
+function update_page_cache(&$pages) {
+	update_post_cache($pages);
+}
+
+/**
+ * Will clean the page in the cache.
+ *
+ * Clean (read: delete) page from cache that matches $id. Will also clean cache
+ * associated with 'all_page_ids' and 'get_pages'.
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 2.0.0
+ *
+ * @uses do_action() Will call the 'clean_page_cache' hook action.
+ *
+ * @param int $id Page ID to clean
+ */
+function clean_page_cache($id) {
+	clean_post_cache($id);
+
+	wp_cache_delete( 'all_page_ids', 'posts' );
+	wp_cache_delete( 'get_pages', 'posts' );
+
+	do_action('clean_page_cache', $id);
+}
+
+/**
+ * Call major cache updating functions for list of Post objects.
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 1.5.0
+ *
+ * @uses $wpdb
+ * @uses update_post_cache()
+ * @uses update_object_term_cache()
+ * @uses update_postmeta_cache()
+ *
+ * @param array $posts Array of Post objects
+ * @param string $post_type The post type of the posts in $posts. Default is 'post'.
+ * @param bool $update_term_cache Whether to update the term cache. Default is true.
+ * @param bool $update_meta_cache Whether to update the meta cache. Default is true.
+ */
+function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) {
+	// No point in doing all this work if we didn't match any posts.
+	if ( !$posts )
+		return;
+
+	update_post_cache($posts);
+
+	$post_ids = array();
+	foreach ( $posts as $post )
+		$post_ids[] = $post->ID;
+
+	if ( empty($post_type) )
+		$post_type = 'post';
+
+	if ( $update_term_cache ) {
+		if ( is_array($post_type) ) {
+			$ptypes = $post_type;
+		} elseif ( 'any' == $post_type ) {
+			// Just use the post_types in the supplied posts.
+			foreach ( $posts as $post )
+				$ptypes[] = $post->post_type;
+			$ptypes = array_unique($ptypes);
+		} else {
+			$ptypes = array($post_type);
+		}
+
+		if ( ! empty($ptypes) )
+			update_object_term_cache($post_ids, $ptypes);
+	}
+
+	if ( $update_meta_cache )
+		update_postmeta_cache($post_ids);
+}
+
+/**
+ * Updates metadata cache for list of post IDs.
+ *
+ * Performs SQL query to retrieve the metadata for the post IDs and updates the
+ * metadata cache for the posts. Therefore, the functions, which call this
+ * function, do not need to perform SQL queries on their own.
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 2.1.0
+ *
+ * @uses $wpdb
+ *
+ * @param array $post_ids List of post IDs.
+ * @return bool|array Returns false if there is nothing to update or an array of metadata.
+ */
+function update_postmeta_cache($post_ids) {
+	return update_meta_cache('post', $post_ids);
+}
+
+/**
+ * Will clean the attachment in the cache.
+ *
+ * Cleaning means delete from the cache. Optionaly will clean the term
+ * object cache associated with the attachment ID.
+ *
+ * This function will not run if $_wp_suspend_cache_invalidation is not empty. See
+ * wp_suspend_cache_invalidation().
+ *
+ * @package WordPress
+ * @subpackage Cache
+ * @since 3.0.0
+ *
+ * @uses do_action() Calls 'clean_attachment_cache' on $id.
+ *
+ * @param int $id The attachment ID in the cache to clean
+ * @param bool $clean_terms optional. Whether to clean terms cache
+ */
+function clean_attachment_cache($id, $clean_terms = false) {
+	global $_wp_suspend_cache_invalidation;
+
+	if ( !empty($_wp_suspend_cache_invalidation) )
+		return;
+
+	$id = (int) $id;
+
+	wp_cache_delete($id, 'posts');
+	wp_cache_delete($id, 'post_meta');
+
+	if ( $clean_terms )
+		clean_object_term_cache($id, 'attachment');
+
+	do_action('clean_attachment_cache', $id);
+}
+
+//
+// Hooks
+//
+
+/**
+ * Hook for managing future post transitions to published.
+ *
+ * @since 2.3.0
+ * @access private
+ * @uses $wpdb
+ * @uses do_action() Calls 'private_to_published' on post ID if this is a 'private_to_published' call.
+ * @uses wp_clear_scheduled_hook() with 'publish_future_post' and post ID.
+ *
+ * @param string $new_status New post status
+ * @param string $old_status Previous post status
+ * @param object $post Object type containing the post information
+ */
+function _transition_post_status($new_status, $old_status, $post) {
+	global $wpdb;
+
+	if ( $old_status != 'publish' && $new_status == 'publish' ) {
+		// Reset GUID if transitioning to publish and it is empty
+		if ( '' == get_the_guid($post->ID) )
+			$wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
+		do_action('private_to_published', $post->ID);  // Deprecated, use private_to_publish
+	}
+
+	// If published posts changed clear the lastpostmodified cache
+	if ( 'publish' == $new_status || 'publish' == $old_status) {
+		foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
+			wp_cache_delete( "lastpostmodified:$timezone", 'timeinfo' );
+			wp_cache_delete( "lastpostdate:$timezone", 'timeinfo' );
+		}
+	}
+
+	// Always clears the hook in case the post status bounced from future to draft.
+	wp_clear_scheduled_hook('publish_future_post', array( $post->ID ) );
+}
+
+/**
+ * Hook used to schedule publication for a post marked for the future.
+ *
+ * The $post properties used and must exist are 'ID' and 'post_date_gmt'.
+ *
+ * @since 2.3.0
+ * @access private
+ *
+ * @param int $deprecated Not used. Can be set to null. Never implemented.
+ *   Not marked as deprecated with _deprecated_argument() as it conflicts with
+ *   wp_transition_post_status() and the default filter for _future_post_hook().
+ * @param object $post Object type containing the post information
+ */
+function _future_post_hook( $deprecated = '', $post ) {
+	wp_clear_scheduled_hook( 'publish_future_post', array( $post->ID ) );
+	wp_schedule_single_event( strtotime( get_gmt_from_date( $post->post_date ) . ' GMT') , 'publish_future_post', array( $post->ID ) );
+}
+
+/**
+ * Hook to schedule pings and enclosures when a post is published.
+ *
+ * @since 2.3.0
+ * @access private
+ * @uses $wpdb
+ * @uses XMLRPC_REQUEST and APP_REQUEST constants.
+ * @uses do_action() Calls 'xmlprc_publish_post' on post ID if XMLRPC_REQUEST is defined.
+ * @uses do_action() Calls 'app_publish_post' on post ID if APP_REQUEST is defined.
+ *
+ * @param int $post_id The ID in the database table of the post being published
+ */
+function _publish_post_hook($post_id) {
+	global $wpdb;
+
+	if ( defined('XMLRPC_REQUEST') )
+		do_action('xmlrpc_publish_post', $post_id);
+	if ( defined('APP_REQUEST') )
+		do_action('app_publish_post', $post_id);
+
+	if ( defined('WP_IMPORTING') )
+		return;
+
+	$data = array( 'post_id' => $post_id, 'meta_value' => '1' );
+	if ( get_option('default_pingback_flag') ) {
+		$wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_pingme' ) );
+		do_action( 'added_postmeta', $wpdb->insert_id, $post_id, '_pingme', 1 );
+	}
+	$wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_encloseme' ) );
+	do_action( 'added_postmeta', $wpdb->insert_id, $post_id, '_encloseme', 1 );
+
+	wp_schedule_single_event(time(), 'do_pings');
+}
+
+/**
+ * Hook used to prevent page/post cache and rewrite rules from staying dirty.
+ *
+ * Does two things. If the post is a page and has a template then it will
+ * update/add that template to the meta. For both pages and posts, it will clean
+ * the post cache to make sure that the cache updates to the changes done
+ * recently. For pages, the rewrite rules of WordPress are flushed to allow for
+ * any changes.
+ *
+ * The $post parameter, only uses 'post_type' property and 'page_template'
+ * property.
+ *
+ * @since 2.3.0
+ * @access private
+ * @uses $wp_rewrite Flushes Rewrite Rules.
+ *
+ * @param int $post_id The ID in the database table for the $post
+ * @param object $post Object type containing the post information
+ */
+function _save_post_hook($post_id, $post) {
+	if ( $post->post_type == 'page' ) {
+		clean_page_cache($post_id);
+		// Avoid flushing rules for every post during import.
+		if ( !defined('WP_IMPORTING') ) {
+			global $wp_rewrite;
+			$wp_rewrite->flush_rules(false);
+		}
+	} else {
+		clean_post_cache($post_id);
+	}
+}
+
+/**
+ * Retrieve post ancestors and append to post ancestors property.
+ *
+ * Will only retrieve ancestors once, if property is already set, then nothing
+ * will be done. If there is not a parent post, or post ID and post parent ID
+ * are the same then nothing will be done.
+ *
+ * The parameter is passed by reference, so nothing needs to be returned. The
+ * property will be updated and can be referenced after the function is
+ * complete. The post parent will be an ancestor and the parent of the post
+ * parent will be an ancestor. There will only be two ancestors at the most.
+ *
+ * @since 2.5.0
+ * @access private
+ * @uses $wpdb
+ *
+ * @param object $_post Post data.
+ * @return null When nothing needs to be done.
+ */
+function _get_post_ancestors(&$_post) {
+	global $wpdb;
+
+	if ( isset($_post->ancestors) )
+		return;
+
+	$_post->ancestors = array();
+
+	if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent )
+		return;
+
+	$id = $_post->ancestors[] = $_post->post_parent;
+	while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) {
+		// Loop detection: If the ancestor has been seen before, break.
+		if ( ( $ancestor == $_post->ID ) || in_array($ancestor,  $_post->ancestors) )
+			break;
+		$id = $_post->ancestors[] = $ancestor;
+	}
+}
+
+/**
+ * Determines which fields of posts are to be saved in revisions.
+ *
+ * Does two things. If passed a post *array*, it will return a post array ready
+ * to be insterted into the posts table as a post revision. Otherwise, returns
+ * an array whose keys are the post fields to be saved for post revisions.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ * @access private
+ * @uses apply_filters() Calls '_wp_post_revision_fields' on 'title', 'content' and 'excerpt' fields.
+ *
+ * @param array $post Optional a post array to be processed for insertion as a post revision.
+ * @param bool $autosave optional Is the revision an autosave?
+ * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
+ */
+function _wp_post_revision_fields( $post = null, $autosave = false ) {
+	static $fields = false;
+
+	if ( !$fields ) {
+		// Allow these to be versioned
+		$fields = array(
+			'post_title' => __( 'Title' ),
+			'post_content' => __( 'Content' ),
+			'post_excerpt' => __( 'Excerpt' ),
+		);
+
+		// Runs only once
+		$fields = apply_filters( '_wp_post_revision_fields', $fields );
+
+		// WP uses these internally either in versioning or elsewhere - they cannot be versioned
+		foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect )
+			unset( $fields[$protect] );
+	}
+
+	if ( !is_array($post) )
+		return $fields;
+
+	$return = array();
+	foreach ( array_intersect( array_keys( $post ), array_keys( $fields ) ) as $field )
+		$return[$field] = $post[$field];
+
+	$return['post_parent']   = $post['ID'];
+	$return['post_status']   = 'inherit';
+	$return['post_type']     = 'revision';
+	$return['post_name']     = $autosave ? "$post[ID]-autosave" : "$post[ID]-revision";
+	$return['post_date']     = isset($post['post_modified']) ? $post['post_modified'] : '';
+	$return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : '';
+
+	return $return;
+}
+
+/**
+ * Saves an already existing post as a post revision.
+ *
+ * Typically used immediately prior to post updates.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses _wp_put_post_revision()
+ *
+ * @param int $post_id The ID of the post to save as a revision.
+ * @return mixed Null or 0 if error, new revision ID, if success.
+ */
+function wp_save_post_revision( $post_id ) {
+	// We do autosaves manually with wp_create_post_autosave()
+	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
+		return;
+
+	// WP_POST_REVISIONS = 0, false
+	if ( ! WP_POST_REVISIONS )
+		return;
+
+	if ( !$post = get_post( $post_id, ARRAY_A ) )
+		return;
+
+	if ( !post_type_supports($post['post_type'], 'revisions') )
+		return;
+
+	$return = _wp_put_post_revision( $post );
+
+	// WP_POST_REVISIONS = true (default), -1
+	if ( !is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 )
+		return $return;
+
+	// all revisions and (possibly) one autosave
+	$revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) );
+
+	// WP_POST_REVISIONS = (int) (# of autosaves to save)
+	$delete = count($revisions) - WP_POST_REVISIONS;
+
+	if ( $delete < 1 )
+		return $return;
+
+	$revisions = array_slice( $revisions, 0, $delete );
+
+	for ( $i = 0; isset($revisions[$i]); $i++ ) {
+		if ( false !== strpos( $revisions[$i]->post_name, 'autosave' ) )
+			continue;
+		wp_delete_post_revision( $revisions[$i]->ID );
+	}
+
+	return $return;
+}
+
+/**
+ * Retrieve the autosaved data of the specified post.
+ *
+ * Returns a post object containing the information that was autosaved for the
+ * specified post.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @param int $post_id The post ID.
+ * @return object|bool The autosaved data or false on failure or when no autosave exists.
+ */
+function wp_get_post_autosave( $post_id ) {
+
+	if ( !$post = get_post( $post_id ) )
+		return false;
+
+	$q = array(
+		'name' => "{$post->ID}-autosave",
+		'post_parent' => $post->ID,
+		'post_type' => 'revision',
+		'post_status' => 'inherit'
+	);
+
+	// Use WP_Query so that the result gets cached
+	$autosave_query = new WP_Query;
+
+	add_action( 'parse_query', '_wp_get_post_autosave_hack' );
+	$autosave = $autosave_query->query( $q );
+	remove_action( 'parse_query', '_wp_get_post_autosave_hack' );
+
+	if ( $autosave && is_array($autosave) && is_object($autosave[0]) )
+		return $autosave[0];
+
+	return false;
+}
+
+/**
+ * Internally used to hack WP_Query into submission.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @param object $query WP_Query object
+ */
+function _wp_get_post_autosave_hack( $query ) {
+	$query->is_single = false;
+}
+
+/**
+ * Determines if the specified post is a revision.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @param int|object $post Post ID or post object.
+ * @return bool|int False if not a revision, ID of revision's parent otherwise.
+ */
+function wp_is_post_revision( $post ) {
+	if ( !$post = wp_get_post_revision( $post ) )
+		return false;
+	return (int) $post->post_parent;
+}
+
+/**
+ * Determines if the specified post is an autosave.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @param int|object $post Post ID or post object.
+ * @return bool|int False if not a revision, ID of autosave's parent otherwise
+ */
+function wp_is_post_autosave( $post ) {
+	if ( !$post = wp_get_post_revision( $post ) )
+		return false;
+	if ( "{$post->post_parent}-autosave" !== $post->post_name )
+		return false;
+	return (int) $post->post_parent;
+}
+
+/**
+ * Inserts post data into the posts table as a post revision.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses wp_insert_post()
+ *
+ * @param int|object|array $post Post ID, post object OR post array.
+ * @param bool $autosave Optional. Is the revision an autosave?
+ * @return mixed Null or 0 if error, new revision ID if success.
+ */
+function _wp_put_post_revision( $post = null, $autosave = false ) {
+	if ( is_object($post) )
+		$post = get_object_vars( $post );
+	elseif ( !is_array($post) )
+		$post = get_post($post, ARRAY_A);
+	if ( !$post || empty($post['ID']) )
+		return;
+
+	if ( isset($post['post_type']) && 'revision' == $post['post_type'] )
+		return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) );
+
+	$post = _wp_post_revision_fields( $post, $autosave );
+	$post = add_magic_quotes($post); //since data is from db
+
+	$revision_id = wp_insert_post( $post );
+	if ( is_wp_error($revision_id) )
+		return $revision_id;
+
+	if ( $revision_id )
+		do_action( '_wp_put_post_revision', $revision_id );
+	return $revision_id;
+}
+
+/**
+ * Gets a post revision.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses get_post()
+ *
+ * @param int|object $post Post ID or post object
+ * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N.
+ * @param string $filter Optional sanitation filter.  @see sanitize_post()
+ * @return mixed Null if error or post object if success
+ */
+function &wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {
+	$null = null;
+	if ( !$revision = get_post( $post, OBJECT, $filter ) )
+		return $revision;
+	if ( 'revision' !== $revision->post_type )
+		return $null;
+
+	if ( $output == OBJECT ) {
+		return $revision;
+	} elseif ( $output == ARRAY_A ) {
+		$_revision = get_object_vars($revision);
+		return $_revision;
+	} elseif ( $output == ARRAY_N ) {
+		$_revision = array_values(get_object_vars($revision));
+		return $_revision;
+	}
+
+	return $revision;
+}
+
+/**
+ * Restores a post to the specified revision.
+ *
+ * Can restore a past revision using all fields of the post revision, or only selected fields.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses wp_get_post_revision()
+ * @uses wp_update_post()
+ * @uses do_action() Calls 'wp_restore_post_revision' on post ID and revision ID if wp_update_post()
+ *  is successful.
+ *
+ * @param int|object $revision_id Revision ID or revision object.
+ * @param array $fields Optional. What fields to restore from. Defaults to all.
+ * @return mixed Null if error, false if no fields to restore, (int) post ID if success.
+ */
+function wp_restore_post_revision( $revision_id, $fields = null ) {
+	if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) )
+		return $revision;
+
+	if ( !is_array( $fields ) )
+		$fields = array_keys( _wp_post_revision_fields() );
+
+	$update = array();
+	foreach( array_intersect( array_keys( $revision ), $fields ) as $field )
+		$update[$field] = $revision[$field];
+
+	if ( !$update )
+		return false;
+
+	$update['ID'] = $revision['post_parent'];
+
+	$update = add_magic_quotes( $update ); //since data is from db
+
+	$post_id = wp_update_post( $update );
+	if ( is_wp_error( $post_id ) )
+		return $post_id;
+
+	if ( $post_id )
+		do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] );
+
+	return $post_id;
+}
+
+/**
+ * Deletes a revision.
+ *
+ * Deletes the row from the posts table corresponding to the specified revision.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses wp_get_post_revision()
+ * @uses wp_delete_post()
+ *
+ * @param int|object $revision_id Revision ID or revision object.
+ * @return mixed Null or WP_Error if error, deleted post if success.
+ */
+function wp_delete_post_revision( $revision_id ) {
+	if ( !$revision = wp_get_post_revision( $revision_id ) )
+		return $revision;
+
+	$delete = wp_delete_post( $revision->ID );
+	if ( is_wp_error( $delete ) )
+		return $delete;
+
+	if ( $delete )
+		do_action( 'wp_delete_post_revision', $revision->ID, $revision );
+
+	return $delete;
+}
+
+/**
+ * Returns all revisions of specified post.
+ *
+ * @package WordPress
+ * @subpackage Post_Revisions
+ * @since 2.6.0
+ *
+ * @uses get_children()
+ *
+ * @param int|object $post_id Post ID or post object
+ * @return array empty if no revisions
+ */
+function wp_get_post_revisions( $post_id = 0, $args = null ) {
+	if ( ! WP_POST_REVISIONS )
+		return array();
+	if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) )
+		return array();
+
+	$defaults = array( 'order' => 'DESC', 'orderby' => 'date' );
+	$args = wp_parse_args( $args, $defaults );
+	$args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) );
+
+	if ( !$revisions = get_children( $args ) )
+		return array();
+	return $revisions;
+}
+
+function _set_preview($post) {
+
+	if ( ! is_object($post) )
+		return $post;
+
+	$preview = wp_get_post_autosave($post->ID);
+
+	if ( ! is_object($preview) )
+		return $post;
+
+	$preview = sanitize_post($preview);
+
+	$post->post_content = $preview->post_content;
+	$post->post_title = $preview->post_title;
+	$post->post_excerpt = $preview->post_excerpt;
+
+	return $post;
+}
+
+function _show_post_preview() {
+
+	if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) {
+		$id = (int) $_GET['preview_id'];
+
+		if ( false == wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) )
+			wp_die( __('You do not have permission to preview drafts.') );
+
+		add_filter('the_preview', '_set_preview');
+	}
+}
+
+/**
+ * Returns the post's parent's post_ID
+ *
+ * @since 3.1.0
+ *
+ * @param int $post_id
+ *
+ * @return int|bool false on error
+ */
+function wp_get_post_parent_id( $post_ID ) {
+	$post = get_post( $post_ID );
+	if ( !$post || is_wp_error( $post ) )
+		return false;
+	return (int) $post->post_parent;
+}
+
+/**
+ * Checks the given subset of the post hierarchy for hierarchy loops.
+ * Prevents loops from forming and breaks those that it finds.
+ *
+ * Attached to the wp_insert_post_parent filter.
+ *
+ * @since 3.1.0
+ * @uses wp_find_hierarchy_loop()
+ *
+ * @param int $post_parent ID of the parent for the post we're checking.
+ * @parem int $post_ID ID of the post we're checking.
+ *
+ * @return int The new post_parent for the post.
+ */
+function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
+	// Nothing fancy here - bail
+	if ( !$post_parent )
+		return 0;
+
+	// New post can't cause a loop
+	if ( empty( $post_ID ) )
+		return $post_parent;
+
+	// Can't be its own parent
+	if ( $post_parent == $post_ID )
+		return 0;
+
+	// Now look for larger loops
+
+	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
+		return $post_parent; // No loop
+
+	// Setting $post_parent to the given value causes a loop
+	if ( isset( $loop[$post_ID] ) )
+		return 0;
+
+	// There's a loop, but it doesn't contain $post_ID.  Break the loop.
+	foreach ( array_keys( $loop ) as $loop_member )
+		wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
+
+	return $post_parent;
+}
+
+/**
+ * Returns an array of post format slugs to their translated and pretty display versions
+ *
+ * @since 3.1.0
+ *
+ * @return array The array of translations
+ */
+function get_post_format_strings() {
+	$strings = array(
+		'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard
+		'aside'    => _x( 'Aside',    'Post format' ),
+		'chat'     => _x( 'Chat',     'Post format' ),
+		'gallery'  => _x( 'Gallery',  'Post format' ),
+		'link'     => _x( 'Link',     'Post format' ),
+		'image'    => _x( 'Image',    'Post format' ),
+		'quote'    => _x( 'Quote',    'Post format' ),
+		'status'   => _x( 'Status',   'Post format' ),
+		'video'    => _x( 'Video',    'Post format' ),
+		'audio'    => _x( 'Audio',    'Post format' ),
+	);
+	return $strings;
+}
+
+/**
+ * Retrieves an array of post format slugs.
+ *
+ * @since 3.1.0
+ *
+ * @return array The array of post format slugs.
+ */
+function get_post_format_slugs() {
+	// 3.2-early: use array_combine() and array_keys( get_post_format_strings() )
+	$slugs = array(
+		'standard' => 'standard', // Special case. any value that evals to false will be considered standard
+		'aside'    => 'aside',
+		'chat'     => 'chat',
+		'gallery'  => 'gallery',
+		'link'     => 'link',
+		'image'    => 'image',
+		'quote'    => 'quote',
+		'status'   => 'status',
+		'video'    => 'video',
+		'audio'    => 'audio',
+	);
+	return $slugs;
+}
+
+/**
+ * Returns a pretty, translated version of a post format slug
+ *
+ * @since 3.1.0
+ *
+ * @param string $slug A post format slug
+ * @return string The translated post format name
+ */
+function get_post_format_string( $slug ) {
+	$strings = get_post_format_strings();
+	if ( !$slug )
+		return $strings['standard'];
+	else
+		return ( isset( $strings[$slug] ) ) ? $strings[$slug] : '';
+}
+
+/**
+ * Sets a post thumbnail.
+ *
+ * @since 3.1.0
+ *
+ * @param int|object $post Post ID or object where thumbnail should be attached.
+ * @param int $thumbnail_id Thumbnail to attach.
+ * @return bool True on success, false on failure.
+ */
+function set_post_thumbnail( $post, $thumbnail_id ) {
+	$post = get_post( $post );
+	$thumbnail_id = absint( $thumbnail_id );
+	if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
+		$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
+		if ( ! empty( $thumbnail_html ) ) {
+			update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
+			return true;
+		}
+	}
+	return false;
+}
+
+/**
+ * Returns a link to a post format index.
+ *
+ * @since 3.1.0
+ *
+ * @param $format string Post format
+ * @return string Link
+ */
+function get_post_format_link( $format ) {
+	$term = get_term_by('slug', 'post-format-' . $format, 'post_format' );
+	if ( ! $term || is_wp_error( $term ) )
+		return false;
+	return get_term_link( $term );
+}
+
+/**
+ * Filters the request to allow for the format prefix.
+ *
+ * @access private
+ * @since 3.1.0
+ */
+function _post_format_request( $qvs ) {
+	if ( ! isset( $qvs['post_format'] ) )
+		return $qvs;
+	$slugs = get_post_format_slugs();
+	if ( isset( $slugs[ $qvs['post_format'] ] ) )
+		$qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ];
+	$tax = get_taxonomy( 'post_format' );
+	$qvs['post_type'] = $tax->object_type;
+	return $qvs;
+}
+add_filter( 'request', '_post_format_request' );
+
+/**
+ * Filters the post format term link to remove the format prefix.
+ *
+ * @access private
+ * @since 3.1.0
+ */
+function _post_format_link( $link, $term, $taxonomy ) {
+	global $wp_rewrite;
+	if ( 'post_format' != $taxonomy )
+		return $link;
+	if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) {
+		return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug ), $link );
+	} else {
+		$link = remove_query_arg( 'post_format', $link );
+		return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link );
+	}
+}
+add_filter( 'term_link', '_post_format_link', 10, 3 );
+
+/**
+ * Remove the post format prefix from the name property of the term object created by get_term().
+ *
+ * @access private
+ * @since 3.1.0
+ */
+function _post_format_get_term( $term ) {
+	if ( isset( $term->slug ) ) {
+		$term->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) );
+	}
+	return $term;
+}
+add_filter( 'get_post_format', '_post_format_get_term' );
+
+/**
+ * Remove the post format prefix from the name property of the term objects created by get_terms().
+ *
+ * @access private
+ * @since 3.1.0
+ */
+function _post_format_get_terms( $terms, $taxonomies, $args ) {
+	if ( in_array( 'post_format', (array) $taxonomies ) ) {
+		if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) {
+			foreach( $terms as $order => $name ) {
+				$terms[$order] = get_post_format_string( str_replace( 'post-format-', '', $name ) );
+			}
+		} else {
+			foreach ( (array) $terms as $order => $term ) {
+				if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) {
+					$terms[$order]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) );
+				}
+			}
+		}
+	}
+	return $terms;
+}
+add_filter( 'get_terms', '_post_format_get_terms', 10, 3 );
+
+/**
+ * Remove the post format prefix from the name property of the term objects created by wp_get_object_terms().
+ *
+ * @access private
+ * @since 3.1.0
+ */
+function _post_format_wp_get_object_terms( $terms ) {
+	foreach ( (array) $terms as $order => $term ) {
+		if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) {
+			$terms[$order]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) );
+		}
+	}
+	return $terms;
+}
+add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
+
+?>
Index: /tags/3.1/wp-includes/query.php
===================================================================
--- /tags/3.1/wp-includes/query.php	(revision 17487)
+++ /tags/3.1/wp-includes/query.php	(revision 17487)
@@ -0,0 +1,3522 @@
+<?php
+/**
+ * WordPress Query API
+ *
+ * The query API attempts to get which part of WordPress to the user is on. It
+ * also provides functionality to getting URL query information.
+ *
+ * @link http://codex.wordpress.org/The_Loop More information on The Loop.
+ *
+ * @package WordPress
+ * @subpackage Query
+ */
+
+/**
+ * Retrieve variable in the WP_Query class.
+ *
+ * @see WP_Query::get()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param string $var The variable key to retrieve.
+ * @return mixed
+ */
+function get_query_var($var) {
+	global $wp_query;
+
+	return $wp_query->get($var);
+}
+
+
+/**
+ * Retrieve the currently-queried object.  Wrapper for $wp_query->get_queried_object()
+ *
+ * @uses WP_Query::get_queried_object
+ *
+ * @since 3.1.0
+ * @access public
+ *
+ * @return object
+ */
+function get_queried_object() {
+	global $wp_query;
+	return $wp_query->get_queried_object();
+}
+
+/**
+ * Retrieve ID of the current queried object. Wrapper for $wp_query->get_queried_object_id()
+ *
+ * @uses WP_Query::get_queried_object_id()
+ *
+ * @since 3.1.0
+ * @access public
+ *
+ * @return int
+ */
+function get_queried_object_id() {
+	global $wp_query;
+	return $wp_query->get_queried_object_id();
+}
+
+/**
+ * Set query variable.
+ *
+ * @see WP_Query::set()
+ * @since 2.2.0
+ * @uses $wp_query
+ *
+ * @param string $var Query variable key.
+ * @param mixed $value
+ * @return null
+ */
+function set_query_var($var, $value) {
+	global $wp_query;
+
+	return $wp_query->set($var, $value);
+}
+
+/**
+ * Set up The Loop with query parameters.
+ *
+ * This will override the current WordPress Loop and shouldn't be used more than
+ * once. This must not be used within the WordPress Loop.
+ *
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param string $query
+ * @return array List of posts
+ */
+function &query_posts($query) {
+	unset($GLOBALS['wp_query']);
+	$GLOBALS['wp_query'] =& new WP_Query();
+	return $GLOBALS['wp_query']->query($query);
+}
+
+/**
+ * Destroy the previous query and set up a new query.
+ *
+ * This should be used after {@link query_posts()} and before another {@link
+ * query_posts()}. This will remove obscure bugs that occur when the previous
+ * wp_query object is not destroyed properly before another is set up.
+ *
+ * @since 2.3.0
+ * @uses $wp_query
+ */
+function wp_reset_query() {
+	unset($GLOBALS['wp_query']);
+	$GLOBALS['wp_query'] =& $GLOBALS['wp_the_query'];
+	wp_reset_postdata();
+}
+
+/**
+ * After looping through a separate query, this function restores
+ * the $post global to the current post in the main query
+ *
+ * @since 3.0.0
+ * @uses $wp_query
+ */
+function wp_reset_postdata() {
+	global $wp_query;
+	if ( !empty($wp_query->post) ) {
+		$GLOBALS['post'] = $wp_query->post;
+		setup_postdata($wp_query->post);
+	}
+}
+
+/*
+ * Query type checks.
+ */
+
+/**
+ * Is the query for an archive page?
+ *
+ * Month, Year, Category, Author, Post Type archive...
+ *
+ * @see WP_Query::is_archive()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_archive() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_archive();
+}
+
+/**
+ * Is the query for a post type archive page?
+ *
+ * @see WP_Query::is_post_type_archive()
+ * @since 3.1.0
+ * @uses $wp_query
+ *
+ * @param mixed $post_types Optional. Post type or array of posts types to check against.
+ * @return bool
+ */
+function is_post_type_archive( $post_types = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_post_type_archive( $post_types );
+}
+
+/**
+ * Is the query for an attachment page?
+ *
+ * @see WP_Query::is_attachment()
+ * @since 2.0.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_attachment() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_attachment();
+}
+
+/**
+ * Is the query for an author archive page?
+ *
+ * If the $author parameter is specified, this function will additionally
+ * check if the query is for one of the authors specified.
+ *
+ * @see WP_Query::is_author()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
+ * @return bool
+ */
+function is_author( $author = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_author( $author );
+}
+
+/**
+ * Is the query for a category archive page?
+ *
+ * If the $category parameter is specified, this function will additionally
+ * check if the query is for one of the categories specified.
+ *
+ * @see WP_Query::is_category()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
+ * @return bool
+ */
+function is_category( $category = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_category( $category );
+}
+
+/**
+ * Is the query for a tag archive page?
+ *
+ * If the $tag parameter is specified, this function will additionally
+ * check if the query is for one of the tags specified.
+ *
+ * @see WP_Query::is_tag()
+ * @since 2.3.0
+ * @uses $wp_query
+ *
+ * @param mixed $slug Optional. Tag slug or array of slugs.
+ * @return bool
+ */
+function is_tag( $slug = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_tag( $slug );
+}
+
+/**
+ * Is the query for a taxonomy archive page?
+ *
+ * If the $taxonomy parameter is specified, this function will additionally
+ * check if the query is for that specific $taxonomy.
+ *
+ * If the $term parameter is specified in addition to the $taxonomy parameter,
+ * this function will additionally check if the query is for one of the terms
+ * specified.
+ *
+ * @see WP_Query::is_tax()
+ * @since 2.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $taxonomy Optional. Taxonomy slug or slugs.
+ * @param mixed $term Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
+ * @return bool
+ */
+function is_tax( $taxonomy = '', $term = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_tax( $taxonomy, $term );
+}
+
+/**
+ * Whether the current URL is within the comments popup window.
+ *
+ * @see WP_Query::is_comments_popup()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_comments_popup() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_comments_popup();
+}
+
+/**
+ * Is the query for a date archive?
+ *
+ * @see WP_Query::is_date()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_date() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_date();
+}
+
+/**
+ * Is the query for a day archive?
+ *
+ * @see WP_Query::is_day()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_day() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_day();
+}
+
+/**
+ * Is the query for a feed?
+ *
+ * @see WP_Query::is_feed()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param string|array $feeds Optional feed types to check.
+ * @return bool
+ */
+function is_feed( $feeds = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_feed( $feeds );
+}
+
+/**
+ * Is the query for a comments feed?
+ *
+ * @see WP_Query::is_comments_feed()
+ * @since 3.0.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_comment_feed() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_comment_feed();
+}
+
+/**
+ * Is the query for the front page of the site?
+ *
+ * This is for what is displayed at your site's main URL.
+ *
+ * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'.
+ *
+ * If you set a static page for the front page of your site, this function will return
+ * true when viewing that page.
+ *
+ * Otherwise the same as @see is_home()
+ *
+ * @see WP_Query::is_front_page()
+ * @since 2.5.0
+ * @uses is_home()
+ * @uses get_option()
+ *
+ * @return bool True, if front of site.
+ */
+function is_front_page() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_front_page();
+}
+
+/**
+ * Is the query for the blog homepage?
+ *
+ * This is the page which shows the time based blog content of your site.
+ *
+ * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'.
+ *
+ * If you set a static page for the front page of your site, this function will return
+ * true only on the page you set as the "Posts page".
+ *
+ * @see is_front_page()
+ *
+ * @see WP_Query::is_home()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool True if blog view homepage.
+ */
+function is_home() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_home();
+}
+
+/**
+ * Is the query for a month archive?
+ *
+ * @see WP_Query::is_month()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_month() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_month();
+}
+
+/**
+ * Is the query for a single page?
+ *
+ * If the $page parameter is specified, this function will additionally
+ * check if the query is for one of the pages specified.
+ *
+ * @see is_single()
+ * @see is_singular()
+ *
+ * @see WP_Query::is_page()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $page Page ID, title, slug, or array of such.
+ * @return bool
+ */
+function is_page( $page = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_page( $page );
+}
+
+/**
+ * Is the query for paged result and not for the first page?
+ *
+ * @see WP_Query::is_paged()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_paged() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_paged();
+}
+
+/**
+ * Is the query for a post or page preview?
+ *
+ * @see WP_Query::is_preview()
+ * @since 2.0.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_preview() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_preview();
+}
+
+/**
+ * Is the query for the robots file?
+ *
+ * @see WP_Query::is_robots()
+ * @since 2.1.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_robots() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_robots();
+}
+
+/**
+ * Is the query for a search?
+ *
+ * @see WP_Query::is_search()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_search() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_search();
+}
+
+/**
+ * Is the query for a single post?
+ *
+ * Works for any post type, except attachments and pages
+ *
+ * If the $post parameter is specified, this function will additionally
+ * check if the query is for one of the Posts specified.
+ *
+ * @see is_page()
+ * @see is_singular()
+ *
+ * @see WP_Query::is_single()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $post Post ID, title, slug, or array of such.
+ * @return bool
+ */
+function is_single( $post = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_single( $post );
+}
+
+/**
+ * Is the query for a single post of any post type (post, attachment, page, ... )?
+ *
+ * If the $post_types parameter is specified, this function will additionally
+ * check if the query is for one of the Posts Types specified.
+ *
+ * @see is_page()
+ * @see is_single()
+ *
+ * @see WP_Query::is_singular()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @param mixed $post_types Optional. Post Type or array of Post Types
+ * @return bool
+ */
+function is_singular( $post_types = '' ) {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_singular( $post_types );
+}
+
+/**
+ * Is the query for a specific time?
+ *
+ * @see WP_Query::is_time()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_time() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_time();
+}
+
+/**
+ * Is the query for a trackback endpoint call?
+ *
+ * @see WP_Query::is_trackback()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_trackback() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_trackback();
+}
+
+/**
+ * Is the query for a specific year?
+ *
+ * @see WP_Query::is_year()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_year() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_year();
+}
+
+/**
+ * Is the query a 404 (returns no results)?
+ *
+ * @see WP_Query::is_404()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function is_404() {
+	global $wp_query;
+
+	if ( ! isset( $wp_query ) ) {
+		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
+		return false;
+	}
+
+	return $wp_query->is_404();
+}
+
+/*
+ * The Loop.  Post loop control.
+ */
+
+/**
+ * Whether current WordPress query has results to loop over.
+ *
+ * @see WP_Query::have_posts()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function have_posts() {
+	global $wp_query;
+
+	return $wp_query->have_posts();
+}
+
+/**
+ * Whether the caller is in the Loop.
+ *
+ * @since 2.0.0
+ * @uses $wp_query
+ *
+ * @return bool True if caller is within loop, false if loop hasn't started or ended.
+ */
+function in_the_loop() {
+	global $wp_query;
+
+	return $wp_query->in_the_loop;
+}
+
+/**
+ * Rewind the loop posts.
+ *
+ * @see WP_Query::rewind_posts()
+ * @since 1.5.0
+ * @uses $wp_query
+ *
+ * @return null
+ */
+function rewind_posts() {
+	global $wp_query;
+
+	return $wp_query->rewind_posts();
+}
+
+/**
+ * Iterate the post index in the loop.
+ *
+ * @see WP_Query::the_post()
+ * @since 1.5.0
+ * @uses $wp_query
+ */
+function the_post() {
+	global $wp_query;
+
+	$wp_query->the_post();
+}
+
+/*
+ * Comments loop.
+ */
+
+/**
+ * Whether there are comments to loop over.
+ *
+ * @see WP_Query::have_comments()
+ * @since 2.2.0
+ * @uses $wp_query
+ *
+ * @return bool
+ */
+function have_comments() {
+	global $wp_query;
+	return $wp_query->have_comments();
+}
+
+/**
+ * Iterate comment index in the comment loop.
+ *
+ * @see WP_Query::the_comment()
+ * @since 2.2.0
+ * @uses $wp_query
+ *
+ * @return object
+ */
+function the_comment() {
+	global $wp_query;
+	return $wp_query->the_comment();
+}
+
+/*
+ * WP_Query
+ */
+
+/**
+ * The WordPress Query class.
+ *
+ * @link http://codex.wordpress.org/Function_Reference/WP_Query Codex page.
+ *
+ * @since 1.5.0
+ */
+class WP_Query {
+
+	/**
+	 * Query vars set by the user
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var array
+	 */
+	var $query;
+
+	/**
+	 * Query vars, after parsing
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var array
+	 */
+	var $query_vars = array();
+
+	/**
+	 * Taxonomy query, as passed to get_tax_sql()
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 * @var object WP_Tax_Query
+	 */
+	var $tax_query;
+
+	/**
+	 * Holds the data for a single object that is queried.
+	 *
+	 * Holds the contents of a post, page, category, attachment.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var object|array
+	 */
+	var $queried_object;
+
+	/**
+	 * The ID of the queried object.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var int
+	 */
+	var $queried_object_id;
+
+	/**
+	 * Get post database query.
+	 *
+	 * @since 2.0.1
+	 * @access public
+	 * @var string
+	 */
+	var $request;
+
+	/**
+	 * List of posts.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var array
+	 */
+	var $posts;
+
+	/**
+	 * The amount of posts for the current query.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var int
+	 */
+	var $post_count = 0;
+
+	/**
+	 * Index of the current item in the loop.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var int
+	 */
+	var $current_post = -1;
+
+	/**
+	 * Whether the loop has started and the caller is in the loop.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var bool
+	 */
+	var $in_the_loop = false;
+
+	/**
+	 * The current post ID.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var object
+	 */
+	var $post;
+
+	/**
+	 * The list of comments for current post.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @var array
+	 */
+	var $comments;
+
+	/**
+	 * The amount of comments for the posts.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @var int
+	 */
+	var $comment_count = 0;
+
+	/**
+	 * The index of the comment in the comment loop.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @var int
+	 */
+	var $current_comment = -1;
+
+	/**
+	 * Current comment ID.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @var int
+	 */
+	var $comment;
+
+	/**
+	 * Amount of posts if limit clause was not used.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var int
+	 */
+	var $found_posts = 0;
+
+	/**
+	 * The amount of pages.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var int
+	 */
+	var $max_num_pages = 0;
+
+	/**
+	 * The amount of comment pages.
+	 *
+	 * @since 2.7.0
+	 * @access public
+	 * @var int
+	 */
+	var $max_num_comment_pages = 0;
+
+	/**
+	 * Set if query is single post.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_single = false;
+
+	/**
+	 * Set if query is preview of blog.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_preview = false;
+
+	/**
+	 * Set if query returns a page.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_page = false;
+
+	/**
+	 * Set if query is an archive list.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_archive = false;
+
+	/**
+	 * Set if query is part of a date.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_date = false;
+
+	/**
+	 * Set if query contains a year.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_year = false;
+
+	/**
+	 * Set if query contains a month.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_month = false;
+
+	/**
+	 * Set if query contains a day.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_day = false;
+
+	/**
+	 * Set if query contains time.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_time = false;
+
+	/**
+	 * Set if query contains an author.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_author = false;
+
+	/**
+	 * Set if query contains category.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_category = false;
+
+	/**
+	 * Set if query contains tag.
+	 *
+	 * @since 2.3.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_tag = false;
+
+	/**
+	 * Set if query contains taxonomy.
+	 *
+	 * @since 2.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_tax = false;
+
+	/**
+	 * Set if query was part of a search result.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_search = false;
+
+	/**
+	 * Set if query is feed display.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_feed = false;
+
+	/**
+	 * Set if query is comment feed display.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_comment_feed = false;
+
+	/**
+	 * Set if query is trackback.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_trackback = false;
+
+	/**
+	 * Set if query is blog homepage.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_home = false;
+
+	/**
+	 * Set if query couldn't found anything.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_404 = false;
+
+	/**
+	 * Set if query is within comments popup window.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_comments_popup = false;
+
+	/**
+	 * Set if query is paged
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_paged = false;
+
+	/**
+	 * Set if query is part of administration page.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_admin = false;
+
+	/**
+	 * Set if query is an attachment.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_attachment = false;
+
+	/**
+	 * Set if is single, is a page, or is an attachment.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_singular = false;
+
+	/**
+	 * Set if query is for robots.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_robots = false;
+
+	/**
+	 * Set if query contains posts.
+	 *
+	 * Basically, the homepage if the option isn't set for the static homepage.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_posts_page = false;
+
+	/**
+	 * Set if query is for a post type archive.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 * @var bool
+	 */
+	var $is_post_type_archive = false;
+
+	/**
+	 * Whether the tax query has been parsed once.
+	 *
+	 * @since 3.1.0
+	 * @access private
+	 * @var bool
+	 */
+	var $parsed_tax_query = false;
+
+	/**
+	 * Resets query flags to false.
+	 *
+	 * The query flags are what page info WordPress was able to figure out.
+	 *
+	 * @since 2.0.0
+	 * @access private
+	 */
+	function init_query_flags() {
+		$this->is_single = false;
+		$this->is_preview = false;
+		$this->is_page = false;
+		$this->is_archive = false;
+		$this->is_date = false;
+		$this->is_year = false;
+		$this->is_month = false;
+		$this->is_day = false;
+		$this->is_time = false;
+		$this->is_author = false;
+		$this->is_category = false;
+		$this->is_tag = false;
+		$this->is_tax = false;
+		$this->is_search = false;
+		$this->is_feed = false;
+		$this->is_comment_feed = false;
+		$this->is_trackback = false;
+		$this->is_home = false;
+		$this->is_404 = false;
+		$this->is_comments_popup = false;
+		$this->is_paged = false;
+		$this->is_admin = false;
+		$this->is_attachment = false;
+		$this->is_singular = false;
+		$this->is_robots = false;
+		$this->is_posts_page = false;
+		$this->is_post_type_archive = false;
+	}
+
+	/**
+	 * Initiates object properties and sets default values.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 */
+	function init() {
+		unset($this->posts);
+		unset($this->query);
+		$this->query_vars = array();
+		unset($this->queried_object);
+		unset($this->queried_object_id);
+		$this->post_count = 0;
+		$this->current_post = -1;
+		$this->in_the_loop = false;
+		unset( $this->request );
+		unset( $this->post );
+		unset( $this->comments );
+		unset( $this->comment );
+		$this->comment_count = 0;
+		$this->current_comment = -1;
+		$this->found_posts = 0;
+		$this->max_num_pages = 0;
+		$this->max_num_comment_pages = 0;
+
+		$this->init_query_flags();
+	}
+
+	/**
+	 * Reparse the query vars.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 */
+	function parse_query_vars() {
+		$this->parse_query();
+	}
+
+	/**
+	 * Fills in the query variables, which do not exist within the parameter.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param array $array Defined query variables.
+	 * @return array Complete query variables with undefined ones filled in empty.
+	 */
+	function fill_query_vars($array) {
+		$keys = array(
+			'error'
+			, 'm'
+			, 'p'
+			, 'post_parent'
+			, 'subpost'
+			, 'subpost_id'
+			, 'attachment'
+			, 'attachment_id'
+			, 'name'
+			, 'static'
+			, 'pagename'
+			, 'page_id'
+			, 'second'
+			, 'minute'
+			, 'hour'
+			, 'day'
+			, 'monthnum'
+			, 'year'
+			, 'w'
+			, 'category_name'
+			, 'tag'
+			, 'cat'
+			, 'tag_id'
+			, 'author_name'
+			, 'feed'
+			, 'tb'
+			, 'paged'
+			, 'comments_popup'
+			, 'meta_key'
+			, 'meta_value'
+			, 'preview'
+			, 's'
+			, 'sentence'
+			, 'fields'
+		);
+
+		foreach ( $keys as $key ) {
+			if ( !isset($array[$key]) )
+				$array[$key] = '';
+		}
+
+		$array_keys = array('category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in',
+			'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and');
+
+		foreach ( $array_keys as $key ) {
+			if ( !isset($array[$key]) )
+				$array[$key] = array();
+		}
+		return $array;
+	}
+
+	/**
+	 * Parse a query string and set query type booleans.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string|array $query Optional query.
+	 */
+	function parse_query( $query =  '' ) {
+		if ( ! empty( $query ) ) {
+			$this->init();
+			$this->query = $this->query_vars = wp_parse_args( $query );
+		} elseif ( ! isset( $this->query ) ) {
+			$this->query = $this->query_vars;
+		}
+
+		$this->query_vars = $this->fill_query_vars($this->query_vars);
+		$qv = &$this->query_vars;
+
+		if ( ! empty($qv['robots']) )
+			$this->is_robots = true;
+
+		$qv['p'] =  absint($qv['p']);
+		$qv['page_id'] =  absint($qv['page_id']);
+		$qv['year'] = absint($qv['year']);
+		$qv['monthnum'] = absint($qv['monthnum']);
+		$qv['day'] = absint($qv['day']);
+		$qv['w'] = absint($qv['w']);
+		$qv['m'] = absint($qv['m']);
+		$qv['paged'] = absint($qv['paged']);
+		$qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers
+		$qv['pagename'] = trim( $qv['pagename'] );
+		$qv['name'] = trim( $qv['name'] );
+		if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
+		if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
+		if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
+
+		// Compat.  Map subpost to attachment.
+		if ( '' != $qv['subpost'] )
+			$qv['attachment'] = $qv['subpost'];
+		if ( '' != $qv['subpost_id'] )
+			$qv['attachment_id'] = $qv['subpost_id'];
+
+		$qv['attachment_id'] = absint($qv['attachment_id']);
+
+		if ( ('' != $qv['attachment']) || !empty($qv['attachment_id']) ) {
+			$this->is_single = true;
+			$this->is_attachment = true;
+		} elseif ( '' != $qv['name'] ) {
+			$this->is_single = true;
+		} elseif ( $qv['p'] ) {
+			$this->is_single = true;
+		} elseif ( ('' !== $qv['hour']) && ('' !== $qv['minute']) &&('' !== $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) {
+			// If year, month, day, hour, minute, and second are set, a single
+			// post is being queried.
+			$this->is_single = true;
+		} elseif ( '' != $qv['static'] || '' != $qv['pagename'] || !empty($qv['page_id']) ) {
+			$this->is_page = true;
+			$this->is_single = false;
+		} else {
+		// Look for archive queries.  Dates, categories, authors, search, post type archives.
+
+			if ( !empty($qv['s']) ) {
+				$this->is_search = true;
+			}
+
+			if ( '' !== $qv['second'] ) {
+				$this->is_time = true;
+				$this->is_date = true;
+			}
+
+			if ( '' !== $qv['minute'] ) {
+				$this->is_time = true;
+				$this->is_date = true;
+			}
+
+			if ( '' !== $qv['hour'] ) {
+				$this->is_time = true;
+				$this->is_date = true;
+			}
+
+			if ( $qv['day'] ) {
+				if ( ! $this->is_date ) {
+					$this->is_day = true;
+					$this->is_date = true;
+				}
+			}
+
+			if ( $qv['monthnum'] ) {
+				if ( ! $this->is_date ) {
+					$this->is_month = true;
+					$this->is_date = true;
+				}
+			}
+
+			if ( $qv['year'] ) {
+				if ( ! $this->is_date ) {
+					$this->is_year = true;
+					$this->is_date = true;
+				}
+			}
+
+			if ( $qv['m'] ) {
+				$this->is_date = true;
+				if ( strlen($qv['m']) > 9 ) {
+					$this->is_time = true;
+				} else if ( strlen($qv['m']) > 7 ) {
+					$this->is_day = true;
+				} else if ( strlen($qv['m']) > 5 ) {
+					$this->is_month = true;
+				} else {
+					$this->is_year = true;
+				}
+			}
+
+			if ( '' != $qv['w'] ) {
+				$this->is_date = true;
+			}
+
+			$this->parsed_tax_query = false;
+			$this->parse_tax_query( $qv );
+
+			foreach ( $this->tax_query->queries as $tax_query ) {
+				if ( 'IN' == $tax_query['operator'] ) {
+					switch ( $tax_query['taxonomy'] ) {
+						case 'category':
+							$this->is_category = true;
+							break;
+						case 'post_tag':
+							$this->is_tag = true;
+							break;
+						default:
+							$this->is_tax = true;
+					}
+				}
+			}
+			unset( $tax_query );
+
+			_parse_meta_query( $qv );
+
+			if ( empty($qv['author']) || ($qv['author'] == '0') ) {
+				$this->is_author = false;
+			} else {
+				$this->is_author = true;
+			}
+
+			if ( '' != $qv['author_name'] )
+				$this->is_author = true;
+
+			if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) {
+				$post_type_obj = get_post_type_object( $qv['post_type'] );
+				if ( ! empty( $post_type_obj->has_archive ) )
+					$this->is_post_type_archive = true;
+			}
+
+			if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax )
+				$this->is_archive = true;
+		}
+
+		if ( '' != $qv['feed'] )
+			$this->is_feed = true;
+
+		if ( '' != $qv['tb'] )
+			$this->is_trackback = true;
+
+		if ( '' != $qv['paged'] && ( intval($qv['paged']) > 1 ) )
+			$this->is_paged = true;
+
+		if ( '' != $qv['comments_popup'] )
+			$this->is_comments_popup = true;
+
+		// if we're previewing inside the write screen
+		if ( '' != $qv['preview'] )
+			$this->is_preview = true;
+
+		if ( is_admin() )
+			$this->is_admin = true;
+
+		if ( false !== strpos($qv['feed'], 'comments-') ) {
+			$qv['feed'] = str_replace('comments-', '', $qv['feed']);
+			$qv['withcomments'] = 1;
+		}
+
+		$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
+
+		if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) )
+			$this->is_comment_feed = true;
+
+		if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup || $this->is_robots ) )
+			$this->is_home = true;
+
+		// Correct is_* for page_on_front and page_for_posts
+		if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {
+			$_query = wp_parse_args($this->query);
+			// pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
+			if ( isset($_query['pagename']) && '' == $_query['pagename'] )
+				unset($_query['pagename']);
+			if ( empty($_query) || !array_diff( array_keys($_query), array('preview', 'page', 'paged', 'cpage') ) ) {
+				$this->is_page = true;
+				$this->is_home = false;
+				$qv['page_id'] = get_option('page_on_front');
+				// Correct <!--nextpage--> for page_on_front
+				if ( !empty($qv['paged']) ) {
+					$qv['page'] = $qv['paged'];
+					unset($qv['paged']);
+				}
+			}
+		}
+
+		if ( '' != $qv['pagename'] ) {
+			$this->queried_object =& get_page_by_path($qv['pagename']);
+			if ( !empty($this->queried_object) )
+				$this->queried_object_id = (int) $this->queried_object->ID;
+			else
+				unset($this->queried_object);
+
+			if  ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) {
+				$this->is_page = false;
+				$this->is_home = true;
+				$this->is_posts_page = true;
+			}
+		}
+
+		if ( $qv['page_id'] ) {
+			if  ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) {
+				$this->is_page = false;
+				$this->is_home = true;
+				$this->is_posts_page = true;
+			}
+		}
+
+		if ( !empty($qv['post_type']) ) {
+			if ( is_array($qv['post_type']) )
+				$qv['post_type'] = array_map('sanitize_key', $qv['post_type']);
+			else
+				$qv['post_type'] = sanitize_key($qv['post_type']);
+		}
+
+		if ( !empty($qv['post_status']) )
+			$qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
+
+		if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) )
+			$this->is_comment_feed = false;
+
+		$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
+		// Done correcting is_* for page_on_front and page_for_posts
+
+		if ( '404' == $qv['error'] )
+			$this->set_404();
+
+		do_action_ref_array('parse_query', array(&$this));
+	}
+
+	/*
+	 * Parses various taxonomy related query vars.
+	 *
+	 * @access protected
+	 * @since 3.1.0
+	 *
+	 * @param array &$q The query variables
+	 */
+	function parse_tax_query( &$q ) {
+		if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) {
+			$tax_query = $q['tax_query'];
+		} else {
+			$tax_query = array();
+		}
+
+		if ( !empty($q['taxonomy']) && !empty($q['term']) ) {
+			$tax_query[] = array(
+				'taxonomy' => $q['taxonomy'],
+				'terms' => array( $q['term'] ),
+				'field' => 'slug',
+			);
+		}
+
+		foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
+			if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
+				$tax_query_defaults = array(
+					'taxonomy' => $taxonomy,
+					'field' => 'slug',
+				);
+
+ 				if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) {
+					$q[$t->query_var] = wp_basename( $q[$t->query_var] );
+				}
+
+				$term = $q[$t->query_var];
+
+				if ( strpos($term, '+') !== false ) {
+					$terms = preg_split( '/[+]+/', $term );
+					foreach ( $terms as $term ) {
+						$tax_query[] = array_merge( $tax_query_defaults, array(
+							'terms' => array( $term )
+						) );
+					}
+				} else {
+					$tax_query[] = array_merge( $tax_query_defaults, array(
+						'terms' => preg_split( '/[,]+/', $term )
+					) );
+				}
+			}
+		}
+
+		// Category stuff
+		if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && !$this->parsed_tax_query ) {
+			$q['cat'] = ''.urldecode($q['cat']).'';
+			$q['cat'] = addslashes_gpc($q['cat']);
+			$cat_array = preg_split('/[,\s]+/', $q['cat']);
+			$q['cat'] = '';
+			$req_cats = array();
+			foreach ( (array) $cat_array as $cat ) {
+				$cat = intval($cat);
+				$req_cats[] = $cat;
+				$in = ($cat > 0);
+				$cat = abs($cat);
+				if ( $in ) {
+					$q['category__in'][] = $cat;
+					$q['category__in'] = array_merge( $q['category__in'], get_term_children($cat, 'category') );
+				} else {
+					$q['category__not_in'][] = $cat;
+					$q['category__not_in'] = array_merge( $q['category__not_in'], get_term_children($cat, 'category') );
+				}
+			}
+			$q['cat'] = implode(',', $req_cats);
+		}
+
+		if ( !empty($q['category__in']) ) {
+			$q['category__in'] = array_map('absint', array_unique( (array) $q['category__in'] ) );
+			$tax_query[] = array(
+				'taxonomy' => 'category',
+				'terms' => $q['category__in'],
+				'field' => 'term_id',
+				'include_children' => false
+			);
+		}
+
+		if ( !empty($q['category__not_in']) ) {
+			$q['category__not_in'] = array_map('absint', array_unique( (array) $q['category__not_in'] ) );
+			$tax_query[] = array(
+				'taxonomy' => 'category',
+				'terms' => $q['category__not_in'],
+				'operator' => 'NOT IN',
+				'include_children' => false
+			);
+		}
+
+		if ( !empty($q['category__and']) ) {
+			$q['category__and'] = array_map('absint', array_unique( (array) $q['category__and'] ) );
+			$tax_query[] = array(
+				'taxonomy' => 'category',
+				'terms' => $q['category__and'],
+				'field' => 'term_id',
+				'operator' => 'AND',
+				'include_children' => false
+			);
+		}
+
+		// Tag stuff
+		if ( '' != $q['tag'] && !$this->is_singular && !$this->parsed_tax_query ) {
+			if ( strpos($q['tag'], ',') !== false ) {
+				$tags = preg_split('/[,\s]+/', $q['tag']);
+				foreach ( (array) $tags as $tag ) {
+					$tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
+					$q['tag_slug__in'][] = $tag;
+				}
+			} else if ( preg_match('/[+\s]+/', $q['tag']) || !empty($q['cat']) ) {
+				$tags = preg_split('/[+\s]+/', $q['tag']);
+				foreach ( (array) $tags as $tag ) {
+					$tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
+					$q['tag_slug__and'][] = $tag;
+				}
+			} else {
+				$q['tag'] = sanitize_term_field('slug', $q['tag'], 0, 'post_tag', 'db');
+				$q['tag_slug__in'][] = $q['tag'];
+			}
+		}
+
+		if ( !empty($q['tag_id']) ) {
+			$q['tag_id'] = absint( $q['tag_id'] );
+			$tax_query[] = array(
+				'taxonomy' => 'post_tag',
+				'terms' => $q['tag_id']
+			);
+		}
+
+		if ( !empty($q['tag__in']) ) {
+			$q['tag__in'] = array_map('absint', array_unique( (array) $q['tag__in'] ) );
+			$tax_query[] = array(
+				'taxonomy' => 'post_tag',
+				'terms' => $q['tag__in']
+			);
+		}
+
+		if ( !empty($q['tag__not_in']) ) {
+			$q['tag__not_in'] = array_map('absint', array_unique( (array) $q['tag__not_in'] ) );
+			$tax_query[] = array(
+				'taxonomy' => 'post_tag',
+				'terms' => $q['tag__not_in'],
+				'operator' => 'NOT IN'
+			);
+		}
+
+		if ( !empty($q['tag__and']) ) {
+			$q['tag__and'] = array_map('absint', array_unique( (array) $q['tag__and'] ) );
+			$tax_query[] = array(
+				'taxonomy' => 'post_tag',
+				'terms' => $q['tag__and'],
+				'operator' => 'AND'
+			);
+		}
+
+		if ( !empty($q['tag_slug__in']) ) {
+			$q['tag_slug__in'] = array_map('sanitize_title', (array) $q['tag_slug__in']);
+			$tax_query[] = array(
+				'taxonomy' => 'post_tag',
+				'terms' => $q['tag_slug__in'],
+				'field' => 'slug'
+			);
+		}
+
+		if ( !empty($q['tag_slug__and']) ) {
+			$q['tag_slug__and'] = array_map('sanitize_title', (array) $q['tag_slug__and']);
+			$tax_query[] = array(
+				'taxonomy' => 'post_tag',
+				'terms' => $q['tag_slug__and'],
+				'field' => 'slug',
+				'operator' => 'AND'
+			);
+		}
+
+		$this->parsed_tax_query = true;
+
+		$this->tax_query = new WP_Tax_Query( $tax_query );
+	}
+
+	/**
+	 * Sets the 404 property and saves whether query is feed.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 */
+	function set_404() {
+		$is_feed = $this->is_feed;
+
+		$this->init_query_flags();
+		$this->is_404 = true;
+
+		$this->is_feed = $is_feed;
+	}
+
+	/**
+	 * Retrieve query variable.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $query_var Query variable key.
+	 * @return mixed
+	 */
+	function get($query_var) {
+		if ( isset($this->query_vars[$query_var]) )
+			return $this->query_vars[$query_var];
+
+		return '';
+	}
+
+	/**
+	 * Set query variable.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $query_var Query variable key.
+	 * @param mixed $value Query variable value.
+	 */
+	function set($query_var, $value) {
+		$this->query_vars[$query_var] = $value;
+	}
+
+	/**
+	 * Retrieve the posts based on query variables.
+	 *
+	 * There are a few filters and actions that can be used to modify the post
+	 * database query.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @uses do_action_ref_array() Calls 'pre_get_posts' hook before retrieving posts.
+	 *
+	 * @return array List of posts.
+	 */
+	function &get_posts() {
+		global $wpdb, $user_ID, $_wp_using_ext_object_cache;
+
+		$this->parse_query();
+
+		do_action_ref_array('pre_get_posts', array(&$this));
+
+		// Shorthand.
+		$q = &$this->query_vars;
+
+		$q = $this->fill_query_vars($q);
+
+		// First let's clear some variables
+		$distinct = '';
+		$whichauthor = '';
+		$whichmimetype = '';
+		$where = '';
+		$limits = '';
+		$join = '';
+		$search = '';
+		$groupby = '';
+		$fields = '';
+		$post_status_join = false;
+		$page = 1;
+
+		if ( isset( $q['caller_get_posts'] ) ) {
+			_deprecated_argument( 'WP_Query', '3.1', __( '"caller_get_posts" is deprecated. Use "ignore_sticky_posts" instead.' ) );
+			if ( !isset( $q['ignore_sticky_posts'] ) )
+				$q['ignore_sticky_posts'] = $q['caller_get_posts'];
+		}
+
+		if ( !isset( $q['ignore_sticky_posts'] ) )
+			$q['ignore_sticky_posts'] = false;
+
+		if ( !isset($q['suppress_filters']) )
+			$q['suppress_filters'] = false;
+
+		if ( !isset($q['cache_results']) ) {
+			if ( $_wp_using_ext_object_cache )
+				$q['cache_results'] = false;
+			else
+				$q['cache_results'] = true;
+		}
+
+		if ( !isset($q['update_post_term_cache']) )
+			$q['update_post_term_cache'] = true;
+
+		if ( !isset($q['update_post_meta_cache']) )
+			$q['update_post_meta_cache'] = true;
+
+		if ( !isset($q['post_type']) ) {
+			if ( $this->is_search )
+				$q['post_type'] = 'any';
+			else
+				$q['post_type'] = '';
+		}
+		$post_type = $q['post_type'];
+		if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
+			$q['posts_per_page'] = get_option('posts_per_page');
+		if ( isset($q['showposts']) && $q['showposts'] ) {
+			$q['showposts'] = (int) $q['showposts'];
+			$q['posts_per_page'] = $q['showposts'];
+		}
+		if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) )
+			$q['posts_per_page'] = $q['posts_per_archive_page'];
+		if ( !isset($q['nopaging']) ) {
+			if ( $q['posts_per_page'] == -1 ) {
+				$q['nopaging'] = true;
+			} else {
+				$q['nopaging'] = false;
+			}
+		}
+		if ( $this->is_feed ) {
+			$q['posts_per_page'] = get_option('posts_per_rss');
+			$q['nopaging'] = false;
+		}
+		$q['posts_per_page'] = (int) $q['posts_per_page'];
+		if ( $q['posts_per_page'] < -1 )
+			$q['posts_per_page'] = abs($q['posts_per_page']);
+		else if ( $q['posts_per_page'] == 0 )
+			$q['posts_per_page'] = 1;
+
+		if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 )
+			$q['comments_per_page'] = get_option('comments_per_page');
+
+		if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) {
+			$this->is_page = true;
+			$this->is_home = false;
+			$q['page_id'] = get_option('page_on_front');
+		}
+
+		if ( isset($q['page']) ) {
+			$q['page'] = trim($q['page'], '/');
+			$q['page'] = absint($q['page']);
+		}
+
+		// If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present.
+		if ( isset($q['no_found_rows']) )
+			$q['no_found_rows'] = (bool) $q['no_found_rows'];
+		else
+			$q['no_found_rows'] = false;
+
+		switch ( $q['fields'] ) {
+			case 'ids':
+				$fields = "$wpdb->posts.ID";
+				break;
+			case 'id=>parent':
+				$fields = "$wpdb->posts.ID, $wpdb->posts.post_parent";
+				break;
+			default:
+				$fields = "$wpdb->posts.*";
+		}
+
+		// If a month is specified in the querystring, load that month
+		if ( $q['m'] ) {
+			$q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
+			$where .= " AND YEAR($wpdb->posts.post_date)=" . substr($q['m'], 0, 4);
+			if ( strlen($q['m']) > 5 )
+				$where .= " AND MONTH($wpdb->posts.post_date)=" . substr($q['m'], 4, 2);
+			if ( strlen($q['m']) > 7 )
+				$where .= " AND DAYOFMONTH($wpdb->posts.post_date)=" . substr($q['m'], 6, 2);
+			if ( strlen($q['m']) > 9 )
+				$where .= " AND HOUR($wpdb->posts.post_date)=" . substr($q['m'], 8, 2);
+			if ( strlen($q['m']) > 11 )
+				$where .= " AND MINUTE($wpdb->posts.post_date)=" . substr($q['m'], 10, 2);
+			if ( strlen($q['m']) > 13 )
+				$where .= " AND SECOND($wpdb->posts.post_date)=" . substr($q['m'], 12, 2);
+		}
+
+		if ( '' !== $q['hour'] )
+			$where .= " AND HOUR($wpdb->posts.post_date)='" . $q['hour'] . "'";
+
+		if ( '' !== $q['minute'] )
+			$where .= " AND MINUTE($wpdb->posts.post_date)='" . $q['minute'] . "'";
+
+		if ( '' !== $q['second'] )
+			$where .= " AND SECOND($wpdb->posts.post_date)='" . $q['second'] . "'";
+
+		if ( $q['year'] )
+			$where .= " AND YEAR($wpdb->posts.post_date)='" . $q['year'] . "'";
+
+		if ( $q['monthnum'] )
+			$where .= " AND MONTH($wpdb->posts.post_date)='" . $q['monthnum'] . "'";
+
+		if ( $q['day'] )
+			$where .= " AND DAYOFMONTH($wpdb->posts.post_date)='" . $q['day'] . "'";
+
+		// If we've got a post_type AND its not "any" post_type.
+		if ( !empty($q['post_type']) && 'any' != $q['post_type'] ) {
+			foreach ( (array)$q['post_type'] as $_post_type ) {
+				$ptype_obj = get_post_type_object($_post_type);
+				if ( !$ptype_obj || !$ptype_obj->query_var || empty($q[ $ptype_obj->query_var ]) )
+					continue;
+
+				if ( ! $ptype_obj->hierarchical || strpos($q[ $ptype_obj->query_var ], '/') === false ) {
+					// Non-hierarchical post_types & parent-level-hierarchical post_types can directly use 'name'
+					$q['name'] = $q[ $ptype_obj->query_var ];
+				} else {
+					// Hierarchical post_types will operate through the
+					$q['pagename'] = $q[ $ptype_obj->query_var ];
+					$q['name'] = '';
+				}
+
+				// Only one request for a slug is possible, this is why name & pagename are overwritten above.
+				break;
+			} //end foreach
+			unset($ptype_obj);
+		}
+
+		if ( '' != $q['name'] ) {
+			$q['name'] = sanitize_title_for_query( $q['name'] );
+			$where .= " AND $wpdb->posts.post_name = '" . $q['name'] . "'";
+		} elseif ( '' != $q['pagename'] ) {
+			if ( isset($this->queried_object_id) ) {
+				$reqpage = $this->queried_object_id;
+			} else {
+				if ( 'page' != $q['post_type'] ) {
+					foreach ( (array)$q['post_type'] as $_post_type ) {
+						$ptype_obj = get_post_type_object($_post_type);
+						if ( !$ptype_obj || !$ptype_obj->hierarchical )
+							continue;
+
+						$reqpage = get_page_by_path($q['pagename'], OBJECT, $_post_type);
+						if ( $reqpage )
+							break;
+					}
+					unset($ptype_obj);
+				} else {
+					$reqpage = get_page_by_path($q['pagename']);
+				}
+				if ( !empty($reqpage) )
+					$reqpage = $reqpage->ID;
+				else
+					$reqpage = 0;
+			}
+
+			$page_for_posts = get_option('page_for_posts');
+			if  ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts ) ) {
+				$q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) );
+				$q['name'] = $q['pagename'];
+				$where .= " AND ($wpdb->posts.ID = '$reqpage')";
+				$reqpage_obj = get_page($reqpage);
+				if ( is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type ) {
+					$this->is_attachment = true;
+					$post_type = $q['post_type'] = 'attachment';
+					$this->is_page = true;
+					$q['attachment_id'] = $reqpage;
+				}
+			}
+		} elseif ( '' != $q['attachment'] ) {
+			$q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) );
+			$q['name'] = $q['attachment'];
+			$where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'";
+		}
+
+		if ( $q['w'] )
+			$where .= ' AND ' . _wp_mysql_week( "`$wpdb->posts`.`post_date`" ) . " = '" . $q['w'] . "'";
+
+		if ( intval($q['comments_popup']) )
+			$q['p'] = absint($q['comments_popup']);
+
+		// If an attachment is requested by number, let it supercede any post number.
+		if ( $q['attachment_id'] )
+			$q['p'] = absint($q['attachment_id']);
+
+		// If a post number is specified, load that post
+		if ( $q['p'] ) {
+			$where .= " AND {$wpdb->posts}.ID = " . $q['p'];
+		} elseif ( $q['post__in'] ) {
+			$post__in = implode(',', array_map( 'absint', $q['post__in'] ));
+			$where .= " AND {$wpdb->posts}.ID IN ($post__in)";
+		} elseif ( $q['post__not_in'] ) {
+			$post__not_in = implode(',',  array_map( 'absint', $q['post__not_in'] ));
+			$where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)";
+		}
+
+		if ( is_numeric($q['post_parent']) )
+			$where .= $wpdb->prepare( " AND $wpdb->posts.post_parent = %d ", $q['post_parent'] );
+
+		if ( $q['page_id'] ) {
+			if  ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) {
+				$q['p'] = $q['page_id'];
+				$where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
+			}
+		}
+
+		// If a search pattern is specified, load the posts that match
+		if ( !empty($q['s']) ) {
+			// added slashes screw with quote grouping when done early, so done later
+			$q['s'] = stripslashes($q['s']);
+			if ( !empty($q['sentence']) ) {
+				$q['search_terms'] = array($q['s']);
+			} else {
+				preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches);
+				$q['search_terms'] = array_map('_search_terms_tidy', $matches[0]);
+			}
+			$n = !empty($q['exact']) ? '' : '%';
+			$searchand = '';
+			foreach( (array) $q['search_terms'] as $term ) {
+				$term = esc_sql( like_escape( $term ) );
+				$search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";
+				$searchand = ' AND ';
+			}
+			$term = esc_sql( like_escape( $q['s'] ) );
+			if ( empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )
+				$search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";
+
+			if ( !empty($search) ) {
+				$search = " AND ({$search}) ";
+				if ( !is_user_logged_in() )
+					$search .= " AND ($wpdb->posts.post_password = '') ";
+			}
+		}
+
+		// Allow plugins to contextually add/remove/modify the search section of the database query
+		$search = apply_filters_ref_array('posts_search', array( $search, &$this ) );
+
+		// Taxonomies
+		$this->parse_tax_query( $q );
+
+		$clauses = $this->tax_query->get_sql( $wpdb->posts, 'ID' );
+
+		$join .= $clauses['join'];
+		$where .= $clauses['where'];
+
+		if ( $this->is_tax ) {
+			if ( empty($post_type) ) {
+				$post_type = 'any';
+				$post_status_join = true;
+			} elseif ( in_array('attachment', (array) $post_type) ) {
+				$post_status_join = true;
+			}
+		}
+
+		// Back-compat
+		if ( !empty($this->tax_query->queries) ) {
+			$tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' );
+			if ( !empty( $tax_query_in_and ) ) {
+				if ( !isset( $q['taxonomy'] ) ) {
+					foreach ( $tax_query_in_and as $a_tax_query ) {
+						if ( !in_array( $a_tax_query['taxonomy'], array( 'category', 'post_tag' ) ) ) {
+							$q['taxonomy'] = $a_tax_query['taxonomy'];
+							if ( 'slug' == $a_tax_query['field'] )
+								$q['term'] = $a_tax_query['terms'][0];
+							else
+								$q['term_id'] = $a_tax_query['terms'][0];
+
+							break;
+						}
+					}
+				}
+
+				$cat_query = wp_list_filter( $tax_query_in_and, array( 'taxonomy' => 'category' ) );
+				if ( !empty( $cat_query ) ) {
+					$cat_query = reset( $cat_query );
+					$the_cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' );
+					if ( $the_cat ) {
+						$this->set( 'cat', $the_cat->term_id );
+						$this->set( 'category_name', $the_cat->slug );
+					}
+					unset( $the_cat );
+				}
+				unset( $cat_query );
+
+				$tag_query = wp_list_filter( $tax_query_in_and, array( 'taxonomy' => 'post_tag' ) );
+				if ( !empty( $tag_query ) ) {
+					$tag_query = reset( $tag_query );
+					$the_tag = get_term_by( $tag_query['field'], $tag_query['terms'][0], 'post_tag' );
+					if ( $the_tag ) {
+						$this->set( 'tag_id', $the_tag->term_id );
+					}
+					unset( $the_tag );
+				}
+				unset( $tag_query );
+			}
+		}
+
+		if ( !empty( $this->tax_query->queries ) || !empty( $q['meta_key'] ) ) {
+			$groupby = "{$wpdb->posts}.ID";
+		}
+
+		// Author/user stuff
+
+		if ( empty($q['author']) || ($q['author'] == '0') ) {
+			$whichauthor = '';
+		} else {
+			$q['author'] = (string)urldecode($q['author']);
+			$q['author'] = addslashes_gpc($q['author']);
+			if ( strpos($q['author'], '-') !== false ) {
+				$eq = '!=';
+				$andor = 'AND';
+				$q['author'] = explode('-', $q['author']);
+				$q['author'] = (string)absint($q['author'][1]);
+			} else {
+				$eq = '=';
+				$andor = 'OR';
+			}
+			$author_array = preg_split('/[,\s]+/', $q['author']);
+			$_author_array = array();
+			foreach ( $author_array as $key => $_author )
+				$_author_array[] = "$wpdb->posts.post_author " . $eq . ' ' . absint($_author);
+			$whichauthor .= ' AND (' . implode(" $andor ", $_author_array) . ')';
+			unset($author_array, $_author_array);
+		}
+
+		// Author stuff for nice URLs
+
+		if ( '' != $q['author_name'] ) {
+			if ( strpos($q['author_name'], '/') !== false ) {
+				$q['author_name'] = explode('/', $q['author_name']);
+				if ( $q['author_name'][ count($q['author_name'])-1 ] ) {
+					$q['author_name'] = $q['author_name'][count($q['author_name'])-1]; // no trailing slash
+				} else {
+					$q['author_name'] = $q['author_name'][count($q['author_name'])-2]; // there was a trailling slash
+				}
+			}
+			$q['author_name'] = sanitize_title_for_query( $q['author_name'] );
+			$q['author'] = get_user_by('slug', $q['author_name']);
+			if ( $q['author'] )
+				$q['author'] = $q['author']->ID;
+			$whichauthor .= " AND ($wpdb->posts.post_author = " . absint($q['author']) . ')';
+		}
+
+		// MIME-Type stuff for attachment browsing
+
+		if ( isset($q['post_mime_type']) && '' != $q['post_mime_type'] ) {
+			$table_alias = $post_status_join ? $wpdb->posts : '';
+			$whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $table_alias);
+		}
+
+		$where .= $search . $whichauthor . $whichmimetype;
+
+		if ( empty($q['order']) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC')) )
+			$q['order'] = 'DESC';
+
+		// Order by
+		if ( empty($q['orderby']) ) {
+			$q['orderby'] = "$wpdb->posts.post_date " . $q['order'];
+		} elseif ( 'none' == $q['orderby'] ) {
+			$q['orderby'] = '';
+		} else {
+			// Used to filter values
+			$allowed_keys = array('author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', 'comment_count');
+			if ( !empty($q['meta_key']) ) {
+				$allowed_keys[] = $q['meta_key'];
+				$allowed_keys[] = 'meta_value';
+				$allowed_keys[] = 'meta_value_num';
+			}
+			$q['orderby'] = urldecode($q['orderby']);
+			$q['orderby'] = addslashes_gpc($q['orderby']);
+			$orderby_array = explode(' ', $q['orderby']);
+			$q['orderby'] = '';
+
+			foreach ( $orderby_array as $i => $orderby ) {
+				// Only allow certain values for safety
+				if ( ! in_array($orderby, $allowed_keys) )
+					continue;
+
+				switch ( $orderby ) {
+					case 'menu_order':
+						break;
+					case 'ID':
+						$orderby = "$wpdb->posts.ID";
+						break;
+					case 'rand':
+						$orderby = 'RAND()';
+						break;
+					case $q['meta_key']:
+					case 'meta_value':
+						$orderby = "$wpdb->postmeta.meta_value";
+						break;
+					case 'meta_value_num':
+						$orderby = "$wpdb->postmeta.meta_value+0";
+						break;
+					case 'comment_count':
+						$orderby = "$wpdb->posts.comment_count";
+						break;
+					default:
+						$orderby = "$wpdb->posts.post_" . $orderby;
+				}
+
+				$q['orderby'] .= (($i == 0) ? '' : ',') . $orderby;
+			}
+
+			// append ASC or DESC at the end
+			if ( !empty($q['orderby']))
+				$q['orderby'] .= " {$q['order']}";
+
+			if ( empty($q['orderby']) )
+				$q['orderby'] = "$wpdb->posts.post_date ".$q['order'];
+		}
+
+		if ( is_array( $post_type ) ) {
+			$post_type_cap = 'multiple_post_type';
+		} else {
+			$post_type_object = get_post_type_object( $post_type );
+			if ( empty( $post_type_object ) )
+				$post_type_cap = $post_type;
+		}
+
+		$exclude_post_types = '';
+		$in_search_post_types = get_post_types( array('exclude_from_search' => false) );
+		if ( ! empty( $in_search_post_types ) )
+			$exclude_post_types .= $wpdb->prepare(" AND $wpdb->posts.post_type IN ('" . join("', '", $in_search_post_types ) . "')");
+
+		if ( 'any' == $post_type ) {
+			$where .= $exclude_post_types;
+		} elseif ( !empty( $post_type ) && is_array( $post_type ) ) {
+			$where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $post_type) . "')";
+		} elseif ( ! empty( $post_type ) ) {
+			$where .= " AND $wpdb->posts.post_type = '$post_type'";
+			$post_type_object = get_post_type_object ( $post_type );
+		} elseif ( $this->is_attachment ) {
+			$where .= " AND $wpdb->posts.post_type = 'attachment'";
+			$post_type_object = get_post_type_object ( 'attachment' );
+		} elseif ( $this->is_page ) {
+			$where .= " AND $wpdb->posts.post_type = 'page'";
+			$post_type_object = get_post_type_object ( 'page' );
+		} else {
+			$where .= " AND $wpdb->posts.post_type = 'post'";
+			$post_type_object = get_post_type_object ( 'post' );
+		}
+
+		if ( ! empty( $post_type_object ) ) {
+			$edit_cap = $post_type_object->cap->edit_post;
+			$read_cap = $post_type_object->cap->read_post;
+			$edit_others_cap = $post_type_object->cap->edit_others_posts;
+			$read_private_cap = $post_type_object->cap->read_private_posts;
+		} else {
+			$edit_cap = 'edit_' . $post_type_cap;
+			$read_cap = 'read_' . $post_type_cap;
+			$edit_others_cap = 'edit_others_' . $post_type_cap . 's';
+			$read_private_cap = 'read_private_' . $post_type_cap . 's';
+		}
+
+		if ( isset($q['post_status']) && '' != $q['post_status'] ) {
+			$statuswheres = array();
+			$q_status = explode(',', $q['post_status']);
+			$r_status = array();
+			$p_status = array();
+			$e_status = array();
+			if ( $q['post_status'] == 'any' ) {
+				foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
+					$e_status[] = "$wpdb->posts.post_status <> '$status'";
+			} else {
+				foreach ( get_post_stati() as $status ) {
+					if ( in_array( $status, $q_status ) ) {
+						if ( 'private' == $status )
+							$p_status[] = "$wpdb->posts.post_status = '$status'";
+						else
+							$r_status[] = "$wpdb->posts.post_status = '$status'";
+					}
+				}
+			}
+
+			if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) {
+				$r_status = array_merge($r_status, $p_status);
+				unset($p_status);
+			}
+
+			if ( !empty($e_status) ) {
+				$statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
+			}
+			if ( !empty($r_status) ) {
+				if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) )
+					$statuswheres[] = "($wpdb->posts.post_author = $user_ID " .  "AND (" . join( ' OR ', $r_status ) . "))";
+				else
+					$statuswheres[] = "(" . join( ' OR ', $r_status ) . ")";
+			}
+			if ( !empty($p_status) ) {
+				if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) )
+					$statuswheres[] = "($wpdb->posts.post_author = $user_ID " .  "AND (" . join( ' OR ', $p_status ) . "))";
+				else
+					$statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
+			}
+			if ( $post_status_join ) {
+				$join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) ";
+				foreach ( $statuswheres as $index => $statuswhere )
+					$statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))";
+			}
+			foreach ( $statuswheres as $statuswhere )
+				$where .= " AND $statuswhere";
+		} elseif ( !$this->is_singular ) {
+			$where .= " AND ($wpdb->posts.post_status = 'publish'";
+
+			// Add public states.
+			$public_states = get_post_stati( array('public' => true) );
+			foreach ( (array) $public_states as $state ) {
+				if ( 'publish' == $state ) // Publish is hard-coded above.
+					continue;
+				$where .= " OR $wpdb->posts.post_status = '$state'";
+			}
+
+			if ( is_admin() ) {
+				// Add protected states that should show in the admin all list.
+				$admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) );
+				foreach ( (array) $admin_all_states as $state )
+					$where .= " OR $wpdb->posts.post_status = '$state'";
+			}
+
+			if ( is_user_logged_in() ) {
+				// Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
+				$private_states = get_post_stati( array('private' => true) );
+				foreach ( (array) $private_states as $state )
+					$where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = '$state'";
+			}
+
+			$where .= ')';
+		}
+
+		if ( !empty( $q['meta_query'] ) ) {
+			$clauses = call_user_func_array( '_get_meta_sql', array( $q['meta_query'], 'post', $wpdb->posts, 'ID', &$this) );
+			$join .= $clauses['join'];
+			$where .= $clauses['where'];
+		}
+
+		// Apply filters on where and join prior to paging so that any
+		// manipulations to them are reflected in the paging by day queries.
+		if ( !$q['suppress_filters'] ) {
+			$where = apply_filters_ref_array('posts_where', array( $where, &$this ) );
+			$join = apply_filters_ref_array('posts_join', array( $join, &$this ) );
+		}
+
+		// Paging
+		if ( empty($q['nopaging']) && !$this->is_singular ) {
+			$page = absint($q['paged']);
+			if ( empty($page) )
+				$page = 1;
+
+			if ( empty($q['offset']) ) {
+				$pgstrt = '';
+				$pgstrt = ($page - 1) * $q['posts_per_page'] . ', ';
+				$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
+			} else { // we're ignoring $page and using 'offset'
+				$q['offset'] = absint($q['offset']);
+				$pgstrt = $q['offset'] . ', ';
+				$limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
+			}
+		}
+
+		// Comments feeds
+		if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular ) ) {
+			if ( $this->is_archive || $this->is_search ) {
+				$cjoin = "JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join ";
+				$cwhere = "WHERE comment_approved = '1' $where";
+				$cgroupby = "$wpdb->comments.comment_id";
+			} else { // Other non singular e.g. front
+				$cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )";
+				$cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'";
+				$cgroupby = '';
+			}
+
+			if ( !$q['suppress_filters'] ) {
+				$cjoin = apply_filters_ref_array('comment_feed_join', array( $cjoin, &$this ) );
+				$cwhere = apply_filters_ref_array('comment_feed_where', array( $cwhere, &$this ) );
+				$cgroupby = apply_filters_ref_array('comment_feed_groupby', array( $cgroupby, &$this ) );
+				$corderby = apply_filters_ref_array('comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
+				$climits = apply_filters_ref_array('comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
+			}
+			$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
+			$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
+
+			$this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits");
+			$this->comment_count = count($this->comments);
+
+			$post_ids = array();
+
+			foreach ( $this->comments as $comment )
+				$post_ids[] = (int) $comment->comment_post_ID;
+
+			$post_ids = join(',', $post_ids);
+			$join = '';
+			if ( $post_ids )
+				$where = "AND $wpdb->posts.ID IN ($post_ids) ";
+			else
+				$where = "AND 0";
+		}
+
+		$orderby = $q['orderby'];
+
+		$pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' );
+
+		// Apply post-paging filters on where and join.  Only plugins that
+		// manipulate paging queries should use these hooks.
+		if ( !$q['suppress_filters'] ) {
+			$where		= apply_filters_ref_array( 'posts_where_paged',	array( $where, &$this ) );
+			$groupby	= apply_filters_ref_array( 'posts_groupby',		array( $groupby, &$this ) );
+			$join		= apply_filters_ref_array( 'posts_join_paged',	array( $join, &$this ) );
+			$orderby	= apply_filters_ref_array( 'posts_orderby',		array( $orderby, &$this ) );
+			$distinct	= apply_filters_ref_array( 'posts_distinct',	array( $distinct, &$this ) );
+			$limits		= apply_filters_ref_array( 'post_limits',		array( $limits, &$this ) );
+			$fields		= apply_filters_ref_array( 'posts_fields',		array( $fields, &$this ) );
+
+			// Filter all clauses at once, for convenience
+			$clauses = (array) apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) );
+			foreach ( $pieces as $piece )
+				$$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
+		}
+
+		// Announce current selection parameters.  For use by caching plugins.
+		do_action( 'posts_selection', $where . $groupby . $orderby . $limits . $join );
+
+		// Filter again for the benefit of caching plugins.  Regular plugins should use the hooks above.
+		if ( !$q['suppress_filters'] ) {
+			$where		= apply_filters_ref_array( 'posts_where_request',		array( $where, &$this ) );
+			$groupby	= apply_filters_ref_array( 'posts_groupby_request',		array( $groupby, &$this ) );
+			$join		= apply_filters_ref_array( 'posts_join_request',		array( $join, &$this ) );
+			$orderby	= apply_filters_ref_array( 'posts_orderby_request',		array( $orderby, &$this ) );
+			$distinct	= apply_filters_ref_array( 'posts_distinct_request',	array( $distinct, &$this ) );
+			$fields		= apply_filters_ref_array( 'posts_fields_request',		array( $fields, &$this ) );
+			$limits		= apply_filters_ref_array( 'post_limits_request',		array( $limits, &$this ) );
+
+			// Filter all clauses at once, for convenience
+			$clauses = (array) apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) );
+			foreach ( $pieces as $piece )
+				$$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
+		}
+
+		if ( ! empty($groupby) )
+			$groupby = 'GROUP BY ' . $groupby;
+		if ( !empty( $orderby ) )
+			$orderby = 'ORDER BY ' . $orderby;
+
+		$found_rows = '';
+		if ( !$q['no_found_rows'] && !empty($limits) )
+			$found_rows = 'SQL_CALC_FOUND_ROWS';
+
+		$this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
+		if ( !$q['suppress_filters'] )
+			$this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) );
+
+		if ( 'ids' == $q['fields'] ) {
+			$this->posts = $wpdb->get_col($this->request);
+
+			return $this->posts;
+		}
+
+		if ( 'id=>parent' == $q['fields'] ) {
+			$this->posts = $wpdb->get_results($this->request);
+
+			$r = array();
+			foreach ( $this->posts as $post )
+				$r[ $post->ID ] = $post->post_parent;
+
+			return $r;
+		}
+
+		$this->posts = $wpdb->get_results($this->request);
+
+		// Raw results filter.  Prior to status checks.
+		if ( !$q['suppress_filters'] )
+			$this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) );
+
+		if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
+			$cjoin = apply_filters_ref_array('comment_feed_join', array( '', &$this ) );
+			$cwhere = apply_filters_ref_array('comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
+			$cgroupby = apply_filters_ref_array('comment_feed_groupby', array( '', &$this ) );
+			$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
+			$corderby = apply_filters_ref_array('comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
+			$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
+			$climits = apply_filters_ref_array('comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
+			$comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits";
+			$this->comments = $wpdb->get_results($comments_request);
+			$this->comment_count = count($this->comments);
+		}
+
+		if ( !$q['no_found_rows'] && !empty($limits) ) {
+			$found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) );
+			$this->found_posts = $wpdb->get_var( $found_posts_query );
+			$this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) );
+			$this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
+		}
+
+		// Check post status to determine if post should be displayed.
+		if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
+			$status = get_post_status($this->posts[0]);
+			$post_status_obj = get_post_status_object($status);
+			//$type = get_post_type($this->posts[0]);
+			if ( !$post_status_obj->public ) {
+				if ( ! is_user_logged_in() ) {
+					// User must be logged in to view unpublished posts.
+					$this->posts = array();
+				} else {
+					if  ( $post_status_obj->protected ) {
+						// User must have edit permissions on the draft to preview.
+						if ( ! current_user_can($edit_cap, $this->posts[0]->ID) ) {
+							$this->posts = array();
+						} else {
+							$this->is_preview = true;
+							if ( 'future' != $status )
+								$this->posts[0]->post_date = current_time('mysql');
+						}
+					} elseif ( $post_status_obj->private ) {
+						if ( ! current_user_can($read_cap, $this->posts[0]->ID) )
+							$this->posts = array();
+					} else {
+						$this->posts = array();
+					}
+				}
+			}
+
+			if ( $this->is_preview && current_user_can( $edit_cap, $this->posts[0]->ID ) )
+				$this->posts[0] = apply_filters_ref_array('the_preview', array( $this->posts[0], &$this ));
+		}
+
+		// Put sticky posts at the top of the posts array
+		$sticky_posts = get_option('sticky_posts');
+		if ( $this->is_home && $page <= 1 && is_array($sticky_posts) && !empty($sticky_posts) && !$q['ignore_sticky_posts'] ) {
+			$num_posts = count($this->posts);
+			$sticky_offset = 0;
+			// Loop over posts and relocate stickies to the front.
+			for ( $i = 0; $i < $num_posts; $i++ ) {
+				if ( in_array($this->posts[$i]->ID, $sticky_posts) ) {
+					$sticky_post = $this->posts[$i];
+					// Remove sticky from current position
+					array_splice($this->posts, $i, 1);
+					// Move to front, after other stickies
+					array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
+					// Increment the sticky offset.  The next sticky will be placed at this offset.
+					$sticky_offset++;
+					// Remove post from sticky posts array
+					$offset = array_search($sticky_post->ID, $sticky_posts);
+					unset( $sticky_posts[$offset] );
+				}
+			}
+
+			// If any posts have been excluded specifically, Ignore those that are sticky.
+			if ( !empty($sticky_posts) && !empty($q['post__not_in']) )
+				$sticky_posts = array_diff($sticky_posts, $q['post__not_in']);
+
+			// Fetch sticky posts that weren't in the query results
+			if ( !empty($sticky_posts) ) {
+				$stickies__in = implode(',', array_map( 'absint', $sticky_posts ));
+				// honor post type(s) if not set to any
+				$stickies_where = '';
+				if ( 'any' != $post_type && '' != $post_type ) {
+					if ( is_array( $post_type ) ) {
+						$post_types = join( "', '", $post_type );
+					} else {
+						$post_types = $post_type;
+					}
+					$stickies_where = "AND $wpdb->posts.post_type IN ('" . $post_types . "')";
+				}
+
+				$stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in) $stickies_where" );
+				foreach ( $stickies as $sticky_post ) {
+					// Ignore sticky posts the current user cannot read or are not published.
+					if ( 'publish' != $sticky_post->post_status )
+						continue;
+					array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
+					$sticky_offset++;
+				}
+			}
+		}
+
+		if ( !$q['suppress_filters'] )
+			$this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) );
+
+		$this->post_count = count($this->posts);
+
+		// Sanitize before caching so it'll only get done once
+		for ( $i = 0; $i < $this->post_count; $i++ ) {
+			$this->posts[$i] = sanitize_post($this->posts[$i], 'raw');
+		}
+
+		if ( $q['cache_results'] )
+			update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);
+
+		if ( $this->post_count > 0 ) {
+			$this->post = $this->posts[0];
+		}
+
+		return $this->posts;
+	}
+
+	/**
+	 * Set up the next post and iterate current post index.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return object Next post.
+	 */
+	function next_post() {
+
+		$this->current_post++;
+
+		$this->post = $this->posts[$this->current_post];
+		return $this->post;
+	}
+
+	/**
+	 * Sets up the current post.
+	 *
+	 * Retrieves the next post, sets up the post, sets the 'in the loop'
+	 * property to true.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @uses $post
+	 * @uses do_action_ref_array() Calls 'loop_start' if loop has just started
+	 */
+	function the_post() {
+		global $post;
+		$this->in_the_loop = true;
+
+		if ( $this->current_post == -1 ) // loop has just started
+			do_action_ref_array('loop_start', array(&$this));
+
+		$post = $this->next_post();
+		setup_postdata($post);
+	}
+
+	/**
+	 * Whether there are more posts available in the loop.
+	 *
+	 * Calls action 'loop_end', when the loop is complete.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @uses do_action_ref_array() Calls 'loop_end' if loop is ended
+	 *
+	 * @return bool True if posts are available, false if end of loop.
+	 */
+	function have_posts() {
+		if ( $this->current_post + 1 < $this->post_count ) {
+			return true;
+		} elseif ( $this->current_post + 1 == $this->post_count && $this->post_count > 0 ) {
+			do_action_ref_array('loop_end', array(&$this));
+			// Do some cleaning up after the loop
+			$this->rewind_posts();
+		}
+
+		$this->in_the_loop = false;
+		return false;
+	}
+
+	/**
+	 * Rewind the posts and reset post index.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 */
+	function rewind_posts() {
+		$this->current_post = -1;
+		if ( $this->post_count > 0 ) {
+			$this->post = $this->posts[0];
+		}
+	}
+
+	/**
+	 * Iterate current comment index and return comment object.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 *
+	 * @return object Comment object.
+	 */
+	function next_comment() {
+		$this->current_comment++;
+
+		$this->comment = $this->comments[$this->current_comment];
+		return $this->comment;
+	}
+
+	/**
+	 * Sets up the current comment.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @global object $comment Current comment.
+	 * @uses do_action() Calls 'comment_loop_start' hook when first comment is processed.
+	 */
+	function the_comment() {
+		global $comment;
+
+		$comment = $this->next_comment();
+
+		if ( $this->current_comment == 0 ) {
+			do_action('comment_loop_start');
+		}
+	}
+
+	/**
+	 * Whether there are more comments available.
+	 *
+	 * Automatically rewinds comments when finished.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 *
+	 * @return bool True, if more comments. False, if no more posts.
+	 */
+	function have_comments() {
+		if ( $this->current_comment + 1 < $this->comment_count ) {
+			return true;
+		} elseif ( $this->current_comment + 1 == $this->comment_count ) {
+			$this->rewind_comments();
+		}
+
+		return false;
+	}
+
+	/**
+	 * Rewind the comments, resets the comment index and comment to first.
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 */
+	function rewind_comments() {
+		$this->current_comment = -1;
+		if ( $this->comment_count > 0 ) {
+			$this->comment = $this->comments[0];
+		}
+	}
+
+	/**
+	 * Sets up the WordPress query by parsing query string.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $query URL query string.
+	 * @return array List of posts.
+	 */
+	function &query( $query ) {
+		$this->init();
+		$this->query = $this->query_vars = wp_parse_args( $query );
+		return $this->get_posts();
+	}
+
+	/**
+	 * Retrieve queried object.
+	 *
+	 * If queried object is not set, then the queried object will be set from
+	 * the category, tag, taxonomy, posts page, single post, page, or author
+	 * query variable. After it is set up, it will be returned.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return object
+	 */
+	function get_queried_object() {
+		if ( isset($this->queried_object) )
+			return $this->queried_object;
+
+		$this->queried_object = NULL;
+		$this->queried_object_id = 0;
+
+		if ( $this->is_category || $this->is_tag || $this->is_tax ) {
+			$tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' );
+
+			$query = reset( $tax_query_in_and );
+
+			if ( 'term_id' == $query['field'] )
+				$term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
+			else
+				$term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );
+
+			if ( $term && ! is_wp_error($term) )  {
+				$this->queried_object = $term;
+				$this->queried_object_id = (int) $term->term_id;
+			}
+		} elseif ( $this->is_post_type_archive ) {
+			$this->queried_object = get_post_type_object( $this->get('post_type') );
+		} elseif ( $this->is_posts_page ) {
+			$page_for_posts = get_option('page_for_posts');
+			$this->queried_object = & get_page( $page_for_posts );
+			$this->queried_object_id = (int) $this->queried_object->ID;
+		} elseif ( $this->is_singular && !is_null($this->post) ) {
+			$this->queried_object = $this->post;
+			$this->queried_object_id = (int) $this->post->ID;
+		} elseif ( $this->is_author ) {
+			$this->queried_object_id = (int) $this->get('author');
+			$this->queried_object = get_userdata( $this->queried_object_id );
+		}
+
+		return $this->queried_object;
+	}
+
+	/**
+	 * Retrieve ID of the current queried object.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return int
+	 */
+	function get_queried_object_id() {
+		$this->get_queried_object();
+
+		if ( isset($this->queried_object_id) ) {
+			return $this->queried_object_id;
+		}
+
+		return 0;
+	}
+
+	/**
+	 * PHP4 type constructor.
+	 *
+	 * Sets up the WordPress query, if parameter is not empty.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $query URL query string.
+	 * @return WP_Query
+	 */
+	function WP_Query($query = '') {
+		if ( ! empty($query) ) {
+			$this->query($query);
+		}
+	}
+
+	/**
+ 	 * Is the query for an archive page?
+ 	 *
+ 	 * Month, Year, Category, Author, Post Type archive...
+	 *
+ 	 * @since 3.1.0
+ 	 *
+ 	 * @return bool
+ 	 */
+	function is_archive() {
+		return (bool) $this->is_archive;
+	}
+
+	/**
+	 * Is the query for a post type archive page?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $post_types Optional. Post type or array of posts types to check against.
+	 * @return bool
+	 */
+	function is_post_type_archive( $post_types = '' ) {
+		if ( empty( $post_types ) || !$this->is_post_type_archive )
+			return (bool) $this->is_post_type_archive;
+
+		$post_type_object = $this->get_queried_object();
+
+		return in_array( $post_type_object->name, (array) $post_types );
+	}
+
+	/**
+	 * Is the query for an attachment page?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_attachment() {
+		return (bool) $this->is_attachment;
+	}
+
+	/**
+	 * Is the query for an author archive page?
+	 *
+	 * If the $author parameter is specified, this function will additionally
+	 * check if the query is for one of the authors specified.
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $author Optional. User ID, nickname, nicename, or array of User IDs, nicknames, and nicenames
+	 * @return bool
+	 */
+	function is_author( $author = '' ) {
+		if ( !$this->is_author )
+			return false;
+
+		if ( empty($author) )
+			return true;
+
+		$author_obj = $this->get_queried_object();
+
+		$author = (array) $author;
+
+		if ( in_array( $author_obj->ID, $author ) )
+			return true;
+		elseif ( in_array( $author_obj->nickname, $author ) )
+			return true;
+		elseif ( in_array( $author_obj->user_nicename, $author ) )
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * Is the query for a category archive page?
+	 *
+	 * If the $category parameter is specified, this function will additionally
+	 * check if the query is for one of the categories specified.
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $category Optional. Category ID, name, slug, or array of Category IDs, names, and slugs.
+	 * @return bool
+	 */
+	function is_category( $category = '' ) {
+		if ( !$this->is_category )
+			return false;
+
+		if ( empty($category) )
+			return true;
+
+		$cat_obj = $this->get_queried_object();
+
+		$category = (array) $category;
+
+		if ( in_array( $cat_obj->term_id, $category ) )
+			return true;
+		elseif ( in_array( $cat_obj->name, $category ) )
+			return true;
+		elseif ( in_array( $cat_obj->slug, $category ) )
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * Is the query for a tag archive page?
+	 *
+	 * If the $tag parameter is specified, this function will additionally
+	 * check if the query is for one of the tags specified.
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $slug Optional. Tag slug or array of slugs.
+	 * @return bool
+	 */
+	function is_tag( $slug = '' ) {
+		if ( !$this->is_tag )
+			return false;
+
+		if ( empty( $slug ) )
+			return true;
+
+		$tag_obj = $this->get_queried_object();
+
+		$slug = (array) $slug;
+
+		if ( in_array( $tag_obj->slug, $slug ) )
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * Is the query for a taxonomy archive page?
+	 *
+	 * If the $taxonomy parameter is specified, this function will additionally
+	 * check if the query is for that specific $taxonomy.
+	 *
+	 * If the $term parameter is specified in addition to the $taxonomy parameter,
+	 * this function will additionally check if the query is for one of the terms
+	 * specified.
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $taxonomy Optional. Taxonomy slug or slugs.
+	 * @param mixed $term. Optional. Term ID, name, slug or array of Term IDs, names, and slugs.
+	 * @return bool
+	 */
+	function is_tax( $taxonomy = '', $term = '' ) {
+		global $wp_taxonomies;
+
+		if ( !$this->is_tax )
+			return false;
+
+		if ( empty( $taxonomy ) )
+			return true;
+
+		$queried_object = $this->get_queried_object();
+		$tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy );
+		$term_array = (array) $term;
+
+		if ( empty( $term ) ) // Only a Taxonomy provided
+			return isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array );
+
+		return isset( $queried_object->term_id ) &&
+			count( array_intersect(
+				array( $queried_object->term_id, $queried_object->name, $queried_object->slug ),
+				$term_array
+			) );
+	}
+
+	/**
+	 * Whether the current URL is within the comments popup window.
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_comments_popup() {
+		return (bool) $this->is_comments_popup;
+	}
+
+	/**
+	 * Is the query for a date archive?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_date() {
+		return (bool) $this->is_date;
+	}
+
+
+	/**
+	 * Is the query for a day archive?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_day() {
+		return (bool) $this->is_day;
+	}
+
+	/**
+	 * Is the query for a feed?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param string|array $feeds Optional feed types to check.
+	 * @return bool
+	 */
+	function is_feed( $feeds = '' ) {
+		if ( empty( $feeds ) || ! $this->is_feed )
+			return (bool) $this->is_feed;
+		$qv = $this->get( 'feed' );
+		if ( 'feed' == $qv )
+			$qv = get_default_feed();
+		return in_array( $qv, (array) $feeds );
+	}
+
+	/**
+	 * Is the query for a comments feed?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_comment_feed() {
+		return (bool) $this->is_comment_feed;
+	}
+
+	/**
+	 * Is the query for the front page of the site?
+	 *
+	 * This is for what is displayed at your site's main URL.
+	 *
+	 * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'.
+	 *
+	 * If you set a static page for the front page of your site, this function will return
+	 * true when viewing that page.
+	 *
+	 * Otherwise the same as @see WP_Query::is_home()
+	 *
+	 * @since 3.1.0
+	 * @uses is_home()
+	 * @uses get_option()
+	 *
+	 * @return bool True, if front of site.
+	 */
+	function is_front_page() {
+		// most likely case
+		if ( 'posts' == get_option( 'show_on_front') && $this->is_home() )
+			return true;
+		elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
+			return true;
+		else
+			return false;
+	}
+
+	/**
+	 * Is the query for the blog homepage?
+	 *
+	 * This is the page which shows the time based blog content of your site.
+	 *
+	 * Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'.
+	 *
+	 * If you set a static page for the front page of your site, this function will return
+	 * true only on the page you set as the "Posts page".
+	 *
+	 * @see WP_Query::is_front_page()
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool True if blog view homepage.
+	 */
+	function is_home() {
+		return (bool) $this->is_home;
+	}
+
+	/**
+	 * Is the query for a month archive?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_month() {
+		return (bool) $this->is_month;
+	}
+
+	/**
+	 * Is the query for a single page?
+	 *
+	 * If the $page parameter is specified, this function will additionally
+	 * check if the query is for one of the pages specified.
+	 *
+	 * @see WP_Query::is_single()
+	 * @see WP_Query::is_singular()
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $page Page ID, title, slug, or array of such.
+	 * @return bool
+	 */
+	function is_page( $page = '' ) {
+		if ( !$this->is_page )
+			return false;
+
+		if ( empty( $page ) )
+			return true;
+
+		$page_obj = $this->get_queried_object();
+
+		$page = (array) $page;
+
+		if ( in_array( $page_obj->ID, $page ) )
+			return true;
+		elseif ( in_array( $page_obj->post_title, $page ) )
+			return true;
+		else if ( in_array( $page_obj->post_name, $page ) )
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * Is the query for paged result and not for the first page?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_paged() {
+		return (bool) $this->is_paged;
+	}
+
+	/**
+	 * Is the query for a post or page preview?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_preview() {
+		return (bool) $this->is_preview;
+	}
+
+	/**
+	 * Is the query for the robots file?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_robots() {
+		return (bool) $this->is_robots;
+	}
+
+	/**
+	 * Is the query for a search?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_search() {
+		return (bool) $this->is_search;
+	}
+
+	/**
+	 * Is the query for a single post?
+	 *
+	 * Works for any post type, except attachments and pages
+	 *
+	 * If the $post parameter is specified, this function will additionally
+	 * check if the query is for one of the Posts specified.
+	 *
+	 * @see WP_Query::is_page()
+	 * @see WP_Query::is_singular()
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $post Post ID, title, slug, or array of such.
+	 * @return bool
+	 */
+	function is_single( $post = '' ) {
+		if ( !$this->is_single )
+			return false;
+
+		if ( empty($post) )
+			return true;
+
+		$post_obj = $this->get_queried_object();
+
+		$post = (array) $post;
+
+		if ( in_array( $post_obj->ID, $post ) )
+			return true;
+		elseif ( in_array( $post_obj->post_title, $post ) )
+			return true;
+		elseif ( in_array( $post_obj->post_name, $post ) )
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * Is the query for a single post of any post type (post, attachment, page, ... )?
+	 *
+	 * If the $post_types parameter is specified, this function will additionally
+	 * check if the query is for one of the Posts Types specified.
+	 *
+	 * @see WP_Query::is_page()
+	 * @see WP_Query::is_single()
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param mixed $post_types Optional. Post Type or array of Post Types
+	 * @return bool
+	 */
+	function is_singular( $post_types = '' ) {
+		if ( empty( $post_types ) || !$this->is_singular )
+			return (bool) $this->is_singular;
+
+		$post_obj = $this->get_queried_object();
+
+		return in_array( $post_obj->post_type, (array) $post_types );
+	}
+
+	/**
+	 * Is the query for a specific time?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_time() {
+		return (bool) $this->is_time;
+	}
+
+	/**
+	 * Is the query for a trackback endpoint call?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_trackback() {
+		return (bool) $this->is_trackback;
+	}
+
+	/**
+	 * Is the query for a specific year?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_year() {
+		return (bool) $this->is_year;
+	}
+
+	/**
+	 * Is the query a 404 (returns no results)?
+	 *
+	 * @since 3.1.0
+	 *
+	 * @return bool
+	 */
+	function is_404() {
+		return (bool) $this->is_404;
+	}
+}
+
+/**
+ * Redirect old slugs to the correct permalink.
+ *
+ * Attempts to find the current slug from the past slugs.
+ *
+ * @since 2.1.0
+ * @uses $wp_query
+ * @uses $wpdb
+ *
+ * @return null If no link is found, null is returned.
+ */
+function wp_old_slug_redirect() {
+	global $wp_query;
+	if ( is_404() && '' != $wp_query->query_vars['name'] ) :
+		global $wpdb;
+
+		// Guess the current post_type based on the query vars.
+		if ( get_query_var('post_type') )
+			$post_type = get_query_var('post_type');
+		elseif ( !empty($wp_query->query_vars['pagename']) )
+			$post_type = 'page';
+		else
+			$post_type = 'post';
+
+		// Do not attempt redirect for hierarchical post types
+		if ( is_post_type_hierarchical( $post_type ) )
+			return;
+
+		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name']);
+
+		// if year, monthnum, or day have been specified, make our query more precise
+		// just in case there are multiple identical _wp_old_slug values
+		if ( '' != $wp_query->query_vars['year'] )
+			$query .= $wpdb->prepare(" AND YEAR(post_date) = %d", $wp_query->query_vars['year']);
+		if ( '' != $wp_query->query_vars['monthnum'] )
+			$query .= $wpdb->prepare(" AND MONTH(post_date) = %d", $wp_query->query_vars['monthnum']);
+		if ( '' != $wp_query->query_vars['day'] )
+			$query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", $wp_query->query_vars['day']);
+
+		$id = (int) $wpdb->get_var($query);
+
+		if ( ! $id )
+			return;
+
+		$link = get_permalink($id);
+
+		if ( !$link )
+			return;
+
+		wp_redirect($link, '301'); // Permanent redirect
+		exit;
+	endif;
+}
+
+/**
+ * Set up global post data.
+ *
+ * @since 1.5.0
+ *
+ * @param object $post Post data.
+ * @uses do_action_ref_array() Calls 'the_post'
+ * @return bool True when finished.
+ */
+function setup_postdata($post) {
+	global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
+
+	$id = (int) $post->ID;
+
+	$authordata = get_userdata($post->post_author);
+
+	$currentday = mysql2date('d.m.y', $post->post_date, false);
+	$currentmonth = mysql2date('m', $post->post_date, false);
+	$numpages = 1;
+	$page = get_query_var('page');
+	if ( !$page )
+		$page = 1;
+	if ( is_single() || is_page() || is_feed() )
+		$more = 1;
+	$content = $post->post_content;
+	if ( strpos( $content, '<!--nextpage-->' ) ) {
+		if ( $page > 1 )
+			$more = 1;
+		$multipage = 1;
+		$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
+		$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
+		$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
+		$pages = explode('<!--nextpage-->', $content);
+		$numpages = count($pages);
+	} else {
+		$pages = array( $post->post_content );
+		$multipage = 0;
+	}
+
+	do_action_ref_array('the_post', array(&$post));
+
+	return true;
+}
+?>
Index: /tags/3.1/wp-includes/registration-functions.php
===================================================================
--- /tags/3.1/wp-includes/registration-functions.php	(revision 17487)
+++ /tags/3.1/wp-includes/registration-functions.php	(revision 17487)
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Deprecated. No longer needed.
+ *
+ * @package WordPress
+ */
+_deprecated_file( basename(__FILE__), '2.1', null, __( 'This file no longer needs to be included.' ) );
+?>
Index: /tags/3.1/wp-includes/registration.php
===================================================================
--- /tags/3.1/wp-includes/registration.php	(revision 17487)
+++ /tags/3.1/wp-includes/registration.php	(revision 17487)
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Deprecated. No longer needed.
+ *
+ * @package WordPress
+ */
+_deprecated_file( basename(__FILE__), '3.1', null, __( 'This file no longer needs to be included.' ) );
+?>
Index: /tags/3.1/wp-includes/rewrite.php
===================================================================
--- /tags/3.1/wp-includes/rewrite.php	(revision 17487)
+++ /tags/3.1/wp-includes/rewrite.php	(revision 17487)
@@ -0,0 +1,1989 @@
+<?php
+/**
+ * WordPress Rewrite API
+ *
+ * @package WordPress
+ * @subpackage Rewrite
+ */
+
+/**
+ * Add a straight rewrite rule.
+ *
+ * @see WP_Rewrite::add_rule() for long description.
+ * @since 2.1.0
+ *
+ * @param string $regex Regular Expression to match request against.
+ * @param string $redirect Page to redirect to.
+ * @param string $after Optional, default is 'bottom'. Where to add rule, can also be 'top'.
+ */
+function add_rewrite_rule($regex, $redirect, $after = 'bottom') {
+	global $wp_rewrite;
+	$wp_rewrite->add_rule($regex, $redirect, $after);
+}
+
+/**
+ * Add a new tag (like %postname%).
+ *
+ * Warning: you must call this on init or earlier, otherwise the query var
+ * addition stuff won't work.
+ *
+ * @since 2.1.0
+ *
+ * @param string $tagname
+ * @param string $regex
+ */
+function add_rewrite_tag($tagname, $regex) {
+	//validation
+	if ( strlen($tagname) < 3 || $tagname[0] != '%' || $tagname[strlen($tagname)-1] != '%' )
+		return;
+
+	$qv = trim($tagname, '%');
+
+	global $wp_rewrite, $wp;
+	$wp->add_query_var($qv);
+	$wp_rewrite->add_rewrite_tag($tagname, $regex, $qv . '=');
+}
+
+/**
+ * Add permalink structure.
+ *
+ * @see WP_Rewrite::add_permastruct()
+ * @since 3.0.0
+ *
+ * @param string $name Name for permalink structure.
+ * @param string $struct Permalink structure.
+ * @param bool $with_front Prepend front base to permalink structure.
+ */
+function add_permastruct( $name, $struct, $with_front = true, $ep_mask = EP_NONE ) {
+	global $wp_rewrite;
+	return $wp_rewrite->add_permastruct( $name, $struct, $with_front, $ep_mask );
+}
+
+/**
+ * Add a new feed type like /atom1/.
+ *
+ * @since 2.1.0
+ *
+ * @param string $feedname
+ * @param callback $function Callback to run on feed display.
+ * @return string Feed action name.
+ */
+function add_feed($feedname, $function) {
+	global $wp_rewrite;
+	if ( ! in_array($feedname, $wp_rewrite->feeds) ) //override the file if it is
+		$wp_rewrite->feeds[] = $feedname;
+	$hook = 'do_feed_' . $feedname;
+	// Remove default function hook
+	remove_action($hook, $hook, 10, 1);
+	add_action($hook, $function, 10, 1);
+	return $hook;
+}
+
+/**
+ * Remove rewrite rules and then recreate rewrite rules.
+ *
+ * @see WP_Rewrite::flush_rules()
+ * @since 3.0.0
+ *
+ * @param bool $hard Whether to update .htaccess (hard flush) or just update
+ * 	rewrite_rules transient (soft flush). Default is true (hard).
+ */
+function flush_rewrite_rules( $hard = true ) {
+	global $wp_rewrite;
+	$wp_rewrite->flush_rules( $hard );
+}
+
+//pseudo-places
+/**
+ * Endpoint Mask for default, which is nothing.
+ *
+ * @since 2.1.0
+ */
+define('EP_NONE', 0);
+
+/**
+ * Endpoint Mask for Permalink.
+ *
+ * @since 2.1.0
+ */
+define('EP_PERMALINK', 1);
+
+/**
+ * Endpoint Mask for Attachment.
+ *
+ * @since 2.1.0
+ */
+define('EP_ATTACHMENT', 2);
+
+/**
+ * Endpoint Mask for date.
+ *
+ * @since 2.1.0
+ */
+define('EP_DATE', 4);
+
+/**
+ * Endpoint Mask for year
+ *
+ * @since 2.1.0
+ */
+define('EP_YEAR', 8);
+
+/**
+ * Endpoint Mask for month.
+ *
+ * @since 2.1.0
+ */
+define('EP_MONTH', 16);
+
+/**
+ * Endpoint Mask for day.
+ *
+ * @since 2.1.0
+ */
+define('EP_DAY', 32);
+
+/**
+ * Endpoint Mask for root.
+ *
+ * @since 2.1.0
+ */
+define('EP_ROOT', 64);
+
+/**
+ * Endpoint Mask for comments.
+ *
+ * @since 2.1.0
+ */
+define('EP_COMMENTS', 128);
+
+/**
+ * Endpoint Mask for searches.
+ *
+ * @since 2.1.0
+ */
+define('EP_SEARCH', 256);
+
+/**
+ * Endpoint Mask for categories.
+ *
+ * @since 2.1.0
+ */
+define('EP_CATEGORIES', 512);
+
+/**
+ * Endpoint Mask for tags.
+ *
+ * @since 2.3.0
+ */
+define('EP_TAGS', 1024);
+
+/**
+ * Endpoint Mask for authors.
+ *
+ * @since 2.1.0
+ */
+define('EP_AUTHORS', 2048);
+
+/**
+ * Endpoint Mask for pages.
+ *
+ * @since 2.1.0
+ */
+define('EP_PAGES', 4096);
+
+/**
+ * Endpoint Mask for everything.
+ *
+ * @since 2.1.0
+ */
+define('EP_ALL', 8191);
+
+/**
+ * Add an endpoint, like /trackback/.
+ *
+ * The endpoints are added to the end of the request. So a request matching
+ * "/2008/10/14/my_post/myep/", the endpoint will be "/myep/".
+ *
+ * Be sure to flush the rewrite rules (wp_rewrite->flush_rules()) when your plugin gets
+ * activated (register_activation_hook()) and deactivated (register_deactivation_hook())
+ *
+ * @since 2.1.0
+ * @see WP_Rewrite::add_endpoint() Parameters and more description.
+ * @uses $wp_rewrite
+ *
+ * @param unknown_type $name
+ * @param unknown_type $places
+ */
+function add_rewrite_endpoint($name, $places) {
+	global $wp_rewrite;
+	$wp_rewrite->add_endpoint($name, $places);
+}
+
+/**
+ * Filter the URL base for taxonomies.
+ *
+ * To remove any manually prepended /index.php/.
+ *
+ * @access private
+ * @since 2.6.0
+ *
+ * @param string $base The taxonomy base that we're going to filter
+ * @return string
+ */
+function _wp_filter_taxonomy_base( $base ) {
+	if ( !empty( $base ) ) {
+		$base = preg_replace( '|^/index\.php/|', '', $base );
+		$base = trim( $base, '/' );
+	}
+	return $base;
+}
+
+/**
+ * Examine a url and try to determine the post ID it represents.
+ *
+ * Checks are supposedly from the hosted site blog.
+ *
+ * @since 1.0.0
+ *
+ * @param string $url Permalink to check.
+ * @return int Post ID, or 0 on failure.
+ */
+function url_to_postid($url) {
+	global $wp_rewrite;
+
+	$url = apply_filters('url_to_postid', $url);
+
+	// First, check to see if there is a 'p=N' or 'page_id=N' to match against
+	if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )	{
+		$id = absint($values[2]);
+		if ( $id )
+			return $id;
+	}
+
+	// Check to see if we are using rewrite rules
+	$rewrite = $wp_rewrite->wp_rewrite_rules();
+
+	// Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
+	if ( empty($rewrite) )
+		return 0;
+
+	// Get rid of the #anchor
+	$url_split = explode('#', $url);
+	$url = $url_split[0];
+
+	// Get rid of URL ?query=string
+	$url_split = explode('?', $url);
+	$url = $url_split[0];
+
+	// Add 'www.' if it is absent and should be there
+	if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') )
+		$url = str_replace('://', '://www.', $url);
+
+	// Strip 'www.' if it is present and shouldn't be
+	if ( false === strpos(home_url(), '://www.') )
+		$url = str_replace('://www.', '://', $url);
+
+	// Strip 'index.php/' if we're not using path info permalinks
+	if ( !$wp_rewrite->using_index_permalinks() )
+		$url = str_replace('index.php/', '', $url);
+
+	if ( false !== strpos($url, home_url()) ) {
+		// Chop off http://domain.com
+		$url = str_replace(home_url(), '', $url);
+	} else {
+		// Chop off /path/to/blog
+		$home_path = parse_url(home_url());
+		$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ;
+		$url = str_replace($home_path, '', $url);
+	}
+
+	// Trim leading and lagging slashes
+	$url = trim($url, '/');
+
+	$request = $url;
+
+	// Look for matches.
+	$request_match = $request;
+	foreach ( (array)$rewrite as $match => $query) {
+		// If the requesting file is the anchor of the match, prepend it
+		// to the path info.
+		if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) )
+			$request_match = $url . '/' . $request;
+
+		if ( preg_match("!^$match!", $request_match, $matches) ) {
+			// Got a match.
+			// Trim the query of everything up to the '?'.
+			$query = preg_replace("!^.+\?!", '', $query);
+
+			// Substitute the substring matches into the query.
+			$query = addslashes(WP_MatchesMapRegex::apply($query, $matches));
+
+			// Filter out non-public query vars
+			global $wp;
+			parse_str($query, $query_vars);
+			$query = array();
+			foreach ( (array) $query_vars as $key => $value ) {
+				if ( in_array($key, $wp->public_query_vars) )
+					$query[$key] = $value;
+			}
+
+			// Do the query
+			$query = new WP_Query($query);
+			if ( !empty($query->posts) && $query->is_singular )
+				return $query->post->ID;
+			else
+				return 0;
+		}
+	}
+	return 0;
+}
+
+/**
+ * WordPress Rewrite Component.
+ *
+ * The WordPress Rewrite class writes the rewrite module rules to the .htaccess
+ * file. It also handles parsing the request to get the correct setup for the
+ * WordPress Query class.
+ *
+ * The Rewrite along with WP class function as a front controller for WordPress.
+ * You can add rules to trigger your page view and processing using this
+ * component. The full functionality of a front controller does not exist,
+ * meaning you can't define how the template files load based on the rewrite
+ * rules.
+ *
+ * @since 1.5.0
+ */
+class WP_Rewrite {
+	/**
+	 * Default permalink structure for WordPress.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $permalink_structure;
+
+	/**
+	 * Whether to add trailing slashes.
+	 *
+	 * @since 2.2.0
+	 * @access private
+	 * @var bool
+	 */
+	var $use_trailing_slashes;
+
+	/**
+	 * Permalink author request base ( example.com/author/authorname ).
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $author_base = 'author';
+
+	/**
+	 * Permalink request structure for author pages.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $author_structure;
+
+	/**
+	 * Permalink request structure for dates.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $date_structure;
+
+	/**
+	 * Permalink request structure for pages.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $page_structure;
+
+	/**
+	 * Search permalink base ( example.com/search/query ).
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $search_base = 'search';
+
+	/**
+	 * Permalink request structure for searches.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $search_structure;
+
+	/**
+	 * Comments permalink base.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $comments_base = 'comments';
+
+	/**
+	 * Pagination permalink base.
+	 *
+	 * @since 3.1.0
+	 * @access private
+	 * @var string
+	 */
+	var $pagination_base = 'page';
+
+	/**
+	 * Feed permalink base.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $feed_base = 'feed';
+
+	/**
+	 * Comments feed request structure permalink.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $comments_feed_structure;
+
+	/**
+	 * Feed request structure permalink.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $feed_structure;
+
+	/**
+	 * Front URL path.
+	 *
+	 * The difference between the root property is that WordPress might be
+	 * located at example/WordPress/index.php, if permalinks are turned off. The
+	 * WordPress/index.php will be the front portion. If permalinks are turned
+	 * on, this will most likely be empty or not set.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $front;
+
+	/**
+	 * Root URL path to WordPress (without domain).
+	 *
+	 * The difference between front property is that WordPress might be located
+	 * at example.com/WordPress/. The root is the 'WordPress/' portion.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $root = '';
+
+	/**
+	 * Permalink to the home page.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var string
+	 */
+	var $index = 'index.php';
+
+	/**
+	 * Request match string.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $matches = '';
+
+	/**
+	 * Rewrite rules to match against the request to find the redirect or query.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var array
+	 */
+	var $rules;
+
+	/**
+	 * Additional rules added external to the rewrite class.
+	 *
+	 * Those not generated by the class, see add_rewrite_rule().
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var array
+	 */
+	var $extra_rules = array(); //
+
+	/**
+	 * Additional rules that belong at the beginning to match first.
+	 *
+	 * Those not generated by the class, see add_rewrite_rule().
+	 *
+	 * @since 2.3.0
+	 * @access private
+	 * @var array
+	 */
+	var $extra_rules_top = array(); //
+
+	/**
+	 * Rules that don't redirect to WP's index.php.
+	 *
+	 * These rules are written to the mod_rewrite portion of the .htaccess.
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var array
+	 */
+	var $non_wp_rules = array(); //
+
+	/**
+	 * Extra permalink structures.
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var array
+	 */
+	var $extra_permastructs = array();
+
+	/**
+	 * Endpoints permalinks
+	 *
+	 * @since 2.1.0
+	 * @access private
+	 * @var array
+	 */
+	var $endpoints;
+
+	/**
+	 * Whether to write every mod_rewrite rule for WordPress.
+	 *
+	 * This is off by default, turning it on might print a lot of rewrite rules
+	 * to the .htaccess file.
+	 *
+	 * @since 2.0.0
+	 * @access public
+	 * @var bool
+	 */
+	var $use_verbose_rules = false;
+
+	/**
+	 * Whether to write every mod_rewrite rule for WordPress pages.
+	 *
+	 * @since 2.5.0
+	 * @access public
+	 * @var bool
+	 */
+	var $use_verbose_page_rules = true;
+
+	/**
+	 * Permalink structure search for preg_replace.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var array
+	 */
+	var $rewritecode =
+		array(
+					'%year%',
+					'%monthnum%',
+					'%day%',
+					'%hour%',
+					'%minute%',
+					'%second%',
+					'%postname%',
+					'%post_id%',
+					'%author%',
+					'%pagename%',
+					'%search%'
+					);
+
+	/**
+	 * Preg_replace values for the search, see {@link WP_Rewrite::$rewritecode}.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var array
+	 */
+	var $rewritereplace =
+		array(
+					'([0-9]{4})',
+					'([0-9]{1,2})',
+					'([0-9]{1,2})',
+					'([0-9]{1,2})',
+					'([0-9]{1,2})',
+					'([0-9]{1,2})',
+					'([^/]+)',
+					'([0-9]+)',
+					'([^/]+)',
+					'([^/]+?)',
+					'(.+)'
+					);
+
+	/**
+	 * Search for the query to look for replacing.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var array
+	 */
+	var $queryreplace =
+		array (
+					'year=',
+					'monthnum=',
+					'day=',
+					'hour=',
+					'minute=',
+					'second=',
+					'name=',
+					'p=',
+					'author_name=',
+					'pagename=',
+					's='
+					);
+
+	/**
+	 * Supported default feeds.
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var array
+	 */
+	var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
+
+	/**
+	 * Whether permalinks are being used.
+	 *
+	 * This can be either rewrite module or permalink in the HTTP query string.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool True, if permalinks are enabled.
+	 */
+	function using_permalinks() {
+		return ! empty($this->permalink_structure);
+	}
+
+	/**
+	 * Whether permalinks are being used and rewrite module is not enabled.
+	 *
+	 * Means that permalink links are enabled and index.php is in the URL.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool
+	 */
+	function using_index_permalinks() {
+		if ( empty($this->permalink_structure) )
+			return false;
+
+		// If the index is not in the permalink, we're using mod_rewrite.
+		if ( preg_match('#^/*' . $this->index . '#', $this->permalink_structure) )
+			return true;
+
+		return false;
+	}
+
+	/**
+	 * Whether permalinks are being used and rewrite module is enabled.
+	 *
+	 * Using permalinks and index.php is not in the URL.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool
+	 */
+	function using_mod_rewrite_permalinks() {
+		if ( $this->using_permalinks() && ! $this->using_index_permalinks() )
+			return true;
+		else
+			return false;
+	}
+
+	/**
+	 * Index for matches for usage in preg_*() functions.
+	 *
+	 * The format of the string is, with empty matches property value, '$NUM'.
+	 * The 'NUM' will be replaced with the value in the $number parameter. With
+	 * the matches property not empty, the value of the returned string will
+	 * contain that value of the matches property. The format then will be
+	 * '$MATCHES[NUM]', with MATCHES as the value in the property and NUM the
+	 * value of the $number parameter.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param int $number Index number.
+	 * @return string
+	 */
+	function preg_index($number) {
+		$match_prefix = '$';
+		$match_suffix = '';
+
+		if ( ! empty($this->matches) ) {
+			$match_prefix = '$' . $this->matches . '[';
+			$match_suffix = ']';
+		}
+
+		return "$match_prefix$number$match_suffix";
+	}
+
+	/**
+	 * Retrieve all page and attachments for pages URIs.
+	 *
+	 * The attachments are for those that have pages as parents and will be
+	 * retrieved.
+	 *
+	 * @since 2.5.0
+	 * @access public
+	 *
+	 * @return array Array of page URIs as first element and attachment URIs as second element.
+	 */
+	function page_uri_index() {
+		global $wpdb;
+
+		//get pages in order of hierarchy, i.e. children after parents
+		$posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page'"));
+
+		// If we have no pages get out quick
+		if ( !$posts )
+			return array( array(), array() );
+
+		//now reverse it, because we need parents after children for rewrite rules to work properly
+		$posts = array_reverse($posts, true);
+
+		$page_uris = array();
+		$page_attachment_uris = array();
+
+		foreach ( $posts as $id => $post ) {
+			// URL => page name
+			$uri = get_page_uri($id);
+			$attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id ));
+			if ( !empty($attachments) ) {
+				foreach ( $attachments as $attachment ) {
+					$attach_uri = get_page_uri($attachment->ID);
+					$page_attachment_uris[$attach_uri] = $attachment->ID;
+				}
+			}
+
+			$page_uris[$uri] = $id;
+		}
+
+		return array( $page_uris, $page_attachment_uris );
+	}
+
+	/**
+	 * Retrieve all of the rewrite rules for pages.
+	 *
+	 * If the 'use_verbose_page_rules' property is false, then there will only
+	 * be a single rewrite rule for pages for those matching '%pagename%'. With
+	 * the property set to true, the attachments and the pages will be added for
+	 * each individual attachment URI and page URI, respectively.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return array
+	 */
+	function page_rewrite_rules() {
+		$rewrite_rules = array();
+		$page_structure = $this->get_page_permastruct();
+
+		if ( ! $this->use_verbose_page_rules ) {
+			$this->add_rewrite_tag('%pagename%', "(.+?)", 'pagename=');
+			$rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
+			return $rewrite_rules;
+		}
+
+		$page_uris = $this->page_uri_index();
+		$uris = $page_uris[0];
+		$attachment_uris = $page_uris[1];
+
+		if ( is_array( $attachment_uris ) ) {
+			foreach ( $attachment_uris as $uri => $pagename ) {
+				$this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
+				$rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
+			}
+		}
+		if ( is_array( $uris ) ) {
+			foreach ( $uris as $uri => $pagename ) {
+				$this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
+				$rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
+			}
+		}
+
+		return $rewrite_rules;
+	}
+
+	/**
+	 * Retrieve date permalink structure, with year, month, and day.
+	 *
+	 * The permalink structure for the date, if not set already depends on the
+	 * permalink structure. It can be one of three formats. The first is year,
+	 * month, day; the second is day, month, year; and the last format is month,
+	 * day, year. These are matched against the permalink structure for which
+	 * one is used. If none matches, then the default will be used, which is
+	 * year, month, day.
+	 *
+	 * Prevents post ID and date permalinks from overlapping. In the case of
+	 * post_id, the date permalink will be prepended with front permalink with
+	 * 'date/' before the actual permalink to form the complete date permalink
+	 * structure.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool|string False on no permalink structure. Date permalink structure.
+	 */
+	function get_date_permastruct() {
+		if ( isset($this->date_structure) )
+			return $this->date_structure;
+
+		if ( empty($this->permalink_structure) ) {
+			$this->date_structure = '';
+			return false;
+		}
+
+		// The date permalink must have year, month, and day separated by slashes.
+		$endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%');
+
+		$this->date_structure = '';
+		$date_endian = '';
+
+		foreach ( $endians as $endian ) {
+			if ( false !== strpos($this->permalink_structure, $endian) ) {
+				$date_endian= $endian;
+				break;
+			}
+		}
+
+		if ( empty($date_endian) )
+			$date_endian = '%year%/%monthnum%/%day%';
+
+		// Do not allow the date tags and %post_id% to overlap in the permalink
+		// structure. If they do, move the date tags to $front/date/.
+		$front = $this->front;
+		preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
+		$tok_index = 1;
+		foreach ( (array) $tokens[0] as $token) {
+			if ( '%post_id%' == $token && ($tok_index <= 3) ) {
+				$front = $front . 'date/';
+				break;
+			}
+			$tok_index++;
+		}
+
+		$this->date_structure = $front . $date_endian;
+
+		return $this->date_structure;
+	}
+
+	/**
+	 * Retrieve the year permalink structure without month and day.
+	 *
+	 * Gets the date permalink structure and strips out the month and day
+	 * permalink structures.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool|string False on failure. Year structure on success.
+	 */
+	function get_year_permastruct() {
+		$structure = $this->get_date_permastruct($this->permalink_structure);
+
+		if ( empty($structure) )
+			return false;
+
+		$structure = str_replace('%monthnum%', '', $structure);
+		$structure = str_replace('%day%', '', $structure);
+
+		$structure = preg_replace('#/+#', '/', $structure);
+
+		return $structure;
+	}
+
+	/**
+	 * Retrieve the month permalink structure without day and with year.
+	 *
+	 * Gets the date permalink structure and strips out the day permalink
+	 * structures. Keeps the year permalink structure.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool|string False on failure. Year/Month structure on success.
+	 */
+	function get_month_permastruct() {
+		$structure = $this->get_date_permastruct($this->permalink_structure);
+
+		if ( empty($structure) )
+			return false;
+
+		$structure = str_replace('%day%', '', $structure);
+
+		$structure = preg_replace('#/+#', '/', $structure);
+
+		return $structure;
+	}
+
+	/**
+	 * Retrieve the day permalink structure with month and year.
+	 *
+	 * Keeps date permalink structure with all year, month, and day.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool|string False on failure. Year/Month/Day structure on success.
+	 */
+	function get_day_permastruct() {
+		return $this->get_date_permastruct($this->permalink_structure);
+	}
+
+	/**
+	 * Retrieve the permalink structure for categories.
+	 *
+	 * If the category_base property has no value, then the category structure
+	 * will have the front property value, followed by 'category', and finally
+	 * '%category%'. If it does, then the root property will be used, along with
+	 * the category_base property value.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return bool|string False on failure. Category permalink structure.
+	 */
+	function get_category_permastruct() {
+		return $this->get_extra_permastruct('category');
+	}
+
+	/**
+	 * Retrieve the permalink structure for tags.
+	 *
+	 * If the tag_base property has no value, then the tag structure will have
+	 * the front property value, followed by 'tag', and finally '%tag%'. If it
+	 * does, then the root property will be used, along with the tag_base
+	 * property value.
+	 *
+	 * @since 2.3.0
+	 * @access public
+	 *
+	 * @return bool|string False on failure. Tag permalink structure.
+	 */
+	function get_tag_permastruct() {
+		return $this->get_extra_permastruct('post_tag');
+	}
+
+	/**
+	 * Retrieve extra permalink structure by name.
+	 *
+	 * @since 2.5.0
+	 * @access public
+	 *
+	 * @param string $name Permalink structure name.
+	 * @return string|bool False if not found. Permalink structure string.
+	 */
+	function get_extra_permastruct($name) {
+		if ( empty($this->permalink_structure) )
+			return false;
+
+		if ( isset($this->extra_permastructs[$name]) )
+			return $this->extra_permastructs[$name][0];
+
+		return false;
+	}
+
+	/**
+	 * Retrieve the author permalink structure.
+	 *
+	 * The permalink structure is front property, author base, and finally
+	 * '/%author%'. Will set the author_structure property and then return it
+	 * without attempting to set the value again.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return string|bool False if not found. Permalink structure string.
+	 */
+	function get_author_permastruct() {
+		if ( isset($this->author_structure) )
+			return $this->author_structure;
+
+		if ( empty($this->permalink_structure) ) {
+			$this->author_structure = '';
+			return false;
+		}
+
+		$this->author_structure = $this->front . $this->author_base . '/%author%';
+
+		return $this->author_structure;
+	}
+
+	/**
+	 * Retrieve the search permalink structure.
+	 *
+	 * The permalink structure is root property, search base, and finally
+	 * '/%search%'. Will set the search_structure property and then return it
+	 * without attempting to set the value again.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return string|bool False if not found. Permalink structure string.
+	 */
+	function get_search_permastruct() {
+		if ( isset($this->search_structure) )
+			return $this->search_structure;
+
+		if ( empty($this->permalink_structure) ) {
+			$this->search_structure = '';
+			return false;
+		}
+
+		$this->search_structure = $this->root . $this->search_base . '/%search%';
+
+		return $this->search_structure;
+	}
+
+	/**
+	 * Retrieve the page permalink structure.
+	 *
+	 * The permalink structure is root property, and '%pagename%'. Will set the
+	 * page_structure property and then return it without attempting to set the
+	 * value again.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return string|bool False if not found. Permalink structure string.
+	 */
+	function get_page_permastruct() {
+		if ( isset($this->page_structure) )
+			return $this->page_structure;
+
+		if (empty($this->permalink_structure)) {
+			$this->page_structure = '';
+			return false;
+		}
+
+		$this->page_structure = $this->root . '%pagename%';
+
+		return $this->page_structure;
+	}
+
+	/**
+	 * Retrieve the feed permalink structure.
+	 *
+	 * The permalink structure is root property, feed base, and finally
+	 * '/%feed%'. Will set the feed_structure property and then return it
+	 * without attempting to set the value again.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return string|bool False if not found. Permalink structure string.
+	 */
+	function get_feed_permastruct() {
+		if ( isset($this->feed_structure) )
+			return $this->feed_structure;
+
+		if ( empty($this->permalink_structure) ) {
+			$this->feed_structure = '';
+			return false;
+		}
+
+		$this->feed_structure = $this->root . $this->feed_base . '/%feed%';
+
+		return $this->feed_structure;
+	}
+
+	/**
+	 * Retrieve the comment feed permalink structure.
+	 *
+	 * The permalink structure is root property, comment base property, feed
+	 * base and finally '/%feed%'. Will set the comment_feed_structure property
+	 * and then return it without attempting to set the value again.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return string|bool False if not found. Permalink structure string.
+	 */
+	function get_comment_feed_permastruct() {
+		if ( isset($this->comment_feed_structure) )
+			return $this->comment_feed_structure;
+
+		if (empty($this->permalink_structure)) {
+			$this->comment_feed_structure = '';
+			return false;
+		}
+
+		$this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';
+
+		return $this->comment_feed_structure;
+	}
+
+	/**
+	 * Append or update tag, pattern, and query for replacement.
+	 *
+	 * If the tag already exists, replace the existing pattern and query for
+	 * that tag, otherwise add the new tag, pattern, and query to the end of the
+	 * arrays.
+	 *
+	 * @internal What is the purpose of this function again? Need to finish long
+	 *           description.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $tag Append tag to rewritecode property array.
+	 * @param string $pattern Append pattern to rewritereplace property array.
+	 * @param string $query Append query to queryreplace property array.
+	 */
+	function add_rewrite_tag($tag, $pattern, $query) {
+		$position = array_search($tag, $this->rewritecode);
+		if ( false !== $position && null !== $position ) {
+			$this->rewritereplace[$position] = $pattern;
+			$this->queryreplace[$position] = $query;
+		} else {
+			$this->rewritecode[] = $tag;
+			$this->rewritereplace[] = $pattern;
+			$this->queryreplace[] = $query;
+		}
+	}
+
+	/**
+	 * Generate the rules from permalink structure.
+	 *
+	 * The main WP_Rewrite function for building the rewrite rule list. The
+	 * contents of the function is a mix of black magic and regular expressions,
+	 * so best just ignore the contents and move to the parameters.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $permalink_structure The permalink structure.
+	 * @param int $ep_mask Optional, default is EP_NONE. Endpoint constant, see EP_* constants.
+	 * @param bool $paged Optional, default is true. Whether permalink request is paged.
+	 * @param bool $feed Optional, default is true. Whether for feed.
+	 * @param bool $forcomments Optional, default is false. Whether for comments.
+	 * @param bool $walk_dirs Optional, default is true. Whether to create list of directories to walk over.
+	 * @param bool $endpoints Optional, default is true. Whether endpoints are enabled.
+	 * @return array Rewrite rule list.
+	 */
+	function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
+		//build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
+		$feedregex2 = '';
+		foreach ( (array) $this->feeds as $feed_name)
+			$feedregex2 .= $feed_name . '|';
+		$feedregex2 = '(' . trim($feedregex2, '|') .  ')/?$';
+
+		//$feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom
+		//and <permalink>/atom are both possible
+		$feedregex = $this->feed_base  . '/' . $feedregex2;
+
+		//build a regex to match the trackback and page/xx parts of URLs
+		$trackbackregex = 'trackback/?$';
+		$pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
+		$commentregex = 'comment-page-([0-9]{1,})/?$';
+
+		//build up an array of endpoint regexes to append => queries to append
+		if ( $endpoints ) {
+			$ep_query_append = array ();
+			foreach ( (array) $this->endpoints as $endpoint) {
+				//match everything after the endpoint name, but allow for nothing to appear there
+				$epmatch = $endpoint[1] . '(/(.*))?/?$';
+				//this will be appended on to the rest of the query for each dir
+				$epquery = '&' . $endpoint[1] . '=';
+				$ep_query_append[$epmatch] = array ( $endpoint[0], $epquery );
+			}
+		}
+
+		//get everything up to the first rewrite tag
+		$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
+		//build an array of the tags (note that said array ends up being in $tokens[0])
+		preg_match_all('/%.+?%/', $permalink_structure, $tokens);
+
+		$num_tokens = count($tokens[0]);
+
+		$index = $this->index; //probably 'index.php'
+		$feedindex = $index;
+		$trackbackindex = $index;
+		//build a list from the rewritecode and queryreplace arrays, that will look something like
+		//tagname=$matches[i] where i is the current $i
+		for ( $i = 0; $i < $num_tokens; ++$i ) {
+			if ( 0 < $i )
+				$queries[$i] = $queries[$i - 1] . '&';
+			else
+				$queries[$i] = '';
+
+			$query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
+			$queries[$i] .= $query_token;
+		}
+
+		//get the structure, minus any cruft (stuff that isn't tags) at the front
+		$structure = $permalink_structure;
+		if ( $front != '/' )
+			$structure = str_replace($front, '', $structure);
+
+		//create a list of dirs to walk over, making rewrite rules for each level
+		//so for example, a $structure of /%year%/%month%/%postname% would create
+		//rewrite rules for /%year%/, /%year%/%month%/ and /%year%/%month%/%postname%
+		$structure = trim($structure, '/');
+		$dirs = $walk_dirs ? explode('/', $structure) : array( $structure );
+		$num_dirs = count($dirs);
+
+		//strip slashes from the front of $front
+		$front = preg_replace('|^/+|', '', $front);
+
+		//the main workhorse loop
+		$post_rewrite = array();
+		$struct = $front;
+		for ( $j = 0; $j < $num_dirs; ++$j ) {
+			//get the struct for this dir, and trim slashes off the front
+			$struct .= $dirs[$j] . '/'; //accumulate. see comment near explode('/', $structure) above
+			$struct = ltrim($struct, '/');
+
+			//replace tags with regexes
+			$match = str_replace($this->rewritecode, $this->rewritereplace, $struct);
+
+			//make a list of tags, and store how many there are in $num_toks
+			$num_toks = preg_match_all('/%.+?%/', $struct, $toks);
+
+			//get the 'tagname=$matches[i]'
+			$query = ( isset($queries) && is_array($queries) ) ? $queries[$num_toks - 1] : '';
+
+			//set up $ep_mask_specific which is used to match more specific URL types
+			switch ( $dirs[$j] ) {
+				case '%year%':
+					$ep_mask_specific = EP_YEAR;
+					break;
+				case '%monthnum%':
+					$ep_mask_specific = EP_MONTH;
+					break;
+				case '%day%':
+					$ep_mask_specific = EP_DAY;
+					break;
+				default:
+					$ep_mask_specific = EP_NONE;
+			}
+
+			//create query for /page/xx
+			$pagematch = $match . $pageregex;
+			$pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
+
+			//create query for /comment-page-xx
+			$commentmatch = $match . $commentregex;
+			$commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1);
+
+			if ( get_option('page_on_front') ) {
+				//create query for Root /comment-page-xx
+				$rootcommentmatch = $match . $commentregex;
+				$rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1);
+			}
+
+			//create query for /feed/(feed|atom|rss|rss2|rdf)
+			$feedmatch = $match . $feedregex;
+			$feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
+
+			//create query for /(feed|atom|rss|rss2|rdf) (see comment near creation of $feedregex)
+			$feedmatch2 = $match . $feedregex2;
+			$feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
+
+			//if asked to, turn the feed queries into comment feed ones
+			if ( $forcomments ) {
+				$feedquery .= '&withcomments=1';
+				$feedquery2 .= '&withcomments=1';
+			}
+
+			//start creating the array of rewrites for this dir
+			$rewrite = array();
+			if ( $feed ) //...adding on /feed/ regexes => queries
+				$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
+			if ( $paged ) //...and /page/xx ones
+				$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
+
+			//only on pages with comments add ../comment-page-xx/
+			if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask )
+				$rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
+			else if ( EP_ROOT & $ep_mask && get_option('page_on_front') )
+				$rewrite = array_merge($rewrite, array($rootcommentmatch => $rootcommentquery));
+
+			//do endpoints
+			if ( $endpoints ) {
+				foreach ( (array) $ep_query_append as $regex => $ep) {
+					//add the endpoints on if the mask fits
+					if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific )
+						$rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);
+				}
+			}
+
+			//if we've got some tags in this dir
+			if ( $num_toks ) {
+				$post = false;
+				$page = false;
+
+				//check to see if this dir is permalink-level: i.e. the structure specifies an
+				//individual post. Do this by checking it contains at least one of 1) post name,
+				//2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
+				//minute all present). Set these flags now as we need them for the endpoints.
+				if ( strpos($struct, '%postname%') !== false
+						|| strpos($struct, '%post_id%') !== false
+						|| strpos($struct, '%pagename%') !== false
+						|| (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false)
+						) {
+					$post = true;
+					if ( strpos($struct, '%pagename%') !== false )
+						$page = true;
+				}
+
+				if ( ! $post ) {
+					// For custom post types, we need to add on endpoints as well.
+					foreach ( get_post_types( array('_builtin' => false ) ) as $ptype ) {
+						if ( strpos($struct, "%$ptype%") !== false ) {
+							$post = true;
+							$page = is_post_type_hierarchical( $ptype ); // This is for page style attachment url's
+							break;
+						}
+					}
+				}
+
+				//if we're creating rules for a permalink, do all the endpoints like attachments etc
+				if ( $post ) {
+					//create query and regex for trackback
+					$trackbackmatch = $match . $trackbackregex;
+					$trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
+					//trim slashes from the end of the regex for this dir
+					$match = rtrim($match, '/');
+					//get rid of brackets
+					$submatchbase = str_replace( array('(', ')'), '', $match);
+
+					//add a rule for at attachments, which take the form of <permalink>/some-text
+					$sub1 = $submatchbase . '/([^/]+)/';
+					$sub1tb = $sub1 . $trackbackregex; //add trackback regex <permalink>/trackback/...
+					$sub1feed = $sub1 . $feedregex; //and <permalink>/feed/(atom|...)
+					$sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...)
+					$sub1comment = $sub1 . $commentregex; //and <permalink>/comment-page-xx
+					//add an ? as we don't have to match that last slash, and finally a $ so we
+					//match to the end of the URL
+
+					//add another rule to match attachments in the explicit form:
+					//<permalink>/attachment/some-text
+					$sub2 = $submatchbase . '/attachment/([^/]+)/';
+					$sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback
+					$sub2feed = $sub2 . $feedregex;    //feeds, <permalink>/attachment/feed/(atom|...)
+					$sub2feed2 = $sub2 . $feedregex2;  //and feeds again on to this <permalink>/attachment/(feed|atom...)
+					$sub2comment = $sub2 . $commentregex; //and <permalink>/comment-page-xx
+
+					//create queries for these extra tag-ons we've just dealt with
+					$subquery = $index . '?attachment=' . $this->preg_index(1);
+					$subtbquery = $subquery . '&tb=1';
+					$subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
+					$subcommentquery = $subquery . '&cpage=' . $this->preg_index(2);
+
+					//do endpoints for attachments
+					if ( !empty($endpoints) ) {
+						foreach ( (array) $ep_query_append as $regex => $ep ) {
+							if ( $ep[0] & EP_ATTACHMENT ) {
+								$rewrite[$sub1 . $regex] = $subquery . $ep[1] . $this->preg_index(2);
+								$rewrite[$sub2 . $regex] = $subquery . $ep[1] . $this->preg_index(2);
+							}
+						}
+					}
+
+					//now we've finished with endpoints, finish off the $sub1 and $sub2 matches
+					$sub1 .= '?$';
+					$sub2 .= '?$';
+
+					//allow URLs like <permalink>/2 for <permalink>/page/2
+					$match = $match . '(/[0-9]+)?/?$';
+					$query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
+				} else { //not matching a permalink so this is a lot simpler
+					//close the match and finalise the query
+					$match .= '?$';
+					$query = $index . '?' . $query;
+				}
+
+				//create the final array for this dir by joining the $rewrite array (which currently
+				//only contains rules/queries for trackback, pages etc) to the main regex/query for
+				//this dir
+				$rewrite = array_merge($rewrite, array($match => $query));
+
+				//if we're matching a permalink, add those extras (attachments etc) on
+				if ( $post ) {
+					//add trackback
+					$rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
+
+					//add regexes/queries for attachments, attachment trackbacks and so on
+					if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
+						$rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery));
+					$rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite);
+				}
+			} //if($num_toks)
+			//add the rules for this dir to the accumulating $post_rewrite
+			$post_rewrite = array_merge($rewrite, $post_rewrite);
+		} //foreach ($dir)
+		return $post_rewrite; //the finished rules. phew!
+	}
+
+	/**
+	 * Generate Rewrite rules with permalink structure and walking directory only.
+	 *
+	 * Shorten version of {@link WP_Rewrite::generate_rewrite_rules()} that
+	 * allows for shorter list of parameters. See the method for longer
+	 * description of what generating rewrite rules does.
+	 *
+	 * @uses WP_Rewrite::generate_rewrite_rules() See for long description and rest of parameters.
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $permalink_structure The permalink structure to generate rules.
+	 * @param bool $walk_dirs Optional, default is false. Whether to create list of directories to walk over.
+	 * @return array
+	 */
+	function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
+		return $this->generate_rewrite_rules($permalink_structure, EP_NONE, false, false, false, $walk_dirs);
+	}
+
+	/**
+	 * Construct rewrite matches and queries from permalink structure.
+	 *
+	 * Runs the action 'generate_rewrite_rules' with the parameter that is an
+	 * reference to the current WP_Rewrite instance to further manipulate the
+	 * permalink structures and rewrite rules. Runs the 'rewrite_rules_array'
+	 * filter on the full rewrite rule array.
+	 *
+	 * There are two ways to manipulate the rewrite rules, one by hooking into
+	 * the 'generate_rewrite_rules' action and gaining full control of the
+	 * object or just manipulating the rewrite rule array before it is passed
+	 * from the function.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return array An associate array of matches and queries.
+	 */
+	function rewrite_rules() {
+		$rewrite = array();
+
+		if ( empty($this->permalink_structure) )
+			return $rewrite;
+
+		// robots.txt -only if installed at the root
+		$home_path = parse_url( home_url() );
+		$robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array();
+
+		// Default Feed rules - These are require to allow for the direct access files to work with permalink structure starting with %category%
+		$default_feeds = array(	'.*wp-atom.php$'	=>	$this->index . '?feed=atom',
+								'.*wp-rdf.php$'		=>	$this->index . '?feed=rdf',
+								'.*wp-rss.php$'		=>	$this->index . '?feed=rss',
+								'.*wp-rss2.php$'	=>	$this->index . '?feed=rss2',
+								'.*wp-feed.php$'	=>	$this->index . '?feed=feed',
+								'.*wp-commentsrss2.php$'	=>	$this->index . '?feed=rss2&withcomments=1');
+
+		// Registration rules
+		$registration_pages = array();
+		if ( is_multisite() && is_main_site() ) {
+			$registration_pages['.*wp-signup.php$'] = $this->index . '?signup=true';
+			$registration_pages['.*wp-activate.php$'] = $this->index . '?activate=true';
+		}
+
+		// Post
+		$post_rewrite = $this->generate_rewrite_rules($this->permalink_structure, EP_PERMALINK);
+		$post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
+
+		// Date
+		$date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE);
+		$date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
+
+		// Root
+		$root_rewrite = $this->generate_rewrite_rules($this->root . '/', EP_ROOT);
+		$root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
+
+		// Comments
+		$comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, EP_COMMENTS, true, true, true, false);
+		$comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
+
+		// Search
+		$search_structure = $this->get_search_permastruct();
+		$search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH);
+		$search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
+
+		// Authors
+		$author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
+		$author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
+
+		// Pages
+		$page_rewrite = $this->page_rewrite_rules();
+		$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
+
+		// Extra permastructs
+		foreach ( $this->extra_permastructs as $permastructname => $permastruct ) {
+			if ( is_array($permastruct) )
+				$rules = $this->generate_rewrite_rules($permastruct[0], $permastruct[1]);
+			else
+				$rules = $this->generate_rewrite_rules($permastruct, EP_NONE);
+
+			$rules = apply_filters($permastructname . '_rewrite_rules', $rules);
+			if ( 'post_tag' == $permastructname )
+				$rules = apply_filters('tag_rewrite_rules', $rules);
+
+			$this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
+		}
+
+		// Put them together.
+		if ( $this->use_verbose_page_rules )
+			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
+		else
+			$this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
+
+		do_action_ref_array('generate_rewrite_rules', array(&$this));
+		$this->rules = apply_filters('rewrite_rules_array', $this->rules);
+
+		return $this->rules;
+	}
+
+	/**
+	 * Retrieve the rewrite rules.
+	 *
+	 * The difference between this method and {@link
+	 * WP_Rewrite::rewrite_rules()} is that this method stores the rewrite rules
+	 * in the 'rewrite_rules' option and retrieves it. This prevents having to
+	 * process all of the permalinks to get the rewrite rules in the form of
+	 * caching.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return array Rewrite rules.
+	 */
+	function wp_rewrite_rules() {
+		$this->rules = get_option('rewrite_rules');
+		if ( empty($this->rules) ) {
+			$this->matches = 'matches';
+			$this->rewrite_rules();
+			update_option('rewrite_rules', $this->rules);
+		}
+
+		return $this->rules;
+	}
+
+	/**
+	 * Retrieve mod_rewrite formatted rewrite rules to write to .htaccess.
+	 *
+	 * Does not actually write to the .htaccess file, but creates the rules for
+	 * the process that will.
+	 *
+	 * Will add  the non_wp_rules property rules to the .htaccess file before
+	 * the WordPress rewrite rules one.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return string
+	 */
+	function mod_rewrite_rules() {
+		if ( ! $this->using_permalinks() )
+			return '';
+
+		$site_root = parse_url(get_option('siteurl'));
+		if ( isset( $site_root['path'] ) )
+			$site_root = trailingslashit($site_root['path']);
+
+		$home_root = parse_url(home_url());
+		if ( isset( $home_root['path'] ) )
+			$home_root = trailingslashit($home_root['path']);
+		else
+			$home_root = '/';
+
+		$rules = "<IfModule mod_rewrite.c>\n";
+		$rules .= "RewriteEngine On\n";
+		$rules .= "RewriteBase $home_root\n";
+		$rules .= "RewriteRule ^index\.php$ - [L]\n"; // Prevent -f checks on index.php.
+
+		//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
+		foreach ( (array) $this->non_wp_rules as $match => $query) {
+			// Apache 1.3 does not support the reluctant (non-greedy) modifier.
+			$match = str_replace('.+?', '.+', $match);
+
+			// If the match is unanchored and greedy, prepend rewrite conditions
+			// to avoid infinite redirects and eclipsing of real files.
+			//if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
+				//nada.
+			//}
+
+			$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
+		}
+
+		if ( $this->use_verbose_rules ) {
+			$this->matches = '';
+			$rewrite = $this->rewrite_rules();
+			$num_rules = count($rewrite);
+			$rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
+				"RewriteCond %{REQUEST_FILENAME} -d\n" .
+				"RewriteRule ^.*$ - [S=$num_rules]\n";
+
+			foreach ( (array) $rewrite as $match => $query) {
+				// Apache 1.3 does not support the reluctant (non-greedy) modifier.
+				$match = str_replace('.+?', '.+', $match);
+
+				// If the match is unanchored and greedy, prepend rewrite conditions
+				// to avoid infinite redirects and eclipsing of real files.
+				//if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
+					//nada.
+				//}
+
+				if ( strpos($query, $this->index) !== false )
+					$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
+				else
+					$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
+			}
+		} else {
+			$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
+				"RewriteCond %{REQUEST_FILENAME} !-d\n" .
+				"RewriteRule . {$home_root}{$this->index} [L]\n";
+		}
+
+		$rules .= "</IfModule>\n";
+
+		$rules = apply_filters('mod_rewrite_rules', $rules);
+		$rules = apply_filters('rewrite_rules', $rules);  // Deprecated
+
+		return $rules;
+	}
+
+	/**
+	 * Retrieve IIS7 URL Rewrite formatted rewrite rules to write to web.config file.
+	 *
+	 * Does not actually write to the web.config file, but creates the rules for
+	 * the process that will.
+	 *
+	 * @since 2.8.0
+	 * @access public
+	 *
+	 * @return string
+	 */
+	function iis7_url_rewrite_rules( $add_parent_tags = false ) {
+
+		if ( ! $this->using_permalinks() )
+			return '';
+		$rules = '';
+		if ( $add_parent_tags ) {
+			$rules .= '<configuration>
+	<system.webServer>
+		<rewrite>
+			<rules>';
+		}
+		if ( !is_multisite() ) {
+			$rules .= '
+				<rule name="wordpress" patternSyntax="Wildcard">
+					<match url="*" />
+						<conditions>
+							<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
+							<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
+						</conditions>
+					<action type="Rewrite" url="index.php" />
+				</rule>';
+		} else {
+			if (is_subdomain_install()) {
+				$rules .= '
+				<rule name="wordpress - Rule 1" stopProcessing="true">
+					<match url="^index\.php$" ignoreCase="false" />
+					<action type="None" />
+				</rule>
+				<rule name="wordpress - Rule 2" stopProcessing="true">
+					<match url="^files/(.+)" ignoreCase="false" />
+					<action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
+				</rule>
+				<rule name="wordpress - Rule 3" stopProcessing="true">
+					<match url="^" ignoreCase="false" />
+					<conditions logicalGrouping="MatchAny">
+						<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
+						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
+					</conditions>
+					<action type="None" />
+				</rule>
+				<rule name="wordpress - Rule 4" stopProcessing="true">
+					<match url="." ignoreCase="false" />
+					<action type="Rewrite" url="index.php" />
+				</rule>';
+			} else {
+				$rules .= '
+				<rule name="wordpress - Rule 1" stopProcessing="true">
+					<match url="^index\.php$" ignoreCase="false" />
+					<action type="None" />
+				</rule>
+				<rule name="wordpress - Rule 2" stopProcessing="true">
+					<match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
+					<action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
+				</rule>
+				<rule name="wordpress - Rule 3" stopProcessing="true">
+					<match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
+					<action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
+				</rule>
+				<rule name="wordpress - Rule 4" stopProcessing="true">
+					<match url="^" ignoreCase="false" />
+					<conditions logicalGrouping="MatchAny">
+						<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
+						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
+					</conditions>
+					<action type="None" />
+				</rule>
+				<rule name="wordpress - Rule 5" stopProcessing="true">
+					<match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
+					<action type="Rewrite" url="{R:2}" />
+				</rule>
+				<rule name="wordpress - Rule 6" stopProcessing="true">
+					<match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
+					<action type="Rewrite" url="{R:2}" />
+				</rule>
+				<rule name="wordpress - Rule 7" stopProcessing="true">
+					<match url="." ignoreCase="false" />
+					<action type="Rewrite" url="index.php" />
+				</rule>';
+			}
+		}
+		if ( $add_parent_tags ) {
+			$rules .= '
+			</rules>
+		</rewrite>
+	</system.webServer>
+</configuration>';
+		}
+
+		$rules = apply_filters('iis7_url_rewrite_rules', $rules);
+
+		return $rules;
+	}
+
+	/**
+	 * Add a straight rewrite rule.
+	 *
+	 * Any value in the $after parameter that isn't 'bottom' will be placed at
+	 * the top of the rules.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string $regex Regular expression to match against request.
+	 * @param string $redirect URL regex redirects to when regex matches request.
+	 * @param string $after Optional, default is bottom. Location to place rule.
+	 */
+	function add_rule($regex, $redirect, $after = 'bottom') {
+		//get everything up to the first ?
+		$index = (strpos($redirect, '?') == false ? strlen($redirect) : strpos($redirect, '?'));
+		$front = substr($redirect, 0, $index);
+		if ( $front != $this->index ) { //it doesn't redirect to WP's index.php
+			$this->add_external_rule($regex, $redirect);
+		} else {
+			if ( 'bottom' == $after)
+				$this->extra_rules = array_merge($this->extra_rules, array($regex => $redirect));
+			else
+				$this->extra_rules_top = array_merge($this->extra_rules_top, array($regex => $redirect));
+			//$this->extra_rules[$regex] = $redirect;
+		}
+	}
+
+	/**
+	 * Add a rule that doesn't redirect to index.php.
+	 *
+	 * Can redirect to any place.
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string $regex Regular expression to match against request.
+	 * @param string $redirect URL regex redirects to when regex matches request.
+	 */
+	function add_external_rule($regex, $redirect) {
+		$this->non_wp_rules[$regex] = $redirect;
+	}
+
+	/**
+	 * Add an endpoint, like /trackback/.
+	 *
+	 * To be inserted after certain URL types (specified in $places).
+	 *
+	 * @since 2.1.0
+	 * @access public
+	 *
+	 * @param string $name Name of endpoint.
+	 * @param array $places URL types that endpoint can be used.
+	 */
+	function add_endpoint($name, $places) {
+		global $wp;
+		$this->endpoints[] = array ( $places, $name );
+		$wp->add_query_var($name);
+	}
+
+	/**
+	 * Add permalink structure.
+	 *
+	 * These are added along with the extra rewrite rules that are merged to the
+	 * top.
+	 *
+	 * @since 2.5.0
+	 * @access public
+	 *
+	 * @param string $name Name for permalink structure.
+	 * @param string $struct Permalink structure.
+	 * @param bool $with_front Prepend front base to permalink structure.
+	 */
+	function add_permastruct($name, $struct, $with_front = true, $ep_mask = EP_NONE) {
+		if ( $with_front )
+			$struct = $this->front . $struct;
+		$this->extra_permastructs[$name] = array($struct, $ep_mask);
+	}
+
+	/**
+	 * Remove rewrite rules and then recreate rewrite rules.
+	 *
+	 * Calls {@link WP_Rewrite::wp_rewrite_rules()} after removing the
+	 * 'rewrite_rules' option. If the function named 'save_mod_rewrite_rules'
+	 * exists, it will be called.
+	 *
+	 * @since 2.0.1
+	 * @access public
+	 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
+	 */
+	function flush_rules($hard = true) {
+		delete_option('rewrite_rules');
+		$this->wp_rewrite_rules();
+		if ( $hard && function_exists('save_mod_rewrite_rules') )
+			save_mod_rewrite_rules();
+		if ( $hard && function_exists('iis7_save_url_rewrite_rules') )
+			iis7_save_url_rewrite_rules();
+	}
+
+	/**
+	 * Sets up the object's properties.
+	 *
+	 * The 'use_verbose_page_rules' object property will be set to true if the
+	 * permalink structure begins with one of the following: '%postname%', '%category%',
+	 * '%tag%', or '%author%'.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 */
+	function init() {
+		$this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
+		$this->permalink_structure = get_option('permalink_structure');
+		$this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));
+		$this->root = '';
+		if ( $this->using_index_permalinks() )
+			$this->root = $this->index . '/';
+		unset($this->author_structure);
+		unset($this->date_structure);
+		unset($this->page_structure);
+		unset($this->search_structure);
+		unset($this->feed_structure);
+		unset($this->comment_feed_structure);
+		$this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) );
+
+		// Enable generic rules for pages if permalink structure doesn't begin with a wildcard.
+		if ( preg_match("/^[^%]*%(?:postname|category|tag|author)%/", $this->permalink_structure) )
+			 $this->use_verbose_page_rules = true;
+		else
+			$this->use_verbose_page_rules = false;
+	}
+
+	/**
+	 * Set the main permalink structure for the blog.
+	 *
+	 * Will update the 'permalink_structure' option, if there is a difference
+	 * between the current permalink structure and the parameter value. Calls
+	 * {@link WP_Rewrite::init()} after the option is updated.
+	 *
+	 * Fires the 'permalink_structure_changed' action once the init call has
+	 * processed passing the old and new values
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $permalink_structure Permalink structure.
+	 */
+	function set_permalink_structure($permalink_structure) {
+		if ( $permalink_structure != $this->permalink_structure ) {
+			update_option('permalink_structure', $permalink_structure);
+			$this->init();
+			do_action('permalink_structure_changed', $this->permalink_structure, $permalink_structure);
+		}
+	}
+
+	/**
+	 * Set the category base for the category permalink.
+	 *
+	 * Will update the 'category_base' option, if there is a difference between
+	 * the current category base and the parameter value. Calls
+	 * {@link WP_Rewrite::init()} after the option is updated.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @param string $category_base Category permalink structure base.
+	 */
+	function set_category_base($category_base) {
+		if ( $category_base != get_option('category_base') ) {
+			update_option('category_base', $category_base);
+			$this->init();
+		}
+	}
+
+	/**
+	 * Set the tag base for the tag permalink.
+	 *
+	 * Will update the 'tag_base' option, if there is a difference between the
+	 * current tag base and the parameter value. Calls
+	 * {@link WP_Rewrite::init()} after the option is updated.
+	 *
+	 * @since 2.3.0
+	 * @access public
+	 *
+	 * @param string $tag_base Tag permalink structure base.
+	 */
+	function set_tag_base( $tag_base ) {
+		if ( $tag_base != get_option( 'tag_base') ) {
+			update_option( 'tag_base', $tag_base );
+			$this->init();
+		}
+	}
+
+	/**
+	 * PHP4 Constructor - Calls init(), which runs setup.
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 *
+	 * @return WP_Rewrite
+	 */
+	function WP_Rewrite() {
+		$this->init();
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/rss-functions.php
===================================================================
--- /tags/3.1/wp-includes/rss-functions.php	(revision 17487)
+++ /tags/3.1/wp-includes/rss-functions.php	(revision 17487)
@@ -0,0 +1,10 @@
+<?php
+/**
+ * Deprecated.  Use rss.php instead.
+ *
+ * @package WordPress
+ */
+
+_deprecated_file( basename(__FILE__), '2.1', WPINC . '/rss.php' );
+require_once (ABSPATH . WPINC . '/rss.php');
+?>
Index: /tags/3.1/wp-includes/rss.php
===================================================================
--- /tags/3.1/wp-includes/rss.php	(revision 17487)
+++ /tags/3.1/wp-includes/rss.php	(revision 17487)
@@ -0,0 +1,939 @@
+<?php
+/**
+ * MagpieRSS: a simple RSS integration tool
+ *
+ * A compiled file for RSS syndication
+ *
+ * @author Kellan Elliott-McCrea <kellan@protest.net>
+ * @version 0.51
+ * @license GPL
+ *
+ * @package External
+ * @subpackage MagpieRSS
+ */
+
+/**
+ * Deprecated. Use SimplePie (class-simplepie.php) instead.
+ */
+_deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/class-simplepie.php' );
+
+/*
+ * Hook to use another RSS object instead of MagpieRSS
+ */
+do_action('load_feed_engine');
+
+/** RSS feed constant. */
+define('RSS', 'RSS');
+define('ATOM', 'Atom');
+define('MAGPIE_USER_AGENT', 'WordPress/' . $GLOBALS['wp_version']);
+
+class MagpieRSS {
+	var $parser;
+	var $current_item	= array();	// item currently being parsed
+	var $items			= array();	// collection of parsed items
+	var $channel		= array();	// hash of channel fields
+	var $textinput		= array();
+	var $image			= array();
+	var $feed_type;
+	var $feed_version;
+
+	// parser variables
+	var $stack				= array(); // parser stack
+	var $inchannel			= false;
+	var $initem 			= false;
+	var $incontent			= false; // if in Atom <content mode="xml"> field
+	var $intextinput		= false;
+	var $inimage 			= false;
+	var $current_field		= '';
+	var $current_namespace	= false;
+
+	//var $ERROR = "";
+
+	var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
+
+	function MagpieRSS ($source) {
+
+		# if PHP xml isn't compiled in, die
+		#
+		if ( !function_exists('xml_parser_create') )
+			trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" );
+
+		$parser = @xml_parser_create();
+
+		if ( !is_resource($parser) )
+			trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php");
+
+
+		$this->parser = $parser;
+
+		# pass in parser, and a reference to this object
+		# set up handlers
+		#
+		xml_set_object( $this->parser, $this );
+		xml_set_element_handler($this->parser,
+				'feed_start_element', 'feed_end_element' );
+
+		xml_set_character_data_handler( $this->parser, 'feed_cdata' );
+
+		$status = xml_parse( $this->parser, $source );
+
+		if (! $status ) {
+			$errorcode = xml_get_error_code( $this->parser );
+			if ( $errorcode != XML_ERROR_NONE ) {
+				$xml_error = xml_error_string( $errorcode );
+				$error_line = xml_get_current_line_number($this->parser);
+				$error_col = xml_get_current_column_number($this->parser);
+				$errormsg = "$xml_error at line $error_line, column $error_col";
+
+				$this->error( $errormsg );
+			}
+		}
+
+		xml_parser_free( $this->parser );
+
+		$this->normalize();
+	}
+
+	function feed_start_element($p, $element, &$attrs) {
+		$el = $element = strtolower($element);
+		$attrs = array_change_key_case($attrs, CASE_LOWER);
+
+		// check for a namespace, and split if found
+		$ns	= false;
+		if ( strpos( $element, ':' ) ) {
+			list($ns, $el) = split( ':', $element, 2);
+		}
+		if ( $ns and $ns != 'rdf' ) {
+			$this->current_namespace = $ns;
+		}
+
+		# if feed type isn't set, then this is first element of feed
+		# identify feed from root element
+		#
+		if (!isset($this->feed_type) ) {
+			if ( $el == 'rdf' ) {
+				$this->feed_type = RSS;
+				$this->feed_version = '1.0';
+			}
+			elseif ( $el == 'rss' ) {
+				$this->feed_type = RSS;
+				$this->feed_version = $attrs['version'];
+			}
+			elseif ( $el == 'feed' ) {
+				$this->feed_type = ATOM;
+				$this->feed_version = $attrs['version'];
+				$this->inchannel = true;
+			}
+			return;
+		}
+
+		if ( $el == 'channel' )
+		{
+			$this->inchannel = true;
+		}
+		elseif ($el == 'item' or $el == 'entry' )
+		{
+			$this->initem = true;
+			if ( isset($attrs['rdf:about']) ) {
+				$this->current_item['about'] = $attrs['rdf:about'];
+			}
+		}
+
+		// if we're in the default namespace of an RSS feed,
+		//  record textinput or image fields
+		elseif (
+			$this->feed_type == RSS and
+			$this->current_namespace == '' and
+			$el == 'textinput' )
+		{
+			$this->intextinput = true;
+		}
+
+		elseif (
+			$this->feed_type == RSS and
+			$this->current_namespace == '' and
+			$el == 'image' )
+		{
+			$this->inimage = true;
+		}
+
+		# handle atom content constructs
+		elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
+		{
+			// avoid clashing w/ RSS mod_content
+			if ($el == 'content' ) {
+				$el = 'atom_content';
+			}
+
+			$this->incontent = $el;
+
+
+		}
+
+		// if inside an Atom content construct (e.g. content or summary) field treat tags as text
+		elseif ($this->feed_type == ATOM and $this->incontent )
+		{
+			// if tags are inlined, then flatten
+			$attrs_str = join(' ',
+					array_map(array('MagpieRSS', 'map_attrs'),
+					array_keys($attrs),
+					array_values($attrs) ) );
+
+			$this->append_content( "<$element $attrs_str>"  );
+
+			array_unshift( $this->stack, $el );
+		}
+
+		// Atom support many links per containging element.
+		// Magpie treats link elements of type rel='alternate'
+		// as being equivalent to RSS's simple link element.
+		//
+		elseif ($this->feed_type == ATOM and $el == 'link' )
+		{
+			if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
+			{
+				$link_el = 'link';
+			}
+			else {
+				$link_el = 'link_' . $attrs['rel'];
+			}
+
+			$this->append($link_el, $attrs['href']);
+		}
+		// set stack[0] to current element
+		else {
+			array_unshift($this->stack, $el);
+		}
+	}
+
+
+
+	function feed_cdata ($p, $text) {
+
+		if ($this->feed_type == ATOM and $this->incontent)
+		{
+			$this->append_content( $text );
+		}
+		else {
+			$current_el = join('_', array_reverse($this->stack));
+			$this->append($current_el, $text);
+		}
+	}
+
+	function feed_end_element ($p, $el) {
+		$el = strtolower($el);
+
+		if ( $el == 'item' or $el == 'entry' )
+		{
+			$this->items[] = $this->current_item;
+			$this->current_item = array();
+			$this->initem = false;
+		}
+		elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
+		{
+			$this->intextinput = false;
+		}
+		elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
+		{
+			$this->inimage = false;
+		}
+		elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
+		{
+			$this->incontent = false;
+		}
+		elseif ($el == 'channel' or $el == 'feed' )
+		{
+			$this->inchannel = false;
+		}
+		elseif ($this->feed_type == ATOM and $this->incontent  ) {
+			// balance tags properly
+			// note:  i don't think this is actually neccessary
+			if ( $this->stack[0] == $el )
+			{
+				$this->append_content("</$el>");
+			}
+			else {
+				$this->append_content("<$el />");
+			}
+
+			array_shift( $this->stack );
+		}
+		else {
+			array_shift( $this->stack );
+		}
+
+		$this->current_namespace = false;
+	}
+
+	function concat (&$str1, $str2="") {
+		if (!isset($str1) ) {
+			$str1="";
+		}
+		$str1 .= $str2;
+	}
+
+	function append_content($text) {
+		if ( $this->initem ) {
+			$this->concat( $this->current_item[ $this->incontent ], $text );
+		}
+		elseif ( $this->inchannel ) {
+			$this->concat( $this->channel[ $this->incontent ], $text );
+		}
+	}
+
+	// smart append - field and namespace aware
+	function append($el, $text) {
+		if (!$el) {
+			return;
+		}
+		if ( $this->current_namespace )
+		{
+			if ( $this->initem ) {
+				$this->concat(
+					$this->current_item[ $this->current_namespace ][ $el ], $text);
+			}
+			elseif ($this->inchannel) {
+				$this->concat(
+					$this->channel[ $this->current_namespace][ $el ], $text );
+			}
+			elseif ($this->intextinput) {
+				$this->concat(
+					$this->textinput[ $this->current_namespace][ $el ], $text );
+			}
+			elseif ($this->inimage) {
+				$this->concat(
+					$this->image[ $this->current_namespace ][ $el ], $text );
+			}
+		}
+		else {
+			if ( $this->initem ) {
+				$this->concat(
+					$this->current_item[ $el ], $text);
+			}
+			elseif ($this->intextinput) {
+				$this->concat(
+					$this->textinput[ $el ], $text );
+			}
+			elseif ($this->inimage) {
+				$this->concat(
+					$this->image[ $el ], $text );
+			}
+			elseif ($this->inchannel) {
+				$this->concat(
+					$this->channel[ $el ], $text );
+			}
+
+		}
+	}
+
+	function normalize () {
+		// if atom populate rss fields
+		if ( $this->is_atom() ) {
+			$this->channel['descripton'] = $this->channel['tagline'];
+			for ( $i = 0; $i < count($this->items); $i++) {
+				$item = $this->items[$i];
+				if ( isset($item['summary']) )
+					$item['description'] = $item['summary'];
+				if ( isset($item['atom_content']))
+					$item['content']['encoded'] = $item['atom_content'];
+
+				$this->items[$i] = $item;
+			}
+		}
+		elseif ( $this->is_rss() ) {
+			$this->channel['tagline'] = $this->channel['description'];
+			for ( $i = 0; $i < count($this->items); $i++) {
+				$item = $this->items[$i];
+				if ( isset($item['description']))
+					$item['summary'] = $item['description'];
+				if ( isset($item['content']['encoded'] ) )
+					$item['atom_content'] = $item['content']['encoded'];
+
+				$this->items[$i] = $item;
+			}
+		}
+	}
+
+	function is_rss () {
+		if ( $this->feed_type == RSS ) {
+			return $this->feed_version;
+		}
+		else {
+			return false;
+		}
+	}
+
+	function is_atom() {
+		if ( $this->feed_type == ATOM ) {
+			return $this->feed_version;
+		}
+		else {
+			return false;
+		}
+	}
+
+	function map_attrs($k, $v) {
+		return "$k=\"$v\"";
+	}
+
+	function error( $errormsg, $lvl = E_USER_WARNING ) {
+		// append PHP's error message if track_errors enabled
+		if ( isset($php_errormsg) ) {
+			$errormsg .= " ($php_errormsg)";
+		}
+		if ( MAGPIE_DEBUG ) {
+			trigger_error( $errormsg, $lvl);
+		} else {
+			error_log( $errormsg, 0);
+		}
+	}
+
+}
+
+if ( !function_exists('fetch_rss') ) :
+/**
+ * Build Magpie object based on RSS from URL.
+ *
+ * @since 1.5.0
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL to retrieve feed
+ * @return bool|MagpieRSS false on failure or MagpieRSS object on success.
+ */
+function fetch_rss ($url) {
+	// initialize constants
+	init();
+
+	if ( !isset($url) ) {
+		// error("fetch_rss called without a url");
+		return false;
+	}
+
+	// if cache is disabled
+	if ( !MAGPIE_CACHE_ON ) {
+		// fetch file, and parse it
+		$resp = _fetch_remote_file( $url );
+		if ( is_success( $resp->status ) ) {
+			return _response_to_rss( $resp );
+		}
+		else {
+			// error("Failed to fetch $url and cache is off");
+			return false;
+		}
+	}
+	// else cache is ON
+	else {
+		// Flow
+		// 1. check cache
+		// 2. if there is a hit, make sure its fresh
+		// 3. if cached obj fails freshness check, fetch remote
+		// 4. if remote fails, return stale object, or error
+
+		$cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
+
+		if (MAGPIE_DEBUG and $cache->ERROR) {
+			debug($cache->ERROR, E_USER_WARNING);
+		}
+
+
+		$cache_status 	 = 0;		// response of check_cache
+		$request_headers = array(); // HTTP headers to send with fetch
+		$rss 			 = 0;		// parsed RSS object
+		$errormsg		 = 0;		// errors, if any
+
+		if (!$cache->ERROR) {
+			// return cache HIT, MISS, or STALE
+			$cache_status = $cache->check_cache( $url );
+		}
+
+		// if object cached, and cache is fresh, return cached obj
+		if ( $cache_status == 'HIT' ) {
+			$rss = $cache->get( $url );
+			if ( isset($rss) and $rss ) {
+				$rss->from_cache = 1;
+				if ( MAGPIE_DEBUG > 1) {
+				debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
+			}
+				return $rss;
+			}
+		}
+
+		// else attempt a conditional get
+
+		// set up headers
+		if ( $cache_status == 'STALE' ) {
+			$rss = $cache->get( $url );
+			if ( isset($rss->etag) and $rss->last_modified ) {
+				$request_headers['If-None-Match'] = $rss->etag;
+				$request_headers['If-Last-Modified'] = $rss->last_modified;
+			}
+		}
+
+		$resp = _fetch_remote_file( $url, $request_headers );
+
+		if (isset($resp) and $resp) {
+			if ($resp->status == '304' ) {
+				// we have the most current copy
+				if ( MAGPIE_DEBUG > 1) {
+					debug("Got 304 for $url");
+				}
+				// reset cache on 304 (at minutillo insistent prodding)
+				$cache->set($url, $rss);
+				return $rss;
+			}
+			elseif ( is_success( $resp->status ) ) {
+				$rss = _response_to_rss( $resp );
+				if ( $rss ) {
+					if (MAGPIE_DEBUG > 1) {
+						debug("Fetch successful");
+					}
+					// add object to cache
+					$cache->set( $url, $rss );
+					return $rss;
+				}
+			}
+			else {
+				$errormsg = "Failed to fetch $url. ";
+				if ( $resp->error ) {
+					# compensate for Snoopy's annoying habbit to tacking
+					# on '\n'
+					$http_error = substr($resp->error, 0, -2);
+					$errormsg .= "(HTTP Error: $http_error)";
+				}
+				else {
+					$errormsg .=  "(HTTP Response: " . $resp->response_code .')';
+				}
+			}
+		}
+		else {
+			$errormsg = "Unable to retrieve RSS file for unknown reasons.";
+		}
+
+		// else fetch failed
+
+		// attempt to return cached object
+		if ($rss) {
+			if ( MAGPIE_DEBUG ) {
+				debug("Returning STALE object for $url");
+			}
+			return $rss;
+		}
+
+		// else we totally failed
+		// error( $errormsg );
+
+		return false;
+
+	} // end if ( !MAGPIE_CACHE_ON ) {
+} // end fetch_rss()
+endif;
+
+/**
+ * Retrieve URL headers and content using WP HTTP Request API.
+ *
+ * @since 1.5.0
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL to retrieve
+ * @param array $headers Optional. Headers to send to the URL.
+ * @return Snoopy style response
+ */
+function _fetch_remote_file($url, $headers = "" ) {
+	$resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
+	if ( is_wp_error($resp) ) {
+		$error = array_shift($resp->errors);
+
+		$resp = new stdClass;
+		$resp->status = 500;
+		$resp->response_code = 500;
+		$resp->error = $error[0] . "\n"; //\n = Snoopy compatibility
+		return $resp;
+	}
+
+	// Snoopy returns headers unprocessed.
+	// Also note, WP_HTTP lowercases all keys, Snoopy did not.
+	$return_headers = array();
+	foreach ( $resp['headers'] as $key => $value ) {
+		if ( !is_array($value) ) {
+			$return_headers[] = "$key: $value";
+		} else {
+			foreach ( $value as $v )
+				$return_headers[] = "$key: $v";
+		}
+	}
+
+	$response = new stdClass;
+	$response->status = $resp['response']['code'];
+	$response->response_code = $resp['response']['code'];
+	$response->headers = $return_headers;
+	$response->results = $resp['body'];
+
+	return $response;
+}
+
+/**
+ * Retrieve
+ *
+ * @since 1.5.0
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param unknown_type $resp
+ * @return unknown
+ */
+function _response_to_rss ($resp) {
+	$rss = new MagpieRSS( $resp->results );
+
+	// if RSS parsed successfully
+	if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) {
+
+		// find Etag, and Last-Modified
+		foreach( (array) $resp->headers as $h) {
+			// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
+			if (strpos($h, ": ")) {
+				list($field, $val) = explode(": ", $h, 2);
+			}
+			else {
+				$field = $h;
+				$val = "";
+			}
+
+			if ( $field == 'etag' ) {
+				$rss->etag = $val;
+			}
+
+			if ( $field == 'last-modified' ) {
+				$rss->last_modified = $val;
+			}
+		}
+
+		return $rss;
+	} // else construct error message
+	else {
+		$errormsg = "Failed to parse RSS file.";
+
+		if ($rss) {
+			$errormsg .= " (" . $rss->ERROR . ")";
+		}
+		// error($errormsg);
+
+		return false;
+	} // end if ($rss and !$rss->error)
+}
+
+/**
+ * Set up constants with default values, unless user overrides.
+ *
+ * @since 1.5.0
+ * @package External
+ * @subpackage MagpieRSS
+ */
+function init () {
+	if ( defined('MAGPIE_INITALIZED') ) {
+		return;
+	}
+	else {
+		define('MAGPIE_INITALIZED', 1);
+	}
+
+	if ( !defined('MAGPIE_CACHE_ON') ) {
+		define('MAGPIE_CACHE_ON', 1);
+	}
+
+	if ( !defined('MAGPIE_CACHE_DIR') ) {
+		define('MAGPIE_CACHE_DIR', './cache');
+	}
+
+	if ( !defined('MAGPIE_CACHE_AGE') ) {
+		define('MAGPIE_CACHE_AGE', 60*60); // one hour
+	}
+
+	if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
+		define('MAGPIE_CACHE_FRESH_ONLY', 0);
+	}
+
+		if ( !defined('MAGPIE_DEBUG') ) {
+		define('MAGPIE_DEBUG', 0);
+	}
+
+	if ( !defined('MAGPIE_USER_AGENT') ) {
+		$ua = 'WordPress/' . $GLOBALS['wp_version'];
+
+		if ( MAGPIE_CACHE_ON ) {
+			$ua = $ua . ')';
+		}
+		else {
+			$ua = $ua . '; No cache)';
+		}
+
+		define('MAGPIE_USER_AGENT', $ua);
+	}
+
+	if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
+		define('MAGPIE_FETCH_TIME_OUT', 2);	// 2 second timeout
+	}
+
+	// use gzip encoding to fetch rss files if supported?
+	if ( !defined('MAGPIE_USE_GZIP') ) {
+		define('MAGPIE_USE_GZIP', true);
+	}
+}
+
+function is_info ($sc) {
+	return $sc >= 100 && $sc < 200;
+}
+
+function is_success ($sc) {
+	return $sc >= 200 && $sc < 300;
+}
+
+function is_redirect ($sc) {
+	return $sc >= 300 && $sc < 400;
+}
+
+function is_error ($sc) {
+	return $sc >= 400 && $sc < 600;
+}
+
+function is_client_error ($sc) {
+	return $sc >= 400 && $sc < 500;
+}
+
+function is_server_error ($sc) {
+	return $sc >= 500 && $sc < 600;
+}
+
+class RSSCache {
+	var $BASE_CACHE;	// where the cache files are stored
+	var $MAX_AGE	= 43200;  		// when are files stale, default twelve hours
+	var $ERROR 		= '';			// accumulate error messages
+
+	function RSSCache ($base='', $age='') {
+		$this->BASE_CACHE = WP_CONTENT_DIR . '/cache';
+		if ( $base ) {
+			$this->BASE_CACHE = $base;
+		}
+		if ( $age ) {
+			$this->MAX_AGE = $age;
+		}
+
+	}
+
+/*=======================================================================*\
+	Function:	set
+	Purpose:	add an item to the cache, keyed on url
+	Input:		url from wich the rss file was fetched
+	Output:		true on sucess
+\*=======================================================================*/
+	function set ($url, $rss) {
+		$cache_option = 'rss_' . $this->file_name( $url );
+
+		set_transient($cache_option, $rss, $this->MAX_AGE);
+
+		return $cache_option;
+	}
+
+/*=======================================================================*\
+	Function:	get
+	Purpose:	fetch an item from the cache
+	Input:		url from wich the rss file was fetched
+	Output:		cached object on HIT, false on MISS
+\*=======================================================================*/
+	function get ($url) {
+		$this->ERROR = "";
+		$cache_option = 'rss_' . $this->file_name( $url );
+
+		if ( ! $rss = get_transient( $cache_option ) ) {
+			$this->debug(
+				"Cache doesn't contain: $url (cache option: $cache_option)"
+			);
+			return 0;
+		}
+
+		return $rss;
+	}
+
+/*=======================================================================*\
+	Function:	check_cache
+	Purpose:	check a url for membership in the cache
+				and whether the object is older then MAX_AGE (ie. STALE)
+	Input:		url from wich the rss file was fetched
+	Output:		cached object on HIT, false on MISS
+\*=======================================================================*/
+	function check_cache ( $url ) {
+		$this->ERROR = "";
+		$cache_option = 'rss_' . $this->file_name( $url );
+
+		if ( get_transient($cache_option) ) {
+			// object exists and is current
+				return 'HIT';
+		} else {
+			// object does not exist
+			return 'MISS';
+		}
+	}
+
+/*=======================================================================*\
+	Function:	serialize
+\*=======================================================================*/
+	function serialize ( $rss ) {
+		return serialize( $rss );
+	}
+
+/*=======================================================================*\
+	Function:	unserialize
+\*=======================================================================*/
+	function unserialize ( $data ) {
+		return unserialize( $data );
+	}
+
+/*=======================================================================*\
+	Function:	file_name
+	Purpose:	map url to location in cache
+	Input:		url from wich the rss file was fetched
+	Output:		a file name
+\*=======================================================================*/
+	function file_name ($url) {
+		return md5( $url );
+	}
+
+/*=======================================================================*\
+	Function:	error
+	Purpose:	register error
+\*=======================================================================*/
+	function error ($errormsg, $lvl=E_USER_WARNING) {
+		// append PHP's error message if track_errors enabled
+		if ( isset($php_errormsg) ) {
+			$errormsg .= " ($php_errormsg)";
+		}
+		$this->ERROR = $errormsg;
+		if ( MAGPIE_DEBUG ) {
+			trigger_error( $errormsg, $lvl);
+		}
+		else {
+			error_log( $errormsg, 0);
+		}
+	}
+			function debug ($debugmsg, $lvl=E_USER_NOTICE) {
+		if ( MAGPIE_DEBUG ) {
+			$this->error("MagpieRSS [debug] $debugmsg", $lvl);
+		}
+	}
+}
+
+if ( !function_exists('parse_w3cdtf') ) :
+function parse_w3cdtf ( $date_str ) {
+
+	# regex to match wc3dtf
+	$pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
+
+	if ( preg_match( $pat, $date_str, $match ) ) {
+		list( $year, $month, $day, $hours, $minutes, $seconds) =
+			array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[7]);
+
+		# calc epoch for current date assuming GMT
+		$epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
+
+		$offset = 0;
+		if ( $match[11] == 'Z' ) {
+			# zulu time, aka GMT
+		}
+		else {
+			list( $tz_mod, $tz_hour, $tz_min ) =
+				array( $match[8], $match[9], $match[10]);
+
+			# zero out the variables
+			if ( ! $tz_hour ) { $tz_hour = 0; }
+			if ( ! $tz_min ) { $tz_min = 0; }
+
+			$offset_secs = (($tz_hour*60)+$tz_min)*60;
+
+			# is timezone ahead of GMT?  then subtract offset
+			#
+			if ( $tz_mod == '+' ) {
+				$offset_secs = $offset_secs * -1;
+			}
+
+			$offset = $offset_secs;
+		}
+		$epoch = $epoch + $offset;
+		return $epoch;
+	}
+	else {
+		return -1;
+	}
+}
+endif;
+
+if ( !function_exists('wp_rss') ) :
+/**
+ * Display all RSS items in a HTML ordered list.
+ *
+ * @since 1.5.0
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL of feed to display. Will not auto sense feed URL.
+ * @param int $num_items Optional. Number of items to display, default is all.
+ */
+function wp_rss( $url, $num_items = -1 ) {
+	if ( $rss = fetch_rss( $url ) ) {
+		echo '<ul>';
+
+		if ( $num_items !== -1 ) {
+			$rss->items = array_slice( $rss->items, 0, $num_items );
+		}
+
+		foreach ( (array) $rss->items as $item ) {
+			printf(
+				'<li><a href="%1$s" title="%2$s">%3$s</a></li>',
+				esc_url( $item['link'] ),
+				esc_attr( strip_tags( $item['description'] ) ),
+				esc_html( $item['title'] )
+			);
+		}
+
+		echo '</ul>';
+	} else {
+		_e( 'An error has occurred, which probably means the feed is down. Try again later.' );
+	}
+}
+endif;
+
+if ( !function_exists('get_rss') ) :
+/**
+ * Display RSS items in HTML list items.
+ *
+ * You have to specify which HTML list you want, either ordered or unordered
+ * before using the function. You also have to specify how many items you wish
+ * to display. You can't display all of them like you can with wp_rss()
+ * function.
+ *
+ * @since 1.5.0
+ * @package External
+ * @subpackage MagpieRSS
+ *
+ * @param string $url URL of feed to display. Will not auto sense feed URL.
+ * @param int $num_items Optional. Number of items to display, default is all.
+ * @return bool False on failure.
+ */
+function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
+	$rss = fetch_rss($url);
+	if ( $rss ) {
+		$rss->items = array_slice($rss->items, 0, $num_items);
+		foreach ( (array) $rss->items as $item ) {
+			echo "<li>\n";
+			echo "<a href='$item[link]' title='$item[description]'>";
+			echo esc_html($item['title']);
+			echo "</a><br />\n";
+			echo "</li>\n";
+		}
+	} else {
+		return false;
+	}
+}
+endif;
+
+?>
Index: /tags/3.1/wp-includes/script-loader.php
===================================================================
--- /tags/3.1/wp-includes/script-loader.php	(revision 17487)
+++ /tags/3.1/wp-includes/script-loader.php	(revision 17487)
@@ -0,0 +1,793 @@
+<?php
+/**
+ * WordPress scripts and styles default loader.
+ *
+ * Most of the functionality that existed here was moved to
+ * {@link http://backpress.automattic.com/ BackPress}. WordPress themes and
+ * plugins will only be concerned about the filters and actions set in this
+ * file.
+ *
+ * Several constants are used to manage the loading, concatenating and compression of scripts and CSS:
+ * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation,
+ * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,
+ * define('COMPRESS_SCRIPTS', false); disables compression of scripts,
+ * define('COMPRESS_CSS', false); disables compression of CSS,
+ * define('ENFORCE_GZIP', true); forces gzip for compression (default is deflate).
+ *
+ * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
+ * to temporarily override the above settings. Also a compression test is run once and the result is saved
+ * as option 'can_compress_scripts' (0/1). The test will run again if that option is deleted.
+ *
+ * @package WordPress
+ */
+
+/** BackPress: WordPress Dependencies Class */
+require( ABSPATH . WPINC . '/class.wp-dependencies.php' );
+
+/** BackPress: WordPress Scripts Class */
+require( ABSPATH . WPINC . '/class.wp-scripts.php' );
+
+/** BackPress: WordPress Scripts Functions */
+require( ABSPATH . WPINC . '/functions.wp-scripts.php' );
+
+/** BackPress: WordPress Styles Class */
+require( ABSPATH . WPINC . '/class.wp-styles.php' );
+
+/** BackPress: WordPress Styles Functions */
+require( ABSPATH . WPINC . '/functions.wp-styles.php' );
+
+/**
+ * Set up WordPress scripts to load by default for Administration Panels.
+ *
+ * Localizes a few of the scripts.
+ * $scripts->add_data( 'script-handle', 'group', 1 ); queues the script for the footer
+ *
+ * @since 2.6.0
+ *
+ * @param object $scripts WP_Scripts object.
+ */
+function wp_default_scripts( &$scripts ) {
+
+	if ( !$guessurl = site_url() )
+		$guessurl = wp_guess_url();
+
+	$scripts->base_url = $guessurl;
+	$scripts->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
+	$scripts->default_version = get_bloginfo( 'version' );
+	$scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/');
+
+	$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
+
+	// Always ensure that we have the convertEntities function
+	$scripts->add( 'l10n', "/wp-includes/js/l10n$suffix.js", false, '20101110' );
+	$scripts->enqueue( 'l10n' );
+
+	$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
+
+	$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101211' );
+	$scripts->add_data( 'common', 'group', 1 );
+	$scripts->localize( 'common', 'commonL10n', array(
+		'warnDelete' => __("You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete."),
+		'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};'
+	) );
+
+	$scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' );
+	$scripts->add_data( 'sack', 'group', 1 );
+
+	$scripts->add( 'quicktags', "/wp-includes/js/quicktags$suffix.js", false, '20090307' );
+	$scripts->add_data( 'quicktags', 'group', 1 );
+	$scripts->localize( 'quicktags', 'quicktagsL10n', array(
+		'quickLinks' => __('(Quick Links)'),
+		'wordLookup' => __('Enter a word to look up:'),
+		'dictionaryLookup' => esc_attr(__('Dictionary lookup')),
+		'lookup' => esc_attr(__('lookup')),
+		'closeAllOpenTags' => esc_attr(__('Close all open tags')),
+		'closeTags' => esc_attr(__('close tags')),
+		'enterURL' => __('Enter the URL'),
+		'enterImageURL' => __('Enter the URL of the image'),
+		'enterImageDescription' => __('Enter a description of the image'),
+		'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'
+	) );
+
+	$scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' );
+
+	$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20091124' );
+
+	$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1');
+
+	$scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20091119' );
+	$scripts->add_data( 'wp-ajax-response', 'group', 1 );
+	$scripts->localize( 'wp-ajax-response', 'wpAjax', array(
+		'noPerm' => __('You do not have permission to do that.'),
+		'broken' => __('An unidentified error has occurred.'),
+		'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
+	) );
+
+	$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20101004' );
+	$scripts->add_data( 'autosave', 'group', 1 );
+
+	$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20101222' );
+	$scripts->add_data( 'wp-lists', 'group', 1 );
+
+	$scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.8.3');
+	$scripts->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.8.3');
+	$scripts->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.8.3');
+	$scripts->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.8.3');
+	$scripts->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.8.3');
+	$scripts->add( 'scriptaculous-sound', '/wp-includes/js/scriptaculous/sound.js', array( 'scriptaculous-root' ), '1.8.3' );
+	$scripts->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.8.3');
+	$scripts->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.8.3');
+
+	// not used in core, replaced by Jcrop.js
+	$scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
+
+	$scripts->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.4.4');
+
+	$scripts->add( 'jquery-ui-core', '/wp-includes/js/jquery/ui.core.js', array('jquery'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-core', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-position', '/wp-includes/js/jquery/ui.position.js', array('jquery'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-position', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-widget', '/wp-includes/js/jquery/ui.widget.js', array('jquery'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-widget', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-mouse', '/wp-includes/js/jquery/ui.mouse.js', array('jquery', 'jquery-ui-widget'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-mouse', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-button', '/wp-includes/js/jquery/ui.button.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-button', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-tabs', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-sortable', '/wp-includes/js/jquery/ui.sortable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-sortable', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-draggable', '/wp-includes/js/jquery/ui.draggable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-draggable', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-droppable', '/wp-includes/js/jquery/ui.droppable.js', array('jquery-ui-core', 'jquery-ui-mouse', 'jquery-ui-draggable'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-droppable', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-selectable', '/wp-includes/js/jquery/ui.selectable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-selectable', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core', 'jquery-ui-mouse'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-resizable', 'group', 1 );
+
+	$scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.8.9' );
+	$scripts->add_data( 'jquery-ui-dialog', 'group', 1 );
+
+	// deprecated, not used in core, most functionality is included in jQuery 1.3
+	$scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '2.02m');
+	$scripts->add_data( 'jquery-form', 'group', 1 );
+
+	$scripts->add( 'jquery-color', "/wp-includes/js/jquery/jquery.color$suffix.js", array('jquery'), '2.0-4561m');
+	$scripts->add_data( 'jquery-color', 'group', 1 );
+
+	$scripts->add( 'suggest', "/wp-includes/js/jquery/suggest$suffix.js", array('jquery'), '1.1-20110113');
+	$scripts->add_data( 'suggest', 'group', 1 );
+
+	$scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m');
+	$scripts->add_data( 'schedule', 'group', 1 );
+
+	$scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7' );
+	$scripts->add_data( 'jquery-query', 'group', 1 );
+
+	$scripts->add( 'jquery-serialize-object', "/wp-includes/js/jquery/jquery.serialize-object.js", array('jquery'), '0.2' );
+	$scripts->add_data( 'jquery-serialize-object', 'group', 1 );
+
+	$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' );
+	$scripts->add_data( 'jquery-hotkeys', 'group', 1 );
+
+	$scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), '20090102' );
+	$scripts->add_data( 'jquery-table-hotkeys', 'group', 1 );
+
+	$scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20100407');
+	$scripts->add_data( 'thickbox', 'group', 1 );
+	$scripts->localize( 'thickbox', 'thickboxL10n', array(
+			'next' => __('Next &gt;'),
+			'prev' => __('&lt; Prev'),
+			'image' => __('Image'),
+			'of' => __('of'),
+			'close' => __('Close'),
+			'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
+			'l10n_print_after' => 'try{convertEntities(thickboxL10n);}catch(e){};'
+	) );
+
+
+	$scripts->add( 'jcrop', "/wp-includes/js/jcrop/jquery.Jcrop$suffix.js", array('jquery'), '0.9.8-20110113');
+
+	$scripts->add( 'swfobject', "/wp-includes/js/swfobject.js", false, '2.2');
+
+	$scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2201-20110113');
+	$scripts->add( 'swfupload-swfobject', '/wp-includes/js/swfupload/plugins/swfupload.swfobject.js', array('swfupload', 'swfobject'), '2201');
+	$scripts->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2201');
+	$scripts->add( 'swfupload-speed', '/wp-includes/js/swfupload/plugins/swfupload.speed.js', array('swfupload'), '2201');
+
+	if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) {
+		// queue all SWFUpload scripts that are used by default
+		$scripts->add( 'swfupload-all', false, array('swfupload', 'swfupload-swfobject', 'swfupload-queue'), '2201');
+	} else {
+		$scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201');
+	}
+
+	$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20100523');
+	$max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
+	if ( empty($max_upload_size) )
+		$max_upload_size = __('not configured');
+	// these error messages came from the sample swfupload js, they might need changing.
+	$scripts->localize( 'swfupload-handlers', 'swfuploadL10n', array(
+			'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
+			'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
+			'zero_byte_file' => __('This file is empty. Please try another.'),
+			'invalid_filetype' => __('This file type is not allowed. Please try another.'),
+			'default_error' => __('An error occurred in the upload. Please try again later.'),
+			'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
+			'upload_limit_exceeded' => __('You may only upload 1 file.'),
+			'http_error' => __('HTTP error.'),
+			'upload_failed' => __('Upload failed.'),
+			'io_error' => __('IO error.'),
+			'security_error' => __('Security error.'),
+			'file_cancelled' => __('File canceled.'),
+			'upload_stopped' => __('Upload stopped.'),
+			'dismiss' => __('Dismiss'),
+			'crunching' => __('Crunching&hellip;'),
+			'deleted' => __('moved to the trash.'),
+			'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error'),
+			'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};',
+	) );
+
+	$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102');
+
+	$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", false, '20110113');
+
+	$scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.1-20110113' );
+	$scripts->add_data( 'imgareaselect', 'group', 1 );
+
+	$scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), '20101027' );
+	$scripts->add_data( 'password-strength-meter', 'group', 1 );
+	$scripts->localize( 'password-strength-meter', 'pwsL10n', array(
+		'empty' => __('Strength indicator'),
+		'short' => __('Very weak'),
+		'bad' => __('Weak'),
+		/* translators: password strength */
+		'good' => _x('Medium', 'password strength'),
+		'strong' => __('Strong'),
+		'mismatch' => __('Mismatch'),
+		'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
+	) );
+
+	$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110113' );
+	$scripts->add_data( 'user-profile', 'group', 1 );
+
+	$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' );
+	$scripts->add_data( 'admin-bar', 'group', 1 );
+
+	$scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array('jquery'), '20110111' );
+	$scripts->localize( 'wplink', 'wpLinkL10n', array(
+		'update' => __('Update'),
+		'save' => __('Add Link'),
+		'noTitle' => __('(no title)'),
+		'noMatchesFound' => __('No matches found.'),
+		'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};',
+	) );
+
+	$scripts->add( 'wpdialogs-popup', "/wp-includes/js/tinymce/plugins/wpdialogs/js/popup$suffix.js", array( 'jquery-ui-dialog' ), '20101119' );
+
+	if ( is_admin() ) {
+		$scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );
+		$scripts->add_data( 'ajaxcat', 'group', 1 );
+		$scripts->localize( 'ajaxcat', 'catL10n', array(
+			'add' => esc_attr(__('Add')),
+			'how' => __('Separate multiple categories with commas.'),
+			'l10n_print_after' => 'try{convertEntities(catL10n);}catch(e){};'
+		) );
+
+		$scripts->add( 'admin-categories', "/wp-admin/js/categories$suffix.js", array('wp-lists'), '20091201' );
+		$scripts->add_data( 'admin-categories', 'group', 1 );
+
+		$scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), '20101216' );
+		$scripts->add_data( 'admin-tags', 'group', 1 );
+		$scripts->localize( 'admin-tags', 'tagsl10n', array(
+			'noPerm' => __('You do not have permission to do that.'),
+			'broken' => __('An unidentified error has occurred.'),
+			'l10n_print_after' => 'try{convertEntities(tagsl10n);}catch(e){};'
+		));
+
+		$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
+		$scripts->add_data( 'admin-custom-fields', 'group', 1 );
+
+		$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'jquery-query'), '20110122' );
+		$scripts->add_data( 'admin-comments', 'group', 1 );
+		$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
+			'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
+			'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last'])
+		) );
+
+		$scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), '20100403' );
+		$scripts->add_data( 'xfn', 'group', 1 );
+
+		$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
+		$scripts->add_data( 'postbox', 'group', 1 );
+
+		$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20110203' );
+		$scripts->add_data( 'post', 'group', 1 );
+		$scripts->localize( 'post', 'postL10n', array(
+			'tagsUsed' =>  __('Tags used on this post:'),
+			'add' => esc_attr(__('Add')),
+			'addTag' => esc_attr(__('Add new Tag')),
+			'separate' => __('Separate tags with commas'),
+			'ok' => __('OK'),
+			'cancel' => __('Cancel'),
+			'edit' => __('Edit'),
+			'publishOn' => __('Publish on:'),
+			'publishOnFuture' =>  __('Schedule for:'),
+			'publishOnPast' => __('Published on:'),
+			'showcomm' => __('Show more comments'),
+			'endcomm' => __('No more comments found.'),
+			'publish' => __('Publish'),
+			'schedule' => __('Schedule'),
+			'update' => __('Update'),
+			'savePending' => __('Save as Pending'),
+			'saveDraft' => __('Save Draft'),
+			'private' => __('Private'),
+			'public' => __('Public'),
+			'publicSticky' => __('Public, Sticky'),
+			'password' => __('Password Protected'),
+			'privatelyPublished' => __('Privately Published'),
+			'published' => __('Published'),
+			'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
+		) );
+
+		$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20090526' );
+		$scripts->add_data( 'link', 'group', 1 );
+
+		$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20091202' );
+		$scripts->add_data( 'comment', 'group', 1 );
+		$scripts->localize( 'comment', 'commentL10n', array(
+			'cancel' => __('Cancel'),
+			'edit' => __('Edit'),
+			'submittedOn' => __('Submitted on:'),
+			'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
+		) );
+
+		$scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090516' );
+
+		$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110113' );
+		$scripts->add_data( 'media-upload', 'group', 1 );
+
+		$scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20101007' );
+		$scripts->add_data( 'admin-widgets', 'group', 1 );
+
+		$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20090422' );
+		$scripts->add_data( 'word-count', 'group', 1 );
+		$scripts->localize( 'word-count', 'wordCountL10n', array(
+			'count' => __('Word count: %d'),
+			'l10n_print_after' => 'try{convertEntities(wordCountL10n);}catch(e){};'
+		));
+
+		$scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'thickbox' ), '20110118' );
+		$scripts->add_data( 'theme', 'group', 1 );
+
+		$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
+		$scripts->add_data( 'theme-preview', 'group', 1 );
+
+		$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20110113' );
+		$scripts->add_data( 'inline-edit-post', 'group', 1 );
+		$scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
+			'error' => __('Error while saving the changes.'),
+			'ntdeltitle' => __('Remove From Bulk Edit'),
+			'notitle' => __('(no title)'),
+			'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
+		) );
+
+		$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20100615' );
+		$scripts->add_data( 'inline-edit-tax', 'group', 1 );
+		$scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
+			'error' => __('Error while saving the changes.'),
+			'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
+		) );
+
+		$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20110113' );
+		$scripts->add_data( 'plugin-install', 'group', 1 );
+		$scripts->localize( 'plugin-install', 'plugininstallL10n', array(
+			'plugin_information' => __('Plugin Information:'),
+			'ays' => __('Are you sure you want to install this plugin?'),
+			'l10n_print_after' => 'try{convertEntities(plugininstallL10n);}catch(e){};'
+		) );
+
+		$scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
+
+		$scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), '20110113' );
+		$scripts->add_data( 'dashboard', 'group', 1 );
+
+		$scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), '20090102' );
+		$scripts->add_data( 'hoverIntent', 'group', 1 );
+
+		$scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js", null, '20091223' );
+
+		$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery-ui-draggable' ), '20101022' );
+		$scripts->add_data( 'media', 'group', 1 );
+
+		$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), '20091111' );
+		$scripts->add_data( 'image-edit', 'group', 1 );
+
+		$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), '20100518' );
+		$scripts->add_data( 'set-post-thumbnail', 'group', 1 );
+		$scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
+			'setThumbnail' => __( 'Use as featured image' ),
+			'saving' => __( 'Saving...' ),
+			'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ),
+			'done' => __( 'Done' ),
+			'l10n_print_after' => 'try{convertEntities(setPostThumbnailL10n);}catch(e){};'
+		) );
+
+		// Navigation Menus
+		$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array('jquery-ui-sortable'), '20100814' );
+		$scripts->localize( 'nav-menu', 'navMenuL10n', array(
+			'noResultsFound' => _x('No results found.', 'search results'),
+			'warnDeleteMenu' => __( "You are about to permanently delete this menu. \n 'Cancel' to stop, 'OK' to delete." ),
+			'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
+			'l10n_print_after' => 'try{convertEntities(navMenuL10n);}catch(e){};'
+		) );
+
+		$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array('farbtastic'), '20101025' );
+		$scripts->add_data( 'custom-background', 'group', 1 );
+	}
+}
+
+/**
+ * Assign default styles to $styles object.
+ *
+ * Nothing is returned, because the $styles parameter is passed by reference.
+ * Meaning that whatever object is passed will be updated without having to
+ * reassign the variable that was passed back to the same value. This saves
+ * memory.
+ *
+ * Adding default styles is not the only task, it also assigns the base_url
+ * property, the default version, and text direction for the object.
+ *
+ * @since 2.6.0
+ *
+ * @param object $styles
+ */
+function wp_default_styles( &$styles ) {
+	// This checks to see if site_url() returns something and if it does not
+	// then it assigns $guess_url to wp_guess_url(). Strange format, but it works.
+	if ( ! $guessurl = site_url() )
+		$guessurl = wp_guess_url();
+
+	$styles->base_url = $guessurl;
+	$styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
+	$styles->default_version = get_bloginfo( 'version' );
+	$styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
+	$styles->default_dirs = array('/wp-admin/');
+
+	$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
+
+	$rtl_styles = array( 'wp-admin', 'global', 'colors', 'colors-fresh', 'colors-classic', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'nav-menu', 'farbtastic', 'admin-bar', 'wplink', 'theme-install' );
+	// Any rtl stylesheets that don't have a .dev version for ltr
+	$no_suffix = array( 'farbtastic' );
+
+	$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110214' );
+
+	$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' );
+	$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
+
+	// all colors stylesheets need to have the same query strings (cache manifest compat)
+	$colors_version = '20110121';
+
+	// Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
+	$styles->add( 'colors', true, array(), $colors_version );
+
+	// do not refer to these directly, the right one is queued by the above "meta" colors handle
+	$styles->add( 'colors-fresh', "/wp-admin/css/colors-fresh$suffix.css", array(), $colors_version );
+	$styles->add( 'colors-classic', "/wp-admin/css/colors-classic$suffix.css", array(), $colors_version );
+
+	$styles->add( 'ms', "/wp-admin/css/ms$suffix.css", array(), '20101213' );
+	$styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20110121' );
+	$styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20110121' );
+	$styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20110104' );
+	$styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20110121' );
+	$styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20110121' ); // Readme as well
+	$styles->add( 'theme-editor', "/wp-admin/css/theme-editor$suffix.css", array(), '20101203' );
+	$styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array(), '20110121' );
+	$styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array(), '20090514' );
+	$styles->add( 'login', "/wp-admin/css/login$suffix.css", array(), '20110121' );
+	$styles->add( 'plugin-install', "/wp-admin/css/plugin-install$suffix.css", array(), '20101230' );
+	$styles->add( 'theme-install', "/wp-admin/css/theme-install$suffix.css", array(), '20101226' );
+	$styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u' );
+	$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
+	$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
+	$styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100907' );
+	$styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20110122' );
+	$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101224' );
+	$styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101224' );
+
+	foreach ( $rtl_styles as $rtl_style ) {
+		$styles->add_data( $rtl_style, 'rtl', true );
+		if ( $suffix && ! in_array( $rtl_style, $no_suffix ) )
+			$styles->add_data( $rtl_style, 'suffix', $suffix );
+	}
+}
+
+/**
+ * Reorder JavaScript scripts array to place prototype before jQuery.
+ *
+ * @since 2.3.1
+ *
+ * @param array $js_array JavaScript scripst array
+ * @return array Reordered array, if needed.
+ */
+function wp_prototype_before_jquery( $js_array ) {
+	if ( false === $jquery = array_search( 'jquery', $js_array, true ) )
+		return $js_array;
+
+	if ( false === $prototype = array_search( 'prototype', $js_array, true ) )
+		return $js_array;
+
+	if ( $prototype < $jquery )
+		return $js_array;
+
+	unset($js_array[$prototype]);
+
+	array_splice( $js_array, $jquery, 0, 'prototype' );
+
+	return $js_array;
+}
+
+/**
+ * Load localized data on print rather than initialization.
+ *
+ * These localizations require information that may not be loaded even by init.
+ *
+ * @since 2.5.0
+ */
+function wp_just_in_time_script_localization() {
+
+	wp_localize_script( 'autosave', 'autosaveL10n', array(
+		'autosaveInterval' => AUTOSAVE_INTERVAL,
+		'previewPageText' => __('Preview this Page'),
+		'previewPostText' => __('Preview this Post'),
+		'requestFile' => admin_url('admin-ajax.php'),
+		'savingText' => __('Saving Draft&#8230;'),
+		'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
+		'l10n_print_after' => 'try{convertEntities(autosaveL10n);}catch(e){};'
+	) );
+
+}
+
+/**
+ * Administration Panel CSS for changing the styles.
+ *
+ * If installing the 'wp-admin/' directory will be replaced with './'.
+ *
+ * The $_wp_admin_css_colors global manages the Administration Panels CSS
+ * stylesheet that is loaded. The option that is set is 'admin_color' and is the
+ * color and key for the array. The value for the color key is an object with
+ * a 'url' parameter that has the URL path to the CSS file.
+ *
+ * The query from $src parameter will be appended to the URL that is given from
+ * the $_wp_admin_css_colors array value URL.
+ *
+ * @since 2.6.0
+ * @uses $_wp_admin_css_colors
+ *
+ * @param string $src Source URL.
+ * @param string $handle Either 'colors' or 'colors-rtl'.
+ * @return string URL path to CSS stylesheet for Administration Panels.
+ */
+function wp_style_loader_src( $src, $handle ) {
+	if ( defined('WP_INSTALLING') )
+		return preg_replace( '#^wp-admin/#', './', $src );
+
+	if ( 'colors' == $handle || 'colors-rtl' == $handle ) {
+		global $_wp_admin_css_colors;
+		$color = get_user_option('admin_color');
+
+		if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
+			$color = 'fresh';
+
+		$color = $_wp_admin_css_colors[$color];
+		$parsed = parse_url( $src );
+		$url = $color->url;
+
+		if ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG )
+			$url = preg_replace('/.css$|.css(?=\?)/', '.dev.css', $url);
+
+		if ( isset($parsed['query']) && $parsed['query'] ) {
+			wp_parse_str( $parsed['query'], $qv );
+			$url = add_query_arg( $qv, $url );
+		}
+
+		return $url;
+	}
+
+	return $src;
+}
+
+/**
+ * Prints the script queue in the HTML head on admin pages.
+ *
+ * Postpones the scripts that were queued for the footer.
+ * print_footer_scripts() is called in the footer to print these scripts.
+ *
+ * @since 2.8
+ * @see wp_print_scripts()
+ */
+function print_head_scripts() {
+	global $wp_scripts, $concatenate_scripts;
+
+	if ( ! did_action('wp_print_scripts') )
+		do_action('wp_print_scripts');
+
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		$wp_scripts = new WP_Scripts();
+
+	script_concat_settings();
+	$wp_scripts->do_items( 'l10n' );
+	$wp_scripts->do_concat = $concatenate_scripts;
+	$wp_scripts->do_head_items();
+
+	if ( apply_filters('print_head_scripts', true) )
+		_print_scripts();
+
+	$wp_scripts->reset();
+	return $wp_scripts->done;
+}
+
+/**
+ * Prints the scripts that were queued for the footer on admin pages.
+ *
+ * @since 2.8
+ */
+function print_footer_scripts() {
+	global $wp_scripts, $concatenate_scripts;
+
+	if ( ! did_action('wp_print_footer_scripts') )
+		do_action('wp_print_footer_scripts');
+
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		return array(); // No need to run if not instantiated.
+
+	script_concat_settings();
+	$wp_scripts->do_concat = $concatenate_scripts;
+	$wp_scripts->do_footer_items();
+
+	if ( apply_filters('print_footer_scripts', true) )
+		_print_scripts();
+
+	$wp_scripts->reset();
+	return $wp_scripts->done;
+}
+
+function _print_scripts() {
+	global $wp_scripts, $compress_scripts;
+
+	$zip = $compress_scripts ? 1 : 0;
+	if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
+		$zip = 'gzip';
+
+	if ( !empty($wp_scripts->concat) ) {
+
+		if ( !empty($wp_scripts->print_code) ) {
+			echo "<script type='text/javascript'>\n";
+			echo "/* <![CDATA[ */\n";
+			echo $wp_scripts->print_code;
+			echo "/* ]]> */\n";
+			echo "</script>\n";
+		}
+
+		$ver = md5("$wp_scripts->concat_version");
+		$src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}&load=" . trim($wp_scripts->concat, ', ') . "&ver=$ver";
+		echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
+	}
+
+	if ( !empty($wp_scripts->print_html) )
+		echo $wp_scripts->print_html;
+}
+
+/**
+ * Prints the script queue in the HTML head on the front end.
+ *
+ * Postpones the scripts that were queued for the footer.
+ * wp_print_footer_scripts() is called in the footer to print these scripts.
+ *
+ * @since 2.8
+ */
+function wp_print_head_scripts() {
+	if ( ! did_action('wp_print_scripts') )
+		do_action('wp_print_scripts');
+
+	global $wp_scripts;
+
+	if ( !is_a($wp_scripts, 'WP_Scripts') )
+		return array(); // no need to run if nothing is queued
+
+	return print_head_scripts();
+}
+
+/**
+ * Prints the scripts that were queued for the footer on the front end.
+ *
+ * @since 2.8
+ */
+function wp_print_footer_scripts() {
+	return print_footer_scripts();
+}
+
+/**
+ * Wrapper for do_action('wp_enqueue_scripts')
+ *
+ * Allows plugins to queue scripts for the front end using wp_enqueue_script().
+ * Runs first in wp_head() where all is_home(), is_page(), etc. functions are available.
+ *
+ * @since 2.8
+ */
+function wp_enqueue_scripts() {
+	do_action('wp_enqueue_scripts');
+}
+
+function print_admin_styles() {
+	global $wp_styles, $concatenate_scripts, $compress_css;
+
+	if ( !is_a($wp_styles, 'WP_Styles') )
+		$wp_styles = new WP_Styles();
+
+	script_concat_settings();
+	$wp_styles->do_concat = $concatenate_scripts;
+	$zip = $compress_css ? 1 : 0;
+	if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP )
+		$zip = 'gzip';
+
+	$wp_styles->do_items(false);
+
+	if ( apply_filters('print_admin_styles', true) ) {
+		if ( !empty($wp_styles->concat) ) {
+			$dir = $wp_styles->text_direction;
+			$ver = md5("$wp_styles->concat_version{$dir}");
+			$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver=$ver";
+			echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
+		}
+
+		if ( !empty($wp_styles->print_html) )
+			echo $wp_styles->print_html;
+	}
+
+	$wp_styles->do_concat = false;
+	$wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = '';
+	return $wp_styles->done;
+}
+
+function script_concat_settings() {
+	global $concatenate_scripts, $compress_scripts, $compress_css;
+
+	$compressed_output = ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') );
+
+	if ( ! isset($concatenate_scripts) ) {
+		$concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
+		if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) )
+			$concatenate_scripts = false;
+	}
+
+	if ( ! isset($compress_scripts) ) {
+		$compress_scripts = defined('COMPRESS_SCRIPTS') ? COMPRESS_SCRIPTS : true;
+		if ( $compress_scripts && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
+			$compress_scripts = false;
+	}
+
+	if ( ! isset($compress_css) ) {
+		$compress_css = defined('COMPRESS_CSS') ? COMPRESS_CSS : true;
+		if ( $compress_css && ( ! get_site_option('can_compress_scripts') || $compressed_output ) )
+			$compress_css = false;
+	}
+}
+
+add_action( 'wp_default_scripts', 'wp_default_scripts' );
+add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
+add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
+
+add_action( 'wp_default_styles', 'wp_default_styles' );
+add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
Index: /tags/3.1/wp-includes/shortcodes.php
===================================================================
--- /tags/3.1/wp-includes/shortcodes.php	(revision 17487)
+++ /tags/3.1/wp-includes/shortcodes.php	(revision 17487)
@@ -0,0 +1,298 @@
+<?php
+/**
+ * WordPress API for creating bbcode like tags or what WordPress calls
+ * "shortcodes." The tag and attribute parsing or regular expression code is
+ * based on the Textpattern tag parser.
+ *
+ * A few examples are below:
+ *
+ * [shortcode /]
+ * [shortcode foo="bar" baz="bing" /]
+ * [shortcode foo="bar"]content[/shortcode]
+ *
+ * Shortcode tags support attributes and enclosed content, but does not entirely
+ * support inline shortcodes in other shortcodes. You will have to call the
+ * shortcode parser in your function to account for that.
+ *
+ * {@internal
+ * Please be aware that the above note was made during the beta of WordPress 2.6
+ * and in the future may not be accurate. Please update the note when it is no
+ * longer the case.}}
+ *
+ * To apply shortcode tags to content:
+ *
+ * <code>
+ * $out = do_shortcode($content);
+ * </code>
+ *
+ * @link http://codex.wordpress.org/Shortcode_API
+ *
+ * @package WordPress
+ * @subpackage Shortcodes
+ * @since 2.5
+ */
+
+/**
+ * Container for storing shortcode tags and their hook to call for the shortcode
+ *
+ * @since 2.5
+ * @name $shortcode_tags
+ * @var array
+ * @global array $shortcode_tags
+ */
+$shortcode_tags = array();
+
+/**
+ * Add hook for shortcode tag.
+ *
+ * There can only be one hook for each shortcode. Which means that if another
+ * plugin has a similar shortcode, it will override yours or yours will override
+ * theirs depending on which order the plugins are included and/or ran.
+ *
+ * Simplest example of a shortcode tag using the API:
+ *
+ * <code>
+ * // [footag foo="bar"]
+ * function footag_func($atts) {
+ * 	return "foo = {$atts[foo]}";
+ * }
+ * add_shortcode('footag', 'footag_func');
+ * </code>
+ *
+ * Example with nice attribute defaults:
+ *
+ * <code>
+ * // [bartag foo="bar"]
+ * function bartag_func($atts) {
+ * 	extract(shortcode_atts(array(
+ * 		'foo' => 'no foo',
+ * 		'baz' => 'default baz',
+ * 	), $atts));
+ *
+ * 	return "foo = {$foo}";
+ * }
+ * add_shortcode('bartag', 'bartag_func');
+ * </code>
+ *
+ * Example with enclosed content:
+ *
+ * <code>
+ * // [baztag]content[/baztag]
+ * function baztag_func($atts, $content='') {
+ * 	return "content = $content";
+ * }
+ * add_shortcode('baztag', 'baztag_func');
+ * </code>
+ *
+ * @since 2.5
+ * @uses $shortcode_tags
+ *
+ * @param string $tag Shortcode tag to be searched in post content.
+ * @param callable $func Hook to run when shortcode is found.
+ */
+function add_shortcode($tag, $func) {
+	global $shortcode_tags;
+
+	if ( is_callable($func) )
+		$shortcode_tags[$tag] = $func;
+}
+
+/**
+ * Removes hook for shortcode.
+ *
+ * @since 2.5
+ * @uses $shortcode_tags
+ *
+ * @param string $tag shortcode tag to remove hook for.
+ */
+function remove_shortcode($tag) {
+	global $shortcode_tags;
+
+	unset($shortcode_tags[$tag]);
+}
+
+/**
+ * Clear all shortcodes.
+ *
+ * This function is simple, it clears all of the shortcode tags by replacing the
+ * shortcodes global by a empty array. This is actually a very efficient method
+ * for removing all shortcodes.
+ *
+ * @since 2.5
+ * @uses $shortcode_tags
+ */
+function remove_all_shortcodes() {
+	global $shortcode_tags;
+
+	$shortcode_tags = array();
+}
+
+/**
+ * Search content for shortcodes and filter shortcodes through their hooks.
+ *
+ * If there are no shortcode tags defined, then the content will be returned
+ * without any filtering. This might cause issues when plugins are disabled but
+ * the shortcode will still show up in the post or content.
+ *
+ * @since 2.5
+ * @uses $shortcode_tags
+ * @uses get_shortcode_regex() Gets the search pattern for searching shortcodes.
+ *
+ * @param string $content Content to search for shortcodes
+ * @return string Content with shortcodes filtered out.
+ */
+function do_shortcode($content) {
+	global $shortcode_tags;
+
+	if (empty($shortcode_tags) || !is_array($shortcode_tags))
+		return $content;
+
+	$pattern = get_shortcode_regex();
+	return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content);
+}
+
+/**
+ * Retrieve the shortcode regular expression for searching.
+ *
+ * The regular expression combines the shortcode tags in the regular expression
+ * in a regex class.
+ *
+ * The regular expresion contains 6 different sub matches to help with parsing.
+ *
+ * 1/6 - An extra [ or ] to allow for escaping shortcodes with double [[]]
+ * 2 - The shortcode name
+ * 3 - The shortcode argument list
+ * 4 - The self closing /
+ * 5 - The content of a shortcode when it wraps some content.
+ *
+ * @since 2.5
+ * @uses $shortcode_tags
+ *
+ * @return string The shortcode search regular expression
+ */
+function get_shortcode_regex() {
+	global $shortcode_tags;
+	$tagnames = array_keys($shortcode_tags);
+	$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
+
+	// WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcodes()
+	return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';
+}
+
+/**
+ * Regular Expression callable for do_shortcode() for calling shortcode hook.
+ * @see get_shortcode_regex for details of the match array contents.
+ *
+ * @since 2.5
+ * @access private
+ * @uses $shortcode_tags
+ *
+ * @param array $m Regular expression match array
+ * @return mixed False on failure.
+ */
+function do_shortcode_tag( $m ) {
+	global $shortcode_tags;
+
+	// allow [[foo]] syntax for escaping a tag
+	if ( $m[1] == '[' && $m[6] == ']' ) {
+		return substr($m[0], 1, -1);
+	}
+
+	$tag = $m[2];
+	$attr = shortcode_parse_atts( $m[3] );
+
+	if ( isset( $m[5] ) ) {
+		// enclosing tag - extra parameter
+		return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, $m[5], $tag ) . $m[6];
+	} else {
+		// self-closing tag
+		return $m[1] . call_user_func( $shortcode_tags[$tag], $attr, NULL,  $tag ) . $m[6];
+	}
+}
+
+/**
+ * Retrieve all attributes from the shortcodes tag.
+ *
+ * The attributes list has the attribute name as the key and the value of the
+ * attribute as the value in the key/value pair. This allows for easier
+ * retrieval of the attributes, since all attributes have to be known.
+ *
+ * @since 2.5
+ *
+ * @param string $text
+ * @return array List of attributes and their value.
+ */
+function shortcode_parse_atts($text) {
+	$atts = array();
+	$pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
+	$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text);
+	if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) {
+		foreach ($match as $m) {
+			if (!empty($m[1]))
+				$atts[strtolower($m[1])] = stripcslashes($m[2]);
+			elseif (!empty($m[3]))
+				$atts[strtolower($m[3])] = stripcslashes($m[4]);
+			elseif (!empty($m[5]))
+				$atts[strtolower($m[5])] = stripcslashes($m[6]);
+			elseif (isset($m[7]) and strlen($m[7]))
+				$atts[] = stripcslashes($m[7]);
+			elseif (isset($m[8]))
+				$atts[] = stripcslashes($m[8]);
+		}
+	} else {
+		$atts = ltrim($text);
+	}
+	return $atts;
+}
+
+/**
+ * Combine user attributes with known attributes and fill in defaults when needed.
+ *
+ * The pairs should be considered to be all of the attributes which are
+ * supported by the caller and given as a list. The returned attributes will
+ * only contain the attributes in the $pairs list.
+ *
+ * If the $atts list has unsupported attributes, then they will be ignored and
+ * removed from the final returned list.
+ *
+ * @since 2.5
+ *
+ * @param array $pairs Entire list of supported attributes and their defaults.
+ * @param array $atts User defined attributes in shortcode tag.
+ * @return array Combined and filtered attribute list.
+ */
+function shortcode_atts($pairs, $atts) {
+	$atts = (array)$atts;
+	$out = array();
+	foreach($pairs as $name => $default) {
+		if ( array_key_exists($name, $atts) )
+			$out[$name] = $atts[$name];
+		else
+			$out[$name] = $default;
+	}
+	return $out;
+}
+
+/**
+ * Remove all shortcode tags from the given content.
+ *
+ * @since 2.5
+ * @uses $shortcode_tags
+ *
+ * @param string $content Content to remove shortcode tags.
+ * @return string Content without shortcode tags.
+ */
+function strip_shortcodes( $content ) {
+	global $shortcode_tags;
+
+	if (empty($shortcode_tags) || !is_array($shortcode_tags))
+		return $content;
+
+	$pattern = get_shortcode_regex();
+
+	return preg_replace('/'.$pattern.'/s', '$1$6', $content);
+}
+
+add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
+
+?>
Index: /tags/3.1/wp-includes/taxonomy.php
===================================================================
--- /tags/3.1/wp-includes/taxonomy.php	(revision 17487)
+++ /tags/3.1/wp-includes/taxonomy.php	(revision 17487)
@@ -0,0 +1,3140 @@
+<?php
+/**
+ * Taxonomy API
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ */
+
+//
+// Taxonomy Registration
+//
+
+/**
+ * Creates the initial taxonomies when 'init' action is fired.
+ */
+function create_initial_taxonomies() {
+	register_taxonomy( 'category', 'post', array(
+		'hierarchical' => true,
+	 	'update_count_callback' => '_update_post_term_count',
+		'query_var' => 'category_name',
+		'rewrite' => did_action( 'init' ) ? array(
+					'hierarchical' => true,
+					'slug' => get_option('category_base') ? get_option('category_base') : 'category',
+					'with_front' => false) : false,
+		'public' => true,
+		'show_ui' => true,
+		'_builtin' => true,
+	) );
+
+	register_taxonomy( 'post_tag', 'post', array(
+	 	'hierarchical' => false,
+		'update_count_callback' => '_update_post_term_count',
+		'query_var' => 'tag',
+		'rewrite' => did_action( 'init' ) ? array(
+					'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag',
+					'with_front' => false) : false,
+		'public' => true,
+		'show_ui' => true,
+		'_builtin' => true,
+	) );
+
+	register_taxonomy( 'nav_menu', 'nav_menu_item', array(
+		'public' => false,
+		'hierarchical' => false,
+		'labels' => array(
+			'name' => __( 'Navigation Menus' ),
+			'singular_name' => __( 'Navigation Menu' ),
+		),
+		'query_var' => false,
+		'rewrite' => false,
+		'show_ui' => false,
+		'_builtin' => true,
+		'show_in_nav_menus' => false,
+	) );
+
+	register_taxonomy( 'link_category', 'link', array(
+		'hierarchical' => false,
+		'labels' => array(
+			'name' => __( 'Link Categories' ),
+			'singular_name' => __( 'Link Category' ),
+			'search_items' => __( 'Search Link Categories' ),
+			'popular_items' => null,
+			'all_items' => __( 'All Link Categories' ),
+			'edit_item' => __( 'Edit Link Category' ),
+			'update_item' => __( 'Update Link Category' ),
+			'add_new_item' => __( 'Add New Link Category' ),
+			'new_item_name' => __( 'New Link Category Name' ),
+			'separate_items_with_commas' => null,
+			'add_or_remove_items' => null,
+			'choose_from_most_used' => null,
+		),
+		'query_var' => false,
+		'rewrite' => false,
+		'public' => false,
+		'show_ui' => false,
+		'_builtin' => true,
+	) );
+
+	$rewrite = false;
+	if ( did_action( 'init' ) ) {
+		$rewrite = apply_filters( 'post_format_rewrite_base', 'type' );
+		$rewrite = $rewrite ? array( 'slug' => $rewrite ) : false;
+	}
+
+	register_taxonomy( 'post_format', 'post', array(
+		'public' => true,
+		'hierarchical' => false,
+		'labels' => array(
+			'name' => _x( 'Format', 'post format' ),
+			'singular_name' => _x( 'Format', 'post format' ),
+		),
+		'query_var' => true,
+		'rewrite' => $rewrite,
+		'show_ui' => false,
+		'_builtin' => true,
+		'show_in_nav_menus' => false,
+	) );
+}
+add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
+
+/**
+ * Get a list of registered taxonomy objects.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 3.0.0
+ * @uses $wp_taxonomies
+ * @see register_taxonomy
+ *
+ * @param array $args An array of key => value arguments to match against the taxonomy objects.
+ * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
+ * @param string $operator The logical operation to perform. 'or' means only one element
+ *  from the array needs to match; 'and' means all elements must match. The default is 'and'.
+ * @return array A list of taxonomy names or objects
+ */
+function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) {
+	global $wp_taxonomies;
+
+	$field = ('names' == $output) ? 'name' : false;
+
+	return wp_filter_object_list($wp_taxonomies, $args, $operator, $field);
+}
+
+
+/**
+ * Return all of the taxonomy names that are of $object_type.
+ *
+ * It appears that this function can be used to find all of the names inside of
+ * $wp_taxonomies global variable.
+ *
+ * <code><?php $taxonomies = get_object_taxonomies('post'); ?></code> Should
+ * result in <code>Array('category', 'post_tag')</code>
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wp_taxonomies
+ *
+ * @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts)
+ * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
+ * @return array The names of all taxonomy of $object_type.
+ */
+function get_object_taxonomies($object, $output = 'names') {
+	global $wp_taxonomies;
+
+	if ( is_object($object) ) {
+		if ( $object->post_type == 'attachment' )
+			return get_attachment_taxonomies($object);
+		$object = $object->post_type;
+	}
+
+	$object = (array) $object;
+
+	$taxonomies = array();
+	foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
+		if ( array_intersect($object, (array) $tax_obj->object_type) ) {
+			if ( 'names' == $output )
+				$taxonomies[] = $tax_name;
+			else
+				$taxonomies[ $tax_name ] = $tax_obj;
+		}
+	}
+
+	return $taxonomies;
+}
+
+/**
+ * Retrieves the taxonomy object of $taxonomy.
+ *
+ * The get_taxonomy function will first check that the parameter string given
+ * is a taxonomy object and if it is, it will return it.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wp_taxonomies
+ * @uses taxonomy_exists() Checks whether taxonomy exists
+ *
+ * @param string $taxonomy Name of taxonomy object to return
+ * @return object|bool The Taxonomy Object or false if $taxonomy doesn't exist
+ */
+function get_taxonomy( $taxonomy ) {
+	global $wp_taxonomies;
+
+	if ( ! taxonomy_exists( $taxonomy ) )
+		return false;
+
+	return $wp_taxonomies[$taxonomy];
+}
+
+/**
+ * Checks that the taxonomy name exists.
+ *
+ * Formerly is_taxonomy(), introduced in 2.3.0.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 3.0.0
+ *
+ * @uses $wp_taxonomies
+ *
+ * @param string $taxonomy Name of taxonomy object
+ * @return bool Whether the taxonomy exists.
+ */
+function taxonomy_exists( $taxonomy ) {
+	global $wp_taxonomies;
+
+	return isset( $wp_taxonomies[$taxonomy] );
+}
+
+/**
+ * Whether the taxonomy object is hierarchical.
+ *
+ * Checks to make sure that the taxonomy is an object first. Then Gets the
+ * object, and finally returns the hierarchical value in the object.
+ *
+ * A false return value might also mean that the taxonomy does not exist.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses taxonomy_exists() Checks whether taxonomy exists
+ * @uses get_taxonomy() Used to get the taxonomy object
+ *
+ * @param string $taxonomy Name of taxonomy object
+ * @return bool Whether the taxonomy is hierarchical
+ */
+function is_taxonomy_hierarchical($taxonomy) {
+	if ( ! taxonomy_exists($taxonomy) )
+		return false;
+
+	$taxonomy = get_taxonomy($taxonomy);
+	return $taxonomy->hierarchical;
+}
+
+/**
+ * Create or modify a taxonomy object. Do not use before init.
+ *
+ * A simple function for creating or modifying a taxonomy object based on the
+ * parameters given. The function will accept an array (third optional
+ * parameter), along with strings for the taxonomy name and another string for
+ * the object type.
+ *
+ * Nothing is returned, so expect error maybe or use taxonomy_exists() to check
+ * whether taxonomy exists.
+ *
+ * Optional $args contents:
+ *
+ * label - Name of the taxonomy shown in the menu. Usually plural. If not set, labels['name'] will be used.
+ *
+ * hierarchical - has some defined purpose at other parts of the API and is a
+ * boolean value.
+ *
+ * update_count_callback - works much like a hook, in that it will be called
+ * when the count is updated.
+ *
+ * rewrite - false to prevent rewrite, or array('slug'=>$slug) to customize
+ * permastruct; default will use $taxonomy as slug.
+ *
+ * query_var - false to prevent queries, or string to customize query var
+ * (?$query_var=$term); default will use $taxonomy as query var.
+ *
+ * public - If the taxonomy should be publically queryable; //@TODO not implemented.
+ * defaults to true.
+ *
+ * show_ui - If the WordPress UI admin tags UI should apply to this taxonomy;
+ * defaults to public.
+ *
+ * show_in_nav_menus - true makes this taxonomy available for selection in navigation menus.
+ * Defaults to public.
+ *
+ * show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget;
+ * defaults to show_ui which defalts to public.
+ *
+ * labels - An array of labels for this taxonomy. You can see accepted values in {@link get_taxonomy_labels()}. By default tag labels are used for non-hierarchical types and category labels for hierarchical ones.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wp_taxonomies Inserts new taxonomy object into the list
+ * @uses $wp_rewrite Adds rewrite tags and permastructs
+ * @uses $wp Adds query vars
+ *
+ * @param string $taxonomy Name of taxonomy object
+ * @param array|string $object_type Name of the object type for the taxonomy object.
+ * @param array|string $args See above description for the two keys values.
+ */
+function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
+	global $wp_taxonomies, $wp_rewrite, $wp;
+
+	if ( ! is_array($wp_taxonomies) )
+		$wp_taxonomies = array();
+
+	$defaults = array(	'hierarchical' => false,
+						'update_count_callback' => '',
+						'rewrite' => true,
+						'query_var' => $taxonomy,
+						'public' => true,
+						'show_ui' => null,
+						'show_tagcloud' => null,
+						'_builtin' => false,
+						'labels' => array(),
+						'capabilities' => array(),
+						'show_in_nav_menus' => null,
+					);
+	$args = wp_parse_args($args, $defaults);
+
+	if ( false !== $args['query_var'] && !empty($wp) ) {
+		if ( true === $args['query_var'] )
+			$args['query_var'] = $taxonomy;
+		$args['query_var'] = sanitize_title_with_dashes($args['query_var']);
+		$wp->add_query_var($args['query_var']);
+	}
+
+	if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) {
+		$args['rewrite'] = wp_parse_args($args['rewrite'], array(
+			'slug' => sanitize_title_with_dashes($taxonomy),
+			'with_front' => true,
+			'hierarchical' => false
+		));
+
+		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )
+			$tag = '(.+?)';
+		else
+			$tag = '([^/]+)';
+
+		$wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");
+		$wp_rewrite->add_permastruct($taxonomy, "{$wp_rewrite->root}{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
+	}
+
+	if ( is_null($args['show_ui']) )
+		$args['show_ui'] = $args['public'];
+
+	// Whether to show this type in nav-menus.php. Defaults to the setting for public.
+	if ( null === $args['show_in_nav_menus'] )
+		$args['show_in_nav_menus'] = $args['public'];
+
+	if ( is_null($args['show_tagcloud']) )
+		$args['show_tagcloud'] = $args['show_ui'];
+
+	$default_caps = array(
+		'manage_terms' => 'manage_categories',
+		'edit_terms'   => 'manage_categories',
+		'delete_terms' => 'manage_categories',
+		'assign_terms' => 'edit_posts',
+	);
+	$args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
+	unset( $args['capabilities'] );
+
+	$args['name'] = $taxonomy;
+	$args['object_type'] = (array) $object_type;
+
+	$args['labels'] = get_taxonomy_labels( (object) $args );
+	$args['label'] = $args['labels']->name;
+
+	$wp_taxonomies[$taxonomy] = (object) $args;
+
+	// register callback handling for metabox
+ 	add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');
+}
+
+/**
+ * Builds an object with all taxonomy labels out of a taxonomy object
+ *
+ * Accepted keys of the label array in the taxonomy object:
+ * - name - general name for the taxonomy, usually plural. The same as and overriden by $tax->label. Default is Post Tags/Categories
+ * - singular_name - name for one object of this taxonomy. Default is Post Tag/Category
+ * - search_items - Default is Search Tags/Search Categories
+ * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags
+ * - all_items - Default is All Tags/All Categories
+ * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category
+ * - parent_item_colon - The same as <code>parent_item</code>, but with colon <code>:</code> in the end
+ * - edit_item - Default is Edit Tag/Edit Category
+ * - update_item - Default is Update Tag/Update Category
+ * - add_new_item - Default is Add New Tag/Add New Category
+ * - new_item_name - Default is New Tag Name/New Category Name
+ * - separate_items_with_commas - This string isn't used on hierarchical taxonomies. Default is "Separate tags with commas," used in the meta box.
+ * - add_or_remove_items - This string isn't used on hierarchical taxonomies. Default is "Add or remove tags," used in the meta box when JavaScript is disabled.
+ * - choose_from_most_used - This string isn't used on hierarchical taxonomies. Default is "Choose from the most used tags," used in the meta box.
+ *
+ * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories.)
+ *
+ * @since 3.0.0
+ * @param object $tax Taxonomy object
+ * @return object object with all the labels as member variables
+ */
+
+function get_taxonomy_labels( $tax ) {
+	if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) )
+		$tax->labels['separate_items_with_commas'] = $tax->helps;
+
+	$nohier_vs_hier_defaults = array(
+		'name' => array( _x( 'Post Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
+		'singular_name' => array( _x( 'Post Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
+		'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
+		'popular_items' => array( __( 'Popular Tags' ), null ),
+		'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
+		'parent_item' => array( null, __( 'Parent Category' ) ),
+		'parent_item_colon' => array( null, __( 'Parent Category:' ) ),
+		'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
+		'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ),
+		'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
+		'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
+		'separate_items_with_commas' => array( __( 'Separate tags with commas' ), null ),
+		'add_or_remove_items' => array( __( 'Add or remove tags' ), null ),
+		'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ),
+	);
+	$nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name'];
+
+	return _get_custom_object_labels( $tax, $nohier_vs_hier_defaults );
+}
+
+/**
+ * Add an already registered taxonomy to an object type.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 3.0.0
+ * @uses $wp_taxonomies Modifies taxonomy object
+ *
+ * @param string $taxonomy Name of taxonomy object
+ * @param array|string $object_type Name of the object type
+ * @return bool True if successful, false if not
+ */
+function register_taxonomy_for_object_type( $taxonomy, $object_type) {
+	global $wp_taxonomies;
+
+	if ( !isset($wp_taxonomies[$taxonomy]) )
+		return false;
+
+	if ( ! get_post_type_object($object_type) )
+		return false;
+
+	$wp_taxonomies[$taxonomy]->object_type[] = $object_type;
+
+	return true;
+}
+
+//
+// Term API
+//
+
+/**
+ * Retrieve object_ids of valid taxonomy and term.
+ *
+ * The strings of $taxonomies must exist before this function will continue. On
+ * failure of finding a valid taxonomy, it will return an WP_Error class, kind
+ * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
+ * still test for the WP_Error class and get the error message.
+ *
+ * The $terms aren't checked the same as $taxonomies, but still need to exist
+ * for $object_ids to be returned.
+ *
+ * It is possible to change the order that object_ids is returned by either
+ * using PHP sort family functions or using the database by using $args with
+ * either ASC or DESC array. The value should be in the key named 'order'.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ * @uses wp_parse_args() Creates an array from string $args.
+ *
+ * @param int|array $term_ids Term id or array of term ids of terms that will be used
+ * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
+ * @param array|string $args Change the order of the object_ids, either ASC or DESC
+ * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
+ *	the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
+ */
+function get_objects_in_term( $term_ids, $taxonomies, $args = array() ) {
+	global $wpdb;
+
+	if ( ! is_array( $term_ids ) )
+		$term_ids = array( $term_ids );
+
+	if ( ! is_array( $taxonomies ) )
+		$taxonomies = array( $taxonomies );
+
+	foreach ( (array) $taxonomies as $taxonomy ) {
+		if ( ! taxonomy_exists( $taxonomy ) )
+			return new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) );
+	}
+
+	$defaults = array( 'order' => 'ASC' );
+	$args = wp_parse_args( $args, $defaults );
+	extract( $args, EXTR_SKIP );
+
+	$order = ( 'desc' == strtolower( $order ) ) ? 'DESC' : 'ASC';
+
+	$term_ids = array_map('intval', $term_ids );
+
+	$taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
+	$term_ids = "'" . implode( "', '", $term_ids ) . "'";
+
+	$object_ids = $wpdb->get_col("SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order");
+
+	if ( ! $object_ids )
+		return array();
+
+	return $object_ids;
+}
+
+/**
+ * Given a taxonomy query, generates SQL to be appended to a main query.
+ *
+ * @since 3.1.0
+ *
+ * @see WP_Tax_Query
+ *
+ * @param array $tax_query A compact tax query
+ * @param string $primary_table
+ * @param string $primary_id_column
+ * @return array
+ */
+function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) {
+	$tax_query_obj = new WP_Tax_Query( $tax_query );
+	return $tax_query_obj->get_sql( $primary_table, $primary_id_column );
+}
+
+/**
+ * Container class for a multiple taxonomy query.
+ *
+ * @since 3.1.0
+ */
+class WP_Tax_Query {
+
+	/**
+	 * List of taxonomy queries. A single taxonomy query is an associative array:
+	 * - 'taxonomy' string The taxonomy being queried
+	 * - 'terms' string|array The list of terms
+	 * - 'field' string (optional) Which term field is being used.
+	 *		Possible values: 'term_id', 'slug' or 'name'
+	 *		Default: 'term_id'
+	 * - 'operator' string (optional)
+	 *		Possible values: 'IN' and 'NOT IN'.
+	 *		Default: 'IN'
+	 * - 'include_children' bool (optional) Whether to include child terms.
+	 *		Default: true
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 * @var array
+	 */
+	var $queries = array();
+
+	/**
+	 * The relation between the queries. Can be one of 'AND' or 'OR'.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 * @var string
+	 */
+	var $relation;
+
+	/**
+	 * PHP4 type constructor.
+	 *
+	 * Parses a compact tax query and sets defaults.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @param array $tax_query A compact tax query:
+	 *  array(
+	 *    'relation' => 'OR',
+	 *    array(
+	 *      'taxonomy' => 'tax1',
+	 *      'terms' => array( 'term1', 'term2' ),
+	 *      'field' => 'slug',
+	 *    ),
+	 *    array(
+	 *      'taxonomy' => 'tax2',
+	 *      'terms' => array( 'term-a', 'term-b' ),
+	 *      'field' => 'slug',
+	 *    ),
+	 *  )
+	 *
+	 * @return WP_Tax_Query
+	 */
+	function WP_Tax_Query( $tax_query ) {
+		if ( isset( $tax_query['relation'] ) && strtoupper( $tax_query['relation'] ) == 'OR' ) {
+			$this->relation = 'OR';
+		} else {
+			$this->relation = 'AND';
+		}
+
+		$defaults = array(
+			'taxonomy' => '',
+			'terms' => array(),
+			'include_children' => true,
+			'field' => 'term_id',
+			'operator' => 'IN',
+		);
+
+		foreach ( $tax_query as $query ) {
+			if ( ! is_array( $query ) )
+				continue;
+
+			$query = array_merge( $defaults, $query );
+
+			$query['terms'] = (array) $query['terms'];
+
+			$this->queries[] = $query;
+		}
+	}
+
+	/**
+	 * Generates SQL clauses to be appended to a main query.
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @param string $primary_table
+	 * @param string $primary_id_column
+	 * @return array
+	 */
+	function get_sql( $primary_table, $primary_id_column ) {
+		global $wpdb;
+
+		$join = '';
+		$where = array();
+		$i = 0;
+
+		foreach ( $this->queries as $query ) {
+			extract( $query );
+
+			if ( ! taxonomy_exists( $taxonomy ) )
+				return array( 'join' => '', 'where' => ' AND 0 = 1');
+
+			$terms = array_unique( (array) $terms );
+
+			if ( empty( $terms ) )
+				continue;
+
+			if ( is_taxonomy_hierarchical( $taxonomy ) && $include_children ) {
+				$this->_transform_terms( $terms, $taxonomy, $field, 'term_id' );
+
+				$children = array();
+				foreach ( $terms as $term ) {
+					$children = array_merge( $children, get_term_children( $term, $taxonomy ) );
+					$children[] = $term;
+				}
+				$terms = $children;
+
+				$this->_transform_terms( $terms, $taxonomy, 'term_id', 'term_taxonomy_id' );
+			}
+			else {
+				$this->_transform_terms( $terms, $taxonomy, $field, 'term_taxonomy_id' );
+			}
+
+			if ( 'IN' == $operator ) {
+
+				if ( empty( $terms ) ) {
+					if ( 'OR' == $this->relation )
+						continue;
+					else
+						return array( 'join' => '', 'where' => ' AND 0 = 1' );
+				}
+
+				$terms = implode( ',', $terms );
+
+				$alias = $i ? 'tt' . $i : $wpdb->term_relationships;
+
+				$join .= " INNER JOIN $wpdb->term_relationships";
+				$join .= $i ? " AS $alias" : '';
+				$join .= " ON ($primary_table.$primary_id_column = $alias.object_id)";
+
+				$where[] = "$alias.term_taxonomy_id $operator ($terms)";
+			} elseif ( 'NOT IN' == $operator ) {
+
+				if ( empty( $terms ) )
+					continue;
+
+				$terms = implode( ',', $terms );
+
+				$where[] = "$primary_table.$primary_id_column NOT IN (
+					SELECT object_id
+					FROM $wpdb->term_relationships
+					WHERE term_taxonomy_id IN ($terms)
+				)";
+			} elseif ( 'AND' == $operator ) {
+
+				if ( empty( $terms ) )
+					continue;
+
+				$num_terms = count( $terms );
+
+				$terms = implode( ',', $terms );
+
+				$where[] = "$primary_table.$primary_id_column IN (
+					SELECT object_id
+					FROM $wpdb->term_relationships
+					WHERE term_taxonomy_id IN ($terms)
+					GROUP BY object_id HAVING COUNT(object_id) = $num_terms
+				)";
+			}
+
+			$i++;
+		}
+
+		if ( !empty( $where ) )
+			$where = ' AND ( ' . implode( " $this->relation ", $where ) . ' )';
+		else
+			$where = '';
+
+		return compact( 'join', 'where' );
+	}
+
+	/**
+	 * Transforms a list of terms, from one field to another.
+	 *
+	 * @since 3.1.0
+	 * @access private
+	 *
+	 * @param array &$terms The list of terms
+	 * @param string $taxonomy The taxonomy of the terms
+	 * @param string $field The initial field
+	 * @param string $resulting_field The resulting field
+	 */
+	function _transform_terms( &$terms, $taxonomy, $field, $resulting_field ) {
+		global $wpdb;
+
+		if ( empty( $terms ) )
+			return;
+
+		if ( $field == $resulting_field )
+			return;
+
+		$resulting_field = esc_sql( $resulting_field );
+
+		switch ( $field ) {
+			case 'slug':
+			case 'name':
+				$terms = "'" . implode( "','", array_map( 'sanitize_title_for_query', $terms ) ) . "'";
+				$terms = $wpdb->get_col( "
+					SELECT $wpdb->term_taxonomy.$resulting_field
+					FROM $wpdb->term_taxonomy
+					INNER JOIN $wpdb->terms USING (term_id)
+					WHERE taxonomy = '$taxonomy'
+					AND $wpdb->terms.$field IN ($terms)
+				" );
+				break;
+
+			default:
+				$terms = implode( ',', array_map( 'intval', $terms ) );
+				$terms = $wpdb->get_col( "
+					SELECT $resulting_field
+					FROM $wpdb->term_taxonomy
+					WHERE taxonomy = '$taxonomy'
+					AND term_id IN ($terms)
+				" );
+		}
+	}
+}
+
+/**
+ * Get all Term data from database by Term ID.
+ *
+ * The usage of the get_term function is to apply filters to a term object. It
+ * is possible to get a term object from the database before applying the
+ * filters.
+ *
+ * $term ID must be part of $taxonomy, to get from the database. Failure, might
+ * be able to be captured by the hooks. Failure would be the same value as $wpdb
+ * returns for the get_row method.
+ *
+ * There are two hooks, one is specifically for each term, named 'get_term', and
+ * the second is for the taxonomy name, 'term_$taxonomy'. Both hooks gets the
+ * term object, and the taxonomy name as parameters. Both hooks are expected to
+ * return a Term object.
+ *
+ * 'get_term' hook - Takes two parameters the term Object and the taxonomy name.
+ * Must return term object. Used in get_term() as a catch-all filter for every
+ * $term.
+ *
+ * 'get_$taxonomy' hook - Takes two parameters the term Object and the taxonomy
+ * name. Must return term object. $taxonomy will be the taxonomy name, so for
+ * example, if 'category', it would be 'get_category' as the filter name. Useful
+ * for custom taxonomies or plugging into default taxonomies.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ * @uses sanitize_term() Cleanses the term based on $filter context before returning.
+ * @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
+ *
+ * @param int|object $term If integer, will get from database. If object will apply filters and return $term.
+ * @param string $taxonomy Taxonomy name that $term is part of.
+ * @param string $output Constant OBJECT, ARRAY_A, or ARRAY_N
+ * @param string $filter Optional, default is raw or no WordPress defined filter will applied.
+ * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
+ * exist then WP_Error will be returned.
+ */
+function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
+	global $wpdb;
+	$null = null;
+
+	if ( empty($term) ) {
+		$error = new WP_Error('invalid_term', __('Empty Term'));
+		return $error;
+	}
+
+	if ( ! taxonomy_exists($taxonomy) ) {
+		$error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+		return $error;
+	}
+
+	if ( is_object($term) && empty($term->filter) ) {
+		wp_cache_add($term->term_id, $term, $taxonomy);
+		$_term = $term;
+	} else {
+		if ( is_object($term) )
+			$term = $term->term_id;
+		$term = (int) $term;
+		if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
+			$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
+			if ( ! $_term )
+				return $null;
+			wp_cache_add($term, $_term, $taxonomy);
+		}
+	}
+
+	$_term = apply_filters('get_term', $_term, $taxonomy);
+	$_term = apply_filters("get_$taxonomy", $_term, $taxonomy);
+	$_term = sanitize_term($_term, $taxonomy, $filter);
+
+	if ( $output == OBJECT ) {
+		return $_term;
+	} elseif ( $output == ARRAY_A ) {
+		$__term = get_object_vars($_term);
+		return $__term;
+	} elseif ( $output == ARRAY_N ) {
+		$__term = array_values(get_object_vars($_term));
+		return $__term;
+	} else {
+		return $_term;
+	}
+}
+
+/**
+ * Get all Term data from database by Term field and data.
+ *
+ * Warning: $value is not escaped for 'name' $field. You must do it yourself, if
+ * required.
+ *
+ * The default $field is 'id', therefore it is possible to also use null for
+ * field, but not recommended that you do so.
+ *
+ * If $value does not exist, the return value will be false. If $taxonomy exists
+ * and $field and $value combinations exist, the Term will be returned.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ * @uses sanitize_term() Cleanses the term based on $filter context before returning.
+ * @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
+ *
+ * @param string $field Either 'slug', 'name', or 'id'
+ * @param string|int $value Search for this term value
+ * @param string $taxonomy Taxonomy Name
+ * @param string $output Constant OBJECT, ARRAY_A, or ARRAY_N
+ * @param string $filter Optional, default is raw or no WordPress defined filter will applied.
+ * @return mixed Term Row from database. Will return false if $taxonomy does not exist or $term was not found.
+ */
+function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') {
+	global $wpdb;
+
+	if ( ! taxonomy_exists($taxonomy) )
+		return false;
+
+	if ( 'slug' == $field ) {
+		$field = 't.slug';
+		$value = sanitize_title($value);
+		if ( empty($value) )
+			return false;
+	} else if ( 'name' == $field ) {
+		// Assume already escaped
+		$value = stripslashes($value);
+		$field = 't.name';
+	} else {
+		return get_term( (int) $value, $taxonomy, $output, $filter);
+	}
+
+	$term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value) );
+	if ( !$term )
+		return false;
+
+	wp_cache_add($term->term_id, $term, $taxonomy);
+
+	$term = apply_filters('get_term', $term, $taxonomy);
+	$term = apply_filters("get_$taxonomy", $term, $taxonomy);
+	$term = sanitize_term($term, $taxonomy, $filter);
+
+	if ( $output == OBJECT ) {
+		return $term;
+	} elseif ( $output == ARRAY_A ) {
+		return get_object_vars($term);
+	} elseif ( $output == ARRAY_N ) {
+		return array_values(get_object_vars($term));
+	} else {
+		return $term;
+	}
+}
+
+/**
+ * Merge all term children into a single array of their IDs.
+ *
+ * This recursive function will merge all of the children of $term into the same
+ * array of term IDs. Only useful for taxonomies which are hierarchical.
+ *
+ * Will return an empty array if $term does not exist in $taxonomy.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ * @uses _get_term_hierarchy()
+ * @uses get_term_children() Used to get the children of both $taxonomy and the parent $term
+ *
+ * @param string $term_id ID of Term to get children
+ * @param string $taxonomy Taxonomy Name
+ * @return array|WP_Error List of Term Objects. WP_Error returned if $taxonomy does not exist
+ */
+function get_term_children( $term_id, $taxonomy ) {
+	if ( ! taxonomy_exists($taxonomy) )
+		return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+
+	$term_id = intval( $term_id );
+
+	$terms = _get_term_hierarchy($taxonomy);
+
+	if ( ! isset($terms[$term_id]) )
+		return array();
+
+	$children = $terms[$term_id];
+
+	foreach ( (array) $terms[$term_id] as $child ) {
+		if ( isset($terms[$child]) )
+			$children = array_merge($children, get_term_children($child, $taxonomy));
+	}
+
+	return $children;
+}
+
+/**
+ * Get sanitized Term field.
+ *
+ * Does checks for $term, based on the $taxonomy. The function is for contextual
+ * reasons and for simplicity of usage. See sanitize_term_field() for more
+ * information.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses sanitize_term_field() Passes the return value in sanitize_term_field on success.
+ *
+ * @param string $field Term field to fetch
+ * @param int $term Term ID
+ * @param string $taxonomy Taxonomy Name
+ * @param string $context Optional, default is display. Look at sanitize_term_field() for available options.
+ * @return mixed Will return an empty string if $term is not an object or if $field is not set in $term.
+ */
+function get_term_field( $field, $term, $taxonomy, $context = 'display' ) {
+	$term = (int) $term;
+	$term = get_term( $term, $taxonomy );
+	if ( is_wp_error($term) )
+		return $term;
+
+	if ( !is_object($term) )
+		return '';
+
+	if ( !isset($term->$field) )
+		return '';
+
+	return sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);
+}
+
+/**
+ * Sanitizes Term for editing.
+ *
+ * Return value is sanitize_term() and usage is for sanitizing the term for
+ * editing. Function is for contextual and simplicity.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses sanitize_term() Passes the return value on success
+ *
+ * @param int|object $id Term ID or Object
+ * @param string $taxonomy Taxonomy Name
+ * @return mixed|null|WP_Error Will return empty string if $term is not an object.
+ */
+function get_term_to_edit( $id, $taxonomy ) {
+	$term = get_term( $id, $taxonomy );
+
+	if ( is_wp_error($term) )
+		return $term;
+
+	if ( !is_object($term) )
+		return '';
+
+	return sanitize_term($term, $taxonomy, 'edit');
+}
+
+/**
+ * Retrieve the terms in a given taxonomy or list of taxonomies.
+ *
+ * You can fully inject any customizations to the query before it is sent, as
+ * well as control the output with a filter.
+ *
+ * The 'get_terms' filter will be called when the cache has the term and will
+ * pass the found term along with the array of $taxonomies and array of $args.
+ * This filter is also called before the array of terms is passed and will pass
+ * the array of terms, along with the $taxonomies and $args.
+ *
+ * The 'list_terms_exclusions' filter passes the compiled exclusions along with
+ * the $args.
+ *
+ * The 'get_terms_orderby' filter passes the ORDER BY clause for the query
+ * along with the $args array.
+ *
+ * The 'get_terms_fields' filter passes the fields for the SELECT query
+ * along with the $args array.
+ *
+ * The list of arguments that $args can contain, which will overwrite the defaults:
+ *
+ * orderby - Default is 'name'. Can be name, count, term_group, slug or nothing
+ * (will use term_id), Passing a custom value other than these will cause it to
+ * order based on the custom value.
+ *
+ * order - Default is ASC. Can use DESC.
+ *
+ * hide_empty - Default is true. Will not return empty terms, which means
+ * terms whose count is 0 according to the given taxonomy.
+ *
+ * exclude - Default is an empty array.  An array, comma- or space-delimited string
+ * of term ids to exclude from the return array.  If 'include' is non-empty,
+ * 'exclude' is ignored.
+ *
+ * exclude_tree - Default is an empty array.  An array, comma- or space-delimited
+ * string of term ids to exclude from the return array, along with all of their
+ * descendant terms according to the primary taxonomy.  If 'include' is non-empty,
+ * 'exclude_tree' is ignored.
+ *
+ * include - Default is an empty array.  An array, comma- or space-delimited string
+ * of term ids to include in the return array.
+ *
+ * number - The maximum number of terms to return.  Default is to return them all.
+ *
+ * offset - The number by which to offset the terms query.
+ *
+ * fields - Default is 'all', which returns an array of term objects.
+ * If 'fields' is 'ids' or 'names', returns an array of
+ * integers or strings, respectively.
+ *
+ * slug - Returns terms whose "slug" matches this value. Default is empty string.
+ *
+ * hierarchical - Whether to include terms that have non-empty descendants
+ * (even if 'hide_empty' is set to true).
+ *
+ * search - Returned terms' names will contain the value of 'search',
+ * case-insensitive.  Default is an empty string.
+ *
+ * name__like - Returned terms' names will begin with the value of 'name__like',
+ * case-insensitive. Default is empty string.
+ *
+ * The argument 'pad_counts', if set to true will include the quantity of a term's
+ * children in the quantity of each term's "count" object variable.
+ *
+ * The 'get' argument, if set to 'all' instead of its default empty string,
+ * returns terms regardless of ancestry or whether the terms are empty.
+ *
+ * The 'child_of' argument, when used, should be set to the integer of a term ID.  Its default
+ * is 0.  If set to a non-zero value, all returned terms will be descendants
+ * of that term according to the given taxonomy.  Hence 'child_of' is set to 0
+ * if more than one taxonomy is passed in $taxonomies, because multiple taxonomies
+ * make term ancestry ambiguous.
+ *
+ * The 'parent' argument, when used, should be set to the integer of a term ID.  Its default is
+ * the empty string '', which has a different meaning from the integer 0.
+ * If set to an integer value, all returned terms will have as an immediate
+ * ancestor the term whose ID is specified by that integer according to the given taxonomy.
+ * The 'parent' argument is different from 'child_of' in that a term X is considered a 'parent'
+ * of term Y only if term X is the father of term Y, not its grandfather or great-grandfather, etc.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ * @uses wp_parse_args() Merges the defaults with those defined by $args and allows for strings.
+ *
+ * @param string|array $taxonomies Taxonomy name or list of Taxonomy names
+ * @param string|array $args The values of what to search for when returning terms
+ * @return array|WP_Error List of Term Objects and their children. Will return WP_Error, if any of $taxonomies do not exist.
+ */
+function &get_terms($taxonomies, $args = '') {
+	global $wpdb;
+	$empty_array = array();
+
+	$single_taxonomy = false;
+	if ( !is_array($taxonomies) ) {
+		$single_taxonomy = true;
+		$taxonomies = array($taxonomies);
+	}
+
+	foreach ( $taxonomies as $taxonomy ) {
+		if ( ! taxonomy_exists($taxonomy) ) {
+			$error = & new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+			return $error;
+		}
+	}
+
+	$defaults = array('orderby' => 'name', 'order' => 'ASC',
+		'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(),
+		'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
+		'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
+		'pad_counts' => false, 'offset' => '', 'search' => '');
+	$args = wp_parse_args( $args, $defaults );
+	$args['number'] = absint( $args['number'] );
+	$args['offset'] = absint( $args['offset'] );
+	if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
+		'' !== $args['parent'] ) {
+		$args['child_of'] = 0;
+		$args['hierarchical'] = false;
+		$args['pad_counts'] = false;
+	}
+
+	if ( 'all' == $args['get'] ) {
+		$args['child_of'] = 0;
+		$args['hide_empty'] = 0;
+		$args['hierarchical'] = false;
+		$args['pad_counts'] = false;
+	}
+
+	$args = apply_filters( 'get_terms_args', $args, $taxonomies );
+
+	extract($args, EXTR_SKIP);
+
+	if ( $child_of ) {
+		$hierarchy = _get_term_hierarchy($taxonomies[0]);
+		if ( !isset($hierarchy[$child_of]) )
+			return $empty_array;
+	}
+
+	if ( $parent ) {
+		$hierarchy = _get_term_hierarchy($taxonomies[0]);
+		if ( !isset($hierarchy[$parent]) )
+			return $empty_array;
+	}
+
+	// $args can be whatever, only use the args defined in defaults to compute the key
+	$filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
+	$key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
+	$last_changed = wp_cache_get('last_changed', 'terms');
+	if ( !$last_changed ) {
+		$last_changed = time();
+		wp_cache_set('last_changed', $last_changed, 'terms');
+	}
+	$cache_key = "get_terms:$key:$last_changed";
+	$cache = wp_cache_get( $cache_key, 'terms' );
+	if ( false !== $cache ) {
+		$cache = apply_filters('get_terms', $cache, $taxonomies, $args);
+		return $cache;
+	}
+
+	$_orderby = strtolower($orderby);
+	if ( 'count' == $_orderby )
+		$orderby = 'tt.count';
+	else if ( 'name' == $_orderby )
+		$orderby = 't.name';
+	else if ( 'slug' == $_orderby )
+		$orderby = 't.slug';
+	else if ( 'term_group' == $_orderby )
+		$orderby = 't.term_group';
+	else if ( 'none' == $_orderby )
+		$orderby = '';
+	elseif ( empty($_orderby) || 'id' == $_orderby )
+		$orderby = 't.term_id';
+
+	$orderby = apply_filters( 'get_terms_orderby', $orderby, $args );
+
+	if ( !empty($orderby) )
+		$orderby = "ORDER BY $orderby";
+	else
+		$order = '';
+
+	$where = "tt.taxonomy IN ('" . implode("', '", $taxonomies) . "')";
+	$inclusions = '';
+	if ( !empty($include) ) {
+		$exclude = '';
+		$exclude_tree = '';
+		$interms = wp_parse_id_list($include);
+		foreach ( $interms as $interm ) {
+			if ( empty($inclusions) )
+				$inclusions = ' AND ( t.term_id = ' . intval($interm) . ' ';
+			else
+				$inclusions .= ' OR t.term_id = ' . intval($interm) . ' ';
+		}
+	}
+
+	if ( !empty($inclusions) )
+		$inclusions .= ')';
+	$where .= $inclusions;
+
+	$exclusions = '';
+	if ( !empty( $exclude_tree ) ) {
+		$excluded_trunks = wp_parse_id_list($exclude_tree);
+		foreach ( $excluded_trunks as $extrunk ) {
+			$excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids', 'hide_empty' => 0));
+			$excluded_children[] = $extrunk;
+			foreach( $excluded_children as $exterm ) {
+				if ( empty($exclusions) )
+					$exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
+				else
+					$exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
+			}
+		}
+	}
+
+	if ( !empty($exclude) ) {
+		$exterms = wp_parse_id_list($exclude);
+		foreach ( $exterms as $exterm ) {
+			if ( empty($exclusions) )
+				$exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
+			else
+				$exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
+		}
+	}
+
+	if ( !empty($exclusions) )
+		$exclusions .= ')';
+	$exclusions = apply_filters('list_terms_exclusions', $exclusions, $args );
+	$where .= $exclusions;
+
+	if ( !empty($slug) ) {
+		$slug = sanitize_title($slug);
+		$where .= " AND t.slug = '$slug'";
+	}
+
+	if ( !empty($name__like) )
+		$where .= " AND t.name LIKE '" . like_escape( $name__like ) . "%'";
+
+	if ( '' !== $parent ) {
+		$parent = (int) $parent;
+		$where .= " AND tt.parent = '$parent'";
+	}
+
+	if ( $hide_empty && !$hierarchical )
+		$where .= ' AND tt.count > 0';
+
+	// don't limit the query results when we have to descend the family tree
+	if ( ! empty($number) && ! $hierarchical && empty( $child_of ) && '' === $parent ) {
+		if ( $offset )
+			$limits = 'LIMIT ' . $offset . ',' . $number;
+		else
+			$limits = 'LIMIT ' . $number;
+	} else {
+		$limits = '';
+	}
+
+	if ( !empty($search) ) {
+		$search = like_escape($search);
+		$where .= " AND (t.name LIKE '%$search%')";
+	}
+
+	$selects = array();
+	switch ( $fields ) {
+		case 'all':
+			$selects = array('t.*', 'tt.*');
+			break;
+		case 'ids':
+		case 'id=>parent':
+			$selects = array('t.term_id', 'tt.parent', 'tt.count');
+			break;
+		case 'names':
+			$selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name');
+			break;
+		case 'count':
+			$orderby = '';
+			$order = '';
+			$selects = array('COUNT(*)');
+	}
+
+	$_fields = $fields;
+
+	$fields = implode(', ', apply_filters( 'get_terms_fields', $selects, $args ));
+
+	$join = "INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
+
+	$pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
+	$clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args );
+	foreach ( $pieces as $piece )
+		$$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
+
+	$query = "SELECT $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits";
+
+	$fields = $_fields;
+
+	if ( 'count' == $fields ) {
+		$term_count = $wpdb->get_var($query);
+		return $term_count;
+	}
+
+	$terms = $wpdb->get_results($query);
+	if ( 'all' == $fields ) {
+		update_term_cache($terms);
+	}
+
+	if ( empty($terms) ) {
+		wp_cache_add( $cache_key, array(), 'terms', 86400 ); // one day
+		$terms = apply_filters('get_terms', array(), $taxonomies, $args);
+		return $terms;
+	}
+
+	if ( $child_of ) {
+		$children = _get_term_hierarchy($taxonomies[0]);
+		if ( ! empty($children) )
+			$terms = & _get_term_children($child_of, $terms, $taxonomies[0]);
+	}
+
+	// Update term counts to include children.
+	if ( $pad_counts && 'all' == $fields )
+		_pad_term_counts($terms, $taxonomies[0]);
+
+	// Make sure we show empty categories that have children.
+	if ( $hierarchical && $hide_empty && is_array($terms) ) {
+		foreach ( $terms as $k => $term ) {
+			if ( ! $term->count ) {
+				$children = _get_term_children($term->term_id, $terms, $taxonomies[0]);
+				if ( is_array($children) )
+					foreach ( $children as $child )
+						if ( $child->count )
+							continue 2;
+
+				// It really is empty
+				unset($terms[$k]);
+			}
+		}
+	}
+	reset ( $terms );
+
+	$_terms = array();
+	if ( 'id=>parent' == $fields ) {
+		while ( $term = array_shift($terms) )
+			$_terms[$term->term_id] = $term->parent;
+		$terms = $_terms;
+	} elseif ( 'ids' == $fields ) {
+		while ( $term = array_shift($terms) )
+			$_terms[] = $term->term_id;
+		$terms = $_terms;
+	} elseif ( 'names' == $fields ) {
+		while ( $term = array_shift($terms) )
+			$_terms[] = $term->name;
+		$terms = $_terms;
+	}
+
+	if ( 0 < $number && intval(@count($terms)) > $number ) {
+		$terms = array_slice($terms, $offset, $number);
+	}
+
+	wp_cache_add( $cache_key, $terms, 'terms', 86400 ); // one day
+
+	$terms = apply_filters('get_terms', $terms, $taxonomies, $args);
+	return $terms;
+}
+
+/**
+ * Check if Term exists.
+ *
+ * Returns the index of a defined term, or 0 (false) if the term doesn't exist.
+ *
+ * Formerly is_term(), introduced in 2.3.0.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 3.0.0
+ *
+ * @uses $wpdb
+ *
+ * @param int|string $term The term to check
+ * @param string $taxonomy The taxonomy name to use
+ * @param int $parent ID of parent term under which to confine the exists search.
+ * @return mixed Get the term id or Term Object, if exists.
+ */
+function term_exists($term, $taxonomy = '', $parent = 0) {
+	global $wpdb;
+
+	$select = "SELECT term_id FROM $wpdb->terms as t WHERE ";
+	$tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
+
+	if ( is_int($term) ) {
+		if ( 0 == $term )
+			return 0;
+		$where = 't.term_id = %d';
+		if ( !empty($taxonomy) )
+			return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy ), ARRAY_A );
+		else
+			return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
+	}
+
+	$term = trim( stripslashes( $term ) );
+
+	if ( '' === $slug = sanitize_title($term) )
+		return 0;
+
+	$where = 't.slug = %s';
+	$else_where = 't.name = %s';
+	$where_fields = array($slug);
+	$else_where_fields = array($term);
+	if ( !empty($taxonomy) ) {
+		$parent = (int) $parent;
+		if ( $parent > 0 ) {
+			$where_fields[] = $parent;
+			$else_where_fields[] = $parent;
+			$where .= ' AND tt.parent = %d';
+			$else_where .= ' AND tt.parent = %d';
+		}
+
+		$where_fields[] = $taxonomy;
+		$else_where_fields[] = $taxonomy;
+
+		if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A) )
+			return $result;
+
+		return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $else_where_fields), ARRAY_A);
+	}
+
+	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields) ) )
+		return $result;
+
+	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $else_where_fields) );
+}
+
+/**
+ * Sanitize Term all fields.
+ *
+ * Relys on sanitize_term_field() to sanitize the term. The difference is that
+ * this function will sanitize <strong>all</strong> fields. The context is based
+ * on sanitize_term_field().
+ *
+ * The $term is expected to be either an array or an object.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses sanitize_term_field Used to sanitize all fields in a term
+ *
+ * @param array|object $term The term to check
+ * @param string $taxonomy The taxonomy name to use
+ * @param string $context Default is 'display'.
+ * @return array|object Term with all fields sanitized
+ */
+function sanitize_term($term, $taxonomy, $context = 'display') {
+
+	if ( 'raw' == $context )
+		return $term;
+
+	$fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group');
+
+	$do_object = false;
+	if ( is_object($term) )
+		$do_object = true;
+
+	$term_id = $do_object ? $term->term_id : (isset($term['term_id']) ? $term['term_id'] : 0);
+
+	foreach ( (array) $fields as $field ) {
+		if ( $do_object ) {
+			if ( isset($term->$field) )
+				$term->$field = sanitize_term_field($field, $term->$field, $term_id, $taxonomy, $context);
+		} else {
+			if ( isset($term[$field]) )
+				$term[$field] = sanitize_term_field($field, $term[$field], $term_id, $taxonomy, $context);
+		}
+	}
+
+	if ( $do_object )
+		$term->filter = $context;
+	else
+		$term['filter'] = $context;
+
+	return $term;
+}
+
+/**
+ * Cleanse the field value in the term based on the context.
+ *
+ * Passing a term field value through the function should be assumed to have
+ * cleansed the value for whatever context the term field is going to be used.
+ *
+ * If no context or an unsupported context is given, then default filters will
+ * be applied.
+ *
+ * There are enough filters for each context to support a custom filtering
+ * without creating your own filter function. Simply create a function that
+ * hooks into the filter you need.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ *
+ * @param string $field Term field to sanitize
+ * @param string $value Search for this term value
+ * @param int $term_id Term ID
+ * @param string $taxonomy Taxonomy Name
+ * @param string $context Either edit, db, display, attribute, or js.
+ * @return mixed sanitized field
+ */
+function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
+	if ( 'parent' == $field  || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) {
+		$value = (int) $value;
+		if ( $value < 0 )
+			$value = 0;
+	}
+
+	if ( 'raw' == $context )
+		return $value;
+
+	if ( 'edit' == $context ) {
+		$value = apply_filters("edit_term_{$field}", $value, $term_id, $taxonomy);
+		$value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id);
+		if ( 'description' == $field )
+			$value = esc_html($value); // textarea_escaped
+		else
+			$value = esc_attr($value);
+	} else if ( 'db' == $context ) {
+		$value = apply_filters("pre_term_{$field}", $value, $taxonomy);
+		$value = apply_filters("pre_{$taxonomy}_{$field}", $value);
+		// Back compat filters
+		if ( 'slug' == $field )
+			$value = apply_filters('pre_category_nicename', $value);
+
+	} else if ( 'rss' == $context ) {
+		$value = apply_filters("term_{$field}_rss", $value, $taxonomy);
+		$value = apply_filters("{$taxonomy}_{$field}_rss", $value);
+	} else {
+		// Use display filters by default.
+		$value = apply_filters("term_{$field}", $value, $term_id, $taxonomy, $context);
+		$value = apply_filters("{$taxonomy}_{$field}", $value, $term_id, $context);
+	}
+
+	if ( 'attribute' == $context )
+		$value = esc_attr($value);
+	else if ( 'js' == $context )
+		$value = esc_js($value);
+
+	return $value;
+}
+
+/**
+ * Count how many terms are in Taxonomy.
+ *
+ * Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true).
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses get_terms()
+ * @uses wp_parse_args() Turns strings into arrays and merges defaults into an array.
+ *
+ * @param string $taxonomy Taxonomy name
+ * @param array|string $args Overwrite defaults. See get_terms()
+ * @return int How many terms are in $taxonomy
+ */
+function wp_count_terms( $taxonomy, $args = array() ) {
+	$defaults = array('hide_empty' => false);
+	$args = wp_parse_args($args, $defaults);
+
+	// backwards compatibility
+	if ( isset($args['ignore_empty']) ) {
+		$args['hide_empty'] = $args['ignore_empty'];
+		unset($args['ignore_empty']);
+	}
+
+	$args['fields'] = 'count';
+
+	return get_terms($taxonomy, $args);
+}
+
+/**
+ * Will unlink the object from the taxonomy or taxonomies.
+ *
+ * Will remove all relationships between the object and any terms in
+ * a particular taxonomy or taxonomies. Does not remove the term or
+ * taxonomy itself.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param int $object_id The term Object Id that refers to the term
+ * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name.
+ */
+function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
+	global $wpdb;
+
+	$object_id = (int) $object_id;
+
+	if ( !is_array($taxonomies) )
+		$taxonomies = array($taxonomies);
+
+	foreach ( (array) $taxonomies as $taxonomy ) {
+		$tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
+		$in_tt_ids = "'" . implode("', '", $tt_ids) . "'";
+		do_action( 'delete_term_relationships', $object_id, $tt_ids );
+		$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id) );
+		do_action( 'deleted_term_relationships', $object_id, $tt_ids );
+		wp_update_term_count($tt_ids, $taxonomy);
+	}
+}
+
+/**
+ * Removes a term from the database.
+ *
+ * If the term is a parent of other terms, then the children will be updated to
+ * that term's parent.
+ *
+ * The $args 'default' will only override the terms found, if there is only one
+ * term found. Any other and the found terms are used.
+ *
+ * The $args 'force_default' will force the term supplied as default to be
+ * assigned even if the object was not going to be termless
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ * @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action
+ *	hooks, passing term object, term id. 'delete_term' gets an additional
+ *	parameter with the $taxonomy parameter.
+ *
+ * @param int $term Term ID
+ * @param string $taxonomy Taxonomy Name
+ * @param array|string $args Optional. Change 'default' term id and override found term ids.
+ * @return bool|WP_Error Returns false if not term; true if completes delete action.
+ */
+function wp_delete_term( $term, $taxonomy, $args = array() ) {
+	global $wpdb;
+
+	$term = (int) $term;
+
+	if ( ! $ids = term_exists($term, $taxonomy) )
+		return false;
+	if ( is_wp_error( $ids ) )
+		return $ids;
+
+	$tt_id = $ids['term_taxonomy_id'];
+
+	$defaults = array();
+
+	if ( 'category' == $taxonomy ) {
+		$defaults['default'] = get_option( 'default_category' );
+		if ( $defaults['default'] == $term )
+			return 0; // Don't delete the default category
+	}
+
+	$args = wp_parse_args($args, $defaults);
+	extract($args, EXTR_SKIP);
+
+	if ( isset( $default ) ) {
+		$default = (int) $default;
+		if ( ! term_exists($default, $taxonomy) )
+			unset($default);
+	}
+
+	// Update children to point to new parent
+	if ( is_taxonomy_hierarchical($taxonomy) ) {
+		$term_obj = get_term($term, $taxonomy);
+		if ( is_wp_error( $term_obj ) )
+			return $term_obj;
+		$parent = $term_obj->parent;
+
+		$edit_tt_ids = $wpdb->get_col( "SELECT `term_taxonomy_id` FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id );
+		do_action( 'edit_term_taxonomies', $edit_tt_ids );
+		$wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) );
+		do_action( 'edited_term_taxonomies', $edit_tt_ids );
+	}
+
+	$objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
+
+	foreach ( (array) $objects as $object ) {
+		$terms = wp_get_object_terms($object, $taxonomy, array('fields' => 'ids', 'orderby' => 'none'));
+		if ( 1 == count($terms) && isset($default) ) {
+			$terms = array($default);
+		} else {
+			$terms = array_diff($terms, array($term));
+			if (isset($default) && isset($force_default) && $force_default)
+				$terms = array_merge($terms, array($default));
+		}
+		$terms = array_map('intval', $terms);
+		wp_set_object_terms($object, $terms, $taxonomy);
+	}
+
+	// Clean the relationship caches for all object types using this term
+	$tax_object = get_taxonomy( $taxonomy );
+	foreach ( $tax_object->object_type as $object_type )
+		clean_object_term_cache( $objects, $object_type );
+
+	do_action( 'delete_term_taxonomy', $tt_id );
+	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %d", $tt_id ) );
+	do_action( 'deleted_term_taxonomy', $tt_id );
+
+	// Delete the term if no taxonomies use it.
+	if ( !$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term) ) )
+		$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->terms WHERE term_id = %d", $term) );
+
+	clean_term_cache($term, $taxonomy);
+
+	do_action('delete_term', $term, $tt_id, $taxonomy);
+	do_action("delete_$taxonomy", $term, $tt_id);
+
+	return true;
+}
+
+/**
+ * Deletes one existing category.
+ *
+ * @since 2.0.0
+ * @uses wp_delete_term()
+ *
+ * @param int $cat_ID
+ * @return mixed Returns true if completes delete action; false if term doesnt exist;
+ * 	Zero on attempted deletion of default Category; WP_Error object is also a possibility.
+ */
+function wp_delete_category( $cat_ID ) {
+	return wp_delete_term( $cat_ID, 'category' );
+}
+
+/**
+ * Retrieves the terms associated with the given object(s), in the supplied taxonomies.
+ *
+ * The following information has to do the $args parameter and for what can be
+ * contained in the string or array of that parameter, if it exists.
+ *
+ * The first argument is called, 'orderby' and has the default value of 'name'.
+ * The other value that is supported is 'count'.
+ *
+ * The second argument is called, 'order' and has the default value of 'ASC'.
+ * The only other value that will be acceptable is 'DESC'.
+ *
+ * The final argument supported is called, 'fields' and has the default value of
+ * 'all'. There are multiple other options that can be used instead. Supported
+ * values are as follows: 'all', 'ids', 'names', and finally
+ * 'all_with_object_id'.
+ *
+ * The fields argument also decides what will be returned. If 'all' or
+ * 'all_with_object_id' is choosen or the default kept intact, then all matching
+ * terms objects will be returned. If either 'ids' or 'names' is used, then an
+ * array of all matching term ids or term names will be returned respectively.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param int|array $object_ids The ID(s) of the object(s) to retrieve.
+ * @param string|array $taxonomies The taxonomies to retrieve terms from.
+ * @param array|string $args Change what is returned
+ * @return array|WP_Error The requested term data or empty array if no terms found. WP_Error if $taxonomy does not exist.
+ */
+function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
+	global $wpdb;
+
+	if ( !is_array($taxonomies) )
+		$taxonomies = array($taxonomies);
+
+	foreach ( (array) $taxonomies as $taxonomy ) {
+		if ( ! taxonomy_exists($taxonomy) )
+			return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+	}
+
+	if ( !is_array($object_ids) )
+		$object_ids = array($object_ids);
+	$object_ids = array_map('intval', $object_ids);
+
+	$defaults = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');
+	$args = wp_parse_args( $args, $defaults );
+
+	$terms = array();
+	if ( count($taxonomies) > 1 ) {
+		foreach ( $taxonomies as $index => $taxonomy ) {
+			$t = get_taxonomy($taxonomy);
+			if ( isset($t->args) && is_array($t->args) && $args != array_merge($args, $t->args) ) {
+				unset($taxonomies[$index]);
+				$terms = array_merge($terms, wp_get_object_terms($object_ids, $taxonomy, array_merge($args, $t->args)));
+			}
+		}
+	} else {
+		$t = get_taxonomy($taxonomies[0]);
+		if ( isset($t->args) && is_array($t->args) )
+			$args = array_merge($args, $t->args);
+	}
+
+	extract($args, EXTR_SKIP);
+
+	if ( 'count' == $orderby )
+		$orderby = 'tt.count';
+	else if ( 'name' == $orderby )
+		$orderby = 't.name';
+	else if ( 'slug' == $orderby )
+		$orderby = 't.slug';
+	else if ( 'term_group' == $orderby )
+		$orderby = 't.term_group';
+	else if ( 'term_order' == $orderby )
+		$orderby = 'tr.term_order';
+	else if ( 'none' == $orderby ) {
+		$orderby = '';
+		$order = '';
+	} else {
+		$orderby = 't.term_id';
+	}
+
+	// tt_ids queries can only be none or tr.term_taxonomy_id
+	if ( ('tt_ids' == $fields) && !empty($orderby) )
+		$orderby = 'tr.term_taxonomy_id';
+
+	if ( !empty($orderby) )
+		$orderby = "ORDER BY $orderby";
+
+	$taxonomies = "'" . implode("', '", $taxonomies) . "'";
+	$object_ids = implode(', ', $object_ids);
+
+	$select_this = '';
+	if ( 'all' == $fields )
+		$select_this = 't.*, tt.*';
+	else if ( 'ids' == $fields )
+		$select_this = 't.term_id';
+	else if ( 'names' == $fields )
+		$select_this = 't.name';
+	else if ( 'all_with_object_id' == $fields )
+		$select_this = 't.*, tt.*, tr.object_id';
+
+	$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";
+
+	if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
+		$terms = array_merge($terms, $wpdb->get_results($query));
+		update_term_cache($terms);
+	} else if ( 'ids' == $fields || 'names' == $fields ) {
+		$terms = array_merge($terms, $wpdb->get_col($query));
+	} else if ( 'tt_ids' == $fields ) {
+		$terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");
+	}
+
+	if ( ! $terms )
+		$terms = array();
+
+	return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);
+}
+
+/**
+ * Adds a new term to the database. Optionally marks it as an alias of an existing term.
+ *
+ * Error handling is assigned for the nonexistance of the $taxonomy and $term
+ * parameters before inserting. If both the term id and taxonomy exist
+ * previously, then an array will be returned that contains the term id and the
+ * contents of what is returned. The keys of the array are 'term_id' and
+ * 'term_taxonomy_id' containing numeric values.
+ *
+ * It is assumed that the term does not yet exist or the above will apply. The
+ * term will be first added to the term table and then related to the taxonomy
+ * if everything is well. If everything is correct, then several actions will be
+ * run prior to a filter and then several actions will be run after the filter
+ * is run.
+ *
+ * The arguments decide how the term is handled based on the $args parameter.
+ * The following is a list of the available overrides and the defaults.
+ *
+ * 'alias_of'. There is no default, but if added, expected is the slug that the
+ * term will be an alias of. Expected to be a string.
+ *
+ * 'description'. There is no default. If exists, will be added to the database
+ * along with the term. Expected to be a string.
+ *
+ * 'parent'. Expected to be numeric and default is 0 (zero). Will assign value
+ * of 'parent' to the term.
+ *
+ * 'slug'. Expected to be a string. There is no default.
+ *
+ * If 'slug' argument exists then the slug will be checked to see if it is not
+ * a valid term. If that check succeeds (it is not a valid term), then it is
+ * added and the term id is given. If it fails, then a check is made to whether
+ * the taxonomy is hierarchical and the parent argument is not empty. If the
+ * second check succeeds, the term will be inserted and the term id will be
+ * given.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @uses apply_filters() Calls 'pre_insert_term' hook with term and taxonomy as parameters.
+ * @uses do_action() Calls 'create_term' hook with the term id and taxonomy id as parameters.
+ * @uses do_action() Calls 'create_$taxonomy' hook with term id and taxonomy id as parameters.
+ * @uses apply_filters() Calls 'term_id_filter' hook with term id and taxonomy id as parameters.
+ * @uses do_action() Calls 'created_term' hook with the term id and taxonomy id as parameters.
+ * @uses do_action() Calls 'created_$taxonomy' hook with term id and taxonomy id as parameters.
+ *
+ * @param string $term The term to add or update.
+ * @param string $taxonomy The taxonomy to which to add the term
+ * @param array|string $args Change the values of the inserted term
+ * @return array|WP_Error The Term ID and Term Taxonomy ID
+ */
+function wp_insert_term( $term, $taxonomy, $args = array() ) {
+	global $wpdb;
+
+	if ( ! taxonomy_exists($taxonomy) )
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
+
+	$term = apply_filters( 'pre_insert_term', $term, $taxonomy );
+		if ( is_wp_error( $term ) )
+			return $term;
+
+	if ( is_int($term) && 0 == $term )
+		return new WP_Error('invalid_term_id', __('Invalid term ID'));
+
+	if ( '' == trim($term) )
+		return new WP_Error('empty_term_name', __('A name is required for this term'));
+
+	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
+	$args = wp_parse_args($args, $defaults);
+	$args['name'] = $term;
+	$args['taxonomy'] = $taxonomy;
+	$args = sanitize_term($args, $taxonomy, 'db');
+	extract($args, EXTR_SKIP);
+
+	// expected_slashed ($name)
+	$name = stripslashes($name);
+	$description = stripslashes($description);
+
+	if ( empty($slug) )
+		$slug = sanitize_title($name);
+
+	$term_group = 0;
+	if ( $alias_of ) {
+		$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
+		if ( $alias->term_group ) {
+			// The alias we want is already in a group, so let's use that one.
+			$term_group = $alias->term_group;
+		} else {
+			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
+			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
+			do_action( 'edit_terms', $alias->term_id );
+			$wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) );
+			do_action( 'edited_terms', $alias->term_id );
+		}
+	}
+
+	if ( $term_id = term_exists($slug) ) {
+		$existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A );
+		// We've got an existing term in the same taxonomy, which matches the name of the new term:
+		if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && $exists = term_exists( (int) $term_id, $taxonomy ) ) {
+			// Hierarchical, and it matches an existing term, Do not allow same "name" in the same level.
+			$siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) );
+			if ( in_array($name, $siblings) ) {
+				return new WP_Error('term_exists', __('A term with the name provided already exists with this parent.'), $exists['term_id']);
+			} else {
+				$slug = wp_unique_term_slug($slug, (object) $args);
+				if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
+					return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
+				$term_id = (int) $wpdb->insert_id;
+			}
+		} elseif ( $existing_term['name'] != $name ) {
+			// We've got an existing term, with a different name, Create the new term.
+			$slug = wp_unique_term_slug($slug, (object) $args);
+			if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
+				return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
+			$term_id = (int) $wpdb->insert_id;
+		} elseif ( $exists = term_exists( (int) $term_id, $taxonomy ) )  {
+			// Same name, same slug.
+			return new WP_Error('term_exists', __('A term with the name provided already exists.'), $exists['term_id']);
+		}
+	} else {
+		// This term does not exist at all in the database, Create it.
+		$slug = wp_unique_term_slug($slug, (object) $args);
+		if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
+			return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
+		$term_id = (int) $wpdb->insert_id;
+	}
+
+	// Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string.
+	if ( empty($slug) ) {
+		$slug = sanitize_title($slug, $term_id);
+		do_action( 'edit_terms', $term_id );
+		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
+		do_action( 'edited_terms', $term_id );
+	}
+
+	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id ) );
+
+	if ( !empty($tt_id) )
+		return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
+
+	$wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) );
+	$tt_id = (int) $wpdb->insert_id;
+
+	do_action("create_term", $term_id, $tt_id, $taxonomy);
+	do_action("create_$taxonomy", $term_id, $tt_id);
+
+	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
+
+	clean_term_cache($term_id, $taxonomy);
+
+	do_action("created_term", $term_id, $tt_id, $taxonomy);
+	do_action("created_$taxonomy", $term_id, $tt_id);
+
+	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
+}
+
+/**
+ * Create Term and Taxonomy Relationships.
+ *
+ * Relates an object (post, link etc) to a term and taxonomy type. Creates the
+ * term and taxonomy relationship if it doesn't already exist. Creates a term if
+ * it doesn't exist (using the slug).
+ *
+ * A relationship means that the term is grouped in or belongs to the taxonomy.
+ * A term has no meaning until it is given context by defining which taxonomy it
+ * exists under.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param int $object_id The object to relate to.
+ * @param array|int|string $terms The slug or id of the term, will replace all existing
+ * related terms in this taxonomy.
+ * @param array|string $taxonomy The context in which to relate the term to the object.
+ * @param bool $append If false will delete difference of terms.
+ * @return array|WP_Error Affected Term IDs
+ */
+function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
+	global $wpdb;
+
+	$object_id = (int) $object_id;
+
+	if ( ! taxonomy_exists($taxonomy) )
+		return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
+
+	if ( !is_array($terms) )
+		$terms = array($terms);
+
+	if ( ! $append )
+		$old_tt_ids =  wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids', 'orderby' => 'none'));
+	else
+		$old_tt_ids = array();
+
+	$tt_ids = array();
+	$term_ids = array();
+
+	foreach ( (array) $terms as $term) {
+		if ( !strlen(trim($term)) )
+			continue;
+
+		if ( !$term_info = term_exists($term, $taxonomy) ) {
+			// Skip if a non-existent term ID is passed.
+			if ( is_int($term) )
+				continue;
+			$term_info = wp_insert_term($term, $taxonomy);
+		}
+		if ( is_wp_error($term_info) )
+			return $term_info;
+		$term_ids[] = $term_info['term_id'];
+		$tt_id = $term_info['term_taxonomy_id'];
+		$tt_ids[] = $tt_id;
+
+		if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) )
+			continue;
+		do_action( 'add_term_relationship', $object_id, $tt_id );
+		$wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) );
+		do_action( 'added_term_relationship', $object_id, $tt_id );
+	}
+
+	wp_update_term_count($tt_ids, $taxonomy);
+
+	if ( ! $append ) {
+		$delete_terms = array_diff($old_tt_ids, $tt_ids);
+		if ( $delete_terms ) {
+			$in_delete_terms = "'" . implode("', '", $delete_terms) . "'";
+			do_action( 'delete_term_relationships', $object_id, $delete_terms );
+			$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_delete_terms)", $object_id) );
+			do_action( 'deleted_term_relationships', $object_id, $delete_terms );
+			wp_update_term_count($delete_terms, $taxonomy);
+		}
+	}
+
+	$t = get_taxonomy($taxonomy);
+	if ( ! $append && isset($t->sort) && $t->sort ) {
+		$values = array();
+		$term_order = 0;
+		$final_tt_ids = wp_get_object_terms($object_id, $taxonomy, array('fields' => 'tt_ids'));
+		foreach ( $tt_ids as $tt_id )
+			if ( in_array($tt_id, $final_tt_ids) )
+				$values[] = $wpdb->prepare( "(%d, %d, %d)", $object_id, $tt_id, ++$term_order);
+		if ( $values )
+			$wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)");
+	}
+
+	do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
+	return $tt_ids;
+}
+
+/**
+ * Will make slug unique, if it isn't already.
+ *
+ * The $slug has to be unique global to every taxonomy, meaning that one
+ * taxonomy term can't have a matching slug with another taxonomy term. Each
+ * slug has to be globally unique for every taxonomy.
+ *
+ * The way this works is that if the taxonomy that the term belongs to is
+ * hierarchical and has a parent, it will append that parent to the $slug.
+ *
+ * If that still doesn't return an unique slug, then it try to append a number
+ * until it finds a number that is truely unique.
+ *
+ * The only purpose for $term is for appending a parent, if one exists.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param string $slug The string that will be tried for a unique slug
+ * @param object $term The term object that the $slug will belong too
+ * @return string Will return a true unique slug.
+ */
+function wp_unique_term_slug($slug, $term) {
+	global $wpdb;
+
+	if ( ! term_exists( $slug ) )
+		return $slug;
+
+	// If the taxonomy supports hierarchy and the term has a parent, make the slug unique
+	// by incorporating parent slugs.
+	if ( is_taxonomy_hierarchical($term->taxonomy) && !empty($term->parent) ) {
+		$the_parent = $term->parent;
+		while ( ! empty($the_parent) ) {
+			$parent_term = get_term($the_parent, $term->taxonomy);
+			if ( is_wp_error($parent_term) || empty($parent_term) )
+				break;
+			$slug .= '-' . $parent_term->slug;
+			if ( ! term_exists( $slug ) )
+				return $slug;
+
+			if ( empty($parent_term->parent) )
+				break;
+			$the_parent = $parent_term->parent;
+		}
+	}
+
+	// If we didn't get a unique slug, try appending a number to make it unique.
+	if ( !empty($args['term_id']) )
+		$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $args['term_id'] );
+	else
+		$query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug );
+
+	if ( $wpdb->get_var( $query ) ) {
+		$num = 2;
+		do {
+			$alt_slug = $slug . "-$num";
+			$num++;
+			$slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) );
+		} while ( $slug_check );
+		$slug = $alt_slug;
+	}
+
+	return $slug;
+}
+
+/**
+ * Update term based on arguments provided.
+ *
+ * The $args will indiscriminately override all values with the same field name.
+ * Care must be taken to not override important information need to update or
+ * update will fail (or perhaps create a new term, neither would be acceptable).
+ *
+ * Defaults will set 'alias_of', 'description', 'parent', and 'slug' if not
+ * defined in $args already.
+ *
+ * 'alias_of' will create a term group, if it doesn't already exist, and update
+ * it for the $term.
+ *
+ * If the 'slug' argument in $args is missing, then the 'name' in $args will be
+ * used. It should also be noted that if you set 'slug' and it isn't unique then
+ * a WP_Error will be passed back. If you don't pass any slug, then a unique one
+ * will be created for you.
+ *
+ * For what can be overrode in $args, check the term scheme can contain and stay
+ * away from the term keys.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses $wpdb
+ * @uses do_action() Will call both 'edit_term' and 'edit_$taxonomy' twice.
+ * @uses apply_filters() Will call the 'term_id_filter' filter and pass the term
+ *	id and taxonomy id.
+ *
+ * @param int $term_id The ID of the term
+ * @param string $taxonomy The context in which to relate the term to the object.
+ * @param array|string $args Overwrite term field values
+ * @return array|WP_Error Returns Term ID and Taxonomy Term ID
+ */
+function wp_update_term( $term_id, $taxonomy, $args = array() ) {
+	global $wpdb;
+
+	if ( ! taxonomy_exists($taxonomy) )
+		return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
+
+	$term_id = (int) $term_id;
+
+	// First, get all of the original args
+	$term = get_term ($term_id, $taxonomy, ARRAY_A);
+
+	if ( is_wp_error( $term ) )
+		return $term;
+
+	// Escape data pulled from DB.
+	$term = add_magic_quotes($term);
+
+	// Merge old and new args with new args overwriting old ones.
+	$args = array_merge($term, $args);
+
+	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
+	$args = wp_parse_args($args, $defaults);
+	$args = sanitize_term($args, $taxonomy, 'db');
+	extract($args, EXTR_SKIP);
+
+	// expected_slashed ($name)
+	$name = stripslashes($name);
+	$description = stripslashes($description);
+
+	if ( '' == trim($name) )
+		return new WP_Error('empty_term_name', __('A name is required for this term'));
+
+	$empty_slug = false;
+	if ( empty($slug) ) {
+		$empty_slug = true;
+		$slug = sanitize_title($name);
+	}
+
+	if ( $alias_of ) {
+		$alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) );
+		if ( $alias->term_group ) {
+			// The alias we want is already in a group, so let's use that one.
+			$term_group = $alias->term_group;
+		} else {
+			// The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
+			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
+			do_action( 'edit_terms', $alias->term_id );
+			$wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) );
+			do_action( 'edited_terms', $alias->term_id );
+		}
+	}
+
+	// Check $parent to see if it will cause a hierarchy loop
+	$parent = apply_filters( 'wp_update_term_parent', $parent, $term_id, $taxonomy, compact( array_keys( $args ) ), $args );
+
+	// Check for duplicate slug
+	$id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) );
+	if ( $id && ($id != $term_id) ) {
+		// If an empty slug was passed or the parent changed, reset the slug to something unique.
+		// Otherwise, bail.
+		if ( $empty_slug || ( $parent != $term['parent']) )
+			$slug = wp_unique_term_slug($slug, (object) $args);
+		else
+			return new WP_Error('duplicate_term_slug', sprintf(__('The slug &#8220;%s&#8221; is already in use by another term'), $slug));
+	}
+	do_action( 'edit_terms', $term_id );
+	$wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );
+	if ( empty($slug) ) {
+		$slug = sanitize_title($name, $term_id);
+		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
+	}
+	do_action( 'edited_terms', $term_id );
+
+	$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) );
+	do_action( 'edit_term_taxonomy', $tt_id, $taxonomy );
+	$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
+	do_action( 'edited_term_taxonomy', $tt_id, $taxonomy );
+
+	do_action("edit_term", $term_id, $tt_id, $taxonomy);
+	do_action("edit_$taxonomy", $term_id, $tt_id);
+
+	$term_id = apply_filters('term_id_filter', $term_id, $tt_id);
+
+	clean_term_cache($term_id, $taxonomy);
+
+	do_action("edited_term", $term_id, $tt_id, $taxonomy);
+	do_action("edited_$taxonomy", $term_id, $tt_id);
+
+	return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
+}
+
+/**
+ * Enable or disable term counting.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $defer Optional. Enable if true, disable if false.
+ * @return bool Whether term counting is enabled or disabled.
+ */
+function wp_defer_term_counting($defer=null) {
+	static $_defer = false;
+
+	if ( is_bool($defer) ) {
+		$_defer = $defer;
+		// flush any deferred counts
+		if ( !$defer )
+			wp_update_term_count( null, null, true );
+	}
+
+	return $_defer;
+}
+
+/**
+ * Updates the amount of terms in taxonomy.
+ *
+ * If there is a taxonomy callback applyed, then it will be called for updating
+ * the count.
+ *
+ * The default action is to count what the amount of terms have the relationship
+ * of term ID. Once that is done, then update the database.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param int|array $terms The term_taxonomy_id of the terms
+ * @param string $taxonomy The context of the term.
+ * @return bool If no terms will return false, and if successful will return true.
+ */
+function wp_update_term_count( $terms, $taxonomy, $do_deferred=false ) {
+	static $_deferred = array();
+
+	if ( $do_deferred ) {
+		foreach ( (array) array_keys($_deferred) as $tax ) {
+			wp_update_term_count_now( $_deferred[$tax], $tax );
+			unset( $_deferred[$tax] );
+		}
+	}
+
+	if ( empty($terms) )
+		return false;
+
+	if ( !is_array($terms) )
+		$terms = array($terms);
+
+	if ( wp_defer_term_counting() ) {
+		if ( !isset($_deferred[$taxonomy]) )
+			$_deferred[$taxonomy] = array();
+		$_deferred[$taxonomy] = array_unique( array_merge($_deferred[$taxonomy], $terms) );
+		return true;
+	}
+
+	return wp_update_term_count_now( $terms, $taxonomy );
+}
+
+/**
+ * Perform term count update immediately.
+ *
+ * @since 2.5.0
+ *
+ * @param array $terms The term_taxonomy_id of terms to update.
+ * @param string $taxonomy The context of the term.
+ * @return bool Always true when complete.
+ */
+function wp_update_term_count_now( $terms, $taxonomy ) {
+	global $wpdb;
+
+	$terms = array_map('intval', $terms);
+
+	$taxonomy = get_taxonomy($taxonomy);
+	if ( !empty($taxonomy->update_count_callback) ) {
+		call_user_func($taxonomy->update_count_callback, $terms, $taxonomy);
+	} else {
+		// Default count updater
+		foreach ( (array) $terms as $term) {
+			$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) );
+			do_action( 'edit_term_taxonomy', $term, $taxonomy );
+			$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
+			do_action( 'edited_term_taxonomy', $term, $taxonomy );
+		}
+
+	}
+
+	clean_term_cache($terms, '', false);
+
+	return true;
+}
+
+//
+// Cache
+//
+
+
+/**
+ * Removes the taxonomy relationship to terms from the cache.
+ *
+ * Will remove the entire taxonomy relationship containing term $object_id. The
+ * term IDs have to exist within the taxonomy $object_type for the deletion to
+ * take place.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @see get_object_taxonomies() for more on $object_type
+ * @uses do_action() Will call action hook named, 'clean_object_term_cache' after completion.
+ *	Passes, function params in same order.
+ *
+ * @param int|array $object_ids Single or list of term object ID(s)
+ * @param array|string $object_type The taxonomy object type
+ */
+function clean_object_term_cache($object_ids, $object_type) {
+	if ( !is_array($object_ids) )
+		$object_ids = array($object_ids);
+
+	foreach ( $object_ids as $id )
+		foreach ( get_object_taxonomies($object_type) as $taxonomy )
+			wp_cache_delete($id, "{$taxonomy}_relationships");
+
+	do_action('clean_object_term_cache', $object_ids, $object_type);
+}
+
+
+/**
+ * Will remove all of the term ids from the cache.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param int|array $ids Single or list of Term IDs
+ * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context.
+ * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.
+ */
+function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {
+	global $wpdb;
+	static $cleaned = array();
+
+	if ( !is_array($ids) )
+		$ids = array($ids);
+
+	$taxonomies = array();
+	// If no taxonomy, assume tt_ids.
+	if ( empty($taxonomy) ) {
+		$tt_ids = array_map('intval', $ids);
+		$tt_ids = implode(', ', $tt_ids);
+		$terms = $wpdb->get_results("SELECT term_id, taxonomy FROM $wpdb->term_taxonomy WHERE term_taxonomy_id IN ($tt_ids)");
+		$ids = array();
+		foreach ( (array) $terms as $term ) {
+			$taxonomies[] = $term->taxonomy;
+			$ids[] = $term->term_id;
+			wp_cache_delete($term->term_id, $term->taxonomy);
+		}
+		$taxonomies = array_unique($taxonomies);
+	} else {
+		$taxonomies = array($taxonomy);
+		foreach ( $taxonomies as $taxonomy ) {
+			foreach ( $ids as $id ) {
+				wp_cache_delete($id, $taxonomy);
+			}
+		}
+	}
+
+	foreach ( $taxonomies as $taxonomy ) {
+		if ( isset($cleaned[$taxonomy]) )
+			continue;
+		$cleaned[$taxonomy] = true;
+
+		if ( $clean_taxonomy ) {
+			wp_cache_delete('all_ids', $taxonomy);
+			wp_cache_delete('get', $taxonomy);
+			delete_option("{$taxonomy}_children");
+			// Regenerate {$taxonomy}_children
+			_get_term_hierarchy($taxonomy);
+		}
+
+		do_action('clean_term_cache', $ids, $taxonomy);
+	}
+
+	wp_cache_set('last_changed', time(), 'terms');
+}
+
+
+/**
+ * Retrieves the taxonomy relationship to the term object id.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @uses wp_cache_get() Retrieves taxonomy relationship from cache
+ *
+ * @param int|array $id Term object ID
+ * @param string $taxonomy Taxonomy Name
+ * @return bool|array Empty array if $terms found, but not $taxonomy. False if nothing is in cache for $taxonomy and $id.
+ */
+function &get_object_term_cache($id, $taxonomy) {
+	$cache = wp_cache_get($id, "{$taxonomy}_relationships");
+	return $cache;
+}
+
+
+/**
+ * Updates the cache for Term ID(s).
+ *
+ * Will only update the cache for terms not already cached.
+ *
+ * The $object_ids expects that the ids be separated by commas, if it is a
+ * string.
+ *
+ * It should be noted that update_object_term_cache() is very time extensive. It
+ * is advised that the function is not called very often or at least not for a
+ * lot of terms that exist in a lot of taxonomies. The amount of time increases
+ * for each term and it also increases for each taxonomy the term belongs to.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ * @uses wp_get_object_terms() Used to get terms from the database to update
+ *
+ * @param string|array $object_ids Single or list of term object ID(s)
+ * @param array|string $object_type The taxonomy object type
+ * @return null|bool Null value is given with empty $object_ids. False if
+ */
+function update_object_term_cache($object_ids, $object_type) {
+	if ( empty($object_ids) )
+		return;
+
+	if ( !is_array($object_ids) )
+		$object_ids = explode(',', $object_ids);
+
+	$object_ids = array_map('intval', $object_ids);
+
+	$taxonomies = get_object_taxonomies($object_type);
+
+	$ids = array();
+	foreach ( (array) $object_ids as $id ) {
+		foreach ( $taxonomies as $taxonomy ) {
+			if ( false === wp_cache_get($id, "{$taxonomy}_relationships") ) {
+				$ids[] = $id;
+				break;
+			}
+		}
+	}
+
+	if ( empty( $ids ) )
+		return false;
+
+	$terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id'));
+
+	$object_terms = array();
+	foreach ( (array) $terms as $term )
+		$object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term;
+
+	foreach ( $ids as $id ) {
+		foreach ( $taxonomies  as $taxonomy ) {
+			if ( ! isset($object_terms[$id][$taxonomy]) ) {
+				if ( !isset($object_terms[$id]) )
+					$object_terms[$id] = array();
+				$object_terms[$id][$taxonomy] = array();
+			}
+		}
+	}
+
+	foreach ( $object_terms as $id => $value ) {
+		foreach ( $value as $taxonomy => $terms ) {
+			wp_cache_set($id, $terms, "{$taxonomy}_relationships");
+		}
+	}
+}
+
+
+/**
+ * Updates Terms to Taxonomy in cache.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @since 2.3.0
+ *
+ * @param array $terms List of Term objects to change
+ * @param string $taxonomy Optional. Update Term to this taxonomy in cache
+ */
+function update_term_cache($terms, $taxonomy = '') {
+	foreach ( (array) $terms as $term ) {
+		$term_taxonomy = $taxonomy;
+		if ( empty($term_taxonomy) )
+			$term_taxonomy = $term->taxonomy;
+
+		wp_cache_add($term->term_id, $term, $term_taxonomy);
+	}
+}
+
+//
+// Private
+//
+
+
+/**
+ * Retrieves children of taxonomy as Term IDs.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @access private
+ * @since 2.3.0
+ *
+ * @uses update_option() Stores all of the children in "$taxonomy_children"
+ *	 option. That is the name of the taxonomy, immediately followed by '_children'.
+ *
+ * @param string $taxonomy Taxonomy Name
+ * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs.
+ */
+function _get_term_hierarchy($taxonomy) {
+	if ( !is_taxonomy_hierarchical($taxonomy) )
+		return array();
+	$children = get_option("{$taxonomy}_children");
+
+	if ( is_array($children) )
+		return $children;
+	$children = array();
+	$terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent'));
+	foreach ( $terms as $term_id => $parent ) {
+		if ( $parent > 0 )
+			$children[$parent][] = $term_id;
+	}
+	update_option("{$taxonomy}_children", $children);
+
+	return $children;
+}
+
+
+/**
+ * Get the subset of $terms that are descendants of $term_id.
+ *
+ * If $terms is an array of objects, then _get_term_children returns an array of objects.
+ * If $terms is an array of IDs, then _get_term_children returns an array of IDs.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @access private
+ * @since 2.3.0
+ *
+ * @param int $term_id The ancestor term: all returned terms should be descendants of $term_id.
+ * @param array $terms The set of terms---either an array of term objects or term IDs---from which those that are descendants of $term_id will be chosen.
+ * @param string $taxonomy The taxonomy which determines the hierarchy of the terms.
+ * @return array The subset of $terms that are descendants of $term_id.
+ */
+function &_get_term_children($term_id, $terms, $taxonomy) {
+	$empty_array = array();
+	if ( empty($terms) )
+		return $empty_array;
+
+	$term_list = array();
+	$has_children = _get_term_hierarchy($taxonomy);
+
+	if  ( ( 0 != $term_id ) && ! isset($has_children[$term_id]) )
+		return $empty_array;
+
+	foreach ( (array) $terms as $term ) {
+		$use_id = false;
+		if ( !is_object($term) ) {
+			$term = get_term($term, $taxonomy);
+			if ( is_wp_error( $term ) )
+				return $term;
+			$use_id = true;
+		}
+
+		if ( $term->term_id == $term_id )
+			continue;
+
+		if ( $term->parent == $term_id ) {
+			if ( $use_id )
+				$term_list[] = $term->term_id;
+			else
+				$term_list[] = $term;
+
+			if ( !isset($has_children[$term->term_id]) )
+				continue;
+
+			if ( $children = _get_term_children($term->term_id, $terms, $taxonomy) )
+				$term_list = array_merge($term_list, $children);
+		}
+	}
+
+	return $term_list;
+}
+
+
+/**
+ * Add count of children to parent count.
+ *
+ * Recalculates term counts by including items from child terms. Assumes all
+ * relevant children are already in the $terms argument.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @access private
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param array $terms List of Term IDs
+ * @param string $taxonomy Term Context
+ * @return null Will break from function if conditions are not met.
+ */
+function _pad_term_counts(&$terms, $taxonomy) {
+	global $wpdb;
+
+	// This function only works for hierarchical taxonomies like post categories.
+	if ( !is_taxonomy_hierarchical( $taxonomy ) )
+		return;
+
+	$term_hier = _get_term_hierarchy($taxonomy);
+
+	if ( empty($term_hier) )
+		return;
+
+	$term_items = array();
+
+	foreach ( (array) $terms as $key => $term ) {
+		$terms_by_id[$term->term_id] = & $terms[$key];
+		$term_ids[$term->term_taxonomy_id] = $term->term_id;
+	}
+
+	// Get the object and term ids and stick them in a lookup table
+	$tax_obj = get_taxonomy($taxonomy);
+	$object_types = esc_sql($tax_obj->object_type);
+	$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'");
+	foreach ( $results as $row ) {
+		$id = $term_ids[$row->term_taxonomy_id];
+		$term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;
+	}
+
+	// Touch every ancestor's lookup row for each post in each term
+	foreach ( $term_ids as $term_id ) {
+		$child = $term_id;
+		while ( $parent = $terms_by_id[$child]->parent ) {
+			if ( !empty($term_items[$term_id]) )
+				foreach ( $term_items[$term_id] as $item_id => $touches ) {
+					$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1;
+				}
+			$child = $parent;
+		}
+	}
+
+	// Transfer the touched cells
+	foreach ( (array) $term_items as $id => $items )
+		if ( isset($terms_by_id[$id]) )
+			$terms_by_id[$id]->count = count($items);
+}
+
+//
+// Default callbacks
+//
+
+/**
+ * Will update term count based on object types of the current taxonomy.
+ *
+ * Private function for the default callback for post_tag and category
+ * taxonomies.
+ *
+ * @package WordPress
+ * @subpackage Taxonomy
+ * @access private
+ * @since 2.3.0
+ * @uses $wpdb
+ *
+ * @param array $terms List of Term taxonomy IDs
+ * @param object $taxonomy Current taxonomy object of terms
+ */
+function _update_post_term_count( $terms, $taxonomy ) {
+	global $wpdb;
+
+	$object_types = is_array($taxonomy->object_type) ? $taxonomy->object_type : array($taxonomy->object_type);
+	$object_types = esc_sql($object_types);
+
+	foreach ( (array) $terms as $term ) {
+		$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types) . "') AND term_taxonomy_id = %d", $term ) );
+		do_action( 'edit_term_taxonomy', $term, $taxonomy );
+		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
+		do_action( 'edited_term_taxonomy', $term, $taxonomy );
+	}
+}
+
+
+/**
+ * Generates a permalink for a taxonomy term archive.
+ *
+ * @since 2.5.0
+ *
+ * @uses apply_filters() Calls 'term_link' with term link and term object, and taxonomy parameters.
+ * @uses apply_filters() For the post_tag Taxonomy, Calls 'tag_link' with tag link and tag ID as parameters.
+ * @uses apply_filters() For the category Taxonomy, Calls 'category_link' filter on category link and category ID.
+ *
+ * @param object|int|string $term
+ * @param string $taxonomy (optional if $term is object)
+ * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist.
+ */
+function get_term_link( $term, $taxonomy = '') {
+	global $wp_rewrite;
+
+	if ( !is_object($term) ) {
+		if ( is_int($term) ) {
+			$term = &get_term($term, $taxonomy);
+		} else {
+			$term = &get_term_by('slug', $term, $taxonomy);
+		}
+	}
+
+	if ( !is_object($term) )
+		$term = new WP_Error('invalid_term', __('Empty Term'));
+
+	if ( is_wp_error( $term ) )
+		return $term;
+
+	$taxonomy = $term->taxonomy;
+
+	$termlink = $wp_rewrite->get_extra_permastruct($taxonomy);
+
+	$slug = $term->slug;
+	$t = get_taxonomy($taxonomy);
+
+	if ( empty($termlink) ) {
+		if ( $t->query_var )
+			$termlink = "?$t->query_var=$slug";
+		else
+			$termlink = "?taxonomy=$taxonomy&term=$slug";
+		$termlink = home_url($termlink);
+	} else {
+		if ( $t->rewrite['hierarchical'] ) {
+			$hierarchical_slugs = array();
+			$ancestors = get_ancestors($term->term_id, $taxonomy);
+			foreach ( (array)$ancestors as $ancestor ) {
+				$ancestor_term = get_term($ancestor, $taxonomy);
+				$hierarchical_slugs[] = $ancestor_term->slug;
+			}
+			$hierarchical_slugs = array_reverse($hierarchical_slugs);
+			$hierarchical_slugs[] = $slug;
+			$termlink = str_replace("%$taxonomy%", implode('/', $hierarchical_slugs), $termlink);
+		} else {
+			$termlink = str_replace("%$taxonomy%", $slug, $termlink);
+		}
+		$termlink = home_url( user_trailingslashit($termlink, 'category') );
+	}
+	// Back Compat filters.
+	if ( 'post_tag' == $taxonomy )
+		$termlink = apply_filters( 'tag_link', $termlink, $term->term_id );
+	elseif ( 'category' == $taxonomy )
+		$termlink = apply_filters( 'category_link', $termlink, $term->term_id );
+
+	return apply_filters('term_link', $termlink, $term, $taxonomy);
+}
+
+/**
+ * Display the taxonomies of a post with available options.
+ *
+ * This function can be used within the loop to display the taxonomies for a
+ * post without specifying the Post ID. You can also use it outside the Loop to
+ * display the taxonomies for a specific post.
+ *
+ * The available defaults are:
+ * 'post' : default is 0. The post ID to get taxonomies of.
+ * 'before' : default is empty string. Display before taxonomies list.
+ * 'sep' : default is empty string. Separate every taxonomy with value in this.
+ * 'after' : default is empty string. Display this after the taxonomies list.
+ * 'template' : The template to use for displaying the taxonomy terms.
+ *
+ * @since 2.5.0
+ * @uses get_the_taxonomies()
+ *
+ * @param array $args Override the defaults.
+ */
+function the_taxonomies($args = array()) {
+	$defaults = array(
+		'post' => 0,
+		'before' => '',
+		'sep' => ' ',
+		'after' => '',
+		'template' => '%s: %l.'
+	);
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	echo $before . join($sep, get_the_taxonomies($post, $r)) . $after;
+}
+
+/**
+ * Retrieve all taxonomies associated with a post.
+ *
+ * This function can be used within the loop. It will also return an array of
+ * the taxonomies with links to the taxonomy and name.
+ *
+ * @since 2.5.0
+ *
+ * @param int $post Optional. Post ID or will use Global Post ID (in loop).
+ * @param array $args Override the defaults.
+ * @return array
+ */
+function get_the_taxonomies($post = 0, $args = array() ) {
+	if ( is_int($post) )
+		$post =& get_post($post);
+	elseif ( !is_object($post) )
+		$post =& $GLOBALS['post'];
+
+	$args = wp_parse_args( $args, array(
+		'template' => '%s: %l.',
+	) );
+	extract( $args, EXTR_SKIP );
+
+	$taxonomies = array();
+
+	if ( !$post )
+		return $taxonomies;
+
+	foreach ( get_object_taxonomies($post) as $taxonomy ) {
+		$t = (array) get_taxonomy($taxonomy);
+		if ( empty($t['label']) )
+			$t['label'] = $taxonomy;
+		if ( empty($t['args']) )
+			$t['args'] = array();
+		if ( empty($t['template']) )
+			$t['template'] = $template;
+
+		$terms = get_object_term_cache($post->ID, $taxonomy);
+		if ( empty($terms) )
+			$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
+
+		$links = array();
+
+		foreach ( $terms as $term )
+			$links[] = "<a href='" . esc_attr( get_term_link($term) ) . "'>$term->name</a>";
+
+		if ( $links )
+			$taxonomies[$taxonomy] = wp_sprintf($t['template'], $t['label'], $links, $terms);
+	}
+	return $taxonomies;
+}
+
+/**
+ * Retrieve all taxonomies of a post with just the names.
+ *
+ * @since 2.5.0
+ * @uses get_object_taxonomies()
+ *
+ * @param int $post Optional. Post ID
+ * @return array
+ */
+function get_post_taxonomies($post = 0) {
+	$post =& get_post($post);
+
+	return get_object_taxonomies($post);
+}
+
+/**
+ * Determine if the given object is associated with any of the given terms.
+ *
+ * The given terms are checked against the object's terms' term_ids, names and slugs.
+ * Terms given as integers will only be checked against the object's terms' term_ids.
+ * If no terms are given, determines if object is associated with any terms in the given taxonomy.
+ *
+ * @since 2.7.0
+ * @uses get_object_term_cache()
+ * @uses wp_get_object_terms()
+ *
+ * @param int $object_id ID of the object (post ID, link ID, ...)
+ * @param string $taxonomy Single taxonomy name
+ * @param int|string|array $terms Optional.  Term term_id, name, slug or array of said
+ * @return bool|WP_Error. WP_Error on input error.
+ */
+function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
+	if ( !$object_id = (int) $object_id )
+		return new WP_Error( 'invalid_object', __( 'Invalid object ID' ) );
+
+	$object_terms = get_object_term_cache( $object_id, $taxonomy );
+	if ( empty( $object_terms ) )
+		 $object_terms = wp_get_object_terms( $object_id, $taxonomy );
+
+	if ( is_wp_error( $object_terms ) )
+		return $object_terms;
+	if ( empty( $object_terms ) )
+		return false;
+	if ( empty( $terms ) )
+		return ( !empty( $object_terms ) );
+
+	$terms = (array) $terms;
+
+	if ( $ints = array_filter( $terms, 'is_int' ) )
+		$strs = array_diff( $terms, $ints );
+	else
+		$strs =& $terms;
+
+	foreach ( $object_terms as $object_term ) {
+		if ( $ints && in_array( $object_term->term_id, $ints ) ) return true; // If int, check against term_id
+		if ( $strs ) {
+			if ( in_array( $object_term->term_id, $strs ) ) return true;
+			if ( in_array( $object_term->name, $strs ) )    return true;
+			if ( in_array( $object_term->slug, $strs ) )    return true;
+		}
+	}
+
+	return false;
+}
+
+/**
+ * Determine if the given object type is associated with the given taxonomy.
+ *
+ * @since 3.0.0
+ * @uses get_object_taxonomies()
+ *
+ * @param string $object_type Object type string
+ * @param string $taxonomy Single taxonomy name
+ * @return bool True if object is associated with the taxonomy, otherwise false.
+ */
+function is_object_in_taxonomy($object_type, $taxonomy) {
+	$taxonomies = get_object_taxonomies($object_type);
+
+	if ( empty($taxonomies) )
+		return false;
+
+	if ( in_array($taxonomy, $taxonomies) )
+		return true;
+
+	return false;
+}
+
+/**
+ * Get an array of ancestor IDs for a given object.
+ *
+ * @param int $object_id The ID of the object
+ * @param string $object_type The type of object for which we'll be retrieving ancestors.
+ * @return array of ancestors from lowest to highest in the hierarchy.
+ */
+function get_ancestors($object_id = 0, $object_type = '') {
+	$object_id = (int) $object_id;
+
+	$ancestors = array();
+
+	if ( empty( $object_id ) ) {
+		return apply_filters('get_ancestors', $ancestors, $object_id, $object_type);
+	}
+
+	if ( is_taxonomy_hierarchical( $object_type ) ) {
+		$term = get_term($object_id, $object_type);
+		while ( ! is_wp_error($term) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors ) ) {
+			$ancestors[] = (int) $term->parent;
+			$term = get_term($term->parent, $object_type);
+		}
+	} elseif ( null !== get_post_type_object( $object_type ) ) {
+		$object = get_post($object_id);
+		if ( ! is_wp_error( $object ) && isset( $object->ancestors ) && is_array( $object->ancestors ) )
+			$ancestors = $object->ancestors;
+		else {
+			while ( ! is_wp_error($object) && ! empty( $object->post_parent ) && ! in_array( $object->post_parent, $ancestors ) ) {
+				$ancestors[] = (int) $object->post_parent;
+				$object = get_post($object->post_parent);
+			}
+		}
+	}
+
+	return apply_filters('get_ancestors', $ancestors, $object_id, $object_type);
+}
+
+/**
+ * Returns the term's parent's term_ID
+ *
+ * @since 3.1.0
+ *
+ * @param int $term_id
+ * @param string $taxonomy
+ *
+ * @return int|bool false on error
+ */
+function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
+	$term = get_term( $term_id, $taxonomy );
+	if ( !$term || is_wp_error( $term ) )
+		return false;
+	return (int) $term->parent;
+}
+
+/**
+ * Checks the given subset of the term hierarchy for hierarchy loops.
+ * Prevents loops from forming and breaks those that it finds.
+ *
+ * Attached to the wp_update_term_parent filter.
+ *
+ * @since 3.1.0
+ * @uses wp_find_hierarchy_loop()
+ *
+ * @param int $parent term_id of the parent for the term we're checking.
+ * @param int $term_id The term we're checking.
+ * @param string $taxonomy The taxonomy of the term we're checking.
+ *
+ * @return int The new parent for the term.
+ */
+function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
+	// Nothing fancy here - bail
+	if ( !$parent )
+		return 0;
+
+	// Can't be its own parent
+	if ( $parent == $term_id )
+		return 0;
+
+	// Now look for larger loops
+
+	if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) )
+		return $parent; // No loop
+
+	// Setting $parent to the given value causes a loop
+	if ( isset( $loop[$term_id] ) )
+		return 0;
+
+	// There's a loop, but it doesn't contain $term_id.  Break the loop.
+	foreach ( array_keys( $loop ) as $loop_member )
+		wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
+
+	return $parent;
+}
Index: /tags/3.1/wp-includes/template-loader.php
===================================================================
--- /tags/3.1/wp-includes/template-loader.php	(revision 17487)
+++ /tags/3.1/wp-includes/template-loader.php	(revision 17487)
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Loads the correct template based on the visitor's url
+ * @package WordPress
+ */
+if ( defined('WP_USE_THEMES') && WP_USE_THEMES )
+	do_action('template_redirect');
+
+// Process feeds and trackbacks even if not using themes.
+if ( is_robots() ) :
+	do_action('do_robots');
+	return;
+elseif ( is_feed() ) :
+	do_feed();
+	return;
+elseif ( is_trackback() ) :
+	include( ABSPATH . 'wp-trackback.php' );
+	return;
+endif;
+
+if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) :
+	$template = false;
+	if     ( is_404()            && $template = get_404_template()            ) :
+	elseif ( is_search()         && $template = get_search_template()         ) :
+	elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
+	elseif ( is_front_page()     && $template = get_front_page_template()     ) :
+	elseif ( is_home()           && $template = get_home_template()           ) :
+	elseif ( is_attachment()     && $template = get_attachment_template()     ) :
+		remove_filter('the_content', 'prepend_attachment');
+	elseif ( is_single()         && $template = get_single_template()         ) :
+	elseif ( is_page()           && $template = get_page_template()           ) :
+	elseif ( is_category()       && $template = get_category_template()       ) :
+	elseif ( is_tag()            && $template = get_tag_template()            ) :
+	elseif ( is_author()         && $template = get_author_template()         ) :
+	elseif ( is_date()           && $template = get_date_template()           ) :
+	elseif ( is_archive()        && $template = get_archive_template()        ) :
+	elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
+	elseif ( is_paged()          && $template = get_paged_template()          ) :
+	else :
+		$template = get_index_template();
+	endif;
+	if ( $template = apply_filters( 'template_include', $template ) )
+		include( $template );
+	return;
+endif;
+
+?>
Index: /tags/3.1/wp-includes/theme-compat/comments-popup.php
===================================================================
--- /tags/3.1/wp-includes/theme-compat/comments-popup.php	(revision 17487)
+++ /tags/3.1/wp-includes/theme-compat/comments-popup.php	(revision 17487)
@@ -0,0 +1,129 @@
+<?php
+/**
+ * @package WordPress
+ * @subpackage Theme_Compat
+ * @deprecated 3.0
+ *
+ * This file is here for Backwards compatibility with old themes and will be removed in a future version
+ *
+ */
+_deprecated_file( sprintf( __( 'Theme without %1$s' ), basename(__FILE__) ), '3.0', null, sprintf( __('Please include a %1$s template in your theme.'), basename(__FILE__) ) );
+?><!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><?php printf(__('%1$s - Comments on %2$s'), get_option('blogname'), the_title('','',false)); ?></title>
+
+	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
+	<style type="text/css" media="screen">
+		@import url( <?php bloginfo('stylesheet_url'); ?> );
+		body { margin: 3px; }
+	</style>
+
+</head>
+<body id="commentspopup">
+
+<h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1>
+
+<?php
+/* Don't remove these lines. */
+add_filter('comment_text', 'popuplinks');
+if ( have_posts() ) :
+while( have_posts()) : the_post();
+?>
+<h2 id="comments"><?php _e('Comments'); ?></h2>
+
+<p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.'); ?></a></p>
+
+<?php if ( pings_open() ) { ?>
+<p><?php printf(__('The <abbr title="Universal Resource Locator">URL</abbr> to TrackBack this entry is: <em>%s</em>'), get_trackback_url()); ?></p>
+<?php } ?>
+
+<?php
+// this line is WordPress' motor, do not delete it.
+$commenter = wp_get_current_commenter();
+extract($commenter);
+$comments = get_approved_comments($id);
+$post = get_post($id);
+if ( post_password_required($post) ) {  // and it doesn't match the cookie
+	echo(get_the_password_form());
+} else { ?>
+
+<?php if ($comments) { ?>
+<ol id="commentlist">
+<?php foreach ($comments as $comment) { ?>
+	<li id="comment-<?php comment_ID() ?>">
+	<?php comment_text() ?>
+	<p><cite><?php comment_type(); ?> <?php printf(__('by %1$s &#8212; %2$s @ <a href="#comment-%3$s">%4$s</a>'), get_comment_author_link(), get_comment_date(), get_comment_ID(), get_comment_time()); ?></cite></p>
+	</li>
+
+<?php } // end for each comment ?>
+</ol>
+<?php } else { // this is displayed if there are no comments so far ?>
+	<p><?php _e('No comments yet.'); ?></p>
+<?php } ?>
+
+<?php if ( comments_open() ) { ?>
+<h2><?php _e('Leave a comment'); ?></h2>
+<p><?php printf(__('Line and paragraph breaks automatic, e-mail address never displayed, <acronym title="Hypertext Markup Language">HTML</acronym> allowed: <code>%s</code>'), allowed_tags()); ?></p>
+
+<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
+<?php if ( $user_ID ) : ?>
+	<p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out &raquo;</a>'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity, wp_logout_url(get_permalink())); ?></p>
+<?php else : ?>
+	<p>
+	  <input type="text" name="author" id="author" class="textarea" value="<?php echo esc_attr($comment_author); ?>" size="28" tabindex="1" />
+	   <label for="author"><?php _e('Name'); ?></label>
+	</p>
+
+	<p>
+	  <input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="28" tabindex="2" />
+	   <label for="email"><?php _e('E-mail'); ?></label>
+	</p>
+
+	<p>
+	  <input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="28" tabindex="3" />
+	   <label for="url"><?php _e('<abbr title="Universal Resource Locator">URL</abbr>'); ?></label>
+	</p>
+<?php endif; ?>
+
+	<p>
+	  <label for="comment"><?php _e('Your Comment'); ?></label>
+	<br />
+	  <textarea name="comment" id="comment" cols="70" rows="4" tabindex="4"></textarea>
+	</p>
+
+	<p>
+	  <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
+	  <input type="hidden" name="redirect_to" value="<?php echo esc_attr($_SERVER["REQUEST_URI"]); ?>" />
+	  <input name="submit" type="submit" tabindex="5" value="<?php _e('Say It!' ); ?>" />
+	</p>
+	<?php do_action('comment_form', $post->ID); ?>
+</form>
+<?php } else { // comments are closed ?>
+<p><?php _e('Sorry, the comment form is closed at this time.'); ?></p>
+<?php }
+} // end password check
+?>
+
+<div><strong><a href="javascript:window.close()"><?php _e('Close this window.'); ?></a></strong></div>
+
+<?php // if you delete this the sky will fall on your head
+endwhile; // have_posts()
+else: // have_posts()
+?>
+<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
+<?php endif; ?>
+<!-- // this is just the end of the motor - don't touch that line either :) -->
+<?php //} ?>
+<p class="credit"><?php timer_stop(1); ?> <cite><?php printf(__('Powered by <a href="%s" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>WordPress</strong></a>'), 'http://wordpress.org/'); ?></cite></p>
+<?php // Seen at http://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18) ?>
+<script type="text/javascript">
+<!--
+document.onkeypress = function esc(e) {
+	if(typeof(e) == "undefined") { e=event; }
+	if (e.keyCode == 27) { self.close(); }
+}
+// -->
+</script>
+</body>
+</html>
Index: /tags/3.1/wp-includes/theme-compat/comments.php
===================================================================
--- /tags/3.1/wp-includes/theme-compat/comments.php	(revision 17487)
+++ /tags/3.1/wp-includes/theme-compat/comments.php	(revision 17487)
@@ -0,0 +1,102 @@
+<?php
+/**
+ * @package WordPress
+ * @subpackage Theme_Compat
+ * @deprecated 3.0
+ *
+ * This file is here for Backwards compatibility with old themes and will be removed in a future version
+ *
+ */
+_deprecated_file( sprintf( __( 'Theme without %1$s' ), basename(__FILE__) ), '3.0', null, sprintf( __('Please include a %1$s template in your theme.'), basename(__FILE__) ) );
+
+// Do not delete these lines
+	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
+		die ('Please do not load this page directly. Thanks!');
+
+	if ( post_password_required() ) { ?>
+		<p class="nocomments"><?php _e('This post is password protected. Enter the password to view comments.'); ?></p>
+	<?php
+		return;
+	}
+?>
+
+<!-- You can start editing here. -->
+
+<?php if ( have_comments() ) : ?>
+	<h3 id="comments"><?php	printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number() ),
+									number_format_i18n( get_comments_number() ), '&#8220;' . get_the_title() . '&#8221;' ); ?></h3>
+
+	<div class="navigation">
+		<div class="alignleft"><?php previous_comments_link() ?></div>
+		<div class="alignright"><?php next_comments_link() ?></div>
+	</div>
+
+	<ol class="commentlist">
+	<?php wp_list_comments();?>
+	</ol>
+
+	<div class="navigation">
+		<div class="alignleft"><?php previous_comments_link() ?></div>
+		<div class="alignright"><?php next_comments_link() ?></div>
+	</div>
+ <?php else : // this is displayed if there are no comments so far ?>
+
+	<?php if ( comments_open() ) : ?>
+		<!-- If comments are open, but there are no comments. -->
+
+	 <?php else : // comments are closed ?>
+		<!-- If comments are closed. -->
+		<p class="nocomments"><?php _e('Comments are closed.'); ?></p>
+
+	<?php endif; ?>
+<?php endif; ?>
+
+
+<?php if ( comments_open() ) : ?>
+
+<div id="respond">
+
+<h3><?php comment_form_title( __('Leave a Reply'), __('Leave a Reply to %s' ) ); ?></h3>
+
+<div id="cancel-comment-reply">
+	<small><?php cancel_comment_reply_link() ?></small>
+</div>
+
+<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
+<p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.'), wp_login_url( get_permalink() )); ?></p>
+<?php else : ?>
+
+<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
+
+<?php if ( is_user_logged_in() ) : ?>
+
+<p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>.'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out of this account'); ?>"><?php _e('Log out &raquo;'); ?></a></p>
+
+<?php else : ?>
+
+<p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
+<label for="author"><small><?php _e('Name'); ?> <?php if ($req) _e('(required)'); ?></small></label></p>
+
+<p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
+<label for="email"><small><?php _e('Mail (will not be published)'); ?> <?php if ($req) _e('(required)'); ?></small></label></p>
+
+<p><input type="text" name="url" id="url" value="<?php echo  esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
+<label for="url"><small><?php _e('Website'); ?></small></label></p>
+
+<?php endif; ?>
+
+<!--<p><small><?php printf(__('<strong>XHTML:</strong> You can use these tags: <code>%s</code>'), allowed_tags()); ?></small></p>-->
+
+<p><textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea></p>
+
+<p><input name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment'); ?>" />
+<?php comment_id_fields(); ?>
+</p>
+<?php do_action('comment_form', $post->ID); ?>
+
+</form>
+
+<?php endif; // If registration required and not logged in ?>
+</div>
+
+<?php endif; // if you delete this the sky will fall on your head ?>
Index: /tags/3.1/wp-includes/theme-compat/footer.php
===================================================================
--- /tags/3.1/wp-includes/theme-compat/footer.php	(revision 17487)
+++ /tags/3.1/wp-includes/theme-compat/footer.php	(revision 17487)
@@ -0,0 +1,30 @@
+<?php
+/**
+ * @package WordPress
+ * @subpackage Theme_Compat
+ * @deprecated 3.0
+ *
+ * This file is here for Backwards compatibility with old themes and will be removed in a future version
+ *
+ */
+_deprecated_file( sprintf( __( 'Theme without %1$s' ), basename(__FILE__) ), '3.0', null, sprintf( __('Please include a %1$s template in your theme.'), basename(__FILE__) ) );
+?>
+
+<hr />
+<div id="footer" role="contentinfo">
+<!-- If you'd like to support WordPress, having the "powered by" link somewhere on your blog is the best way; it's our only promotion or advertising. -->
+	<p>
+		<?php printf(__('%1$s is proudly powered by %2$s'), get_bloginfo('name'),
+		'<a href="http://wordpress.org/">WordPress</a>'); ?>
+		<br /><?php printf(__('%1$s and %2$s.'), '<a href="' . get_bloginfo('rss2_url') . '">' . __('Entries (RSS)') . '</a>', '<a href="' . get_bloginfo('comments_rss2_url') . '">' . __('Comments (RSS)') . '</a>'); ?>
+		<!-- <?php printf(__('%d queries. %s seconds.'), get_num_queries(), timer_stop(0, 3)); ?> -->
+	</p>
+</div>
+</div>
+
+<!-- Gorgeous design by Michael Heilemann - http://binarybonsai.com/kubrick/ -->
+<?php /* "Just what do you think you're doing Dave?" */ ?>
+
+		<?php wp_footer(); ?>
+</body>
+</html>
Index: /tags/3.1/wp-includes/theme-compat/header.php
===================================================================
--- /tags/3.1/wp-includes/theme-compat/header.php	(revision 17487)
+++ /tags/3.1/wp-includes/theme-compat/header.php	(revision 17487)
@@ -0,0 +1,50 @@
+<?php
+/**
+ * @package WordPress
+ * @subpackage Theme_Compat
+ * @deprecated 3.0
+ *
+ * This file is here for Backwards compatibility with old themes and will be removed in a future version
+ *
+ */
+_deprecated_file( sprintf( __( 'Theme without %1$s' ), basename(__FILE__) ), '3.0', null, sprintf( __('Please include a %1$s template in your theme.'), basename(__FILE__) ) );
+?>
+<!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 language_attributes(); ?>>
+
+<head profile="http://gmpg.org/xfn/11">
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
+
+<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
+
+<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
+<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
+
+<style type="text/css" media="screen">
+
+<?php
+// Checks to see whether it needs a sidebar
+if ( empty($withcomments) && !is_single() ) {
+?>
+	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg-<?php bloginfo('text_direction'); ?>.jpg") repeat-y top; border: none; }
+<?php } else { // No sidebar ?>
+	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
+<?php } ?>
+
+</style>
+
+<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
+
+<?php wp_head(); ?>
+</head>
+<body <?php body_class(); ?>>
+<div id="page">
+
+
+<div id="header" role="banner">
+	<div id="headerimg">
+		<h1><a href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a></h1>
+		<div class="description"><?php bloginfo('description'); ?></div>
+	</div>
+</div>
+<hr />
Index: /tags/3.1/wp-includes/theme-compat/sidebar.php
===================================================================
--- /tags/3.1/wp-includes/theme-compat/sidebar.php	(revision 17487)
+++ /tags/3.1/wp-includes/theme-compat/sidebar.php	(revision 17487)
@@ -0,0 +1,84 @@
+<?php
+/**
+ * @package WordPress
+ * @subpackage Theme_Compat
+ * @deprecated 3.0
+ *
+ * This file is here for Backwards compatibility with old themes and will be removed in a future version
+ *
+ */
+_deprecated_file( sprintf( __( 'Theme without %1$s' ), basename(__FILE__) ), '3.0', null, sprintf( __('Please include a %1$s template in your theme.'), basename(__FILE__) ) );
+?>
+	<div id="sidebar" role="complementary">
+		<ul>
+			<?php 	/* Widgetized sidebar, if you have the plugin installed. */
+					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
+			<li>
+				<?php get_search_form(); ?>
+			</li>
+
+			<!-- Author information is disabled per default. Uncomment and fill in your details if you want to use it.
+			<li><h2><?php _e('Author'); ?></h2>
+			<p>A little something about you, the author. Nothing lengthy, just an overview.</p>
+			</li>
+			-->
+
+			<?php if ( is_404() || is_category() || is_day() || is_month() ||
+						is_year() || is_search() || is_paged() ) {
+			?> <li>
+
+			<?php /* If this is a 404 page */ if (is_404()) { ?>
+			<?php /* If this is a category archive */ } elseif (is_category()) { ?>
+			<p><?php printf(__('You are currently browsing the archives for the %s category.'), single_cat_title('', false)); ?></p>
+
+			<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
+			<p><?php printf(__('You are currently browsing the <a href="%1$s/">%2$s</a> blog archives for the day %3$s.'), get_bloginfo('url'), get_bloginfo('name'), get_the_time(__('l, F jS, Y'))); ?></p>
+
+			<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
+			<p><?php printf(__('You are currently browsing the <a href="%1$s/">%2$s</a> blog archives for %3$s.'), get_bloginfo('url'), get_bloginfo('name'), get_the_time(__('F, Y'))); ?></p>
+
+			<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
+			<p><?php printf(__('You are currently browsing the <a href="%1$s/">%2$s</a> blog archives for the year %3$s.'), get_bloginfo('url'), get_bloginfo('name'), get_the_time('Y')); ?></p>
+
+			<?php /* If this is a search result */ } elseif (is_search()) { ?>
+			<p><?php printf(__('You have searched the <a href="%1$s/">%2$s</a> blog archives for <strong>&#8216;%3$s&#8217;</strong>. If you are unable to find anything in these search results, you can try one of these links.'), get_bloginfo('url'), get_bloginfo('name'), esc_html( get_search_query() ) ); ?></p>
+
+			<?php /* If this set is paginated */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
+			<p><?php printf(__('You are currently browsing the <a href="%1$s/">%2$s</a> blog archives.'), get_bloginfo('url'), get_bloginfo('name')); ?></p>
+
+			<?php } ?>
+
+			</li>
+		<?php }?>
+		</ul>
+		<ul role="navigation">
+			<?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>' ); ?>
+
+			<li><h2><?php _e('Archives'); ?></h2>
+				<ul>
+				<?php wp_get_archives(array('type' => 'monthly')); ?>
+				</ul>
+			</li>
+
+			<?php wp_list_categories(array('show_count' => 1, 'title_li' => '<h2>' . __('Categories') . '</h2>')); ?>
+		</ul>
+		<ul>
+			<?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
+				<?php wp_list_bookmarks(); ?>
+
+				<li><h2><?php _e('Meta'); ?></h2>
+				<ul>
+					<?php wp_register(); ?>
+					<li><?php wp_loginout(); ?></li>
+					<li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
+					<li><a href="http://gmpg.org/xfn/"><abbr title="<?php _e('XHTML Friends Network'); ?>"><?php _e('XFN'); ?></abbr></a></li>
+					<li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress, state-of-the-art semantic personal publishing platform.'); ?>">WordPress</a></li>
+					<?php wp_meta(); ?>
+				</ul>
+				</li>
+			<?php } ?>
+
+			<?php endif; ?>
+		</ul>
+	</div>
+
Index: /tags/3.1/wp-includes/theme.php
===================================================================
--- /tags/3.1/wp-includes/theme.php	(revision 17487)
+++ /tags/3.1/wp-includes/theme.php	(revision 17487)
@@ -0,0 +1,1882 @@
+<?php
+/**
+ * Theme, template, and stylesheet functions.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Whether a child theme is in use.
+ *
+ * @since 3.0.0
+ *
+ * @return bool true if a child theme is in use, false otherwise.
+ **/
+function is_child_theme() {
+	return ( TEMPLATEPATH !== STYLESHEETPATH );
+}
+
+/**
+ * Retrieve name of the current stylesheet.
+ *
+ * The theme name that the administrator has currently set the front end theme
+ * as.
+ *
+ * For all extensive purposes, the template name and the stylesheet name are
+ * going to be the same for most cases.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'stylesheet' filter on stylesheet name.
+ *
+ * @return string Stylesheet name.
+ */
+function get_stylesheet() {
+	return apply_filters('stylesheet', get_option('stylesheet'));
+}
+
+/**
+ * Retrieve stylesheet directory path for current theme.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'stylesheet_directory' filter on stylesheet directory and theme name.
+ *
+ * @return string Path to current theme directory.
+ */
+function get_stylesheet_directory() {
+	$stylesheet = get_stylesheet();
+	$theme_root = get_theme_root( $stylesheet );
+	$stylesheet_dir = "$theme_root/$stylesheet";
+
+	return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
+}
+
+/**
+ * Retrieve stylesheet directory URI.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_stylesheet_directory_uri() {
+	$stylesheet = get_stylesheet();
+	$theme_root_uri = get_theme_root_uri( $stylesheet );
+	$stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
+
+	return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
+}
+
+/**
+ * Retrieve URI of current theme stylesheet.
+ *
+ * The stylesheet file name is 'style.css' which is appended to {@link
+ * get_stylesheet_directory_uri() stylesheet directory URI} path.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.
+ *
+ * @return string
+ */
+function get_stylesheet_uri() {
+	$stylesheet_dir_uri = get_stylesheet_directory_uri();
+	$stylesheet_uri = $stylesheet_dir_uri . "/style.css";
+	return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
+}
+
+/**
+ * Retrieve localized stylesheet URI.
+ *
+ * The stylesheet directory for the localized stylesheet files are located, by
+ * default, in the base theme directory. The name of the locale file will be the
+ * locale followed by '.css'. If that does not exist, then the text direction
+ * stylesheet will be checked for existence, for example 'ltr.css'.
+ *
+ * The theme may change the location of the stylesheet directory by either using
+ * the 'stylesheet_directory_uri' filter or the 'locale_stylesheet_uri' filter.
+ * If you want to change the location of the stylesheet files for the entire
+ * WordPress workflow, then change the former. If you just have the locale in a
+ * separate folder, then change the latter.
+ *
+ * @since 2.1.0
+ * @uses apply_filters() Calls 'locale_stylesheet_uri' filter on stylesheet URI path and stylesheet directory URI.
+ *
+ * @return string
+ */
+function get_locale_stylesheet_uri() {
+	global $wp_locale;
+	$stylesheet_dir_uri = get_stylesheet_directory_uri();
+	$dir = get_stylesheet_directory();
+	$locale = get_locale();
+	if ( file_exists("$dir/$locale.css") )
+		$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
+	elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
+		$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
+	else
+		$stylesheet_uri = '';
+	return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
+}
+
+/**
+ * Retrieve name of the current theme.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'template' filter on template option.
+ *
+ * @return string Template name.
+ */
+function get_template() {
+	return apply_filters('template', get_option('template'));
+}
+
+/**
+ * Retrieve current theme directory.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'template_directory' filter on template directory path and template name.
+ *
+ * @return string Template directory path.
+ */
+function get_template_directory() {
+	$template = get_template();
+	$theme_root = get_theme_root( $template );
+	$template_dir = "$theme_root/$template";
+
+	return apply_filters( 'template_directory', $template_dir, $template, $theme_root );
+}
+
+/**
+ * Retrieve theme directory URI.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'template_directory_uri' filter on template directory URI path and template name.
+ *
+ * @return string Template directory URI.
+ */
+function get_template_directory_uri() {
+	$template = get_template();
+	$theme_root_uri = get_theme_root_uri( $template );
+	$template_dir_uri = "$theme_root_uri/$template";
+
+	return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
+}
+
+/**
+ * Retrieve theme data from parsed theme file.
+ *
+ * The description will have the tags filtered with the following HTML elements
+ * whitelisted. The <b>'a'</b> element with the <em>href</em> and <em>title</em>
+ * attributes. The <b>abbr</b> element with the <em>title</em> attribute. The
+ * <b>acronym</b> element with the <em>title</em> attribute allowed. The
+ * <b>code</b>, <b>em</b>, and <b>strong</b> elements also allowed.
+ *
+ * The style.css file must contain theme name, theme URI, and description. The
+ * data can also contain author URI, author, template (parent template),
+ * version, status, and finally tags. Some of these are not used by WordPress
+ * administration panels, but are used by theme directory web sites which list
+ * the theme.
+ *
+ * @since 1.5.0
+ *
+ * @param string $theme_file Theme file path.
+ * @return array Theme data.
+ */
+function get_theme_data( $theme_file ) {
+	$default_headers = array(
+		'Name' => 'Theme Name',
+		'URI' => 'Theme URI',
+		'Description' => 'Description',
+		'Author' => 'Author',
+		'AuthorURI' => 'Author URI',
+		'Version' => 'Version',
+		'Template' => 'Template',
+		'Status' => 'Status',
+		'Tags' => 'Tags'
+		);
+
+	$themes_allowed_tags = array(
+		'a' => array(
+			'href' => array(),'title' => array()
+			),
+		'abbr' => array(
+			'title' => array()
+			),
+		'acronym' => array(
+			'title' => array()
+			),
+		'code' => array(),
+		'em' => array(),
+		'strong' => array()
+	);
+
+	$theme_data = get_file_data( $theme_file, $default_headers, 'theme' );
+
+	$theme_data['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags );
+
+	$theme_data['URI'] = esc_url( $theme_data['URI'] );
+
+	$theme_data['Description'] = wptexturize( wp_kses( $theme_data['Description'], $themes_allowed_tags ) );
+
+	$theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] );
+
+	$theme_data['Template'] = wp_kses( $theme_data['Template'], $themes_allowed_tags );
+
+	$theme_data['Version'] = wp_kses( $theme_data['Version'], $themes_allowed_tags );
+
+	if ( $theme_data['Status'] == '' )
+		$theme_data['Status'] = 'publish';
+	else
+		$theme_data['Status'] = wp_kses( $theme_data['Status'], $themes_allowed_tags );
+
+	if ( $theme_data['Tags'] == '' )
+		$theme_data['Tags'] = array();
+	else
+		$theme_data['Tags'] = array_map( 'trim', explode( ',', wp_kses( $theme_data['Tags'], array() ) ) );
+
+	if ( $theme_data['Author'] == '' ) {
+		$theme_data['Author'] = $theme_data['AuthorName'] = __('Anonymous');
+	} else {
+		$theme_data['AuthorName'] = wp_kses( $theme_data['Author'], $themes_allowed_tags );
+		if ( empty( $theme_data['AuthorURI'] ) ) {
+			$theme_data['Author'] = $theme_data['AuthorName'];
+		} else {
+			$theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName'] );
+		}
+	}
+
+	return $theme_data;
+}
+
+/**
+ * Retrieve list of themes with theme data in theme directory.
+ *
+ * The theme is broken, if it doesn't have a parent theme and is missing either
+ * style.css and, or index.php. If the theme has a parent theme then it is
+ * broken, if it is missing style.css; index.php is optional. The broken theme
+ * list is saved in the {@link $wp_broken_themes} global, which is displayed on
+ * the theme list in the administration panels.
+ *
+ * @since 1.5.0
+ * @global array $wp_broken_themes Stores the broken themes.
+ * @global array $wp_themes Stores the working themes.
+ *
+ * @return array Theme list with theme data.
+ */
+function get_themes() {
+	global $wp_themes, $wp_broken_themes;
+
+	if ( isset($wp_themes) )
+		return $wp_themes;
+
+	if ( !$theme_files = search_theme_directories() )
+		return false;
+
+	asort( $theme_files );
+
+	$wp_themes = array();
+
+	foreach ( (array) $theme_files as $theme_file ) {
+		$theme_root = $theme_file['theme_root'];
+		$theme_file = $theme_file['theme_file'];
+
+		if ( !is_readable("$theme_root/$theme_file") ) {
+			$wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
+			continue;
+		}
+
+		$theme_data = get_theme_data("$theme_root/$theme_file");
+
+		$name        = $theme_data['Name'];
+		$title       = $theme_data['Title'];
+		$description = wptexturize($theme_data['Description']);
+		$version     = $theme_data['Version'];
+		$author      = $theme_data['Author'];
+		$template    = $theme_data['Template'];
+		$stylesheet  = dirname($theme_file);
+
+		$screenshot = false;
+		foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
+			if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
+				$screenshot = "screenshot.$ext";
+				break;
+			}
+		}
+
+		if ( empty($name) ) {
+			$name = dirname($theme_file);
+			$title = $name;
+		}
+
+		$parent_template = $template;
+
+		if ( empty($template) ) {
+			if ( file_exists("$theme_root/$stylesheet/index.php") )
+				$template = $stylesheet;
+			else
+				continue;
+		}
+
+		$template = trim( $template );
+
+		if ( !file_exists("$theme_root/$template/index.php") ) {
+			$parent_dir = dirname(dirname($theme_file));
+			if ( file_exists("$theme_root/$parent_dir/$template/index.php") ) {
+				$template = "$parent_dir/$template";
+				$template_directory = "$theme_root/$template";
+			} else {
+				/**
+				 * The parent theme doesn't exist in the current theme's folder or sub folder
+				 * so lets use the theme root for the parent template.
+				 */
+				if ( isset($theme_files[$template]) && file_exists( $theme_files[$template]['theme_root'] . "/$template/index.php" ) ) {
+					$template_directory = $theme_files[$template]['theme_root'] . "/$template";
+				} else {
+					if ( empty( $parent_template) )
+						$wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'), 'error' => 'no_template');
+					else
+						$wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => sprintf( __('The parent theme is missing. Please install the "%s" parent theme.'),  $parent_template ), 'error' => 'no_parent', 'parent' => $parent_template );
+					continue;
+				}
+
+			}
+		} else {
+			$template_directory = trim( $theme_root . '/' . $template );
+		}
+
+		$stylesheet_files = array();
+		$template_files = array();
+
+		$stylesheet_dir = @ dir("$theme_root/$stylesheet");
+		if ( $stylesheet_dir ) {
+			while ( ($file = $stylesheet_dir->read()) !== false ) {
+				if ( !preg_match('|^\.+$|', $file) ) {
+					if ( preg_match('|\.css$|', $file) )
+						$stylesheet_files[] = "$theme_root/$stylesheet/$file";
+					elseif ( preg_match('|\.php$|', $file) )
+						$template_files[] = "$theme_root/$stylesheet/$file";
+				}
+			}
+			@ $stylesheet_dir->close();
+		}
+
+		$template_dir = @ dir("$template_directory");
+		if ( $template_dir ) {
+			while ( ($file = $template_dir->read()) !== false ) {
+				if ( preg_match('|^\.+$|', $file) )
+					continue;
+				if ( preg_match('|\.php$|', $file) ) {
+					$template_files[] = "$template_directory/$file";
+				} elseif ( is_dir("$template_directory/$file") ) {
+					$template_subdir = @ dir("$template_directory/$file");
+					if ( !$template_subdir )
+						continue;
+					while ( ($subfile = $template_subdir->read()) !== false ) {
+						if ( preg_match('|^\.+$|', $subfile) )
+							continue;
+						if ( preg_match('|\.php$|', $subfile) )
+							$template_files[] = "$template_directory/$file/$subfile";
+					}
+					@ $template_subdir->close();
+				}
+			}
+			@ $template_dir->close();
+		}
+
+		//Make unique and remove duplicates when stylesheet and template are the same i.e. most themes
+		$template_files = array_unique($template_files);
+		$stylesheet_files = array_unique($stylesheet_files);
+
+		$template_dir = $template_directory;
+		$stylesheet_dir = $theme_root . '/' . $stylesheet;
+
+		if ( empty($template_dir) )
+			$template_dir = '/';
+		if ( empty($stylesheet_dir) )
+			$stylesheet_dir = '/';
+
+		// Check for theme name collision.  This occurs if a theme is copied to
+		// a new theme directory and the theme header is not updated.  Whichever
+		// theme is first keeps the name.  Subsequent themes get a suffix applied.
+		// The Twenty Ten, Default and Classic themes always trump their pretenders.
+		if ( isset($wp_themes[$name]) ) {
+			$trump_cards = array(
+				'classic'   => 'WordPress Classic',
+				'default'   => 'WordPress Default',
+				'twentyten' => 'Twenty Ten',
+			);
+			if ( isset( $trump_cards[ $stylesheet ] ) && $name == $trump_cards[ $stylesheet ] ) {
+				// If another theme has claimed to be one of our default themes, move
+				// them aside.
+				$suffix = $wp_themes[$name]['Stylesheet'];
+				$new_name = "$name/$suffix";
+				$wp_themes[$new_name] = $wp_themes[$name];
+				$wp_themes[$new_name]['Name'] = $new_name;
+			} else {
+				$name = "$name/$stylesheet";
+			}
+		}
+
+		$theme_roots[$stylesheet] = str_replace( WP_CONTENT_DIR, '', $theme_root );
+		$wp_themes[$name] = array(
+			'Name' => $name,
+			'Title' => $title,
+			'Description' => $description,
+			'Author' => $author,
+			'Author Name' => $theme_data['AuthorName'],
+			'Author URI' => $theme_data['AuthorURI'],
+			'Version' => $version,
+			'Template' => $template,
+			'Stylesheet' => $stylesheet,
+			'Template Files' => $template_files,
+			'Stylesheet Files' => $stylesheet_files,
+			'Template Dir' => $template_dir,
+			'Stylesheet Dir' => $stylesheet_dir,
+			'Status' => $theme_data['Status'],
+			'Screenshot' => $screenshot,
+			'Tags' => $theme_data['Tags'],
+			'Theme Root' => $theme_root,
+			'Theme Root URI' => str_replace( WP_CONTENT_DIR, content_url(), $theme_root ),
+		);
+	}
+
+	unset($theme_files);
+
+	/* Store theme roots in the DB */
+	if ( get_site_transient( 'theme_roots' ) != $theme_roots )
+		set_site_transient( 'theme_roots', $theme_roots, 7200 ); // cache for two hours
+	unset($theme_roots);
+
+	/* Resolve theme dependencies. */
+	$theme_names = array_keys( $wp_themes );
+	foreach ( (array) $theme_names as $theme_name ) {
+		$wp_themes[$theme_name]['Parent Theme'] = '';
+		if ( $wp_themes[$theme_name]['Stylesheet'] != $wp_themes[$theme_name]['Template'] ) {
+			foreach ( (array) $theme_names as $parent_theme_name ) {
+				if ( ($wp_themes[$parent_theme_name]['Stylesheet'] == $wp_themes[$parent_theme_name]['Template']) && ($wp_themes[$parent_theme_name]['Template'] == $wp_themes[$theme_name]['Template']) ) {
+					$wp_themes[$theme_name]['Parent Theme'] = $wp_themes[$parent_theme_name]['Name'];
+					break;
+				}
+			}
+		}
+	}
+
+	return $wp_themes;
+}
+
+/**
+ * Retrieve theme roots.
+ *
+ * @since 2.9.0
+ *
+ * @return array|string An arry of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
+ */
+function get_theme_roots() {
+	global $wp_theme_directories;
+
+	if ( count($wp_theme_directories) <= 1 )
+		return '/themes';
+
+	$theme_roots = get_site_transient( 'theme_roots' );
+	if ( false === $theme_roots ) {
+		get_themes();
+		$theme_roots = get_site_transient( 'theme_roots' ); // this is set in get_theme()
+	}
+	return $theme_roots;
+}
+
+/**
+ * Retrieve theme data.
+ *
+ * @since 1.5.0
+ *
+ * @param string $theme Theme name.
+ * @return array|null Null, if theme name does not exist. Theme data, if exists.
+ */
+function get_theme($theme) {
+	$themes = get_themes();
+
+	if ( array_key_exists($theme, $themes) )
+		return $themes[$theme];
+
+	return null;
+}
+
+/**
+ * Retrieve current theme display name.
+ *
+ * If the 'current_theme' option has already been set, then it will be returned
+ * instead. If it is not set, then each theme will be iterated over until both
+ * the current stylesheet and current template name.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_current_theme() {
+	if ( $theme = get_option('current_theme') )
+		return $theme;
+
+	$themes = get_themes();
+	$theme_names = array_keys($themes);
+	$current_template = get_option('template');
+	$current_stylesheet = get_option('stylesheet');
+	$current_theme = 'Twenty Ten';
+
+	if ( $themes ) {
+		foreach ( (array) $theme_names as $theme_name ) {
+			if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
+					$themes[$theme_name]['Template'] == $current_template ) {
+				$current_theme = $themes[$theme_name]['Name'];
+				break;
+			}
+		}
+	}
+
+	update_option('current_theme', $current_theme);
+
+	return $current_theme;
+}
+
+/**
+ * Register a directory that contains themes.
+ *
+ * @since 2.9.0
+ *
+ * @param string $directory Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR
+ * @return bool
+ */
+function register_theme_directory( $directory) {
+	global $wp_theme_directories;
+
+	/* If this folder does not exist, return and do not register */
+	if ( !file_exists( $directory ) )
+			/* Try prepending as the theme directory could be relative to the content directory */
+		$registered_directory = WP_CONTENT_DIR . '/' . $directory;
+	else
+		$registered_directory = $directory;
+
+	/* If this folder does not exist, return and do not register */
+	if ( !file_exists( $registered_directory ) )
+		return false;
+
+	$wp_theme_directories[] = $registered_directory;
+
+	return true;
+}
+
+/**
+ * Search all registered theme directories for complete and valid themes.
+ *
+ * @since 2.9.0
+ *
+ * @return array Valid themes found
+ */
+function search_theme_directories() {
+	global $wp_theme_directories, $wp_broken_themes;
+	if ( empty( $wp_theme_directories ) )
+		return false;
+
+	$theme_files = array();
+	$wp_broken_themes = array();
+
+	/* Loop the registered theme directories and extract all themes */
+	foreach ( (array) $wp_theme_directories as $theme_root ) {
+		$theme_loc = $theme_root;
+
+		/* We don't want to replace all forward slashes, see Trac #4541 */
+		if ( '/' != WP_CONTENT_DIR )
+			$theme_loc = str_replace(WP_CONTENT_DIR, '', $theme_root);
+
+		/* Files in the root of the current theme directory and one subdir down */
+		$themes_dir = @ opendir($theme_root);
+
+		if ( !$themes_dir )
+			return false;
+
+		while ( ($theme_dir = readdir($themes_dir)) !== false ) {
+			if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
+				if ( $theme_dir[0] == '.' || $theme_dir == 'CVS' )
+					continue;
+
+				$stylish_dir = @opendir($theme_root . '/' . $theme_dir);
+				$found_stylesheet = false;
+
+				while ( ($theme_file = readdir($stylish_dir)) !== false ) {
+					if ( $theme_file == 'style.css' ) {
+						$theme_files[$theme_dir] = array( 'theme_file' => $theme_dir . '/' . $theme_file, 'theme_root' => $theme_root );
+						$found_stylesheet = true;
+						break;
+					}
+				}
+				@closedir($stylish_dir);
+
+				if ( !$found_stylesheet ) { // look for themes in that dir
+					$subdir = "$theme_root/$theme_dir";
+					$subdir_name = $theme_dir;
+					$theme_subdirs = @opendir( $subdir );
+
+					$found_subdir_themes = false;
+					while ( ($theme_subdir = readdir($theme_subdirs)) !== false ) {
+						if ( is_dir( $subdir . '/' . $theme_subdir) && is_readable($subdir . '/' . $theme_subdir) ) {
+							if ( $theme_subdir[0] == '.' || $theme_subdir == 'CVS' )
+								continue;
+
+							$stylish_dir = @opendir($subdir . '/' . $theme_subdir);
+							$found_stylesheet = false;
+
+							while ( ($theme_file = readdir($stylish_dir)) !== false ) {
+								if ( $theme_file == 'style.css' ) {
+									$theme_files["$theme_dir/$theme_subdir"] = array( 'theme_file' => $subdir_name . '/' . $theme_subdir . '/' . $theme_file, 'theme_root' => $theme_root );
+									$found_stylesheet = true;
+									$found_subdir_themes = true;
+									break;
+								}
+							}
+							@closedir($stylish_dir);
+						}
+					}
+					@closedir($theme_subdirs);
+					if ( !$found_subdir_themes )
+						$wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
+				}
+			}
+		}
+		@closedir( $themes_dir );
+	}
+	return $theme_files;
+}
+
+/**
+ * Retrieve path to themes directory.
+ *
+ * Does not have trailing slash.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'theme_root' filter on path.
+ *
+ * @param string $stylesheet_or_template The stylesheet or template name of the theme
+ * @return string Theme path.
+ */
+function get_theme_root( $stylesheet_or_template = false ) {
+	if ( $stylesheet_or_template ) {
+		if ( $theme_root = get_raw_theme_root($stylesheet_or_template) )
+			$theme_root = WP_CONTENT_DIR . $theme_root;
+		else
+			$theme_root = WP_CONTENT_DIR . '/themes';
+	} else {
+		$theme_root = WP_CONTENT_DIR . '/themes';
+	}
+
+	return apply_filters( 'theme_root', $theme_root );
+}
+
+/**
+ * Retrieve URI for themes directory.
+ *
+ * Does not have trailing slash.
+ *
+ * @since 1.5.0
+ *
+ * @param string $stylesheet_or_template The stylesheet or template name of the theme
+ * @return string Themes URI.
+ */
+function get_theme_root_uri( $stylesheet_or_template = false ) {
+	if ( $stylesheet_or_template ) {
+		if ( $theme_root = get_raw_theme_root($stylesheet_or_template) )
+			$theme_root_uri = content_url( $theme_root );
+		else
+			$theme_root_uri = content_url( 'themes' );
+	} else {
+		$theme_root_uri = content_url( 'themes' );
+	}
+
+	return apply_filters( 'theme_root_uri', $theme_root_uri, get_option('siteurl'), $stylesheet_or_template );
+}
+
+/**
+ * Get the raw theme root relative to the content directory with no filters applied.
+ *
+ * @since 3.1.0
+ *
+ * @param string $stylesheet_or_template The stylesheet or template name of the theme
+ * @return string Theme root
+ */
+function get_raw_theme_root( $stylesheet_or_template, $no_cache = false ) {
+	global $wp_theme_directories;
+
+	if ( count($wp_theme_directories) <= 1 )
+		return '/themes';
+
+	$theme_root = false;
+
+	// If requesting the root for the current theme, consult options to avoid calling get_theme_roots()
+	if ( !$no_cache ) {
+		if ( get_option('stylesheet') == $stylesheet_or_template )
+			$theme_root = get_option('stylesheet_root');
+		elseif ( get_option('template') == $stylesheet_or_template )
+			$theme_root = get_option('template_root');
+	}
+
+	if ( empty($theme_root) ) {
+		$theme_roots = get_theme_roots();
+		if ( !empty($theme_roots[$stylesheet_or_template]) )
+			$theme_root = $theme_roots[$stylesheet_or_template];
+	}
+
+	return $theme_root;
+}
+
+/**
+ * Retrieve path to a template
+ *
+ * Used to quickly retrieve the path of a template without including the file
+ * extension. It will also check the parent theme, if the file exists, with
+ * the use of {@link locate_template()}. Allows for more generic template location
+ * without the use of the other get_*_template() functions.
+ *
+ * @since 1.5.0
+ *
+ * @param string $type Filename without extension.
+ * @param array $templates An optional list of template candidates
+ * @return string Full path to file.
+ */
+function get_query_template( $type, $templates = array() ) {
+	$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
+
+	if ( empty( $templates ) )
+		$templates = array("{$type}.php");
+
+	return apply_filters( "{$type}_template", locate_template( $templates ) );
+}
+
+/**
+ * Retrieve path of index template in current or parent template.
+ *
+ * @since 3.0.0
+ *
+ * @return string
+ */
+function get_index_template() {
+	return get_query_template('index');
+}
+
+/**
+ * Retrieve path of 404 template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_404_template() {
+	return get_query_template('404');
+}
+
+/**
+ * Retrieve path of archive template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_archive_template() {
+	$post_type = get_query_var( 'post_type' );
+
+	$templates = array();
+
+	if ( $post_type )
+		$templates[] = "archive-{$post_type}.php";
+	$templates[] = 'archive.php';
+
+	return get_query_template( 'archive', $templates );
+}
+
+/**
+ * Retrieve path of author template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_author_template() {
+	$author = get_queried_object();
+
+	$templates = array();
+
+	$templates[] = "author-{$author->user_nicename}.php";
+	$templates[] = "author-{$author->ID}.php";
+	$templates[] = 'author.php';
+
+	return get_query_template( 'author', $templates );
+}
+
+/**
+ * Retrieve path of category template in current or parent template.
+ *
+ * Works by first retrieving the current slug for example 'category-default.php' and then
+ * trying category ID, for example 'category-1.php' and will finally fallback to category.php
+ * template, if those files don't exist.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'category_template' on file path of category template.
+ *
+ * @return string
+ */
+function get_category_template() {
+	$category = get_queried_object();
+
+	$templates = array();
+
+	$templates[] = "category-{$category->slug}.php";
+	$templates[] = "category-{$category->term_id}.php";
+	$templates[] = "category.php";
+
+	return get_query_template( 'category', $templates );
+}
+
+/**
+ * Retrieve path of tag template in current or parent template.
+ *
+ * Works by first retrieving the current tag name, for example 'tag-wordpress.php' and then
+ * trying tag ID, for example 'tag-1.php' and will finally fallback to tag.php
+ * template, if those files don't exist.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'tag_template' on file path of tag template.
+ *
+ * @return string
+ */
+function get_tag_template() {
+	$tag = get_queried_object();
+
+	$templates = array();
+
+	$templates[] = "tag-{$tag->slug}.php";
+	$templates[] = "tag-{$tag->term_id}.php";
+	$templates[] = "tag.php";
+
+	return get_query_template( 'tag', $templates );
+}
+
+/**
+ * Retrieve path of taxonomy template in current or parent template.
+ *
+ * Retrieves the taxonomy and term, if term is available. The template is
+ * prepended with 'taxonomy-' and followed by both the taxonomy string and
+ * the taxonomy string followed by a dash and then followed by the term.
+ *
+ * The taxonomy and term template is checked and used first, if it exists.
+ * Second, just the taxonomy template is checked, and then finally, taxonomy.php
+ * template is used. If none of the files exist, then it will fall back on to
+ * index.php.
+ *
+ * @since 2.5.0
+ * @uses apply_filters() Calls 'taxonomy_template' filter on found path.
+ *
+ * @return string
+ */
+function get_taxonomy_template() {
+	$term = get_queried_object();
+	$taxonomy = $term->taxonomy;
+
+	$templates = array();
+
+	$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
+	$templates[] = "taxonomy-$taxonomy.php";
+	$templates[] = "taxonomy.php";
+
+	return get_query_template( 'taxonomy', $templates );
+}
+
+/**
+ * Retrieve path of date template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_date_template() {
+	return get_query_template('date');
+}
+
+/**
+ * Retrieve path of home template in current or parent template.
+ *
+ * This is the template used for the page containing the blog posts
+ *
+ * Attempts to locate 'home.php' first before falling back to 'index.php'.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'home_template' on file path of home template.
+ *
+ * @return string
+ */
+function get_home_template() {
+	$templates = array( 'home.php', 'index.php' );
+
+	return get_query_template( 'home', $templates );
+}
+
+/**
+ * Retrieve path of front-page template in current or parent template.
+ *
+ * Looks for 'front-page.php'.
+ *
+ * @since 3.0.0
+ * @uses apply_filters() Calls 'front_page_template' on file path of template.
+ *
+ * @return string
+ */
+function get_front_page_template() {
+	$templates = array('front-page.php');
+
+	return get_query_template( 'front_page', $templates );
+}
+
+/**
+ * Retrieve path of page template in current or parent template.
+ *
+ * Will first look for the specifically assigned page template
+ * The will search for 'page-{slug}.php' followed by 'page-id.php'
+ * and finally 'page.php'
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_page_template() {
+	$id = get_queried_object_id();
+	$template = get_post_meta($id, '_wp_page_template', true);
+	$pagename = get_query_var('pagename');
+
+	if ( !$pagename && $id > 0 ) {
+		// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
+		$post = get_queried_object();
+		$pagename = $post->post_name;
+	}
+
+	if ( 'default' == $template )
+		$template = '';
+
+	$templates = array();
+	if ( !empty($template) && !validate_file($template) )
+		$templates[] = $template;
+	if ( $pagename )
+		$templates[] = "page-$pagename.php";
+	if ( $id )
+		$templates[] = "page-$id.php";
+	$templates[] = "page.php";
+
+	return get_query_template( 'page', $templates );
+}
+
+/**
+ * Retrieve path of paged template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_paged_template() {
+	return get_query_template('paged');
+}
+
+/**
+ * Retrieve path of search template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_search_template() {
+	return get_query_template('search');
+}
+
+/**
+ * Retrieve path of single template in current or parent template.
+ *
+ * @since 1.5.0
+ *
+ * @return string
+ */
+function get_single_template() {
+	$object = get_queried_object();
+
+	$templates = array();
+
+	$templates[] = "single-{$object->post_type}.php";
+	$templates[] = "single.php";
+
+	return get_query_template( 'single', $templates );
+}
+
+/**
+ * Retrieve path of attachment template in current or parent template.
+ *
+ * The attachment path first checks if the first part of the mime type exists.
+ * The second check is for the second part of the mime type. The last check is
+ * for both types separated by an underscore. If neither are found then the file
+ * 'attachment.php' is checked and returned.
+ *
+ * Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and
+ * finally 'text_plain.php'.
+ *
+ * @since 2.0.0
+ *
+ * @return string
+ */
+function get_attachment_template() {
+	global $posts;
+	$type = explode('/', $posts[0]->post_mime_type);
+	if ( $template = get_query_template($type[0]) )
+		return $template;
+	elseif ( $template = get_query_template($type[1]) )
+		return $template;
+	elseif ( $template = get_query_template("$type[0]_$type[1]") )
+		return $template;
+	else
+		return get_query_template('attachment');
+}
+
+/**
+ * Retrieve path of comment popup template in current or parent template.
+ *
+ * Checks for comment popup template in current template, if it exists or in the
+ * parent template.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'comments_popup_template' filter on path.
+ *
+ * @return string
+ */
+function get_comments_popup_template() {
+	$template = get_query_template( 'comments_popup', array( 'comments-popup.php' ) );
+
+	// Backward compat code will be removed in a future release
+	if ('' == $template)
+		$template = ABSPATH . WPINC . '/theme-compat/comments-popup.php';
+
+	return $template;
+}
+
+/**
+ * Retrieve the name of the highest priority template file that exists.
+ *
+ * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which
+ * inherit from a parent theme can just overload one file.
+ *
+ * @since 2.7.0
+ *
+ * @param string|array $template_names Template file(s) to search for, in order.
+ * @param bool $load If true the template file will be loaded if it is found.
+ * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false.
+ * @return string The template filename if one is located.
+ */
+function locate_template($template_names, $load = false, $require_once = true ) {
+	$located = '';
+	foreach ( (array) $template_names as $template_name ) {
+		if ( !$template_name )
+			continue;
+		if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
+			$located = STYLESHEETPATH . '/' . $template_name;
+			break;
+		} else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
+			$located = TEMPLATEPATH . '/' . $template_name;
+			break;
+		}
+	}
+
+	if ( $load && '' != $located )
+		load_template( $located, $require_once );
+
+	return $located;
+}
+
+/**
+ * Require the template file with WordPress environment.
+ *
+ * The globals are set up for the template file to ensure that the WordPress
+ * environment is available from within the function. The query variables are
+ * also available.
+ *
+ * @since 1.5.0
+ *
+ * @param string $_template_file Path to template file.
+ * @param bool $require_once Whether to require_once or require. Default true.
+ */
+function load_template( $_template_file, $require_once = true ) {
+	global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
+
+	if ( is_array( $wp_query->query_vars ) )
+		extract( $wp_query->query_vars, EXTR_SKIP );
+
+	if ( $require_once )
+		require_once( $_template_file );
+	else
+		require( $_template_file );
+}
+
+/**
+ * Display localized stylesheet link element.
+ *
+ * @since 2.1.0
+ */
+function locale_stylesheet() {
+	$stylesheet = get_locale_stylesheet_uri();
+	if ( empty($stylesheet) )
+		return;
+	echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
+}
+
+/**
+ * Start preview theme output buffer.
+ *
+ * Will only preform task if the user has permissions and template and preview
+ * query variables exist.
+ *
+ * @since 2.6.0
+ */
+function preview_theme() {
+	if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )
+		return;
+
+	if ( !current_user_can( 'switch_themes' ) )
+		return;
+
+	// Admin Thickbox requests
+	if ( isset( $_GET['preview_iframe'] ) )
+		show_admin_bar( false );
+
+	$_GET['template'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['template']);
+
+	if ( validate_file($_GET['template']) )
+		return;
+
+	add_filter( 'template', '_preview_theme_template_filter' );
+
+	if ( isset($_GET['stylesheet']) ) {
+		$_GET['stylesheet'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['stylesheet']);
+		if ( validate_file($_GET['stylesheet']) )
+			return;
+		add_filter( 'stylesheet', '_preview_theme_stylesheet_filter' );
+	}
+
+	// Prevent theme mods to current theme being used on theme being previewed
+	add_filter( 'pre_option_mods_' . get_current_theme(), '__return_empty_array' );
+
+	ob_start( 'preview_theme_ob_filter' );
+}
+add_action('setup_theme', 'preview_theme');
+
+/**
+ * Private function to modify the current template when previewing a theme
+ *
+ * @since 2.9.0
+ * @access private
+ *
+ * @return string
+ */
+function _preview_theme_template_filter() {
+	return isset($_GET['template']) ? $_GET['template'] : '';
+}
+
+/**
+ * Private function to modify the current stylesheet when previewing a theme
+ *
+ * @since 2.9.0
+ * @access private
+ *
+ * @return string
+ */
+function _preview_theme_stylesheet_filter() {
+	return isset($_GET['stylesheet']) ? $_GET['stylesheet'] : '';
+}
+
+/**
+ * Callback function for ob_start() to capture all links in the theme.
+ *
+ * @since 2.6.0
+ * @access private
+ *
+ * @param string $content
+ * @return string
+ */
+function preview_theme_ob_filter( $content ) {
+	return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
+}
+
+/**
+ * Manipulates preview theme links in order to control and maintain location.
+ *
+ * Callback function for preg_replace_callback() to accept and filter matches.
+ *
+ * @since 2.6.0
+ * @access private
+ *
+ * @param array $matches
+ * @return string
+ */
+function preview_theme_ob_filter_callback( $matches ) {
+	if ( strpos($matches[4], 'onclick') !== false )
+		$matches[4] = preg_replace('#onclick=([\'"]).*?(?<!\\\)\\1#i', '', $matches[4]); //Strip out any onclicks from rest of <a>. (?<!\\\) means to ignore the '" if its escaped by \  to prevent breaking mid-attribute.
+	if (
+		( false !== strpos($matches[3], '/wp-admin/') )
+	||
+		( false !== strpos( $matches[3], '://' ) && 0 !== strpos( $matches[3], home_url() ) )
+	||
+		( false !== strpos($matches[3], '/feed/') )
+	||
+		( false !== strpos($matches[3], '/trackback/') )
+	)
+		return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
+
+	$link = add_query_arg( array('preview' => 1, 'template' => $_GET['template'], 'stylesheet' => @$_GET['stylesheet'] ), $matches[3] );
+	if ( 0 === strpos($link, 'preview=1') )
+		$link = "?$link";
+	return $matches[1] . esc_attr( $link ) . $matches[4];
+}
+
+/**
+ * Switches current theme to new template and stylesheet names.
+ *
+ * @since 2.5.0
+ * @uses do_action() Calls 'switch_theme' action on updated theme display name.
+ *
+ * @param string $template Template name
+ * @param string $stylesheet Stylesheet name.
+ */
+function switch_theme($template, $stylesheet) {
+	global $wp_theme_directories;
+
+	update_option('template', $template);
+	update_option('stylesheet', $stylesheet);
+	if ( count($wp_theme_directories) > 1 ) {
+		update_option('template_root', get_raw_theme_root($template, true));
+		update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
+	}
+	delete_option('current_theme');
+	$theme = get_current_theme();
+	if ( is_admin() && false === get_option( "theme_mods_$stylesheet" ) ) {
+		$default_theme_mods = (array) get_option( "mods_$theme" );
+		add_option( "theme_mods_$stylesheet", $default_theme_mods );
+	}
+	do_action('switch_theme', $theme);
+}
+
+/**
+ * Checks that current theme files 'index.php' and 'style.css' exists.
+ *
+ * Does not check the default theme, which is the fallback and should always exist.
+ * Will switch theme to the fallback theme if current theme does not validate.
+ * You can use the 'validate_current_theme' filter to return FALSE to
+ * disable this functionality.
+ *
+ * @since 1.5.0
+ * @see WP_DEFAULT_THEME
+ *
+ * @return bool
+ */
+function validate_current_theme() {
+	// Don't validate during an install/upgrade.
+	if ( defined('WP_INSTALLING') || !apply_filters( 'validate_current_theme', true ) )
+		return true;
+
+	if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) {
+		switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
+		return false;
+	}
+
+	if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) {
+		switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
+		return false;
+	}
+
+	if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
+		switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
+		return false;
+	}
+
+	return true;
+}
+
+/**
+ * Retrieve all theme modifications.
+ *
+ * @since 3.1.0
+ *
+ * @return array Theme modifications.
+ */
+function get_theme_mods() {
+	$theme_slug = get_option( 'stylesheet' );
+	if ( false === ( $mods = get_option( "theme_mods_$theme_slug" ) ) ) {
+		$theme_name = get_current_theme();
+		$mods = get_option( "mods_$theme_name" ); // Deprecated location.
+		if ( is_admin() && false !== $mods ) {
+			update_option( "theme_mods_$theme_slug", $mods );
+			delete_option( "mods_$theme_name" );
+		}
+	}
+	return $mods;
+}
+
+/**
+ * Retrieve theme modification value for the current theme.
+ *
+ * If the modification name does not exist, then the $default will be passed
+ * through {@link http://php.net/sprintf sprintf()} PHP function with the first
+ * string the template directory URI and the second string the stylesheet
+ * directory URI.
+ *
+ * @since 2.1.0
+ * @uses apply_filters() Calls 'theme_mod_$name' filter on the value.
+ *
+ * @param string $name Theme modification name.
+ * @param bool|string $default
+ * @return string
+ */
+function get_theme_mod( $name, $default = false ) {
+	$mods = get_theme_mods();
+
+	if ( isset( $mods[ $name ] ) )
+		return apply_filters( "theme_mod_$name", $mods[ $name ] );
+
+	return apply_filters( "theme_mod_$name", sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ) );
+}
+
+/**
+ * Update theme modification value for the current theme.
+ *
+ * @since 2.1.0
+ *
+ * @param string $name Theme modification name.
+ * @param string $value theme modification value.
+ */
+function set_theme_mod( $name, $value ) {
+	$mods = get_theme_mods();
+
+	$mods[ $name ] = $value;
+
+	$theme = get_option( 'stylesheet' );
+	update_option( "theme_mods_$theme", $mods );
+}
+
+/**
+ * Remove theme modification name from current theme list.
+ *
+ * If removing the name also removes all elements, then the entire option will
+ * be removed.
+ *
+ * @since 2.1.0
+ *
+ * @param string $name Theme modification name.
+ * @return null
+ */
+function remove_theme_mod( $name ) {
+	$mods = get_theme_mods();
+
+	if ( ! isset( $mods[ $name ] ) )
+		return;
+
+	unset( $mods[ $name ] );
+
+	if ( empty( $mods ) )
+		return remove_theme_mods();
+
+	$theme = get_option( 'stylesheet' );
+	update_option( "theme_mods_$theme", $mods );
+}
+
+/**
+ * Remove theme modifications option for current theme.
+ *
+ * @since 2.1.0
+ */
+function remove_theme_mods() {
+	delete_option( 'theme_mods_' . get_option( 'stylesheet' ) );
+	delete_option( 'mods_' . get_current_theme() );
+}
+
+/**
+ * Retrieve text color for custom header.
+ *
+ * @since 2.1.0
+ * @uses HEADER_TEXTCOLOR
+ *
+ * @return string
+ */
+function get_header_textcolor() {
+	$default = defined('HEADER_TEXTCOLOR') ? HEADER_TEXTCOLOR : '';
+
+	return get_theme_mod('header_textcolor', $default);
+}
+
+/**
+ * Display text color for custom header.
+ *
+ * @since 2.1.0
+ */
+function header_textcolor() {
+	echo get_header_textcolor();
+}
+
+/**
+ * Retrieve header image for custom header.
+ *
+ * @since 2.1.0
+ * @uses HEADER_IMAGE
+ *
+ * @return string
+ */
+function get_header_image() {
+	$default = defined( 'HEADER_IMAGE' ) ? HEADER_IMAGE : '';
+
+	$url = get_theme_mod( 'header_image', $default );
+
+	if ( is_ssl() )
+		$url = str_replace( 'http://', 'https://', $url );
+	else
+		$url = str_replace( 'https://', 'http://', $url );
+
+	return $url;
+}
+
+/**
+ * Display header image path.
+ *
+ * @since 2.1.0
+ */
+function header_image() {
+	echo get_header_image();
+}
+
+/**
+ * Add callbacks for image header display.
+ *
+ * The parameter $header_callback callback will be required to display the
+ * content for the 'wp_head' action. The parameter $admin_header_callback
+ * callback will be added to Custom_Image_Header class and that will be added
+ * to the 'admin_menu' action.
+ *
+ * @since 2.1.0
+ * @uses Custom_Image_Header Sets up for $admin_header_callback for administration panel display.
+ *
+ * @param callback $header_callback Call on 'wp_head' action.
+ * @param callback $admin_header_callback Call on custom header administration screen.
+ * @param callback $admin_image_div_callback Output a custom header image div on the custom header administration screen. Optional.
+ */
+function add_custom_image_header( $header_callback, $admin_header_callback, $admin_image_div_callback = '' ) {
+	if ( ! empty( $header_callback ) )
+		add_action('wp_head', $header_callback);
+
+	add_theme_support( 'custom-header', array( 'callback' => $header_callback ) );
+	add_theme_support( 'custom-header-uploads' );
+
+	if ( ! is_admin() )
+		return;
+
+	global $custom_image_header;
+
+	require_once( ABSPATH . 'wp-admin/custom-header.php' );
+	$custom_image_header = new Custom_Image_Header( $admin_header_callback, $admin_image_div_callback );
+	add_action( 'admin_menu', array( &$custom_image_header, 'init' ) );
+}
+
+/**
+ * Remove image header support.
+ *
+ * @since 3.1.0
+ * @see add_custom_image_header()
+ *
+ * @return bool Whether support was removed.
+ */
+function remove_custom_image_header() {
+	if ( ! current_theme_supports( 'custom-header' ) )
+		return false;
+
+	$callback = get_theme_support( 'custom-header' );
+	remove_action( 'wp_head', $callback[0]['callback'] );
+	_remove_theme_support( 'custom-header' );
+	remove_theme_support( 'custom-header-uploads' );
+
+	if ( is_admin() ) {
+		remove_action( 'admin_menu', array( &$GLOBALS['custom_image_header'], 'init' ) );
+		unset( $GLOBALS['custom_image_header'] );
+	}
+
+	return true;
+}
+
+/**
+ * Register a selection of default headers to be displayed by the custom header admin UI.
+ *
+ * @since 3.0.0
+ *
+ * @param array $headers Array of headers keyed by a string id. The ids point to arrays containing 'url', 'thumbnail_url', and 'description' keys.
+ */
+function register_default_headers( $headers ) {
+	global $_wp_default_headers;
+
+	$_wp_default_headers = array_merge( (array) $_wp_default_headers, (array) $headers );
+}
+
+/**
+ * Unregister default headers.
+ *
+ * This function must be called after register_default_headers() has already added the
+ * header you want to remove.
+ *
+ * @see register_default_headers()
+ * @since 3.0.0
+ *
+ * @param string|array $header The header string id (key of array) to remove, or an array thereof.
+ * @return True on success, false on failure.
+ */
+function unregister_default_headers( $header ) {
+	global $_wp_default_headers;
+	if ( is_array( $header ) ) {
+		array_map( 'unregister_default_headers', $header );
+	} elseif ( isset( $_wp_default_headers[ $header ] ) ) {
+		unset( $_wp_default_headers[ $header ] );
+		return true;
+	} else {
+		return false;
+	}
+}
+
+/**
+ * Retrieve background image for custom background.
+ *
+ * @since 3.0.0
+ *
+ * @return string
+ */
+function get_background_image() {
+	$default = defined('BACKGROUND_IMAGE') ? BACKGROUND_IMAGE : '';
+
+	return get_theme_mod('background_image', $default);
+}
+
+/**
+ * Display background image path.
+ *
+ * @since 3.0.0
+ */
+function background_image() {
+	echo get_background_image();
+}
+
+/**
+ * Retrieve value for custom background color.
+ *
+ * @since 3.0.0
+ * @uses BACKGROUND_COLOR
+ *
+ * @return string
+ */
+function get_background_color() {
+	$default = defined('BACKGROUND_COLOR') ? BACKGROUND_COLOR : '';
+
+	return get_theme_mod('background_color', $default);
+}
+
+/**
+ * Display background color value.
+ *
+ * @since 3.0.0
+ */
+function background_color() {
+	echo get_background_color();
+}
+
+/**
+ * Add callbacks for background image display.
+ *
+ * The parameter $header_callback callback will be required to display the
+ * content for the 'wp_head' action. The parameter $admin_header_callback
+ * callback will be added to Custom_Background class and that will be added
+ * to the 'admin_menu' action.
+ *
+ * @since 3.0.0
+ * @uses Custom_Background Sets up for $admin_header_callback for administration panel display.
+ *
+ * @param callback $header_callback Call on 'wp_head' action.
+ * @param callback $admin_header_callback Call on custom background administration screen.
+ * @param callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional.
+ */
+function add_custom_background( $header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '' ) {
+	if ( isset( $GLOBALS['custom_background'] ) )
+		return;
+
+	if ( empty( $header_callback ) )
+		$header_callback = '_custom_background_cb';
+
+	add_action( 'wp_head', $header_callback );
+
+	add_theme_support( 'custom-background', array( 'callback' => $header_callback ) );
+
+	if ( ! is_admin() )
+		return;
+	require_once( ABSPATH . 'wp-admin/custom-background.php' );
+	$GLOBALS['custom_background'] =& new Custom_Background( $admin_header_callback, $admin_image_div_callback );
+	add_action( 'admin_menu', array( &$GLOBALS['custom_background'], 'init' ) );
+}
+
+/**
+ * Remove custom background support.
+ *
+ * @since 3.1.0
+ * @see add_custom_background()
+ *
+ * @return bool Whether support was removed.
+ */
+function remove_custom_background() {
+	if ( ! current_theme_supports( 'custom-background' ) )
+		return false;
+
+	$callback = get_theme_support( 'custom-background' );
+	remove_action( 'wp_head', $callback[0]['callback'] );
+	_remove_theme_support( 'custom-background' );
+
+	if ( is_admin() ) {
+		remove_action( 'admin_menu', array( &$GLOBALS['custom_background'], 'init' ) );
+		unset( $GLOBALS['custom_background'] );
+	}
+
+	return true;
+}
+
+/**
+ * Default custom background callback.
+ *
+ * @since 3.0.0
+ * @see add_custom_background()
+ * @access protected
+ */
+function _custom_background_cb() {
+	$background = get_background_image();
+	$color = get_background_color();
+	if ( ! $background && ! $color )
+		return;
+
+	$style = $color ? "background-color: #$color;" : '';
+
+	if ( $background ) {
+		$image = " background-image: url('$background');";
+
+		$repeat = get_theme_mod( 'background_repeat', 'repeat' );
+		if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
+			$repeat = 'repeat';
+		$repeat = " background-repeat: $repeat;";
+
+		$position = get_theme_mod( 'background_position_x', 'left' );
+		if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
+			$position = 'left';
+		$position = " background-position: top $position;";
+
+		$attachment = get_theme_mod( 'background_attachment', 'scroll' );
+		if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
+			$attachment = 'scroll';
+		$attachment = " background-attachment: $attachment;";
+
+		$style .= $image . $repeat . $position . $attachment;
+	}
+?>
+<style type="text/css">
+body { <?php echo trim( $style ); ?> }
+</style>
+<?php
+}
+
+/**
+ * Add callback for custom TinyMCE editor stylesheets.
+ *
+ * The parameter $stylesheet is the name of the stylesheet, relative to
+ * the theme root. It also accepts an array of stylesheets.
+ * It is optional and defaults to 'editor-style.css'.
+ *
+ * Supports RTL stylesheets automatically by searching for the -rtl prefix, e.g.
+ * editor-style-rtl.css. If an array of stylesheets is passed to add_editor_style(),
+ * RTL is only added for the first stylesheet.
+ *
+ * @since 3.0.0
+ *
+ * @param mixed $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.
+ * 	Defaults to 'editor-style.css'
+ */
+function add_editor_style( $stylesheet = 'editor-style.css' ) {
+
+	add_theme_support( 'editor-style' );
+
+	if ( ! is_admin() )
+		return;
+
+	global $editor_styles;
+	$editor_styles = (array) $editor_styles;
+	$stylesheet    = (array) $stylesheet;
+	if ( is_rtl() ) {
+		$rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
+		$stylesheet[] = $rtl_stylesheet;
+	}
+
+	$editor_styles = array_merge( $editor_styles, $stylesheet );
+}
+
+/**
+ * Removes all visual editor stylesheets.
+ *
+ * @since 3.1.0
+ *
+ * @return bool True on success, false if there were no stylesheets to remove.
+ */
+function remove_editor_styles() {
+	if ( ! current_theme_supports( 'editor-style' ) )
+		return false;
+	_remove_theme_support( 'editor-style' );
+	if ( is_admin() )
+		$GLOBALS['editor_styles'] = array();
+	return true;
+}
+
+/**
+ * Allows a theme to register its support of a certain feature
+ *
+ * Must be called in the theme's functions.php file to work.
+ * If attached to a hook, it must be after_setup_theme.
+ * The init hook may be too late for some features.
+ *
+ * @since 2.9.0
+ * @param string $feature the feature being added
+ */
+function add_theme_support( $feature ) {
+	global $_wp_theme_features;
+
+	if ( func_num_args() == 1 )
+		$_wp_theme_features[$feature] = true;
+	else
+		$_wp_theme_features[$feature] = array_slice( func_get_args(), 1 );
+
+	if ( $feature == 'post-formats' && is_array( $_wp_theme_features[$feature][0] ) )
+		$_wp_theme_features[$feature][0] = array_intersect( $_wp_theme_features[$feature][0], array_keys( get_post_format_slugs() ) );
+}
+
+/**
+ * Gets the theme support arguments passed when registering that support
+ *
+ * @since 3.1
+ * @param string $feature the feature to check
+ * @return array The array of extra arguments
+ */
+function get_theme_support( $feature ) {
+	global $_wp_theme_features;
+	if ( !isset( $_wp_theme_features[$feature] ) )
+		return false;
+	else
+		return $_wp_theme_features[$feature];
+}
+
+/**
+ * Allows a theme to de-register its support of a certain feature
+ *
+ * Should be called in the theme's functions.php file. Generally would
+ * be used for child themes to override support from the parent theme.
+ *
+ * @since 3.0.0
+ * @see add_theme_support()
+ * @param string $feature the feature being added
+ * @return bool Whether feature was removed.
+ */
+function remove_theme_support( $feature ) {
+	// Blacklist: for internal registrations not used directly by themes.
+	if ( in_array( $feature, array( 'custom-background', 'custom-header', 'editor-style', 'widgets', 'menus' ) ) )
+		return false;
+	return _remove_theme_support( $feature );
+}
+
+/**
+ * Do not use. Removes theme support internally, ignorant of the blacklist.
+ *
+ * @access private
+ * @since 3.1.0
+ */
+function _remove_theme_support( $feature ) {
+	global $_wp_theme_features;
+
+	if ( ! isset( $_wp_theme_features[$feature] ) )
+		return false;
+	unset( $_wp_theme_features[$feature] );
+	return true;
+}
+
+/**
+ * Checks a theme's support for a given feature
+ *
+ * @since 2.9.0
+ * @param string $feature the feature being checked
+ * @return boolean
+ */
+function current_theme_supports( $feature ) {
+	global $_wp_theme_features;
+
+	if ( !isset( $_wp_theme_features[$feature] ) )
+		return false;
+
+	// If no args passed then no extra checks need be performed
+	if ( func_num_args() <= 1 )
+		return true;
+
+	$args = array_slice( func_get_args(), 1 );
+
+	// @todo Allow pluggable arg checking
+	switch ( $feature ) {
+		case 'post-thumbnails':
+			// post-thumbnails can be registered for only certain content/post types by passing
+			// an array of types to add_theme_support().  If no array was passed, then
+			// any type is accepted
+			if ( true === $_wp_theme_features[$feature] )  // Registered for all types
+				return true;
+			$content_type = $args[0];
+			if ( in_array($content_type, $_wp_theme_features[$feature][0]) )
+				return true;
+			else
+				return false;
+			break;
+	}
+
+	return true;
+}
+
+/**
+ * Checks a theme's support for a given feature before loading the functions which implement it.
+ *
+ * @since 2.9.0
+ * @param string $feature the feature being checked
+ * @param string $include the file containing the functions that implement the feature
+ */
+function require_if_theme_supports( $feature, $include) {
+	if ( current_theme_supports( $feature ) )
+		require ( $include );
+}
+
+/**
+ * Checks an attachment being deleted to see if it's a header or background image.
+ *
+ * If true it removes the theme modification which would be pointing at the deleted
+ * attachment
+ *
+ * @access private
+ * @since 3.0.0
+ * @param int $id the attachment id
+ */
+function _delete_attachment_theme_mod( $id ) {
+	$attachment_image = wp_get_attachment_url( $id );
+	$header_image = get_header_image();
+	$background_image = get_background_image();
+
+	if ( $header_image && $header_image == $attachment_image )
+		remove_theme_mod( 'header_image' );
+
+	if ( $background_image && $background_image == $attachment_image )
+		remove_theme_mod( 'background_image' );
+}
+
+add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
+
+?>
Index: /tags/3.1/wp-includes/update.php
===================================================================
--- /tags/3.1/wp-includes/update.php	(revision 17487)
+++ /tags/3.1/wp-includes/update.php	(revision 17487)
@@ -0,0 +1,375 @@
+<?php
+/**
+ * A simple set of functions to check our version 1.0 update service.
+ *
+ * @package WordPress
+ * @since 2.3.0
+ */
+
+/**
+ * Check WordPress version against the newest version.
+ *
+ * The WordPress version, PHP version, and Locale is sent. Checks against the
+ * WordPress server at api.wordpress.org server. Will only check if WordPress
+ * isn't installing.
+ *
+ * @package WordPress
+ * @since 2.3.0
+ * @uses $wp_version Used to check against the newest WordPress version.
+ *
+ * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
+ */
+function wp_version_check() {
+	if ( defined('WP_INSTALLING') )
+		return;
+
+	global $wp_version, $wpdb, $wp_local_package;
+	$php_version = phpversion();
+
+	$current = get_site_transient( 'update_core' );
+	if ( ! is_object($current) ) {
+		$current = new stdClass;
+		$current->updates = array();
+		$current->version_checked = $wp_version;
+	}
+
+	$locale = apply_filters( 'core_version_check_locale', get_locale() );
+
+	// Update last_checked for current to prevent multiple blocking requests if request hangs
+	$current->last_checked = time();
+	set_site_transient( 'update_core', $current );
+
+	if ( method_exists( $wpdb, 'db_version' ) )
+		$mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
+	else
+		$mysql_version = 'N/A';
+
+	if ( is_multisite( ) ) {
+		$user_count = get_user_count( );
+		$num_blogs = get_blog_count( );
+		$wp_install = network_site_url( );
+		$multisite_enabled = 1;
+	} else {
+		$user_count = count_users( );
+		$multisite_enabled = 0;
+		$num_blogs = 1;
+		$wp_install = home_url( '/' );
+	}
+
+	$local_package = isset( $wp_local_package )? $wp_local_package : '';
+	$url = "http://api.wordpress.org/core/version-check/1.5/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
+
+	$options = array(
+		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
+		'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
+		'headers' => array(
+			'wp_install' => $wp_install,
+			'wp_blog' => home_url( '/' )
+		)
+	);
+
+	$response = wp_remote_get($url, $options);
+
+	if ( is_wp_error( $response ) )
+		return false;
+
+	if ( 200 != $response['response']['code'] )
+		return false;
+
+	$body = trim( $response['body'] );
+	$body = str_replace(array("\r\n", "\r"), "\n", $body);
+	$new_options = array();
+	foreach ( explode( "\n\n", $body ) as $entry ) {
+		$returns = explode("\n", $entry);
+		$new_option = new stdClass();
+		$new_option->response = esc_attr( $returns[0] );
+		if ( isset( $returns[1] ) )
+			$new_option->url = esc_url( $returns[1] );
+		if ( isset( $returns[2] ) )
+			$new_option->package = esc_url( $returns[2] );
+		if ( isset( $returns[3] ) )
+			$new_option->current = esc_attr( $returns[3] );
+		if ( isset( $returns[4] ) )
+			$new_option->locale = esc_attr( $returns[4] );
+		if ( isset( $returns[5] ) )
+			$new_option->php_version = esc_attr( $returns[5] );
+		if ( isset( $returns[6] ) )
+			$new_option->mysql_version = esc_attr( $returns[6] );
+		$new_options[] = $new_option;
+	}
+
+	$updates = new stdClass();
+	$updates->updates = $new_options;
+	$updates->last_checked = time();
+	$updates->version_checked = $wp_version;
+	set_site_transient( 'update_core',  $updates);
+}
+
+/**
+ * Check plugin versions against the latest versions hosted on WordPress.org.
+ *
+ * The WordPress version, PHP version, and Locale is sent along with a list of
+ * all plugins installed. Checks against the WordPress server at
+ * api.wordpress.org. Will only check if WordPress isn't installing.
+ *
+ * @package WordPress
+ * @since 2.3.0
+ * @uses $wp_version Used to notify the WordPress version.
+ *
+ * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
+ */
+function wp_update_plugins() {
+	global $wp_version;
+
+	if ( defined('WP_INSTALLING') )
+		return false;
+
+	// If running blog-side, bail unless we've not checked in the last 12 hours
+	if ( !function_exists( 'get_plugins' ) )
+		require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+
+	$plugins = get_plugins();
+	$active  = get_option( 'active_plugins', array() );
+	$current = get_site_transient( 'update_plugins' );
+	if ( ! is_object($current) )
+		$current = new stdClass;
+
+	$new_option = new stdClass;
+	$new_option->last_checked = time();
+	$timeout = 'load-plugins.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
+	$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
+
+	$plugin_changed = false;
+	foreach ( $plugins as $file => $p ) {
+		$new_option->checked[ $file ] = $p['Version'];
+
+		if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) )
+			$plugin_changed = true;
+	}
+
+	if ( isset ( $current->response ) && is_array( $current->response ) ) {
+		foreach ( $current->response as $plugin_file => $update_details ) {
+			if ( ! isset($plugins[ $plugin_file ]) ) {
+				$plugin_changed = true;
+				break;
+			}
+		}
+	}
+
+	// Bail if we've checked in the last 12 hours and if nothing has changed
+	if ( $time_not_changed && !$plugin_changed )
+		return false;
+
+	// Update last_checked for current to prevent multiple blocking requests if request hangs
+	$current->last_checked = time();
+	set_site_transient( 'update_plugins', $current );
+
+	$to_send = (object) compact('plugins', 'active');
+
+	$options = array(
+		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
+		'body' => array( 'plugins' => serialize( $to_send ) ),
+		'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
+	);
+
+	$raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options);
+
+	if ( is_wp_error( $raw_response ) )
+		return false;
+
+	if ( 200 != $raw_response['response']['code'] )
+		return false;
+
+	$response = unserialize( $raw_response['body'] );
+
+	if ( false !== $response )
+		$new_option->response = $response;
+	else
+		$new_option->response = array();
+
+	set_site_transient( 'update_plugins', $new_option );
+}
+
+/**
+ * Check theme versions against the latest versions hosted on WordPress.org.
+ *
+ * A list of all themes installed in sent to WP. Checks against the
+ * WordPress server at api.wordpress.org. Will only check if WordPress isn't
+ * installing.
+ *
+ * @package WordPress
+ * @since 2.7.0
+ * @uses $wp_version Used to notify the WordPress version.
+ *
+ * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
+ */
+function wp_update_themes( ) {
+	global $wp_version;
+
+	if ( defined( 'WP_INSTALLING' ) )
+		return false;
+
+	if ( !function_exists( 'get_themes' ) )
+		require_once( ABSPATH . 'wp-includes/theme.php' );
+
+	$installed_themes = get_themes( );
+	$last_update = get_site_transient( 'update_themes' );
+	if ( ! is_object($last_update) )
+		$last_update = new stdClass;
+
+	$timeout = 'load-themes.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
+	$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
+
+	$themes = array();
+	$checked = array();
+	$exclude_fields = array('Template Files', 'Stylesheet Files', 'Status', 'Theme Root', 'Theme Root URI', 'Template Dir', 'Stylesheet Dir', 'Description', 'Tags', 'Screenshot');
+
+	// Put slug of current theme into request.
+	$themes['current_theme'] = get_option( 'stylesheet' );
+
+	foreach ( (array) $installed_themes as $theme_title => $theme ) {
+		$themes[$theme['Stylesheet']] = array();
+		$checked[$theme['Stylesheet']] = $theme['Version'];
+
+		$themes[$theme['Stylesheet']]['Name'] = $theme['Name'];
+		$themes[$theme['Stylesheet']]['Version'] = $theme['Version'];
+
+		foreach ( (array) $theme as $key => $value ) {
+			if ( !in_array($key, $exclude_fields) )
+				$themes[$theme['Stylesheet']][$key] = $value;
+		}
+	}
+
+	$theme_changed = false;
+	foreach ( $checked as $slug => $v ) {
+		$update_request->checked[ $slug ] = $v;
+
+		if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) )
+			$theme_changed = true;
+	}
+
+	if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) {
+		foreach ( $last_update->response as $slug => $update_details ) {
+			if ( ! isset($checked[ $slug ]) ) {
+				$theme_changed = true;
+				break;
+			}
+		}
+	}
+
+	if ( $time_not_changed && !$theme_changed )
+		return false;
+
+	// Update last_checked for current to prevent multiple blocking requests if request hangs
+	$last_update->last_checked = time();
+	set_site_transient( 'update_themes', $last_update );
+
+	$options = array(
+		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
+		'body'			=> array( 'themes' => serialize( $themes ) ),
+		'user-agent'	=> 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
+	);
+
+	$raw_response = wp_remote_post( 'http://api.wordpress.org/themes/update-check/1.0/', $options );
+
+	if ( is_wp_error( $raw_response ) )
+		return false;
+
+	if ( 200 != $raw_response['response']['code'] )
+		return false;
+
+	$new_update = new stdClass;
+	$new_update->last_checked = time( );
+	$response = unserialize( $raw_response['body'] );
+	if ( $response ) {
+		$new_update->checked = $checked;
+		$new_update->response = $response;
+	}
+
+	set_site_transient( 'update_themes', $new_update );
+}
+
+function _maybe_update_core() {
+	global $wp_version;
+
+	$current = get_site_transient( 'update_core' );
+
+	if ( isset( $current->last_checked ) &&
+		43200 > ( time() - $current->last_checked ) &&
+		isset( $current->version_checked ) &&
+		$current->version_checked == $wp_version )
+		return;
+
+	wp_version_check();
+}
+/**
+ * Check the last time plugins were run before checking plugin versions.
+ *
+ * This might have been backported to WordPress 2.6.1 for performance reasons.
+ * This is used for the wp-admin to check only so often instead of every page
+ * load.
+ *
+ * @since 2.7.0
+ * @access private
+ */
+function _maybe_update_plugins() {
+	$current = get_site_transient( 'update_plugins' );
+	if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
+		return;
+	wp_update_plugins();
+}
+
+/**
+ * Check themes versions only after a duration of time.
+ *
+ * This is for performance reasons to make sure that on the theme version
+ * checker is not run on every page load.
+ *
+ * @since 2.7.0
+ * @access private
+ */
+function _maybe_update_themes( ) {
+	$current = get_site_transient( 'update_themes' );
+	if ( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
+		return;
+
+	wp_update_themes();
+}
+
+/**
+ * Schedule core, theme, and plugin update checks.
+ *
+ * @since 3.1.0
+ */
+function wp_schedule_update_checks() {
+	if ( !wp_next_scheduled('wp_version_check') && !defined('WP_INSTALLING') )
+		wp_schedule_event(time(), 'twicedaily', 'wp_version_check');
+
+	if ( !wp_next_scheduled('wp_update_plugins') && !defined('WP_INSTALLING') )
+		wp_schedule_event(time(), 'twicedaily', 'wp_update_plugins');
+
+	if ( !wp_next_scheduled('wp_update_themes') && !defined('WP_INSTALLING') )
+		wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
+}
+
+if ( ! is_main_site() )
+	return;
+
+add_action( 'admin_init', '_maybe_update_core' );
+add_action( 'wp_version_check', 'wp_version_check' );
+
+add_action( 'load-plugins.php', 'wp_update_plugins' );
+add_action( 'load-update.php', 'wp_update_plugins' );
+add_action( 'load-update-core.php', 'wp_update_plugins' );
+add_action( 'admin_init', '_maybe_update_plugins' );
+add_action( 'wp_update_plugins', 'wp_update_plugins' );
+
+add_action( 'load-themes.php', 'wp_update_themes' );
+add_action( 'load-update.php', 'wp_update_themes' );
+add_action( 'load-update-core.php', 'wp_update_themes' );
+add_action( 'admin_init', '_maybe_update_themes' );
+add_action( 'wp_update_themes', 'wp_update_themes' );
+
+add_action('init', 'wp_schedule_update_checks');
+
+?>
Index: /tags/3.1/wp-includes/user.php
===================================================================
--- /tags/3.1/wp-includes/user.php	(revision 17487)
+++ /tags/3.1/wp-includes/user.php	(revision 17487)
@@ -0,0 +1,1620 @@
+<?php
+/**
+ * WordPress User API
+ *
+ * @package WordPress
+ */
+
+/**
+ * Authenticate user with remember capability.
+ *
+ * The credentials is an array that has 'user_login', 'user_password', and
+ * 'remember' indices. If the credentials is not given, then the log in form
+ * will be assumed and used if set.
+ *
+ * The various authentication cookies will be set by this function and will be
+ * set for a longer period depending on if the 'remember' credential is set to
+ * true.
+ *
+ * @since 2.5.0
+ *
+ * @param array $credentials Optional. User info in order to sign on.
+ * @param bool $secure_cookie Optional. Whether to use secure cookie.
+ * @return object Either WP_Error on failure, or WP_User on success.
+ */
+function wp_signon( $credentials = '', $secure_cookie = '' ) {
+	if ( empty($credentials) ) {
+		if ( ! empty($_POST['log']) )
+			$credentials['user_login'] = $_POST['log'];
+		if ( ! empty($_POST['pwd']) )
+			$credentials['user_password'] = $_POST['pwd'];
+		if ( ! empty($_POST['rememberme']) )
+			$credentials['remember'] = $_POST['rememberme'];
+	}
+
+	if ( !empty($credentials['remember']) )
+		$credentials['remember'] = true;
+	else
+		$credentials['remember'] = false;
+
+	// TODO do we deprecate the wp_authentication action?
+	do_action_ref_array('wp_authenticate', array(&$credentials['user_login'], &$credentials['user_password']));
+
+	if ( '' === $secure_cookie )
+		$secure_cookie = is_ssl();
+
+	$secure_cookie = apply_filters('secure_signon_cookie', $secure_cookie, $credentials);
+
+	global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie
+	$auth_secure_cookie = $secure_cookie;
+
+	add_filter('authenticate', 'wp_authenticate_cookie', 30, 3);
+
+	$user = wp_authenticate($credentials['user_login'], $credentials['user_password']);
+
+	if ( is_wp_error($user) ) {
+		if ( $user->get_error_codes() == array('empty_username', 'empty_password') ) {
+			$user = new WP_Error('', '');
+		}
+
+		return $user;
+	}
+
+	wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie);
+	do_action('wp_login', $credentials['user_login']);
+	return $user;
+}
+
+
+/**
+ * Authenticate the user using the username and password.
+ */
+add_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
+function wp_authenticate_username_password($user, $username, $password) {
+	if ( is_a($user, 'WP_User') ) { return $user; }
+
+	if ( empty($username) || empty($password) ) {
+		$error = new WP_Error();
+
+		if ( empty($username) )
+			$error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
+
+		if ( empty($password) )
+			$error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
+
+		return $error;
+	}
+
+	$userdata = get_user_by('login', $username);
+
+	if ( !$userdata )
+		return new WP_Error('invalid_username', sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login')));
+
+	if ( is_multisite() ) {
+		// Is user marked as spam?
+		if ( 1 == $userdata->spam)
+			return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Your account has been marked as a spammer.'));
+
+		// Is a user's blog marked as spam?
+		if ( !is_super_admin( $userdata->ID ) && isset($userdata->primary_blog) ) {
+			$details = get_blog_details( $userdata->primary_blog );
+			if ( is_object( $details ) && $details->spam == 1 )
+				return new WP_Error('blog_suspended', __('Site Suspended.'));
+		}
+	}
+
+	$userdata = apply_filters('wp_authenticate_user', $userdata, $password);
+	if ( is_wp_error($userdata) )
+		return $userdata;
+
+	if ( !wp_check_password($password, $userdata->user_pass, $userdata->ID) )
+		return new WP_Error( 'incorrect_password', sprintf( __( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?' ),
+		$username, site_url( 'wp-login.php?action=lostpassword', 'login' ) ) );
+
+	$user =  new WP_User($userdata->ID);
+	return $user;
+}
+
+/**
+ * Authenticate the user using the WordPress auth cookie.
+ */
+function wp_authenticate_cookie($user, $username, $password) {
+	if ( is_a($user, 'WP_User') ) { return $user; }
+
+	if ( empty($username) && empty($password) ) {
+		$user_id = wp_validate_auth_cookie();
+		if ( $user_id )
+			return new WP_User($user_id);
+
+		global $auth_secure_cookie;
+
+		if ( $auth_secure_cookie )
+			$auth_cookie = SECURE_AUTH_COOKIE;
+		else
+			$auth_cookie = AUTH_COOKIE;
+
+		if ( !empty($_COOKIE[$auth_cookie]) )
+			return new WP_Error('expired_session', __('Please log in again.'));
+
+		// If the cookie is not set, be silent.
+	}
+
+	return $user;
+}
+
+/**
+ * Number of posts user has written.
+ *
+ * @since 3.0.0
+ * @uses $wpdb WordPress database object for queries.
+ *
+ * @param int $userid User ID.
+ * @return int Amount of posts user has written.
+ */
+function count_user_posts($userid) {
+	global $wpdb;
+
+	$where = get_posts_by_author_sql('post', TRUE, $userid);
+
+	$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
+
+	return apply_filters('get_usernumposts', $count, $userid);
+}
+
+/**
+ * Number of posts written by a list of users.
+ *
+ * @since 3.0.0
+ * @param array $users User ID number list.
+ * @return array Amount of posts each user has written.
+ */
+function count_many_users_posts($users) {
+	global $wpdb;
+
+	$count = array();
+	if ( ! is_array($users) || empty( $users ) )
+		return $count;
+
+	$userlist = implode( ',', $users );
+	$where = get_posts_by_author_sql( 'post' );
+
+	$result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );
+	foreach ( $result as $row ) {
+		$count[ $row[0] ] = $row[1];
+	}
+
+	foreach ( $users as $id ) {
+		if ( ! isset( $count[ $id ] ) )
+			$count[ $id ] = 0;
+	}
+
+	return $count;
+}
+
+/**
+ * Check that the user login name and password is correct.
+ *
+ * @since 0.71
+ * @todo xmlrpc only. Maybe move to xmlrpc.php.
+ *
+ * @param string $user_login User name.
+ * @param string $user_pass User password.
+ * @return bool False if does not authenticate, true if username and password authenticates.
+ */
+function user_pass_ok($user_login, $user_pass) {
+	$user = wp_authenticate($user_login, $user_pass);
+	if ( is_wp_error($user) )
+		return false;
+
+	return true;
+}
+
+//
+// User option functions
+//
+
+/**
+ * Get the current user's ID
+ *
+ * @since MU
+ *
+ * @uses wp_get_current_user
+ *
+ * @return int The current user's ID
+ */
+function get_current_user_id() {
+	$user = wp_get_current_user();
+	return ( isset( $user->ID ) ? (int) $user->ID : 0 );
+}
+
+/**
+ * Retrieve user option that can be either per Site or per Network.
+ *
+ * If the user ID is not given, then the current user will be used instead. If
+ * the user ID is given, then the user data will be retrieved. The filter for
+ * the result, will also pass the original option name and finally the user data
+ * object as the third parameter.
+ *
+ * The option will first check for the per site name and then the per Network name.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database object for queries.
+ * @uses apply_filters() Calls 'get_user_option_$option' hook with result,
+ *		option parameter, and user data object.
+ *
+ * @param string $option User option name.
+ * @param int $user Optional. User ID.
+ * @param bool $deprecated Use get_option() to check for an option in the options table.
+ * @return mixed
+ */
+function get_user_option( $option, $user = 0, $deprecated = '' ) {
+	global $wpdb;
+
+	if ( !empty( $deprecated ) )
+		_deprecated_argument( __FUNCTION__, '3.0' );
+
+	if ( empty($user) ) {
+		$user = wp_get_current_user();
+		$user = $user->ID;
+	}
+
+	$user = get_userdata($user);
+
+	// Keys used as object vars cannot have dashes.
+	$key = str_replace('-', '', $option);
+
+	if ( isset( $user->{$wpdb->prefix . $key} ) ) // Blog specific
+		$result = $user->{$wpdb->prefix . $key};
+	elseif ( isset( $user->{$key} ) ) // User specific and cross-blog
+		$result = $user->{$key};
+	else
+		$result = false;
+
+	return apply_filters("get_user_option_{$option}", $result, $option, $user);
+}
+
+/**
+ * Update user option with global blog capability.
+ *
+ * User options are just like user metadata except that they have support for
+ * global blog options. If the 'global' parameter is false, which it is by default
+ * it will prepend the WordPress table prefix to the option name.
+ *
+ * Deletes the user option if $newvalue is empty.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param int $user_id User ID
+ * @param string $option_name User option name.
+ * @param mixed $newvalue User option value.
+ * @param bool $global Optional. Whether option name is global or blog specific. Default false (blog specific).
+ * @return unknown
+ */
+function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
+	global $wpdb;
+
+	if ( !$global )
+		$option_name = $wpdb->prefix . $option_name;
+
+	// For backward compatibility. See differences between update_user_meta() and deprecated update_usermeta().
+	// http://core.trac.wordpress.org/ticket/13088
+	if ( is_null( $newvalue ) || is_scalar( $newvalue ) && empty( $newvalue ) )
+		return delete_user_meta( $user_id, $option_name );
+
+	return update_user_meta( $user_id, $option_name, $newvalue );
+}
+
+/**
+ * Delete user option with global blog capability.
+ *
+ * User options are just like user metadata except that they have support for
+ * global blog options. If the 'global' parameter is false, which it is by default
+ * it will prepend the WordPress table prefix to the option name.
+ *
+ * @since 3.0.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param int $user_id User ID
+ * @param string $option_name User option name.
+ * @param bool $global Optional. Whether option name is global or blog specific. Default false (blog specific).
+ * @return unknown
+ */
+function delete_user_option( $user_id, $option_name, $global = false ) {
+	global $wpdb;
+
+	if ( !$global )
+		$option_name = $wpdb->prefix . $option_name;
+	return delete_user_meta( $user_id, $option_name );
+}
+
+/**
+ * WordPress User Query class.
+ *
+ * @since 3.1.0
+ */
+class WP_User_Query {
+
+	/**
+	 * List of found user ids
+	 *
+	 * @since 3.1.0
+	 * @access private
+	 * @var array
+	 */
+	var $results;
+
+	/**
+	 * Total number of found users for the current query
+	 *
+	 * @since 3.1.0
+	 * @access private
+	 * @var int
+	 */
+	var $total_users = 0;
+
+	// SQL clauses
+	var $query_fields;
+	var $query_from;
+	var $query_where;
+	var $query_orderby;
+	var $query_limit;
+
+	/**
+	 * PHP4 constructor
+	 */
+	function WP_User_Query( $query = null ) {
+		$this->__construct( $query );
+	}
+
+	/**
+	 * PHP5 constructor
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param string|array $args The query variables
+	 * @return WP_User_Query
+	 */
+	function __construct( $query = null ) {
+		if ( !empty( $query ) ) {
+			$this->query_vars = wp_parse_args( $query, array(
+				'blog_id' => $GLOBALS['blog_id'],
+				'role' => '',
+				'meta_key' => '',
+				'meta_value' => '',
+				'meta_compare' => '',
+				'include' => array(),
+				'exclude' => array(),
+				'search' => '',
+				'orderby' => 'login',
+				'order' => 'ASC',
+				'offset' => '', 'number' => '',
+				'count_total' => true,
+				'fields' => 'all',
+				'who' => ''
+			) );
+
+			$this->prepare_query();
+			$this->query();
+		}
+	}
+
+	/**
+	 * Prepare the query variables
+	 *
+	 * @since 3.1.0
+	 * @access private
+	 */
+	function prepare_query() {
+		global $wpdb;
+
+		$qv = &$this->query_vars;
+
+		if ( is_array( $qv['fields'] ) ) {
+			$qv['fields'] = array_unique( $qv['fields'] );
+
+			$this->query_fields = array();
+			foreach ( $qv['fields'] as $field )
+				$this->query_fields[] = $wpdb->users . '.' . esc_sql( $field );
+			$this->query_fields = implode( ',', $this->query_fields );
+		} elseif ( 'all' == $qv['fields'] ) {
+			$this->query_fields = "$wpdb->users.*";
+		} else {
+			$this->query_fields = "$wpdb->users.ID";
+		}
+
+		$this->query_from = "FROM $wpdb->users";
+		$this->query_where = "WHERE 1=1";
+
+		// sorting
+		if ( in_array( $qv['orderby'], array('nicename', 'email', 'url', 'registered') ) ) {
+			$orderby = 'user_' . $qv['orderby'];
+		} elseif ( in_array( $qv['orderby'], array('user_nicename', 'user_email', 'user_url', 'user_registered') ) ) {
+			$orderby = $qv['orderby'];
+		} elseif ( 'name' == $qv['orderby'] || 'display_name' == $qv['orderby'] ) {
+			$orderby = 'display_name';
+		} elseif ( 'post_count' == $qv['orderby'] ) {
+			// todo: avoid the JOIN
+			$where = get_posts_by_author_sql('post');
+			$this->query_from .= " LEFT OUTER JOIN (
+				SELECT post_author, COUNT(*) as post_count
+				FROM wp_posts
+				$where
+				GROUP BY post_author
+			) p ON ({$wpdb->users}.ID = p.post_author)
+			";
+			$orderby = 'post_count';
+		} elseif ( 'ID' == $qv['orderby'] || 'id' == $qv['orderby'] ) {
+			$orderby = 'ID';
+		} else {
+			$orderby = 'user_login';
+		}
+
+		$qv['order'] = strtoupper( $qv['order'] );
+		if ( 'ASC' == $qv['order'] )
+			$order = 'ASC';
+		else
+			$order = 'DESC';
+		$this->query_orderby = "ORDER BY $orderby $order";
+
+		// limit
+		if ( $qv['number'] ) {
+			if ( $qv['offset'] )
+				$this->query_limit = $wpdb->prepare("LIMIT %d, %d", $qv['offset'], $qv['number']);
+			else
+				$this->query_limit = $wpdb->prepare("LIMIT %d", $qv['number']);
+		}
+
+		$search = trim( $qv['search'] );
+		if ( $search ) {
+			$leading_wild = ( ltrim($search, '*') != $search );
+			$trailing_wild = ( rtrim($search, '*') != $search );
+			if ( $leading_wild && $trailing_wild )
+				$wild = 'both';
+			elseif ( $leading_wild )
+				$wild = 'leading';
+			elseif ( $trailing_wild )
+				$wild = 'trailing';
+			else
+				$wild = false;
+			if ( $wild )
+				$search = trim($search, '*');
+
+			if ( false !== strpos( $search, '@') )
+				$search_columns = array('user_email');
+			elseif ( is_numeric($search) )
+				$search_columns = array('user_login', 'ID');
+			elseif ( preg_match('|^https?://|', $search) )
+				$search_columns = array('user_url');
+			else
+				$search_columns = array('user_login', 'user_nicename');
+
+			$this->query_where .= $this->get_search_sql( $search, $search_columns, $wild );
+		}
+
+		$blog_id = absint( $qv['blog_id'] );
+
+		if ( 'authors' == $qv['who'] && $blog_id ) {
+			$qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level';
+			$qv['meta_value'] = '_wp_zero_value'; // Hack to pass '0'
+			$qv['meta_compare'] = '!=';
+			$qv['blog_id'] = $blog_id = 0; // Prevent extra meta query
+		}
+
+		_parse_meta_query( $qv );
+
+		$role = trim( $qv['role'] );
+
+		if ( $blog_id && ( $role || is_multisite() ) ) {
+			$cap_meta_query = array();
+			$cap_meta_query['key'] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
+
+			if ( $role ) {
+				$cap_meta_query['value'] = '"' . $role . '"';
+				$cap_meta_query['compare'] = 'like';
+			}
+
+			$qv['meta_query'][] = $cap_meta_query;
+		}
+
+		if ( !empty( $qv['meta_query'] ) ) {
+			$clauses = call_user_func_array( '_get_meta_sql', array( $qv['meta_query'], 'user', $wpdb->users, 'ID', &$this ) );
+			$this->query_from .= $clauses['join'];
+			$this->query_where .= $clauses['where'];
+		}
+
+		if ( !empty( $qv['include'] ) ) {
+			$ids = implode( ',', wp_parse_id_list( $qv['include'] ) );
+			$this->query_where .= " AND $wpdb->users.ID IN ($ids)";
+		} elseif ( !empty($qv['exclude']) ) {
+			$ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
+			$this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
+		}
+
+		do_action_ref_array( 'pre_user_query', array( &$this ) );
+	}
+
+	/**
+	 * Execute the query, with the current variables
+	 *
+	 * @since 3.1.0
+	 * @access private
+	 */
+	function query() {
+		global $wpdb;
+
+		if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) {
+			$this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
+		} else {
+			$this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit");
+		}
+
+		if ( $this->query_vars['count_total'] )
+			$this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where");
+
+		if ( !$this->results )
+			return;
+
+		if ( 'all_with_meta' == $this->query_vars['fields'] ) {
+			cache_users( $this->results );
+
+			$r = array();
+			foreach ( $this->results as $userid )
+				$r[ $userid ] = new WP_User( $userid, '', $this->query_vars['blog_id'] );
+
+			$this->results = $r;
+		}
+	}
+
+	/*
+	 * Used internally to generate an SQL string for searching across multiple columns
+	 *
+	 * @access protected
+	 * @since 3.1.0
+	 *
+	 * @param string $string
+	 * @param array $cols
+	 * @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for
+	 *  single site. Single site allows leading and trailing wildcards, Network Admin only trailing.
+	 * @return string
+	 */
+	function get_search_sql( $string, $cols, $wild = false ) {
+		$string = esc_sql( $string );
+
+		$searches = array();
+		$leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : '';
+		$trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : '';
+		foreach ( $cols as $col ) {
+			if ( 'ID' == $col )
+				$searches[] = "$col = '$string'";
+			else
+				$searches[] = "$col LIKE '$leading_wild" . like_escape($string) . "$trailing_wild'";
+		}
+
+		return ' AND (' . implode(' OR ', $searches) . ')';
+	}
+
+	/**
+	 * Return the list of users
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @return array
+	 */
+	function get_results() {
+		return $this->results;
+	}
+
+	/**
+	 * Return the total number of users for the current query
+	 *
+	 * @since 3.1.0
+	 * @access public
+	 *
+	 * @return array
+	 */
+	function get_total() {
+		return $this->total_users;
+	}
+}
+
+/**
+ * Retrieve list of users matching criteria.
+ *
+ * @since 3.1.0
+ * @uses $wpdb
+ * @uses WP_User_Query See for default arguments and information.
+ *
+ * @param array $args Optional.
+ * @return array List of users.
+ */
+function get_users( $args = array() ) {
+
+	$args = wp_parse_args( $args );
+	$args['count_total'] = false;
+
+	$user_search = new WP_User_Query($args);
+
+	return (array) $user_search->get_results();
+}
+
+/**
+ * Get the blogs a user belongs to.
+ *
+ * @since 3.0.0
+ *
+ * @param int $id User Id
+ * @param bool $all Whether to retrieve all blogs or only blogs that are not marked as deleted, archived, or spam.
+ * @return array A list of the user's blogs. False if the user was not found or an empty array if the user has no blogs.
+ */
+function get_blogs_of_user( $id, $all = false ) {
+	global $wpdb;
+
+	if ( !is_multisite() ) {
+		$blog_id = get_current_blog_id();
+		$blogs = array();
+		$blogs[ $blog_id ]->userblog_id = $blog_id;
+		$blogs[ $blog_id ]->blogname = get_option('blogname');
+		$blogs[ $blog_id ]->domain = '';
+		$blogs[ $blog_id ]->path = '';
+		$blogs[ $blog_id ]->site_id = 1;
+		$blogs[ $blog_id ]->siteurl = get_option('siteurl');
+		return $blogs;
+	}
+
+	$blogs = wp_cache_get( 'blogs_of_user-' . $id, 'users' );
+
+	// Try priming the new cache from the old cache
+	if ( false === $blogs ) {
+		$cache_suffix = $all ? '_all' : '_short';
+		$blogs = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' );
+		if ( is_array( $blogs ) ) {
+			$blogs = array_keys( $blogs );
+			if ( $all )
+				wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' );
+		}
+	}
+
+	if ( false === $blogs ) {
+		$user = get_userdata( (int) $id );
+		if ( !$user )
+			return false;
+
+		$blogs = $match = array();
+		$prefix_length = strlen($wpdb->base_prefix);
+		foreach ( (array) $user as $key => $value ) {
+			if ( $prefix_length && substr($key, 0, $prefix_length) != $wpdb->base_prefix )
+				continue;
+			if ( substr($key, -12, 12) != 'capabilities' )
+				continue;
+			if ( preg_match( '/^' . $wpdb->base_prefix . '((\d+)_)?capabilities$/', $key, $match ) ) {
+				if ( count( $match ) > 2 )
+					$blogs[] = (int) $match[ 2 ];
+				else
+					$blogs[] = 1;
+			}
+		}
+		wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' );
+	}
+
+	$blog_deets = array();
+	foreach ( (array) $blogs as $blog_id ) {
+		$blog = get_blog_details( $blog_id );
+		if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) {
+			$blog_deets[ $blog_id ]->userblog_id	= $blog_id;
+			$blog_deets[ $blog_id ]->blogname		= $blog->blogname;
+			$blog_deets[ $blog_id ]->domain		= $blog->domain;
+			$blog_deets[ $blog_id ]->path			= $blog->path;
+			$blog_deets[ $blog_id ]->site_id		= $blog->site_id;
+			$blog_deets[ $blog_id ]->siteurl		= $blog->siteurl;
+		}
+	}
+
+	return apply_filters( 'get_blogs_of_user', $blog_deets, $id, $all );
+}
+
+/**
+ * Checks if the current user belong to a given blog.
+ *
+ * @since 3.0.0
+ *
+ * @param int $blog_id Blog ID
+ * @return bool True if the current users belong to $blog_id, false if not.
+ */
+function is_blog_user( $blog_id = 0 ) {
+	global $wpdb;
+
+	$current_user = wp_get_current_user();
+	if ( !$blog_id )
+		$blog_id = $wpdb->blogid;
+
+	$cap_key = $wpdb->base_prefix . $blog_id . '_capabilities';
+
+	if ( is_array($current_user->$cap_key) && in_array(1, $current_user->$cap_key) )
+		return true;
+
+	return false;
+}
+
+/**
+ * Add meta data field to a user.
+ *
+ * Post meta data is called "Custom Fields" on the Administration Panels.
+ *
+ * @since 3.0.0
+ * @uses add_metadata()
+ * @link http://codex.wordpress.org/Function_Reference/add_user_meta
+ *
+ * @param int $user_id Post ID.
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Metadata value.
+ * @param bool $unique Optional, default is false. Whether the same key should not be added.
+ * @return bool False for failure. True for success.
+ */
+function add_user_meta($user_id, $meta_key, $meta_value, $unique = false) {
+	return add_metadata('user', $user_id, $meta_key, $meta_value, $unique);
+}
+
+/**
+ * Remove metadata matching criteria from a user.
+ *
+ * You can match based on the key, or key and value. Removing based on key and
+ * value, will keep from removing duplicate metadata with the same key. It also
+ * allows removing all metadata matching key, if needed.
+ *
+ * @since 3.0.0
+ * @uses delete_metadata()
+ * @link http://codex.wordpress.org/Function_Reference/delete_user_meta
+ *
+ * @param int $user_id user ID
+ * @param string $meta_key Metadata name.
+ * @param mixed $meta_value Optional. Metadata value.
+ * @return bool False for failure. True for success.
+ */
+function delete_user_meta($user_id, $meta_key, $meta_value = '') {
+	return delete_metadata('user', $user_id, $meta_key, $meta_value);
+}
+
+/**
+ * Retrieve user meta field for a user.
+ *
+ * @since 3.0.0
+ * @uses get_metadata()
+ * @link http://codex.wordpress.org/Function_Reference/get_user_meta
+ *
+ * @param int $user_id Post ID.
+ * @param string $key The meta key to retrieve.
+ * @param bool $single Whether to return a single value.
+ * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
+ *  is true.
+ */
+function get_user_meta($user_id, $key, $single = false) {
+	return get_metadata('user', $user_id, $key, $single);
+}
+
+/**
+ * Update user meta field based on user ID.
+ *
+ * Use the $prev_value parameter to differentiate between meta fields with the
+ * same key and user ID.
+ *
+ * If the meta field for the user does not exist, it will be added.
+ *
+ * @since 3.0.0
+ * @uses update_metadata
+ * @link http://codex.wordpress.org/Function_Reference/update_user_meta
+ *
+ * @param int $user_id Post ID.
+ * @param string $meta_key Metadata key.
+ * @param mixed $meta_value Metadata value.
+ * @param mixed $prev_value Optional. Previous value to check before removing.
+ * @return bool False on failure, true if success.
+ */
+function update_user_meta($user_id, $meta_key, $meta_value, $prev_value = '') {
+	return update_metadata('user', $user_id, $meta_key, $meta_value, $prev_value);
+}
+
+/**
+ * Count number of users who have each of the user roles.
+ *
+ * Assumes there are neither duplicated nor orphaned capabilities meta_values.
+ * Assumes role names are unique phrases.  Same assumption made by WP_User_Query::prepare_query()
+ * Using $strategy = 'time' this is CPU-intensive and should handle around 10^7 users.
+ * Using $strategy = 'memory' this is memory-intensive and should handle around 10^5 users, but see WP Bug #12257.
+ *
+ * @since 3.0.0
+ * @param string $strategy 'time' or 'memory'
+ * @return array Includes a grand total and an array of counts indexed by role strings.
+ */
+function count_users($strategy = 'time') {
+	global $wpdb, $wp_roles;
+
+	// Initialize
+	$id = get_current_blog_id();
+	$blog_prefix = $wpdb->get_blog_prefix($id);
+	$result = array();
+
+	if ( 'time' == $strategy ) {
+		global $wp_roles;
+
+		if ( ! isset( $wp_roles ) )
+			$wp_roles = new WP_Roles();
+
+		$avail_roles = $wp_roles->get_names();
+
+		// Build a CPU-intensive query that will return concise information.
+		$select_count = array();
+		foreach ( $avail_roles as $this_role => $name ) {
+			$select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%" . like_escape($this_role) . "%', FALSE))";
+		}
+		$select_count = implode(', ', $select_count);
+
+		// Add the meta_value index to the selection list, then run the query.
+		$row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
+
+		// Run the previous loop again to associate results with role names.
+		$col = 0;
+		$role_counts = array();
+		foreach ( $avail_roles as $this_role => $name ) {
+			$count = (int) $row[$col++];
+			if ($count > 0) {
+				$role_counts[$this_role] = $count;
+			}
+		}
+
+		// Get the meta_value index from the end of the result set.
+		$total_users = (int) $row[$col];
+
+		$result['total_users'] = $total_users;
+		$result['avail_roles'] =& $role_counts;
+	} else {
+		$avail_roles = array();
+
+		$users_of_blog = $wpdb->get_col( "SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'" );
+
+		foreach ( $users_of_blog as $caps_meta ) {
+			$b_roles = unserialize($caps_meta);
+			if ( is_array($b_roles) ) {
+				foreach ( $b_roles as $b_role => $val ) {
+					if ( isset($avail_roles[$b_role]) ) {
+						$avail_roles[$b_role]++;
+					} else {
+						$avail_roles[$b_role] = 1;
+					}
+				}
+			}
+		}
+
+		$result['total_users'] = count( $users_of_blog );
+		$result['avail_roles'] =& $avail_roles;
+	}
+
+	return $result;
+}
+
+//
+// Private helper functions
+//
+
+/**
+ * Set up global user vars.
+ *
+ * Used by wp_set_current_user() for back compat. Might be deprecated in the future.
+ *
+ * @since 2.0.4
+ * @global string $userdata User description.
+ * @global string $user_login The user username for logging in
+ * @global int $user_level The level of the user
+ * @global int $user_ID The ID of the user
+ * @global string $user_email The email address of the user
+ * @global string $user_url The url in the user's profile
+ * @global string $user_pass_md5 MD5 of the user's password
+ * @global string $user_identity The display name of the user
+ *
+ * @param int $for_user_id Optional. User ID to set up global data.
+ */
+function setup_userdata($for_user_id = '') {
+	global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity;
+
+	if ( '' == $for_user_id )
+		$user = wp_get_current_user();
+	else
+		$user = new WP_User($for_user_id);
+
+	$userdata   = $user->data;
+	$user_ID    = (int) $user->ID;
+	$user_level = (int) isset($user->user_level) ? $user->user_level : 0;
+
+	if ( 0 == $user->ID ) {
+		$user_login = $user_email = $user_url = $user_pass_md5 = $user_identity = '';
+		return;
+	}
+
+	$user_login	= $user->user_login;
+	$user_email	= $user->user_email;
+	$user_url	= $user->user_url;
+	$user_pass_md5	= md5($user->user_pass);
+	$user_identity	= $user->display_name;
+}
+
+/**
+ * Create dropdown HTML content of users.
+ *
+ * The content can either be displayed, which it is by default or retrieved by
+ * setting the 'echo' argument. The 'include' and 'exclude' arguments do not
+ * need to be used; all users will be displayed in that case. Only one can be
+ * used, either 'include' or 'exclude', but not both.
+ *
+ * The available arguments are as follows:
+ * <ol>
+ * <li>show_option_all - Text to show all and whether HTML option exists.</li>
+ * <li>show_option_none - Text for show none and whether HTML option exists.</li>
+ * <li>hide_if_only_one_author - Don't create the dropdown if there is only one user.</li>
+ * <li>orderby - SQL order by clause for what order the users appear. Default is 'display_name'.</li>
+ * <li>order - Default is 'ASC'. Can also be 'DESC'.</li>
+ * <li>include - User IDs to include.</li>
+ * <li>exclude - User IDs to exclude.</li>
+ * <li>multi - Default is 'false'. Whether to skip the ID attribute on the 'select' element. A 'true' value is overridden when id argument is set.</li>
+ * <li>show - Default is 'display_name'. User table column to display. If the selected item is empty then the user_login will be displayed in parentheses</li>
+ * <li>echo - Default is '1'. Whether to display or retrieve content.</li>
+ * <li>selected - Which User ID is selected.</li>
+ * <li>include_selected - Always include the selected user ID in the dropdown. Default is false.</li>
+ * <li>name - Default is 'user'. Name attribute of select element.</li>
+ * <li>id - Default is the value of the 'name' parameter. ID attribute of select element.</li>
+ * <li>class - Class attribute of select element.</li>
+ * <li>blog_id - ID of blog (Multisite only). Defaults to ID of current blog.</li>
+ * <li>who - Which users to query.  Currently only 'authors' is supported. Default is all users.</li>
+ * </ol>
+ *
+ * @since 2.3.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param string|array $args Optional. Override defaults.
+ * @return string|null Null on display. String of HTML content on retrieve.
+ */
+function wp_dropdown_users( $args = '' ) {
+	$defaults = array(
+		'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '',
+		'orderby' => 'display_name', 'order' => 'ASC',
+		'include' => '', 'exclude' => '', 'multi' => 0,
+		'show' => 'display_name', 'echo' => 1,
+		'selected' => 0, 'name' => 'user', 'class' => '', 'id' => '',
+		'blog_id' => $GLOBALS['blog_id'], 'who' => '', 'include_selected' => false
+	);
+
+	$defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
+
+	$r = wp_parse_args( $args, $defaults );
+	extract( $r, EXTR_SKIP );
+
+	$query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) );
+	$query_args['fields'] = array( 'ID', $show );
+	$users = get_users( $query_args );
+
+	$output = '';
+	if ( !empty($users) && ( empty($hide_if_only_one_author) || count($users) > 1 ) ) {
+		$name = esc_attr( $name );
+		if ( $multi && ! $id )
+			$id = '';
+		else
+			$id = $id ? " id='" . esc_attr( $id ) . "'" : " id='$name'";
+
+		$output = "<select name='{$name}'{$id} class='$class'>\n";
+
+		if ( $show_option_all )
+			$output .= "\t<option value='0'>$show_option_all</option>\n";
+
+		if ( $show_option_none ) {
+			$_selected = selected( -1, $selected, false );
+			$output .= "\t<option value='-1'$_selected>$show_option_none</option>\n";
+		}
+
+		$found_selected = false;
+		foreach ( (array) $users as $user ) {
+			$user->ID = (int) $user->ID;
+			$_selected = selected( $user->ID, $selected, false );
+			if ( $_selected )
+				$found_selected = true;
+			$display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
+			$output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
+		}
+
+		if ( $include_selected && ! $found_selected && ( $selected > 0 ) ) {
+			$user = get_userdata( $selected );
+			$_selected = selected( $user->ID, $selected, false );
+			$display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
+			$output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
+		}
+
+		$output .= "</select>";
+	}
+
+	$output = apply_filters('wp_dropdown_users', $output);
+
+	if ( $echo )
+		echo $output;
+
+	return $output;
+}
+
+/**
+ * Add user meta data as properties to given user object.
+ *
+ * The finished user data is cached, but the cache is not used to fill in the
+ * user data for the given object. Once the function has been used, the cache
+ * should be used to retrieve user data. The intention is if the current data
+ * had been cached already, there would be no need to call this function.
+ *
+ * @access private
+ * @since 2.5.0
+ * @uses $wpdb WordPress database object for queries
+ *
+ * @param object $user The user data object.
+ */
+function _fill_user( &$user ) {
+	$metavalues = get_user_metavalues(array($user->ID));
+	_fill_single_user($user, $metavalues[$user->ID]);
+}
+
+/**
+ * Perform the query to get the $metavalues array(s) needed by _fill_user and _fill_many_users
+ *
+ * @since 3.0.0
+ * @param array $ids User ID numbers list.
+ * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays.
+ */
+function get_user_metavalues($ids) {
+	$objects = array();
+
+	$ids = array_map('intval', $ids);
+	foreach ( $ids as $id )
+		$objects[$id] = array();
+
+	$metas = update_meta_cache('user', $ids);
+
+	foreach ( $metas as $id => $meta ) {
+		foreach ( $meta as $key => $metavalues ) {
+			foreach ( $metavalues as $value ) {
+				$objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value);
+			}
+		}
+	}
+
+	return $objects;
+}
+
+/**
+ * Unserialize user metadata, fill $user object, then cache everything.
+ *
+ * @since 3.0.0
+ * @param object $user The User object.
+ * @param array $metavalues An array of objects provided by get_user_metavalues()
+ */
+function _fill_single_user( &$user, &$metavalues ) {
+	global $wpdb;
+
+	foreach ( $metavalues as $meta ) {
+		$value = maybe_unserialize($meta->meta_value);
+		// Keys used as object vars cannot have dashes.
+		$key = str_replace('-', '', $meta->meta_key);
+		$user->{$key} = $value;
+	}
+
+	$level = $wpdb->prefix . 'user_level';
+	if ( isset( $user->{$level} ) )
+		$user->user_level = $user->{$level};
+
+	// For backwards compat.
+	if ( isset($user->first_name) )
+		$user->user_firstname = $user->first_name;
+	if ( isset($user->last_name) )
+		$user->user_lastname = $user->last_name;
+	if ( isset($user->description) )
+		$user->user_description = $user->description;
+
+	update_user_caches($user);
+}
+
+/**
+ * Take an array of user objects, fill them with metas, and cache them.
+ *
+ * @since 3.0.0
+ * @param array $users User objects
+ */
+function _fill_many_users( &$users ) {
+	$ids = array();
+	foreach( $users as $user_object ) {
+		$ids[] = $user_object->ID;
+	}
+
+	$metas = get_user_metavalues($ids);
+
+	foreach ( $users as $user_object ) {
+		if ( isset($metas[$user_object->ID]) ) {
+			_fill_single_user($user_object, $metas[$user_object->ID]);
+		}
+	}
+}
+
+/**
+ * Sanitize every user field.
+ *
+ * If the context is 'raw', then the user object or array will get minimal santization of the int fields.
+ *
+ * @since 2.3.0
+ * @uses sanitize_user_field() Used to sanitize the fields.
+ *
+ * @param object|array $user The User Object or Array
+ * @param string $context Optional, default is 'display'. How to sanitize user fields.
+ * @return object|array The now sanitized User Object or Array (will be the same type as $user)
+ */
+function sanitize_user_object($user, $context = 'display') {
+	if ( is_object($user) ) {
+		if ( !isset($user->ID) )
+			$user->ID = 0;
+		if ( isset($user->data) )
+			$vars = get_object_vars( $user->data );
+		else
+			$vars = get_object_vars($user);
+		foreach ( array_keys($vars) as $field ) {
+			if ( is_string($user->$field) || is_numeric($user->$field) )
+				$user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context);
+		}
+		$user->filter = $context;
+	} else {
+		if ( !isset($user['ID']) )
+			$user['ID'] = 0;
+		foreach ( array_keys($user) as $field )
+			$user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context);
+		$user['filter'] = $context;
+	}
+
+	return $user;
+}
+
+/**
+ * Sanitize user field based on context.
+ *
+ * Possible context values are:  'raw', 'edit', 'db', 'display', 'attribute' and 'js'. The
+ * 'display' context is used by default. 'attribute' and 'js' contexts are treated like 'display'
+ * when calling filters.
+ *
+ * @since 2.3.0
+ * @uses apply_filters() Calls 'edit_$field' and '{$field_no_prefix}_edit_pre' passing $value and
+ *  $user_id if $context == 'edit' and field name prefix == 'user_'.
+ *
+ * @uses apply_filters() Calls 'edit_user_$field' passing $value and $user_id if $context == 'db'.
+ * @uses apply_filters() Calls 'pre_$field' passing $value if $context == 'db' and field name prefix == 'user_'.
+ * @uses apply_filters() Calls '{$field}_pre' passing $value if $context == 'db' and field name prefix != 'user_'.
+ *
+ * @uses apply_filters() Calls '$field' passing $value, $user_id and $context if $context == anything
+ *  other than 'raw', 'edit' and 'db' and field name prefix == 'user_'.
+ * @uses apply_filters() Calls 'user_$field' passing $value if $context == anything other than 'raw',
+ *  'edit' and 'db' and field name prefix != 'user_'.
+ *
+ * @param string $field The user Object field name.
+ * @param mixed $value The user Object value.
+ * @param int $user_id user ID.
+ * @param string $context How to sanitize user fields. Looks for 'raw', 'edit', 'db', 'display',
+ *               'attribute' and 'js'.
+ * @return mixed Sanitized value.
+ */
+function sanitize_user_field($field, $value, $user_id, $context) {
+	$int_fields = array('ID');
+	if ( in_array($field, $int_fields) )
+		$value = (int) $value;
+
+	if ( 'raw' == $context )
+		return $value;
+
+	if ( !is_string($value) && !is_numeric($value) )
+		return $value;
+
+	$prefixed = false;
+	if ( false !== strpos($field, 'user_') ) {
+		$prefixed = true;
+		$field_no_prefix = str_replace('user_', '', $field);
+	}
+
+	if ( 'edit' == $context ) {
+		if ( $prefixed ) {
+			$value = apply_filters("edit_{$field}", $value, $user_id);
+		} else {
+			$value = apply_filters("edit_user_{$field}", $value, $user_id);
+		}
+
+		if ( 'description' == $field )
+			$value = esc_html( $value ); // textarea_escaped?
+		else
+			$value = esc_attr($value);
+	} else if ( 'db' == $context ) {
+		if ( $prefixed ) {
+			$value = apply_filters("pre_{$field}", $value);
+		} else {
+			$value = apply_filters("pre_user_{$field}", $value);
+		}
+	} else {
+		// Use display filters by default.
+		if ( $prefixed )
+			$value = apply_filters($field, $value, $user_id, $context);
+		else
+			$value = apply_filters("user_{$field}", $value, $user_id, $context);
+	}
+
+	if ( 'user_url' == $field )
+		$value = esc_url($value);
+
+	if ( 'attribute' == $context )
+		$value = esc_attr($value);
+	else if ( 'js' == $context )
+		$value = esc_js($value);
+
+	return $value;
+}
+
+/**
+ * Update all user caches
+ *
+ * @since 3.0.0
+ *
+ * @param object $user User object to be cached
+ */
+function update_user_caches(&$user) {
+	wp_cache_add($user->ID, $user, 'users');
+	wp_cache_add($user->user_login, $user->ID, 'userlogins');
+	wp_cache_add($user->user_email, $user->ID, 'useremail');
+	wp_cache_add($user->user_nicename, $user->ID, 'userslugs');
+}
+
+/**
+ * Clean all user caches
+ *
+ * @since 3.0.0
+ *
+ * @param int $id User ID
+ */
+function clean_user_cache($id) {
+	$user = new WP_User($id);
+
+	wp_cache_delete($id, 'users');
+	wp_cache_delete($user->user_login, 'userlogins');
+	wp_cache_delete($user->user_email, 'useremail');
+	wp_cache_delete($user->user_nicename, 'userslugs');
+	wp_cache_delete('blogs_of_user-' . $id, 'users');
+}
+
+/**
+ * Checks whether the given username exists.
+ *
+ * @since 2.0.0
+ *
+ * @param string $username Username.
+ * @return null|int The user's ID on success, and null on failure.
+ */
+function username_exists( $username ) {
+	if ( $user = get_userdatabylogin( $username ) ) {
+		return $user->ID;
+	} else {
+		return null;
+	}
+}
+
+/**
+ * Checks whether the given email exists.
+ *
+ * @since 2.1.0
+ * @uses $wpdb
+ *
+ * @param string $email Email.
+ * @return bool|int The user's ID on success, and false on failure.
+ */
+function email_exists( $email ) {
+	if ( $user = get_user_by_email($email) )
+		return $user->ID;
+
+	return false;
+}
+
+/**
+ * Checks whether an username is valid.
+ *
+ * @since 2.0.1
+ * @uses apply_filters() Calls 'validate_username' hook on $valid check and $username as parameters
+ *
+ * @param string $username Username.
+ * @return bool Whether username given is valid
+ */
+function validate_username( $username ) {
+	$sanitized = sanitize_user( $username, true );
+	$valid = ( $sanitized == $username );
+	return apply_filters( 'validate_username', $valid, $username );
+}
+
+/**
+ * Insert an user into the database.
+ *
+ * Can update a current user or insert a new user based on whether the user's ID
+ * is present.
+ *
+ * Can be used to update the user's info (see below), set the user's role, and
+ * set the user's preference on whether they want the rich editor on.
+ *
+ * Most of the $userdata array fields have filters associated with the values.
+ * The exceptions are 'rich_editing', 'role', 'jabber', 'aim', 'yim',
+ * 'user_registered', and 'ID'. The filters have the prefix 'pre_user_' followed
+ * by the field name. An example using 'description' would have the filter
+ * called, 'pre_user_description' that can be hooked into.
+ *
+ * The $userdata array can contain the following fields:
+ * 'ID' - An integer that will be used for updating an existing user.
+ * 'user_pass' - A string that contains the plain text password for the user.
+ * 'user_login' - A string that contains the user's username for logging in.
+ * 'user_nicename' - A string that contains a nicer looking name for the user.
+ *		The default is the user's username.
+ * 'user_url' - A string containing the user's URL for the user's web site.
+ * 'user_email' - A string containing the user's email address.
+ * 'display_name' - A string that will be shown on the site. Defaults to user's
+ *		username. It is likely that you will want to change this, for both
+ *		appearance and security through obscurity (that is if you don't use and
+ *		delete the default 'admin' user).
+ * 'nickname' - The user's nickname, defaults to the user's username.
+ * 'first_name' - The user's first name.
+ * 'last_name' - The user's last name.
+ * 'description' - A string containing content about the user.
+ * 'rich_editing' - A string for whether to enable the rich editor. False
+ *		if not empty.
+ * 'user_registered' - The date the user registered. Format is 'Y-m-d H:i:s'.
+ * 'role' - A string used to set the user's role.
+ * 'jabber' - User's Jabber account.
+ * 'aim' - User's AOL IM account.
+ * 'yim' - User's Yahoo IM account.
+ *
+ * @since 2.0.0
+ * @uses $wpdb WordPress database layer.
+ * @uses apply_filters() Calls filters for most of the $userdata fields with the prefix 'pre_user'. See note above.
+ * @uses do_action() Calls 'profile_update' hook when updating giving the user's ID
+ * @uses do_action() Calls 'user_register' hook when creating a new user giving the user's ID
+ *
+ * @param array $userdata An array of user data.
+ * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not be created.
+ */
+function wp_insert_user($userdata) {
+	global $wpdb;
+
+	extract($userdata, EXTR_SKIP);
+
+	// Are we updating or creating?
+	if ( !empty($ID) ) {
+		$ID = (int) $ID;
+		$update = true;
+		$old_user_data = get_userdata($ID);
+	} else {
+		$update = false;
+		// Hash the password
+		$user_pass = wp_hash_password($user_pass);
+	}
+
+	$user_login = sanitize_user($user_login, true);
+	$user_login = apply_filters('pre_user_login', $user_login);
+
+	//Remove any non-printable chars from the login string to see if we have ended up with an empty username
+	$user_login = trim($user_login);
+
+	if ( empty($user_login) )
+		return new WP_Error('empty_user_login', __('Cannot create a user with an empty login name.') );
+
+	if ( !$update && username_exists( $user_login ) )
+		return new WP_Error('existing_user_login', __('This username is already registered.') );
+
+	if ( empty($user_nicename) )
+		$user_nicename = sanitize_title( $user_login );
+	$user_nicename = apply_filters('pre_user_nicename', $user_nicename);
+
+	if ( empty($user_url) )
+		$user_url = '';
+	$user_url = apply_filters('pre_user_url', $user_url);
+
+	if ( empty($user_email) )
+		$user_email = '';
+	$user_email = apply_filters('pre_user_email', $user_email);
+
+	if ( !$update && ! defined( 'WP_IMPORTING' ) && email_exists($user_email) )
+		return new WP_Error('existing_user_email', __('This email address is already registered.') );
+
+	if ( empty($display_name) )
+		$display_name = $user_login;
+	$display_name = apply_filters('pre_user_display_name', $display_name);
+
+	if ( empty($nickname) )
+		$nickname = $user_login;
+	$nickname = apply_filters('pre_user_nickname', $nickname);
+
+	if ( empty($first_name) )
+		$first_name = '';
+	$first_name = apply_filters('pre_user_first_name', $first_name);
+
+	if ( empty($last_name) )
+		$last_name = '';
+	$last_name = apply_filters('pre_user_last_name', $last_name);
+
+	if ( empty($description) )
+		$description = '';
+	$description = apply_filters('pre_user_description', $description);
+
+	if ( empty($rich_editing) )
+		$rich_editing = 'true';
+
+	if ( empty($comment_shortcuts) )
+		$comment_shortcuts = 'false';
+
+	if ( empty($admin_color) )
+		$admin_color = 'fresh';
+	$admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
+
+	if ( empty($use_ssl) )
+		$use_ssl = 0;
+
+	if ( empty($user_registered) )
+		$user_registered = gmdate('Y-m-d H:i:s');
+
+	if ( empty($show_admin_bar_front) )
+		$show_admin_bar_front = 'true';
+
+	if ( empty($show_admin_bar_admin) )
+		$show_admin_bar_admin = is_multisite() ? 'true' : 'false';
+
+	$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login));
+
+	if ( $user_nicename_check ) {
+		$suffix = 2;
+		while ($user_nicename_check) {
+			$alt_user_nicename = $user_nicename . "-$suffix";
+			$user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login));
+			$suffix++;
+		}
+		$user_nicename = $alt_user_nicename;
+	}
+
+	$data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
+	$data = stripslashes_deep( $data );
+
+	if ( $update ) {
+		$wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
+		$user_id = (int) $ID;
+	} else {
+		$wpdb->insert( $wpdb->users, $data + compact( 'user_login' ) );
+		$user_id = (int) $wpdb->insert_id;
+	}
+
+	update_user_meta( $user_id, 'first_name', $first_name );
+	update_user_meta( $user_id, 'last_name', $last_name );
+	update_user_meta( $user_id, 'nickname', $nickname );
+	update_user_meta( $user_id, 'description', $description );
+	update_user_meta( $user_id, 'rich_editing', $rich_editing );
+	update_user_meta( $user_id, 'comment_shortcuts', $comment_shortcuts );
+	update_user_meta( $user_id, 'admin_color', $admin_color );
+	update_user_meta( $user_id, 'use_ssl', $use_ssl );
+	update_user_meta( $user_id, 'show_admin_bar_front', $show_admin_bar_front );
+	update_user_meta( $user_id, 'show_admin_bar_admin', $show_admin_bar_admin );
+
+	$user = new WP_User($user_id);
+
+	foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
+		if ( empty($$method) )
+			$$method = '';
+
+		update_user_meta( $user_id, $method, $$method );
+	}
+
+	if ( isset($role) )
+		$user->set_role($role);
+	elseif ( !$update )
+		$user->set_role(get_option('default_role'));
+
+	wp_cache_delete($user_id, 'users');
+	wp_cache_delete($user_login, 'userlogins');
+
+	if ( $update )
+		do_action('profile_update', $user_id, $old_user_data);
+	else
+		do_action('user_register', $user_id);
+
+	return $user_id;
+}
+
+/**
+ * Update an user in the database.
+ *
+ * It is possible to update a user's password by specifying the 'user_pass'
+ * value in the $userdata parameter array.
+ *
+ * If $userdata does not contain an 'ID' key, then a new user will be created
+ * and the new user's ID will be returned.
+ *
+ * If current user's password is being updated, then the cookies will be
+ * cleared.
+ *
+ * @since 2.0.0
+ * @see wp_insert_user() For what fields can be set in $userdata
+ * @uses wp_insert_user() Used to update existing user or add new one if user doesn't exist already
+ *
+ * @param array $userdata An array of user data.
+ * @return int The updated user's ID.
+ */
+function wp_update_user($userdata) {
+	$ID = (int) $userdata['ID'];
+
+	// First, get all of the original fields
+	$user = get_userdata($ID);
+
+	// Escape data pulled from DB.
+	$user = add_magic_quotes(get_object_vars($user));
+
+	// If password is changing, hash it now.
+	if ( ! empty($userdata['user_pass']) ) {
+		$plaintext_pass = $userdata['user_pass'];
+		$userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
+	}
+
+	wp_cache_delete($user[ 'user_email' ], 'useremail');
+
+	// Merge old and new fields with new fields overwriting old ones.
+	$userdata = array_merge($user, $userdata);
+	$user_id = wp_insert_user($userdata);
+
+	// Update the cookies if the password changed.
+	$current_user = wp_get_current_user();
+	if ( $current_user->id == $ID ) {
+		if ( isset($plaintext_pass) ) {
+			wp_clear_auth_cookie();
+			wp_set_auth_cookie($ID);
+		}
+	}
+
+	return $user_id;
+}
+
+/**
+ * A simpler way of inserting an user into the database.
+ *
+ * Creates a new user with just the username, password, and email. For a more
+ * detail creation of a user, use wp_insert_user() to specify more infomation.
+ *
+ * @since 2.0.0
+ * @see wp_insert_user() More complete way to create a new user
+ *
+ * @param string $username The user's username.
+ * @param string $password The user's password.
+ * @param string $email The user's email (optional).
+ * @return int The new user's ID.
+ */
+function wp_create_user($username, $password, $email = '') {
+	$user_login = esc_sql( $username );
+	$user_email = esc_sql( $email    );
+	$user_pass = $password;
+
+	$userdata = compact('user_login', 'user_email', 'user_pass');
+	return wp_insert_user($userdata);
+}
+
+
+/**
+ * Set up the default contact methods
+ *
+ * @access private
+ * @since
+ *
+ * @param object $user User data object (optional)
+ * @return array $user_contactmethods Array of contact methods and their labels.
+ */
+function _wp_get_user_contactmethods( $user = null ) {
+	$user_contactmethods = array(
+		'aim' => __('AIM'),
+		'yim' => __('Yahoo IM'),
+		'jabber' => __('Jabber / Google Talk')
+	);
+	return apply_filters( 'user_contactmethods', $user_contactmethods, $user );
+}
+
+?>
Index: /tags/3.1/wp-includes/vars.php
===================================================================
--- /tags/3.1/wp-includes/vars.php	(revision 17487)
+++ /tags/3.1/wp-includes/vars.php	(revision 17487)
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Creates common globals for the rest of WordPress
+ *
+ * Sets $pagenow global which is the current page. Checks
+ * for the browser to set which one is currently being used.
+ *
+ * Detects which user environment WordPress is being used on.
+ * Only attempts to check for Apache and IIS. Two web servers
+ * with known permalink capability.
+ *
+ * @package WordPress
+ */
+
+// On which page are we ?
+if ( is_admin() ) {
+	// wp-admin pages are checked more carefully
+	if ( is_network_admin() )
+		preg_match('#/wp-admin/network/?(.*?)$#i', $PHP_SELF, $self_matches);
+	elseif ( is_user_admin() )
+		preg_match('#/wp-admin/user/?(.*?)$#i', $PHP_SELF, $self_matches);
+	else
+		preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
+	$pagenow = $self_matches[1];
+	$pagenow = trim($pagenow, '/');
+	$pagenow = preg_replace('#\?.*?$#', '', $pagenow);
+	if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
+		$pagenow = 'index.php';
+	} else {
+		preg_match('#(.*?)(/|$)#', $pagenow, $self_matches);
+		$pagenow = strtolower($self_matches[1]);
+		if ( '.php' !== substr($pagenow, -4, 4) )
+			$pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried)
+	}
+} else {
+	if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) )
+		$pagenow = strtolower($self_matches[1]);
+	else
+		$pagenow = 'index.php';
+}
+unset($self_matches);
+
+// Simple browser detection
+$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
+
+if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
+	if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) {
+		$is_lynx = true;
+	} elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'chrome') !== false ) {
+		$is_chrome = true;
+	} elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false ) {
+		$is_safari = true;
+	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) {
+		$is_gecko = true;
+	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) {
+		$is_winIE = true;
+	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) {
+		$is_macIE = true;
+	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) {
+		$is_opera = true;
+	} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) {
+		$is_NS4 = true;
+	}
+}
+
+if ( $is_safari && stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false )
+	$is_iphone = true;
+
+$is_IE = ( $is_macIE || $is_winIE );
+
+// Server detection
+
+/**
+ * Whether the server software is Apache or something else
+ * @global bool $is_apache
+ */
+$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
+
+/**
+ * Whether the server software is IIS or something else
+ * @global bool $is_IIS
+ */
+$is_IIS = !$is_apache && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false);
+
+/**
+ * Whether the server software is IIS 7.X
+ * @global bool $is_iis7
+ */
+$is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);
+
+?>
Index: /tags/3.1/wp-includes/version.php
===================================================================
--- /tags/3.1/wp-includes/version.php	(revision 17487)
+++ /tags/3.1/wp-includes/version.php	(revision 17487)
@@ -0,0 +1,60 @@
+<?php
+/*
+WordPress - Web publishing software
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+/**
+ * The WordPress version string
+ *
+ * @global string $wp_version
+ */
+$wp_version = '3.1';
+
+/**
+ * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
+ *
+ * @global int $wp_db_version
+ */
+$wp_db_version = 17056;
+
+/**
+ * Holds the TinyMCE version
+ *
+ * @global string $tinymce_version
+ */
+$tinymce_version = '3393';
+
+/**
+ * Holds the cache manifest version
+ *
+ * @global string $manifest_version
+ */
+$manifest_version = '20111113';
+
+/**
+ * Holds the required PHP version
+ *
+ * @global string $required_php_version
+ */
+$required_php_version = '4.3';
+
+/**
+ * Holds the required MySQL version
+ *
+ * @global string $required_mysql_version
+ */
+$required_mysql_version = '4.1.2';
Index: /tags/3.1/wp-includes/widgets.php
===================================================================
--- /tags/3.1/wp-includes/widgets.php	(revision 17487)
+++ /tags/3.1/wp-includes/widgets.php	(revision 17487)
@@ -0,0 +1,1215 @@
+<?php
+/**
+ * API for creating dynamic sidebar without hardcoding functionality into
+ * themes. Includes both internal WordPress routines and theme use routines.
+ *
+ * This functionality was found in a plugin before WordPress 2.2 release which
+ * included it in the core from that point on.
+ *
+ * @link http://codex.wordpress.org/Plugins/WordPress_Widgets WordPress Widgets
+ * @link http://codex.wordpress.org/Plugins/WordPress_Widgets_Api Widgets API
+ *
+ * @package WordPress
+ * @subpackage Widgets
+ */
+
+/**
+ * This class must be extended for each widget and WP_Widget::widget(), WP_Widget::update()
+ * and WP_Widget::form() need to be over-ridden.
+ *
+ * @package WordPress
+ * @subpackage Widgets
+ * @since 2.8
+ */
+class WP_Widget {
+
+	var $id_base;			// Root id for all widgets of this type.
+	var $name;				// Name for this widget type.
+	var $widget_options;	// Option array passed to wp_register_sidebar_widget()
+	var $control_options;	// Option array passed to wp_register_widget_control()
+
+	var $number = false;	// Unique ID number of the current instance.
+	var $id = false;		// Unique ID string of the current instance (id_base-number)
+	var $updated = false;	// Set true when we update the data after a POST submit - makes sure we don't do it twice.
+
+	// Member functions that you must over-ride.
+
+	/** Echo the widget content.
+	 *
+	 * Subclasses should over-ride this function to generate their widget code.
+	 *
+	 * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
+	 * @param array $instance The settings for the particular instance of the widget
+	 */
+	function widget($args, $instance) {
+		die('function WP_Widget::widget() must be over-ridden in a sub-class.');
+	}
+
+	/** Update a particular instance.
+	 *
+	 * This function should check that $new_instance is set correctly.
+	 * The newly calculated value of $instance should be returned.
+	 * If "false" is returned, the instance won't be saved/updated.
+	 *
+	 * @param array $new_instance New settings for this instance as input by the user via form()
+	 * @param array $old_instance Old settings for this instance
+	 * @return array Settings to save or bool false to cancel saving
+	 */
+	function update($new_instance, $old_instance) {
+		return $new_instance;
+	}
+
+	/** Echo the settings update form
+	 *
+	 * @param array $instance Current settings
+	 */
+	function form($instance) {
+		echo '<p class="no-options-widget">' . __('There are no options for this widget.') . '</p>';
+		return 'noform';
+	}
+
+	// Functions you'll need to call.
+
+	/**
+	 * PHP4 constructor
+	 */
+	function WP_Widget( $id_base = false, $name, $widget_options = array(), $control_options = array() ) {
+		$this->__construct( $id_base, $name, $widget_options, $control_options );
+	}
+
+	/**
+	 * PHP5 constructor
+	 *
+	 * @param string $id_base Optional Base ID for the widget, lower case,
+	 * if left empty a portion of the widget's class name will be used. Has to be unique.
+	 * @param string $name Name for the widget displayed on the configuration page.
+	 * @param array $widget_options Optional Passed to wp_register_sidebar_widget()
+	 *	 - description: shown on the configuration page
+	 *	 - classname
+	 * @param array $control_options Optional Passed to wp_register_widget_control()
+	 *	 - width: required if more than 250px
+	 *	 - height: currently not used but may be needed in the future
+	 */
+	function __construct( $id_base = false, $name, $widget_options = array(), $control_options = array() ) {
+		$this->id_base = empty($id_base) ? preg_replace( '/(wp_)?widget_/', '', strtolower(get_class($this)) ) : strtolower($id_base);
+		$this->name = $name;
+		$this->option_name = 'widget_' . $this->id_base;
+		$this->widget_options = wp_parse_args( $widget_options, array('classname' => $this->option_name) );
+		$this->control_options = wp_parse_args( $control_options, array('id_base' => $this->id_base) );
+	}
+
+	/**
+	 * Constructs name attributes for use in form() fields
+	 *
+	 * This function should be used in form() methods to create name attributes for fields to be saved by update()
+	 *
+	 * @param string $field_name Field name
+	 * @return string Name attribute for $field_name
+	 */
+	function get_field_name($field_name) {
+		return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
+	}
+
+	/**
+	 * Constructs id attributes for use in form() fields
+	 *
+	 * This function should be used in form() methods to create id attributes for fields to be saved by update()
+	 *
+	 * @param string $field_name Field name
+	 * @return string ID attribute for $field_name
+	 */
+	function get_field_id($field_name) {
+		return 'widget-' . $this->id_base . '-' . $this->number . '-' . $field_name;
+	}
+
+	// Private Functions. Don't worry about these.
+
+	function _register() {
+		$settings = $this->get_settings();
+		$empty = true;
+
+		if ( is_array($settings) ) {
+			foreach ( array_keys($settings) as $number ) {
+				if ( is_numeric($number) ) {
+					$this->_set($number);
+					$this->_register_one($number);
+					$empty = false;
+				}
+			}
+		}
+
+		if ( $empty ) {
+			// If there are none, we register the widget's existance with a
+			// generic template
+			$this->_set(1);
+			$this->_register_one();
+		}
+	}
+
+	function _set($number) {
+		$this->number = $number;
+		$this->id = $this->id_base . '-' . $number;
+	}
+
+	function _get_display_callback() {
+		return array(&$this, 'display_callback');
+	}
+
+	function _get_update_callback() {
+		return array(&$this, 'update_callback');
+	}
+
+	function _get_form_callback() {
+		return array(&$this, 'form_callback');
+	}
+
+	/** Generate the actual widget content.
+	 *	Just finds the instance and calls widget().
+	 *	Do NOT over-ride this function. */
+	function display_callback( $args, $widget_args = 1 ) {
+		if ( is_numeric($widget_args) )
+			$widget_args = array( 'number' => $widget_args );
+
+		$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
+		$this->_set( $widget_args['number'] );
+		$instance = $this->get_settings();
+
+		if ( array_key_exists( $this->number, $instance ) ) {
+			$instance = $instance[$this->number];
+			// filters the widget's settings, return false to stop displaying the widget
+			$instance = apply_filters('widget_display_callback', $instance, $this, $args);
+			if ( false !== $instance )
+				$this->widget($args, $instance);
+		}
+	}
+
+	/** Deal with changed settings.
+	 *	Do NOT over-ride this function. */
+	function update_callback( $widget_args = 1 ) {
+		global $wp_registered_widgets;
+
+		if ( is_numeric($widget_args) )
+			$widget_args = array( 'number' => $widget_args );
+
+		$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
+		$all_instances = $this->get_settings();
+
+		// We need to update the data
+		if ( $this->updated )
+			return;
+
+		$sidebars_widgets = wp_get_sidebars_widgets();
+
+		if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
+			// Delete the settings for this instance of the widget
+			if ( isset($_POST['the-widget-id']) )
+				$del_id = $_POST['the-widget-id'];
+			else
+				return;
+
+			if ( isset($wp_registered_widgets[$del_id]['params'][0]['number']) ) {
+				$number = $wp_registered_widgets[$del_id]['params'][0]['number'];
+
+				if ( $this->id_base . '-' . $number == $del_id )
+					unset($all_instances[$number]);
+			}
+		} else {
+			if ( isset($_POST['widget-' . $this->id_base]) && is_array($_POST['widget-' . $this->id_base]) ) {
+				$settings = $_POST['widget-' . $this->id_base];
+			} elseif ( isset($_POST['id_base']) && $_POST['id_base'] == $this->id_base ) {
+				$num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number'];
+				$settings = array( $num => array() );
+			} else {
+				return;
+			}
+
+			foreach ( $settings as $number => $new_instance ) {
+				$new_instance = stripslashes_deep($new_instance);
+				$this->_set($number);
+
+				$old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array();
+
+				$instance = $this->update($new_instance, $old_instance);
+
+				// filters the widget's settings before saving, return false to cancel saving (keep the old settings if updating)
+				$instance = apply_filters('widget_update_callback', $instance, $new_instance, $old_instance, $this);
+				if ( false !== $instance )
+					$all_instances[$number] = $instance;
+
+				break; // run only once
+			}
+		}
+
+		$this->save_settings($all_instances);
+		$this->updated = true;
+	}
+
+	/** Generate the control form.
+	 *	Do NOT over-ride this function. */
+	function form_callback( $widget_args = 1 ) {
+		if ( is_numeric($widget_args) )
+			$widget_args = array( 'number' => $widget_args );
+
+		$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
+		$all_instances = $this->get_settings();
+
+		if ( -1 == $widget_args['number'] ) {
+			// We echo out a form where 'number' can be set later
+			$this->_set('__i__');
+			$instance = array();
+		} else {
+			$this->_set($widget_args['number']);
+			$instance = $all_instances[ $widget_args['number'] ];
+		}
+
+		// filters the widget admin form before displaying, return false to stop displaying it
+		$instance = apply_filters('widget_form_callback', $instance, $this);
+
+		$return = null;
+		if ( false !== $instance ) {
+			$return = $this->form($instance);
+			// add extra fields in the widget form - be sure to set $return to null if you add any
+			// if the widget has no form the text echoed from the default form method can be hidden using css
+			do_action_ref_array( 'in_widget_form', array(&$this, &$return, $instance) );
+		}
+		return $return;
+	}
+
+	/** Helper function: Registers a single instance. */
+	function _register_one($number = -1) {
+		wp_register_sidebar_widget(	$this->id, $this->name,	$this->_get_display_callback(), $this->widget_options, array( 'number' => $number ) );
+		_register_widget_update_callback( $this->id_base, $this->_get_update_callback(), $this->control_options, array( 'number' => -1 ) );
+		_register_widget_form_callback(	$this->id, $this->name,	$this->_get_form_callback(), $this->control_options, array( 'number' => $number ) );
+	}
+
+	function save_settings($settings) {
+		$settings['_multiwidget'] = 1;
+		update_option( $this->option_name, $settings );
+	}
+
+	function get_settings() {
+		$settings = get_option($this->option_name);
+
+		if ( false === $settings && isset($this->alt_option_name) )
+			$settings = get_option($this->alt_option_name);
+
+		if ( !is_array($settings) )
+			$settings = array();
+
+		if ( !array_key_exists('_multiwidget', $settings) ) {
+			// old format, conver if single widget
+			$settings = wp_convert_widget_settings($this->id_base, $this->option_name, $settings);
+		}
+
+		unset($settings['_multiwidget'], $settings['__i__']);
+		return $settings;
+	}
+}
+
+/**
+ * Singleton that registers and instantiates WP_Widget classes.
+ *
+ * @package WordPress
+ * @subpackage Widgets
+ * @since 2.8
+ */
+class WP_Widget_Factory {
+	var $widgets = array();
+
+	function WP_Widget_Factory() {
+		add_action( 'widgets_init', array( &$this, '_register_widgets' ), 100 );
+	}
+
+	function register($widget_class) {
+		$this->widgets[$widget_class] = & new $widget_class();
+	}
+
+	function unregister($widget_class) {
+		if ( isset($this->widgets[$widget_class]) )
+			unset($this->widgets[$widget_class]);
+	}
+
+	function _register_widgets() {
+		global $wp_registered_widgets;
+		$keys = array_keys($this->widgets);
+		$registered = array_keys($wp_registered_widgets);
+		$registered = array_map('_get_widget_id_base', $registered);
+
+		foreach ( $keys as $key ) {
+			// don't register new widget if old widget with the same id is already registered
+			if ( in_array($this->widgets[$key]->id_base, $registered, true) ) {
+				unset($this->widgets[$key]);
+				continue;
+			}
+
+			$this->widgets[$key]->_register();
+		}
+	}
+}
+
+/* Global Variables */
+
+/** @ignore */
+global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
+
+/**
+ * Stores the sidebars, since many themes can have more than one.
+ *
+ * @global array $wp_registered_sidebars
+ * @since 2.2.0
+ */
+$wp_registered_sidebars = array();
+
+/**
+ * Stores the registered widgets.
+ *
+ * @global array $wp_registered_widgets
+ * @since 2.2.0
+ */
+$wp_registered_widgets = array();
+
+/**
+ * Stores the registered widget control (options).
+ *
+ * @global array $wp_registered_widget_controls
+ * @since 2.2.0
+ */
+$wp_registered_widget_controls = array();
+$wp_registered_widget_updates = array();
+
+/**
+ * Private
+ */
+$_wp_sidebars_widgets = array();
+
+/**
+ * Private
+ */
+ $_wp_deprecated_widgets_callbacks = array(
+ 	'wp_widget_pages',
+	'wp_widget_pages_control',
+	'wp_widget_calendar',
+	'wp_widget_calendar_control',
+	'wp_widget_archives',
+	'wp_widget_archives_control',
+	'wp_widget_links',
+	'wp_widget_meta',
+	'wp_widget_meta_control',
+	'wp_widget_search',
+	'wp_widget_recent_entries',
+	'wp_widget_recent_entries_control',
+	'wp_widget_tag_cloud',
+	'wp_widget_tag_cloud_control',
+	'wp_widget_categories',
+	'wp_widget_categories_control',
+	'wp_widget_text',
+	'wp_widget_text_control',
+	'wp_widget_rss',
+	'wp_widget_rss_control',
+	'wp_widget_recent_comments',
+	'wp_widget_recent_comments_control'
+ );
+
+/* Template tags & API functions */
+
+/**
+ * Register a widget
+ *
+ * Registers a WP_Widget widget
+ *
+ * @since 2.8.0
+ *
+ * @see WP_Widget
+ * @see WP_Widget_Factory
+ * @uses WP_Widget_Factory
+ *
+ * @param string $widget_class The name of a class that extends WP_Widget
+ */
+function register_widget($widget_class) {
+	global $wp_widget_factory;
+
+	$wp_widget_factory->register($widget_class);
+}
+
+/**
+ * Unregister a widget
+ *
+ * Unregisters a WP_Widget widget. Useful for unregistering default widgets.
+ * Run within a function hooked to the widgets_init action.
+ *
+ * @since 2.8.0
+ *
+ * @see WP_Widget
+ * @see WP_Widget_Factory
+ * @uses WP_Widget_Factory
+ *
+ * @param string $widget_class The name of a class that extends WP_Widget
+ */
+function unregister_widget($widget_class) {
+	global $wp_widget_factory;
+
+	$wp_widget_factory->unregister($widget_class);
+}
+
+/**
+ * Creates multiple sidebars.
+ *
+ * If you wanted to quickly create multiple sidebars for a theme or internally.
+ * This function will allow you to do so. If you don't pass the 'name' and/or
+ * 'id' in $args, then they will be built for you.
+ *
+ * The default for the name is "Sidebar #", with '#' being replaced with the
+ * number the sidebar is currently when greater than one. If first sidebar, the
+ * name will be just "Sidebar". The default for id is "sidebar-" followed by the
+ * number the sidebar creation is currently at. If the id is provided, and mutliple
+ * sidebars are being defined, the id will have "-2" appended, and so on.
+ *
+ * @since 2.2.0
+ *
+ * @see register_sidebar() The second parameter is documented by register_sidebar() and is the same here.
+ * @uses parse_str() Converts a string to an array to be used in the rest of the function.
+ * @uses register_sidebar() Sends single sidebar information [name, id] to this
+ *	function to handle building the sidebar.
+ *
+ * @param int $number Number of sidebars to create.
+ * @param string|array $args Builds Sidebar based off of 'name' and 'id' values.
+ */
+function register_sidebars($number = 1, $args = array()) {
+	global $wp_registered_sidebars;
+	$number = (int) $number;
+
+	if ( is_string($args) )
+		parse_str($args, $args);
+
+	for ( $i = 1; $i <= $number; $i++ ) {
+		$_args = $args;
+
+		if ( $number > 1 )
+			$_args['name'] = isset($args['name']) ? sprintf($args['name'], $i) : sprintf(__('Sidebar %d'), $i);
+		else
+			$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
+
+		// Custom specified ID's are suffixed if they exist already.
+		// Automatically generated sidebar names need to be suffixed regardless starting at -0
+		if ( isset($args['id']) ) {
+			$_args['id'] = $args['id'];
+			$n = 2; // Start at -2 for conflicting custom ID's
+			while ( isset($wp_registered_sidebars[$_args['id']]) )
+				$_args['id'] = $args['id'] . '-' . $n++;
+		} else {
+			$n = count($wp_registered_sidebars);
+			do {
+				$_args['id'] = 'sidebar-' . ++$n;
+			} while ( isset($wp_registered_sidebars[$_args['id']]) );
+		}
+		register_sidebar($_args);
+	}
+}
+
+/**
+ * Builds the definition for a single sidebar and returns the ID.
+ *
+ * The $args parameter takes either a string or an array with 'name' and 'id'
+ * contained in either usage. It will be noted that the values will be applied
+ * to all sidebars, so if creating more than one, it will be advised to allow
+ * for WordPress to create the defaults for you.
+ *
+ * Example for string would be <code>'name=whatever;id=whatever1'</code> and for
+ * the array it would be <code>array(
+ *    'name' => 'whatever',
+ *    'id' => 'whatever1')</code>.
+ *
+ * name - The name of the sidebar, which presumably the title which will be
+ *     displayed.
+ * id - The unique identifier by which the sidebar will be called by.
+ * before_widget - The content that will prepended to the widgets when they are
+ *     displayed.
+ * after_widget - The content that will be appended to the widgets when they are
+ *     displayed.
+ * before_title - The content that will be prepended to the title when displayed.
+ * after_title - the content that will be appended to the title when displayed.
+ *
+ * <em>Content</em> is assumed to be HTML and should be formatted as such, but
+ * doesn't have to be.
+ *
+ * @since 2.2.0
+ * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
+ *
+ * @param string|array $args Builds Sidebar based off of 'name' and 'id' values
+ * @return string The sidebar id that was added.
+ */
+function register_sidebar($args = array()) {
+	global $wp_registered_sidebars;
+
+	$i = count($wp_registered_sidebars) + 1;
+
+	$defaults = array(
+		'name' => sprintf(__('Sidebar %d'), $i ),
+		'id' => "sidebar-$i",
+		'description' => '',
+		'before_widget' => '<li id="%1$s" class="widget %2$s">',
+		'after_widget' => "</li>\n",
+		'before_title' => '<h2 class="widgettitle">',
+		'after_title' => "</h2>\n",
+	);
+
+	$sidebar = wp_parse_args( $args, $defaults );
+
+	$wp_registered_sidebars[$sidebar['id']] = $sidebar;
+
+	add_theme_support('widgets');
+
+	do_action( 'register_sidebar', $sidebar );
+
+	return $sidebar['id'];
+}
+
+/**
+ * Removes a sidebar from the list.
+ *
+ * @since 2.2.0
+ *
+ * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
+ *
+ * @param string $name The ID of the sidebar when it was added.
+ */
+function unregister_sidebar( $name ) {
+	global $wp_registered_sidebars;
+
+	if ( isset( $wp_registered_sidebars[$name] ) )
+		unset( $wp_registered_sidebars[$name] );
+}
+
+/**
+ * Register widget for use in sidebars.
+ *
+ * The default widget option is 'classname' that can be override.
+ *
+ * The function can also be used to unregister widgets when $output_callback
+ * parameter is an empty string.
+ *
+ * @since 2.2.0
+ *
+ * @uses $wp_registered_widgets Uses stored registered widgets.
+ * @uses $wp_register_widget_defaults Retrieves widget defaults.
+ *
+ * @param int|string $id Widget ID.
+ * @param string $name Widget display title.
+ * @param callback $output_callback Run when widget is called.
+ * @param array|string $options Optional. Widget Options.
+ * @param mixed $params,... Widget parameters to add to widget.
+ * @return null Will return if $output_callback is empty after removing widget.
+ */
+function wp_register_sidebar_widget($id, $name, $output_callback, $options = array()) {
+	global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates, $_wp_deprecated_widgets_callbacks;
+
+	$id = strtolower($id);
+
+	if ( empty($output_callback) ) {
+		unset($wp_registered_widgets[$id]);
+		return;
+	}
+
+	$id_base = _get_widget_id_base($id);
+	if ( in_array($output_callback, $_wp_deprecated_widgets_callbacks, true) && !is_callable($output_callback) ) {
+		if ( isset($wp_registered_widget_controls[$id]) )
+			unset($wp_registered_widget_controls[$id]);
+
+		if ( isset($wp_registered_widget_updates[$id_base]) )
+			unset($wp_registered_widget_updates[$id_base]);
+
+		return;
+	}
+
+	$defaults = array('classname' => $output_callback);
+	$options = wp_parse_args($options, $defaults);
+	$widget = array(
+		'name' => $name,
+		'id' => $id,
+		'callback' => $output_callback,
+		'params' => array_slice(func_get_args(), 4)
+	);
+	$widget = array_merge($widget, $options);
+
+	if ( is_callable($output_callback) && ( !isset($wp_registered_widgets[$id]) || did_action( 'widgets_init' ) ) ) {
+		do_action( 'wp_register_sidebar_widget', $widget );
+		$wp_registered_widgets[$id] = $widget;
+	}
+}
+
+/**
+ * Retrieve description for widget.
+ *
+ * When registering widgets, the options can also include 'description' that
+ * describes the widget for display on the widget administration panel or
+ * in the theme.
+ *
+ * @since 2.5.0
+ *
+ * @param int|string $id Widget ID.
+ * @return string Widget description, if available. Null on failure to retrieve description.
+ */
+function wp_widget_description( $id ) {
+	if ( !is_scalar($id) )
+		return;
+
+	global $wp_registered_widgets;
+
+	if ( isset($wp_registered_widgets[$id]['description']) )
+		return esc_html( $wp_registered_widgets[$id]['description'] );
+}
+
+/**
+ * Retrieve description for a sidebar.
+ *
+ * When registering sidebars a 'description' parameter can be included that
+ * describes the sidebar for display on the widget administration panel.
+ *
+ * @since 2.9.0
+ *
+ * @param int|string $id sidebar ID.
+ * @return string Sidebar description, if available. Null on failure to retrieve description.
+ */
+function wp_sidebar_description( $id ) {
+	if ( !is_scalar($id) )
+		return;
+
+	global $wp_registered_sidebars;
+
+	if ( isset($wp_registered_sidebars[$id]['description']) )
+		return esc_html( $wp_registered_sidebars[$id]['description'] );
+}
+
+
+/**
+ * Remove widget from sidebar.
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $id Widget ID.
+ */
+function wp_unregister_sidebar_widget($id) {
+	do_action( 'wp_unregister_sidebar_widget', $id );
+
+	wp_register_sidebar_widget($id, '', '');
+	wp_unregister_widget_control($id);
+}
+
+/**
+ * Registers widget control callback for customizing options.
+ *
+ * The options contains the 'height', 'width', and 'id_base' keys. The 'height'
+ * option is never used. The 'width' option is the width of the fully expanded
+ * control form, but try hard to use the default width. The 'id_base' is for
+ * multi-widgets (widgets which allow multiple instances such as the text
+ * widget), an id_base must be provided. The widget id will end up looking like
+ * {$id_base}-{$unique_number}.
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $id Sidebar ID.
+ * @param string $name Sidebar display name.
+ * @param callback $control_callback Run when sidebar is displayed.
+ * @param array|string $options Optional. Widget options. See above long description.
+ * @param mixed $params,... Optional. Additional parameters to add to widget.
+ */
+function wp_register_widget_control($id, $name, $control_callback, $options = array()) {
+	global $wp_registered_widget_controls, $wp_registered_widget_updates, $wp_registered_widgets, $_wp_deprecated_widgets_callbacks;
+
+	$id = strtolower($id);
+	$id_base = _get_widget_id_base($id);
+
+	if ( empty($control_callback) ) {
+		unset($wp_registered_widget_controls[$id]);
+		unset($wp_registered_widget_updates[$id_base]);
+		return;
+	}
+
+	if ( in_array($control_callback, $_wp_deprecated_widgets_callbacks, true) && !is_callable($control_callback) ) {
+		if ( isset($wp_registered_widgets[$id]) )
+			unset($wp_registered_widgets[$id]);
+
+		return;
+	}
+
+	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) )
+		return;
+
+	$defaults = array('width' => 250, 'height' => 200 ); // height is never used
+	$options = wp_parse_args($options, $defaults);
+	$options['width'] = (int) $options['width'];
+	$options['height'] = (int) $options['height'];
+
+	$widget = array(
+		'name' => $name,
+		'id' => $id,
+		'callback' => $control_callback,
+		'params' => array_slice(func_get_args(), 4)
+	);
+	$widget = array_merge($widget, $options);
+
+	$wp_registered_widget_controls[$id] = $widget;
+
+	if ( isset($wp_registered_widget_updates[$id_base]) )
+		return;
+
+	if ( isset($widget['params'][0]['number']) )
+		$widget['params'][0]['number'] = -1;
+
+	unset($widget['width'], $widget['height'], $widget['name'], $widget['id']);
+	$wp_registered_widget_updates[$id_base] = $widget;
+}
+
+function _register_widget_update_callback($id_base, $update_callback, $options = array()) {
+	global $wp_registered_widget_updates;
+
+	if ( isset($wp_registered_widget_updates[$id_base]) ) {
+		if ( empty($update_callback) )
+			unset($wp_registered_widget_updates[$id_base]);
+		return;
+	}
+
+	$widget = array(
+		'callback' => $update_callback,
+		'params' => array_slice(func_get_args(), 3)
+	);
+
+	$widget = array_merge($widget, $options);
+	$wp_registered_widget_updates[$id_base] = $widget;
+}
+
+function _register_widget_form_callback($id, $name, $form_callback, $options = array()) {
+	global $wp_registered_widget_controls;
+
+	$id = strtolower($id);
+
+	if ( empty($form_callback) ) {
+		unset($wp_registered_widget_controls[$id]);
+		return;
+	}
+
+	if ( isset($wp_registered_widget_controls[$id]) && !did_action( 'widgets_init' ) )
+		return;
+
+	$defaults = array('width' => 250, 'height' => 200 );
+	$options = wp_parse_args($options, $defaults);
+	$options['width'] = (int) $options['width'];
+	$options['height'] = (int) $options['height'];
+
+	$widget = array(
+		'name' => $name,
+		'id' => $id,
+		'callback' => $form_callback,
+		'params' => array_slice(func_get_args(), 4)
+	);
+	$widget = array_merge($widget, $options);
+
+	$wp_registered_widget_controls[$id] = $widget;
+}
+
+/**
+ * Remove control callback for widget.
+ *
+ * @since 2.2.0
+ * @uses wp_register_widget_control() Unregisters by using empty callback.
+ *
+ * @param int|string $id Widget ID.
+ */
+function wp_unregister_widget_control($id) {
+	return wp_register_widget_control($id, '', '');
+}
+
+/**
+ * Display dynamic sidebar.
+ *
+ * By default it displays the default sidebar or 'sidebar-1'. The 'sidebar-1' is
+ * not named by the theme, the actual name is '1', but 'sidebar-' is added to
+ * the registered sidebars for the name. If you named your sidebar 'after-post',
+ * then the parameter $index will still be 'after-post', but the lookup will be
+ * for 'sidebar-after-post'.
+ *
+ * It is confusing for the $index parameter, but just know that it should just
+ * work. When you register the sidebar in the theme, you will use the same name
+ * for this function or "Pay no heed to the man behind the curtain." Just accept
+ * it as an oddity of WordPress sidebar register and display.
+ *
+ * @since 2.2.0
+ *
+ * @param int|string $index Optional, default is 1. Name or ID of dynamic sidebar.
+ * @return bool True, if widget sidebar was found and called. False if not found or not called.
+ */
+function dynamic_sidebar($index = 1) {
+	global $wp_registered_sidebars, $wp_registered_widgets;
+
+	if ( is_int($index) ) {
+		$index = "sidebar-$index";
+	} else {
+		$index = sanitize_title($index);
+		foreach ( (array) $wp_registered_sidebars as $key => $value ) {
+			if ( sanitize_title($value['name']) == $index ) {
+				$index = $key;
+				break;
+			}
+		}
+	}
+
+	$sidebars_widgets = wp_get_sidebars_widgets();
+
+	if ( empty($wp_registered_sidebars[$index]) || !array_key_exists($index, $sidebars_widgets) || !is_array($sidebars_widgets[$index]) || empty($sidebars_widgets[$index]) )
+		return false;
+
+	$sidebar = $wp_registered_sidebars[$index];
+
+	$did_one = false;
+	foreach ( (array) $sidebars_widgets[$index] as $id ) {
+
+		if ( !isset($wp_registered_widgets[$id]) ) continue;
+
+		$params = array_merge(
+			array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
+			(array) $wp_registered_widgets[$id]['params']
+		);
+
+		// Substitute HTML id and class attributes into before_widget
+		$classname_ = '';
+		foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
+			if ( is_string($cn) )
+				$classname_ .= '_' . $cn;
+			elseif ( is_object($cn) )
+				$classname_ .= '_' . get_class($cn);
+		}
+		$classname_ = ltrim($classname_, '_');
+		$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
+
+		$params = apply_filters( 'dynamic_sidebar_params', $params );
+
+		$callback = $wp_registered_widgets[$id]['callback'];
+
+		do_action( 'dynamic_sidebar', $wp_registered_widgets[$id] );
+
+		if ( is_callable($callback) ) {
+			call_user_func_array($callback, $params);
+			$did_one = true;
+		}
+	}
+
+	return $did_one;
+}
+
+/**
+ * Whether widget is displayied on the front-end.
+ *
+ * Either $callback or $id_base can be used
+ * $id_base is the first argument when extending WP_Widget class
+ * Without the optional $widget_id parameter, returns the ID of the first sidebar
+ * in which the first instance of the widget with the given callback or $id_base is found.
+ * With the $widget_id parameter, returns the ID of the sidebar where
+ * the widget with that callback/$id_base AND that ID is found.
+ *
+ * NOTE: $widget_id and $id_base are the same for single widgets. To be effective
+ * this function has to run after widgets have initialized, at action 'init' or later.
+ *
+ * @since 2.2.0
+ *
+ * @param string $callback Optional, Widget callback to check.
+ * @param int $widget_id Optional, but needed for checking. Widget ID.
+ * @param string $id_base Optional, the base ID of a widget created by extending WP_Widget.
+ * @param bool $skip_inactive Optional, whether to check in 'wp_inactive_widgets'.
+ * @return mixed false if widget is not active or id of sidebar in which the widget is active.
+ */
+function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true) {
+	global $wp_registered_widgets;
+
+	$sidebars_widgets = wp_get_sidebars_widgets();
+
+	if ( is_array($sidebars_widgets) ) {
+		foreach ( $sidebars_widgets as $sidebar => $widgets ) {
+			if ( $skip_inactive && 'wp_inactive_widgets' == $sidebar )
+				continue;
+
+			if ( is_array($widgets) ) {
+				foreach ( $widgets as $widget ) {
+					if ( ( $callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback ) || ( $id_base && _get_widget_id_base($widget) == $id_base ) ) {
+						if ( !$widget_id || $widget_id == $wp_registered_widgets[$widget]['id'] )
+							return $sidebar;
+					}
+				}
+			}
+		}
+	}
+	return false;
+}
+
+/**
+ * Whether the dynamic sidebar is enabled and used by theme.
+ *
+ * @since 2.2.0
+ *
+ * @return bool True, if using widgets. False, if not using widgets.
+ */
+function is_dynamic_sidebar() {
+	global $wp_registered_widgets, $wp_registered_sidebars;
+	$sidebars_widgets = get_option('sidebars_widgets');
+	foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
+		if ( count($sidebars_widgets[$index]) ) {
+			foreach ( (array) $sidebars_widgets[$index] as $widget )
+				if ( array_key_exists($widget, $wp_registered_widgets) )
+					return true;
+		}
+	}
+	return false;
+}
+
+/**
+ * Whether a sidebar is in use.
+ *
+ * @since 2.8
+ *
+ * @param mixed $index Sidebar name, id or number to check.
+ * @return bool true if the sidebar is in use, false otherwise.
+ */
+function is_active_sidebar( $index ) {
+	$index = ( is_int($index) ) ? "sidebar-$index" : sanitize_title($index);
+	$sidebars_widgets = wp_get_sidebars_widgets();
+	if ( !empty($sidebars_widgets[$index]) )
+		return true;
+
+	return false;
+}
+
+/* Internal Functions */
+
+/**
+ * Retrieve full list of sidebars and their widgets.
+ *
+ * Will upgrade sidebar widget list, if needed. Will also save updated list, if
+ * needed.
+ *
+ * @since 2.2.0
+ * @access private
+ *
+ * @param bool $deprecated Not used (deprecated).
+ * @return array Upgraded list of widgets to version 3 array format when called from the admin.
+ */
+function wp_get_sidebars_widgets($deprecated = true) {
+	if ( $deprecated !== true )
+		_deprecated_argument( __FUNCTION__, '2.8.1' );
+
+	global $wp_registered_widgets, $wp_registered_sidebars, $_wp_sidebars_widgets;
+
+	// If loading from front page, consult $_wp_sidebars_widgets rather than options
+	// to see if wp_convert_widget_settings() has made manipulations in memory.
+	if ( !is_admin() ) {
+		if ( empty($_wp_sidebars_widgets) )
+			$_wp_sidebars_widgets = get_option('sidebars_widgets', array());
+
+		$sidebars_widgets = $_wp_sidebars_widgets;
+	} else {
+		$sidebars_widgets = get_option('sidebars_widgets', array());
+		$_sidebars_widgets = array();
+
+		if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
+			$sidebars_widgets['array_version'] = 3;
+		elseif ( !isset($sidebars_widgets['array_version']) )
+			$sidebars_widgets['array_version'] = 1;
+
+		switch ( $sidebars_widgets['array_version'] ) {
+			case 1 :
+				foreach ( (array) $sidebars_widgets as $index => $sidebar )
+				if ( is_array($sidebar) )
+				foreach ( (array) $sidebar as $i => $name ) {
+					$id = strtolower($name);
+					if ( isset($wp_registered_widgets[$id]) ) {
+						$_sidebars_widgets[$index][$i] = $id;
+						continue;
+					}
+					$id = sanitize_title($name);
+					if ( isset($wp_registered_widgets[$id]) ) {
+						$_sidebars_widgets[$index][$i] = $id;
+						continue;
+					}
+
+					$found = false;
+
+					foreach ( $wp_registered_widgets as $widget_id => $widget ) {
+						if ( strtolower($widget['name']) == strtolower($name) ) {
+							$_sidebars_widgets[$index][$i] = $widget['id'];
+							$found = true;
+							break;
+						} elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {
+							$_sidebars_widgets[$index][$i] = $widget['id'];
+							$found = true;
+							break;
+						}
+					}
+
+					if ( $found )
+						continue;
+
+					unset($_sidebars_widgets[$index][$i]);
+				}
+				$_sidebars_widgets['array_version'] = 2;
+				$sidebars_widgets = $_sidebars_widgets;
+				unset($_sidebars_widgets);
+
+			case 2 :
+				$sidebars = array_keys( $wp_registered_sidebars );
+				if ( !empty( $sidebars ) ) {
+					// Move the known-good ones first
+					foreach ( (array) $sidebars as $id ) {
+						if ( array_key_exists( $id, $sidebars_widgets ) ) {
+							$_sidebars_widgets[$id] = $sidebars_widgets[$id];
+							unset($sidebars_widgets[$id], $sidebars[$id]);
+						}
+					}
+
+					// move the rest to wp_inactive_widgets
+					if ( !isset($_sidebars_widgets['wp_inactive_widgets']) )
+						$_sidebars_widgets['wp_inactive_widgets'] = array();
+
+					if ( !empty($sidebars_widgets) ) {
+						foreach ( $sidebars_widgets as $lost => $val ) {
+							if ( is_array($val) )
+								$_sidebars_widgets['wp_inactive_widgets'] = array_merge( (array) $_sidebars_widgets['wp_inactive_widgets'], $val );
+						}
+					}
+
+					$sidebars_widgets = $_sidebars_widgets;
+					unset($_sidebars_widgets);
+				}
+		}
+	}
+
+	if ( is_array( $sidebars_widgets ) && isset($sidebars_widgets['array_version']) )
+		unset($sidebars_widgets['array_version']);
+
+	$sidebars_widgets = apply_filters('sidebars_widgets', $sidebars_widgets);
+	return $sidebars_widgets;
+}
+
+/**
+ * Set the sidebar widget option to update sidebars.
+ *
+ * @since 2.2.0
+ * @access private
+ *
+ * @param array $sidebars_widgets Sidebar widgets and their settings.
+ */
+function wp_set_sidebars_widgets( $sidebars_widgets ) {
+	if ( !isset( $sidebars_widgets['array_version'] ) )
+		$sidebars_widgets['array_version'] = 3;
+	update_option( 'sidebars_widgets', $sidebars_widgets );
+}
+
+/**
+ * Retrieve default registered sidebars list.
+ *
+ * @since 2.2.0
+ * @access private
+ *
+ * @return array
+ */
+function wp_get_widget_defaults() {
+	global $wp_registered_sidebars;
+
+	$defaults = array();
+
+	foreach ( (array) $wp_registered_sidebars as $index => $sidebar )
+		$defaults[$index] = array();
+
+	return $defaults;
+}
+
+/**
+ * Convert the widget settings from single to multi-widget format.
+ *
+ * @since 2.8.0
+ *
+ * @return array
+ */
+function wp_convert_widget_settings($base_name, $option_name, $settings) {
+	// This test may need expanding.
+	$single = $changed = false;
+	if ( empty($settings) ) {
+		$single = true;
+	} else {
+		foreach ( array_keys($settings) as $number ) {
+			if ( 'number' == $number )
+				continue;
+			if ( !is_numeric($number) ) {
+				$single = true;
+				break;
+			}
+		}
+	}
+
+	if ( $single ) {
+		$settings = array( 2 => $settings );
+
+		// If loading from the front page, update sidebar in memory but don't save to options
+		if ( is_admin() ) {
+			$sidebars_widgets = get_option('sidebars_widgets');
+		} else {
+			if ( empty($GLOBALS['_wp_sidebars_widgets']) )
+				$GLOBALS['_wp_sidebars_widgets'] = get_option('sidebars_widgets', array());
+			$sidebars_widgets = &$GLOBALS['_wp_sidebars_widgets'];
+		}
+
+		foreach ( (array) $sidebars_widgets as $index => $sidebar ) {
+			if ( is_array($sidebar) ) {
+				foreach ( $sidebar as $i => $name ) {
+					if ( $base_name == $name ) {
+						$sidebars_widgets[$index][$i] = "$name-2";
+						$changed = true;
+						break 2;
+					}
+				}
+			}
+		}
+
+		if ( is_admin() && $changed )
+			update_option('sidebars_widgets', $sidebars_widgets);
+	}
+
+	$settings['_multiwidget'] = 1;
+	if ( is_admin() )
+		update_option( $option_name, $settings );
+
+	return $settings;
+}
+
+/**
+ * Output an arbitrary widget as a template tag
+ *
+ * @since 2.8
+ *
+ * @param string $widget the widget's PHP class name (see default-widgets.php)
+ * @param array $instance the widget's instance settings
+ * @param array $args the widget's sidebar args
+ * @return void
+ **/
+function the_widget($widget, $instance = array(), $args = array()) {
+	global $wp_widget_factory;
+
+	$widget_obj = $wp_widget_factory->widgets[$widget];
+	if ( !is_a($widget_obj, 'WP_Widget') )
+		return;
+
+	$before_widget = sprintf('<div class="widget %s">', $widget_obj->widget_options['classname']);
+	$default_args = array('before_widget' => $before_widget, 'after_widget' => "</div>", 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>');
+
+	$args = wp_parse_args($args, $default_args);
+	$instance = wp_parse_args($instance);
+
+	do_action( 'the_widget', $widget, $instance, $args );
+
+	$widget_obj->_set(-1);
+	$widget_obj->widget($args, $instance);
+}
+
+/**
+ * Private
+ */
+function _get_widget_id_base($id) {
+	return preg_replace( '/-[0-9]+$/', '', $id );
+}
Index: /tags/3.1/wp-includes/wlwmanifest.xml
===================================================================
--- /tags/3.1/wp-includes/wlwmanifest.xml	(revision 17487)
+++ /tags/3.1/wp-includes/wlwmanifest.xml	(revision 17487)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8" ?>
+
+<manifest xmlns="http://schemas.microsoft.com/wlw/manifest/weblog">
+
+  <options>
+    <clientType>WordPress</clientType>
+	<supportsKeywords>Yes</supportsKeywords>
+	<supportsGetTags>Yes</supportsGetTags>
+  </options>
+  
+  <weblog>
+    <serviceName>WordPress</serviceName>
+    <imageUrl>images/wlw/wp-icon.png</imageUrl>
+    <watermarkImageUrl>images/wlw/wp-watermark.png</watermarkImageUrl>
+    <homepageLinkText>View site</homepageLinkText>
+    <adminLinkText>Dashboard</adminLinkText>
+    <adminUrl>
+      <![CDATA[ 
+			{blog-postapi-url}/../wp-admin/ 
+		]]>
+    </adminUrl>
+    <postEditingUrl>
+      <![CDATA[ 
+			{blog-postapi-url}/../wp-admin/post.php?action=edit&post={post-id} 
+		]]>
+    </postEditingUrl>
+  </weblog>
+
+  <buttons>
+    <button>
+      <id>0</id>
+      <text>Manage Comments</text>
+      <imageUrl>images/wlw/wp-comments.png</imageUrl>
+      <clickUrl>
+        <![CDATA[ 
+				{blog-postapi-url}/../wp-admin/edit-comments.php
+			]]>
+      </clickUrl>
+    </button>
+
+  </buttons>
+
+</manifest>
+
Index: /tags/3.1/wp-includes/wp-db.php
===================================================================
--- /tags/3.1/wp-includes/wp-db.php	(revision 17487)
+++ /tags/3.1/wp-includes/wp-db.php	(revision 17487)
@@ -0,0 +1,1576 @@
+<?php
+/**
+ * WordPress DB Class
+ *
+ * Original code from {@link http://php.justinvincent.com Justin Vincent (justin@visunet.ie)}
+ *
+ * @package WordPress
+ * @subpackage Database
+ * @since 0.71
+ */
+
+/**
+ * @since 0.71
+ */
+define( 'EZSQL_VERSION', 'WP1.25' );
+
+/**
+ * @since 0.71
+ */
+define( 'OBJECT', 'OBJECT', true );
+
+/**
+ * @since 2.5.0
+ */
+define( 'OBJECT_K', 'OBJECT_K' );
+
+/**
+ * @since 0.71
+ */
+define( 'ARRAY_A', 'ARRAY_A' );
+
+/**
+ * @since 0.71
+ */
+define( 'ARRAY_N', 'ARRAY_N' );
+
+/**
+ * WordPress Database Access Abstraction Object
+ *
+ * It is possible to replace this class with your own
+ * by setting the $wpdb global variable in wp-content/db.php
+ * file with your class. You can name it wpdb also, since
+ * this file will not be included, if the other file is
+ * available.
+ *
+ * @link http://codex.wordpress.org/Function_Reference/wpdb_Class
+ *
+ * @package WordPress
+ * @subpackage Database
+ * @since 0.71
+ */
+class wpdb {
+
+	/**
+	 * Whether to show SQL/DB errors
+	 *
+	 * @since 0.71
+	 * @access private
+	 * @var bool
+	 */
+	var $show_errors = false;
+
+	/**
+	 * Whether to suppress errors during the DB bootstrapping.
+	 *
+	 * @access private
+	 * @since 2.5.0
+	 * @var bool
+	 */
+	var $suppress_errors = false;
+
+	/**
+	 * The last error during query.
+	 *
+	 * @see get_last_error()
+	 * @since 2.5.0
+	 * @access private
+	 * @var string
+	 */
+	var $last_error = '';
+
+	/**
+	 * Amount of queries made
+	 *
+	 * @since 1.2.0
+	 * @access private
+	 * @var int
+	 */
+	var $num_queries = 0;
+
+	/**
+	 * Count of rows returned by previous query
+	 *
+	 * @since 1.2.0
+	 * @access private
+	 * @var int
+	 */
+	var $num_rows = 0;
+
+	/**
+	 * Count of affected rows by previous query
+	 *
+	 * @since 0.71
+	 * @access private
+	 * @var int
+	 */
+	var $rows_affected = 0;
+
+	/**
+	 * The ID generated for an AUTO_INCREMENT column by the previous query (usually INSERT).
+	 *
+	 * @since 0.71
+	 * @access public
+	 * @var int
+	 */
+	var $insert_id = 0;
+
+	/**
+	 * Saved result of the last query made
+	 *
+	 * @since 1.2.0
+	 * @access private
+	 * @var array
+	 */
+	var $last_query;
+
+	/**
+	 * Results of the last query made
+	 *
+	 * @since 1.0.0
+	 * @access private
+	 * @var array|null
+	 */
+	var $last_result;
+
+	/**
+	 * Saved info on the table column
+	 *
+	 * @since 1.2.0
+	 * @access private
+	 * @var array
+	 */
+	var $col_info;
+
+	/**
+	 * Saved queries that were executed
+	 *
+	 * @since 1.5.0
+	 * @access private
+	 * @var array
+	 */
+	var $queries;
+
+	/**
+	 * WordPress table prefix
+	 *
+	 * You can set this to have multiple WordPress installations
+	 * in a single database. The second reason is for possible
+	 * security precautions.
+	 *
+	 * @since 0.71
+	 * @access private
+	 * @var string
+	 */
+	var $prefix = '';
+
+	/**
+	 * Whether the database queries are ready to start executing.
+	 *
+	 * @since 2.5.0
+	 * @access private
+	 * @var bool
+	 */
+	var $ready = false;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var int
+	 */
+	var $blogid = 0;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var int
+	 */
+	var $siteid = 0;
+
+	/**
+	 * List of WordPress per-blog tables
+	 *
+	 * @since 2.5.0
+	 * @access private
+	 * @see wpdb::tables()
+	 * @var array
+	 */
+	var $tables = array( 'posts', 'comments', 'links', 'options', 'postmeta',
+		'terms', 'term_taxonomy', 'term_relationships', 'commentmeta' );
+
+	/**
+	 * List of deprecated WordPress tables
+	 *
+	 * categories, post2cat, and link2cat were deprecated in 2.3.0, db version 5539
+	 *
+	 * @since 2.9.0
+	 * @access private
+	 * @see wpdb::tables()
+	 * @var array
+	 */
+	var $old_tables = array( 'categories', 'post2cat', 'link2cat' );
+
+	/**
+	 * List of WordPress global tables
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 * @see wpdb::tables()
+	 * @var array
+	 */
+	var $global_tables = array( 'users', 'usermeta' );
+
+	/**
+	 * List of Multisite global tables
+	 *
+	 * @since 3.0.0
+	 * @access private
+	 * @see wpdb::tables()
+	 * @var array
+	 */
+	var $ms_global_tables = array( 'blogs', 'signups', 'site', 'sitemeta',
+		'sitecategories', 'registration_log', 'blog_versions' );
+
+	/**
+	 * WordPress Comments table
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var string
+	 */
+	var $comments;
+
+	/**
+	 * WordPress Comment Metadata table
+	 *
+	 * @since 2.9.0
+	 * @access public
+	 * @var string
+	 */
+	var $commentmeta;
+
+	/**
+	 * WordPress Links table
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var string
+	 */
+	var $links;
+
+	/**
+	 * WordPress Options table
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var string
+	 */
+	var $options;
+
+	/**
+	 * WordPress Post Metadata table
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var string
+	 */
+	var $postmeta;
+
+	/**
+	 * WordPress Posts table
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var string
+	 */
+	var $posts;
+
+	/**
+	 * WordPress Terms table
+	 *
+	 * @since 2.3.0
+	 * @access public
+	 * @var string
+	 */
+	var $terms;
+
+	/**
+	 * WordPress Term Relationships table
+	 *
+	 * @since 2.3.0
+	 * @access public
+	 * @var string
+	 */
+	var $term_relationships;
+
+	/**
+	 * WordPress Term Taxonomy table
+	 *
+	 * @since 2.3.0
+	 * @access public
+	 * @var string
+	 */
+	var $term_taxonomy;
+
+	/*
+	 * Global and Multisite tables
+	 */
+
+	/**
+	 * WordPress User Metadata table
+	 *
+	 * @since 2.3.0
+	 * @access public
+	 * @var string
+	 */
+	var $usermeta;
+
+	/**
+	 * WordPress Users table
+	 *
+	 * @since 1.5.0
+	 * @access public
+	 * @var string
+	 */
+	var $users;
+
+	/**
+	 * Multisite Blogs table
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $blogs;
+
+	/**
+	 * Multisite Blog Versions table
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $blog_versions;
+
+	/**
+	 * Multisite Registration Log table
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $registration_log;
+
+	/**
+	 * Multisite Signups table
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $signups;
+
+	/**
+	 * Multisite Sites table
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $site;
+
+	/**
+	 * Multisite Sitewide Terms table
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $sitecategories;
+
+	/**
+	 * Multisite Site Metadata table
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $sitemeta;
+
+	/**
+	 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized during WP load.
+	 *
+	 * Keys are column names, values are format types: 'ID' => '%d'
+	 *
+	 * @since 2.8.0
+	 * @see wpdb:prepare()
+	 * @see wpdb:insert()
+	 * @see wpdb:update()
+	 * @see wp_set_wpdb_vars()
+	 * @access public
+	 * @var array
+	 */
+	var $field_types = array();
+
+	/**
+	 * Database table columns charset
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @var string
+	 */
+	var $charset;
+
+	/**
+	 * Database table columns collate
+	 *
+	 * @since 2.2.0
+	 * @access public
+	 * @var string
+	 */
+	var $collate;
+
+	/**
+	 * Whether to use mysql_real_escape_string
+	 *
+	 * @since 2.8.0
+	 * @access public
+	 * @var bool
+	 */
+	var $real_escape = false;
+
+	/**
+	 * Database Username
+	 *
+	 * @since 2.9.0
+	 * @access private
+	 * @var string
+	 */
+	var $dbuser;
+
+	/**
+	 * A textual description of the last query/get_row/get_var call
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @var string
+	 */
+	var $func_call;
+
+	/**
+	 * Connects to the database server and selects a database
+	 *
+	 * PHP4 compatibility layer for calling the PHP5 constructor.
+	 *
+	 * @uses wpdb::__construct() Passes parameters and returns result
+	 * @since 0.71
+	 *
+	 * @param string $dbuser MySQL database user
+	 * @param string $dbpassword MySQL database password
+	 * @param string $dbname MySQL database name
+	 * @param string $dbhost MySQL database host
+	 */
+	function wpdb( $dbuser, $dbpassword, $dbname, $dbhost ) {
+		return $this->__construct( $dbuser, $dbpassword, $dbname, $dbhost );
+	}
+
+	/**
+	 * Connects to the database server and selects a database
+	 *
+	 * PHP5 style constructor for compatibility with PHP5. Does
+	 * the actual setting up of the class properties and connection
+	 * to the database.
+	 *
+	 * @link http://core.trac.wordpress.org/ticket/3354
+	 * @since 2.0.8
+	 *
+	 * @param string $dbuser MySQL database user
+	 * @param string $dbpassword MySQL database password
+	 * @param string $dbname MySQL database name
+	 * @param string $dbhost MySQL database host
+	 */
+	function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
+		register_shutdown_function( array( &$this, '__destruct' ) );
+
+		if ( WP_DEBUG )
+			$this->show_errors();
+
+		$this->init_charset();
+
+		$this->dbuser = $dbuser;
+		$this->dbpassword = $dbpassword;
+		$this->dbname = $dbname;
+		$this->dbhost = $dbhost;
+
+		$this->db_connect();
+	}
+
+	/**
+	 * PHP5 style destructor and will run when database object is destroyed.
+	 *
+	 * @see wpdb::__construct()
+	 * @since 2.0.8
+	 * @return bool true
+	 */
+	function __destruct() {
+		return true;
+	}
+
+	/**
+	 * Set $this->charset and $this->collate
+	 *
+	 * @since 3.1.0
+	 */
+	function init_charset() {
+		if ( function_exists('is_multisite') && is_multisite() ) {
+			$this->charset = 'utf8';
+			if ( defined( 'DB_COLLATE' ) && DB_COLLATE )
+				$this->collate = DB_COLLATE;
+			else
+				$this->collate = 'utf8_general_ci';
+		} elseif ( defined( 'DB_COLLATE' ) ) {
+			$this->collate = DB_COLLATE;
+		}
+
+		if ( defined( 'DB_CHARSET' ) )
+			$this->charset = DB_CHARSET;
+	}
+
+	/**
+	 * Sets the connection's character set.
+	 *
+	 * @since 3.1.0
+	 *
+	 * @param resource $dbh     The resource given by mysql_connect
+	 * @param string   $charset The character set (optional)
+	 * @param string   $collate The collation (optional)
+	 */
+	function set_charset($dbh, $charset = null, $collate = null) {
+		if ( !isset($charset) )
+			$charset = $this->charset;
+		if ( !isset($collate) )
+			$collate = $this->collate;
+		if ( $this->has_cap( 'collation', $dbh ) && !empty( $charset ) ) {
+			if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset', $dbh ) ) {
+				mysql_set_charset( $charset, $dbh );
+				$this->real_escape = true;
+			} else {
+				$query = $this->prepare( 'SET NAMES %s', $charset );
+				if ( ! empty( $collate ) )
+					$query .= $this->prepare( ' COLLATE %s', $collate );
+				mysql_query( $query, $dbh );
+			}
+		}
+	}
+
+	/**
+	 * Sets the table prefix for the WordPress tables.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @param string $prefix Alphanumeric name for the new prefix.
+	 * @return string|WP_Error Old prefix or WP_Error on error
+	 */
+	function set_prefix( $prefix, $set_table_names = true ) {
+
+		if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
+			return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/);
+
+		$old_prefix = is_multisite() ? '' : $prefix;
+
+		if ( isset( $this->base_prefix ) )
+			$old_prefix = $this->base_prefix;
+
+		$this->base_prefix = $prefix;
+
+		if ( $set_table_names ) {
+			foreach ( $this->tables( 'global' ) as $table => $prefixed_table )
+				$this->$table = $prefixed_table;
+
+			if ( is_multisite() && empty( $this->blogid ) )
+				return $old_prefix;
+
+			$this->prefix = $this->get_blog_prefix();
+
+			foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
+				$this->$table = $prefixed_table;
+
+			foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
+				$this->$table = $prefixed_table;
+		}
+		return $old_prefix;
+	}
+
+	/**
+	 * Sets blog id.
+	 *
+	 * @since 3.0.0
+	 * @access public
+	 * @param int $blog_id
+	 * @param int $site_id Optional.
+	 * @return string previous blog id
+	 */
+	function set_blog_id( $blog_id, $site_id = 0 ) {
+		if ( ! empty( $site_id ) )
+			$this->siteid = $site_id;
+
+		$old_blog_id  = $this->blogid;
+		$this->blogid = $blog_id;
+
+		$this->prefix = $this->get_blog_prefix();
+
+		foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
+			$this->$table = $prefixed_table;
+
+		foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
+			$this->$table = $prefixed_table;
+
+		return $old_blog_id;
+	}
+
+	/**
+	 * Gets blog prefix.
+	 *
+	 * @uses is_multisite()
+	 * @since 3.0.0
+	 * @param int $blog_id Optional.
+	 * @return string Blog prefix.
+	 */
+	function get_blog_prefix( $blog_id = null ) {
+		if ( is_multisite() ) {
+			if ( null === $blog_id )
+				$blog_id = $this->blogid;
+			if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) )
+				return $this->base_prefix;
+			else
+				return $this->base_prefix . $blog_id . '_';
+		} else {
+			return $this->base_prefix;
+		}
+	}
+
+	/**
+	 * Returns an array of WordPress tables.
+	 *
+	 * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to
+	 * override the WordPress users and usersmeta tables that would otherwise
+	 * be determined by the prefix.
+	 *
+	 * The scope argument can take one of the following:
+	 *
+	 * 'all' - returns 'all' and 'global' tables. No old tables are returned.
+	 * 'blog' - returns the blog-level tables for the queried blog.
+	 * 'global' - returns the global tables for the installation, returning multisite tables only if running multisite.
+	 * 'ms_global' - returns the multisite global tables, regardless if current installation is multisite.
+	 * 'old' - returns tables which are deprecated.
+	 *
+	 * @since 3.0.0
+	 * @uses wpdb::$tables
+	 * @uses wpdb::$old_tables
+	 * @uses wpdb::$global_tables
+	 * @uses wpdb::$ms_global_tables
+	 * @uses is_multisite()
+	 *
+	 * @param string $scope Optional. Can be all, global, ms_global, blog, or old tables. Defaults to all.
+	 * @param bool $prefix Optional. Whether to include table prefixes. Default true. If blog
+	 * 	prefix is requested, then the custom users and usermeta tables will be mapped.
+	 * @param int $blog_id Optional. The blog_id to prefix. Defaults to wpdb::$blogid. Used only when prefix is requested.
+	 * @return array Table names. When a prefix is requested, the key is the unprefixed table name.
+	 */
+	function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
+		switch ( $scope ) {
+			case 'all' :
+				$tables = array_merge( $this->global_tables, $this->tables );
+				if ( is_multisite() )
+					$tables = array_merge( $tables, $this->ms_global_tables );
+				break;
+			case 'blog' :
+				$tables = $this->tables;
+				break;
+			case 'global' :
+				$tables = $this->global_tables;
+				if ( is_multisite() )
+					$tables = array_merge( $tables, $this->ms_global_tables );
+				break;
+			case 'ms_global' :
+				$tables = $this->ms_global_tables;
+				break;
+			case 'old' :
+				$tables = $this->old_tables;
+				break;
+			default :
+				return array();
+				break;
+		}
+
+		if ( $prefix ) {
+			if ( ! $blog_id )
+				$blog_id = $this->blogid;
+			$blog_prefix = $this->get_blog_prefix( $blog_id );
+			$base_prefix = $this->base_prefix;
+			$global_tables = array_merge( $this->global_tables, $this->ms_global_tables );
+			foreach ( $tables as $k => $table ) {
+				if ( in_array( $table, $global_tables ) )
+					$tables[ $table ] = $base_prefix . $table;
+				else
+					$tables[ $table ] = $blog_prefix . $table;
+				unset( $tables[ $k ] );
+			}
+
+			if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) )
+				$tables['users'] = CUSTOM_USER_TABLE;
+
+			if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) )
+				$tables['usermeta'] = CUSTOM_USER_META_TABLE;
+		}
+
+		return $tables;
+	}
+
+	/**
+	 * Selects a database using the current database connection.
+	 *
+	 * The database name will be changed based on the current database
+	 * connection. On failure, the execution will bail and display an DB error.
+	 *
+	 * @since 0.71
+	 *
+	 * @param string $db MySQL database name
+	 * @param resource $dbh Optional link identifier.
+	 * @return null Always null.
+	 */
+	function select( $db, $dbh = null) {
+		if ( is_null($dbh) )
+			$dbh = $this->dbh;
+
+		if ( !@mysql_select_db( $db, $dbh ) ) {
+			$this->ready = false;
+			$this->bail( sprintf( /*WP_I18N_DB_SELECT_DB*/'<h1>Can&#8217;t select database</h1>
+<p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>%1$s</code> database.</p>
+<ul>
+<li>Are you sure it exists?</li>
+<li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
+<li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li>
+</ul>
+<p>If you don\'t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="http://wordpress.org/support/">WordPress Support Forums</a>.</p>'/*/WP_I18N_DB_SELECT_DB*/, $db, $this->dbuser ), 'db_select_fail' );
+			return;
+		}
+	}
+
+	/**
+	 * Weak escape, using addslashes()
+	 *
+	 * @see addslashes()
+	 * @since 2.8.0
+	 * @access private
+	 *
+	 * @param string $string
+	 * @return string
+	 */
+	function _weak_escape( $string ) {
+		return addslashes( $string );
+	}
+
+	/**
+	 * Real escape, using mysql_real_escape_string() or addslashes()
+	 *
+	 * @see mysql_real_escape_string()
+	 * @see addslashes()
+	 * @since 2.8.0
+	 * @access private
+	 *
+	 * @param  string $string to escape
+	 * @return string escaped
+	 */
+	function _real_escape( $string ) {
+		if ( $this->dbh && $this->real_escape )
+			return mysql_real_escape_string( $string, $this->dbh );
+		else
+			return addslashes( $string );
+	}
+
+	/**
+	 * Escape data. Works on arrays.
+	 *
+	 * @uses wpdb::_escape()
+	 * @uses wpdb::_real_escape()
+	 * @since  2.8.0
+	 * @access private
+	 *
+	 * @param  string|array $data
+	 * @return string|array escaped
+	 */
+	function _escape( $data ) {
+		if ( is_array( $data ) ) {
+			foreach ( (array) $data as $k => $v ) {
+				if ( is_array($v) )
+					$data[$k] = $this->_escape( $v );
+				else
+					$data[$k] = $this->_real_escape( $v );
+			}
+		} else {
+			$data = $this->_real_escape( $data );
+		}
+
+		return $data;
+	}
+
+	/**
+	 * Escapes content for insertion into the database using addslashes(), for security.
+	 *
+	 * Works on arrays.
+	 *
+	 * @since 0.71
+	 * @param string|array $data to escape
+	 * @return string|array escaped as query safe string
+	 */
+	function escape( $data ) {
+		if ( is_array( $data ) ) {
+			foreach ( (array) $data as $k => $v ) {
+				if ( is_array( $v ) )
+					$data[$k] = $this->escape( $v );
+				else
+					$data[$k] = $this->_weak_escape( $v );
+			}
+		} else {
+			$data = $this->_weak_escape( $data );
+		}
+
+		return $data;
+	}
+
+	/**
+	 * Escapes content by reference for insertion into the database, for security
+	 *
+	 * @uses wpdb::_real_escape()
+	 * @since 2.3.0
+	 * @param string $string to escape
+	 * @return void
+	 */
+	function escape_by_ref( &$string ) {
+		$string = $this->_real_escape( $string );
+	}
+
+	/**
+	 * Prepares a SQL query for safe execution. Uses sprintf()-like syntax.
+	 *
+	 * The following directives can be used in the query format string:
+	 *   %d (decimal number)
+	 *   %s (string)
+	 *   %% (literal percentage sign - no argument needed)
+	 *
+	 * Both %d and %s are to be left unquoted in the query string and they need an argument passed for them.
+	 * Literals (%) as parts of the query must be properly written as %%.
+	 *
+	 * This function only supports a small subset of the sprintf syntax; it only supports %d (decimal number), %s (string).
+	 * Does not support sign, padding, alignment, width or precision specifiers.
+	 * Does not support argument numbering/swapping.
+	 *
+	 * May be called like {@link http://php.net/sprintf sprintf()} or like {@link http://php.net/vsprintf vsprintf()}.
+	 *
+	 * Both %d and %s should be left unquoted in the query string.
+	 *
+	 * <code>
+	 * wpdb::prepare( "SELECT * FROM `table` WHERE `column` = %s AND `field` = %d", 'foo', 1337 )
+	 * wpdb::prepare( "SELECT DATE_FORMAT(`field`, '%%c') FROM `table` WHERE `column` = %s", 'foo' );
+	 * </code>
+	 *
+	 * @link http://php.net/sprintf Description of syntax.
+	 * @since 2.3.0
+	 *
+	 * @param string $query Query statement with sprintf()-like placeholders
+	 * @param array|mixed $args The array of variables to substitute into the query's placeholders if being called like
+	 * 	{@link http://php.net/vsprintf vsprintf()}, or the first variable to substitute into the query's placeholders if
+	 * 	being called like {@link http://php.net/sprintf sprintf()}.
+	 * @param mixed $args,... further variables to substitute into the query's placeholders if being called like
+	 * 	{@link http://php.net/sprintf sprintf()}.
+	 * @return null|false|string Sanitized query string, null if there is no query, false if there is an error and string
+	 * 	if there was something to prepare
+	 */
+	function prepare( $query = null ) { // ( $query, *$args )
+		if ( is_null( $query ) )
+			return;
+
+		$args = func_get_args();
+		array_shift( $args );
+		// If args were passed as an array (as in vsprintf), move them up
+		if ( isset( $args[0] ) && is_array($args[0]) )
+			$args = $args[0];
+		$query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
+		$query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
+		$query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s
+		array_walk( $args, array( &$this, 'escape_by_ref' ) );
+		return @vsprintf( $query, $args );
+	}
+
+	/**
+	 * Print SQL/DB error.
+	 *
+	 * @since 0.71
+	 * @global array $EZSQL_ERROR Stores error information of query and error string
+	 *
+	 * @param string $str The error to display
+	 * @return bool False if the showing of errors is disabled.
+	 */
+	function print_error( $str = '' ) {
+		global $EZSQL_ERROR;
+
+		if ( !$str )
+			$str = mysql_error( $this->dbh );
+		$EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str );
+
+		if ( $this->suppress_errors )
+			return false;
+
+		if ( $caller = $this->get_caller() )
+			$error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR_FULL*/'WordPress database error %1$s for query %2$s made by %3$s'/*/WP_I18N_DB_QUERY_ERROR_FULL*/, $str, $this->last_query, $caller );
+		else
+			$error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR*/'WordPress database error %1$s for query %2$s'/*/WP_I18N_DB_QUERY_ERROR*/, $str, $this->last_query );
+
+		if ( function_exists( 'error_log' )
+			&& ( $log_file = @ini_get( 'error_log' ) )
+			&& ( 'syslog' == $log_file || @is_writable( $log_file ) )
+			)
+			@error_log( $error_str );
+
+		// Are we showing errors?
+		if ( ! $this->show_errors )
+			return false;
+
+		// If there is an error then take note of it
+		if ( is_multisite() ) {
+			$msg = "WordPress database error: [$str]\n{$this->last_query}\n";
+			if ( defined( 'ERRORLOGFILE' ) )
+				error_log( $msg, 3, ERRORLOGFILE );
+			if ( defined( 'DIEONDBERROR' ) )
+				wp_die( $msg );
+		} else {
+			$str   = htmlspecialchars( $str, ENT_QUOTES );
+			$query = htmlspecialchars( $this->last_query, ENT_QUOTES );
+
+			print "<div id='error'>
+			<p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
+			<code>$query</code></p>
+			</div>";
+		}
+	}
+
+	/**
+	 * Enables showing of database errors.
+	 *
+	 * This function should be used only to enable showing of errors.
+	 * wpdb::hide_errors() should be used instead for hiding of errors. However,
+	 * this function can be used to enable and disable showing of database
+	 * errors.
+	 *
+	 * @since 0.71
+	 * @see wpdb::hide_errors()
+	 *
+	 * @param bool $show Whether to show or hide errors
+	 * @return bool Old value for showing errors.
+	 */
+	function show_errors( $show = true ) {
+		$errors = $this->show_errors;
+		$this->show_errors = $show;
+		return $errors;
+	}
+
+	/**
+	 * Disables showing of database errors.
+	 *
+	 * By default database errors are not shown.
+	 *
+	 * @since 0.71
+	 * @see wpdb::show_errors()
+	 *
+	 * @return bool Whether showing of errors was active
+	 */
+	function hide_errors() {
+		$show = $this->show_errors;
+		$this->show_errors = false;
+		return $show;
+	}
+
+	/**
+	 * Whether to suppress database errors.
+	 *
+	 * By default database errors are suppressed, with a simple
+	 * call to this function they can be enabled.
+	 *
+	 * @since 2.5.0
+	 * @see wpdb::hide_errors()
+	 * @param bool $suppress Optional. New value. Defaults to true.
+	 * @return bool Old value
+	 */
+	function suppress_errors( $suppress = true ) {
+		$errors = $this->suppress_errors;
+		$this->suppress_errors = (bool) $suppress;
+		return $errors;
+	}
+
+	/**
+	 * Kill cached query results.
+	 *
+	 * @since 0.71
+	 * @return void
+	 */
+	function flush() {
+		$this->last_result = array();
+		$this->col_info    = null;
+		$this->last_query  = null;
+	}
+
+	/**
+	 * Connect to and select database
+	 *
+	 * @since 3.0.0
+	 */
+	function db_connect() {
+		global $db_list, $global_db_list;
+
+		if ( WP_DEBUG ) {
+			$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true );
+		} else {
+			$this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true );
+		}
+
+		if ( !$this->dbh ) {
+			$this->bail( sprintf( /*WP_I18N_DB_CONN_ERROR*/"
+<h1>Error establishing a database connection</h1>
+<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>
+<ul>
+	<li>Are you sure you have the correct username and password?</li>
+	<li>Are you sure that you have typed the correct hostname?</li>
+	<li>Are you sure that the database server is running?</li>
+</ul>
+<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
+"/*/WP_I18N_DB_CONN_ERROR*/, $this->dbhost ), 'db_connect_fail' );
+
+			// If show errors is disabled then we need to die anyway as we don't have a working DB connection
+			// unless we're trying to test the initial connection, in which case setup-config.php will handle.
+			if ( defined( 'WP_SETUP_CONFIG' ) )
+				return;
+
+			die();
+		}
+
+		$this->set_charset( $this->dbh );
+
+		$this->ready = true;
+
+		$this->select( $this->dbname, $this->dbh );
+	}
+
+	/**
+	 * Perform a MySQL database query, using current database connection.
+	 *
+	 * More information can be found on the codex page.
+	 *
+	 * @since 0.71
+	 *
+	 * @param string $query Database query
+	 * @return int|false Number of rows affected/selected or false on error
+	 */
+	function query( $query ) {
+		if ( ! $this->ready )
+			return false;
+
+		// some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
+		if ( function_exists( 'apply_filters' ) )
+			$query = apply_filters( 'query', $query );
+
+		$return_val = 0;
+		$this->flush();
+
+		// Log how the function was called
+		$this->func_call = "\$db->query(\"$query\")";
+
+		// Keep track of the last query for debug..
+		$this->last_query = $query;
+
+		if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
+			$this->timer_start();
+
+		$this->result = @mysql_query( $query, $this->dbh );
+		$this->num_queries++;
+
+		if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
+			$this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() );
+
+		// If there is an error then take note of it..
+		if ( $this->last_error = mysql_error( $this->dbh ) ) {
+			$this->print_error();
+			return false;
+		}
+
+		if ( preg_match( "/^\\s*(insert|delete|update|replace|alter) /i", $query ) ) {
+			$this->rows_affected = mysql_affected_rows( $this->dbh );
+			// Take note of the insert_id
+			if ( preg_match( "/^\\s*(insert|replace) /i", $query ) ) {
+				$this->insert_id = mysql_insert_id($this->dbh);
+			}
+			// Return number of rows affected
+			$return_val = $this->rows_affected;
+		} else {
+			$i = 0;
+			while ( $i < @mysql_num_fields( $this->result ) ) {
+				$this->col_info[$i] = @mysql_fetch_field( $this->result );
+				$i++;
+			}
+			$num_rows = 0;
+			while ( $row = @mysql_fetch_object( $this->result ) ) {
+				$this->last_result[$num_rows] = $row;
+				$num_rows++;
+			}
+
+			@mysql_free_result( $this->result );
+
+			// Log number of rows the query returned
+			// and return number of rows selected
+			$this->num_rows = $num_rows;
+			$return_val     = $num_rows;
+		}
+
+		return $return_val;
+	}
+
+	/**
+	 * Insert a row into a table.
+	 *
+	 * <code>
+	 * wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 'bar' ) )
+	 * wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) )
+	 * </code>
+	 *
+	 * @since 2.5.0
+	 * @see wpdb::prepare()
+	 * @see wpdb::$field_types
+	 * @see wp_set_wpdb_vars()
+	 *
+	 * @param string $table table name
+	 * @param array $data Data to insert (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
+	 * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data.
+	 * 	A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
+	 * @return int|false The number of rows inserted, or false on error.
+	 */
+	function insert( $table, $data, $format = null ) {
+		return $this->_insert_replace_helper( $table, $data, $format, 'INSERT' );
+	}
+
+	/**
+	 * Replace a row into a table.
+	 *
+	 * <code>
+	 * wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 'bar' ) )
+	 * wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) )
+	 * </code>
+	 *
+	 * @since 3.0.0
+	 * @see wpdb::prepare()
+	 * @see wpdb::$field_types
+	 * @see wp_set_wpdb_vars()
+	 *
+	 * @param string $table table name
+	 * @param array $data Data to insert (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
+	 * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data.
+	 * 	A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
+	 * @return int|false The number of rows affected, or false on error.
+	 */
+	function replace( $table, $data, $format = null ) {
+		return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' );
+	}
+
+	/**
+	 * Helper function for insert and replace.
+	 *
+	 * Runs an insert or replace query based on $type argument.
+	 *
+	 * @access private
+	 * @since 3.0.0
+	 * @see wpdb::prepare()
+	 * @see wpdb::$field_types
+	 * @see wp_set_wpdb_vars()
+	 *
+	 * @param string $table table name
+	 * @param array $data Data to insert (in column => value pairs).  Both $data columns and $data values should be "raw" (neither should be SQL escaped).
+	 * @param array|string $format Optional. An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data.
+	 * 	A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
+	 * @return int|false The number of rows affected, or false on error.
+	 */
+	function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) {
+		if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ) ) )
+			return false;
+		$formats = $format = (array) $format;
+		$fields = array_keys( $data );
+		$formatted_fields = array();
+		foreach ( $fields as $field ) {
+			if ( !empty( $format ) )
+				$form = ( $form = array_shift( $formats ) ) ? $form : $format[0];
+			elseif ( isset( $this->field_types[$field] ) )
+				$form = $this->field_types[$field];
+			else
+				$form = '%s';
+			$formatted_fields[] = $form;
+		}
+		$sql = "{$type} INTO `$table` (`" . implode( '`,`', $fields ) . "`) VALUES ('" . implode( "','", $formatted_fields ) . "')";
+		return $this->query( $this->prepare( $sql, $data ) );
+	}
+
+	/**
+	 * Update a row in the table
+	 *
+	 * <code>
+	 * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 'bar' ), array( 'ID' => 1 ) )
+	 * wpdb::update( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) )
+	 * </code>
+	 *
+	 * @since 2.5.0
+	 * @see wpdb::prepare()
+	 * @see wpdb::$field_types
+	 * @see wp_set_wpdb_vars()
+	 *
+	 * @param string $table table name
+	 * @param array $data Data to update (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped).
+	 * @param array $where A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw".
+	 * @param array|string $format Optional. An array of formats to be mapped to each of the values in $data. If string, that format will be used for all of the values in $data.
+	 * 	A format is one of '%d', '%s' (decimal number, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
+	 * @param array|string $format_where Optional. An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where.  A format is one of '%d', '%s' (decimal number, string).  If omitted, all values in $where will be treated as strings.
+	 * @return int|false The number of rows updated, or false on error.
+	 */
+	function update( $table, $data, $where, $format = null, $where_format = null ) {
+		if ( ! is_array( $data ) || ! is_array( $where ) )
+			return false;
+
+		$formats = $format = (array) $format;
+		$bits = $wheres = array();
+		foreach ( (array) array_keys( $data ) as $field ) {
+			if ( !empty( $format ) )
+				$form = ( $form = array_shift( $formats ) ) ? $form : $format[0];
+			elseif ( isset($this->field_types[$field]) )
+				$form = $this->field_types[$field];
+			else
+				$form = '%s';
+			$bits[] = "`$field` = {$form}";
+		}
+
+		$where_formats = $where_format = (array) $where_format;
+		foreach ( (array) array_keys( $where ) as $field ) {
+			if ( !empty( $where_format ) )
+				$form = ( $form = array_shift( $where_formats ) ) ? $form : $where_format[0];
+			elseif ( isset( $this->field_types[$field] ) )
+				$form = $this->field_types[$field];
+			else
+				$form = '%s';
+			$wheres[] = "`$field` = {$form}";
+		}
+
+		$sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres );
+		return $this->query( $this->prepare( $sql, array_merge( array_values( $data ), array_values( $where ) ) ) );
+	}
+
+	/**
+	 * Retrieve one variable from the database.
+	 *
+	 * Executes a SQL query and returns the value from the SQL result.
+	 * If the SQL result contains more than one column and/or more than one row, this function returns the value in the column and row specified.
+	 * If $query is null, this function returns the value in the specified column and row from the previous SQL result.
+	 *
+	 * @since 0.71
+	 *
+	 * @param string|null $query Optional. SQL query. Defaults to null, use the result from the previous query.
+	 * @param int $x Optional. Column of value to return.  Indexed from 0.
+	 * @param int $y Optional. Row of value to return.  Indexed from 0.
+	 * @return string|null Database query result (as string), or null on failure
+	 */
+	function get_var( $query = null, $x = 0, $y = 0 ) {
+		$this->func_call = "\$db->get_var(\"$query\", $x, $y)";
+		if ( $query )
+			$this->query( $query );
+
+		// Extract var out of cached results based x,y vals
+		if ( !empty( $this->last_result[$y] ) ) {
+			$values = array_values( get_object_vars( $this->last_result[$y] ) );
+		}
+
+		// If there is a value return it else return null
+		return ( isset( $values[$x] ) && $values[$x] !== '' ) ? $values[$x] : null;
+	}
+
+	/**
+	 * Retrieve one row from the database.
+	 *
+	 * Executes a SQL query and returns the row from the SQL result.
+	 *
+	 * @since 0.71
+	 *
+	 * @param string|null $query SQL query.
+	 * @param string $output Optional. one of ARRAY_A | ARRAY_N | OBJECT constants. Return an associative array (column => value, ...),
+	 * 	a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively.
+	 * @param int $y Optional. Row to return. Indexed from 0.
+	 * @return mixed Database query result in format specifed by $output or null on failure
+	 */
+	function get_row( $query = null, $output = OBJECT, $y = 0 ) {
+		$this->func_call = "\$db->get_row(\"$query\",$output,$y)";
+		if ( $query )
+			$this->query( $query );
+		else
+			return null;
+
+		if ( !isset( $this->last_result[$y] ) )
+			return null;
+
+		if ( $output == OBJECT ) {
+			return $this->last_result[$y] ? $this->last_result[$y] : null;
+		} elseif ( $output == ARRAY_A ) {
+			return $this->last_result[$y] ? get_object_vars( $this->last_result[$y] ) : null;
+		} elseif ( $output == ARRAY_N ) {
+			return $this->last_result[$y] ? array_values( get_object_vars( $this->last_result[$y] ) ) : null;
+		} else {
+			$this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/);
+		}
+	}
+
+	/**
+	 * Retrieve one column from the database.
+	 *
+	 * Executes a SQL query and returns the column from the SQL result.
+	 * If the SQL result contains more than one column, this function returns the column specified.
+	 * If $query is null, this function returns the specified column from the previous SQL result.
+	 *
+	 * @since 0.71
+	 *
+	 * @param string|null $query Optional. SQL query. Defaults to previous query.
+	 * @param int $x Optional. Column to return. Indexed from 0.
+	 * @return array Database query result. Array indexed from 0 by SQL result row number.
+	 */
+	function get_col( $query = null , $x = 0 ) {
+		if ( $query )
+			$this->query( $query );
+
+		$new_array = array();
+		// Extract the column values
+		for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) {
+			$new_array[$i] = $this->get_var( null, $x, $i );
+		}
+		return $new_array;
+	}
+
+	/**
+	 * Retrieve an entire SQL result set from the database (i.e., many rows)
+	 *
+	 * Executes a SQL query and returns the entire SQL result.
+	 *
+	 * @since 0.71
+	 *
+	 * @param string $query SQL query.
+	 * @param string $output Optional. Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. With one of the first three, return an array of rows indexed from 0 by SQL result row number.
+	 * 	Each row is an associative array (column => value, ...), a numerically indexed array (0 => value, ...), or an object. ( ->column = value ), respectively.
+	 * 	With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value.  Duplicate keys are discarded.
+	 * @return mixed Database query results
+	 */
+	function get_results( $query = null, $output = OBJECT ) {
+		$this->func_call = "\$db->get_results(\"$query\", $output)";
+
+		if ( $query )
+			$this->query( $query );
+		else
+			return null;
+
+		$new_array = array();
+		if ( $output == OBJECT ) {
+			// Return an integer-keyed array of row objects
+			return $this->last_result;
+		} elseif ( $output == OBJECT_K ) {
+			// Return an array of row objects with keys from column 1
+			// (Duplicates are discarded)
+			foreach ( $this->last_result as $row ) {
+				$key = array_shift( $var_by_ref = get_object_vars( $row ) );
+				if ( ! isset( $new_array[ $key ] ) )
+					$new_array[ $key ] = $row;
+			}
+			return $new_array;
+		} elseif ( $output == ARRAY_A || $output == ARRAY_N ) {
+			// Return an integer-keyed array of...
+			if ( $this->last_result ) {
+				foreach( (array) $this->last_result as $row ) {
+					if ( $output == ARRAY_N ) {
+						// ...integer-keyed row arrays
+						$new_array[] = array_values( get_object_vars( $row ) );
+					} else {
+						// ...column name-keyed row arrays
+						$new_array[] = get_object_vars( $row );
+					}
+				}
+			}
+			return $new_array;
+		}
+		return null;
+	}
+
+	/**
+	 * Retrieve column metadata from the last query.
+	 *
+	 * @since 0.71
+	 *
+	 * @param string $info_type Optional. Type one of name, table, def, max_length, not_null, primary_key, multiple_key, unique_key, numeric, blob, type, unsigned, zerofill
+	 * @param int $col_offset Optional. 0: col name. 1: which table the col's in. 2: col's max length. 3: if the col is numeric. 4: col's type
+	 * @return mixed Column Results
+	 */
+	function get_col_info( $info_type = 'name', $col_offset = -1 ) {
+		if ( $this->col_info ) {
+			if ( $col_offset == -1 ) {
+				$i = 0;
+				$new_array = array();
+				foreach( (array) $this->col_info as $col ) {
+					$new_array[$i] = $col->{$info_type};
+					$i++;
+				}
+				return $new_array;
+			} else {
+				return $this->col_info[$col_offset]->{$info_type};
+			}
+		}
+	}
+
+	/**
+	 * Starts the timer, for debugging purposes.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @return true
+	 */
+	function timer_start() {
+		$mtime            = explode( ' ', microtime() );
+		$this->time_start = $mtime[1] + $mtime[0];
+		return true;
+	}
+
+	/**
+	 * Stops the debugging timer.
+	 *
+	 * @since 1.5.0
+	 *
+	 * @return int Total time spent on the query, in milliseconds
+	 */
+	function timer_stop() {
+		$mtime      = explode( ' ', microtime() );
+		$time_end   = $mtime[1] + $mtime[0];
+		$time_total = $time_end - $this->time_start;
+		return $time_total;
+	}
+
+	/**
+	 * Wraps errors in a nice header and footer and dies.
+	 *
+	 * Will not die if wpdb::$show_errors is true
+	 *
+	 * @since 1.5.0
+	 *
+	 * @param string $message The Error message
+	 * @param string $error_code Optional. A Computer readable string to identify the error.
+	 * @return false|void
+	 */
+	function bail( $message, $error_code = '500' ) {
+		if ( !$this->show_errors ) {
+			if ( class_exists( 'WP_Error' ) )
+				$this->error = new WP_Error($error_code, $message);
+			else
+				$this->error = $message;
+			return false;
+		}
+		wp_die($message);
+	}
+
+	/**
+	 * Whether MySQL database is at least the required minimum version.
+	 *
+	 * @since 2.5.0
+	 * @uses $wp_version
+	 * @uses $required_mysql_version
+	 *
+	 * @return WP_Error
+	 */
+	function check_database_version() {
+		global $wp_version, $required_mysql_version;
+		// Make sure the server has the required MySQL version
+		if ( version_compare($this->db_version(), $required_mysql_version, '<') )
+			return new WP_Error('database_version', sprintf( __( '<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ));
+	}
+
+	/**
+	 * Whether the database supports collation.
+	 *
+	 * Called when WordPress is generating the table scheme.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @return bool True if collation is supported, false if version does not
+	 */
+	function supports_collation() {
+		return $this->has_cap( 'collation' );
+	}
+
+	/**
+	 * Determine if a database supports a particular feature
+	 *
+	 * @since 2.7.0
+	 * @see   wpdb::db_version()
+	 *
+	 * @param string $db_cap the feature
+	 * @return bool
+	 */
+	function has_cap( $db_cap ) {
+		$version = $this->db_version();
+
+		switch ( strtolower( $db_cap ) ) {
+			case 'collation' :    // @since 2.5.0
+			case 'group_concat' : // @since 2.7
+			case 'subqueries' :   // @since 2.7
+				return version_compare( $version, '4.1', '>=' );
+			case 'set_charset' :
+				return version_compare($version, '5.0.7', '>=');
+		};
+
+		return false;
+	}
+
+	/**
+	 * Retrieve the name of the function that called wpdb.
+	 *
+	 * Searches up the list of functions until it reaches
+	 * the one that would most logically had called this method.
+	 *
+	 * @since 2.5.0
+	 *
+	 * @return string The name of the calling function
+	 */
+	function get_caller() {
+		$trace  = array_reverse( debug_backtrace() );
+		$caller = array();
+
+		foreach ( $trace as $call ) {
+			if ( isset( $call['class'] ) && __CLASS__ == $call['class'] )
+				continue; // Filter out wpdb calls.
+			$caller[] = isset( $call['class'] ) ? "{$call['class']}->{$call['function']}" : $call['function'];
+		}
+
+		return join( ', ', $caller );
+	}
+
+	/**
+	 * The database version number.
+	 *
+	 * @since 2.7.0
+	 *
+	 * @return false|string false on failure, version number on success
+	 */
+	function db_version() {
+		return preg_replace( '/[^0-9.].*/', '', mysql_get_server_info( $this->dbh ) );
+	}
+}
+
+?>
Index: /tags/3.1/wp-includes/wp-diff.php
===================================================================
--- /tags/3.1/wp-includes/wp-diff.php	(revision 17487)
+++ /tags/3.1/wp-includes/wp-diff.php	(revision 17487)
@@ -0,0 +1,478 @@
+<?php
+/**
+ * WordPress Diff bastard child of old MediaWiki Diff Formatter.
+ *
+ * Basically all that remains is the table structure and some method names.
+ *
+ * @package WordPress
+ * @subpackage Diff
+ */
+
+if ( !class_exists( 'Text_Diff' ) ) {
+	/** Text_Diff class */
+	require( dirname(__FILE__).'/Text/Diff.php' );
+	/** Text_Diff_Renderer class */
+	require( dirname(__FILE__).'/Text/Diff/Renderer.php' );
+	/** Text_Diff_Renderer_inline class */
+	require( dirname(__FILE__).'/Text/Diff/Renderer/inline.php' );
+}
+
+/**
+ * Table renderer to display the diff lines.
+ *
+ * @since 2.6.0
+ * @uses Text_Diff_Renderer Extends
+ */
+class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
+
+	/**
+	 * @see Text_Diff_Renderer::_leading_context_lines
+	 * @var int
+	 * @access protected
+	 * @since 2.6.0
+	 */
+	var $_leading_context_lines  = 10000;
+
+	/**
+	 * @see Text_Diff_Renderer::_trailing_context_lines
+	 * @var int
+	 * @access protected
+	 * @since 2.6.0
+	 */
+	var $_trailing_context_lines = 10000;
+
+	/**
+	 * {@internal Missing Description}}
+	 *
+	 * @var float
+	 * @access protected
+	 * @since 2.6.0
+	 */
+	var $_diff_threshold = 0.6;
+
+	/**
+	 * Inline display helper object name.
+	 *
+	 * @var string
+	 * @access protected
+	 * @since 2.6.0
+	 */
+	var $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline';
+
+	/**
+	 * PHP4 Constructor - Call parent constructor with params array.
+	 *
+	 * This will set class properties based on the key value pairs in the array.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param array $params
+	 */
+	function Text_Diff_Renderer_Table( $params = array() ) {
+		$parent = get_parent_class($this);
+		$this->$parent( $params );
+	}
+
+	/**
+	 * @ignore
+	 *
+	 * @param string $header
+	 * @return string
+	 */
+	function _startBlock( $header ) {
+		return '';
+	}
+
+	/**
+	 * @ignore
+	 *
+	 * @param array $lines
+	 * @param string $prefix
+	 */
+	function _lines( $lines, $prefix=' ' ) {
+	}
+
+	/**
+	 * @ignore
+	 *
+	 * @param string $line HTML-escape the value.
+	 * @return string
+	 */
+	function addedLine( $line ) {
+		return "<td>+</td><td class='diff-addedline'>{$line}</td>";
+	}
+
+	/**
+	 * @ignore
+	 *
+	 * @param string $line HTML-escape the value.
+	 * @return string
+	 */
+	function deletedLine( $line ) {
+		return "<td>-</td><td class='diff-deletedline'>{$line}</td>";
+	}
+
+	/**
+	 * @ignore
+	 *
+	 * @param string $line HTML-escape the value.
+	 * @return string
+	 */
+	function contextLine( $line ) {
+		return "<td> </td><td class='diff-context'>{$line}</td>";
+	}
+
+	/**
+	 * @ignore
+	 *
+	 * @return string
+	 */
+	function emptyLine() {
+		return '<td colspan="2">&nbsp;</td>';
+	}
+
+	/**
+	 * @ignore
+	 * @access private
+	 *
+	 * @param array $lines
+	 * @param bool $encode
+	 * @return string
+	 */
+	function _added( $lines, $encode = true ) {
+		$r = '';
+		foreach ($lines as $line) {
+			if ( $encode )
+				$line = htmlspecialchars( $line );
+			$r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
+		}
+		return $r;
+	}
+
+	/**
+	 * @ignore
+	 * @access private
+	 *
+	 * @param array $lines
+	 * @param bool $encode
+	 * @return string
+	 */
+	function _deleted( $lines, $encode = true ) {
+		$r = '';
+		foreach ($lines as $line) {
+			if ( $encode )
+				$line = htmlspecialchars( $line );
+			$r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n";
+		}
+		return $r;
+	}
+
+	/**
+	 * @ignore
+	 * @access private
+	 *
+	 * @param array $lines
+	 * @param bool $encode
+	 * @return string
+	 */
+	function _context( $lines, $encode = true ) {
+		$r = '';
+		foreach ($lines as $line) {
+			if ( $encode )
+				$line = htmlspecialchars( $line );
+			$r .= '<tr>' .
+				$this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n";
+		}
+		return $r;
+	}
+
+	/**
+	 * Process changed lines to do word-by-word diffs for extra highlighting.
+	 *
+	 * (TRAC style) sometimes these lines can actually be deleted or added rows.
+	 * We do additional processing to figure that out
+	 *
+	 * @access private
+	 * @since 2.6.0
+	 *
+	 * @param array $orig
+	 * @param array $final
+	 * @return string
+	 */
+	function _changed( $orig, $final ) {
+		$r = '';
+
+		// Does the aforementioned additional processing
+		// *_matches tell what rows are "the same" in orig and final.  Those pairs will be diffed to get word changes
+		//	match is numeric: an index in other column
+		//	match is 'X': no match.  It is a new row
+		// *_rows are column vectors for the orig column and the final column.
+		//	row >= 0: an indix of the $orig or $final array
+		//	row  < 0: a blank row for that column
+		list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final );
+
+
+		// These will hold the word changes as determined by an inline diff
+		$orig_diffs  = array();
+		$final_diffs = array();
+
+		// Compute word diffs for each matched pair using the inline diff
+		foreach ( $orig_matches as $o => $f ) {
+			if ( is_numeric($o) && is_numeric($f) ) {
+				$text_diff = new Text_Diff( 'auto', array( array($orig[$o]), array($final[$f]) ) );
+				$renderer = new $this->inline_diff_renderer;
+				$diff = $renderer->render( $text_diff );
+
+				// If they're too different, don't include any <ins> or <dels>
+				if ( $diff_count = preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) {
+					// length of all text between <ins> or <del>
+					$stripped_matches = strlen(strip_tags( join(' ', $diff_matches[0]) ));
+					// since we count lengith of text between <ins> or <del> (instead of picking just one),
+					//	we double the length of chars not in those tags.
+					$stripped_diff = strlen(strip_tags( $diff )) * 2 - $stripped_matches;
+					$diff_ratio = $stripped_matches / $stripped_diff;
+					if ( $diff_ratio > $this->_diff_threshold )
+						continue; // Too different.  Don't save diffs.
+				}
+
+				// Un-inline the diffs by removing del or ins
+				$orig_diffs[$o]  = preg_replace( '|<ins>.*?</ins>|', '', $diff );
+				$final_diffs[$f] = preg_replace( '|<del>.*?</del>|', '', $diff );
+			}
+		}
+
+		foreach ( array_keys($orig_rows) as $row ) {
+			// Both columns have blanks.  Ignore them.
+			if ( $orig_rows[$row] < 0 && $final_rows[$row] < 0 )
+				continue;
+
+			// If we have a word based diff, use it.  Otherwise, use the normal line.
+			if ( isset( $orig_diffs[$orig_rows[$row]] ) )
+				$orig_line = $orig_diffs[$orig_rows[$row]];
+			elseif ( isset( $orig[$orig_rows[$row]] ) )
+				$orig_line = htmlspecialchars($orig[$orig_rows[$row]]);
+			else
+				$orig_line = '';
+
+			if ( isset( $final_diffs[$final_rows[$row]] ) )
+				$final_line = $final_diffs[$final_rows[$row]];
+			elseif ( isset( $final[$final_rows[$row]] ) )
+				$final_line = htmlspecialchars($final[$final_rows[$row]]);
+			else
+				$final_line = '';
+
+			if ( $orig_rows[$row] < 0 ) { // Orig is blank.  This is really an added row.
+				$r .= $this->_added( array($final_line), false );
+			} elseif ( $final_rows[$row] < 0 ) { // Final is blank.  This is really a deleted row.
+				$r .= $this->_deleted( array($orig_line), false );
+			} else { // A true changed row.
+				$r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "</tr>\n";
+			}
+		}
+
+		return $r;
+	}
+
+	/**
+	 * Takes changed blocks and matches which rows in orig turned into which rows in final.
+	 *
+	 * Returns
+	 *	*_matches ( which rows match with which )
+	 *	*_rows ( order of rows in each column interleaved with blank rows as
+	 *		necessary )
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param unknown_type $orig
+	 * @param unknown_type $final
+	 * @return unknown
+	 */
+	function interleave_changed_lines( $orig, $final ) {
+
+		// Contains all pairwise string comparisons.  Keys are such that this need only be a one dimensional array.
+		$matches = array();
+		foreach ( array_keys($orig) as $o ) {
+			foreach ( array_keys($final) as $f ) {
+				$matches["$o,$f"] = $this->compute_string_distance( $orig[$o], $final[$f] );
+			}
+		}
+		asort($matches); // Order by string distance.
+
+		$orig_matches  = array();
+		$final_matches = array();
+
+		foreach ( $matches as $keys => $difference ) {
+			list($o, $f) = explode(',', $keys);
+			$o = (int) $o;
+			$f = (int) $f;
+
+			// Already have better matches for these guys
+			if ( isset($orig_matches[$o]) && isset($final_matches[$f]) )
+				continue;
+
+			// First match for these guys.  Must be best match
+			if ( !isset($orig_matches[$o]) && !isset($final_matches[$f]) ) {
+				$orig_matches[$o] = $f;
+				$final_matches[$f] = $o;
+				continue;
+			}
+
+			// Best match of this final is already taken?  Must mean this final is a new row.
+			if ( isset($orig_matches[$o]) )
+				$final_matches[$f] = 'x';
+
+			// Best match of this orig is already taken?  Must mean this orig is a deleted row.
+			elseif ( isset($final_matches[$f]) )
+				$orig_matches[$o] = 'x';
+		}
+
+		// We read the text in this order
+		ksort($orig_matches);
+		ksort($final_matches);
+
+
+		// Stores rows and blanks for each column.
+		$orig_rows = $orig_rows_copy = array_keys($orig_matches);
+		$final_rows = array_keys($final_matches);
+
+		// Interleaves rows with blanks to keep matches aligned.
+		// We may end up with some extraneous blank rows, but we'll just ignore them later.
+		foreach ( $orig_rows_copy as $orig_row ) {
+			$final_pos = array_search($orig_matches[$orig_row], $final_rows, true);
+			$orig_pos = (int) array_search($orig_row, $orig_rows, true);
+
+			if ( false === $final_pos ) { // This orig is paired with a blank final.
+				array_splice( $final_rows, $orig_pos, 0, -1 );
+			} elseif ( $final_pos < $orig_pos ) { // This orig's match is up a ways.  Pad final with blank rows.
+				$diff_pos = $final_pos - $orig_pos;
+				while ( $diff_pos < 0 )
+					array_splice( $final_rows, $orig_pos, 0, $diff_pos++ );
+			} elseif ( $final_pos > $orig_pos ) { // This orig's match is down a ways.  Pad orig with blank rows.
+				$diff_pos = $orig_pos - $final_pos;
+				while ( $diff_pos < 0 )
+					array_splice( $orig_rows, $orig_pos, 0, $diff_pos++ );
+			}
+		}
+
+
+		// Pad the ends with blank rows if the columns aren't the same length
+		$diff_count = count($orig_rows) - count($final_rows);
+		if ( $diff_count < 0 ) {
+			while ( $diff_count < 0 )
+				array_push($orig_rows, $diff_count++);
+		} elseif ( $diff_count > 0 ) {
+			$diff_count = -1 * $diff_count;
+			while ( $diff_count < 0 )
+				array_push($final_rows, $diff_count++);
+		}
+
+		return array($orig_matches, $final_matches, $orig_rows, $final_rows);
+
+/*
+		// Debug
+		echo "\n\n\n\n\n";
+
+		echo "-- DEBUG Matches: Orig -> Final --";
+
+		foreach ( $orig_matches as $o => $f ) {
+			echo "\n\n\n\n\n";
+			echo "ORIG: $o, FINAL: $f\n";
+			var_dump($orig[$o],$final[$f]);
+		}
+		echo "\n\n\n\n\n";
+
+		echo "-- DEBUG Matches: Final -> Orig --";
+
+		foreach ( $final_matches as $f => $o ) {
+			echo "\n\n\n\n\n";
+			echo "FINAL: $f, ORIG: $o\n";
+			var_dump($final[$f],$orig[$o]);
+		}
+		echo "\n\n\n\n\n";
+
+		echo "-- DEBUG Rows: Orig -- Final --";
+
+		echo "\n\n\n\n\n";
+		foreach ( $orig_rows as $row => $o ) {
+			if ( $o < 0 )
+				$o = 'X';
+			$f = $final_rows[$row];
+			if ( $f < 0 )
+				$f = 'X';
+			echo "$o -- $f\n";
+		}
+		echo "\n\n\n\n\n";
+
+		echo "-- END DEBUG --";
+
+		echo "\n\n\n\n\n";
+
+		return array($orig_matches, $final_matches, $orig_rows, $final_rows);
+*/
+	}
+
+	/**
+	 * Computes a number that is intended to reflect the "distance" between two strings.
+	 *
+	 * @since 2.6.0
+	 *
+	 * @param string $string1
+	 * @param string $string2
+	 * @return int
+	 */
+	function compute_string_distance( $string1, $string2 ) {
+		// Vectors containing character frequency for all chars in each string
+		$chars1 = count_chars($string1);
+		$chars2 = count_chars($string2);
+
+		// L1-norm of difference vector.
+		$difference = array_sum( array_map( array(&$this, 'difference'), $chars1, $chars2 ) );
+
+		// $string1 has zero length? Odd.  Give huge penalty by not dividing.
+		if ( !$string1 )
+			return $difference;
+
+		// Return distance per charcter (of string1)
+		return $difference / strlen($string1);
+	}
+
+	/**
+	 * @ignore
+	 * @since 2.6.0
+	 *
+	 * @param int $a
+	 * @param int $b
+	 * @return int
+	 */
+	function difference( $a, $b ) {
+		return abs( $a - $b );
+	}
+
+}
+
+/**
+ * Better word splitting than the PEAR package provides.
+ *
+ * @since 2.6.0
+ * @uses Text_Diff_Renderer_inline Extends
+ */
+class WP_Text_Diff_Renderer_inline extends Text_Diff_Renderer_inline {
+
+	/**
+	 * @ignore
+	 * @since 2.6.0
+	 *
+	 * @param string $string
+	 * @param string $newlineEscape
+	 * @return string
+	 */
+	function _splitOnWords($string, $newlineEscape = "\n") {
+		$string = str_replace("\0", '', $string);
+		$words  = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
+		$words  = str_replace( "\n", $newlineEscape, $words );
+		return $words;
+	}
+
+}
+
+?>
Index: /tags/3.1/wp-links-opml.php
===================================================================
--- /tags/3.1/wp-links-opml.php	(revision 17487)
+++ /tags/3.1/wp-links-opml.php	(revision 17487)
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Outputs the OPML XML format for getting the links defined in the link
+ * administration. This can be used to export links from one blog over to
+ * another. Links aren't exported by the WordPress export, so this file handles
+ * that.
+ *
+ * This file is not added by default to WordPress theme pages when outputting
+ * feed links. It will have to be added manually for browsers and users to pick
+ * up that this file exists.
+ *
+ * @package WordPress
+ */
+
+require_once('./wp-load.php');
+
+header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
+$link_cat = '';
+if ( !empty($_GET['link_cat']) ) {
+	$link_cat = $_GET['link_cat'];
+	if ( !in_array($link_cat, array('all', '0')) )
+		$link_cat = absint( (string)urldecode($link_cat) );
+}
+
+echo '<?xml version="1.0"?'.">\n";
+?>
+<opml version="1.0">
+	<head>
+		<title><?php printf( __('Links for %s'), esc_attr(get_bloginfo('name', 'display')) ); ?></title>
+		<dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
+		<?php do_action('opml_head'); ?>
+	</head>
+	<body>
+<?php
+if ( empty($link_cat) )
+	$cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0));
+else
+	$cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0, 'include' => $link_cat));
+
+foreach ( (array)$cats as $cat ) :
+	$catname = apply_filters('link_category', $cat->name);
+
+?>
+<outline type="category" title="<?php echo esc_attr($catname); ?>">
+<?php
+	$bookmarks = get_bookmarks(array("category" => $cat->term_id));
+	foreach ( (array)$bookmarks as $bookmark ) :
+		$title = apply_filters('link_title', $bookmark->link_name);
+?>
+	<outline text="<?php echo esc_attr($title); ?>" type="link" xmlUrl="<?php echo esc_attr($bookmark->link_rss); ?>" htmlUrl="<?php echo esc_attr($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />
+<?php
+	endforeach; // $bookmarks
+?>
+</outline>
+<?php
+endforeach; // $cats
+?>
+</body>
+</opml>
Index: /tags/3.1/wp-load.php
===================================================================
--- /tags/3.1/wp-load.php	(revision 17487)
+++ /tags/3.1/wp-load.php	(revision 17487)
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Bootstrap file for setting the ABSPATH constant
+ * and loading the wp-config.php file. The wp-config.php
+ * file will then load the wp-settings.php file, which
+ * will then set up the WordPress environment.
+ *
+ * If the wp-config.php file is not found then an error
+ * will be displayed asking the visitor to set up the
+ * wp-config.php file.
+ *
+ * Will also search for wp-config.php in WordPress' parent
+ * directory to allow the WordPress directory to remain
+ * untouched.
+ *
+ * @package WordPress
+ */
+
+/** Define ABSPATH as this files directory */
+define( 'ABSPATH', dirname(__FILE__) . '/' );
+
+if ( defined('E_RECOVERABLE_ERROR') )
+	error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
+else
+	error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
+
+if ( file_exists( ABSPATH . 'wp-config.php') ) {
+
+	/** The config file resides in ABSPATH */
+	require_once( ABSPATH . 'wp-config.php' );
+
+} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! file_exists( dirname(ABSPATH) . '/wp-settings.php' ) ) {
+
+	/** The config file resides one level above ABSPATH but is not part of another install*/
+	require_once( dirname(ABSPATH) . '/wp-config.php' );
+
+} else {
+
+	// A config file doesn't exist
+
+	// Set a path for the link to the installer
+	if ( strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false )
+		$path = '';
+	else
+		$path = 'wp-admin/';
+
+	// Die with an error message
+	require_once( ABSPATH . '/wp-includes/class-wp-error.php' );
+	require_once( ABSPATH . '/wp-includes/functions.php' );
+	require_once( ABSPATH . '/wp-includes/plugin.php' );
+	$text_direction = /*WP_I18N_TEXT_DIRECTION*/"ltr"/*/WP_I18N_TEXT_DIRECTION*/;
+	wp_die(sprintf(/*WP_I18N_NO_CONFIG*/"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/Editing_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='%ssetup-config.php' class='button'>Create a Configuration File</a>"/*/WP_I18N_NO_CONFIG*/, $path), /*WP_I18N_ERROR_TITLE*/"WordPress &rsaquo; Error"/*/WP_I18N_ERROR_TITLE*/, array('text_direction' => $text_direction));
+
+}
+
+?>
Index: /tags/3.1/wp-login.php
===================================================================
--- /tags/3.1/wp-login.php	(revision 17487)
+++ /tags/3.1/wp-login.php	(revision 17487)
@@ -0,0 +1,704 @@
+<?php
+/**
+ * WordPress User Page
+ *
+ * Handles authentication, registering, resetting passwords, forgot password,
+ * and other user handling.
+ *
+ * @package WordPress
+ */
+
+/** Make sure that the WordPress bootstrap has run before continuing. */
+require( dirname(__FILE__) . '/wp-load.php' );
+
+// Redirect to https login if forced to use SSL
+if ( force_ssl_admin() && !is_ssl() ) {
+	if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
+		wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
+		exit();
+	} else {
+		wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+		exit();
+	}
+}
+
+/**
+ * Outputs the header for the login page.
+ *
+ * @uses do_action() Calls the 'login_head' for outputting HTML in the Log In
+ *		header.
+ * @uses apply_filters() Calls 'login_headerurl' for the top login link.
+ * @uses apply_filters() Calls 'login_headertitle' for the top login title.
+ * @uses apply_filters() Calls 'login_message' on the message to display in the
+ *		header.
+ * @uses $error The error global, which is checked for displaying errors.
+ *
+ * @param string $title Optional. WordPress Log In Page title to display in
+ *		<title/> element.
+ * @param string $message Optional. Message to display in header.
+ * @param WP_Error $wp_error Optional. WordPress Error Object
+ */
+function login_header($title = 'Log In', $message = '', $wp_error = '') {
+	global $error, $is_iphone, $interim_login, $current_site;
+
+	// Don't index any of these forms
+	add_filter( 'pre_option_blog_public', '__return_zero' );
+	add_action( 'login_head', 'noindex' );
+
+	if ( empty($wp_error) )
+		$wp_error = new WP_Error();
+
+	// Shake it!
+	$shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
+	$shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
+
+	if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
+		add_action( 'login_head', 'wp_shake_js', 12 );
+
+	?>
+<!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 language_attributes(); ?>>
+<head>
+	<title><?php bloginfo('name'); ?> &rsaquo; <?php echo $title; ?></title>
+	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
+<?php
+	wp_admin_css( 'login', true );
+	wp_admin_css( 'colors-fresh', true );
+
+	if ( $is_iphone ) { ?>
+	<meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" />
+	<style type="text/css" media="screen">
+	form { margin-left: 0px; }
+	#login { margin-top: 20px; }
+	</style>
+<?php
+	} elseif ( isset($interim_login) && $interim_login ) { ?>
+	<style type="text/css" media="all">
+	.login #login { margin: 20px auto; }
+	</style>
+<?php
+	}
+
+	do_action( 'login_enqueue_scripts' );
+	do_action( 'login_head' ); ?>
+</head>
+<body class="login">
+<?php   if ( !is_multisite() ) { ?>
+<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', esc_attr__('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1>
+<?php   } else { ?>
+<div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', network_home_url() ); ?>" title="<?php echo apply_filters('login_headertitle', esc_attr($current_site->site_name) ); ?>"><span class="hide"><?php bloginfo('name'); ?></span></a></h1>
+<?php   }
+
+	$message = apply_filters('login_message', $message);
+	if ( !empty( $message ) ) echo $message . "\n";
+
+	// Incase a plugin uses $error rather than the $errors object
+	if ( !empty( $error ) ) {
+		$wp_error->add('error', $error);
+		unset($error);
+	}
+
+	if ( $wp_error->get_error_code() ) {
+		$errors = '';
+		$messages = '';
+		foreach ( $wp_error->get_error_codes() as $code ) {
+			$severity = $wp_error->get_error_data($code);
+			foreach ( $wp_error->get_error_messages($code) as $error ) {
+				if ( 'message' == $severity )
+					$messages .= '	' . $error . "<br />\n";
+				else
+					$errors .= '	' . $error . "<br />\n";
+			}
+		}
+		if ( !empty($errors) )
+			echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
+		if ( !empty($messages) )
+			echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
+	}
+} // End of login_header()
+
+/**
+ * Outputs the footer for the login page.
+ *
+ * @param string $input_id Which input to auto-focus
+ */
+function login_footer($input_id = '') {
+	echo "</div>\n";
+
+	if ( !empty($input_id) ) {
+?>
+<script type="text/javascript">
+try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){}
+if(typeof wpOnload=='function')wpOnload();
+</script>
+<?php
+	}
+?>
+<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php esc_attr_e('Are you lost?') ?>"><?php printf(__('&larr; Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
+<?php do_action('login_footer'); ?>
+</body>
+</html>
+<?php
+}
+
+function wp_shake_js() {
+	global $is_iphone;
+	if ( $is_iphone )
+		return;
+?>
+<script type="text/javascript">
+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();}}};
+function s(id,pos){g(id).left=pos+'px';}
+function g(id){return document.getElementById(id).style;}
+function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){shake(id,a,d);},d);}else{try{g(id).position='static';wp_attempt_focus();}catch(e){}}}
+addLoadEvent(function(){ var p=new Array(15,30,15,0,-15,-30,-15,0);p=p.concat(p.concat(p));var i=document.forms[0].id;g(i).position='relative';shake(i,p,20);});
+</script>
+<?php
+}
+
+/**
+ * Handles sending password retrieval email to user.
+ *
+ * @uses $wpdb WordPress Database object
+ *
+ * @return bool|WP_Error True: when finish. WP_Error on error
+ */
+function retrieve_password() {
+	global $wpdb, $current_site;
+
+	$errors = new WP_Error();
+
+	if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
+		$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
+
+	if ( strpos($_POST['user_login'], '@') ) {
+		$user_data = get_user_by_email(trim($_POST['user_login']));
+		if ( empty($user_data) )
+			$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
+	} else {
+		$login = trim($_POST['user_login']);
+		$user_data = get_userdatabylogin($login);
+	}
+
+	do_action('lostpassword_post');
+
+	if ( $errors->get_error_code() )
+		return $errors;
+
+	if ( !$user_data ) {
+		$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
+		return $errors;
+	}
+
+	// redefining user_login ensures we return the right case in the email
+	$user_login = $user_data->user_login;
+	$user_email = $user_data->user_email;
+
+	do_action('retreive_password', $user_login);  // Misspelled and deprecated
+	do_action('retrieve_password', $user_login);
+
+	$allow = apply_filters('allow_password_reset', true, $user_data->ID);
+
+	if ( ! $allow )
+		return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
+	else if ( is_wp_error($allow) )
+		return $allow;
+
+	$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
+	if ( empty($key) ) {
+		// Generate something random for a key...
+		$key = wp_generate_password(20, false);
+		do_action('retrieve_password_key', $user_login, $key);
+		// Now insert the new md5 key into the db
+		$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
+	}
+	$message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
+	$message .= network_site_url() . "\r\n\r\n";
+	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
+	$message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
+	$message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
+	$message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n";
+
+	if ( is_multisite() )
+		$blogname = $GLOBALS['current_site']->site_name;
+	else
+		// The blogname option is escaped with esc_html on the way into the database in sanitize_option
+		// we want to reverse this for the plain text arena of emails.
+		$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
+
+	$title = sprintf( __('[%s] Password Reset'), $blogname );
+
+	$title = apply_filters('retrieve_password_title', $title);
+	$message = apply_filters('retrieve_password_message', $message, $key);
+
+	if ( $message && !wp_mail($user_email, $title, $message) )
+		wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') );
+
+	return true;
+}
+
+/**
+ * Retrieves a user row based on password reset key and login
+ *
+ * @uses $wpdb WordPress Database object
+ *
+ * @param string $key Hash to validate sending user's password
+ * @param string $login The user login
+ *
+ * @return object|WP_Error
+ */
+function check_password_reset_key($key, $login) {
+	global $wpdb;
+
+	$key = preg_replace('/[^a-z0-9]/i', '', $key);
+
+	if ( empty( $key ) || !is_string( $key ) )
+		return new WP_Error('invalid_key', __('Invalid key'));
+
+	if ( empty($login) || !is_string($login) )
+		return new WP_Error('invalid_key', __('Invalid key'));
+
+	$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
+
+	if ( empty( $user ) )
+		return new WP_Error('invalid_key', __('Invalid key'));
+
+	return $user;
+}
+
+/**
+ * Handles resetting the user's password.
+ *
+ * @uses $wpdb WordPress Database object
+ *
+ * @param string $key Hash to validate sending user's password
+ */
+function reset_password($user, $new_pass) {
+	do_action('password_reset', $user, $new_pass);
+
+	wp_set_password($new_pass, $user->ID);
+
+	wp_password_change_notification($user);
+}
+
+/**
+ * Handles registering a new user.
+ *
+ * @param string $user_login User's username for logging in
+ * @param string $user_email User's email address to send password and add
+ * @return int|WP_Error Either user's ID or error on failure.
+ */
+function register_new_user( $user_login, $user_email ) {
+	$errors = new WP_Error();
+
+	$sanitized_user_login = sanitize_user( $user_login );
+	$user_email = apply_filters( 'user_registration_email', $user_email );
+
+	// Check the username
+	if ( $sanitized_user_login == '' ) {
+		$errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) );
+	} elseif ( ! validate_username( $user_login ) ) {
+		$errors->add( 'invalid_username', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ) );
+		$sanitized_user_login = '';
+	} elseif ( username_exists( $sanitized_user_login ) ) {
+		$errors->add( 'username_exists', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' ) );
+	}
+
+	// Check the e-mail address
+	if ( $user_email == '' ) {
+		$errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your e-mail address.' ) );
+	} elseif ( ! is_email( $user_email ) ) {
+		$errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.' ) );
+		$user_email = '';
+	} elseif ( email_exists( $user_email ) ) {
+		$errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) );
+	}
+
+	do_action( 'register_post', $sanitized_user_login, $user_email, $errors );
+
+	$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
+
+	if ( $errors->get_error_code() )
+		return $errors;
+
+	$user_pass = wp_generate_password( 12, false);
+	$user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
+	if ( ! $user_id ) {
+		$errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
+		return $errors;
+	}
+
+	update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.
+
+	wp_new_user_notification( $user_id, $user_pass );
+
+	return $user_id;
+}
+
+//
+// Main
+//
+
+$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
+$errors = new WP_Error();
+
+if ( isset($_GET['key']) )
+	$action = 'resetpass';
+
+// validate action so as to default to the login screen
+if ( !in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login'), true) && false === has_filter('login_form_' . $action) )
+	$action = 'login';
+
+nocache_headers();
+
+header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
+
+if ( defined('RELOCATE') ) { // Move flag is set
+	if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
+		$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
+
+	$schema = is_ssl() ? 'https://' : 'http://';
+	if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('siteurl') )
+		update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
+}
+
+//Set a cookie now to see if they are supported by the browser.
+setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
+if ( SITECOOKIEPATH != COOKIEPATH )
+	setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
+
+// allow plugins to override the default actions, and to add extra actions if they want
+do_action('login_form_' . $action);
+
+$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
+switch ($action) {
+
+case 'logout' :
+	check_admin_referer('log-out');
+	wp_logout();
+
+	$redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?loggedout=true';
+	wp_safe_redirect( $redirect_to );
+	exit();
+
+break;
+
+case 'lostpassword' :
+case 'retrievepassword' :
+
+	if ( $http_post ) {
+		$errors = retrieve_password();
+		if ( !is_wp_error($errors) ) {
+			$redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
+			wp_safe_redirect( $redirect_to );
+			exit();
+		}
+	}
+
+	if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] ) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
+	$redirect_to = apply_filters( 'lostpassword_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
+
+	do_action('lost_password');
+	login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors);
+
+	$user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
+
+?>
+
+<form name="lostpasswordform" id="lostpasswordform" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" method="post">
+	<p>
+		<label><?php _e('Username or E-mail:') ?><br />
+		<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" tabindex="10" /></label>
+	</p>
+<?php do_action('lostpassword_form'); ?>
+	<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
+	<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Get New Password'); ?>" tabindex="100" /></p>
+</form>
+
+<p id="nav">
+<a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a>
+<?php if (get_option('users_can_register')) : ?>
+ | <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a>
+<?php endif; ?>
+</p>
+
+<?php
+login_footer('user_login');
+break;
+
+case 'resetpass' :
+case 'rp' :
+	$user = check_password_reset_key($_GET['key'], $_GET['login']);
+
+	if ( is_wp_error($user) ) {
+		wp_redirect( site_url('wp-login.php?action=lostpassword&error=invalidkey') );
+		exit;
+	}
+
+	$errors = '';
+
+	if ( isset($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2'] ) {
+		$errors = new WP_Error('password_reset_mismatch', __('The passwords do not match.'));
+	} elseif ( isset($_POST['pass1']) && !empty($_POST['pass1']) ) {
+		reset_password($user, $_POST['pass1']);
+		login_header(__('Password Reset'), '<p class="message reset-pass">' . __('Your password has been reset.') . ' <a href="' . site_url('wp-login.php', 'login') . '">' . __('Log in') . '</a></p>');
+		login_footer();
+		exit;
+	}
+
+	wp_enqueue_script('utils');
+	wp_enqueue_script('user-profile');
+
+	login_header(__('Reset Password'), '<p class="message reset-pass">' . __('Enter your new password below.') . '</p>', $errors );
+
+?>
+<form name="resetpassform" id="resetpassform" action="<?php echo site_url('wp-login.php?action=resetpass&key=' . urlencode($_GET['key']) . '&login=' . urlencode($_GET['login']), 'login_post') ?>" method="post">
+	<input type="hidden" id="user_login" value="<?php echo esc_attr( $_GET['login'] ); ?>" autocomplete="off" />
+
+	<p>
+		<label><?php _e('New password') ?><br />
+		<input type="password" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" /></label>
+	</p>
+	<p>
+		<label><?php _e('Confirm new password') ?><br />
+		<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" /></label>
+	</p>
+
+	<div id="pass-strength-result" class="hide-if-no-js"><?php _e('Strength indicator'); ?></div>
+	<p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
+
+	<br class="clear" />
+	<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Reset Password'); ?>" tabindex="100" /></p>
+</form>
+
+<p id="nav">
+<a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a>
+<?php if (get_option('users_can_register')) : ?>
+ | <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a>
+<?php endif; ?>
+</p>
+
+<?php
+login_footer('user_pass');
+break;
+
+case 'register' :
+	if ( is_multisite() ) {
+		// Multisite uses wp-signup.php
+		wp_redirect( apply_filters( 'wp_signup_location', site_url('wp-signup.php') ) );
+		exit;
+	}
+
+	if ( !get_option('users_can_register') ) {
+		wp_redirect( site_url('wp-login.php?registration=disabled') );
+		exit();
+	}
+
+	$user_login = '';
+	$user_email = '';
+	if ( $http_post ) {
+		$user_login = $_POST['user_login'];
+		$user_email = $_POST['user_email'];
+		$errors = register_new_user($user_login, $user_email);
+		if ( !is_wp_error($errors) ) {
+			$redirect_to = !empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : 'wp-login.php?checkemail=registered';
+			wp_safe_redirect( $redirect_to );
+			exit();
+		}
+	}
+
+	$redirect_to = apply_filters( 'registration_redirect', !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );
+	login_header(__('Registration Form'), '<p class="message register">' . __('Register For This Site') . '</p>', $errors);
+?>
+
+<form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
+	<p>
+		<label><?php _e('Username') ?><br />
+		<input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" tabindex="10" /></label>
+	</p>
+	<p>
+		<label><?php _e('E-mail') ?><br />
+		<input type="text" name="user_email" id="user_email" class="input" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" tabindex="20" /></label>
+	</p>
+<?php do_action('register_form'); ?>
+	<p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p>
+	<br class="clear" />
+	<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
+	<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Register'); ?>" tabindex="100" /></p>
+</form>
+
+<p id="nav">
+<a href="<?php echo site_url('wp-login.php', 'login') ?>"><?php _e('Log in') ?></a> |
+<a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
+</p>
+
+<?php
+login_footer('user_login');
+break;
+
+case 'login' :
+default:
+	$secure_cookie = '';
+	$interim_login = isset($_REQUEST['interim-login']);
+
+	// If the user wants ssl but the session is not ssl, force a secure cookie.
+	if ( !empty($_POST['log']) && !force_ssl_admin() ) {
+		$user_name = sanitize_user($_POST['log']);
+		if ( $user = get_userdatabylogin($user_name) ) {
+			if ( get_user_option('use_ssl', $user->ID) ) {
+				$secure_cookie = true;
+				force_ssl_admin(true);
+			}
+		}
+	}
+
+	if ( isset( $_REQUEST['redirect_to'] ) ) {
+		$redirect_to = $_REQUEST['redirect_to'];
+		// Redirect to https if user wants ssl
+		if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') )
+			$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
+	} else {
+		$redirect_to = admin_url();
+	}
+
+	$reauth = empty($_REQUEST['reauth']) ? false : true;
+
+	// If the user was redirected to a secure login form from a non-secure admin page, and secure login is required but secure admin is not, then don't use a secure
+	// cookie and redirect back to the referring non-secure admin page.  This allows logins to always be POSTed over SSL while allowing the user to choose visiting
+	// the admin via http or https.
+	if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
+		$secure_cookie = false;
+
+	$user = wp_signon('', $secure_cookie);
+
+	$redirect_to = apply_filters('login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
+
+	if ( !is_wp_error($user) && !$reauth ) {
+		if ( $interim_login ) {
+			$message = '<p class="message">' . __('You have logged in successfully.') . '</p>';
+			login_header( '', $message ); ?>
+			<script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script>
+			<p class="alignright">
+			<input type="button" class="button-primary" value="<?php esc_attr_e('Close'); ?>" onclick="window.close()" /></p>
+			</div></body></html>
+<?php		exit;
+		}
+
+		if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
+			// If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
+			if ( is_multisite() && !get_active_blog_for_user($user->id) )
+				$redirect_to = user_admin_url();
+			elseif ( is_multisite() && !$user->has_cap('read') )
+				$redirect_to = get_dashboard_url( $user->id );
+			elseif ( !$user->has_cap('edit_posts') )
+				$redirect_to = admin_url('profile.php');
+		}
+		wp_safe_redirect($redirect_to);
+		exit();
+	}
+
+	$errors = $user;
+	// Clear errors if loggedout is set.
+	if ( !empty($_GET['loggedout']) || $reauth )
+		$errors = new WP_Error();
+
+	// If cookies are disabled we can't log in even with a valid user+pass
+	if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
+		$errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
+
+	// Some parts of this script use the main login form to display a message
+	if		( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
+		$errors->add('loggedout', __('You are now logged out.'), 'message');
+	elseif	( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
+		$errors->add('registerdisabled', __('User registration is currently not allowed.'));
+	elseif	( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
+		$errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
+	elseif	( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
+		$errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
+	elseif	( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )
+		$errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
+	elseif	( $interim_login )
+		$errors->add('expired', __('Your session has expired. Please log-in again.'), 'message');
+
+	// Clear any stale cookies.
+	if ( $reauth )
+		wp_clear_auth_cookie();
+
+	login_header(__('Log In'), '', $errors);
+
+	if ( isset($_POST['log']) )
+		$user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(stripslashes($_POST['log'])) : '';
+	$rememberme = ! empty( $_POST['rememberme'] );
+?>
+
+<form name="loginform" id="loginform" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post">
+	<p>
+		<label><?php _e('Username') ?><br />
+		<input type="text" name="log" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" tabindex="10" /></label>
+	</p>
+	<p>
+		<label><?php _e('Password') ?><br />
+		<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
+	</p>
+<?php do_action('login_form'); ?>
+	<p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90"<?php checked( $rememberme ); ?> /> <?php esc_attr_e('Remember Me'); ?></label></p>
+	<p class="submit">
+		<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e('Log In'); ?>" tabindex="100" />
+<?php	if ( $interim_login ) { ?>
+		<input type="hidden" name="interim-login" value="1" />
+<?php	} else { ?>
+		<input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />
+<?php 	} ?>
+		<input type="hidden" name="testcookie" value="1" />
+	</p>
+</form>
+
+<?php if ( !$interim_login ) { ?>
+<p id="nav">
+<?php if ( isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) ) : ?>
+<?php elseif ( get_option('users_can_register') ) : ?>
+<a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a> |
+<a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
+<?php else : ?>
+<a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
+<?php endif; ?>
+</p>
+</div>
+<p id="backtoblog"><a href="<?php bloginfo('url'); ?>/" title="<?php esc_attr_e('Are you lost?') ?>"><?php printf(__('&larr; Back to %s'), get_bloginfo('title', 'display' )); ?></a></p>
+<?php } else { ?>
+</div>
+<?php } ?>
+
+<script type="text/javascript">
+function wp_attempt_focus(){
+setTimeout( function(){ try{
+<?php if ( $user_login || $interim_login ) { ?>
+d = document.getElementById('user_pass');
+d.value = '';
+<?php } else { ?>
+d = document.getElementById('user_login');
+<?php if ( 'invalid_username' == $errors->get_error_code() ) { ?>
+if( d.value != '' )
+d.value = '';
+<?php
+}
+}?>
+d.focus();
+d.select();
+} catch(e){}
+}, 200);
+}
+
+<?php if ( !$error ) { ?>
+wp_attempt_focus();
+<?php } ?>
+if(typeof wpOnload=='function')wpOnload();
+</script>
+<?php do_action( 'login_footer' ); ?>
+</body>
+</html>
+<?php
+
+break;
+} // end action switch
+?>
Index: /tags/3.1/wp-mail.php
===================================================================
--- /tags/3.1/wp-mail.php	(revision 17487)
+++ /tags/3.1/wp-mail.php	(revision 17487)
@@ -0,0 +1,236 @@
+<?php
+/**
+ * Gets the email message from the user's mailbox to add as
+ * a WordPress post. Mailbox connection information must be
+ * configured under Settings > Writing
+ *
+ * @package WordPress
+ */
+
+/** Make sure that the WordPress bootstrap has run before continuing. */
+require(dirname(__FILE__) . '/wp-load.php');
+
+if ( ! apply_filters( 'enable_post_by_email_configuration', true ) )
+	wp_die( __( 'This action has been disabled by the administrator.' ) );
+
+/** Allow a plugin to do a complete takeover of Post by Email **/
+do_action('wp-mail.php');
+
+/** Get the POP3 class with which to access the mailbox. */
+require_once( ABSPATH . WPINC . '/class-pop3.php' );
+
+/** Only check at this interval for new messages. */
+if ( !defined('WP_MAIL_INTERVAL') )
+	define('WP_MAIL_INTERVAL', 300); // 5 minutes
+
+$last_checked = get_transient('mailserver_last_checked');
+
+if ( $last_checked )
+	wp_die(__('Slow down cowboy, no need to check for new mails so often!'));
+
+set_transient('mailserver_last_checked', true, WP_MAIL_INTERVAL);
+
+$time_difference = get_option('gmt_offset') * 3600;
+
+$phone_delim = '::';
+
+$pop3 = new POP3();
+
+if ( !$pop3->connect( get_option('mailserver_url'), get_option('mailserver_port') ) || !$pop3->user( get_option('mailserver_login') ) )
+	wp_die( esc_html( $pop3->ERROR ) );
+
+$count = $pop3->pass( get_option('mailserver_pass') );
+
+if( false === $count )
+	wp_die( esc_html( $pop3->ERROR ) );
+
+if( 0 === $count ) {
+	$pop3->quit();
+	wp_die( __('There doesn&#8217;t seem to be any new mail.') );
+}
+
+for ( $i = 1; $i <= $count; $i++ ) {
+
+	$message = $pop3->get($i);
+
+	$bodysignal = false;
+	$boundary = '';
+	$charset = '';
+	$content = '';
+	$content_type = '';
+	$content_transfer_encoding = '';
+	$post_author = 1;
+	$author_found = false;
+	$dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
+	foreach ($message as $line) {
+		// body signal
+		if ( strlen($line) < 3 )
+			$bodysignal = true;
+		if ( $bodysignal ) {
+			$content .= $line;
+		} else {
+			if ( preg_match('/Content-Type: /i', $line) ) {
+				$content_type = trim($line);
+				$content_type = substr($content_type, 14, strlen($content_type) - 14);
+				$content_type = explode(';', $content_type);
+				if ( ! empty( $content_type[1] ) ) {
+					$charset = explode('=', $content_type[1]);
+					$charset = ( ! empty( $charset[1] ) ) ? trim($charset[1]) : '';
+				}
+				$content_type = $content_type[0];
+			}
+			if ( preg_match('/Content-Transfer-Encoding: /i', $line) ) {
+				$content_transfer_encoding = trim($line);
+				$content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding) - 27);
+				$content_transfer_encoding = explode(';', $content_transfer_encoding);
+				$content_transfer_encoding = $content_transfer_encoding[0];
+			}
+			if ( ( $content_type == 'multipart/alternative' ) && ( false !== strpos($line, 'boundary="') ) && ( '' == $boundary ) ) {
+				$boundary = trim($line);
+				$boundary = explode('"', $boundary);
+				$boundary = $boundary[1];
+			}
+			if (preg_match('/Subject: /i', $line)) {
+				$subject = trim($line);
+				$subject = substr($subject, 9, strlen($subject) - 9);
+				// Captures any text in the subject before $phone_delim as the subject
+				if ( function_exists('iconv_mime_decode') ) {
+					$subject = iconv_mime_decode($subject, 2, get_option('blog_charset'));
+				} else {
+					$subject = wp_iso_descrambler($subject);
+				}
+				$subject = explode($phone_delim, $subject);
+				$subject = $subject[0];
+			}
+
+			// Set the author using the email address (From or Reply-To, the last used)
+			// otherwise use the site admin
+			if ( preg_match('/(From|Reply-To): /', $line) )  {
+				if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) )
+					$author = $matches[0];
+				else
+					$author = trim($line);
+				$author = sanitize_email($author);
+				if ( is_email($author) ) {
+					echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';
+					$userdata = get_user_by_email($author);
+					if ( empty($userdata) ) {
+						$author_found = false;
+					} else {
+						$post_author = $userdata->ID;
+						$author_found = true;
+					}
+				} else {
+					$author_found = false;
+				}
+			}
+
+			if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
+				$ddate = trim($line);
+				$ddate = str_replace('Date: ', '', $ddate);
+				if (strpos($ddate, ',')) {
+					$ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
+				}
+				$date_arr = explode(' ', $ddate);
+				$date_time = explode(':', $date_arr[3]);
+
+				$ddate_H = $date_time[0];
+				$ddate_i = $date_time[1];
+				$ddate_s = $date_time[2];
+
+				$ddate_m = $date_arr[1];
+				$ddate_d = $date_arr[0];
+				$ddate_Y = $date_arr[2];
+				for ( $j = 0; $j < 12; $j++ ) {
+					if ( $ddate_m == $dmonths[$j] ) {
+						$ddate_m = $j+1;
+					}
+				}
+
+				$time_zn = intval($date_arr[4]) * 36;
+				$ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
+				$ddate_U = $ddate_U - $time_zn;
+				$post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);
+				$post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
+			}
+		}
+	}
+
+	// Set $post_status based on $author_found and on author's publish_posts capability
+	if ( $author_found ) {
+		$user = new WP_User($post_author);
+		$post_status = ( $user->has_cap('publish_posts') ) ? 'publish' : 'pending';
+	} else {
+		// Author not found in DB, set status to pending.  Author already set to admin.
+		$post_status = 'pending';
+	}
+
+	$subject = trim($subject);
+
+	if ( $content_type == 'multipart/alternative' ) {
+		$content = explode('--'.$boundary, $content);
+		$content = $content[2];
+		// match case-insensitive content-transfer-encoding
+		if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim) ) {
+			$content = explode($delim[0], $content);
+			$content = $content[1];
+		}
+		$content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
+	}
+	$content = trim($content);
+
+	//Give Post-By-Email extending plugins full access to the content
+	//Either the raw content or the content of the last quoted-printable section
+	$content = apply_filters('wp_mail_original_content', $content);
+
+	if ( false !== stripos($content_transfer_encoding, "quoted-printable") ) {
+		$content = quoted_printable_decode($content);
+	}
+
+	if ( function_exists('iconv') && ! empty( $charset ) ) {
+		$content = iconv($charset, get_option('blog_charset'), $content);
+	}
+
+	// Captures any text in the body after $phone_delim as the body
+	$content = explode($phone_delim, $content);
+	$content = empty( $content[1] ) ? $content[0] : $content[1];
+
+	$content = trim($content);
+
+	$post_content = apply_filters('phone_content', $content);
+
+	$post_title = xmlrpc_getposttitle($content);
+
+	if ($post_title == '') $post_title = $subject;
+
+	$post_category = array(get_option('default_email_category'));
+
+	$post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
+	$post_data = add_magic_quotes($post_data);
+
+	$post_ID = wp_insert_post($post_data);
+	if ( is_wp_error( $post_ID ) )
+		echo "\n" . $post_ID->get_error_message();
+
+	// We couldn't post, for whatever reason. Better move forward to the next email.
+	if ( empty( $post_ID ) )
+		continue;
+
+	do_action('publish_phone', $post_ID);
+
+	echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), esc_html($post_author)) . '</p>';
+	echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), esc_html($post_title)) . '</p>';
+
+	if(!$pop3->delete($i)) {
+		echo '<p>' . sprintf(__('Oops: %s'), esc_html($pop3->ERROR)) . '</p>';
+		$pop3->reset();
+		exit;
+	} else {
+		echo '<p>' . sprintf(__('Mission complete.  Message <strong>%s</strong> deleted.'), $i) . '</p>';
+	}
+
+}
+
+$pop3->quit();
+
+?>
Index: /tags/3.1/wp-pass.php
===================================================================
--- /tags/3.1/wp-pass.php	(revision 17487)
+++ /tags/3.1/wp-pass.php	(revision 17487)
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Creates the password cookie and redirects back to where the
+ * visitor was before.
+ *
+ * @package WordPress
+ */
+
+/** Make sure that the WordPress bootstrap has run before continuing. */
+require( dirname(__FILE__) . '/wp-load.php');
+
+if ( get_magic_quotes_gpc() )
+	$_POST['post_password'] = stripslashes($_POST['post_password']);
+
+// 10 days
+setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);
+
+wp_safe_redirect(wp_get_referer());
+exit;
+?>
Index: /tags/3.1/wp-rdf.php
===================================================================
--- /tags/3.1/wp-rdf.php	(revision 17487)
+++ /tags/3.1/wp-rdf.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Redirects to the RDF feed
+ * This file is deprecated and only exists for backwards compatibility
+ *
+ * @package WordPress
+ */
+
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'rdf_url' ), 301 );
+exit;
+?>
Index: /tags/3.1/wp-register.php
===================================================================
--- /tags/3.1/wp-register.php	(revision 17487)
+++ /tags/3.1/wp-register.php	(revision 17487)
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Used to be the page which displayed the registration form.
+ *
+ * This file is no longer used in WordPress and is
+ * deprecated.
+ *
+ * @package WordPress
+ * @deprecated Use wp_register() to create a registration link instead
+ */
+
+require('./wp-load.php');
+wp_redirect( site_url('wp-login.php?action=register') );
+exit;
+?>
Index: /tags/3.1/wp-rss.php
===================================================================
--- /tags/3.1/wp-rss.php	(revision 17487)
+++ /tags/3.1/wp-rss.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Redirects to the RSS feed
+ * This file is deprecated and only exists for backwards compatibility
+ *
+ * @package WordPress
+ */
+
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'rss_url' ), 301 );
+exit;
+?>
Index: /tags/3.1/wp-rss2.php
===================================================================
--- /tags/3.1/wp-rss2.php	(revision 17487)
+++ /tags/3.1/wp-rss2.php	(revision 17487)
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Redirects to the RSS2 feed
+ * This file is deprecated and only exists for backwards compatibility
+ *
+ * @package WordPress
+ */
+
+require( './wp-load.php' );
+wp_redirect( get_bloginfo( 'rss2_url' ), 301 );
+exit;
+?>
Index: /tags/3.1/wp-settings.php
===================================================================
--- /tags/3.1/wp-settings.php	(revision 17487)
+++ /tags/3.1/wp-settings.php	(revision 17487)
@@ -0,0 +1,320 @@
+<?php
+/**
+ * Used to set up and fix common variables and include
+ * the WordPress procedural and class library.
+ *
+ * Allows for some configuration in wp-config.php (see default-constants.php)
+ *
+ * @package WordPress
+ */
+
+/**
+ * Stores the location of the WordPress directory of functions, classes, and core content.
+ *
+ * @since 1.0.0
+ */
+define( 'WPINC', 'wp-includes' );
+
+// Include files required for initialization.
+require( ABSPATH . WPINC . '/load.php' );
+require( ABSPATH . WPINC . '/default-constants.php' );
+require( ABSPATH . WPINC . '/version.php' );
+
+// Set initial default constants including WP_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
+wp_initial_constants( );
+
+// Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
+set_magic_quotes_runtime( 0 );
+@ini_set( 'magic_quotes_sybase', 0 );
+
+// Set default timezone in PHP 5.
+if ( function_exists( 'date_default_timezone_set' ) )
+	date_default_timezone_set( 'UTC' );
+
+// Turn register_globals off.
+wp_unregister_GLOBALS();
+
+// Ensure these global variables do not exist so they do not interfere with WordPress.
+unset( $wp_filter, $cache_lastcommentmodified );
+
+// Standardize $_SERVER variables across setups.
+wp_fix_server_vars();
+
+// Check for the required PHP version and for the MySQL extension or a database drop-in.
+wp_check_php_mysql_versions();
+
+// Check if we have recieved a request due to missing favicon.ico
+wp_favicon_request();
+
+// Check if we're in maintenance mode.
+wp_maintenance();
+
+// Start loading timer.
+timer_start();
+
+// Check if we're in WP_DEBUG mode.
+wp_debug_mode();
+
+// For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
+if ( WP_CACHE )
+	WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' );
+
+// Define WP_LANG_DIR if not set.
+wp_set_lang_dir();
+
+// Load early WordPress files.
+require( ABSPATH . WPINC . '/compat.php' );
+require( ABSPATH . WPINC . '/functions.php' );
+require( ABSPATH . WPINC . '/class-wp.php' );
+require( ABSPATH . WPINC . '/class-wp-error.php' );
+require( ABSPATH . WPINC . '/plugin.php' );
+
+// Include the wpdb class and, if present, a db.php database drop-in.
+require_wp_db();
+
+// Set the database table prefix and the format specifiers for database table columns.
+wp_set_wpdb_vars();
+
+// Start the WordPress object cache, or an external object cache if the drop-in is present.
+wp_start_object_cache();
+
+// Load early WordPress files.
+require( ABSPATH . WPINC . '/default-filters.php' );
+require( ABSPATH . WPINC . '/pomo/mo.php' );
+
+// Initialize multisite if enabled.
+if ( is_multisite() ) {
+	require( ABSPATH . WPINC . '/ms-blogs.php' );
+	require( ABSPATH . WPINC . '/ms-settings.php' );
+} elseif ( ! defined( 'MULTISITE' ) ) {
+	define( 'MULTISITE', false );
+}
+
+// Stop most of WordPress from being loaded if we just want the basics.
+if ( SHORTINIT )
+	return false;
+
+// Load the l18n library.
+require( ABSPATH . WPINC . '/l10n.php' );
+
+// Run the installer if WordPress is not installed.
+wp_not_installed();
+
+// Load most of WordPress.
+require( ABSPATH . WPINC . '/class-wp-walker.php' );
+require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
+require( ABSPATH . WPINC . '/formatting.php' );
+require( ABSPATH . WPINC . '/capabilities.php' );
+require( ABSPATH . WPINC . '/query.php' );
+require( ABSPATH . WPINC . '/theme.php' );
+require( ABSPATH . WPINC . '/user.php' );
+require( ABSPATH . WPINC . '/meta.php' );
+require( ABSPATH . WPINC . '/general-template.php' );
+require( ABSPATH . WPINC . '/link-template.php' );
+require( ABSPATH . WPINC . '/author-template.php' );
+require( ABSPATH . WPINC . '/post.php' );
+require( ABSPATH . WPINC . '/post-template.php' );
+require( ABSPATH . WPINC . '/category.php' );
+require( ABSPATH . WPINC . '/category-template.php' );
+require( ABSPATH . WPINC . '/comment.php' );
+require( ABSPATH . WPINC . '/comment-template.php' );
+require( ABSPATH . WPINC . '/rewrite.php' );
+require( ABSPATH . WPINC . '/feed.php' );
+require( ABSPATH . WPINC . '/bookmark.php' );
+require( ABSPATH . WPINC . '/bookmark-template.php' );
+require( ABSPATH . WPINC . '/kses.php' );
+require( ABSPATH . WPINC . '/cron.php' );
+require( ABSPATH . WPINC . '/deprecated.php' );
+require( ABSPATH . WPINC . '/script-loader.php' );
+require( ABSPATH . WPINC . '/taxonomy.php' );
+require( ABSPATH . WPINC . '/update.php' );
+require( ABSPATH . WPINC . '/canonical.php' );
+require( ABSPATH . WPINC . '/shortcodes.php' );
+require( ABSPATH . WPINC . '/media.php' );
+require( ABSPATH . WPINC . '/http.php' );
+require( ABSPATH . WPINC . '/class-http.php' );
+require( ABSPATH . WPINC . '/widgets.php' );
+require( ABSPATH . WPINC . '/nav-menu.php' );
+require( ABSPATH . WPINC . '/nav-menu-template.php' );
+require( ABSPATH . WPINC . '/admin-bar.php' );
+
+// Load multisite-specific files.
+if ( is_multisite() ) {
+	require( ABSPATH . WPINC . '/ms-functions.php' );
+	require( ABSPATH . WPINC . '/ms-default-filters.php' );
+	require( ABSPATH . WPINC . '/ms-deprecated.php' );
+}
+
+// Define constants that rely on the API to obtain the default value.
+// Define must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
+wp_plugin_directory_constants( );
+
+// Load must-use plugins.
+foreach ( wp_get_mu_plugins() as $mu_plugin ) {
+	include_once( $mu_plugin );
+}
+unset( $mu_plugin );
+
+// Load network activated plugins.
+if ( is_multisite() ) {
+	foreach( wp_get_active_network_plugins() as $network_plugin ) {
+		include_once( $network_plugin );
+	}
+	unset( $network_plugin );
+}
+
+do_action( 'muplugins_loaded' );
+
+if ( is_multisite() )
+	ms_cookie_constants(  );
+
+// Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
+wp_cookie_constants( );
+
+// Define and enforce our SSL constants
+wp_ssl_constants( );
+
+// Create common globals.
+require( ABSPATH . WPINC . '/vars.php' );
+
+// Make taxonomies and posts available to plugins and themes.
+// @plugin authors: warning: these get registered again on the init hook.
+create_initial_taxonomies();
+create_initial_post_types();
+
+// Register the default theme directory root
+register_theme_directory( get_theme_root() );
+
+// Load active plugins.
+foreach ( wp_get_active_and_valid_plugins() as $plugin )
+	include_once( $plugin );
+unset( $plugin );
+
+// Load pluggable functions.
+require( ABSPATH . WPINC . '/pluggable.php' );
+require( ABSPATH . WPINC . '/pluggable-deprecated.php' );
+
+// Set internal encoding.
+wp_set_internal_encoding();
+
+// Run wp_cache_postload() if object cache is enabled and the function exists.
+if ( WP_CACHE && function_exists( 'wp_cache_postload' ) )
+	wp_cache_postload();
+
+do_action( 'plugins_loaded' );
+
+// Define constants which affect functionality if not already defined.
+wp_functionality_constants( );
+
+// Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
+wp_magic_quotes();
+
+do_action( 'sanitize_comment_cookies' );
+
+/**
+ * WordPress Query object
+ * @global object $wp_the_query
+ * @since 2.0.0
+ */
+$wp_the_query =& new WP_Query();
+
+/**
+ * Holds the reference to @see $wp_the_query
+ * Use this global for WordPress queries
+ * @global object $wp_query
+ * @since 1.5.0
+ */
+$wp_query =& $wp_the_query;
+
+/**
+ * Holds the WordPress Rewrite object for creating pretty URLs
+ * @global object $wp_rewrite
+ * @since 1.5.0
+ */
+$wp_rewrite =& new WP_Rewrite();
+
+/**
+ * WordPress Object
+ * @global object $wp
+ * @since 2.0.0
+ */
+$wp =& new WP();
+
+/**
+ * WordPress Widget Factory Object
+ * @global object $wp_widget_factory
+ * @since 2.8.0
+ */
+$wp_widget_factory =& new WP_Widget_Factory();
+
+do_action( 'setup_theme' );
+
+// Define the template related constants.
+wp_templating_constants(  );
+
+// Load the default text localization domain.
+load_default_textdomain();
+
+// Find the blog locale.
+$locale = get_locale();
+$locale_file = WP_LANG_DIR . "/$locale.php";
+if ( is_readable( $locale_file ) )
+	require( $locale_file );
+unset($locale_file);
+
+// Pull in locale data after loading text domain.
+require( ABSPATH . WPINC . '/locale.php' );
+
+/**
+ * WordPress Locale object for loading locale domain date and various strings.
+ * @global object $wp_locale
+ * @since 2.1.0
+ */
+$wp_locale =& new WP_Locale();
+
+// Load the functions for the active theme, for both parent and child theme if applicable.
+if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
+	include( STYLESHEETPATH . '/functions.php' );
+if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
+	include( TEMPLATEPATH . '/functions.php' );
+
+do_action( 'after_setup_theme' );
+
+// Load any template functions the theme supports.
+require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
+
+register_shutdown_function( 'shutdown_action_hook' );
+
+// Set up current user.
+$wp->init();
+
+/**
+ * Most of WP is loaded at this stage, and the user is authenticated. WP continues
+ * to load on the init hook that follows (e.g. widgets), and many plugins instantiate
+ * themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
+ *
+ * If you wish to plug an action once WP is loaded, use the wp_loaded hook below.
+ */
+do_action( 'init' );
+
+// Check site status
+if ( is_multisite() ) {
+	if ( true !== ( $file = ms_site_check() ) ) {
+		require( $file );
+		die();
+	}
+	unset($file);
+}
+
+/**
+ * This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.
+ *
+ * AJAX requests should use wp-admin/admin-ajax.php. admin-ajax.php can handle requests for
+ * users not logged in.
+ *
+ * @link http://codex.wordpress.org/AJAX_in_Plugins
+ *
+ * @since 3.0.0
+ */
+do_action('wp_loaded');
+?>
Index: /tags/3.1/wp-signup.php
===================================================================
--- /tags/3.1/wp-signup.php	(revision 17487)
+++ /tags/3.1/wp-signup.php	(revision 17487)
@@ -0,0 +1,455 @@
+<?php
+
+/** Sets up the WordPress Environment. */
+require( dirname(__FILE__) . '/wp-load.php' );
+
+add_action( 'wp_head', 'signuppageheaders' ) ;
+
+require( './wp-blog-header.php' );
+
+if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
+	wp_redirect( network_home_url() );
+	die();
+}
+
+function do_signup_header() {
+	do_action("signup_header");
+}
+add_action( 'wp_head', 'do_signup_header' );
+
+function signuppageheaders() {
+	echo "<meta name='robots' content='noindex,nofollow' />\n";
+}
+
+if ( !is_multisite() ) {
+	wp_redirect( site_url('wp-login.php?action=register') );
+	die();
+}
+
+if ( !is_main_site() ) {
+	wp_redirect( network_home_url( 'wp-signup.php' ) );
+	die();
+}
+
+// Fix for page title
+$wp_query->is_404 = false;
+
+function wpmu_signup_stylesheet() {
+	?>
+	<style type="text/css">
+		.mu_register { width: 90%; margin:0 auto; }
+		.mu_register form { margin-top: 2em; }
+		.mu_register .error { font-weight:700; padding:10px; color:#333333; background:#FFEBE8; border:1px solid #CC0000; }
+		.mu_register input[type="submit"],
+			.mu_register #blog_title,
+			.mu_register #user_email,
+			.mu_register #blogname,
+			.mu_register #user_name { width:100%; font-size: 24px; margin:5px 0; }
+		.mu_register .prefix_address,
+			.mu_register .suffix_address {font-size: 18px;display:inline; }
+		.mu_register label { font-weight:700; font-size:15px; display:block; margin:10px 0; }
+		.mu_register label.checkbox { display:inline; }
+		.mu_register .mu_alert { font-weight:700; padding:10px; color:#333333; background:#ffffe0; border:1px solid #e6db55; }
+	</style>
+	<?php
+}
+
+add_action( 'wp_head', 'wpmu_signup_stylesheet' );
+get_header();
+
+do_action( 'before_signup_form' );
+?>
+<div id="content" class="widecolumn">
+<div class="mu_register">
+<?php
+function show_blog_form($blogname = '', $blog_title = '', $errors = '') {
+	global $current_site;
+	// Blog name
+	if ( !is_subdomain_install() )
+		echo '<label for="blogname">' . __('Site Name:') . '</label>';
+	else
+		echo '<label for="blogname">' . __('Site Domain:') . '</label>';
+
+	if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
+		<p class="error"><?php echo $errmsg ?></p>
+	<?php }
+
+	if ( !is_subdomain_install() )
+		echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" /><br />';
+	else
+		echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';
+
+	if ( !is_user_logged_in() ) {
+		if ( !is_subdomain_install() )
+			$site = $current_site->domain . $current_site->path . __( 'sitename' );
+		else
+			$site = __( 'domain' ) . '.' . $site_domain . $current_site->path;
+		echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
+	}
+
+	// Blog Title
+	?>
+	<label for="blog_title"><?php _e('Site Title:') ?></label>
+	<?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
+		<p class="error"><?php echo $errmsg ?></p>
+	<?php }
+	echo '<input name="blog_title" type="text" id="blog_title" value="'.esc_attr($blog_title).'" />';
+	?>
+
+	<div id="privacy">
+        <p class="privacy-intro">
+            <label for="blog_public_on"><?php _e('Privacy:') ?></label>
+            <?php _e('Allow my site to appear in search engines like Google, Technorati, and in public listings around this network.'); ?>
+            <br style="clear:both" />
+            <label class="checkbox" for="blog_public_on">
+                <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if ( !isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
+                <strong><?php _e( 'Yes' ); ?></strong>
+            </label>
+            <label class="checkbox" for="blog_public_off">
+                <input type="radio" id="blog_public_off" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
+                <strong><?php _e( 'No' ); ?></strong>
+            </label>
+        </p>
+	</div>
+
+	<?php
+	do_action('signup_blogform', $errors);
+}
+
+function validate_blog_form() {
+	$user = '';
+	if ( is_user_logged_in() )
+		$user = wp_get_current_user();
+
+	return wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $user);
+}
+
+function show_user_form($user_name = '', $user_email = '', $errors = '') {
+	// User name
+	echo '<label for="user_name">' . __('Username:') . '</label>';
+	if ( $errmsg = $errors->get_error_message('user_name') ) {
+		echo '<p class="error">'.$errmsg.'</p>';
+	}
+	echo '<input name="user_name" type="text" id="user_name" value="'. esc_attr($user_name) .'" maxlength="60" /><br />';
+	_e( '(Must be at least 4 characters, letters and numbers only.)' );
+	?>
+
+	<label for="user_email"><?php _e( 'Email&nbsp;Address:' ) ?></label>
+	<?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
+		<p class="error"><?php echo $errmsg ?></p>
+	<?php } ?>
+	<input name="user_email" type="text" id="user_email" value="<?php  echo esc_attr($user_email) ?>" maxlength="200" /><br /><?php _e('We send your registration email to this address. (Double-check your email address before continuing.)') ?>
+	<?php
+	if ( $errmsg = $errors->get_error_message('generic') ) {
+		echo '<p class="error">' . $errmsg . '</p>';
+	}
+	do_action( 'signup_extra_fields', $errors );
+}
+
+function validate_user_form() {
+	return wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
+}
+
+function signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
+	global $current_site;
+	$current_user = wp_get_current_user();
+
+	if ( ! is_wp_error($errors) ) {
+		$errors = new WP_Error();
+	}
+
+	// allow definition of default variables
+	$filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
+	$blogname = $filtered_results['blogname'];
+	$blog_title = $filtered_results['blog_title'];
+	$errors = $filtered_results['errors'];
+
+	echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), $current_site->site_name ) . '</h2>';
+
+	if ( $errors->get_error_code() ) {
+		echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
+	}
+	?>
+	<p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart&#8217;s content, but write responsibly!' ), $current_user->display_name ) ?></p>
+
+	<?php
+	$blogs = get_blogs_of_user($current_user->ID);
+	if ( !empty($blogs) ) { ?>
+
+			<p><?php _e( 'Sites you are already a member of:' ) ?></p>
+			<ul>
+				<?php foreach ( $blogs as $blog ) {
+					$home_url = get_home_url( $blog->userblog_id );
+					echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
+				} ?>
+			</ul>
+	<?php } ?>
+
+	<p><?php _e( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!' ) ?></p>
+	<form id="setupform" method="post" action="wp-signup.php">
+		<input type="hidden" name="stage" value="gimmeanotherblog" />
+		<?php do_action( "signup_hidden_fields" ); ?>
+		<?php show_blog_form($blogname, $blog_title, $errors); ?>
+		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site' ) ?>" /></p>
+	</form>
+	<?php
+}
+
+function validate_another_blog_signup() {
+	global $wpdb, $blogname, $blog_title, $errors, $domain, $path;
+	$current_user = wp_get_current_user();
+	if ( !is_user_logged_in() )
+		die();
+
+	$result = validate_blog_form();
+	extract($result);
+
+	if ( $errors->get_error_code() ) {
+		signup_another_blog($blogname, $blog_title, $errors);
+		return false;
+	}
+
+	$public = (int) $_POST['blog_public'];
+	$meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // deprecated
+	$meta = apply_filters( 'add_signup_meta', $meta );
+
+	wpmu_create_blog( $domain, $path, $blog_title, $current_user->id, $meta, $wpdb->siteid );
+	confirm_another_blog_signup($domain, $path, $blog_title, $current_user->user_login, $current_user->user_email, $meta);
+	return true;
+}
+
+function confirm_another_blog_signup($domain, $path, $blog_title, $user_name, $user_email = '', $meta = '') {
+	?>
+	<h2><?php printf( __( 'The site %s is yours.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
+	<p>
+		<?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site.  <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $user_name ) ?>
+	</p>
+	<?php
+	do_action( 'signup_finished' );
+}
+
+function signup_user($user_name = '', $user_email = '', $errors = '') {
+	global $current_site, $active_signup;
+
+	if ( !is_wp_error($errors) )
+		$errors = new WP_Error();
+	if ( isset( $_POST[ 'signup_for' ] ) )
+		$signup[ esc_html( $_POST[ 'signup_for' ] ) ] = 'checked="checked"';
+	else
+		$signup[ 'blog' ] = 'checked="checked"';
+
+	//TODO - This doesn't seem to do anything do we really need it?
+	$signup['user'] = isset( $signup['user'] ) ? $signup['user'] : '';
+
+	// allow definition of default variables
+	$filtered_results = apply_filters('signup_user_init', array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors ));
+	$user_name = $filtered_results['user_name'];
+	$user_email = $filtered_results['user_email'];
+	$errors = $filtered_results['errors'];
+
+	?>
+
+	<h2><?php printf( __( 'Get your own %s account in seconds' ), $current_site->site_name ) ?></h2>
+	<form id="setupform" method="post" action="wp-signup.php">
+		<input type="hidden" name="stage" value="validate-user-signup" />
+		<?php do_action( "signup_hidden_fields" ); ?>
+		<?php show_user_form($user_name, $user_email, $errors); ?>
+
+		<p>
+		<?php if ( $active_signup == 'blog' ) { ?>
+			<input id="signupblog" type="hidden" name="signup_for" value="blog" />
+		<?php } elseif ( $active_signup == 'user' ) { ?>
+			<input id="signupblog" type="hidden" name="signup_for" value="user" />
+		<?php } else { ?>
+			<input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> />
+			<label class="checkbox" for="signupblog"><?php _e('Gimme a site!') ?></label>
+			<br />
+			<input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />
+			<label class="checkbox" for="signupuser"><?php _e('Just a username, please.') ?></label>
+		<?php } ?>
+		</p>
+
+		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Next') ?>" /></p>
+	</form>
+	<?php
+}
+
+function validate_user_signup() {
+	$result = validate_user_form();
+	extract($result);
+
+	if ( $errors->get_error_code() ) {
+		signup_user($user_name, $user_email, $errors);
+		return false;
+	}
+
+	if ( 'blog' == $_POST['signup_for'] ) {
+		signup_blog($user_name, $user_email);
+		return false;
+	}
+
+	wpmu_signup_user($user_name, $user_email, apply_filters( "add_signup_meta", array() ) );
+
+	confirm_user_signup($user_name, $user_email);
+	return true;
+}
+
+function confirm_user_signup($user_name, $user_email) {
+	?>
+	<h2><?php printf( __( '%s is your new username' ), $user_name) ?></h2>
+	<p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) ?></p>
+	<p><?php printf(__( 'Check your inbox at <strong>%1$s</strong> and click the link given.' ),  $user_email) ?></p>
+	<p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.' ); ?></p>
+	<?php
+	do_action( 'signup_finished' );
+}
+
+function signup_blog($user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '') {
+	if ( !is_wp_error($errors) )
+		$errors = new WP_Error();
+
+	// allow definition of default variables
+	$filtered_results = apply_filters('signup_blog_init', array('user_name' => $user_name, 'user_email' => $user_email, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
+	$user_name = $filtered_results['user_name'];
+	$user_email = $filtered_results['user_email'];
+	$blogname = $filtered_results['blogname'];
+	$blog_title = $filtered_results['blog_title'];
+	$errors = $filtered_results['errors'];
+
+	if ( empty($blogname) )
+		$blogname = $user_name;
+	?>
+	<form id="setupform" method="post" action="wp-signup.php">
+		<input type="hidden" name="stage" value="validate-blog-signup" />
+		<input type="hidden" name="user_name" value="<?php echo esc_attr($user_name) ?>" />
+		<input type="hidden" name="user_email" value="<?php echo esc_attr($user_email) ?>" />
+		<?php do_action( "signup_hidden_fields" ); ?>
+		<?php show_blog_form($blogname, $blog_title, $errors); ?>
+		<p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e('Signup') ?>" /></p>
+	</form>
+	<?php
+}
+
+function validate_blog_signup() {
+	// Re-validate user info.
+	$result = wpmu_validate_user_signup($_POST['user_name'], $_POST['user_email']);
+	extract($result);
+
+	if ( $errors->get_error_code() ) {
+		signup_user($user_name, $user_email, $errors);
+		return false;
+	}
+
+	$result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title']);
+	extract($result);
+
+	if ( $errors->get_error_code() ) {
+		signup_blog($user_name, $user_email, $blogname, $blog_title, $errors);
+		return false;
+	}
+
+	$public = (int) $_POST['blog_public'];
+	$meta = array ('lang_id' => 1, 'public' => $public);
+	$meta = apply_filters( "add_signup_meta", $meta );
+
+	wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);
+	confirm_blog_signup($domain, $path, $blog_title, $user_name, $user_email, $meta);
+	return true;
+}
+
+function confirm_blog_signup($domain, $path, $blog_title, $user_name = '', $user_email = '', $meta) {
+	?>
+	<h2><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
+
+	<p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) ?></p>
+	<p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.' ),  $user_email) ?></p>
+	<p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.' ); ?></p>
+	<h2><?php _e( 'Still waiting for your email?' ); ?></h2>
+	<p>
+		<?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ) ?>
+		<ul id="noemail-tips">
+			<li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) ?></strong></p></li>
+			<li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) ?></p></li>
+			<li><?php printf( __( 'Have you entered your email correctly?  You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_email ) ?></li>
+		</ul>
+	</p>
+	<?php
+	do_action( 'signup_finished' );
+}
+
+// Main
+$active_signup = get_site_option( 'registration' );
+if ( !$active_signup )
+	$active_signup = 'all';
+
+$active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
+
+// Make the signup type translatable.
+$i18n_signup['all'] = _x('all', 'Multisite active signup type');
+$i18n_signup['none'] = _x('none', 'Multisite active signup type');
+$i18n_signup['blog'] = _x('blog', 'Multisite active signup type');
+$i18n_signup['user'] = _x('user', 'Multisite active signup type');
+
+if ( is_super_admin() )
+	echo '<div class="mu_alert">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing &#8220;%s&#8221; registrations. To change or disable registration go to your <a href="%s">Options page</a>.' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'settings.php' ) ) ) . '</div>';
+
+$newblogname = isset($_GET['new']) ? strtolower(preg_replace('/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'])) : null;
+
+$current_user = wp_get_current_user();
+if ( $active_signup == "none" ) {
+	_e( 'Registration has been disabled.' );
+} elseif ( $active_signup == 'blog' && !is_user_logged_in() ) {
+	if ( is_ssl() )
+		$proto = 'https://';
+	else
+		$proto = 'http://';
+	$login_url = site_url( 'wp-login.php?redirect_to=' . urlencode($proto . $_SERVER['HTTP_HOST'] . '/wp-signup.php' ));
+	echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url );
+} else {
+	$stage = isset( $_POST['stage'] ) ?  $_POST['stage'] : 'default';
+	switch ( $stage ) {
+		case 'validate-user-signup' :
+			if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' )
+				validate_user_signup();
+			else
+				_e( 'User registration has been disabled.' );
+		break;
+		case 'validate-blog-signup':
+			if ( $active_signup == 'all' || $active_signup == 'blog' )
+				validate_blog_signup();
+			else
+				_e( 'Site registration has been disabled.' );
+			break;
+		case 'gimmeanotherblog':
+			validate_another_blog_signup();
+			break;
+		case 'default':
+		default :
+			$user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
+			do_action( "preprocess_signup_form" ); // populate the form from invites, elsewhere?
+			if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
+				signup_another_blog($newblogname);
+			elseif ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) )
+				signup_user( $newblogname, $user_email );
+			elseif ( is_user_logged_in() == false && ( $active_signup == 'blog' ) )
+				_e( 'Sorry, new registrations are not allowed at this time.' );
+			else
+				_e( 'You are logged in already. No need to register again!' );
+
+			if ( $newblogname ) {
+				$newblog = get_blogaddress_by_name( $newblogname );
+
+				if ( $active_signup == 'blog' || $active_signup == 'all' )
+					printf( __( '<p><em>The site you were looking for, <strong>%s</strong> does not exist, but you can create it now!</em></p>' ), $newblog );
+				else
+					printf( __( '<p><em>The site you were looking for, <strong>%s</strong>, does not exist.</em></p>' ), $newblog );
+			}
+			break;
+	}
+}
+?>
+</div>
+</div>
+<?php do_action( 'after_signup_form' ); ?>
+
+<?php get_footer(); ?>
Index: /tags/3.1/wp-trackback.php
===================================================================
--- /tags/3.1/wp-trackback.php	(revision 17487)
+++ /tags/3.1/wp-trackback.php	(revision 17487)
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Handle Trackbacks and Pingbacks sent to WordPress
+ *
+ * @package WordPress
+ */
+
+if (empty($wp)) {
+	require_once('./wp-load.php');
+	wp( array( 'tb' => '1' ) );
+}
+
+/**
+ * trackback_response() - Respond with error or success XML message
+ *
+ * @param int|bool $error Whether there was an error
+ * @param string $error_message Error message if an error occurred
+ */
+function trackback_response($error = 0, $error_message = '') {
+	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
+	if ($error) {
+		echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
+		echo "<response>\n";
+		echo "<error>1</error>\n";
+		echo "<message>$error_message</message>\n";
+		echo "</response>";
+		die();
+	} else {
+		echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
+		echo "<response>\n";
+		echo "<error>0</error>\n";
+		echo "</response>";
+	}
+}
+
+// trackback is done by a POST
+$request_array = 'HTTP_POST_VARS';
+
+if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
+	$tb_id = explode('/', $_SERVER['REQUEST_URI']);
+	$tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
+}
+
+$tb_url  = isset($_POST['url'])     ? $_POST['url']     : '';
+$charset = isset($_POST['charset']) ? $_POST['charset'] : '';
+
+// These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
+$title     = isset($_POST['title'])     ? stripslashes($_POST['title'])      : '';
+$excerpt   = isset($_POST['excerpt'])   ? stripslashes($_POST['excerpt'])    : '';
+$blog_name = isset($_POST['blog_name']) ? stripslashes($_POST['blog_name'])  : '';
+
+if ($charset)
+	$charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
+else
+	$charset = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
+
+// No valid uses for UTF-7
+if ( false !== strpos($charset, 'UTF-7') )
+	die;
+
+if ( function_exists('mb_convert_encoding') ) { // For international trackbacks
+	$title     = mb_convert_encoding($title, get_option('blog_charset'), $charset);
+	$excerpt   = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset);
+	$blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset);
+}
+
+// Now that mb_convert_encoding() has been given a swing, we need to escape these three
+$title     = $wpdb->escape($title);
+$excerpt   = $wpdb->escape($excerpt);
+$blog_name = $wpdb->escape($blog_name);
+
+if ( is_single() || is_page() )
+	$tb_id = $posts[0]->ID;
+
+if ( !isset($tb_id) || !intval( $tb_id ) )
+	trackback_response(1, 'I really need an ID for this to work.');
+
+if (empty($title) && empty($tb_url) && empty($blog_name)) {
+	// If it doesn't look like a trackback at all...
+	wp_redirect(get_permalink($tb_id));
+	exit;
+}
+
+if ( !empty($tb_url) && !empty($title) ) {
+	header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
+
+	if ( !pings_open($tb_id) )
+		trackback_response(1, 'Sorry, trackbacks are closed for this item.');
+
+	$title =  wp_html_excerpt( $title, 250 ).'...';
+	$excerpt = wp_html_excerpt( $excerpt, 252 ).'...';
+
+	$comment_post_ID = (int) $tb_id;
+	$comment_author = $blog_name;
+	$comment_author_email = '';
+	$comment_author_url = $tb_url;
+	$comment_content = "<strong>$title</strong>\n\n$excerpt";
+	$comment_type = 'trackback';
+
+	$dupe = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url) );
+	if ( $dupe )
+		trackback_response(1, 'We already have a ping from that URL for this post.');
+
+	$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
+
+	wp_new_comment($commentdata);
+
+	do_action('trackback_post', $wpdb->insert_id);
+	trackback_response(0);
+}
+?>
Index: /tags/3.1/xmlrpc.php
===================================================================
--- /tags/3.1/xmlrpc.php	(revision 17487)
+++ /tags/3.1/xmlrpc.php	(revision 17487)
@@ -0,0 +1,107 @@
+<?php
+/**
+ * XML-RPC protocol support for WordPress
+ *
+ * @package WordPress
+ */
+
+/**
+ * Whether this is a XMLRPC Request
+ *
+ * @var bool
+ */
+define('XMLRPC_REQUEST', true);
+
+// Some browser-embedded clients send cookies. We don't want them.
+$_COOKIE = array();
+
+// A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
+// but we can do it ourself.
+if ( !isset( $HTTP_RAW_POST_DATA ) ) {
+	$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
+}
+
+// fix for mozBlog and other cases where '<?xml' isn't on the very first line
+if ( isset($HTTP_RAW_POST_DATA) )
+	$HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
+
+/** Include the bootstrap for setting up WordPress environment */
+include('./wp-load.php');
+
+if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
+header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
+?>
+<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
+<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
+  <service>
+    <engineName>WordPress</engineName>
+    <engineLink>http://wordpress.org/</engineLink>
+    <homePageLink><?php bloginfo_rss('url') ?></homePageLink>
+    <apis>
+      <api name="WordPress" blogID="1" preferred="true" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
+      <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
+      <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
+      <api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
+      <api name="Atom" blogID="" preferred="false" apiLink="<?php echo apply_filters('atom_service_url', site_url('wp-app.php/service', 'rpc') ) ?>" />
+    </apis>
+  </service>
+</rsd>
+<?php
+exit;
+}
+
+include_once(ABSPATH . 'wp-admin/includes/admin.php');
+include_once(ABSPATH . WPINC . '/class-IXR.php');
+include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php');
+
+// Turn off all warnings and errors.
+// error_reporting(0);
+
+/**
+ * Posts submitted via the xmlrpc interface get that title
+ * @name post_default_title
+ * @var string
+ */
+$post_default_title = "";
+
+/**
+ * Whether to enable XMLRPC Logging.
+ *
+ * @name xmlrpc_logging
+ * @var int|bool
+ */
+$xmlrpc_logging = 0;
+
+/**
+ * logIO() - Writes logging info to a file.
+ *
+ * @uses $xmlrpc_logging
+ * @package WordPress
+ * @subpackage Logging
+ *
+ * @param string $io Whether input or output
+ * @param string $msg Information describing logging reason.
+ * @return bool Always return true
+ */
+function logIO($io,$msg) {
+	global $xmlrpc_logging;
+	if ($xmlrpc_logging) {
+		$fp = fopen("../xmlrpc.log","a+");
+		$date = gmdate("Y-m-d H:i:s ");
+		$iot = ($io == "I") ? " Input: " : " Output: ";
+		fwrite($fp, "\n\n".$date.$iot.$msg);
+		fclose($fp);
+	}
+	return true;
+}
+
+if ( isset($HTTP_RAW_POST_DATA) )
+	logIO("I", $HTTP_RAW_POST_DATA);
+
+// Allow for a plugin to insert a different class to handle requests.
+$wp_xmlrpc_server_class = apply_filters('wp_xmlrpc_server_class', 'wp_xmlrpc_server');
+$wp_xmlrpc_server = new $wp_xmlrpc_server_class;
+
+// Fire off the request
+$wp_xmlrpc_server->serve_request();
+?>
